diff options
author | allen <allen@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 1999-09-21 11:27:32 +0000 |
---|---|---|
committer | allen <allen@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 1999-09-21 11:27:32 +0000 |
commit | 1940d71782b4cc3519972ebf4504bbe4486cf7d0 (patch) | |
tree | bc11dc4e95891c19d3e88c0b15bb4ebf068d1d45 /src/OutputInfo.c | |
parent | ac667e93729515249ec4d81961d1c83e2a0e217d (diff) |
This commit was generated by cvs2svn to compensate for changes in r2, which
included commits to RCS files with non-trunk default branches.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@3 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src/OutputInfo.c')
-rw-r--r-- | src/OutputInfo.c | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/src/OutputInfo.c b/src/OutputInfo.c new file mode 100644 index 0000000..220104f --- /dev/null +++ b/src/OutputInfo.c @@ -0,0 +1,226 @@ + /*@@ + @file OutputInfo.c + @date June 31 1999 + @author Gabrielle Allen + @desc + Functions to deal with Info output of Variables + @enddesc + @@*/ + +/*#define IO_DEBUG*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cctk_Flesh.h" +#include "cctk_Groups.h" +#include "cctk_Comm.h" +#include "cctk_GHExtensions.h" +#include "cctk_WarnLevel.h" +#include "cctk_Misc.h" +#include "cctk_parameters.h" +#include "iobasicGH.h" + +CCTK_REAL IOBasic_WriteInfo (cGH *GH, int index, const char *operator, const char *alias); + +static int first = 1; + +int IOBasic_OutputInfoGH (cGH *GH) +{ + DECLARE_CCTK_PARAMETERS + int i; + int grouptype; + char *name=NULL; + iobasicGH *myGH; + + /* Get the GH extensions for IOBasic */ + myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; + + /* Return if no output is required (should use do_1dio parameter) */ + if (myGH->infoevery < 1 || + GH->cctk_iteration % myGH->infoevery != 0) + return 0; + + /* Print a header the first time through */ + if (first == 1) + { + char l1[1024],l2[1024],l3[1024]; + + sprintf (l1," it | |"); + sprintf (l2," | t |"); + sprintf (l3,"--------------"); + + for (i = 0; i < CCTK_NumVars (); i++) + { + char ll[80]; + if(myGH->infonum[i] != 0) + { + 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; + } + + /* Print the timestep information for all variables */ + printf("%4d |%7.3f|",GH->cctk_iteration,GH->cctk_time); + + + /* Loop over all variables */ + for (i = 0; i < CCTK_NumVars (); i++) { + + grouptype = CCTK_GroupTypeFromVarI (i); + + /* Check this Variable should be output */ + if (myGH->infonum [i] != 0) { + + /* Check variable not already output this iteration */ + if (myGH->infolast [i] == GH->cctk_iteration) { + + printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]); + + } + /* Check GF has storage */ + else if (grouptype == GROUP_GF && ! CCTK_QueryGroupStorageI (GH, + CCTK_GroupIndexFromVarI (i))){ + char *msg, *varname; + + varname = CCTK_VarName(i); + msg = (char *) malloc (200 * sizeof (char) + strlen (varname)); + sprintf (msg, "No info output in IOBasic_OutputInfoGH for '%s' " + "(no storage)", varname); + CCTK_WARN (2, msg); + free (msg); + } else { + + /* 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->infolast[i]); + printf(" Output iteration number = %d\n",myGH->infonum[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); + + printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]); + + /* Register another info output for this variable */ + myGH->infonum [i]++; + + /* Register GF as having info output this iteration */ + myGH->infolast [i] = GH->cctk_iteration; + } + } + } + + /* Add the new line */ + if (CCTK_MyProc(GH) == 0) + printf("\n"); + + return 0; +} + + + /*@@ + @routine IOBasic_TimeForInfo + @date June 31 1999 + @author Gabrielle Allen + @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 + + @endhistory + @var GH + @vdesc Pointer to CCTK GH + @vtype cGH + @vio in + @vcomment + @endvar + @var var + @vdesc index of variable + @vtype int + @vio in + @vcomment + @endvar +@@*/ + +int IOBasic_TimeForInfo (cGH *GH, int var) +{ + int return_type; + int grouptype; + iobasicGH *myGH; + + /* Default is do not do output */ + return_type = 0; + + /* Get the GH extensions for IOBasic */ + myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; + + grouptype = CCTK_GroupTypeFromVarI (var); + + /* Check this GF should be output */ + if (myGH->infonum [var] != 0 + && (GH->cctk_iteration % myGH->infoevery == 0)) { + + /* Check GF not already output this iteration */ + if (myGH->infolast [var] == GH->cctk_iteration) + CCTK_WARN (2, "Already done info output in IO"); + else + return_type = 1; + } + + return return_type; +} + +int IOBasic_TriggerOutputInfo (cGH *GH, int variable) +{ + char *var; + iobasicGH *myGH; + + + /* Get the GH extension for IOBasic */ + myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; + + var = CCTK_VarName (variable); + + /* Do the Info output */ +#ifdef IO_DEBUG + printf("\nIn IO TriggerOutputInfo\n---------------------\n"); + printf(" Index = %d\n",variable); + printf(" Variable = -%s-\n",var); +#endif + + myGH->infovals[variable][0]=IOBasic_WriteInfo (GH, variable, "minimum",var); + myGH->infovals[variable][1]=IOBasic_WriteInfo (GH, variable, "maximum",var); + + /* Register another Info output for this GF */ + myGH->infonum [variable]++; + + /* Register GF as having Info output this iteration */ + myGH->infolast [variable] = GH->cctk_iteration; + + return 0; +} + + + |