diff options
Diffstat (limited to 'src/RecoverVar.c')
-rw-r--r-- | src/RecoverVar.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/src/RecoverVar.c b/src/RecoverVar.c index 8724f7b..f8e63da 100644 --- a/src/RecoverVar.c +++ b/src/RecoverVar.c @@ -247,14 +247,14 @@ int IOHDF5Util_RecoverGHextensions (cGH *GH, const fileinfo_t *fileinfo) (don't have subcommunicators yet) */ int IOHDF5Util_RecoverParameters (const fileinfo_t *fileinfo) { - hid_t group, attr, atype; + hid_t group, attr, dataset, atype; char *parameters; CCTK_INT4 parameterSize; DECLARE_CCTK_PARAMETERS /* To make the compiler happy */ - group = attr = 0; + group = attr = dataset = -1; parameters = NULL; parameterSize = 0; @@ -267,21 +267,35 @@ int IOHDF5Util_RecoverParameters (const fileinfo_t *fileinfo) } /* the parameters are stored in the CACTUS_PARAMETERS_GROUP group - in the attribute ALL_PARAMETERS */ + in the attribute (old style) or dataset (new style) ALL_PARAMETERS */ group = H5Gopen (fileinfo->file, CACTUS_PARAMETERS_GROUP); if (group > 0) { - attr = H5Aopen_name (group, ALL_PARAMETERS); + H5E_BEGIN_TRY + { + attr = H5Aopen_name (group, ALL_PARAMETERS); + dataset = H5Dopen (group, ALL_PARAMETERS); + } H5E_END_TRY } - if (group > 0 && attr > 0) + if (group >= 0 && (attr >= 0 || dataset >= 0)) { - HDF5_ERROR (atype = H5Aget_type (attr)); - parameterSize = H5Tget_size (atype); - parameters = malloc (parameterSize + 1); - HDF5_ERROR (H5Aread (attr, atype, parameters)); - parameters[parameterSize] = 0; - HDF5_ERROR (H5Tclose (atype)); + if (attr >= 0) + { + HDF5_ERROR (atype = H5Aget_type (attr)); + parameterSize = H5Tget_size (atype); + parameters = malloc (parameterSize + 1); + HDF5_ERROR (H5Aread (attr, atype, parameters)); + parameters[parameterSize] = 0; + HDF5_ERROR (H5Tclose (atype)); + } + else + { + parameterSize = H5Dget_storage_size (dataset); + parameters = malloc (parameterSize); + HDF5_ERROR (H5Dread (dataset, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, + H5P_DEFAULT, parameters)); + } } else { @@ -289,11 +303,15 @@ int IOHDF5Util_RecoverParameters (const fileinfo_t *fileinfo) "Is this really a Cactus HDF5 checkpoint file ?"); } - if (attr > 0) + if (attr >= 0) { HDF5_ERROR (H5Aclose (attr)); } - if (group > 0) + if (dataset >= 0) + { + HDF5_ERROR (H5Dclose (dataset)); + } + if (group >= 0) { HDF5_ERROR (H5Gclose (group)); } |