diff options
author | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2001-06-12 22:39:17 +0000 |
---|---|---|
committer | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2001-06-12 22:39:17 +0000 |
commit | bb8a2a2e3aacbcf0d2bf515c3db180c763ff3690 (patch) | |
tree | bc11b5555638a1160d2b4aa548a652261d144610 /src/RecoverVar.c | |
parent | 55fbce955242ab0381d3ccee78f6b35e569c1ae3 (diff) |
Support I/O for all the fixed-sized CCTK datatypes also.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@33 7842ec3a-9562-4be5-9c5b-06ba18f2b668
Diffstat (limited to 'src/RecoverVar.c')
-rw-r--r-- | src/RecoverVar.c | 66 |
1 files changed, 22 insertions, 44 deletions
diff --git a/src/RecoverVar.c b/src/RecoverVar.c index ca23d2a..0195416 100644 --- a/src/RecoverVar.c +++ b/src/RecoverVar.c @@ -451,13 +451,16 @@ static int GetCommonAttributes (cGH *GH, /* The CCTK variable type defines do not correlate with the HDF5 defines so compare them explicitely here. */ flag = (H5Tget_class (datatype) == H5T_FLOAT && - group_static_data.vartype == CCTK_VARIABLE_REAL) || + strncmp (CCTK_VarTypeName (group_static_data.vartype), + "CCTK_VARIABLE_REAL", 18) == 0) || (H5Tget_class (datatype) == H5T_INTEGER && - group_static_data.vartype == CCTK_VARIABLE_INT) || - (H5Tget_class (datatype) == H5T_INTEGER && - group_static_data.vartype == CCTK_VARIABLE_CHAR) || + (strncmp (CCTK_VarTypeName (group_static_data.vartype), + "CCTK_VARIABLE_INT", 17) == 0 || + strcmp (CCTK_VarTypeName (group_static_data.vartype), + "CCTK_VARIABLE_CHAR") == 0)) || (H5Tget_class (datatype) == H5T_COMPOUND && - group_static_data.vartype == CCTK_VARIABLE_COMPLEX); + strncmp (CCTK_VarTypeName (group_static_data.vartype), + "CCTK_VARIABLE_COMPLEX", 21) == 0); IOHDF5_ERROR (H5Tclose (datatype)); if (! flag) @@ -715,8 +718,8 @@ static herr_t processDataset (hid_t group, DECLARE_CCTK_PARAMETERS pGH *pughGH; ioGH *ioUtilGH; - ioHDF5UtilGH *h5UtilGH; - int vindex, gtype, timelevel; + ioHDF5UtilGH *myGH; + int vindex, vtype, gtype, timelevel; iterate_info_t *it_info = (iterate_info_t *) arg; recover_info_t rec_info; hid_t dataset; @@ -734,7 +737,7 @@ static herr_t processDataset (hid_t group, /* Get the handle for PUGH, IOUtil, and IOHDF5Util extensions */ pughGH = PUGH_pGH (it_info->GH); ioUtilGH = (ioGH *) CCTK_GHExtension (it_info->GH, "IO"); - h5UtilGH = (ioHDF5UtilGH *) CCTK_GHExtension (it_info->GH, "IOHDF5Util"); + myGH = (ioHDF5UtilGH *) CCTK_GHExtension (it_info->GH, "IOHDF5Util"); IOHDF5_ERROR (H5Gget_objinfo (group, datasetname, 0, &object_info)); is_group = object_info.type == H5G_GROUP; @@ -781,47 +784,22 @@ static herr_t processDataset (hid_t group, free (varname); } + vtype = CCTK_VarTypeI (vindex); rec_info.it_info = it_info; - - switch (CCTK_VarTypeI (vindex)) - { - case CCTK_VARIABLE_CHAR: - rec_info.iohdf5_type = IOHDF5_CHAR; - rec_info.element_size = sizeof (CCTK_CHAR); -#ifdef CCTK_MPI - rec_info.mpi_type = PUGH_MPI_CHAR; -#endif - break; - - case CCTK_VARIABLE_INT: - rec_info.iohdf5_type = IOHDF5_INT; - rec_info.element_size = sizeof (CCTK_INT); + rec_info.element_size = CCTK_VarTypeSize (vtype); #ifdef CCTK_MPI - rec_info.mpi_type = PUGH_MPI_INT; + rec_info.mpi_type = PUGH_MPIDataType (pughGH, vtype); #endif - break; - - case CCTK_VARIABLE_REAL: - rec_info.iohdf5_type = IOHDF5_REAL; - rec_info.element_size = sizeof (CCTK_REAL); + rec_info.iohdf5_type = IOHDF5Util_DataType (myGH, vtype); + if (rec_info.element_size <= 0 || #ifdef CCTK_MPI - rec_info.mpi_type = PUGH_MPI_REAL; + rec_info.mpi_type == MPI_DATATYPE_NULL || #endif - break; - - case CCTK_VARIABLE_COMPLEX: - rec_info.iohdf5_type = h5UtilGH->IOHDF5_COMPLEX; - rec_info.element_size = sizeof (CCTK_COMPLEX); -#ifdef CCTK_MPI - rec_info.mpi_type = pughGH->PUGH_mpi_complex; -#endif - break; - - default: - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Unsupported variable datatype '%s'", - CCTK_VarTypeName (CCTK_VarTypeI (vindex))); - return (0); + rec_info.iohdf5_type < 0) + { + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Unsupported variable datatype %d", vtype); + return (1); } /* Read in the data */ |