diff options
Diffstat (limited to 'tools/h5dump/h5dumpgentest.c')
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 926 |
1 files changed, 873 insertions, 53 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 4114a94..a37f908 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -97,10 +97,11 @@ #define FILE65 "file_space.h5" #define FILE66 "packedbits.h5" #define FILE67 "zerodim.h5" -#define FILE68 "tdset_idx.h5" - - - +#define FILE68a "tdset_idx.h5" +#define FILE68 "charsets.h5" +#define FILE69 "tattrintsize.h5" +#define FILE70 "tcmpdintsize.h5" +#define FILE71 "tcmpdattrintsize.h5" /*------------------------------------------------------------------------- * prototypes @@ -262,22 +263,22 @@ typedef struct s1_t { #define THRESHOLD10 10 /* Free space section threshold */ /* "FILE66" macros */ -#define F66_XDIM 8 +#define F66_XDIM 8 #define F66_DATASETU08 "DU08BITS" #define F66_DATASETS08 "DS08BITS" -#define F66_YDIM8 8 +#define F66_YDIM8 8 #define F66_DATASETU16 "DU16BITS" #define F66_DATASETS16 "DS16BITS" -#define F66_YDIM16 16 +#define F66_YDIM16 16 #define F66_DATASETU32 "DU32BITS" #define F66_DATASETS32 "DS32BITS" -#define F66_YDIM32 32 +#define F66_YDIM32 32 #define F66_DATASETU64 "DU64BITS" #define F66_DATASETS64 "DS64BITS" #define F66_YDIM64 64 -#define F66_DUMMYDBL "DummyDBL" +#define F66_DUMMYDBL "DummyDBL" -/* Declarations for gent_dataset_idx() for "FILE68" */ +/* Declarations for gent_dataset_idx() for "FILE68a" */ #define DSET_FIXED "dset_fixed" #define DSET_FIXED_FILTER "dset_filter" #define DSET_BTREE "dset_btree" @@ -287,6 +288,29 @@ typedef struct s1_t { #define DIM10 10 #define CHUNK 5 +/* "FILE70" macros and for FILE71 */ +/* Name of dataset to create in datafile */ +#define F70_DATASETNAME "CompoundIntSize" +#define F70_LENGTH 4 +#define F70_RANK 1 +#define F70_ARRAY_RANK 2 +#define F70_XDIM 8 +#define F70_DATASETU08 "DU08BITS" +#define F70_DATASETS08 "DS08BITS" +#define F70_YDIM8 8 +#define F70_DATASETU16 "DU16BITS" +#define F70_DATASETS16 "DS16BITS" +#define F70_YDIM16 16 +#define F70_DATASETU32 "DU32BITS" +#define F70_DATASETS32 "DS32BITS" +#define F70_YDIM32 32 +#define F70_DATASETU64 "DU64BITS" +#define F70_DATASETS64 "DS64BITS" +#define F70_YDIM64 64 +#define F70_DUMMYDBL "DummyDBL" +/* Name of dataset to create in datafile */ +#define F71_DATASETNAME "CompoundAttrIntSize" + static void gent_group(void) { @@ -586,7 +610,7 @@ static int gent_softlink2(void) */ /* Create a new dataset as sample object */ dset1 = H5Dcreate2(fileid1, "/dset1", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (dset1 < 0) { fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); @@ -607,7 +631,7 @@ static int gent_softlink2(void) */ /* Create a new dataset as sample object */ dset2 = H5Dcreate2(fileid1, "/dset2", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (dset2 < 0) { fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); @@ -3354,7 +3378,7 @@ static void gent_array8(void) hsize_t sdims[] = {F64_DIM0}; hsize_t tdims[] = {F64_DIM1}; int wdata[(F64_DIM1) * sizeof(int)]; /* Write buffer */ - unsigned int i; + unsigned int i; /* * Initialize data. i is the element in the dataspace, j and k the @@ -6982,7 +7006,7 @@ gent_dataset_idx(void) ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); assert(ret >= 0); - fid = H5Fcreate(FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fid = H5Fcreate(FILE68a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); dcpl = H5Pcreate(H5P_DATASET_CREATE); dims[0] = CHUNK; @@ -7040,8 +7064,8 @@ gent_dataset_idx(void) * Function: gent_packedbits * * Purpose: Generate a file to be used in the h5dump packed bits tests. - * Three datasets of 1, 2 and 4 bytes of unsigned int types are created. - * Three more datasets of 1, 2 and 4 bytes of signed int types are created. + * Four datasets of 1, 2, 4 and 8 bytes of unsigned int types are created. + * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. * Fill them with raw data such that no bit will be all zero in a dataset. * A dummy dataset of double type is created for failure test. * Created: Albert Cheng, 2010/5/10. @@ -7073,11 +7097,11 @@ gent_packedbits(void) valu8bits = (uint8_t) ~0u; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { + dsetu8[i][0] = valu8bits; + for(j = 1; j < dims[1]; j++) { dsetu8[i][j] = dsetu8[i][j-1] << 1; - } - valu8bits <<= 1; + } + valu8bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); @@ -7089,13 +7113,13 @@ gent_packedbits(void) space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ + valu16bits = (uint16_t) ~0u; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { + dsetu16[i][0] = valu16bits; + for(j = 1; j < dims[1]; j++) { dsetu16[i][j] = dsetu16[i][j-1] << 1; - } - valu16bits <<= 1; + } + valu16bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); @@ -7107,13 +7131,13 @@ gent_packedbits(void) space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ + valu32bits = (uint32_t) ~0u; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { + dsetu32[i][0] = valu32bits; + for(j = 1; j < dims[1]; j++) { dsetu32[i][j] = dsetu32[i][j-1] << 1; - } - valu32bits <<= 1; + } + valu32bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); @@ -7127,11 +7151,11 @@ gent_packedbits(void) valu64bits = (uint64_t) ~0Lu; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { + dsetu64[i][0] = valu64bits; + for(j = 1; j < dims[1]; j++) { dsetu64[i][j] = dsetu64[i][j-1] << 1; - } - valu64bits <<= 1; + } + valu64bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); @@ -7143,13 +7167,13 @@ gent_packedbits(void) space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ + val8bits = (int8_t) ~0; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { + dset8[i][0] = val8bits; + for(j = 1; j < dims[1]; j++) { dset8[i][j] = dset8[i][j-1] << 1; - } - val8bits <<= 1; + } + val8bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); @@ -7161,13 +7185,13 @@ gent_packedbits(void) space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ + val16bits = (int16_t) ~0; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { + dset16[i][0] = val16bits; + for(j = 1; j < dims[1]; j++) { dset16[i][j] = dset16[i][j-1] << 1; - } - val16bits <<= 1; + } + val16bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); @@ -7179,13 +7203,13 @@ gent_packedbits(void) space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ + val32bits = (int32_t) ~0; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { + dset32[i][0] = val32bits; + for(j = 1; j < dims[1]; j++) { dset32[i][j] = dset32[i][j-1] << 1; - } - val32bits <<= 1; + } + val32bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); @@ -7199,11 +7223,11 @@ gent_packedbits(void) val64bits = (int64_t) ~0L; /* all 1s */ for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { + dset64[i][0] = val64bits; + for(j = 1; j < dims[1]; j++) { dset64[i][j] = dset64[i][j-1] << 1; - } - val64bits <<= 1; + } + val64bits <<= 1; } H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); @@ -7227,6 +7251,798 @@ gent_packedbits(void) } /*------------------------------------------------------------------------- + * Function: gent_attr_packedbits + * + * Purpose: Generate a file to be used in the h5dump packed bits tests. + * Four attributes of 1, 2, 4 and 8 bytes of unsigned int types are created. + * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. + * Fill them with raw data such that no bit will be all zero in a dataset. + * A dummy dataset of double type is created for failure test. + * Use file to test Signed/Unsigned datatypes and keep in sync with gent_packedbits() + *------------------------------------------------------------------------- + */ +static void +gent_attr_intsize(void) +{ + hid_t fid, attr, space, root; + hsize_t dims[2]; + uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; + uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; + uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; + uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; + int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; + int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; + int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; + int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; + double dsetdbl[F66_XDIM][F66_YDIM8]; + unsigned int i, j; + + fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + root = H5Gopen2(fid, "/", H5P_DEFAULT); + + /* Attribute of 8 bits unsigned int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu8bits = (uint8_t) ~0u; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dsetu8[i][0] = valu8bits; + for(j = 1; j < dims[1]; j++) { + dsetu8[i][j] = dsetu8[i][j-1] << 1; + } + valu8bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8); + H5Sclose(space); + H5Aclose(attr); + + /* Attribute of 16 bits unsigned int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu16bits = (uint16_t) ~0u; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dsetu16[i][0] = valu16bits; + for(j = 1; j < dims[1]; j++) { + dsetu16[i][j] = dsetu16[i][j-1] << 1; + } + valu16bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16); + H5Sclose(space); + H5Aclose(attr); + + /* Attribute of 32 bits unsigned int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu32bits = (uint32_t) ~0u; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dsetu32[i][0] = valu32bits; + for(j = 1; j < dims[1]; j++) { + dsetu32[i][j] = dsetu32[i][j-1] << 1; + } + valu32bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32); + H5Sclose(space); + H5Aclose(attr); + + /* Attribute of 64 bits unsigned int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT); + + valu64bits = (uint64_t) ~0Lu; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dsetu64[i][0] = valu64bits; + for(j = 1; j < dims[1]; j++) { + dsetu64[i][j] = dsetu64[i][j-1] << 1; + } + valu64bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64); + H5Sclose(space); + H5Aclose(attr); + + /* Attribute of 8 bits signed int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val8bits = (int8_t) ~0; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dset8[i][0] = val8bits; + for(j = 1; j < dims[1]; j++) { + dset8[i][j] = dset8[i][j-1] << 1; + } + val8bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_INT8, dset8); + H5Sclose(space); + H5Aclose(attr); + + /* Attribute of 16 bits signed int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val16bits = (int16_t) ~0; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dset16[i][0] = val16bits; + for(j = 1; j < dims[1]; j++) { + dset16[i][j] = dset16[i][j-1] << 1; + } + val16bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_INT16, dset16); + H5Sclose(space); + H5Aclose(attr); + + /* Attribute of 32 bits signed int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val32bits = (int32_t) ~0; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dset32[i][0] = val32bits; + for(j = 1; j < dims[1]; j++) { + dset32[i][j] = dset32[i][j-1] << 1; + } + val32bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_INT32, dset32); + H5Sclose(space); + H5Aclose(attr); + + /* Attribute of 64 bits signed int */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT); + + val64bits = (int64_t) ~0L; /* all 1s */ + for(i = 0; i < dims[0]; i++){ + dset64[i][0] = val64bits; + for(j = 1; j < dims[1]; j++) { + dset64[i][j] = dset64[i][j-1] << 1; + } + val64bits <<= 1; + } + + H5Awrite(attr, H5T_NATIVE_INT64, dset64); + H5Sclose(space); + H5Aclose(attr); + + /* Double Dummy set for failure tests */ + dims[0] = F66_XDIM; dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); + + for(i = 0; i < dims[0]; i++) + for(j = 0; j < dims[1]; j++) + dsetdbl[i][j] = 0.0001 * j + i; + + H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl); + + H5Sclose(space); + H5Aclose(attr); + + H5Gclose(root); + H5Fclose(fid); +} + +/*------------------------------------------------------------------------- + * Function: gent_charsets + * + * Purpose: Generate a file to be used in the character set test + * Contains: + * 1) a ascii datatype + * 2) a utf8 datatype + * + *------------------------------------------------------------------------- + */ +static void +gent_charsets(void) +{ + hid_t fid, did, sid; + herr_t status; + hsize_t dim[] = {1}; /* Dataspace dimensions */ + typedef struct CharSetInfo { + const char *ascii_p_; + const char *utf8_p_; + } CharSetInfo; + + sid = H5Screate_simple( 1, dim, NULL ); + fid = H5Fcreate( FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); + + hid_t charset_dtid = H5Tcreate( H5T_COMPOUND, sizeof( CharSetInfo ) ); + + hid_t ascii_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); + status = H5Tset_cset( ascii_dtid, H5T_CSET_ASCII ); + H5Tinsert( charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_ ), ascii_dtid ); + + hid_t utf8_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); + status = H5Tset_cset( utf8_dtid, H5T_CSET_UTF8 ); + H5Tinsert( charset_dtid, "utf8", HOFFSET( CharSetInfo, utf8_p_ ), utf8_dtid ); + + did = H5Dcreate2( fid, "CharSets", charset_dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); + + const char * writeData[] = { "ascii", "utf8", }; + status = H5Dwrite( did, charset_dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, writeData ); + + H5Tclose( charset_dtid ); + H5Tclose( ascii_dtid ); + H5Tclose( utf8_dtid ); + H5Sclose( sid ); + H5Dclose( did ); + H5Fclose( fid ); +} + +static void gent_compound_intsizes(void) { + hid_t fid, dataset, space, root; + hsize_t dims[2]; + hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ + hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ + hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ + hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + /* Structure and array for compound types */ + typedef struct Array1Struct { + uint8_t dsetu8[F70_XDIM][F70_YDIM8]; + uint16_t dsetu16[F70_XDIM][F70_YDIM16]; + uint32_t dsetu32[F70_XDIM][F70_YDIM32]; + uint64_t dsetu64[F70_XDIM][F70_YDIM64]; + int8_t dset8[F70_XDIM][F70_YDIM8]; + int16_t dset16[F70_XDIM][F70_YDIM16]; + int32_t dset32[F70_XDIM][F70_YDIM32]; + int64_t dset64[F70_XDIM][F70_YDIM64]; + double dsetdbl[F70_XDIM][F70_YDIM8]; + } Array1Struct; + Array1Struct Array1[F70_LENGTH]; + + hid_t Array1Structid; /* File datatype identifier */ + herr_t status; /* Error checking variable */ + hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ + + int m, n, o; /* Array init loop vars */ + + /* Initialize the data in the arrays/datastructure */ + for (m = 0; m < F70_LENGTH; m++) { + + /* Array of 8 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + + valu8bits = (uint8_t) ~0u; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu8[n][0] = valu8bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu8[n][o] = Array1[m].dsetu8[n][o-1] << 1; + } + valu8bits <<= 1; + } + + /* Array of 16 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + + valu16bits = (uint16_t) ~0u; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu16[n][0] = valu16bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu16[n][o] = Array1[m].dsetu16[n][o-1] << 1; + } + valu16bits <<= 1; + } + + /* Array of 32 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + + valu32bits = (uint32_t) ~0u; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu32[n][0] = valu32bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; + } + valu32bits <<= 1; + } + + /* Array of 64 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + + valu64bits = (uint64_t) ~0Lu; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu64[n][0] = valu64bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; + } + valu64bits <<= 1; + } + + /* Array of 8 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + + val8bits = (int8_t) ~0; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset8[n][0] = val8bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset8[n][o] = Array1[m].dset8[n][o-1] << 1; + } + val8bits <<= 1; + } + + /* Array of 16 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + + val16bits = (int16_t) ~0; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset16[n][0] = val16bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset16[n][o] = Array1[m].dset16[n][o-1] << 1; + } + val16bits <<= 1; + } + + /* Array of 32 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + + val32bits = (int32_t) ~0; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset32[n][0] = val32bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; + } + val32bits <<= 1; + } + + /* Array of 64 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + + val64bits = (int64_t) ~0L; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset64[n][0] = val64bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; + } + val64bits <<= 1; + } + + /* Double Dummy set for failure tests */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + + for(n = 0; n < dims[0]; n++) + for(o = 0; o < dims[1]; o++) + Array1[m].dsetdbl[n][o] = 0.0001 * o + n; + } + + /* Create the array data type for the 8 bits signed int array */ + array8_tid = H5Tarray_create2(H5T_NATIVE_SCHAR, F70_ARRAY_RANK, array_dim8); + HDassert(array8_tid >= 0); + + /* Create the array data type for the 16 bits signed int array */ + array16_tid = H5Tarray_create2(H5T_NATIVE_SHORT, F70_ARRAY_RANK, array_dim16); + HDassert(array16_tid >= 0); + + /* Create the array data type for the 32 bits signed int array */ + array32_tid = H5Tarray_create2(H5T_NATIVE_INT, F70_ARRAY_RANK, array_dim32); + HDassert(array32_tid >= 0); + + /* Create the array data type for the 64 bits signed int array */ + array64_tid = H5Tarray_create2(H5T_NATIVE_LONG, F70_ARRAY_RANK, array_dim64); + HDassert(array64_tid >= 0); + + /* Create the array data type for the 8 bits signed int array */ + arrayu8_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, F70_ARRAY_RANK, array_dim8); + HDassert(arrayu8_tid >= 0); + + /* Create the array data type for the 16 bits signed int array */ + arrayu16_tid = H5Tarray_create2(H5T_NATIVE_USHORT, F70_ARRAY_RANK, array_dim16); + HDassert(arrayu16_tid >= 0); + + /* Create the array data type for the 32 bits signed int array */ + arrayu32_tid = H5Tarray_create2(H5T_NATIVE_UINT, F70_ARRAY_RANK, array_dim32); + HDassert(arrayu32_tid >= 0); + + /* Create the array data type for the 64 bits signed int array */ + arrayu64_tid = H5Tarray_create2(H5T_NATIVE_ULONG, F70_ARRAY_RANK, array_dim64); + HDassert(arrayu64_tid >= 0); + + /* Create the array data type for the 32 bits double array */ + arraydbl_tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F70_ARRAY_RANK, array_dim8); + HDassert(arraydbl_tid >= 0); + + /* Create the dataspace */ + space = H5Screate_simple(F70_RANK, dim, NULL); + HDassert(space >= 0); + + /* Create the file */ + fid = H5Fcreate(FILE70, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); + + /* Create the memory data type */ + Array1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Array1Struct)); + HDassert(Array1Structid >= 0); + + /* Insert the arrays and variables into the structure */ + status = H5Tinsert(Array1Structid, F70_DATASETU08, HOFFSET(Array1Struct, dsetu8), arrayu8_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETU16, HOFFSET(Array1Struct, dsetu16), arrayu16_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETU32, HOFFSET(Array1Struct, dsetu32), arrayu32_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETU64, HOFFSET(Array1Struct, dsetu64), arrayu64_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS08, HOFFSET(Array1Struct, dset8), array8_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS16, HOFFSET(Array1Struct, dset16), array16_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS32, HOFFSET(Array1Struct, dset32), array32_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS64, HOFFSET(Array1Struct, dset64), array64_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DUMMYDBL, HOFFSET(Array1Struct, dsetdbl), arraydbl_tid); + HDassert(status >= 0); + + /* Create the dataset */ + dataset = H5Dcreate2(fid, F70_DATASETNAME, Array1Structid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* Write data to the dataset */ + status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL, H5P_DEFAULT, Array1); + HDassert(status >= 0); + + /* Release resources */ + status = H5Tclose(Array1Structid); + HDassert(status >= 0); + + status = H5Tclose(arrayu8_tid); + HDassert(status >= 0); + + status = H5Tclose(arrayu16_tid); + HDassert(status >= 0); + + status = H5Tclose(arrayu32_tid); + HDassert(status >= 0); + + status = H5Tclose(arrayu64_tid); + HDassert(status >= 0); + + status = H5Tclose(array8_tid); + HDassert(status >= 0); + + status = H5Tclose(array16_tid); + HDassert(status >= 0); + + status = H5Tclose(array32_tid); + HDassert(status >= 0); + + status = H5Tclose(array64_tid); + HDassert(status >= 0); + + status = H5Tclose(arraydbl_tid); + HDassert(status >= 0); + + status = H5Sclose(space); + HDassert(status >= 0); + + status = H5Dclose(dataset); + HDassert(status >= 0); + + status = H5Fclose(fid); + HDassert(status >= 0); +} + +static void gent_compound_attr_intsizes(void) { + hid_t fid, attr, space, root; + hsize_t dims[2]; + hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ + hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ + hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ + hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + /* Structure and array for compound types */ + typedef struct Array1Struct { + uint8_t dsetu8[F70_XDIM][F70_YDIM8]; + uint16_t dsetu16[F70_XDIM][F70_YDIM16]; + uint32_t dsetu32[F70_XDIM][F70_YDIM32]; + uint64_t dsetu64[F70_XDIM][F70_YDIM64]; + int8_t dset8[F70_XDIM][F70_YDIM8]; + int16_t dset16[F70_XDIM][F70_YDIM16]; + int32_t dset32[F70_XDIM][F70_YDIM32]; + int64_t dset64[F70_XDIM][F70_YDIM64]; + double dsetdbl[F70_XDIM][F70_YDIM8]; + } Array1Struct; + Array1Struct Array1[F70_LENGTH]; + + hid_t Array1Structid; /* File datatype identifier */ + herr_t status; /* Error checking variable */ + hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ + + int m, n, o; /* Array init loop vars */ + + /* Initialize the data in the arrays/datastructure */ + for (m = 0; m < F70_LENGTH; m++) { + + /* Array of 8 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + + valu8bits = (uint8_t) ~0u; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu8[n][0] = valu8bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu8[n][o] = Array1[m].dsetu8[n][o-1] << 1; + } + valu8bits <<= 1; + } + + /* Array of 16 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + + valu16bits = (uint16_t) ~0u; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu16[n][0] = valu16bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu16[n][o] = Array1[m].dsetu16[n][o-1] << 1; + } + valu16bits <<= 1; + } + + /* Array of 32 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + + valu32bits = (uint32_t) ~0u; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu32[n][0] = valu32bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; + } + valu32bits <<= 1; + } + + /* Array of 64 bits unsigned int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + + valu64bits = (uint64_t) ~0Lu; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dsetu64[n][0] = valu64bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; + } + valu64bits <<= 1; + } + + /* Array of 8 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + + val8bits = (int8_t) ~0; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset8[n][0] = val8bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset8[n][o] = Array1[m].dset8[n][o-1] << 1; + } + val8bits <<= 1; + } + + /* Array of 16 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + + val16bits = (int16_t) ~0; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset16[n][0] = val16bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset16[n][o] = Array1[m].dset16[n][o-1] << 1; + } + val16bits <<= 1; + } + + /* Array of 32 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + + val32bits = (int32_t) ~0; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset32[n][0] = val32bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; + } + val32bits <<= 1; + } + + /* Array of 64 bits signed int */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + + val64bits = (int64_t) ~0L; /* all 1s */ + for(n = 0; n < dims[0]; n++){ + Array1[m].dset64[n][0] = val64bits; + for(o = 1; o < dims[1]; o++) { + Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; + } + val64bits <<= 1; + } + + /* Double Dummy set for failure tests */ + dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + + for(n = 0; n < dims[0]; n++) + for(o = 0; o < dims[1]; o++) + Array1[m].dsetdbl[n][o] = 0.0001 * o + n; + } + + /* Create the array data type for the 8 bits signed int array */ + array8_tid = H5Tarray_create2(H5T_NATIVE_SCHAR, F70_ARRAY_RANK, array_dim8); + HDassert(array8_tid >= 0); + + /* Create the array data type for the 16 bits signed int array */ + array16_tid = H5Tarray_create2(H5T_NATIVE_SHORT, F70_ARRAY_RANK, array_dim16); + HDassert(array16_tid >= 0); + + /* Create the array data type for the 32 bits signed int array */ + array32_tid = H5Tarray_create2(H5T_NATIVE_INT, F70_ARRAY_RANK, array_dim32); + HDassert(array32_tid >= 0); + + /* Create the array data type for the 64 bits signed int array */ + array64_tid = H5Tarray_create2(H5T_NATIVE_LONG, F70_ARRAY_RANK, array_dim64); + HDassert(array64_tid >= 0); + + /* Create the array data type for the 8 bits signed int array */ + arrayu8_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, F70_ARRAY_RANK, array_dim8); + HDassert(arrayu8_tid >= 0); + + /* Create the array data type for the 16 bits signed int array */ + arrayu16_tid = H5Tarray_create2(H5T_NATIVE_USHORT, F70_ARRAY_RANK, array_dim16); + HDassert(arrayu16_tid >= 0); + + /* Create the array data type for the 32 bits signed int array */ + arrayu32_tid = H5Tarray_create2(H5T_NATIVE_UINT, F70_ARRAY_RANK, array_dim32); + HDassert(arrayu32_tid >= 0); + + /* Create the array data type for the 64 bits signed int array */ + arrayu64_tid = H5Tarray_create2(H5T_NATIVE_ULONG, F70_ARRAY_RANK, array_dim64); + HDassert(arrayu64_tid >= 0); + + /* Create the array data type for the 32 bits double array */ + arraydbl_tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F70_ARRAY_RANK, array_dim8); + HDassert(arraydbl_tid >= 0); + + /* Create the dataspace */ + space = H5Screate_simple(F70_RANK, dim, NULL); + HDassert(space >= 0); + + /* Create the file */ + fid = H5Fcreate(FILE71, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); + + /* Create the memory data type */ + Array1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Array1Struct)); + HDassert(Array1Structid >= 0); + + /* Insert the arrays and variables into the structure */ + status = H5Tinsert(Array1Structid, F70_DATASETU08, HOFFSET(Array1Struct, dsetu8), arrayu8_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETU16, HOFFSET(Array1Struct, dsetu16), arrayu16_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETU32, HOFFSET(Array1Struct, dsetu32), arrayu32_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETU64, HOFFSET(Array1Struct, dsetu64), arrayu64_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS08, HOFFSET(Array1Struct, dset8), array8_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS16, HOFFSET(Array1Struct, dset16), array16_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS32, HOFFSET(Array1Struct, dset32), array32_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DATASETS64, HOFFSET(Array1Struct, dset64), array64_tid); + HDassert(status >= 0); + + status = H5Tinsert(Array1Structid, F70_DUMMYDBL, HOFFSET(Array1Struct, dsetdbl), arraydbl_tid); + HDassert(status >= 0); + + root = H5Gopen2(fid, "/", H5P_DEFAULT); + + /* Create the Attribute */ + attr = H5Acreate2(root, F71_DATASETNAME, Array1Structid, space, H5P_DEFAULT, H5P_DEFAULT); + + /* Write data to the attribute */ + status = H5Awrite(attr, Array1Structid, Array1); + HDassert(status >= 0); + + status = H5Tclose(arrayu8_tid); + HDassert(status >= 0); + + status = H5Tclose(arrayu16_tid); + HDassert(status >= 0); + + status = H5Tclose(arrayu32_tid); + HDassert(status >= 0); + + status = H5Tclose(arrayu64_tid); + HDassert(status >= 0); + + status = H5Tclose(array8_tid); + HDassert(status >= 0); + + status = H5Tclose(array16_tid); + HDassert(status >= 0); + + status = H5Tclose(array32_tid); + HDassert(status >= 0); + + status = H5Tclose(array64_tid); + HDassert(status >= 0); + + status = H5Tclose(arraydbl_tid); + HDassert(status >= 0); + + /* Release resources */ + status = H5Tclose(Array1Structid); + HDassert(status >= 0); + + status = H5Sclose(space); + HDassert(status >= 0); + + status = H5Aclose(attr); + HDassert(status >= 0); + + status = H5Fclose(fid); + HDassert(status >= 0); +} + + +/*------------------------------------------------------------------------- * Function: main * *------------------------------------------------------------------------- @@ -7303,6 +8119,10 @@ int main(void) gent_fs_strategy_threshold(); gent_packedbits(); gent_dataset_idx(); + gent_attr_intsize(); + gent_charsets(); + gent_compound_intsizes(); + gent_compound_attr_intsizes(); return 0; } |