Esempio n. 1
0
 /*@@
   @routine    PUGH_InitializeMemory
   @author     Thomas Radke
   @date       Thu 30 Aug 2001
   @desc
               Initializes allocated memory to all zeros (all variable types)
               or NaNs (floating point types only)
   @enddesc

   @var        initialize_memory
   @vdesc      keyword describing how to initialize memory
   @vtype      const char *
   @vio        in
   @endvar
   @var        vtype
   @vdesc      CCTK variable type of the variable to initialize
   @vtype      int
   @vio        in
   @endvar
   @var        bytes
   @vdesc      total number of bytes to initialize
   @vtype      int
   @vio        in
   @endvar
   @var        data
   @vdesc      pointer to data to initialize
   @vtype      void *
   @vio        in
   @endvar
@@*/
static void PUGH_InitializeMemory (const char *initialize_memory,
                                   int vtype,
                                   int bytes,
                                   void *data)
{
  const char *vtypename;


  /* zero out variable */
  if (CCTK_Equals (initialize_memory, "zero"))
  {
    memset (data, 0, bytes);
  }
  /* set elements to Not-a-Number values (floating point variables only) */
  else if (CCTK_Equals (initialize_memory, "NaN"))
  {
    vtypename = CCTK_VarTypeName (vtype);
    if (strncmp (vtypename, "CCTK_VARIABLE_REAL",    18) == 0 ||
        strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 22) == 0)
    {
      memset (data, -1, bytes);
    }
  }
  else if (! CCTK_Equals (initialize_memory, "none"))
  {
    CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
                "InitializeMemory: Unknown keyword '%s' for "
                "parameter 'initialize_memory'", initialize_memory);
  }
}
Esempio n. 2
0
 /*@@
   @routine    CCTKi_CommandLineParameterLevel
   @date       Wed Feb 21 2001
   @author     Gabrielle Allen
   @desc
               Sets the parameter checking level from a command line argument.
   @enddesc
   @calls      CCTKi_SetParameterLevel

   @var        argument
   @vdesc      option argument
   @vtype      const char *
   @vio        in
   @endvar
@@*/
void CCTKi_CommandLineParameterLevel (const char *argument)
{
  int parameterlevel;


  if (CCTK_Equals (argument, "strict"))
  {
    parameterlevel = CCTK_PARAMETER_STRICT;
  }
  else if (CCTK_Equals (argument, "normal"))
  {
    parameterlevel = CCTK_PARAMETER_NORMAL;
  }
  else if (CCTK_Equals (argument, "relaxed"))
  {
    parameterlevel = CCTK_PARAMETER_RELAXED;
  }
  else
  {
    CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
                "CCTKi_CommandLineParameterLevel: Parameter checking level "
                "'%s' not recognized, defaulting to normal", argument);
    parameterlevel = CCTK_PARAMETER_NORMAL;
  }

  CCTKi_SetParameterLevel (parameterlevel);
}
Esempio n. 3
0
 /*@@
   @routine    CCTKi_ShutdownCactus
   @date       Mon Sep 28 14:50:50 1998
   @author     Tom Goodale
   @desc
               Cactus specific shutdown stuff.
   @enddesc
   @calls      CCTK_SchedulePrintTimes

   @var        ConfigData
   @vdesc      Flesh configuration data
   @vtype      tFleshConfig *
   @vio        unused
   @endvar

   @returntype int
   @returndesc
               0  - success
   @endreturndesc
@@*/
int CCTKi_ShutdownCactus(tFleshConfig *ConfigData)
{
  DECLARE_CCTK_PARAMETERS


  /* avoid compiler warning about unused argument */
  ConfigData = ConfigData;

  if (CCTK_Equals (cctk_timer_output, "full"))
  {
    CCTK_SchedulePrintTimes (NULL);
  }

  USE_CCTK_PARAMETERS;   return 0;
}
Esempio n. 4
0
 /*@@
   @routine    PUGH_EnableScalarGroupStorage
   @author     Thomas Radke
   @date       Thu 30 Aug 2001
   @desc
               Enables storage for a group of CCTK_SCALAR variables
               For efficiency reasons, PUGH allocates storage for scalars
               only once when the group is created.
               The current state of storage allocation (which is toggled by
               Enable/DisableGroupStorage) is stored in a byte-sized flag
               immediately after the scalar data.
   @enddesc

   @var        pughGH
   @vdesc      Pointer to PUGH GH extensions
   @vtype      pGH *
   @vio        in
   @endvar
   @var        first_var
   @vdesc      index of the first variable to enable storage for
   @vtype      int
   @vio        in
   @endvar
   @var        n_variables
   @vdesc      total number of variables to enable storage for
   @vtype      int
   @vio        in
   @endvar
   @var        n_timelevels
   @vdesc      total number of timelevels to enable storage for
   @vtype      int
   @vio        in
   @endvar

   @returntype int
   @returndesc
                1 if storage was already enabled before
                0 if storage was successfully enabled
   @endreturndesc
@@*/
static int PUGH_EnableScalarGroupStorage (pGH *pughGH,
                                          int first_var,
                                          int n_variables,
                                          int n_timelevels)
{
  DECLARE_CCTK_PARAMETERS
  int vtype, vtypesize, variable, level, retval;
  void *temp;


  vtype = CCTK_VarTypeI (first_var);
  vtypesize = CCTK_VarTypeSize (vtype);
  temp = pughGH->variables[first_var][0];
  retval = ((char *) temp)[vtypesize] == PUGH_STORAGE;

  /* don't assign storage if was already switched on */
  if (! retval)
  {
    for (variable = 0; variable < n_variables; variable++)
    {
      for (level = 0; level < n_timelevels; level++)
      {
        temp = pughGH->variables[variable+first_var][level];

        /* raise the query_storage flag */
        ((char *) temp)[vtypesize] = PUGH_STORAGE;

        /* initialize memory if desired */
        if (! CCTK_Equals (initialize_memory, "none"))
        {
          PUGH_InitializeMemory (initialize_memory, vtype, vtypesize, temp);
        }
      }
    }
  }

  USE_CCTK_PARAMETERS;   return (retval);
}
Esempio n. 5
0
 /*@@
   @routine    CCTK_ParameterFilename
   @date       Tue Oct 3 2000
   @author     Gabrielle Allen
   @desc 
   Returns the parameter filename
   @enddesc 
   @calls    CCTK_Equals 
   @calledby   
   @history 
 
   @endhistory 
   @var     len
   @vdesc   The length of the incoming string
   @vtype   int
   @vio     in
   @vcomment 
 
   @endvar 
   @var     filename
   @vdesc   String to contain the filename
   @vtype   char *
   @vio     out
   @vcomment 
 
   @endvar 

   @returntype int
   @returndesc
   The length of the returned string.
   @endreturndesc

@@*/
int CCTK_ParameterFilename(int len, char *filename)
{
  int retval;
  const char *copy_string;


  if (CCTK_Equals(parameter_file_name,"-"))
  {
    copy_string = "STDIN";
  }
  else
  {
    copy_string = parameter_file_name;
  }
  retval = strlen (copy_string);
  if (retval > len - 1)
  {
    retval = len - 1;
  }
  strncpy (filename, copy_string, retval);
  filename[retval] = 0;
  return retval;
}
Esempio n. 6
0
void CCTKi_BindingsSchedule_Einstein(void)
{
  DECLARE_CCTK_PARAMETERS
  CCTKi_ScheduleGroupStorage( "einstein::metric");
  CCTKi_ScheduleGroupStorage( "einstein::curv");
  CCTKi_ScheduleGroupStorage( "einstein::lapse");
  CCTKi_ScheduleGroupStorage( "einstein::flags");
  CCTKi_ScheduleGroupStorage( "einstein::slicing_flags");
  CCTKi_ScheduleGroupComm( "einstein::metric");
  CCTKi_ScheduleGroupComm( "einstein::curv");
  CCTKi_ScheduleGroupComm( "einstein::lapse");
  CCTKi_ScheduleGroupComm( "einstein::flags");
  CCTKi_ScheduleGroupComm( "einstein::slicing_flags");

if (!CCTK_Equals(shift,"none")) 

{

  CCTKi_ScheduleGroupStorage( "einstein::shift");
  CCTKi_ScheduleGroupComm( "einstein::shift");

}

if (use_conformal) {

  CCTKi_ScheduleGroupStorage( "einstein::confac");
  CCTKi_ScheduleGroupComm( "einstein::confac");

}

if (use_conformal_derivs) {

  CCTKi_ScheduleGroupStorage( "einstein::confac_1derivs");
  CCTKi_ScheduleGroupStorage( "einstein::confac_2derivs");
  CCTKi_ScheduleGroupComm( "einstein::confac_1derivs");
  CCTKi_ScheduleGroupComm( "einstein::confac_2derivs");

}

if (use_mask) {

  CCTKi_ScheduleGroupStorage( "einstein::mask");
  CCTKi_ScheduleGroupComm( "einstein::mask");

  CCTKi_ScheduleFunction((void *)MaskOne,
                        "MaskOne",
                        "Einstein",
                        "einstein",
                        "Set mask to one",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


}

  CCTKi_ScheduleFunction((void *)Einstein_InitSymBound,
                        "Einstein_InitSymBound",
                        "Einstein",
                        "einstein",
                        "Set up GF symmetries",
                        "CCTK_BASEGRID",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


if (einstein_register_slicing)

{

  CCTKi_ScheduleFunction((void *)Einstein_ActivateSlicing,
                        "Einstein_ActivateSlicing",
                        "Einstein",
                        "einstein",
                        "Initialize slicing, setup priorities for mixed slicings",
                        "CCTK_BASEGRID",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


}

  CCTKi_ScheduleFunction((void *)InitialEinstein,
                        "InitialEinstein",
                        "Einstein",
                        "einstein",
                        "Initialisation for Einstein methods",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


if (CCTK_Equals(initial_data,"flat")) 

{

  CCTKi_ScheduleFunction((void *)InitialFlat,
                        "InitialFlat",
                        "Einstein",
                        "einstein",
                        "Flat initial data",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        1,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "InitialEinstein");


}

if (CCTK_Equals(initial_lapse,"one") || CCTK_Equals(slicing,"geodesic"))

{

  CCTKi_ScheduleFunction((void *)LapseOne,
                        "LapseOne",
                        "Einstein",
                        "einstein",
                        "Set initial lapse to one",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


}

if (CCTK_Equals(initial_lapse,"gaussian"))

{

  CCTKi_ScheduleFunction((void *)LapseGaussian,
                        "LapseGaussian",
                        "Einstein",
                        "einstein",
                        "Set initial lapse to a gaussian",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


}

if (CCTK_Equals(initial_lapse,"psiminustwo"))

{

  CCTKi_ScheduleFunction((void *)LapsePsiMinusTwo,
                        "LapsePsiMinusTwo",
                        "Einstein",
                        "einstein",
                        "Set initial lapse to psi to the minus two",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        3,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "BiBBAM_InitialWrapper",
                        "IDAxiBrillBH",
                        "Schwarzschild");


}

if (CCTK_Equals(initial_lapse,"isotropic"))

{

  CCTKi_ScheduleFunction((void *)LapseIsotropic,
                        "LapseIsotropic",
                        "Einstein",
                        "einstein",
                        "Set initial lapse to isotropic lapse",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        3,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "BiBBAM_InitialWrapper",
                        "IDAxiBrillBH",
                        "Schwarzschild");


}

if (!CCTK_Equals(shift,"none"))

{

   if (CCTK_Equals(initial_shift,"zero"))

   {

  CCTKi_ScheduleFunction((void *)ShiftZero,
                        "ShiftZero",
                        "Einstein",
                        "einstein",
                        "Set initial shift to zero",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


   }

   if (CCTK_Equals(initial_shift,"rotation"))

   {

  CCTKi_ScheduleFunction((void *)ShiftRotation,
                        "ShiftRotation",
                        "Einstein",
                        "einstein",
                        "Set initial shift to rigid rotation",
                        "CCTK_INITIAL",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        3,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "BiBBAM_InitialWrapper",
                        "IDAxiBrillBH",
                        "Schwarzschild");


   }

}

if (einstein_register_slicing)

{

  CCTKi_ScheduleFunction((void *)Einstein_SetNextSlicing,
                        "Einstein_SetNextSlicing",
                        "Einstein",
                        "einstein",
                        "Identify the slicing for the next iteration",
                        "CCTK_PRESTEP",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */);


}

  CCTKi_ScheduleFunction((void *)evaltrK,
                        "evaltrK",
                        "Einstein",
                        "einstein",
                        "Compute the trace of the extrinsic curvature",
                        "CCTK_ANALYSIS",
                        "C",
                        2,                       /* Number of STORAGE  groups   */
                        2,                      /* Number of COMM     groups   */
                        2,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "Einstein::trace_of_K",
                        "Einstein::detofg",
                        "Einstein::trace_of_K",
                        "Einstein::detofg",
                        "Einstein::trace_of_K",
                        "Einstein::detofg");


  CCTKi_ScheduleFunction((void *)metric_carttosphere,
                        "metric_carttosphere",
                        "Einstein",
                        "einstein",
                        "Calculate the spherical metric in r,theta(q), phi(p)",
                        "CCTK_ANALYSIS",
                        "C",
                        1,                       /* Number of STORAGE  groups   */
                        1,                      /* Number of COMM     groups   */
                        1,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "Einstein::spherical_metric",
                        "Einstein::spherical_metric",
                        "Einstein::spherical_metric");


  CCTKi_ScheduleFunction((void *)curv_carttosphere,
                        "curv_carttosphere",
                        "Einstein",
                        "einstein",
                        "Calculate the spherical ex. curvature in r, theta(q), phi(p)",
                        "CCTK_ANALYSIS",
                        "C",
                        1,                       /* Number of STORAGE  groups   */
                        1,                      /* Number of COMM     groups   */
                        1,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        0,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "Einstein::spherical_curv",
                        "Einstein::spherical_curv",
                        "Einstein::spherical_curv");


if (CCTK_Equals(timestep_method,"courant") || CCTK_Equals(timestep_method,"courant_time")) 

{

  CCTKi_ScheduleFunction((void *)CalcCourant,
                        "CalcCourant",
                        "Einstein",
                        "einstein",
                        "Calculate the wavespeed for the Courant condition",
                        "CCTK_PRESTEP",
                        "C",
                        0,                       /* Number of STORAGE  groups   */
                        0,                      /* Number of COMM     groups   */
                        0,                   /* Number of TRIGGERS groups   */
                        0,                      /* Number of SYNC     groups   */
                        0,                          /* Number of Options           */
                        1,                      /* Number of BEFORE  routines  */
                        0,                       /* Number of AFTER   routines  */
                        0                        /* Number of WHILE   variables */,
                        "Time_Simple");


}


USE_CCTK_PARAMETERS; return;
}
Esempio n. 7
0
int CCTKi_BindingsParameterRecovery_Einstein(void)
{
  DECLARE_CCTK_PARAMETERS
  int result = 0;


if (!CCTK_Equals(shift,"none")) 

{


}

if (use_conformal) {


}

if (use_conformal_derivs) {


}

if (use_mask) {



}


if (einstein_register_slicing)

{


}


if (CCTK_Equals(initial_data,"flat")) 

{


}

if (CCTK_Equals(initial_lapse,"one") || CCTK_Equals(slicing,"geodesic"))

{


}

if (CCTK_Equals(initial_lapse,"gaussian"))

{


}

if (CCTK_Equals(initial_lapse,"psiminustwo"))

{


}

if (CCTK_Equals(initial_lapse,"isotropic"))

{


}

if (!CCTK_Equals(shift,"none"))

{

   if (CCTK_Equals(initial_shift,"zero"))

   {


   }

   if (CCTK_Equals(initial_shift,"rotation"))

   {


   }

}

if (einstein_register_slicing)

{


}




if (CCTK_Equals(timestep_method,"courant") || CCTK_Equals(timestep_method,"courant_time")) 

{


}


  USE_CCTK_PARAMETERS;   return (result);
}
Esempio n. 8
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; }
Esempio n. 9
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; }
Esempio n. 10
0
 /*@@
   @routine    PUGH_EnableGArrayDataStorage
   @author     Tom Goodale
   @date       30 Mar 1999
   @desc
               Allocates storage for a single variable.
               For now this routine cannot be made static because it's used
               in BAM :-(
   @enddesc
   @calls      Util_CacheMalloc

   @var        GA
   @vdesc      Pointer to the variable's info structure
   @vtype      pGA *
   @vio        in
   @endvar
   @var        this_proc
   @vdesc      the processor ID
   @vtype      int
   @vio        unused
   @endvar
   @var        initialize_memory
   @vdesc      how to initialize allocated memory
   @vtype      const char *
   @vio        in
   @endvar
   @var        padding_active, padding_cacheline_bits, padding_size,
               padding_address_spacing
   @vdesc      padding information
   @vtype      int
   @vio        unused
   @endvar

   @returntype int
   @returndesc
                0 if storage was enabled
               -1 if memory allocation failed
   @endreturndesc
@@*/
/* static */ int PUGH_EnableGArrayDataStorage (pGA *GA,
                                         int this_proc,
                                         const char *initialize_memory,
                                         int padding_active,
                                         int padding_cacheline_bits,
                                         int padding_size,
                                         int padding_address_spacing)
{
  int retval;


  /* avoid compiler warnings about unused parameters */
  this_proc = this_proc;
  padding_active = padding_active;
  padding_cacheline_bits = padding_cacheline_bits;
  padding_size = padding_size;
  padding_address_spacing = padding_address_spacing;

  retval = 0;
  if (GA->storage == PUGH_NOSTORAGE)
  {

#ifdef DEBUG_PUGH
    printf (" PUGH_EnableGArrayDataStorage: allocating storage "
            "for var '%s'\n", GA->name);
    fflush (stdout);
#endif

    if(GA->vector_size > 1 && GA->vector_entry > 0)
    {
      GA->data = (char *)(GA->vector_base->data) + GA->extras->npoints * GA->varsize * GA->vector_entry;
      retval = 0;
    }
    else
    {

      /* Now assign memory for the variable itself */
      if (GA->padddata)
      {
        free (GA->padddata);
        GA->padddata = NULL;
      }

      if (GA->extras->npoints * GA->varsize <= 0)
      {
        CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
                    "PUGH_EnableGArrayDataStorage: Tried to allocate storage "
                    "for zero-sized variable '%s'", GA->name);
        GA->data = GA->padddata = NULL;
      }
      else if (! padding_active)
      {
        /* Easy case. */
        GA->data = malloc (GA->extras->npoints * GA->varsize);
        GA->padddata = GA->data;
      }
      else
      {
        /* Use the Cactus Cache alignment function */
        GA->data = Util_CacheMalloc (GA->arrayid,
                                     GA->extras->npoints * GA->varsize * GA->vector_size,
                                     &GA->padddata);
      }

      /* Initialize the memory if desired. */
      if (GA->data && ! CCTK_Equals (initialize_memory, "none"))
      {
        PUGH_InitializeMemory (initialize_memory, GA->vtype,
                               GA->extras->npoints * GA->varsize, GA->data);
      }
    }

    if (GA->extras->npoints * GA->varsize > 0 && GA->padddata == NULL)
    {
      CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
                  "PUGH_EnableGArrayDataStorage: Cannot allocate data for "
                  "'%s' [%d]", GA->name, GA->id);
      retval = -1;
    }
  }

  GA->storage = PUGH_STORAGE;

  return (retval);
}
Esempio n. 11
0
 /*@@
   @routine    PUGH_DisableGroupStorage
   @author     Tom Goodale
   @date       30 Mar 1999
   @desc
               Disables storage for all variables in the group
               indicated by groupname.
   @enddesc
   @calls      CCTK_GroupIndex
               CCTK_GroupData
               CCTK_FirstVarIndexI
               PUGH_DisableGArrayGroupStorage

   @var        GH
   @vdesc      Pointer to CCTK grid hierarchy
   @vtype      cGH *
   @vio        in
   @endvar
   @var        groupname
   @vdesc      name of the group to enable storage for
   @vtype      const char *
   @vio        in
   @endvar

   @returntype int
   @returndesc
                1 if storage for given group was disabled
               -1 if group type is invalid
   @endreturndesc
@@*/
int PUGH_DisableGroupStorage (cGH *GH, const char *groupname)
 {
  DECLARE_CCTK_PARAMETERS
  int group;               /* group index */
  cGroup pgroup;           /* group information */
  int vtypesize, retval;
  pGA ***variables;
  int first_var, var, level;
  int unchanged;           /* count how many aren't toggled */
  char *temp;


#ifdef DEBUG_PUGH
  printf (" PUGH_DisableGroupStorage: request for group '%s'\n", groupname);
  fflush (stdout);
#endif

  group = CCTK_GroupIndex (groupname);
  CCTK_GroupData (group, &pgroup);

  /* get global index of first variable in group */
  first_var = CCTK_FirstVarIndexI (group);

  variables = (pGA ***) PUGH_pGH (GH)->variables;

  /* get the group info from its index */
  unchanged = 0;

  retval = 1;
  if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
  {
    for (var = first_var; var < first_var+pgroup.numvars; var++)
    {
      for (level = 0; level < pgroup.numtimelevels; level++)
      {
        unchanged += PUGH_DisableGArrayDataStorage (variables[var][level]);
      }
    }
  }
  else if (pgroup.grouptype == CCTK_SCALAR)
  {
    vtypesize = CCTK_VarTypeSize (pgroup.vartype);
    for (var = first_var; var < first_var+pgroup.numvars; var++)
    {
      for (level = 0; level < pgroup.numtimelevels; level++)
      {
        temp = (char *) variables[var][level];
        if (temp[vtypesize] == PUGH_STORAGE)
        {
          temp[vtypesize] = PUGH_NOSTORAGE;
        }
        else
        {
          unchanged++;
        }
      }
    }
  }
  else
  {
    CCTK_WARN (1, "Unknown group type in PUGH_DisableGroupStorage");
    retval = -1;
  }

  /* Report on memory usage */
  if (!CCTK_Equals(storage_verbose,"no") && retval >= 0)
  {
    if (unchanged == 0)
    {

      /* Memory toggled */
      if (pgroup.grouptype == CCTK_GF)
      {
        totalnumberGF  -= pgroup.numvars;
      }
      else if (pgroup.grouptype == CCTK_ARRAY)
      {
        totalnumberGA  -= pgroup.numvars;
      }
      totalstorage -= (variables[first_var][0]->extras->npoints *
                       variables[first_var][0]->varsize *
                       pgroup.numtimelevels * pgroup.numvars) /
                      (float) (1024 * 1024);
      if (CCTK_Equals(storage_verbose,"yes"))
      {
        CCTK_VInfo (CCTK_THORNSTRING, "Switched memory off for group '%s'"
                    "  [GFs: %d GAs: %d Total Size: %6.2fMB]",
                    groupname, totalnumberGF, totalnumberGA, totalstorage);
      }
    }
    else if (unchanged == pgroup.numvars)
    {
      /* Memory already off */
      if (CCTK_Equals(storage_verbose,"yes"))
      {
        CCTK_VInfo (CCTK_THORNSTRING, "Memory already off for group '%s'", groupname);
      }
    }
    else
    {
      CCTK_WARN (1, "PUGH_DisableGroupStorage: Inconsistency in group memory assignment");
    }
  }

  USE_CCTK_PARAMETERS;   return (retval);
}
Esempio n. 12
0
 /*@@
   @routine    PUGH_EnableGroupStorage
   @author     Tom Goodale
   @date       30 Mar 1999
   @desc
               Enables storage for all variables in the group
               indicated by groupname.
   @enddesc
   @calls      CCTK_GroupIndex
               CCTK_GroupData
               PUGH_EnableScalarGroupStorage
               PUGH_EnableGArrayGroupStorage

   @var        GH
   @vdesc      Pointer to CCTK grid hierarchy
   @vtype      cGH *
   @vio        in
   @endvar
   @var        groupname
   @vdesc      name of the group to enable storage for
   @vtype      const char *
   @vio        in
   @endvar

   @returntype int
   @returndesc
                return code of @seeroutine PUGH_EnableScalarGroupStorage or
                @seeroutine PUGH_EnableGArrayGroupStorage: <BR>
                1 if storage was already enabled, or <BR>
                0 if storage was successfully enabled <BR>
               -1 if group type is not one of the above <BR>
               -2 if an invalid GH pointer was given <BR>
               -3 if invalid groupname was given
   @endreturndesc
@@*/
int PUGH_EnableGroupStorage (cGH *GH, const char *groupname)
{
  DECLARE_CCTK_PARAMETERS
  int group;               /* group index */
  int first_var;           /* first variable's index */
  cGroup pgroup;           /* group information */
  int retval;
  pGA *GA;
  pGH *pughGH;


#ifdef DEBUG_PUGH
  printf (" PUGH_EnableGroupStorage: request for group '%s'\n", groupname);
  fflush (stdout);
#endif

  pughGH = PUGH_pGH (GH);
  group = CCTK_GroupIndex (groupname);

  if (pughGH && group >= 0)
  {
    first_var = CCTK_FirstVarIndexI (group);

    /* get the group info from its index */
    CCTK_GroupData (group, &pgroup);

    if (pgroup.grouptype == CCTK_SCALAR)
    {
      retval = PUGH_EnableScalarGroupStorage (pughGH,
                                              first_var,
                                              pgroup.numvars,
                                              pgroup.numtimelevels);
    }
    else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
    {
      retval = PUGH_EnableGArrayGroupStorage (pughGH,
                                              first_var,
                                              pgroup.numvars,
                                              pgroup.numtimelevels);
      if (!CCTK_Equals(storage_verbose,"no") && retval == 0)
      {
        /* get GA pointer of first var in group */
        GA = (pGA *) pughGH->variables[first_var][0];
        if (pgroup.grouptype == CCTK_GF)
        {
          totalnumberGF  += pgroup.numvars * pgroup.numtimelevels;
        }
        else
        {
          totalnumberGA  += pgroup.numvars * pgroup.numtimelevels;
        }
        totalstorage += (GA->extras->npoints * GA->varsize *
                         pgroup.numtimelevels * pgroup.numvars) /
                        (float) (1024*1024);
        if (totalstorage > maxstorage)
        {
          numberGF = totalnumberGF;
          numberGA = totalnumberGA;
          maxstorage = totalstorage;
        }

        /* Report on memory usage */
        if (CCTK_Equals(storage_verbose,"yes"))
        {
          CCTK_VInfo (CCTK_THORNSTRING, "Switched memory on for group '%s'"
                      "  [GFs: %d GAs: %d Total Size: %6.2fMB]",
                      groupname, totalnumberGF, totalnumberGA, totalstorage);
        }
      }

    }
    else
    {
      CCTK_WARN (1, "PUGH_EnableGroupStorage: Unknown group type");
      retval = -1;
    }

  }
  else
  {
    if (! pughGH)
    {
      CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
                  "PUGH_EnableGroupStorage: Error with cctkGH pointer "
                  "for group %s", groupname);
      retval = -2;
    }
    else
    {
      CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
                  "PUGH_EnableGroupStorage: Invalid group %s", groupname);
      retval = -3;
    }
  }

  USE_CCTK_PARAMETERS;   return (retval);
}