aboutsummaryrefslogtreecommitdiff
path: root/src/Storage.c
diff options
context:
space:
mode:
authortradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2002-05-10 08:59:34 +0000
committertradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2002-05-10 08:59:34 +0000
commit185eb785089738d93053d2f443aea4b38c85fd31 (patch)
treec1e9358b6cf0792ceeeec408f5f97159154e5803 /src/Storage.c
parent92e0869725c459c47be7d12f3d0c8f8de5956cd4 (diff)
Bugfix for switching off storage for scalar variables.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@382 b61c5cb5-eaca-4651-9a7a-d64986f99364
Diffstat (limited to 'src/Storage.c')
-rw-r--r--src/Storage.c142
1 files changed, 66 insertions, 76 deletions
diff --git a/src/Storage.c b/src/Storage.c
index 02cc285..f612786 100644
--- a/src/Storage.c
+++ b/src/Storage.c
@@ -1052,57 +1052,53 @@ void PUGHi_PrintStorageReport ()
@routine PUGH_GroupStorageIncrease
@date Tue Apr 16 16:01:22 2002
@author Tom Goodale
- @desc
+ @desc
The increase group storage routine should increase the allocated memory
to the specified number of timelevels of each listed group, returning the
- previous number of timelevels enable for that group in the status array,
+ previous number of timelevels enable for that group in the status array,
if that is not NULL. It should never decrease the number of timelevels enabled,
i.e. if it is asked to enable less timelevels than are already enable it should
not change the storage for that group.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @enddesc
+ @calls PUGHi_EnableScalarGroupStorage
+ PUGHi_EnableGArrayGroupStorage
+
@var GH
@vdesc Pointer to CCTK grid hierarchy
@vtype cGH *
@vio inout
- @vcomment
+ @vcomment
A driver should replace the appropriate GV pointers on this
structure when they change the storage state of a GV.
- @endvar
+ @endvar
@var n_groups
@vdesc Number of groups in group array
@vtype int
@vio in
- @vcomment
-
- @endvar
+ @endvar
@var groups
@vdesc Groups to allocate storage for
@vtype const int *
@vio in
- @vcomment
+ @vcomment
This should be a list of group indices. -1 is treated as a flag to ignore this entry.
- @endvar
+ @endvar
@var timelevels
@vdesc Number of timelevels to allocate storage for for each group.
@vtype const int *
@vio in
- @vcomment
+ @vcomment
This array should have n_groups elements.
- @endvar
+ @endvar
@var status
@vdesc Optional return array to contain previous state of storage for each group.
@vtype const int *
@vio in
- @vcomment
+ @vcomment
If this array is not NULL, it will, on return, contain the number of timelevels which
were previously allocated storage for each group.
- @endvar
+ @endvar
@returntype int
@returndesc
@@ -1183,57 +1179,53 @@ int PUGH_GroupStorageIncrease(cGH *GH, int n_groups,const int *groups,const int
@routine PUGH_GroupStorageDecrease
@date Tue Apr 16 16:01:22 2002
@author Tom Goodale
- @desc
+ @desc
The decrease group storage routine should decrease the memory allocated
to the specified number of timelevels for each listed group, returning the
- previous number of timelevels enable for that group in the status array,
+ previous number of timelevels enable for that group in the status array,
if that is not NULL. It should never increase the number of timelevels enabled,
i.e. if it is asked to reduce to more timelevels than are enable it should
not change the storage for that group.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @enddesc
+ @calls PUGHi_DisableScalarGroupStorage
+ PUGHi_DisableGArrayGroupStorage
+
@var GH
@vdesc Pointer to CCTK grid hierarchy
@vtype cGH *
@vio inout
- @vcomment
+ @vcomment
A driver should replace the appropriate GV pointers on this
structure when they change the storage state of a GV.
- @endvar
+ @endvar
@var n_groups
@vdesc Number of groups in group array
@vtype int
@vio in
- @vcomment
-
- @endvar
+ @endvar
@var groups
@vdesc Groups to reduce storage for
@vtype const int *
@vio in
- @vcomment
+ @vcomment
This should be a list of group indices. -1 is treated as a flag to ignore this entry.
- @endvar
+ @endvar
@var timelevels
@vdesc Number of timelevels to reduce storage for for each group.
@vtype const int *
@vio in
- @vcomment
+ @vcomment
This array should have n_groups elements.
- @endvar
+ @endvar
@var status
@vdesc Optional return array to contain previous state of storage for each group.
@vtype const int *
@vio in
- @vcomment
+ @vcomment
If this array is not NULL, it will, on return, contain the number of timelevels which
were previously allocated storage for each group.
- @endvar
+ @endvar
@returntype int
@returndesc
@@ -1393,14 +1385,14 @@ static int PUGHi_EnableGArrayGroupStorage (pGH *pughGH,
}
((cGH *) pughGH->callerid)->data[var][level] = GA->data;
-
+
nnostorage++;
}
else
{
((cGH *) pughGH->callerid)->data[var][level] = GA->data;
nstorage++;
-
+
/* Count the number of timelevels which were previously allocated. */
if(var == first_var)
{
@@ -1486,15 +1478,15 @@ static int PUGHi_DisableGArrayGroupStorage (pGH *pughGH,
}
if(level >= n_timelevels)
- {
+ {
#ifdef DEBUG_PUGH
printf (" PUGHi_DisableGArrayGroupStorage: request for var '%s' "
"timelevel %d\n", GA->name, level);
fflush (stdout);
#endif
PUGH_DisableGArrayDataStorage (GA);
- }
-
+ }
+
((cGH *) pughGH->callerid)->data[var][level] = GA->data;
nstorage++;
}
@@ -1573,12 +1565,12 @@ static int PUGHi_EnableScalarGroupStorage (pGH *pughGH,
temp = pughGH->variables[variable+first_var][level];
if(((char *) temp)[vtypesize] != PUGH_STORAGE)
- {
+ {
if(level < n_timelevels)
{
/* raise the query_storage flag */
((char *) temp)[vtypesize] = PUGH_STORAGE;
-
+
/* initialize memory if desired */
if (! CCTK_Equals (initialize_memory, "none"))
{
@@ -1649,23 +1641,22 @@ static int PUGHi_DisableScalarGroupStorage (pGH *pughGH,
int max_timelevels,
int n_timelevels)
{
- DECLARE_CCTK_PARAMETERS
- int vtype, vtypesize, variable, level, retval;
+ int vtypesize, variable, level, retval;
void *temp;
+ DECLARE_CCTK_PARAMETERS
retval = 0;
- vtype = CCTK_VarTypeI (first_var);
- vtypesize = CCTK_VarTypeSize (vtype);
+ vtypesize = CCTK_VarTypeSize (CCTK_VarTypeI (first_var));
for (variable = 0; variable < n_variables; variable++)
{
for (level = 0; level < max_timelevels; level++)
- {
+ {
temp = pughGH->variables[variable+first_var][level];
- if(((char *) temp)[vtypesize] == PUGH_NOSTORAGE)
- {
+ if(((char *) temp)[vtypesize] != PUGH_NOSTORAGE)
+ {
if(variable == 0)
{
retval++;
@@ -1687,11 +1678,12 @@ static int PUGHi_DisableScalarGroupStorage (pGH *pughGH,
@routine PUGH_NumTimeLevels
@date Tue Apr 16 19:03:30 2002
@author Tom Goodale
- @desc
+ @desc
Work out the number of enabled timelevels for a variable.
- @enddesc
- @calls
- @calledby
+ @enddesc
+ @calls PUGHi_NumTimeLevelsScalar
+ PUGHi_NumTimeLevelsArray
+
@var pughGH
@vdesc a PUGH GH
@vtype const pGH *
@@ -1700,26 +1692,26 @@ static int PUGHi_DisableScalarGroupStorage (pGH *pughGH,
@vdesc The variable index to get the info for
@vtype int
@vio in
-
+
@returntype int
@returndesc
The number of timelevels enabled for this variable
- @endreturndesc
+ @endreturndesc
@@*/
int PUGH_NumTimeLevels(const pGH *pughGH, int var)
{
int retval;
int timelevels;
-
+
timelevels = CCTK_NumTimeLevelsFromVarI(var);
switch(CCTK_GroupTypeFromVarI(var))
{
- case CCTK_SCALAR:
+ case CCTK_SCALAR:
retval = PUGHi_NumTimeLevelsScalar(pughGH, var, timelevels);
break;
- case CCTK_GF:
+ case CCTK_GF:
/* Fall through. */
case CCTK_ARRAY:
retval = PUGHi_NumTimeLevelsArray(pughGH, var, timelevels);
@@ -1730,16 +1722,15 @@ int PUGH_NumTimeLevels(const pGH *pughGH, int var)
return retval;
}
-
+
/*@@
@routine PUGH_NumTimeLevelsScalar
@date Tue Apr 16 19:03:30 2002
@author Tom Goodale
- @desc
+ @desc
Work out the number of enabled timelevels for a scalar variable.
- @enddesc
- @calls
- @calledby
+ @enddesc
+
@var pughGH
@vdesc a PUGH GH
@vtype const pGH *
@@ -1756,7 +1747,7 @@ int PUGH_NumTimeLevels(const pGH *pughGH, int var)
@returntype int
@returndesc
The number of timelevels enabled for this variable
- @endreturndesc
+ @endreturndesc
@@*/
static int PUGHi_NumTimeLevelsScalar(const pGH *pughGH, int var, int timelevels)
{
@@ -1771,13 +1762,13 @@ static int PUGHi_NumTimeLevelsScalar(const pGH *pughGH, int var, int timelevels)
vtype = CCTK_VarTypeI (var);
vtypesize = CCTK_VarTypeSize (vtype);
-
+
for (level = 0; level < timelevels; level++)
{
temp = pughGH->variables[var][level];
-
+
if(((char *) temp)[vtypesize] == PUGH_STORAGE)
- {
+ {
retval++;
}
else
@@ -1793,11 +1784,10 @@ static int PUGHi_NumTimeLevelsScalar(const pGH *pughGH, int var, int timelevels)
@routine PUGH_NumTimeLevelsArray
@date Tue Apr 16 19:03:30 2002
@author Tom Goodale
- @desc
+ @desc
Work out the number of enabled timelevels for an array variable.
- @enddesc
- @calls
- @calledby
+ @enddesc
+
@var pughGH
@vdesc a PUGH GH
@vtype const pGH *
@@ -1814,7 +1804,7 @@ static int PUGHi_NumTimeLevelsScalar(const pGH *pughGH, int var, int timelevels)
@returntype int
@returndesc
The number of timelevels enabled for this variable
- @endreturndesc
+ @endreturndesc
@@*/
static int PUGHi_NumTimeLevelsArray(const pGH *pughGH, int var, int timelevels)
{
@@ -1827,7 +1817,7 @@ static int PUGHi_NumTimeLevelsArray(const pGH *pughGH, int var, int timelevels)
for (level = 0; level < timelevels; level++)
{
GA = (pGA *) pughGH->variables[var][level];
-
+
if (GA->storage)
{
retval++;