summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in17
-rw-r--r--test/cmpd_dset.c71
-rw-r--r--test/dtypes.c148
-rw-r--r--test/gen_new_array.c146
-rw-r--r--test/gen_old_array.c144
-rw-r--r--test/tarray.c1849
-rw-r--r--test/tarrold.h5bin0 -> 6032 bytes
-rw-r--r--test/testhdf5.c1
-rw-r--r--test/testhdf5.h2
9 files changed, 2271 insertions, 107 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index fd97c82..a6108bf 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -47,7 +47,8 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
big.data big[0-9][0-9][0-9][0-9][0-9].h5 dtypes1.h5 dtypes2.h5 \
tattr.h5 tselect.h5 mtime.h5 ragged.h5 unlink.h5 overhead.h5 \
fillval_[0-9].h5 fillval.raw mount_[0-9].h5 ttime.h5 trefer[12].h5 \
- tvltypes.h5 tvlstr.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5
+ tvltypes.h5 tvlstr.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 \
+ tarray1.h5
CLEAN=$(TIMINGS)
## Source and object files for programs... The TEST_SRC list contains all the
@@ -58,12 +59,11 @@ CLEAN=$(TIMINGS)
TEST_SRC=big.c bittests.c chunk.c cmpd_dset.c dsets.c dtypes.c extend.c \
external.c fillval.c flush1.c flush2.c gheap.c h5test.c hyperslab.c \
iopipe.c istore.c lheap.c links.c mount.c mtime.c ohdr.c overhead.c \
- ragged.c stab.c tattr.c testhdf5.c tfile.c th5s.c titerate.c tmeta.c \
- ttime.c trefer.c tselect.c ttbbt.c tvltypes.c tvlstr.c unlink.c enum.c \
- ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \
- ttsafe_acreate.c \
- gass_write.c gass_read.c gass_append.c dpss_read.c dpss_write.c \
- srb_read.c srb_write.c srb_append.c stream_test.c
+ ragged.c stab.c tarray.c tattr.c testhdf5.c tfile.c th5s.c titerate.c \
+ tmeta.c trefer.c tselect.c ttime.c ttbbt.c tvltypes.c tvlstr.c unlink.c \
+ enum.c ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \
+ ttsafe_acreate.c gass_write.c gass_read.c gass_append.c dpss_read.c \
+ dpss_write.c srb_read.c srb_write.c srb_append.c stream_test.c
TEST_OBJ=$(TEST_SRC:.c=.lo)
@@ -83,7 +83,8 @@ timings _timings: $(TIMINGS)
## How to build the tests... They all depend on the test and hdf5 libraries.
$(TEST_PROGS): $(LIB) $(LIBHDF5)
-TESTHDF5_OBJ=testhdf5.lo tattr.lo tfile.lo titerate.lo tmeta.lo ttime.lo trefer.lo tselect.lo ttbbt.lo tvltypes.lo tvlstr.lo th5s.lo
+TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tfile.lo titerate.lo tmeta.lo \
+ ttime.lo trefer.lo tselect.lo ttbbt.lo tvltypes.lo tvlstr.lo th5s.lo
TTS_OBJ=ttsafe.lo ttsafe_dcreate.lo ttsafe_error.lo ttsafe_cancel.lo \
ttsafe_acreate.lo
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index 062707e..00ef239 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -128,10 +128,11 @@ main (int argc, char *argv[])
/* Other variables */
unsigned int i, j;
hid_t file, dataset, space, PRESERVE, fapl;
+ hid_t array_dt;
static hsize_t dim[] = {NX, NY};
hssize_t f_offset[2]; /*offset of hyperslab in file */
hsize_t h_size[2]; /*size of hyperslab */
- size_t memb_size[1] = {4};
+ hsize_t memb_size[1] = {4};
char filename[256];
h5_reset();
@@ -178,15 +179,16 @@ main (int argc, char *argv[])
}
/* Create the memory data type */
- if ((s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)))<0) goto error;
+ if ((s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)))<0)
+ goto error;
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, memb_size, NULL);
if (H5Tinsert (s1_tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s1_tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array (s1_tid, "c", HOFFSET(s1_t,c), 1, memb_size, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert (s1_tid, "d", HOFFSET(s1_t,d), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s1_tid, "e", HOFFSET(s1_t,e), H5T_NATIVE_INT)<0) {
- goto error;
- }
+ H5Tinsert (s1_tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s1_tid, "c", HOFFSET(s1_t,c), array_dt)<0 ||
+ H5Tinsert (s1_tid, "d", HOFFSET(s1_t,d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s1_tid, "e", HOFFSET(s1_t,e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
/* Create the dataset */
if ((dataset = H5Dcreate (file, "s1", s1_tid, space, H5P_DEFAULT))<0) {
@@ -208,15 +210,16 @@ main (int argc, char *argv[])
TESTING("basic compound read");
/* Create a data type for s2 */
- if ((s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)))<0) goto error;
+ if ((s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)))<0)
+ goto error;
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, memb_size, NULL);
if (H5Tinsert (s2_tid, "a", HOFFSET(s2_t,a), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s2_tid, "b", HOFFSET(s2_t,b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array (s2_tid, "c", HOFFSET(s2_t,c), 1, memb_size, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert (s2_tid, "d", HOFFSET(s2_t,d), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s2_tid, "e", HOFFSET(s2_t,e), H5T_NATIVE_INT)<0) {
- goto error;
- }
+ H5Tinsert (s2_tid, "b", HOFFSET(s2_t,b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s2_tid, "c", HOFFSET(s2_t,c), array_dt)<0 ||
+ H5Tinsert (s2_tid, "d", HOFFSET(s2_t,d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s2_tid, "e", HOFFSET(s2_t,e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
/* Read the data */
if (H5Dread (dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s2)<0) {
@@ -249,15 +252,16 @@ main (int argc, char *argv[])
TESTING("reversal of struct members");
/* Create a data type for s3 */
- if ((s3_tid = H5Tcreate (H5T_COMPOUND, sizeof(s3_t)))<0) goto error;
+ if ((s3_tid = H5Tcreate (H5T_COMPOUND, sizeof(s3_t)))<0)
+ goto error;
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, memb_size, NULL);
if (H5Tinsert (s3_tid, "a", HOFFSET(s3_t,a), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s3_tid, "b", HOFFSET(s3_t,b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array (s3_tid, "c", HOFFSET(s3_t,c), 1, memb_size, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert (s3_tid, "d", HOFFSET(s3_t,d), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s3_tid, "e", HOFFSET(s3_t,e), H5T_NATIVE_INT)<0) {
- goto error;
- }
+ H5Tinsert (s3_tid, "b", HOFFSET(s3_t,b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s3_tid, "c", HOFFSET(s3_t,c), array_dt)<0 ||
+ H5Tinsert (s3_tid, "d", HOFFSET(s3_t,d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s3_tid, "e", HOFFSET(s3_t,e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
/* Read the data */
if (H5Dread (dataset, s3_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s3)<0) {
@@ -325,15 +329,16 @@ main (int argc, char *argv[])
}
/* Create a data type for s5 */
- if ((s5_tid = H5Tcreate (H5T_COMPOUND, sizeof(s5_t)))<0) goto error;
+ if ((s5_tid = H5Tcreate (H5T_COMPOUND, sizeof(s5_t)))<0)
+ goto error;
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, memb_size, NULL);
if (H5Tinsert (s5_tid, "a", HOFFSET(s5_t,a), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s5_tid, "b", HOFFSET(s5_t,b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array (s5_tid, "c", HOFFSET(s5_t,c), 1, memb_size, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert (s5_tid, "d", HOFFSET(s5_t,d), H5T_NATIVE_INT)<0 ||
- H5Tinsert (s5_tid, "e", HOFFSET(s5_t,e), H5T_NATIVE_INT)) {
- goto error;
- }
+ H5Tinsert (s5_tid, "b", HOFFSET(s5_t,b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s5_tid, "c", HOFFSET(s5_t,c), array_dt)<0 ||
+ H5Tinsert (s5_tid, "d", HOFFSET(s5_t,d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert (s5_tid, "e", HOFFSET(s5_t,e), H5T_NATIVE_INT))
+ goto error;
+ H5Tclose(array_dt);
/* Read the data */
if (H5Dread (dataset, s5_tid, H5S_ALL, H5S_ALL, PRESERVE, s5)<0) {
diff --git a/test/dtypes.c b/test/dtypes.c
index 1bf7a7c..dc91425 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -440,9 +440,10 @@ test_compound_2(void)
} *d_ptr;
const int nelmts = NTESTELEM;
- const size_t four = 4;
+ const hsize_t four = 4;
unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
hid_t st=-1, dt=-1;
+ hid_t array_dt;
int i;
TESTING("compound element reordering");
@@ -465,23 +466,25 @@ test_compound_2(void)
memcpy(buf, orig, nelmts*sizeof(struct st));
/* Build hdf5 datatypes */
+ array_dt=H5Tarray_create(H5T_NATIVE_INT,1, &four, NULL);
if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st)))<0 ||
- H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array(st, "c", HOFFSET(struct st, c), 1, &four, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT)<0)
- goto error;
+ H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt)<0 ||
+ H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
+ array_dt=H5Tarray_create(H5T_NATIVE_INT,1, &four, NULL);
if ((dt=H5Tcreate(H5T_COMPOUND, sizeof(struct dt)))<0 ||
- H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT)<0 ||
- H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array(dt, "c", HOFFSET(struct dt, c), 1, &four, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_INT)<0 ||
- H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT)<0)
- goto error;
+ H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt)<0 ||
+ H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
/* Perform the conversion */
if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error;
@@ -554,9 +557,10 @@ test_compound_3(void)
} *d_ptr;
const int nelmts = NTESTELEM;
- const size_t four = 4;
+ const hsize_t four = 4;
unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
hid_t st=-1, dt=-1;
+ hid_t array_dt;
int i;
TESTING("compound subset conversions");
@@ -566,37 +570,40 @@ test_compound_3(void)
bkg = malloc(nelmts * sizeof(struct dt));
orig = malloc(nelmts * sizeof(struct st));
for (i=0; i<nelmts; i++) {
- s_ptr = ((struct st*)orig) + i;
- s_ptr->a = i*8+0;
- s_ptr->b = i*8+1;
- s_ptr->c[0] = i*8+2;
- s_ptr->c[1] = i*8+3;
- s_ptr->c[2] = i*8+4;
- s_ptr->c[3] = i*8+5;
- s_ptr->d = i*8+6;
- s_ptr->e = i*8+7;
+ s_ptr = ((struct st*)orig) + i;
+ s_ptr->a = i*8+0;
+ s_ptr->b = i*8+1;
+ s_ptr->c[0] = i*8+2;
+ s_ptr->c[1] = i*8+3;
+ s_ptr->c[2] = i*8+4;
+ s_ptr->c[3] = i*8+5;
+ s_ptr->d = i*8+6;
+ s_ptr->e = i*8+7;
}
memcpy(buf, orig, nelmts*sizeof(struct st));
/* Build hdf5 datatypes */
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL);
if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st)))<0 ||
- H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array(st, "c", HOFFSET(struct st, c), 1, &four, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT)<0)
- goto error;
+ H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt)<0 ||
+ H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL);
if ((dt=H5Tcreate(H5T_COMPOUND, sizeof(struct dt)))<0 ||
- H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array(dt, "c", HOFFSET(struct dt, c), 1, &four, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT)<0)
- goto error;
+ H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt)<0 ||
+ H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
/* Perform the conversion */
- if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error;
+ if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0)
+ goto error;
/* Compare results */
for (i=0; i<nelmts; i++) {
@@ -668,9 +675,10 @@ test_compound_4(void)
} *d_ptr;
const int nelmts = NTESTELEM;
- const size_t four = 4;
+ const hsize_t four = 4;
unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
hid_t st=-1, dt=-1;
+ hid_t array_dt;
int i;
TESTING("compound element shrinking & reordering");
@@ -680,39 +688,42 @@ test_compound_4(void)
bkg = malloc(nelmts * sizeof(struct dt));
orig = malloc(nelmts * sizeof(struct st));
for (i=0; i<nelmts; i++) {
- s_ptr = ((struct st*)orig) + i;
- s_ptr->a = i*8+0;
- s_ptr->b = (i*8+1) & 0x7fff;
- s_ptr->c[0] = i*8+2;
- s_ptr->c[1] = i*8+3;
- s_ptr->c[2] = i*8+4;
- s_ptr->c[3] = i*8+5;
- s_ptr->d = (i*8+6) & 0x7fff;
- s_ptr->e = i*8+7;
+ s_ptr = ((struct st*)orig) + i;
+ s_ptr->a = i*8+0;
+ s_ptr->b = (i*8+1) & 0x7fff;
+ s_ptr->c[0] = i*8+2;
+ s_ptr->c[1] = i*8+3;
+ s_ptr->c[2] = i*8+4;
+ s_ptr->c[3] = i*8+5;
+ s_ptr->d = (i*8+6) & 0x7fff;
+ s_ptr->e = i*8+7;
}
memcpy(buf, orig, nelmts*sizeof(struct st));
/* Build hdf5 datatypes */
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL);
if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st)))<0 ||
- H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT)<0 ||
- H5Tinsert_array(st, "c", HOFFSET(struct st, c), 1, &four, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT)<0 ||
- H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT)<0)
- goto error;
+ H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt)<0 ||
+ H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL);
if ((dt=H5Tcreate(H5T_COMPOUND, sizeof(struct dt)))<0 ||
- H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT)<0 ||
- H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_SHORT)<0 ||
- H5Tinsert_array(dt, "c", HOFFSET(struct dt, c), 1, &four, NULL,
- H5T_NATIVE_INT)<0 ||
- H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_SHORT)<0 ||
- H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT)<0)
- goto error;
+ H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT)<0 ||
+ H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_SHORT)<0 ||
+ H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt)<0 ||
+ H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_SHORT)<0 ||
+ H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT)<0)
+ goto error;
+ H5Tclose(array_dt);
/* Perform the conversion */
- if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error;
+ if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0)
+ goto error;
/* Compare results */
for (i=0; i<nelmts; i++) {
@@ -787,8 +798,9 @@ test_compound_5(void)
int coll_ids[4];
} dst_type_t;
- size_t dims[1] = {4};
+ hsize_t dims[1] = {4};
hid_t src_type, dst_type, short_array, int_array, string;
+ hid_t array_dt;
src_type_t src[2] = {{"one", 102, {104, 105, 106, 107}},
{"two", 202, {204, 205, 206, 207}}};
@@ -807,10 +819,14 @@ test_compound_5(void)
/* Build datatypes */
short_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(short));
- H5Tinsert_array(short_array, "_", 0, 1, dims, NULL, H5T_NATIVE_SHORT);
+ array_dt=H5Tarray_create(H5T_NATIVE_SHORT, 1, dims, NULL);
+ H5Tinsert(short_array, "_", 0, array_dt);
+ H5Tclose(array_dt);
int_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(int));
- H5Tinsert_array(int_array, "_", 0, 1, dims, NULL, H5T_NATIVE_INT);
+ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, dims, NULL);
+ H5Tinsert(int_array, "_", 0, array_dt);
+ H5Tclose(array_dt);
string = H5Tcopy(H5T_C_S1);
H5Tset_size(string, 16);
diff --git a/test/gen_new_array.c b/test/gen_new_array.c
new file mode 100644
index 0000000..b15d9da
--- /dev/null
+++ b/test/gen_new_array.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2000 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Thursday, November 09, 2000
+ *
+ * Purpose: Create a two datasets, one with a compound datatypes with array
+ * fields (which should be stored in the newer version (version 2)) and
+ * one with an array datatype.
+ * This program is used to create the test file `tarrnew.h5' which has a
+ * datatypes stored in the newer (version 2) style in the object headers.
+ * To build the test file, this program MUST be compiled and linked with
+ * the hdf5-1.3+ series of libraries and the generated test file must be
+ * put into the 'test' directory in the 1.2.x branch of the library.
+ * The test file should be generated on a little-endian machine with
+ * 16-bit shorts, 32-bit floats, 32-bit ints and 64-bit doubles.
+ */
+#include <hdf5.h>
+
+#define TESTFILE "tarrnew.h5"
+
+/* 1-D array datatype */
+#define ARRAY1_RANK 1
+#define ARRAY1_DIM1 4
+
+/* 2-D dataset with fixed dimensions */
+#define SPACE1_RANK 2
+#define SPACE1_DIM1 8
+#define SPACE1_DIM2 9
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Robb Matzke
+ * Monday, October 26, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ typedef struct { /* Typedef for compound datatype */
+ short i;
+ float f[ARRAY1_DIM1];
+ long l[ARRAY1_DIM1];
+ double d;
+ } s3_t;
+ hid_t file, space, type, arr_type, dset;
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ hsize_t cur_dim[SPACE1_RANK]={SPACE1_DIM1,SPACE1_DIM2};
+ herr_t ret; /* Generic return value */
+
+ /* Create the file */
+ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if(file<0)
+ printf("file<0!\n");
+
+ /* Create the dataspace (for both datasets) */
+ space = H5Screate_simple(SPACE1_RANK, cur_dim, NULL);
+ if(space<0)
+ printf("space<0!\n");
+
+ /* Create the compound datatype with array fields */
+ type = H5Tcreate(H5T_COMPOUND, sizeof(s3_t));
+ if(type<0)
+ printf("type<0!\n");
+
+ /* Insert integer field */
+ ret = H5Tinsert (type, "i", HOFFSET(s3_t,i), H5T_NATIVE_SHORT);
+ if(ret<0)
+ printf("field 1 insert<0!\n");
+
+ /* Creat the array datatype */
+ arr_type=H5Tarray_create(H5T_NATIVE_FLOAT,ARRAY1_RANK,tdims1,NULL);
+ if(arr_type<0)
+ printf("arr_type<0!\n");
+
+ /* Insert float array field */
+ ret = H5Tinsert (type, "f", HOFFSET(s3_t,f), arr_type);
+ if(ret<0)
+ printf("field 3 insert<0!\n");
+
+ /* Close array datatype */
+ ret = H5Tclose (arr_type);
+ if(ret<0)
+ printf("field 3 array close<0!\n");
+
+ /* Creat the array datatype */
+ arr_type=H5Tarray_create(H5T_NATIVE_LONG,ARRAY1_RANK,tdims1,NULL);
+ if(arr_type<0)
+ printf("arr_type<0!\n");
+
+ /* Insert long array field */
+ ret = H5Tinsert (type, "l", HOFFSET(s3_t,l), arr_type);
+ if(ret<0)
+ printf("field 3 insert<0!\n");
+
+ /* Close array datatype */
+ ret = H5Tclose (arr_type);
+ if(ret<0)
+ printf("field 3 array close<0!\n");
+
+ /* Insert double field */
+ ret = H5Tinsert (type, "d", HOFFSET(s3_t,d), H5T_NATIVE_DOUBLE);
+ if(ret<0)
+ printf("field 4 insert<0!\n");
+
+ /* Create the dataset with compound array fields */
+ dset = H5Dcreate(file, "Dataset1", type, space, H5P_DEFAULT);
+ if(dset<0)
+ printf("dset<0!\n");
+ H5Dclose(dset);
+
+ /* Close compound datatype */
+ H5Tclose(type);
+
+ /* Create the compound datatype with array fields */
+ type = H5Tarray_create(H5T_NATIVE_INT, ARRAY1_RANK, tdims1, NULL);
+ if(type<0)
+ printf("type<0!\n");
+
+ /* Create the dataset with array datatype */
+ dset = H5Dcreate(file, "Dataset2", type, space, H5P_DEFAULT);
+ if(dset<0)
+ printf("dset<0!\n");
+ H5Dclose(dset);
+
+ /* Close array datatype */
+ H5Tclose(type);
+
+ H5Sclose(space);
+ H5Fclose(file);
+
+ return 0;
+}
+
diff --git a/test/gen_old_array.c b/test/gen_old_array.c
new file mode 100644
index 0000000..c307b4f
--- /dev/null
+++ b/test/gen_old_array.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2000 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Thursday, November 09, 2000
+ *
+ * Purpose: Create a two datasets with compound datatypes, one with no array
+ * fields and one with array fields.
+ * This program is used to create the test file `tarrold.h5' which has a
+ * datatypes stored in the older (version 1) style in the object headers.
+ * To build the test file, this program MUST be compiled and linked with
+ * the hdf5-1.2.x series of libraries and the generated test file must be
+ * put into the 'test' directory in the 1.3+ branch of the library.
+ * The test file should be generated on a little-endian machine with
+ * 16-bit shorts, 32-bit floats, 32-bit ints and 64-bit doubles.
+ */
+#include <hdf5.h>
+
+#define TESTFILE "tarrold.h5"
+
+/* 1-D array datatype */
+#define ARRAY1_RANK 1
+#define ARRAY1_DIM1 4
+
+/* 2-D dataset with fixed dimensions */
+#define SPACE1_RANK 2
+#define SPACE1_DIM1 8
+#define SPACE1_DIM2 9
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Robb Matzke
+ * Monday, October 26, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ typedef struct { /* Typedef for compound datatype */
+ short i;
+ float f;
+ long l;
+ } s2_t;
+ typedef struct { /* Typedef for compound datatype */
+ short i;
+ float f[ARRAY1_DIM1];
+ long l[ARRAY1_DIM1];
+ double d;
+ } s3_t;
+ hid_t file, space, type, dset;
+ size_t tdims1[] = {ARRAY1_DIM1};
+ hsize_t cur_dim[SPACE1_RANK]={SPACE1_DIM1,SPACE1_DIM2};
+ herr_t ret; /* Generic return value */
+
+ /* Create the file */
+ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if(file<0)
+ printf("file<0!\n");
+
+ /* Create the dataspace (for both datasets) */
+ space = H5Screate_simple(SPACE1_RANK, cur_dim, NULL);
+ if(space<0)
+ printf("space<0!\n");
+
+ /* Create the compound datatype with non-array fields */
+ type = H5Tcreate(H5T_COMPOUND, sizeof(s2_t));
+ if(type<0)
+ printf("type<0!\n");
+
+ /* Insert integer field */
+ ret = H5Tinsert (type, "i", HOFFSET(s2_t,i), H5T_NATIVE_SHORT);
+ if(ret<0)
+ printf("field 1 insert<0!\n");
+
+ /* Insert float field */
+ ret = H5Tinsert (type, "f", HOFFSET(s2_t,f), H5T_NATIVE_FLOAT);
+ if(ret<0)
+ printf("field 3 insert<0!\n");
+
+ /* Insert long field */
+ ret = H5Tinsert (type, "l", HOFFSET(s2_t,l), H5T_NATIVE_LONG);
+ if(ret<0)
+ printf("field 3 insert<0!\n");
+
+ /* Create the dataset with compound non-array fields */
+ dset = H5Dcreate(file, "Dataset1", type, space, H5P_DEFAULT);
+ if(dset<0)
+ printf("dset<0!\n");
+ H5Dclose(dset);
+
+ /* Close first compound datatype */
+ H5Tclose(type);
+
+ /* Create the compound datatype with array fields */
+ type = H5Tcreate(H5T_COMPOUND, sizeof(s3_t));
+ if(type<0)
+ printf("type<0!\n");
+
+ /* Insert integer field */
+ ret = H5Tinsert (type, "i", HOFFSET(s3_t,i), H5T_NATIVE_SHORT);
+ if(ret<0)
+ printf("field 1 insert<0!\n");
+
+ /* Insert float array field */
+ ret = H5Tinsert_array (type, "f", HOFFSET(s3_t,f), ARRAY1_RANK, tdims1, NULL, H5T_NATIVE_FLOAT);
+ if(ret<0)
+ printf("field 3 insert<0!\n");
+
+ /* Insert long array field */
+ ret = H5Tinsert_array (type, "l", HOFFSET(s3_t,l), ARRAY1_RANK, tdims1, NULL, H5T_NATIVE_LONG);
+ if(ret<0)
+ printf("field 3 insert<0!\n");
+
+ /* Insert double field */
+ ret = H5Tinsert (type, "d", HOFFSET(s3_t,d), H5T_NATIVE_DOUBLE);
+ if(ret<0)
+ printf("field 4 insert<0!\n");
+
+ /* Create the dataset with compound array fields */
+ dset = H5Dcreate(file, "Dataset2", type, space, H5P_DEFAULT);
+ if(dset<0)
+ printf("dset<0!\n");
+ H5Dclose(dset);
+
+ /* Close second compound datatype */
+ H5Tclose(type);
+
+ H5Sclose(space);
+ H5Fclose(file);
+
+ return 0;
+}
diff --git a/test/tarray.c b/test/tarray.c
new file mode 100644
index 0000000..6877981
--- /dev/null
+++ b/test/tarray.c
@@ -0,0 +1,1849 @@
+/****************************************************************************
+ * NCSA HDF *
+ * Software Development Group *
+ * National Center for Supercomputing Applications *
+ * University of Illinois at Urbana-Champaign *
+ * 605 E. Springfield, Champaign IL 61820 *
+ * *
+ * For conditions of distribution and use, see the accompanying *
+ * hdf/COPYING file. *
+ * *
+ ****************************************************************************/
+
+#ifdef RCSID
+static char RcsId[] = "$Revision$";
+#endif
+
+/* $Id$ */
+
+/***********************************************************
+*
+* Test program: tarray
+*
+* Test the Array Datatype functionality
+*
+*************************************************************/
+
+#include <testhdf5.h>
+
+#include <hdf5.h>
+
+#define FILENAME "tarray1.h5"
+#define TESTFILE "tarrold.h5"
+
+/* 1-D array datatype */
+#define ARRAY1_RANK 1
+#define ARRAY1_DIM1 4
+
+/* 3-D array datatype */
+#define ARRAY2_RANK 3
+#define ARRAY2_DIM1 3
+#define ARRAY2_DIM2 4
+#define ARRAY2_DIM3 5
+
+/* 2-D array datatype */
+#define ARRAY3_RANK 2
+#define ARRAY3_DIM1 6
+#define ARRAY3_DIM2 3
+
+/* 1-D dataset with fixed dimensions */
+#define SPACE1_NAME "Space1"
+#define SPACE1_RANK 1
+#define SPACE1_DIM1 4
+
+/* 2-D dataset with fixed dimensions */
+#define SPACE2_NAME "Space2"
+#define SPACE2_RANK 2
+#define SPACE2_DIM1 10
+#define SPACE2_DIM2 10
+
+/****************************************************************
+**
+** test_array_atomic_1d(): Test basic array datatype code.
+** Tests 1-D array of atomic datatypes
+**
+****************************************************************/
+static void
+test_array_atomic_1d(void)
+{
+ int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */
+ int rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1; /* Datatype ID */
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int ndims; /* Array rank for reading */
+ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+ intn i,j; /* counting variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing 1-D Array of Atomic Datatypes Functionality\n"));
+
+ /* Allocate and initialize array data to write */
+ for(i=0; i<SPACE1_DIM1; i++)
+ for(j=0; j<ARRAY1_DIM1; j++)
+ wdata[i][j]=i*10+j;
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create a datatype to refer to */
+ tid1 = H5Tarray_create (H5T_NATIVE_INT,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid1, FAIL, "H5Tarray_create");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open file */
+ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fopen");
+
+ /* Open the dataset */
+ dataset=H5Dopen(fid1,"Dataset1");
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ /* Get the datatype */
+ tid1 = H5Dget_type (dataset);
+ CHECK(tid1, FAIL, "H5Dget_type");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(tid1);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(tid1,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ if(wdata[i][j]!=rdata[i][j]) {
+ num_errs++;
+ printf("Array data information doesn't match!, wdata[%d][%d]=%d, rdata[%d][%d]=%d\n",(int)i,(int)j,(int)wdata[i][j],(int)i,(int)j,(int)rdata[i][j]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+
+ /* Close Datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_array_atomic_1d() */
+
+/****************************************************************
+**
+** test_array_atomic_3d(): Test basic array datatype code.
+** Tests 3-D array of atomic datatypes
+**
+****************************************************************/
+static void
+test_array_atomic_3d(void)
+{
+ int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */
+ int rdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information read in */
+ hid_t fid; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims2[] = {ARRAY2_DIM1,ARRAY2_DIM2,ARRAY2_DIM3};
+ int ndims; /* Array rank for reading */
+ hsize_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */
+ intn i,j,k,l; /* counting variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing 3-D Array of Atomic Datatypes Functionality\n"));
+
+ /* Allocate and initialize array data to write */
+ for(i=0; i<SPACE1_DIM1; i++)
+ for(j=0; j<ARRAY2_DIM1; j++)
+ for(k=0; k<ARRAY2_DIM2; k++)
+ for(l=0; l<ARRAY2_DIM3; l++)
+ wdata[i][j][k][l]=i*1000+j*100+k*10+l;
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid = H5Screate_simple(SPACE1_RANK, sdims1, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create a datatype to refer to */
+ tid = H5Tarray_create (H5T_NATIVE_INT,ARRAY2_RANK,tdims2,NULL);
+ CHECK(tid, FAIL, "H5Tarray_create");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid,"Dataset1",tid,sid,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Open the dataset */
+ dataset=H5Dopen(fid,"Dataset1");
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ /* Get the datatype */
+ tid = H5Dget_type (dataset);
+ CHECK(tid, FAIL, "H5Dget_type");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(tid);
+ VERIFY(ndims,ARRAY2_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(tid,rdims2,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims2[i]!=tdims2[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims2[%d]=%d, tdims2[%d]=%d\n",(int)i,(int)rdims2[i],(int)i,(int)tdims2[i]);
+ continue;
+ } /* end if */
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<ARRAY2_DIM1; j++) {
+ for(k=0; k<ARRAY2_DIM2; k++) {
+ for(l=0; l<ARRAY2_DIM3; l++) {
+ if(wdata[i][j][k][l]!=rdata[i][j][k][l]) {
+ num_errs++;
+ printf("Array data information doesn't match!, wdata[%d][%d][%d][%d]=%d, rdata[%d][%d][%d][%d]=%d\n",(int)i,(int)j,(int)k,(int)l,(int)wdata[i][j][k][l],(int)i,(int)j,(int)k,(int)l,(int)rdata[i][j][k][l]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+
+ /* Close Datatype */
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_array_atomic_3d() */
+
+/****************************************************************
+**
+** test_array_array_atomic(): Test basic array datatype code.
+** Tests 1-D array 2-D arrays of atomic datatypes
+**
+****************************************************************/
+static void
+test_array_array_atomic(void)
+{
+ int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */
+ int rdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information read in */
+ hid_t fid; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid1; /* 1-D array Datatype ID */
+ hid_t tid2; /* 2-D array Datatype ID */
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ hsize_t tdims2[] = {ARRAY3_DIM1,ARRAY3_DIM2};
+ int ndims1; /* Array rank for reading */
+ int ndims2; /* Array rank for reading */
+ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+ hsize_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */
+ intn i,j,k,l; /* counting variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing 1-D Array 2-D Arrays of Atomic Datatypes Functionality\n"));
+
+ /* Allocate and initialize array data to write */
+ for(i=0; i<SPACE1_DIM1; i++)
+ for(j=0; j<ARRAY1_DIM1; j++)
+ for(k=0; k<ARRAY3_DIM1; k++)
+ for(l=0; l<ARRAY3_DIM2; l++)
+ wdata[i][j][k][l]=i*1000+j*100+k*10+l;
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid = H5Screate_simple(SPACE1_RANK, sdims1, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create a 2-D datatype to refer to */
+ tid2 = H5Tarray_create (H5T_NATIVE_INT,ARRAY3_RANK,tdims2,NULL);
+ CHECK(tid2, FAIL, "H5Tarray_create");
+
+ /* Create a 1-D datatype to refer to */
+ tid1 = H5Tarray_create (tid2,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid1, FAIL, "H5Tarray_create");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid,"Dataset1",tid1,sid,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatypes */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Open the dataset */
+ dataset=H5Dopen(fid,"Dataset1");
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ /* Get the 1-D datatype */
+ tid1 = H5Dget_type (dataset);
+ CHECK(tid1, FAIL, "H5Dget_type");
+
+ /* Check the 1-D array rank */
+ ndims1=H5Tget_array_ndims(tid1);
+ VERIFY(ndims1,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the 1-D array dimensions */
+ ret=H5Tget_array_dims(tid1,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims1; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Get the 2-D datatype */
+ tid2 = H5Tget_super (tid1);
+ CHECK(tid2, FAIL, "H5Tget_super");
+
+ /* Check the 2-D array rank */
+ ndims2=H5Tget_array_ndims(tid2);
+ VERIFY(ndims2,ARRAY3_RANK,"H5Tget_array_ndims");
+
+ /* Get the 2-D array dimensions */
+ ret=H5Tget_array_dims(tid2,rdims2,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims2; i++)
+ if(rdims2[i]!=tdims2[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims2[%d]=%d, tdims2[%d]=%d\n",(int)i,(int)rdims2[i],(int)i,(int)tdims2[i]);
+ continue;
+ } /* end if */
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<ARRAY2_DIM1; j++) {
+ for(k=0; k<ARRAY2_DIM2; k++) {
+ for(l=0; l<ARRAY2_DIM3; l++) {
+ if(wdata[i][j][k][l]!=rdata[i][j][k][l]) {
+ num_errs++;
+ printf("Array data information doesn't match!, wdata[%d][%d][%d][%d]=%d, rdata[%d][%d][%d][%d]=%d\n",(int)i,(int)j,(int)k,(int)l,(int)wdata[i][j][k][l],(int)i,(int)j,(int)k,(int)l,(int)rdata[i][j][k][l]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+
+ /* Close Datatypes */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_array_array_atomic() */
+
+/****************************************************************
+**
+** test_array_compound_atomic(): Test basic array datatype code.
+** Tests 1-D array of compound datatypes (with no array fields)
+**
+****************************************************************/
+static void
+test_array_compound_atomic(void)
+{
+ typedef struct { /* Typedef for compound datatype */
+ int i;
+ float f;
+ } s1_t;
+ s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */
+ s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1; /* Array Datatype ID */
+ hid_t tid2; /* Compound Datatype ID */
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int ndims; /* Array rank for reading */
+ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+ int nmemb; /* Number of compound members */
+ char *mname; /* Name of compound field */
+ size_t off; /* Offset of compound field */
+ hid_t mtid; /* Datatype ID for field */
+ intn i,j; /* counting variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing 1-D Array of Compound Atomic Datatypes Functionality\n"));
+
+ /* Initialize array data to write */
+ for(i=0; i<SPACE1_DIM1; i++)
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ wdata[i][j].i=i*10+j;
+ wdata[i][j].f=i*2.5+j;
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create a compound datatype to refer to */
+ tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
+ CHECK(tid2, FAIL, "H5Tcreate");
+
+ /* Insert integer field */
+ ret = H5Tinsert (tid2, "i", HOFFSET(s1_t,i), H5T_NATIVE_INT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Insert float field */
+ ret = H5Tinsert (tid2, "f", HOFFSET(s1_t,f), H5T_NATIVE_FLOAT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Create an array datatype to refer to */
+ tid1 = H5Tarray_create (tid2,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid1, FAIL, "H5Tarray_create");
+
+ /* Close compound datatype */
+ ret=H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open file */
+ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fopen");
+
+ /* Open the dataset */
+ dataset=H5Dopen(fid1,"Dataset1");
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ /* Get the datatype */
+ tid1 = H5Dget_type (dataset);
+ CHECK(tid1, FAIL, "H5Dget_type");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(tid1);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(tid1,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Get the compound datatype */
+ tid2 = H5Tget_super (tid1);
+ CHECK(tid2, FAIL, "H5Tget_super");
+
+ /* Check the number of members */
+ nmemb=H5Tget_nmembers(tid2);
+ VERIFY(nmemb,2,"H5Tget_nmembers");
+
+ /* Check the 1st field's name */
+ mname=H5Tget_member_name(tid2,0);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"i")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 1st field's offset */
+ off=H5Tget_member_offset(tid2,0);
+ VERIFY(off, HOFFSET(s1_t,i), "H5Tget_member_offset");
+
+ /* Check the 1st field's datatype */
+ mtid=H5Tget_member_type(tid2,0);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_NATIVE_INT))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Check the 2nd field's name */
+ mname=H5Tget_member_name(tid2,1);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"f")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 2nd field's offset */
+ off=H5Tget_member_offset(tid2,1);
+ VERIFY(off, HOFFSET(s1_t,f), "H5Tget_member_offset");
+
+ /* Check the 2nd field's datatype */
+ mtid=H5Tget_member_type(tid2,1);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_NATIVE_FLOAT))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Close Compound Datatype */
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ if(wdata[i][j].i!=rdata[i][j].i) {
+ num_errs++;
+ printf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",(int)i,(int)j,(int)wdata[i][j].i,(int)i,(int)j,(int)rdata[i][j].i);
+ continue;
+ } /* end if */
+ if(wdata[i][j].f!=rdata[i][j].f) {
+ num_errs++;
+ printf("Array data information doesn't match!, wdata[%d][%d].f=%f, rdata[%d][%d].f=%f\n",(int)i,(int)j,wdata[i][j].f,(int)i,(int)j,rdata[i][j].f);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+
+ /* Close Datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_array_compound_atomic() */
+
+/****************************************************************
+**
+** test_array_compound_array(): Test basic array datatype code.
+** Tests 1-D array of compound datatypes (with array fields)
+**
+****************************************************************/
+static void
+test_array_compound_array(void)
+{
+ typedef struct { /* Typedef for compound datatype */
+ int i;
+ float f[ARRAY1_DIM1];
+ } s1_t;
+ s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */
+ s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1; /* Array Datatype ID */
+ hid_t tid2; /* Compound Datatype ID */
+ hid_t tid3; /* Nested Array Datatype ID */
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int ndims; /* Array rank for reading */
+ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+ int nmemb; /* Number of compound members */
+ char *mname; /* Name of compound field */
+ size_t off; /* Offset of compound field */
+ hid_t mtid; /* Datatype ID for field */
+ H5T_class_t mclass; /* Datatype class for field */
+ intn i,j,k; /* counting variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing 1-D Array of Compound Array Datatypes Functionality\n"));
+
+ /* Initialize array data to write */
+ for(i=0; i<SPACE1_DIM1; i++)
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ wdata[i][j].i=i*10+j;
+ for(k=0; k<ARRAY1_DIM1; k++)
+ wdata[i][j].f[k]=i*10+j*2.5+k;
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create a compound datatype to refer to */
+ tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
+ CHECK(tid2, FAIL, "H5Tcreate");
+
+ /* Insert integer field */
+ ret = H5Tinsert (tid2, "i", HOFFSET(s1_t,i), H5T_NATIVE_INT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Create an array of floats datatype */
+ tid3 = H5Tarray_create (H5T_NATIVE_FLOAT,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid3, FAIL, "H5Tarray_create");
+
+ /* Insert float array field */
+ ret = H5Tinsert (tid2, "f", HOFFSET(s1_t,f), tid3);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Close array of floats field datatype */
+ ret=H5Tclose(tid3);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Create an array datatype to refer to */
+ tid1 = H5Tarray_create (tid2,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid1, FAIL, "H5Tarray_create");
+
+ /* Close compound datatype */
+ ret=H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open file */
+ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fopen");
+
+ /* Open the dataset */
+ dataset=H5Dopen(fid1,"Dataset1");
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ /* Get the datatype */
+ tid1 = H5Dget_type (dataset);
+ CHECK(tid1, FAIL, "H5Dget_type");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(tid1);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(tid1,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Get the compound datatype */
+ tid2 = H5Tget_super (tid1);
+ CHECK(tid2, FAIL, "H5Tget_super");
+
+ /* Check the number of members */
+ nmemb=H5Tget_nmembers(tid2);
+ VERIFY(nmemb,2,"H5Tget_nmembers");
+
+ /* Check the 1st field's name */
+ mname=H5Tget_member_name(tid2,0);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"i")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 1st field's offset */
+ off=H5Tget_member_offset(tid2,0);
+ VERIFY(off, HOFFSET(s1_t,i), "H5Tget_member_offset");
+
+ /* Check the 1st field's datatype */
+ mtid=H5Tget_member_type(tid2,0);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_NATIVE_INT))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Check the 2nd field's name */
+ mname=H5Tget_member_name(tid2,1);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"f")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 2nd field's offset */
+ off=H5Tget_member_offset(tid2,1);
+ VERIFY(off, HOFFSET(s1_t,f), "H5Tget_member_offset");
+
+ /* Check the 2nd field's datatype */
+ mtid=H5Tget_member_type(tid2,1);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+
+ /* Get the 2nd field's class */
+ mclass=H5Tget_class(mtid);
+ VERIFY(mclass, H5T_ARRAY, "H5Tget_class");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(mtid);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(mtid,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Nested array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Check the nested array's datatype */
+ tid3=H5Tget_super(mtid);
+ CHECK(tid3, FAIL, "H5Tget_super");
+
+ if((ret=H5Tequal(tid3,H5T_NATIVE_FLOAT))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+
+ /* Close the array's base type datatype */
+ ret=H5Tclose(tid3);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Close the member datatype */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Close Compound Datatype */
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ if(wdata[i][j].i!=rdata[i][j].i) {
+ num_errs++;
+ printf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",(int)i,(int)j,(int)wdata[i][j].i,(int)i,(int)j,(int)rdata[i][j].i);
+ continue;
+ } /* end if */
+ for(k=0; k<ARRAY1_DIM1; k++)
+ if(wdata[i][j].f[k]!=rdata[i][j].f[k]) {
+ num_errs++;
+ printf("Array data information doesn't match!, wdata[%d][%d].f[%d]=%f, rdata[%d][%d].f[%d]=%f\n",(int)i,(int)j,(int)k,wdata[i][j].f[k],(int)i,(int)j,(int)k,rdata[i][j].f[k]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+
+ /* Close Datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_array_compound_array() */
+
+void *test_array_alloc_custom(size_t size, void *info);
+void test_array_free_custom(void *mem, void *info);
+
+/****************************************************************
+**
+** test_array_alloc_custom(): Test VL datatype custom memory
+** allocation routines. This routine just uses malloc to
+** allocate the memory and increments the amount of memory
+** allocated.
+**
+****************************************************************/
+void *test_array_alloc_custom(size_t size, void *info)
+{
+ void *ret_value=NULL; /* Pointer to return */
+ int *mem_used=(int *)info; /* Get the pointer to the memory used */
+ size_t extra; /* Extra space needed */
+
+ /*
+ * This weird contortion is required on the DEC Alpha to keep the
+ * alignment correct - QAK
+ */
+ extra=MAX(sizeof(void *),sizeof(size_t));
+
+ if((ret_value=HDmalloc(extra+size))!=NULL) {
+ *(size_t *)ret_value=size;
+ *mem_used+=size;
+ } /* end if */
+ ret_value=((unsigned char *)ret_value)+extra;
+ return(ret_value);
+}
+
+/****************************************************************
+**
+** test_array_free_custom(): Test VL datatype custom memory
+** allocation routines. This routine just uses free to
+** release the memory and decrements the amount of memory
+** allocated.
+**
+****************************************************************/
+void test_array_free_custom(void *_mem, void *info)
+{
+ unsigned char *mem;
+ int *mem_used=(int *)info; /* Get the pointer to the memory used */
+ size_t extra; /* Extra space needed */
+
+ /*
+ * This weird contortion is required on the DEC Alpha to keep the
+ * alignment correct - QAK
+ */
+ extra=MAX(sizeof(void *),sizeof(size_t));
+
+ if(_mem!=NULL) {
+ mem=((unsigned char *)_mem)-extra;
+ *mem_used-=*(size_t *)mem;
+ HDfree(mem);
+ } /* end if */
+}
+
+/****************************************************************
+**
+** test_array_vlen_atomic(): Test basic array datatype code.
+** Tests 1-D array of atomic VL datatypes
+**
+****************************************************************/
+static void
+test_array_vlen_atomic(void)
+{
+ hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */
+ hvl_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1; /* Array Datatype ID */
+ hid_t tid2; /* VL Datatype ID */
+ hid_t tid3; /* Atomic Datatype ID */
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int ndims; /* Array rank for reading */
+ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+ H5T_class_t mclass; /* Datatype class for VL */
+ hid_t xfer_pid; /* Dataset transfer property list ID */
+ hsize_t size; /* Number of bytes which will be used */
+ int mem_used=0; /* Memory used during allocation */
+ intn i,j,k; /* counting variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing 1-D Array of Atomic Variable-Length Datatypes Functionality\n"));
+
+ /* Initialize array data to write */
+ for(i=0; i<SPACE1_DIM1; i++)
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ wdata[i][j].p=malloc((i+j+1)*sizeof(unsigned int));
+ wdata[i][j].len=i+j+1;
+ for(k=0; k<(i+j+1); k++)
+ ((unsigned int *)wdata[i][j].p)[k]=i*100+j*10+k;
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create a compound datatype to refer to */
+ tid2 = H5Tvlen_create(H5T_NATIVE_UINT);
+ CHECK(tid2, FAIL, "H5Tcreate");
+
+ /* Create an array datatype to refer to */
+ tid1 = H5Tarray_create (tid2,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid1, FAIL, "H5Tarray_create");
+
+ /* Close VL datatype */
+ ret=H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open file */
+ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fopen");
+
+ /* Open the dataset */
+ dataset=H5Dopen(fid1,"Dataset1");
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ /* Get the dataspace */
+ sid1 = H5Dget_space (dataset);
+ CHECK(sid1, FAIL, "H5Dget_space");
+
+ /* Get the datatype */
+ tid1 = H5Dget_type (dataset);
+ CHECK(tid1, FAIL, "H5Dget_type");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(tid1);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(tid1,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Get the VL datatype */
+ tid2 = H5Tget_super (tid1);
+ CHECK(tid2, FAIL, "H5Tget_super");
+
+ /* Get the 2nd field's class */
+ mclass=H5Tget_class(tid2);
+ VERIFY(mclass, H5T_VLEN, "H5Tget_class");
+
+ /* Check the VL datatype's base type */
+ tid3=H5Tget_super(tid2);
+ CHECK(tid3, FAIL, "H5Tget_super");
+
+ if((ret=H5Tequal(tid3,H5T_NATIVE_UINT))<=0) {
+ num_errs++;
+ printf("VL base datatype is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+
+ /* Close the array's base type datatype */
+ ret=H5Tclose(tid3);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close VL Datatype */
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Change to the custom memory allocation routines for reading VL data */
+ xfer_pid=H5Pcreate(H5P_DATA_XFER);
+ CHECK(xfer_pid, FAIL, "H5Pcreate");
+
+ ret=H5Pset_vlen_mem_manager(xfer_pid,test_array_alloc_custom,&mem_used,test_array_free_custom,&mem_used);
+ CHECK(ret, FAIL, "H5Pset_vlen_mem_manager");
+
+ /* Make certain the correct amount of memory will be used */
+ ret=H5Dvlen_get_buf_size(dataset,tid1,sid1,&size);
+ CHECK(ret, FAIL, "H5Dvlen_get_buf_size");
+
+ /* # elements allocated = (1 + 2 + 3 + 4) + (2 + 3 + 4 + 5) +
+ * (3 + 4 + 5 + 6) + (4 + 5 + 6 + 7) = 64 elements
+ */
+ VERIFY(size,64*sizeof(unsigned int),"H5Dvlen_get_buf_size");
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Make certain the correct amount of memory has been used */
+ /* # elements allocated = (1 + 2 + 3 + 4) + (2 + 3 + 4 + 5) +
+ * (3 + 4 + 5 + 6) + (4 + 5 + 6 + 7) = 64 elements
+ */
+ VERIFY(mem_used,64*sizeof(unsigned int),"H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ if(wdata[i][j].len!=rdata[i][j].len) {
+ num_errs++;
+ printf("VL data length don't match!, wdata[%d][%d].len=%d, rdata[%d][%d].len=%d\n",(int)i,(int)j,(int)wdata[i][j].len,(int)i,(int)j,(int)rdata[i][j].len);
+ continue;
+ } /* end if */
+ for(k=0; k<(int)rdata[i][j].len; k++) {
+ if( ((unsigned int *)wdata[i][j].p)[k] != ((unsigned int *)rdata[i][j].p)[k] ) {
+ num_errs++;
+ printf("VL data values don't match!, wdata[%d][%d].p[%d]=%d, rdata[%d][%d].p[%d]=%d\n",(int)i,(int)j,(int)k, (int)((unsigned int *)wdata[i][j].p)[k], (int)i,(int)j,(int)k, (int)((unsigned int *)rdata[i][j].p)[k]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+
+ /* Reclaim the read VL data */
+ ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Make certain the VL memory has been freed */
+ VERIFY(mem_used,0,"H5Dvlen_reclaim");
+
+ /* Reclaim the write VL data */
+ ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Close Datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_array_vlen_atomic() */
+
+/****************************************************************
+**
+** test_array_vlen_array(): Test basic array datatype code.
+** Tests 1-D array of 1-D array VL datatypes
+**
+****************************************************************/
+static void
+test_array_vlen_array(void)
+{
+ hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */
+ hvl_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1; /* Array Datatype ID */
+ hid_t tid2; /* VL Datatype ID */
+ hid_t tid3; /* Nested Array Datatype ID */
+ hid_t tid4; /* Atomic Datatype ID */
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int ndims; /* Array rank for reading */
+ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+ H5T_class_t mclass; /* Datatype class for VL */
+ hid_t xfer_pid; /* Dataset transfer property list ID */
+ hsize_t size; /* Number of bytes which will be used */
+ int mem_used=0; /* Memory used during allocation */
+ intn i,j,k,l; /* Index variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing 1-D Array of 1-D Array Variable-Length Datatypes Functionality\n"));
+
+ /* Initialize array data to write */
+ for(i=0; i<SPACE1_DIM1; i++)
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ wdata[i][j].p=malloc((i+j+1)*(sizeof(unsigned int)*ARRAY1_DIM1));
+ wdata[i][j].len=i+j+1;
+ for(k=0; k<(i+j+1); k++)
+ for(l=0; l<ARRAY1_DIM1; l++)
+ ((unsigned int *)wdata[i][j].p)[k*ARRAY1_DIM1+l]=i*1000+j*100+k*10+l;
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create the nested array datatype to refer to */
+ tid3 = H5Tarray_create(H5T_NATIVE_UINT,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid3, FAIL, "H5Tcreate");
+
+ /* Create a VL datatype of 1-D arrays to refer to */
+ tid2 = H5Tvlen_create(tid3);
+ CHECK(tid2, FAIL, "H5Tcreate");
+
+ /* Close nested array datatype */
+ ret=H5Tclose(tid3);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Create an array datatype to refer to */
+ tid1 = H5Tarray_create (tid2,ARRAY1_RANK,tdims1,NULL);
+ CHECK(tid1, FAIL, "H5Tarray_create");
+
+ /* Close VL datatype */
+ ret=H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open file */
+ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fopen");
+
+ /* Open the dataset */
+ dataset=H5Dopen(fid1,"Dataset1");
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ /* Get the dataspace */
+ sid1 = H5Dget_space (dataset);
+ CHECK(sid1, FAIL, "H5Dget_space");
+
+ /* Get the datatype */
+ tid1 = H5Dget_type (dataset);
+ CHECK(tid1, FAIL, "H5Dget_type");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(tid1);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(tid1,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Get the VL datatype */
+ tid2 = H5Tget_super (tid1);
+ CHECK(tid2, FAIL, "H5Tget_super");
+
+ /* Get the VL datatype's class */
+ mclass=H5Tget_class(tid2);
+ VERIFY(mclass, H5T_VLEN, "H5Tget_class");
+
+ /* Check the VL datatype's base type */
+ tid3=H5Tget_super(tid2);
+ CHECK(tid3, FAIL, "H5Tget_super");
+
+ /* Get the nested array datatype's class */
+ mclass=H5Tget_class(tid3);
+ VERIFY(mclass, H5T_ARRAY, "H5Tget_class");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(tid3);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(tid3,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Check the array's base type */
+ tid4=H5Tget_super(tid3);
+ CHECK(tid4, FAIL, "H5Tget_super");
+
+
+ if((ret=H5Tequal(tid4,H5T_NATIVE_UINT))<=0) {
+ num_errs++;
+ printf("VL base datatype is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+
+ /* Close the array's base type datatype */
+ ret=H5Tclose(tid4);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close the nested array datatype */
+ ret=H5Tclose(tid3);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close VL Datatype */
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Change to the custom memory allocation routines for reading VL data */
+ xfer_pid=H5Pcreate(H5P_DATA_XFER);
+ CHECK(xfer_pid, FAIL, "H5Pcreate");
+
+ ret=H5Pset_vlen_mem_manager(xfer_pid,test_array_alloc_custom,&mem_used,test_array_free_custom,&mem_used);
+ CHECK(ret, FAIL, "H5Pset_vlen_mem_manager");
+
+ /* Make certain the correct amount of memory will be used */
+ ret=H5Dvlen_get_buf_size(dataset,tid1,sid1,&size);
+ CHECK(ret, FAIL, "H5Dvlen_get_buf_size");
+
+ /* # elements allocated = (1 + 2 + 3 + 4) + (2 + 3 + 4 + 5) +
+ * (3 + 4 + 5 + 6) + (4 + 5 + 6 + 7) = 64*ARRAY1_DIM1 elements
+ */
+ VERIFY(size,64*(sizeof(unsigned int)*ARRAY1_DIM1),"H5Dvlen_get_buf_size");
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Make certain the correct amount of memory has been used */
+ /* # elements allocated = (1 + 2 + 3 + 4) + (2 + 3 + 4 + 5) +
+ * (3 + 4 + 5 + 6) + (4 + 5 + 6 + 7) = 64*ARRAY1_DIM1 elements
+ */
+ VERIFY(mem_used,64*(sizeof(unsigned int)*ARRAY1_DIM1),"H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<ARRAY1_DIM1; j++) {
+ if(wdata[i][j].len!=rdata[i][j].len) {
+ num_errs++;
+ printf("VL data length don't match!, wdata[%d][%d].len=%d, rdata[%d][%d].len=%d\n",(int)i,(int)j,(int)wdata[i][j].len,(int)i,(int)j,(int)rdata[i][j].len);
+ continue;
+ } /* end if */
+ for(k=0; k<(int)rdata[i][j].len; k++) {
+ for(l=0; l<ARRAY1_DIM1; l++) {
+ if( ((unsigned int *)wdata[i][j].p)[k*ARRAY1_DIM1+l] != ((unsigned int *)rdata[i][j].p)[k*ARRAY1_DIM1+l] ) {
+ num_errs++;
+ printf("VL data values don't match!, wdata[%d][%d].p[%d][%d]=%d, rdata[%d][%d].p[%d][%d]=%d\n",(int)i,(int)j,(int)k,(int)l, (int)((unsigned int *)wdata[i][j].p)[k*ARRAY1_DIM1+l], (int)i,(int)j,(int)k,(int)l, (int)((unsigned int *)rdata[i][j].p)[k*ARRAY1_DIM1+l]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+
+ /* Reclaim the read VL data */
+ ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Make certain the VL memory has been freed */
+ VERIFY(mem_used,0,"H5Dvlen_reclaim");
+
+ /* Reclaim the write VL data */
+ ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Close Datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_array_vlen_array() */
+
+/****************************************************************
+**
+** test_compat(): Test array datatype compatibility code.
+** Reads file containing old version of datatype object header
+** messages for compound datatypes and verifies reading the older
+** version of the is working correctly.
+**
+****************************************************************/
+static void
+test_compat(void)
+{
+ typedef struct { /* Typedef for compound datatype */
+ short i;
+ float f;
+ long l;
+ } s2_t;
+ typedef struct { /* Typedef for compound datatype */
+ short i;
+ float f[ARRAY1_DIM1];
+ long l[ARRAY1_DIM1];
+ double d;
+ } s3_t;
+ char testfile[512]=""; /* Character buffer for corrected test file name */
+ char *srcdir = getenv("srcdir"); /* Pointer to the directory the source code is located within */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t tid1; /* Array Datatype ID */
+ hid_t tid2; /* Datatype ID */
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int ndims; /* Array rank for reading */
+ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+ H5T_class_t mclass; /* Datatype class for VL */
+ int nmemb; /* Number of compound members */
+ char *mname; /* Name of compound field */
+ size_t off; /* Offset of compound field */
+ hid_t mtid; /* Datatype ID for field */
+ intn i; /* Index variables */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Array Datatypes Compatibility Functionality\n"));
+
+ /*
+ * Try reading a file that has been prepared that has datasets with
+ * compound datatypes which use an older version (version 1) of the
+ * datatype object header message for describing the datatype.
+ *
+ * If this test fails and the datatype object header message version has
+ * changed, follow the instructions in gen_old_array.c for regenerating
+ * the tarrold.h5 file.
+ */
+ /* Generate the correct name for the test file, by prepending the source path */
+ if (srcdir && ((strlen(srcdir) + strlen(TESTFILE) + 1) < sizeof(testfile))) {
+ strcpy(testfile, srcdir);
+ strcat(testfile, "/");
+ }
+ strcat(testfile, TESTFILE);
+
+ /* Open the testfile */
+ fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK_I(fid1, "H5Fopen");
+
+ /* Only try to proceed if the file is around */
+ if (fid1 >= 0){
+ /* Open the first dataset (with no array fields) */
+ dataset = H5Dopen(fid1, "Dataset1");
+ CHECK_I(dataset, "H5Dopen");
+
+ /* Get the datatype */
+ tid1=H5Dget_type(dataset);
+ CHECK_I(tid1, "H5Dget_type");
+
+ /* Verify datatype class */
+ mclass=H5Tget_class(tid1);
+ VERIFY(mclass, H5T_COMPOUND, "H5Tget_class");
+
+ /* Get the number of compound datatype fields */
+ nmemb=H5Tget_nmembers(tid1);
+ VERIFY(nmemb,3,"H5Tget_nmembers");
+
+ /* Check the 1st field's name */
+ mname=H5Tget_member_name(tid1,0);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"i")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 1st field's offset */
+ off=H5Tget_member_offset(tid1,0);
+ VERIFY(off, 0, "H5Tget_member_offset");
+
+ /* Check the 1st field's datatype */
+ mtid=H5Tget_member_type(tid1,0);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_STD_I16LE))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Check the 2nd field's name */
+ mname=H5Tget_member_name(tid1,1);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"f")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 2nd field's offset */
+ off=H5Tget_member_offset(tid1,1);
+ VERIFY(off, 4, "H5Tget_member_offset");
+
+ /* Check the 2nd field's datatype */
+ mtid=H5Tget_member_type(tid1,1);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_IEEE_F32LE))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Check the 3rd field's name */
+ mname=H5Tget_member_name(tid1,2);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"l")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 3rd field's offset */
+ off=H5Tget_member_offset(tid1,2);
+ VERIFY(off, 8, "H5Tget_member_offset");
+
+ /* Check the 3rd field's datatype */
+ mtid=H5Tget_member_type(tid1,2);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_STD_I32LE))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Close the datatype */
+ ret = H5Tclose(tid1);
+ CHECK_I(ret, "H5Tclose");
+
+ /* Close the dataset */
+ ret = H5Dclose(dataset);
+ CHECK_I(ret, "H5Dclose");
+
+
+ /* Open the second dataset (with array fields) */
+ dataset = H5Dopen(fid1, "Dataset2");
+ CHECK_I(dataset, "H5Dopen");
+
+ /* Get the datatype */
+ tid1=H5Dget_type(dataset);
+ CHECK_I(tid1, "H5Dget_type");
+
+ /* Verify datatype class */
+ mclass=H5Tget_class(tid1);
+ VERIFY(mclass, H5T_COMPOUND, "H5Tget_class");
+
+ /* Get the number of compound datatype fields */
+ nmemb=H5Tget_nmembers(tid1);
+ VERIFY(nmemb,4,"H5Tget_nmembers");
+
+ /* Check the 1st field's name */
+ mname=H5Tget_member_name(tid1,0);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"i")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 1st field's offset */
+ off=H5Tget_member_offset(tid1,0);
+ VERIFY(off, 0, "H5Tget_member_offset");
+
+ /* Check the 1st field's datatype */
+ mtid=H5Tget_member_type(tid1,0);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_STD_I16LE))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Check the 2nd field's name */
+ mname=H5Tget_member_name(tid1,1);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"f")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 2nd field's offset */
+ off=H5Tget_member_offset(tid1,1);
+ VERIFY(off, 4, "H5Tget_member_offset");
+
+ /* Check the 2nd field's datatype */
+ mtid=H5Tget_member_type(tid1,1);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+
+ /* Verify datatype class */
+ mclass=H5Tget_class(mtid);
+ VERIFY(mclass, H5T_ARRAY, "H5Tget_class");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(mtid);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(mtid,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Check the array's base datatype */
+ tid2=H5Tget_super(mtid);
+ CHECK(tid2, FAIL, "H5Tget_member_type");
+
+ if((ret=H5Tequal(tid2,H5T_IEEE_F32LE))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret=H5Tclose(mtid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Check the 3rd field's name */
+ mname=H5Tget_member_name(tid1,2);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"l")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 3rd field's offset */
+ off=H5Tget_member_offset(tid1,2);
+ VERIFY(off, 20, "H5Tget_member_offset");
+
+ /* Check the 3rd field's datatype */
+ mtid=H5Tget_member_type(tid1,2);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+
+ /* Verify datatype class */
+ mclass=H5Tget_class(mtid);
+ VERIFY(mclass, H5T_ARRAY, "H5Tget_class");
+
+ /* Check the array rank */
+ ndims=H5Tget_array_ndims(mtid);
+ VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims");
+
+ /* Get the array dimensions */
+ ret=H5Tget_array_dims(mtid,rdims1,NULL);
+ CHECK(ret, FAIL, "H5Tget_array_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims1[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims1[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+
+ /* Check the array's base datatype */
+ tid2=H5Tget_super(mtid);
+ CHECK(tid2, FAIL, "H5Tget_member_type");
+
+ if((ret=H5Tequal(tid2,H5T_STD_I32LE))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret=H5Tclose(mtid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Check the 4th field's name */
+ mname=H5Tget_member_name(tid1,3);
+ CHECK(mname, NULL, "H5Tget_member_name");
+ if(HDstrcmp(mname,"d")!=0) {
+ num_errs++;
+ printf("Compound field name doesn't match!, mname=%s\n",mname);
+ } /* end if */
+ free(mname);
+
+ /* Check the 4th field's offset */
+ off=H5Tget_member_offset(tid1,3);
+ VERIFY(off, 36, "H5Tget_member_offset");
+
+ /* Check the 4th field's datatype */
+ mtid=H5Tget_member_type(tid1,3);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+ if((ret=H5Tequal(mtid,H5T_IEEE_F64LE))<=0) {
+ num_errs++;
+ printf("Compound data type is incorrect!, ret=%d\n",(int)ret);
+ } /* end if */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
+ /* Close the datatype */
+ ret = H5Tclose(tid1);
+ CHECK_I(ret, "H5Tclose");
+
+ /* Close the dataset */
+ ret = H5Dclose(dataset);
+ CHECK_I(ret, "H5Dclose");
+
+ /* Close the file */
+ ret = H5Fclose(fid1);
+ CHECK_I(ret, "H5Fclose");
+ }
+ else
+ printf("***cannot open the pre-created compound datatype test file (%s)\n",testfile);
+
+} /* end test_compat() */
+
+/****************************************************************
+**
+** test_array(): Main array datatype testing routine.
+**
+****************************************************************/
+void
+test_array(void)
+{
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Array Datatypes\n"));
+
+ /* These tests use the same file... */
+ test_array_atomic_1d(); /* Test 1-D array of atomic datatypes */
+ test_array_atomic_3d(); /* Test 3-D array of atomic datatypes */
+ test_array_array_atomic(); /* Test 1-D array of 2-D arrays of atomic datatypes */
+ test_array_compound_atomic(); /* Test 1-D array of compound datatypes (with no array fields) */
+ test_array_compound_array(); /* Test 1-D array of compound datatypes (with array fields) */
+ test_array_vlen_atomic(); /* Test 1-D array of atomic VL datatypes */
+ test_array_vlen_array(); /* Test 1-D array of 1-D array VL datatypes */
+
+ /* This test uses a custom file */
+ test_compat(); /* Test compatibility changes for compound datatype fields */
+} /* test_array() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: cleanup_array
+ *
+ * Purpose: Cleanup temporary test files
+ *
+ * Return: none
+ *
+ * Programmer: Quincey Koziol
+ * June 8, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+cleanup_array(void)
+{
+ remove(FILENAME);
+}
+
diff --git a/test/tarrold.h5 b/test/tarrold.h5
new file mode 100644
index 0000000..7747ce4
--- /dev/null
+++ b/test/tarrold.h5
Binary files differ
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 2b79074..51b6ef3 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -173,6 +173,7 @@ main(int argc, char *argv[])
InitTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes");
InitTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings");
InitTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration");
+ InitTest("array", test_array, cleanup_array, "Array Datatypes");
Verbosity = 4; /* Default Verbosity is Low */
H5get_libversion(&major, &minor, &release);
diff --git a/test/testhdf5.h b/test/testhdf5.h
index 93b3398..ae2ccc6 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -130,6 +130,7 @@ void test_reference(void);
void test_vltypes(void);
void test_vlstrings(void);
void test_iterate(void);
+void test_array(void);
/* Prototypes for the cleanup routines */
void cleanup_metadata(void);
@@ -142,5 +143,6 @@ void cleanup_reference(void);
void cleanup_vltypes(void);
void cleanup_vlstrings(void);
void cleanup_iterate(void);
+void cleanup_array(void);
#endif /* HDF5cleanup_H */