aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2004-06-08 15:27:53 +0000
committertradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2004-06-08 15:27:53 +0000
commit58f0716f87960c507a9cefbe901c1f584ddd7cb2 (patch)
tree0b07ed8db5375a6cf752cc24b186fb7234dbb707
parente686497920f1e3243334f038050645597663f51b (diff)
Added a sanity check 'nsize >= 3*nghosts' and abort if this is not true.
This puts PR CactusPUGH/1726 "Periodic boundaries without MPI are broken" into a suspended state. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@443 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r--src/SetupPGV.c375
1 files changed, 169 insertions, 206 deletions
diff --git a/src/SetupPGV.c b/src/SetupPGV.c
index 9117e44..7a94029 100644
--- a/src/SetupPGV.c
+++ b/src/SetupPGV.c
@@ -2,9 +2,9 @@
@file SetupPGV.c
@date Wed Oct 27 11:09:05 1999
@author Tom Goodale
- @desc
+ @desc
Sets up a PUGH grid variable.
- @enddesc
+ @enddesc
@version $Header$
@@*/
@@ -33,13 +33,13 @@ CCTK_FILEVERSION(CactusPUGH_PUGH_SetupPGV_c);
********************************************************************/
static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this);
-static int PUGH_SetupPGExtrasOwnership(int dim,
+static int PUGH_SetupPGExtrasOwnership(int dim,
int *perme,
int this_proc,
pGExtras *this);
static int PUGH_SetupPGExtrasStaggering(int dim, int this_proc, pGExtras *this);
static int PUGH_SetupBoundingBox(int is_gf,
- int dim,
+ int dim,
int stagger,
int *nghosts,
int total_procs,
@@ -47,7 +47,7 @@ static int PUGH_SetupBoundingBox(int is_gf,
pGExtras *this);
static int PUGH_SetupRemoteSizes(int dim, int total_procs, pGExtras *this);
static int PUGH_SetupPGExtrasSizes(int is_gf,
- int dim,
+ int dim,
int stagger,
int *sh,
int *nghosts,
@@ -77,12 +77,12 @@ static int IntSort(const void *a, const void *b);
@routine PUGH_SetupPGExtras
@date Tue Nov 9 09:23:27 1999
@author Tom Goodale
- @desc
+ @desc
Sets up a PGExtras structure.
- @enddesc
+ @enddesc
@@*/
pGExtras *PUGH_SetupPGExtras(int is_gf,
- int dim,
+ int dim,
int *perme,
int stagger,
int *sh,
@@ -91,7 +91,6 @@ pGExtras *PUGH_SetupPGExtras(int is_gf,
int *nprocs,
int this_proc)
{
- int error;
pGExtras *this;
this = malloc(sizeof(pGExtras));
@@ -99,18 +98,15 @@ pGExtras *PUGH_SetupPGExtras(int is_gf,
/* Setup memory */
if(this)
{
- error = PUGH_SetupPGExtrasMemory(dim, total_procs, this);
- if(!error)
+ if (! PUGH_SetupPGExtrasMemory(dim, total_procs, this))
{
-
this->dim = dim;
- PUGH_SetupPGExtrasSizes(is_gf, dim, stagger, sh, nghosts,
+ PUGH_SetupPGExtrasSizes(is_gf, dim, stagger, sh, nghosts,
total_procs, nprocs, this_proc,this);
PUGH_SetupPGExtrasOwnership(dim, perme, this_proc, this);
PUGH_SetupPGExtrasStaggering(dim, this_proc, this);
- }
-
+ }
}
return this;
@@ -120,9 +116,9 @@ pGExtras *PUGH_SetupPGExtras(int is_gf,
@routine PUGH_DestroyPGExtras
@date Mar 12 2000
@author Thomas Radke
- @desc
+ @desc
Destroys a PGExtras structure.
- @enddesc
+ @enddesc
@@*/
void PUGH_DestroyPGExtras(pGExtras **PGExtras)
{
@@ -168,14 +164,14 @@ void PUGH_DestroyPGExtras(pGExtras **PGExtras)
@routine PUGH_SetupConnectivity
@date Fri Nov 5 11:32:12 1999
@author Tom Goodale
- @desc
- Create a connectivity structure containing
+ @desc
+ Create a connectivity structure containing
all the details of processor connectivities
for this processor layout.
- @enddesc
+ @enddesc
@@*/
-pConnectivity *PUGH_SetupConnectivity(int dim,
- int total_procs,
+pConnectivity *PUGH_SetupConnectivity(int dim,
+ int total_procs,
int *nprocs,
int *perme)
{
@@ -202,7 +198,6 @@ pConnectivity *PUGH_SetupConnectivity(int dim,
this->neighbours = NULL;
}
-
if((dim && ! this->nprocs) || (dim && ! this->perme) || ! this->neighbours)
{
if(this->neighbours)
@@ -236,9 +231,8 @@ pConnectivity *PUGH_SetupConnectivity(int dim,
}
PUGH_GenerateTopology(dim, total_procs, this->nprocs);
-
- PUGH_GenerateNeighbours(dim, total_procs, this->nprocs, this->neighbours, this->perme);
-
+ PUGH_GenerateNeighbours(dim, total_procs, this->nprocs, this->neighbours,
+ this->perme);
}
return this;
@@ -248,11 +242,11 @@ pConnectivity *PUGH_SetupConnectivity(int dim,
@routine PUGH_DestroyConnectivity
@date Mar 12 2000
@author Thomas Radke
- @desc
- Destroys a connectivity structure containing
+ @desc
+ Destroys a connectivity structure containing
all the details of processor connectivities
for this processor layout.
- @enddesc
+ @enddesc
@@*/
void PUGH_DestroyConnectivity(pConnectivity **conn)
{
@@ -271,17 +265,17 @@ void PUGH_DestroyConnectivity(pConnectivity **conn)
@routine PUGH_GenerateTopology
@date Fri Nov 5 11:31:21 1999
@author Tom Goodale
- @desc
+ @desc
Generate the appropriate processor topology for this processor
decomposition.
- @enddesc
- @history
+ @enddesc
+ @history
@hdate Tue Jan 30 17:04:50 2001 @hauthor Tom Goodale
@hdesc Added call to integer root function and qsort to
avoid problems with real to integer conversions and
demonstrable failure of the algorithm when dealing
- with large prime factors.
- @endhistory
+ with large prime factors.
+ @endhistory
@@*/
int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs)
{
@@ -303,7 +297,7 @@ int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs)
if((nprocs[i])>0)
{
free_dims--;
- if(used_procs)
+ if(used_procs)
{
used_procs *= nprocs[i];
}
@@ -344,7 +338,7 @@ int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs)
for(i = 0; i < free_dims ; i++)
{
working[i] = PUGH_IntegerRoot(free_procs, root);
-
+
while(free_procs % working[i]) working[i]--;
#ifdef DEBUG_PUGH
@@ -354,8 +348,8 @@ int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs)
root--;
}
-
- /* The above doesn't necessarily sort them properly
+
+ /* The above doesn't necessarily sort them properly
* e.g. if one of the factors is a prime then the
* above will sort the 1 before the prime.
*/
@@ -384,15 +378,15 @@ int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs)
@routine PUGH_GenerateNeighbours
@date Mon Nov 8 08:15:08 1999
@author Tom Goodale
- @desc
+ @desc
Works out the array of neighbouring processors for
every processor.
- @enddesc
+ @enddesc
@@*/
-int PUGH_GenerateNeighbours(int dim,
- int total_procs,
- int *nprocs,
- int **neighbours,
+int PUGH_GenerateNeighbours(int dim,
+ int total_procs,
+ int *nprocs,
+ int **neighbours,
int *perme)
{
int retval;
@@ -401,7 +395,7 @@ int PUGH_GenerateNeighbours(int dim,
int idim;
int *pos;
int temp;
-
+
pos = malloc(dim*sizeof(int));
if(dim == 0 || pos)
@@ -409,12 +403,12 @@ int PUGH_GenerateNeighbours(int dim,
for(i = 0; i < total_procs; i++)
{
PUGH_DecomposeIJK(dim,i,nprocs, pos);
-
+
for(idim = 0; idim < dim ; idim++)
{
/* Deal with minus neighbour in this direction */
pos[idim]--;
-
+
if(pos[idim] > -1)
{
neighbours[i][idim*2] = PUGH_ComposeIJK(dim, nprocs, pos);
@@ -432,7 +426,7 @@ int PUGH_GenerateNeighbours(int dim,
}
pos[idim]++;
-
+
/* Deal with plus neighbour in this direction */
pos[idim]++;
@@ -481,17 +475,17 @@ int PUGH_GenerateNeighbours(int dim,
return retval;
}
-
+
/*@@
@routine PUGH_DecomposeIJK
@date Fri Nov 5 11:29:43 1999
@author Tom Goodale
- @desc
+ @desc
Decompose an ijk index into seperate components.
Taken from libHLL.
- @enddesc
+ @enddesc
@@*/
static int PUGH_DecomposeIJK(int dim, int ijk, int *nprocs, int *pos)
{
@@ -518,17 +512,17 @@ static int PUGH_DecomposeIJK(int dim, int ijk, int *nprocs, int *pos)
@routine PUGH_ComposeIJK
@date Fri Nov 5 11:29:43 1999
@author Tom Goodale
- @desc
+ @desc
Compose an ijk index from seperate components.
Taken from libHLL.
- @enddesc
+ @enddesc
@@*/
static int PUGH_ComposeIJK(int dim, int *nprocs, int *pos)
{
int ijk;
int idim;
- /* Construct the position in the linear space.
+ /* Construct the position in the linear space.
*
* e.g. i+nx*(j+ny*k)
*/
@@ -547,9 +541,9 @@ static int PUGH_ComposeIJK(int dim, int *nprocs, int *pos)
@routine PUGH_SetupPGExtrasMemory
@date Mon Nov 8 08:16:02 1999
@author Tom Goodale
- @desc
+ @desc
Allocate memory for the members of the pGExtras structure.
- @enddesc
+ @enddesc
@@*/
static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
{
@@ -561,7 +555,7 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
if(this)
{
/* Do it in stages.
- * First: things depending on the number of processors
+ * First: things depending on the number of processors
*/
this->lb = malloc(total_procs*sizeof(int *));
this->ub = malloc(total_procs*sizeof(int *));
@@ -576,8 +570,8 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
this->iterator = malloc(dim*sizeof(int));
this->hyper_volume = malloc(dim*sizeof(int));
- /* Check all the above succeeded and then get memory for
- * arrays hanging off the above.
+ /* Check all the above succeeded and then get memory for
+ * arrays hanging off the above.
*/
if(this->lb &&
this->ub &&
@@ -627,17 +621,17 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
free(this->rnpoints);
this->rnpoints = NULL;
free(this->nghostzones);
- this->nghostzones = NULL;
+ this->nghostzones = NULL;
free(this->nsize);
- this->nsize = NULL;
+ this->nsize = NULL;
free(this->lnsize);
- this->lnsize = NULL;
+ this->lnsize = NULL;
free(this->bbox);
- this->bbox = NULL;
+ this->bbox = NULL;
free(this->iterator);
- this->iterator = NULL;
+ this->iterator = NULL;
free(this->hyper_volume);
- this->hyper_volume = NULL;
+ this->hyper_volume = NULL;
}
}
}
@@ -653,19 +647,19 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
free(this->rnpoints);
this->rnpoints = NULL;
free(this->nghostzones);
- this->nghostzones = NULL;
+ this->nghostzones = NULL;
free(this->nsize);
- this->nsize = NULL;
+ this->nsize = NULL;
free(this->lnsize);
- this->lnsize = NULL;
+ this->lnsize = NULL;
free(this->bbox);
- this->bbox = NULL;
+ this->bbox = NULL;
free(this->iterator);
- this->iterator = NULL;
+ this->iterator = NULL;
free(this->hyper_volume);
- this->hyper_volume = NULL;
+ this->hyper_volume = NULL;
}
-
+
if(this->lb &&
this->ub &&
this->rnsize &&
@@ -702,16 +696,16 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
{
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)
{
@@ -719,10 +713,10 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
{
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;
}
@@ -744,10 +738,10 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
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;
}
@@ -775,18 +769,18 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
free(this->rnpoints);
this->rnpoints = NULL;
free(this->nghostzones);
- this->nghostzones = NULL;
+ this->nghostzones = NULL;
free(this->nsize);
- this->nsize = NULL;
+ this->nsize = NULL;
free(this->lnsize);
- this->lnsize = NULL;
+ this->lnsize = NULL;
free(this->bbox);
- this->bbox = NULL;
+ this->bbox = NULL;
free(this->iterator);
- this->iterator = NULL;
+ this->iterator = NULL;
free(this->hyper_volume);
- this->hyper_volume = NULL;
- }
+ this->hyper_volume = NULL;
+ }
}
}
else
@@ -801,13 +795,13 @@ static int PUGH_SetupPGExtrasMemory(int dim, int total_procs, pGExtras *this)
@routine PUGH_SetupPGExtrasSizes
@date Mon Nov 8 08:59:33 1999
@author Tom Goodale
- @desc
- Sets up the size information in the pGExtras
+ @desc
+ Sets up the size information in the pGExtras
structure.
- @enddesc
+ @enddesc
@@*/
static int PUGH_SetupPGExtrasSizes(int is_gf,
- int dim,
+ int dim,
int stagger,
int *sh,
int *nghosts,
@@ -823,18 +817,18 @@ static int PUGH_SetupPGExtrasSizes(int is_gf,
for (dir=0 ; dir < dim ; dir++)
{
/* A -ve size means constant load per proc */
- if (sh[dir] < 0 && nprocs[dir] > 1)
+ if (sh[dir] < 0 && nprocs[dir] > 1)
{
- this->nsize[dir] = (nprocs[dir]-2) *
+ this->nsize[dir] = (nprocs[dir]-2) *
(-sh[dir] - 2*nghosts[dir]) +
2 * (-sh[dir] - nghosts[dir]);
-
- if (stagger == PUGH_STAGGER)
+
+ if (stagger == PUGH_STAGGER)
{
this->nsize[dir] -= nprocs[dir]-1;
}
- }
- else
+ }
+ else
{
this->nsize[dir] = abs(sh[dir]);
}
@@ -847,21 +841,12 @@ static int PUGH_SetupPGExtrasSizes(int is_gf,
}
/* Setup the bounding box stuff */
-
- PUGH_SetupBoundingBox(is_gf,
- dim,
- stagger,
- nghosts,
- total_procs,
- nprocs,
- this);
+ PUGH_SetupBoundingBox(is_gf, dim, stagger, nghosts, total_procs, nprocs,this);
/* Set the remote sizes */
+ PUGH_SetupRemoteSizes(dim, total_procs, this);
- PUGH_SetupRemoteSizes(dim, total_procs, this);
-
/* Set the local sizes */
-
for (dir = 0; dir < dim; dir++)
{
this->lnsize[dir] = this->rnsize[this_proc][dir];
@@ -870,7 +855,6 @@ static int PUGH_SetupPGExtrasSizes(int is_gf,
this->npoints = this->rnpoints[this_proc];
/* Set up the maxskew */
-
maxpoints=this->npoints;
minpoints=this->npoints;
avgpoints=0;
@@ -886,20 +870,20 @@ static int PUGH_SetupPGExtrasSizes(int is_gf,
return 0;
}
-
+
/*@@
@routine PUGH_SetupPGExtrasOwnership
@date Mon Nov 8 09:00:10 1999
@author Tom Goodale
- @desc
- Sets up ownership, overlap, ghostzones, etc
+ @desc
+ Sets up ownership, overlap, ghostzones, etc
in a pGExtras structure.
Mostly taken from original SetupOwnership by Paul.
- @enddesc
+ @enddesc
@@*/
-static int PUGH_SetupPGExtrasOwnership(int dim,
+static int PUGH_SetupPGExtrasOwnership(int dim,
int *perme,
int this_proc,
pGExtras *this)
@@ -908,6 +892,7 @@ static int PUGH_SetupPGExtrasOwnership(int dim,
int dir, idir;
int istart, iend;
+
/* Ownership is pretty easy. Remember ownership is indexed as
[stagger][ijk][min/max]. See pGF_Reduction for a use of this,
among others.
@@ -915,16 +900,13 @@ static int PUGH_SetupPGExtrasOwnership(int dim,
*/
for (dir = 0 ; dir < dim; dir++)
{
- this->ownership[PUGH_VERTEXCTR][0][dir] =
+ this->ownership[PUGH_VERTEXCTR][0][dir] =
(this->lb[this_proc][dir] == 0 ? 0 : this->nghostzones[dir]);
this->ownership[PUGH_VERTEXCTR][1][dir] =
- (this->ub[this_proc][dir] == this->nsize[dir]-1 ?
+ (this->ub[this_proc][dir] == this->nsize[dir]-1 ?
this->lnsize[dir] : this->lnsize[dir] - this->nghostzones[dir]);
- this->bbox[2*dir] = this->lb[this_proc][dir] == 0;
- this->bbox[2*dir+1] = this->ub[this_proc][dir] ==
- this->nsize[dir]-1;
-
-
+ this->bbox[2*dir+0] = this->lb[this_proc][dir] == 0;
+ this->bbox[2*dir+1] = this->ub[this_proc][dir] == this->nsize[dir]-1;
}
/* correct for periodic identification : Tue Jun 17 08:40:15 CDT 1997 */
@@ -932,16 +914,26 @@ static int PUGH_SetupPGExtrasOwnership(int dim,
{
if(perme[dir])
{
- this->ownership[PUGH_VERTEXCTR][0][dir] =
- this->nghostzones[dir];
- this->ownership[PUGH_VERTEXCTR][1][dir] =
- this->lnsize[dir] - this->nghostzones[dir];
+ /* sanity check for periodic BC */
+ if (this->nsize[dir] < 3*this->nghostzones[dir])
+ {
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Not enough interior grid points in dimension %d ! "
+ "Please set the number of global grid points (currently "
+ "%d) to something >= 3 * the number of ghostzones "
+ "(currently %d) !",
+ dir, this->nsize[dir], this->nghostzones[dir]);
+ }
+
+ this->ownership[PUGH_VERTEXCTR][0][dir] = this->nghostzones[dir];
+ this->ownership[PUGH_VERTEXCTR][1][dir] =
+ this->lnsize[dir] - this->nghostzones[dir];
}
- }
+ }
for (dir = 0; dir < dim; dir++)
{
- if (this->nsize[dir] == 1)
+ if (this->nsize[dir] == 1)
{
this->ownership[PUGH_VERTEXCTR][0][dir] = 0;
this->ownership[PUGH_VERTEXCTR][1][dir] = 1;
@@ -953,17 +945,17 @@ static int PUGH_SetupPGExtrasOwnership(int dim,
but which is covered by our neighbors ghost. So this is what we
want to SEND
*/
- for (dir = 0; dir < 2*dim; dir++)
+ for (dir = 0; dir < 2*dim; dir++)
{
for (idir = 0; idir < dim; idir++)
{
- istart = 0;
+ istart = 0;
iend = this->lnsize[idir];
/* We want to send at the dir - 1 */
/* Correct to direction specific sweeps ... */
- if (dir == 2*idir)
+ if (dir == 2*idir)
{
/* Want to go from sw to sw + sw (eg, 1 to < 2, 2 to < 4) */
istart = this->nghostzones[idir];
@@ -986,23 +978,23 @@ static int PUGH_SetupPGExtrasOwnership(int dim,
/* And finally the ghost indices. This used to be in
pGF_FinishRecv.c, but now it is here.
*/
- for (dir = 0; dir < 2*dim; dir++)
+ for (dir = 0; dir < 2*dim; dir++)
{
/* We want to send at the dir - 1 */
for (idir = 0; idir < dim; idir++)
{
- istart = 0;
+ istart = 0;
iend = this->lnsize[idir];
/* Correct to direction specific sweeps ... */
/* Remember this is SW less than the other way... */
- if (dir == 2*idir)
+ if (dir == 2*idir)
{
/* Want to go from sw to sw + sw (eg, 1 to < 2, 2 to < 4) */
istart = 0;
iend = this->nghostzones[idir];
}
- if (dir == 2*idir+1)
+ if (dir == 2*idir+1)
{
/* Want to go from nx - 2 sw to nx - sw
(eg nx-2 to < nx-1, nx-4 to < nx-2)
@@ -1014,9 +1006,7 @@ static int PUGH_SetupPGExtrasOwnership(int dim,
this->ghosts[PUGH_VERTEXCTR][0][dir][idir] = istart;
this->ghosts[PUGH_VERTEXCTR][1][dir][idir] = iend;
-
}
-
}
return 0;
@@ -1027,13 +1017,13 @@ static int PUGH_SetupPGExtrasStaggering(int dim, int this_proc, pGExtras *this)
int s,d,k,dir;
int *upperbnd;
- upperbnd = malloc(dim*sizeof(int));
+ upperbnd = malloc(dim*sizeof(int));
for (d=0;d<dim;d++)
{
upperbnd[d] = (this->ub[this_proc][d] == this->nsize[d]-1) ? 1 : 0;
}
-
+
/* copy ownership/ghost/overlap from the default PUGH_VERTEXCTR */
for(s=1;s<PUGH_NSTAGGER;s++)
{
@@ -1045,12 +1035,12 @@ static int PUGH_SetupPGExtrasStaggering(int dim, int this_proc, pGExtras *this)
for (dir=0;dir<2*dim;dir++)
{
this->overlap[s][k][dir][d] = this->overlap[0][k][dir][d];
- this->ghosts [s][k][dir][d] = this->ghosts [0][k][dir][d];
+ this->ghosts [s][k][dir][d] = this->ghosts [0][k][dir][d];
}
}
-
+
/* decrease ownership at upper bound */
- if(upperbnd[d])
+ if(upperbnd[d])
{
this->ownership[s][1][d] --;
}
@@ -1061,7 +1051,7 @@ static int PUGH_SetupPGExtrasStaggering(int dim, int this_proc, pGExtras *this)
{
for (d=0;d<dim;d++)
{
- /* if we are at a upper physical bnd && at a upperface (1,3,5)
+ /* if we are at a upper physical bnd && at a upperface (1,3,5)
&& we are in the dir direction decrease by one */
if((upperbnd[d])&&((dir+1)%2==0)&&(dir==2*d+1))
{
@@ -1081,12 +1071,12 @@ static int PUGH_SetupPGExtrasStaggering(int dim, int this_proc, pGExtras *this)
@routine PUGH_SetupBoundingBox
@date Mon Nov 8 09:03:40 1999
@author Tom Goodale
- @desc
+ @desc
Sets up the bounding box info for a pgExtras structure.
- @enddesc
+ @enddesc
@@*/
static int PUGH_SetupBoundingBox(int is_gf,
- int dim,
+ int dim,
int stagger,
int *nghosts,
int total_procs,
@@ -1103,7 +1093,7 @@ static int PUGH_SetupBoundingBox(int is_gf,
if(dim > 0 && bounds && pos)
{
- /* Work out the bounds in each direction - either from parameters
+ /* Work out the bounds in each direction - either from parameters
file or default*/
PUGH_GetBounds(is_gf, dim, bounds, nprocs, this->nsize);
@@ -1117,7 +1107,7 @@ static int PUGH_SetupBoundingBox(int is_gf,
{
PUGH_DecomposeIJK(dim, pnum, nprocs, pos);
-
+
for(dir = 0 ; dir < dim; dir++)
{
if (pos[dir] == 0)
@@ -1133,7 +1123,7 @@ static int PUGH_SetupBoundingBox(int is_gf,
}
}
- if (pos[dir] == nprocs[dir]-1)
+ if (pos[dir] == nprocs[dir]-1)
{
this->ub[pnum][dir] = this->nsize[dir]-1;
}
@@ -1160,7 +1150,7 @@ static int PUGH_SetupBoundingBox(int is_gf,
printf(" setup_Bounding_Box (%d):", i);
for (dir = 0 ; dir < dim; dir++)
printf(" (%d,%d)",
- this->lb[i][dir], this->ub[i][dir]);
+ this->lb[i][dir], this->ub[i][dir]);
printf(" \n");
}
}
@@ -1174,9 +1164,9 @@ static int PUGH_SetupBoundingBox(int is_gf,
@routine PUGH_SetupRemoteSizes
@date Mon Nov 8 09:07:27 1999
@author Tom Goodale
- @desc
+ @desc
Determines info about the sizes on each processor.
- @enddesc
+ @enddesc
@@*/
static int PUGH_SetupRemoteSizes(int dim, int total_procs, pGExtras *this)
{
@@ -1204,9 +1194,9 @@ static int PUGH_SetupRemoteSizes(int dim, int total_procs, pGExtras *this)
@routine PUGH_SetupGArrayGroupComm
@date Tue 06 Jun 2000
@author Thomas Radke
- @desc
+ @desc
Sets up a communication buffer for a group of GAs.
- @enddesc
+ @enddesc
@@*/
pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH,
int dim,
@@ -1225,7 +1215,7 @@ pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH,
(void) (vartype + 0);
#endif
- this = malloc (sizeof (pComm));
+ this = calloc (1, sizeof (pComm));
if (this)
{
@@ -1273,36 +1263,15 @@ pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH,
}
else
{
- if (this->buffer_sz)
- {
- free (this->buffer_sz);
- }
- if (this->send_buffer)
- {
- free (this->send_buffer);
- }
- if (this->recv_buffer)
- {
- free (this->recv_buffer);
- }
+ free (this->buffer_sz);
+ free (this->send_buffer);
+ free (this->recv_buffer);
#ifdef CCTK_MPI
- if (this->sreq)
- {
- free (this->sreq);
- }
- if (this->rreq)
- {
- free (this->rreq);
- }
- if (this->sstatus)
- {
- free (this->sstatus);
- }
+ free (this->sreq);
+ free (this->rreq);
+ free (this->sstatus);
#endif
- if (this->docomm)
- {
- free (this->docomm);
- }
+ free (this->docomm);
free (this);
this = NULL;
@@ -1334,9 +1303,9 @@ pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH,
@routine PUGH_SetupGArrayComm
@date Tue 06 Jun 2000
@author Thomas Radke
- @desc
+ @desc
Sets up a communication buffer for a GA.
- @enddesc
+ @enddesc
@@*/
pComm *PUGH_SetupGArrayComm(pGH *pughGH,
int dim,
@@ -1359,9 +1328,9 @@ pComm *PUGH_SetupGArrayComm(pGH *pughGH,
@routine PUGH_DestroyComm
@date Tue 06 Jun 2000
@author Thomas Radke
- @desc
+ @desc
Destroys a communication buffer.
- @enddesc
+ @enddesc
@@*/
void PUGH_DestroyComm(pComm **comm)
{
@@ -1384,9 +1353,9 @@ void PUGH_DestroyComm(pComm **comm)
@routine PUGH_SetupGArray
@date Mon Nov 8 16:29:34 1999
@author Tom Goodale
- @desc
+ @desc
Sets up a new pGA.
- @enddesc
+ @enddesc
@@*/
pGA *PUGH_SetupGArray(void *parent,
pGExtras *extras,
@@ -1395,16 +1364,16 @@ pGA *PUGH_SetupGArray(void *parent,
const char *name,
int id,
int arrayid,
- int varsize,
- int vtype,
+ int varsize,
+ int vtype,
int stagger,
int vector_size,
int vector_entry,
- pGA *vector_base)
+ pGA *vector_base)
{
pGA *this;
- this = malloc(sizeof(pGA));
+ this = calloc(1, sizeof(pGA));
if(this)
{
@@ -1434,14 +1403,8 @@ pGA *PUGH_SetupGArray(void *parent,
}
else
{
- if(this->name)
- {
- free(this->name);
- }
- if(this->padddata)
- {
- free(this->padddata);
- }
+ free(this->name);
+ free(this->padddata);
free(this);
this = NULL;
}
@@ -1454,9 +1417,9 @@ pGA *PUGH_SetupGArray(void *parent,
@routine PUGH_DestroyGArray
@date Mar 12 2000
@author Thomas Radke
- @desc
+ @desc
Destroys a pGA object.
- @enddesc
+ @enddesc
@@*/
void PUGH_DestroyGArray(pGA **GA)
{
@@ -1494,20 +1457,20 @@ void PUGH_DestroyGArray(pGA **GA)
@routine PUGH_IntegerRoot
@date Tue Jan 30 17:06:21 2001
@author Tom Goodale
- @desc
+ @desc
Generate the highest integer below a given integer root of an integer.
- @enddesc
+ @enddesc
@var number
@vdesc The number to take the root of
@vtype int
@vio in
- @endvar
+ @endvar
@var invpower
@vdesc The root to take
@vtype int
@vio in
- @endvar
+ @endvar
@returntype int
@returndesc
@@ -1530,7 +1493,7 @@ static int PUGH_IntegerRoot(int number, int invpower)
break;
}
}
-
+
return root;
}