Actual source code: slepcinit.c
1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) 2002-2013, Universitat Politecnica de Valencia, Spain
6: This file is part of SLEPc.
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-private/slepcimpl.h> /*I "slepcsys.h" I*/
23: #include <slepc-private/epsimpl.h>
24: #include <slepc-private/stimpl.h>
25: #include <slepc-private/svdimpl.h>
26: #include <slepc-private/qepimpl.h>
27: #include <slepc-private/nepimpl.h>
28: #include <slepc-private/mfnimpl.h>
29: #include <slepc-private/ipimpl.h>
30: #include <slepc-private/dsimpl.h>
31: #include <slepc-private/fnimpl.h>
32: #include <slepc-private/vecimplslepc.h>
33: #include <stdlib.h>
37: /*@C
38: SlepcGetVersion - Gets the SLEPc version information in a string.
40: Input Parameter:
41: . len - length of the string
43: Output Parameter:
44: . version - version string
46: Fortran Note:
47: This routine is not supported in Fortran.
49: Level: developer
50: @*/
51: PetscErrorCode SlepcGetVersion(char version[],size_t len)
52: {
56: #if (SLEPC_VERSION_RELEASE == 1)
57: PetscSNPrintf(version,len,"SLEPc Release Version %d.%d.%d, %s",SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_DATE);
58: #else
59: PetscSNPrintf(version,len,"SLEPc Development GIT revision: %d GIT Date: %s",SLEPC_VERSION_GIT,SLEPC_VERSION_DATE_GIT);
60: #endif
61: return(0);
62: }
66: /*
67: SlepcPrintVersion - Prints SLEPc version info.
69: Collective on MPI_Comm
70: */
71: PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
72: {
74: char version[256];
77: SlepcGetVersion(version,256);
78: (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");
79: (*PetscHelpPrintf)(comm,"%s\n",version);
80: (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO);
81: (*PetscHelpPrintf)(comm,"See docs/manual.html for help.\n");
82: (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR);
83: return(0);
84: }
88: /*
89: SlepcPrintHelpIntro - Prints introductory SLEPc help info.
91: Collective on MPI_Comm
92: */
93: PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
94: {
95: PetscErrorCode ierr;
98: (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n");
99: (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n");
100: (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");
101: return(0);
102: }
104: /* ------------------------Nasty global variables -------------------------------*/
105: /*
106: Indicates whether SLEPc started PETSc, or whether it was
107: already started before SLEPc was initialized.
108: */
109: PetscBool SlepcBeganPetsc = PETSC_FALSE;
110: PetscBool SlepcInitializeCalled = PETSC_FALSE;
112: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
116: /*
117: SlepcInitialize_DynamicLibraries - Adds the default dynamic link libraries to the
118: search path.
119: */
120: PetscErrorCode SlepcInitialize_DynamicLibraries(void)
121: {
123: PetscBool found;
124: char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
127: PetscStrcpy(libs,SLEPC_LIB_DIR);
128: PetscStrcat(libs,"/libslepc");
129: PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);
130: if (found) {
131: PetscDLLibraryAppend(PETSC_COMM_WORLD,&PetscDLLibrariesLoaded,libs);
132: } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries");
133: return(0);
134: }
135: #endif
139: /*
140: SlepcInitialize_LogEvents - Initialize log events not pertaining to any object class.
141: */
142: PetscErrorCode SlepcInitialize_LogEvents(void)
143: {
147: PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);
148: PetscLogEventRegister("VecMAXPBY",0,&SLEPC_VecMAXPBY);
149: PetscLogEventRegister("DenseMatProd",EPS_CLASSID,&SLEPC_SlepcDenseMatProd);
150: PetscLogEventRegister("DenseMatNorm",EPS_CLASSID,&SLEPC_SlepcDenseNorm);
151: PetscLogEventRegister("DenseCopy",EPS_CLASSID,&SLEPC_SlepcDenseCopy);
152: PetscLogEventRegister("VecsMult",EPS_CLASSID,&SLEPC_VecsMult);
153: return(0);
154: }
158: /*@C
159: SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
160: PetscInitialize() if that has not been called yet, so this routine should
161: always be called near the beginning of your program.
163: Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
165: Input Parameters:
166: + argc - count of number of command line arguments
167: . args - the command line arguments
168: . file - [optional] PETSc database file, defaults to ~username/.petscrc
169: (use NULL for default)
170: - help - [optional] Help message to print, use NULL for no message
172: Fortran Note:
173: Fortran syntax is very similar to that of PetscInitialize()
175: Level: beginner
177: .seealso: SlepcFinalize(), PetscInitialize()
178: @*/
179: PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[])
180: {
182: PetscBool flg;
185: if (SlepcInitializeCalled) return(0);
186: PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);
187: PetscInitialized(&flg);
188: if (!flg) {
189: PetscInitialize(argc,args,file,help);
190: SlepcBeganPetsc = PETSC_TRUE;
191: }
193: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
194: SlepcInitialize_DynamicLibraries();
195: #endif
196: SlepcInitialize_LogEvents();
198: #if defined(PETSC_HAVE_DRAND48)
199: /* work-around for Cygwin drand48() initialization bug */
200: srand48(0);
201: #endif
203: SlepcInitializeCalled = PETSC_TRUE;
204: PetscInfo(0,"SLEPc successfully started\n");
205: return(0);
206: }
210: /*@
211: SlepcFinalize - Checks for options to be called at the conclusion
212: of the SLEPc program and calls PetscFinalize().
214: Collective on PETSC_COMM_WORLD
216: Level: beginner
218: .seealso: SlepcInitialize(), PetscFinalize()
219: @*/
220: PetscErrorCode SlepcFinalize(void)
221: {
225: PetscInfo(0,"SlepcFinalize() called\n");
226: if (SlepcBeganPetsc) {
227: PetscFinalize();
228: }
229: SlepcInitializeCalled = PETSC_FALSE;
230: return(0);
231: }
235: /*@C
236: SlepcInitializeNoArguments - Calls SlepcInitialize() from C/C++ without
237: the command line arguments.
239: Collective
241: Level: advanced
243: .seealso: SlepcInitialize(), SlepcInitializeFortran()
244: @*/
245: PetscErrorCode SlepcInitializeNoArguments(void)
246: {
248: int argc = 0;
249: char **args = 0;
252: SlepcInitialize(&argc,&args,NULL,NULL);
253: PetscFunctionReturn(ierr);
254: }
258: /*@
259: SlepcInitialized - Determine whether SLEPc is initialized.
261: Level: beginner
263: .seealso: SlepcInitialize(), SlepcInitializeFortran()
264: @*/
265: PetscErrorCode SlepcInitialized(PetscBool *isInitialized)
266: {
269: *isInitialized = SlepcInitializeCalled;
270: return(0);
271: }
273: PETSC_EXTERN PetscBool PetscBeganMPI;
277: /*
278: SlepcInitializeNoPointers - Calls SlepcInitialize() from C/C++ without the pointers
279: to argc and args (analogue to PetscInitializeNoPointers).
281: Collective
283: Level: advanced
285: .seealso: SlepcInitialize()
286: */
287: PetscErrorCode SlepcInitializeNoPointers(int argc,char **args,const char *filename,const char *help)
288: {
290: int myargc = argc;
291: char **myargs = args;
294: SlepcInitialize(&myargc,&myargs,filename,help);
295: PetscPopSignalHandler();
296: PetscBeganMPI = PETSC_FALSE;
297: PetscFunctionReturn(ierr);
298: }
300: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
304: /*
305: PetscDLLibraryRegister - This function is called when the dynamic library
306: it is in is opened.
308: This one registers all the EPS and ST methods in the libslepc.a
309: library.
311: Input Parameter:
312: path - library path
313: */
314: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
315: {
319: EPSInitializePackage();
320: SVDInitializePackage();
321: QEPInitializePackage();
322: NEPInitializePackage();
323: MFNInitializePackage();
324: STInitializePackage();
325: IPInitializePackage();
326: DSInitializePackage();
327: FNInitializePackage();
328: return(0);
329: }
330: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */