aboutsummaryrefslogtreecommitdiff
path: root/src/RecoverVar.c
diff options
context:
space:
mode:
authortradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2001-04-19 21:09:35 +0000
committertradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2001-04-19 21:09:35 +0000
commitfb4dafb0cd8c3d6e2db422ccdc46679bbf2c26f8 (patch)
treeee0df7093203e2f8e34da3fbb4efe4fb61c367db /src/RecoverVar.c
parent37d6c29790cb185ec28177168266c74b65d3e53a (diff)
Check if a checkpoint file has got a 'Cactus version' attribute in the
global attributes group. If not it indicates a checkpoint file with the old timelevel naming scheme so we have to decrement the timelevel to restore for variables with multiple timelevels. This fix lets the IOHDF5 recovery testsuite (with the old checkpoint file) pass again. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@24 7842ec3a-9562-4be5-9c5b-06ba18f2b668
Diffstat (limited to 'src/RecoverVar.c')
-rw-r--r--src/RecoverVar.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/src/RecoverVar.c b/src/RecoverVar.c
index 2347501..ebe93fa 100644
--- a/src/RecoverVar.c
+++ b/src/RecoverVar.c
@@ -35,6 +35,7 @@ typedef struct
int ioproc;
int ioproc_every;
int unchunked;
+ int has_version;
} iterate_info_t;
typedef struct
@@ -88,6 +89,7 @@ int IOHDF5Util_RecoverVariables (cGH *GH,
info.ioproc = fileinfo->ioproc;
info.unchunked = fileinfo->unchunked;
info.ioproc_every = fileinfo->ioproc_every;
+ info.has_version = fileinfo->has_version;
#ifdef CCTK_MPI
/* Get the handle for PUGH extensions */
@@ -147,16 +149,12 @@ int IOHDF5Util_RecoverVariables (cGH *GH,
break;
}
- switch (CCTK_VarTypeI (vindex))
+ mpi_type = PUGH_MPIDataType (pughGH, CCTK_VarTypeI (vindex);
+ if (! mpi_type)
{
- case CCTK_VARIABLE_CHAR: mpi_type = PUGH_MPI_CHAR; break;
- case CCTK_VARIABLE_INT: mpi_type = PUGH_MPI_INT; break;
- case CCTK_VARIABLE_REAL: mpi_type = PUGH_MPI_REAL; break;
- case CCTK_VARIABLE_COMPLEX: mpi_type = pughGH->PUGH_mpi_complex; break;
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unsupported datatype %d", CCTK_VarTypeI (vindex));
- continue;
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Unsupported datatype %d", CCTK_VarTypeI (vindex));
+ continue;
}
/* receive following data from my IO processor */
@@ -179,13 +177,15 @@ int IOHDF5Util_RecoverVariables (cGH *GH,
int IOHDF5Util_RecoverGHextensions (cGH *GH,
fileinfo_t *fileinfo)
{
- hid_t group;
+ hid_t group, version_attr;
CCTK_REAL4 real4Buffer;
- CCTK_INT4 int4Buffer[3];
+ CCTK_INT4 int4Buffer[4];
if (CCTK_MyProc (GH) == 0)
{
+ int4Buffer[3] = 0;
+
/* all the important global attributes and GH extensions
are stored in the GLOBAL_ATTRIBUTES_GROUP group */
group = H5Gopen (fileinfo->file, GLOBAL_ATTRIBUTES_GROUP);
@@ -198,6 +198,14 @@ int IOHDF5Util_RecoverGHextensions (cGH *GH,
READ_ATTRIBUTE (group, "main_loop_index", IOHDF5_INT4, &int4Buffer[2]);
READ_ATTRIBUTE (group, "cctk_time", IOHDF5_REAL4, &real4Buffer);
+ /* check if there exists a version attribute */
+ version_attr = H5Aopen_name (group, "Cactus version");
+ int4Buffer[3] = version_attr >= 0;
+ if (int4Buffer[3])
+ {
+ IOHDF5_ERROR (H5Aclose (version_attr));
+ }
+
IOHDF5_ERROR (H5Gclose (group));
}
@@ -213,7 +221,7 @@ int IOHDF5Util_RecoverGHextensions (cGH *GH,
/* NOTE: We have to use MPI_COMM_WORLD here
because PUGH_COMM_WORLD is not yet set up at parameter recovery time.
We also assume that PUGH_MPI_INT4 is a compile-time defined datatype. */
- CACTUS_MPI_ERROR (MPI_Bcast (int4Buffer, 3, PUGH_MPI_INT4, 0,MPI_COMM_WORLD));
+ CACTUS_MPI_ERROR (MPI_Bcast (int4Buffer, 4, PUGH_MPI_INT4, 0,MPI_COMM_WORLD));
if (int4Buffer[0])
{
CACTUS_MPI_ERROR (MPI_Bcast (&real4Buffer, 1, PUGH_MPI_REAL4, 0,
@@ -227,6 +235,7 @@ int IOHDF5Util_RecoverGHextensions (cGH *GH,
GH->cctk_iteration = int4Buffer[1];
CCTK_SetMainLoopIndex ((int) int4Buffer[2]);
}
+ fileinfo->has_version = (int) int4Buffer[3];
/* Return 0 for success otherwise negative */
return (int4Buffer[0] ? 0 : -1);
@@ -250,6 +259,7 @@ int IOHDF5Util_RecoverParameters (fileinfo_t *fileinfo)
/* To make the compiler happy */
group = attr = 0;
parameters = NULL;
+ parameterSize = 0;
if (CCTK_MyProc (GH) == 0)
{
@@ -343,9 +353,15 @@ int IOHDF5Util_RecoverParameters (fileinfo_t *fileinfo)
to restore are stored in {*vindex, *gtype, *timelevel}, and 0 is returned.
*/
-static int GetCommonAttributes (cGH *GH, hid_t dataset, const char *datasetname,
- int unchunked, int *vindex, int *grouptype,
- int *timelevel, int is_group)
+static int GetCommonAttributes (cGH *GH,
+ hid_t dataset,
+ const char *datasetname,
+ int unchunked,
+ int *vindex,
+ int *grouptype,
+ int *timelevel,
+ int is_group,
+ int has_version)
{
cGroup group_static_data;
cGroupDynamicData group_dynamic_data;
@@ -412,6 +428,11 @@ static int GetCommonAttributes (cGH *GH, hid_t dataset, const char *datasetname,
"Number of timelevels don't match for '%s'", fullvarname);
return (-1);
}
+ /* increment the timelevel for data from old checkpoint files */
+ if (! has_version && group_static_data.numtimelevels > 1)
+ {
+ (*timelevel)++;
+ }
/* open the first chunk to determine datatype, dims and sizes
if the dataset is a chunk group */
if (is_group)
@@ -444,7 +465,7 @@ static int GetCommonAttributes (cGH *GH, hid_t dataset, const char *datasetname,
IOHDF5_ERROR (ndims_stored = H5Sget_simple_extent_ndims (dataspace));
dims_stored = (hsize_t *) malloc (ndims_stored * sizeof (hsize_t));
IOHDF5_ERROR (rank_stored = H5Sget_simple_extent_dims (dataspace,
- dims_stored, NULL));
+ dims_stored, NULL));
/* scalars are stored as rank 0 in HDF5 but have rank 1 in Cactus */
if (rank_stored == 0)
{
@@ -721,7 +742,8 @@ static herr_t processDataset (hid_t group,
/* read in the dataset's attributes and verify them */
if (GetCommonAttributes (it_info->GH, dataset, datasetname,
- it_info->unchunked, &vindex, &gtype, &timelevel, is_group) < 0)
+ it_info->unchunked, &vindex, &gtype, &timelevel,
+ is_group, it_info->has_version) < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Ignoring dataset '%s'", datasetname);