aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-02-25 16:46:34 +0000
committertradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-02-25 16:46:34 +0000
commitacb671b983d62e4284a69fa4e7818e05af0b63ad (patch)
tree9f460f685252bb7a2a9ae29cf964409780ff7b5c /src
parent1846383accf3761522ff28362bebf98a2f075ada (diff)
Some more stuff for steering parameters.
Thomas git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@37 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src')
-rw-r--r--src/Output.c102
-rw-r--r--src/OutputInfo.c55
2 files changed, 131 insertions, 26 deletions
diff --git a/src/Output.c b/src/Output.c
index 4f0afbf..12bfc9f 100644
--- a/src/Output.c
+++ b/src/Output.c
@@ -19,38 +19,44 @@
#include "iobasicGH.h"
+/* function prototypes */
+int IOBasic_TimeForOutput (cGH *GH, int index);
+static void CheckSteerableParameters (iobasicGH *myGH);
+
+
+/*@@
+ @routine IOBasic_OutputGH
+ @date Sat March 6 1999
+ @author Gabrielle Allen
+ @desc
+ Loops over all variables and outputs them if necessary
+ @enddesc
+ @calledby CCTK_OutputGH ("IOBasic")
+ @history
+
+ @endhistory
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH
+ @vio in
+ @endvar
+@@*/
int IOBasic_OutputGH (cGH *GH)
{
- DECLARE_CCTK_PARAMETERS
int index;
const char *name;
iobasicGH *myGH;
- cParamData *paramdata;
- static int outScalar_vars_lastset = 0;
/* Get the GH extensions for IOBasic */
myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")];
+ CheckSteerableParameters (myGH);
+
/* Return if no output is required */
if (myGH->outScalar_every <= 0)
return (0);
- /* Check the 'outScalar_vars' parameter */
- paramdata = CCTK_ParameterData ("outScalar_vars", CCTK_THORNSTRING);
- if (! paramdata) {
- CCTK_WARN (3, "Couldn't get info on parameter 'outScalar_vars'");
- return (0);
- }
-
- /* re-parse the 'outScalar_vars' parameter if it was changed */
- if (paramdata->n_set != outScalar_vars_lastset) {
- ParseVarsForOutput (outScalar_vars, myGH->do_outScalar);
-
- /* Save the last setting of 'outScalar_vars' parameter */
- outScalar_vars_lastset = paramdata->n_set;
- }
-
/* Loop over all variables */
for (index = 0; index < CCTK_NumVars (); index++) {
@@ -85,6 +91,33 @@ int IOBasic_OutputGH (cGH *GH)
}
+/*@@
+ @routine IOBasic_OutputVarAs
+ @date Sat March 6 1999
+ @author Gabrielle Allen
+ @desc
+ unconditional output of a variable using the IOBasic output method
+ @enddesc
+ @calledby IOBasic_OutputGH, CCTK_OutputVarAsByMethod ("IOBasic")
+ @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 IOBasic_OutputVarAs (cGH *GH, const char *fullname, const char *alias)
{
int index;
@@ -150,6 +183,8 @@ int IOBasic_TimeForOutput (cGH *GH, int index)
/* Get the GH extension for IOBasic */
myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")];
+ CheckSteerableParameters (myGH);
+
grouptype = CCTK_GroupTypeFromVarI (index);
/* Check this GF should be output */
@@ -195,3 +230,34 @@ int IOBasic_TriggerOutput (cGH *GH, int index)
return (0);
}
+
+
+/**************************** local functions ******************************/
+static void CheckSteerableParameters (iobasicGH *myGH)
+{
+ DECLARE_CCTK_PARAMETERS
+ cParamData *paramdata;
+ static int outScalar_vars_lastset = 0;
+
+
+ /* How often to output */
+ myGH->outScalar_every = out_every > 0 ? out_every : -1;
+ if (outScalar_every > 0)
+ myGH->outScalar_every = outScalar_every;
+
+ /* Check the 'outScalar_vars' parameter */
+ paramdata = CCTK_ParameterData ("outScalar_vars", CCTK_THORNSTRING);
+ if (! paramdata) {
+ CCTK_WARN (1, "Couldn't get info on parameter 'outScalar_vars'");
+ return;
+ }
+
+ /* re-parse the 'outScalar_vars' parameter if it was changed */
+ if (paramdata->n_set != outScalar_vars_lastset) {
+ ParseVarsForOutput (outScalar_vars, myGH->do_outScalar);
+
+ /* Save the last setting of 'outScalar_vars' parameter */
+ outScalar_vars_lastset = paramdata->n_set;
+ }
+
+}
diff --git a/src/OutputInfo.c b/src/OutputInfo.c
index 77f6d31..bff52dd 100644
--- a/src/OutputInfo.c
+++ b/src/OutputInfo.c
@@ -28,6 +28,9 @@ CCTK_REAL IOBasic_WriteInfo (cGH *GH, int index, const char *operator,
#define DECIMAL_PRECISION 1.0e-8
#define USE_DECIMAL_NOTATION(x) ((fabs (x) > DECIMAL_PRECISION) || ((x) == 0.0))
+/* static variables */
+static int outInfo_vars_lastset = 0;
+
/*@@
@routine IOBasic_OutputInfoGH
@@ -56,12 +59,16 @@ int IOBasic_OutputInfoGH (cGH *GH)
const char *name;
iobasicGH *myGH;
cParamData *paramdata;
- static int outInfo_vars_lastset = 0;
/* Get the GH extensions for IOBasic */
myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")];
+ /* How often to output */
+ myGH->outInfo_every = out_every > 0 ? out_every : -1;
+ if (outInfo_every > 0)
+ myGH->outInfo_every = outInfo_every;
+
/* Return if no output is required */
if (myGH->outInfo_every < 1 ||
GH->cctk_iteration % myGH->outInfo_every != 0)
@@ -73,7 +80,7 @@ int IOBasic_OutputInfoGH (cGH *GH)
paramdata = CCTK_ParameterData ("outInfo_vars", CCTK_THORNSTRING);
if (! paramdata)
{
- CCTK_WARN (3, "Couldn't get info on parameter 'outInfo_vars'");
+ CCTK_WARN (1, "Couldn't get info on parameter 'outInfo_vars'");
return (0);
}
@@ -81,10 +88,22 @@ int IOBasic_OutputInfoGH (cGH *GH)
and also print a header */
if (paramdata->n_set != outInfo_vars_lastset)
{
+ int do_outInfo;
char l1[1024],l2[1024],l3[1024];
ParseVarsForOutput (outInfo_vars, myGH->do_outInfo);
+ /* Save the last setting of 'outInfo_vars' parameter */
+ outInfo_vars_lastset = paramdata->n_set;
+
+ do_outInfo = 0;
+ for (i = 0; i < CCTK_NumVars (); i++)
+ do_outInfo |= myGH->do_outInfo [i];
+
+ /* suppress any output if there are no variables to output */
+ if (! do_outInfo)
+ return (0);
+
sprintf (l1," it | |");
sprintf (l2," | t |");
sprintf (l3,"----------------");
@@ -102,9 +121,6 @@ int IOBasic_OutputInfoGH (cGH *GH)
}
printf ("%s\n%s\n%s\n%s\n",l3,l1,l2,l3);
fflush(stdout);
-
- /* Save the last setting of 'outInfo_vars' parameter */
- outInfo_vars_lastset = paramdata->n_set;
}
/* Print the iteration/timestep information for all variables */
@@ -214,6 +230,9 @@ int IOBasic_TimeForInfo (cGH *GH, int var)
{
int return_type;
iobasicGH *myGH;
+ cParamData *paramdata;
+ DECLARE_CCTK_PARAMETERS
+
/* Default is do not do output */
return_type = 0;
@@ -221,6 +240,29 @@ int IOBasic_TimeForInfo (cGH *GH, int var)
/* Get the GH extensions for IOBasic */
myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")];
+ /* How often to output */
+ myGH->outInfo_every = out_every > 0 ? out_every : -1;
+ if (outInfo_every > 0)
+ myGH->outInfo_every = outInfo_every;
+
+ /* Check the 'outInfo_vars' parameter */
+ paramdata = CCTK_ParameterData ("outInfo_vars", CCTK_THORNSTRING);
+ if (! paramdata)
+ {
+ CCTK_WARN (1, "Couldn't get info on parameter 'outInfo_vars'");
+ return (0);
+ }
+
+ /* re-parse the 'outInfo_vars' parameter if it was changed
+ and also print a header */
+ if (paramdata->n_set != outInfo_vars_lastset)
+ {
+ ParseVarsForOutput (outInfo_vars, myGH->do_outInfo);
+
+ /* Save the last setting of 'outInfo_vars' parameter */
+ outInfo_vars_lastset = paramdata->n_set;
+ }
+
/* Check this GF should be output */
if (myGH->do_outInfo [var] &&
(GH->cctk_iteration % myGH->outInfo_every == 0)) {
@@ -287,6 +329,3 @@ int IOBasic_TriggerOutputInfo (cGH *GH, int variable)
return 0;
}
-
-
-