Beispiel #1
0
 /*@@
   @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);
}
Beispiel #2
0
 /*@@
   @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);
}
Beispiel #3
0
/* check if this variable can be output (static conditions) */
static int CheckOutputVar (int vindex)
{
  int retval;
  int grouptype;
  char *fullname;


  /* check the variable type */
  grouptype = CCTK_GroupTypeFromVarI (vindex);
  retval = grouptype != CCTK_GF && grouptype != CCTK_ARRAY;
  if (retval)
  {
    fullname = CCTK_FullName (vindex);
    CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
                "CheckOutputVar: No IOASCII 1D output for '%s' (not a grid "
                "function or an array)", fullname);
    free (fullname);
  }

  return (retval);
}
Beispiel #4
0
/* check if steerable parameters have changed */
static void CheckSteerableParameters (asciiioGH *myGH)
{
  int i, num_vars, out_old, times_set;
  int verboselength;
  char *fullname, *msg;
  static int out1D_vars_lastset = -1;
  DECLARE_CCTK_PARAMETERS


  out_old = myGH->out1D_every;

  /* How often to output */
  myGH->out1D_every = out_every > 0 ? out_every : -1;
  if (out1D_every > 0)
  {
    myGH->out1D_every = out1D_every;
  }

  /* Report if frequency changed */
  if (myGH->out1D_every != out_old)
  {
    if (CCTK_Equals (newverbose, "standard") ||
        CCTK_Equals (newverbose, "full"))
    {
      CCTK_VInfo (CCTK_THORNSTRING, "IOASCII_1D: Output every %d iterations",
                  myGH->out1D_every);
    }
  }

  /* re-parse the 'out1D_vars' parameter if it was changed */
  times_set = CCTK_ParameterQueryTimesSet ("out1D_vars", CCTK_THORNSTRING);
  if (times_set != out1D_vars_lastset)
  {
    num_vars = CCTK_NumVars ();
    memset (myGH->do_out1D, 0, num_vars);
    CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH->do_out1D,
                         CCTK_GROUP_OR_VAR);

    if (CCTK_Equals (newverbose, "standard") ||
        CCTK_Equals (newverbose, "full"))
    {

      /* Count the length of the string */
      verboselength = 0;
      for (i = 0; i < num_vars; i++)
      {
        if (myGH->do_out1D[i])
        {
          fullname = CCTK_FullName (i);
          verboselength += strlen(fullname)+1;
          free (fullname);
        }
      }
      verboselength += strlen("IOASCII_1D: Output requested for ");
      msg = (char *)malloc((verboselength+1)*sizeof(char));

      sprintf(msg,"IOASCII_1D: Output requested for ");
      for (i = 0; i < num_vars; i++)
      {
        if (myGH->do_out1D[i])
        {
          fullname = CCTK_FullName (i);
          sprintf (msg, "%s %s",msg,fullname);
          free (fullname);
        }
      }
      if (msg)
      {
        CCTK_INFO (msg);
        free (msg);
      }
    }

    /* Save the last setting of 'out1D_vars' parameter */
    out1D_vars_lastset = times_set;
  }

  USE_CCTK_PARAMETERS; }
Beispiel #5
0
/* check if steerable parameters have changed */
static void CheckSteerableParameters (iobasicGH *myGH)
{
  int i, num_vars, out_old;
  int times_set;
  char *fullname, *msg, *oldmsg;
  static int outScalar_vars_lastset = -1;
  DECLARE_CCTK_PARAMETERS


  /* How often to output */
  out_old = myGH->outScalar_every;
  myGH->outScalar_every = out_every > 0 ? out_every : -1;
  if (outScalar_every > 0)
  {
    myGH->outScalar_every = outScalar_every;
  }

  if (myGH->outScalar_every != out_old)
  {
    if (CCTK_Equals (newverbose, "standard") ||
        CCTK_Equals (newverbose, "full"))
    {
      CCTK_VInfo (CCTK_THORNSTRING, "Scalar: Output every %d iterations",
                  myGH->outScalar_every);
    }
  }

  /* re-parse the 'outScalar_vars' parameter if it was changed */
  times_set = CCTK_ParameterQueryTimesSet ("outScalar_vars", CCTK_THORNSTRING);
  if (times_set != outScalar_vars_lastset)
  {
    num_vars = CCTK_NumVars ();
    memset (myGH->do_outScalar, 0, num_vars);
    CCTK_TraverseString (outScalar_vars, SetOutputFlag, myGH->do_outScalar,
                         CCTK_GROUP_OR_VAR);

    if (myGH->outScalar_every &&
        (CCTK_Equals (newverbose, "standard") ||
         CCTK_Equals (newverbose, "full")))
    {
      msg = NULL;
      for (i = 0; i < num_vars; i++)
      {
        if (myGH->do_outScalar[i])
        {
          fullname = CCTK_FullName (i);
          if (! msg)
          {
            Util_asprintf (&msg, "Scalar: Output requested for %s", fullname);
          }
          else
          {
            oldmsg = msg;
            Util_asprintf (&msg, "%s %s", oldmsg, fullname);
            free (oldmsg);
          }
          free (fullname);
        }
      }
      if (msg)
      {
        CCTK_INFO (msg);
        free (msg);
      }
    }

    /* Save the last setting of 'outScalar_vars' parameter */
    outScalar_vars_lastset = times_set;
  }

  USE_CCTK_PARAMETERS; }