diff options
-rw-r--r-- | param.ccl | 5 | ||||
-rw-r--r-- | schedule.ccl | 27 | ||||
-rw-r--r-- | src/DumpGH.c | 23 | ||||
-rw-r--r-- | src/DumpVar.c | 8 | ||||
-rw-r--r-- | src/GHExtension.c | 69 | ||||
-rw-r--r-- | src/Output1D.c | 27 | ||||
-rw-r--r-- | src/Output2D.c | 25 | ||||
-rw-r--r-- | src/Output3D.c | 25 | ||||
-rw-r--r-- | src/RecoverGH.c | 2 | ||||
-rw-r--r-- | src/RestoreFile.c | 12 | ||||
-rw-r--r-- | src/Startup.c | 2 |
11 files changed, 159 insertions, 66 deletions
@@ -139,7 +139,10 @@ STRING length "Default length of the hyperslab to stream" ######################### # Checkpointing requested ######################### -BOOLEAN checkpoint "Do checkpointing with HDF5" +BOOLEAN checkpoint "Do checkpointing with HDF5" STEERABLE = ALWAYS +{ +} "no" +BOOLEAN checkpoint_next "Checkpoint at next iteration" STEERABLE = ALWAYS { } "no" diff --git a/schedule.ccl b/schedule.ccl index 7d9ed82..54ce214 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -17,29 +17,20 @@ schedule SliceCenterSetup at BASEGRID after IOASCII_Choose1D ######################################################################## ### register checkpointing routines ######################################################################## -if (checkpoint && checkpoint_ID) +schedule IOHDF5_InitialDataDumpGH at CCTK_CPINITIAL { - schedule IOHDF5_InitialDataDumpGH at CCTK_CPINITIAL - { - LANG:C - } "Initial data checkpoint routine" -} + LANG:C +} "Initial data checkpoint routine" -if (checkpoint && checkpoint_every > 0) +schedule IOHDF5_ConditionallyDumpGH at CCTK_CHECKPOINT { - schedule IOHDF5_ConditionallyDumpGH at CCTK_CHECKPOINT - { - LANG:C - } "Regular checkpoint routine" -} + LANG:C +} "Regular checkpoint routine" -#if (checkpoint) +#schedule IOHDF5_TerminationDumpGH at CCTK_TERMINATE BEFORE Driver_Terminate #{ -# schedule IOHDF5_TerminationDumpGH at CCTK_TERMINATE BEFORE Driver_Terminate -# { -# LANG:C -# } "Termination checkpoint routine" -#} +# LANG:C +#} "Termination checkpoint routine" if (! CCTK_Equals (recover, "no") && *recover_file) { diff --git a/src/DumpGH.c b/src/DumpGH.c index 74d7729..803bb8f 100644 --- a/src/DumpGH.c +++ b/src/DumpGH.c @@ -18,6 +18,7 @@ #include "cctk.h" #include "cctk_Parameters.h" #include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" #include "ioHDF5GH.h" /* the rcs ID and its dummy funtion to use it */ @@ -52,13 +53,24 @@ void IOHDF5_ConditionallyDumpGH (cGH *GH) { DECLARE_CCTK_PARAMETERS - if (checkpoint_every > 0 && GH->cctk_iteration % checkpoint_every == 0) { - if (verbose) { + + if (checkpoint && + ((checkpoint_every > 0 && GH->cctk_iteration % checkpoint_every == 0) || + checkpoint_next)) + { + if (verbose) + { CCTK_INFO("------------------------------------------------------------"); CCTK_VInfo (CCTK_THORNSTRING, "Dumping periodic checkpoint file at " "iteration %d", GH->cctk_iteration); } IOHDF5_DumpGH (GH, CP_EVOLUTION_DATA); + + /* reset the 'checkpoint_next' parameter */ + if (checkpoint_next) + { + CCTK_ParameterSet ("checkpoint_next", CCTK_THORNSTRING, "no"); + } } } @@ -119,6 +131,7 @@ void IOHDF5_TerminationDumpGH (cGH *GH) void IOHDF5_InitialDataDumpGH (cGH *GH) { + DECLARE_CCTK_PARAMETERS /*** FIXME ***/ #if 0 @@ -145,7 +158,11 @@ void IOHDF5_InitialDataDumpGH (cGH *GH) } #endif #endif - IOHDF5_DumpGH (GH, CP_INITIAL_DATA); + + if (checkpoint && checkpoint_ID) + { + IOHDF5_DumpGH (GH, CP_INITIAL_DATA); + } } diff --git a/src/DumpVar.c b/src/DumpVar.c index f000024..e82cffb 100644 --- a/src/DumpVar.c +++ b/src/DumpVar.c @@ -156,11 +156,11 @@ int IOHDF5_DumpVar (cGH *GH, int index, int timelevel, ioHDF5Geo_t *geo, hid_t i } switch (CCTK_GroupTypeFromVarI (index)) { - case GROUP_SCALAR: + case CCTK_SCALAR: IOHDF5_DumpGS (GH, index, timelevel, iof, info.iohdf5_type); break; - case GROUP_ARRAY: - case GROUP_GF: + case CCTK_ARRAY: + case CCTK_GF: retval = IOHDF5_DumpGA (GH, index, timelevel, geo, iof, &info); break; default: @@ -300,7 +300,7 @@ static int IOHDF5_DumpGA (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_g pGH *pughGH; int myproc; int nprocs; - int dim,sdim; + int sdim; CCTK_INT *geom; /* Lower bounds, sizes and global shape of data */ void *outme; /* The data pointer to dump ... */ int free_outme; /* and whether it needs freeing */ diff --git a/src/GHExtension.c b/src/GHExtension.c index 4246036..c6faa95 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -22,8 +22,6 @@ #include "cctk_Parameters.h" #include "cctk_Arguments.h" -#include "CactusPUGH/PUGH/src/include/pugh.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "ioHDF5GH.h" void IOHDF5_DefaultGeo(cGH *GH, int sdim, ioHDF5Geo_t *geo); @@ -75,84 +73,107 @@ void *IOHDF5_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) int IOHDF5_InitGH (cGH *GH) { DECLARE_CCTK_PARAMETERS - int inum,idim,i; + int i; ioHDF5GH *myGH; - const cParamData *paramdata; - ioHDF5Geo_t geo_default; + myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")]; /* How often to output */ myGH->out1D_every = out_every > 0 ? out_every : -1; if (out1D_every > 0) + { myGH->out1D_every = out1D_every; - IOUtil_ParseVarsForOutput (out1D_vars, myGH->do_out1D); + } myGH->out2D_every = out_every > 0 ? out_every : -1; if (out2D_every > 0) + { myGH->out2D_every = out2D_every; - IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D); + } myGH->out3D_every = out_every > 0 ? out_every : -1; if (out3D_every > 0) + { myGH->out3D_every = out3D_every; - IOUtil_ParseVarsForOutput (out3D_vars, myGH->do_out3D); + } /* Check whether "outdir2D" and/or "outdir3D" was set. If so take these dirs otherwise default to "IO::outdir" */ - paramdata = CCTK_ParameterData ("outdir1D", CCTK_THORNSTRING); - if (paramdata && paramdata->n_set > 0) + if (CCTK_ParameterQueryTimesSet ("outdir1D", CCTK_THORNSTRING) > 0) + { myGH->outdir1D = strdup (outdir1D); + } else + { myGH->outdir1D = strdup (outdir); + } - paramdata = CCTK_ParameterData ("outdir2D", CCTK_THORNSTRING); - if (paramdata && paramdata->n_set > 0) + if (CCTK_ParameterQueryTimesSet ("outdir2D", CCTK_THORNSTRING) > 0) + { myGH->outdir2D = strdup (outdir2D); + } else + { myGH->outdir2D = strdup (outdir); + } - paramdata = CCTK_ParameterData ("outdir3D", CCTK_THORNSTRING); - if (paramdata && paramdata->n_set > 0) + if (CCTK_ParameterQueryTimesSet ("outdir3D", CCTK_THORNSTRING) > 0) + { myGH->outdir3D = strdup (outdir3D); + } else + { myGH->outdir3D = strdup (outdir); + } /* Create the output directories */ - if (CCTK_MyProc (GH) == 0) { + if (CCTK_MyProc (GH) == 0) + { i = CCTK_CreateDirectory (0755, myGH->outdir1D); if (i < 0) + { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating HDF5 1D output directory '%s'", myGH->outdir1D); + } else if (i > 0) + { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "HDF5 1D output directory '%s' already exists", myGH->outdir1D); + } i = CCTK_CreateDirectory (0755, myGH->outdir2D); if (i < 0) + { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating HDF5 2D output directory '%s'", myGH->outdir2D); + } else if (i > 0) + { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "HDF5 2D output directory '%s' already exists", myGH->outdir2D); + } i = CCTK_CreateDirectory (0755, myGH->outdir3D); if (i < 0) + { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating HDF5 3D output directory '%s'", myGH->outdir3D); + } else if (i > 0) + { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "HDF5 3D output directory '%s' already exists", myGH->outdir3D); + } } - for (inum=0; inum<CCTK_NumVars(); inum++) + for (i = 0; i < CCTK_NumVars (); i++) { - myGH->out2D_last [inum] = myGH->out3D_last [inum] = -1; - myGH->out1D_last [inum] = myGH->out3D_last [inum] = -1; + myGH->out2D_last [i] = myGH->out3D_last [i] = -1; + myGH->out1D_last [i] = myGH->out3D_last [i] = -1; } - - /* FIX ME default geometry should be set ehre, but has to + /* FIXME default geometry should be set ehre, but has to be done outside currently, because it needs spxyz and needs to scheduled at BASEGRID */ @@ -165,7 +186,9 @@ int IOHDF5_InitGH (cGH *GH) for (i = 0; i < 4; i++) { if ((myGH->timers[i] = CCTK_TimerCreateI ()) < 0) + { break; + } } if (i != 4) { @@ -187,6 +210,7 @@ int IOHDF5_InitGH (cGH *GH) return (0); } + void SliceCenterSetup(CCTK_ARGUMENTS) { DECLARE_CCTK_PARAMETERS @@ -194,15 +218,16 @@ void SliceCenterSetup(CCTK_ARGUMENTS) ioHDF5Geo_t geo_default; ioHDF5GH *myGH; + myGH = (ioHDF5GH *) cctkGH->extensions [CCTK_GHExtensionHandle ("IOHDF5")]; /* Loop over all slab dimension */ - for (idim=0;idim<IOHDF5_MAXDIM;idim++) { + for (idim=0;idim<IOHDF5_MAXDIM;idim++) + { IOHDF5_DefaultGeo(cctkGH, idim, &geo_default); /* Set the default HDF5 slab geometry for slab with dimension -idim-*/ for (inum=0; inum<CCTK_NumVars(); inum++) myGH->out_geo[inum][idim] = geo_default; } - } diff --git a/src/Output1D.c b/src/Output1D.c index 70c3b97..f601ef3 100644 --- a/src/Output1D.c +++ b/src/Output1D.c @@ -18,7 +18,6 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "ioHDF5GH.h" @@ -26,6 +25,7 @@ int IOHDF5_TimeFor1D (cGH *GH, int index); int IOHDF5_Output1DVarAs (cGH *GH, const char *var, const char *alias); static void CheckSteerableParameters (ioHDF5GH *myGH); +static void SetOutputFlag (int index, const char *optstring, void *arg); /*@@ @@ -254,7 +254,7 @@ static void CheckSteerableParameters (ioHDF5GH *myGH) { DECLARE_CCTK_PARAMETERS int out1D_vars_current_nset; - static int out1D_vars_lastset = 0; + static int out1D_vars_lastset = -1; /* How often to output */ @@ -262,14 +262,33 @@ static void CheckSteerableParameters (ioHDF5GH *myGH) if (out1D_every > 0) myGH->out1D_every = out1D_every; - /* re-parse the 'out1D_vars' parameter if it was changed */ + /* re-parse the 'IOHDF5::out1D_vars' parameter if it was changed */ out1D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out1D_vars", CCTK_THORNSTRING); if (out1D_vars_current_nset != out1D_vars_lastset) { - IOUtil_ParseVarsForOutput (out1D_vars, myGH->do_out1D); + memset (myGH->do_out1D, 0, CCTK_NumVars ()); + CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH->do_out1D, + CCTK_GROUP_OR_VAR); /* Save the last setting of 'out1D_vars' parameter */ out1D_vars_lastset = out1D_vars_current_nset; } } + + +/* callback for CCTK_TraverseString() to set the output flag + for the given variable */ +static void SetOutputFlag (int index, const char *optstring, void *arg) +{ + char *flags = (char *) arg; + + + flags[index] = 1; + + if (optstring) + { + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Optional string '%s' in variable name ignored", optstring); + } +} diff --git a/src/Output2D.c b/src/Output2D.c index b07efc8..021b258 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -18,7 +18,6 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "ioHDF5GH.h" @@ -26,6 +25,7 @@ int IOHDF5_TimeFor2D (cGH *GH, int index); int IOHDF5_Output2DVarAs (cGH *GH, const char *var, const char *alias); static void CheckSteerableParameters (ioHDF5GH *myGH); +static void SetOutputFlag (int index, const char *optstring, void *arg); /*@@ @@ -262,14 +262,33 @@ static void CheckSteerableParameters (ioHDF5GH *myGH) if (out2D_every > 0) myGH->out2D_every = out2D_every; - /* re-parse the 'out2D_vars' parameter if it was changed */ + /* re-parse the 'IOHDF5::out2D_vars' parameter if it was changed */ out2D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out2D_vars", CCTK_THORNSTRING); if (out2D_vars_current_nset != out2D_vars_lastset) { - IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D); + memset (myGH->do_out2D, 0, CCTK_NumVars ()); + CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH->do_out2D, + CCTK_GROUP_OR_VAR); /* Save the last setting of 'out2D_vars' parameter */ out2D_vars_lastset = out2D_vars_current_nset; } } + + +/* callback for CCTK_TraverseString() to set the output flag + for the given variable */ +static void SetOutputFlag (int index, const char *optstring, void *arg) +{ + char *flags = (char *) arg; + + + flags[index] = 1; + + if (optstring) + { + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Optional string '%s' in variable name ignored", optstring); + } +} diff --git a/src/Output3D.c b/src/Output3D.c index caaca4a..5bfcfaf 100644 --- a/src/Output3D.c +++ b/src/Output3D.c @@ -18,7 +18,6 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "ioHDF5GH.h" @@ -26,6 +25,7 @@ int IOHDF5_TimeFor3D (cGH *GH, int index); int IOHDF5_Output3DVarAs (cGH *GH, const char *var, const char *alias); static void CheckSteerableParameters (ioHDF5GH *myGH); +static void SetOutputFlag (int index, const char *optstring, void *arg); /*@@ @@ -253,14 +253,33 @@ static void CheckSteerableParameters (ioHDF5GH *myGH) if (out3D_every > 0) myGH->out3D_every = out3D_every; - /* re-parse the 'out3D_vars' parameter if it was changed */ + /* re-parse the 'IOHDF5::out3D_vars' parameter if it was changed */ out3D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out3D_vars", CCTK_THORNSTRING); if (out3D_vars_current_nset != out3D_vars_lastset) { - IOUtil_ParseVarsForOutput (out3D_vars, myGH->do_out3D); + memset (myGH->do_out3D, 0, CCTK_NumVars ()); + CCTK_TraverseString (out3D_vars, SetOutputFlag, myGH->do_out3D, + CCTK_GROUP_OR_VAR); /* Save the last setting of 'out3D_vars' parameter */ out3D_vars_lastset = out3D_vars_current_nset; } } + + +/* callback for CCTK_TraverseString() to set the output flag + for the given variable */ +static void SetOutputFlag (int index, const char *optstring, void *arg) +{ + char *flags = (char *) arg; + + + flags[index] = 1; + + if (optstring) + { + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Optional string '%s' in variable name ignored", optstring); + } +} diff --git a/src/RecoverGH.c b/src/RecoverGH.c index e97e86f..29249bc 100644 --- a/src/RecoverGH.c +++ b/src/RecoverGH.c @@ -26,7 +26,7 @@ #include "cctk.h" #include "cctk_Parameters.h" #include "CactusPUGH/PUGH/src/include/pugh.h" -#include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" #include "ioHDF5GH.h" diff --git a/src/RestoreFile.c b/src/RestoreFile.c index 78eaa78..ef9db7b 100644 --- a/src/RestoreFile.c +++ b/src/RestoreFile.c @@ -272,10 +272,10 @@ static int GetCommonAttributes (cGH *GH, hid_t dataset, const char *datasetname, if (groupdata.dim != rank_stored) flag = 1; switch (groupdata.grouptype) { - case GROUP_SCALAR: + case CCTK_SCALAR: break; - case GROUP_ARRAY: - case GROUP_GF: + case CCTK_ARRAY: + case CCTK_GF: extras = ((pGA ***) PUGH_pGH (GH)->variables)[*index][*timelevel]->extras; dims = unchunked ? extras->nsize : extras->lnsize; for (i = 0; i < groupdata.dim; i++) @@ -558,11 +558,11 @@ static herr_t processDataset (hid_t group, const char *datasetname, void *arg) /* Read in the data */ switch (gtype) { - case GROUP_SCALAR: + case CCTK_SCALAR: IOHDF5_RestoreGS (dataset, index, timelevel, &rec_info); break; - case GROUP_GF: - case GROUP_ARRAY: + case CCTK_GF: + case CCTK_ARRAY: IOHDF5_RestoreGA (dataset, index, timelevel, &rec_info); break; default: diff --git a/src/Startup.c b/src/Startup.c index 2ec6c14..a2e6690 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -15,7 +15,7 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" /* prototypes of functions to be registered */ |