Subversion Repositories slepc-dev

Rev

Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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;
2206 eromero 92
extern PetscLogEvent SLEPC_UpdateVectors, SLEPC_VecMAXPBY, SLEPC_SlepcDenseMatProd, SLEPC_SlepcDenseOrth,
93
                     SLEPC_SlepcDenseMatInvProd, SLEPC_SlepcDenseNorm, SLEPC_SlepcDenseCopy, SLEPC_VecsMult;
6 dsic.upv.es!jroman 94
 
95
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1354 slepc 96
extern PetscDLLibrary DLLibrariesLoaded;
6 dsic.upv.es!jroman 97
#endif
98
 
99
#undef __FUNCT__  
100
#define __FUNCT__ "SlepcInitialize"
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.
105
 
106
   Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
107
 
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
114
 
115
   Fortran Note:
116
   Fortran syntax is very similar to that of PetscInitialize()
117
 
118
   Level: beginner
119
 
120
.seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
121
@*/
476 dsic.upv.es!antodo 122
PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
6 dsic.upv.es!jroman 123
{
842 dsic.upv.es!antodo 124
  PetscErrorCode ierr;
125
  PetscErrorCode info=0;
373 dsic.upv.es!antodo 126
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
476 dsic.upv.es!antodo 127
  char           libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
128
  PetscTruth     found;
373 dsic.upv.es!antodo 129
#endif
6 dsic.upv.es!jroman 130
 
131
  PetscFunctionBegin;
132
 
1609 slepc 133
  if (SlepcInitializeCalled) {
6 dsic.upv.es!jroman 134
    PetscFunctionReturn(0);
135
  }
136
 
137
#if !defined(PARCH_t3d)
138
  info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
139
#endif
140
 
141
  if (!PetscInitializeCalled) {
142
    info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
143
    SlepcBeganPetsc = PETSC_TRUE;
144
  }
145
 
146
  /*
147
      Load the dynamic libraries
148
  */
149
 
150
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
151
  ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);CHKERRQ(ierr);
152
  ierr = PetscStrcat(libs,"/libslepc");CHKERRQ(ierr);
153
  ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);CHKERRQ(ierr);
154
  if (found) {
155
    ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);CHKERRQ(ierr);
156
  } else {
1523 slepc 157
    SETERRQ1(1,"Unable to locate SLEPc dynamic library %s \n",libs);
6 dsic.upv.es!jroman 158
  }
159
#else
842 dsic.upv.es!antodo 160
  ierr = STInitializePackage(PETSC_NULL); CHKERRQ(ierr);
161
  ierr = EPSInitializePackage(PETSC_NULL); CHKERRQ(ierr);
1249 slepc 162
  ierr = SVDInitializePackage(PETSC_NULL); CHKERRQ(ierr);
1887 jroman 163
  ierr = QEPInitializePackage(PETSC_NULL); CHKERRQ(ierr);
1302 slepc 164
  ierr = IPInitializePackage(PETSC_NULL); CHKERRQ(ierr);
6 dsic.upv.es!jroman 165
#endif
166
 
1601 slepc 167
  ierr = PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors);CHKERRQ(ierr);
1755 antodo 168
  ierr = PetscLogEventRegister("VecMAXPBY",0,&SLEPC_VecMAXPBY);CHKERRQ(ierr);
2213 jroman 169
  ierr = PetscLogEventRegister("DenseMatProd", EPS_CLASSID, &SLEPC_SlepcDenseMatProd); CHKERRQ(ierr);
170
  ierr = PetscLogEventRegister("DenseOrth", EPS_CLASSID, &SLEPC_SlepcDenseOrth); CHKERRQ(ierr);
171
  ierr = PetscLogEventRegister("DenseMatInvProd", EPS_CLASSID, &SLEPC_SlepcDenseMatInvProd); CHKERRQ(ierr);
172
  ierr = PetscLogEventRegister("DenseMatNorm", EPS_CLASSID, &SLEPC_SlepcDenseNorm); CHKERRQ(ierr);
173
  ierr = PetscLogEventRegister("DenseCopy", EPS_CLASSID, &SLEPC_SlepcDenseCopy); CHKERRQ(ierr);
174
  ierr = PetscLogEventRegister("VecsMult", EPS_CLASSID, &SLEPC_VecsMult); CHKERRQ(ierr);
1601 slepc 175
 
1166 slepc 176
#if defined(PETSC_HAVE_DRAND48)
177
  /* work-around for Cygwin drand48() initialization bug */
178
  srand48(0);
179
#endif
180
 
6 dsic.upv.es!jroman 181
  SlepcInitializeCalled = PETSC_TRUE;
1038 slepc 182
  PetscInfo(0,"SLEPc successfully started\n");
6 dsic.upv.es!jroman 183
  PetscFunctionReturn(info);
184
}
185
 
186
#undef __FUNCT__  
187
#define __FUNCT__ "SlepcFinalize"
188
/*@
189
   SlepcFinalize - Checks for options to be called at the conclusion
190
   of the SLEPc program and calls PetscFinalize().
191
 
192
   Collective on PETSC_COMM_WORLD
193
 
194
   Level: beginner
195
 
196
.seealso: SlepcInitialize(), PetscFinalize()
197
@*/
476 dsic.upv.es!antodo 198
PetscErrorCode SlepcFinalize(void)
6 dsic.upv.es!jroman 199
{
572 dsic.upv.es!antodo 200
  PetscErrorCode info=0;
6 dsic.upv.es!jroman 201
 
202
  PetscFunctionBegin;
1038 slepc 203
  PetscInfo(0,"SLEPc successfully ended!\n");
6 dsic.upv.es!jroman 204
 
205
  if (SlepcBeganPetsc) {
206
    info = PetscFinalize();CHKERRQ(info);
207
  }
208
 
209
  SlepcInitializeCalled = PETSC_FALSE;
210
 
211
  PetscFunctionReturn(info);
212
}
213
 
842 dsic.upv.es!antodo 214
#ifdef PETSC_USE_DYNAMIC_LIBRARIES
215
EXTERN_C_BEGIN
216
#undef __FUNCT__  
217
#define __FUNCT__ "PetscDLLibraryRegister_slepc"
218
/*
219
  PetscDLLibraryRegister - This function is called when the dynamic library
220
  it is in is opened.
221
 
222
  This one registers all the EPS and ST methods in the libslepc.a
223
  library.
224
 
225
  Input Parameter:
226
  path - library path
227
 */
228
PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
229
{
230
  PetscErrorCode ierr;
231
 
232
  ierr = PetscInitializeNoArguments(); if (ierr) return 1;
233
 
234
  PetscFunctionBegin;
235
  /*
236
      If we got here then PETSc was properly loaded
237
  */
238
  ierr = STInitializePackage(path); CHKERRQ(ierr);
239
  ierr = EPSInitializePackage(path); CHKERRQ(ierr);
1250 slepc 240
  ierr = SVDInitializePackage(path); CHKERRQ(ierr);
1887 jroman 241
  ierr = QEPInitializePackage(path); CHKERRQ(ierr);
1354 slepc 242
  ierr = IPInitializePackage(path); CHKERRQ(ierr);
842 dsic.upv.es!antodo 243
  PetscFunctionReturn(0);
244
}
245
EXTERN_C_END
246
 
247
#endif /* PETSC_USE_DYNAMIC_LIBRARIES */