| 1376 |
slepc |
1 |
/*
|
|
|
2 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 1672 |
slepc |
3 |
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
| 2575 |
eromero |
4 |
Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain
|
| 6 |
dsic.upv.es!jroman |
5 |
|
| 1672 |
slepc |
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.
|
|
|
11 |
|
|
|
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.
|
|
|
16 |
|
|
|
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/>.
|
| 1376 |
slepc |
19 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
20 |
*/
|
|
|
21 |
|
| 2729 |
jroman |
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/ipimpl.h>
|
| 2757 |
jroman |
28 |
#include <slepc-private/psimpl.h>
|
| 2729 |
jroman |
29 |
#include <slepc-private/vecimplslepc.h>
|
| 1167 |
slepc |
30 |
#include <stdlib.h>
|
| 6 |
dsic.upv.es!jroman |
31 |
|
|
|
32 |
#undef __FUNCT__
|
|
|
33 |
#define __FUNCT__ "SlepcPrintVersion"
|
|
|
34 |
/*
|
|
|
35 |
SlepcPrintVersion - Prints SLEPc version info.
|
|
|
36 |
|
|
|
37 |
Collective on MPI_Comm
|
|
|
38 |
*/
|
| 476 |
dsic.upv.es!antodo |
39 |
PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
|
| 6 |
dsic.upv.es!jroman |
40 |
{
|
| 2269 |
jroman |
41 |
PetscErrorCode ierr;
|
|
|
42 |
char version[256];
|
| 6 |
dsic.upv.es!jroman |
43 |
|
|
|
44 |
PetscFunctionBegin;
|
| 2269 |
jroman |
45 |
ierr = SlepcGetVersion(version,256);CHKERRQ(ierr);
|
|
|
46 |
ierr = (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");CHKERRQ(ierr);
|
|
|
47 |
ierr = (*PetscHelpPrintf)(comm,"%s\n",version);CHKERRQ(ierr);
|
|
|
48 |
ierr = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO);CHKERRQ(ierr);
|
|
|
49 |
ierr = (*PetscHelpPrintf)(comm,"See docs/manual.html for help.\n");CHKERRQ(ierr);
|
|
|
50 |
ierr = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR);CHKERRQ(ierr);
|
|
|
51 |
PetscFunctionReturn(0);
|
| 6 |
dsic.upv.es!jroman |
52 |
}
|
|
|
53 |
|
|
|
54 |
#undef __FUNCT__
|
|
|
55 |
#define __FUNCT__ "SlepcPrintHelpIntro"
|
|
|
56 |
/*
|
|
|
57 |
SlepcPrintHelpIntro - Prints introductory SLEPc help info.
|
|
|
58 |
|
|
|
59 |
Collective on MPI_Comm
|
|
|
60 |
*/
|
| 476 |
dsic.upv.es!antodo |
61 |
PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
|
| 6 |
dsic.upv.es!jroman |
62 |
{
|
| 2269 |
jroman |
63 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
64 |
|
|
|
65 |
PetscFunctionBegin;
|
| 2269 |
jroman |
66 |
ierr = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n");CHKERRQ(ierr);
|
|
|
67 |
ierr = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n");CHKERRQ(ierr);
|
|
|
68 |
ierr = (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");CHKERRQ(ierr);
|
|
|
69 |
PetscFunctionReturn(0);
|
| 6 |
dsic.upv.es!jroman |
70 |
}
|
|
|
71 |
|
|
|
72 |
/* ------------------------Nasty global variables -------------------------------*/
|
|
|
73 |
/*
|
|
|
74 |
Indicates whether SLEPc started PETSc, or whether it was
|
|
|
75 |
already started before SLEPc was initialized.
|
|
|
76 |
*/
|
| 2216 |
jroman |
77 |
PetscBool SlepcBeganPetsc = PETSC_FALSE;
|
|
|
78 |
PetscBool SlepcInitializeCalled = PETSC_FALSE;
|
| 2331 |
jroman |
79 |
extern PetscLogEvent SLEPC_UpdateVectors,SLEPC_VecMAXPBY,SLEPC_SlepcDenseMatProd,SLEPC_SlepcDenseOrth,
|
|
|
80 |
SLEPC_SlepcDenseMatInvProd,SLEPC_SlepcDenseNorm,SLEPC_SlepcDenseCopy,SLEPC_VecsMult;
|
| 6 |
dsic.upv.es!jroman |
81 |
|
|
|
82 |
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
|
| 1354 |
slepc |
83 |
extern PetscDLLibrary DLLibrariesLoaded;
|
| 2275 |
jroman |
84 |
|
|
|
85 |
#undef __FUNCT__
|
|
|
86 |
#define __FUNCT__ "SlepcInitialize_DynamicLibraries"
|
|
|
87 |
/*
|
|
|
88 |
SlepcInitialize_DynamicLibraries - Adds the default dynamic link libraries to the
|
|
|
89 |
search path.
|
|
|
90 |
*/
|
|
|
91 |
PetscErrorCode SlepcInitialize_DynamicLibraries(void)
|
|
|
92 |
{
|
|
|
93 |
PetscErrorCode ierr;
|
|
|
94 |
PetscBool found;
|
|
|
95 |
char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
|
|
|
96 |
|
|
|
97 |
PetscFunctionBegin;
|
|
|
98 |
ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);CHKERRQ(ierr);
|
|
|
99 |
ierr = PetscStrcat(libs,"/libslepc");CHKERRQ(ierr);
|
|
|
100 |
ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);CHKERRQ(ierr);
|
|
|
101 |
if (found) {
|
|
|
102 |
ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);CHKERRQ(ierr);
|
| 2762 |
jroman |
103 |
} else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\n You cannot move the dynamic libraries!");
|
| 2275 |
jroman |
104 |
PetscFunctionReturn(0);
|
|
|
105 |
}
|
| 6 |
dsic.upv.es!jroman |
106 |
#endif
|
|
|
107 |
|
|
|
108 |
#undef __FUNCT__
|
| 2275 |
jroman |
109 |
#define __FUNCT__ "SlepcInitialize_Packages"
|
|
|
110 |
/*
|
|
|
111 |
SlepcInitialize_Packages - Initialize all SLEPc packages at the initialization.
|
|
|
112 |
*/
|
|
|
113 |
PetscErrorCode SlepcInitialize_Packages(void)
|
|
|
114 |
{
|
|
|
115 |
PetscErrorCode ierr;
|
| 2317 |
jroman |
116 |
|
| 2275 |
jroman |
117 |
PetscFunctionBegin;
|
|
|
118 |
ierr = STInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
119 |
ierr = EPSInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
120 |
ierr = SVDInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
121 |
ierr = QEPInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
122 |
ierr = IPInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
| 2757 |
jroman |
123 |
ierr = PSInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
| 2337 |
jroman |
124 |
/* New special type of Vec, implemented in SLEPc */
|
|
|
125 |
ierr = VecRegister_Comp(PETSC_NULL);CHKERRQ(ierr);
|
| 2275 |
jroman |
126 |
PetscFunctionReturn(0);
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
#undef __FUNCT__
|
|
|
130 |
#define __FUNCT__ "SlepcInitialize_LogEvents"
|
|
|
131 |
/*
|
|
|
132 |
SlepcInitialize_LogEvents - Initialize log events not pertaining to any object class.
|
|
|
133 |
*/
|
|
|
134 |
PetscErrorCode SlepcInitialize_LogEvents(void)
|
|
|
135 |
{
|
|
|
136 |
PetscErrorCode ierr;
|
| 2317 |
jroman |
137 |
|
| 2275 |
jroman |
138 |
PetscFunctionBegin;
|
|
|
139 |
ierr = PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);CHKERRQ(ierr);
|
|
|
140 |
ierr = PetscLogEventRegister("VecMAXPBY",0,&SLEPC_VecMAXPBY);CHKERRQ(ierr);
|
|
|
141 |
ierr = PetscLogEventRegister("DenseMatProd",EPS_CLASSID,&SLEPC_SlepcDenseMatProd);CHKERRQ(ierr);
|
|
|
142 |
ierr = PetscLogEventRegister("DenseOrth",EPS_CLASSID,&SLEPC_SlepcDenseOrth);CHKERRQ(ierr);
|
|
|
143 |
ierr = PetscLogEventRegister("DenseMatNorm",EPS_CLASSID,&SLEPC_SlepcDenseNorm);CHKERRQ(ierr);
|
|
|
144 |
ierr = PetscLogEventRegister("DenseCopy",EPS_CLASSID,&SLEPC_SlepcDenseCopy);CHKERRQ(ierr);
|
|
|
145 |
ierr = PetscLogEventRegister("VecsMult",EPS_CLASSID,&SLEPC_VecsMult);CHKERRQ(ierr);
|
|
|
146 |
PetscFunctionReturn(0);
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
150 |
#define __FUNCT__ "SlepcInitialize"
|
|
|
151 |
/*@C
|
|
|
152 |
SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
|
|
|
153 |
PetscInitialize() if that has not been called yet, so this routine should
|
|
|
154 |
always be called near the beginning of your program.
|
|
|
155 |
|
|
|
156 |
Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
|
|
|
157 |
|
|
|
158 |
Input Parameters:
|
|
|
159 |
+ argc - count of number of command line arguments
|
|
|
160 |
. args - the command line arguments
|
|
|
161 |
. file - [optional] PETSc database file, defaults to ~username/.petscrc
|
|
|
162 |
(use PETSC_NULL for default)
|
|
|
163 |
- help - [optional] Help message to print, use PETSC_NULL for no message
|
|
|
164 |
|
|
|
165 |
Fortran Note:
|
|
|
166 |
Fortran syntax is very similar to that of PetscInitialize()
|
|
|
167 |
|
|
|
168 |
Level: beginner
|
|
|
169 |
|
| 2275 |
jroman |
170 |
.seealso: SlepcFinalize(), PetscInitialize()
|
| 6 |
dsic.upv.es!jroman |
171 |
@*/
|
| 2428 |
jroman |
172 |
PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[])
|
| 6 |
dsic.upv.es!jroman |
173 |
{
|
| 2730 |
jroman |
174 |
PetscErrorCode ierr;
|
| 2273 |
jroman |
175 |
PetscBool flg;
|
| 6 |
dsic.upv.es!jroman |
176 |
|
| 2317 |
jroman |
177 |
PetscFunctionBegin;
|
| 1609 |
slepc |
178 |
if (SlepcInitializeCalled) {
|
| 6 |
dsic.upv.es!jroman |
179 |
PetscFunctionReturn(0);
|
|
|
180 |
}
|
| 2730 |
jroman |
181 |
ierr = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(ierr);
|
| 2273 |
jroman |
182 |
ierr = PetscInitialized(&flg);CHKERRQ(ierr);
|
|
|
183 |
if (!flg) {
|
| 2730 |
jroman |
184 |
ierr = PetscInitialize(argc,args,file,help);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
185 |
SlepcBeganPetsc = PETSC_TRUE;
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
|
| 2275 |
jroman |
189 |
ierr = SlepcInitialize_DynamicLibraries();CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
190 |
#else
|
| 2275 |
jroman |
191 |
ierr = SlepcInitialize_Packages();CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
192 |
#endif
|
| 2275 |
jroman |
193 |
ierr = SlepcInitialize_LogEvents();CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
194 |
|
| 1166 |
slepc |
195 |
#if defined(PETSC_HAVE_DRAND48)
|
|
|
196 |
/* work-around for Cygwin drand48() initialization bug */
|
|
|
197 |
srand48(0);
|
|
|
198 |
#endif
|
|
|
199 |
|
| 6 |
dsic.upv.es!jroman |
200 |
SlepcInitializeCalled = PETSC_TRUE;
|
| 2730 |
jroman |
201 |
ierr = PetscInfo(0,"SLEPc successfully started\n");CHKERRQ(ierr);
|
|
|
202 |
PetscFunctionReturn(0);
|
| 6 |
dsic.upv.es!jroman |
203 |
}
|
|
|
204 |
|
|
|
205 |
#undef __FUNCT__
|
|
|
206 |
#define __FUNCT__ "SlepcFinalize"
|
|
|
207 |
/*@
|
|
|
208 |
SlepcFinalize - Checks for options to be called at the conclusion
|
|
|
209 |
of the SLEPc program and calls PetscFinalize().
|
|
|
210 |
|
|
|
211 |
Collective on PETSC_COMM_WORLD
|
|
|
212 |
|
|
|
213 |
Level: beginner
|
|
|
214 |
|
|
|
215 |
.seealso: SlepcInitialize(), PetscFinalize()
|
|
|
216 |
@*/
|
| 476 |
dsic.upv.es!antodo |
217 |
PetscErrorCode SlepcFinalize(void)
|
| 6 |
dsic.upv.es!jroman |
218 |
{
|
| 2730 |
jroman |
219 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
220 |
|
|
|
221 |
PetscFunctionBegin;
|
| 2730 |
jroman |
222 |
ierr = PetscInfo(0,"SlepcFinalize() called\n");CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
223 |
if (SlepcBeganPetsc) {
|
| 2730 |
jroman |
224 |
ierr = PetscFinalize();CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
225 |
}
|
|
|
226 |
SlepcInitializeCalled = PETSC_FALSE;
|
| 2730 |
jroman |
227 |
PetscFunctionReturn(0);
|
| 6 |
dsic.upv.es!jroman |
228 |
}
|
|
|
229 |
|
| 2428 |
jroman |
230 |
#undef __FUNCT__
|
|
|
231 |
#define __FUNCT__ "SlepcInitialized"
|
|
|
232 |
/*@
|
|
|
233 |
SlepcInitialized - Determine whether SLEPc is initialized.
|
|
|
234 |
|
|
|
235 |
Level: beginner
|
|
|
236 |
|
|
|
237 |
.seealso: SlepcInitialize(), SlepcInitializeFortran()
|
|
|
238 |
@*/
|
|
|
239 |
PetscErrorCode SlepcInitialized(PetscBool *isInitialized)
|
|
|
240 |
{
|
|
|
241 |
PetscFunctionBegin;
|
|
|
242 |
PetscValidPointer(isInitialized,1);
|
|
|
243 |
*isInitialized = SlepcInitializeCalled;
|
|
|
244 |
PetscFunctionReturn(0);
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
#if defined(PETSC_HAVE_MATLAB_ENGINE)
|
|
|
248 |
extern PetscBool PetscBeganMPI;
|
|
|
249 |
|
|
|
250 |
#undef __FUNCT__
|
| 2817 |
jroman |
251 |
#define __FUNCT__ "SlepcInitializeNoPointers"
|
| 2428 |
jroman |
252 |
/*
|
| 2817 |
jroman |
253 |
SlepcInitializeNoPointers - Calls SlepcInitialize() from C/C++ without the pointers
|
|
|
254 |
to argc and args (analogue to PetscInitializeNoPointers).
|
| 2428 |
jroman |
255 |
|
|
|
256 |
Collective
|
|
|
257 |
|
|
|
258 |
Level: advanced
|
|
|
259 |
|
|
|
260 |
.seealso: SlepcInitialize()
|
|
|
261 |
*/
|
| 2817 |
jroman |
262 |
PetscErrorCode SlepcInitializeNoPointers(int argc,char **args,const char *filename,const char *help)
|
| 2428 |
jroman |
263 |
{
|
|
|
264 |
PetscErrorCode ierr;
|
|
|
265 |
int myargc = argc;
|
|
|
266 |
char **myargs = args;
|
|
|
267 |
|
|
|
268 |
PetscFunctionBegin;
|
|
|
269 |
ierr = SlepcInitialize(&myargc,&myargs,filename,help);
|
|
|
270 |
ierr = PetscPopSignalHandler();CHKERRQ(ierr);
|
|
|
271 |
PetscBeganMPI = PETSC_FALSE;
|
|
|
272 |
PetscFunctionReturn(ierr);
|
|
|
273 |
}
|
|
|
274 |
#endif
|
|
|
275 |
|
| 842 |
dsic.upv.es!antodo |
276 |
#ifdef PETSC_USE_DYNAMIC_LIBRARIES
|
|
|
277 |
EXTERN_C_BEGIN
|
|
|
278 |
#undef __FUNCT__
|
|
|
279 |
#define __FUNCT__ "PetscDLLibraryRegister_slepc"
|
|
|
280 |
/*
|
|
|
281 |
PetscDLLibraryRegister - This function is called when the dynamic library
|
|
|
282 |
it is in is opened.
|
|
|
283 |
|
|
|
284 |
This one registers all the EPS and ST methods in the libslepc.a
|
|
|
285 |
library.
|
|
|
286 |
|
|
|
287 |
Input Parameter:
|
|
|
288 |
path - library path
|
|
|
289 |
*/
|
|
|
290 |
PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
|
|
|
291 |
{
|
|
|
292 |
PetscErrorCode ierr;
|
|
|
293 |
|
|
|
294 |
ierr = PetscInitializeNoArguments(); if (ierr) return 1;
|
|
|
295 |
|
|
|
296 |
PetscFunctionBegin;
|
|
|
297 |
/*
|
|
|
298 |
If we got here then PETSc was properly loaded
|
|
|
299 |
*/
|
| 2275 |
jroman |
300 |
ierr = SlepcInitialize_Packages();CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
301 |
PetscFunctionReturn(0);
|
|
|
302 |
}
|
|
|
303 |
EXTERN_C_END
|
|
|
304 |
#endif /* PETSC_USE_DYNAMIC_LIBRARIES */
|