/*@@ @routine IOASCII_TriggerOutput1D @date Sat March 6 1999 @author Gabrielle Allen @desc Triggers the output a variable using the IOASCII output method method @enddesc @calls IOASCII_Write1D @var GH @vdesc Pointer to CCTK GH @vtype const cGH * @vio in @endvar @var vindex @vdesc index of variable to output @vtype int @vio in @endvar @returntype int @returndesc return code of @seeroutine IOASCII_Write1D @endreturndesc @@*/ int IOASCII_TriggerOutput1D (const cGH *GH, int vindex) { int retval; const char *var; asciiioGH *myGH; myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); var = CCTK_VarName (vindex); /* Do the 1D output */ #ifdef IO_DEBUG printf ("\nIn IOASCII TriggerOutput1D\n---------------------\n"); printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", var); #endif retval = IOASCII_Write1D (GH, vindex, var); if (retval == 0) { /* Register variables as having 1D output this iteration */ myGH->out1D_last[vindex] = GH->cctk_iteration; } return (retval); }
/*@@ @routine IOASCII_Choose2D @author Gabrielle Allen @date July 6 2000 @desc Use parameters to choose the 2D slices through the output data. @enddesc @calls CCTK_ParameterQueryTimesSet IOUtil_2DPlanes @var GH @vdesc Pointer to CCTK grid hierarchy @vtype cGH * @vio in @endvar @@*/ void IOASCII_Choose2D (cGH *GH) { DECLARE_CCTK_PARAMETERS int i; asciiioGH *myGH; /* IOASCII extension handle */ int origin_index[3]; /* Specify output planes by indices */ CCTK_REAL origin_phys[3]; /* Specify output planes by coordinates */ GET_SLICE (out2D_xyplane_z, out_xyplane_z, origin_index[0], origin_phys[0]); GET_SLICE (out2D_xzplane_y, out_xzplane_y, origin_index[1], origin_phys[1]); GET_SLICE (out2D_yzplane_x, out_yzplane_x, origin_index[2], origin_phys[2]); myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); for (i = 1; i <= CCTK_MaxDim (); i++) { if (i > 1 && i <= 3) { IOUtil_2DPlanes (GH, i, origin_index, origin_phys, myGH->sp2xyz[i-1]); } else { memset (myGH->sp2xyz[i-1], 0, i * sizeof (myGH->sp2xyz[i-1][0])); } } USE_CCTK_PARAMETERS; }
/*@@ @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_Choose1D @author Gabrielle Allen @date July 6 2000 @desc Use parameters to choose the 1D slices through the output data. @enddesc @calls CCTK_ParameterQueryTimesSet IOUtil_1DLines @var GH @vdesc Pointer to CCTK grid hierarchy @vtype cGH * @vio in @endvar @@*/ void IOASCII_Choose1D (cGH *GH) { DECLARE_CCTK_PARAMETERS int i, j; asciiioGH *myGH; int *origin_index[3]; CCTK_REAL *origin_phys[3]; /* allocate arrays for origins */ origin_phys[0] = (CCTK_REAL *) malloc (3 * 3 * sizeof (CCTK_REAL)); origin_phys[1] = origin_phys[0] + 3; origin_phys[2] = origin_phys[1] + 3; origin_index[0] = (int *) malloc (3 * 3 * sizeof (int)); origin_index[1] = origin_index[0] + 3; origin_index[2] = origin_index[1] + 3; /* get slice points */ GET_SLICE (out1D_xline_y, out_xline_y, origin_index[0][1], origin_phys[0][1]); GET_SLICE (out1D_xline_z, out_xline_z, origin_index[0][2], origin_phys[0][2]); GET_SLICE (out1D_yline_x, out_yline_x, origin_index[1][0], origin_phys[1][0]); GET_SLICE (out1D_yline_z, out_yline_z, origin_index[1][2], origin_phys[1][2]); GET_SLICE (out1D_zline_x, out_zline_x, origin_index[2][0], origin_phys[2][0]); GET_SLICE (out1D_zline_y, out_zline_y, origin_index[2][1], origin_phys[2][1]); myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); for (i = 1; i <= CCTK_MaxDim (); i++) { if (i <= 3) { IOUtil_1DLines (GH, i, origin_index, origin_phys, myGH->spxyz[i-1]); } else { for (j = 0; j < i; j++) { memset (myGH->spxyz[i-1][j], 0, i); } } } /* free allocated resources */ free (origin_phys[0]); free (origin_index[0]); USE_CCTK_PARAMETERS; }
/*@@ @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); }
/*@@ @routine IOBasic_TriggerScalarOutput @date Sat March 6 1999 @author Gabrielle Allen @desc Triggers the output of a variable using IOBasic's Scalar output method @enddesc @var GH @vdesc Pointer to CCTK GH @vtype const cGH * @vio in @endvar @var vindex @vdesc index of variable to output @vtype int @vio in @endvar @returntype int @returndesc return code of @seeroutine IOBasic_WriteScalarGS or @seeroutine IOBasic_WriteScalarGA @endreturndesc @@*/ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex) { int retval; const char *name; iobasicGH *myGH; /* Get the GH extension for IOBasic */ myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic"); name = CCTK_VarName (vindex); #ifdef IOBASIC_DEBUG printf ("\nIn IOBasic_TriggerScalarOutput\n---------------------\n"); printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", name); #endif /* Do the Scalar output */ if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR) { retval = IOBasic_WriteScalarGS (GH, vindex, name); } else { retval = IOBasic_WriteScalarGA (GH, vindex, name); } if (retval == 0) { /* Register variable as having Scalar output this iteration */ myGH->outScalar_last [vindex] = GH->cctk_iteration; } return (retval); }