diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index d3c30ab627..da0bca1a5a 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -1320,86 +1320,101 @@ list_attr (hid_t obj, const char *attr_name, void UNUSED *op_data) hsize_t temp_need; void *buf; h5dump_t info; + H5S_class_t space_type; printf(" Attribute: "); n = display_string(stdout, attr_name, TRUE); printf("%*s", MAX(0, 9-n), ""); + if ((attr = H5Aopen_name(obj, attr_name))) { - space = H5Aget_space(attr); - type = H5Aget_type(attr); + space = H5Aget_space(attr); + type = H5Aget_type(attr); - /* Data space */ - ndims = H5Sget_simple_extent_dims(space, size, NULL); - if (0==ndims) { - puts(" scalar"); - } else { - printf(" {"); - for (i=0; i=0) { - temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)); - assert(temp_need==(hsize_t)((size_t)temp_need)); - need = (size_t)temp_need; - buf = malloc(need); - assert(buf); - if (H5Aread(attr, p_type, buf)>=0) { - h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1); - } - free(buf); - H5Tclose(p_type); - } - - H5Sclose(space); - H5Tclose(type); - H5Aclose(attr); + /* Data */ + memset(&info, 0, sizeof info); + info.line_multi_new = 1; + if (nelmts<5) { + info.idx_fmt = ""; + info.line_1st = " Data: "; + info.line_pre = " "; + info.line_cont = " "; + info.str_repeat = 8; + + } else { + printf(" Data:\n"); + info.idx_fmt = "(%s)"; + info.line_pre = " %s "; + info.line_cont = " %s "; + info.str_repeat = 8; + } + + info.line_ncols = width_g; + if (label_g) info.cmpd_name = "%s="; + if (string_g && 1==H5Tget_size(type) && + H5T_INTEGER==H5Tget_class(type)) { + info.ascii = TRUE; + info.elmt_suf1 = ""; + info.elmt_suf2 = ""; + info.idx_fmt = "(%s)"; + info.line_pre = " %s \""; + info.line_suf = "\""; + } + + /* values of type reference */ + info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT; + info.obj_hidefileno = 0; + if (hexdump_g) { + p_type = H5Tcopy(type); + } else { + p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT); + } + + if (p_type>=0) { + temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)); + assert(temp_need==(hsize_t)((size_t)temp_need)); + need = (size_t)temp_need; + buf = malloc(need); + assert(buf); + if (H5Aread(attr, p_type, buf)>=0) { + h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1); + } + free(buf); + H5Tclose(p_type); + } + + H5Sclose(space); + H5Tclose(type); + H5Aclose(attr); } else { - putchar('\n'); + putchar('\n'); } return 0; @@ -1430,13 +1445,15 @@ dataset_list1(hid_t dset) { hsize_t cur_size[64]; /* current dataset dimensions */ hsize_t max_size[64]; /* maximum dataset dimensions */ - hid_t space; /* data space */ - int ndims; /* dimensionality */ + hid_t space; /* data space */ + int ndims; /* dimensionality */ + H5S_class_t space_type; /* type of dataspace */ int i; /* Information that goes on the same row as the name. The name has * already been printed. */ space = H5Dget_space(dset); + space_type = H5Sget_simple_extent_type(space); ndims = H5Sget_simple_extent_dims(space, cur_size, max_size); printf (" {"); for (i=0; i 0) { + if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) { if (!sset) status = h5tools_dump_simple_dset(rawdatastream, info, dset, p_type, indentlevel); else status = h5tools_dump_simple_subset(rawdatastream, info, dset, p_type, sset, indentlevel); - } + } else /* space is H5S_NULL */ + status = SUCCEED; /* Close the dataspace */ H5Sclose(f_space); diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 143685f66a..ce4b6f6fdf 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -455,8 +455,9 @@ extern FILE *rawdatastream; /*output stream for raw data */ #define NLINK "NLINK" #define OBJID "OBJECTID" #define OBJNO "OBJNO" -#define SCALAR "SCALAR" -#define SIMPLE "SIMPLE" +#define S_SCALAR "SCALAR" +#define S_SIMPLE "SIMPLE" +#define S_NULL "NULL" #define SOFTLINK "SOFTLINK" #define STORAGELAYOUT "STORAGELAYOUT" #define START "START" diff --git a/tools/testfiles/tall-2A.h5.xml b/tools/testfiles/tall-2A.h5.xml index 8f2853d93e..dfa5c9794d 100644 --- a/tools/testfiles/tall-2A.h5.xml +++ b/tools/testfiles/tall-2A.h5.xml @@ -3,7 +3,7 @@ Expected output for 'h5dump --xml -A tall.h5' ############################# - + @@ -40,9 +40,9 @@ Expected output for 'h5dump --xml -A tall.h5' - - - + + + @@ -99,10 +99,10 @@ Expected output for 'h5dump --xml -A tall.h5' - + - + @@ -122,18 +122,18 @@ Expected output for 'h5dump --xml -A tall.h5' - + - - - + + + - - + + @@ -153,10 +153,10 @@ Expected output for 'h5dump --xml -A tall.h5' - + - + @@ -177,7 +177,7 @@ Expected output for 'h5dump --xml -A tall.h5' - + diff --git a/tools/testfiles/tall.h5 b/tools/testfiles/tall.h5 index 82529d3e6c..2bc4993576 100644 Binary files a/tools/testfiles/tall.h5 and b/tools/testfiles/tall.h5 differ diff --git a/tools/testfiles/tall.h5.xml b/tools/testfiles/tall.h5.xml index dc31aaddd8..22e6f51fa0 100644 --- a/tools/testfiles/tall.h5.xml +++ b/tools/testfiles/tall.h5.xml @@ -3,7 +3,7 @@ Expected output for 'h5dump --xml tall.h5' ############################# - + @@ -40,9 +40,9 @@ Expected output for 'h5dump --xml tall.h5' - - - + + + @@ -113,7 +113,7 @@ Expected output for 'h5dump --xml tall.h5' - + @@ -139,14 +139,14 @@ Expected output for 'h5dump --xml tall.h5' - - - + + + - - + + @@ -171,7 +171,7 @@ Expected output for 'h5dump --xml tall.h5' - + diff --git a/tools/testfiles/tattr-1.ddl b/tools/testfiles/tattr-1.ddl index b5b8afe9f5..ad473af93c 100644 --- a/tools/testfiles/tattr-1.ddl +++ b/tools/testfiles/tattr-1.ddl @@ -44,5 +44,11 @@ GROUP "/" { "string attribute" } } + ATTRIBUTE "attr6" { + DATATYPE H5T_STD_U32LE + DATASPACE NULL + DATA { + } + } } } diff --git a/tools/testfiles/tattr.h5 b/tools/testfiles/tattr.h5 index 2c7e60a71d..4314cdf17c 100644 Binary files a/tools/testfiles/tattr.h5 and b/tools/testfiles/tattr.h5 differ diff --git a/tools/testfiles/tattr.h5.xml b/tools/testfiles/tattr.h5.xml index 0fe76420d2..0fbb8330ff 100644 --- a/tools/testfiles/tattr.h5.xml +++ b/tools/testfiles/tattr.h5.xml @@ -3,7 +3,7 @@ Expected output for 'h5dump --xml tattr.h5' ############################# - + @@ -86,5 +86,20 @@ Expected output for 'h5dump --xml tattr.h5' + + + + + + + + + + + + + + + diff --git a/tools/testfiles/tdset-1.ddl b/tools/testfiles/tdset-1.ddl index cbec6aae20..68dc8a8be0 100644 --- a/tools/testfiles/tdset-1.ddl +++ b/tools/testfiles/tdset-1.ddl @@ -122,5 +122,11 @@ GROUP "/" { 29.0016, 29.0017, 29.0018, 29.0019 } } + DATASET "dset3" { + DATATYPE H5T_STD_I32BE + DATASPACE NULL + DATA { + } + } } } diff --git a/tools/testfiles/tdset-1.ls b/tools/testfiles/tdset-1.ls index 68534298c3..dad8ef698f 100644 --- a/tools/testfiles/tdset-1.ls +++ b/tools/testfiles/tdset-1.ls @@ -99,3 +99,5 @@ (28,19) 28.0019, 29, 29.0001, 29.0002, 29.0003, 29.0004, 29.0005, (29,6) 29.0006, 29.0007, 29.0008, 29.0009, 29.001, 29.0011, 29.0012, (29,13) 29.0013, 29.0014, 29.0015, 29.0016, 29.0017, 29.0018, 29.0019 +/dset3 Dataset {NULL} + Data: diff --git a/tools/testfiles/tdset-2.ddl b/tools/testfiles/tdset-2.ddl index 93c961c13d..0ddcb334c4 100644 --- a/tools/testfiles/tdset-2.ddl +++ b/tools/testfiles/tdset-2.ddl @@ -1,5 +1,5 @@ ############################# -Expected output for 'h5dump -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5' +Expected output for 'h5dump -H -d dset1 -d /dset2 -d dset3 --dataset=dset4 tdset.h5' ############################# HDF5 "tdset.h5" { DATASET "dset1" { @@ -11,6 +11,10 @@ DATASET "/dset2" { DATASPACE SIMPLE { ( 30, 20 ) / ( 30, 20 ) } } DATASET "dset3" { + DATATYPE H5T_STD_I32BE + DATASPACE NULL +} +DATASET "dset4" { } } -h5dump error: unable to open dataset "dset3" +h5dump error: unable to open dataset "dset4" diff --git a/tools/testfiles/tdset.h5 b/tools/testfiles/tdset.h5 index 9c6815e619..c3b7c9c1c4 100644 Binary files a/tools/testfiles/tdset.h5 and b/tools/testfiles/tdset.h5 differ diff --git a/tools/testfiles/tdset.h5.xml b/tools/testfiles/tdset.h5.xml index 7781d1d64c..2af4a8c3a8 100644 --- a/tools/testfiles/tdset.h5.xml +++ b/tools/testfiles/tdset.h5.xml @@ -3,8 +3,8 @@ Expected output for 'h5dump --xml tdset.h5' ############################# - - + + @@ -39,7 +39,7 @@ Expected output for 'h5dump --xml tdset.h5' - + @@ -144,5 +144,26 @@ Expected output for 'h5dump --xml tdset.h5' + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/testfiles/tnamed_dtype_attr.h5 b/tools/testfiles/tnamed_dtype_attr.h5 index 4e136e50b2..cb40ddcb5c 100644 Binary files a/tools/testfiles/tnamed_dtype_attr.h5 and b/tools/testfiles/tnamed_dtype_attr.h5 differ diff --git a/tools/testfiles/tnamed_dtype_attr.h5.xml b/tools/testfiles/tnamed_dtype_attr.h5.xml index 38700db9a9..329d3ac769 100644 --- a/tools/testfiles/tnamed_dtype_attr.h5.xml +++ b/tools/testfiles/tnamed_dtype_attr.h5.xml @@ -36,7 +36,7 @@ Expected output for 'h5dump --xml tnamed_dtype_attr.h5' - +