| 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 |
|
| 2283 |
jroman |
22 |
#include <slepcsys.h>
|
|
|
23 |
#include <private/epsimpl.h> /*I "slepceps.h" I*/
|
|
|
24 |
#include <private/stimpl.h> /*I "slepcst.h" I*/
|
|
|
25 |
#include <private/svdimpl.h> /*I "slepcsvd.h" I*/
|
|
|
26 |
#include <private/qepimpl.h> /*I "slepcqep.h" I*/
|
|
|
27 |
#include <private/ipimpl.h> /*I "slepcip.h" I*/
|
| 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 |
{
|
| 2269 |
jroman |
39 |
PetscErrorCode ierr;
|
|
|
40 |
char version[256];
|
| 6 |
dsic.upv.es!jroman |
41 |
|
|
|
42 |
PetscFunctionBegin;
|
| 2269 |
jroman |
43 |
ierr = SlepcGetVersion(version,256);CHKERRQ(ierr);
|
|
|
44 |
ierr = (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");CHKERRQ(ierr);
|
|
|
45 |
ierr = (*PetscHelpPrintf)(comm,"%s\n",version);CHKERRQ(ierr);
|
|
|
46 |
ierr = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO);CHKERRQ(ierr);
|
|
|
47 |
ierr = (*PetscHelpPrintf)(comm,"See docs/manual.html for help.\n");CHKERRQ(ierr);
|
|
|
48 |
ierr = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR);CHKERRQ(ierr);
|
|
|
49 |
PetscFunctionReturn(0);
|
| 6 |
dsic.upv.es!jroman |
50 |
}
|
|
|
51 |
|
|
|
52 |
#undef __FUNCT__
|
|
|
53 |
#define __FUNCT__ "SlepcPrintHelpIntro"
|
|
|
54 |
/*
|
|
|
55 |
SlepcPrintHelpIntro - Prints introductory SLEPc help info.
|
|
|
56 |
|
|
|
57 |
Collective on MPI_Comm
|
|
|
58 |
*/
|
| 476 |
dsic.upv.es!antodo |
59 |
PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
|
| 6 |
dsic.upv.es!jroman |
60 |
{
|
| 2269 |
jroman |
61 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
62 |
|
|
|
63 |
PetscFunctionBegin;
|
| 2269 |
jroman |
64 |
ierr = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n");CHKERRQ(ierr);
|
|
|
65 |
ierr = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n");CHKERRQ(ierr);
|
|
|
66 |
ierr = (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");CHKERRQ(ierr);
|
|
|
67 |
PetscFunctionReturn(0);
|
| 6 |
dsic.upv.es!jroman |
68 |
}
|
|
|
69 |
|
|
|
70 |
/* ------------------------Nasty global variables -------------------------------*/
|
|
|
71 |
/*
|
|
|
72 |
Indicates whether SLEPc started PETSc, or whether it was
|
|
|
73 |
already started before SLEPc was initialized.
|
|
|
74 |
*/
|
| 2216 |
jroman |
75 |
PetscBool SlepcBeganPetsc = PETSC_FALSE;
|
|
|
76 |
PetscBool SlepcInitializeCalled = PETSC_FALSE;
|
| 2206 |
eromero |
77 |
extern PetscLogEvent SLEPC_UpdateVectors, SLEPC_VecMAXPBY, SLEPC_SlepcDenseMatProd, SLEPC_SlepcDenseOrth,
|
|
|
78 |
SLEPC_SlepcDenseMatInvProd, SLEPC_SlepcDenseNorm, SLEPC_SlepcDenseCopy, SLEPC_VecsMult;
|
| 6 |
dsic.upv.es!jroman |
79 |
|
|
|
80 |
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
|
| 1354 |
slepc |
81 |
extern PetscDLLibrary DLLibrariesLoaded;
|
| 2275 |
jroman |
82 |
|
|
|
83 |
#undef __FUNCT__
|
|
|
84 |
#define __FUNCT__ "SlepcInitialize_DynamicLibraries"
|
|
|
85 |
/*
|
|
|
86 |
SlepcInitialize_DynamicLibraries - Adds the default dynamic link libraries to the
|
|
|
87 |
search path.
|
|
|
88 |
*/
|
|
|
89 |
PetscErrorCode SlepcInitialize_DynamicLibraries(void)
|
|
|
90 |
{
|
|
|
91 |
PetscErrorCode ierr;
|
|
|
92 |
PetscBool found;
|
|
|
93 |
char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
|
|
|
94 |
|
|
|
95 |
PetscFunctionBegin;
|
|
|
96 |
ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);CHKERRQ(ierr);
|
|
|
97 |
ierr = PetscStrcat(libs,"/libslepc");CHKERRQ(ierr);
|
|
|
98 |
ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);CHKERRQ(ierr);
|
|
|
99 |
if (found) {
|
|
|
100 |
ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);CHKERRQ(ierr);
|
|
|
101 |
} else {
|
|
|
102 |
SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\n You cannot move the dynamic libraries!");
|
|
|
103 |
}
|
|
|
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;
|
|
|
116 |
PetscFunctionBegin;
|
|
|
117 |
ierr = STInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
118 |
ierr = EPSInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
119 |
ierr = SVDInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
120 |
ierr = QEPInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
121 |
ierr = IPInitializePackage(PETSC_NULL);CHKERRQ(ierr);
|
|
|
122 |
PetscFunctionReturn(0);
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
#undef __FUNCT__
|
|
|
126 |
#define __FUNCT__ "SlepcInitialize_LogEvents"
|
|
|
127 |
/*
|
|
|
128 |
SlepcInitialize_LogEvents - Initialize log events not pertaining to any object class.
|
|
|
129 |
*/
|
|
|
130 |
PetscErrorCode SlepcInitialize_LogEvents(void)
|
|
|
131 |
{
|
|
|
132 |
PetscErrorCode ierr;
|
|
|
133 |
PetscFunctionBegin;
|
|
|
134 |
ierr = PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);CHKERRQ(ierr);
|
|
|
135 |
ierr = PetscLogEventRegister("VecMAXPBY",0,&SLEPC_VecMAXPBY);CHKERRQ(ierr);
|
|
|
136 |
ierr = PetscLogEventRegister("DenseMatProd",EPS_CLASSID,&SLEPC_SlepcDenseMatProd);CHKERRQ(ierr);
|
|
|
137 |
ierr = PetscLogEventRegister("DenseOrth",EPS_CLASSID,&SLEPC_SlepcDenseOrth);CHKERRQ(ierr);
|
|
|
138 |
ierr = PetscLogEventRegister("DenseMatInvProd",EPS_CLASSID,&SLEPC_SlepcDenseMatInvProd);CHKERRQ(ierr);
|
|
|
139 |
ierr = PetscLogEventRegister("DenseMatNorm",EPS_CLASSID,&SLEPC_SlepcDenseNorm);CHKERRQ(ierr);
|
|
|
140 |
ierr = PetscLogEventRegister("DenseCopy",EPS_CLASSID,&SLEPC_SlepcDenseCopy);CHKERRQ(ierr);
|
|
|
141 |
ierr = PetscLogEventRegister("VecsMult",EPS_CLASSID,&SLEPC_VecsMult);CHKERRQ(ierr);
|
|
|
142 |
PetscFunctionReturn(0);
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
146 |
#define __FUNCT__ "SlepcInitialize"
|
|
|
147 |
/*@C
|
|
|
148 |
SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
|
|
|
149 |
PetscInitialize() if that has not been called yet, so this routine should
|
|
|
150 |
always be called near the beginning of your program.
|
|
|
151 |
|
|
|
152 |
Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
|
|
|
153 |
|
|
|
154 |
Input Parameters:
|
|
|
155 |
+ argc - count of number of command line arguments
|
|
|
156 |
. args - the command line arguments
|
|
|
157 |
. file - [optional] PETSc database file, defaults to ~username/.petscrc
|
|
|
158 |
(use PETSC_NULL for default)
|
|
|
159 |
- help - [optional] Help message to print, use PETSC_NULL for no message
|
|
|
160 |
|
|
|
161 |
Fortran Note:
|
|
|
162 |
Fortran syntax is very similar to that of PetscInitialize()
|
|
|
163 |
|
|
|
164 |
Level: beginner
|
|
|
165 |
|
| 2275 |
jroman |
166 |
.seealso: SlepcFinalize(), PetscInitialize()
|
| 6 |
dsic.upv.es!jroman |
167 |
@*/
|
| 476 |
dsic.upv.es!antodo |
168 |
PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
|
| 6 |
dsic.upv.es!jroman |
169 |
{
|
| 842 |
dsic.upv.es!antodo |
170 |
PetscErrorCode ierr;
|
|
|
171 |
PetscErrorCode info=0;
|
| 2273 |
jroman |
172 |
PetscBool flg;
|
| 6 |
dsic.upv.es!jroman |
173 |
PetscFunctionBegin;
|
|
|
174 |
|
| 1609 |
slepc |
175 |
if (SlepcInitializeCalled) {
|
| 6 |
dsic.upv.es!jroman |
176 |
PetscFunctionReturn(0);
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
|
|
|
180 |
|
| 2273 |
jroman |
181 |
ierr = PetscInitialized(&flg);CHKERRQ(ierr);
|
|
|
182 |
if (!flg) {
|
| 6 |
dsic.upv.es!jroman |
183 |
info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
|
|
|
184 |
SlepcBeganPetsc = PETSC_TRUE;
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
|
| 2275 |
jroman |
188 |
ierr = SlepcInitialize_DynamicLibraries();CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
189 |
#else
|
| 2275 |
jroman |
190 |
ierr = SlepcInitialize_Packages();CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
191 |
#endif
|
| 2275 |
jroman |
192 |
ierr = SlepcInitialize_LogEvents();CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
193 |
|
| 1166 |
slepc |
194 |
#if defined(PETSC_HAVE_DRAND48)
|
|
|
195 |
/* work-around for Cygwin drand48() initialization bug */
|
|
|
196 |
srand48(0);
|
|
|
197 |
#endif
|
|
|
198 |
|
| 6 |
dsic.upv.es!jroman |
199 |
SlepcInitializeCalled = PETSC_TRUE;
|
| 1038 |
slepc |
200 |
PetscInfo(0,"SLEPc successfully started\n");
|
| 6 |
dsic.upv.es!jroman |
201 |
PetscFunctionReturn(info);
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
#undef __FUNCT__
|
|
|
205 |
#define __FUNCT__ "SlepcFinalize"
|
|
|
206 |
/*@
|
|
|
207 |
SlepcFinalize - Checks for options to be called at the conclusion
|
|
|
208 |
of the SLEPc program and calls PetscFinalize().
|
|
|
209 |
|
|
|
210 |
Collective on PETSC_COMM_WORLD
|
|
|
211 |
|
|
|
212 |
Level: beginner
|
|
|
213 |
|
|
|
214 |
.seealso: SlepcInitialize(), PetscFinalize()
|
|
|
215 |
@*/
|
| 476 |
dsic.upv.es!antodo |
216 |
PetscErrorCode SlepcFinalize(void)
|
| 6 |
dsic.upv.es!jroman |
217 |
{
|
| 572 |
dsic.upv.es!antodo |
218 |
PetscErrorCode info=0;
|
| 6 |
dsic.upv.es!jroman |
219 |
|
|
|
220 |
PetscFunctionBegin;
|
| 1038 |
slepc |
221 |
PetscInfo(0,"SLEPc successfully ended!\n");
|
| 6 |
dsic.upv.es!jroman |
222 |
|
|
|
223 |
if (SlepcBeganPetsc) {
|
|
|
224 |
info = PetscFinalize();CHKERRQ(info);
|
|
|
225 |
}
|
|
|
226 |
|
|
|
227 |
SlepcInitializeCalled = PETSC_FALSE;
|
|
|
228 |
|
|
|
229 |
PetscFunctionReturn(info);
|
|
|
230 |
}
|
|
|
231 |
|
| 842 |
dsic.upv.es!antodo |
232 |
#ifdef PETSC_USE_DYNAMIC_LIBRARIES
|
|
|
233 |
EXTERN_C_BEGIN
|
|
|
234 |
#undef __FUNCT__
|
|
|
235 |
#define __FUNCT__ "PetscDLLibraryRegister_slepc"
|
|
|
236 |
/*
|
|
|
237 |
PetscDLLibraryRegister - This function is called when the dynamic library
|
|
|
238 |
it is in is opened.
|
|
|
239 |
|
|
|
240 |
This one registers all the EPS and ST methods in the libslepc.a
|
|
|
241 |
library.
|
|
|
242 |
|
|
|
243 |
Input Parameter:
|
|
|
244 |
path - library path
|
|
|
245 |
*/
|
|
|
246 |
PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
|
|
|
247 |
{
|
|
|
248 |
PetscErrorCode ierr;
|
|
|
249 |
|
|
|
250 |
ierr = PetscInitializeNoArguments(); if (ierr) return 1;
|
|
|
251 |
|
|
|
252 |
PetscFunctionBegin;
|
|
|
253 |
/*
|
|
|
254 |
If we got here then PETSc was properly loaded
|
|
|
255 |
*/
|
| 2275 |
jroman |
256 |
ierr = SlepcInitialize_Packages();CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
257 |
PetscFunctionReturn(0);
|
|
|
258 |
}
|
|
|
259 |
EXTERN_C_END
|
|
|
260 |
#endif /* PETSC_USE_DYNAMIC_LIBRARIES */
|