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 PetscRandom rctx;
18: extern int ST_COOKIE;
19: extern int EPS_COOKIE;
21: static PetscTruth SlepcInitializeCalled=PETSC_FALSE;
23: #if defined(PETSC_HAVE_NAGF90)
24: #define iargc_ f90_unix_MP_iargc
25: #define getarg_ f90_unix_MP_getarg
26: #endif
28: #ifdef PETSC_HAVE_FORTRAN_CAPS
29: #define petscinitialize_ PETSCINITIALIZE
30: #define slepcinitialize_ SLEPCINITIALIZE
31: #define iargc_ IARGC
32: #define getarg_ GETARG
33: #if defined(PARCH_win32)
34: #define IARGC NARGS
35: #endif
37: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
38: #define petscinitialize_ petscinitialize
39: #define slepcinitialize_ slepcinitialize
40: /*
41: HP-UX does not have Fortran underscore but iargc and getarg
42: do have underscores????
43: */
44: #if !defined(PETSC_HAVE_FORTRAN_IARGC_UNDERSCORE)
45: #define iargc_ iargc
46: #define getarg_ getarg
47: #endif
49: #endif
51: EXTERN_C_BEGIN
52: extern void PETSC_STDCALL mpi_init_(int*);
54: #if defined(PETSC_USE_FORTRAN_MIXED_STR_ARG)
55: extern void petscinitialize_(CHAR,int,int*);
56: #else
57: extern void petscinitialize_(CHAR,int*,int);
58: #endif
60: /*
61: Different Fortran compilers handle command lines in different ways
62: */
63: #if defined(PARCH_win32)
64: /*
65: extern short __declspec(dllimport) __stdcall iargc_();
66: extern void __declspec(dllimport) __stdcall getarg_(short*,char*,int,short *);
67: */
68: extern short __stdcall iargc_();
69: extern void __stdcall getarg_(short*,char*,int,short *);
71: #else
72: extern int iargc_();
73: extern void getarg_(int*,char*,int);
74: /*
75: The Cray T3D/T3E use the PXFGETARG() function
76: */
77: #if defined(PETSC_HAVE_PXFGETARG)
78: extern void PXFGETARG(int *,_fcd,int*,int*);
79: #endif
80: #endif
81: EXTERN_C_END
83: extern int SlepcRegisterEvents();
85: EXTERN_C_BEGIN
86: /*
87: SlepcInitialize - Version called from Fortran.
89: Notes:
90: Since this routine is called from Fortran it does not return error codes.
91: */
92: void PETSC_STDCALL slepcinitialize_(CHAR filename PETSC_MIXED_LEN(len),int *ierr PETSC_END_LEN(len))
93: {
94: *1;
95: if (SlepcInitializeCalled) {*0; return;}
97: if (!PetscInitializeCalled) {
98: #if defined(PETSC_USE_FORTRAN_MIXED_STR_ARG)
99: petscinitialize_(filename,len,ierr);
100: #else
101: petscinitialize_(filename,ierr,len);
102: #endif
103: if (*ierr) return;
104: SlepcBeganPetsc = PETSC_TRUE;
105: }
107: PetscRandomCreate(PETSC_COMM_WORLD,RANDOM_DEFAULT,&rctx);
109: EPS_COOKIE = 0;
110: PetscLogClassRegister(&EPS_COOKIE,"Eigenproblem Solver");
111: ST_COOKIE = 0;
112: PetscLogClassRegister(&ST_COOKIE,"Spectral Transform");
114: *SlepcRegisterEvents();
116: SlepcInitializeCalled = PETSC_TRUE;
117: PetscLogInfo(0,"SlepcInitialize: SLEPc successfully started from Fortran\n");
119: }
121: EXTERN_C_END