diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2002-05-06 09:16:28 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2002-05-06 09:16:28 +0000 |
commit | fe88d9e6f770a9d36acc8ffc02655a5c68fa8b7d (patch) | |
tree | 50c97ccae5cd94d5b65209ed2be3dd4cbe1783c7 /src/Output2D.c | |
parent | 4121f7f8af4cb1b3232319205129d9cef22e53b1 (diff) |
Parameter names changes as announced in today's mail to users@cactuscode.org.
You must also update thorn IOUtil now.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@241 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/Output2D.c')
-rw-r--r-- | src/Output2D.c | 209 |
1 files changed, 117 insertions, 92 deletions
diff --git a/src/Output2D.c b/src/Output2D.c index 14d86e7..a7ba92f 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -3,20 +3,17 @@ @date Tue Jan 9 1999 @author Gabrielle Allen @desc - Functions to deal 2D output of GFs + Functions to deal with output of 2D planes of grid variables. @enddesc - @history - @hauthor Thomas Radke @hdate 16 Mar 1999 - @hdesc Converted to Cactus 4.0 - @hendhistory + @version $Id$ @@*/ -#include <stdio.h> #include <stdlib.h> #include <string.h> #include "cctk.h" #include "cctk_Parameters.h" +#include "util_String.h" #include "ioFlexGH.h" static const char *rcsid = "$Header$"; @@ -24,7 +21,7 @@ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_Output2D_c) /* prototypes of routines defined in this source file */ -static int CheckOutputVar (int vindex); +static int CheckOutputVar (int vindex, int warn); static void CheckSteerableParameters (flexioGH *myGH); static void SetOutputFlag (int vindex, const char *optstring, void *arg); @@ -50,41 +47,22 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg); int IOFlexIO_Output2DGH (const cGH *GH) { - int i, retval; - flexioGH *myGH; - const char *name; - char *fullname; - DECLARE_CCTK_PARAMETERS - - - /* Get the GH extension for IOFlexIO */ - myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; - - CheckSteerableParameters (myGH); - - if (myGH->out2D_every <= 0) - return (0); - - /* Loop over all variables */ - for (i = retval = 0; i < CCTK_NumVars (); i++) { - - if (IOFlexIO_TimeFor2D (GH, i)) { - - name = CCTK_VarName (i); - fullname = CCTK_FullName (i); + int vindex, retval; + const flexioGH *myGH; - if (verbose) - CCTK_VInfo (CCTK_THORNSTRING, "IOFlexIO_Output2DGH: " - "fullname / name = %s / %s", fullname, name); - if (IOFlexIO_Output2DVarAs (GH, fullname, name) == 0) - { - /* Register GF as having 2D output this iteration */ - myGH->out2D_last[i] = GH->cctk_iteration; - retval++; - } + retval = 0; + myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); - free (fullname); + /* loop over all variables */ + for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--) + { + if (IOFlexIO_TimeFor2D (GH, vindex) && CheckOutputVar (vindex, 0) && + IOFlexIO_Write2D (GH, vindex, CCTK_VarName (vindex)) == 0) + { + /* register variable as having 2D output this iteration */ + myGH->out2D_last[vindex] = GH->cctk_iteration; + retval++; } } @@ -130,13 +108,15 @@ int IOFlexIO_Output2DVarAs (const cGH *GH, const char *fullname, const char *ali vindex = CCTK_VarIndex (fullname); - if (verbose) + if (CCTK_Equals (verbose, "full")) + { CCTK_VInfo (CCTK_THORNSTRING, "IOFlexIO_Output2DVarAs: " "fullname, alias, index = (%s, %s, %d)", fullname,alias,vindex); + } - /* Do the 2D output */ + /* do the 2D output */ retval = -1; - if (CheckOutputVar (vindex) == 0) + if (CheckOutputVar (vindex, 1) == 0) { retval = IOFlexIO_Write2D (GH, vindex, alias); } @@ -172,37 +152,37 @@ int IOFlexIO_Output2DVarAs (const cGH *GH, const char *fullname, const char *ali @@*/ int IOFlexIO_TimeFor2D (const cGH *GH, int vindex) { + int result; + char *fullname; flexioGH *myGH; - /* Get the GH extension for IOUtil and IOFlexIO */ - myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; + /* default is not do any output */ + result = 0; + myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); CheckSteerableParameters (myGH); - /* Check if any output was requested */ - if (myGH->out2D_every <= 0) - return (0); - - /* Check this GF should be output */ - if (! (CCTK_GroupTypeFromVarI (vindex) == CCTK_GF && myGH->do_out2D [vindex] - && GH->cctk_iteration % myGH->out2D_every == 0)) - return (0); - - /* Check GF not already output this iteration */ - if (myGH->out2D_last [vindex] == GH->cctk_iteration) + /* check if this variable should be output */ + if (myGH->out2D_every[vindex] > 0 && + GH->cctk_iteration % myGH->out2D_every[vindex] == 0) { - char *fullname = CCTK_FullName (vindex); - - - CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, - "Already done 2D FlexIO output for variable '%s' in current " - "iteration (probably via triggers)", fullname); - free (fullname); - return (0); + /* check if variable wasn't already output this iteration */ + if (myGH->out2D_last [vindex] == GH->cctk_iteration) + { + fullname = CCTK_FullName (vindex); + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Already done 2D FlexIO output for variable '%s' in current " + "iteration (probably via triggers)", fullname); + free (fullname); + } + else + { + result = 1; + } } - return (1); + return (result); } @@ -234,26 +214,25 @@ int IOFlexIO_TimeFor2D (const cGH *GH, int vindex) int IOFlexIO_TriggerOutput2D (const cGH *GH, int vindex) { int retval; - flexioGH *myGH; const char *varname; + const flexioGH *myGH; DECLARE_CCTK_PARAMETERS varname = CCTK_VarName (vindex); - /* get the handle for IOFlexIO extensions */ - myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; - - if (verbose) + if (CCTK_Equals (verbose, "full")) + { CCTK_VInfo (CCTK_THORNSTRING, "IOFlexIO_TriggerOutput2D: " "name, index = (%s, %d)", varname, vindex); + } - /* Do the 2D output */ + /* do the 2D output */ retval = IOFlexIO_Write2D (GH, vindex, varname); - if (retval == 0) { - /* Register GF as having 2D output this iteration */ + /* register variable as having 2D output this iteration */ + myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); myGH->out2D_last [vindex] = GH->cctk_iteration; } @@ -265,45 +244,91 @@ int IOFlexIO_TriggerOutput2D (const cGH *GH, int vindex) /* check if steerable parameters have changed */ static void CheckSteerableParameters (flexioGH *myGH) { - int times_set; - static int out2D_vars_lastset = -1; + int i, num_vars; + char *fullname, *msg; DECLARE_CCTK_PARAMETERS - /* How often to output */ - myGH->out2D_every = out2D_every >= 0 ? out2D_every : out_every; + /* how often to output */ + i = myGH->out2D_every_default; + myGH->out2D_every_default = out2D_every; + if (myGH->out2D_every_default < 0) + { + myGH->out2D_every_default = *(const CCTK_INT *) + CCTK_ParameterGet ("out_every", CCTK_ImplementationThorn ("IO"), NULL); + } - /* re-parse the 'out2D_vars' parameter if it was changed */ - times_set = CCTK_ParameterQueryTimesSet ("out2D_vars", CCTK_THORNSTRING); - if (times_set != out2D_vars_lastset) + /* report if frequency changed */ + if (myGH->out2D_every_default != i && ! CCTK_Equals (verbose, "none")) { - memset (myGH->do_out2D, 0, CCTK_NumVars ()); - CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH->do_out2D, + if (myGH->out2D_every_default > 0) + { + CCTK_VInfo (CCTK_THORNSTRING, "IOFlexIO_2D: Periodic output every %d " + "iterations", myGH->out2D_every_default); + } + else + { + CCTK_INFO ("IOFlexIO_2D: Periodic output turned off"); + } + } + + /* re-parse the 'IOFlexIO::out2D_vars' parameter if it was changed */ + if (strcmp (out2D_vars, myGH->out2D_vars) || myGH->out2D_every_default != i) + { + num_vars = CCTK_NumVars (); + memset (myGH->out2D_every, 0, num_vars); + CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH->out2D_every, CCTK_GROUP_OR_VAR); - /* Save the last setting of 'out2D_vars' parameter */ - out2D_vars_lastset = times_set; + if (myGH->out2D_every_default == i || ! CCTK_Equals (verbose, "none")) + { + msg = NULL; + for (i = 0; i < num_vars; i++) + { + if (myGH->out2D_every[i]) + { + fullname = CCTK_FullName (i); + if (! msg) + { + Util_asprintf (&msg, "IOFlexIO_2D: Periodic output requested for " + "'%s'", fullname); + } + else + { + Util_asprintf (&msg, "%s, '%s'", msg, fullname); + } + free (fullname); + } + } + if (msg) + { + CCTK_INFO (msg); + free (msg); + } + } + + /* save the last setting of 'IOFlexIO::out2D_vars' parameter */ + free (myGH->out2D_vars); + myGH->out2D_vars = strdup (out2D_vars); } } /* check if this variable can be output (static conditions) */ -static int CheckOutputVar (int vindex) +static int CheckOutputVar (int vindex, int warn) { int retval; char *fullname; - retval = 0; - /* check the group dimension */ - if (CCTK_GroupDimFromVarI (vindex) != 3) + retval = CCTK_GroupDimFromVarI (vindex) == 3 ? 0 : -1; + if (retval && warn) { fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "No IOFlexIO 2D output for '%s' (dim != 3)", fullname); free (fullname); - retval = -1; } return (retval); @@ -314,13 +339,13 @@ static int CheckOutputVar (int vindex) for the given variable */ static void SetOutputFlag (int vindex, const char *optstring, void *arg) { - char *flags = (char *) arg; + int *out2D_every = (int *) arg; - /* Check the variable type */ - if (CheckOutputVar (vindex) == 0) + /* check the variable type */ + if (CheckOutputVar (vindex, 1) == 0) { - flags[vindex] = 1; + out2D_every[vindex] = 1; } if (optstring) |