From d77e4fb3d67b829ccac829e92d8293c290bed78c Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 18 Sep 2004 13:40:00 +0000 Subject: Add test routine for hyperslabbing darcs-hash:20040918134055-891bb-2255e545a38dc4a4a87a2b1f9a135ac8ce905790.gz --- Carpet/CarpetTest/interface.ccl | 41 +++++++++++++++++++++++++++ Carpet/CarpetTest/schedule.ccl | 5 ++++ Carpet/CarpetTest/src/make.code.defn | 2 +- Carpet/CarpetTest/src/slabtest.c | 55 ++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 Carpet/CarpetTest/src/slabtest.c (limited to 'Carpet/CarpetTest') diff --git a/Carpet/CarpetTest/interface.ccl b/Carpet/CarpetTest/interface.ccl index d4b58deb4..214ba898a 100644 --- a/Carpet/CarpetTest/interface.ccl +++ b/Carpet/CarpetTest/interface.ccl @@ -3,6 +3,8 @@ implements: CarpetTest + + CCTK_REAL gfg type=GF { gf @@ -27,3 +29,42 @@ CCTK_REAL scg type=SCALAR { sc } "scalar" + + + +CCTK_INT FUNCTION \ + Hyperslab_GlobalMappingByIndex (CCTK_POINTER_TO_CONST IN cctkGH, \ + CCTK_INT IN vindex, \ + CCTK_INT IN hdim, \ + CCTK_INT ARRAY IN direction, \ + CCTK_INT ARRAY IN origin, \ + CCTK_INT ARRAY IN extent, \ + CCTK_INT ARRAY IN downsample, \ + CCTK_INT IN table_handle, \ + CCTK_INT CCTK_FPOINTER IN \ + conversion_fn (CCTK_INT IN nelems, \ + CCTK_INT IN src_stride, \ + CCTK_INT IN dst_stride, \ + CCTK_INT IN src_type, \ + CCTK_INT IN dst_type, \ + CCTK_POINTER_TO_CONST IN from, \ + CCTK_POINTER IN to), \ + CCTK_INT ARRAY OUT hsize) +REQUIRES FUNCTION Hyperslab_GlobalMappingByIndex + +CCTK_INT FUNCTION Hyperslab_FreeMapping (CCTK_INT IN mapping_handle) +REQUIRES FUNCTION Hyperslab_FreeMapping + +CCTK_INT FUNCTION \ + Hyperslab_Get (CCTK_POINTER_TO_CONST IN cctkGH, \ + CCTK_INT IN mapping_handle, \ + CCTK_INT IN proc, \ + CCTK_INT IN vindex, \ + CCTK_INT IN timelevel, \ + CCTK_INT IN hdatatype, \ + CCTK_POINTER IN hdata) +REQUIRES FUNCTION Hyperslab_Get + + + +CCTK_REAL yy TYPE=gf "A copy of y" diff --git a/Carpet/CarpetTest/schedule.ccl b/Carpet/CarpetTest/schedule.ccl index 79efc6f29..d082bea0d 100644 --- a/Carpet/CarpetTest/schedule.ccl +++ b/Carpet/CarpetTest/schedule.ccl @@ -12,3 +12,8 @@ schedule carpettest_check_arguments AT initial { LANG: Fortran } "Check grid function and grid array arguments" + +schedule carpettest_slabtest AT initial +{ + LANG: C +} "Test hyperslabbing" diff --git a/Carpet/CarpetTest/src/make.code.defn b/Carpet/CarpetTest/src/make.code.defn index 51882d30b..20c679952 100644 --- a/Carpet/CarpetTest/src/make.code.defn +++ b/Carpet/CarpetTest/src/make.code.defn @@ -2,7 +2,7 @@ # $Header:$ # Source files in this directory -SRCS = carpettest_check_sizes.c carpettest_check_arguments.F77 +SRCS = carpettest_check_sizes.c carpettest_check_arguments.F77 slabtest.c # Subdirectories containing source files SUBDIRS = diff --git a/Carpet/CarpetTest/src/slabtest.c b/Carpet/CarpetTest/src/slabtest.c new file mode 100644 index 000000000..7b94a08ad --- /dev/null +++ b/Carpet/CarpetTest/src/slabtest.c @@ -0,0 +1,55 @@ +/* $Header$ */ + +#include +#include + +#include "cctk.h" +#include "cctk_Arguments.h" + +void +carpettest_slabtest (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + + int vi; + + CCTK_INT directions[3][3]; + CCTK_INT origin[3]; + CCTK_INT extent[3]; + CCTK_INT hsize[3]; + + int mapping; + + int d, dd; + + int ierr; + + + + assert (CCTK_nProcs(cctkGH) == 1); + + vi = CCTK_VarIndex ("grid::y"); + assert (vi >= 0); + + for (d=0; d<3; ++d) { + for (dd=0; d<3; ++dd) { + directions[d][dd] = d == dd; + } + origin[d] = cctk_lbnd[d]; + extent[d] = cctk_lsh[d]; + } + + mapping = Hyperslab_GlobalMappingByIndex + (cctkGH, vi, 3, &directions[0][0], origin, extent, NULL, -1, NULL, hsize); + assert (mapping >= 0); + + for (d=0; d<3; ++d) { + assert (hsize[d] == cctk_lsh[d]); + } + + ierr = Hyperslab_Get (cctkGH, mapping, -1, vi, 0, CCTK_VARIABLE_REAL, yy); + assert (! ierr); + + ierr = Hyperslab_FreeMapping (mapping); + assert (! ierr); +} -- cgit v1.2.3