xref: /petsc/src/sys/fileio/ftn-custom/zsysiof.c (revision a9acdec706a421f16b453f642779436a4561f6fb)
1af0996ceSBarry Smith #include <petsc/private/fortranimpl.h>
255fcb7f5SSatish Balay 
355fcb7f5SSatish Balay #if defined(PETSC_HAVE_FORTRAN_CAPS)
455fcb7f5SSatish Balay #define petscbinaryopen_           PETSCBINARYOPEN
59860990eSLisandro Dalcin #define petscbinaryread_           PETSCBINARYREAD
6c1bccaadSBarry Smith #define petsctestfile_             PETSCTESTFILE
7*a9acdec7SBarry Smith #define petscbinarywrite_          PETSCBINARYWRITE
855fcb7f5SSatish Balay #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
9*a9acdec7SBarry Smith #define petscbinarywrite_          petscbinarywrite
1055fcb7f5SSatish Balay #define petscbinaryopen_           petscbinaryopen
119860990eSLisandro Dalcin #define petscbinaryread_           petscbinaryread
12a8cc4164SSatish Balay #define petsctestfile_             petsctestfile
1355fcb7f5SSatish Balay #endif
1455fcb7f5SSatish Balay 
15*a9acdec7SBarry Smith /* Definitions of Fortran Wrapper routines */
16*a9acdec7SBarry Smith #if defined(__cplusplus)
17*a9acdec7SBarry Smith extern "C" {
18*a9acdec7SBarry Smith #endif
19*a9acdec7SBarry Smith 
20*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinarywriteint_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
21*a9acdec7SBarry Smith {
22*a9acdec7SBarry Smith   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
23*a9acdec7SBarry Smith }
24*a9acdec7SBarry Smith 
25*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinarywritereal_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
26*a9acdec7SBarry Smith {
27*a9acdec7SBarry Smith   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
28*a9acdec7SBarry Smith }
29*a9acdec7SBarry Smith 
30*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinarywritecomplex_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
31*a9acdec7SBarry Smith {
32*a9acdec7SBarry Smith   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
33*a9acdec7SBarry Smith }
34*a9acdec7SBarry Smith 
35*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinarywriteint1_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
36*a9acdec7SBarry Smith {
37*a9acdec7SBarry Smith   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
38*a9acdec7SBarry Smith }
39*a9acdec7SBarry Smith 
40*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinarywritereal1_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
41*a9acdec7SBarry Smith {
42*a9acdec7SBarry Smith   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
43*a9acdec7SBarry Smith }
44*a9acdec7SBarry Smith 
45*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinarywritecomplex1_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
46*a9acdec7SBarry Smith {
47*a9acdec7SBarry Smith   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
48*a9acdec7SBarry Smith }
49*a9acdec7SBarry Smith 
50390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL petscbinaryopen_(char* name PETSC_MIXED_LEN(len),PetscFileMode *type,int *fd,
5155fcb7f5SSatish Balay                                     PetscErrorCode *ierr PETSC_END_LEN(len))
5255fcb7f5SSatish Balay {
5355fcb7f5SSatish Balay   char *c1;
5455fcb7f5SSatish Balay 
5555fcb7f5SSatish Balay   FIXCHAR(name,len,c1);
56d49bb8f9SBarry Smith   *ierr = PetscBinaryOpen(c1,*type,fd);if (*ierr) return;
5755fcb7f5SSatish Balay   FREECHAR(name,c1);
5855fcb7f5SSatish Balay }
5955fcb7f5SSatish Balay 
60*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadint_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
61*a9acdec7SBarry Smith {
62*a9acdec7SBarry Smith   CHKFORTRANNULLINTEGER(count);
63*a9acdec7SBarry Smith   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
64*a9acdec7SBarry Smith }
65*a9acdec7SBarry Smith 
66*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadreal_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
67*a9acdec7SBarry Smith {
68*a9acdec7SBarry Smith   CHKFORTRANNULLINTEGER(count);
69*a9acdec7SBarry Smith   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
70*a9acdec7SBarry Smith }
71*a9acdec7SBarry Smith 
72*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadcomplex_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
73*a9acdec7SBarry Smith {
74*a9acdec7SBarry Smith   CHKFORTRANNULLINTEGER(count);
75*a9acdec7SBarry Smith   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
76*a9acdec7SBarry Smith }
77*a9acdec7SBarry Smith 
78*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadint1_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
79*a9acdec7SBarry Smith {
80*a9acdec7SBarry Smith   CHKFORTRANNULLINTEGER(count);
81*a9acdec7SBarry Smith   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
82*a9acdec7SBarry Smith }
83*a9acdec7SBarry Smith 
84*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadreal1_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
85*a9acdec7SBarry Smith {
86*a9acdec7SBarry Smith   CHKFORTRANNULLINTEGER(count);
87*a9acdec7SBarry Smith   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
88*a9acdec7SBarry Smith }
89*a9acdec7SBarry Smith 
90*a9acdec7SBarry Smith PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadcomplex1_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
919860990eSLisandro Dalcin {
929860990eSLisandro Dalcin   CHKFORTRANNULLINTEGER(count);
939860990eSLisandro Dalcin   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
949860990eSLisandro Dalcin }
959860990eSLisandro Dalcin 
96390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL petsctestfile_(char* name PETSC_MIXED_LEN(len),char* mode PETSC_MIXED_LEN(len1),PetscBool *flg,PetscErrorCode *ierr PETSC_END_LEN(len) PETSC_END_LEN(len1))
97c1bccaadSBarry Smith {
98ca43db0aSBarry Smith   char *c1;
99c1bccaadSBarry Smith 
100c1bccaadSBarry Smith   FIXCHAR(name,len,c1);
101d49bb8f9SBarry Smith   *ierr = PetscTestFile(c1,*mode,flg);if (*ierr) return;
102c1bccaadSBarry Smith   FREECHAR(name,c1);
103c1bccaadSBarry Smith }
104