GCC Code Coverage Report


Directory: ./
File: src/sys/slepcinit.c
Date: 2026-05-25 04:09:24
Exec Total Coverage
Lines: 108 120 90.0%
Functions: 13 14 92.9%
Branches: 226 448 50.4%

Line Branch Exec Source
1 /*
2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3 SLEPc - Scalable Library for Eigenvalue Problem Computations
4 Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
5
6 This file is part of SLEPc.
7 SLEPc is distributed under a 2-clause BSD license (see LICENSE).
8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9 */
10
11 #include <slepc/private/slepcimpl.h> /*I "slepcsys.h" I*/
12 #include <slepcconfiginfo.h>
13
14 #if defined(SLEPC_HAVE_HPDDM)
15 #include <petscksp.h>
16 SLEPC_EXTERN PetscErrorCode KSPCreate_HPDDM(KSP);
17 SLEPC_EXTERN PetscErrorCode PCCreate_HPDDM(PC);
18 #endif
19
20 /*@C
21 SlepcGetVersion - Gets the SLEPc version information in a string.
22
23 Not Collective
24
25 Input Parameter:
26 . len - length of the string
27
28 Output Parameter:
29 . version - version string
30
31 Level: intermediate
32
33 .seealso: [](sec:writing-prog), `SlepcGetVersionNumber()`
34 @*/
35 19 PetscErrorCode SlepcGetVersion(char version[],size_t len)
36 {
37
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
19 PetscFunctionBegin;
38 #if (SLEPC_VERSION_RELEASE == 1)
39 PetscCall(PetscSNPrintf(version,len,"SLEPc Release Version %d.%d.%d, %s",SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_DATE));
40 #else
41
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
19 PetscCall(PetscSNPrintf(version,len,"SLEPc Development Git Revision: %s Git Date: %s",SLEPC_VERSION_GIT,SLEPC_VERSION_DATE_GIT));
42 #endif
43
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
4 PetscFunctionReturn(PETSC_SUCCESS);
44 }
45
46 /*@
47 SlepcGetVersionNumber - Gets the SLEPc version information from the library.
48
49 Not Collective
50
51 Output Parameters:
52 + major - the major version
53 . minor - the minor version
54 . subminor - the subminor version (patch number)
55 - release - indicates the library is from a release
56
57 Notes:
58 Pass `NULL` in any argument that is not requested.
59
60 The C macros `SLEPC_VERSION_MAJOR`, `SLEPC_VERSION_MINOR`, `SLEPC_VERSION_SUBMINOR`,
61 `SLEPC_VERSION_RELEASE` provide the information at compile time. This can be used to confirm
62 that the shared library being loaded at runtime has the appropriate version updates.
63
64 This function can be called before `SlepcInitialize()`.
65
66 Level: intermediate
67
68 .seealso: [](sec:writing-prog), `SlepcGetVersion()`, `SlepcInitialize()`
69 @*/
70 17 PetscErrorCode SlepcGetVersionNumber(PetscInt *major,PetscInt *minor,PetscInt *subminor,PetscInt *release)
71 {
72
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
17 if (major) *major = SLEPC_VERSION_MAJOR;
73
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
17 if (minor) *minor = SLEPC_VERSION_MINOR;
74
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
17 if (subminor) *subminor = SLEPC_VERSION_SUBMINOR;
75
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
17 if (release) *release = SLEPC_VERSION_RELEASE;
76 17 return PETSC_SUCCESS;
77 }
78
79 /*@C
80 SlepcGetConfiguration - Gets the SLEPc configuration information in a string.
81
82 Not Collective
83
84 Output Parameter:
85 . configuration - configuration string
86
87 Level: developer
88
89 .seealso: `SlepcGetVersionNumber()`
90 @*/
91 10 PetscErrorCode SlepcGetConfiguration(const char *configuration[])
92 {
93
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
10 PetscFunctionBegin;
94 10 *configuration = slepcconfigureoptions;
95
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
10 PetscFunctionReturn(PETSC_SUCCESS);
96 }
97
98 /*
99 SlepcPrintVersion - Prints SLEPc version info.
100
101 Collective
102 */
103 2 static PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
104 {
105 2 char version[256];
106
107
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 PetscFunctionBegin;
108
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall(SlepcGetVersion(version,256));
109
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall((*PetscHelpPrintf)(comm,"%s\n",version));
110
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall((*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO));
111
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall((*PetscHelpPrintf)(comm,"See https://slepc.upv.es/documentation/ for help.\n"));
112
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall((*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR));
113
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
2 PetscFunctionReturn(PETSC_SUCCESS);
114 }
115
116 /*
117 SlepcPrintHelpIntro - Prints introductory SLEPc help info.
118
119 Collective
120 */
121 2 static PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
122 {
123
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 PetscFunctionBegin;
124
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall((*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n"));
125
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall((*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n"));
126
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 PetscCall((*PetscHelpPrintf)(comm,"----------------------------------------\n"));
127
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
2 PetscFunctionReturn(PETSC_SUCCESS);
128 }
129
130 /* ------------------------Nasty global variables -------------------------------*/
131 /*
132 Indicates whether SLEPc started PETSc, or whether it was
133 already started before SLEPc was initialized.
134 */
135 PetscBool SlepcBeganPetsc = PETSC_FALSE;
136 PetscBool SlepcInitializeCalled = PETSC_FALSE;
137 PetscBool SlepcFinalizeCalled = PETSC_FALSE;
138
139 #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES)
140 16 static PetscErrorCode SlepcLoadDynamicLibrary(const char *name,PetscBool *found)
141 {
142 16 char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
143
144
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
16 PetscFunctionBegin;
145
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
16 PetscCall(PetscStrcpy(libs,SLEPC_LIB_DIR));
146
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
16 PetscCall(PetscStrlcat(libs,"/libslepc",sizeof(libs)));
147
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
16 PetscCall(PetscStrlcat(libs,name,sizeof(libs)));
148 #if defined(PETSC_LIB_NAME_SUFFIX)
149
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
16 PetscCall(PetscStrlcat(libs,PETSC_LIB_NAME_SUFFIX,sizeof(libs)));
150 #endif
151
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
16 PetscCall(PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,sizeof(dlib),found));
152
5/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
16 if (*found) PetscCall(PetscDLLibraryAppend(PETSC_COMM_WORLD,&PetscDLLibrariesLoaded,dlib));
153
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
2 PetscFunctionReturn(PETSC_SUCCESS);
154 }
155 #endif
156
157 #if defined(PETSC_USE_SINGLE_LIBRARY) && !(defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES))
158 SLEPC_EXTERN PetscErrorCode STInitializePackage(void);
159 SLEPC_EXTERN PetscErrorCode DSInitializePackage(void);
160 SLEPC_EXTERN PetscErrorCode FNInitializePackage(void);
161 SLEPC_EXTERN PetscErrorCode BVInitializePackage(void);
162 SLEPC_EXTERN PetscErrorCode RGInitializePackage(void);
163 SLEPC_EXTERN PetscErrorCode EPSInitializePackage(void);
164 SLEPC_EXTERN PetscErrorCode SVDInitializePackage(void);
165 SLEPC_EXTERN PetscErrorCode PEPInitializePackage(void);
166 SLEPC_EXTERN PetscErrorCode NEPInitializePackage(void);
167 SLEPC_EXTERN PetscErrorCode MFNInitializePackage(void);
168 SLEPC_EXTERN PetscErrorCode LMEInitializePackage(void);
169 #endif
170
171 /*
172 SlepcInitialize_DynamicLibraries - Adds the default dynamic link libraries to the
173 search path.
174 */
175 17447 PetscErrorCode SlepcInitialize_DynamicLibraries(void)
176 {
177 17447 PetscBool preload = PETSC_FALSE;
178
179
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
17447 PetscFunctionBegin;
180 #if defined(PETSC_HAVE_THREADSAFETY)
181 /* These must be all initialized here because it is not safe for individual threads to call these initialize routines */
182 preload = PETSC_TRUE;
183 #endif
184
185
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17447 PetscCall(PetscOptionsGetBool(NULL,NULL,"-library_preload",&preload,NULL));
186
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
17447 if (preload) {
187 #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES)
188 10 PetscBool found;
189 #if defined(PETSC_USE_SINGLE_LIBRARY)
190
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9 PetscCall(SlepcLoadDynamicLibrary("",&found));
191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library. You cannot move the dynamic libraries!");
192 #else
193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 PetscCall(SlepcLoadDynamicLibrary("sys",&found));
194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc sys dynamic library. You cannot move the dynamic libraries!");
195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 PetscCall(SlepcLoadDynamicLibrary("eps",&found));
196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc EPS dynamic library. You cannot move the dynamic libraries!");
197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 PetscCall(SlepcLoadDynamicLibrary("pep",&found));
198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc PEP dynamic library. You cannot move the dynamic libraries!");
199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 PetscCall(SlepcLoadDynamicLibrary("nep",&found));
200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc NEP dynamic library. You cannot move the dynamic libraries!");
201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 PetscCall(SlepcLoadDynamicLibrary("svd",&found));
202
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc SVD dynamic library. You cannot move the dynamic libraries!");
203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 PetscCall(SlepcLoadDynamicLibrary("mfn",&found));
204
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc MFN dynamic library. You cannot move the dynamic libraries!");
205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 PetscCall(SlepcLoadDynamicLibrary("lme",&found));
206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 PetscCheck(found,PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc LME dynamic library. You cannot move the dynamic libraries!");
207 #endif
208 #else /* defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES) */
209 #if defined(PETSC_USE_SINGLE_LIBRARY)
210 PetscCall(STInitializePackage());
211 PetscCall(DSInitializePackage());
212 PetscCall(FNInitializePackage());
213 PetscCall(BVInitializePackage());
214 PetscCall(RGInitializePackage());
215 PetscCall(EPSInitializePackage());
216 PetscCall(SVDInitializePackage());
217 PetscCall(PEPInitializePackage());
218 PetscCall(NEPInitializePackage());
219 PetscCall(MFNInitializePackage());
220 PetscCall(LMEInitializePackage());
221 #else
222 SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Cannot use -library_preload with multiple static SLEPc libraries");
223 #endif
224 #endif /* defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES) */
225 }
226
227 #if defined(SLEPC_HAVE_HPDDM)
228
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
3278 PetscCall(KSPRegister(KSPHPDDM,KSPCreate_HPDDM));
229
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
3278 PetscCall(PCRegister(PCHPDDM,PCCreate_HPDDM));
230 #endif
231
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
3278 PetscFunctionReturn(PETSC_SUCCESS);
232 }
233
234 17447 PetscErrorCode SlepcCitationsInitialize(void)
235 {
236
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
17447 PetscFunctionBegin;
237
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17447 PetscCall(PetscCitationsRegister("@Article{slepc-toms,\n"
238 " author = \"Vicente Hernandez and Jose E. Roman and Vicente Vidal\",\n"
239 " title = \"{SLEPc}: A Scalable and Flexible Toolkit for the Solution of Eigenvalue Problems\",\n"
240 " journal = \"{ACM} Trans. Math. Software\",\n"
241 " volume = \"31\",\n"
242 " number = \"3\",\n"
243 " pages = \"351--362\",\n"
244 " year = \"2005\",\n"
245 " doi = \"https://doi.org/10.1145/1089014.1089019\"\n"
246 "}\n",NULL));
247
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17447 PetscCall(PetscCitationsRegister("@TechReport{slepc-manual,\n"
248 " author = \"J. E. Roman and C. Campos and L. Dalcin and E. Romero and A. Tomas\",\n"
249 " title = \"{SLEPc} Users Manual\",\n"
250 " number = \"DSIC-II/24/02 - Revision 3.25\",\n"
251 " institution = \"D. Sistemes Inform\\`atics i Computaci\\'o, Universitat Polit\\`ecnica de Val\\`encia\",\n"
252 " year = \"2026\"\n"
253 "}\n",NULL));
254
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
3278 PetscFunctionReturn(PETSC_SUCCESS);
255 }
256
257 /*@C
258 SlepcInitialize - Initializes the SLEPc library. `SlepcInitialize()` calls
259 `PetscInitialize()` if it has not been called yet, so this function should
260 always be called near the beginning of your program.
261
262 Collective on `MPI_COMM_WORLD` or `PETSC_COMM_WORLD` if it has been set
263
264 Input Parameters:
265 + argc - count of number of command line arguments
266 . args - the command line arguments
267 . file - [optional] PETSc database file
268 - help - [optional] Help message to print, use `NULL` for no message
269
270 Note:
271 Works in the same way as `PetscInitialize()`, but in addition initializes SLEPc.
272 The same considerations apply with respect to command line options and
273 environment variables.
274
275 Fortran Notes:
276 In Fortran this routine can be called with
277 .vb
278 call SlepcInitialize(ierr)
279 .ve
280 .vb
281 call SlepcInitialize(file,ierr)
282 .ve
283 or
284 .vb
285 call SlepcInitialize(file,help,ierr)
286 .ve
287
288 If your main program is C but you call Fortran code that also uses SLEPc you need
289 to call `SlepcInitializeFortran()` soon after calling `SlepcInitialize()`.
290
291 Level: beginner
292
293 .seealso: [](sec:writing-prog), `SlepcFinalize()`, `PetscInitialize()`, `SlepcInitializeFortran()`
294 @*/
295 17176 PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[])
296 {
297 17176 PetscBool flg;
298
299
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
17176 PetscFunctionBegin;
300
8/14
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
17176 if (SlepcInitializeCalled) PetscFunctionReturn(PETSC_SUCCESS);
301
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17149 PetscCall(PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion));
302
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17149 PetscCall(PetscInitialized(&flg));
303
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
17149 if (!flg) {
304
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17092 PetscCall(PetscInitialize(argc,args,file,help));
305 17092 SlepcBeganPetsc = PETSC_TRUE;
306 }
307
308
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17149 PetscCall(SlepcCitationsInitialize());
309
310 /* Load the dynamic libraries (on machines that support them), this registers all the solvers etc. */
311
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17149 PetscCall(SlepcInitialize_DynamicLibraries());
312
313 17149 SlepcInitializeCalled = PETSC_TRUE;
314 17149 SlepcFinalizeCalled = PETSC_FALSE;
315
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17149 PetscCall(PetscInfo(0,"SLEPc successfully started\n"));
316
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
3278 PetscFunctionReturn(PETSC_SUCCESS);
317 }
318
319 /*@C
320 SlepcFinalize - Checks for options to be called at the conclusion
321 of the SLEPc program and calls `PetscFinalize()`.
322
323 Collective on `PETSC_COMM_WORLD`
324
325 Level: beginner
326
327 .seealso: [](sec:writing-prog), `SlepcInitialize()`, `PetscFinalize()`
328 @*/
329 17437 PetscErrorCode SlepcFinalize(void)
330 {
331
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
17437 PetscFunctionBegin;
332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
17437 if (PetscUnlikely(!SlepcInitializeCalled)) {
333 fprintf(PETSC_STDOUT,"SlepcInitialize() must be called before SlepcFinalize()\n");
334 PetscStackClearTop;
335 return PETSC_ERR_ARG_WRONGSTATE;
336 }
337
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
17437 PetscCall(PetscInfo(NULL,"SlepcFinalize() called\n"));
338
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
17437 if (SlepcBeganPetsc) {
339
2/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17390 PetscCall(PetscFinalize());
340 SlepcBeganPetsc = PETSC_FALSE;
341 }
342 47 SlepcInitializeCalled = PETSC_FALSE;
343 47 SlepcFinalizeCalled = PETSC_TRUE;
344
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
47 PetscStackClearTop;
345 47 return PETSC_SUCCESS;
346 }
347
348 /*@C
349 SlepcInitializeNoArguments - Calls `SlepcInitialize()` from C/C++ without
350 the command line arguments.
351
352 Collective
353
354 Level: advanced
355
356 .seealso: [](sec:writing-prog), `SlepcInitialize()`, `SlepcInitializeFortran()`
357 @*/
358 37 PetscErrorCode SlepcInitializeNoArguments(void) PeNS
359 {
360 37 int argc = 0;
361 37 char **args = NULL;
362
363
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
37 PetscFunctionBegin;
364
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
37 PetscCall(SlepcInitialize(&argc,&args,NULL,NULL));
365
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
29 PetscFunctionReturn(PETSC_SUCCESS);
366 }
367
368 /*@
369 SlepcInitialized - Determine whether SLEPc is initialized.
370
371 Output Parameter:
372 . isInitialized - the result
373
374 Level: beginner
375
376 .seealso: [](sec:writing-prog), `SlepcInitialize()`, `SlepcInitializeFortran()`
377 @*/
378 87 PetscErrorCode SlepcInitialized(PetscBool *isInitialized)
379 {
380
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
87 PetscFunctionBegin;
381 87 *isInitialized = SlepcInitializeCalled;
382
8/12
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
87 PetscFunctionReturn(PETSC_SUCCESS);
383 }
384
385 /*@
386 SlepcFinalized - Determine whether `SlepcFinalize()` has been called.
387
388 Output Parameter:
389 . isFinalized - the result
390
391 Level: beginner
392
393 .seealso: [](sec:writing-prog), `SlepcFinalize()`
394 @*/
395 30 PetscErrorCode SlepcFinalized(PetscBool *isFinalized)
396 {
397
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
30 PetscFunctionBegin;
398 30 *isFinalized = SlepcFinalizeCalled;
399
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
30 PetscFunctionReturn(PETSC_SUCCESS);
400 }
401
402 PETSC_EXTERN PetscBool PetscBeganMPI;
403
404 /*@C
405 SlepcInitializeNoPointers - Calls `SlepcInitialize()` from C/C++ without the pointers
406 to `argc` and `args`.
407
408 Collective
409
410 Input Parameters:
411 + argc - count of number of command line arguments
412 . args - the command line arguments
413 . file - [optional] PETSc database file
414 - help - [optional] Help message to print, use `NULL` for no message
415
416 Note:
417 Check the manual page of `PetscInitializeNoPointers()` for an explanation.
418
419 Level: advanced
420
421 .seealso: [](sec:writing-prog), `SlepcInitialize()`
422 @*/
423 PetscErrorCode SlepcInitializeNoPointers(int argc,char **args,const char *file,const char *help)
424 {
425 int myargc = argc;
426 char **myargs = args;
427
428 PetscFunctionBegin;
429 PetscCall(SlepcInitialize(&myargc,&myargs,file,help));
430 PetscCall(PetscPopSignalHandler());
431 PetscBeganMPI = PETSC_FALSE;
432 PetscFunctionReturn(PETSC_SUCCESS);
433 }
434