diff options
author | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2000-06-02 15:17:55 +0000 |
---|---|---|
committer | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2000-06-02 15:17:55 +0000 |
commit | e84210459cfbed430d8dfd0f1b4d04e76c1b0f6f (patch) | |
tree | ecc9fb15aa93adde2fc854644e3182ecf9ba61da /src/Output2D.c | |
parent | e4b33cec4b4c3899f97259e4037bda4ed734becd (diff) |
IOASCII using thorn Hyperslab. No PUGH in here anymore !
Also changed the output format to use tabs rather than spaces
which reduces the output filesize by 1/3.
Should still pass all testsuites (tested for the WaveToys).
If everything else is okay we can move IOASCII into the IOBasic/ arrangement
and remove CactusPUGHIO/IOASCII.
Also finally removed all the http stuff.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@2 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src/Output2D.c')
-rw-r--r-- | src/Output2D.c | 289 |
1 files changed, 289 insertions, 0 deletions
diff --git a/src/Output2D.c b/src/Output2D.c new file mode 100644 index 0000000..273de3f --- /dev/null +++ b/src/Output2D.c @@ -0,0 +1,289 @@ + /*@@ + @file Output2D.c + @date Thu May 11 2000 + @author Thomas Radke + @desc + Functions to deal with 2D ASCII output of variables + @enddesc + @@*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "ioASCIIGH.h" + +/*#define IOASCII_DEBUG*/ + +/* function prototypes */ +int IOASCII_TimeFor2D (cGH *GH, int index); +static void CheckSteerableParameters (asciiioGH *myGH); + + +/*@@ + @routine IOASCII_Output2DGH + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Loops over all variables and outputs them if necessary + @enddesc + @calledby CCTK_OutputGH ("IOASCII") + @history + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @endvar +@@*/ +int IOASCII_Output2DGH (cGH *GH) +{ + int index; + asciiioGH *myGH; + const char *name; + + + /* Get the GH extensions for IOUtil and IOASCII */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + CheckSteerableParameters (myGH); + + /* Return if no output is required */ + if (myGH->out2D_every <= 0) + { + return (0); + } + + /* Loop over all variables */ + for (index = 0; index < CCTK_NumVars (); index++) + { + + /* Check if this variable should be output */ + if (! IOASCII_TimeFor2D (GH, index)) + { + continue; + } + + /* Get the variable name for this index (for filename) */ + name = CCTK_VarName (index); + +#ifdef IO_DEBUG + printf ("\nIn IOASCII Output2DGH\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", name); + printf (" On iteration %d\n", GH->cctk_iteration); + printf (" Last output iteration was = %d\n", myGH->out2D_last [index]); +#endif + + /* Make the IO call */ + IOASCII_Write2D (GH, index, name); + + /* Register GF as having 2D output this iteration */ + myGH->out2D_last [index] = GH->cctk_iteration; + + } /* end of loop over all variables */ + + return (0); + + +} + + +/*@@ + @routine IOASCII_Output2DVarAs + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + unconditional output of a variable using the IOASCII output method + @enddesc + @calledby IOASCII_Output2DGH, CCTK_OutputVarAsByMethod ("IOASCII") + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var fullname + @vdesc complete name of variable to output + @vtype const char * + @vio in + @vcomment + @endvar + @var alias + @vdesc alias name of variable to output (used to generate output filename) + @vtype const char * + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_Output2DVarAs (cGH *GH, const char *fullname, const char *alias) +{ + int index; + + + index = CCTK_VarIndex (fullname); + +#ifdef IO_DEBUG + printf ("\nIn IOASCII Output2DVarAs\n-------------------\n"); + printf (" Fullname = -%s-\n", fullname); + printf (" Alias = -%s-\n", alias); + printf (" Index = %d\n", index); +#endif + + IOASCII_Write2D (GH, index, alias); + + return (0); +} + + + /*@@ + @routine IOASCII_TimeFor2D + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Decides if it is time to output a variable using the IO 2D output + method + @enddesc + @calledby IOASCII_Output2DGH + @history + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc index of variable + @vtype int + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_TimeFor2D (cGH *GH, int index) +{ + int return_type; + int grouptype; + asciiioGH *myGH; + DECLARE_CCTK_PARAMETERS + + + /* Default is do not do output */ + return_type = 0; + + /* Get the GH extensions for IOUtil and IOASCII */ + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + CheckSteerableParameters (myGH); + + /* return if no output requested */ + if (myGH->out2D_every <= 0) + return (0); + + grouptype = CCTK_GroupTypeFromVarI (index); + + /* Check this GF should be output */ + if (myGH->do_out2D [index] && grouptype == GROUP_GF + && (GH->cctk_iteration%myGH->out2D_every == 0)) + { + + /* Check GF not already output this iteration */ + if (myGH->out2D_last[index] == GH->cctk_iteration) + { + CCTK_WARN(2,"Already done 2D output in IO"); + } + else + { + return_type = 1; + } + } + + return (return_type); +} + + +/*@@ + @routine IOASCII_TriggerOutput2D + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Triggers the output a variable using the IOASCII output method + method + @enddesc + @calledby CCTK scheduler + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var index + @vdesc index of variable to output + @vtype int + @vio in + @vcomment + @endvar +@@*/ +int IOASCII_TriggerOutput2D (cGH *GH, int index) +{ + const char *var; + asciiioGH *myGH; + + myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; + + var = CCTK_VarName (index); + + /* Do the 2D output */ +#ifdef IO_DEBUG + printf ("\nIn IOASCII TriggerOutput2D\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", var); +#endif + + IOASCII_Write2D (GH, index, var); + + /* Register variables as having 2D output this iteration */ + myGH->out2D_last [index] = GH->cctk_iteration; + + return (0); +} + + +/**************************** local functions ******************************/ +static void CheckSteerableParameters (asciiioGH *myGH) +{ + DECLARE_CCTK_PARAMETERS + const cParamData *paramdata; + static int out2D_vars_lastset = 0; + + + /* How often to output */ + myGH->out2D_every = out_every > 0 ? out_every : -1; + if (out2D_every > 0) + { + myGH->out2D_every = out2D_every; + } + + /* Check the 'out2D_vars' parameter */ + paramdata = CCTK_ParameterData ("out2D_vars", CCTK_THORNSTRING); + if (! paramdata) + { + CCTK_WARN (1, "Couldn't get info on parameter 'out2D_vars'"); + return; + } + + /* re-parse the 'out2D_vars' parameter if it was changed */ + if (paramdata->n_set != out2D_vars_lastset) + { + ParseVarsForOutput (out2D_vars, myGH->do_out2D); + + /* Save the last setting of 'out2D_vars' parameter */ + out2D_vars_lastset = paramdata->n_set; + } + +} |