diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2011-11-21 15:08:28 -0500 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 19:55:00 +0000 |
commit | 6796795b92e67d9bfeaa58e8943a27174de6d229 (patch) | |
tree | 7d28a9bf288a58ccd412a9cea9e03c90d5337b4b /Carpet/CarpetIOHDF5 | |
parent | 808b6ebe3dec9c3cb3bf5762dabbe58a5387f7c0 (diff) |
CarpetIOHDF5: Introduce API to checkpoint only a subset of groups
Introduce a new API to checkpoint only a subset of group, via an
aliased function IO_SetCheckpointGroups. This can be used for
simulation spawning, i.e. off-loading certain calculations (e.g.
analysis) outside of the main simulation.
Diffstat (limited to 'Carpet/CarpetIOHDF5')
-rw-r--r-- | Carpet/CarpetIOHDF5/interface.ccl | 11 | ||||
-rw-r--r-- | Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc | 31 | ||||
-rw-r--r-- | Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh | 10 |
3 files changed, 50 insertions, 2 deletions
diff --git a/Carpet/CarpetIOHDF5/interface.ccl b/Carpet/CarpetIOHDF5/interface.ccl index e14a9c143..55d092e85 100644 --- a/Carpet/CarpetIOHDF5/interface.ccl +++ b/Carpet/CarpetIOHDF5/interface.ccl @@ -63,6 +63,17 @@ REQUIRES FUNCTION IO_TruncateOutputFiles +# Checkpoint only a restricted set of variables +# (Set ngroups=-1 to checkpoint all variables.) +CCTK_INT \ +FUNCTION IO_SetCheckpointGroups(CCTK_INT ARRAY IN groups, \ + CCTK_INT IN ngroups) +PROVIDES FUNCTION IO_SetCheckpointGroups \ + WITH CarpetIOHDF5_SetCheckpointGroups \ + LANGUAGE C + + + # Return a pointer to an unmodifiable C string # which contains a unique ID for this configuration CCTK_POINTER_TO_CONST \ diff --git a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc index 12c9a68ea..c3053c332 100644 --- a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc +++ b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.cc @@ -229,6 +229,28 @@ void CarpetIOHDF5_TerminationCheckpoint (CCTK_ARGUMENTS) } +CCTK_INT CarpetIOHDF5_SetCheckpointGroups (CCTK_INT const * const groups, + CCTK_INT const ngroups) +{ + if (ngroups == -1) { + // Checkpoint all groups + groups_to_checkpoint.clear(); + } else { + assert (ngroups >= 0); + groups_to_checkpoint.resize(CCTK_NumGroups()); + for (int n=0; n<CCTK_NumGroups(); ++n) { + groups_to_checkpoint.at(n) = false; + } + for (int n=0; n<ngroups; ++n) { + groups_to_checkpoint.at(groups[n]) = true; + } + } + return 0; +} + +vector<bool> groups_to_checkpoint; + + hid_t CCTKtoHDF5_Datatype (const cGH* const cctkGH, int cctk_type, bool single_precision) { @@ -938,9 +960,16 @@ static void Checkpoint (const cGH* const cctkGH, int called_from) } for (int group = CCTK_NumGroups () - 1; group >= 0; group--) { + /* skip variables which have been disabled for checkpointing */ + if (not groups_to_checkpoint.empty() and + not groups_to_checkpoint.at(group)) + { + continue; + } /* only dump groups which have storage assigned */ if (CCTK_QueryGroupStorageI (cctkGH, group) <= 0 or - CCTK_NumVarsInGroupI(group) == 0) { + CCTK_NumVarsInGroupI(group) == 0) + { continue; } diff --git a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh index dfa6a276e..3cff7bf3b 100644 --- a/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh +++ b/Carpet/CarpetIOHDF5/src/CarpetIOHDF5.hh @@ -247,7 +247,8 @@ namespace CarpetIOHDF5 }; // struct IOHDF5 - // scheduled routines (must be declared as C according to schedule.ccl) + // scheduled and aliased routines (must be declared as C according + // to schedule.ccl) extern "C" { int CarpetIOHDF5_RecoverParameters (void); @@ -261,8 +262,15 @@ namespace CarpetIOHDF5 void CarpetIOHDF5_EvolutionCheckpoint (CCTK_ARGUMENTS); void CarpetIOHDF5_TerminationCheckpoint (CCTK_ARGUMENTS); + CCTK_INT CarpetIOHDF5_SetCheckpointGroups (CCTK_INT const *groups, + CCTK_INT ngroups); + } // extern "C" + // Which groups should be checkpointed. If empty, all variables + // should be checkpointed (default). + extern vector<bool> groups_to_checkpoint; + } // namespace CarpetIOHDF5 #endif // !defined(CARPETIOHDF5_HH) |