/*@@ @routine IOBasic_ScalarOutputGH @date Sat March 6 1999 @author Gabrielle Allen @desc Loops over all variables and outputs them if necessary @enddesc @calls IOBasic_TimeForScalarOutput IOBasic_WriteScalarGS IOBasic_WriteScalarGA @var GH @vdesc Pointer to CCTK GH @vtype const cGH * @vio in @endvar @returntype int @returndesc the number of variables which were output at this iteration (or 0 if it wasn't time to output yet) @endreturndesc @@*/ int IOBasic_ScalarOutputGH (const cGH *GH) { int i, vindex, retval; const char *name; iobasicGH *myGH; /* Get the GH extensions for IOBasic */ myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic"); CheckSteerableParameters (myGH); /* Return if no output is required */ if (myGH->outScalar_every <= 0) { return (0); } /* Loop over all variables */ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { /* Is it time for output ? */ if (! IOBasic_TimeForScalarOutput (GH, vindex)) { continue; } /* Get the variable name for this index (for filename) */ name = CCTK_VarName (vindex); #ifdef IOBASIC_DEBUG printf("\nIn IOBasic_ScalarOutputGH\n----------------\n"); printf(" Index = %d\n",vindex); printf(" Variable = -%s-\n",name); printf(" Last output iteration was = %d\n",myGH->outScalar_last[vindex]); #endif /* Make the IO call */ if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR) { i = IOBasic_WriteScalarGS (GH, vindex, name); } else { i = IOBasic_WriteScalarGA (GH, vindex, name); } if (i == 0) { /* Register GF as having 0D output this iteration */ myGH->outScalar_last [vindex] = GH->cctk_iteration; retval++; } } /* end of loop over all variables */ return (retval); }
/*@@ @routine IOASCII_Output1DGH @date Sat March 6 1999 @author Gabrielle Allen @desc Loops over all variables and outputs them if necessary @enddesc @calls IOASCII_TimeFor1D IOASCII_Write1D @var GH @vdesc Pointer to CCTK GH @vtype const cGH * @vio in @endvar @returntype int @returndesc the number of variables which were output at this iteration (or 0 if it wasn't time to output yet) @endreturndesc @@*/ int IOASCII_Output1DGH (const cGH *GH) { int vindex, retval; asciiioGH *myGH; const char *name; /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); CheckSteerableParameters (myGH); /* Return if no output is required */ if (myGH->out1D_every <= 0) { return (0); } /* Loop over all variables */ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { /* Check if this variable should be output */ if (! IOASCII_TimeFor1D (GH, vindex)) { continue; } /* Get the variable name for this index (for filename) */ name = CCTK_VarName (vindex); #ifdef IO_DEBUG printf ("\nIn IOASCII Output1DGH\n---------------------\n"); printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", name); printf (" On iteration %d\n", GH->cctk_iteration); printf (" Last output iteration was = %d\n", myGH->out1D_last[vindex]); #endif /* Make the IO call */ if (IOASCII_Write1D (GH, vindex, name) == 0) { /* Register variable as having 1D output this iteration */ myGH->out1D_last[vindex] = GH->cctk_iteration; retval++; } } /* end of loop over all variables */ return (retval); }
/*@@ @routine IOASCII_TimeFor1D @date Sat March 6 1999 @author Gabrielle Allen @desc Decides if it is time to output a variable using the IO 1D output method @enddesc @var GH @vdesc Pointer to CCTK GH @vtype const cGH * @vio in @endvar @var vindex @vdesc index of variable @vtype int @vio in @endvar @returntype int @returndesc 1 if output should take place at this iteration, or<BR> 0 if not @endreturndesc @@*/ int IOASCII_TimeFor1D (const cGH *GH, int vindex) { int return_type; asciiioGH *myGH; char *fullname; /* Default is do not do output */ return_type = 0; /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); CheckSteerableParameters (myGH); /* return if no output requested */ if (myGH->out1D_every <= 0) { return (0); } /* Check if this variable should be output */ if (myGH->do_out1D[vindex] && GH->cctk_iteration % myGH->out1D_every == 0) { /* Check if this variable wasn't already output this iteration */ if (myGH->out1D_last[vindex] == GH->cctk_iteration) { fullname = CCTK_FullName (vindex); CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, "Already done IOASCII 1D output for '%s' in current " "iteration (probably via triggers)", fullname); free (fullname); } else { return_type = 1; } } return (return_type); }
/*@@ @routine IOBasic_TimeForScalarOutput @date Sat March 6 1999 @author Gabrielle Allen @desc Decides if it is time to do Scalar output. @enddesc @var GH @vdesc Pointer to CCTK GH @vtype const cGH * @vio in @endvar @var vindex @vdesc index of variable @vtype int @vio in @endvar @returntype int @returndesc 1 if output should take place at this iteration, or<BR> 0 if not @endreturndesc @@*/ int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex) { int return_type; iobasicGH *myGH; char *fullname; /* Default is do not do output */ return_type = 0; /* Get the GH extension for IOBasic */ myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic"); CheckSteerableParameters (myGH); /* check if any output was requested */ if (myGH->outScalar_every <= 0) { return (0); } /* Check if this variable should be output */ if (myGH->do_outScalar [vindex] && (GH->cctk_iteration % myGH->outScalar_every) == 0) { /* Check if variable wasn't already output this iteration */ if (myGH->outScalar_last [vindex] == GH->cctk_iteration) { fullname = CCTK_FullName (vindex); CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, "Already done IOBasic scalar output for '%s' in " "current iteration (probably via triggers)", fullname); free (fullname); } else { return_type = 1; } } return (return_type); }