aboutsummaryrefslogtreecommitdiff
path: root/src/Output.c
diff options
context:
space:
mode:
authortradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2000-10-12 11:53:20 +0000
committertradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2000-10-12 11:53:20 +0000
commit8297b39029c9314bc4e4691c9965b318c610fb3c (patch)
tree1bf238922da24615203954bb62a0e5c3686fcedc /src/Output.c
parentedfc67c37108ac3d583b794cf4930b7482c62417 (diff)
Added checkpoint/recovery functionality.
Moved a lot of code into IOHDF5Util and inherit from this thorn. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@44 0888f3d4-9f52-45d2-93bc-d00801ff5e46
Diffstat (limited to 'src/Output.c')
-rw-r--r--src/Output.c250
1 files changed, 139 insertions, 111 deletions
diff --git a/src/Output.c b/src/Output.c
index 92766da..0539fdf 100644
--- a/src/Output.c
+++ b/src/Output.c
@@ -3,61 +3,56 @@
@date Tue Jan 9 1999
@author Gabrielle Allen
@desc
- Functions to deal with output of variables in HDF5 FiberBundle format
+ Functions to deal with streaming output of variables
+ in HDF5 format.
@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 <assert.h>
#include "cctk.h"
#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "StreamedHDF5GH.h"
+#include "ioStreamedHDF5GH.h"
+
+/* the rcs ID and its dummy function to use it */
+static char *rcsid = "$Id$";
+CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_Output_c)
/* function prototypes */
-int StreamedHDF5_TimeFor (cGH *GH, int index);
-int StreamedHDF5_OutputVarAs (cGH *GH, const char *var, const char *alias);
-static void CheckSteerableParameters (StreamedHDF5GH *myGH);
+static void CheckSteerableParameters (ioStreamedHDF5GH *myGH);
/*@@
- @routine StreamedHDF5_OutputGH
+ @routine IOStreamedHDF5_OutputGH
@date Sat March 6 1999
@author Gabrielle Allen
@desc
- Loops over all variables and outputs them if necessary
+ Loops over all variables and outputs them if necessary
@enddesc
- @calledby CCTK_OutputGH ("StreamedHDF5")
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
+
+ @calls IOStreamedHDF5_TimeFor
+ IOStreamedHDF5_OutputVarAs
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH *
+ @vio in
@endvar
@@*/
-
-int StreamedHDF5_OutputGH (cGH *GH)
+int IOStreamedHDF5_OutputGH (cGH *GH)
{
DECLARE_CCTK_PARAMETERS
- int i;
- StreamedHDF5GH *myGH;
+ int index;
+ ioStreamedHDF5GH *myGH;
const char *name;
char *fullname;
- /* Get the GH extension for StreamedHDF5 */
- myGH = (StreamedHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("StreamedHDF5")];
+ /* Get the GH extension for IOStreamedHDF5 */
+ myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
CheckSteerableParameters (myGH);
@@ -67,27 +62,28 @@ int StreamedHDF5_OutputGH (cGH *GH)
}
/* Loop over all variables */
- for (i = 0; i < CCTK_NumVars (); i++)
+ for (index = 0; index < CCTK_NumVars (); index++)
{
- if (StreamedHDF5_TimeFor (GH, i))
+ if (IOStreamedHDF5_TimeFor (GH, index))
{
- name = CCTK_VarName (i);
- fullname = CCTK_FullName (i);
+ name = CCTK_VarName (index);
+ fullname = CCTK_FullName (index);
if (verbose)
{
- CCTK_VInfo (CCTK_THORNSTRING, "StreamedHDF5_OutputGH: fullname / name "
- "= %s / %s", fullname, name);
+ CCTK_VInfo (CCTK_THORNSTRING, "IOStreamedHDF5_OutputGH: "
+ "output of variable (fullname / name) "
+ "= ('%s' / '%s')", fullname, name);
}
- StreamedHDF5_OutputVarAs (GH, fullname, name);
+ IOStreamedHDF5_OutputVarAs (GH, fullname, name);
free (fullname);
/* Register variable as having output this iteration */
- myGH->out_last [i] = GH->cctk_iteration;
+ myGH->out_last[index] = GH->cctk_iteration;
}
}
@@ -96,34 +92,36 @@ int StreamedHDF5_OutputGH (cGH *GH)
/*@@
- @routine StreamedHDF5_OutputVarAs
+ @routine IOStreamedHDF5_OutputVarAs
@date Sat March 6 1999
@author Gabrielle Allen
@desc
- unconditional output of a variable using the StreamedHDF5 output method
+ Unconditional output of a variable
+ using the IOStreamedHDF5 output method.
@enddesc
- @calledby StreamedHDF5_OutputGH, CCTK_OutputVarAsByMethod ("StreamedHDF5")
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
+
+ @calls IOStreamedHDF5_Write
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH *
+ @vio in
@endvar
- @var fullname
- @vdesc complete name of variable to output
- @vtype const char *
- @vio in
- @vcomment
+ @var fullname
+ @vdesc complete name of variable to output
+ @vtype const char *
+ @vio in
@endvar
- @var alias
- @vdesc alias name of variable to output (used to generate output filename)
- @vtype const char *
- @vio in
- @vcomment
+ @var alias
+ @vdesc alias name of variable to output
+ (used to generate output filename)
+ @vtype const char *
+ @vio in
@endvar
@@*/
-
-int StreamedHDF5_OutputVarAs (cGH *GH, const char *fullname, const char *alias)
+int IOStreamedHDF5_OutputVarAs (cGH *GH,
+ const char *fullname,
+ const char *alias)
{
DECLARE_CCTK_PARAMETERS
int index;
@@ -133,50 +131,54 @@ int StreamedHDF5_OutputVarAs (cGH *GH, const char *fullname, const char *alias)
if (verbose)
{
- CCTK_VInfo (CCTK_THORNSTRING, "StreamedHDF5_OutputVarAs: fullname, alias, "
- "index = (%s, %s, %d)", fullname, alias, index);
+ CCTK_VInfo (CCTK_THORNSTRING, "IOStreamedHDF5_OutputVarAs: "
+ "output of variable (fullname / alias) "
+ "= ('%s' / '%s')", fullname, alias);
}
/* Do the output */
- StreamedHDF5_Write (GH, index, alias);
+ IOStreamedHDF5_Write (GH, index, alias);
return (0);
}
/*@@
- @routine StreamedHDF5_TimeFor
+ @routine IOStreamedHDF5_TimeFor
@date Sat March 6 1999
@author Gabrielle Allen
@desc
- Decides if it is time to output a variable using the StreamedHDF5 output
- method
+ Decides if it is time to output a variable
+ using the IOStreamedHDF5 output method.
@enddesc
- @calledby StreamedHDF5_OutputGH
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
+
+ @calls CheckSteerableParameters
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH *
+ @vio in
@endvar
- @var index
- @vdesc index of variable
- @vtype int
- @vio in
- @vcomment
+ @var index
+ @vdesc index of variable
+ @vtype int
+ @vio in
@endvar
-@@*/
-int StreamedHDF5_TimeFor (cGH *GH, int index)
+ @returntype int
+ @returndesc
+ 1 if output should take place
+ 0 if not
+ @endreturndesc
+@@*/
+int IOStreamedHDF5_TimeFor (cGH *GH,
+ int index)
{
- StreamedHDF5GH *myGH;
+ ioStreamedHDF5GH *myGH;
- /* Get the GH extension for StreamedHDF5 */
- myGH = (StreamedHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("StreamedHDF5")];
+ /* Get the GH extension for IOStreamedHDF5 */
+ myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
CheckSteerableParameters (myGH);
@@ -187,15 +189,15 @@ int StreamedHDF5_TimeFor (cGH *GH, int index)
}
/* Check this variable should be output */
- if (! (myGH->do_output [index] && GH->cctk_iteration % myGH->out_every == 0))
+ if (! (myGH->do_output[index] && GH->cctk_iteration % myGH->out_every == 0))
{
return (0);
}
/* Check variable not already output this iteration */
- if (myGH->out_last [index] == GH->cctk_iteration)
+ if (myGH->out_last[index] == GH->cctk_iteration)
{
- CCTK_WARN (2, "Already done output in StreamedHDF5");
+ CCTK_WARN (2, "Already done output in IOStreamedHDF5");
return (0);
}
@@ -204,54 +206,80 @@ int StreamedHDF5_TimeFor (cGH *GH, int index)
/*@@
- @routine StreamedHDF5_TriggerOutput
+ @routine IOStreamedHDF5_TriggerOutput
@date Sat March 6 1999
@author Gabrielle Allen
@desc
- Triggers the output a variable using the StreamedHDF5 output
- method
+ Triggers the output of a variable
+ using the IOStreamedHDF5 output.
@enddesc
- @calledby CCTK scheduler
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
+
+ @calls IOStreamedHDF5_Write
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH *
+ @vio in
@endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
+ @var index
+ @vdesc index of variable
+ @vtype int
+ @vio in
@endvar
@@*/
-
-int StreamedHDF5_TriggerOutput (cGH *GH, int index)
+int IOStreamedHDF5_TriggerOutput (cGH *GH,
+ int index)
{
DECLARE_CCTK_PARAMETERS
- StreamedHDF5GH *myGH;
+ ioStreamedHDF5GH *myGH;
+ char *fullname;
const char *varname;
+
varname = CCTK_VarName (index);
- myGH = (StreamedHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("StreamedHDF5")];
+ myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "StreamedHDF5_TriggerOutput: varname, index "
- "= (%s, %d)", varname, index);
+ {
+ fullname = CCTK_FullName (index);
+ CCTK_VInfo (CCTK_THORNSTRING, "IOStreamedHDF5_TriggerOutput: "
+ "output of (varname, fullname) "
+ "= ('%s', '%s')", varname, fullname);
+ free (fullname);
+ }
/* Do the output */
- StreamedHDF5_Write (GH, index, varname);
+ IOStreamedHDF5_Write (GH, index, varname);
/* Register variable as having output this iteration */
- myGH->out_last [index] = GH->cctk_iteration;
+ myGH->out_last[index] = GH->cctk_iteration;
return (0);
}
-/**************************** local functions ******************************/
-static void CheckSteerableParameters (StreamedHDF5GH *myGH)
+/***************************************************************************/
+/* local functions */
+/***************************************************************************/
+/*@@
+ @routine CheckSteerableParameters
+ @date Mon Oct 10 2000
+ @author Thomas Radke
+ @desc
+ Checks if IOStreamedHDF5 steerable parameters were changed
+ and does appropriate re-evaluation.
+ @enddesc
+
+ @calls IOHDF5Util_ParseVarsForOutput
+
+ @var myGH
+ @vdesc Pointer to IOStreamedHDF5 GH
+ @vtype ioStreamedHDF5GH *
+ @vio in
+ @endvar
+@@*/
+static void CheckSteerableParameters (ioStreamedHDF5GH *myGH)
{
DECLARE_CCTK_PARAMETERS
int times_set;
@@ -265,11 +293,11 @@ static void CheckSteerableParameters (StreamedHDF5GH *myGH)
myGH->out_every = outHDF5_every;
}
- /* re-parse the 'out_vars' parameter if it was changed */
+ /* re-parse the 'IOStreamedHDF5::out_vars' parameter if it was changed */
times_set = CCTK_ParameterQueryTimesSet ("out_vars", CCTK_THORNSTRING);
if (times_set != out_vars_lastset)
{
- ParseVarsForOutputH5stream (myGH, out_vars);
+ IOHDF5Util_ParseVarsForOutput (out_vars, myGH->do_output, myGH->geo_output);
/* Save the last setting of 'out_vars' parameter */
out_vars_lastset = times_set;