Actual source code: slepcinit.c
2: #include slepc.h
3: #include slepceps.h
4: #include slepcst.h
8: /*
9: SlepcPrintVersion - Prints SLEPc version info.
11: Collective on MPI_Comm
12: */
13: PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
14: {
15: int info = 0;
16:
19: info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
20: ------------------------------\n"); CHKERRQ(info);
21: #if (PETSC_VERSION_RELEASE == 1)
22: info = (*PetscHelpPrintf)(comm,"SLEPc Release Version %d.%d.%d-%d, %s\n",
23: #else
24: info = (*PetscHelpPrintf)(comm,"SLEPc Development Version %d.%d.%d-%d, %s\n",
25: #endif
26: SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_PATCH,SLEPC_VERSION_PATCH_DATE); CHKERRQ(info);
27: info = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO); CHKERRQ(info);
28: info = (*PetscHelpPrintf)(comm,"See docs/manual.html for help. \n"); CHKERRQ(info);
29: #if !defined(PARCH_win32)
30: info = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR); CHKERRQ(info);
31: #endif
32: info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
33: ------------------------------\n"); CHKERRQ(info);
35: PetscFunctionReturn(info);
36: }
40: /*
41: SlepcPrintHelpIntro - Prints introductory SLEPc help info.
43: Collective on MPI_Comm
44: */
45: PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
46: {
47: int info = 0;
48:
51: info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
52: ------------------------------\n"); CHKERRQ(info);
53: info = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n"); CHKERRQ(info);
54: info = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n"); CHKERRQ(info);
55: info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
56: ------------------------------\n"); CHKERRQ(info);
58: PetscFunctionReturn(info);
59: }
61: /* ------------------------Nasty global variables -------------------------------*/
62: /*
63: Indicates whether SLEPc started PETSc, or whether it was
64: already started before SLEPc was initialized.
65: */
66: PetscTruth SlepcBeganPetsc = PETSC_FALSE;
67: PetscTruth SlepcInitializeCalled = PETSC_FALSE;
69: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
71: #endif
75: /*@C
76: SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
77: PetscInitialize() if that has not been called yet, so this routine should
78: always be called near the beginning of your program.
80: Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
82: Input Parameters:
83: + argc - count of number of command line arguments
84: . args - the command line arguments
85: . file - [optional] PETSc database file, defaults to ~username/.petscrc
86: (use PETSC_NULL for default)
87: - help - [optional] Help message to print, use PETSC_NULL for no message
89: Fortran Note:
90: Fortran syntax is very similar to that of PetscInitialize()
91:
92: Level: beginner
94: .seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
95: @*/
96: PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
97: {
99: PetscErrorCode info=0;
100: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
101: char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
102: PetscTruth found;
103: #endif
107: if (SlepcInitializeCalled==PETSC_TRUE) {
108: return(0);
109: }
111: #if !defined(PARCH_t3d)
112: info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
113: #endif
115: if (!PetscInitializeCalled) {
116: info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
117: SlepcBeganPetsc = PETSC_TRUE;
118: }
120: /*
121: Load the dynamic libraries
122: */
124: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
125: PetscStrcpy(libs,SLEPC_LIB_DIR);
126: PetscStrcat(libs,"/libslepc");
127: PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);
128: if (found) {
129: PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);
130: } else {
131: SETERRQ1(1,"Unable to locate SLEPc dynamic library %s \n You cannot move the dynamic libraries!\n or remove USE_DYNAMIC_LIBRARIES from ${PETSC_DIR}/bmake/$PETSC_ARCH/petscconf.h\n and rebuild libraries before moving",libs);
132: }
133: #else
134: STInitializePackage(PETSC_NULL);
135: EPSInitializePackage(PETSC_NULL);
136: #endif
138: SlepcInitializeCalled = PETSC_TRUE;
139: PetscInfo(0,"SLEPc successfully started\n");
140: PetscFunctionReturn(info);
141: }
145: /*@
146: SlepcFinalize - Checks for options to be called at the conclusion
147: of the SLEPc program and calls PetscFinalize().
149: Collective on PETSC_COMM_WORLD
151: Level: beginner
153: .seealso: SlepcInitialize(), PetscFinalize()
154: @*/
155: PetscErrorCode SlepcFinalize(void)
156: {
157: PetscErrorCode info=0;
158:
160: PetscInfo(0,"SLEPc successfully ended!\n");
162: if (SlepcBeganPetsc) {
163: info = PetscFinalize();CHKERRQ(info);
164: }
166: SlepcInitializeCalled = PETSC_FALSE;
168: PetscFunctionReturn(info);
169: }
171: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
175: /*
176: PetscDLLibraryRegister - This function is called when the dynamic library
177: it is in is opened.
179: This one registers all the EPS and ST methods in the libslepc.a
180: library.
182: Input Parameter:
183: path - library path
184: */
185: PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
186: {
189: PetscInitializeNoArguments(); if (ierr) return 1;
192: /*
193: If we got here then PETSc was properly loaded
194: */
195: STInitializePackage(path);
196: EPSInitializePackage(path);
197: return(0);
198: }
201: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */