Actual source code: zslepc_start.c
1: /*
2: This file contains the Fortran version of SlepcInitialize().
3: */
5: /*
6: This is to prevent the Cray T3D version of MPI (University of Edinburgh)
7: from redefining MPI_INIT(). They put this in to detect errors in C code,
8: but here we do want to be calling the Fortran version from a C subroutine.
9: */
10: #define T3DMPI_FORTRAN
11: #define T3EMPI_FORTRAN
13: #include "src/fortran/custom/zpetsc.h"
14: #include slepc.h
16: extern PetscTruth SlepcBeganPetsc;
17: extern PetscCookie ST_COOKIE;
18: extern PetscCookie EPS_COOKIE;
20: static PetscTruth SlepcInitializeCalled=PETSC_FALSE;
22: #if defined(PETSC_HAVE_NAGF90)
23: #define iargc_ f90_unix_MP_iargc
24: #define getarg_ f90_unix_MP_getarg
25: #endif
27: #ifdef PETSC_HAVE_FORTRAN_CAPS
28: #define petscinitialize_ PETSCINITIALIZE
29: #define slepcinitialize_ SLEPCINITIALIZE
30: #define iargc_ IARGC
31: #define getarg_ GETARG
32: #if defined(PARCH_win32)
33: #define IARGC NARGS
34: #endif
36: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
37: #define petscinitialize_ petscinitialize
38: #define slepcinitialize_ slepcinitialize
39: /*
40: HP-UX does not have Fortran underscore but iargc and getarg
41: do have underscores????
42: */
43: #if !defined(PETSC_HAVE_FORTRAN_IARGC_UNDERSCORE)
44: #define iargc_ iargc
45: #define getarg_ getarg
46: #endif
48: #endif
50: EXTERN_C_BEGIN
51: extern void PETSC_STDCALL mpi_init_(int*);
53: #if defined(PETSC_USE_FORTRAN_MIXED_STR_ARG)
54: extern void petscinitialize_(CHAR,int,int*);
55: #else
56: extern void petscinitialize_(CHAR,int*,int);
57: #endif
59: /*
60: Different Fortran compilers handle command lines in different ways
61: */
62: #if defined(PARCH_win32)
63: /*
64: extern short __declspec(dllimport) __stdcall iargc_();
65: extern void __declspec(dllimport) __stdcall getarg_(short*,char*,int,short *);
66: */
67: extern short __stdcall iargc_();
68: extern void __stdcall getarg_(short*,char*,int,short *);
70: #else
71: extern int iargc_();
72: extern void getarg_(int*,char*,int);
73: /*
74: The Cray T3D/T3E use the PXFGETARG() function
75: */
76: #if defined(PETSC_HAVE_PXFGETARG)
77: extern void PXFGETARG(int *,_fcd,int*,int*);
78: #endif
79: #endif
80: EXTERN_C_END
82: extern int SlepcRegisterEvents();
84: EXTERN_C_BEGIN
85: /*
86: SlepcInitialize - Version called from Fortran.
88: Notes:
89: Since this routine is called from Fortran it does not return error codes.
90: */
91: void PETSC_STDCALL slepcinitialize_(CHAR filename PETSC_MIXED_LEN(len),int *ierr PETSC_END_LEN(len))
92: {
93: *1;
94: if (SlepcInitializeCalled) {*0; return;}
96: if (!PetscInitializeCalled) {
97: #if defined(PETSC_USE_FORTRAN_MIXED_STR_ARG)
98: petscinitialize_(filename,len,ierr);
99: #else
100: petscinitialize_(filename,ierr,len);
101: #endif
102: if (*ierr) return;
103: SlepcBeganPetsc = PETSC_TRUE;
104: }
106: EPS_COOKIE = 0;
107: PetscLogClassRegister(&EPS_COOKIE,"Eigenproblem Solver");
108: ST_COOKIE = 0;
109: PetscLogClassRegister(&ST_COOKIE,"Spectral Transform");
111: *SlepcRegisterEvents();
113: SlepcInitializeCalled = PETSC_TRUE;
114: PetscLogInfo(0,"SlepcInitialize: SLEPc successfully started from Fortran\n");
116: }
118: EXTERN_C_END