aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2008-05-12 16:52:52 -0500
committerErik Schnetter <schnetter@cct.lsu.edu>2008-05-12 16:52:52 -0500
commitc2d99e93a19643107104c4e5e8b5dd3529964af8 (patch)
tree19729fd15b4dfddf1c28737ea874bd394d04e5ea
parentf6ce25b3d0e219e2fe467ebef56dc9f359938fa8 (diff)
CarpetIOHDF5: Implement checkpoint_every_walltime_hours
-rw-r--r--Carpet/CarpetIOHDF5/param.ccl1
-rw-r--r--Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc18
2 files changed, 17 insertions, 2 deletions
diff --git a/Carpet/CarpetIOHDF5/param.ccl b/Carpet/CarpetIOHDF5/param.ccl
index a133a754f..bbaca928b 100644
--- a/Carpet/CarpetIOHDF5/param.ccl
+++ b/Carpet/CarpetIOHDF5/param.ccl
@@ -17,6 +17,7 @@ USES KEYWORD out_save_parameters
USES BOOLEAN abort_on_io_errors
USES INT checkpoint_every
+USES REAL checkpoint_every_walltime_hours
USES INT checkpoint_keep
USES BOOLEAN checkpoint_ID
USES BOOLEAN recover_and_remove
diff --git a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc
index 68fbc31b5..c9662eb26 100644
--- a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc
+++ b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc
@@ -131,9 +131,21 @@ void CarpetIOHDF5_EvolutionCheckpoint (CCTK_ARGUMENTS)
DECLARE_CCTK_PARAMETERS;
+ static CCTK_INT last_checkpoint_iteration = 0;
+ static CCTK_REAL last_checkpoint_walltime = 0.0;
+ CCTK_INT const iteration = cctk_iteration;
+ CCTK_REAL const walltime = CCTK_RunTime() / 3600.0;
+
+ bool const checkpoint_by_iteration =
+ checkpoint_every > 0 and
+ iteration >= last_checkpoint_iteration + checkpoint_every;
+ bool const checkpoint_by_walltime =
+ checkpoint_every_walltime_hours > 0 and
+ walltime >= last_checkpoint_walltime + checkpoint_every_walltime_hours;
+
if (checkpoint and
- ((checkpoint_every > 0 and cctk_iteration % checkpoint_every == 0) or
- checkpoint_next)) {
+ (checkpoint_by_iteration or checkpoint_by_walltime or checkpoint_next))
+ {
if (not CCTK_Equals (verbose, "none")) {
CCTK_INFO ("---------------------------------------------------------");
CCTK_VInfo (CCTK_THORNSTRING, "Dumping periodic checkpoint at "
@@ -143,6 +155,8 @@ void CarpetIOHDF5_EvolutionCheckpoint (CCTK_ARGUMENTS)
Checkpoint (cctkGH, CP_EVOLUTION_DATA);
+ last_checkpoint_iteration = iteration;
+ last_checkpoint_walltime = walltime;
if (checkpoint_next) {
CCTK_ParameterSet ("checkpoint_next", CCTK_THORNSTRING, "no");
}