diff options
author | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2000-07-26 02:32:50 +0000 |
---|---|---|
committer | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2000-07-26 02:32:50 +0000 |
commit | 89da3588c8551a9d41a73e8fedaf98a2fd1d8b2e (patch) | |
tree | 892acd7b844a8af081223560169c3fdcab04bf66 /src/OutputInfo.c | |
parent | 5ef5219e049640848f134969fec13edf850606c7 (diff) |
Fixed wrong Info output (BR CactusBase-408).
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@64 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src/OutputInfo.c')
-rw-r--r-- | src/OutputInfo.c | 122 |
1 files changed, 59 insertions, 63 deletions
diff --git a/src/OutputInfo.c b/src/OutputInfo.c index b0d8c0e..eaf3bf1 100644 --- a/src/OutputInfo.c +++ b/src/OutputInfo.c @@ -19,11 +19,6 @@ #include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" -/* extern prototypes */ -int IOBasic_WriteInfo (cGH *GH, CCTK_REAL *val,int index, - const char *operator, - const char *alias); - /* the number at which to switch from decimal to exp notation */ #define DECIMAL_PRECISION 1.0e-8 @@ -56,18 +51,17 @@ static int outInfo_vars_lastset = 0; int IOBasic_OutputInfoGH (cGH *GH) { - DECLARE_CCTK_PARAMETERS - int i; - int ierr1=-1; - int ierr2=-1; - const char *name; + int i; + int ierr1; + int ierr2; + const char *varname; iobasicGH *myGH; const cParamData *paramdata; - CCTK_REAL val; + /* Get the GH extensions for IOBasic */ - myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; + myGH = (iobasicGH *) GH->extensions[CCTK_GHExtensionHandle ("IOBasic")]; /* How often to output */ myGH->outInfo_every = out_every > 0 ? out_every : -1; @@ -104,7 +98,7 @@ int IOBasic_OutputInfoGH (cGH *GH) do_outInfo = 0; for (i = 0; i < CCTK_NumVars (); i++) - do_outInfo |= myGH->do_outInfo [i]; + do_outInfo |= myGH->do_outInfo[i]; /* suppress any output if there are no variables to output */ if (! do_outInfo) @@ -123,10 +117,12 @@ int IOBasic_OutputInfoGH (cGH *GH) 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]) { + if (myGH->do_outInfo[i]) + { sprintf (ll," "); ll[25-strlen(CCTK_VarName(i))] = '\0'; sprintf (l1,"%s %s%s |",l1,CCTK_VarName(i),ll); @@ -153,45 +149,47 @@ int IOBasic_OutputInfoGH (cGH *GH) { /* Check this Variable should be output */ - if (! myGH->do_outInfo [i]) + if (! myGH->do_outInfo[i]) { continue; } + ierr1 = ierr2 = 0; + /* Check variable not already output this iteration */ - if (myGH->outInfo_last [i] != GH->cctk_iteration) + if (myGH->outInfo_last[i] != GH->cctk_iteration) { /* Get the variable name for this index (for filename) */ - name = CCTK_VarName(i); + varname = 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(" Index = %d\n", i); + printf(" Variable = -%s-\n", varname); + printf(" Last output iteration was = %d\n", myGH->outInfo_last[i]); #endif /* Make the IO call */ - ierr1 = IOBasic_WriteInfo (GH, &val, i, "minimum", name); - myGH->infovals[i][0] = val; - ierr2 = IOBasic_WriteInfo (GH, &val, i, "maximum", name); - myGH->infovals[i][1] = val; + ierr1 = IOBasic_WriteInfo (GH, &myGH->infovals[i][0], i, + "minimum", varname); + ierr2 = IOBasic_WriteInfo (GH, &myGH->infovals[i][1], i, + "maximum", varname); /* Register GF as having info output this iteration */ - myGH->outInfo_last [i] = GH->cctk_iteration; + myGH->outInfo_last[i] = GH->cctk_iteration; } if (ierr1 == 0) { /* finally print out the stuff */ - if (USE_DECIMAL_NOTATION (myGH->infovals [i][0])) + if (USE_DECIMAL_NOTATION (myGH->infovals[i][0])) { - printf ("%12.8f |", myGH->infovals [i][0]); + printf ("%12.8f |", myGH->infovals[i][0]); } else { - printf ("%10.6e |", myGH->infovals [i][0]); + printf ("%10.6e |", myGH->infovals[i][0]); } } else @@ -201,13 +199,13 @@ int IOBasic_OutputInfoGH (cGH *GH) if (ierr2 == 0) { - if (USE_DECIMAL_NOTATION (myGH->infovals [i][1])) + if (USE_DECIMAL_NOTATION (myGH->infovals[i][1])) { - printf ("%12.8f |", myGH->infovals [i][1]); + printf ("%12.8f |", myGH->infovals[i][1]); } else { - printf ("%10.6e |", myGH->infovals [i][1]); + printf ("%10.6e |", myGH->infovals[i][1]); } } else @@ -249,27 +247,27 @@ int IOBasic_OutputInfoGH (cGH *GH) @vio in @vcomment @endvar - @var var - @vdesc index of variable + @var index + @vdesc index of variable to output @vtype int @vio in @vcomment @endvar @@*/ -int IOBasic_TimeForInfo (cGH *GH, int var) +int IOBasic_TimeForInfo (cGH *GH, int index) { - int return_type; + DECLARE_CCTK_PARAMETERS + int retval; iobasicGH *myGH; const cParamData *paramdata; - DECLARE_CCTK_PARAMETERS /* Default is do not do output */ - return_type = 0; + retval = 0; /* Get the GH extensions for IOBasic */ - myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; + myGH = (iobasicGH *) GH->extensions[CCTK_GHExtensionHandle ("IOBasic")]; /* How often to output */ myGH->outInfo_every = out_every > 0 ? out_every : -1; @@ -300,18 +298,19 @@ int IOBasic_TimeForInfo (cGH *GH, int var) print_header = 1; } - /* Check this GF should be output */ - if (myGH->do_outInfo [var] && - (GH->cctk_iteration % myGH->outInfo_every == 0)) { + /* Check if this variable should be output */ + if (myGH->do_outInfo[index] && + (GH->cctk_iteration % myGH->outInfo_every == 0)) + { /* Check GF not already output this iteration */ - if (myGH->outInfo_last [var] == GH->cctk_iteration) + if (myGH->outInfo_last[index] == GH->cctk_iteration) CCTK_WARN (2, "Already done info output in IO"); else - return_type = 1; + retval = 1; } - return return_type; + return retval; } @@ -332,40 +331,37 @@ int IOBasic_TimeForInfo (cGH *GH, int var) @vio in @vcomment @endvar - @var variable - @vdesc index of variable + @var index + @vdesc index of variable to output @vtype int @vio in @vcomment @endvar @@*/ -int IOBasic_TriggerOutputInfo (cGH *GH, int variable) +int IOBasic_TriggerOutputInfo (cGH *GH, int index) { - const char *var; iobasicGH *myGH; - int ierr1,ierr2; - CCTK_REAL val; + const char *varname; + /* Get the GH extension for IOBasic */ - myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; - - var = CCTK_VarName (variable); + myGH = (iobasicGH *) GH->extensions[CCTK_GHExtensionHandle ("IOBasic")]; + + varname = CCTK_VarName (index); /* Do the Info output */ #ifdef IO_DEBUG - printf("\nIn IO TriggerOutputInfo\n---------------------\n"); - printf(" Index = %d\n",variable); - printf(" Variable = -%s-\n",var); + printf ("\nIn IO TriggerOutputInfo\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", varname); #endif - ierr1=IOBasic_WriteInfo (GH, &val, variable, "minimum",var); - myGH->infovals[variable][0] = val; - ierr2=IOBasic_WriteInfo (GH, &val, variable, "maximum",var); - myGH->infovals[variable][1] = val; + IOBasic_WriteInfo (GH, &myGH->infovals[index][0], index, "minimum", varname); + IOBasic_WriteInfo (GH, &myGH->infovals[index][1], index, "maximum", varname); - /* Register GF as having Info output this iteration */ - myGH->outInfo_last [variable] = GH->cctk_iteration; + /* Register variable as having Info output at this iteration */ + myGH->outInfo_last[index] = GH->cctk_iteration; return 0; } |