| 1376 |
slepc |
1 |
/*
|
|
|
2 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 1672 |
slepc |
3 |
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
| 2116 |
eromero |
4 |
Copyright (c) 2002-2010, Universidad 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 |
|
| 1885 |
jroman |
22 |
#include "slepcsys.h" /*I "slepcsys.h" I*/
|
| 1853 |
antodo |
23 |
#include "private/epsimpl.h"
|
|
|
24 |
#include "private/stimpl.h"
|
|
|
25 |
#include "private/svdimpl.h"
|
| 1887 |
jroman |
26 |
#include "private/qepimpl.h"
|
| 1853 |
antodo |
27 |
#include "private/ipimpl.h"
|
| 1167 |
slepc |
28 |
#include <stdlib.h>
|
| 6 |
dsic.upv.es!jroman |
29 |
|
|
|
30 |
#undef __FUNCT__
|
|
|
31 |
#define __FUNCT__ "SlepcPrintVersion"
|
|
|
32 |
/*
|
|
|
33 |
SlepcPrintVersion - Prints SLEPc version info.
|
|
|
34 |
|
|
|
35 |
Collective on MPI_Comm
|
|
|
36 |
*/
|
| 476 |
dsic.upv.es!antodo |
37 |
PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
|
| 6 |
dsic.upv.es!jroman |
38 |
{
|
| 1510 |
slepc |
39 |
PetscErrorCode info = 0;
|
| 6 |
dsic.upv.es!jroman |
40 |
|
|
|
41 |
PetscFunctionBegin;
|
|
|
42 |
|
|
|
43 |
info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
|
|
|
44 |
------------------------------\n"); CHKERRQ(info);
|
| 1077 |
slepc |
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);
|
| 761 |
dsic.upv.es!jroman |
52 |
info = (*PetscHelpPrintf)(comm,"See docs/manual.html for help. \n"); CHKERRQ(info);
|
| 6 |
dsic.upv.es!jroman |
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);
|
|
|
58 |
|
|
|
59 |
PetscFunctionReturn(info);
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
#undef __FUNCT__
|
|
|
63 |
#define __FUNCT__ "SlepcPrintHelpIntro"
|
|
|
64 |
/*
|
|
|
65 |
SlepcPrintHelpIntro - Prints introductory SLEPc help info.
|
|
|
66 |
|
|
|
67 |
Collective on MPI_Comm
|
|
|
68 |
*/
|
| 476 |
dsic.upv.es!antodo |
69 |
PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
|
| 6 |
dsic.upv.es!jroman |
70 |
{
|
| 1510 |
slepc |
71 |
PetscErrorCode info = 0;
|
| 6 |
dsic.upv.es!jroman |
72 |
|
|
|
73 |
PetscFunctionBegin;
|
|
|
74 |
|
|
|
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);
|
|
|
81 |
|
|
|
82 |
PetscFunctionReturn(info);
|
|
|
83 |
}
|
|
|
84 |
|
|
|
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;
|
| 1755 |
antodo |
92 |
extern PetscLogEvent SLEPC_UpdateVectors, SLEPC_VecMAXPBY;
|
| 6 |
dsic.upv.es!jroman |
93 |
|
|
|
94 |
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
|
| 1354 |
slepc |
95 |
extern PetscDLLibrary DLLibrariesLoaded;
|
| 6 |
dsic.upv.es!jroman |
96 |
#endif
|
|
|
97 |
|
|
|
98 |
#undef __FUNCT__
|
|
|
99 |
#define __FUNCT__ "SlepcInitialize"
|
|
|
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.
|
|
|
104 |
|
|
|
105 |
Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
|
|
|
106 |
|
|
|
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
|
|
|
113 |
|
|
|
114 |
Fortran Note:
|
|
|
115 |
Fortran syntax is very similar to that of PetscInitialize()
|
|
|
116 |
|
|
|
117 |
Level: beginner
|
|
|
118 |
|
|
|
119 |
.seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
|
|
|
120 |
@*/
|
| 476 |
dsic.upv.es!antodo |
121 |
PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
|
| 6 |
dsic.upv.es!jroman |
122 |
{
|
| 842 |
dsic.upv.es!antodo |
123 |
PetscErrorCode ierr;
|
|
|
124 |
PetscErrorCode info=0;
|
| 373 |
dsic.upv.es!antodo |
125 |
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
|
| 476 |
dsic.upv.es!antodo |
126 |
char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
|
|
|
127 |
PetscTruth found;
|
| 373 |
dsic.upv.es!antodo |
128 |
#endif
|
| 6 |
dsic.upv.es!jroman |
129 |
|
|
|
130 |
PetscFunctionBegin;
|
|
|
131 |
|
| 1609 |
slepc |
132 |
if (SlepcInitializeCalled) {
|
| 6 |
dsic.upv.es!jroman |
133 |
PetscFunctionReturn(0);
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
#if !defined(PARCH_t3d)
|
|
|
137 |
info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
|
|
|
138 |
#endif
|
|
|
139 |
|
|
|
140 |
if (!PetscInitializeCalled) {
|
|
|
141 |
info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
|
|
|
142 |
SlepcBeganPetsc = PETSC_TRUE;
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
/*
|
|
|
146 |
Load the dynamic libraries
|
|
|
147 |
*/
|
|
|
148 |
|
|
|
149 |
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
|
|
|
150 |
ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);CHKERRQ(ierr);
|
|
|
151 |
ierr = PetscStrcat(libs,"/libslepc");CHKERRQ(ierr);
|
|
|
152 |
ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);CHKERRQ(ierr);
|
|
|
153 |
if (found) {
|
|
|
154 |
ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);CHKERRQ(ierr);
|
|
|
155 |
} else {
|
| 1523 |
slepc |
156 |
SETERRQ1(1,"Unable to locate SLEPc dynamic library %s \n",libs);
|
| 6 |
dsic.upv.es!jroman |
157 |
}
|
|
|
158 |
#else
|
| 842 |
dsic.upv.es!antodo |
159 |
ierr = STInitializePackage(PETSC_NULL); CHKERRQ(ierr);
|
|
|
160 |
ierr = EPSInitializePackage(PETSC_NULL); CHKERRQ(ierr);
|
| 1249 |
slepc |
161 |
ierr = SVDInitializePackage(PETSC_NULL); CHKERRQ(ierr);
|
| 1887 |
jroman |
162 |
ierr = QEPInitializePackage(PETSC_NULL); CHKERRQ(ierr);
|
| 1302 |
slepc |
163 |
ierr = IPInitializePackage(PETSC_NULL); CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
164 |
#endif
|
|
|
165 |
|
| 1601 |
slepc |
166 |
ierr = PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);CHKERRQ(ierr);
|
| 1755 |
antodo |
167 |
ierr = PetscLogEventRegister("VecMAXPBY",0,&SLEPC_VecMAXPBY);CHKERRQ(ierr);
|
| 1601 |
slepc |
168 |
|
| 1166 |
slepc |
169 |
#if defined(PETSC_HAVE_DRAND48)
|
|
|
170 |
/* work-around for Cygwin drand48() initialization bug */
|
|
|
171 |
srand48(0);
|
|
|
172 |
#endif
|
|
|
173 |
|
| 6 |
dsic.upv.es!jroman |
174 |
SlepcInitializeCalled = PETSC_TRUE;
|
| 1038 |
slepc |
175 |
PetscInfo(0,"SLEPc successfully started\n");
|
| 6 |
dsic.upv.es!jroman |
176 |
PetscFunctionReturn(info);
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
#undef __FUNCT__
|
|
|
180 |
#define __FUNCT__ "SlepcFinalize"
|
|
|
181 |
/*@
|
|
|
182 |
SlepcFinalize - Checks for options to be called at the conclusion
|
|
|
183 |
of the SLEPc program and calls PetscFinalize().
|
|
|
184 |
|
|
|
185 |
Collective on PETSC_COMM_WORLD
|
|
|
186 |
|
|
|
187 |
Level: beginner
|
|
|
188 |
|
|
|
189 |
.seealso: SlepcInitialize(), PetscFinalize()
|
|
|
190 |
@*/
|
| 476 |
dsic.upv.es!antodo |
191 |
PetscErrorCode SlepcFinalize(void)
|
| 6 |
dsic.upv.es!jroman |
192 |
{
|
| 572 |
dsic.upv.es!antodo |
193 |
PetscErrorCode info=0;
|
| 6 |
dsic.upv.es!jroman |
194 |
|
|
|
195 |
PetscFunctionBegin;
|
| 1038 |
slepc |
196 |
PetscInfo(0,"SLEPc successfully ended!\n");
|
| 6 |
dsic.upv.es!jroman |
197 |
|
|
|
198 |
if (SlepcBeganPetsc) {
|
|
|
199 |
info = PetscFinalize();CHKERRQ(info);
|
|
|
200 |
}
|
|
|
201 |
|
|
|
202 |
SlepcInitializeCalled = PETSC_FALSE;
|
|
|
203 |
|
|
|
204 |
PetscFunctionReturn(info);
|
|
|
205 |
}
|
|
|
206 |
|
| 842 |
dsic.upv.es!antodo |
207 |
#ifdef PETSC_USE_DYNAMIC_LIBRARIES
|
|
|
208 |
EXTERN_C_BEGIN
|
|
|
209 |
#undef __FUNCT__
|
|
|
210 |
#define __FUNCT__ "PetscDLLibraryRegister_slepc"
|
|
|
211 |
/*
|
|
|
212 |
PetscDLLibraryRegister - This function is called when the dynamic library
|
|
|
213 |
it is in is opened.
|
|
|
214 |
|
|
|
215 |
This one registers all the EPS and ST methods in the libslepc.a
|
|
|
216 |
library.
|
|
|
217 |
|
|
|
218 |
Input Parameter:
|
|
|
219 |
path - library path
|
|
|
220 |
*/
|
|
|
221 |
PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
|
|
|
222 |
{
|
|
|
223 |
PetscErrorCode ierr;
|
|
|
224 |
|
|
|
225 |
ierr = PetscInitializeNoArguments(); if (ierr) return 1;
|
|
|
226 |
|
|
|
227 |
PetscFunctionBegin;
|
|
|
228 |
/*
|
|
|
229 |
If we got here then PETSc was properly loaded
|
|
|
230 |
*/
|
|
|
231 |
ierr = STInitializePackage(path); CHKERRQ(ierr);
|
|
|
232 |
ierr = EPSInitializePackage(path); CHKERRQ(ierr);
|
| 1250 |
slepc |
233 |
ierr = SVDInitializePackage(path); CHKERRQ(ierr);
|
| 1887 |
jroman |
234 |
ierr = QEPInitializePackage(path); CHKERRQ(ierr);
|
| 1354 |
slepc |
235 |
ierr = IPInitializePackage(path); CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
236 |
PetscFunctionReturn(0);
|
|
|
237 |
}
|
|
|
238 |
EXTERN_C_END
|
|
|
239 |
|
|
|
240 |
#endif /* PETSC_USE_DYNAMIC_LIBRARIES */
|