Actual source code: slepcinit.c

  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2010, 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 slepcsys.h
 23:  #include private/epsimpl.h
 24:  #include private/stimpl.h
 25:  #include private/svdimpl.h
 26:  #include private/qepimpl.h
 27:  #include private/ipimpl.h
 28: #include <stdlib.h>

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

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

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

 59:   PetscFunctionReturn(info);
 60: }

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

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

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

 82:   PetscFunctionReturn(info);
 83: }

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

 94: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
 96: #endif

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

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

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

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

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


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

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

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

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

149: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
150:   PetscStrcpy(libs,SLEPC_LIB_DIR);
151:   PetscStrcat(libs,"/libslepc");
152:   PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);
153:   if (found) {
154:     PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);
155:   } else {
156:     SETERRQ1(1,"Unable to locate SLEPc dynamic library %s \n",libs);
157:   }
158: #else
159:   STInitializePackage(PETSC_NULL);
160:   EPSInitializePackage(PETSC_NULL);
161:   SVDInitializePackage(PETSC_NULL);
162:   QEPInitializePackage(PETSC_NULL);
163:   IPInitializePackage(PETSC_NULL);
164: #endif

166:   PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);
167:   PetscLogEventRegister("VecMAXPBY",0,&SLEPC_VecMAXPBY);

169: #if defined(PETSC_HAVE_DRAND48)
170:   /* work-around for Cygwin drand48() initialization bug */
171:   srand48(0);
172: #endif

174:   SlepcInitializeCalled = PETSC_TRUE;
175:   PetscInfo(0,"SLEPc successfully started\n");
176:   PetscFunctionReturn(info);
177: }

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

185:    Collective on PETSC_COMM_WORLD

187:    Level: beginner

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

198:   if (SlepcBeganPetsc) {
199:     info = PetscFinalize();CHKERRQ(info);
200:   }

202:   SlepcInitializeCalled = PETSC_FALSE;

204:   PetscFunctionReturn(info);
205: }

207: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
211: /*
212:   PetscDLLibraryRegister - This function is called when the dynamic library 
213:   it is in is opened.

215:   This one registers all the EPS and ST methods in the libslepc.a
216:   library.

218:   Input Parameter:
219:   path - library path
220:  */
221: PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
222: {

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

228:   /*
229:       If we got here then PETSc was properly loaded
230:   */
231:   STInitializePackage(path);
232:   EPSInitializePackage(path);
233:   SVDInitializePackage(path);
234:   QEPInitializePackage(path);
235:   IPInitializePackage(path);
236:   return(0);
237: }

240: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */