aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@b61c5cb5-eaca-4651-9a7a-d64986f99364>2003-11-21 15:27:24 +0000
committerschnetter <schnetter@b61c5cb5-eaca-4651-9a7a-d64986f99364>2003-11-21 15:27:24 +0000
commitf6a8262ccb22d44d19707bf25b39ebbe30f6c66a (patch)
tree6c0df81c905a58122e1f250fb0cc71938107c901
parentd61946959b3663d95b31677378c0681a0eec303a (diff)
Allow vector groups of scalars.
Allow vector groups with more than one declared variable. Much of this patch consists of removing special case code for scalars. Scalars are now almost everywhere treated as rank 0 arrays. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@423 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r--src/Comm.c60
-rw-r--r--src/GHExtension.c18
-rw-r--r--src/Overloadables.c39
-rw-r--r--src/PughUtils.c9
-rw-r--r--src/SetupGroup.c162
-rw-r--r--src/SetupPGH.c55
-rw-r--r--src/SetupPGV.c204
-rw-r--r--src/Storage.c579
-rw-r--r--src/include/pGV.h9
-rw-r--r--src/include/pugh.h6
10 files changed, 259 insertions, 882 deletions
diff --git a/src/Comm.c b/src/Comm.c
index b37331c..f83268c 100644
--- a/src/Comm.c
+++ b/src/Comm.c
@@ -40,7 +40,6 @@ static int PUGH_SyncSingleProc(pGH *pughGH, pComm *comm);
@date 30 Mar 1999
@desc
Synchronizes all variables in the group indicated by groupname.
- Only groups of type GROUP_ARRAY and GROUP_GF can be synchronized.
@enddesc
@calls PUGH_SyncGArrayGroup
@@ -57,7 +56,6 @@ static int PUGH_SyncSingleProc(pGH *pughGH, pComm *comm);
@returntype int
@returndesc
- 0 for grid scalar groups<BR>
return code of @seeroutine PUGH_SyncGArrayGroup
for grid array groups<BR>
-1 for an unknown group or group type
@@ -86,21 +84,7 @@ int PUGH_SyncGroup(const cGH *GH, const char *groupname)
{
CCTK_GroupData(group, &pgroup);
- if (pgroup.grouptype == CCTK_SCALAR)
- {
- retval = 0;
- CCTK_VWarn(4, __LINE__, __FILE__, CCTK_THORNSTRING,
- "PUGH_SyncGroup: Synchronising scalar group: %s",groupname);
- }
- else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
- {
- retval = PUGH_SyncGArrayGroup(PUGH_pGH(GH), CCTK_FirstVarIndexI(group));
- }
- else
- {
- CCTK_WARN(1, "PUGH_SyncGroup: Unknown group type");
- retval = -1;
- }
+ retval = PUGH_SyncGArrayGroup(PUGH_pGH(GH), CCTK_FirstVarIndexI(group));
}
return (retval);
@@ -130,7 +114,6 @@ int PUGH_SyncGroup(const cGH *GH, const char *groupname)
@returntype int
@returndesc
- 1 for grid scalar groups<BR>
return code of @seeroutine PUGH_EnableGArrayGroupComm
for grid array groups<BR>
-1 for an unknown group type
@@ -151,21 +134,9 @@ int PUGH_EnableGroupComm(const cGH *GH, const char *groupname)
group = CCTK_GroupIndex(groupname);
CCTK_GroupData(group, &pgroup);
- if (pgroup.grouptype == CCTK_SCALAR)
- {
- retval = 1;
- }
- else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
- {
- retval = PUGH_EnableGArrayGroupComm(PUGH_pGH(GH),
- CCTK_FirstVarIndexI(group),
- PUGH_ALLCOMM);
- }
- else
- {
- CCTK_WARN(1, "Unknown group type in PUGH_EnableGroupComm");
- retval = -1;
- }
+ retval = PUGH_EnableGArrayGroupComm(PUGH_pGH(GH),
+ CCTK_FirstVarIndexI(group),
+ PUGH_ALLCOMM);
return (retval);
}
@@ -194,7 +165,6 @@ int PUGH_EnableGroupComm(const cGH *GH, const char *groupname)
@returntype int
@returndesc
- 1 for grid scalar groups<BR>
return code of @seeroutine PUGH_DisableGArrayGroupComm
for grid array groups<BR>
-1 for an unknown group type
@@ -217,24 +187,12 @@ int PUGH_DisableGroupComm(const cGH *GH, const char *groupname)
group = CCTK_GroupIndex(groupname);
CCTK_GroupData(group, &pgroup);
- if (pgroup.grouptype == CCTK_SCALAR)
- {
- retval = 1;
- }
- else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
- {
- first_var = CCTK_FirstVarIndexI(group);
- pughGH = PUGH_pGH(GH);
- GA = (pGA *) pughGH->variables[first_var][0];
+ first_var = CCTK_FirstVarIndexI(group);
+ pughGH = PUGH_pGH(GH);
+ GA = (pGA *) pughGH->variables[first_var][0];
- /* FIXME: workaround. This one is really bad ! */
- retval = PUGH_DisableGArrayGroupComm(pughGH, first_var, GA->groupcomm);
- }
- else
- {
- CCTK_WARN(1, "Unknown group type in PUGH_DisableGroupComm");
- retval = -1;
- }
+ /* FIXME: workaround. This one is really bad ! */
+ retval = PUGH_DisableGArrayGroupComm(pughGH, first_var, GA->groupcomm);
return (retval);
}
diff --git a/src/GHExtension.c b/src/GHExtension.c
index 3d48578..0f69046 100644
--- a/src/GHExtension.c
+++ b/src/GHExtension.c
@@ -140,7 +140,7 @@ void *PUGH_SetupGH (tFleshConfig *config,
groupghostsize[i] = *size[i];
}
}
- else if (pgroup.grouptype == CCTK_ARRAY)
+ else if (pgroup.grouptype == CCTK_ARRAY || pgroup.grouptype == CCTK_SCALAR)
{
memset (groupghostsize, 0, pgroup.dim * sizeof (int));
}
@@ -151,7 +151,8 @@ void *PUGH_SetupGH (tFleshConfig *config,
PUGH_SetupGroup (newGH, groupsize, groupghostsize, pgroup.grouptype,
pgroup.vartype, pgroup.dim, pgroup.numvars,
- pgroup.stagtype, pgroup.numtimelevels,pgroup.vectorgroup);
+ pgroup.vectorlength, pgroup.stagtype,
+ pgroup.numtimelevels, pgroup.vectorgroup);
}
/* clean up */
@@ -249,18 +250,7 @@ static void PUGH_InitGHVariables (cGH *GH)
for (level = 0; level < ntimelevels; level++)
{
- switch (gtype)
- {
- case CCTK_SCALAR:
- GH->data[var][level] = mypGH->variables[var][level];
- break;
- case CCTK_GF:
- case CCTK_ARRAY:
- GH->data[var][level] = ((pGA *) mypGH->variables[var][level])->data;
- break;
- default:
- CCTK_WARN (0, "PUGH_InitGHVariables: Unknown group type");
- }
+ GH->data[var][level] = ((pGA *) mypGH->variables[var][level])->data;
}
}
}
diff --git a/src/Overloadables.c b/src/Overloadables.c
index ebb2551..ac70e9a 100644
--- a/src/Overloadables.c
+++ b/src/Overloadables.c
@@ -22,7 +22,6 @@ CCTK_FILEVERSION(CactusPUGH_PUGH_Overloadables_c)
@date 2000/06/22
@desc
Returns the driver's internal data for a given group
- of CCTK_GF or CCTK_ARRAY variables
@enddesc
@calls CCTK_GroupTypeI
CCTK_FirstVarIndexI
@@ -47,7 +46,6 @@ CCTK_FILEVERSION(CactusPUGH_PUGH_Overloadables_c)
@returndesc
0 for success <BR>
-1 if given pointer to data structure is NULL <BR>
- -2 if given group is not of type CCTK_GF or CCTK_ARRAY <BR>
-3 if given GH pointer is invalid
@endreturndesc
@@*/
@@ -62,34 +60,27 @@ int PUGH_GroupDynamicData (const cGH *GH, int group, cGroupDynamicData *data)
if (data)
{
gtype = CCTK_GroupTypeI (group);
- if (gtype == CCTK_GF || gtype == CCTK_ARRAY)
- {
- /* Get the first variable in the group */
- var = CCTK_FirstVarIndexI (group);
+ /* Get the first variable in the group */
+ var = CCTK_FirstVarIndexI (group);
- pughGH = PUGH_pGH (GH);
- if (pughGH)
- {
- extras = ((pGA ***) pughGH->variables)[var][0]->extras;
+ pughGH = PUGH_pGH (GH);
+ if (pughGH)
+ {
+ extras = ((pGA ***) pughGH->variables)[var][0]->extras;
- data->dim = extras->dim;
- data->lsh = extras->lnsize;
- data->gsh = extras->nsize;
- data->lbnd = extras->lb[pughGH->myproc];
- data->ubnd = extras->ub[pughGH->myproc];
- data->nghostzones = extras->nghostzones;
- data->bbox = extras->bbox;
+ data->dim = extras->dim;
+ data->lsh = extras->lnsize;
+ data->gsh = extras->nsize;
+ data->lbnd = extras->lb[pughGH->myproc];
+ data->ubnd = extras->ub[pughGH->myproc];
+ data->nghostzones = extras->nghostzones;
+ data->bbox = extras->bbox;
- retval = 0;
- }
- else
- {
- retval = -3;
- }
+ retval = 0;
}
else
{
- retval = -2;
+ retval = -3;
}
}
else
diff --git a/src/PughUtils.c b/src/PughUtils.c
index 975f197..c820f56 100644
--- a/src/PughUtils.c
+++ b/src/PughUtils.c
@@ -97,7 +97,10 @@ void PUGH_Report (const cGH *GH)
if (CCTK_GroupTypeI(gi) == CCTK_GF)
{
dim = CCTK_GroupDimI(gi);
- havedims[dim-1]=1;
+ if (dim > 0)
+ {
+ havedims[dim-1]=1;
+ }
}
}
@@ -349,7 +352,7 @@ void PUGH_PrintStorage (const cGH *GH)
{
countarray += strlen(CCTK_GroupName(i))+1;
}
- else if (CCTK_GroupTypeI(i) == CCTK_SCALAR)
+ else
{
countscalar += strlen(CCTK_GroupName(i))+1;
}
@@ -385,7 +388,7 @@ void PUGH_PrintStorage (const cGH *GH)
{
sprintf(messarray,"%s%s ",messarray,CCTK_GroupName(i));
}
- else if (CCTK_GroupTypeI(i) == CCTK_SCALAR)
+ else
{
sprintf(messscalar,"%s%s ",messscalar,CCTK_GroupName(i));
}
diff --git a/src/SetupGroup.c b/src/SetupGroup.c
index 346da2a..1e91bc4 100644
--- a/src/SetupGroup.c
+++ b/src/SetupGroup.c
@@ -8,6 +8,7 @@
@version $Id$
@@*/
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -23,12 +24,6 @@ CCTK_FILEVERSION (CactusPUGH_PUGH_SetupGroup_c)
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int PUGH_SetupScalarGroup (pGH *newGH,
- int vtype,
- int n_variables,
- int n_timelevels,
- int vectorgroup);
-
static int PUGH_SetupGAGroup (pGH *newGH,
int *nsize,
int *ghostsize,
@@ -36,124 +31,10 @@ static int PUGH_SetupGAGroup (pGH *newGH,
int vtype,
int dim,
int n_variables,
+ int vectorlength,
int staggercode,
int n_timelevels,
- int vectorgroup);
-
-
- /*@@
- @routine PUGH_SetupScalarGroup
- @date Wed Feb 17 04:45:49 1999
- @author Tom Goodale
- @desc
- Set up a group of scalar variables on a pGH.
- 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 newGH
- @vdesc Pointer to PUGH grid hierarchy
- @vtype pGH *
- @vio in
- @endvar
- @var vtype
- @vdesc CCTK data type for variables in this group
- @vtype int
- @vio in
- @endvar
- @var n_variables
- @vdesc number of variables in this group
- @vtype int
- @vio in
- @endvar
- @var n_timelevels
- @vdesc number of timelevels in this group
- @vtype int
- @vio in
- @endvar
- @var vectorgroup
- @vdesc is this a vector group ?
- @vtype int
- @vio in
- @endvar
-
- @returntype int
- @returndesc
- PUGH_SUCCESS (0) if successful, or
- PUGH_ERRORMEMORY (negative) if memory allocation failed
- @endreturndesc
-@@*/
-static int PUGH_SetupScalarGroup (pGH *newGH,
- int vtype,
- int n_variables,
- int n_timelevels,
- int vectorgroup)
-{
- DECLARE_CCTK_PARAMETERS
- int variable, level, vtypesize, retval;
- void *temp;
-
-
- (void) (vectorgroup + 0);
-
- retval = 0; /* PUGH_SUCCESS */
-
- temp = realloc (newGH->variables,
- (newGH->nvariables + n_variables) * sizeof (void **));
- if (temp)
- {
- newGH->variables = (void ***) temp;
- vtypesize = CCTK_VarTypeSize (vtype);
-
- for (variable = 0; variable < n_variables && retval == 0; variable++)
- {
- temp = malloc (n_timelevels * sizeof (void *));
- if (temp)
- {
- newGH->variables[newGH->nvariables + variable] = (void **) temp;
- for (level = 0; level < n_timelevels; level++)
- {
- /* allocate one more byte for the query_storage flag */
- temp = malloc (vtypesize + 1);
- if (temp)
- {
- newGH->variables[newGH->nvariables + variable][level] = temp;
-
- /* reset the query_storage flag */
- ((char *) temp)[vtypesize] = PUGH_NOSTORAGE;
- }
- else
- {
- retval = PUGH_ERRORMEMORY;
- break;
- }
- }
- }
- else
- {
- retval = PUGH_ERRORMEMORY;
- }
- }
- }
- else
- {
- retval = PUGH_ERRORMEMORY;
- }
-
- if (! retval)
- {
- newGH->nvariables += n_variables;
- }
- else
- {
- CCTK_WARN (1, "Memory allocation error in PUGH_SetupScalarGroup");
- }
-
- return (retval);
-}
+ int vectorgroup);
/*@@
@@ -161,8 +42,7 @@ static int PUGH_SetupScalarGroup (pGH *newGH,
@date January 19 2000
@author Gabrielle Allen
@desc
- Set up a group of grid array variables (CCTK_GF or CCTK_ARRAY
- types) on a pGH.
+ Set up a group of grid array variables on a pGH.
@enddesc
@calls CCTK_VarTypeSize
PUGH_SetupConnectivity
@@ -234,6 +114,7 @@ static int PUGH_SetupGAGroup (pGH *newGH,
int vtype,
int dim,
int n_variables,
+ int vectorlength,
int staggercode,
int n_timelevels,
int vectorgroup)
@@ -254,7 +135,7 @@ static int PUGH_SetupGAGroup (pGH *newGH,
retval = PUGH_SUCCESS;
var_size = CCTK_VarTypeSize (vtype);
- if (gtype == CCTK_ARRAY)
+ if (gtype == CCTK_ARRAY || gtype == CCTK_SCALAR)
{
/* Arrays can't (yet) have periodicity and manual setup,
so initialize them to zero */
@@ -293,6 +174,7 @@ static int PUGH_SetupGAGroup (pGH *newGH,
else
{
/* this is for CCTK_GF variables */
+ assert (dim > 0);
connectivity = newGH->Connectivity[dim-1];
extras = newGH->GFExtras[dim-1];
}
@@ -341,9 +223,9 @@ static int PUGH_SetupGAGroup (pGH *newGH,
var_size,
vtype,
staggercode,
- vectorgroup ? n_variables : 1,
- variable,
- variable > 0 ? newGH->variables[newGH->nvariables-variable][level] : NULL);
+ vectorlength,
+ variable%vectorlength,
+ variable%vectorlength > 0 ? newGH->variables[newGH->nvariables-variable%vectorlength][level] : NULL);
newGH->narrays++;
}
newGH->nvariables++;
@@ -376,8 +258,7 @@ static int PUGH_SetupGAGroup (pGH *newGH,
@desc
Sets up a group on a pGH
@enddesc
- @calls PUGH_SetupScalarGroup
- PUGH_SetupGAGroup
+ @calls PUGH_SetupGAGroup
@var newGH
@vdesc Pointer to PUGH grid hierarchy
@@ -432,8 +313,7 @@ static int PUGH_SetupGAGroup (pGH *newGH,
@returntype int
@returndesc
- return code of @seeroutine PUGH_SetupScalarGroup or
- @seeroutine PUGH_SetupGAGroup, or
+ return code of @seeroutine PUGH_SetupGAGroup, or
PUGH_ERROR if invalid group type was passed in
@endreturndesc
@@*/
@@ -444,26 +324,16 @@ int PUGH_SetupGroup (pGH *newGH,
int vtype,
int dim,
int n_variables,
+ int vectorlength,
int staggercode,
int n_timelevels,
int vectorgroup)
{
int retval;
- if (gtype == CCTK_SCALAR)
- {
- retval = PUGH_SetupScalarGroup (newGH, vtype, n_variables, n_timelevels, vectorgroup);
- }
- else if (gtype == CCTK_ARRAY || gtype == CCTK_GF)
- {
- retval = PUGH_SetupGAGroup (newGH, nsize, nghostsize, gtype, vtype, dim,
- n_variables, staggercode, n_timelevels,vectorgroup);
- }
- else
- {
- CCTK_WARN (0, "Unknown group type in PUGH_SetupGroup");
- retval = PUGH_ERROR;
- }
+ retval = PUGH_SetupGAGroup (newGH, nsize, nghostsize, gtype, vtype, dim,
+ n_variables, vectorlength, staggercode,
+ n_timelevels, vectorgroup);
return (retval);
}
diff --git a/src/SetupPGH.c b/src/SetupPGH.c
index 459c4f2..174cd6c 100644
--- a/src/SetupPGH.c
+++ b/src/SetupPGH.c
@@ -235,51 +235,36 @@ void PUGH_DestroyPGH (pGH **GHin)
CCTK_GroupData(group,&pgroup);
- if (pgroup.grouptype == CCTK_ARRAY || pgroup.grouptype == CCTK_GF)
- {
- GA = (pGA *) GH->variables[variable][0];
+ GA = (pGA *) GH->variables[variable][0];
- /* Destroy group comm buffers */
- if (GA->groupcomm)
+ /* Destroy group comm buffers */
+ if (GA->groupcomm)
+ {
+ if (GA->groupcomm->commflag != PUGH_NOCOMM)
{
- if (GA->groupcomm->commflag != PUGH_NOCOMM)
- {
- PUGH_DisableGArrayGroupComm (GH, variable, GA->groupcomm);
- }
- PUGH_DestroyComm (&GA->groupcomm);
+ PUGH_DisableGArrayGroupComm (GH, variable, GA->groupcomm);
}
+ PUGH_DestroyComm (&GA->groupcomm);
+ }
- /* Destroy the group's connectivity and extras structure
- for CCTK_ARRAY groups.
- Remember that the connectivity and extras for CCTK_GF types
- are shared between all such groups and are destroyed later. */
- if (GA->connectivity != GH->Connectivity[pgroup.dim-1])
- {
- PUGH_DestroyConnectivity (&GA->connectivity);
- }
- if (GA->extras != GH->GFExtras[pgroup.dim-1])
- {
- PUGH_DestroyPGExtras (&GA->extras);
- }
+ /* Destroy the group's connectivity and extras structure
+ for CCTK_ARRAY groups.
+ Remember that the connectivity and extras for CCTK_GF types
+ are shared between all such groups and are destroyed later. */
+ if (GA->connectivity != GH->Connectivity[pgroup.dim-1])
+ {
+ PUGH_DestroyConnectivity (&GA->connectivity);
+ }
+ if (GA->extras != GH->GFExtras[pgroup.dim-1])
+ {
+ PUGH_DestroyPGExtras (&GA->extras);
}
for (this_var = 0; this_var < pgroup.numvars; this_var++, variable++)
{
for(i = 0 ; i < pgroup.numtimelevels; i++)
{
- switch(pgroup.grouptype)
- {
- case CCTK_GF:
- case CCTK_ARRAY:
- PUGH_DestroyGArray(&(((pGA ***)GH->variables)[variable][i]));
- break;
- case CCTK_SCALAR:
- if (GH->variables[variable][i])
- {
- free(GH->variables[variable][i]);
- }
- break;
- }
+ PUGH_DestroyGArray(&(((pGA ***)GH->variables)[variable][i]));
}
free(GH->variables[variable]);
}
diff --git a/src/SetupPGV.c b/src/SetupPGV.c
index 5536c26..a1554a8 100644
--- a/src/SetupPGV.c
+++ b/src/SetupPGV.c
@@ -126,8 +126,11 @@ void PUGH_DestroyPGExtras(pGExtras **PGExtras)
{
for(j = 0; j < 2; j++)
{
- free((*PGExtras)->ghosts[i][j][0]);
- free((*PGExtras)->overlap[i][j][0]);
+ if((*PGExtras)->dim > 0)
+ {
+ free((*PGExtras)->ghosts[i][j][0]);
+ free((*PGExtras)->overlap[i][j][0]);
+ }
free((*PGExtras)->ownership[i][j]);
free((*PGExtras)->ghosts[i][j]);
free((*PGExtras)->overlap[i][j]);
@@ -416,7 +419,7 @@ int PUGH_GenerateNeighbours(int dim,
pos = (int *)malloc(dim*sizeof(int));
- if(pos)
+ if(dim == 0 || pos)
{
for(i = 0; i < total_procs; i++)
{
@@ -559,11 +562,11 @@ int PUGH_ComposeIJK(int dim,
* e.g. i+nx*(j+ny*k)
*/
- ijk = pos[dim-1];
- for(idim = dim-2; idim >=0; idim--)
+ ijk = 0;
+ for(idim = dim-1; idim >=0; idim--)
{
ijk = pos[idim] + nprocs[idim]*ijk;
- };
+ }
return ijk;
}
@@ -618,59 +621,62 @@ int PUGH_SetupPGExtrasMemory(int dim,
this->ub &&
this->rnsize &&
this->rnpoints &&
- this->nghostzones &&
- this->nsize &&
- this->lnsize &&
- this->bbox &&
- this->iterator &&
- this->hyper_volume)
+ (dim == 0 || this->nghostzones ) &&
+ (dim == 0 || this->nsize ) &&
+ (dim == 0 || this->lnsize ) &&
+ (dim == 0 || this->bbox ) &&
+ (dim == 0 || this->iterator ) &&
+ (dim == 0 || this->hyper_volume))
{
this->lb[0] = (int *)malloc(total_procs *dim*sizeof(int));
this->ub[0] = (int *)malloc(total_procs *dim*sizeof(int));
this->rnsize[0] = (int *)malloc(total_procs*2*dim*sizeof(int));
- if(this->lb[0] &&
- this->ub[0] &&
- this->rnsize[0])
+ if (dim > 0)
{
- for (i = 1; i < total_procs; i++)
+ if(this->lb[0] &&
+ this->ub[0] &&
+ this->rnsize[0])
{
- this->lb[i] = this->lb[0] + i*dim;
- this->ub[i] = this->ub[0] + i*dim;
- this->rnsize[i] = this->rnsize[0] + i*2*dim;
+ for (i = 1; i < total_procs; i++)
+ {
+ this->lb[i] = this->lb[0] + i*dim;
+ this->ub[i] = this->ub[0] + i*dim;
+ this->rnsize[i] = this->rnsize[0] + i*2*dim;
+ }
+ }
+ else
+ {
+ /* Free inner arrays */
+ free(this->lb[0]);
+ this->lb[0] = NULL;
+ free(this->ub[0]);
+ this->ub[0] = NULL;
+ free(this->rnsize[0]);
+ this->rnsize[0] = NULL;
+
+ /* Free toplevel arrays */
+ free(this->lb);
+ this->lb = NULL;
+ free(this->ub);
+ this->ub = NULL;
+ free(this->rnsize);
+ this->rnsize = NULL;
+ free(this->rnpoints);
+ this->rnpoints = NULL;
+ free(this->nghostzones);
+ this->nghostzones = NULL;
+ free(this->nsize);
+ this->nsize = NULL;
+ free(this->lnsize);
+ this->lnsize = NULL;
+ free(this->bbox);
+ this->bbox = NULL;
+ free(this->iterator);
+ this->iterator = NULL;
+ free(this->hyper_volume);
+ this->hyper_volume = NULL;
}
- }
- else
- {
- /* Free inner arrays */
- free(this->lb[0]);
- this->lb[0] = NULL;
- free(this->ub[0]);
- this->ub[0] = NULL;
- free(this->rnsize[0]);
- this->rnsize[0] = NULL;
-
- /* Free toplevel arrays */
- free(this->lb);
- this->lb = NULL;
- free(this->ub);
- this->ub = NULL;
- free(this->rnsize);
- this->rnsize = NULL;
- free(this->rnpoints);
- this->rnpoints = NULL;
- free(this->nghostzones);
- this->nghostzones = NULL;
- free(this->nsize);
- this->nsize = NULL;
- free(this->lnsize);
- this->lnsize = NULL;
- free(this->bbox);
- this->bbox = NULL;
- free(this->iterator);
- this->iterator = NULL;
- free(this->hyper_volume);
- this->hyper_volume = NULL;
}
}
else
@@ -697,18 +703,17 @@ int PUGH_SetupPGExtrasMemory(int dim,
free(this->hyper_volume);
this->hyper_volume = NULL;
}
-
-
+
if(this->lb &&
this->ub &&
this->rnsize &&
this->rnpoints &&
- this->nghostzones &&
- this->nsize &&
- this->lnsize &&
- this->bbox &&
- this->iterator &&
- this->hyper_volume)
+ (dim == 0 || this->nghostzones ) &&
+ (dim == 0 || this->nsize ) &&
+ (dim == 0 || this->lnsize ) &&
+ (dim == 0 || this->bbox ) &&
+ (dim == 0 || this->iterator ) &&
+ (dim == 0 || this->hyper_volume))
{
retcode = 0;
for (i = 0 ; i < PUGH_NSTAGGER; i++)
@@ -718,44 +723,46 @@ int PUGH_SetupPGExtrasMemory(int dim,
this->ownership[i][j] = (int *) malloc(dim*sizeof(int));
this->ghosts[i][j] = (int **)malloc(2*dim*sizeof(int *));
this->overlap[i][j] = (int **)malloc(2*dim*sizeof(int *));
- if(this->ghosts[i][j] &&
- this->overlap[i][j])
+ if(dim > 0)
{
- this->ghosts[i][j][0] = (int *)malloc(2*dim*dim*sizeof(int));
- this->overlap[i][j][0] = (int *)malloc(2*dim*dim*sizeof(int));
- for (k=1; k < 2*dim; k++)
+ if(this->ghosts[i][j] &&
+ this->overlap[i][j])
{
- this->ghosts[i][j][k] = this->ghosts[i][j][0] + k*dim;
- this->overlap[i][j][k] = this->overlap[i][j][0] + k*dim;
+ this->ghosts[i][j][0] = (int *)malloc(2*dim*dim*sizeof(int));
+ this->overlap[i][j][0] = (int *)malloc(2*dim*dim*sizeof(int));
+ for (k=1; k < 2*dim; k++)
+ {
+ this->ghosts[i][j][k] = this->ghosts[i][j][0] + k*dim;
+ this->overlap[i][j][k] = this->overlap[i][j][0] + k*dim;
+ }
+ }
+ else
+ {
+ free(this->ownership[i][j]);
+ this->ownership[i][j] = NULL;
+
+ free(this->ghosts[i][j]);
+ this->ghosts[i][j] = NULL;
+
+ free(this->overlap[i][j]);
+ this->overlap[i][j] = NULL;
+ retcode = 1;
+ break;
}
- }
- else
- {
- free(this->ownership[i][j]);
- this->ownership[i][j] = NULL;
-
- free(this->ghosts[i][j]);
- this->ghosts[i][j] = NULL;
-
- free(this->overlap[i][j]);
- this->overlap[i][j] = NULL;
- retcode = 1;
- break;
}
}
if(retcode)
{
for(j=1; j >=0 ; j--)
{
- free(this->ownership[i][j]);
- this->ownership[i][j] = NULL;
-
- free(this->ghosts[i][j]);
- this->ghosts[i][j] = NULL;
+ free(this->ownership[i][j]);
+ this->ownership[i][j] = NULL;
- free(this->overlap[i][j]);
- this->overlap[i][j] = NULL;
+ free(this->ghosts[i][j]);
+ this->ghosts[i][j] = NULL;
+ free(this->overlap[i][j]);
+ this->overlap[i][j] = NULL;
}
break;
}
@@ -767,8 +774,11 @@ int PUGH_SetupPGExtrasMemory(int dim,
{
for(j=1; j >=0 ; j--)
{
- free(this->ghosts[i][j][0]);
- free(this->overlap[i][j][0]);
+ if(dim > 0)
+ {
+ free(this->ghosts[i][j][0]);
+ free(this->overlap[i][j][0]);
+ }
free(this->ownership[i][j]);
this->ownership[i][j] = NULL;
@@ -813,9 +823,9 @@ int PUGH_SetupPGExtrasMemory(int dim,
free(this->iterator);
this->iterator = NULL;
free(this->hyper_volume);
- this->hyper_volume = NULL;
- }
- }
+ this->hyper_volume = NULL;
+ }
+ }
}
else
{
@@ -1169,7 +1179,7 @@ int PUGH_SetupBoundingBox(int dim,
bounds = (int **)malloc(dim*sizeof(int*));
pos = (int *)malloc(dim*sizeof(int));
- if(bounds && pos)
+ if(dim > 0 && bounds && pos)
{
/* Work out the bounds in each direction - either from parameters
file or default*/
@@ -1252,6 +1262,7 @@ int PUGH_SetupBoundingBox(int dim,
@endhistory
@@*/
+
int PUGH_SetupRemoteSizes(int dim,
int *perme,
int stagger,
@@ -1397,10 +1408,13 @@ pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH,
*/
if(this)
{
- extras->hyper_volume[0] = 1;
- for (i = 1; i < extras->dim; i++)
+ if (extras->dim > 0)
{
- extras->hyper_volume[i] = extras->hyper_volume[i-1] * extras->lnsize[i-1];
+ extras->hyper_volume[0] = 1;
+ for (i = 1; i < extras->dim; i++)
+ {
+ extras->hyper_volume[i] = extras->hyper_volume[i-1] * extras->lnsize[i-1];
+ }
}
}
diff --git a/src/Storage.c b/src/Storage.c
index e702a08..d27e197 100644
--- a/src/Storage.c
+++ b/src/Storage.c
@@ -37,18 +37,10 @@ static int numberGF = 0; /* Number of GFs at max */
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int PUGH_EnableScalarGroupStorage (pGH *pughGH,
- int first_var,
- int n_variables,
- int n_timelevels);
static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
int first_var,
int n_variables,
int n_timelevels);
-static void PUGH_InitializeMemory (const char *initialize_memory,
- int vtype,
- int bytes,
- void *data);
static int PUGHi_EnableGArrayGroupStorage (pGH *pughGH,
@@ -57,25 +49,12 @@ static int PUGHi_EnableGArrayGroupStorage (pGH *pughGH,
int max_timelevels,
int n_timelevels);
-static int PUGHi_EnableScalarGroupStorage (pGH *pughGH,
- int first_var,
- int n_variables,
- int max_timelevels,
- int n_timelevels);
-
static int PUGHi_DisableGArrayGroupStorage (pGH *pughGH,
int first_var,
int n_variables,
int max_timelevels,
int n_timelevels);
-static int PUGHi_DisableScalarGroupStorage (pGH *pughGH,
- int first_var,
- int n_variables,
- int max_timelevels,
- int n_timelevels);
-
-static int PUGHi_NumTimeLevelsScalar(const pGH *pughGH, int var, int timelevels);
static int PUGHi_NumTimeLevelsArray(const pGH *pughGH, int var, int timelevels);
/********************************************************************
@@ -226,7 +205,6 @@ int PUGH_QueryGroupStorage (const cGH *GH, int group, const char *groupname)
int first_var;
int storage;
int grouptype;
- int vtypesize;
int retval;
pGH *pughGH;
@@ -244,20 +222,7 @@ int PUGH_QueryGroupStorage (const cGH *GH, int group, const char *groupname)
{
pughGH = PUGH_pGH (GH);
grouptype = CCTK_GroupTypeI (group);
- if (grouptype == CCTK_SCALAR)
- {
- vtypesize = CCTK_VarTypeSize (CCTK_VarTypeI (first_var));
- storage = ((char *) pughGH->variables[first_var][0])[vtypesize];
- }
- else if (grouptype == CCTK_GF || grouptype == CCTK_ARRAY)
- {
- storage = ((pGA *) pughGH->variables[first_var][0])->storage;
- }
- else
- {
- storage = -1;
- CCTK_WARN (1, "Unknown group type in PUGH_QueryGroupStorage");
- }
+ storage = ((pGA *) pughGH->variables[first_var][0])->storage;
if (storage == PUGH_STORAGE)
{
@@ -302,7 +267,6 @@ int PUGH_QueryGroupStorage (const cGH *GH, int group, const char *groupname)
@enddesc
@calls CCTK_GroupIndex
CCTK_GroupData
- PUGH_EnableScalarGroupStorage
PUGH_EnableGArrayGroupStorage
@var GH
@@ -318,8 +282,7 @@ int PUGH_QueryGroupStorage (const cGH *GH, int group, const char *groupname)
@returntype int
@returndesc
- return code of @seeroutine PUGH_EnableScalarGroupStorage or
- @seeroutine PUGH_EnableGArrayGroupStorage: <BR>
+ return code of @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>
@@ -353,55 +316,39 @@ int PUGH_EnableGroupStorage (const cGH *GH, const char *groupname)
/* get the group info from its index */
CCTK_GroupData (group, &pgroup);
- if (pgroup.grouptype == CCTK_SCALAR)
+ retval = PUGH_EnableGArrayGroupStorage (pughGH,
+ first_var,
+ pgroup.numvars,
+ pgroup.numtimelevels);
+ if (!CCTK_Equals(storage_verbose,"no") && retval == 0)
{
- 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)
{
- /* 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);
- }
+ 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;
}
- }
- else
- {
- CCTK_WARN (1, "PUGH_EnableGroupStorage: Unknown group type");
- retval = -1;
+ /* 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);
+ }
}
}
@@ -461,11 +408,10 @@ int PUGH_DisableGroupStorage (const cGH *GH, const char *groupname)
DECLARE_CCTK_PARAMETERS
int group; /* group index */
cGroup pgroup; /* group information */
- int vtypesize, retval;
+ int retval;
pGA ***variables;
int first_var, var, level;
int unchanged; /* count how many aren't toggled */
- char *temp;
#ifdef DEBUG_PUGH
@@ -485,40 +431,13 @@ int PUGH_DisableGroupStorage (const cGH *GH, const char *groupname)
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)
+ for (var = first_var; var < first_var+pgroup.numvars; var++)
{
- vtypesize = CCTK_VarTypeSize (pgroup.vartype);
- for (var = first_var; var < first_var+pgroup.numvars; var++)
+ for (level = 0; level < pgroup.numtimelevels; level++)
{
- for (level = 0; level < pgroup.numtimelevels; level++)
- {
- temp = (char *) variables[var][level];
- if (temp[vtypesize] == PUGH_STORAGE)
- {
- temp[vtypesize] = PUGH_NOSTORAGE;
- }
- else
- {
- unchanged++;
- }
- }
+ unchanged += PUGH_DisableGArrayDataStorage (variables[var][level]);
}
}
- else
- {
- CCTK_WARN (1, "Unknown group type in PUGH_DisableGroupStorage");
- retval = -1;
- }
/* Report on memory usage */
if (!CCTK_Equals(storage_verbose,"no") && retval >= 0)
@@ -531,7 +450,7 @@ int PUGH_DisableGroupStorage (const cGH *GH, const char *groupname)
{
totalnumberGF -= pgroup.numvars;
}
- else if (pgroup.grouptype == CCTK_ARRAY)
+ else
{
totalnumberGA -= pgroup.numvars;
}
@@ -607,86 +526,6 @@ float PUGH_ReturnMaxStorage(void)
********************************************************************/
/*@@
- @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);
- }
- }
- }
- }
-
- return (retval);
-}
-
-
- /*@@
@routine PUGH_EnableGArrayGroupStorage
@author Tom Goodale
@date 30 Mar 1999
@@ -897,9 +736,14 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
GA->extras->npoints * GA->varsize * GA->vector_size,
&GA->padddata);
}
+#ifdef DEBUG_PUGH
+ printf (" PUGH_EnableGArrayDataStorage: new pointer is %p (%p)\n",
+ GA->padddata, GA->data);
+ fflush (stdout);
+#endif
/* Initialize the memory if desired. */
- if (GA->data && ! CCTK_Equals (initialize_memory, "none"))
+ if (GA->data)
{
PUGH_InitializeMemory (initialize_memory, GA->vtype,
GA->extras->npoints * GA->varsize, GA->data);
@@ -953,7 +797,7 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
{
#ifdef DEBUG_PUGH
- printf ("PUGH_DisableGArrayDataStorage: freeing storage for var '%s'\n",
+ printf (" PUGH_DisableGArrayDataStorage: freeing storage for var '%s'\n",
GA->name);
fflush (stdout);
#endif
@@ -966,6 +810,11 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
{
if (GA->padddata)
{
+#ifdef DEBUG_PUGH
+ printf (" PUGH_DisableGArrayDataStorage: old pointer is %p (%p)\n",
+ GA->padddata, GA->data);
+ fflush (stdout);
+#endif
free (GA->padddata);
}
GA->padddata = NULL;
@@ -988,7 +837,7 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
or NaNs (floating point types only)
@enddesc
- @var initialize_memory
+ @var do_initialize_memory
@vdesc keyword describing how to initialize memory
@vtype const char *
@vio in
@@ -1009,21 +858,22 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
@vio in
@endvar
@@*/
-static void PUGH_InitializeMemory (const char *initialize_memory,
- int vtype,
- int bytes,
- void *data)
+void PUGH_InitializeMemory (const char *do_initialize_memory,
+ int vtype,
+ int bytes,
+ void *data)
{
+ DECLARE_CCTK_PARAMETERS;
const char *vtypename;
/* zero out variable */
- if (CCTK_Equals (initialize_memory, "zero"))
+ if (CCTK_Equals (do_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"))
+ else if (CCTK_Equals (do_initialize_memory, "NaN"))
{
vtypename = CCTK_VarTypeName (vtype);
if (strncmp (vtypename, "CCTK_VARIABLE_REAL", 18) == 0 ||
@@ -1032,11 +882,11 @@ static void PUGH_InitializeMemory (const char *initialize_memory,
memset (data, -1, bytes);
}
}
- else if (! CCTK_Equals (initialize_memory, "none"))
+ else if (! CCTK_Equals (do_initialize_memory, "none"))
{
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
"InitializeMemory: Unknown value '%s' for "
- "argument 'initialize_memory'", initialize_memory);
+ "argument 'do_initialize_memory'", do_initialize_memory);
}
}
@@ -1071,8 +921,7 @@ void PUGHi_PrintStorageReport ()
not change the storage for that group.
@enddesc
- @calls PUGHi_EnableScalarGroupStorage
- PUGHi_EnableGArrayGroupStorage
+ @calls PUGHi_EnableGArrayGroupStorage
@var GH
@vdesc Pointer to CCTK grid hierarchy
@@ -1149,27 +998,11 @@ int PUGH_GroupStorageIncrease(const cGH *GH, int n_groups,const int *groups,cons
tlevels = timelevels[group];
}
- if (pgroup.grouptype == CCTK_SCALAR)
- {
- previous = PUGHi_EnableScalarGroupStorage (pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels,
- tlevels);
- }
- else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
- {
- previous = PUGHi_EnableGArrayGroupStorage (pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels,
- tlevels);
- }
- else
- {
- CCTK_WARN (1, "PUGH_GroupStorageIncrease: Unknown group type");
- previous = 0;
- }
+ previous = PUGHi_EnableGArrayGroupStorage (pughGH,
+ first_var,
+ pgroup.numvars,
+ pgroup.numtimelevels,
+ tlevels);
if(status)
{
@@ -1198,8 +1031,7 @@ int PUGH_GroupStorageIncrease(const cGH *GH, int n_groups,const int *groups,cons
not change the storage for that group.
@enddesc
- @calls PUGHi_DisableScalarGroupStorage
- PUGHi_DisableGArrayGroupStorage
+ @calls PUGHi_DisableGArrayGroupStorage
@var GH
@vdesc Pointer to CCTK grid hierarchy
@@ -1276,27 +1108,11 @@ int PUGH_GroupStorageDecrease(const cGH *GH, int n_groups,const int *groups,cons
tlevels = timelevels[group];
}
- if (pgroup.grouptype == CCTK_SCALAR)
- {
- previous = PUGHi_DisableScalarGroupStorage (pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels,
- tlevels);
- }
- else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
- {
- previous = PUGHi_DisableGArrayGroupStorage (pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels,
- tlevels);
- }
- else
- {
- CCTK_WARN (1, "PUGH_GroupStorageIncrease: Unknown group type");
- previous = 0;
- }
+ previous = PUGHi_DisableGArrayGroupStorage (pughGH,
+ first_var,
+ pgroup.numvars,
+ pgroup.numtimelevels,
+ tlevels);
if(status)
{
@@ -1381,7 +1197,7 @@ static int PUGHi_EnableGArrayGroupStorage (pGH *pughGH,
if(level < n_timelevels)
{
#ifdef DEBUG_PUGH
- printf (" PUGH_EnableGArrayGroupStorage: request for var '%s' "
+ printf (" PUGHi_EnableGArrayGroupStorage: request for var '%s' "
"timelevel %d\n", GA->name, level);
fflush (stdout);
#endif
@@ -1512,193 +1328,13 @@ static int PUGHi_DisableGArrayGroupStorage (pGH *pughGH,
}
/*@@
- @routine PUGHi_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 max_timelevels
- @vdesc total number of timelevels for this group
- @vtype int
- @vio in
- @var n_timelevels
- @vdesc number of timelevels to enable storage for
- @vtype int
- @vio in
- @endvar
-
- @returntype int
- @returndesc
- The number of timelevels enabled previously
- @endreturndesc
-@@*/
-static int PUGHi_EnableScalarGroupStorage (pGH *pughGH,
- int first_var,
- int n_variables,
- int max_timelevels,
- int n_timelevels)
-{
- DECLARE_CCTK_PARAMETERS
- int vtype, vtypesize, variable, level, retval;
- void *temp;
-
- retval = 0;
- vtype = CCTK_VarTypeI (first_var);
- vtypesize = CCTK_VarTypeSize (vtype);
-
- 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_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"))
- {
- PUGH_InitializeMemory (initialize_memory, vtype, vtypesize, temp);
- }
- }
- }
- else
- {
- if(variable == 0)
- {
- retval++;
- }
- }
-
- /* set the variable's data pointer in the cGH structure */
- ((cGH *) pughGH->callerid)->data[variable+first_var][level] = temp;
- }
- }
-
- return retval;
-}
-
-
- /*@@
- @routine PUGHi_DisableScalarGroupStorage
- @author Thomas Radke
- @date Thu 30 Aug 2001
- @desc
- Disables 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 disable storage for
- @vtype int
- @vio in
- @endvar
- @var n_variables
- @vdesc total number of variables to disable storage for
- @vtype int
- @vio in
- @endvar
- @var max_timelevels
- @vdesc total number of timelevels for this group
- @vtype int
- @vio in
- @var n_timelevels
- @vdesc number of timelevels to disable storage for
- @vtype int
- @vio in
- @endvar
-
- @returntype int
- @returndesc
- The number of timelevels disabled previously
- @endreturndesc
-@@*/
-static int PUGHi_DisableScalarGroupStorage (pGH *pughGH,
- int first_var,
- int n_variables,
- int max_timelevels,
- int n_timelevels)
-{
- int vtypesize, variable, level, retval;
- void *temp;
- DECLARE_CCTK_PARAMETERS
-
- retval = 0;
-
- 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(variable == 0)
- {
- retval++;
- }
-
- if(level >= n_timelevels)
- {
- /* set the storage flag to no-storage*/
- ((char *) temp)[vtypesize] = PUGH_NOSTORAGE;
-
- /* set the variable's data pointer in the cGH structure */
- ((cGH *) pughGH->callerid)->data[variable+first_var][level] = NULL;
- }
- }
- }
- }
-
- return retval;
-}
-
- /*@@
@routine PUGH_NumTimeLevels
@date Tue Apr 16 19:03:30 2002
@author Tom Goodale
@desc
Work out the number of enabled timelevels for a variable.
@enddesc
- @calls PUGHi_NumTimeLevelsScalar
- PUGHi_NumTimeLevelsArray
+ @calls PUGHi_NumTimeLevelsArray
@var pughGH
@vdesc a PUGH GH
@@ -1722,76 +1358,7 @@ int PUGH_NumTimeLevels(const pGH *pughGH, int var)
timelevels = CCTK_MaxTimeLevelsVI(var);
- switch(CCTK_GroupTypeFromVarI(var))
- {
- case CCTK_SCALAR:
- retval = PUGHi_NumTimeLevelsScalar(pughGH, var, timelevels);
- break;
- case CCTK_GF:
- /* Fall through. */
- case CCTK_ARRAY:
- retval = PUGHi_NumTimeLevelsArray(pughGH, var, timelevels);
- break;
- default:
- retval = -1;
- }
-
- return retval;
-}
-
- /*@@
- @routine PUGH_NumTimeLevelsScalar
- @date Tue Apr 16 19:03:30 2002
- @author Tom Goodale
- @desc
- Work out the number of enabled timelevels for a scalar variable.
- @enddesc
-
- @var pughGH
- @vdesc a PUGH GH
- @vtype const pGH *
- @vio in
- @var var
- @vdesc The variable index to get the info for
- @vtype int
- @vio in
- @var timelevels
- @vdesc The maximum number of timelevels the variable can have
- @vtype int
- @vio in
-
- @returntype int
- @returndesc
- The number of timelevels enabled for this variable
- @endreturndesc
- @@*/
-static int PUGHi_NumTimeLevelsScalar(const pGH *pughGH, int var, int timelevels)
-{
- int retval;
-
- int vtype;
- int vtypesize;
- int level;
- void *temp;
-
- retval = 0;
-
- 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
- {
- break;
- }
- }
+ retval = PUGHi_NumTimeLevelsArray(pughGH, var, timelevels);
return retval;
}
diff --git a/src/include/pGV.h b/src/include/pGV.h
index fd6edd8..250a653 100644
--- a/src/include/pGV.h
+++ b/src/include/pGV.h
@@ -18,7 +18,7 @@ extern "C"
#define DATINDEX(GH,i,j,k) ((i) + GH->lnsize[0]*((j)+GH->lnsize[1]*(k)))
-typedef enum {pgv_none, pgv_scalar, pgv_array, pgv_gf} pgv_type;
+typedef enum {pgv_none, pgv_array, pgv_gf} pgv_type;
typedef struct PConnectivity
{
@@ -28,12 +28,6 @@ typedef struct PConnectivity
int *perme; /* Is the system periodic? */
} pConnectivity;
-typedef struct PGS
-{
- int vtype;
- void *data;
-} pGS;
-
typedef struct PGExtras
{
int dim; /* dimension of GA */
@@ -129,7 +123,6 @@ typedef struct PGV
{
pgv_type type;
- pGS *scalar;
pGA *array;
} pGV;
diff --git a/src/include/pugh.h b/src/include/pugh.h
index d9ddd4b..a90a693 100644
--- a/src/include/pugh.h
+++ b/src/include/pugh.h
@@ -126,6 +126,7 @@ int PUGH_SetupGroup (pGH *newGH,
int vtype,
int dim,
int n_variables,
+ int vectorlength,
int staggercode,
int n_timelevels,
int vectorgroup);
@@ -151,6 +152,11 @@ int PUGH_GetBounds(int dim,
int *nprocs,
int *nsize);
+void PUGH_InitializeMemory (const char *do_initialize_memory,
+ int vtype,
+ int bytes,
+ void *data);
+
int PUGH_Terminate (cGH *GH);
int PUGH_ParallelInit(cGH *GH);