Actual source code: slepcinit.c

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

  6:    This file is part of SLEPc.
  7:       
  8:    SLEPc is free software: you can redistribute it and/or modify it under  the
  9:    terms of version 3 of the GNU Lesser General Public License as published by
 10:    the Free Software Foundation.

 12:    SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 13:    WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 14:    FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 15:    more details.

 17:    You  should have received a copy of the GNU Lesser General  Public  License
 18:    along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 19:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 20: */

 22:  #include slepc.h
 23:  #include slepceps.h
 24:  #include slepcst.h
 25:  #include slepcsvd.h
 26:  #include slepcip.h
 27: #include <stdlib.h>

 31: /*
 32:    SlepcPrintVersion - Prints SLEPc version info.

 34:    Collective on MPI_Comm
 35: */
 36: PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
 37: {
 38:   PetscErrorCode  info = 0;
 39: 

 42:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 43: ------------------------------\n"); CHKERRQ(info);
 44: #if (PETSC_VERSION_RELEASE == 1)
 45:   info = (*PetscHelpPrintf)(comm,"SLEPc Release Version %d.%d.%d-%d, %s\n",
 46: #else
 47:   info = (*PetscHelpPrintf)(comm,"SLEPc Development Version %d.%d.%d-%d, %s\n",
 48: #endif
 49:     SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_PATCH,SLEPC_VERSION_PATCH_DATE); CHKERRQ(info);
 50:   info = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO); CHKERRQ(info);
 51:   info = (*PetscHelpPrintf)(comm,"See docs/manual.html for help. \n"); CHKERRQ(info);
 52: #if !defined(PARCH_win32)
 53:   info = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR); CHKERRQ(info);
 54: #endif
 55:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 56: ------------------------------\n"); CHKERRQ(info);

 58:   PetscFunctionReturn(info);
 59: }

 63: /*
 64:    SlepcPrintHelpIntro - Prints introductory SLEPc help info.

 66:    Collective on MPI_Comm
 67: */
 68: PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
 69: {
 70:   PetscErrorCode  info = 0;
 71: 

 74:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 75: ------------------------------\n"); CHKERRQ(info);
 76:   info = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n"); CHKERRQ(info);
 77:   info = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n"); CHKERRQ(info);
 78:   info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
 79: ------------------------------\n"); CHKERRQ(info);

 81:   PetscFunctionReturn(info);
 82: }

 84: /* ------------------------Nasty global variables -------------------------------*/
 85: /*
 86:    Indicates whether SLEPc started PETSc, or whether it was 
 87:    already started before SLEPc was initialized.
 88: */
 89: PetscTruth  SlepcBeganPetsc = PETSC_FALSE;
 90: PetscTruth  SlepcInitializeCalled = PETSC_FALSE;

 93: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
 95: #endif

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

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

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

113:    Fortran Note:
114:    Fortran syntax is very similar to that of PetscInitialize()
115:    
116:    Level: beginner

118: .seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
119: @*/
120: PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
121: {
123:   PetscErrorCode info=0;
124: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
125:   char           libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
126:   PetscTruth     found;
127: #endif


131:   if (SlepcInitializeCalled) {
132:     return(0);
133:   }

135: #if !defined(PARCH_t3d)
136:   info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
137: #endif

139:   if (!PetscInitializeCalled) {
140:     info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
141:     SlepcBeganPetsc = PETSC_TRUE;
142:   }

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",libs);
156:   }
157: #else
158:   STInitializePackage(PETSC_NULL);
159:   EPSInitializePackage(PETSC_NULL);
160:   SVDInitializePackage(PETSC_NULL);
161:   IPInitializePackage(PETSC_NULL);
162: #endif

164:   PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);

166: #if defined(PETSC_HAVE_DRAND48)
167:   /* work-around for Cygwin drand48() initialization bug */
168:   srand48(0);
169: #endif

171:   SlepcInitializeCalled = PETSC_TRUE;
172:   PetscInfo(0,"SLEPc successfully started\n");
173:   PetscFunctionReturn(info);
174: }

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

182:    Collective on PETSC_COMM_WORLD

184:    Level: beginner

186: .seealso: SlepcInitialize(), PetscFinalize()
187: @*/
188: PetscErrorCode SlepcFinalize(void)
189: {
190:   PetscErrorCode info=0;
191: 
193:   PetscInfo(0,"SLEPc successfully ended!\n");

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

199:   SlepcInitializeCalled = PETSC_FALSE;

201:   PetscFunctionReturn(info);
202: }

204: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
208: /*
209:   PetscDLLibraryRegister - This function is called when the dynamic library 
210:   it is in is opened.

212:   This one registers all the EPS and ST methods in the libslepc.a
213:   library.

215:   Input Parameter:
216:   path - library path
217:  */
218: PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
219: {

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

225:   /*
226:       If we got here then PETSc was properly loaded
227:   */
228:   STInitializePackage(path);
229:   EPSInitializePackage(path);
230:   SVDInitializePackage(path);
231:   IPInitializePackage(path);
232:   return(0);
233: }

236: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */