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;
93: SLEPC_SlepcDenseNorm, SLEPC_SlepcDenseCopy, SLEPC_VecsMult;
95: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
97: #endif
101: /*@C
102: SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
103: PetscInitialize() if that has not been called yet, so this routine should
104: always be called near the beginning of your program.
106: Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
108: Input Parameters:
109: + argc - count of number of command line arguments
110: . args - the command line arguments
111: . file - [optional] PETSc database file, defaults to ~username/.petscrc
112: (use PETSC_NULL for default)
113: - help - [optional] Help message to print, use PETSC_NULL for no message
115: Fortran Note:
116: Fortran syntax is very similar to that of PetscInitialize()
117:
118: Level: beginner
120: .seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
121: @*/
122: PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
123: {
125: PetscErrorCode info=0;
126: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
127: char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
128: PetscTruth found;
129: #endif
133: if (SlepcInitializeCalled) {
134: return(0);
135: }
137: #if !defined(PARCH_t3d)
138: info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
139: #endif
141: if (!PetscInitializeCalled) {
142: info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
143: SlepcBeganPetsc = PETSC_TRUE;
144: }
146: /*
147: Load the dynamic libraries
148: */
150: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
151: PetscStrcpy(libs,SLEPC_LIB_DIR);
152: PetscStrcat(libs,"/libslepc");
153: PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);
154: if (found) {
155: PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);
156: } else {
157: SETERRQ1(1,"Unable to locate SLEPc dynamic library %s \n",libs);
158: }
159: #else
160: STInitializePackage(PETSC_NULL);
161: EPSInitializePackage(PETSC_NULL);
162: SVDInitializePackage(PETSC_NULL);
163: QEPInitializePackage(PETSC_NULL);
164: IPInitializePackage(PETSC_NULL);
165: #endif
167: PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);
168: PetscLogEventRegister("VecMAXPBY",0,&SLEPC_VecMAXPBY);
169: PetscLogEventRegister("DenseMatProd", EPS_COOKIE, &SLEPC_SlepcDenseMatProd);
170: PetscLogEventRegister("DenseOrth", EPS_COOKIE, &SLEPC_SlepcDenseOrth);
171: PetscLogEventRegister("DenseMatNorm", EPS_COOKIE, &SLEPC_SlepcDenseNorm);
172: PetscLogEventRegister("DenseCopy", EPS_COOKIE, &SLEPC_SlepcDenseCopy);
173: PetscLogEventRegister("VecsMult", EPS_COOKIE, &SLEPC_VecsMult);
175: #if defined(PETSC_HAVE_DRAND48)
176: /* work-around for Cygwin drand48() initialization bug */
177: srand48(0);
178: #endif
180: SlepcInitializeCalled = PETSC_TRUE;
181: PetscInfo(0,"SLEPc successfully started\n");
182: PetscFunctionReturn(info);
183: }
187: /*@
188: SlepcFinalize - Checks for options to be called at the conclusion
189: of the SLEPc program and calls PetscFinalize().
191: Collective on PETSC_COMM_WORLD
193: Level: beginner
195: .seealso: SlepcInitialize(), PetscFinalize()
196: @*/
197: PetscErrorCode SlepcFinalize(void)
198: {
199: PetscErrorCode info=0;
200:
202: PetscInfo(0,"SLEPc successfully ended!\n");
204: if (SlepcBeganPetsc) {
205: info = PetscFinalize();CHKERRQ(info);
206: }
208: SlepcInitializeCalled = PETSC_FALSE;
210: PetscFunctionReturn(info);
211: }
213: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
217: /*
218: PetscDLLibraryRegister - This function is called when the dynamic library
219: it is in is opened.
221: This one registers all the EPS and ST methods in the libslepc.a
222: library.
224: Input Parameter:
225: path - library path
226: */
227: PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
228: {
231: PetscInitializeNoArguments(); if (ierr) return 1;
234: /*
235: If we got here then PETSc was properly loaded
236: */
237: STInitializePackage(path);
238: EPSInitializePackage(path);
239: SVDInitializePackage(path);
240: QEPInitializePackage(path);
241: IPInitializePackage(path);
242: return(0);
243: }
246: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */