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