xref: /petsc/src/sys/fileio/ftn-custom/zsysiof.c (revision 18d1adefffea661e60e6680fc855c731754765cd)
1 #include <petsc/private/fortranimpl.h>
2 
3 #if defined(PETSC_HAVE_FORTRAN_CAPS)
4 #define petscbinaryopen_            PETSCBINARYOPEN
5 #define petsctestfile_              PETSCTESTFILE
6 #define petscbinaryreadint_         PETSCBINARYREADINT
7 #define petscbinaryreadreal_        PETSCBINARYREADREAL
8 #define petscbinaryreadcomplex_     PETSCBINARYREADCOMPLEX
9 #define petscbinaryreadrealcnt_     PETSCBINARYREADREALCNT
10 #define petscbinaryreadcomplexcnt_  PETSCBINARYREADCOMPLEXCNT
11 #define petscbinaryreadint1_        PETSCBINARYREADINT1
12 #define petscbinaryreadread1_       PETSCBINARYREADREAL1
13 #define petscbinaryreadcomplex1_    PETSCBINARYREADCOMPLEX1
14 #define petscbinaryreadintcnt1_     PETSCBINARYREADINT1CNT
15 #define petscbinaryreadrealcnt1_    PETSCBINARYREADREAL1CNT
16 #define petscbinaryreadcomplexcnt1_ PETSCBINARYREADCOMPLEX1CNT
17 #define petscbinarywriteint_        PETSCBINARYWRITEINT
18 #define petscbinarywritereal_       PETSCBINARYWRITEREAL
19 #define petscbinarywritecomplex_    PETSCBINARYWRITECOMPLEX
20 #define petscbinarywriteint1_       PETSCBINARYWRITEINT1
21 #define petscbinarywritereal1_      PETSCBINARYWRITEREAL1
22 #define petscbinarywritecomplex1_   PETSCBINARYWRITECOMPLEX1
23 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
24 #define petscbinaryopen_            petscbinaryopen
25 #define petsctestfile_              petsctestfile
26 #define petscbinaryreadint_         petscbinaryreadint
27 #define petscbinaryreadreal_        petscbinaryreadreal
28 #define petscbinaryreadcomplex_     petscbinaryreadcomplex
29 #define petscbinaryreadrealcnt_     petscbinaryreadrealcnt
30 #define petscbinaryreadcomplexcnt_  petscbinaryreadcomplexcnt
31 #define petscbinaryreadint1_        petscbinaryreadint1
32 #define petscbinaryreadread1_       petscbinaryreadread1
33 #define petscbinaryreadcomplex1_    petscbinaryreadcomplex1
34 #define petscbinaryreadintcnt1_     petscbinaryreadintcnt1
35 #define petscbinaryreadrealcnt1_    petscbinaryreadrealcnt1
36 #define petscbinaryreadcomplexcnt1_ petscbinaryreadcomplexcnt1
37 #define petscbinarywriteint_        petscbinarywriteint
38 #define petscbinarywritereal_       petscbinarywritereal
39 #define petscbinarywritecomplex_    petscbinarywritecomplex
40 #define petscbinarywriteint1_       petscbinarywriteint1
41 #define petscbinarywritereal1_      petscbinarywritereal1
42 #define petscbinarywritecomplex1_   petscbinarywritecomplex1
43 #endif
44 
45 /* Definitions of Fortran Wrapper routines */
46 #if defined(__cplusplus)
47 extern "C" {
48 #endif
49 
50 PETSC_EXTERN void PETSC_STDCALL  petscbinarywriteint_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
51 {
52   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
53 }
54 
55 PETSC_EXTERN void PETSC_STDCALL  petscbinarywritereal_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
56 {
57   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
58 }
59 
60 PETSC_EXTERN void PETSC_STDCALL  petscbinarywritecomplex_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
61 {
62   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
63 }
64 
65 PETSC_EXTERN void PETSC_STDCALL  petscbinarywriteint1_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
66 {
67   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
68 }
69 
70 PETSC_EXTERN void PETSC_STDCALL  petscbinarywritereal1_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
71 {
72   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
73 }
74 
75 PETSC_EXTERN void PETSC_STDCALL  petscbinarywritecomplex1_(int *fd,void*p,PetscInt *n,PetscDataType *type,PetscBool  *istemp, int *ierr)
76 {
77   *ierr = PetscBinaryWrite(*fd,p,*n,*type,*istemp);
78 }
79 
80 PETSC_EXTERN void PETSC_STDCALL petscbinaryopen_(char* name PETSC_MIXED_LEN(len),PetscFileMode *type,int *fd,
81                                     PetscErrorCode *ierr PETSC_END_LEN(len))
82 {
83   char *c1;
84 
85   FIXCHAR(name,len,c1);
86   *ierr = PetscBinaryOpen(c1,*type,fd);if (*ierr) return;
87   FREECHAR(name,c1);
88 }
89 
90 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadint_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
91 {
92   CHKFORTRANNULLINTEGER(count);
93   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
94 }
95 
96 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadreal_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
97 {
98   CHKFORTRANNULLINTEGER(count);
99   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
100 }
101 
102 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadcomplex_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
103 {
104   CHKFORTRANNULLINTEGER(count);
105   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
106 }
107 
108 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadint1_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
109 {
110   CHKFORTRANNULLINTEGER(count);
111   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
112 }
113 
114 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadreal1_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
115 {
116   CHKFORTRANNULLINTEGER(count);
117   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
118 }
119 
120 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadcomplex1_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
121 {
122   CHKFORTRANNULLINTEGER(count);
123   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
124 }
125 
126 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadintcnt_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
127 {
128   CHKFORTRANNULLINTEGER(count);
129   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
130 }
131 
132 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadrealcnt_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
133 {
134   CHKFORTRANNULLINTEGER(count);
135   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
136 }
137 
138 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadcomplexcnt_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
139 {
140   CHKFORTRANNULLINTEGER(count);
141   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
142 }
143 
144 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadint1cnt_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
145 {
146   CHKFORTRANNULLINTEGER(count);
147   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
148 }
149 
150 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadreal1cnt_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
151 {
152   CHKFORTRANNULLINTEGER(count);
153   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
154 }
155 
156 PETSC_EXTERN void PETSC_STDCALL  petscbinaryreadcomplex1cnt_(int *fd,void *data,PetscInt *num,PetscInt *count,PetscDataType *type,int *ierr)
157 {
158   CHKFORTRANNULLINTEGER(count);
159   *ierr = PetscBinaryRead(*fd,data,*num,count,*type);if (*ierr) return;
160 }
161 
162 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))
163 {
164   char *c1;
165 
166   FIXCHAR(name,len,c1);
167   *ierr = PetscTestFile(c1,*mode,flg);if (*ierr) return;
168   FREECHAR(name,c1);
169 }
170 
171 #if defined(__cplusplus)
172 }
173 #endif
174