xref: /petsc/include/petscviewerhdf5.h (revision 2fb8446c541684a316151fd601c81003e751a50f)
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 
13 /* On 32 bit systems HDF5 is limited by size of integer, because hsize_t is defined as size_t */
14 #define PETSC_HDF5_INT_MAX  2147483647
15 #define PETSC_HDF5_INT_MIN -2147483647
16 
17 #undef __FUNCT__
18 #define __FUNCT__ "PetscHDF5IntCast"
19 PETSC_STATIC_INLINE PetscErrorCode PetscHDF5IntCast(PetscInt a,hsize_t *b)
20 {
21   PetscFunctionBegin;
22 #if defined(PETSC_USE_64BIT_INDICES) && (PETSC_SIZEOF_SIZE_T == 4)
23   if ((a) > PETSC_HDF5_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for HDF5");
24 #endif
25   *b =  (hsize_t)(a);
26   PetscFunctionReturn(0);
27 }
28 PETSC_EXTERN PetscErrorCode PetscDataTypeToHDF5DataType(PetscDataType,hid_t*);
29 PETSC_EXTERN PetscErrorCode PetscHDF5DataTypeToPetscDataType(hid_t,PetscDataType*);
30 
31 #endif  /* defined(PETSC_HAVE_HDF5) */
32 
33 PETSC_EXTERN PetscErrorCode PetscViewerHDF5ReadAttribute(PetscViewer,const char[],const char[],PetscDataType,void*);
34 PETSC_EXTERN PetscErrorCode PetscViewerHDF5WriteAttribute(PetscViewer,const char[],const char[],PetscDataType,const void*);
35 PETSC_EXTERN PetscErrorCode PetscViewerHDF5HasAttribute(PetscViewer, const char[], const char[], PetscBool *);
36 PETSC_EXTERN PetscErrorCode PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int);
37 
38 PETSC_EXTERN PetscErrorCode PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
39 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PushGroup(PetscViewer,const char *);
40 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PopGroup(PetscViewer);
41 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetGroup(PetscViewer, const char **);
42 PETSC_EXTERN PetscErrorCode PetscViewerHDF5IncrementTimestep(PetscViewer);
43 PETSC_EXTERN PetscErrorCode PetscViewerHDF5SetTimestep(PetscViewer,PetscInt);
44 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetTimestep(PetscViewer,PetscInt*);
45 
46 /* Reset __FUNCT__ in case the user does not define it themselves */
47 #undef __FUNCT__
48 #define __FUNCT__ "User provided function"
49 
50 #endif
51