From 3499de1b5302d739c5593724d4d7d10f9f23b039 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 9 Nov 2000 16:48:33 -0500 Subject: [svn-r2845] Purpose: New Feature Description: Added dumping array datatypes to h5dump and the tool library. Platforms tested: FreeBSD 4.1.1 (hawkwind) --- tools/h5dump.c | 493 ++++++++++++++++++++++++++++-------------------------- tools/h5dumptst.c | 378 +++++++++++++++++++++++------------------ tools/h5ls.c | 78 +++++---- tools/h5tools.c | 203 +++++++++++++--------- tools/talign.c | 29 +++- 5 files changed, 652 insertions(+), 529 deletions(-) diff --git a/tools/h5dump.c b/tools/h5dump.c index 6272ca4..515e61c 100644 --- a/tools/h5dump.c +++ b/tools/h5dump.c @@ -259,271 +259,288 @@ print_datatype(hid_t type) char *fname ; hid_t nmembers, mtype, str_type; int i, j, ndims, perm[H5DUMP_MAX_RANK]; - size_t dims[H5DUMP_MAX_RANK], size; + size_t size; + hsize_t dims[H5DUMP_MAX_RANK]; H5T_str_t str_pad; H5T_cset_t cset; H5G_stat_t statbuf; hid_t super; switch (H5Tget_class(type)) { - case H5T_INTEGER: - if (H5Tequal(type, H5T_STD_I8BE)) { - printf("H5T_STD_I8BE"); - } else if (H5Tequal(type, H5T_STD_I8LE)) { - printf("H5T_STD_I8LE"); - } else if (H5Tequal(type, H5T_STD_I16BE)) { - printf("H5T_STD_I16BE"); - } else if (H5Tequal(type, H5T_STD_I16LE)) { - printf("H5T_STD_I16LE"); - } else if (H5Tequal(type, H5T_STD_I32BE)) { - printf("H5T_STD_I32BE"); - } else if (H5Tequal(type, H5T_STD_I32LE)) { - printf("H5T_STD_I32LE"); - } else if (H5Tequal(type, H5T_STD_I64BE)) { - printf("H5T_STD_I64BE"); - } else if (H5Tequal(type, H5T_STD_I64LE)) { - printf("H5T_STD_I64LE"); - } else if (H5Tequal(type, H5T_STD_U8BE)) { - printf("H5T_STD_U8BE"); - } else if (H5Tequal(type, H5T_STD_U8LE)) { - printf("H5T_STD_U8LE"); - } else if (H5Tequal(type, H5T_STD_U16BE)) { - printf("H5T_STD_U16BE"); - } else if (H5Tequal(type, H5T_STD_U16LE)) { - printf("H5T_STD_U16LE"); - } else if (H5Tequal(type, H5T_STD_U32BE)) { - printf("H5T_STD_U32BE"); - } else if (H5Tequal(type, H5T_STD_U32LE)) { - printf("H5T_STD_U32LE"); - } else if (H5Tequal(type, H5T_STD_U64BE)) { - printf("H5T_STD_U64BE"); - } else if (H5Tequal(type, H5T_STD_U64LE)) { - printf("H5T_STD_U64LE"); - } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { - printf("H5T_NATIVE_SCHAR"); - } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { - printf("H5T_NATIVE_UCHAR"); - } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - printf("H5T_NATIVE_SHORT"); - } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - printf("H5T_NATIVE_USHORT"); - } else if (H5Tequal(type, H5T_NATIVE_INT)) { - printf("H5T_NATIVE_INT"); - } else if (H5Tequal(type, H5T_NATIVE_UINT)) { - printf("H5T_NATIVE_UINT"); - } else if (H5Tequal(type, H5T_NATIVE_LONG)) { - printf("H5T_NATIVE_LONG"); - } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { - printf("H5T_NATIVE_ULONG"); - } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { - printf("H5T_NATIVE_LLONG"); - } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { - printf("H5T_NATIVE_ULLONG"); - } else { - printf("undefined integer"); - d_status = 1; - } - break; - - case H5T_FLOAT: - if (H5Tequal(type, H5T_IEEE_F32BE)) { - printf("H5T_IEEE_F32BE"); - } else if (H5Tequal(type, H5T_IEEE_F32LE)) { - printf("H5T_IEEE_F32LE"); - } else if (H5Tequal(type, H5T_IEEE_F64BE)) { - printf("H5T_IEEE_F64BE"); - } else if (H5Tequal(type, H5T_IEEE_F64LE)) { - printf("H5T_IEEE_F64LE"); - } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { - printf("H5T_NATIVE_FLOAT"); - } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { - printf("H5T_NATIVE_DOUBLE"); - } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { - printf("H5T_NATIVE_LDOUBLE"); - } else { - printf("undefined float"); - d_status = 1; - } - break; - - case H5T_TIME: - printf("H5T_TIME: not yet implemented"); - break; + case H5T_INTEGER: + if (H5Tequal(type, H5T_STD_I8BE)) { + printf("H5T_STD_I8BE"); + } else if (H5Tequal(type, H5T_STD_I8LE)) { + printf("H5T_STD_I8LE"); + } else if (H5Tequal(type, H5T_STD_I16BE)) { + printf("H5T_STD_I16BE"); + } else if (H5Tequal(type, H5T_STD_I16LE)) { + printf("H5T_STD_I16LE"); + } else if (H5Tequal(type, H5T_STD_I32BE)) { + printf("H5T_STD_I32BE"); + } else if (H5Tequal(type, H5T_STD_I32LE)) { + printf("H5T_STD_I32LE"); + } else if (H5Tequal(type, H5T_STD_I64BE)) { + printf("H5T_STD_I64BE"); + } else if (H5Tequal(type, H5T_STD_I64LE)) { + printf("H5T_STD_I64LE"); + } else if (H5Tequal(type, H5T_STD_U8BE)) { + printf("H5T_STD_U8BE"); + } else if (H5Tequal(type, H5T_STD_U8LE)) { + printf("H5T_STD_U8LE"); + } else if (H5Tequal(type, H5T_STD_U16BE)) { + printf("H5T_STD_U16BE"); + } else if (H5Tequal(type, H5T_STD_U16LE)) { + printf("H5T_STD_U16LE"); + } else if (H5Tequal(type, H5T_STD_U32BE)) { + printf("H5T_STD_U32BE"); + } else if (H5Tequal(type, H5T_STD_U32LE)) { + printf("H5T_STD_U32LE"); + } else if (H5Tequal(type, H5T_STD_U64BE)) { + printf("H5T_STD_U64BE"); + } else if (H5Tequal(type, H5T_STD_U64LE)) { + printf("H5T_STD_U64LE"); + } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { + printf("H5T_NATIVE_SCHAR"); + } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { + printf("H5T_NATIVE_UCHAR"); + } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { + printf("H5T_NATIVE_SHORT"); + } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { + printf("H5T_NATIVE_USHORT"); + } else if (H5Tequal(type, H5T_NATIVE_INT)) { + printf("H5T_NATIVE_INT"); + } else if (H5Tequal(type, H5T_NATIVE_UINT)) { + printf("H5T_NATIVE_UINT"); + } else if (H5Tequal(type, H5T_NATIVE_LONG)) { + printf("H5T_NATIVE_LONG"); + } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { + printf("H5T_NATIVE_ULONG"); + } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { + printf("H5T_NATIVE_LLONG"); + } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { + printf("H5T_NATIVE_ULLONG"); + } else { + printf("undefined integer"); + d_status = 1; + } + break; + + case H5T_FLOAT: + if (H5Tequal(type, H5T_IEEE_F32BE)) { + printf("H5T_IEEE_F32BE"); + } else if (H5Tequal(type, H5T_IEEE_F32LE)) { + printf("H5T_IEEE_F32LE"); + } else if (H5Tequal(type, H5T_IEEE_F64BE)) { + printf("H5T_IEEE_F64BE"); + } else if (H5Tequal(type, H5T_IEEE_F64LE)) { + printf("H5T_IEEE_F64LE"); + } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { + printf("H5T_NATIVE_FLOAT"); + } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { + printf("H5T_NATIVE_DOUBLE"); + } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { + printf("H5T_NATIVE_LDOUBLE"); + } else { + printf("undefined float"); + d_status = 1; + } + break; - case H5T_STRING: - size = H5Tget_size(type); - str_pad = H5Tget_strpad(type); - cset = H5Tget_cset(type); + case H5T_TIME: + printf("H5T_TIME: not yet implemented"); + break; - indentation (indent + COL); - printf("%s %s %d;\n", dump_header_format->strblockbegin, - STRSIZE, (int)size); - indentation(indent + COL); - printf(" %s ", STRPAD); - - if (str_pad == H5T_STR_NULLTERM ) - printf("H5T_STR_NULLTERM;\n"); - else if (str_pad == H5T_STR_NULLPAD ) - printf("H5T_STR_NULLPAD;\n"); - else if (str_pad == H5T_STR_SPACEPAD ) - printf("H5T_STR_SPACEPAD;\n"); - else - printf("H5T_STR_ERROR;\n"); + case H5T_STRING: + size = H5Tget_size(type); + str_pad = H5Tget_strpad(type); + cset = H5Tget_cset(type); - indentation(indent + COL); - printf(" %s ", CSET); + indentation (indent + COL); + printf("%s %s %d;\n", dump_header_format->strblockbegin, + STRSIZE, (int)size); + indentation(indent + COL); + printf(" %s ", STRPAD); + + if (str_pad == H5T_STR_NULLTERM ) + printf("H5T_STR_NULLTERM;\n"); + else if (str_pad == H5T_STR_NULLPAD ) + printf("H5T_STR_NULLPAD;\n"); + else if (str_pad == H5T_STR_SPACEPAD ) + printf("H5T_STR_SPACEPAD;\n"); + else + printf("H5T_STR_ERROR;\n"); - if (cset == H5T_CSET_ASCII) - printf("H5T_CSET_ASCII;\n"); - else - printf("unknown_cset;\n"); + indentation(indent + COL); + printf(" %s ", CSET); - str_type = H5Tcopy(H5T_C_S1); - H5Tset_cset(str_type, cset); - H5Tset_size(str_type, size); - H5Tset_strpad(str_type, str_pad); - indentation(indent + COL); - printf(" %s ", CTYPE); + if (cset == H5T_CSET_ASCII) + printf("H5T_CSET_ASCII;\n"); + else + printf("unknown_cset;\n"); - if (H5Tequal(type,str_type)) { - printf("H5T_C_S1;\n"); - H5Tclose(str_type); - } else { - H5Tclose(str_type); - str_type = H5Tcopy(H5T_FORTRAN_S1); - H5Tset_cset(str_type, cset ) ; + str_type = H5Tcopy(H5T_C_S1); + H5Tset_cset(str_type, cset); H5Tset_size(str_type, size); - H5Tset_strpad(str_type, str_pad ); + H5Tset_strpad(str_type, str_pad); + indentation(indent + COL); + printf(" %s ", CTYPE); if (H5Tequal(type,str_type)) { - printf( "H5T_FORTRAN_S1;\n"); + printf("H5T_C_S1;\n"); + H5Tclose(str_type); } else { - printf("unknown_one_character_type;\n "); - d_status = 1; - } - - H5Tclose(str_type); - } - - indentation(indent + COL); - printf("%s", dump_header_format->strblockend); - break; - - case H5T_BITFIELD: - if (H5Tequal(type, H5T_STD_B8BE)) { - printf("H5T_STD_B8BE"); - } else if (H5Tequal(type, H5T_STD_B8LE)) { - printf("H5T_STD_B8LE"); - } else if (H5Tequal(type, H5T_STD_B16BE)) { - printf("H5T_STD_B16BE"); - } else if (H5Tequal(type, H5T_STD_B16LE)) { - printf("H5T_STD_B16LE"); - } else if (H5Tequal(type, H5T_STD_B32BE)) { - printf("H5T_STD_B32BE"); - } else if (H5Tequal(type, H5T_STD_B32LE)) { - printf("H5T_STD_B32LE"); - } else if (H5Tequal(type, H5T_STD_B64BE)) { - printf("H5T_STD_B64BE"); - } else if (H5Tequal(type, H5T_STD_B64LE)) { - printf("H5T_STD_B64LE"); - } else { - printf("undefined bitfield"); - d_status = 1; - } - break; + H5Tclose(str_type); + str_type = H5Tcopy(H5T_FORTRAN_S1); + H5Tset_cset(str_type, cset ) ; + H5Tset_size(str_type, size); + H5Tset_strpad(str_type, str_pad ); + + if (H5Tequal(type,str_type)) { + printf( "H5T_FORTRAN_S1;\n"); + } else { + printf("unknown_one_character_type;\n "); + d_status = 1; + } - case H5T_OPAQUE: - printf("\n"); - indentation(indent + COL); - printf("H5T_OPAQUE;\n"); - indentation(indent + COL); - printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type)); - indentation(indent); - break; + H5Tclose(str_type); + } - case H5T_COMPOUND: - if (H5Tcommitted(type) > 0) { - H5Gget_objinfo(type, ".", TRUE, &statbuf); - i = search_obj (type_table, statbuf.objno); indentation(indent + COL); - - if (i >= 0) { - if (!type_table->objs[i].recorded) - printf("\"/#%lu:%lu\"\n", type_table->objs[i].objno[0], - type_table->objs[i].objno[1]); - else - printf("\"%s\"\n", type_table->objs[i].objname); + printf("%s", dump_header_format->strblockend); + break; + + case H5T_BITFIELD: + if (H5Tequal(type, H5T_STD_B8BE)) { + printf("H5T_STD_B8BE"); + } else if (H5Tequal(type, H5T_STD_B8LE)) { + printf("H5T_STD_B8LE"); + } else if (H5Tequal(type, H5T_STD_B16BE)) { + printf("H5T_STD_B16BE"); + } else if (H5Tequal(type, H5T_STD_B16LE)) { + printf("H5T_STD_B16LE"); + } else if (H5Tequal(type, H5T_STD_B32BE)) { + printf("H5T_STD_B32BE"); + } else if (H5Tequal(type, H5T_STD_B32LE)) { + printf("H5T_STD_B32LE"); + } else if (H5Tequal(type, H5T_STD_B64BE)) { + printf("H5T_STD_B64BE"); + } else if (H5Tequal(type, H5T_STD_B64LE)) { + printf("H5T_STD_B64LE"); } else { - printf("h5dump error: unknown committed type.\n"); + printf("undefined bitfield"); d_status = 1; } - } else { - nmembers = H5Tget_nmembers(type); - - for (i = 0; i < nmembers; i++) { - fname = H5Tget_member_name(type, i); - mtype = H5Tget_member_type(type, i); - ndims = H5Tget_member_dims(type, i, dims, perm); + break; - if (H5Tget_class(mtype) != H5T_STRING) - indentation (indent + COL); + case H5T_OPAQUE: + printf("\n"); + indentation(indent + COL); + printf("H5T_OPAQUE;\n"); + indentation(indent + COL); + printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type)); + indentation(indent); + break; + + case H5T_COMPOUND: + if (H5Tcommitted(type) > 0) { + H5Gget_objinfo(type, ".", TRUE, &statbuf); + i = search_obj (type_table, statbuf.objno); + indentation(indent + COL); + + if (i >= 0) { + if (!type_table->objs[i].recorded) + printf("\"/#%lu:%lu\"\n", type_table->objs[i].objno[0], + type_table->objs[i].objno[1]); + else + printf("\"%s\"\n", type_table->objs[i].objname); + } else { + printf("h5dump error: unknown committed type.\n"); + d_status = 1; + } + } else { + nmembers = H5Tget_nmembers(type); + + for (i = 0; i < nmembers; i++) { + fname = H5Tget_member_name(type, i); + mtype = H5Tget_member_type(type, i); + + if (H5Tget_class(mtype) != H5T_STRING) + indentation (indent + COL); + + if (H5Tget_class(mtype) == H5T_COMPOUND) { + indent += COL; + printf("{\n"); + } - if (H5Tget_class(mtype) == H5T_COMPOUND) { - indent += COL; - printf("{\n"); - } + print_datatype(mtype); - print_datatype(mtype); + if (H5Tget_class(mtype) == H5T_COMPOUND) { + indent -= COL; + indentation(indent + COL); + printf("}"); + } - if (H5Tget_class(mtype) == H5T_COMPOUND) { - indent -= COL; - indentation(indent + COL); - printf("}"); - } + printf (" \"%s\";\n", fname); - printf (" \"%s\"", fname); + free(fname); + } + } + break; - if (ndims != 1 || dims[0] != 1) - for (j = 0; j < ndims; j++) - printf("[%d]",(int)dims[j]); + case H5T_REFERENCE: + printf("H5T_REFERENCE"); + break; - printf(";\n"); - free(fname); - } - } + case H5T_ENUM: + printf("H5T_ENUM\n"); + indentation(indent + COL); + printf("%s ", dump_header_format->enumblockbegin); + super = H5Tget_super(type); + print_datatype(super); + printf(";"); + print_enum(type); + printf("\n"); + indentation(indent + COL); + printf("%s", dump_header_format->enumblockend); + break; - break; + case H5T_VLEN: + super = H5Tget_super(type); - case H5T_REFERENCE: - printf("H5T_REFERENCE"); - break; + printf("H5T_VLEN of "); + print_datatype(super); + H5Tclose(super); + break; - case H5T_ENUM: - printf("H5T_ENUM\n"); - indentation(indent + COL); - printf("%s ", dump_header_format->enumblockbegin); - super = H5Tget_super(type); - print_datatype(super); - printf(";"); - print_enum(type); - printf("\n"); - indentation(indent + COL); - printf("%s", dump_header_format->enumblockend); - break; + case H5T_ARRAY: + /* Get array base type */ + super = H5Tget_super(type); + + /* Print lead-in */ + printf("H5T_ARRAY "); - case H5T_VLEN: { - hid_t super = H5Tget_super(type); + /* Get array information */ + ndims = H5Tget_array_ndims(type); + H5Tget_array_dims(type, dims, perm); - printf("H5T_VLEN OF "); - print_datatype(super); - H5Tclose(super); - break; - } + /* Print array dimensions */ + for (j = 0; j < ndims; j++) + printf("[%d]",(int)dims[j]); - default: - printf("unknown data type"); - d_status = 1; - break; + printf(" of "); + + /* Print base type */ + print_datatype(super); + + /* Close array base type */ + H5Tclose(super); + break; + + default: + printf("unknown data type"); + d_status = 1; + break; } } @@ -994,11 +1011,9 @@ done: static void dump_named_datatype(hid_t type, const char *name) { - int nmembers = 1, x,j; + int nmembers = 1, x; hid_t comptype; char *compname; - int ndims, perm[H5DUMP_MAX_RANK]; - size_t dims[H5DUMP_MAX_RANK]; indentation(indent); begin_obj(dump_header_format->datatypebegin, name, @@ -1010,15 +1025,11 @@ dump_named_datatype(hid_t type, const char *name) for (x = 0; x < nmembers; x++) { comptype = H5Tget_member_type(type,x); compname = H5Tget_member_name(type,x); - ndims = H5Tget_member_dims(type, x, dims, perm); + indentation(indent + COL); print_datatype(comptype); printf(" \"%s\"", compname); - if (ndims != 1 || dims[0] != 1) - for (j = 0; j < ndims; j++) - printf("[%d]",(int)dims[j]); - printf(";\n"); } } else { @@ -1250,7 +1261,7 @@ dump_data(hid_t obj_id, int obj_data) */ depth = indent / stdindent + 1; indentation(indent); - begin_obj(dump_header_format->databegin, NULL, + begin_obj(dump_header_format->databegin, (const char *)NULL, dump_header_format->datablockbegin); /* Print all the values. */ @@ -1306,13 +1317,13 @@ dump_data(hid_t obj_id, int obj_data) * *----------------------------------------------------------------------- */ -int +static int set_output_file(const char *fname) { FILE *f; /* temporary holding place for the stream pointer */ /* so that rawdatastream is changed only when succeeded */ - if (f = fopen(fname, "w")){ + if ((f = fopen(fname, "w"))!=NULL) { rawdatastream = f; return 0; } diff --git a/tools/h5dumptst.c b/tools/h5dumptst.c index feb9d1a..75a6229 100644 --- a/tools/h5dumptst.c +++ b/tools/h5dumptst.c @@ -321,43 +321,44 @@ int i, dset[5]; */ static void test_compound_dt(void) { /* test compound data type */ -hid_t fid, group, dataset, space, space3, type, type2; -typedef struct { - int a; - float b; - double c; -} dset1_t; -dset1_t dset1[5]; - -typedef struct { - int a; - float b; -} dset2_t; -dset2_t dset2[5]; - -typedef struct { - int a[4]; - float b[5][6]; -} dset3_t; -dset3_t dset3[3][6]; - -typedef struct { - int a; - float b; -} dset4_t; -dset4_t dset4[5]; - -typedef struct { - int a; - float b; -} dset5_t; -dset5_t dset5[5]; - -int i, j, k, l, ndims; -size_t dim[2]; - -hsize_t sdim = 5; -hsize_t dset3_dim[2]; + hid_t fid, group, dataset, space, space3, type, type2; + hid_t array_dt; + typedef struct { + int a; + float b; + double c; + } dset1_t; + dset1_t dset1[5]; + + typedef struct { + int a; + float b; + } dset2_t; + dset2_t dset2[5]; + + typedef struct { + int a[4]; + float b[5][6]; + } dset3_t; + dset3_t dset3[3][6]; + + typedef struct { + int a; + float b; + } dset4_t; + dset4_t dset4[5]; + + typedef struct { + int a; + float b; + } dset5_t; + dset5_t dset5[5]; + + int i, j, k, l, ndims; + hsize_t dim[2]; + + hsize_t sdim = 5; + hsize_t dset3_dim[2]; for (i = 0; i < (int)sdim; i++) { @@ -414,13 +415,27 @@ hsize_t dset3_dim[2]; /* shared data type 2 */ type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + ndims = 1; dim[0] = 4; - H5Tinsert_array(type, "int_array", HOFFSET(dset3_t, a), ndims, dim, NULL, H5T_STD_I32BE); - H5Tinsert_array(type2, "int_array", HOFFSET(dset3_t, a), ndims, dim, NULL, H5T_NATIVE_INT); + + array_dt=H5Tarray_create(H5T_STD_I32BE,ndims,dim,NULL); + H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(H5T_NATIVE_INT,ndims,dim,NULL); + H5Tinsert(type2, "int_array", HOFFSET(dset3_t, a), array_dt); + H5Tclose(array_dt); + ndims = 2; dim[0] = 5; dim[1] = 6; - H5Tinsert_array(type, "float_array", HOFFSET(dset3_t, b), ndims, dim, NULL, H5T_IEEE_F32BE); - H5Tinsert_array(type2, "float_array", HOFFSET(dset3_t, b), ndims, dim, NULL, H5T_NATIVE_FLOAT); + array_dt=H5Tarray_create(H5T_IEEE_F32BE,ndims,dim,NULL); + H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,ndims,dim,NULL); + H5Tinsert(type2, "float_array", HOFFSET(dset3_t, b), array_dt); + H5Tclose(array_dt); + H5Tcommit(fid, "type2", type); @@ -493,42 +508,44 @@ hsize_t dset3_dim[2]; */ static void test_compound_dt2(void) { /* test compound data type */ -hid_t fid, group, dataset, space, type, create_plist, type2; -typedef struct { - int a; - float b; - double c; -} dset1_t; -dset1_t dset1[10]; - -typedef struct { - int a; - float b; -} dset2_t; -dset2_t dset2[10]; - -typedef struct { - int a[4]; - float b[5][6]; -} dset3_t; - -typedef struct { - int a; - float b; -} dset4_t; -dset4_t dset4[10]; - -typedef struct { - int a; - float b; -} dset5_t; -dset5_t dset5[10]; - -int i, ndims; -const int perm[2]={0,1}; -size_t dim[2]; - -hsize_t sdim, maxdim; + hid_t fid, group, dataset, space, type, create_plist, type2; + hid_t array_dt; + + typedef struct { + int a; + float b; + double c; + } dset1_t; + dset1_t dset1[10]; + + typedef struct { + int a; + float b; + } dset2_t; + dset2_t dset2[10]; + + typedef struct { + int a[4]; + float b[5][6]; + } dset3_t; + + typedef struct { + int a; + float b; + } dset4_t; + dset4_t dset4[10]; + + typedef struct { + int a; + float b; + } dset5_t; + dset5_t dset5[10]; + + int i, ndims; + const int perm[2]={0,1}; + hsize_t dim[2]; + + hsize_t sdim, maxdim; sdim = 10; for (i = 0; i < (int)sdim; i++) { @@ -606,10 +623,17 @@ hsize_t sdim, maxdim; /* shared data type 2 */ type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + ndims = 1; dim[0] = 4; - H5Tinsert_array(type, "int_array", HOFFSET(dset3_t, a), ndims, dim, perm, H5T_STD_I32BE); + array_dt=H5Tarray_create(H5T_STD_I32BE,ndims,dim,perm); + H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); + H5Tclose(array_dt); + ndims = 2; dim[0] = 5; dim[1] = 6; - H5Tinsert_array(type, "float_array", HOFFSET(dset3_t, b), ndims, dim, perm, H5T_IEEE_F32BE); + array_dt=H5Tarray_create(H5T_IEEE_F32BE,ndims,dim,perm); + H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); + H5Tclose(array_dt); + H5Tcommit(fid, "type2", type); H5Tclose(type); @@ -855,26 +879,27 @@ hid_t fid, group; */ static void test_many(void) { -hid_t fid, group, attr, dataset, space, space2, type, create_plist, type2; -hsize_t dims[2]; -int data[2][2], dset2[10][10], dset3[10][10]; -double d[10]; - -char buf[60]; -int i, j; -int i0, i1, i2, i3; -hsize_t sdim, maxdim; - -typedef struct { /* compound type has members with rank > 1 */ - int a[2][2][2][2]; /* arrays are 2x2x2x2 */ - double b[2][2][2][2]; - double c[2][2][2][2]; -} dset1_t; -dset1_t dset1[6]; - -size_t dim[4]; -int index[4] = {0,1,2,3}; /* normal indicies */ -const int perm[4] = {0,1,2,3}; /* the 0'th and the 3'rd indices are permuted */ + hid_t fid, group, attr, dataset, space, space2, type, create_plist, type2; + hid_t array_dt; + hsize_t dims[2]; + int data[2][2], dset2[10][10], dset3[10][10]; + double d[10]; + + char buf[60]; + int i, j; + int i0, i1, i2, i3; + hsize_t sdim, maxdim; + + typedef struct { /* compound type has members with rank > 1 */ + int a[2][2][2][2]; /* arrays are 2x2x2x2 */ + double b[2][2][2][2]; + double c[2][2][2][2]; + } dset1_t; + dset1_t dset1[6]; + + hsize_t dim[4]; + int index[4] = {0,1,2,3}; /* normal indicies */ + const int perm[4] = {0,1,2,3}; /* the 0'th and the 3'rd indices are permuted */ fid = H5Fcreate(FILE12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -891,15 +916,32 @@ const int perm[4] = {0,1,2,3}; /* the 0'th and the 3'rd indices are permuted */ type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); dim[0] = dim[1] = dim[2] = dim[3] = 2; - H5Tinsert_array(type, "a_array", HOFFSET(dset1_t, a), 4, dim, perm, H5T_STD_I32BE); - H5Tinsert_array(type, "b_array", HOFFSET(dset1_t, b), 4, dim, perm, H5T_IEEE_F64BE); - H5Tinsert_array(type, "c_array", HOFFSET(dset1_t, c), 4, dim, perm, H5T_IEEE_F64BE); + array_dt=H5Tarray_create(H5T_STD_I32BE,4,dim,perm); + H5Tinsert(type, "a_array", HOFFSET(dset1_t, a), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(H5T_IEEE_F64BE,4,dim,perm); + H5Tinsert(type, "b_array", HOFFSET(dset1_t, b), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(H5T_IEEE_F64BE,4,dim,perm); + H5Tinsert(type, "c_array", HOFFSET(dset1_t, c), array_dt); + H5Tclose(array_dt); type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); - H5Tinsert_array(type2, "a_array", HOFFSET(dset1_t, a), 4, dim, perm, H5T_NATIVE_INT); - H5Tinsert_array(type2, "b_array", HOFFSET(dset1_t, b), 4, dim, perm, H5T_NATIVE_DOUBLE); - H5Tinsert_array(type2, "c_array", HOFFSET(dset1_t, c), 4, dim, perm, H5T_NATIVE_DOUBLE); + array_dt=H5Tarray_create(H5T_NATIVE_INT,4,dim,perm); + H5Tinsert(type2, "a_array", HOFFSET(dset1_t, a), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(H5T_NATIVE_DOUBLE,4,dim,perm); + H5Tinsert(type2, "b_array", HOFFSET(dset1_t, b), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(H5T_NATIVE_DOUBLE,4,dim,perm); + H5Tinsert(type2, "c_array", HOFFSET(dset1_t, c), array_dt); + H5Tclose(array_dt); + /* dset1 */ sdim = 6; @@ -1033,41 +1075,42 @@ hid_t type; } static void test_str(void) { -hid_t fid, dataset, space, f_type, m_type, str_type, f_type2; - -hsize_t dims1[] = { 3, 4}; -char string1[12][2] = {"s1","s2","s3","s4","s5","s6","s7","s8","s9", - "s0","s1","s2"}; - -hsize_t dims2[]={20}; -char string2[20][9] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", - "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", - "ab cd ef3", "ab cd ef4", "ab cd ef5", "ab cd ef6", - "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; - -hsize_t dims3[] = { 27}; -char string3[27][5] = {"abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6", "abcd7", - "abcd8", "abcd9", "abcd0", "abcd1", - "abcd2", "abcd3", "abcd4", "abcd5", - "abcd6", "abcd7", "abcd8", "abcd9", - "abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6"}; - -int i, j, k, l; - -hsize_t dims4[] = { 3 }; -char string4[3][20] = { "s1234567890123456789", "s1234567890123456789", - "s1234567890123456789"}; - -hsize_t dims5[] = { 3, 6}; -typedef struct { - int a[8][10]; - char s[12][32]; -} compound_t; -compound_t comp1[3][6]; -size_t mdims[2]; + hid_t fid, dataset, space, f_type, m_type, str_type, f_type2; + hid_t array_dt; + + hsize_t dims1[] = { 3, 4}; + char string1[12][2] = {"s1","s2","s3","s4","s5","s6","s7","s8","s9", + "s0","s1","s2"}; + + hsize_t dims2[]={20}; + char string2[20][9] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", + "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", + "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", + "ab cd ef3", "ab cd ef4", "ab cd ef5", "ab cd ef6", + "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + + hsize_t dims3[] = { 27}; + char string3[27][5] = {"abcd0", "abcd1", "abcd2", "abcd3", + "abcd4", "abcd5", "abcd6", "abcd7", + "abcd8", "abcd9", "abcd0", "abcd1", + "abcd2", "abcd3", "abcd4", "abcd5", + "abcd6", "abcd7", "abcd8", "abcd9", + "abcd0", "abcd1", "abcd2", "abcd3", + "abcd4", "abcd5", "abcd6"}; + + int i, j, k, l; + + hsize_t dims4[] = { 3 }; + char string4[3][20] = { "s1234567890123456789", "s1234567890123456789", + "s1234567890123456789"}; + + hsize_t dims5[] = { 3, 6}; + typedef struct { + int a[8][10]; + char s[12][32]; + } compound_t; + compound_t comp1[3][6]; + hsize_t mdims[2]; fid = H5Fcreate(FILE13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1119,17 +1162,27 @@ size_t mdims[2]; space = H5Screate_simple(2, dims5, NULL); f_type = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); f_type2 = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); + mdims[0] = 8; mdims[1] = 10; - H5Tinsert_array(f_type, "int_array", HOFFSET(compound_t, a), 2, mdims, - NULL, H5T_STD_I32BE); - H5Tinsert_array(f_type2, "int_array", HOFFSET(compound_t, a), 2, mdims, - NULL, H5T_NATIVE_INT); + + array_dt=H5Tarray_create(H5T_STD_I32BE,2,mdims,NULL); + H5Tinsert(f_type, "int_array", HOFFSET(compound_t, a), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(H5T_NATIVE_INT,2,mdims,NULL); + H5Tinsert(f_type2, "int_array", HOFFSET(compound_t, a), array_dt); + H5Tclose(array_dt); + str_type = mkstr(32, H5T_STR_SPACEPAD); mdims[0] = 3; mdims[1] = 4; - H5Tinsert_array(f_type, "string", HOFFSET(compound_t, s), 2, mdims, - NULL, str_type); - H5Tinsert_array(f_type2, "string", HOFFSET(compound_t, s), 2, mdims, - NULL, str_type); + + array_dt=H5Tarray_create(str_type,2,mdims,NULL); + H5Tinsert(f_type, "string", HOFFSET(compound_t, s), array_dt); + H5Tclose(array_dt); + + array_dt=H5Tarray_create(str_type,2,mdims,NULL); + H5Tinsert(f_type2, "string", HOFFSET(compound_t, s), array_dt); + H5Tclose(array_dt); for (i = 0; i < 3; i++) for (j = 0; j < 6; j++) { @@ -1574,14 +1627,16 @@ void test_datareg(void){ free(drbuf); } -void test_nestcomp(void){ + /*taken from Elena's compound test file*/ +void test_nestcomp(void) { /* Compound memeber of the compound datatype*/ typedef struct cmp_t { - char a; - float b[2]; + char a; + float b[2]; } cmp_t; + /* First structure and dataset*/ typedef struct s1_t { int a; @@ -1589,11 +1644,11 @@ void test_nestcomp(void){ double c; cmp_t d; } s1_t; - hid_t cmp_tid; /* Handle for the compound datatype */ - hid_t char_id; /* Handle for the string datatype */ - size_t array_dims[] = {2}; /* Dataspace dimensions */ - int ndims = 1; /* Number of dimensions in the array field */ - + hid_t cmp_tid; /* Handle for the compound datatype */ + hid_t char_id; /* Handle for the string datatype */ + hid_t array_dt; + hsize_t array_dims[] = {2}; /* Dataspace dimensions */ + int ndims = 1; /* Number of dimensions in the array field */ s1_t s1[10]; hid_t s1_tid; /* File datatype identifier */ @@ -1604,6 +1659,8 @@ void test_nestcomp(void){ hsize_t dim[] = {10}; /* Dataspace dimensions */ char datasetname[] = "ArrayOfStructures"; + + /* * Initialize the data */ @@ -1637,8 +1694,10 @@ void test_nestcomp(void){ char_id = H5Tcopy(H5T_C_S1); H5Tset_strpad(char_id, H5T_STR_NULLTERM); H5Tinsert(cmp_tid, "char_name", HOFFSET(cmp_t, a), char_id); - H5Tinsert_array(cmp_tid, "array_name", HOFFSET(cmp_t, b), ndims, - array_dims, NULL, H5T_NATIVE_FLOAT); + + array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,ndims,array_dims,NULL); + H5Tinsert(cmp_tid, "array_name", HOFFSET(cmp_t, b), array_dt); + H5Tclose(array_dt); s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); H5Tinsert(s1_tid, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT); @@ -1666,9 +1725,6 @@ void test_nestcomp(void){ H5Sclose(space); H5Dclose(dataset); H5Fclose(file); - - - } void test_opaque(void) { diff --git a/tools/h5ls.c b/tools/h5ls.c index 2a37318..fcd22bd 100644 --- a/tools/h5ls.c +++ b/tools/h5ls.c @@ -718,9 +718,9 @@ display_cmpd_type(hid_t type, int ind) { char *name=NULL; /*member name */ int ndims; /*dimensionality */ - size_t dims[8]; /*dimensions */ + hsize_t dims[H5S_MAX_RANK]; /*dimensions */ size_t size; /*total size of type in bytes */ - int perm[8]; /*index permutation */ + int perm[H5S_MAX_RANK]; /*index permutation */ hid_t subtype; /*member data type */ int i, j, n; /*miscellaneous counters */ @@ -729,39 +729,47 @@ display_cmpd_type(hid_t type, int ind) printf("struct {"); for (i=0; i0) { - printf("["); - for (j=0; j0) { + printf("["); + for (j=0; jcmpd_pre, "{")); for (j = 0; j < nmembs; j++) { - unsigned int i; - int k; - - if (j) h5dump_str_append(str, "%s", - OPT(info->cmpd_sep, - ", " OPTIONAL_LINE_BREAK)); + if (j) + h5dump_str_append(str, "%s", + OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); /* RPM 2000-10-31 * If the previous character is a line-feed (which is true when @@ -956,40 +954,10 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, /* The value */ offset = H5Tget_member_offset(type, j); memb = H5Tget_member_type(type, j); - size = H5Tget_size(memb); - ndims = H5Tget_member_dims(type, j, dims, NULL); - assert(ndims>=0 && ndims<=H5S_MAX_RANK); - - for (k = 0, nelmts = 1; k < ndims; k++) - nelmts *= dims[k]; - - if (nelmts > 1) - h5dump_str_append(str, "%s", OPT(info->arr_pre, "[")); - - for (i = 0; i < nelmts; i++) { - if (i) - h5dump_str_append(str, "%s", - OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); - - if (ndims > 0 && info->arr_linebreak && i && 0 == i % dims[ndims - 1]) { - h5dump_str_append(str, "%s", "\n"); - - /*need to indent some more here*/ - if (ctx->indent_level >= 0) - h5dump_str_append(str, "%s", OPT(info->line_pre, "")); - - for (x = 0; x < ctx->indent_level + 1; x++) - h5dump_str_append(str,"%s",OPT(info->line_indent,"")); - } - - ctx->indent_level++; - h5dump_sprint(str, info, container, memb, - cp_vp + offset + i * size, ctx); - ctx->indent_level--; - } - if (nelmts > 1) - h5dump_str_append(str, "%s", OPT(info->arr_suf, "]")); + ctx->indent_level++; + h5dump_sprint(str, info, container, memb, cp_vp + offset , ctx); + ctx->indent_level--; H5Tclose(memb); } @@ -1092,15 +1060,63 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, sb.objno[1], sb.objno[0]); } } + } else if (H5T_ARRAY==H5Tget_class(type)) { + int x; + unsigned int i; + int k; + + /* Get the array's base datatype for each element */ + memb=H5Tget_super(type); + + size = H5Tget_size(memb); + ndims = H5Tget_array_ndims(type); + H5Tget_array_dims(type, dims, NULL); + assert(ndims>=1 && ndims<=H5S_MAX_RANK); + + /* Calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) + nelmts *= dims[k]; + + /* Print the opening bracket */ + h5dump_str_append(str, "%s", OPT(info->arr_pre, "[")); + + for (i = 0; i < nelmts; i++) { + if (i) + h5dump_str_append(str, "%s", + OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); + + if (info->arr_linebreak && i && 0 == i % dims[ndims - 1]) { + h5dump_str_append(str, "%s", "\n"); + + /*need to indent some more here*/ + if (ctx->indent_level >= 0) + h5dump_str_append(str, "%s", OPT(info->line_pre, "")); + + for (x = 0; x < ctx->indent_level + 1; x++) + h5dump_str_append(str,"%s",OPT(info->line_indent,"")); + } /* end if */ + + ctx->indent_level++; + + /* Dump the array element */ + h5dump_sprint(str, info, container, memb, cp_vp + i * size, ctx); + + ctx->indent_level--; + } /* end for */ + + /* Print the closing bracket */ + h5dump_str_append(str, "%s", OPT(info->arr_suf, "]")); + + H5Tclose(memb); } else { - /* All other types get printed as hexadecimal */ - unsigned int i; + /* All other types get printed as hexadecimal */ + unsigned int i; - h5dump_str_append(str, "0x"); - n = H5Tget_size(type); + h5dump_str_append(str, "0x"); + n = H5Tget_size(type); - for (i = 0; i < n; i++) - h5dump_str_append(str, "%02x", ((unsigned char *)vp)[i]); + for (i = 0; i < n; i++) + h5dump_str_append(str, "%02x", ((unsigned char *)vp)[i]); } return h5dump_str_fmt(str, start, OPT(info->elmt_fmt, "%s")); @@ -1642,8 +1658,11 @@ h5dump_fixtype(hid_t f_type) hid_t m_type = FAIL, f_memb; hid_t *memb = NULL; char **name = NULL; - int nmembs = 0, i, *ndims = NULL; - size_t size, offset, *dims = NULL, nelmts; + int nmembs = 0, i; + int ndims; + hsize_t dim[H5S_MAX_RANK]; + size_t size, offset; + hid_t array_base; /* H5T_str_t strpad; */ size = H5Tget_size(f_type); @@ -1708,11 +1727,8 @@ h5dump_fixtype(hid_t f_type) nmembs = H5Tget_nmembers(f_type); memb = calloc(nmembs, sizeof(hid_t)); name = calloc(nmembs, sizeof(char *)); - ndims = calloc(nmembs, sizeof(int)); - dims = calloc(nmembs * 4, sizeof(size_t)); for (i = 0, size = 0; i < nmembs; i++) { - int j; /* Get the member type and fix it */ f_memb = H5Tget_member_type(f_type, i); @@ -1720,48 +1736,52 @@ h5dump_fixtype(hid_t f_type) H5Tclose(f_memb); if (memb[i] < 0) - goto done; - - /* Get the member dimensions */ - ndims[i] = H5Tget_member_dims(f_type, i, dims + i * 4, NULL); - assert(ndims[i] >= 0 && ndims[i] <= 4); - - for (j = 0, nelmts = 1; j < ndims[i]; j++) - nelmts *= dims[i * 4 + j]; + goto done; /* Get the member name */ name[i] = H5Tget_member_name(f_type, i); if (name[i] == NULL) - goto done; + goto done; /* * Compute the new offset so each member is aligned on a byte * boundary which is the same as the member size. */ - size = ALIGN(size, H5Tget_size(memb[i])) + - nelmts * H5Tget_size(memb[i]); + size = ALIGN(size, H5Tget_size(memb[i])) + H5Tget_size(memb[i]); } m_type = H5Tcreate(H5T_COMPOUND, size); for (i = 0, offset = 0; i < nmembs; i++) { - int j; - if (offset) - offset = ALIGN(offset, H5Tget_size(memb[i])); + if (offset) + offset = ALIGN(offset, H5Tget_size(memb[i])); - H5Tinsert_array(m_type, name[i], offset, ndims[i], dims + i * 4, - NULL, memb[i]); + H5Tinsert(m_type, name[i], offset, memb[i]); - for (j = 0, nelmts = 1; j < ndims[i]; j++) - nelmts *= dims[i * 4 + j]; - - offset += nelmts * H5Tget_size(memb[i]); + offset += H5Tget_size(memb[i]); } break; + case H5T_ARRAY: + /* Get the array information */ + ndims=H5Tget_array_ndims(f_type); + H5Tget_array_dims(f_type,dim,NULL); + + /* Get the array's base type and convert it to the printable version */ + f_memb=H5Tget_super(f_type); + array_base = h5dump_fixtype(f_memb); + + /* Copy the array */ + m_type=H5Tarray_create(array_base,ndims,dim,NULL); + + /* Close the temporary datatypes */ + H5Tclose(array_base); + H5Tclose(f_memb); + break; + case H5T_ENUM: case H5T_REFERENCE: case H5T_OPAQUE: @@ -1793,21 +1813,19 @@ h5dump_fixtype(hid_t f_type) done: /* Clean up temp buffers */ - if (memb && name && ndims && dims) { - int j; + if (memb && name) { + int j; - for (j = 0; j < nmembs; j++) { - if (memb[j] >= 0) - H5Tclose(memb[j]); + for (j = 0; j < nmembs; j++) { + if (memb[j] >= 0) + H5Tclose(memb[j]); - if (name[j]) - free(name[j]); - } + if (name[j]) + free(name[j]); + } - free(memb); - free(name); - free(ndims); - free(dims); + free(memb); + free(name); } return m_type; @@ -1897,6 +1915,22 @@ done: return status; } +static +void *vlcustom_alloc(size_t size, void *info) +{ + void *ret_value = NULL; + int *mem_used = (int *)info; + size_t extra = MAX(sizeof(void *), sizeof(size_t)); + + if ((ret_value = HDmalloc(extra + size)) != NULL) { + *(size_t *)ret_value = size; + *mem_used += size; + } + + ret_value = ((unsigned char *)ret_value) + extra; + return ret_value; +} + /*------------------------------------------------------------------------- * Function: h5dump_vlen_dset * @@ -1991,6 +2025,9 @@ recheck: case H5T_TIME: if (!bad_type) bad_type = "H5T_TIME"; + case H5T_ARRAY: + if (!bad_type) + bad_type = "H5T_ARRAY"; default: fprintf(stream, "Dumper doesn't support %s variable length datatype at this time.\n", diff --git a/tools/talign.c b/tools/talign.c index 7c9b64b..f36eccf 100644 --- a/tools/talign.c +++ b/tools/talign.c @@ -26,9 +26,10 @@ int main(void) hid_t cs6, cmp, fix; hid_t cmp1, cmp2, cmp3; hid_t plist; + hid_t array_dt; hsize_t dim[2]; - size_t cdim[4]; + hsize_t cdim[4]; char string5[5]; float fok[2] = {1234., 2341.}; @@ -61,25 +62,35 @@ int main(void) cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok)); H5Tinsert(cmp, "Awkward length", 0, cs6); + cdim[0] = sizeof(fok) / sizeof(float); - H5Tinsert_array(cmp, "Ok", sizeof(string5), 1, cdim, NULL, H5T_NATIVE_FLOAT); + array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL); + H5Tinsert(cmp, "Ok", sizeof(string5), array_dt); + H5Tclose(array_dt); + cdim[0] = sizeof(fnok) / sizeof(float); - H5Tinsert_array(cmp, "Not Ok", sizeof(fok) + sizeof(string5), - 1, cdim, NULL, H5T_NATIVE_FLOAT); + array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL); + H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt); + H5Tclose(array_dt); fix = h5dump_fixtype(cmp); - cdim[0] = sizeof(fok) / sizeof(float); cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok)); - H5Tinsert_array(cmp1, "Ok", 0, 1, cdim, NULL, H5T_NATIVE_FLOAT); + + cdim[0] = sizeof(fok) / sizeof(float); + array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL); + H5Tinsert(cmp1, "Ok", 0, array_dt); + H5Tclose(array_dt); cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5)); H5Tinsert(cmp2, "Awkward length", 0, cs6); - cdim[0] = sizeof(fnok) / sizeof(float); cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok)); - H5Tinsert_array(cmp3, "Not Ok", 0, 1, cdim, NULL, - H5T_NATIVE_FLOAT); + + cdim[0] = sizeof(fnok) / sizeof(float); + array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL); + H5Tinsert(cmp3, "Not Ok", 0, array_dt); + H5Tclose(array_dt); plist = H5Pcreate(H5P_DATASET_XFER); H5Pset_preserve(plist, 1); -- cgit v0.12