diff options
author | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2001-03-06 14:23:37 +0000 |
---|---|---|
committer | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2001-03-06 14:23:37 +0000 |
commit | 1c26785b4b71a720ec6898ff4294158b75c187db (patch) | |
tree | 8f9b3bf889d3359f1db782ad9e70dff968e58534 | |
parent | cde9d1c4ccdb9caff0145f20e97f56847be08c24 (diff) |
Do not skip output if there are no variables to output. It will at least output
the iteration number and time. This closes PR CactusBase-544.
Also fixed gcc warnings and finished grdoc.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@80 b589c3ab-70e8-4b4d-a09f-cba2dd200880
-rw-r--r-- | src/OutputInfo.c | 226 |
1 files changed, 110 insertions, 116 deletions
diff --git a/src/OutputInfo.c b/src/OutputInfo.c index 2847554..3a6a913 100644 --- a/src/OutputInfo.c +++ b/src/OutputInfo.c @@ -3,12 +3,11 @@ @date June 31 1999 @author Gabrielle Allen @desc - Functions to deal with Info output of Variables + Functions to deal with info output of variables @enddesc + @version $Header$ @@*/ -/*#define IO_DEBUG 1*/ - #include <math.h> #include <stdio.h> #include <stdlib.h> @@ -18,6 +17,12 @@ #include "cctk_Parameters.h" #include "iobasicGH.h" +/* the rcs ID and its dummy function to use it */ +static char *rcsid = "$Header$"; +CCTK_FILEVERSION(CactusBase_IOBasic_OutputInfo_c) + +/* uncomment the following to get some debugging output */ +/* #define IO_DEBUG 1 */ /* the number at which to switch from decimal to exp notation */ #define DECIMAL_PRECISION 1.0e-8 @@ -26,8 +31,11 @@ ((x) == 0.0) || \ (fabs(x) < DECIMAL_TOOBIG)) -/* function prototypes */ -static void SetOutputFlag (int index, const char *optstring, void *arg); +/* prototypes of routines defined in this source file */ +int IOBasic_OutputInfoGH (cGH *GH); +int IOBasic_TimeForInfo (cGH *GH, int vindex); +int IOBasic_TriggerOutputInfo (cGH *GH, int vindex); +static void SetOutputFlag (int vindex, const char *optstring, void *arg); /* static variables */ static int print_header = 1; @@ -38,21 +46,27 @@ static int outInfo_vars_lastset = -1; @routine IOBasic_OutputInfoGH @date June 31 1999 @author Gabrielle Allen - @desc + @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 + @enddesc + @calls CCTK_GHExtension + CCTK_ParameterQueryTimesSet + CCTK_TraverseString + CCTK_NumVars + CCTK_VarName + IOBasic_WriteInfo + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in @endvar + + @returntype int + @returndesc + 0 for success + @endreturndesc @@*/ - int IOBasic_OutputInfoGH (cGH *GH) { DECLARE_CCTK_PARAMETERS @@ -60,12 +74,13 @@ int IOBasic_OutputInfoGH (cGH *GH) int ierr1; int ierr2; int times_set; - const char *varname; + const char *vname; iobasicGH *myGH; + char ll[80], l1[1024], l2[1024], l3[1024]; /* Get the GH extensions for IOBasic */ - myGH = (iobasicGH *) GH->extensions[CCTK_GHExtensionHandle ("IOBasic")]; + myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic"); /* How often to output */ myGH->outInfo_every = out_every > 0 ? out_every : -1; @@ -86,9 +101,6 @@ int IOBasic_OutputInfoGH (cGH *GH) times_set = CCTK_ParameterQueryTimesSet ("outInfo_vars", CCTK_THORNSTRING); if (times_set != outInfo_vars_lastset) { - int do_outInfo; - - memset (myGH->do_outInfo, 0, CCTK_NumVars ()); CCTK_TraverseString (outInfo_vars, SetOutputFlag, myGH->do_outInfo, CCTK_GROUP_OR_VAR); @@ -96,25 +108,11 @@ int IOBasic_OutputInfoGH (cGH *GH) /* Save the last setting of 'outInfo_vars' parameter */ outInfo_vars_lastset = times_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); - } - print_header = 1; } if (print_header) { - char l1[1024],l2[1024],l3[1024]; - print_header = 0; sprintf (l1," it | |"); @@ -123,29 +121,27 @@ int IOBasic_OutputInfoGH (cGH *GH) 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); + 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); + printf ("%s\n%s\n%s\n%s\n", l3, l1, l2, l3); + fflush (stdout); } /* 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); + printf ("%4d |%9.3f|", GH->cctk_iteration, GH->cctk_time); } else { - printf("%4d |%7.3e|",GH->cctk_iteration,GH->cctk_time); + printf ("%4d |%7.3e|", GH->cctk_iteration, GH->cctk_time); } /* Loop over all variables */ @@ -165,20 +161,18 @@ int IOBasic_OutputInfoGH (cGH *GH) { /* Get the variable name for this index (for filename) */ - varname = CCTK_VarName (i); + vname = CCTK_VarName (i); #ifdef IO_DEBUG printf("\nIn IO OutputInfoGH\n----------------\n"); printf(" Index = %d\n", i); - printf(" Variable = -%s-\n", varname); + printf(" Variable = -%s-\n", vname); printf(" Last output iteration was = %d\n", myGH->outInfo_last[i]); #endif /* Make the IO call */ - ierr1 = IOBasic_WriteInfo (GH, &myGH->infovals[i][0], i, - "minimum", varname); - ierr2 = IOBasic_WriteInfo (GH, &myGH->infovals[i][1], i, - "maximum", varname); + ierr1 = IOBasic_WriteInfo (GH, &myGH->infovals[i][0], i, "minimum",vname); + ierr2 = IOBasic_WriteInfo (GH, &myGH->infovals[i][1], i, "maximum",vname); /* Register GF as having info output this iteration */ myGH->outInfo_last[i] = GH->cctk_iteration; @@ -221,7 +215,6 @@ int IOBasic_OutputInfoGH (cGH *GH) /* Add the new line */ printf ("\n"); - fflush(stdout); return (0); @@ -232,45 +225,45 @@ int IOBasic_OutputInfoGH (cGH *GH) @routine IOBasic_TimeForInfo @date June 31 1999 @author Gabrielle Allen - @desc + @desc Decides if it is time to output a variable using info output - method - @enddesc - @calls CCTK_GHExtensionHandle - CCTK_GroupTypeFromVarI - CCTK_WARN - CCTK_QueryGroupStorageI - CCTK_GroupFromVar - @calledby - @history + @enddesc + @calls CCTK_GHExtensionHandle + CCTK_GroupTypeFromVarI + CCTK_WARN + CCTK_QueryGroupStorageI + CCTK_GroupFromVar - @endhistory - @var GH - @vdesc Pointer to CCTK GH - @vtype cGH - @vio in - @vcomment + @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 vindex + @vdesc index of variable to output + @vtype int + @vio in @endvar + + @returntype int + @returndesc + true/false (1 or 0) if this variable should be output or not + @endreturndesc @@*/ -int IOBasic_TimeForInfo (cGH *GH, int index) +int IOBasic_TimeForInfo (cGH *GH, int vindex) { DECLARE_CCTK_PARAMETERS int retval; int times_set; iobasicGH *myGH; + char *fullname; /* Default is do not do output */ retval = 0; /* Get the GH extensions for IOBasic */ - myGH = (iobasicGH *) GH->extensions[CCTK_GHExtensionHandle ("IOBasic")]; + myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic"); /* How often to output */ myGH->outInfo_every = out_every > 0 ? out_every : -1; @@ -301,16 +294,14 @@ int IOBasic_TimeForInfo (cGH *GH, int index) } /* Check if this variable should be output */ - if (myGH->do_outInfo[index] && + if (myGH->do_outInfo[vindex] && (GH->cctk_iteration % myGH->outInfo_every == 0)) { /* Check GF not already output this iteration */ - if (myGH->outInfo_last[index] == GH->cctk_iteration) + if (myGH->outInfo_last[vindex] == GH->cctk_iteration) { - char *fullname = CCTK_FullName (index); - - + fullname = CCTK_FullName (vindex); CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, "Already done Info output for '%s' in current " "iteration (probably via triggers)", fullname); @@ -322,7 +313,7 @@ int IOBasic_TimeForInfo (cGH *GH, int index) } } - return retval; + return (retval); } @@ -330,64 +321,67 @@ int IOBasic_TimeForInfo (cGH *GH, int index) @routine IOBasic_TriggerOutputInfo @date June 31 1999 @author Gabrielle Allen - @desc + @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 index - @vdesc index of variable to output - @vtype int - @vio in - @vcomment - @endvar + @enddesc + @calls CCTK_GHExtensionHandle + IOBasic_WriteInfo + + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH * + @vio in + @endvar + @var vindex + @vdesc index of variable to output + @vtype int + @vio in + @endvar + + @returntype int + @returndesc + 0 for success + @endreturndesc @@*/ - -int IOBasic_TriggerOutputInfo (cGH *GH, int index) +int IOBasic_TriggerOutputInfo (cGH *GH, int vindex) { iobasicGH *myGH; - const char *varname; + const char *vname; /* Get the GH extension for IOBasic */ - myGH = (iobasicGH *) GH->extensions[CCTK_GHExtensionHandle ("IOBasic")]; + myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic"); - varname = CCTK_VarName (index); + vname = CCTK_VarName (vindex); /* Do the Info output */ #ifdef IO_DEBUG printf ("\nIn IO TriggerOutputInfo\n---------------------\n"); - printf (" Index = %d\n", index); - printf (" Variable = -%s-\n", varname); + printf (" Index = %d\n", vindex); + printf (" Variable = -%s-\n", vname); #endif - IOBasic_WriteInfo (GH, &myGH->infovals[index][0], index, "minimum", varname); - IOBasic_WriteInfo (GH, &myGH->infovals[index][1], index, "maximum", varname); + IOBasic_WriteInfo (GH, &myGH->infovals[vindex][0], vindex, "minimum", vname); + IOBasic_WriteInfo (GH, &myGH->infovals[vindex][1], vindex, "maximum", vname); /* Register variable as having Info output at this iteration */ - myGH->outInfo_last[index] = GH->cctk_iteration; - - return 0; + myGH->outInfo_last[vindex] = GH->cctk_iteration; + + return (0); } -/**************************** local functions ******************************/ +/***************************************************************************/ +/* local functions */ +/***************************************************************************/ /* callback for CCTK_TraverseString() to set the output flag for the given variable */ -static void SetOutputFlag (int index, const char *optstring, void *arg) +static void SetOutputFlag (int vindex, const char *optstring, void *arg) { char *flags = (char *) arg; - flags[index] = 1; + flags[vindex] = 1; if (optstring) { |