diff options
author | schnetter <> | 2004-05-21 16:11:00 +0000 |
---|---|---|
committer | schnetter <> | 2004-05-21 16:11:00 +0000 |
commit | d7842effa63fcb225fb3514dd451804d4ecc57a4 (patch) | |
tree | 30d9689337d20ca6848176b734bde328bc9c992c | |
parent | 4a9bebb3765b2a97ea502c5a4c5ab59c4c92ff90 (diff) |
Add out_dt output criterion.
Add out_dt output criterion.
Correct return types.
darcs-hash:20040521161134-07bb3-605eedc5f4e23ea1d7022f6c26c6af7303e11055.gz
-rw-r--r-- | Carpet/CarpetIOHDF5/interface.ccl | 8 | ||||
-rw-r--r-- | Carpet/CarpetIOHDF5/param.ccl | 20 | ||||
-rw-r--r-- | Carpet/CarpetIOHDF5/schedule.ccl | 8 | ||||
-rw-r--r-- | Carpet/CarpetIOHDF5/src/iohdf5.cc | 109 | ||||
-rw-r--r-- | Carpet/CarpetIOHDF5/src/iohdf5.h | 5 | ||||
-rw-r--r-- | Carpet/CarpetIOHDF5/src/iohdf5chckpt_recover.cc | 2 |
6 files changed, 128 insertions, 24 deletions
diff --git a/Carpet/CarpetIOHDF5/interface.ccl b/Carpet/CarpetIOHDF5/interface.ccl index e25ac2ebf..d152b1c9f 100644 --- a/Carpet/CarpetIOHDF5/interface.ccl +++ b/Carpet/CarpetIOHDF5/interface.ccl @@ -1,5 +1,5 @@ # Interface definition for thorn CarpetIOHDF5 -# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/interface.ccl,v 1.3 2004/05/04 22:52:39 schnetter Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/interface.ccl,v 1.4 2004/05/21 18:11:34 schnetter Exp $ IMPLEMENTS: IOHDF5 @@ -14,3 +14,9 @@ uses include header: data.hh uses include header: gdata.hh uses include header: ggf.hh + + + +CCTK_INT next_output_iteration TYPE=scalar +CCTK_REAL next_output_time TYPE=scalar +CCTK_INT this_iteration TYPE=scalar diff --git a/Carpet/CarpetIOHDF5/param.ccl b/Carpet/CarpetIOHDF5/param.ccl index 4459174c8..d44da1559 100644 --- a/Carpet/CarpetIOHDF5/param.ccl +++ b/Carpet/CarpetIOHDF5/param.ccl @@ -1,5 +1,5 @@ # Parameter definitions for thorn CarpetIOHDF5 -# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/param.ccl,v 1.9 2004/04/09 18:32:14 schnetter Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/param.ccl,v 1.10 2004/05/21 18:11:34 schnetter Exp $ @@ -7,7 +7,9 @@ shares: IO USES STRING out_dir +USES KEYWORD out_criterion USES CCTK_INT out_every +USES CCTK_REAL out_dt USES INT checkpoint_every USES INT checkpoint_keep @@ -50,6 +52,14 @@ CCTK_STRING out3D_extension "File extension to use for 3D CarpetIOHDF5 output" S ".*" :: "File extension (including a leading dot, if desired)" } ".h5" +KEYWORD out3D_criterion "Criterion to select 3D CarpetIOHDF5 output intervals, overrides out_every" STEERABLE = ALWAYS +{ + "default" :: "Use IO::out_criterion" + "never" :: "Never output" + "iteration" :: "Output every so many iterations" + "time" :: "Output every that much coordinate time" +} "default" + CCTK_INT out3D_every "How often to do 3D CarpetIOHDF5 output, overrides out_every" STEERABLE = ALWAYS { 1:* :: "Output every so many time steps" @@ -57,6 +67,14 @@ CCTK_INT out3D_every "How often to do 3D CarpetIOHDF5 output, overrides out_ever -2 :: "Use IO::out_every" } -2 +REAL out3D_dt "How often to do 3D CarpetIOHDF5 output, overrides IO::out_dt" STEERABLE = ALWAYS +{ + (0:* :: "In intervals of that much coordinate time" + 0 :: "As often as possible" + -1 :: "Disable output" + -2 :: "Default to IO::out_dt" +} -2 + CCTK_STRING in3D_dir "Name of 3D CarpetIOHDF5 input directory" STEERABLE = ALWAYS diff --git a/Carpet/CarpetIOHDF5/schedule.ccl b/Carpet/CarpetIOHDF5/schedule.ccl index f2c5c6130..d3d25d2c0 100644 --- a/Carpet/CarpetIOHDF5/schedule.ccl +++ b/Carpet/CarpetIOHDF5/schedule.ccl @@ -1,11 +1,17 @@ # Schedule definitions for thorn CarpetIOHDF5 -# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/schedule.ccl,v 1.6 2004/03/18 15:12:45 cott Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/schedule.ccl,v 1.7 2004/05/21 18:11:34 schnetter Exp $ schedule CarpetIOHDF5Startup at STARTUP after IOUtil_Startup { LANG: C } "Startup routine" +schedule CarpetIOHDF5Init at INITIAL +{ + LANG: C + OPTIONS: global +} "Initialisation routine" + schedule CarpetIOHDF5ReadData at INITIAL { LANG: C diff --git a/Carpet/CarpetIOHDF5/src/iohdf5.cc b/Carpet/CarpetIOHDF5/src/iohdf5.cc index 7afd88dee..f9de8183b 100644 --- a/Carpet/CarpetIOHDF5/src/iohdf5.cc +++ b/Carpet/CarpetIOHDF5/src/iohdf5.cc @@ -17,7 +17,7 @@ #include "cctk_Parameters.h" extern "C" { - static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5.cc,v 1.29 2004/05/17 14:40:12 bzink Exp $"; + static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5.cc,v 1.30 2004/05/21 18:11:34 schnetter Exp $"; CCTK_FILEVERSION(Carpet_CarpetIOHDF5_iohdf5_cc); } @@ -84,6 +84,17 @@ namespace CarpetIOHDF5 { + void CarpetIOHDF5Init (CCTK_ARGUMENTS) + { + DECLARE_CCTK_ARGUMENTS; + + *this_iteration = -1; + *next_output_iteration = 0; + *next_output_time = cctk_time; + } + + + void* SetupGH (tFleshConfig* const fc, const int convLevel, cGH* const cctkGH) { @@ -493,9 +504,6 @@ namespace CarpetIOHDF5 { WriteAttribute (dataset, "cctk_version", 1); WriteAttribute (dataset, "cctk_dim", cctk_dim); WriteAttribute (dataset, "cctk_iteration", cctk_iteration); - // TODO: disable temporarily - // WriteAttribute (dataset, "cctk_nmaps", cctk_nmaps); - // WriteAttribute (dataset, "cctk_map", cctk_map); WriteAttribute (dataset, "cctk_gsh", cctk_gsh, dim); WriteAttribute (dataset, "cctk_lsh", cctk_lsh, dim); WriteAttribute (dataset, "cctk_lbnd", cctk_lbnd, dim); @@ -548,12 +556,15 @@ namespace CarpetIOHDF5 { - int TimeToOutput (const cGH* const cctkGH, const int vindex) { + int TimeToOutput (const cGH* const cctkGH, const int vindex) + { DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; assert (vindex>=0 && vindex<CCTK_NumVars()); - + + + const int grouptype = CCTK_GroupTypeFromVarI(vindex); switch (grouptype) { case CCTK_SCALAR: @@ -561,29 +572,92 @@ namespace CarpetIOHDF5 { if (! do_global_mode) return 0; break; case CCTK_GF: - /* do nothing */ + // do nothing break; default: assert (0); } - const int myoutevery = out3D_every == -2 ? out_every : out3D_every; - if (myoutevery < 0) { - // Nothing should be output at all - return 0; - } - if (cctk_iteration % myoutevery != 0) { - // Nothing should be output during this iteration - return 0; + // check whether to output at this iteration + bool output_this_iteration; + + const char* myoutcriterion = out3D_criterion; + if (CCTK_EQUALS(myoutcriterion, "default")) { + myoutcriterion = out_criterion; } + if (CCTK_EQUALS (myoutcriterion, "never")) { + + // Never output + output_this_iteration = false; + + } else if (CCTK_EQUALS (myoutcriterion, "iteration")) { + + int myoutevery = out3D_every; + if (myoutevery == -2) { + myoutevery = out_every; + } + if (myoutevery <= 0) { + // output is disabled + output_this_iteration = false; + } else if (cctk_iteration == *this_iteration) { + // we already decided to output this iteration + output_this_iteration = true; + } else if (cctk_iteration >= *next_output_iteration) { + // it is time for the next output + output_this_iteration = true; + *next_output_iteration = cctk_iteration + myoutevery; + *this_iteration = cctk_iteration; + } else { + // we want no output at this iteration + output_this_iteration = false; + } + + } else if (CCTK_EQUALS (myoutcriterion, "time")) { + + CCTK_REAL myoutdt = out3D_dt; + if (myoutdt == -2) { + myoutdt = out_dt; + } + if (myoutdt < 0) { + // output is disabled + output_this_iteration = false; + } else if (myoutdt == 0) { + // output all iterations + output_this_iteration = true; + } else if (cctk_iteration == *this_iteration) { + // we already decided to output this iteration + output_this_iteration = true; + } else if (cctk_time / cctk_delta_time + >= *next_output_time / cctk_delta_time - 1.0e-12) { + // it is time for the next output + output_this_iteration = true; + *next_output_time = cctk_time + myoutdt; + *this_iteration = cctk_iteration; + } else { + // we want no output at this iteration + output_this_iteration = false; + } + + } else { + + assert (0); + + } // select output criterion + + if (! output_this_iteration) return 0; + + + if (! CheckForVariable(cctkGH, out3D_vars, vindex)) { // This variable should not be output return 0; } + + if (last_output.at(mglevel).at(reflevel).at(vindex) == cctk_iteration) { // Has already been output during this iteration char* varname = CCTK_FullName(vindex); @@ -1064,10 +1138,9 @@ namespace CarpetIOHDF5 { - int CarpetIOHDF5ReadData (CCTK_ARGUMENTS) + void CarpetIOHDF5ReadData (CCTK_ARGUMENTS) { - DECLARE_CCTK_ARGUMENTS; - return InputGH(cctkGH); + InputGH (cctkGH); } diff --git a/Carpet/CarpetIOHDF5/src/iohdf5.h b/Carpet/CarpetIOHDF5/src/iohdf5.h index 434947400..abaef7ee4 100644 --- a/Carpet/CarpetIOHDF5/src/iohdf5.h +++ b/Carpet/CarpetIOHDF5/src/iohdf5.h @@ -1,4 +1,4 @@ -/* $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5.h,v 1.4 2004/03/18 15:12:45 cott Exp $ */ +/* $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5.h,v 1.5 2004/05/21 18:11:34 schnetter Exp $ */ #ifndef CARPETIOHDF5_H #define CARPETIOHDF5_H @@ -12,7 +12,8 @@ namespace CarpetIOHDF5 { /* Scheduled functions */ int CarpetIOHDF5Startup (void); - int CarpetIOHDF5ReadData (CCTK_ARGUMENTS); + void CarpetIOHDF5Init (CCTK_ARGUMENTS); + void CarpetIOHDF5ReadData (CCTK_ARGUMENTS); void CarpetIOHDF5_EvolutionCheckpoint (const cGH*); void CarpetIOHDF5_InitialDataCheckpoint (const cGH*); diff --git a/Carpet/CarpetIOHDF5/src/iohdf5chckpt_recover.cc b/Carpet/CarpetIOHDF5/src/iohdf5chckpt_recover.cc index 7429da933..a2f8e03e8 100644 --- a/Carpet/CarpetIOHDF5/src/iohdf5chckpt_recover.cc +++ b/Carpet/CarpetIOHDF5/src/iohdf5chckpt_recover.cc @@ -18,7 +18,7 @@ #include "cctk_Version.h" extern "C" { - static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5chckpt_recover.cc,v 1.24 2004/05/12 10:13:21 bzink Exp $"; + static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5chckpt_recover.cc,v 1.25 2004/05/21 18:11:34 schnetter Exp $"; CCTK_FILEVERSION(Carpet_CarpetIOHDF5_iohdf5chckpt_recover_cc); } |