[svn-r2844] Purpose:

New Feature
Description:
    Added array datatype tests to the regression tests.  These datatype
    combinations are tested currently:
        1-D array of atomic datatypes
        3-D array of atomic datatypes
        array of array of atomic datatypes
        array of compound of atomic datatypes
        array of compound of array datatypes
        array of VL of atomic datatypes
        array of VL of array datatypes

    Also added a test to verify that the older style compound datatype with
    array fields works correctly.
Platforms tested:
    FreeBSD 4.1.1 (hawkwind)
This commit is contained in:
Quincey Koziol 2000-11-09 16:47:59 -05:00
parent e32c78d023
commit f178100d14
9 changed files with 2271 additions and 107 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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);

146
test/gen_new_array.c Normal file
View File

@ -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;
}

144
test/gen_old_array.c Normal file
View File

@ -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;
}

1849
test/tarray.c Normal file

File diff suppressed because it is too large Load Diff

BIN
test/tarrold.h5 Normal file

Binary file not shown.

View File

@ -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);

View File

@ -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 */