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
6 dsic.upv.es!jroman 1
 
183 dsic.upv.es!antodo 2
#include "slepc.h" /*I "slepc.h" I*/
341 dsic.upv.es!antodo 3
#include "slepceps.h"
4
#include "slepcst.h"
1249 slepc 5
#include "slepcsvd.h"
1302 slepc 6
#include "slepcip.h"
1167 slepc 7
#include <stdlib.h>
6 dsic.upv.es!jroman 8
 
9
#undef __FUNCT__  
10
#define __FUNCT__ "SlepcPrintVersion"
11
/*
12
   SlepcPrintVersion - Prints SLEPc version info.
13
 
14
   Collective on MPI_Comm
15
*/
476 dsic.upv.es!antodo 16
PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
6 dsic.upv.es!jroman 17
{
18
  int  info = 0;
19
 
20
  PetscFunctionBegin;
21
 
22
  info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
23
------------------------------\n"); CHKERRQ(info);
1077 slepc 24
#if (PETSC_VERSION_RELEASE == 1)
25
  info = (*PetscHelpPrintf)(comm,"SLEPc Release Version %d.%d.%d-%d, %s\n",
26
#else
27
  info = (*PetscHelpPrintf)(comm,"SLEPc Development Version %d.%d.%d-%d, %s\n",
28
#endif
29
    SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_PATCH,SLEPC_VERSION_PATCH_DATE); CHKERRQ(info);
30
  info = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO); CHKERRQ(info);
761 dsic.upv.es!jroman 31
  info = (*PetscHelpPrintf)(comm,"See docs/manual.html for help. \n"); CHKERRQ(info);
6 dsic.upv.es!jroman 32
#if !defined(PARCH_win32)
33
  info = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR); CHKERRQ(info);
34
#endif
35
  info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
36
------------------------------\n"); CHKERRQ(info);
37
 
38
  PetscFunctionReturn(info);
39
}
40
 
41
#undef __FUNCT__  
42
#define __FUNCT__ "SlepcPrintHelpIntro"
43
/*
44
   SlepcPrintHelpIntro - Prints introductory SLEPc help info.
45
 
46
   Collective on MPI_Comm
47
*/
476 dsic.upv.es!antodo 48
PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
6 dsic.upv.es!jroman 49
{
50
  int  info = 0;
51
 
52
  PetscFunctionBegin;
53
 
54
  info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
55
------------------------------\n"); CHKERRQ(info);
56
  info = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n"); CHKERRQ(info);
57
  info = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n"); CHKERRQ(info);
58
  info = (*PetscHelpPrintf)(comm,"--------------------------------------------\
59
------------------------------\n"); CHKERRQ(info);
60
 
61
  PetscFunctionReturn(info);
62
}
63
 
64
/* ------------------------Nasty global variables -------------------------------*/
65
/*
66
   Indicates whether SLEPc started PETSc, or whether it was
67
   already started before SLEPc was initialized.
68
*/
69
PetscTruth  SlepcBeganPetsc = PETSC_FALSE;
70
PetscTruth  SlepcInitializeCalled = PETSC_FALSE;
71
 
72
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
73
extern PetscDLLibraryList DLLibrariesLoaded;
74
#endif
75
 
76
#undef __FUNCT__  
77
#define __FUNCT__ "SlepcInitialize"
78
/*@C
79
   SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
80
   PetscInitialize() if that has not been called yet, so this routine should
81
   always be called near the beginning of your program.
82
 
83
   Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set
84
 
85
   Input Parameters:
86
+  argc - count of number of command line arguments
87
.  args - the command line arguments
88
.  file - [optional] PETSc database file, defaults to ~username/.petscrc
89
          (use PETSC_NULL for default)
90
-  help - [optional] Help message to print, use PETSC_NULL for no message
91
 
92
   Fortran Note:
93
   Fortran syntax is very similar to that of PetscInitialize()
94
 
95
   Level: beginner
96
 
97
.seealso: SlepcInitializeFortran(), SlepcFinalize(), PetscInitialize()
98
@*/
476 dsic.upv.es!antodo 99
PetscErrorCode SlepcInitialize(int *argc,char ***args,char file[],const char help[])
6 dsic.upv.es!jroman 100
{
842 dsic.upv.es!antodo 101
  PetscErrorCode ierr;
102
  PetscErrorCode info=0;
373 dsic.upv.es!antodo 103
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
476 dsic.upv.es!antodo 104
  char           libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
105
  PetscTruth     found;
373 dsic.upv.es!antodo 106
#endif
6 dsic.upv.es!jroman 107
 
108
  PetscFunctionBegin;
109
 
110
  if (SlepcInitializeCalled==PETSC_TRUE) {
111
    PetscFunctionReturn(0);
112
  }
113
 
114
#if !defined(PARCH_t3d)
115
  info = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(info);
116
#endif
117
 
118
  if (!PetscInitializeCalled) {
119
    info = PetscInitialize(argc,args,file,help);CHKERRQ(info);
120
    SlepcBeganPetsc = PETSC_TRUE;
121
  }
122
 
123
  /*
124
      Load the dynamic libraries
125
  */
126
 
127
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
128
  ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);CHKERRQ(ierr);
129
  ierr = PetscStrcat(libs,"/libslepc");CHKERRQ(ierr);
130
  ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);CHKERRQ(ierr);
131
  if (found) {
132
    ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);CHKERRQ(ierr);
133
  } else {
134
    SETERRQ1(1,"Unable to locate SLEPc dynamic library %s \n You cannot move the dynamic libraries!\n or remove USE_DYNAMIC_LIBRARIES from ${PETSC_DIR}/bmake/$PETSC_ARCH/petscconf.h\n and rebuild libraries before moving",libs);
135
  }
136
#else
842 dsic.upv.es!antodo 137
  ierr = STInitializePackage(PETSC_NULL); CHKERRQ(ierr);
138
  ierr = EPSInitializePackage(PETSC_NULL); CHKERRQ(ierr);
1249 slepc 139
  ierr = SVDInitializePackage(PETSC_NULL); CHKERRQ(ierr);
1302 slepc 140
  ierr = IPInitializePackage(PETSC_NULL); CHKERRQ(ierr);
6 dsic.upv.es!jroman 141
#endif
142
 
1166 slepc 143
#if defined(PETSC_HAVE_DRAND48)
144
  /* work-around for Cygwin drand48() initialization bug */
145
  srand48(0);
146
#endif
147
 
6 dsic.upv.es!jroman 148
  SlepcInitializeCalled = PETSC_TRUE;
1038 slepc 149
  PetscInfo(0,"SLEPc successfully started\n");
6 dsic.upv.es!jroman 150
  PetscFunctionReturn(info);
151
}
152
 
153
#undef __FUNCT__  
154
#define __FUNCT__ "SlepcFinalize"
155
/*@
156
   SlepcFinalize - Checks for options to be called at the conclusion
157
   of the SLEPc program and calls PetscFinalize().
158
 
159
   Collective on PETSC_COMM_WORLD
160
 
161
   Level: beginner
162
 
163
.seealso: SlepcInitialize(), PetscFinalize()
164
@*/
476 dsic.upv.es!antodo 165
PetscErrorCode SlepcFinalize(void)
6 dsic.upv.es!jroman 166
{
572 dsic.upv.es!antodo 167
  PetscErrorCode info=0;
6 dsic.upv.es!jroman 168
 
169
  PetscFunctionBegin;
1038 slepc 170
  PetscInfo(0,"SLEPc successfully ended!\n");
6 dsic.upv.es!jroman 171
 
172
  if (SlepcBeganPetsc) {
173
    info = PetscFinalize();CHKERRQ(info);
174
  }
175
 
176
  SlepcInitializeCalled = PETSC_FALSE;
177
 
178
  PetscFunctionReturn(info);
179
}
180
 
842 dsic.upv.es!antodo 181
#ifdef PETSC_USE_DYNAMIC_LIBRARIES
182
EXTERN_C_BEGIN
183
#undef __FUNCT__  
184
#define __FUNCT__ "PetscDLLibraryRegister_slepc"
185
/*
186
  PetscDLLibraryRegister - This function is called when the dynamic library
187
  it is in is opened.
188
 
189
  This one registers all the EPS and ST methods in the libslepc.a
190
  library.
191
 
192
  Input Parameter:
193
  path - library path
194
 */
195
PetscErrorCode PetscDLLibraryRegister_slepc(char *path)
196
{
197
  PetscErrorCode ierr;
198
 
199
  ierr = PetscInitializeNoArguments(); if (ierr) return 1;
200
 
201
  PetscFunctionBegin;
202
  /*
203
      If we got here then PETSc was properly loaded
204
  */
205
  ierr = STInitializePackage(path); CHKERRQ(ierr);
206
  ierr = EPSInitializePackage(path); CHKERRQ(ierr);
1250 slepc 207
  ierr = SVDInitializePackage(path); CHKERRQ(ierr);
842 dsic.upv.es!antodo 208
  PetscFunctionReturn(0);
209
}
210
EXTERN_C_END
211
 
212
#endif /* PETSC_USE_DYNAMIC_LIBRARIES */