aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Haas <rhaas@tapir.caltech.edu>2013-08-17 23:20:53 -0700
committerRoland Haas <rhaas@tapir.caltech.edu>2013-08-18 14:53:46 -0700
commitc02dd99bbded56ab4dee2477cbc045b65708420d (patch)
tree8c1e8ebb33e4c4d6c5b4dcc2e11ca40a309bb44f
parenta80e3537a7cd6d1a1b3db0bd31a271984b2958a2 (diff)
CarpetIOHDF5: fix reading of new-style grid structures
last commit to CarpetIOHDF5 broke this. This commit also updates the test suite data so that it actually tests the file format. This commit adds a level 2 warning if no grid structure is found in file.
-rw-r--r--Carpet/CarpetIOHDF5/src/Input.cc27
-rw-r--r--Carpet/CarpetIOHDF5/test/input_initial_data/phi.h5bin12553 -> 15189 bytes
-rw-r--r--Carpet/CarpetIOHDF5/test/input_initial_data/psi.h5bin12553 -> 21193 bytes
3 files changed, 17 insertions, 10 deletions
diff --git a/Carpet/CarpetIOHDF5/src/Input.cc b/Carpet/CarpetIOHDF5/src/Input.cc
index a2e64245d..9d1f77443 100644
--- a/Carpet/CarpetIOHDF5/src/Input.cc
+++ b/Carpet/CarpetIOHDF5/src/Input.cc
@@ -88,7 +88,7 @@ static list<fileset_t>::iterator OpenFileSet (const cGH* const cctkGH,
const string setname,
const char *basefilename,
int called_from);
-static void ReadMetadata (fileset_t& fileset, hid_t file);
+static void ReadMetadata (fileset_t& fileset, const file_t& file);
static herr_t BrowseDatasets (hid_t group, const char *objectname, void *arg);
static int ReadVar (const cGH* const cctkGH,
file_t & file,
@@ -976,7 +976,7 @@ static list<fileset_t>::iterator OpenFileSet (const cGH* const cctkGH,
// read all the metadata information
- ReadMetadata (fileset, file.file);
+ ReadMetadata (fileset, file);
// recover parameters
if (called_from == CP_RECOVER_PARAMETERS) {
@@ -984,7 +984,7 @@ static list<fileset_t>::iterator OpenFileSet (const cGH* const cctkGH,
CCTK_VInfo (CCTK_THORNSTRING, "Recovering parameters from checkpoint "
"file '%s'", file.filename);
}
- hid_t dataset, datatype;
+ hid_t dataset, datatype, memtype = -1;
size_t len;
htri_t old_data;
@@ -999,15 +999,19 @@ static list<fileset_t>::iterator OpenFileSet (const cGH* const cctkGH,
CCTK_WARN (CCTK_WARN_ALERT, "Old-style checkpoint data found.");
HDF5_ERROR (len = H5Sget_simple_extent_npoints(dataspace) + 1);
HDF5_ERROR (H5Sclose(dataspace));
+ HDF5_ERROR (memtype = H5Tcopy(H5T_NATIVE_CHAR));
} else {
HDF5_ERROR (len = H5Tget_size(datatype));
+ HDF5_ERROR (memtype = H5Tcopy(H5T_C_S1));
+ HDF5_ERROR (H5Tset_size(memtype, len));
}
vector<char> parameter_buf(len);
char* parameters = &parameter_buf[0];
- HDF5_ERROR (H5Dread (dataset, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL,
+ HDF5_ERROR (H5Dread (dataset, memtype, H5S_ALL, H5S_ALL,
H5P_DEFAULT, parameters));
HDF5_ERROR (H5Dclose (dataset));
+ HDF5_ERROR (H5Tclose (memtype));
HDF5_ERROR (H5Tclose (datatype));
IOUtil_SetAllParameters (parameters);
@@ -1037,7 +1041,7 @@ static list<fileset_t>::iterator OpenFileSet (const cGH* const cctkGH,
//////////////////////////////////////////////////////////////////////////////
// Read the metadata for a set of input files
//////////////////////////////////////////////////////////////////////////////
-static void ReadMetadata (fileset_t& fileset, hid_t file)
+static void ReadMetadata (fileset_t& fileset, const file_t& file)
{
int error_count = 0;
DECLARE_CCTK_PARAMETERS;
@@ -1045,7 +1049,7 @@ static void ReadMetadata (fileset_t& fileset, hid_t file)
fileset.nioprocs = 1;
hid_t metadata, attr; //, dataspace;
H5E_BEGIN_TRY {
- metadata = H5Gopen (file, METADATA_GROUP);
+ metadata = H5Gopen (file.file, METADATA_GROUP);
} H5E_END_TRY;
if (metadata < 0) {
// no metadata at all - this must be old-fashioned data output file
@@ -1060,7 +1064,7 @@ static void ReadMetadata (fileset_t& fileset, hid_t file)
const bool is_old_fashioned_file = attr < 0;
if (is_old_fashioned_file) {
HDF5_ERROR (H5Gclose (metadata));
- HDF5_ERROR (metadata = H5Dopen (file,
+ HDF5_ERROR (metadata = H5Dopen (file.file,
METADATA_GROUP "/" ALL_PARAMETERS));
} else {
HDF5_ERROR (H5Aread (attr, H5T_NATIVE_INT, &fileset.nioprocs));
@@ -1091,12 +1095,11 @@ static void ReadMetadata (fileset_t& fileset, hid_t file)
dataset = H5Dopen (metadata, GRID_STRUCTURE);
} H5E_END_TRY;
if (dataset >= 0) {
- hid_t datatype;
+ hid_t datatype, memtype = -1;
htri_t old_data;
size_t len;
HDF5_ERROR (datatype = H5Dget_type(dataset));
- HDF5_ERROR (datatype = H5Dget_type(dataset));
HDF5_ERROR (old_data = H5Tequal(datatype, H5T_NATIVE_CHAR));
if (old_data) {
hid_t dataspace;
@@ -1105,15 +1108,19 @@ static void ReadMetadata (fileset_t& fileset, hid_t file)
CCTK_WARN (CCTK_WARN_ALERT, "Old-style checkpoint data found.");
HDF5_ERROR (len = H5Sget_simple_extent_npoints(dataspace) + 1);
HDF5_ERROR (H5Sclose(dataspace));
+ HDF5_ERROR (memtype = H5Tcopy(H5T_NATIVE_CHAR));
} else {
HDF5_ERROR (len = H5Tget_size(datatype));
+ HDF5_ERROR (memtype = H5Tcopy(H5T_C_S1));
+ HDF5_ERROR (H5Tset_size(memtype, len));
}
vector<char> gs_str_buf(len);
char* gs_str = &gs_str_buf[0];
- HDF5_ERROR (H5Dread (dataset, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL,
+ HDF5_ERROR (H5Dread (dataset, memtype, H5S_ALL, H5S_ALL,
H5P_DEFAULT, gs_str));
HDF5_ERROR (H5Dclose (dataset));
+ HDF5_ERROR (H5Tclose (memtype));
HDF5_ERROR (H5Tclose (datatype));
istringstream gs_buf (gs_str);
diff --git a/Carpet/CarpetIOHDF5/test/input_initial_data/phi.h5 b/Carpet/CarpetIOHDF5/test/input_initial_data/phi.h5
index 1ed2aa856..06d1fbb1f 100644
--- a/Carpet/CarpetIOHDF5/test/input_initial_data/phi.h5
+++ b/Carpet/CarpetIOHDF5/test/input_initial_data/phi.h5
Binary files differ
diff --git a/Carpet/CarpetIOHDF5/test/input_initial_data/psi.h5 b/Carpet/CarpetIOHDF5/test/input_initial_data/psi.h5
index c7eddeec8..3f801678f 100644
--- a/Carpet/CarpetIOHDF5/test/input_initial_data/psi.h5
+++ b/Carpet/CarpetIOHDF5/test/input_initial_data/psi.h5
Binary files differ