Actual source code: slepcinit.c

 2:  #include slepc.h

  6: /*
  7:    SlepcPrintVersion - Prints SLEPc version info.

  9:    Collective on MPI_Comm
 10: */
 11: int SlepcPrintVersion(MPI_Comm comm)
 12: {
 13:   int  info = 0;
 14: 

 17:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 18: ------------------------------\n"); CHKERRQ(info);
 19:   info = (*PetscHelpPrintf)(comm,"\t   %s\n",SLEPC_VERSION_NUMBER); CHKERRQ(info);
 20:   info = (*PetscHelpPrintf)(comm,"%s",SLEPC_AUTHOR_INFO); CHKERRQ(info);
 21:   info = (*PetscHelpPrintf)(comm,"See docs/index.html for help. \n"); CHKERRQ(info);
 22: #if !defined(PARCH_win32)
 23:   info = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR); CHKERRQ(info);
 24: #endif
 25:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 26: ------------------------------\n"); CHKERRQ(info);

 28:   PetscFunctionReturn(info);
 29: }

 33: /*
 34:    SlepcPrintHelpIntro - Prints introductory SLEPc help info.

 36:    Collective on MPI_Comm
 37: */
 38: int SlepcPrintHelpIntro(MPI_Comm comm)
 39: {
 40:   int  info = 0;
 41: 

 44:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 45: ------------------------------\n"); CHKERRQ(info);
 46:   info = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n"); CHKERRQ(info);
 47:   info = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n"); CHKERRQ(info);
 48:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 49: ------------------------------\n"); CHKERRQ(info);

 51:   PetscFunctionReturn(info);
 52: }

 56: int EPS_SetUp, EPS_Solve, ST_SetUp, ST_Apply, ST_ApplyB, ST_ApplyNoB, EPS_Orthogonalization;

 58: /*
 59:    SlepcRegisterEvents - Registers SLEPc events for use in performance logging.
 60: */
 61: int SlepcRegisterEvents()
 62: {
 63:   int  info = 0;
 64: 

 67:   info = PetscLogEventRegister(&EPS_SetUp,"EPSSetUp",PETSC_NULL); CHKERRQ(info);
 68:   info = PetscLogEventRegister(&EPS_Solve,"EPSSolve",PETSC_NULL); CHKERRQ(info);
 69:   info = PetscLogEventRegister(&ST_SetUp,"STSetUp",PETSC_NULL); CHKERRQ(info);
 70:   info = PetscLogEventRegister(&ST_Apply,"STApply",PETSC_NULL); CHKERRQ(info);
 71:   info = PetscLogEventRegister(&ST_ApplyB,"STApplyB",PETSC_NULL); CHKERRQ(info);
 72:   info = PetscLogEventRegister(&ST_ApplyNoB,"STApplyNoB",PETSC_NULL); CHKERRQ(info);
 73:   info = PetscLogEventRegister(&EPS_Orthogonalization,"EPSOrthogonalization",PETSC_NULL); CHKERRQ(info);

 75:   PetscFunctionReturn(info);
 76: }

 78: /* ------------------------Nasty global variables -------------------------------*/
 79: /*
 80:    Indicates whether SLEPc started PETSc, or whether it was 
 81:    already started before SLEPc was initialized.
 82: */
 83: PetscTruth  SlepcBeganPetsc = PETSC_FALSE;
 84: PetscTruth  SlepcInitializeCalled = PETSC_FALSE;
 85: PetscRandom rctx = PETSC_NULL;
 86: int         EPS_COOKIE = 0;
 87: int         ST_COOKIE = 0;

 89: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
 90: extern PetscDLLibraryList DLLibrariesLoaded;
 91: #endif

 95: /*@C 
 96:    SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
 97:    PetscInitialize() if that has not been called yet, so this routine should
 98:    always be called near the beginning of your program.

100:    Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set

102:    Input Parameters:
103: +  argc - count of number of command line arguments
104: .  args - the command line arguments
105: .  file - [optional] PETSc database file, defaults to ~username/.petscrc
106:           (use PETSC_NULL for default)
107: -  help - [optional] Help message to print, use PETSC_NULL for no message

109:    Fortran Note:
110:    Fortran syntax is very similar to that of PetscInitialize()
111:    
112:    Level: beginner

114: .seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
115: @*/
116: int SlepcInitialize(int *argc,char ***args,char file[],const char help[])
117: {
118:   int        ierr,info=0;
119:   char       libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
120:   PetscTruth found;


124:   if (SlepcInitializeCalled==PETSC_TRUE) {
125:     return(0);
126:   }

128: #if !defined(PARCH_t3d)
129:   info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
130: #endif

132:   if (!PetscInitializeCalled) {
133:     info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
134:     SlepcBeganPetsc = PETSC_TRUE;
135:   }

137:   PetscRandomCreate(PETSC_COMM_WORLD,RANDOM_DEFAULT,&rctx);

139:   EPS_COOKIE = 0;
140:   PetscLogClassRegister(&EPS_COOKIE,"Eigenproblem Solver");
141:   ST_COOKIE = 0;
142:   PetscLogClassRegister(&ST_COOKIE,"Spectral Transform");

144:   /*
145:       Load the dynamic libraries
146:   */

148: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
149:   PetscStrcpy(libs,SLEPC_LIB_DIR);
150:   PetscStrcat(libs,"/libslepc");
151:   PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);
152:   if (found) {
153:     PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);
154:   } else {
155:     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);
156:   }
157: #else

159:   EPSRegisterAll(PETSC_NULL);
160:   STRegisterAll(PETSC_NULL);

162: #endif

164:   /*
165:       Register SLEPc events
166:   */
167:   info = SlepcRegisterEvents();CHKERRQ(info);
168:   SlepcInitializeCalled = PETSC_TRUE;
169:   PetscLogInfo(0,"SlepcInitialize: SLEPc successfully started\n");
170:   PetscFunctionReturn(info);
171: }

175: /*@
176:    SlepcFinalize - Checks for options to be called at the conclusion
177:    of the SLEPc program and calls PetscFinalize().

179:    Collective on PETSC_COMM_WORLD

181:    Level: beginner

183: .seealso: SlepcInitialize(), PetscFinalize()
184: @*/
185: int SlepcFinalize(void)
186: {
187:   int ierr,info=0;
188: 
190:   PetscLogInfo(0,"SlepcFinalize: SLEPc successfully ended!\n");

192:   PetscRandomDestroy(rctx);

194:   if (SlepcBeganPetsc) {
195:     info = PetscFinalize();CHKERRQ(info);
196:   }

198:   SlepcInitializeCalled = PETSC_FALSE;

200:   PetscFunctionReturn(info);
201: }