diff options
-rw-r--r-- | src/GHExtension.c | 46 | ||||
-rw-r--r-- | src/Output.c | 31 | ||||
-rw-r--r-- | src/OutputInfo.c | 34 | ||||
-rw-r--r-- | src/Write.c | 2 | ||||
-rw-r--r-- | src/WriteGF.c | 8 | ||||
-rw-r--r-- | src/iobasicGH.h | 21 |
6 files changed, 64 insertions, 78 deletions
diff --git a/src/GHExtension.c b/src/GHExtension.c index 3cfaa02..3313abc 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -15,6 +15,7 @@ #include "cctk.h" #include "cctk_parameters.h" +#include "cctk_ParameterFunctions.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" @@ -29,11 +30,11 @@ void *IOBasic_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) for (i=0;i<CCTK_NumVars ();i++) newGH->infovals[i] = (CCTK_REAL *) malloc (2 * sizeof (CCTK_REAL)); - newGH->Scalarnum = (int *) malloc (CCTK_NumVars () * sizeof (int)); - newGH->Scalarlast = (int *) malloc (CCTK_NumVars () * sizeof (int)); + newGH->do_outScalar = (char *) malloc (CCTK_NumVars () * sizeof (char)); + newGH->outScalar_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); - newGH->infonum = (int *) malloc (CCTK_NumVars () * sizeof (int)); - newGH->infolast = (int *) malloc (CCTK_NumVars () * sizeof (int)); + newGH->do_outInfo = (char *) malloc (CCTK_NumVars () * sizeof (char)); + newGH->outInfo_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); return newGH; } @@ -43,39 +44,40 @@ int IOBasic_InitGH (cGH *GH) DECLARE_CCTK_PARAMETERS int i; iobasicGH *myGH; + t_param_prop *param_prop; /* get the handles for IOBasic extensions */ myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; myGH->filenameListScalar = NULL; /* How often to output */ - myGH->infoevery = out_every > 0 ? out_every : -1; + myGH->outInfo_every = out_every > 0 ? out_every : -1; if (outInfo_every > 0) - myGH->infoevery = outInfo_every; + myGH->outInfo_every = outInfo_every; - myGH->Scalarevery = out_every > 0 ? out_every : -1; + myGH->outScalar_every = out_every > 0 ? out_every : -1; if (outScalar_every > 0) - myGH->Scalarevery = outScalar_every; + myGH->outScalar_every = outScalar_every; - InitIONum(myGH->infonum,outInfo_vars); - InitIONum(myGH->Scalarnum,outScalar_vars); + ParseVarsForOutput (outInfo_vars, myGH->do_outInfo); + ParseVarsForOutput (outScalar_vars, myGH->do_outScalar); - /* Deal with the output directories */ - myGH->outpfx_Scalar = outdir; - if (!CCTK_Equals(outdirScalar,"outdir")) - myGH->outpfx_Scalar = outdirScalar; + /* Check whether "outdirScalar" was set. + If so take this dir otherwise default to "IO::outdir" */ + param_prop = CCTK_ParameterInfo ("outdirScalar", CCTK_THORNSTRING); + if (param_prop && param_prop->n_set > 0) + myGH->outdirScalar = outdirScalar; + else + myGH->outdirScalar = outdir; - /* Create the output directories */ - if (myGH->Scalarevery > 0) { - if (CCTK_MyProc (GH) == 0) { - CCTK_mkdir(myGH->outpfx_Scalar); - } - } + /* create the output dir */ + if (CCTK_MyProc (GH) == 0) + CCTK_mkdir (myGH->outdirScalar); for (i=0; i<CCTK_NumVars(); i++) - myGH->Scalarlast[i] = -1; + myGH->outScalar_last[i] = -1; for (i=0; i<CCTK_NumVars(); i++) - myGH->infolast [i] = -1; + myGH->outInfo_last [i] = -1; for (i=0; i<CCTK_NumVars(); i++) { diff --git a/src/Output.c b/src/Output.c index 4dea94f..fdfd92c 100644 --- a/src/Output.c +++ b/src/Output.c @@ -31,7 +31,7 @@ int IOBasic_OutputGH (cGH *GH) myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; /* Return if no output is required */ - if (myGH->Scalarevery < 0) + if (myGH->outScalar_every <= 0) return 0; /* Loop over all variables */ @@ -40,12 +40,12 @@ int IOBasic_OutputGH (cGH *GH) grouptype = CCTK_GroupTypeFromVarI (i); /* Check this GF should be output */ - if ((grouptype == GROUP_GF||grouptype == GROUP_SCALAR) - && myGH->Scalarnum [i] != 0 - && (GH->cctk_iteration % myGH->Scalarevery == 0)) { + if (myGH->do_outScalar [i] + && (grouptype == GROUP_GF||grouptype == GROUP_SCALAR) + && (GH->cctk_iteration % myGH->outScalar_every == 0)) { /* Check GF not already output this iteration */ - if (myGH->Scalarlast [i] == GH->cctk_iteration) { + if (myGH->outScalar_last [i] == GH->cctk_iteration) { char *msg, *varname; varname = CCTK_VarName (i); @@ -78,8 +78,7 @@ int IOBasic_OutputGH (cGH *GH) printf("\nIn IOBasic_OutputGH\n----------------\n"); printf(" Index = %d\n",i); printf(" Variable = -%s-\n",name); - printf(" Last output iteration was = %d\n",myGH->Scalarlast[i]); - printf(" Output iteration number = %d\n",myGH->Scalarnum[i]); + printf(" Last output iteration was = %d\n",myGH->outScalar_last[i]); #endif /* Make the IO call */ @@ -92,11 +91,8 @@ int IOBasic_OutputGH (cGH *GH) IOBasic_WriteGF (GH, i, name); } - /* Register another 0D output for this GF */ - myGH->Scalarnum [i]++; - /* Register GF as having 0D output this iteration */ - myGH->Scalarlast [i] = GH->cctk_iteration; + myGH->outScalar_last [i] = GH->cctk_iteration; } } } @@ -179,12 +175,12 @@ int IOBasic_TimeForOutput (cGH *GH, int var) grouptype = CCTK_GroupTypeFromVarI (var); /* Check this GF should be output */ - if ((grouptype == GROUP_GF || grouptype == GROUP_SCALAR) - && myGH->Scalarnum [var] != 0 - && (GH->cctk_iteration % myGH->Scalarevery == 0)) { + if (myGH->do_outScalar [var] + && (grouptype == GROUP_GF || grouptype == GROUP_SCALAR) + && (GH->cctk_iteration % myGH->outScalar_every == 0)) { /* Check GF not already output this iteration */ - if (myGH->Scalarlast [var] == GH->cctk_iteration) + if (myGH->outScalar_last [var] == GH->cctk_iteration) CCTK_WARN (2, "Already done Scalar output in IO"); else return_type = 1; @@ -223,11 +219,8 @@ int IOBasic_TriggerOutput (cGH *GH, int variable) IOBasic_WriteGF (GH, variable, var); } - /* Register another Scalar output for this GF */ - myGH->Scalarnum [variable]++; - /* Register variable as having Scalar output this iteration */ - myGH->Scalarlast [variable] = GH->cctk_iteration; + myGH->outScalar_last [variable] = GH->cctk_iteration; return 0; } diff --git a/src/OutputInfo.c b/src/OutputInfo.c index 5bbe723..f55388f 100644 --- a/src/OutputInfo.c +++ b/src/OutputInfo.c @@ -29,12 +29,12 @@ int IOBasic_OutputInfoGH (cGH *GH) 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 if no output is required */ + if (myGH->outInfo_every < 1 || GH->cctk_iteration % myGH->outInfo_every != 0) return 0; /* Print a header the first time through */ @@ -49,7 +49,7 @@ int IOBasic_OutputInfoGH (cGH *GH) for (i = 0; i < CCTK_NumVars (); i++) { char ll[80]; - if(myGH->infonum[i] != 0) + if(myGH->do_outInfo [i]) { sprintf (ll," "); ll[25-strlen(CCTK_VarName(i))] = '\0'; @@ -73,10 +73,10 @@ int IOBasic_OutputInfoGH (cGH *GH) grouptype = CCTK_GroupTypeFromVarI (i); /* Check this Variable should be output */ - if (myGH->infonum [i] != 0) { + if (myGH->do_outInfo [i]) { /* Check variable not already output this iteration */ - if (myGH->infolast [i] == GH->cctk_iteration) { + if (myGH->outInfo_last [i] == GH->cctk_iteration) { printf("%12.8f |%12.8f |",myGH->infovals[i][0],myGH->infovals[i][1]); @@ -101,8 +101,7 @@ int IOBasic_OutputInfoGH (cGH *GH) 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]); + printf(" Last output iteration was = %d\n",myGH->outInfo_last[i]); #endif /* Make the IO call */ @@ -111,11 +110,8 @@ int IOBasic_OutputInfoGH (cGH *GH) 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; + myGH->outInfo_last [i] = GH->cctk_iteration; } } } @@ -162,7 +158,6 @@ int IOBasic_OutputInfoGH (cGH *GH) int IOBasic_TimeForInfo (cGH *GH, int var) { int return_type; - int grouptype; iobasicGH *myGH; /* Default is do not do output */ @@ -171,14 +166,12 @@ int IOBasic_TimeForInfo (cGH *GH, int var) /* 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)) { + if (myGH->do_outInfo [var] && + (GH->cctk_iteration % myGH->outInfo_every == 0)) { /* Check GF not already output this iteration */ - if (myGH->infolast [var] == GH->cctk_iteration) + if (myGH->outInfo_last [var] == GH->cctk_iteration) CCTK_WARN (2, "Already done info output in IO"); else return_type = 1; @@ -208,11 +201,8 @@ int IOBasic_TriggerOutputInfo (cGH *GH, int variable) 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; + myGH->outInfo_last [variable] = GH->cctk_iteration; return 0; } diff --git a/src/Write.c b/src/Write.c index f42dbfb..c2c9531 100644 --- a/src/Write.c +++ b/src/Write.c @@ -45,7 +45,7 @@ void IOBasic_Write (cGH *GH, int index, const char *alias) } else openmode = "a"; - sprintf (fname, "%s/%s.tl", myGH->outpfx_Scalar, alias); + sprintf (fname, "%s/%s.tl", myGH->outdirScalar, alias); file = fopen(fname,openmode); if (*openmode == 'w') { diff --git a/src/WriteGF.c b/src/WriteGF.c index 01da1bb..ddfb516 100644 --- a/src/WriteGF.c +++ b/src/WriteGF.c @@ -45,16 +45,16 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias) } else openmode = "a"; - sprintf (fname, "%s/%s_max.tl", myGH->outpfx_Scalar, alias); + sprintf (fname, "%s/%s_max.tl", myGH->outdirScalar, alias); file[0] = fopen(fname,openmode); - sprintf(fname,"%s/%s_min.tl", myGH->outpfx_Scalar, alias); + sprintf(fname,"%s/%s_min.tl", myGH->outdirScalar, alias); file[1] = fopen(fname,openmode); - sprintf(fname,"%s/%s_nm1.tl", myGH->outpfx_Scalar, alias); + sprintf(fname,"%s/%s_nm1.tl", myGH->outdirScalar, alias); file[2] = fopen(fname,openmode); - sprintf(fname,"%s/%s_nm2.tl", myGH->outpfx_Scalar, alias); + sprintf(fname,"%s/%s_nm2.tl", myGH->outdirScalar, alias); file[3] = fopen(fname,openmode); if (*openmode == 'w') { diff --git a/src/iobasicGH.h b/src/iobasicGH.h index a61fdb4..1c21c61 100644 --- a/src/iobasicGH.h +++ b/src/iobasicGH.h @@ -13,23 +13,25 @@ typedef struct IOBASICGH { - /* The number of times output */ - int *infonum; - int *Scalarnum; + /* how often to output */ + int outScalar_every; + int outInfo_every; - int Scalarevery; - int infoevery; + /* flags indicating output for var [i] */ + char *do_outInfo; + char *do_outScalar; - /* Directory in which to output */ - char *outpfx_Scalar; + /* directory in which to output */ + char *outdirScalar; /* The last iteration output */ - int *infolast; - int *Scalarlast; + int *outInfo_last; + int *outScalar_last; /* The values for info */ CCTK_REAL **infovals; + /* database for names of output files that were already created */ pNamedData *filenameListScalar; } iobasicGH; @@ -39,4 +41,3 @@ typedef struct IOBASICGH { void IOBasic_Write (cGH *GH, int index, const char *alias); void IOBasic_WriteGF (cGH *GH, int index, const char *alias); CCTK_REAL IOBasic_WriteInfo (cGH *GH, int index, const char *operator, const char *alias); - |