diff options
author | tradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d> | 2000-10-12 12:07:33 +0000 |
---|---|---|
committer | tradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d> | 2000-10-12 12:07:33 +0000 |
commit | 1f56ad69714215149c2a78143e18997c7fdfb2fc (patch) | |
tree | 59cef723b4dcdc4454bb4c44aa62f4e7b01b1f0d /src/ioHDF5GH.h | |
parent | 3e71e6e2bc1974c55b553d13bb893c1b9634856a (diff) |
Moved a lot of code into IOHDF5Util and inherit from this thorn.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@25 4825ed28-b72c-4eae-9704-e50c059e567d
Diffstat (limited to 'src/ioHDF5GH.h')
-rw-r--r-- | src/ioHDF5GH.h | 197 |
1 files changed, 35 insertions, 162 deletions
diff --git a/src/ioHDF5GH.h b/src/ioHDF5GH.h index c7134c0..5aa5926 100644 --- a/src/ioHDF5GH.h +++ b/src/ioHDF5GH.h @@ -1,199 +1,70 @@ /*@@ @header ioHDF5GH.h - @date Fri May 21 1999 + @date Jun 20 2000 @author Thomas Radke @desc - The extensions to the GH structure from IOHDF5. - @history - @hauthor Thomas Radke @hdate May 21 1999 - @hdesc Just copied from thorn FlexIO. - @endhistory + The extensions to the GH structure from IOHDF5. + @version $Id$ @@*/ -#ifdef __cplusplus -extern "C" { -#endif - -#include <string.h> -#include <hdf5.h> +#ifndef _IOHDF5_IOHDF5GH_H_ +#define _IOHDF5_IOHDF5GH_H_ +#include "BetaThorns/IOHDF5Util/src/ioHDF5UtilGH.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 IOHDF5_MAXDIM 4 - -/* structure holding necessary information about a recovery file */ -typedef struct { - int is_HDF5_file; /* flag indicating valid file info */ - hid_t fid; /* HDF5 file handle */ - char filename [1024]; /* complete file name for recovery */ - int nprocs; /* number of total processors */ - int ioproc; /* the associated IO processor */ - int ioproc_every; /* how many IO processors there are */ - int unchunked; /* whether data was written chunked or unchunked */ -} fileinfo_t; - -/* structure holding information on the output geometry */ -typedef struct ioHDF5Geo -{ - int vdim; /* dimension of the gridvariable (dynamic) */ - int sdim; /* dimension of the slab (dynamic) */ - int direction[IOHDF5_MAXDIM]; /* direction of slab (by parameter) */ - int slab_start[IOHDF5_MAXDIM]; /* global start index (by parameter) */ - int length[IOHDF5_MAXDIM]; /* requested index slab length (by parameter) */ - int actlen[IOHDF5_MAXDIM]; /* actual index slab length (by PUGHSlab)*/ - int downs[IOHDF5_MAXDIM]; /* downsampling (by parameter) */ -} ioHDF5Geo_t; - /* IOHDF5 GH extension structure */ -typedef struct IOHDF5GH { +typedef struct +{ /* how often to output */ - int out1D_every; - int out2D_every; - int out3D_every; + int out_every; /* flags indicating output for var [i] */ - char *do_out1D; - char *do_out2D; - char *do_out3D; + char *do_output; /* directories in which to output */ - char *outdir1D; - char *outdir2D; - char *outdir3D; + char *outdir; /* the last iteration output */ - int *out1D_last; - int *out2D_last; - int *out3D_last; + int *out_last; /* filename database for opened files */ - pNamedData *filenameList; + pNamedData *open_output_files; /* for restart from recovery: flags indicating whether to check for already existing groups/datasets to delete before creating them anew */ - char *checkForExistingObjects; - - /* 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; + char *check_exisiting_objects; /* timer array for checkpointing/recovery */ - int timers[4]; + int timers[IOHDF5_NUM_TIMERS]; /* flag to indicate request for timer output */ int print_timing_info; /* geometry information (downsampling, zooming, etc.) */ - ioHDF5Geo_t **out_geo; + ioHDF5Geo_t *out_geo; + + /* ring buffer for list of successfully created cp files */ + int cp_filename_index; + char **cp_filename_list; } ioHDF5GH; -/* function prototypes */ -int IOHDF5_Write3D (cGH *GH, int index, const char *alias); -int IOHDF5_Write2D (cGH *GH, int index, const char *alias); -int IOHDF5_Write1D (cGH *GH, int index, const char *alias); +#ifdef __cplusplus +extern "C" +{ +#endif -void IOHDF5_DumpParams (cGH *GH, hid_t group); -void IOHDF5_DumpGHExtensions (cGH *GH, hid_t group); -int IOHDF5_DumpVar (cGH *GH, int index, int timelevel, ioHDF5Geo_t *geo, hid_t iof); -void IOHDF5_DumpGH (cGH *GH, int called_from); +/* prototypes of functions to be registered as IOHDF5's IO method */ +int IOHDF5_OutputGH (cGH *GH); +int IOHDF5_TriggerOutput (cGH *GH, int); +int IOHDF5_TimeFor (cGH *GH, int); +int IOHDF5_OutputVarAs (cGH *GH, const char *var, const char *alias); +int IOHDF5_Recover (cGH *GH, const char *basename, int called_from); +/* other function prototypes */ +void IOHDF5_Write (cGH *GH, int index, const char *alias); int IOHDF5_WriteIsosurface (cGH *GH, const char *filename, const char *GVname, @@ -208,5 +79,7 @@ int IOHDF5_WriteIsosurface (cGH *GH, CCTK_REAL4 *vertices); #ifdef __cplusplus -} // extern "C" { +} // extern "C" #endif + +#endif /* _IOHDF5_IOHDF5GH_H_ */ |