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
6
   Copyright (c) 2002-2009, 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"
986 slepc 25
#include "slepc.h"
26
#include "slepcst.h"
27
#include "slepceps.h"
1375 slepc 28
#include "slepcsvd.h"
29
#include "slepcip.h"
986 slepc 30
 
31
extern PetscTruth SlepcBeganPetsc;
32
 
1409 slepc 33
extern PetscTruth SlepcInitializeCalled;
986 slepc 34
 
35
#ifdef PETSC_HAVE_FORTRAN_CAPS
36
#define petscinitialize_              PETSCINITIALIZE
37
#define slepcinitialize_              SLEPCINITIALIZE
38
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
39
#define petscinitialize_              petscinitialize
40
#define slepcinitialize_              slepcinitialize
41
#endif
42
 
43
EXTERN_C_BEGIN
1021 slepc 44
extern void PETSC_STDCALL petscinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len));
986 slepc 45
EXTERN_C_END
46
 
47
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1363 slepc 48
extern PetscDLLibrary DLLibrariesLoaded;
986 slepc 49
#endif
50
 
51
EXTERN_C_BEGIN
52
/*
53
    SlepcInitialize - Version called from Fortran.
54
 
55
    Notes:
56
    Since this routine is called from Fortran it does not return error codes.
57
*/
1510 slepc 58
void PETSC_STDCALL slepcinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
986 slepc 59
{
60
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
61
  char       libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];
62
  PetscTruth found;
63
#endif
64
  *ierr = 1;
65
  if (SlepcInitializeCalled) {*ierr = 0; return;}
66
 
67
  if (!PetscInitializeCalled) {
1021 slepc 68
#if defined(PETSC_HAVE_FORTRAN_MIXED_STR_ARG)
986 slepc 69
    petscinitialize_(filename,len,ierr);
70
#else
71
    petscinitialize_(filename,ierr,len);
72
#endif
1021 slepc 73
    if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:PetscInitialize failed");return;}
986 slepc 74
    SlepcBeganPetsc = PETSC_TRUE;
75
  }
76
 
77
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
78
  *ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);if (*ierr) return;
79
  *ierr = PetscStrcat(libs,"/libslepc");if (*ierr) return;
80
  *ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,&found);if (*ierr) return;
81
  if (found) {
82
    *ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&DLLibrariesLoaded,libs);if (*ierr) return;
83
  } else {
84
    *ierr = 1;
1523 slepc 85
    (*PetscErrorPrintf)("Unable to locate SLEPc dynamic library %s \n",libs);
986 slepc 86
    return;
87
  }
88
#else
1021 slepc 89
  *ierr = STInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing ST package");return;}
90
  *ierr = EPSInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing EPS package");return;}
1375 slepc 91
  *ierr = SVDInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing SVD package");return;}
92
  *ierr = IPInitializePackage(PETSC_NULL); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing IP package");return;}
986 slepc 93
#endif
94
 
95
  SlepcInitializeCalled = PETSC_TRUE;
1038 slepc 96
  *ierr = PetscInfo(0,"SLEPc successfully started from Fortran\n");
1037 slepc 97
  if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Calling PetscInfo()");return;}
986 slepc 98
 
99
}  
100
 
101
EXTERN_C_END