Actual source code: slepcinit.c

 2:  #include slepc.h
 3:  #include slepceps.h
 4:  #include slepcst.h
  5: #include <stdlib.h>

  9: /*
 10:    SlepcPrintVersion - Prints SLEPc version info.

 12:    Collective on MPI_Comm
 13: */
 14: PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
 15: {
 16:   int  info = 0;
 17: 

 20:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 21: ------------------------------\n"); CHKERRQ(info);
 22: #if (PETSC_VERSION_RELEASE == 1)
 23:   info = (*PetscHelpPrintf)(comm,"SLEPc Release Version %d.%d.%d-%d, %s\n",
 24: #else
 25:   info = (*PetscHelpPrintf)(comm,"SLEPc Development Version %d.%d.%d-%d, %s\n",
 26: #endif
 27:     SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_PATCH,SLEPC_VERSION_PATCH_DATE); CHKERRQ(info);
 28:   info = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO); CHKERRQ(info);
 29:   info = (*PetscHelpPrintf)(comm,"See docs/manual.html for help. \n"); CHKERRQ(info);
 30: #if !defined(PARCH_win32)
 31:   info = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR); CHKERRQ(info);
 32: #endif
 33:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 34: ------------------------------\n"); CHKERRQ(info);

 36:   PetscFunctionReturn(info);
 37: }

 41: /*
 42:    SlepcPrintHelpIntro - Prints introductory SLEPc help info.

 44:    Collective on MPI_Comm
 45: */
 46: PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
 47: {
 48:   int  info = 0;
 49: 

 52:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 53: ------------------------------\n"); CHKERRQ(info);
 54:   info = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n"); CHKERRQ(info);
 55:   info = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n"); CHKERRQ(info);
 56:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 57: ------------------------------\n"); CHKERRQ(info);

 59:   PetscFunctionReturn(info);
 60: }

 62: /* ------------------------Nasty global variables -------------------------------*/
 63: /*
 64:    Indicates whether SLEPc started PETSc, or whether it was 
 65:    already started before SLEPc was initialized.
 66: */
 67: PetscTruth  SlepcBeganPetsc = PETSC_FALSE;
 68: PetscTruth  SlepcInitializeCalled = PETSC_FALSE;

 70: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
 72: #endif

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

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

 83:    Input Parameters:
 84: +  argc - count of number of command line arguments
 85: .  args - the command line arguments
 86: .  file - [optional] PETSc database file, defaults to ~username/.petscrc
 87:           (use PETSC_NULL for default)
 88: -  help - [optional] Help message to print, use PETSC_NULL for no message

 90:    Fortran Note:
 91:    Fortran syntax is very similar to that of PetscInitialize()
 92:    
 93:    Level: beginner

 95: .seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
 96: @*/
 97: PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
 98: {
100:   PetscErrorCode info=0;
101: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
102:   char           libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
103:   PetscTruth     found;
104: #endif


108:   if (SlepcInitializeCalled==PETSC_TRUE) {
109:     return(0);
110:   }

112: #if !defined(PARCH_t3d)
113:   info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
114: #endif

116:   if (!PetscInitializeCalled) {
117:     info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
118:     SlepcBeganPetsc = PETSC_TRUE;
119:   }

121:   /*
122:       Load the dynamic libraries
123:   */

125: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
126:   PetscStrcpy(libs,SLEPC_LIB_DIR);
127:   PetscStrcat(libs,"/libslepc");
128:   PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);
129:   if (found) {
130:     PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);
131:   } else {
132:     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);
133:   }
134: #else
135:   STInitializePackage(PETSC_NULL);
136:   EPSInitializePackage(PETSC_NULL);
137: #endif

139: #if defined(PETSC_HAVE_DRAND48)
140:   /* work-around for Cygwin drand48() initialization bug */
141:   srand48(0);
142: #endif

144:   SlepcInitializeCalled = PETSC_TRUE;
145:   PetscInfo(0,"SLEPc successfully started\n");
146:   PetscFunctionReturn(info);
147: }

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

155:    Collective on PETSC_COMM_WORLD

157:    Level: beginner

159: .seealso: SlepcInitialize(), PetscFinalize()
160: @*/
161: PetscErrorCode SlepcFinalize(void)
162: {
163:   PetscErrorCode info=0;
164: 
166:   PetscInfo(0,"SLEPc successfully ended!\n");

168:   if (SlepcBeganPetsc) {
169:     info = PetscFinalize();CHKERRQ(info);
170:   }

172:   SlepcInitializeCalled = PETSC_FALSE;

174:   PetscFunctionReturn(info);
175: }

177: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
181: /*
182:   PetscDLLibraryRegister - This function is called when the dynamic library 
183:   it is in is opened.

185:   This one registers all the EPS and ST methods in the libslepc.a
186:   library.

188:   Input Parameter:
189:   path - library path
190:  */
191: PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
192: {

195:   PetscInitializeNoArguments(); if (ierr) return 1;

198:   /*
199:       If we got here then PETSc was properly loaded
200:   */
201:   STInitializePackage(path);
202:   EPSInitializePackage(path);
203:   return(0);
204: }

207: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */