diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2002-04-26 15:51:27 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2002-04-26 15:51:27 +0000 |
commit | 171ad55757d3758a22b835ae6ec430d5132d36b2 (patch) | |
tree | 8f15671eaea46d54e6f04523f566f424e2b0197c /src/Output.c | |
parent | d0dacb328e1c824c38d8b577089d2939008e58aa (diff) |
Switched IOFlexIO to use the new Hyperslabbing API for outputting arbitrary
hyperslabs.
You must update thorn CactusBase/IOUtil now.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@237 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/Output.c')
-rw-r--r-- | src/Output.c | 149 |
1 files changed, 66 insertions, 83 deletions
diff --git a/src/Output.c b/src/Output.c index 1b67d68..776a473 100644 --- a/src/Output.c +++ b/src/Output.c @@ -24,9 +24,7 @@ CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_Output_c) /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ -static int CheckOutputVar (int vindex); -static void CheckSteerableParameters (flexioGH *myGH); -static void SetOutputFlag (int vindex, const char *optstring, void *arg); +static void CheckSteerableParameters (const cGH *GH); /*@@ @@ -37,11 +35,12 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg); Loops over all variables and outputs them if necessary @enddesc - @calls IOFlexIO_TimeFor + @calls CheckSteerableParameters + IOFlexIO_TimeFor IOFlexIO_OutputVarAs @var GH - @vdesc Pointer to CCTK GH + @vdesc pointer to CCTK GH @vtype const cGH * @vio in @endvar @@ -55,17 +54,15 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg); int IOFlexIO_OutputGH (const cGH *GH) { int vindex, retval; - flexioGH *myGH; + const flexioGH *myGH; char *fullname; const char *name; DECLARE_CCTK_PARAMETERS - /* get the GH extension for IOFlexIO */ - myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); - - CheckSteerableParameters (myGH); + CheckSteerableParameters (GH); + myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); if (myGH->out_every <= 0) { return (0); @@ -87,7 +84,7 @@ int IOFlexIO_OutputGH (const cGH *GH) if (IOFlexIO_OutputVarAs (GH, fullname, name) == 0) { - /* Register variables as having output this iteration */ + /* register variables as having output this iteration */ myGH->out_last[vindex] = GH->cctk_iteration; retval++; } @@ -108,10 +105,12 @@ int IOFlexIO_OutputGH (const cGH *GH) Unconditional output of a variable using the IOFlexIO I/O method. @enddesc - @calls IOFlexIO_Write + @calls IOUtil_ParseVarsForOutput + IOFlexIO_Write + IOUtil_FreeIORequest @var GH - @vdesc Pointer to CCTK GH + @vdesc pointer to CCTK GH @vtype const cGH * @vio in @endvar @@ -134,7 +133,8 @@ int IOFlexIO_OutputGH (const cGH *GH) @@*/ int IOFlexIO_OutputVarAs (const cGH *GH, const char *fullname, const char*alias) { - int vindex, retval; + int vindex, oneshot, retval; + const flexioGH *myGH; DECLARE_CCTK_PARAMETERS @@ -146,9 +146,22 @@ int IOFlexIO_OutputVarAs (const cGH *GH, const char *fullname, const char*alias) "index) = (%s, %s, %d)", fullname, alias, vindex); } + /* check whether the variable already has an I/O request entry */ + myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); + oneshot = myGH->requests[vindex] == NULL; + if (oneshot) + { + IOUtil_ParseVarsForOutput (GH, fullname, myGH->requests); + } + /* do the output */ retval = IOFlexIO_Write (GH, vindex, alias); + if (oneshot && myGH->requests[vindex]) + { + IOUtil_FreeIORequest (&myGH->requests[vindex]); + } + return (retval); } @@ -165,7 +178,7 @@ int IOFlexIO_OutputVarAs (const cGH *GH, const char *fullname, const char*alias) @calls CheckSteerableParameters @var GH - @vdesc Pointer to CCTK GH + @vdesc pointer to CCTK GH @vtype const cGH * @vio in @endvar @@ -184,17 +197,15 @@ int IOFlexIO_OutputVarAs (const cGH *GH, const char *fullname, const char*alias) int IOFlexIO_TimeFor (const cGH *GH, int vindex) { int retval; - flexioGH *myGH; char *fullname; + const flexioGH *myGH; - /* get the GH extension for IOFlexIO */ - myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); - - CheckSteerableParameters (myGH); + CheckSteerableParameters (GH); /* check if this variable should be output */ - retval = myGH->out_every > 0 && myGH->do_out[vindex] && + myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); + retval = myGH->out_every > 0 && myGH->requests[vindex] && GH->cctk_iteration % myGH->out_every == 0; if (retval) { @@ -225,7 +236,7 @@ int IOFlexIO_TimeFor (const cGH *GH, int vindex) @calls IOFlexIO_Write @var GH - @vdesc Pointer to CCTK GH + @vdesc pointer to CCTK GH @vtype const cGH * @vio in @endvar @@ -250,12 +261,11 @@ int IOFlexIO_TriggerOutput (const cGH *GH, int vindex) varname = CCTK_VarName (vindex); - /* get the GH extension for IOFlexIO */ - myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); - if (verbose) + { CCTK_VInfo (CCTK_THORNSTRING, "IOFlexIO_TriggerOutput: " "name, index = %s, %d", varname, vindex); + } /* do the output */ retval = IOFlexIO_Write (GH, vindex, varname); @@ -263,6 +273,7 @@ int IOFlexIO_TriggerOutput (const cGH *GH, int vindex) if (retval == 0) { /* register variable as having output this iteration */ + myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); myGH->out_last[vindex] = GH->cctk_iteration; } @@ -282,81 +293,53 @@ int IOFlexIO_TriggerOutput (const cGH *GH, int vindex) and does appropriate re-evaluation. @enddesc - @calls CCTK_TraverseString + @calls IOUtil_ParseVarsForOutput - @var myGH - @vdesc Pointer to IOFlexIO GH - @vtype flexioGH * + @var GH + @vdesc pointer to CCTK GH + @vtype const cGH * @vio in @endvar @@*/ -static void CheckSteerableParameters (flexioGH *myGH) +static void CheckSteerableParameters (const cGH *GH) { - int times_set; + int vindex, times_set; + flexioGH *myGH; + char *fullname; static int out_vars_lastset = -1; DECLARE_CCTK_PARAMETERS /* how often to output */ + myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); myGH->out_every = out3D_every >= 0 ? out3D_every : out_every; /* re-parse the 'out3D_vars' parameter if it was changed */ times_set = CCTK_ParameterQueryTimesSet ("out3D_vars", CCTK_THORNSTRING); if (times_set != out_vars_lastset) { - memset (myGH->do_out, 0, CCTK_NumVars ()); - CCTK_TraverseString (out3D_vars, SetOutputFlag, myGH->do_out, - CCTK_GROUP_OR_VAR); + IOUtil_ParseVarsForOutput (GH, out3D_vars, myGH->requests); + + /*** FIXME: IEEEIO doesn't provide a COMPLEX datatype + so we should map CCTK_COMPLEX to two REALs here. + We have to check for this already here because if an IEEEIO file + is created and nothing is written to it, it will crash + at re-opening. ***/ + for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--) + { + if (myGH->requests[vindex] && + strncmp (CCTK_VarTypeName (vindex), "CCTK_VARIABLE_COMPLEX", 21)) + { + fullname = CCTK_FullName (vindex); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOFlexIO output for complex variable '%s' not yet " + "supported", fullname); + free (fullname); + IOUtil_FreeIORequest (&myGH->requests[vindex]); + } + } - /* Save the last setting of 'out3D_vars' parameter */ + /* save the last setting of 'out3D_vars' parameter */ out_vars_lastset = times_set; } } - - -/* check if this variable can be output (static conditions) */ -static int CheckOutputVar (int vindex) -{ - int retval; - char *fullname; - - -/*** FIXME: IEEEIO doesn't provide a COMPLEX datatype - so we should map CCTK_COMPLEX to two REALs here. - We have to check for this already here because if an IEEEIO file - is created and nothing is written to it, it will crash - at re-opening. ***/ - retval = strncmp (CCTK_VarTypeName (CCTK_VarTypeI (vindex)), - "CCTK_VARIABLE_COMPLEX", 21); - if (! retval) - { - fullname = CCTK_FullName (vindex); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOFlexIO output for complex variable '%s' not yet " - "supported", fullname); - free (fullname); - } - - return (! retval); -} - - -/* callback for CCTK_TraverseString() to set the output flag - for the given variable */ -static void SetOutputFlag (int vindex, const char *optstring, void *arg) -{ - char *flags = (char *) arg; - - - /* Check the variable type */ - if (CheckOutputVar (vindex) == 0) - { - flags[vindex] = 1; - } - - if (optstring) - { - CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, - "Optional string '%s' in variable name ignored", optstring); - } -} |