diff options
Diffstat (limited to 'src/OutputScalar.c')
-rw-r--r-- | src/OutputScalar.c | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/src/OutputScalar.c b/src/OutputScalar.c index e83a065..243ebb2 100644 --- a/src/OutputScalar.c +++ b/src/OutputScalar.c @@ -33,72 +33,9 @@ CCTK_FILEVERSION(CactusBase_IOBasic_OutputScalar_c) /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ -static void CheckSteerableParameters (iobasicGH *myGH); static int TimeForOutput (const cGH *cctkGH); -static int TimeForOutput (const cGH *cctkGH) -{ - DECLARE_CCTK_ARGUMENTS; - DECLARE_CCTK_PARAMETERS; - iobasicGH *myGH; - - - /* get the GH extensions for IOBasic */ - myGH = CCTK_GHExtension (cctkGH, "IOBasic"); - - /* check if steerable parameters changed */ - CheckSteerableParameters (myGH); - - /* how to decide when to output? */ - /* (return if no output is required) */ - if (CCTK_EQUALS(outScalar_criterion, "never")) - { - return 0; - } - else if (CCTK_EQUALS(outScalar_criterion, "iteration")) - { - if (myGH->outScalar_every <= 0 || cctk_iteration % myGH->outScalar_every) - { - return 0; - } - } - else if (CCTK_EQUALS(outScalar_criterion, "time")) - { - if (myGH->outScalar_dt < 0) - { - return 0; - } - if (myGH->outScalar_dt > 0) - { - static int output_iteration = -1; - static int output_this_iteration; - assert (cctk_iteration >= output_iteration); - if (cctk_iteration > output_iteration) - { - output_iteration = cctk_iteration; - output_this_iteration - = cctk_time >= *next_scalar_output_time - 1.0e-12 * cctk_delta_time; - if (output_this_iteration) - { - *next_scalar_output_time += myGH->outScalar_dt; - } - } - if (! output_this_iteration) - { - return 0; - } - } - } - else - { - assert (0); - } - - return 1; -} - - /******************************************************************** ******************** External Routines ************************ ********************************************************************/ @@ -134,7 +71,7 @@ int IOBasic_ScalarOutputGH (const cGH *GH) myGH = CCTK_GHExtension (GH, "IOBasic"); /* check if steerable parameters changed */ - CheckSteerableParameters (myGH); + IOBasic_CheckSteerableScalarParameters (myGH); if (! TimeForOutput(GH)) return 0; @@ -290,7 +227,7 @@ int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex) myGH = CCTK_GHExtension (GH, "IOBasic"); /* check if steerable parameters changed */ - CheckSteerableParameters (myGH); + IOBasic_CheckSteerableScalarParameters (myGH); if (myGH->scalar_reductions[vindex].num_reductions == 0) { @@ -372,11 +309,8 @@ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex) } -/******************************************************************** - ******************** Internal Routines ************************ - ********************************************************************/ /*@@ - @routine CheckSteerableParameters + @routine IOBasic_CheckSteerableScalarParameters @date Tue 31 Jul 2001 @author Thomas Radke @desc @@ -393,7 +327,7 @@ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex) @vio in @endvar @@*/ -static void CheckSteerableParameters (iobasicGH *myGH) +void IOBasic_CheckSteerableScalarParameters (iobasicGH *myGH) { int vindex, out_old, times_set, update_reductions_list, num_vars; CCTK_REAL outdt_old; @@ -420,12 +354,12 @@ static void CheckSteerableParameters (iobasicGH *myGH) { if (myGH->outScalar_every > 0) { - CCTK_VInfo (CCTK_THORNSTRING, "Scalar: Periodic output every %d iterations", + CCTK_VInfo (CCTK_THORNSTRING, "Periodic scalar output every %d iterations", myGH->outScalar_every); } else { - CCTK_INFO ("Scalar: Periodic output turned off"); + CCTK_INFO ("Periodic scalar output turned off"); } } @@ -446,12 +380,12 @@ static void CheckSteerableParameters (iobasicGH *myGH) { if (myGH->outScalar_dt >= 0) { - CCTK_VInfo (CCTK_THORNSTRING, "Scalar: Periodic output dt %g", + CCTK_VInfo (CCTK_THORNSTRING, "Periodic scalar output dt %g", (double)myGH->outScalar_dt); } else { - CCTK_INFO ("Scalar: Periodic output turned off"); + CCTK_INFO ("Periodic scalar output turned off"); } } @@ -503,7 +437,8 @@ static void CheckSteerableParameters (iobasicGH *myGH) if (CCTK_TraverseString (outScalar_vars, IOBasic_AssignReductionList, &info, CCTK_GROUP_OR_VAR) < 0) { - CCTK_WARN (1, "Failed to parse 'IOBasic::outScalar_vars' parameter"); + CCTK_WARN (myGH->stop_on_parse_errors ? 0 : 1, + "error while parsing parameter 'IOBasic::outScalar_vars'"); } else if (! CCTK_Equals (verbose, "none")) { @@ -515,7 +450,7 @@ static void CheckSteerableParameters (iobasicGH *myGH) fullname = CCTK_FullName (vindex); if (! msg) { - Util_asprintf (&msg, "Scalar: Periodic output requested for '%s'", + Util_asprintf (&msg, "Periodic scalar output requested for '%s'", fullname); } else @@ -535,3 +470,68 @@ static void CheckSteerableParameters (iobasicGH *myGH) } } } + + +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ +static int TimeForOutput (const cGH *cctkGH) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + iobasicGH *myGH; + + + /* get the GH extensions for IOBasic */ + myGH = CCTK_GHExtension (cctkGH, "IOBasic"); + + /* check if steerable parameters changed */ + IOBasic_CheckSteerableScalarParameters (myGH); + + /* how to decide when to output? */ + /* (return if no output is required) */ + if (CCTK_EQUALS(outScalar_criterion, "never")) + { + return 0; + } + else if (CCTK_EQUALS(outScalar_criterion, "iteration")) + { + if (myGH->outScalar_every <= 0 || cctk_iteration % myGH->outScalar_every) + { + return 0; + } + } + else if (CCTK_EQUALS(outScalar_criterion, "time")) + { + if (myGH->outScalar_dt < 0) + { + return 0; + } + if (myGH->outScalar_dt > 0) + { + static int output_iteration = -1; + static int output_this_iteration; + assert (cctk_iteration >= output_iteration); + if (cctk_iteration > output_iteration) + { + output_iteration = cctk_iteration; + output_this_iteration + = cctk_time >= *next_scalar_output_time - 1.0e-12 * cctk_delta_time; + if (output_this_iteration) + { + *next_scalar_output_time += myGH->outScalar_dt; + } + } + if (! output_this_iteration) + { + return 0; + } + } + } + else + { + assert (0); + } + + return 1; +} |