Actual source code: slepcinit.c

  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:       SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:       Copyright (c) 2002-2007, Universidad Politecnica de Valencia, Spain

  6:       This file is part of SLEPc. See the README file for conditions of use
  7:       and additional information.
  8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9: */

 11:  #include slepc.h
 12:  #include slepceps.h
 13:  #include slepcst.h
 14:  #include slepcsvd.h
 15:  #include slepcip.h
 16: #include <stdlib.h>

 20: /*
 21:    SlepcPrintVersion - Prints SLEPc version info.

 23:    Collective on MPI_Comm
 24: */
 25: PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
 26: {
 27:   int  info = 0;
 28: 

 31:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 32: ------------------------------\n"); CHKERRQ(info);
 33: #if (PETSC_VERSION_RELEASE == 1)
 34:   info = (*PetscHelpPrintf)(comm,"SLEPc Release Version %d.%d.%d-%d, %s\n",
 35: #else
 36:   info = (*PetscHelpPrintf)(comm,"SLEPc Development Version %d.%d.%d-%d, %s\n",
 37: #endif
 38:     SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_PATCH,SLEPC_VERSION_PATCH_DATE); CHKERRQ(info);
 39:   info = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO); CHKERRQ(info);
 40:   info = (*PetscHelpPrintf)(comm,"See docs/manual.html for help. \n"); CHKERRQ(info);
 41: #if !defined(PARCH_win32)
 42:   info = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR); CHKERRQ(info);
 43: #endif
 44:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 45: ------------------------------\n"); CHKERRQ(info);

 47:   PetscFunctionReturn(info);
 48: }

 52: /*
 53:    SlepcPrintHelpIntro - Prints introductory SLEPc help info.

 55:    Collective on MPI_Comm
 56: */
 57: PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
 58: {
 59:   int  info = 0;
 60: 

 63:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 64: ------------------------------\n"); CHKERRQ(info);
 65:   info = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n"); CHKERRQ(info);
 66:   info = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n"); CHKERRQ(info);
 67:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 68: ------------------------------\n"); CHKERRQ(info);

 70:   PetscFunctionReturn(info);
 71: }

 73: /* ------------------------Nasty global variables -------------------------------*/
 74: /*
 75:    Indicates whether SLEPc started PETSc, or whether it was 
 76:    already started before SLEPc was initialized.
 77: */
 78: PetscTruth  SlepcBeganPetsc = PETSC_FALSE;
 79: PetscTruth  SlepcInitializeCalled = PETSC_FALSE;

 81: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
 83: #endif

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

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

 94:    Input Parameters:
 95: +  argc - count of number of command line arguments
 96: .  args - the command line arguments
 97: .  file - [optional] PETSc database file, defaults to ~username/.petscrc
 98:           (use PETSC_NULL for default)
 99: -  help - [optional] Help message to print, use PETSC_NULL for no message

101:    Fortran Note:
102:    Fortran syntax is very similar to that of PetscInitialize()
103:    
104:    Level: beginner

106: .seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
107: @*/
108: PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
109: {
111:   PetscErrorCode info=0;
112: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
113:   char           libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
114:   PetscTruth     found;
115: #endif


119:   if (SlepcInitializeCalled==PETSC_TRUE) {
120:     return(0);
121:   }

123: #if !defined(PARCH_t3d)
124:   info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
125: #endif

127:   if (!PetscInitializeCalled) {
128:     info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
129:     SlepcBeganPetsc = PETSC_TRUE;
130:   }

132:   /*
133:       Load the dynamic libraries
134:   */

136: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
137:   PetscStrcpy(libs,SLEPC_LIB_DIR);
138:   PetscStrcat(libs,"/libslepc");
139:   PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);
140:   if (found) {
141:     PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);
142:   } else {
143:     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);
144:   }
145: #else
146:   STInitializePackage(PETSC_NULL);
147:   EPSInitializePackage(PETSC_NULL);
148:   SVDInitializePackage(PETSC_NULL);
149:   IPInitializePackage(PETSC_NULL);
150: #endif

152: #if defined(PETSC_HAVE_DRAND48)
153:   /* work-around for Cygwin drand48() initialization bug */
154:   srand48(0);
155: #endif

157:   SlepcInitializeCalled = PETSC_TRUE;
158:   PetscInfo(0,"SLEPc successfully started\n");
159:   PetscFunctionReturn(info);
160: }

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

168:    Collective on PETSC_COMM_WORLD

170:    Level: beginner

172: .seealso: SlepcInitialize(), PetscFinalize()
173: @*/
174: PetscErrorCode SlepcFinalize(void)
175: {
176:   PetscErrorCode info=0;
177: 
179:   PetscInfo(0,"SLEPc successfully ended!\n");

181:   if (SlepcBeganPetsc) {
182:     info = PetscFinalize();CHKERRQ(info);
183:   }

185:   SlepcInitializeCalled = PETSC_FALSE;

187:   PetscFunctionReturn(info);
188: }

190: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
194: /*
195:   PetscDLLibraryRegister - This function is called when the dynamic library 
196:   it is in is opened.

198:   This one registers all the EPS and ST methods in the libslepc.a
199:   library.

201:   Input Parameter:
202:   path - library path
203:  */
204: PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
205: {

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

211:   /*
212:       If we got here then PETSc was properly loaded
213:   */
214:   STInitializePackage(path);
215:   EPSInitializePackage(path);
216:   SVDInitializePackage(path);
217:   IPInitializePackage(path);
218:   return(0);
219: }

222: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */