diff options
author | cott <devnull@localhost> | 2011-03-12 08:59:14 -0800 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 18:26:03 +0000 |
commit | d28b646fbecdc055ac1f154f4b0b4707b9d089eb (patch) | |
tree | f7e33f0829ca895968eb3469a01704d8060bab4c /Carpet | |
parent | c97b6e7291507bd7006e6b37b9e63de311744695 (diff) |
* encapsulate read of potentially not present attribute
in an H5E_BEGIN_TRY H5E_END_TRY environment. This prevents
hate crimes.
Diffstat (limited to 'Carpet')
-rw-r--r-- | Carpet/CarpetIOHDF5/src/Input.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Carpet/CarpetIOHDF5/src/Input.cc b/Carpet/CarpetIOHDF5/src/Input.cc index cb0e57040..9165efe96 100644 --- a/Carpet/CarpetIOHDF5/src/Input.cc +++ b/Carpet/CarpetIOHDF5/src/Input.cc @@ -336,7 +336,6 @@ int Recover (cGH* cctkGH, const char *basefilename, int called_from) int error_count = 0; DECLARE_CCTK_PARAMETERS; - assert (called_from == CP_RECOVER_PARAMETERS or called_from == CP_RECOVER_DATA or called_from == FILEREADER_DATA); @@ -825,11 +824,13 @@ static list<fileset_t>::iterator OpenFileSet (const cGH* const cctkGH, "checkpoint" : "input", file.filename); } + // read all the metadata information ReadMetadata (fileset, file.file); // first try to open a chunked file written on this processor // browse through all datasets contained in this file + HDF5_ERROR (H5Giterate (file.file, "/", NULL, BrowseDatasets, &file)); assert (file.patches.size() > 0); @@ -852,6 +853,8 @@ static list<fileset_t>::iterator OpenFileSet (const cGH* const cctkGH, num_reflevels = fileset.num_reflevels; } + + // allocate and initialise the list of input files for this set fileset.files.resize (fileset.nioprocs); for (int i = 0; i < fileset.nioprocs; i++) { @@ -1031,7 +1034,6 @@ static herr_t BrowseDatasets (hid_t group, const char *objectname, void *arg) if (object_info.type != H5G_DATASET) { return (0); } - HDF5_ERROR (dataset = H5Dopen (group, objectname)); HDF5_ERROR (dataspace = H5Dget_space (dataset)); patch.rank = H5Sget_simple_extent_ndims (dataspace); @@ -1068,7 +1070,9 @@ static herr_t BrowseDatasets (hid_t group, const char *objectname, void *arg) HDF5_ERROR (H5Aread (attr, H5T_NATIVE_INT, &patch.iorigin[0])); HDF5_ERROR (H5Aclose (attr)); patch.ioffset = 0; - attr = H5Aopen_name (dataset, "ioffset"); + H5E_BEGIN_TRY { + attr = H5Aopen_name (dataset, "ioffset"); + } H5E_END_TRY; // ioffset and ioffsetdenom may not be present; if so, use a default if (attr >= 0) { HDF5_ERROR (dataspace = H5Aget_space (attr)); @@ -1078,7 +1082,9 @@ static herr_t BrowseDatasets (hid_t group, const char *objectname, void *arg) HDF5_ERROR (H5Aclose (attr)); } patch.ioffsetdenom = 1; - attr = H5Aopen_name (dataset, "ioffsetdenom"); + H5E_BEGIN_TRY { + attr = H5Aopen_name (dataset, "ioffsetdenom"); + } H5E_END_TRY; if (attr >= 0) { HDF5_ERROR (dataspace = H5Aget_space (attr)); assert (H5Sget_simple_extent_npoints (dataspace) == patch.rank); |