diff options
Diffstat (limited to 'src/slab.c')
-rw-r--r-- | src/slab.c | 83 |
1 files changed, 81 insertions, 2 deletions
@@ -2,7 +2,7 @@ /* TODO: - Provide facilities for dim != 3 + Provide facilities for dim > 3 Set up the slab exchange information in advance Test slabbing without MPI Allow using / not setting the ghost zones @@ -586,7 +586,8 @@ int Slab_Transfer (cGH * restrict const cctkGH, assert (dsttype >= 0); assert (dstptr); - info = malloc (dim * sizeof *info); + assert (dim <= SLAB_MAXDIM); + info = malloc (SLAB_MAXDIM * sizeof *info); assert (info); for (d=0; d<dim; ++d) { global2bbox (&xferinfo[d].src, &info[d].src.global); @@ -608,6 +609,15 @@ int Slab_Transfer (cGH * restrict const cctkGH, info[d].flip = xferinfo[d].flip; assert (info[d].flip == 0 || info[d].flip == 1); } + for (d=dim; d<SLAB_MAXDIM; ++d) { + struct bbox const fake_bbox = { 0, 1, 1 }; + struct arrays const fake_arrays + = { fake_bbox, fake_bbox, fake_bbox, fake_bbox }; + info[d].src = fake_arrays; + info[d].dst = fake_arrays; + info[d].xpose = d; + info[d].flip = 0; + } { int iflag[dim]; @@ -980,3 +990,72 @@ int Slab_Transfer (cGH * restrict const cctkGH, return 0; } + + + +void CCTK_FCALL +CCTK_FNAME(Slab_Transfer) (int * restrict const ierr, + cGH * restrict const cctkGH, + int const * restrict const dim, + int const * restrict const src_gsh, + int const * restrict const src_lbnd, + int const * restrict const src_lsh, + int const * restrict const src_lbbox, + int const * restrict const src_ubbox, + int const * restrict const src_nghostzones, + int const * restrict const src_off, + int const * restrict const src_str, + int const * restrict const src_len, + int const * restrict const dst_gsh, + int const * restrict const dst_lbnd, + int const * restrict const dst_lsh, + int const * restrict const dst_lbbox, + int const * restrict const dst_ubbox, + int const * restrict const dst_nghostzones, + int const * restrict const dst_off, + int const * restrict const dst_str, + int const * restrict const dst_len, + int const * restrict const xpose, + int const * restrict const flip, + int const * restrict const options, + int const * restrict const srctype, + void const * const srcptr, + int const * restrict const dsttype, + void * const dstptr) +{ + struct xferinfo * xferinfo; + int d; + + xferinfo = malloc (*dim * sizeof *xferinfo); + assert (xferinfo); + + for (d=0; d<*dim; ++d) { + xferinfo[d].src.gsh = src_gsh[d]; + xferinfo[d].src.lbnd = src_lbnd[d]; + xferinfo[d].src.lsh = src_lsh[d]; + xferinfo[d].src.lbbox = src_lbbox[d]; + xferinfo[d].src.ubbox = src_ubbox[d]; + xferinfo[d].src.nghostzones = src_nghostzones[d]; + xferinfo[d].src.off = src_off[d]; + xferinfo[d].src.str = src_str[d]; + xferinfo[d].src.len = src_len[d]; + + xferinfo[d].dst.gsh = dst_gsh[d]; + xferinfo[d].dst.lbnd = dst_lbnd[d]; + xferinfo[d].dst.lsh = dst_lsh[d]; + xferinfo[d].dst.lbbox = dst_lbbox[d]; + xferinfo[d].dst.ubbox = dst_ubbox[d]; + xferinfo[d].dst.nghostzones = dst_nghostzones[d]; + xferinfo[d].dst.off = dst_off[d]; + xferinfo[d].dst.str = dst_str[d]; + xferinfo[d].dst.len = dst_len[d]; + + xferinfo[d].xpose = xpose[d]; + xferinfo[d].flip = flip[d]; + } + + *ierr = Slab_Transfer (cctkGH, *dim, xferinfo, *options, + *srctype, srcptr, *dsttype, dstptr); + + free (xferinfo); +} |