aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc26
-rw-r--r--Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh4
-rw-r--r--Carpet/CarpetIOHDF5/src/Input.cc19
3 files changed, 46 insertions, 3 deletions
diff --git a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc
index da55245dc..a0744f481 100644
--- a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc
+++ b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc
@@ -253,6 +253,8 @@ static void* SetupGH (tFleshConfig* const fleshconfig,
myGH->cp_filename_index = 0;
myGH->checkpoint_keep = abs (checkpoint_keep);
myGH->cp_filename_list = (char **) calloc (myGH->checkpoint_keep, sizeof (char *));
+ myGH->recovery_num_filenames = 0;
+ myGH->recovery_filename_list = NULL;
myGH->out_vars = strdup ("");
myGH->out_every_default = out_every - 1;
@@ -798,13 +800,31 @@ static int Checkpoint (const cGH* const cctkGH, int called_from)
CarpetIOHDF5GH *myGH =
(CarpetIOHDF5GH *) CCTK_GHExtension (cctkGH, CCTK_THORNSTRING);
+ // should an older checkpoint file be removed ?
if (myGH->cp_filename_list[myGH->cp_filename_index]) {
- remove (myGH->cp_filename_list[myGH->cp_filename_index]);
- free (myGH->cp_filename_list[myGH->cp_filename_index]);
- myGH->cp_filename_list[myGH->cp_filename_index] = NULL;
+ // check whether the recovery checkpoint (which can be a list of
+ // several chunked files) or a checkpoint file should be removed
+ if (myGH->recovery_filename_list) {
+ for (int i = 0; i < myGH->recovery_num_filenames; i++) {
+ if (myGH->recovery_filename_list[i]) {
+ remove (myGH->recovery_filename_list[i]);
+ free (myGH->recovery_filename_list[i]);
+ }
+ }
+ free (myGH->recovery_filename_list);
+ myGH->recovery_filename_list = NULL;
+ } else {
+ remove (myGH->cp_filename_list[myGH->cp_filename_index]);
+ free (myGH->cp_filename_list[myGH->cp_filename_index]);
+ }
}
+
+ // add this checkpoint to the checkpoint filename ring buffer
myGH->cp_filename_list[myGH->cp_filename_index] = strdup (filename);
myGH->cp_filename_index = (myGH->cp_filename_index+1) % checkpoint_keep;
+
+ // since the 'checkpoint_keep' parameter is steerable,
+ // we may need to resize the ring buffer
if (myGH->checkpoint_keep != checkpoint_keep) {
char **cp_filename_list = (char **) calloc (checkpoint_keep,
sizeof (char *));
diff --git a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh
index 0210adcff..55344bc54 100644
--- a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh
+++ b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh
@@ -75,6 +75,10 @@ typedef struct
int cp_filename_index;
char **cp_filename_list;
+ // list of recovery files to remove
+ int recovery_num_filenames;
+ char **recovery_filename_list;
+
// iteration number of the last checkpoint
int last_checkpoint_iteration;
diff --git a/Carpet/CarpetIOHDF5/src/Input.cc b/Carpet/CarpetIOHDF5/src/Input.cc
index aa0f52854..b45dd21b8 100644
--- a/Carpet/CarpetIOHDF5/src/Input.cc
+++ b/Carpet/CarpetIOHDF5/src/Input.cc
@@ -339,6 +339,22 @@ int Recover (cGH* cctkGH, const char *basefilename, int called_from)
}
const ioGH* ioUtilGH = (const ioGH*) CCTK_GHExtension (cctkGH, "IO");
+ CarpetIOHDF5GH* myGH =
+ (CarpetIOHDF5GH*) CCTK_GHExtension (cctkGH, CCTK_THORNSTRING);
+ // allocate list of recovery filenames
+ // if the recovery checkpoint should be removed eventually
+ if (in_recovery and not recover_and_remove and checkpoint_keep > 0) {
+ if (not myGH->recovery_filename_list) {
+ myGH->recovery_num_filenames = fileset->files.size();
+ myGH->recovery_filename_list =
+ (char **) calloc (fileset->files.size(), sizeof (char **));
+ assert (myGH->cp_filename_index == 0);
+
+ // add a dummy entry in the checkpoint filename ring buffer
+ myGH->cp_filename_list[myGH->cp_filename_index] = "bla";
+ myGH->cp_filename_index = (myGH->cp_filename_index+1) % checkpoint_keep;
+ }
+ }
// loop over all input files of this set
for (unsigned int i = 0; i < fileset->files.size(); i++) {
@@ -364,6 +380,9 @@ int Recover (cGH* cctkGH, const char *basefilename, int called_from)
HDF5_ERROR (H5Giterate (file.file, "/", NULL, BrowseDatasets, &file));
}
assert (file.patches.size() > 0);
+ if (myGH->recovery_filename_list and not myGH->recovery_filename_list[i]) {
+ myGH->recovery_filename_list[i] = strdup (file.filename);
+ }
// some optimisation for the case when all processors recover
// from a single chunked checkpoint file: