1 2 #if !defined(__PETSCVIEWERHDF5_H) 3 #define __PETSCVIEWERHDF5_H 4 5 #include <petscviewer.h> 6 7 #if defined(PETSC_HAVE_HDF5) 8 9 #include <hdf5.h> 10 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetFileId(PetscViewer,hid_t*); 11 PETSC_EXTERN PetscErrorCode PetscViewerHDF5OpenGroup(PetscViewer, hid_t *, hid_t *); 12 PETSC_EXTERN PetscErrorCode PetscViewerHDF5ReadSizes(PetscViewer, const char[], PetscInt *, PetscInt *); 13 14 /* On 32 bit systems HDF5 is limited by size of integer, because hsize_t is defined as size_t */ 15 #define PETSC_HDF5_INT_MAX 2147483647 16 #define PETSC_HDF5_INT_MIN -2147483647 17 18 #undef __FUNCT__ 19 #define __FUNCT__ "PetscHDF5IntCast" 20 PETSC_STATIC_INLINE PetscErrorCode PetscHDF5IntCast(PetscInt a,hsize_t *b) 21 { 22 PetscFunctionBegin; 23 #if defined(PETSC_USE_64BIT_INDICES) && (PETSC_SIZEOF_SIZE_T == 4) 24 if ((a) > PETSC_HDF5_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for HDF5"); 25 #endif 26 *b = (hsize_t)(a); 27 PetscFunctionReturn(0); 28 } 29 PETSC_EXTERN PetscErrorCode PetscDataTypeToHDF5DataType(PetscDataType,hid_t*); 30 PETSC_EXTERN PetscErrorCode PetscHDF5DataTypeToPetscDataType(hid_t,PetscDataType*); 31 32 #define PetscStackCallHDF5(func,args) do { \ 33 hid_t status; \ 34 PetscStackPush(#func);status = func args;PetscStackPop; if (status) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in %s() Status %d",#func,(int)status); \ 35 } while (0) 36 37 #endif /* defined(PETSC_HAVE_HDF5) */ 38 39 PETSC_EXTERN PetscErrorCode PetscViewerHDF5ReadAttribute(PetscViewer,const char[],const char[],PetscDataType,void*); 40 PETSC_EXTERN PetscErrorCode PetscViewerHDF5WriteAttribute(PetscViewer,const char[],const char[],PetscDataType,const void*); 41 PETSC_EXTERN PetscErrorCode PetscViewerHDF5HasAttribute(PetscViewer, const char[], const char[], PetscBool *); 42 PETSC_EXTERN PetscErrorCode PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int); 43 44 PETSC_EXTERN PetscErrorCode PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 45 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PushGroup(PetscViewer,const char *); 46 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PopGroup(PetscViewer); 47 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetGroup(PetscViewer, const char **); 48 PETSC_EXTERN PetscErrorCode PetscViewerHDF5IncrementTimestep(PetscViewer); 49 PETSC_EXTERN PetscErrorCode PetscViewerHDF5SetTimestep(PetscViewer,PetscInt); 50 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetTimestep(PetscViewer,PetscInt*); 51 52 /* Reset __FUNCT__ in case the user does not define it themselves */ 53 #undef __FUNCT__ 54 #define __FUNCT__ "User provided function" 55 56 #endif 57