From 6dfcface9a2d26e6ba3f6a6de60dec0617a70796 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 2 Jun 2008 15:18:50 +0200 Subject: CarpetIOHDF5: Correct error in determining checkpointing interval Correct error in determining checkpointing interval after restarting. --- Carpet/CarpetIOHDF5/schedule.ccl | 11 ++++------- Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc | 32 +++++++++++++++++++------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Carpet/CarpetIOHDF5/schedule.ccl b/Carpet/CarpetIOHDF5/schedule.ccl index 0ff1986a5..25263ccc8 100644 --- a/Carpet/CarpetIOHDF5/schedule.ccl +++ b/Carpet/CarpetIOHDF5/schedule.ccl @@ -13,14 +13,11 @@ schedule CarpetIOHDF5_Init at BASEGRID OPTIONS: global } "Initialisation routine" -if (checkpoint && checkpoint_ID) +schedule CarpetIOHDF5_InitialDataCheckpoint at CPINITIAL { - schedule CarpetIOHDF5_InitialDataCheckpoint at CPINITIAL - { - LANG: C - OPTIONS: meta - } "Initial data checkpoint routine" -} + LANG: C + OPTIONS: meta +} "Initial data checkpoint routine" schedule CarpetIOHDF5_EvolutionCheckpoint at CHECKPOINT { diff --git a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc index f97e62570..e00494f3c 100644 --- a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc +++ b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc @@ -35,6 +35,7 @@ using namespace Carpet; // when was the last checkpoint written ? static int last_checkpoint_iteration = -1; +static CCTK_REAL last_checkpoint_walltime; // registered GH extension setup routine @@ -108,6 +109,10 @@ void CarpetIOHDF5_Init (CCTK_ARGUMENTS) *this_iteration = -1; *next_output_iteration = 0; *next_output_time = cctk_time; + + // Initialise checkpointing intervals + last_checkpoint_iteration = cctk_iteration; + last_checkpoint_walltime = CCTK_RunTime() / 3600.0; } @@ -116,12 +121,14 @@ void CarpetIOHDF5_InitialDataCheckpoint (CCTK_ARGUMENTS) DECLARE_CCTK_PARAMETERS; - if (not CCTK_Equals (verbose, "none")) { - CCTK_INFO ("---------------------------------------------------------"); - CCTK_INFO ("Dumping initial data checkpoint"); - CCTK_INFO ("---------------------------------------------------------"); + if (checkpoint and checkpoint_ID) { + if (not CCTK_Equals (verbose, "none")) { + CCTK_INFO ("---------------------------------------------------------"); + CCTK_INFO ("Dumping initial data checkpoint"); + CCTK_INFO ("---------------------------------------------------------"); + } + Checkpoint (cctkGH, CP_INITIAL_DATA); } - Checkpoint (cctkGH, CP_INITIAL_DATA); } @@ -131,8 +138,6 @@ 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; @@ -154,12 +159,6 @@ 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"); - } } } @@ -785,6 +784,9 @@ static void Checkpoint (const cGH* const cctkGH, int called_from) error_count += WriteMetadata (cctkGH, nioprocs, -1, -1, true, file); } + // remember the current wall time + CCTK_REAL const walltime = CCTK_RunTime() / 3600.0; + // now dump the grid variables on all mglevels, reflevels, maps and components BEGIN_MGLEVEL_LOOP (cctkGH) { @@ -961,6 +963,10 @@ static void Checkpoint (const cGH* const cctkGH, int called_from) // save the iteration number of this checkpoint last_checkpoint_iteration = cctkGH->cctk_iteration; + last_checkpoint_walltime = walltime; + if (checkpoint_next) { + CCTK_ParameterSet ("checkpoint_next", CCTK_THORNSTRING, "no"); + } // free allocated resources free (tempname); -- cgit v1.2.3