diff options
Diffstat (limited to 'src/StreamedHDF5GH.h')
-rw-r--r-- | src/StreamedHDF5GH.h | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/src/StreamedHDF5GH.h b/src/StreamedHDF5GH.h deleted file mode 100644 index 4317db4..0000000 --- a/src/StreamedHDF5GH.h +++ /dev/null @@ -1,164 +0,0 @@ - /*@@ - @header StreamedHDF5GH.h - @date Fri May 21 1999 - @author Thomas Radke - @desc - The extensions to the GH structure from StreamedHDF5. - @history - @hauthor Thomas Radke @hdate May 21 1999 - @hdesc Just copied from thorn FlexIO. - @endhistory - @@*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <string.h> -#include <hdf5.h> - -#include "StoreNamedData.h" - - -/* names of the (empty) groups that hold GH extensions or global parameters */ -#define GHEXTENSIONS_GROUP "GHextensions_group" -#define GLOBAL_PARAMETERS_GROUP "global_parameters_group" -#define GLOBAL_PARAMETERS "global_parameters" - -/*****************************************************************************/ -/* some useful macros */ -/*****************************************************************************/ -/* Check error flags from HDF5 calls */ -#define CACTUS_IOHDF5_ERROR(fn_call) \ - do { \ - size_t strlen(const char *str); \ - \ - int error_code = fn_call; \ - \ - if (error_code < 0) \ - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, \ - "HDF5 call '%s' returned error code %d\n", \ - #fn_call, error_code); \ - } while (0) - -/* macro for writing an attribute */ -#define WRITE_ATTRIBUTE(name, value, dataset, dataspace, dim, datatype) \ - do { \ - hid_t attr; \ - void *val = value; \ - hsize_t arrayDim = dim; \ - \ - if (H5Tget_class (datatype) == H5T_STRING) { \ - int len = strlen ((char *) val); \ - \ - if (len == 0) /* HDF5 doesn't like zero-len strings */ \ - len++; \ - CACTUS_IOHDF5_ERROR (H5Tset_size (datatype, len)); \ - } \ - if (arrayDim > 0) \ - CACTUS_IOHDF5_ERROR (H5Sset_extent_simple (dataspace, 1, \ - &arrayDim, NULL)); \ - CACTUS_IOHDF5_ERROR (attr = H5Acreate (dataset, name, datatype, \ - dataspace, H5P_DEFAULT)); \ - CACTUS_IOHDF5_ERROR (H5Awrite (attr, datatype, val)); \ - CACTUS_IOHDF5_ERROR (H5Aclose (attr)); \ - } while (0); - -/* macro for reading an attribute */ -#define READ_ATTRIBUTE(dataset, attrname, requested_type, buffer) \ - { hid_t attr, attrtype; \ - hsize_t asize = 0; \ - \ - if ((attr = H5Aopen_name (dataset, attrname)) < 0) \ - CCTK_WARN (1, "Can't find " attrname " attribute"); \ - if (requested_type == H5T_C_S1) { \ - CACTUS_IOHDF5_ERROR (attrtype = H5Aget_type (attr)); \ - CACTUS_IOHDF5_ERROR (asize = H5Tget_size (attrtype)); \ - if (asize + 1 >= sizeof (buffer)) \ - CCTK_WARN (1, "Can't read " attrname " attribute (too long)");\ - } else \ - attrtype = requested_type; \ - if (H5Aread (attr, attrtype, buffer) < 0) \ - CCTK_WARN (1, "Can't read " attrname " attribute"); \ - if (requested_type == H5T_C_S1) { \ - ((char *) buffer) [asize] = 0; \ - CACTUS_IOHDF5_ERROR (H5Tclose (attrtype)); \ - } \ - CACTUS_IOHDF5_ERROR (H5Aclose (attr)); \ - } - - -/* define the HDF5 datatypes according to CCTK_??? datatypes */ -#define IOHDF5_REAL4 H5T_NATIVE_FLOAT - -#ifdef CCTK_REAL_PRECISION_16 -#define IOHDF5_REAL H5T_NATIVE_LDOUBLE -#elif CCTK_REAL_PRECISION_8 -#define IOHDF5_REAL H5T_NATIVE_DOUBLE -#elif CCTK_REAL_PRECISION_4 -#define IOHDF5_REAL H5T_NATIVE_FLOAT -#endif - -#define IOHDF5_INT (sizeof (CCTK_INT) == sizeof (int) ? \ - H5T_NATIVE_INT : H5T_NATIVE_SHORT) -#define IOHDF5_INT4 (sizeof (int) == 4 ? \ - H5T_NATIVE_INT : H5T_NATIVE_SHORT) -#define IOHDF5_CHAR H5T_NATIVE_CHAR - -#define STREAM_MAXDIM 5 - -/* Geometry information structure for output variable */ -typedef struct -{ - int vdim; - int sdim; - int direction[STREAM_MAXDIM]; - int origin[STREAM_MAXDIM]; - int length[STREAM_MAXDIM]; - int downs[STREAM_MAXDIM]; -} StreamGeo_t; - - -/* StreamedHDF5 GH extension structure */ -typedef struct StreamedHDF5GH -{ - /* how often to output */ - int out_every; - - /* flags indicating output for var [i] */ - char *do_output; - StreamGeo_t *geo_output; - - /* the last iteration output */ - int *out_last; - - /* variables holding the original error printing routine and its argument */ - H5E_auto_t printErrorFn; - void *printErrorFnArg; - - /* predefined dataspaces for writing scalar and array attributes */ - hid_t scalarDataspace, arrayDataspace; - - /* predefined datatype for writing CCTK_COMPLEX types */ - hid_t IOHDF5_COMPLEX; - - /* predefined datatype for writing C string string attributes */ - hid_t IOHDF5_STRING; - - /* the socket to pass to the Stream VFD */ - int socket; - -} StreamedHDF5GH; - -/* function prototypes */ -void StreamedHDF5_Write (cGH *GH, int index, const char *alias); -void StreamedHDF5_DumpParams (cGH *GH, hid_t group); -void StreamedHDF5_DumpGHExtensions (cGH *GH, hid_t group); -int StreamedHDF5_DumpVar (cGH *GH, int index, int timelevel, hid_t iof); -int ParseVarsForOutputH5stream (StreamedHDF5GH *h5GH, const char *var_list); -void SetDefaultGeoH5stream(StreamGeo_t *geo); -int GeometryParserH5stream(const char *before, char **outname, StreamGeo_t *geo); - -#ifdef __cplusplus -} // extern "C" { -#endif |