diff options
-rw-r--r-- | tools/lib/h5tools_dump.c | 3 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 18 | ||||
-rw-r--r-- | tools/src/h5ls/h5ls.c | 105 |
3 files changed, 102 insertions, 24 deletions
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 9517b21..34637c5 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -3930,6 +3930,8 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * for (i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) { void* memref = region_buf + i * nsize; + H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos); + datactx.need_prefix = TRUE; h5tools_str_reset(&buffer); H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF_DSETREG:%d", i); @@ -3999,6 +4001,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed"); } } /* end else to if (h5tools_is_zero(... */ + H5TOOLS_DEBUG("finished reference loop:%d",i); } /* end for (i = 0; i < nelmts... */ HDfree(region_buf); } diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index a12ea7f..3a139c3 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1090,7 +1090,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai else { if(nsize == H5R_DSET_REG_REF_BUF_SIZE) { /* if (H5Tequal(type, H5T_STD_REF_DSETREG)) */ - H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); + H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF_DSETREG"); h5tools_str_append(str, H5_TOOLS_DATASET); h5tools_str_sprint_reference(str, container, vp); } @@ -1102,22 +1102,22 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai H5O_info_t oi; const char *path; - H5TOOLS_DEBUG("ref_type is H5R_OBJECT"); + H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF_OBJ"); obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); H5Oget_info2(obj, &oi, H5O_INFO_BASIC); /* Print object type and close object */ switch(oi.type) { case H5O_TYPE_GROUP: - h5tools_str_append(str, H5_TOOLS_GROUP); + h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_GROUP); break; case H5O_TYPE_DATASET: - h5tools_str_append(str, H5_TOOLS_DATASET); + h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATASET); break; case H5O_TYPE_NAMED_DATATYPE: - h5tools_str_append(str, H5_TOOLS_DATATYPE); + h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATATYPE); break; case H5O_TYPE_UNKNOWN: @@ -1128,6 +1128,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /* end switch */ H5Oclose(obj); + h5tools_str_sprint_reference(str, container, vp); + /* Print OID */ if(info->obj_hidefileno) h5tools_str_append(str, info->obj_format, oi.addr); @@ -1304,25 +1306,23 @@ h5tools_str_sprint_reference(h5tools_str_t *str, hid_t container, void *vp) H5TOOLS_START_DEBUG(""); - h5tools_str_append(str, " \""); obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, vp); if(obj >= 0) { region = H5Rget_region(container, H5R_DATASET_REGION, vp); if(region >= 0) { H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*) ref_name, 1024); - + h5tools_str_append(str, " \""); h5tools_str_append(str, "%s", ref_name); + h5tools_str_append(str, "\""); H5Sclose(region); } /* end if (region >= 0) */ H5Dclose(obj); } /* end if (obj >= 0) */ - h5tools_str_append(str, "\""); H5TOOLS_ENDDEBUG(""); } - /*------------------------------------------------------------------------- * Function: h5tools_escape * diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index eafa592..4d22df5 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -1320,12 +1320,15 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx datactx.need_prefix = TRUE; h5tools_str_reset(&buffer); + H5TOOLS_DEBUG("reference loop - h5tools_str_sprint"); h5tools_str_sprint(&buffer, info, container, f_type, memref, &datactx); h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims); - datactx.indent_level++; - h5tools_dump_dset(stream, info, &datactx, container); - datactx.indent_level--; + if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) { + datactx.indent_level++; + h5tools_dump_dset(stream, info, &datactx, container); + datactx.indent_level--; + } H5TOOLS_DEBUG("finished reference loop:%d",i); } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */ @@ -1354,6 +1357,7 @@ dump_dataset_values(hid_t dset) hsize_t total_size[H5S_MAX_RANK]; int ndims; size_t i; + size_t nsize; char string_prefix[64]; static char fmt_double[16]; static char fmt_float[16]; @@ -1362,11 +1366,13 @@ dump_dataset_values(hid_t dset) h5tools_context_t ctx; /* print context */ h5tool_format_t outputformat; h5tool_format_t *info = &ls_dataformat; + unsigned char *region_buf = NULL; H5TOOLS_START_DEBUG(""); f_type = H5Dget_type(dset); space = H5Dget_space(dset); + nsize = H5Tget_size(f_type); HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -1457,10 +1463,42 @@ dump_dataset_values(hid_t dset) ctx.need_prefix = TRUE; ctx.cur_column = (size_t)curr_pos; - if (h5tools_dump_dset(rawoutstream, info, &ctx, dset) < 0) { - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " Unable to print data."); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + if (H5Tget_class(f_type) == H5T_REFERENCE) { + H5TOOLS_DEBUG("reference class type"); + if (!H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { + H5TOOLS_GOTO_DONE_NO_RET(); + } + + ndims = (int)H5Sget_simple_extent_npoints(space); + H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims); + + /* Assume entire data space to be printed */ + if (ctx.ndims > 0) + for (i = 0; i < (size_t)ctx.ndims; i++) + ctx.p_min_idx[i] = 0; + + H5Sget_simple_extent_dims(space, total_size, NULL); + if (ctx.ndims > 0) + init_acc_pos(&ctx, total_size); + ctx.need_prefix = TRUE; + + if (NULL != (region_buf = (void *)HDcalloc(nsize, (size_t)ndims))) { + H5TOOLS_DEBUG("H5Dread reference read"); + if (H5Dread(dset, f_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, region_buf) < 0) { + HDfree(region_buf); + H5TOOLS_INFO("H5Dread reference failed"); + H5TOOLS_GOTO_DONE_NO_RET(); + } + dump_reference(rawoutstream, info, &ctx, dset, region_buf, ndims); + HDfree(region_buf); + } + } + else { + if (h5tools_dump_dset(rawoutstream, info, &ctx, dset) < 0) { + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " Unable to print data."); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + } } done: H5Sclose(space); @@ -1490,6 +1528,7 @@ dump_attribute_values(hid_t attr) hsize_t total_size[H5S_MAX_RANK]; int ndims; size_t i; + size_t nsize; char string_prefix[64]; static char fmt_double[16]; static char fmt_float[16]; @@ -1498,11 +1537,13 @@ dump_attribute_values(hid_t attr) h5tools_context_t ctx; /* print context */ h5tool_format_t outputformat; h5tool_format_t *info = &ls_dataformat; + unsigned char *region_buf = NULL; H5TOOLS_START_DEBUG(""); f_type = H5Aget_type(attr); space = H5Aget_space(attr); + nsize = H5Tget_size(f_type); HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -1594,15 +1635,49 @@ dump_attribute_values(hid_t attr) ctx.need_prefix = TRUE; ctx.cur_column = (size_t)curr_pos; - H5TOOLS_DEBUG("Attribute data read"); - ctx.indent_level++; - if (h5tools_dump_mem(rawoutstream, info, &ctx, attr) < 0) { - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " Unable to print data."); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + if (H5Tget_class(f_type) == H5T_REFERENCE) { + H5TOOLS_DEBUG("reference class type"); + if (!H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { + H5TOOLS_GOTO_DONE_NO_RET(); + } + + ndims = (int)H5Sget_simple_extent_npoints(space); + H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims); + + /* Assume entire data space to be printed */ + if (ctx.ndims > 0) + for (i = 0; i < (size_t)ctx.ndims; i++) + ctx.p_min_idx[i] = 0; + + H5Sget_simple_extent_dims(space, total_size, NULL); + if (ctx.ndims > 0) + init_acc_pos(&ctx, total_size); + ctx.need_prefix = TRUE; + + if (NULL != (region_buf = (void *)HDcalloc(nsize, (size_t)ndims))) { + H5TOOLS_DEBUG("H5Aread reference read"); + if (H5Aread(attr, f_type, region_buf) < 0) { + HDfree(region_buf); + H5TOOLS_INFO("H5Aread reference failed"); + H5TOOLS_GOTO_DONE_NO_RET(); + } + ctx.indent_level++; + dump_reference(rawoutstream, info, &ctx, attr, region_buf, ndims); + ctx.indent_level--; + HDfree(region_buf); + } + } + else { + H5TOOLS_DEBUG("Attribute data read"); + ctx.indent_level++; + if (h5tools_dump_mem(rawoutstream, info, &ctx, attr) < 0) { + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " Unable to print data."); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + } + ctx.indent_level--; + H5TOOLS_DEBUG("Attribute data read complete"); } - ctx.indent_level--; - H5TOOLS_DEBUG("Attribute data read complete"); done: H5Sclose(space); H5Tclose(f_type); |