From 12b4a99653dc25c21c567afb6a5a1b841b8d5e77 Mon Sep 17 00:00:00 2001 From: roland haas Date: Wed, 22 Feb 2012 07:32:10 -0800 Subject: CarpetIOBasic: implement individual reductions lists for output variables This patch imports Thomas Radke's improvements to IOScalar to IOBasic. --8<-- By default, CarpetIOScalar outputs all reductions as listed in the IOScalar::outScalar_reductions parameter (defaulting to all norms available). Now it is possible to overwrite this default for individual variables in an option string, eg. as in IOScalar::outScalar_vars = "grid::x grid::y{reductions = 'minimum maximum'}". --8<-- --- Carpet/CarpetIOBasic/src/iobasic.cc | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'Carpet/CarpetIOBasic') diff --git a/Carpet/CarpetIOBasic/src/iobasic.cc b/Carpet/CarpetIOBasic/src/iobasic.cc index 14b4c28b8..2d0dcb895 100644 --- a/Carpet/CarpetIOBasic/src/iobasic.cc +++ b/Carpet/CarpetIOBasic/src/iobasic.cc @@ -59,6 +59,7 @@ namespace CarpetIOBasic { bool TimeToOutput (const cGH* cctkGH); void OutputHeader (const cGH* cctkGH); void OutputVar (const cGH* cctkGH, int vindex); + void OutputVar (const cGH* cctkGH, int vindex, const char* out_reductions); void CheckSteerableParameters (const cGH * cctkGH); void @@ -182,7 +183,12 @@ namespace CarpetIOBasic { int const numvars = CCTK_NumVars(); for (int vindex=0; vindexreductions; + if (not out_reductions) out_reductions = outInfo_reductions; + + OutputVar (cctkGH, vindex, out_reductions); } } @@ -213,10 +219,6 @@ namespace CarpetIOBasic { if (CCTK_MyProc(cctkGH) == 0) { - // Find the set of desired reductions - vector const reductions = ParseReductions (outInfo_reductions); - int const numreds = reductions.size(); - int const numvars = CCTK_NumVars(); // The header consists of four lines: @@ -269,6 +271,15 @@ namespace CarpetIOBasic { assert (0); } + // use individual reductions list for this variable when given + // otherwise IOScalar::outInfo_reductions + const char* out_reductions = IOparameters.requests[vindex]->reductions; + if (not out_reductions) out_reductions = outInfo_reductions; + + // Find the set of desired reductions + vector const reductions = ParseReductions (out_reductions); + int const numreds = reductions.size(); + int const width = isint ? int_width : real_width; int const mynumreds = isscalar ? 1 : numreds; @@ -324,6 +335,16 @@ namespace CarpetIOBasic { void OutputVar (const cGH * const cctkGH, int const n) + { + DECLARE_CCTK_PARAMETERS; + + OutputVar (cctkGH, n, outInfo_reductions); + } + + void + OutputVar (const cGH * const cctkGH, + int n, + const char* out_reductions) { DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; @@ -360,7 +381,7 @@ namespace CarpetIOBasic { // Find the set of desired reductions vector const reductionstrings - = ParseReductions (outInfo_reductions); + = ParseReductions (out_reductions); list reductions; for (vector::const_iterator ireduction = reductionstrings.begin(); ireduction != reductionstrings.end(); -- cgit v1.2.3