summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-20 16:51:49 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-20 16:51:49 (GMT)
commitde3a870bcd4953a3654b3e9dc92edab86fe858cd (patch)
tree8bf2fc6e0814f67b1388c23136aaff9e4a7cba96 /test
parent98754fa9d12090f5e048fdb05cc5e9ce9111676f (diff)
downloadhdf5-de3a870bcd4953a3654b3e9dc92edab86fe858cd.zip
hdf5-de3a870bcd4953a3654b3e9dc92edab86fe858cd.tar.gz
hdf5-de3a870bcd4953a3654b3e9dc92edab86fe858cd.tar.bz2
[svn-r19110] Description:
Bring r19049:19109 from trunk to revise_chunks branch Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/Makefile.am3
-rw-r--r--test/Makefile.in43
-rw-r--r--test/cache_api.c235
-rw-r--r--test/cache_common.h66
-rw-r--r--test/gen_sizes_lheap.c82
-rw-r--r--test/h5test.h2
-rw-r--r--test/lheap.c26
-rw-r--r--test/testframe.c2
-rw-r--r--test/tselect.c5244
-rw-r--r--test/tsizeslheap.h5bin0 -> 1028 bytes
11 files changed, 5422 insertions, 282 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ae5786a..772466a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -301,6 +301,7 @@ IF (CREATE_GENERATORS)
space_overflow
gen_filespace
gen_specmetaread
+ gen_sizes_lheap
)
FOREACH (gen ${H5_GENERATORS})
diff --git a/test/Makefile.am b/test/Makefile.am
index e556c91..6ca7227 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -64,7 +64,8 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta
# so do not appear in this list.
BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx gen_new_array \
gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \
- gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread
+ gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread \
+ gen_sizes_lheap
if BUILD_ALL_CONDITIONAL
noinst_PROGRAMS=$(BUILD_ALL_PROGS)
diff --git a/test/Makefile.in b/test/Makefile.in
index 2a0b13d..65bdaec 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -100,7 +100,7 @@ am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \
gen_new_super$(EXEEXT) gen_noencoder$(EXEEXT) \
gen_nullspace$(EXEEXT) gen_udlinks$(EXEEXT) \
space_overflow$(EXEEXT) gen_filespace$(EXEEXT) \
- gen_specmetaread$(EXEEXT)
+ gen_specmetaread$(EXEEXT) gen_sizes_lheap$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
app_ref_SOURCES = app_ref.c
app_ref_OBJECTS = app_ref.$(OBJEXT)
@@ -262,6 +262,10 @@ gen_nullspace_SOURCES = gen_nullspace.c
gen_nullspace_OBJECTS = gen_nullspace.$(OBJEXT)
gen_nullspace_LDADD = $(LDADD)
gen_nullspace_DEPENDENCIES = libh5test.la $(LIBHDF5)
+gen_sizes_lheap_SOURCES = gen_sizes_lheap.c
+gen_sizes_lheap_OBJECTS = gen_sizes_lheap.$(OBJEXT)
+gen_sizes_lheap_LDADD = $(LDADD)
+gen_sizes_lheap_DEPENDENCIES = libh5test.la $(LIBHDF5)
gen_specmetaread_SOURCES = gen_specmetaread.c
gen_specmetaread_OBJECTS = gen_specmetaread.$(OBJEXT)
gen_specmetaread_LDADD = $(LDADD)
@@ -405,13 +409,13 @@ SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.c \
gen_bogus.c gen_cross.c gen_deflate.c gen_filespace.c \
gen_filters.c gen_idx.c gen_new_array.c gen_new_fill.c \
gen_new_group.c gen_new_mtime.c gen_new_super.c \
- gen_noencoder.c gen_nullspace.c gen_specmetaread.c \
- gen_udlinks.c getname.c gheap.c hyperslab.c istore.c lheap.c \
- links.c mf.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
- reserved.c set_extent.c space_overflow.c stab.c \
- swmr_generator.c swmr_reader.c swmr_writer.c tcheck_version.c \
- $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
- vfd.c
+ gen_noencoder.c gen_nullspace.c gen_sizes_lheap.c \
+ gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \
+ istore.c lheap.c links.c mf.c mount.c mtime.c ntypes.c \
+ objcopy.c ohdr.c pool.c reserved.c set_extent.c \
+ space_overflow.c stab.c swmr_generator.c swmr_reader.c \
+ swmr_writer.c tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
+ $(ttsafe_SOURCES) unlink.c vfd.c
DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \
btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \
cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \
@@ -420,13 +424,13 @@ DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \
gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \
gen_filespace.c gen_filters.c gen_idx.c gen_new_array.c \
gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \
- gen_noencoder.c gen_nullspace.c gen_specmetaread.c \
- gen_udlinks.c getname.c gheap.c hyperslab.c istore.c lheap.c \
- links.c mf.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
- reserved.c set_extent.c space_overflow.c stab.c \
- swmr_generator.c swmr_reader.c swmr_writer.c tcheck_version.c \
- $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
- vfd.c
+ gen_noencoder.c gen_nullspace.c gen_sizes_lheap.c \
+ gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \
+ istore.c lheap.c links.c mf.c mount.c mtime.c ntypes.c \
+ objcopy.c ohdr.c pool.c reserved.c set_extent.c \
+ space_overflow.c stab.c swmr_generator.c swmr_reader.c \
+ swmr_writer.c tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
+ $(ttsafe_SOURCES) unlink.c vfd.c
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@@ -470,6 +474,7 @@ CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
+CXX_VERSION = @CXX_VERSION@
CYGPATH_W = @CYGPATH_W@
DEBUG_PKG = @DEBUG_PKG@
DEFAULT_API_VERSION = @DEFAULT_API_VERSION@
@@ -495,6 +500,7 @@ FC = @FC@
FCFLAGS = @FCFLAGS@
FCFLAGS_f90 = @FCFLAGS_f90@
FCLIBS = @FCLIBS@
+FC_VERSION = @FC_VERSION@
FGREP = @FGREP@
FILTERS = @FILTERS@
FSEARCH_DIRS = @FSEARCH_DIRS@
@@ -749,7 +755,8 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
# so do not appear in this list.
BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx gen_new_array \
gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \
- gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread
+ gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread \
+ gen_sizes_lheap
# The libh5test library provides common support code for the tests.
@@ -1025,6 +1032,9 @@ gen_noencoder$(EXEEXT): $(gen_noencoder_OBJECTS) $(gen_noencoder_DEPENDENCIES)
gen_nullspace$(EXEEXT): $(gen_nullspace_OBJECTS) $(gen_nullspace_DEPENDENCIES)
@rm -f gen_nullspace$(EXEEXT)
$(LINK) $(gen_nullspace_OBJECTS) $(gen_nullspace_LDADD) $(LIBS)
+gen_sizes_lheap$(EXEEXT): $(gen_sizes_lheap_OBJECTS) $(gen_sizes_lheap_DEPENDENCIES)
+ @rm -f gen_sizes_lheap$(EXEEXT)
+ $(LINK) $(gen_sizes_lheap_OBJECTS) $(gen_sizes_lheap_LDADD) $(LIBS)
gen_specmetaread$(EXEEXT): $(gen_specmetaread_OBJECTS) $(gen_specmetaread_DEPENDENCIES)
@rm -f gen_specmetaread$(EXEEXT)
$(LINK) $(gen_specmetaread_OBJECTS) $(gen_specmetaread_LDADD) $(LIBS)
@@ -1157,6 +1167,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_new_super.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_noencoder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_nullspace.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_sizes_lheap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_specmetaread.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_udlinks.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getname.Po@am__quote@
diff --git a/test/cache_api.c b/test/cache_api.c
index 8fd2912..c6e27c6 100644
--- a/test/cache_api.c
+++ b/test/cache_api.c
@@ -65,11 +65,8 @@ static void check_file_mdc_api_errs(void);
* Programmer: John Mainzer
* 4/12/04
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-
static void
check_fapl_mdc_api_calls(void)
{
@@ -113,7 +110,9 @@ check_fapl_mdc_api_calls(void)
/* int epochs_before_eviction = */ 4,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.05,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
H5AC_cache_config_t scratch;
H5C_auto_size_ctl_t default_auto_size_ctl;
@@ -560,7 +559,9 @@ check_file_mdc_api_calls(void)
/* int epochs_before_eviction = */ 4,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.05,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
H5AC_cache_config_t mod_config_2 =
{
@@ -593,7 +594,9 @@ check_file_mdc_api_calls(void)
/* int epochs_before_eviction = */ 4,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.05,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
H5AC_cache_config_t mod_config_3 =
{
@@ -626,7 +629,9 @@ check_file_mdc_api_calls(void)
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ FALSE,
/* double empty_reserve = */ 0.05,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
H5AC_cache_config_t mod_config_4 =
{
@@ -660,7 +665,9 @@ check_file_mdc_api_calls(void)
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
TESTING("MDC/FILE related API calls");
@@ -915,7 +922,9 @@ mdc_api_call_smoke_check(int express_test)
/* int epochs_before_eviction = */ 2,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.05,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
H5AC_cache_config_t mod_config_2 =
{
@@ -948,7 +957,9 @@ mdc_api_call_smoke_check(int express_test)
/* int epochs_before_eviction = */ 2,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.05,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
H5AC_cache_config_t mod_config_3 =
{
@@ -981,7 +992,9 @@ mdc_api_call_smoke_check(int express_test)
/* int epochs_before_eviction = */ 2,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.05,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
};
TESTING("MDC API smoke check");
@@ -1514,7 +1527,7 @@ mdc_api_call_smoke_check(int express_test)
* used to test error rejection in the MDC related API calls.
*/
-#define NUM_INVALID_CONFIGS 41
+#define NUM_INVALID_CONFIGS 42
H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
{
@@ -1549,7 +1562,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 1 -- bad rpt_fcn_enabled */
@@ -1582,7 +1597,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 2 -- bad open_trace_file */
@@ -1615,7 +1632,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 3 -- bad close_trace_file */
@@ -1648,7 +1667,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 4 -- open_trace_file == TRUE and empty trace_file_name */
@@ -1681,7 +1702,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 5 -- bad set_initial_size */
@@ -1714,7 +1737,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 6 -- max_size too big */
@@ -1747,7 +1772,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 7 -- min_size too small */
@@ -1780,7 +1807,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 8 -- min_size > max_size */
@@ -1813,7 +1842,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 9 -- initial size out of range (too big) */
@@ -1846,7 +1877,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 10 -- initial_size out of range (too small) */
@@ -1879,7 +1912,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 11 -- min_clean_fraction too big */
@@ -1912,7 +1947,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 12 -- min_clean_fraction too small */
@@ -1945,7 +1982,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 13 -- epoch_length too small */
@@ -1978,7 +2017,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 14 -- epoch_length too big */
@@ -2011,7 +2052,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 15 -- invalid incr_mode */
@@ -2044,7 +2087,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 16 -- lower_hr_threshold too small */
@@ -2077,7 +2122,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 17 -- lower_hr_threshold too big */
@@ -2110,7 +2157,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 18 -- increment too small */
@@ -2143,7 +2192,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 19 -- bad apply_max_increment */
@@ -2176,7 +2227,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 20 -- invalid flash_incr_mode */
@@ -2209,7 +2262,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 21 -- flash_multiple too small */
@@ -2242,7 +2297,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 22 -- flash_multiple too big */
@@ -2275,7 +2332,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 23 -- flash_threshold too small */
@@ -2308,7 +2367,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 24 -- flash_threshold too big */
@@ -2341,7 +2402,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 25 -- bad decr_mode */
@@ -2374,7 +2437,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 26 -- upper_hr_threshold too big */
@@ -2407,7 +2472,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 27 -- decrement too small */
@@ -2440,7 +2507,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 28 -- decrement too big */
@@ -2473,7 +2542,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 29 -- epochs_before_eviction too small */
@@ -2506,7 +2577,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 0,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 30 -- epochs_before_eviction too big */
@@ -2539,7 +2612,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ H5C__MAX_EPOCH_MARKERS + 1,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 31 -- invalid apply_empty_reserve */
@@ -2572,7 +2647,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ 2,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 32 -- empty_reserve too small */
@@ -2605,7 +2682,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ -0.0000000001,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 33 -- empty_reserve too big */
@@ -2638,7 +2717,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 1.00000000001,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 34 -- upper_hr_threshold too small */
@@ -2671,7 +2752,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 35 -- upper_hr_threshold too big */
@@ -2704,7 +2787,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 36 -- upper_hr_threshold <= lower_hr_threshold */
@@ -2737,7 +2822,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 37 -- dirty_bytes_threshold too small */
@@ -2770,7 +2857,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (H5C__MIN_MAX_CACHE_SIZE / 2) - 1
+ /* int dirty_bytes_threshold = */ (H5C__MIN_MAX_CACHE_SIZE / 2) - 1,
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 38 -- dirty_bytes_threshold too big */
@@ -2803,7 +2892,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (H5C__MAX_MAX_CACHE_SIZE / 4) + 1
+ /* int dirty_bytes_threshold = */ (H5C__MAX_MAX_CACHE_SIZE / 4) + 1,
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 39 -- attempt to disable evictions when auto incr enabled */
@@ -2836,7 +2927,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
},
{
/* 40 -- attempt to disable evictions when auto decr enabled */
@@ -2869,7 +2962,43 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* int epochs_before_eviction = */ 3,
/* hbool_t apply_empty_reserve = */ TRUE,
/* double empty_reserve = */ 0.1,
- /* int dirty_bytes_threshold = */ (256 * 1024)
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */
+ H5AC__DEFAULT_METADATA_WRITE_STRATEGY
+ },
+ {
+ /* 41 -- unknown metadata write strategy */
+ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
+ /* hbool_t rpt_fcn_enabled = */ FALSE,
+ /* hbool_t open_trace_file = */ FALSE,
+ /* hbool_t close_trace_file = */ FALSE,
+ /* char trace_file_name[] = */ "",
+ /* hbool_t evictions_enabled = */ TRUE,
+ /* hbool_t set_initial_size = */ TRUE,
+ /* size_t initial_size = */ (1 * 1024 * 1024),
+ /* double min_clean_fraction = */ 0.25,
+ /* size_t max_size = */ (16 * 1024 * 1024),
+ /* size_t min_size = */ ( 1 * 1024 * 1024),
+ /* long int epoch_length = */ 50000,
+ /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold,
+ /* double lower_hr_threshold = */ 0.9,
+ /* double increment = */ 2.0,
+ /* hbool_t apply_max_increment = */ TRUE,
+ /* size_t max_increment = */ (4 * 1024 * 1024),
+ /* enum H5C_cache_flash_incr_mode */
+ /* flash_incr_mode = */ H5C_flash_incr__off,
+ /* double flash_multiple = */ 2.0,
+ /* double flash_threshold = */ 0.5,
+ /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold,
+ /* double upper_hr_threshold = */ 0.999,
+ /* double decrement = */ 0.9,
+ /* hbool_t apply_max_decrement = */ TRUE,
+ /* size_t max_decrement = */ (1 * 1024 * 1024),
+ /* int epochs_before_eviction = */ 3,
+ /* hbool_t apply_empty_reserve = */ TRUE,
+ /* double empty_reserve = */ 0.1,
+ /* int dirty_bytes_threshold = */ (256 * 1024),
+ /* int metadata_write_strategy = */ -1
}
};
diff --git a/test/cache_common.h b/test/cache_common.h
index f493239..d7e7f1a 100644
--- a/test/cache_common.h
+++ b/test/cache_common.h
@@ -412,38 +412,40 @@ if ( ( (cache_ptr) == NULL ) || \
/* Macros used in H5AC level tests */
-#define CACHE_CONFIGS_EQUAL(a, b, cmp_set_init, cmp_init_size) \
- ( ( (a).version == (b).version ) && \
- ( (a).rpt_fcn_enabled == (b).rpt_fcn_enabled ) && \
- ( (a).open_trace_file == (b).open_trace_file ) && \
- ( (a).close_trace_file == (b).close_trace_file ) && \
- ( ( (a).open_trace_file == FALSE ) || \
- ( strcmp((a).trace_file_name, (b).trace_file_name) == 0 ) ) && \
- ( (a).evictions_enabled == (b).evictions_enabled ) && \
- ( ( ! cmp_set_init ) || \
- ( (a).set_initial_size == (b).set_initial_size ) ) && \
- ( ( ! cmp_init_size ) || \
- ( (a).initial_size == (b).initial_size ) ) && \
- ( (a).min_clean_fraction == (b).min_clean_fraction ) && \
- ( (a).max_size == (b).max_size ) && \
- ( (a).min_size == (b).min_size ) && \
- ( (a).epoch_length == (b).epoch_length ) && \
- ( (a).incr_mode == (b).incr_mode ) && \
- ( (a).lower_hr_threshold == (b).lower_hr_threshold ) && \
- ( (a).increment == (b).increment ) && \
- ( (a).apply_max_increment == (b).apply_max_increment ) && \
- ( (a).max_increment == (b).max_increment ) && \
- ( (a).flash_incr_mode == (b).flash_incr_mode ) && \
- ( (a).flash_multiple == (b).flash_multiple ) && \
- ( (a).flash_threshold == (b).flash_threshold ) && \
- ( (a).decr_mode == (b).decr_mode ) && \
- ( (a).upper_hr_threshold == (b).upper_hr_threshold ) && \
- ( (a).decrement == (b).decrement ) && \
- ( (a).apply_max_decrement == (b).apply_max_decrement ) && \
- ( (a).max_decrement == (b).max_decrement ) && \
- ( (a).epochs_before_eviction == (b).epochs_before_eviction ) && \
- ( (a).apply_empty_reserve == (b).apply_empty_reserve ) && \
- ( (a).empty_reserve == (b).empty_reserve ) )
+#define CACHE_CONFIGS_EQUAL(a, b, cmp_set_init, cmp_init_size) \
+ ( ( (a).version == (b).version ) && \
+ ( (a).rpt_fcn_enabled == (b).rpt_fcn_enabled ) && \
+ ( (a).open_trace_file == (b).open_trace_file ) && \
+ ( (a).close_trace_file == (b).close_trace_file ) && \
+ ( ( (a).open_trace_file == FALSE ) || \
+ ( strcmp((a).trace_file_name, (b).trace_file_name) == 0 ) ) && \
+ ( (a).evictions_enabled == (b).evictions_enabled ) && \
+ ( ( ! cmp_set_init ) || \
+ ( (a).set_initial_size == (b).set_initial_size ) ) && \
+ ( ( ! cmp_init_size ) || \
+ ( (a).initial_size == (b).initial_size ) ) && \
+ ( (a).min_clean_fraction == (b).min_clean_fraction ) && \
+ ( (a).max_size == (b).max_size ) && \
+ ( (a).min_size == (b).min_size ) && \
+ ( (a).epoch_length == (b).epoch_length ) && \
+ ( (a).incr_mode == (b).incr_mode ) && \
+ ( (a).lower_hr_threshold == (b).lower_hr_threshold ) && \
+ ( (a).increment == (b).increment ) && \
+ ( (a).apply_max_increment == (b).apply_max_increment ) && \
+ ( (a).max_increment == (b).max_increment ) && \
+ ( (a).flash_incr_mode == (b).flash_incr_mode ) && \
+ ( (a).flash_multiple == (b).flash_multiple ) && \
+ ( (a).flash_threshold == (b).flash_threshold ) && \
+ ( (a).decr_mode == (b).decr_mode ) && \
+ ( (a).upper_hr_threshold == (b).upper_hr_threshold ) && \
+ ( (a).decrement == (b).decrement ) && \
+ ( (a).apply_max_decrement == (b).apply_max_decrement ) && \
+ ( (a).max_decrement == (b).max_decrement ) && \
+ ( (a).epochs_before_eviction == (b).epochs_before_eviction ) && \
+ ( (a).apply_empty_reserve == (b).apply_empty_reserve ) && \
+ ( (a).empty_reserve == (b).empty_reserve ) && \
+ ( (a).dirty_bytes_threshold == (b).dirty_bytes_threshold ) && \
+ ( (a).metadata_write_strategy == (b).metadata_write_strategy ) )
#define XLATE_EXT_TO_INT_MDC_CONFIG(i, e) \
{ \
diff --git a/test/gen_sizes_lheap.c b/test/gen_sizes_lheap.c
new file mode 100644
index 0000000..de7e261
--- /dev/null
+++ b/test/gen_sizes_lheap.c
@@ -0,0 +1,82 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Neil Fortner <nfortne2@hdfgroup.org>
+ * Thursday, July 15, 2010
+ *
+ * Purpose: Creates a file with non-default sizes of lengths and addresses.
+ * This is used to make sure that the local heap code is able to
+ * handle this case correctly, even when the heap prefix and data
+ * are contiguous.
+ */
+
+#include "hdf5.h"
+
+#define TESTFILE "tsizeslheap.h5"
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Neil Fortner
+ * Thursday, July 15, 2010
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t file, space, dset, fcpl;
+
+ /* Create the FCPL */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ if(fcpl < 0)
+ printf("fcpl < 0!\n");
+
+ /* Set sizeof_addr and sizeof_size to be 4 */
+ if(H5Pset_sizes(fcpl, 4, 4) < 0)
+ printf("H5Pset_sizes < 0!\n");
+
+ /* Create the file */
+ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
+ if(file < 0)
+ printf("file < 0!\n");
+
+ /* Create the dataspace (for dataset) */
+ space = H5Screate(H5S_SCALAR);
+ if(space < 0)
+ printf("space < 0!\n");
+
+ /* Create the dataset with compound array fields */
+ dset = H5Dcreate2(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if(dset < 0)
+ printf("dset < 0!\n");
+
+ H5Dclose(dset);
+ H5Sclose(space);
+ H5Fclose(file);
+ H5Pclose(fcpl);
+
+ return 0;
+}
diff --git a/test/h5test.h b/test/h5test.h
index f984751..722d850 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -118,7 +118,7 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */
/*
* Alarm definitions to wait up (terminate) a test that runs too long.
*/
-#define alarm_seconds 1200 /* default is 20 minutes */
+#define alarm_seconds 1800 /* default is 30 minutes */
#define ALARM_ON HDalarm(alarm_seconds)
#define ALARM_OFF HDalarm(0)
/* set alarms to N seconds if N > 0, else use default alarm_seconds. */
diff --git a/test/lheap.c b/test/lheap.c
index 1d98fc4..9f78a15 100644
--- a/test/lheap.c
+++ b/test/lheap.c
@@ -20,6 +20,7 @@
* Purpose: Test local heaps used by symbol tables (groups).
*/
#include "h5test.h"
+#include "H5srcdir.h"
#include "H5ACprivate.h"
#include "H5HLprivate.h"
#include "H5Iprivate.h"
@@ -29,6 +30,8 @@ const char *FILENAME[] = {
NULL
};
+#define TESTFILE "tsizeslheap.h5"
+
#define NOBJS 40
@@ -170,6 +173,29 @@ main(void)
if (H5Fclose(file)<0) goto error;
PASSED();
+
+ /* Check opening existing file non-default sizes of lengths and addresses */
+ TESTING("opening pre-created file with non-default sizes");
+ {
+ const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */
+ hid_t dset = -1;
+
+ file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
+ if(file >= 0){
+ if((dset = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+ if(H5Fclose(file) < 0) TEST_ERROR
+ }
+ else {
+ H5_FAILED();
+ printf("***cannot open the pre-created non-default sizes test file (%s)\n",
+ testfile);
+ goto error;
+ } /* end else */
+ }
+ PASSED();
+
puts("All local heap tests passed.");
h5_cleanup(FILENAME, fapl);
diff --git a/test/testframe.c b/test/testframe.c
index f0d94d8..201f569 100644
--- a/test/testframe.c
+++ b/test/testframe.c
@@ -26,7 +26,7 @@
/*
* Definitions for the testing structure.
*/
-#define MAXNUMOFTESTS 45
+#define MAXNUMOFTESTS 50
#define MAXTESTNAME 16
#define MAXTESTDESC 64
diff --git a/test/tselect.c b/test/tselect.c
index b8c59d8..89cd9e5 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -159,6 +159,9 @@
#define SPACERE5_DIM3 12
#define SPACERE5_DIM4 8
+/* #defines for shape same / different rank tests */
+#define SS_DR_MAX_RANK 5
+
/* Location comparison function */
@@ -1585,6 +1588,2031 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist)
HDfree(rbuf);
} /* test_select_hyper_contig3() */
+
+/****************************************************************
+**
+** verify_select_hyper_contig_dr__run_test(): Verify data from
+** test_select_hyper_contig_dr__run_test()
+**
+****************************************************************/
+static void
+verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf,
+ size_t cube_size, unsigned edge_size, unsigned cube_rank)
+{
+ const uint16_t *cube_ptr; /* Pointer into the cube buffer */
+ uint16_t expected_value; /* Expected value in dataset */
+ unsigned i, j, k, l, m; /* Local index variables */
+ size_t s; /* Local index variable */
+ hbool_t mis_match; /* Flag to indicate mis-match in expected value */
+
+ HDassert(cube_buf);
+ HDassert(cube_size > 0);
+
+ expected_value = 0;
+ mis_match = FALSE;
+ cube_ptr = cube_buf;
+ s = 0;
+ i = 0;
+ do {
+ j = 0;
+ do {
+ k = 0;
+ do {
+ l = 0;
+ do {
+ m = 0;
+ do {
+ /* Sanity check */
+ HDassert(s < cube_size);
+
+ /* Check for correct value */
+ if(*cube_ptr != expected_value)
+ mis_match = TRUE;
+
+ /* Advance to next element */
+ cube_ptr++;
+ expected_value++;
+ s++;
+ m++;
+ } while((cube_rank > 0) && (m < edge_size));
+ l++;
+ } while((cube_rank > 1) && (l < edge_size));
+ k++;
+ } while((cube_rank > 2) && (k < edge_size));
+ j++;
+ } while((cube_rank > 3) && (j < edge_size));
+ i++;
+ } while((cube_rank > 4) && (i < edge_size));
+ if(mis_match)
+ TestErrPrintf("Initial cube data don't match! Line = %d\n", __LINE__);
+} /* verify_select_hyper_contig_dr__run_test() */
+
+
+/****************************************************************
+**
+** test_select_hyper_contig_dr__run_test(): Test H5S (dataspace)
+** selection code with contiguous source and target having
+** different ranks but the same shape. We have already
+** tested H5S_shape_same in isolation, so now we try to do
+** I/O.
+**
+****************************************************************/
+static void
+test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf,
+ const uint16_t *zero_buf, unsigned edge_size, unsigned chunk_edge_size,
+ unsigned small_rank, unsigned large_rank, hid_t dset_type, hid_t xfer_plist)
+{
+ hbool_t mis_match; /* Flag indicating a value read in wasn't what was expected */
+ hid_t fapl; /* File access property list */
+ hid_t fid1; /* File ID */
+ hid_t small_cube_sid; /* Dataspace ID for small cube in memory & file */
+ hid_t mem_large_cube_sid; /* Dataspace ID for large cube in memory */
+ hid_t file_large_cube_sid; /* Dataspace ID for large cube in file */
+ hid_t small_cube_dcpl_id = H5P_DEFAULT; /* DCPL for small cube dataset */
+ hid_t large_cube_dcpl_id = H5P_DEFAULT; /* DCPL for large cube dataset */
+ hid_t small_cube_dataset; /* Dataset ID */
+ hid_t large_cube_dataset; /* Dataset ID */
+ size_t start_index; /* Offset within buffer to begin inspecting */
+ size_t stop_index; /* Offset within buffer to end inspecting */
+ uint16_t expected_value; /* Expected value in dataset */
+ uint16_t * small_cube_buf_1; /* Buffer for small cube data */
+ uint16_t * large_cube_buf_1; /* Buffer for large cube data */
+ uint16_t * ptr_1; /* Temporary pointer into cube data */
+ hsize_t dims[SS_DR_MAX_RANK]; /* Dataspace dimensions */
+ hsize_t start[SS_DR_MAX_RANK]; /* Shared hyperslab start offset */
+ hsize_t stride[SS_DR_MAX_RANK]; /* Shared hyperslab stride */
+ hsize_t count[SS_DR_MAX_RANK]; /* Shared hyperslab count */
+ hsize_t block[SS_DR_MAX_RANK]; /* Shared hyperslab block size */
+ hsize_t * start_ptr; /* Actual hyperslab start offset */
+ hsize_t * stride_ptr; /* Actual hyperslab stride */
+ hsize_t * count_ptr; /* Actual hyperslab count */
+ hsize_t * block_ptr; /* Actual hyperslab block size */
+ size_t small_cube_size; /* Number of elements in small cube */
+ size_t large_cube_size; /* Number of elements in large cube */
+ unsigned u, v, w, x; /* Local index variables */
+ size_t s; /* Local index variable */
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ MESSAGE(7, ("\tn-cube slice through m-cube I/O test %d.\n", test_num));
+ MESSAGE(7, ("\tranks = %u/%u, edge_size = %u, chunk_edge_size = %u.\n", small_rank, large_rank, edge_size, chunk_edge_size));
+
+ HDassert(edge_size >= 6);
+ HDassert(edge_size >= chunk_edge_size);
+ HDassert((chunk_edge_size == 0) || (chunk_edge_size >= 3));
+ HDassert(small_rank > 0);
+ HDassert(small_rank < large_rank);
+ HDassert(large_rank <= SS_DR_MAX_RANK);
+
+ /* Compute cube sizes */
+ small_cube_size = large_cube_size = (size_t)1;
+ for(u = 0; u < large_rank; u++) {
+ if(u < small_rank)
+ small_cube_size *= (size_t)edge_size;
+
+ large_cube_size *= (size_t)edge_size;
+ } /* end for */
+
+ HDassert(large_cube_size < (size_t)UINT_MAX);
+
+ /* set up the start, stride, count, and block pointers */
+ start_ptr = &(start[SS_DR_MAX_RANK - large_rank]);
+ stride_ptr = &(stride[SS_DR_MAX_RANK - large_rank]);
+ count_ptr = &(count[SS_DR_MAX_RANK - large_rank]);
+ block_ptr = &(block[SS_DR_MAX_RANK - large_rank]);
+
+ /* Allocate buffers */
+ small_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), small_cube_size);
+ CHECK(small_cube_buf_1, NULL, "HDcalloc");
+ large_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), large_cube_size);
+ CHECK(large_cube_buf_1, NULL, "HDcalloc");
+
+ /* Create a dataset transfer property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Use the 'core' VFD for this test */
+ ret = H5Pset_fapl_core(fapl, (size_t)(1024 * 1024), FALSE);
+ CHECK(ret, FAIL, "H5Pset_fapl_core");
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Close file access property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* setup dims: */
+ dims[0] = dims[1] = dims[2] = dims[3] = dims[4] = (hsize_t)edge_size;
+
+ /* Create small cube dataspaces */
+ small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
+ CHECK(small_cube_sid, FAIL, "H5Screate_simple");
+
+ /* Create large cube dataspace */
+ mem_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
+ CHECK(mem_large_cube_sid, FAIL, "H5Screate_simple");
+ file_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
+ CHECK(file_large_cube_sid, FAIL, "H5Screate_simple");
+
+ /* if chunk edge size is greater than zero, set up the small and
+ * large data set creation property lists to specify chunked
+ * datasets.
+ */
+ if(chunk_edge_size > 0) {
+ hsize_t chunk_dims[SS_DR_MAX_RANK]; /* Chunk dimensions */
+
+ chunk_dims[0] = chunk_dims[1] =
+ chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = (hsize_t)chunk_edge_size;
+
+ small_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(small_cube_dcpl_id, FAIL, "H5Pcreate");
+
+ ret = H5Pset_layout(small_cube_dcpl_id, H5D_CHUNKED);
+ CHECK(ret, FAIL, "H5Pset_layout");
+
+ ret = H5Pset_chunk(small_cube_dcpl_id, (int)small_rank, chunk_dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+
+
+ large_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(large_cube_dcpl_id, FAIL, "H5Pcreate");
+
+ ret = H5Pset_layout(large_cube_dcpl_id, H5D_CHUNKED);
+ CHECK(ret, FAIL, "H5Pset_layout");
+
+ ret = H5Pset_chunk(large_cube_dcpl_id, (int)large_rank, chunk_dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+ } /* end if */
+
+ /* create the small cube dataset */
+ small_cube_dataset = H5Dcreate2(fid1, "small_cube_dataset", dset_type,
+ small_cube_sid, H5P_DEFAULT, small_cube_dcpl_id, H5P_DEFAULT);
+ CHECK(small_cube_dataset, FAIL, "H5Dcreate2");
+
+ /* Close non-default small dataset DCPL */
+ if(small_cube_dcpl_id != H5P_DEFAULT) {
+ ret = H5Pclose(small_cube_dcpl_id);
+ CHECK(ret, FAIL, "H5Pclose");
+ } /* end if */
+
+ /* create the large cube dataset */
+ large_cube_dataset = H5Dcreate2(fid1, "large_cube_dataset", dset_type,
+ file_large_cube_sid, H5P_DEFAULT, large_cube_dcpl_id, H5P_DEFAULT);
+ CHECK(large_cube_dataset, FAIL, "H5Dcreate2");
+
+ /* Close non-default large dataset DCPL */
+ if(large_cube_dcpl_id != H5P_DEFAULT) {
+ ret = H5Pclose(large_cube_dcpl_id);
+ CHECK(ret, FAIL, "H5Pclose");
+ } /* end if */
+
+
+ /* write initial data to the on disk datasets */
+ ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid,
+ small_cube_sid, xfer_plist, cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid,
+ file_large_cube_sid, xfer_plist, cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* read initial data from disk and verify that it is as expected. */
+ ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid,
+ small_cube_sid, xfer_plist, small_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check that the data is valid */
+ verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size,
+ edge_size, small_rank);
+
+ ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid,
+ file_large_cube_sid, xfer_plist, large_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check that the data is valid */
+ verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size,
+ edge_size, large_rank);
+
+
+ /* first, verify that we can read from disk correctly using selections
+ * of different rank that H5S_select_shape_same() views as being of the
+ * same shape.
+ *
+ * Start by reading small_rank-D slice from the on disk large cube, and
+ * verifying that the data read is correct. Verify that H5S_select_shape_same()
+ * returns true on the memory and file selections.
+ */
+
+
+ /* set up start, stride, count, and block -- note that we will
+ * change start[] so as to read slices of the large cube.
+ */
+ for(u = 0; u < SS_DR_MAX_RANK; u++) {
+ start[u] = 0;
+ stride[u] = 1;
+ count[u] = 1;
+ if((SS_DR_MAX_RANK - u) > small_rank)
+ block[u] = 1;
+ else
+ block[u] = (hsize_t)edge_size;
+ } /* end for */
+
+ u = 0;
+ do {
+ v = 0;
+ do {
+ w = 0;
+ do {
+ x = 0;
+ do {
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+ start[0] = (hsize_t)u;
+ start[1] = (hsize_t)v;
+ start[2] = (hsize_t)w;
+ start[3] = (hsize_t)x;
+ start[4] = (hsize_t)0;
+
+ ret = H5Sselect_hyperslab(file_large_cube_sid,
+ H5S_SELECT_SET,
+ start_ptr,
+ stride_ptr,
+ count_ptr,
+ block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* verify that H5S_select_shape_same() reports the two
+ * selections as having the same shape.
+ */
+ check = H5S_select_shape_same_test(small_cube_sid,
+ file_large_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ /* Read selection from disk */
+ ret = H5Dread(large_cube_dataset,
+ H5T_NATIVE_UINT16,
+ small_cube_sid,
+ file_large_cube_sid,
+ xfer_plist,
+ small_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* verify that expected data is retrieved */
+ mis_match = FALSE;
+ ptr_1 = small_cube_buf_1;
+ expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size));
+ for(s = 0; s < small_cube_size; s++ ) {
+ if(*ptr_1 != expected_value )
+ mis_match = TRUE;
+ ptr_1++;
+ expected_value++;
+ } /* end for */
+ if(mis_match)
+ TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__);
+
+ x++;
+ } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
+ w++;
+ } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
+ v++;
+ } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
+ u++;
+ } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));
+
+
+ /* similarly, read the on disk small cube into slices through the in memory
+ * large cube, and verify that the correct data (and only the correct data)
+ * is read.
+ */
+
+ /* zero out the in-memory large cube */
+ HDmemset(large_cube_buf_1, 0, large_cube_size * sizeof(uint16_t));
+
+ u = 0;
+ do {
+ v = 0;
+ do {
+ w = 0;
+ do {
+ x = 0;
+ do {
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+ start[0] = (hsize_t)u;
+ start[1] = (hsize_t)v;
+ start[2] = (hsize_t)w;
+ start[3] = (hsize_t)x;
+ start[4] = (hsize_t)0;
+
+ ret = H5Sselect_hyperslab(mem_large_cube_sid,
+ H5S_SELECT_SET,
+ start_ptr,
+ stride_ptr,
+ count_ptr,
+ block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* verify that H5S_select_shape_same() reports the two
+ * selections as having the same shape.
+ */
+ check = H5S_select_shape_same_test(small_cube_sid,
+ mem_large_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+
+ /* Read selection from disk */
+ ret = H5Dread(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ mem_large_cube_sid,
+ small_cube_sid,
+ xfer_plist,
+ large_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+
+ /* verify that the expected data and only the
+ * expected data was read.
+ */
+ start_index = (u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size);
+ stop_index = start_index + small_cube_size - 1;
+
+ HDassert(start_index < stop_index);
+ HDassert(stop_index <= large_cube_size);
+
+ mis_match = FALSE;
+ ptr_1 = large_cube_buf_1;
+ expected_value = 0;
+ for(s = 0; s < start_index; s++) {
+ if(*ptr_1 != 0)
+ mis_match = TRUE;
+ ptr_1++;
+ } /* end for */
+ for(; s <= stop_index; s++) {
+ if(*ptr_1 != expected_value)
+ mis_match = TRUE;
+ expected_value++;
+ ptr_1++;
+ } /* end for */
+ for(; s < large_cube_size; s++) {
+ if(*ptr_1 != 0)
+ mis_match = TRUE;
+ ptr_1++;
+ } /* end for */
+ if(mis_match)
+ TestErrPrintf("large cube read from small cube has bad data! Line=%u\n", __LINE__);
+
+ /* Zero out the buffer for the next pass */
+ HDmemset(large_cube_buf_1 + start_index, 0, small_cube_size * sizeof(uint16_t));
+
+ x++;
+ } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
+ w++;
+ } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
+ v++;
+ } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
+ u++;
+ } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));
+
+
+ /* now we go in the opposite direction, verifying that we can write
+ * from memory to file using selections of different rank that
+ * H5S_select_shape_same() views as being of the same shape.
+ *
+ * Start by writing small_rank D slices from the in memory large cube, to
+ * the the on disk small cube dataset. After each write, read the small
+ * cube dataset back from disk, and verify that it contains the expected
+ * data. Verify that H5S_select_shape_same() returns true on the
+ * memory and file selections.
+ */
+
+ u = 0;
+ do {
+ v = 0;
+ do {
+ w = 0;
+ do {
+ x = 0;
+ do {
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+
+ /* zero out the on disk small cube */
+ ret = H5Dwrite(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ small_cube_sid,
+ small_cube_sid,
+ xfer_plist,
+ zero_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* select the portion of the in memory large cube from which we
+ * are going to write data.
+ */
+ start[0] = (hsize_t)u;
+ start[1] = (hsize_t)v;
+ start[2] = (hsize_t)w;
+ start[3] = (hsize_t)x;
+ start[4] = (hsize_t)0;
+
+ ret = H5Sselect_hyperslab(mem_large_cube_sid,
+ H5S_SELECT_SET,
+ start_ptr,
+ stride_ptr,
+ count_ptr,
+ block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* verify that H5S_select_shape_same() reports the in
+ * memory slice through the cube selection and the
+ * on disk full small cube selections as having the same shape.
+ */
+ check = H5S_select_shape_same_test(small_cube_sid,
+ mem_large_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+
+ /* write the slice from the in memory large cube to the on disk small cube */
+ ret = H5Dwrite(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ mem_large_cube_sid,
+ small_cube_sid,
+ xfer_plist,
+ cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+
+ /* read the on disk small cube into memory */
+ ret = H5Dread(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ small_cube_sid,
+ small_cube_sid,
+ xfer_plist,
+ small_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+
+ /* verify that expected data is retrieved */
+ mis_match = FALSE;
+ ptr_1 = small_cube_buf_1;
+ expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size));
+ for(s = 0; s < small_cube_size; s++) {
+ if(*ptr_1 != expected_value)
+ mis_match = TRUE;
+ expected_value++;
+ ptr_1++;
+ } /* end for */
+ if(mis_match )
+ TestErrPrintf("small cube data don't match! Line=%d\n",__LINE__);
+
+ x++;
+ } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
+ w++;
+ } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
+ v++;
+ } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
+ u++;
+ } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));
+
+
+ /* Now write the contents of the in memory small cube to slices of
+ * the on disk cube. After each write, read the on disk cube
+ * into memeory, and verify that it contains the expected
+ * data. Verify that H5S_select_shape_same() returns true on
+ * the memory and file selections.
+ */
+
+ /* select the entire memory and file cube dataspaces */
+ ret = H5Sselect_all(mem_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sselect_all");
+
+ ret = H5Sselect_all(file_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sselect_all");
+
+ u = 0;
+ do {
+ v = 0;
+ do {
+ w = 0;
+ do {
+ x = 0;
+ do {
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+
+ /* zero out the on disk cube */
+ ret = H5Dwrite(large_cube_dataset,
+ H5T_NATIVE_USHORT,
+ mem_large_cube_sid,
+ file_large_cube_sid,
+ xfer_plist,
+ zero_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+
+ /* select the portion of the in memory large cube to which we
+ * are going to write data.
+ */
+ start[0] = (hsize_t)u;
+ start[1] = (hsize_t)v;
+ start[2] = (hsize_t)w;
+ start[3] = (hsize_t)x;
+ start[4] = (hsize_t)0;
+
+ ret = H5Sselect_hyperslab(file_large_cube_sid,
+ H5S_SELECT_SET,
+ start_ptr,
+ stride_ptr,
+ count_ptr,
+ block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* verify that H5S_select_shape_same() reports the in
+ * memory full selection of the small cube and the
+ * on disk slice through the large cube selection
+ * as having the same shape.
+ */
+ check = H5S_select_shape_same_test(small_cube_sid,
+ file_large_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+
+ /* write the cube from memory to the target slice of the disk cube */
+ ret = H5Dwrite(large_cube_dataset,
+ H5T_NATIVE_UINT16,
+ small_cube_sid,
+ file_large_cube_sid,
+ xfer_plist,
+ cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+
+ /* read the on disk cube into memory */
+ ret = H5Sselect_all(file_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sselect_all");
+
+ ret = H5Dread(large_cube_dataset,
+ H5T_NATIVE_UINT16,
+ mem_large_cube_sid,
+ file_large_cube_sid,
+ xfer_plist,
+ large_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+
+ /* verify that the expected data and only the
+ * expected data was read.
+ */
+ start_index = (u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size);
+ stop_index = start_index + small_cube_size - 1;
+
+ HDassert(start_index < stop_index);
+ HDassert(stop_index <= large_cube_size);
+
+ mis_match = FALSE;
+ ptr_1 = large_cube_buf_1;
+ expected_value = 0;
+ for(s = 0; s < start_index; s++) {
+ if(*ptr_1 != 0)
+ mis_match = TRUE;
+ ptr_1++;
+ } /* end for */
+ for(; s <= stop_index; s++) {
+ if(*ptr_1 != expected_value)
+ mis_match = TRUE;
+ expected_value++;
+ ptr_1++;
+ } /* end for */
+ for(; s < large_cube_size; s++) {
+ if(*ptr_1 != 0)
+ mis_match = TRUE;
+ ptr_1++;
+ } /* end for */
+ if(mis_match)
+ TestErrPrintf("large cube written from small cube has bad data! Line=%d\n", __LINE__);
+
+ x++;
+ } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
+ w++;
+ } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
+ v++;
+ } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
+ u++;
+ } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));
+
+ /* Close memory dataspaces */
+ ret = H5Sclose(small_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(mem_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ /* Close disk dataspace */
+ ret = H5Sclose(file_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ /* Close Datasets */
+ ret = H5Dclose(small_cube_dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Dclose(large_cube_dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Free memory buffers */
+ HDfree(small_cube_buf_1);
+ HDfree(large_cube_buf_1);
+
+} /* test_select_hyper_contig_dr__run_test() */
+
+
+/****************************************************************
+**
+** test_select_hyper_contig_dr(): Test H5S (dataspace)
+** selection code with contiguous source and target having
+** different ranks but the same shape. We have already
+** tested H5S_shape_same in isolation, so now we try to do
+** I/O.
+**
+****************************************************************/
+static void
+test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist)
+{
+ int test_num = 0;
+ unsigned chunk_edge_size; /* Size of chunk's dataspace dimensions */
+ unsigned edge_size = 6; /* Size of dataset's dataspace dimensions */
+ unsigned small_rank; /* Current rank of small dataset */
+ unsigned large_rank; /* Current rank of large dataset */
+ uint16_t *cube_buf; /* Buffer for writing cube data */
+ uint16_t *zero_buf; /* Buffer for writing zeroed cube data */
+ uint16_t *cube_ptr; /* Temporary pointer into cube data */
+ unsigned max_rank = 5; /* Max. rank to use */
+ size_t max_cube_size; /* Max. number of elements in largest cube */
+ size_t s; /* Local index variable */
+ unsigned u; /* Local index variable */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Contiguous Hyperslabs With Different Rank I/O Functionality\n"));
+
+ /* Compute max. cube size */
+ max_cube_size = (size_t)1;
+ for(u = 0; u < max_rank; u++)
+ max_cube_size *= (size_t)edge_size;
+
+ /* Allocate cube buffer for writing values */
+ cube_buf = (uint16_t *)HDmalloc(sizeof(uint16_t) * max_cube_size);
+ CHECK(cube_buf, NULL, "HDmalloc");
+
+ /* Initialize the cube buffer */
+ cube_ptr = cube_buf;
+ for(s = 0; s < max_cube_size; s++)
+ *cube_ptr++ = (uint16_t)s;
+
+ /* Allocate cube buffer for zeroing values on disk */
+ zero_buf = (uint16_t *)HDcalloc(sizeof(uint16_t), max_cube_size);
+ CHECK(zero_buf, NULL, "HDcalloc");
+
+ for(large_rank = 1; large_rank <= max_rank; large_rank++) {
+ for(small_rank = 1; small_rank < large_rank; small_rank++) {
+ chunk_edge_size = 0;
+ test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf,
+ edge_size, chunk_edge_size, small_rank, large_rank,
+ dset_type, xfer_plist);
+ test_num++;
+
+ chunk_edge_size = 3;
+ test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf,
+ edge_size, chunk_edge_size, small_rank, large_rank,
+ dset_type, xfer_plist);
+ test_num++;
+ } /* for loop on small rank */
+ } /* for loop on large rank */
+
+ HDfree(cube_buf);
+ HDfree(zero_buf);
+
+} /* test_select_hyper_contig_dr() */
+
+
+/****************************************************************
+**
+** test_select_hyper_checker_board_dr__select_checker_board():
+** Given an n-cube data space with each edge of length
+** edge_size, and a checker_edge_size either select a checker
+** board selection of the entire cube(if sel_rank == n),
+** or select a checker board selection of a
+** sel_rank dimensional slice through n-cube parallel to the
+** sel_rank fastest changing indices, with origin (in the
+** higher indices) as indicated by the start array.
+**
+** Note that this function, like all its relatives, is
+** hard coded to presume a maximum n-cube rank of 5.
+** While this maximum is declared as a constant, increasing
+** it will require extensive coding in addition to changing
+** the value of the constant.
+**
+** JRM -- 9/9/09
+**
+****************************************************************/
+static void
+test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid,
+ unsigned tgt_n_cube_rank, unsigned edge_size, unsigned checker_edge_size,
+ unsigned sel_rank, hsize_t sel_start[])
+{
+ hbool_t first_selection = TRUE;
+ unsigned n_cube_offset;
+ unsigned sel_offset;
+ hsize_t base_count;
+ hsize_t offset_count;
+ hsize_t start[SS_DR_MAX_RANK]; /* Offset of hyperslab selection */
+ hsize_t stride[SS_DR_MAX_RANK]; /* Stride of hyperslab selection */
+ hsize_t count[SS_DR_MAX_RANK]; /* Count of hyperslab selection */
+ hsize_t block[SS_DR_MAX_RANK]; /* Block size of hyperslab selection */
+ unsigned i, j, k, l, m; /* Local index variable */
+ unsigned u; /* Local index variables */
+ herr_t ret; /* Generic return value */
+
+ HDassert(edge_size >= 6);
+ HDassert(0 < checker_edge_size);
+ HDassert(checker_edge_size <= edge_size);
+ HDassert(0 < sel_rank);
+ HDassert(sel_rank <= tgt_n_cube_rank);
+ HDassert(tgt_n_cube_rank <= SS_DR_MAX_RANK);
+
+ sel_offset = SS_DR_MAX_RANK - sel_rank;
+ n_cube_offset = SS_DR_MAX_RANK - tgt_n_cube_rank;
+ HDassert(n_cube_offset <= sel_offset);
+
+ /* First, compute the base count (which assumes start == 0
+ * for the associated offset) and offset_count (which
+ * assumes start == checker_edge_size for the associated
+ * offset).
+ */
+ base_count = edge_size / (checker_edge_size * 2);
+ if((edge_size % (checker_edge_size * 2)) > 0)
+ base_count++;
+
+ offset_count = (edge_size - checker_edge_size) / (checker_edge_size * 2);
+ if(((edge_size - checker_edge_size) % (checker_edge_size * 2)) > 0)
+ offset_count++;
+
+ /* Now set up the stride and block arrays, and portions of the start
+ * and count arrays that will not be altered during the selection of
+ * the checker board.
+ */
+ u = 0;
+ while(u < n_cube_offset) {
+ /* these values should never be used */
+ start[u] = 0;
+ stride[u] = 0;
+ count[u] = 0;
+ block[u] = 0;
+
+ u++;
+ } /* end while */
+
+ while(u < sel_offset) {
+ start[u] = sel_start[u];
+ stride[u] = 2 * edge_size;
+ count[u] = 1;
+ block[u] = 1;
+
+ u++;
+ } /* end while */
+
+ while(u < SS_DR_MAX_RANK) {
+ stride[u] = 2 * checker_edge_size;
+ block[u] = checker_edge_size;
+
+ u++;
+ } /* end while */
+
+ i = 0;
+ do {
+ if(0 >= sel_offset) {
+ if(i == 0) {
+ start[0] = 0;
+ count[0] = base_count;
+ } /* end if */
+ else {
+ start[0] = checker_edge_size;
+ count[0] = offset_count;
+ } /* end else */
+ } /* end if */
+
+ j = 0;
+ do {
+ if(1 >= sel_offset) {
+ if(j == 0 ) {
+ start[1] = 0;
+ count[1] = base_count;
+ } /* end if */
+ else {
+ start[1] = checker_edge_size;
+ count[1] = offset_count;
+ } /* end else */
+ } /* end if */
+
+ k = 0;
+ do {
+ if(2 >= sel_offset) {
+ if(k == 0) {
+ start[2] = 0;
+ count[2] = base_count;
+ } /* end if */
+ else {
+ start[2] = checker_edge_size;
+ count[2] = offset_count;
+ } /* end else */
+ } /* end if */
+
+ l = 0;
+ do {
+ if(3 >= sel_offset) {
+ if(l == 0) {
+ start[3] = 0;
+ count[3] = base_count;
+ } /* end if */
+ else {
+ start[3] = checker_edge_size;
+ count[3] = offset_count;
+ } /* end else */
+ } /* end if */
+
+ m = 0;
+ do {
+ if(4 >= sel_offset) {
+ if(m == 0) {
+ start[4] = 0;
+ count[4] = base_count;
+ } /* end if */
+ else {
+ start[4] = checker_edge_size;
+ count[4] = offset_count;
+ } /* end else */
+ } /* end if */
+
+ if(((i + j + k + l + m) % 2) == 0) {
+ if(first_selection) {
+ first_selection = FALSE;
+
+ ret = H5Sselect_hyperslab(tgt_n_cube_sid,
+ H5S_SELECT_SET,
+ &(start[n_cube_offset]),
+ &(stride[n_cube_offset]),
+ &(count[n_cube_offset]),
+ &(block[n_cube_offset]));
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+ } /* end if */
+ else {
+ ret = H5Sselect_hyperslab(tgt_n_cube_sid,
+ H5S_SELECT_OR,
+ &(start[n_cube_offset]),
+ &(stride[n_cube_offset]),
+ &(count[n_cube_offset]),
+ &(block[n_cube_offset]));
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+ } /* end else */
+ } /* end if */
+
+ m++;
+ } while((m <= 1) && (4 >= sel_offset));
+ l++;
+ } while((l <= 1) && (3 >= sel_offset));
+ k++;
+ } while((k <= 1) && (2 >= sel_offset));
+ j++;
+ } while((j <= 1) && (1 >= sel_offset));
+ i++;
+ } while((i <= 1) && (0 >= sel_offset));
+
+ /* Wierdness alert:
+ *
+ * Some how, it seems that selections can extend beyond the
+ * boundaries of the target data space -- hence the following
+ * code to manually clip the selection back to the data space
+ * proper.
+ */
+ for(u = 0; u < SS_DR_MAX_RANK; u++) {
+ start[u] = 0;
+ stride[u] = edge_size;
+ count[u] = 1;
+ block[u] = edge_size;
+ } /* end for */
+
+ ret = H5Sselect_hyperslab(tgt_n_cube_sid, H5S_SELECT_AND, start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+} /* test_select_hyper_checker_board_dr__select_checker_board() */
+
+
+/****************************************************************
+**
+** test_select_hyper_checker_board_dr__verify_data():
+**
+** Examine the supplied buffer to see if it contains the
+** expected data. Return TRUE if it does, and FALSE
+** otherwise.
+**
+** The supplied buffer is presumed to contain the results
+** of read or writing a checkerboard selection of an
+** n-cube, or a checkerboard selection of an m (1 <= m < n)
+** dimensional slice through an n-cube parallel to the
+** fastest changing indices.
+**
+** It is further presumed that the buffer was zeroed before
+** the read, and that the n-cube was initialize with the
+** natural numbers listed in order from the origin along
+** the fastest changing axis.
+**
+** Thus for a 10x10x10 3-cube, the value stored in location
+** (x, y, z) (assuming that z is the fastest changing index
+** and x the slowest) is assumed to be:
+**
+** (10 * 10 * x) + (10 * y) + z
+**
+** Thus, if the buffer contains the result of reading a
+** checker board selection of a 10x10x10 3-cube, location
+** (x, y, z) will contain zero if it is not in a checker,
+** and 100x + 10y + z if (x, y, z) is in a checker.
+**
+** If the buffer contains the result of reading a 3
+** dimensional slice (parallel to the three fastest changing
+** indices) through an n cube (n > 3), then the expected
+** values in the buffer will be the same, save that we will
+** add a constant determined by the origin of the 3-cube
+** in the n-cube.
+**
+** Finally, the function presumes that the first element
+** of the buffer resides either at the origin of either
+** a selected or an unselected checker.
+**
+****************************************************************/
+static hbool_t
+test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr,
+ unsigned rank, unsigned edge_size, unsigned checker_edge_size,
+ uint16_t first_expected_val, hbool_t buf_starts_in_checker)
+{
+ hbool_t good_data = TRUE;
+ hbool_t in_checker;
+ hbool_t start_in_checker[5];
+ uint16_t expected_value;
+ uint16_t * val_ptr;
+ unsigned i, j, k, l, m; /* to track position in n-cube */
+ unsigned v, w, x, y, z; /* to track position in checker */
+ const unsigned test_max_rank = 5; /* code changes needed if this is increased */
+
+ HDassert(buf_ptr != NULL);
+ HDassert(0 < rank);
+ HDassert(rank <= test_max_rank);
+ HDassert(edge_size >= 6);
+ HDassert(0 < checker_edge_size);
+ HDassert(checker_edge_size <= edge_size);
+ HDassert(test_max_rank <= SS_DR_MAX_RANK);
+
+ val_ptr = buf_ptr;
+ expected_value = first_expected_val;
+
+ i = 0;
+ v = 0;
+ start_in_checker[0] = buf_starts_in_checker;
+ do {
+ if(v >= checker_edge_size) {
+ start_in_checker[0] = !start_in_checker[0];
+ v = 0;
+ } /* end if */
+
+ j = 0;
+ w = 0;
+ start_in_checker[1] = start_in_checker[0];
+ do {
+ if(w >= checker_edge_size) {
+ start_in_checker[1] = !start_in_checker[1];
+ w = 0;
+ } /* end if */
+
+ k = 0;
+ x = 0;
+ start_in_checker[2] = start_in_checker[1];
+ do {
+ if(x >= checker_edge_size) {
+ start_in_checker[2] = !start_in_checker[2];
+ x = 0;
+ } /* end if */
+
+ l = 0;
+ y = 0;
+ start_in_checker[3] = start_in_checker[2];
+ do {
+ if(y >= checker_edge_size) {
+ start_in_checker[3] = ! start_in_checker[3];
+ y = 0;
+ } /* end if */
+
+ m = 0;
+ z = 0;
+ in_checker = start_in_checker[3];
+ do {
+ if(z >= checker_edge_size) {
+ in_checker = ! in_checker;
+ z = 0;
+ } /* end if */
+
+ if(in_checker) {
+ if(*val_ptr != expected_value)
+ good_data = FALSE;
+ } /* end if */
+ else {
+ if(*val_ptr != 0)
+ good_data = FALSE;
+ } /* end else */
+
+ val_ptr++;
+ expected_value++;
+
+ m++;
+ z++;
+ } while((rank >= (test_max_rank - 4)) && (m < edge_size));
+ l++;
+ y++;
+ } while((rank >= (test_max_rank - 3)) && (l < edge_size));
+ k++;
+ x++;
+ } while((rank >= (test_max_rank - 2)) && (k < edge_size));
+ j++;
+ w++;
+ } while((rank >= (test_max_rank - 1)) && (j < edge_size));
+ i++;
+ v++;
+ } while((rank >= test_max_rank) && (i < edge_size));
+
+ return(good_data);
+} /* test_select_hyper_checker_board_dr__verify_data() */
+
+
+/****************************************************************
+**
+** test_select_hyper_checker_board_dr__run_test(): Test H5S
+** (dataspace) selection code with checker board source and
+** target selections having different ranks but the same
+** shape. We have already tested H5S_shape_same in
+** isolation, so now we try to do I/O.
+**
+****************************************************************/
+static void
+test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_buf,
+ const uint16_t *zero_buf, unsigned edge_size, unsigned checker_edge_size,
+ unsigned chunk_edge_size, unsigned small_rank, unsigned large_rank,
+ hid_t dset_type, hid_t xfer_plist)
+{
+ hbool_t data_ok;
+ hbool_t start_in_checker[5];
+ hid_t fapl; /* File access property list */
+ hid_t fid; /* HDF5 File IDs */
+ hid_t full_small_cube_sid; /* Dataspace for small cube w/all selection */
+ hid_t mem_small_cube_sid;
+ hid_t file_small_cube_sid;
+ hid_t full_large_cube_sid; /* Dataspace for large cube w/all selection */
+ hid_t mem_large_cube_sid;
+ hid_t file_large_cube_sid;
+ hid_t small_cube_dcpl_id = H5P_DEFAULT; /* DCPL for small cube dataset */
+ hid_t large_cube_dcpl_id = H5P_DEFAULT; /* DCPL for large cube dataset */
+ hid_t small_cube_dataset; /* Dataset ID */
+ hid_t large_cube_dataset; /* Dataset ID */
+ unsigned small_rank_offset; /* Rank offset of slice */
+ const unsigned test_max_rank = 5; /* must update code if this changes */
+ size_t start_index; /* Offset within buffer to begin inspecting */
+ size_t stop_index; /* Offset within buffer to end inspecting */
+ uint16_t expected_value;
+ uint16_t * small_cube_buf_1;
+ uint16_t * large_cube_buf_1;
+ uint16_t * ptr_1;
+ size_t small_cube_size; /* Number of elements in small cube */
+ size_t large_cube_size; /* Number of elements in large cube */
+ hsize_t dims[SS_DR_MAX_RANK];
+ hsize_t chunk_dims[SS_DR_MAX_RANK];
+ hsize_t sel_start[SS_DR_MAX_RANK];
+ unsigned u, v, w, x; /* Local index variables */
+ size_t s; /* Local index variable */
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ MESSAGE(7, ("\tn-cube slice through m-cube I/O test %d.\n", test_num));
+ MESSAGE(7, ("\tranks = %d/%d, edge_size = %d, checker_edge_size = %d, chunk_edge_size = %d.\n", small_rank, large_rank, edge_size, checker_edge_size, chunk_edge_size));
+
+ HDassert(edge_size >= 6);
+ HDassert(checker_edge_size > 0);
+ HDassert(checker_edge_size <= edge_size);
+ HDassert(edge_size >= chunk_edge_size);
+ HDassert((chunk_edge_size == 0) || (chunk_edge_size >= 3));
+ HDassert(small_rank > 0);
+ HDassert(small_rank < large_rank);
+ HDassert(large_rank <= test_max_rank);
+ HDassert(test_max_rank <= SS_DR_MAX_RANK);
+
+ /* Compute cube sizes */
+ small_cube_size = large_cube_size = (size_t)1;
+ for(u = 0; u < large_rank; u++) {
+ if(u < small_rank)
+ small_cube_size *= (size_t)edge_size;
+
+ large_cube_size *= (size_t)edge_size;
+ } /* end for */
+ HDassert(large_cube_size < (size_t)(UINT_MAX));
+
+ small_rank_offset = test_max_rank - small_rank;
+ HDassert(small_rank_offset >= 1);
+
+ /* also, at present, we use 16 bit values in this test --
+ * hence the following assertion. Delete it if we convert
+ * to 32 bit values.
+ */
+ HDassert(large_cube_size < (size_t)(UINT16_MAX));
+
+
+ /* Allocate & initialize buffers */
+ small_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), small_cube_size);
+ CHECK(small_cube_buf_1, NULL, "HDcalloc");
+ large_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), large_cube_size);
+ CHECK(large_cube_buf_1, NULL, "HDcalloc");
+
+
+ /* Create a dataset transfer property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Use the 'core' VFD for this test */
+ ret = H5Pset_fapl_core(fapl, (size_t)(1024 * 1024), FALSE);
+ CHECK(ret, FAIL, "H5Pset_fapl_core");
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Close file access property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+
+ /* setup dims: */
+ dims[0] = dims[1] = dims[2] = dims[3] = dims[4] = edge_size;
+
+
+ /* Create small cube dataspaces */
+ full_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
+ CHECK(full_small_cube_sid, FAIL, "H5Screate_simple");
+
+ mem_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
+ CHECK(mem_small_cube_sid, FAIL, "H5Screate_simple");
+
+ file_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
+ CHECK(file_small_cube_sid, FAIL, "H5Screate_simple");
+
+
+ /* Create large cube dataspace */
+ full_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
+ CHECK(full_large_cube_sid, FAIL, "H5Screate_simple");
+
+ mem_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
+ CHECK(mem_large_cube_sid, FAIL, "H5Screate_simple");
+
+ file_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
+ CHECK(file_large_cube_sid, FAIL, "H5Screate_simple");
+
+
+ /* if chunk edge size is greater than zero, set up the small and
+ * large data set creation property lists to specify chunked
+ * datasets.
+ */
+ if(chunk_edge_size > 0) {
+ chunk_dims[0] = chunk_dims[1] =
+ chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = chunk_edge_size;
+
+ small_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(small_cube_dcpl_id, FAIL, "H5Pcreate");
+
+ ret = H5Pset_layout(small_cube_dcpl_id, H5D_CHUNKED);
+ CHECK(ret, FAIL, "H5Pset_layout");
+
+ ret = H5Pset_chunk(small_cube_dcpl_id, (int)small_rank, chunk_dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+
+
+ large_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(large_cube_dcpl_id, FAIL, "H5Pcreate");
+
+ ret = H5Pset_layout(large_cube_dcpl_id, H5D_CHUNKED);
+ CHECK(ret, FAIL, "H5Pset_layout");
+
+ ret = H5Pset_chunk(large_cube_dcpl_id, (int)large_rank, chunk_dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+ } /* end if */
+
+
+ /* create the small cube dataset */
+ small_cube_dataset = H5Dcreate2(fid, "small_cube_dataset", dset_type,
+ file_small_cube_sid, H5P_DEFAULT, small_cube_dcpl_id, H5P_DEFAULT);
+ CHECK(small_cube_dataset, FAIL, "H5Dcreate2");
+
+ /* Close non-default small dataset DCPL */
+ if(small_cube_dcpl_id != H5P_DEFAULT) {
+ ret = H5Pclose(small_cube_dcpl_id);
+ CHECK(ret, FAIL, "H5Pclose");
+ } /* end if */
+
+ /* create the large cube dataset */
+ large_cube_dataset = H5Dcreate2(fid, "large_cube_dataset", dset_type,
+ file_large_cube_sid, H5P_DEFAULT, large_cube_dcpl_id, H5P_DEFAULT);
+ CHECK(large_cube_dataset, FAIL, "H5Dcreate2");
+
+ /* Close non-default large dataset DCPL */
+ if(large_cube_dcpl_id != H5P_DEFAULT) {
+ ret = H5Pclose(large_cube_dcpl_id);
+ CHECK(ret, FAIL, "H5Pclose");
+ } /* end if */
+
+
+ /* write initial data to the on disk datasets */
+ ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid,
+ full_small_cube_sid, xfer_plist, cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid,
+ full_large_cube_sid, xfer_plist, cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+
+ /* read initial small cube data from disk and verify that it is as expected. */
+ ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid,
+ full_small_cube_sid, xfer_plist, small_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check that the data is valid */
+ verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size,
+ edge_size, small_rank);
+
+ /* read initial large cube data from disk and verify that it is as expected. */
+ ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid,
+ full_large_cube_sid, xfer_plist, large_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check that the data is valid */
+ verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size,
+ edge_size, large_rank);
+
+
+ /* first, verify that we can read from disk correctly using selections
+ * of different rank that H5S_select_shape_same() views as being of the
+ * same shape.
+ *
+ * Start by reading small_rank-D slice from the on disk large cube, and
+ * verifying that the data read is correct. Verify that H5S_select_shape_same()
+ * returns true on the memory and file selections.
+ *
+ * The first step is to set up the needed checker board selection in the
+ * in memory small small cube
+ */
+
+ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0;
+
+ test_select_hyper_checker_board_dr__select_checker_board(mem_small_cube_sid,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start);
+
+ /* now read slices from the large, on-disk cube into the small cube.
+ * Note how we adjust sel_start only in the dimensions peculiar to the
+ * large cube.
+ */
+
+ start_in_checker[0] = TRUE;
+ u = 0;
+ do {
+ if(small_rank_offset > 0)
+ sel_start[0] = u;
+
+ v = 0;
+ do {
+ if(small_rank_offset > 1)
+ sel_start[1] = v;
+
+ w = 0;
+ do {
+ if(small_rank_offset > 2)
+ sel_start[2] = w;
+
+ x = 0;
+ do {
+ if(small_rank_offset > 3)
+ sel_start[3] = x;
+
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+
+ HDassert((sel_start[0] == 0) || (0 < small_rank_offset));
+ HDassert((sel_start[1] == 0) || (1 < small_rank_offset));
+ HDassert((sel_start[2] == 0) || (2 < small_rank_offset));
+ HDassert((sel_start[3] == 0) || (3 < small_rank_offset));
+ HDassert((sel_start[4] == 0) || (4 < small_rank_offset));
+
+ test_select_hyper_checker_board_dr__select_checker_board
+ (
+ file_large_cube_sid,
+ large_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start
+ );
+
+ /* verify that H5S_select_shape_same() reports the two
+ * selections as having the same shape.
+ */
+ check = H5S_select_shape_same_test(mem_small_cube_sid,
+ file_large_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ /* zero the buffer that we will be using for reading */
+ HDmemset(small_cube_buf_1, 0, sizeof(*small_cube_buf_1) * small_cube_size);
+
+ /* Read selection from disk */
+ ret = H5Dread(large_cube_dataset,
+ H5T_NATIVE_UINT16,
+ mem_small_cube_sid,
+ file_large_cube_sid,
+ xfer_plist,
+ small_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+ expected_value = (uint16_t)
+ ((u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size));
+
+ data_ok = test_select_hyper_checker_board_dr__verify_data
+ (
+ small_cube_buf_1,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ expected_value,
+ (hbool_t)TRUE
+ );
+ if(!data_ok)
+ TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__);
+
+ x++;
+ } while((large_rank >= (test_max_rank - 3)) &&
+ (small_rank <= (test_max_rank - 4)) && (x < edge_size));
+ w++;
+ } while((large_rank >= (test_max_rank - 2)) &&
+ (small_rank <= (test_max_rank - 3)) && (w < edge_size));
+ v++;
+ } while((large_rank >= (test_max_rank - 1)) &&
+ (small_rank <= (test_max_rank - 2)) && (v < edge_size));
+ u++;
+ } while((large_rank >= test_max_rank) &&
+ (small_rank <= (test_max_rank - 1)) && (u < edge_size));
+
+
+ /* similarly, read the on disk small cube into slices through the in memory
+ * large cube, and verify that the correct data (and only the correct data)
+ * is read.
+ */
+
+ /* select a checker board in the file small cube dataspace */
+ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0;
+ test_select_hyper_checker_board_dr__select_checker_board(file_small_cube_sid,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start);
+
+
+ start_in_checker[0] = TRUE;
+ u = 0;
+ do {
+ if(0 < small_rank_offset)
+ sel_start[0] = u;
+
+ v = 0;
+ do {
+ if(1 < small_rank_offset)
+ sel_start[1] = v;
+
+ w = 0;
+ do {
+ if(2 < small_rank_offset)
+ sel_start[2] = w;
+
+ x = 0;
+ do {
+ if(3 < small_rank_offset)
+ sel_start[3] = x;
+
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+
+ HDassert((sel_start[0] == 0) || (0 < small_rank_offset));
+ HDassert((sel_start[1] == 0) || (1 < small_rank_offset));
+ HDassert((sel_start[2] == 0) || (2 < small_rank_offset));
+ HDassert((sel_start[3] == 0) || (3 < small_rank_offset));
+ HDassert((sel_start[4] == 0) || (4 < small_rank_offset));
+
+ test_select_hyper_checker_board_dr__select_checker_board
+ (
+ mem_large_cube_sid,
+ large_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start
+ );
+
+ /* verify that H5S_select_shape_same() reports the two
+ * selections as having the same shape.
+ */
+ check = H5S_select_shape_same_test(file_small_cube_sid,
+ mem_large_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+
+ /* zero out the in memory large cube */
+ HDmemset(large_cube_buf_1, 0, sizeof(*large_cube_buf_1) * large_cube_size);
+
+ /* Read selection from disk */
+ ret = H5Dread(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ mem_large_cube_sid,
+ file_small_cube_sid,
+ xfer_plist,
+ large_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+
+ /* verify that the expected data and only the
+ * expected data was read.
+ */
+ data_ok = TRUE;
+ ptr_1 = large_cube_buf_1;
+ expected_value = 0;
+ start_index = (u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size);
+ stop_index = start_index + small_cube_size - 1;
+
+ HDassert( start_index < stop_index );
+ HDassert( stop_index <= large_cube_size );
+
+ /* verify that the large cube contains only zeros before the slice */
+ for(s = 0; s < start_index; s++) {
+ if(*ptr_1 != 0)
+ data_ok = FALSE;
+ ptr_1++;
+ } /* end for */
+ HDassert(s == start_index);
+
+ data_ok &= test_select_hyper_checker_board_dr__verify_data
+ (
+ ptr_1,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ (uint16_t)0,
+ (hbool_t)TRUE
+ );
+
+ ptr_1 += small_cube_size;
+ s += small_cube_size;
+
+ HDassert(s == stop_index + 1);
+
+ /* verify that the large cube contains only zeros after the slice */
+ for(s = stop_index + 1; s < large_cube_size; s++) {
+ if(*ptr_1 != 0)
+ data_ok = FALSE;
+ ptr_1++;
+ } /* end for */
+ if(!data_ok)
+ TestErrPrintf("large cube read from small cube has bad data! Line=%d\n",__LINE__);
+
+ x++;
+ } while((large_rank >= (test_max_rank - 3)) &&
+ (small_rank <= (test_max_rank - 4)) && (x < edge_size));
+ w++;
+ } while((large_rank >= (test_max_rank - 2)) &&
+ (small_rank <= (test_max_rank - 3)) && (w < edge_size));
+ v++;
+ } while((large_rank >= (test_max_rank - 1)) &&
+ (small_rank <= (test_max_rank - 2)) && (v < edge_size));
+ u++;
+ } while((large_rank >= test_max_rank) &&
+ (small_rank <= (test_max_rank - 1)) && (u < edge_size));
+
+
+ /* now we go in the opposite direction, verifying that we can write
+ * from memory to file using selections of different rank that
+ * H5S_select_shape_same() views as being of the same shape.
+ *
+ * Start by writing small_rank D slices from the in memory large cube, to
+ * the the on disk small cube dataset. After each write, read the small
+ * cube dataset back from disk, and verify that it contains the expected
+ * data. Verify that H5S_select_shape_same() returns true on the
+ * memory and file selections.
+ */
+
+ /* select a checker board in the file small cube dataspace */
+ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0;
+ test_select_hyper_checker_board_dr__select_checker_board(file_small_cube_sid,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start);
+
+ start_in_checker[0] = TRUE;
+ u = 0;
+ do {
+ if(small_rank_offset > 0)
+ sel_start[0] = u;
+
+ v = 0;
+ do {
+ if(small_rank_offset > 1)
+ sel_start[1] = v;
+
+ w = 0;
+ do {
+ if(small_rank_offset > 2)
+ sel_start[2] = w;
+
+ x = 0;
+ do {
+ if(small_rank_offset > 3)
+ sel_start[3] = x;
+
+ /* zero out the on disk small cube */
+ ret = H5Dwrite(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ full_small_cube_sid,
+ full_small_cube_sid,
+ xfer_plist,
+ zero_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+
+ HDassert((sel_start[0] == 0) || (0 < small_rank_offset));
+ HDassert((sel_start[1] == 0) || (1 < small_rank_offset));
+ HDassert((sel_start[2] == 0) || (2 < small_rank_offset));
+ HDassert((sel_start[3] == 0) || (3 < small_rank_offset));
+ HDassert((sel_start[4] == 0) || (4 < small_rank_offset));
+
+ test_select_hyper_checker_board_dr__select_checker_board
+ (
+ mem_large_cube_sid,
+ large_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start
+ );
+
+ /* verify that H5S_select_shape_same() reports the two
+ * selections as having the same shape.
+ */
+ check = H5S_select_shape_same_test(file_small_cube_sid,
+ mem_large_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+
+ /* write the slice from the in memory large cube to the
+ * on disk small cube
+ */
+ ret = H5Dwrite(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ mem_large_cube_sid,
+ file_small_cube_sid,
+ xfer_plist,
+ cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+
+ /* zero the buffer that we will be using for reading */
+ HDmemset(small_cube_buf_1, 0, sizeof(*small_cube_buf_1) * small_cube_size);
+
+ /* read the on disk small cube into memory */
+ ret = H5Dread(small_cube_dataset,
+ H5T_NATIVE_UINT16,
+ full_small_cube_sid,
+ full_small_cube_sid,
+ xfer_plist,
+ small_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+ expected_value = (uint16_t)
+ ((u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size));
+
+ data_ok = test_select_hyper_checker_board_dr__verify_data
+ (
+ small_cube_buf_1,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ expected_value,
+ (hbool_t)TRUE
+ );
+ if(!data_ok)
+ TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__);
+
+ x++;
+ } while((large_rank >= (test_max_rank - 3)) &&
+ (small_rank <= (test_max_rank - 4)) && (x < edge_size));
+ w++;
+ } while((large_rank >= (test_max_rank - 2)) &&
+ (small_rank <= (test_max_rank - 3)) && (w < edge_size));
+ v++;
+ } while((large_rank >= (test_max_rank - 1)) &&
+ (small_rank <= (test_max_rank - 2)) && (v < edge_size));
+ u++;
+ } while((large_rank >= test_max_rank) &&
+ (small_rank <= (test_max_rank - 1)) && (u < edge_size));
+
+
+ /* Now write checker board selections of the entries in memory
+ * small cube to slices of the on disk cube. After each write,
+ * read the on disk large cube * into memeory, and verify that
+ * it contains the expected * data. Verify that
+ * H5S_select_shape_same() returns true on the memory and file
+ * selections.
+ */
+
+ /* select a checker board in the in memory small cube dataspace */
+ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0;
+ test_select_hyper_checker_board_dr__select_checker_board(mem_small_cube_sid,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start);
+
+ start_in_checker[0] = TRUE;
+ u = 0;
+ do {
+ if(small_rank_offset > 0)
+ sel_start[0] = u;
+
+ v = 0;
+ do {
+ if(small_rank_offset > 1)
+ sel_start[1] = v;
+
+ w = 0;
+ do {
+ if(small_rank_offset > 2)
+ sel_start[2] = w;
+
+ x = 0;
+ do {
+ if(small_rank_offset > 3)
+ sel_start[3] = x;
+
+ /* zero out the on disk cube */
+ ret = H5Dwrite(large_cube_dataset,
+ H5T_NATIVE_USHORT,
+ full_large_cube_sid,
+ full_large_cube_sid,
+ xfer_plist,
+ zero_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* we know that small_rank >= 1 and that large_rank > small_rank
+ * by the assertions at the head of this function. Thus no
+ * need for another inner loop.
+ */
+
+ HDassert((sel_start[0] == 0) || (0 < small_rank_offset));
+ HDassert((sel_start[1] == 0) || (1 < small_rank_offset));
+ HDassert((sel_start[2] == 0) || (2 < small_rank_offset));
+ HDassert((sel_start[3] == 0) || (3 < small_rank_offset));
+ HDassert((sel_start[4] == 0) || (4 < small_rank_offset));
+
+
+ test_select_hyper_checker_board_dr__select_checker_board
+ (
+ file_large_cube_sid,
+ large_rank,
+ edge_size,
+ checker_edge_size,
+ small_rank,
+ sel_start
+ );
+
+ /* verify that H5S_select_shape_same() reports the two
+ * selections as having the same shape.
+ */
+ check = H5S_select_shape_same_test(file_large_cube_sid,
+ mem_small_cube_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+
+ /* write the checker board selection of the in memory
+ * small cube to a slice through the on disk large
+ * cube.
+ */
+ ret = H5Dwrite(large_cube_dataset,
+ H5T_NATIVE_UINT16,
+ mem_small_cube_sid,
+ file_large_cube_sid,
+ xfer_plist,
+ cube_buf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+
+ /* zero out the in memory large cube */
+ HDmemset(large_cube_buf_1, 0, sizeof(*large_cube_buf_1) * large_cube_size);
+
+ /* read the on disk large cube into memory */
+ ret = H5Dread(large_cube_dataset,
+ H5T_NATIVE_UINT16,
+ full_large_cube_sid,
+ full_large_cube_sid,
+ xfer_plist,
+ large_cube_buf_1);
+ CHECK(ret, FAIL, "H5Dread");
+
+
+ /* verify that the expected data and only the
+ * expected data was written to the on disk large
+ * cube.
+ */
+ data_ok = TRUE;
+ ptr_1 = large_cube_buf_1;
+ expected_value = 0;
+ start_index = (u * edge_size * edge_size * edge_size * edge_size) +
+ (v * edge_size * edge_size * edge_size) +
+ (w * edge_size * edge_size) +
+ (x * edge_size);
+ stop_index = start_index + small_cube_size - 1;
+
+ HDassert( start_index < stop_index );
+ HDassert( stop_index <= large_cube_size );
+
+ /* verify that the large cube contains only zeros before the slice */
+ for(s = 0; s < start_index; s++) {
+ if(*ptr_1 != 0)
+ data_ok = FALSE;
+ ptr_1++;
+ } /* end for */
+ HDassert(s == start_index);
+
+ /* verify that the slice contains the expected data */
+ data_ok &= test_select_hyper_checker_board_dr__verify_data
+ (
+ ptr_1,
+ small_rank,
+ edge_size,
+ checker_edge_size,
+ (uint16_t)0,
+ (hbool_t)TRUE
+ );
+
+ ptr_1 += small_cube_size;
+ s += small_cube_size;
+
+ HDassert(s == stop_index + 1);
+
+ /* verify that the large cube contains only zeros after the slice */
+ for(s = stop_index + 1; s < large_cube_size; s++) {
+ if(*ptr_1 != 0)
+ data_ok = FALSE;
+ ptr_1++;
+ } /* end for */
+ if(!data_ok)
+ TestErrPrintf("large cube written from small cube has bad data! Line=%d\n",__LINE__);
+
+ x++;
+ } while((large_rank >= (test_max_rank - 3)) &&
+ (small_rank <= (test_max_rank - 4)) && (x < edge_size));
+ w++;
+ } while((large_rank >= (test_max_rank - 2)) &&
+ (small_rank <= (test_max_rank - 3)) && (w < edge_size));
+ v++;
+ } while((large_rank >= (test_max_rank - 1)) &&
+ (small_rank <= (test_max_rank - 2)) && (v < edge_size));
+ u++;
+ } while((large_rank >= test_max_rank) &&
+ (small_rank <= (test_max_rank - 1)) && (u < edge_size));
+
+
+ /* Close memory dataspaces */
+ ret = H5Sclose(full_small_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(full_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(mem_small_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(mem_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ /* Close disk dataspace */
+ ret = H5Sclose(file_small_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(file_large_cube_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close Datasets */
+ ret = H5Dclose(small_cube_dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Dclose(large_cube_dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Free memory buffers */
+ HDfree(small_cube_buf_1);
+ HDfree(large_cube_buf_1);
+
+} /* test_select_hyper_checker_board_dr__run_test() */
+
+
+/****************************************************************
+**
+** test_select_hyper_checker_board_dr(): Test H5S (dataspace)
+** selection code with checkerboard source and target having
+** different ranks but the same shape. We have already
+** tested H5S_shape_same in isolation, so now we try to do
+** I/O.
+**
+** This is just an initial smoke check, so we will work
+** with a slice through a cube only.
+**
+****************************************************************/
+static void
+test_select_hyper_checker_board_dr(hid_t dset_type, hid_t xfer_plist)
+{
+ uint16_t *cube_buf; /* Buffer for writing cube data */
+ uint16_t *cube_ptr; /* Temporary pointer into cube data */
+ uint16_t *zero_buf; /* Buffer for writing zeroed cube data */
+ int test_num = 0;
+ unsigned checker_edge_size = 2; /* Size of checkerboard dimension */
+ unsigned chunk_edge_size; /* Size of chunk's dataspace dimensions */
+ unsigned edge_size = 6; /* Size of dataset's dataspace dimensions */
+ unsigned small_rank; /* Current rank of small dataset */
+ unsigned large_rank; /* Current rank of large dataset */
+ unsigned max_rank = 5; /* Max. rank to use */
+ size_t max_cube_size; /* Max. number of elements in largest cube */
+ size_t s; /* Local index variable */
+ unsigned u; /* Local index variable */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Checker Board Hyperslabs With Different Rank I/O Functionality\n"));
+
+ /* Compute max. cube size */
+ max_cube_size = (size_t)1;
+ for(u = 0; u < max_rank; u++)
+ max_cube_size *= (size_t)(edge_size + 1);
+
+ /* Allocate cube buffer for writing values */
+ cube_buf = (uint16_t *)HDmalloc(sizeof(uint16_t) * max_cube_size);
+ CHECK(cube_buf, NULL, "HDmalloc");
+
+ /* Initialize the cube buffer */
+ cube_ptr = cube_buf;
+ for(s = 0; s < max_cube_size; s++)
+ *cube_ptr++ = (uint16_t)s;
+
+ /* Allocate cube buffer for zeroing values on disk */
+ zero_buf = (uint16_t *)HDcalloc(sizeof(uint16_t), max_cube_size);
+ CHECK(zero_buf, NULL, "HDcalloc");
+
+ for(large_rank = 1; large_rank <= max_rank; large_rank++) {
+ for(small_rank = 1; small_rank < large_rank; small_rank++) {
+ chunk_edge_size = 0;
+ test_select_hyper_checker_board_dr__run_test(test_num, cube_buf,
+ zero_buf, edge_size, checker_edge_size, chunk_edge_size, small_rank,
+ large_rank, dset_type, xfer_plist);
+ test_num++;
+
+ test_select_hyper_checker_board_dr__run_test(test_num, cube_buf,
+ zero_buf,
+ edge_size + 1, checker_edge_size, chunk_edge_size, small_rank,
+ large_rank, dset_type, xfer_plist);
+ test_num++;
+
+ chunk_edge_size = 3;
+ test_select_hyper_checker_board_dr__run_test(test_num, cube_buf,
+ zero_buf,
+ edge_size, checker_edge_size, chunk_edge_size, small_rank,
+ large_rank, dset_type, xfer_plist);
+ test_num++;
+
+ test_select_hyper_checker_board_dr__run_test(test_num, cube_buf,
+ zero_buf,
+ edge_size + 1, checker_edge_size, chunk_edge_size, small_rank,
+ large_rank, dset_type, xfer_plist);
+ test_num++;
+ } /* for loop on small rank */
+ } /* for loop on large rank */
+
+ HDfree(cube_buf);
+ HDfree(zero_buf);
+
+} /* test_select_hyper_checker_board_dr() */
+
+
/****************************************************************
**
** test_select_hyper_copy(): Test H5S (dataspace) selection code.
@@ -2345,15 +4373,15 @@ test_select_point_offset(void)
CHECK(ret, FAIL, "H5Sselect_elements");
/* Read selection from disk */
- ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,rbuf);
+ ret = H5Dread(dataset, H5T_NATIVE_UCHAR, sid2, sid1, H5P_DEFAULT, rbuf);
CHECK(ret, FAIL, "H5Dread");
/* Compare data read with data written out */
- for(i=0; i<POINT1_NPOINTS; i++) {
- tbuf=wbuf+((coord2[i][0]+offset[0])*SPACE2_DIM2)+coord2[i][1]+offset[1];
- tbuf2=rbuf+(coord3[i][0]*SPACE3_DIM2)+coord3[i][1];
- if(*tbuf!=*tbuf2)
- TestErrPrintf("element values don't match!, i=%d\n",i);
+ for(i = 0; i < POINT1_NPOINTS; i++) {
+ tbuf = wbuf + ((coord2[i][0] + (hsize_t)offset[0]) * SPACE2_DIM2) + coord2[i][1] + (hsize_t)offset[1];
+ tbuf2 = rbuf + (coord3[i][0] * SPACE3_DIM2) + coord3[i][1];
+ if(*tbuf != *tbuf2)
+ TestErrPrintf("element values don't match!, i=%d\n", i);
} /* end for */
/* Close memory dataspace */
@@ -2410,7 +4438,7 @@ test_select_hyper_union(void)
*tbuf2; /* temporary buffer pointer */
int i,j; /* Counters */
herr_t ret; /* Generic return value */
- hsize_t npoints; /* Number of elements in selection */
+ hssize_t npoints; /* Number of elements in selection */
/* Output message about test being performed */
MESSAGE(5, ("Testing Hyperslab Selection Functions with unions of hyperslabs\n"));
@@ -2448,7 +4476,7 @@ test_select_hyper_union(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints = H5Sget_select_npoints(sid1);
- VERIFY(npoints, 2*15*13, "H5Sget_select_npoints");
+ VERIFY(npoints, 2 * 15 * 13, "H5Sget_select_npoints");
/* Select 8x26 hyperslab for memory dataset */
start[0]=15; start[1]=0;
@@ -2561,7 +4589,7 @@ test_select_hyper_union(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints = H5Sget_select_npoints(sid2);
- VERIFY(npoints, 15*26, "H5Sget_select_npoints");
+ VERIFY(npoints, 15 * 26, "H5Sget_select_npoints");
/* Create a dataset */
dataset = H5Dcreate2(fid1, SPACE2_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -2647,7 +4675,7 @@ test_select_hyper_union(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints = H5Sget_select_npoints(sid2);
- VERIFY(npoints, 15*26, "H5Sget_select_npoints");
+ VERIFY(npoints, 15 * 26, "H5Sget_select_npoints");
/* Create a dataset */
dataset = H5Dcreate2(fid1, SPACE3_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -2737,7 +4765,7 @@ test_select_hyper_union(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints = H5Sget_select_npoints(sid2);
- VERIFY(npoints, 15*26, "H5Sget_select_npoints");
+ VERIFY(npoints, 15 * 26, "H5Sget_select_npoints");
/* Create a dataset */
dataset = H5Dcreate2(fid1, SPACE4_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -2834,7 +4862,7 @@ test_select_hyper_union(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints = H5Sget_select_npoints(sid2);
- VERIFY(npoints, 15*26, "H5Sget_select_npoints");
+ VERIFY(npoints, 15 * 26, "H5Sget_select_npoints");
/* Create a dataset */
dataset = H5Dcreate2(fid1,SPACE5_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -3277,7 +5305,7 @@ test_select_hyper_and_2d(void)
*tbuf2; /* temporary buffer pointer */
int i,j; /* Counters */
herr_t ret; /* Generic return value */
- hsize_t npoints; /* Number of elements in selection */
+ hssize_t npoints; /* Number of elements in selection */
/* Output message about test being performed */
MESSAGE(5, ("Testing Hyperslab Selection Functions with intersection of 2-D hyperslabs\n"));
@@ -3322,7 +5350,7 @@ test_select_hyper_and_2d(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints = H5Sget_select_npoints(sid1);
- VERIFY(npoints, 5*5, "H5Sget_select_npoints");
+ VERIFY(npoints, 5 * 5, "H5Sget_select_npoints");
/* Select 25 hyperslab for memory dataset */
start[0]=0;
@@ -3333,7 +5361,7 @@ test_select_hyper_and_2d(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints = H5Sget_select_npoints(sid2);
- VERIFY(npoints, 5*5, "H5Sget_select_npoints");
+ VERIFY(npoints, 5 * 5, "H5Sget_select_npoints");
/* Create a dataset */
dataset = H5Dcreate2(fid1, SPACE2_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -3406,7 +5434,7 @@ test_select_hyper_xor_2d(void)
*tbuf2; /* temporary buffer pointer */
int i,j; /* Counters */
herr_t ret; /* Generic return value */
- hsize_t npoints; /* Number of elements in selection */
+ hssize_t npoints; /* Number of elements in selection */
/* Output message about test being performed */
MESSAGE(5, ("Testing Hyperslab Selection Functions with XOR of 2-D hyperslabs\n"));
@@ -3537,7 +5565,7 @@ test_select_hyper_notb_2d(void)
*tbuf2; /* temporary buffer pointer */
int i,j; /* Counters */
herr_t ret; /* Generic return value */
- hsize_t npoints; /* Number of elements in selection */
+ hssize_t npoints; /* Number of elements in selection */
/* Output message about test being performed */
MESSAGE(5, ("Testing Hyperslab Selection Functions with NOTB of 2-D hyperslabs\n"));
@@ -3667,7 +5695,7 @@ test_select_hyper_nota_2d(void)
*tbuf2; /* temporary buffer pointer */
int i,j; /* Counters */
herr_t ret; /* Generic return value */
- hsize_t npoints; /* Number of elements in selection */
+ hssize_t npoints; /* Number of elements in selection */
/* Output message about test being performed */
MESSAGE(5, ("Testing Hyperslab Selection Functions with NOTA of 2-D hyperslabs\n"));
@@ -3878,7 +5906,7 @@ test_select_hyper_union_random_5d(hid_t read_plist)
#else /* QAK */
seed=987909620;
#endif /* QAK */
- HDsrand(seed);
+ HDsrandom(seed);
#ifdef QAK
printf("test_num=%d, seed=%u\n",test_num,seed);
@@ -3893,26 +5921,26 @@ printf("hyperslab=%d\n",i);
#endif /* QAK */
/* Select random hyperslab location & size for selection */
for(j=0; j<SPACE5_RANK; j++) {
- start[j]=rand()%dims1[j];
- count[j]=(rand()%(dims1[j]-start[j]))+1;
+ start[j] = ((hsize_t)HDrandom() % dims1[j]);
+ count[j] = (((hsize_t)HDrandom() % (dims1[j] - start[j])) + 1);
#ifdef QAK
printf("start[%d]=%d, count[%d]=%d (end[%d]=%d)\n",j,(int)start[j],j,(int)count[j],j,(int)(start[j]+count[j]-1));
#endif /* QAK */
} /* end for */
/* Select hyperslab */
- ret = H5Sselect_hyperslab(sid1,(i==0 ? H5S_SELECT_SET : H5S_SELECT_OR),start,NULL,count,NULL);
+ ret = H5Sselect_hyperslab(sid1, (i == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
} /* end for */
/* Get the number of elements selected */
- npoints=H5Sget_select_npoints(sid1);
+ npoints = H5Sget_select_npoints(sid1);
CHECK(npoints, 0, "H5Sget_select_npoints");
/* Select linear 1-D hyperslab for memory dataset */
- start[0]=0;
- count[0]=npoints;
- ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,NULL,count,NULL);
+ start[0] = 0;
+ count[0] = (hsize_t)npoints;
+ ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
npoints2 = H5Sget_select_npoints(sid2);
@@ -4973,24 +7001,24 @@ typedef struct {
static herr_t
test_select_hyper_iter3(void *_elem, hid_t UNUSED type_id, unsigned ndim, const hsize_t *point, void *_operator_data)
{
- unsigned short *tbuf=(unsigned short *)_elem; /* temporary buffer pointer */
- fill_iter_info *iter_info=(fill_iter_info *)_operator_data; /* Get the pointer to the iterator information */
+ unsigned *tbuf = (unsigned *)_elem; /* temporary buffer pointer */
+ fill_iter_info *iter_info = (fill_iter_info *)_operator_data; /* Get the pointer to the iterator information */
hsize_t *coord_ptr; /* Pointer to the coordinate information for a point*/
/* Check value in current buffer location */
- if(*tbuf!=iter_info->fill_value)
+ if(*tbuf != iter_info->fill_value)
return(-1);
else {
/* Check number of dimensions */
- if(ndim!=SPACE7_RANK)
+ if(ndim != SPACE7_RANK)
return(-1);
else {
/* Check Coordinates */
- coord_ptr=iter_info->coords+(2*iter_info->curr_coord);
+ coord_ptr = iter_info->coords + (2 * iter_info->curr_coord);
iter_info->curr_coord++;
- if(coord_ptr[0]!=point[0])
+ if(coord_ptr[0] != point[0])
return(-1);
- else if(coord_ptr[1]!=point[1])
+ else if(coord_ptr[1] != point[1])
return(-1);
else
return(0);
@@ -5009,25 +7037,25 @@ test_select_fill_all(void)
{
hid_t sid1; /* Dataspace ID */
hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2};
- int fill_value; /* Fill value */
+ unsigned fill_value; /* Fill value */
fill_iter_info iter_info; /* Iterator information structure */
hsize_t points[SPACE7_DIM1*SPACE7_DIM2][SPACE7_RANK]; /* Coordinates of selection */
- unsigned short *wbuf, /* buffer to write to disk */
+ unsigned *wbuf, /* buffer to write to disk */
*tbuf; /* temporary buffer pointer */
- int i,j; /* Counters */
+ unsigned u, v; /* Counters */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Filling 'all' Selections\n"));
/* Allocate memory buffer */
- wbuf = (unsigned short *)HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2);
CHECK(wbuf, NULL, "HDmalloc");
/* Initialize memory buffer */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++)
- *tbuf++=(unsigned short)(i*SPACE7_DIM2)+j;
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++)
+ *tbuf++ = (u * SPACE7_DIM2) + v;
/* Create dataspace for dataset on disk */
sid1 = H5Screate_simple(SPACE7_RANK, dims1, NULL);
@@ -5036,32 +7064,32 @@ test_select_fill_all(void)
/* Space defaults to "all" selection */
/* Set fill value */
- fill_value=SPACE7_FILL;
+ fill_value = SPACE7_FILL;
/* Fill selection in memory */
- ret=H5Dfill(&fill_value,H5T_NATIVE_INT,wbuf,H5T_NATIVE_USHORT,sid1);
+ ret = H5Dfill(&fill_value, H5T_NATIVE_UINT, wbuf, H5T_NATIVE_UINT, sid1);
CHECK(ret, FAIL, "H5Dfill");
/* Verify memory buffer the hard way... */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++)
- if(*tbuf!=(unsigned short)fill_value)
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%x, fill_value=%x\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++)
+ if(*tbuf != fill_value)
+ TestErrPrintf("Error! v=%d, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, fill_value);
/* Set the coordinates of the selection */
- for(i=0; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++) {
- points[(i*SPACE7_DIM2)+j][0]=i;
- points[(i*SPACE7_DIM2)+j][1]=j;
+ for(u = 0; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++) {
+ points[(u * SPACE7_DIM2) + v][0] = u;
+ points[(u * SPACE7_DIM2) + v][1] = v;
} /* end for */
/* Initialize the iterator structure */
- iter_info.fill_value=SPACE7_FILL;
- iter_info.curr_coord=0;
- iter_info.coords=(hsize_t *)points;
+ iter_info.fill_value = SPACE7_FILL;
+ iter_info.curr_coord = 0;
+ iter_info.coords = (hsize_t *)points;
/* Iterate through selection, verifying correct data */
- ret = H5Diterate(wbuf,H5T_NATIVE_USHORT,sid1,test_select_hyper_iter3,&iter_info);
+ ret = H5Diterate(wbuf, H5T_NATIVE_UINT, sid1, test_select_hyper_iter3, &iter_info);
CHECK(ret, FAIL, "H5Diterate");
/* Close dataspace */
@@ -5085,78 +7113,78 @@ test_select_fill_point(hssize_t *offset)
hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2};
hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */
hsize_t points[5][SPACE7_RANK] = {{2,4}, {3,8}, {8,4}, {7,5}, {7,7}};
- size_t num_points=5; /* Number of points selected */
+ size_t num_points = 5; /* Number of points selected */
int fill_value; /* Fill value */
fill_iter_info iter_info; /* Iterator information structure */
- unsigned short *wbuf, /* buffer to write to disk */
+ unsigned *wbuf, /* buffer to write to disk */
*tbuf; /* temporary buffer pointer */
- int i,j,k; /* Counters */
+ unsigned u, v, w; /* Counters */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Filling 'point' Selections\n"));
/* Allocate memory buffer */
- wbuf = (unsigned short *)HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2);
CHECK(wbuf, NULL, "HDmalloc");
/* Initialize memory buffer */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++)
- *tbuf++=(unsigned short)(i*SPACE7_DIM2)+j;
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++)
+ *tbuf++ = (unsigned short)(u * SPACE7_DIM2) + v;
/* Create dataspace for dataset on disk */
sid1 = H5Screate_simple(SPACE7_RANK, dims1, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");
/* Select "point" selection */
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET,num_points,(const hsize_t *)points);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET, num_points, (const hsize_t *)points);
CHECK(ret, FAIL, "H5Sselect_elements");
- if(offset!=NULL) {
- HDmemcpy(real_offset,offset,SPACE7_RANK*sizeof(hssize_t));
+ if(offset != NULL) {
+ HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t));
/* Set offset, if provided */
- ret = H5Soffset_simple(sid1,real_offset);
+ ret = H5Soffset_simple(sid1, real_offset);
CHECK(ret, FAIL, "H5Soffset_simple");
} /* end if */
else
- HDmemset(real_offset,0,SPACE7_RANK*sizeof(hssize_t));
+ HDmemset(real_offset, 0, SPACE7_RANK * sizeof(hssize_t));
/* Set fill value */
- fill_value=SPACE7_FILL;
+ fill_value = SPACE7_FILL;
/* Fill selection in memory */
- ret=H5Dfill(&fill_value,H5T_NATIVE_INT,wbuf,H5T_NATIVE_USHORT,sid1);
+ ret = H5Dfill(&fill_value, H5T_NATIVE_INT, wbuf, H5T_NATIVE_UINT, sid1);
CHECK(ret, FAIL, "H5Dfill");
/* Verify memory buffer the hard way... */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
- for(k=0; k<(int)num_points; k++) {
- if(i==(int)(points[k][0]+real_offset[0]) && j==(int)(points[k][1]+real_offset[1])) {
- if(*tbuf!=(unsigned short)fill_value)
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++, tbuf++) {
+ for(w = 0; w < (unsigned)num_points; w++) {
+ if(u == (unsigned)(points[w][0] + (hsize_t)real_offset[0]) && v == (unsigned)(points[w][1] + (hsize_t)real_offset[1])) {
+ if(*tbuf != (unsigned)fill_value)
+ TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value);
break;
} /* end if */
} /* end for */
- if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
+ if(w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v))
+ TestErrPrintf("Error! v=%d, u=%d, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v));
} /* end for */
/* Initialize the iterator structure */
- iter_info.fill_value=SPACE7_FILL;
- iter_info.curr_coord=0;
- iter_info.coords=(hsize_t *)points;
+ iter_info.fill_value = SPACE7_FILL;
+ iter_info.curr_coord = 0;
+ iter_info.coords = (hsize_t *)points;
/* Add in the offset */
- for(i=0; i<(int)num_points; i++) {
- points[i][0]+=real_offset[0];
- points[i][1]+=real_offset[1];
+ for(u = 0; u < (unsigned)num_points; u++) {
+ points[u][0] = (hsize_t)(points[u][0] + real_offset[0]);
+ points[u][1] = (hsize_t)(points[u][1] + real_offset[1]);
} /* end for */
/* Iterate through selection, verifying correct data */
- ret = H5Diterate(wbuf,H5T_NATIVE_USHORT,sid1,test_select_hyper_iter3,&iter_info);
+ ret = H5Diterate(wbuf, H5T_NATIVE_UINT, sid1, test_select_hyper_iter3, &iter_info);
CHECK(ret, FAIL, "H5Diterate");
/* Close dataspace */
@@ -5185,78 +7213,78 @@ test_select_fill_hyper_simple(hssize_t *offset)
hsize_t points[16][SPACE7_RANK]; /* Coordinates selected */
int fill_value; /* Fill value */
fill_iter_info iter_info; /* Iterator information structure */
- unsigned short *wbuf, /* buffer to write to disk */
+ unsigned *wbuf, /* buffer to write to disk */
*tbuf; /* temporary buffer pointer */
- int i,j; /* Counters */
+ unsigned u, v; /* Counters */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Filling Simple 'hyperslab' Selections\n"));
/* Allocate memory buffer */
- wbuf = (unsigned short *)HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2);
CHECK(wbuf, NULL, "HDmalloc");
/* Initialize memory buffer */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++)
- *tbuf++=(unsigned short)(i*SPACE7_DIM2)+j;
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++)
+ *tbuf++ = (unsigned short)(u * SPACE7_DIM2) + v;
/* Create dataspace for dataset on disk */
sid1 = H5Screate_simple(SPACE7_RANK, dims1, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");
/* Select "hyperslab" selection */
- start[0]=3; start[1]=3;
- count[0]=4; count[1]=4;
- ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET,start,NULL,count,NULL);
+ start[0] = 3; start[1] = 3;
+ count[0] = 4; count[1] = 4;
+ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
- if(offset!=NULL) {
- HDmemcpy(real_offset,offset,SPACE7_RANK*sizeof(hssize_t));
+ if(offset != NULL) {
+ HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t));
/* Set offset, if provided */
- ret = H5Soffset_simple(sid1,real_offset);
+ ret = H5Soffset_simple(sid1, real_offset);
CHECK(ret, FAIL, "H5Soffset_simple");
} /* end if */
else
- HDmemset(real_offset,0,SPACE7_RANK*sizeof(hssize_t));
+ HDmemset(real_offset, 0, SPACE7_RANK * sizeof(hssize_t));
/* Set fill value */
- fill_value=SPACE7_FILL;
+ fill_value = SPACE7_FILL;
/* Fill selection in memory */
- ret=H5Dfill(&fill_value,H5T_NATIVE_INT,wbuf,H5T_NATIVE_USHORT,sid1);
+ ret = H5Dfill(&fill_value, H5T_NATIVE_INT, wbuf, H5T_NATIVE_UINT, sid1);
CHECK(ret, FAIL, "H5Dfill");
/* Verify memory buffer the hard way... */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
- if((i>=(int)(start[0]+real_offset[0]) && i<(int)(start[0]+count[0]+real_offset[0]))
- && (j>=(int)(start[1]+real_offset[1]) && j<(int)(start[1]+count[1]+real_offset[1]))) {
- if(*tbuf!=(unsigned short)fill_value)
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++, tbuf++) {
+ if((u >= (unsigned)(start[0] + real_offset[0]) && u < (unsigned)(start[0] + count[0] + real_offset[0]))
+ && (v >= (unsigned)(start[1] + real_offset[1]) && v < (unsigned)(start[1] + count[1] + real_offset[1]))) {
+ if(*tbuf != (unsigned)fill_value)
+ TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value);
} /* end if */
else {
- if(*tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
+ if(*tbuf != ((unsigned)(u * SPACE7_DIM2) + v))
+ TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v));
} /* end else */
} /* end for */
/* Initialize the iterator structure */
- iter_info.fill_value=SPACE7_FILL;
- iter_info.curr_coord=0;
- iter_info.coords=(hsize_t *)points;
+ iter_info.fill_value = SPACE7_FILL;
+ iter_info.curr_coord = 0;
+ iter_info.coords = (hsize_t *)points;
/* Set the coordinates of the selection (with the offset) */
- for(i=0, num_points=0; i<(int)count[0]; i++)
- for(j=0; j<(int)count[1]; j++, num_points++) {
- points[num_points][0]=i+start[0]+real_offset[0];
- points[num_points][1]=j+start[1]+real_offset[1];
+ for(u = 0, num_points = 0; u < (unsigned)count[0]; u++)
+ for(v = 0; v < (unsigned)count[1]; v++, num_points++) {
+ points[num_points][0] = (hsize_t)(u + start[0] + real_offset[0]);
+ points[num_points][1] = (hsize_t)(v + start[1] + real_offset[1]);
} /* end for */
/* Iterate through selection, verifying correct data */
- ret = H5Diterate(wbuf,H5T_NATIVE_USHORT,sid1,test_select_hyper_iter3,&iter_info);
+ ret = H5Diterate(wbuf, H5T_NATIVE_UINT, sid1, test_select_hyper_iter3, &iter_info);
CHECK(ret, FAIL, "H5Diterate");
/* Close dataspace */
@@ -5292,79 +7320,79 @@ test_select_fill_hyper_regular(hssize_t *offset)
size_t num_points=16; /* Number of points selected */
int fill_value; /* Fill value */
fill_iter_info iter_info; /* Iterator information structure */
- unsigned short *wbuf, /* buffer to write to disk */
+ unsigned *wbuf, /* buffer to write to disk */
*tbuf; /* temporary buffer pointer */
- int i,j,k; /* Counters */
+ unsigned u, v, w; /* Counters */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Filling Regular 'hyperslab' Selections\n"));
/* Allocate memory buffer */
- wbuf = (unsigned short *)HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2);
CHECK(wbuf, NULL, "HDmalloc");
/* Initialize memory buffer */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++)
- *tbuf++=(unsigned short)(i*SPACE7_DIM2)+j;
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++)
+ *tbuf++ =(u * SPACE7_DIM2) + v;
/* Create dataspace for dataset on disk */
sid1 = H5Screate_simple(SPACE7_RANK, dims1, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");
/* Select "hyperslab" selection */
- start[0]=2; start[1]=2;
- stride[0]=4; stride[1]=4;
- count[0]=2; count[1]=2;
- block[0]=2; block[1]=2;
- ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block);
+ start[0] = 2; start[1] = 2;
+ stride[0] = 4; stride[1] = 4;
+ count[0] = 2; count[1] = 2;
+ block[0] = 2; block[1] = 2;
+ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
- if(offset!=NULL) {
- HDmemcpy(real_offset,offset,SPACE7_RANK*sizeof(hssize_t));
+ if(offset != NULL) {
+ HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t));
/* Set offset, if provided */
- ret = H5Soffset_simple(sid1,real_offset);
+ ret = H5Soffset_simple(sid1, real_offset);
CHECK(ret, FAIL, "H5Soffset_simple");
} /* end if */
else
- HDmemset(real_offset,0,SPACE7_RANK*sizeof(hssize_t));
+ HDmemset(real_offset, 0, SPACE7_RANK * sizeof(hssize_t));
/* Set fill value */
- fill_value=SPACE7_FILL;
+ fill_value = SPACE7_FILL;
/* Fill selection in memory */
- ret=H5Dfill(&fill_value,H5T_NATIVE_INT,wbuf,H5T_NATIVE_USHORT,sid1);
+ ret = H5Dfill(&fill_value, H5T_NATIVE_INT, wbuf, H5T_NATIVE_UINT, sid1);
CHECK(ret, FAIL, "H5Dfill");
/* Verify memory buffer the hard way... */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
- for(k=0; k<(int)num_points; k++) {
- if(i==(int)(points[k][0]+real_offset[0]) && j==(int)(points[k][1]+real_offset[1])) {
- if(*tbuf!=(unsigned short)fill_value)
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++, tbuf++) {
+ for(w = 0; w < (unsigned)num_points; w++) {
+ if(u == (unsigned)(points[w][0] + real_offset[0]) && v == (unsigned)(points[w][1] + real_offset[1])) {
+ if(*tbuf != (unsigned)fill_value)
+ TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value);
break;
} /* end if */
} /* end for */
- if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
+ if(w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v))
+ TestErrPrintf("Error! v=%d, u=%d, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v));
} /* end for */
/* Initialize the iterator structure */
- iter_info.fill_value=SPACE7_FILL;
- iter_info.curr_coord=0;
- iter_info.coords=(hsize_t *)points;
+ iter_info.fill_value = SPACE7_FILL;
+ iter_info.curr_coord = 0;
+ iter_info.coords = (hsize_t *)points;
/* Add in the offset */
- for(i=0; i<(int)num_points; i++) {
- points[i][0] += real_offset[0];
- points[i][1] += real_offset[1];
+ for(u = 0; u < (unsigned)num_points; u++) {
+ points[u][0] = (hsize_t)(points[u][0] + real_offset[0]);
+ points[u][1] = (hsize_t)(points[u][1] + real_offset[1]);
} /* end for */
/* Iterate through selection, verifying correct data */
- ret = H5Diterate(wbuf,H5T_NATIVE_USHORT,sid1,test_select_hyper_iter3,&iter_info);
+ ret = H5Diterate(wbuf, H5T_NATIVE_UINT, sid1, test_select_hyper_iter3, &iter_info);
CHECK(ret, FAIL, "H5Diterate");
/* Close dataspace */
@@ -5407,72 +7435,72 @@ test_select_fill_hyper_irregular(hssize_t *offset)
{6,4}, {6,5}, {6,6}, {6,7},
{7,4}, {7,5}, {7,6}, {7,7},
};
- size_t num_points=32; /* Number of points selected */
- size_t num_iter_points=28; /* Number of resulting points */
+ size_t num_points = 32; /* Number of points selected */
+ size_t num_iter_points = 28; /* Number of resulting points */
int fill_value; /* Fill value */
fill_iter_info iter_info; /* Iterator information structure */
- unsigned short *wbuf, /* buffer to write to disk */
+ unsigned *wbuf, /* buffer to write to disk */
*tbuf; /* temporary buffer pointer */
- int i,j,k; /* Counters */
+ unsigned u, v, w; /* Counters */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Filling Irregular 'hyperslab' Selections\n"));
/* Allocate memory buffer */
- wbuf = (unsigned short *)HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2);
CHECK(wbuf, NULL, "HDmalloc");
/* Initialize memory buffer */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++)
- *tbuf++=(unsigned short)(i*SPACE7_DIM2)+j;
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++)
+ *tbuf++ = (u * SPACE7_DIM2) + v;
/* Create dataspace for dataset on disk */
sid1 = H5Screate_simple(SPACE7_RANK, dims1, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");
/* Select first "hyperslab" selection */
- start[0]=2; start[1]=2;
- count[0]=4; count[1]=4;
- ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
+ start[0] = 2; start[1] = 2;
+ count[0] = 4; count[1] = 4;
+ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Combine with second "hyperslab" selection */
- start[0]=4; start[1]=4;
- count[0]=4; count[1]=4;
- ret = H5Sselect_hyperslab(sid1,H5S_SELECT_OR,start,NULL,count,NULL);
+ start[0] = 4; start[1] = 4;
+ count[0] = 4; count[1] = 4;
+ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_OR, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
- if(offset!=NULL) {
- HDmemcpy(real_offset,offset,SPACE7_RANK*sizeof(hssize_t));
+ if(offset != NULL) {
+ HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t));
/* Set offset, if provided */
- ret = H5Soffset_simple(sid1,real_offset);
+ ret = H5Soffset_simple(sid1, real_offset);
CHECK(ret, FAIL, "H5Soffset_simple");
} /* end if */
else
- HDmemset(real_offset,0,SPACE7_RANK*sizeof(hssize_t));
+ HDmemset(real_offset, 0, SPACE7_RANK * sizeof(hssize_t));
/* Set fill value */
- fill_value=SPACE7_FILL;
+ fill_value = SPACE7_FILL;
/* Fill selection in memory */
- ret=H5Dfill(&fill_value,H5T_NATIVE_INT,wbuf,H5T_NATIVE_USHORT,sid1);
+ ret = H5Dfill(&fill_value, H5T_NATIVE_INT, wbuf, H5T_NATIVE_UINT, sid1);
CHECK(ret, FAIL, "H5Dfill");
/* Verify memory buffer the hard way... */
- for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
- for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
- for(k=0; k<(int)num_points; k++) {
- if(i==(int)(points[k][0]+real_offset[0]) && j==(int)(points[k][1]+real_offset[1])) {
- if(*tbuf!=(unsigned short)fill_value)
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
+ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++)
+ for(v = 0; v < SPACE7_DIM2; v++, tbuf++) {
+ for(w = 0; w < (unsigned)num_points; w++) {
+ if(u == (unsigned)(points[w][0] + real_offset[0]) && v == (unsigned)(points[w][1] + real_offset[1])) {
+ if(*tbuf != (unsigned)fill_value)
+ TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value);
break;
} /* end if */
} /* end for */
- if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
- TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
+ if(w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v))
+ TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v));
} /* end for */
/* Initialize the iterator structure */
@@ -5481,13 +7509,13 @@ test_select_fill_hyper_irregular(hssize_t *offset)
iter_info.coords = (hsize_t *)iter_points;
/* Add in the offset */
- for(i=0; i<(int)num_iter_points; i++) {
- iter_points[i][0] += real_offset[0];
- iter_points[i][1] += real_offset[1];
+ for(u = 0; u < (unsigned)num_iter_points; u++) {
+ iter_points[u][0] = (hsize_t)(iter_points[u][0] + real_offset[0]);
+ iter_points[u][1] = (hsize_t)(iter_points[u][1] + real_offset[1]);
} /* end for */
/* Iterate through selection, verifying correct data */
- ret = H5Diterate(wbuf, H5T_NATIVE_USHORT, sid1, test_select_hyper_iter3, &iter_info);
+ ret = H5Diterate(wbuf, H5T_NATIVE_UINT, sid1, test_select_hyper_iter3, &iter_info);
CHECK(ret, FAIL, "H5Diterate");
/* Close dataspace */
@@ -7005,6 +9033,2855 @@ test_shape_same(void)
CHECK(ret, FAIL, "H5Sclose");
} /* test_shape_same() */
+/****************************************************************
+**
+** test_shape_same_dr__smoke_check_1():
+**
+** Create a square, 2 D data space (10 X 10), and select
+** all of it.
+**
+** Similarly, create nine, 3 D data spaces (10 X 10 X 10),
+** and select (10 X 10 X 1) hyper slabs in each, three with
+** the slab parallel to the xy plane, three parallel to the
+** xz plane, and three parallel to the yz plane.
+**
+** Assuming that z is the fastest changing dimension,
+** H5S_select_shape_same() should return TRUE when comparing
+** the full 2 D space against any hyperslab parallel to the
+** yz plane in the 3 D space, and FALSE when comparing the
+** full 2 D space against the other two hyper slabs.
+**
+** Also create two additional 3 D data spaces (10 X 10 X 10),
+** and select a (10 X 10 X 2) hyper slab parallel to the yz
+** axis in one of them, and two parallel (10 X 10 X 1) hyper
+** slabs parallel to the yz axis in the other.
+** H5S_select_shape_same() should return FALSE when comparing
+** each to the 2 D selection.
+**
+****************************************************************/
+static void
+test_shape_same_dr__smoke_check_1(void)
+{
+ hid_t small_square_sid;
+ hid_t small_cube_xy_slice_0_sid;
+ hid_t small_cube_xy_slice_1_sid;
+ hid_t small_cube_xy_slice_2_sid;
+ hid_t small_cube_xz_slice_0_sid;
+ hid_t small_cube_xz_slice_1_sid;
+ hid_t small_cube_xz_slice_2_sid;
+ hid_t small_cube_yz_slice_0_sid;
+ hid_t small_cube_yz_slice_1_sid;
+ hid_t small_cube_yz_slice_2_sid;
+ hid_t small_cube_yz_slice_3_sid;
+ hid_t small_cube_yz_slice_4_sid;
+ hsize_t small_cube_dims[] = {10, 10, 10};
+ hsize_t start[3];
+ hsize_t stride[3];
+ hsize_t count[3];
+ hsize_t block[3];
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ MESSAGE(7, (" Smoke check 1: Slices through a cube.\n"));
+
+ /* Create the 10 x 10 dataspace */
+ small_square_sid = H5Screate_simple(2, small_cube_dims, NULL);
+ CHECK(small_square_sid, FAIL, "H5Screate_simple");
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xy axis */
+ small_cube_xy_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xy_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xy_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_2_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 0; /* x */
+ start[1] = 0; /* y */
+ start[2] = 0; /* z */
+
+ /* stride is a bit silly here, since we are only selecting a single */
+ /* contiguous plane, but include it anyway, with values large enough */
+ /* to ensure that we will only get the single block selected. */
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 10; /* x */
+ block[1] = 10; /* y */
+ block[2] = 1; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[2] = 5;
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[2] = 9;
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xz axis */
+ small_cube_xz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xz_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_2_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 0; /* x */
+ start[1] = 0; /* y */
+ start[2] = 0; /* z */
+
+ /* stride is a bit silly here, since we are only selecting a single */
+ /* contiguous chunk, but include it anyway, with values large enough */
+ /* to ensure that we will only get the single chunk. */
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 10; /* x */
+ block[1] = 1; /* y */
+ block[2] = 10; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[1] = 4;
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[1] = 9;
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslabs parallel to the yz axis */
+ small_cube_yz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_2_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_3_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_3_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_4_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_4_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 0; /* x */
+ start[1] = 0; /* y */
+ start[2] = 0; /* z */
+
+ /* stride is a bit silly here, since we are only selecting a single */
+ /* contiguous chunk, but include it anyway, with values large enough */
+ /* to ensure that we will only get the single chunk. */
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 1; /* x */
+ block[1] = 10; /* y */
+ block[2] = 10; /* z */
+
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 4;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 9;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 4;
+ block[0] = 2;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 3;
+ block[0] = 1;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_4_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 6;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_4_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* setup is done -- run the tests: */
+
+ /* Compare against "xy" selection */
+ check = H5S_select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Compare against "xz" selection */
+ check = H5S_select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Compare against "yz" selection */
+ check = H5S_select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_3_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_4_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(small_square_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_xy_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xy_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xy_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_xz_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xz_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xz_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_yz_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_3_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_4_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_shape_same_dr__smoke_check_1() */
+
+/****************************************************************
+**
+** test_shape_same_dr__smoke_check_2():
+**
+** Create a square, 2 D data space (10 X 10), and select
+** a "checker board" hyper slab as follows:
+**
+** * * - - * * - - * *
+** * * - - * * - - * *
+** - - * * - - * * - -
+** - - * * - - * * - -
+** * * - - * * - - * *
+** * * - - * * - - * *
+** - - * * - - * * - -
+** - - * * - - * * - -
+** * * - - * * - - * *
+** * * - - * * - - * *
+**
+** where asterisks indicate selected elements, and dashes
+** indicate unselected elements.
+**
+** Similarly, create nine, 3 D data spaces (10 X 10 X 10),
+** and select similar (10 X 10 X 1) checker board hyper
+** slabs in each, three with the slab parallel to the xy
+** plane, three parallel to the xz plane, and three parallel
+** to the yz plane.
+**
+** Assuming that z is the fastest changing dimension,
+** H5S_select_shape_same() should return TRUE when comparing
+** the 2 D space checker board selection against a checker
+** board hyperslab parallel to the yz plane in the 3 D
+** space, and FALSE when comparing the 2 D checkerboard
+** selection against two hyper slabs parallel to the xy
+** or xz planes.
+**
+** Also create an additional 3 D data spaces (10 X 10 X 10),
+** and select a checker board parallel with the yz axis,
+** save with some squares being on different planes.
+** H5S_select_shape_same() should return FALSE when
+** comparing this selection to the 2 D selection.
+**
+****************************************************************/
+static void
+test_shape_same_dr__smoke_check_2(void)
+{
+ hid_t small_square_sid;
+ hid_t small_cube_xy_slice_0_sid;
+ hid_t small_cube_xy_slice_1_sid;
+ hid_t small_cube_xy_slice_2_sid;
+ hid_t small_cube_xz_slice_0_sid;
+ hid_t small_cube_xz_slice_1_sid;
+ hid_t small_cube_xz_slice_2_sid;
+ hid_t small_cube_yz_slice_0_sid;
+ hid_t small_cube_yz_slice_1_sid;
+ hid_t small_cube_yz_slice_2_sid;
+ hid_t small_cube_yz_slice_3_sid;
+ hsize_t small_cube_dims[] = {10, 10, 10};
+ hsize_t start[3];
+ hsize_t stride[3];
+ hsize_t count[3];
+ hsize_t block[3];
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ MESSAGE(7, (" Smoke check 2: Checker board slices through a cube.\n"));
+
+ /* Create the 10 x 10 dataspace */
+ small_square_sid = H5Screate_simple(2, small_cube_dims, NULL);
+ CHECK(small_square_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 0; /* x */
+ start[1] = 0; /* y */
+
+ stride[0] = 4; /* x */
+ stride[1] = 4; /* y */
+
+ count[0] = 3; /* x */
+ count[1] = 3; /* y */
+
+ block[0] = 2; /* x */
+ block[1] = 2; /* y */
+ ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 2; /* x */
+ start[1] = 2; /* y */
+
+ stride[0] = 4; /* x */
+ stride[1] = 4; /* y */
+
+ count[0] = 2; /* x */
+ count[1] = 2; /* y */
+
+ block[0] = 2; /* x */
+ block[1] = 2; /* y */
+ ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xy axis */
+ small_cube_xy_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xy_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xy_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_2_sid, FAIL, "H5Screate_simple");
+
+
+ start[0] = 0; /* x */
+ start[1] = 0; /* y */
+ start[2] = 0; /* z */
+
+ stride[0] = 4; /* x */
+ stride[1] = 4; /* y */
+ stride[2] = 20; /* z -- large enough that there will only be one slice */
+
+ count[0] = 3; /* x */
+ count[1] = 3; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 2; /* y */
+ block[2] = 1; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[2] = 3;
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[2] = 9;
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ start[0] = 2; /* x */
+ start[1] = 2; /* y */
+ start[2] = 0; /* z */
+
+ stride[0] = 4; /* x */
+ stride[1] = 4; /* y */
+ stride[2] = 20; /* z -- large enough that there will only be one slice */
+
+ count[0] = 2; /* x */
+ count[1] = 2; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 2; /* y */
+ block[2] = 1; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[2] = 3;
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[2] = 9;
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xz axis */
+ small_cube_xz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xz_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_2_sid, FAIL, "H5Screate_simple");
+
+
+ start[0] = 0; /* x */
+ start[1] = 0; /* y */
+ start[2] = 0; /* z */
+
+ stride[0] = 4; /* x */
+ stride[1] = 20; /* y -- large enough that there will only be one slice */
+ stride[2] = 4; /* z */
+
+ count[0] = 3; /* x */
+ count[1] = 1; /* y */
+ count[2] = 3; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 1; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[1] = 5;
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[1] = 9;
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 2; /* x */
+ start[1] = 0; /* y */
+ start[2] = 2; /* z */
+
+ stride[0] = 4; /* x */
+ stride[1] = 20; /* y -- large enough that there will only be one slice */
+ stride[2] = 4; /* z */
+
+ count[0] = 2; /* x */
+ count[1] = 1; /* y */
+ count[2] = 2; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 1; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[1] = 5;
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[1] = 9;
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslabs parallel to the yz axis */
+ small_cube_yz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_2_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_3_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_3_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 0; /* x */
+ start[1] = 0; /* y */
+ start[2] = 0; /* z */
+
+ stride[0] = 20; /* x -- large enough that there will only be one slice */
+ stride[1] = 4; /* y */
+ stride[2] = 4; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 3; /* y */
+ count[2] = 3; /* z */
+
+ block[0] = 1; /* x */
+ block[1] = 2; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 8;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 9;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 3;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ start[0] = 0; /* x */
+ start[1] = 2; /* y */
+ start[2] = 2; /* z */
+
+ stride[0] = 20; /* x -- large enough that there will only be one slice */
+ stride[1] = 4; /* y */
+ stride[2] = 4; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 2; /* y */
+ count[2] = 2; /* z */
+
+ block[0] = 1; /* x */
+ block[1] = 2; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 8;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 9;
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 4;
+ /* This test gets the right answer, but it fails the shape same
+ * test in an unexpected point. Bring this up with Quincey, as
+ * the oddness looks like it is not related to my code.
+ * -- JRM
+ */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* setup is done -- run the tests: */
+
+ /* Compare against "xy" selection */
+ check = H5S_select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Compare against "xz" selection */
+ check = H5S_select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Compare against "yz" selection */
+ check = H5S_select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_3_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(small_square_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_xy_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xy_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xy_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_xz_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xz_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xz_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_yz_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_3_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_shape_same_dr__smoke_check_2() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr__smoke_check_3():
+**
+** Create a square, 2 D data space (10 X 10), and select an
+** irregular hyper slab as follows:
+**
+** y
+** 9 - - - - - - - - - -
+** 8 - - - - - - - - - -
+** 7 - - - * * * * - - -
+** 6 - - * * * * * - - -
+** 5 - - * * - - - - - -
+** 4 - - * * - * * - - -
+** 3 - - * * - * * - - -
+** 2 - - - - - - - - - -
+** 1 - - - - - - - - - -
+** 0 - - - - - - - - - -
+** 0 1 2 3 4 5 6 7 8 9 x
+**
+** where asterisks indicate selected elements, and dashes
+** indicate unselected elements.
+**
+** Similarly, create nine, 3 D data spaces (10 X 10 X 10),
+** and select similar irregular hyper slabs in each, three
+** with the slab parallel to the xy plane, three parallel
+** to the xz plane, and three parallel to the yz plane.
+** Further, translate the irregular slab in 2/3rds of the
+** cases.
+**
+** Assuming that z is the fastest changing dimension,
+** H5S_select_shape_same() should return TRUE when
+** comparing the 2 D irregular hyperslab selection
+** against the irregular hyperslab selections parallel
+** to the yz plane in the 3 D space, and FALSE when
+** comparing it against the irregular hyper slabs
+** selections parallel to the xy or xz planes.
+**
+****************************************************************/
+static void
+test_shape_same_dr__smoke_check_3(void)
+{
+ hid_t small_square_sid;
+ hid_t small_cube_xy_slice_0_sid;
+ hid_t small_cube_xy_slice_1_sid;
+ hid_t small_cube_xy_slice_2_sid;
+ hid_t small_cube_xz_slice_0_sid;
+ hid_t small_cube_xz_slice_1_sid;
+ hid_t small_cube_xz_slice_2_sid;
+ hid_t small_cube_yz_slice_0_sid;
+ hid_t small_cube_yz_slice_1_sid;
+ hid_t small_cube_yz_slice_2_sid;
+ hsize_t small_cube_dims[] = {10, 10, 10};
+ hsize_t start[3];
+ hsize_t stride[3];
+ hsize_t count[3];
+ hsize_t block[3];
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ MESSAGE(7, (" Smoke check 3: Offset subsets of slices through a cube.\n"));
+
+ /* Create the 10 x 10 dataspace */
+ small_square_sid = H5Screate_simple(2, small_cube_dims, NULL);
+ CHECK(small_square_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 2; /* x */
+ start[1] = 3; /* y */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+
+ block[0] = 2; /* x */
+ block[1] = 4; /* y */
+ ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 3; /* x */
+ start[1] = 6; /* y */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+
+ block[0] = 4; /* x */
+ block[1] = 2; /* y */
+ ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 5; /* x */
+ start[1] = 3; /* y */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+
+ block[0] = 2; /* x */
+ block[1] = 2; /* y */
+ ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xy axis */
+ small_cube_xy_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xy_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xy_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xy_slice_2_sid, FAIL, "H5Screate_simple");
+
+
+ start[0] = 2; /* x */
+ start[1] = 3; /* y */
+ start[2] = 5; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 4; /* y */
+ block[2] = 1; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[0] -= 1; /* x */
+ start[1] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[1] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 3; /* x */
+ start[1] = 6; /* y */
+ start[2] = 5; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 4; /* x */
+ block[1] = 2; /* y */
+ block[2] = 1; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[0] -= 1; /* x */
+ start[1] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[1] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 5; /* x */
+ start[1] = 3; /* y */
+ start[2] = 5; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 2; /* y */
+ block[2] = 1; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[0] -= 1; /* x */
+ start[1] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[1] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xz axis */
+ small_cube_xz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xz_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_xz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_xz_slice_2_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 2; /* x */
+ start[1] = 5; /* y */
+ start[2] = 3; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 1; /* y */
+ block[2] = 4; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[0] -= 1; /* x */
+ start[2] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[2] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 3; /* x */
+ start[1] = 5; /* y */
+ start[2] = 6; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 4; /* x */
+ block[1] = 1; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[0] -= 1; /* x */
+ start[2] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[2] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 5; /* x */
+ start[1] = 5; /* y */
+ start[2] = 3; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 2; /* x */
+ block[1] = 1; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[0] -= 1; /* x */
+ start[2] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[2] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+/* QAK: Start here.
+ */
+ /* Create the 10 X 10 X 10 dataspaces for the hyperslabs parallel to the yz axis */
+ small_cube_yz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_0_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_1_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_1_sid, FAIL, "H5Screate_simple");
+
+ small_cube_yz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL);
+ CHECK(small_cube_yz_slice_2_sid, FAIL, "H5Screate_simple");
+
+ start[0] = 8; /* x */
+ start[1] = 2; /* y */
+ start[2] = 3; /* z */
+
+ stride[0] = 20; /* x -- large enough that there will only be one slice */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 1; /* x */
+ block[1] = 2; /* y */
+ block[2] = 4; /* z */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[1] -= 1; /* x */
+ start[2] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[2] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 8; /* x */
+ start[1] = 3; /* y */
+ start[2] = 6; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 1; /* x */
+ block[1] = 4; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[1] -= 1; /* x */
+ start[2] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[2] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start[0] = 8; /* x */
+ start[1] = 5; /* y */
+ start[2] = 3; /* z */
+
+ stride[0] = 20; /* x */
+ stride[1] = 20; /* y */
+ stride[2] = 20; /* z */
+
+ count[0] = 1; /* x */
+ count[1] = 1; /* y */
+ count[2] = 1; /* z */
+
+ block[0] = 1; /* x */
+ block[1] = 2; /* y */
+ block[2] = 2; /* z */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the starting point to the origin */
+ start[1] -= 1; /* x */
+ start[2] -= 2; /* y */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* move the irregular selection to the upper right hand corner */
+ start[0] += 5; /* x */
+ start[2] += 5; /* y */
+ ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* setup is done -- run the tests: */
+
+ /* Compare against "xy" selection */
+ check = H5S_select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Compare against "xz" selection */
+ check = H5S_select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Compare against "yz" selection */
+ check = H5S_select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(small_square_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_xy_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xy_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xy_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_xz_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xz_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_xz_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(small_cube_yz_slice_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(small_cube_yz_slice_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_shape_same_dr__smoke_check_3() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr__smoke_check_4():
+**
+** Create a square, 2 D data space (10 X 10), and select
+** the entire space.
+**
+** Similarly, create 3 D and 4 D data spaces:
+**
+** (1 X 10 X 10)
+** (10 X 1 X 10)
+** (10 X 10 X 1)
+** (10 X 10 X 10)
+**
+** (1 X 1 X 10 X 10)
+** (1 X 10 X 1 X 10)
+** (1 X 10 X 10 X 1)
+** (10 X 1 X 1 X 10)
+** (10 X 1 X 10 X 1)
+** (10 X 10 X 1 X 1)
+** (10 X 1 X 10 X 10)
+**
+** And select these entire spaces as well.
+**
+** Compare the 2 D space against all the other spaces
+** with H5S_select_shape_same(). The (1 X 10 X 10) &
+** (1 X 1 X 10 X 10) should return TRUE. All others
+** should return FALSE.
+**
+****************************************************************/
+static void
+test_shape_same_dr__smoke_check_4(void)
+{
+ hid_t square_sid;
+ hid_t three_d_space_0_sid;
+ hid_t three_d_space_1_sid;
+ hid_t three_d_space_2_sid;
+ hid_t three_d_space_3_sid;
+ hid_t four_d_space_0_sid;
+ hid_t four_d_space_1_sid;
+ hid_t four_d_space_2_sid;
+ hid_t four_d_space_3_sid;
+ hid_t four_d_space_4_sid;
+ hid_t four_d_space_5_sid;
+ hid_t four_d_space_6_sid;
+ hsize_t dims[] = {10, 10, 10, 10};
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ MESSAGE(7, (" Smoke check 4: Spaces of different dimension but same size.\n"));
+
+ /* Create the 10 x 10 dataspace */
+ square_sid = H5Screate_simple(2, dims, NULL);
+ CHECK(square_sid, FAIL, "H5Screate_simple");
+
+ /* create (1 X 10 X 10) data space */
+ dims[0] = 1;
+ dims[1] = 10;
+ dims[2] = 10;
+ three_d_space_0_sid = H5Screate_simple(3, dims, NULL);
+ CHECK(three_d_space_0_sid, FAIL, "H5Screate_simple");
+
+ /* create (10 X 1 X 10) data space */
+ dims[0] = 10;
+ dims[1] = 1;
+ dims[2] = 10;
+ three_d_space_1_sid = H5Screate_simple(3, dims, NULL);
+ CHECK(three_d_space_1_sid, FAIL, "H5Screate_simple");
+
+ /* create (10 X 10 X 1) data space */
+ dims[0] = 10;
+ dims[1] = 10;
+ dims[2] = 1;
+ three_d_space_2_sid = H5Screate_simple(3, dims, NULL);
+ CHECK(three_d_space_2_sid, FAIL, "H5Screate_simple");
+
+ /* create (10 X 10 X 10) data space */
+ dims[0] = 10;
+ dims[1] = 10;
+ dims[2] = 10;
+ three_d_space_3_sid = H5Screate_simple(3, dims, NULL);
+ CHECK(three_d_space_3_sid, FAIL, "H5Screate_simple");
+
+
+ /* create (1 X 1 X 10 X 10) data space */
+ dims[0] = 1;
+ dims[1] = 1;
+ dims[2] = 10;
+ dims[3] = 10;
+ four_d_space_0_sid = H5Screate_simple(4, dims, NULL);
+ CHECK(four_d_space_0_sid, FAIL, "H5Screate_simple");
+
+ /* create (1 X 10 X 1 X 10) data space */
+ dims[0] = 1;
+ dims[1] = 10;
+ dims[2] = 1;
+ dims[3] = 10;
+ four_d_space_1_sid = H5Screate_simple(4, dims, NULL);
+ CHECK(four_d_space_1_sid, FAIL, "H5Screate_simple");
+
+ /* create (1 X 10 X 10 X 1) data space */
+ dims[0] = 1;
+ dims[1] = 10;
+ dims[2] = 10;
+ dims[3] = 1;
+ four_d_space_2_sid = H5Screate_simple(4, dims, NULL);
+ CHECK(four_d_space_2_sid, FAIL, "H5Screate_simple");
+
+ /* create (10 X 1 X 1 X 10) data space */
+ dims[0] = 10;
+ dims[1] = 1;
+ dims[2] = 1;
+ dims[3] = 10;
+ four_d_space_3_sid = H5Screate_simple(4, dims, NULL);
+ CHECK(four_d_space_3_sid, FAIL, "H5Screate_simple");
+
+ /* create (10 X 1 X 10 X 1) data space */
+ dims[0] = 10;
+ dims[1] = 1;
+ dims[2] = 10;
+ dims[3] = 1;
+ four_d_space_4_sid = H5Screate_simple(4, dims, NULL);
+ CHECK(four_d_space_4_sid, FAIL, "H5Screate_simple");
+
+ /* create (10 X 10 X 1 X 1) data space */
+ dims[0] = 10;
+ dims[1] = 10;
+ dims[2] = 1;
+ dims[3] = 1;
+ four_d_space_5_sid = H5Screate_simple(4, dims, NULL);
+ CHECK(four_d_space_5_sid, FAIL, "H5Screate_simple");
+
+ /* create (10 X 1 X 10 X 10) data space */
+ dims[0] = 10;
+ dims[1] = 1;
+ dims[2] = 10;
+ dims[3] = 10;
+ four_d_space_6_sid = H5Screate_simple(4, dims, NULL);
+ CHECK(four_d_space_6_sid, FAIL, "H5Screate_simple");
+
+
+ /* setup is done -- run the tests: */
+
+ check = H5S_select_shape_same_test(three_d_space_0_sid, square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(three_d_space_1_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(three_d_space_2_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(three_d_space_3_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ check = H5S_select_shape_same_test(four_d_space_0_sid, square_sid);
+ VERIFY(check, TRUE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(four_d_space_1_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(four_d_space_2_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(four_d_space_3_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(four_d_space_4_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(four_d_space_5_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+ check = H5S_select_shape_same_test(four_d_space_6_sid, square_sid);
+ VERIFY(check, FALSE, "H5S_select_shape_same_test");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(square_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(three_d_space_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(three_d_space_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(three_d_space_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(three_d_space_3_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ ret = H5Sclose(four_d_space_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(four_d_space_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(four_d_space_2_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(four_d_space_3_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(four_d_space_4_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(four_d_space_5_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(four_d_space_6_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_shape_same_dr__smoke_check_4() */
+
+/****************************************************************
+**
+** test_shape_same_dr__full_space_vs_slice(): Tests selection
+** of a full n-cube data space vs an n-dimensional slice of
+** of an m-cube (m > n) in a call to H5S_select_shape_same().
+** Note that this test does not require the n-cube and the
+** n-dimensional slice to have the same rank (although
+** H5S_select_shape_same() should always return FALSE if
+** they don't).
+**
+** Per Quincey's suggestion, only test up to 5 dimensional
+** spaces.
+**
+****************************************************************/
+static void
+test_shape_same_dr__full_space_vs_slice(int test_num,
+ int small_rank,
+ int large_rank,
+ int offset,
+ hsize_t edge_size,
+ hbool_t dim_selected[],
+ hbool_t expected_result)
+{
+ char test_desc_0[128];
+ char test_desc_1[128];
+ int i;
+ hid_t n_cube_0_sid; /* the fully selected hyper cube */
+ hid_t n_cube_1_sid; /* the hyper cube in which a slice is selected */
+ hsize_t dims[SS_DR_MAX_RANK];
+ hsize_t start[SS_DR_MAX_RANK];
+ hsize_t * start_ptr;
+ hsize_t stride[SS_DR_MAX_RANK];
+ hsize_t * stride_ptr;
+ hsize_t count[SS_DR_MAX_RANK];
+ hsize_t * count_ptr;
+ hsize_t block[SS_DR_MAX_RANK];
+ hsize_t * block_ptr;
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ HDassert( 0 < small_rank );
+ HDassert( small_rank <= large_rank );
+ HDassert( large_rank <= SS_DR_MAX_RANK );
+ HDassert( 0 <= offset );
+ HDassert( offset < large_rank );
+ HDassert( edge_size > 0 );
+ HDassert( edge_size <= 1000 );
+
+ sprintf(test_desc_0,
+ "\tn-cube slice through m-cube (n <= m) test %d.\n",
+ test_num);
+ MESSAGE(7, (test_desc_0));
+
+ /* This statement must be updated if SS_DR_MAX_RANK is changed */
+ sprintf(test_desc_1,
+ "\t\tranks: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d.\n",
+ small_rank, large_rank, offset,
+ (int)dim_selected[0],
+ (int)dim_selected[1],
+ (int)dim_selected[2],
+ (int)dim_selected[3],
+ (int)dim_selected[4]);
+ MESSAGE(7, (test_desc_1));
+
+ /* copy the edge size into the dims array */
+ for(i = 0; i < SS_DR_MAX_RANK; i++)
+ dims[i] = edge_size;
+
+ /* Create the small n-cube */
+ n_cube_0_sid = H5Screate_simple(small_rank, dims, NULL);
+ CHECK(n_cube_0_sid, FAIL, "H5Screate_simple");
+
+
+ /* Create the large n-cube */
+ n_cube_1_sid = H5Screate_simple(large_rank, dims, NULL);
+ CHECK(n_cube_1_sid, FAIL, "H5Screate_simple");
+
+ /* set up start, stride, count, and block for the hyperslab selection */
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ stride[i] = 2 * edge_size; /* a bit silly in this case */
+ count[i] = 1;
+ if(dim_selected[i]) {
+ start[i] = 0;
+ block[i] = edge_size;
+ } /* end if */
+ else {
+ start[i] = (hsize_t)offset;
+ block[i] = 1;
+ } /* end else */
+ } /* end for */
+
+ /* since large rank may be less than SS_DR_MAX_RANK, we may not
+ * use the entire start, stride, count, and block arrays. This
+ * is a problem, since it is inconvenient to set up the dim_selected
+ * array to reflect the large rank, and thus if large_rank <
+ * SS_DR_MAX_RANK, we need to hide the lower index entries
+ * from H5Sselect_hyperslab().
+ *
+ * Do this by setting up pointers to the first valid entry in start,
+ * stride, count, and block below, and pass these pointers in
+ * to H5Sselect_hyperslab() instead of the array base addresses.
+ */
+
+ i = SS_DR_MAX_RANK - large_rank;
+ HDassert(i >= 0);
+
+ start_ptr = &(start[i]);
+ stride_ptr = &(stride[i]);
+ count_ptr = &(count[i]);
+ block_ptr = &(block[i]);
+
+
+ /* select the hyper slab */
+ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET,
+ start_ptr, stride_ptr, count_ptr, block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* setup is done -- run the test: */
+ check = H5S_select_shape_same_test(n_cube_0_sid, n_cube_1_sid);
+ VERIFY(check, expected_result, "test_shape_same_dr__full_space_vs_slice");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(n_cube_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(n_cube_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_shape_same_dr__full_space_vs_slice() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr__run_full_space_vs_slice_tests():
+**
+** Run the est_shape_same_dr__full_space_vs_slice() test
+** over a variety of ranks and offsets.
+**
+** At present, we test H5S_select_shape_same() with
+** fully selected 1, 2, 3, and 4 cubes as one parameter, and
+** 1, 2, 3, and 4 dimensional slices through a n-cube of rank
+** no more than 5 (and at least the rank of the slice).
+** We stop at rank 5, as Quincey suggested that it would be
+** sufficient.
+**
+** All the n-cubes will have lengths of the same size, so
+** H5S_select_shape_same() should return true iff:
+**
+** 1) the rank for the fully selected n cube equals the
+** number of dimensions selected in the slice through the
+** m-cube (m >= n).
+**
+** 2) The dimensions selected in the slice through the m-cube
+** are the dimesnions with the most quickly changing
+** indices.
+**
+****************************************************************/
+static void
+test_shape_same_dr__run_full_space_vs_slice_tests(void)
+{
+ hbool_t dim_selected[5];
+ hbool_t expected_result;
+ int i, j;
+ int v, w, x, y, z;
+ int test_num = 0;
+ int small_rank;
+ int large_rank;
+ hsize_t edge_size = 10;
+
+ for(large_rank = 1; large_rank <= 5; large_rank++) {
+ for(small_rank = 1; small_rank <= large_rank; small_rank++) {
+ v = 0;
+ do {
+ if(v == 0)
+ dim_selected[0] = FALSE;
+ else
+ dim_selected[0] = TRUE;
+
+ w = 0;
+ do {
+ if(w == 0)
+ dim_selected[1] = FALSE;
+ else
+ dim_selected[1] = TRUE;
+
+ x = 0;
+ do {
+ if(x == 0)
+ dim_selected[2] = FALSE;
+ else
+ dim_selected[2] = TRUE;
+
+ y = 0;
+ do {
+ if(y == 0)
+ dim_selected[3] = FALSE;
+ else
+ dim_selected[3] = TRUE;
+
+ z = 0;
+ do {
+ if(z == 0)
+ dim_selected[4] = FALSE;
+ else
+ dim_selected[4] = TRUE;
+
+ /* compute the expected result: */
+ i = 0;
+ j = 4;
+ expected_result = TRUE;
+ while((i < small_rank) && expected_result) {
+ if(!dim_selected[j])
+ expected_result = FALSE;
+ i++;
+ j--;
+ } /* end while */
+
+ while((i < large_rank) && expected_result) {
+ if(dim_selected[j])
+ expected_result = FALSE;
+ i++;
+ j--;
+ } /* end while */
+
+
+ /* everything is set up -- run the tests */
+
+ test_shape_same_dr__full_space_vs_slice
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ 0,
+ edge_size,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__full_space_vs_slice
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ large_rank / 2,
+ edge_size,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__full_space_vs_slice
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ large_rank - 1,
+ edge_size,
+ dim_selected,
+ expected_result
+ );
+
+ z++;
+ } while((z < 2) && (large_rank >= 1));
+
+ y++;
+ } while((y < 2) && (large_rank >= 2));
+
+ x++;
+ } while((x < 2) && (large_rank >= 3));
+
+ w++;
+ } while((w < 2) && (large_rank >= 4));
+
+ v++;
+ } while((v < 2) && (large_rank >= 5));
+ } /* end for */
+ } /* end for */
+
+} /* test_shape_same_dr__run_full_space_vs_slice_tests() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr__checkerboard(): Tests selection of a
+** "checker board" subset of a full n-cube data space vs
+** a "checker board" n-dimensional slice of an m-cube (m > n).
+** in a call to H5S_select_shape_same().
+**
+** Note that this test does not require the n-cube and the
+** n-dimensional slice to have the same rank (although
+** H5S_select_shape_same() should always return FALSE if
+** they don't).
+**
+** Per Quincey's suggestion, only test up to 5 dimensional
+** spaces.
+**
+****************************************************************/
+static void
+test_shape_same_dr__checkerboard(int test_num,
+ int small_rank,
+ int large_rank,
+ int offset,
+ hsize_t edge_size,
+ hsize_t checker_size,
+ hbool_t dim_selected[],
+ hbool_t expected_result)
+{
+ char test_desc_0[128];
+ char test_desc_1[128];
+ int i;
+ int dims_selected = 0;
+ hid_t n_cube_0_sid; /* the checker board selected
+ * hyper cube
+ */
+ hid_t n_cube_1_sid; /* the hyper cube in which a
+ * checkerboard slice is selected
+ */
+ hsize_t dims[SS_DR_MAX_RANK];
+ hsize_t base_start[2];
+ hsize_t start[SS_DR_MAX_RANK];
+ hsize_t * start_ptr;
+ hsize_t base_stride[2];
+ hsize_t stride[SS_DR_MAX_RANK];
+ hsize_t * stride_ptr;
+ hsize_t base_count[2];
+ hsize_t count[SS_DR_MAX_RANK];
+ hsize_t * count_ptr;
+ hsize_t base_block[2];
+ hsize_t block[SS_DR_MAX_RANK];
+ hsize_t * block_ptr;
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ HDassert( 0 < small_rank );
+ HDassert( small_rank <= large_rank );
+ HDassert( large_rank <= SS_DR_MAX_RANK );
+ HDassert( 0 < checker_size );
+ HDassert( checker_size <= edge_size );
+ HDassert( edge_size <= 1000 );
+ HDassert( 0 <= offset );
+ HDassert( offset < (int)edge_size );
+
+ for(i = SS_DR_MAX_RANK - large_rank; i < SS_DR_MAX_RANK; i++)
+ if(dim_selected[i] == TRUE)
+ dims_selected++;
+
+ HDassert( dims_selected >= 0 );
+ HDassert( dims_selected <= large_rank );
+
+ sprintf(test_desc_0,
+ "\tcheckerboard n-cube slice through m-cube (n <= m) test %d.\n",
+ test_num);
+ MESSAGE(7, (test_desc_0));
+
+ /* This statement must be updated if SS_DR_MAX_RANK is changed */
+ sprintf(test_desc_1,
+ "\tranks: %d/%d edge/chkr size: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d:%d.\n",
+ small_rank, large_rank,
+ (int)edge_size, (int)checker_size,
+ offset,
+ (int)dim_selected[0],
+ (int)dim_selected[1],
+ (int)dim_selected[2],
+ (int)dim_selected[3],
+ (int)dim_selected[4],
+ dims_selected);
+ MESSAGE(7, (test_desc_1));
+
+ /* copy the edge size into the dims array */
+ for(i = 0; i < SS_DR_MAX_RANK; i++)
+ dims[i] = edge_size;
+
+ /* Create the small n-cube */
+ n_cube_0_sid = H5Screate_simple(small_rank, dims, NULL);
+ CHECK(n_cube_0_sid, FAIL, "H5Screate_simple");
+
+ /* Select a "checkerboard" pattern in the small n-cube.
+ *
+ * In the 1-D case, the "checkerboard" would look like this:
+ *
+ * * * - - * * - - * *
+ *
+ * and in the 2-D case, it would look like this:
+ *
+ * * * - - * * - - * *
+ * * * - - * * - - * *
+ * - - * * - - * * - -
+ * - - * * - - * * - -
+ * * * - - * * - - * *
+ * * * - - * * - - * *
+ * - - * * - - * * - -
+ * - - * * - - * * - -
+ * * * - - * * - - * *
+ * * * - - * * - - * *
+ *
+ * In both cases, asterisks indicate selected elements,
+ * and dashes indicate unselected elements.
+ *
+ * 3-D and 4-D ascii art is somewhat painful, so I'll
+ * leave those selections to your imagination. :-)
+ *
+ * Note, that since the edge_size and checker_size are
+ * parameters that are passed in, the selection need
+ * not look exactly like the selection shown above.
+ * At present, the function allows checker sizes that
+ * are not even divisors of the edge size -- thus
+ * something like the following is also possible:
+ *
+ * * * * - - - * * * -
+ * * * * - - - * * * -
+ * * * * - - - * * * -
+ * - - - * * * - - - *
+ * - - - * * * - - - *
+ * - - - * * * - - - *
+ * * * * - - - * * * -
+ * * * * - - - * * * -
+ * * * * - - - * * * -
+ * - - - * * * - - - *
+ *
+ * As the above pattern can't be selected in one
+ * call to H5Sselect_hyperslab(), and since the
+ * values in the start, stride, count, and block
+ * arrays will be repeated over all entries in
+ * the selected space case, and over all selected
+ * dimensions in the selected hyperslab case, we
+ * compute these values first and store them in
+ * in the base_start, base_stride, base_count,
+ * and base_block arrays.
+ */
+
+ base_start[0] = 0;
+ base_start[1] = checker_size;
+
+ base_stride[0] = 2 * checker_size;
+ base_stride[1] = 2 * checker_size;
+
+ /* Note that the following computation depends on the C99
+ * requirement that integer division discard any fraction
+ * (truncation towards zero) to function correctly. As we
+ * now require C99, this shouldn't be a problem, but noting
+ * it may save us some pain if we are ever obliged to support
+ * pre-C99 compilers again.
+ */
+
+ base_count[0] = edge_size / (checker_size * 2);
+ if((edge_size % (checker_size * 2)) > 0)
+ base_count[0]++;
+
+ base_count[1] = (edge_size - checker_size) / (checker_size * 2);
+ if(((edge_size - checker_size) % (checker_size * 2)) > 0)
+ base_count[1]++;
+
+ base_block[0] = checker_size;
+ base_block[1] = checker_size;
+
+ /* now setup start, stride, count, and block arrays for
+ * the first call to H5Sselect_hyperslab().
+ */
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ start[i] = base_start[0];
+ stride[i] = base_stride[0];
+ count[i] = base_count[0];
+ block[i] = base_block[0];
+ } /* end for */
+
+ ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_SET,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* if small_rank == 1, or if edge_size == checker_size, we
+ * are done, as either there is no added dimension in which
+ * to place offset selected "checkers".
+ *
+ * Otherwise, set up start, stride, count and block, and
+ * make the additional selection.
+ */
+
+ if((small_rank > 1) && (checker_size < edge_size)) {
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ start[i] = base_start[1];
+ stride[i] = base_stride[1];
+ count[i] = base_count[1];
+ block[i] = base_block[1];
+ } /* end for */
+
+ ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_OR,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+ } /* end if */
+
+ /* Wierdness alert:
+ *
+ * Some how, it seems that selections can extend beyond the
+ * boundaries of the target data space -- hence the following
+ * code to manually clip the selection back to the data space
+ * proper.
+ */
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ start[i] = 0;
+ stride[i] = edge_size;
+ count[i] = 1;
+ block[i] = edge_size;
+ } /* end for */
+
+ ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_AND,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the large n-cube */
+ n_cube_1_sid = H5Screate_simple(large_rank, dims, NULL);
+ CHECK(n_cube_1_sid, FAIL, "H5Screate_simple");
+
+
+ /* Now select the checkerboard selection in the (possibly larger) n-cube.
+ *
+ * Since we have already calculated the base start, stride, count,
+ * and block, re-use the values in setting up start, stride, count,
+ * and block.
+ */
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ if(dim_selected[i]) {
+ start[i] = base_start[0];
+ stride[i] = base_stride[0];
+ count[i] = base_count[0];
+ block[i] = base_block[0];
+ } /* end if */
+ else {
+ start[i] = (hsize_t)offset;
+ stride[i] = (hsize_t)(2 * edge_size);
+ count[i] = 1;
+ block[i] = 1;
+ } /* end else */
+ } /* end for */
+
+ /* Since large rank may be less than SS_DR_MAX_RANK, we may not
+ * use the entire start, stride, count, and block arrays. This
+ * is a problem, since it is inconvenient to set up the dim_selected
+ * array to reflect the large rank, and thus if large_rank <
+ * SS_DR_MAX_RANK, we need to hide the lower index entries
+ * from H5Sselect_hyperslab().
+ *
+ * Do this by setting up pointers to the first valid entry in start,
+ * stride, count, and block below, and pass these pointers in
+ * to H5Sselect_hyperslab() instead of the array base addresses.
+ */
+
+ i = SS_DR_MAX_RANK - large_rank;
+ HDassert( i >= 0 );
+
+ start_ptr = &(start[i]);
+ stride_ptr = &(stride[i]);
+ count_ptr = &(count[i]);
+ block_ptr = &(block[i]);
+
+ /* select the hyper slab */
+ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET,
+ start_ptr, stride_ptr, count_ptr, block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* As before, if the number of dimensions selected is less than or
+ * equal to 1, or if edge_size == checker_size, we are done, as
+ * either there is no added dimension in which to place offset selected
+ * "checkers", or the hyperslab is completely occupied by one
+ * "checker".
+ *
+ * Otherwise, set up start, stride, count and block, and
+ * make the additional selection.
+ */
+ if((dims_selected > 1) && (checker_size < edge_size)) {
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ if(dim_selected[i]) {
+ start[i] = base_start[1];
+ stride[i] = base_stride[1];
+ count[i] = base_count[1];
+ block[i] = base_block[1];
+ } /* end if */
+ else {
+ start[i] = (hsize_t)offset;
+ stride[i] = (hsize_t)(2 * edge_size);
+ count[i] = 1;
+ block[i] = 1;
+ } /* end else */
+ } /* end for */
+
+ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_OR,
+ start_ptr, stride_ptr, count_ptr, block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+ } /* end if */
+
+
+ /* Wierdness alert:
+ *
+ * Again, it seems that selections can extend beyond the
+ * boundaries of the target data space -- hence the following
+ * code to manually clip the selection back to the data space
+ * proper.
+ */
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ start[i] = 0;
+ stride[i] = edge_size;
+ count[i] = 1;
+ block[i] = edge_size;
+ } /* end for */
+
+ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_AND,
+ start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* setup is done -- run the test: */
+ check = H5S_select_shape_same_test(n_cube_0_sid, n_cube_1_sid);
+ VERIFY(check, expected_result, "test_shape_same_dr__checkerboard");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(n_cube_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(n_cube_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_shape_same_dr__checkerboard() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr__run_checkerboard_tests():
+**
+** In this set of tests, we test H5S_select_shape_same()
+** with a "checkerboard" selection of 1, 2, 3, and 4 cubes as
+** one parameter, and 1, 2, 3, and 4 dimensional checkerboard
+** slices through a n-cube of rank no more than 5 (and at
+** least the rank of the slice).
+**
+** All the n-cubes will have lengths of the same size, so
+** H5S_select_shape_same() should return true iff:
+**
+** 1) the rank of the n cube equals the number of dimensions
+** selected in the checker board slice through the m-cube
+** (m >= n).
+**
+** 2) The dimensions selected in the checkerboard slice
+** through the m-cube are the dimensions with the most
+** quickly changing indices.
+**
+****************************************************************/
+static void
+test_shape_same_dr__run_checkerboard_tests(void)
+{
+ hbool_t dim_selected[5];
+ hbool_t expected_result;
+ int i, j;
+ int v, w, x, y, z;
+ int test_num = 0;
+ int small_rank;
+ int large_rank;
+
+ for(large_rank = 1; large_rank <= 5; large_rank++) {
+ for(small_rank = 1; small_rank <= large_rank; small_rank++) {
+ v = 0;
+ do {
+ if(v == 0)
+ dim_selected[0] = FALSE;
+ else
+ dim_selected[0] = TRUE;
+
+ w = 0;
+ do {
+ if(w == 0)
+ dim_selected[1] = FALSE;
+ else
+ dim_selected[1] = TRUE;
+
+ x = 0;
+ do {
+ if(x == 0)
+ dim_selected[2] = FALSE;
+ else
+ dim_selected[2] = TRUE;
+
+ y = 0;
+ do {
+ if(y == 0)
+ dim_selected[3] = FALSE;
+ else
+ dim_selected[3] = TRUE;
+
+ z = 0;
+ do {
+ if(z == 0)
+ dim_selected[4] = FALSE;
+ else
+ dim_selected[4] = TRUE;
+
+
+ /* compute the expected result: */
+ i = 0;
+ j = 4;
+ expected_result = TRUE;
+ while((i < small_rank) && expected_result) {
+ if(!dim_selected[j])
+ expected_result = FALSE;
+ i++;
+ j--;
+ } /* end while */
+
+ while((i < large_rank) && expected_result) {
+ if(dim_selected[j])
+ expected_result = FALSE;
+ i++;
+ j--;
+ } /* end while */
+
+
+ /* everything is set up -- run the tests */
+
+ /* run test with edge size 16, checker
+ * size 1, and a variety of offsets
+ */
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 0,
+ /* edge_size */ 16,
+ /* checker_size */ 1,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 5,
+ /* edge_size */ 16,
+ /* checker_size */ 1,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 15,
+ /* edge_size */ 16,
+ /* checker_size */ 1,
+ dim_selected,
+ expected_result
+ );
+
+
+ /* run test with edge size 10, checker
+ * size 2, and a variety of offsets
+ */
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 0,
+ /* edge_size */ 10,
+ /* checker_size */ 2,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 5,
+ /* edge_size */ 10,
+ /* checker_size */ 2,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 9,
+ /* edge_size */ 10,
+ /* checker_size */ 2,
+ dim_selected,
+ expected_result
+ );
+
+
+ /* run test with edge size 10, checker
+ * size 3, and a variety of offsets
+ */
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 0,
+ /* edge_size */ 10,
+ /* checker_size */ 3,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 5,
+ /* edge_size */ 10,
+ /* checker_size */ 3,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 9,
+ /* edge_size */ 10,
+ /* checker_size */ 3,
+ dim_selected,
+ expected_result
+ );
+
+
+ /* run test with edge size 8, checker
+ * size 8, and a variety of offsets
+ */
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 0,
+ /* edge_size */ 8,
+ /* checker_size */ 8,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 4,
+ /* edge_size */ 8,
+ /* checker_size */ 8,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__checkerboard
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* offset */ 7,
+ /* edge_size */ 8,
+ /* checker_size */ 8,
+ dim_selected,
+ expected_result
+ );
+
+ z++;
+ } while((z < 2) && (large_rank >= 1));
+
+ y++;
+ } while((y < 2) && (large_rank >= 2));
+
+ x++;
+ } while((x < 2) && (large_rank >= 3));
+
+ w++;
+ } while((w < 2) && (large_rank >= 4));
+
+ v++;
+ } while((v < 2) && (large_rank >= 5));
+ } /* end for */
+ } /* end for */
+
+} /* test_shape_same_dr__run_checkerboard_tests() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr__irregular():
+**
+** Tests selection of an "irregular" subset of a full
+** n-cube data space vs an identical "irregular" subset
+** of an n-dimensional slice of an m-cube (m > n).
+** in a call to H5S_select_shape_same().
+**
+** Note that this test does not require the n-cube and the
+** n-dimensional slice to have the same rank (although
+** H5S_select_shape_same() should always return FALSE if
+** they don't).
+**
+****************************************************************/
+static void
+test_shape_same_dr__irregular(int test_num,
+ int small_rank,
+ int large_rank,
+ int pattern_offset,
+ int slice_offset,
+ hbool_t dim_selected[],
+ hbool_t expected_result)
+{
+ char test_desc_0[128];
+ char test_desc_1[128];
+ int edge_size = 10;
+ int i;
+ int j;
+ int k;
+ int dims_selected = 0;
+ hid_t n_cube_0_sid; /* the hyper cube containing
+ * an irregular selection
+ */
+ hid_t n_cube_1_sid; /* the hyper cube in which a
+ * slice contains an irregular
+ * selection.
+ */
+ hsize_t dims[SS_DR_MAX_RANK];
+ hsize_t start_0[SS_DR_MAX_RANK] = { 2, 2, 2, 2, 5};
+ hsize_t stride_0[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10};
+ hsize_t count_0[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1};
+ hsize_t block_0[SS_DR_MAX_RANK] = { 2, 2, 2, 2, 3};
+
+ hsize_t start_1[SS_DR_MAX_RANK] = { 2, 2, 2, 5, 2};
+ hsize_t stride_1[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10};
+ hsize_t count_1[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1};
+ hsize_t block_1[SS_DR_MAX_RANK] = { 2, 2, 2, 3, 2};
+
+ hsize_t start_2[SS_DR_MAX_RANK] = { 2, 2, 5, 2, 2};
+ hsize_t stride_2[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10};
+ hsize_t count_2[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1};
+ hsize_t block_2[SS_DR_MAX_RANK] = { 2, 2, 3, 2, 2};
+
+ hsize_t start_3[SS_DR_MAX_RANK] = { 2, 5, 2, 2, 2};
+ hsize_t stride_3[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10};
+ hsize_t count_3[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1};
+ hsize_t block_3[SS_DR_MAX_RANK] = { 2, 3, 2, 2, 2};
+
+ hsize_t start_4[SS_DR_MAX_RANK] = { 5, 2, 2, 2, 2};
+ hsize_t stride_4[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10};
+ hsize_t count_4[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1};
+ hsize_t block_4[SS_DR_MAX_RANK] = { 3, 2, 2, 2, 2};
+
+ hsize_t clip_start[SS_DR_MAX_RANK] = { 0, 0, 0, 0, 0};
+ hsize_t clip_stride[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10};
+ hsize_t clip_count[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1};
+ hsize_t clip_block[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10};
+
+
+ hsize_t *(starts[SS_DR_MAX_RANK]) =
+ {start_0, start_1, start_2, start_3, start_4};
+ hsize_t *(strides[SS_DR_MAX_RANK]) =
+ {stride_0, stride_1, stride_2, stride_3, stride_4};
+ hsize_t *(counts[SS_DR_MAX_RANK]) =
+ {count_0, count_1, count_2, count_3, count_4};
+ hsize_t *(blocks[SS_DR_MAX_RANK]) =
+ {block_0, block_1, block_2, block_3, block_4};
+
+ hsize_t start[SS_DR_MAX_RANK];
+ hsize_t * start_ptr;
+ hsize_t stride[SS_DR_MAX_RANK];
+ hsize_t * stride_ptr;
+ hsize_t count[SS_DR_MAX_RANK];
+ hsize_t * count_ptr;
+ hsize_t block[SS_DR_MAX_RANK];
+ hsize_t * block_ptr;
+ htri_t check; /* Shape comparison return value */
+ herr_t ret; /* Generic return value */
+
+ HDassert( 0 < small_rank );
+ HDassert( small_rank <= large_rank );
+ HDassert( large_rank <= SS_DR_MAX_RANK );
+ HDassert( 9 <= edge_size );
+ HDassert( edge_size <= 1000 );
+ HDassert( 0 <= slice_offset );
+ HDassert( slice_offset < edge_size );
+ HDassert( -2 <= pattern_offset );
+ HDassert( pattern_offset <= 2 );
+
+ for(i = SS_DR_MAX_RANK - large_rank; i < SS_DR_MAX_RANK; i++)
+ if(dim_selected[i] == TRUE)
+ dims_selected++;
+
+ HDassert( dims_selected >= 0 );
+ HDassert( dims_selected <= large_rank );
+
+ sprintf(test_desc_0,
+ "\tirregular sub set of n-cube slice through m-cube (n <= m) test %d.\n",
+ test_num);
+ MESSAGE(7, (test_desc_0));
+
+ /* This statement must be updated if SS_DR_MAX_RANK is changed */
+ sprintf(test_desc_1,
+ "\tranks: %d/%d edge: %d s/p offset: %d/%d dim_selected: %d/%d/%d/%d/%d:%d.\n",
+ small_rank, large_rank,
+ edge_size,
+ slice_offset, pattern_offset,
+ (int)dim_selected[0],
+ (int)dim_selected[1],
+ (int)dim_selected[2],
+ (int)dim_selected[3],
+ (int)dim_selected[4],
+ dims_selected);
+ MESSAGE(7, (test_desc_1));
+
+ /* copy the edge size into the dims array */
+ for(i = 0; i < SS_DR_MAX_RANK; i++)
+ dims[i] = (hsize_t)edge_size;
+
+ /* Create the small n-cube */
+ n_cube_0_sid = H5Screate_simple(small_rank, dims, NULL);
+ CHECK(n_cube_0_sid, FAIL, "H5Screate_simple");
+
+ /* Select an "irregular" pattern in the small n-cube. This
+ * pattern can be though of a set of four 3 x 2 x 2 X 2
+ * four dimensional prisims, each parallel to one of the
+ * axies and none of them intersecting with the other.
+ *
+ * In the lesser dimensional cases, this 4D pattern is
+ * projected onto the lower dimensional space.
+ *
+ * In the 1-D case, the projection of the pattern looks
+ * like this:
+ *
+ * - - * * - * * * - -
+ * 0 1 2 3 4 5 6 7 8 9 x
+ *
+ * and in the 2-D case, it would look like this:
+ *
+ *
+ * y
+ * 9 - - - - - - - - - -
+ * 8 - - - - - - - - - -
+ * 7 - - * * - - - - - -
+ * 6 - - * * - - - - - -
+ * 5 - - * * - - - - - -
+ * 4 - - - - - - - - - -
+ * 3 - - * * - * * * - -
+ * 2 - - * * - * * * - -
+ * 1 - - - - - - - - - -
+ * 0 - - - - - - - - - -
+ * 0 1 2 3 4 5 6 7 8 9 x
+ *
+ * In both cases, asterisks indicate selected elements,
+ * and dashes indicate unselected elements.
+ *
+ * Note that is this case, since the edge size is fixed,
+ * the pattern does not change. However, we do use the
+ * displacement parameter to allow it to be moved around
+ * within the n-cube or hyper slab.
+ */
+
+ /* first, ensure that the small n-cube has no selection */
+ ret = H5Sselect_none(n_cube_0_sid);
+ CHECK(ret, FAIL, "H5Sselect_none");
+
+ /* now, select the irregular pattern */
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_OR,
+ starts[i], strides[i], counts[i], blocks[i]);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+ } /* end for */
+
+ /* finally, clip the selection to ensure that it lies fully
+ * within the n-cube.
+ */
+ ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_AND,
+ clip_start, clip_stride, clip_count, clip_block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* Create the large n-cube */
+ n_cube_1_sid = H5Screate_simple(large_rank, dims, NULL);
+ CHECK(n_cube_1_sid, FAIL, "H5Screate_simple");
+
+ /* Ensure that the large n-cube has no selection */
+ H5Sselect_none(n_cube_1_sid);
+ CHECK(ret, FAIL, "H5Sselect_none");
+
+
+ /* Since large rank may be less than SS_DR_MAX_RANK, we may not
+ * use the entire start, stride, count, and block arrays. This
+ * is a problem, since it is inconvenient to set up the dim_selected
+ * array to reflect the large rank, and thus if large_rank <
+ * SS_DR_MAX_RANK, we need to hide the lower index entries
+ * from H5Sselect_hyperslab().
+ *
+ * Do this by setting up pointers to the first valid entry in start,
+ * stride, count, and block below, and pass these pointers in
+ * to H5Sselect_hyperslab() instead of the array base addresses.
+ */
+
+ i = SS_DR_MAX_RANK - large_rank;
+ HDassert( i >= 0 );
+
+ start_ptr = &(start[i]);
+ stride_ptr = &(stride[i]);
+ count_ptr = &(count[i]);
+ block_ptr = &(block[i]);
+
+
+ /* Now select the irregular selection in the (possibly larger) n-cube.
+ *
+ * Basic idea is to project the pattern used in the smaller n-cube
+ * onto the dimensions selected in the larger n-cube, with the displacement
+ * specified.
+ */
+ for(i = 0; i < SS_DR_MAX_RANK; i++) {
+ j = 0;
+ for(k = 0; k < SS_DR_MAX_RANK; k++) {
+ if(dim_selected[k]) {
+ start[k] = (starts[i])[j] + (hsize_t)pattern_offset;
+ stride[k] = (strides[i])[j];
+ count[k] = (counts[i])[j];
+ block[k] = (blocks[i])[j];
+ j++;
+ } /* end if */
+ else {
+ start[k] = (hsize_t)slice_offset;
+ stride[k] = (hsize_t)(2 * edge_size);
+ count[k] = 1;
+ block[k] = 1;
+ } /* end else */
+ } /* end for */
+
+ /* select the hyper slab */
+ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_OR,
+ start_ptr, stride_ptr, count_ptr, block_ptr);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+ } /* end for */
+
+ /* it is possible that the selection extends beyond the data space.
+ * clip the selection to ensure that it doesn't.
+ */
+ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_AND,
+ clip_start, clip_stride, clip_count, clip_block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+
+ /* setup is done -- run the test: */
+ check = H5S_select_shape_same_test(n_cube_0_sid, n_cube_1_sid);
+ VERIFY(check, expected_result, "test_shape_same_dr__checkerboard");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(n_cube_0_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(n_cube_1_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_shape_same_dr__irregular() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr__run_irregular_tests():
+**
+** In this set of tests, we test H5S_select_shape_same()
+** with an "irregular" subselection of 1, 2, 3, and 4 cubes as
+** one parameter, and irregular subselections of 1, 2, 3,
+** and 4 dimensional slices through a n-cube of rank no more
+** than 5 (and at least the rank of the slice) as the other.
+** Note that the "irregular" selection may be offset between
+** the n-cube and the slice.
+**
+** All the irregular selections will be identical (modulo rank)
+** so H5S_select_shape_same() should return true iff:
+**
+** 1) the rank of the n cube equals the number of dimensions
+** selected in the irregular slice through the m-cube
+** (m >= n).
+**
+** 2) The dimensions selected in the irregular slice
+** through the m-cube are the dimensions with the most
+** quickly changing indices.
+**
+****************************************************************/
+static void
+test_shape_same_dr__run_irregular_tests(void)
+{
+ hbool_t dim_selected[5];
+ hbool_t expected_result;
+ int i, j;
+ int v, w, x, y, z;
+ int test_num = 0;
+ int small_rank;
+ int large_rank;
+
+ for(large_rank = 1; large_rank <= 5; large_rank++) {
+ for(small_rank = 1; small_rank <= large_rank; small_rank++) {
+ v = 0;
+ do {
+ if(v == 0)
+ dim_selected[0] = FALSE;
+ else
+ dim_selected[0] = TRUE;
+
+ w = 0;
+ do {
+ if(w == 0)
+ dim_selected[1] = FALSE;
+ else
+ dim_selected[1] = TRUE;
+
+ x = 0;
+ do {
+ if(x == 0)
+ dim_selected[2] = FALSE;
+ else
+ dim_selected[2] = TRUE;
+
+ y = 0;
+ do {
+ if(y == 0)
+ dim_selected[3] = FALSE;
+ else
+ dim_selected[3] = TRUE;
+
+ z = 0;
+ do {
+ if(z == 0)
+ dim_selected[4] = FALSE;
+ else
+ dim_selected[4] = TRUE;
+
+
+ /* compute the expected result: */
+ i = 0;
+ j = 4;
+ expected_result = TRUE;
+ while((i < small_rank) && expected_result) {
+ if(!dim_selected[j])
+ expected_result = FALSE;
+ i++;
+ j--;
+ } /* end while */
+
+ while((i < large_rank) && expected_result) {
+ if(dim_selected[j])
+ expected_result = FALSE;
+ i++;
+ j--;
+ } /* end while */
+
+
+ /* everything is set up -- run the tests */
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ -2,
+ /* slice_offset */ 0,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ -2,
+ /* slice_offset */ 4,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ -2,
+ /* slice_offset */ 9,
+ dim_selected,
+ expected_result
+ );
+
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ 0,
+ /* slice_offset */ 0,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ 0,
+ /* slice_offset */ 6,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ 0,
+ /* slice_offset */ 9,
+ dim_selected,
+ expected_result
+ );
+
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ 2,
+ /* slice_offset */ 0,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ 2,
+ /* slice_offset */ 5,
+ dim_selected,
+ expected_result
+ );
+
+ test_shape_same_dr__irregular
+ (
+ test_num++,
+ small_rank,
+ large_rank,
+ /* pattern_offset */ 2,
+ /* slice_offset */ 9,
+ dim_selected,
+ expected_result
+ );
+
+ z++;
+ } while((z < 2) && (large_rank >= 1));
+
+ y++;
+ } while((y < 2) && (large_rank >= 2));
+
+ x++;
+ } while((x < 2) && (large_rank >= 3));
+
+ w++;
+ } while((w < 2) && (large_rank >= 4));
+
+ v++;
+ } while((v < 2 ) && (large_rank >= 5));
+ } /* end for */
+ } /* end for */
+
+} /* test_shape_same_dr__run_irregular_tests() */
+
+
+/****************************************************************
+**
+** test_shape_same_dr(): Tests selections on dataspace with
+** different ranks, to verify that "shape same" routine
+** is now handling this case correctly.
+**
+****************************************************************/
+static void
+test_shape_same_dr(void)
+{
+ /* Output message about test being performed */
+ MESSAGE(6, ("Testing Same Shape/Different Rank Comparisons\n"));
+
+
+ /* first run some smoke checks */
+ test_shape_same_dr__smoke_check_1();
+ test_shape_same_dr__smoke_check_2();
+ test_shape_same_dr__smoke_check_3();
+ test_shape_same_dr__smoke_check_4();
+
+
+ /* now run more intensive tests. */
+ test_shape_same_dr__run_full_space_vs_slice_tests();
+ test_shape_same_dr__run_checkerboard_tests();
+ test_shape_same_dr__run_irregular_tests();
+
+} /* test_shape_same_dr() */
+
/****************************************************************
**
@@ -8241,6 +13118,14 @@ test_select(void)
test_select_hyper_contig3(H5T_STD_U16LE,plist_id); /* Test yet more contiguous hyperslab selection cases */
test_select_hyper_contig3(H5T_STD_U16BE,H5P_DEFAULT); /* Test yet more contiguous hyperslab selection cases */
test_select_hyper_contig3(H5T_STD_U16BE,plist_id); /* Test yet more contiguous hyperslab selection cases */
+ test_select_hyper_contig_dr(H5T_STD_U16LE, H5P_DEFAULT);
+ test_select_hyper_contig_dr(H5T_STD_U16LE, plist_id);
+ test_select_hyper_contig_dr(H5T_STD_U16BE, H5P_DEFAULT);
+ test_select_hyper_contig_dr(H5T_STD_U16BE, plist_id);
+ test_select_hyper_checker_board_dr(H5T_STD_U16LE, H5P_DEFAULT);
+ test_select_hyper_checker_board_dr(H5T_STD_U16LE, plist_id);
+ test_select_hyper_checker_board_dr(H5T_STD_U16BE, H5P_DEFAULT);
+ test_select_hyper_checker_board_dr(H5T_STD_U16BE, plist_id);
test_select_hyper_copy(); /* Test hyperslab selection copying code */
test_select_point_copy(); /* Test point selection copying code */
test_select_hyper_offset(); /* Test selection offset code with hyperslabs */
@@ -8320,6 +13205,9 @@ test_select(void)
/* Test "same shape" routine */
test_shape_same();
+ /* Test "same shape" routine for selections of different rank */
+ test_shape_same_dr();
+
/* Test "re-build" routine */
test_space_rebuild();
diff --git a/test/tsizeslheap.h5 b/test/tsizeslheap.h5
new file mode 100644
index 0000000..c7f2adb
--- /dev/null
+++ b/test/tsizeslheap.h5
Binary files differ