Actual source code: zhdf5f.c

      1: #include <petsc/private/fortranimpl.h>
      2: #include <petscviewerhdf5.h>

      4: #if defined(PETSC_HAVE_FORTRAN_CAPS)
      5:   #define petscviewerhdf5open_           PETSCVIEWERHDF5OPEN
      6:   #define petscviewerhdf5pushgroup_      PETSCVIEWERHDF5PUSHGROUP
      7:   #define petscviewerhdf5getgroup_       PETSCVIEWERHDF5GETGROUP
      8:   #define petscviewerhdf5hasdataset_     PETSCVIEWERHDF5HASDATASET
      9:   #define petscviewerhdf5hasattribute_   PETSCVIEWERHDF5HASATTRIBUTE
     10:   #define petscviewerhdf5writeattribute_ PETSCVIEWERHDF5WRITEATTRIBUTE
     11:   #define petscviewerhdf5readattribute_  PETSCVIEWERHDF5READATTRIBUTE
     12:   #define petscviewerhdf5hasgroup_       PETSCVIEWERHDF5HASGROUP
     13:   #define petscviewerhdf5opengroup_      PETSCVIEWERHDF5OPENGROUP
     14:   #define petscviewerhdf5writegroup_     PETSCVIEWERHDF5WRITEGROUP
     15: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
     16:   #define petscviewerhdf5open_           petscviewerhdf5open
     17:   #define petscviewerhdf5pushgroup_      petscviewerhdf5pushgroup
     18:   #define petscviewerhdf5getgroup_       petscviewerhdf5getgroup
     19:   #define petscviewerhdf5hasdataset_     petscviewerhdf5hasdataset
     20:   #define petscviewerhdf5hasattribute_   petscviewerhdf5hasattribute
     21:   #define petscviewerhdf5writeattribute_ petscviewerhdf5writeattribute
     22:   #define petscviewerhdf5readattribute_  petscviewerhdf5readattribute
     23:   #define petscviewerhdf5hasgroup_       petscviewerhdf5hasgroup
     24:   #define petscviewerhdf5opengroup_      petscviewerhdf5opengroup
     25:   #define petscviewerhdf5writegroup_     petscviewerhdf5writegroup
     26: #endif

     28: PETSC_EXTERN void petscviewerhdf5open_(MPI_Comm *comm, char *name, PetscFileMode *type, PetscViewer *binv, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
     29: {
     30:   char *c1;

     32:   FIXCHAR(name, len, c1);
     33:   *ierr = PetscViewerHDF5Open(MPI_Comm_f2c(*(MPI_Fint *)&*comm), c1, *type, binv);
     34:   if (*ierr) return;
     35:   FREECHAR(name, c1);
     36: }

     38: PETSC_EXTERN void petscviewerhdf5pushgroup_(PetscViewer *viewer, char *name, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
     39: {
     40:   char *c1;

     42:   FIXCHAR(name, len, c1);
     43:   *ierr = PetscViewerHDF5PushGroup(*viewer, c1);
     44:   if (*ierr) return;
     45:   FREECHAR(name, c1);
     46: }

     48: PETSC_EXTERN void petscviewerhdf5getgroup_(PetscViewer *viewer, char *path, char *abspath, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len0, PETSC_FORTRAN_CHARLEN_T len1)
     49: {
     50:   char *c0;
     51:   char *c1;

     53:   FIXCHAR(path, len0, c0);
     54:   *ierr = PetscViewerHDF5GetGroup(*viewer, c0, &c1);
     55:   if (*ierr) return;
     56:   *ierr = PetscStrncpy(abspath, c1, len1);
     57:   if (*ierr) return;
     58:   *ierr = PetscFree(c1);
     59:   if (*ierr) return;
     60:   FREECHAR(path, c0);
     61:   FIXRETURNCHAR(PETSC_TRUE, abspath, len1);
     62: }

     64: PETSC_EXTERN void petscviewerhdf5hasattribute_(PetscViewer *viewer, char *parent, char *name, PetscBool *has, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T plen, PETSC_FORTRAN_CHARLEN_T nlen)
     65: {
     66:   char *c1, *c2;

     68:   FIXCHAR(parent, plen, c1);
     69:   FIXCHAR(name, nlen, c2);
     70:   *ierr = PetscViewerHDF5HasAttribute(*viewer, c1, c2, has);
     71:   if (*ierr) return;
     72:   FREECHAR(parent, c1);
     73:   FREECHAR(name, c2);
     74: }

     76: PETSC_EXTERN void petscviewerhdf5writeattribute_(PetscViewer *viewer, char *parent, char *name, PetscDataType *datatype, const void *value, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T plen, PETSC_FORTRAN_CHARLEN_T nlen)
     77: {
     78:   char *c1, *c2;

     80:   FIXCHAR(parent, plen, c1);
     81:   FIXCHAR(name, nlen, c2);
     82:   *ierr = PetscViewerHDF5WriteAttribute(*viewer, c1, c2, *datatype, value);
     83:   if (*ierr) return;
     84:   FREECHAR(parent, c1);
     85:   FREECHAR(name, c2);
     86: }

     88: PETSC_EXTERN void petscviewerhdf5readattribute_(PetscViewer *viewer, char *parent, char *name, PetscDataType *datatype, void *defaultValue, void *value, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T plen, PETSC_FORTRAN_CHARLEN_T nlen)
     89: {
     90:   char *c1, *c2;

     92:   FIXCHAR(parent, plen, c1);
     93:   FIXCHAR(name, nlen, c2);
     94:   *ierr = PetscViewerHDF5ReadAttribute(*viewer, c1, c2, *datatype, defaultValue, value);
     95:   if (*ierr) return;
     96:   FREECHAR(parent, c1);
     97:   FREECHAR(name, c2);
     98: }

    100: PETSC_EXTERN void petscviewerhdf5hasdataset_(PetscViewer *viewer, char *path, PetscBool *has, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
    101: {
    102:   char *c1;

    104:   FIXCHAR(path, len, c1);
    105:   *ierr = PetscViewerHDF5HasDataset(*viewer, c1, has);
    106:   if (*ierr) return;
    107:   FREECHAR(path, c1);
    108: }

    110: PETSC_EXTERN void petscviewerhdf5hasgroup_(PetscViewer *viewer, char *path, PetscBool *has, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
    111: {
    112:   char *c1;

    114:   FIXCHAR(path, len, c1);
    115:   *ierr = PetscViewerHDF5HasGroup(*viewer, c1, has);
    116:   if (*ierr) return;
    117:   FREECHAR(path, c1);
    118: }

    120: PETSC_EXTERN void petscviewerhdf5opengroup_(PetscViewer *viewer, char path[], hid_t *fileId, hid_t *groupId, int *ierr, PETSC_FORTRAN_CHARLEN_T len)
    121: {
    122:   char *c1;

    124:   FIXCHAR(path, len, c1);
    125:   *ierr = PetscViewerHDF5OpenGroup(*viewer, c1, fileId, groupId);
    126:   FREECHAR(path, c1);
    127: }

    129: PETSC_EXTERN void petscviewerhdf5writegroup_(PetscViewer *viewer, char path[], int *ierr, PETSC_FORTRAN_CHARLEN_T len)
    130: {
    131:   char *c1;

    133:   FIXCHAR(path, len, c1);
    134:   *ierr = PetscViewerHDF5WriteGroup(*viewer, c1);
    135:   FREECHAR(path, c1);
    136: }