Subversion Repositories slepc-dev

Rev

Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
986 slepc 1
/*
2
  This file contains the Fortran version of SlepcInitialize().
1376 slepc 3
 
4
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1672 slepc 5
   SLEPc - Scalable Library for Eigenvalue Problem Computations
2116 eromero 6
   Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
1376 slepc 7
 
1672 slepc 8
   This file is part of SLEPc.
9
 
10
   SLEPc is free software: you can redistribute it and/or modify it under  the
11
   terms of version 3 of the GNU Lesser General Public License as published by
12
   the Free Software Foundation.
13
 
14
   SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
15
   WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
16
   FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
17
   more details.
18
 
19
   You  should have received a copy of the GNU Lesser General  Public  License
20
   along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
1376 slepc 21
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
986 slepc 22
*/
23
 
1469 slepc 24
#include "private/fortranimpl.h"
1885 jroman 25
#include "slepcsys.h"
1853 antodo 26
#include "private/epsimpl.h"
27
#include "private/stimpl.h"
28
#include "private/svdimpl.h"
29
#include "private/ipimpl.h"
1882 jroman 30
#include <stdlib.h>
986 slepc 31
 
32
extern PetscTruth SlepcBeganPetsc;
1409 slepc 33
extern PetscTruth SlepcInitializeCalled;
1882 jroman 34
extern PetscLogEvent SLEPC_UpdateVectors;
986 slepc 35
 
36
#ifdef PETSC_HAVE_FORTRAN_CAPS
37
#define petscinitialize_              PETSCINITIALIZE
38
#define slepcinitialize_              SLEPCINITIALIZE
39
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
40
#define petscinitialize_              petscinitialize
41
#define slepcinitialize_              slepcinitialize
42
#endif
43
 
44
EXTERN_C_BEGIN
1021 slepc 45
extern void PETSC_STDCALL petscinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len));
986 slepc 46
EXTERN_C_END
47
 
48
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1363 slepc 49
extern PetscDLLibrary DLLibrariesLoaded;
986 slepc 50
#endif
51
 
52
EXTERN_C_BEGIN
53
/*
54
    SlepcInitialize - Version called from Fortran.
55
 
56
    Notes:
57
    Since this routine is called from Fortran it does not return error codes.
58
*/
1510 slepc 59
void PETSC_STDCALL slepcinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
986 slepc 60
{
61
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
62
  char       libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
63
  PetscTruth found;
64
#endif
65
  *ierr = 1;
66
  if (SlepcInitializeCalled) {*ierr = 0; return;}
67
 
68
  if (!PetscInitializeCalled) {
1021 slepc 69
#if defined(PETSC_HAVE_FORTRAN_MIXED_STR_ARG)
986 slepc 70
    petscinitialize_(filename,len,ierr);
71
#else
72
    petscinitialize_(filename,ierr,len);
73
#endif
1021 slepc 74
    if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:PetscInitialize failed");return;}
986 slepc 75
    SlepcBeganPetsc = PETSC_TRUE;
76
  }
77
 
78
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
79
  *ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);if (*ierr) return;
80
  *ierr = PetscStrcat(libs,"/libslepc");if (*ierr) return;
81
  *ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);if (*ierr) return;
82
  if (found) {
83
    *ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);if (*ierr) return;
84
  } else {
85
    *ierr = 1;
1523 slepc 86
    (*PetscErrorPrintf)("Unable to locate SLEPc dynamic library %s \n",libs);
986 slepc 87
    return;
88
  }
89
#else
1021 slepc 90
  *ierr = STInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing ST package");return;}
91
  *ierr = EPSInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing EPS package");return;}
1375 slepc 92
  *ierr = SVDInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing SVD package");return;}
93
  *ierr = IPInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing IP package");return;}
986 slepc 94
#endif
95
 
1882 jroman 96
  *ierr = PetscLogEventRegister("UpdateVectors",0,&SLEPC_UpdateVectors); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Registering log event");return;}
97
 
98
#if defined(PETSC_HAVE_DRAND48)
99
  /* work-around for Cygwin drand48() initialization bug */
100
  srand48(0);
101
#endif
102
 
986 slepc 103
  SlepcInitializeCalled = PETSC_TRUE;
1038 slepc 104
  *ierr = PetscInfo(0,"SLEPc successfully started from Fortran\n");
1037 slepc 105
  if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Calling PetscInfo()");return;}
986 slepc 106
 
107
}  
108
 
109
EXTERN_C_END