diff options
author | schnetter <schnetter@2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8> | 2003-02-28 15:50:25 +0000 |
---|---|---|
committer | schnetter <schnetter@2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8> | 2003-02-28 15:50:25 +0000 |
commit | a49d0b6ae9a948563470998c99e3ea30587efc61 (patch) | |
tree | 4b3b199c17cd31aaf33a169ba718dca21e384960 | |
parent | b2633ed89c2d29f1ff7063c1391125630476bb34 (diff) |
Make it also work with less than three dimensions.
Create a Fortran wrapper.
Create an interface for the Fortran wrapper.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Slab/trunk@14 2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8
-rw-r--r-- | interface.ccl | 1 | ||||
-rw-r--r-- | src/slab.c | 83 | ||||
-rw-r--r-- | src/slab.h | 2 | ||||
-rw-r--r-- | src/slab.inc | 33 |
4 files changed, 117 insertions, 2 deletions
diff --git a/interface.ccl b/interface.ccl index e1bed10..171bc4a 100644 --- a/interface.ccl +++ b/interface.ccl @@ -4,3 +4,4 @@ IMPLEMENTS: Slab INCLUDES HEADER: slab.h IN Slab.h +INCLUDES HEADER: slab.inc IN Slab.inc @@ -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); +} @@ -70,6 +70,8 @@ The source and the destination arrays may be the same. */ +#define SLAB_MAXDIM 3 + struct slabinfo { int gsh; int lbnd, lsh; diff --git a/src/slab.inc b/src/slab.inc new file mode 100644 index 0000000..a0f9bdc --- /dev/null +++ b/src/slab.inc @@ -0,0 +1,33 @@ +! -*-F90-*- +! $Header$ + +interface + subroutine Slab_Transfer (ierr, cctkGH, dim, & + src_gsh, src_lbnd, src_lsh, & + src_lbbox, src_ubbox, src_nghostzones, & + src_off, src_str, src_len, & + dst_gsh, dst_lbnd, dst_lsh, & + dst_lbbox, dst_ubbox, dst_nghostzones, & + dst_off, dst_str, dst_len, & + xpose, flip, & + options, & + srctype, srcptr, & + dsttype, dstptr) + implicit none + integer ierr + CCTK_POINTER cctkGH + integer dim + integer src_gsh, src_lbnd, src_lsh + integer src_lbbox, src_ubbox, src_nghostzones + integer src_off, src_str, src_len + integer dst_gsh, dst_lbnd, dst_lsh + integer dst_lbbox, dst_ubbox, dst_nghostzones + integer dst_off, dst_str, dst_len + integer xpose, flip + integer options + integer srctype + CCTK_POINTER srcptr + integer dsttype + CCTK_POINTER dstptr + end subroutine Slab_Transfer +end interface |