From 97bf19361e4c738bd094d9bfc750e21153569ea0 Mon Sep 17 00:00:00 2001 From: tradke Date: Tue, 19 Sep 2000 12:06:29 +0000 Subject: Erik's bugfix for hyperslabbing on CCTK_ARRAY types. This fixes BR 439. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@35 10716dce-81a3-4424-a2c8-48026a0d3035 --- src/Hyperslab.c | 330 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 200 insertions(+), 130 deletions(-) (limited to 'src/Hyperslab.c') diff --git a/src/Hyperslab.c b/src/Hyperslab.c index b2bbce7..79930ec 100644 --- a/src/Hyperslab.c +++ b/src/Hyperslab.c @@ -23,12 +23,12 @@ #define MAX(x, y) ((x) > (y) ? (x) : (y)) /* shortcuts for the local/global start/endpoints on this processor */ -#define MY_LOCAL_SP(extras, istag, dim) (extras->ownership [istag][0][dim]) -#define MY_LOCAL_EP(extras, istag, dim) (extras->ownership [istag][1][dim]) +#define MY_LOCAL_SP(extras, istag, dim) (extras->ownership[istag][0][dim]) +#define MY_LOCAL_EP(extras, istag, dim) (extras->ownership[istag][1][dim]) #define MY_GLOBAL_SP(extras, myproc, istag, dim) \ - (extras->lb [myproc][dim] + MY_LOCAL_SP (extras, istag, dim)) + (extras->lb[myproc][dim] + MY_LOCAL_SP (extras, istag, dim)) #define MY_GLOBAL_EP(extras, myproc, istag, dim) \ - (extras->lb [myproc][dim] + MY_LOCAL_EP (extras, istag, dim)) + (extras->lb[myproc][dim] + MY_LOCAL_EP (extras, istag, dim)) /* macro for copying all relevant data points @@ -43,41 +43,49 @@ \ \ /* set point to local startpoint */ \ - memcpy (point, startpoint, vdim * sizeof (point [0])); \ + memcpy (point, startpoint, vdim * sizeof (point[0])); \ \ /* do the nested loops starting with the innermost */ \ dim = 0; \ while (1) \ { \ /* check for end of current loop */ \ - if (point [dim] >= endpoint [dim]) \ + if (point[dim] >= endpoint[dim]) \ { \ /* increment outermost loopers */ \ for (dim++; dim < vdim; dim++) \ { \ - point [dim] += downsample [dim]; \ - if (point [dim] < endpoint [dim]) \ + point[dim] += downsample[dim]; \ + if (point[dim] < endpoint[dim]) \ + { \ break; \ + } \ } \ \ /* done if beyond outermost loop */ \ if (dim >= vdim) \ + { \ break; \ + } \ \ /* reset innermost loopers */ \ for (dim--; dim >= 0; dim--) \ - point [dim] = startpoint [dim]; \ + { \ + point[dim] = startpoint[dim]; \ + } \ dim = 0; \ } \ \ /* copy the data point */ \ - vindex = point [0]; \ + vindex = point[0]; \ for (i = 1; i < vdim; i++) \ - vindex += point [i] * points_per_dim [i]; \ - *typed_hdata++ = typed_vdata [vindex]; \ + { \ + vindex += point[i] * points_per_dim[i]; \ + } \ + *typed_hdata++ = typed_vdata[vindex]; \ \ /* increment current looper */ \ - point [dim] += downsample [dim]; \ + point[dim] += downsample[dim]; \ \ } /* end of nested loops over all dimensions */ \ } @@ -88,6 +96,7 @@ int Hyperslab_CollectData1D (cGH *GH, int vindex, int vtimelvl, const int *origin, const int *directions, + int downsampling, int length, void **hdata, @@ -96,12 +105,12 @@ int Hyperslab_CollectData1D (cGH *GH, int vindex, int vtimelvl, /* routine to check parameters passed to the Hyperslab routines */ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl, int hdim, - const int global_startpoint [/*vdim*/], - const int directions [/*vdim*/], - const int extents [/*hdim*/], - const int downsample_ [/*hdim*/], + const int global_startpoint[/*vdim*/], + const int directions[/*vdim*/], + const int extents[/*hdim*/], + const int downsample_[/*hdim*/], void **hdata, - int hsize [/*hdim*/]); + int hsize[/*hdim*/]); /*@@ @@ -145,7 +154,7 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl, @endvar @var global_startpoint @vdesc global coordinates of the hyperslab origin - @vtype const int [dimensions of vindex] + @vtype const int[dimensions of vindex] @vio in @endvar @var directions @@ -155,19 +164,19 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl, for hyperslabs of higher dimensions. If the hyperslab is of same dimensionality as the variable the directions vector is ignored. - @vtype const int [dimensions of vindex] + @vtype const int[dimensions of vindex] @vio in @endvar @var extents @vdesc number of grid points to follow in each hyperslab direction starting from origin Negative values are taken as extents up to the grid boundaries. - @vtype const int [hdim] + @vtype const int[hdim] @vio in @endvar @var downsample_ @vdesc downsampling values for each hyperslab dimension - @vtype const int [hdim] + @vtype const int[hdim] @vio in @endvar @var hdata @@ -177,31 +186,31 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl, @endvar @var hsize @vdesc sizes of the (local) hyperslab data buffer in each dimension - @vtype int [hdim] + @vtype int[hdim] @vio out @endvar @var hsize_global @vdesc sizes of the global hyperslab data buffer in each dimension - @vtype int [hdim] + @vtype int[hdim] @vio out @endvar @var hoffset_global @vdesc if not NULL, array to save the offsets of the local hyperslab into the global one for each dimension - @vtype int [hdim] + @vtype int[hdim] @vio out @endvar @@*/ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, int hdim, - const int global_startpoint [/*vdim*/], - const int directions [/*vdim*/], - const int extents [/*hdim*/], - const int downsample_ [/*hdim*/], + const int global_startpoint[/*vdim*/], + const int directions[/*vdim*/], + const int extents[/*hdim*/], + const int downsample_[/*hdim*/], void **hdata, - int hsize [/*hdim*/], - int hsize_global [/*hdim*/], - int hoffset_global [/*hdim*/]) + int hsize[/*hdim*/], + int hsize_global[/*hdim*/], + int hoffset_global[/*hdim*/]) { int *point; /* looper over hyperslab dimensions */ int *startpoint, /* hyperslab's local start and endpoint */ @@ -256,38 +265,44 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, hdim == vdim the normal vector is completely ignored, and all directions are selected */ if (hdim == 1) + { memcpy (do_dir, directions, vinfo.dim * sizeof (int)); + } else if (hdim < vinfo.dim) { for (vdim = 0; vdim < vinfo.dim; vdim++) - do_dir [vdim] = ! directions [vdim]; + { + do_dir[vdim] = ! directions[vdim]; + } } else { for (vdim = 0; vdim < vinfo.dim; vdim++) - do_dir [vdim] = 1; + { + do_dir[vdim] = 1; + } } /* get the pGH pointer and the variable's GA structure */ pughGH = PUGH_pGH (GH); - GA = (pGA *) pughGH->variables [vindex][vtimelvl]; + GA = (pGA *) pughGH->variables[vindex][vtimelvl]; /* compute the global endpoint */ for (vdim = hdim = 0; vdim < vinfo.dim; vdim++) { - if (do_dir [vdim]) + if (do_dir[vdim]) { - global_endpoint [vdim] = extents [hdim] > 0 ? - MIN (global_startpoint [vdim] + extents [hdim], - GA->extras->nsize [vdim]) : - GA->extras->nsize [vdim]; - downsample [vdim] = downsample_ [hdim]; + global_endpoint[vdim] = extents[hdim] > 0 ? + MIN (global_startpoint[vdim] + extents[hdim], + GA->extras->nsize[vdim]) : + GA->extras->nsize[vdim]; + downsample[vdim] = downsample_[hdim]; hdim++; } else { - global_endpoint [vdim] = global_startpoint [vdim] + 1; - downsample [vdim] = 1; + global_endpoint[vdim] = global_startpoint[vdim] + 1; + downsample[vdim] = 1; } } @@ -299,29 +314,33 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, { stagger_index = CCTK_StaggerDirIndex (vdim, vinfo.stagtype); - if (global_startpoint [vdim] < MY_GLOBAL_EP (GA->extras, myproc, + if (global_startpoint[vdim] < MY_GLOBAL_EP (GA->extras, myproc, stagger_index, vdim)) { - if (global_startpoint [vdim] < MY_GLOBAL_SP (GA->extras, myproc, + if (global_startpoint[vdim] < MY_GLOBAL_SP (GA->extras, myproc, stagger_index, vdim)) { int npoints; npoints = (MY_GLOBAL_SP (GA->extras, myproc, stagger_index, vdim) - - global_startpoint [vdim]) / downsample [vdim]; + - global_startpoint[vdim]) / downsample[vdim]; if ((MY_GLOBAL_SP (GA->extras, myproc, stagger_index, vdim) - - global_startpoint [vdim]) % downsample [vdim]) + - global_startpoint[vdim]) % downsample[vdim]) + { npoints++; - my_global_startpoint [vdim] = global_startpoint [vdim] + - npoints*downsample [vdim]; + } + my_global_startpoint[vdim] = global_startpoint[vdim] + + npoints*downsample[vdim]; } else { - my_global_startpoint [vdim] = global_startpoint [vdim]; + my_global_startpoint[vdim] = global_startpoint[vdim]; } } else - my_global_startpoint [vdim] = -1; + { + my_global_startpoint[vdim] = -1; + } } /* compute the local start- and endpoint from the global ranges */ @@ -330,56 +349,60 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, { stagger_index = CCTK_StaggerDirIndex (vdim, vinfo.stagtype); - if (my_global_startpoint [vdim] >= 0 && - my_global_startpoint [vdim] < MY_GLOBAL_EP (GA->extras, myproc, + if (my_global_startpoint[vdim] >= 0 && + my_global_startpoint[vdim] < MY_GLOBAL_EP (GA->extras, myproc, stagger_index, vdim)) { - startpoint [vdim] = my_global_startpoint [vdim] - - GA->extras->lb [myproc][vdim]; + startpoint[vdim] = my_global_startpoint[vdim] - + GA->extras->lb[myproc][vdim]; } else - startpoint [vdim] = -1; + { + startpoint[vdim] = -1; + } - if (global_endpoint [vdim] > MY_GLOBAL_SP (GA->extras, myproc, + if (global_endpoint[vdim] > MY_GLOBAL_SP (GA->extras, myproc, stagger_index, vdim)) { - endpoint [vdim] = MIN (MY_LOCAL_EP (GA->extras, stagger_index, vdim), - global_endpoint [vdim] - GA->extras->lb[myproc][vdim]); + endpoint[vdim] = MIN (MY_LOCAL_EP (GA->extras, stagger_index, vdim), + global_endpoint[vdim] - GA->extras->lb[myproc][vdim]); } else - endpoint [vdim] = -1; + { + endpoint[vdim] = -1; + } #ifdef DEBUG - printf ("direction %d: local ranges [%d, %d)\n", - vdim, startpoint [vdim], endpoint [vdim]); + printf ("direction %d: local ranges[%d, %d)\n", + vdim, startpoint[vdim], endpoint[vdim]); #endif - if (endpoint [vdim] < 0 || startpoint [vdim] < 0) + if (endpoint[vdim] < 0 || startpoint[vdim] < 0) { totals = 0; - endpoint [vdim] = startpoint [vdim]; + endpoint[vdim] = startpoint[vdim]; } - if (do_dir [vdim]) + if (do_dir[vdim]) { /* compute the global and local size in each hyperslab dimension */ - hsize_global [hdim] = (global_endpoint[vdim] - global_startpoint[vdim]) / - downsample [vdim]; - if ((global_endpoint [vdim] - global_startpoint [vdim]) % - downsample [vdim]) + hsize_global[hdim] = (global_endpoint[vdim] - global_startpoint[vdim]) / + downsample[vdim]; + if ((global_endpoint[vdim] - global_startpoint[vdim]) % + downsample[vdim]) { - hsize_global [hdim]++; + hsize_global[hdim]++; } - if (GA->connectivity->perme [vdim]) + if (GA->connectivity->perme[vdim]) { - hsize_global [hdim] -= 2 * GA->extras->nghostzones [vdim]; + hsize_global[hdim] -= 2 * GA->extras->nghostzones[vdim]; } - hsize [hdim] = (endpoint [vdim] - startpoint [vdim]) / downsample [vdim]; - if ((endpoint [vdim] - startpoint [vdim]) % downsample [vdim]) + hsize[hdim] = (endpoint[vdim] - startpoint[vdim]) / downsample[vdim]; + if ((endpoint[vdim] - startpoint[vdim]) % downsample[vdim]) { - hsize [hdim]++; + hsize[hdim]++; } - totals *= hsize [hdim]; + totals *= hsize[hdim]; hdim++; } } @@ -389,7 +412,7 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, #endif /* nested loop over vinfo.dim dimensions */ - /* NOTE: the following code assumes startpoint [vdim] < endpoint [vdim] */ + /* NOTE: the following code assumes startpoint[vdim] < endpoint[vdim] */ if (totals > 0) { void *vdata = CCTK_VarDataPtrI (GH, vtimelvl, vindex); @@ -400,17 +423,17 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, { for (vdim = hdim = 0; vdim < vinfo.dim; vdim++) { - if (do_dir [vdim]) + if (do_dir[vdim]) { - hoffset_global [hdim] = (my_global_startpoint [vdim] - - global_startpoint [vdim]) / downsample [vdim]; - if (GA->connectivity->perme [vdim]) + hoffset_global[hdim] = (my_global_startpoint[vdim] - + global_startpoint[vdim]) / downsample[vdim]; + if (GA->connectivity->perme[vdim]) { - hoffset_global [hdim] -= GA->extras->nghostzones [vdim]; + hoffset_global[hdim] -= GA->extras->nghostzones[vdim]; } #ifdef DEBUG printf ("hoffset_global, hsize in direction %d: %d, %d\n", - hdim, hoffset_global [hdim], hsize [hdim]); + hdim, hoffset_global[hdim], hsize[hdim]); #endif hdim++; } @@ -423,9 +446,12 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, /* compute the points_per_dim[] vector */ /* NOTE: this could be computed at startup and kept in a GH extension once we have one for thorn Hyperslab */ - points_per_dim [0] = 1; + points_per_dim[0] = 1; for (vdim = 1; vdim < vinfo.dim; vdim++) - points_per_dim [vdim] = points_per_dim [vdim-1] * GH->cctk_lsh [vdim-1]; + { + points_per_dim[vdim] = points_per_dim[vdim-1] * + GA->extras->lnsize[vdim-1]; + } /* now get the hyperslab data points using that wonderful macro... */ switch (vinfo.vartype) @@ -506,7 +532,7 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, @endvar @var global_startpoint @vdesc global coordinates of the hyperslab origin - @vtype const int [dimensions of vindex] + @vtype const int[dimensions of vindex] @vio in @endvar @var directions @@ -516,19 +542,19 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, for hyperslabs of higher dimensions. If the hyperslab is of same dimensionality as the variable the directions vector is ignored. - @vtype const int [dimensions of vindex] + @vtype const int[dimensions of vindex] @vio in @endvar @var extents @vdesc number of grid points to follow in each hyperslab direction starting from origin Negative values are taken as extents up to the grid boundaries. - @vtype const int [hdim] + @vtype const int[hdim] @vio in @endvar @var downsample_ @vdesc downsampling values for each hyperslab dimension - @vtype const int [hdim] + @vtype const int[hdim] @vio in @endvar @var hdata @@ -538,18 +564,18 @@ int Hyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl, @endvar @var hsize @vdesc sizes of the hyperslab data buffer in each dimension - @vtype int [hdim] + @vtype int[hdim] @vio out @endvar @@*/ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, int hdim, - const int global_startpoint [/*vdim*/], - const int directions [/*vdim*/], - const int extents [/*hdim*/], - const int downsample_ [/*hdim*/], + const int global_startpoint[/*vdim*/], + const int directions[/*vdim*/], + const int extents[/*hdim*/], + const int downsample_[/*hdim*/], void **hdata, - int hsize [/*hdim*/]) + int hsize[/*hdim*/]) { int myproc, nprocs; /* processor identification */ int retval; /* the return value */ @@ -597,11 +623,13 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, return (-1); } - length = extents [0]; + length = extents[0]; if (length > 0) + { length--; + } return (Hyperslab_CollectData1D (GH, vindex, vtimelvl, global_startpoint, - directions, downsample_ [0], length, + directions, downsample_[0], length, hdata, hsize, target_proc)); } @@ -661,7 +689,9 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, /* that's it for the single processor case */ if (nprocs == 1) + { return (retval); + } #ifdef CCTK_MPI if (retval) @@ -678,11 +708,11 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, totals_local = 1; for (i = 0; i < hdim; i++) { - totals_local *= hsize_local [i]; - sizes_local [0*hdim + i] = hsize_local [i]; - sizes_local [1*hdim + i] = hoffset_local [i]; + totals_local *= hsize_local[i]; + sizes_local[0*hdim + i] = hsize_local[i]; + sizes_local[1*hdim + i] = hoffset_local[i]; } - sizes_local [2*hdim + 0] = totals_local; + sizes_local[2*hdim + 0] = totals_local; comm = PUGH_pGH (GH)->PUGH_COMM_WORLD; /* FIXME: do an Allgather here so that all procs know how many data points @@ -692,9 +722,11 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, sizes_global, 2*hdim + 1, PUGH_MPI_INT, comm)); /* sum up the total number of hyperslab data points */ - totals_global = sizes_global [2*hdim]; + totals_global = sizes_global[2*hdim]; for (proc = 1; proc < nprocs; proc++) - totals_global += sizes_global [proc*(2*hdim+1) + 2*hdim]; + { + totals_global += sizes_global[proc*(2*hdim+1) + 2*hdim]; + } /* immediately return if there is no data at all */ if (totals_global <= 0) @@ -720,19 +752,19 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, { for (proc = 0; proc < nprocs; proc++) { - displs [proc] = sizes_global [proc*(2*hdim+1) + 2*hdim - 1]; - recvcnts [proc] = sizes_global [proc*(2*hdim+1) + 2*hdim]; + displs[proc] = sizes_global[proc*(2*hdim+1) + 2*hdim - 1]; + recvcnts[proc] = sizes_global[proc*(2*hdim+1) + 2*hdim]; } } else { - displs [0] = 0; - recvcnts [0] = sizes_global [2*hdim]; + displs[0] = 0; + recvcnts[0] = sizes_global[2*hdim]; for (proc = 1; proc < nprocs; proc++) { - displs [proc] = displs [proc-1] + sizes_global [(proc-1)*(2*hdim+1) + - 2*hdim]; - recvcnts [proc] = sizes_global [proc*(2*hdim+1) + 2*hdim]; + displs[proc] = displs[proc-1] + sizes_global[(proc-1)*(2*hdim+1) + + 2*hdim]; + recvcnts[proc] = sizes_global[proc*(2*hdim+1) + 2*hdim]; } } @@ -797,9 +829,11 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, point = (int *) malloc (2 * hdim * sizeof (int)); points_per_hdim = point + hdim; - points_per_hdim [0] = 1; + points_per_hdim[0] = 1; for (i = 1; i < hdim; i++) - points_per_hdim [i] = points_per_hdim [i-1] * hsize [i-1]; + { + points_per_hdim[i] = points_per_hdim[i-1] * hsize[i-1]; + } /* allocate buffer for the returned hyperslab */ *hdata = malloc (totals_global * vtypesize); @@ -812,8 +846,10 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, for (proc = 0; proc < nprocs; proc++) { /* skip processors which didn't contribute any data */ - if (sizes_global [proc * (2*hdim + 1) + 2*hdim] <= 0) + if (sizes_global[proc * (2*hdim + 1) + 2*hdim] <= 0) + { continue; + } hsize_chunk = sizes_global + proc * (2*hdim+1); hoffset_chunk = hsize_chunk + hdim; @@ -825,37 +861,45 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, while (1) { /* check for end of current loop */ - if (point [i] >= hsize_chunk [i]) + if (point[i] >= hsize_chunk[i]) { /* increment outermost loopers */ for (i++; i < hdim; i++) - if (++point [i] < hsize_chunk [i]) + { + if (++point[i] < hsize_chunk[i]) + { break; + } + } /* done if beyond outermost loop */ if (i >= hdim) + { break; + } /* reset innermost loopers */ for (i--; i > 0; i--) - point [i] = 0; + { + point[i] = 0; + } i = 1; } /* get the linear offset */ - linear_hoffset = hoffset_chunk [0]; + linear_hoffset = hoffset_chunk[0]; for (j = 1; j < hdim; j++) { - linear_hoffset += (hoffset_chunk [j] + point [j]) * - points_per_hdim [j]; + linear_hoffset += (hoffset_chunk[j] + point[j]) * + points_per_hdim[j]; } /* copy the line */ memcpy (copy_to + linear_hoffset * vtypesize, - copy_from, hsize_chunk [0] * vtypesize); - copy_from += hsize_chunk [0] * vtypesize; + copy_from, hsize_chunk[0] * vtypesize); + copy_from += hsize_chunk[0] * vtypesize; /* increment current looper */ - point [i]++; + point[i]++; } /* end of nested loops over all dimensions */ } /* end of loop over all processors */ @@ -882,12 +926,12 @@ int Hyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl, /********************** local routines ************************************/ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl, int hdim, - const int global_startpoint [/*vdim*/], - const int directions [/*vdim*/], - const int extents [/*hdim*/], - const int downsample_ [/*hdim*/], + const int global_startpoint[/*vdim*/], + const int directions[/*vdim*/], + const int extents[/*hdim*/], + const int downsample_[/*hdim*/], void **hdata, - int hsize [/*hdim*/]) + int hsize[/*hdim*/]) { int dim; /* looper */ int num_directions; /* number of non-zero directions */ @@ -896,52 +940,78 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl, /* check the variable index and timelevel */ if (vindex < 0 || vindex >= CCTK_NumVars ()) + { return ("Invalid variable index"); + } if (vtimelvl < 0 || vtimelvl >= CCTK_NumTimeLevelsFromVarI (vindex)) + { return ("Invalid timelevel"); + } /* check the passed pointers */ if (! global_startpoint || ! directions || ! extents || ! downsample_ || ! hdata || ! hsize) + { return ("NULL pointer(s) passed as parameters"); + } /* check the extent and downsample parameters */ for (dim = 0; dim < hdim; dim++) { - if (extents [dim] == 0) + if (extents[dim] == 0) + { return ("Invalid hyperslab extent parameters"); - if (downsample_ [dim] <= 0) + } + if (downsample_[dim] <= 0) + { return ( "Invalid hyperslab downsample parameters"); + } } /* get the info on the variable to extract a hyperslab from */ if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0) + { return ("Couldn't get group info"); + } /* check the variable's grouptype */ if (vinfo.grouptype != CCTK_GF && vinfo.grouptype != CCTK_ARRAY) + { return ("Invalid variable group type"); + } /* check the hyperslab dimension */ if (hdim < 0 || hdim > vinfo.dim) + { return ("Invalid hyperslab dimension"); + } /* check the direction(s) of the hyperslab if it is less-dimensional than the variable */ if (hdim != vinfo.dim) { for (dim = 0, num_directions = 0; dim < vinfo.dim; dim++) - if (directions [dim]) + { + if (directions[dim]) + { num_directions++; + } + } if (num_directions == 0) + { return ("Given normal vector is a null vector"); + } if (num_directions > 1) + { return ("Given normal vector isn't axis-parallel"); + } } /* check if PUGH is active */ if (! PUGH_pGH (GH)) + { return ("No GH extension for PUGH found. Did you activate thorn PUGH ?"); + } return (NULL); } -- cgit v1.2.3