xref: /petsc/src/sys/fileio/ftn-custom/zmpiuopenf.c (revision b0dcfd164860a975c76f90dabf1036901aab1c4e)
1 #include <petsc/private/ftnimpl.h>
2 
3 #if defined(PETSC_HAVE_FORTRAN_CAPS)
4   #define petscfopen_  PETSCFOPEN
5   #define petscfclose_ PETSCFCLOSE
6 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
7   #define petscfopen_  petscfopen
8   #define petscfclose_ petscfclose
9 #endif
10 
11 #if defined(__cplusplus)
12 extern "C" {
13 #endif
14 
petscfopen_(MPI_Comm * comm,char * fname,char * fmode,FILE ** file,PetscErrorCode * ierr,PETSC_FORTRAN_CHARLEN_T len1,PETSC_FORTRAN_CHARLEN_T len2)15 PETSC_EXTERN void petscfopen_(MPI_Comm *comm, char *fname, char *fmode, FILE **file, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len1, PETSC_FORTRAN_CHARLEN_T len2)
16 {
17   char *c1, *c2;
18 
19   FIXCHAR(fname, len1, c1);
20   FIXCHAR(fmode, len2, c2);
21   *ierr = PetscFOpen(MPI_Comm_f2c(*(MPI_Fint *)&*comm), c1, c2, file);
22   if (*ierr) return;
23   FREECHAR(fname, c1);
24   FREECHAR(fmode, c2);
25 }
26 
petscfclose_(MPI_Comm * comm,FILE ** file,PetscErrorCode * ierr)27 PETSC_EXTERN void petscfclose_(MPI_Comm *comm, FILE **file, PetscErrorCode *ierr)
28 {
29   *ierr = PetscFClose(MPI_Comm_f2c(*(MPI_Fint *)&*comm), *file);
30 }
31 
32 #if defined(__cplusplus)
33 }
34 #endif
35