aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-01-18 16:04:24 +0000
committertradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-01-18 16:04:24 +0000
commit637f87359d1bd17dccdb3f2e42d92e83faae2a07 (patch)
tree17511c4645534323fe82b559ce5ba685ffe082bc /src
parent6484e89cae2cb585c91e2ea61d5139d2407e00c1 (diff)
Started to make IO parameters steerable. Now this can be done for outInfo_every
and outInfo_vars. Also added missing grdocs. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@26 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src')
-rw-r--r--src/OutputInfo.c180
1 files changed, 115 insertions, 65 deletions
diff --git a/src/OutputInfo.c b/src/OutputInfo.c
index fab8d8c..0fe5ff3 100644
--- a/src/OutputInfo.c
+++ b/src/OutputInfo.c
@@ -9,125 +9,149 @@
/*#define IO_DEBUG*/
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cctk.h"
#include "cctk_parameters.h"
+#include "cctk_ParameterFunctions.h"
+#include "CactusBase/IOUtil/src/ioGH.h"
#include "iobasicGH.h"
-CCTK_REAL IOBasic_WriteInfo (cGH *GH, int index, const char *operator, const char *alias);
+/* extern prototypes */
+CCTK_REAL IOBasic_WriteInfo (cGH *GH, int index, const char *operator,
+ const char *alias);
-static int first = 1;
+/* the number at which to switch from decimal to exp notation */
+#define DECIMAL_PRECISION 1.0e-8
+#define USE_DECIMAL_NOTATION(x) ((fabs (x) > DECIMAL_PRECISION) || ((x) == 0.0))
+
+
+ /*@@
+ @routine IOBasic_OutputInfoGH
+ @date June 31 1999
+ @author Gabrielle Allen
+ @desc
+ Loops over all variables and prints output if requested
+ method
+ @enddesc
+ @history
+
+ @endhistory
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH
+ @vio in
+ @vcomment
+ @endvar
+@@*/
+
int IOBasic_OutputInfoGH (cGH *GH)
{
DECLARE_CCTK_PARAMETERS
int i;
char *name=NULL;
iobasicGH *myGH;
+ t_param_prop *param_prop;
+ static int outInfo_vars_lastset = 0;
- /* the number at which to switch from decimal to exp notation*/
- CCTK_REAL hprec,lprec;
- hprec = 1.0e-8;
- lprec =-1.0e-8;
/* Get the GH extensions for IOBasic */
myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")];
/* Return if no output is required */
if (myGH->outInfo_every < 1 || GH->cctk_iteration % myGH->outInfo_every != 0)
- return 0;
+ return (0);
- /* Print a header the first time through */
- if (first == 1)
- {
+ /* Check the 'outInfo_vars' parameter */
+ param_prop = CCTK_ParameterInfo ("outInfo_vars", CCTK_THORNSTRING);
+ if (! param_prop) {
+ CCTK_WARN (3, "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 (param_prop->n_set != outInfo_vars_lastset) {
char l1[1024],l2[1024],l3[1024];
-
+
+ ParseVarsForOutput (outInfo_vars, myGH->do_outInfo);
+
sprintf (l1," it | |");
sprintf (l2," | t |");
sprintf (l3,"----------------");
- for (i = 0; i < CCTK_NumVars (); i++)
- {
+ for (i = 0; i < CCTK_NumVars (); i++) {
char ll[80];
- if(myGH->do_outInfo [i])
- {
- sprintf (ll," ");
- ll[25-strlen(CCTK_VarName(i))] = '\0';
- sprintf (l1,"%s %s%s |",l1,CCTK_VarName(i),ll);
- sprintf (l2,"%s Min Max |",l2);
- sprintf (l3,"%s----------------------------",l3);
+
+ if(myGH->do_outInfo [i]) {
+ sprintf (ll," ");
+ ll[25-strlen(CCTK_VarName(i))] = '\0';
+ sprintf (l1,"%s %s%s |",l1,CCTK_VarName(i),ll);
+ sprintf (l2,"%s Min Max |",l2);
+ sprintf (l3,"%s----------------------------",l3);
}
}
printf ("%s\n%s\n%s\n%s\n",l3,l1,l2,l3);
fflush(stdout);
- first = 0;
+
+ /* Save the last setting of 'outInfo_vars' parameter */
+ outInfo_vars_lastset = param_prop->n_set;
}
-
- /* Print the timestep information for all variables */
- if ((GH->cctk_time>hprec)||
- (GH->cctk_time<lprec)||
- (GH->cctk_time==0.0))
+ /* Print the iteration/timestep information for all variables */
+ if (USE_DECIMAL_NOTATION (GH->cctk_time))
printf("%4d |%9.3f|",GH->cctk_iteration,GH->cctk_time);
else
printf("%4d |%7.3e|",GH->cctk_iteration,GH->cctk_time);
-
/* Loop over all variables */
for (i = 0; i < CCTK_NumVars (); i++) {
/* Check this Variable should be output */
- if (myGH->do_outInfo [i]) {
-
- /* Check variable not already output this iteration */
- if (myGH->outInfo_last [i] == GH->cctk_iteration) {
+ if (! myGH->do_outInfo [i])
+ continue;
- if ((myGH->infovals[i][0]>hprec)||
- (myGH->infovals[i][0]<lprec)||
- (myGH->infovals[i][0]>hprec)==0.0)
- printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]);
- else
- printf("%10.6e |%10.6e |",myGH->infovals[i][0],myGH->infovals[i][1]);
-
- } else {
+ /* Check variable not already output this iteration */
+ if (myGH->outInfo_last [i] != GH->cctk_iteration) {
- /* Get the variable name for this index (for filename) */
- name = CCTK_VarName(i);
+ /* Get the variable name for this index (for filename) */
+ name = CCTK_VarName(i);
#ifdef IO_DEBUG
- printf("\nIn IO OutputInfoGH\n----------------\n");
- printf(" Index = %d\n",i);
- printf(" Variable = -%s-\n",name);
- printf(" Last output iteration was = %d\n",myGH->outInfo_last[i]);
+ printf("\nIn IO OutputInfoGH\n----------------\n");
+ printf(" Index = %d\n",i);
+ printf(" Variable = -%s-\n",name);
+ printf(" Last output iteration was = %d\n",myGH->outInfo_last[i]);
#endif
-
- /* Make the IO call */
- myGH->infovals[i][0]=IOBasic_WriteInfo (GH, i, "minimum", name);
- myGH->infovals[i][1]=IOBasic_WriteInfo (GH, i, "maximum", name);
-
-
- if ((myGH->infovals[i][0]>hprec)||
- (myGH->infovals[i][0]<lprec)||
- (myGH->infovals[i][0]>hprec)==0.0)
- printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]);
- else
- printf("%10.6e |%10.6e |",myGH->infovals[i][0],myGH->infovals[i][1]);
+ /* Make the IO call */
+ myGH->infovals[i][0] = IOBasic_WriteInfo (GH, i, "minimum", name);
+ myGH->infovals[i][1] = IOBasic_WriteInfo (GH, i, "maximum", name);
- /* Register GF as having info output this iteration */
- myGH->outInfo_last [i] = GH->cctk_iteration;
- }
+ /* Register GF as having info output this iteration */
+ myGH->outInfo_last [i] = GH->cctk_iteration;
}
- }
+
+ /* finally print out the stuff */
+ if (USE_DECIMAL_NOTATION (myGH->infovals [i][0]))
+ printf ("%12.8f |", myGH->infovals [i][0]);
+ else
+ printf ("%10.6e |", myGH->infovals [i][0]);
+ if (USE_DECIMAL_NOTATION (myGH->infovals [i][1]))
+ printf ("%12.8f |", myGH->infovals [i][1]);
+ else
+ printf ("%10.6e |", myGH->infovals [i][1]);
+
+ } /* end of loop over all variables */
/* Add the new line */
- if (CCTK_MyProc(GH) == 0)
- printf("\n");
+ printf ("\n");
- return 0;
+ return (0);
USE_CCTK_PARAMETERS
@@ -139,7 +163,7 @@ int IOBasic_OutputInfoGH (cGH *GH)
@date June 31 1999
@author Gabrielle Allen
@desc
- Decides if it is time to output a variable using info output
+ Decides if it is time to output a variable using info output
method
@enddesc
@calls CCTK_GHExtensionHandle
@@ -190,6 +214,32 @@ int IOBasic_TimeForInfo (cGH *GH, int var)
return return_type;
}
+
+ /*@@
+ @routine IOBasic_TriggerOutputInfo
+ @date June 31 1999
+ @author Gabrielle Allen
+ @desc
+ Triggers the output of a variable using IOBasic's info output
+ method
+ @enddesc
+ @history
+
+ @endhistory
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH
+ @vio in
+ @vcomment
+ @endvar
+ @var variable
+ @vdesc index of variable
+ @vtype int
+ @vio in
+ @vcomment
+ @endvar
+@@*/
+
int IOBasic_TriggerOutputInfo (cGH *GH, int variable)
{
char *var;