From f1c4d0ff3fbdfcebf3a22a24c26f1d69ecb3a5fe Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 4 Mar 2015 08:34:24 -0500 Subject: [svn-r26352] Update h5dump to latest BNF - reg vs irreg hyperslabs. --- tools/lib/h5tools.h | 5 +++- tools/lib/h5tools_dump.c | 28 +++++++++++------- tools/lib/h5tools_str.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++-- tools/lib/h5tools_str.h | 1 + 4 files changed, 96 insertions(+), 13 deletions(-) diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 323425f..7ed60e8 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -94,8 +94,11 @@ #define PACKED_OFFSET "OFFSET" #define PACKED_LENGTH "LENGTH" #define VDS_VIRTUAL "VIRTUAL" -#define VDS_HYPERSLAB "HYPERSLAB" +#define VDS_REG_HYPERSLAB "REGULAR_HYPERSLAB" +#define VDS_IRR_HYPERSLAB "IRREGULAR_HYPERSLAB" #define VDS_POINT "POINT" +#define VDS_SRC_FILE "SRC_FILE" +#define VDS_SRC_DATASET "SRC_DATASET" #define BEGIN "{" #define END "}" diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 84318a1..3fee4d1 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -225,7 +225,8 @@ void h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims); void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, struct subset_t *sset, int dims); -void h5tools_print_virtual_selection(h5tools_str_t *buffer, const h5tool_format_t *info, hid_t vspace, hid_t dcpl_id, size_t index); +void h5tools_print_virtual_selection(h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx, + hid_t vspace, hid_t dcpl_id, size_t index); void h5tools_dump_init(void) @@ -2861,9 +2862,10 @@ h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, *------------------------------------------------------------------------- */ void -h5tools_print_virtual_selection(h5tools_str_t *buffer, const h5tool_format_t *info, hid_t vspace, hid_t dcpl_id, size_t index) +h5tools_print_virtual_selection(h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx, + hid_t vspace, hid_t dcpl_id, size_t index) { - h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->virtualselectionbegin); + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->virtualselectionbegin); switch(H5Sget_select_type(vspace)) { case H5S_SEL_NONE: /* Nothing selected */ h5tools_str_append(buffer, "NONE"); @@ -2874,9 +2876,15 @@ h5tools_print_virtual_selection(h5tools_str_t *buffer, const h5tool_format_t *in h5tools_str_append(buffer, " %s", h5tools_dump_header_format->virtualselectionblockend); break; case H5S_SEL_HYPERSLABS: /* "New-style" hyperslab selection defined */ - h5tools_str_append(buffer, "%s %s ", VDS_HYPERSLAB, h5tools_dump_header_format->virtualselectionblockbegin); - h5tools_str_dump_space_blocks(buffer, vspace, info); - h5tools_str_append(buffer, " %s", h5tools_dump_header_format->virtualselectionblockend); + if (H5Sis_regular_hyperslab(vspace)) { + h5tools_str_append(buffer, "%s %s ", VDS_REG_HYPERSLAB, h5tools_dump_header_format->virtualselectionblockbegin); + h5tools_str_dump_space_slabs(buffer, vspace, info, ctx); + } + else { + h5tools_str_append(buffer, "%s %s ", VDS_IRR_HYPERSLAB, h5tools_dump_header_format->virtualselectionblockbegin); + h5tools_str_dump_space_blocks(buffer, vspace, info); + } + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->virtualselectionblockend); break; case H5S_SEL_ALL: /* Entire extent selected */ h5tools_str_append(buffer, "ALL"); @@ -3154,7 +3162,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, ctx->indent_level++; h5tools_str_reset(&buffer); - h5tools_print_virtual_selection(&buffer, info, virtual_vspace, dcpl_id, next); + h5tools_print_virtual_selection(&buffer, info, ctx, virtual_vspace, dcpl_id, next); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); ssize_out = H5Pget_virtual_filename(dcpl_id, next, NULL, 0); @@ -3166,7 +3174,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualfilenamebegin); + h5tools_str_append(&buffer, "%s %s", VDS_SRC_FILE, h5tools_dump_header_format->virtualfilenamebegin); h5tools_str_append(&buffer, "%s", name); h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualfilenameend); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); @@ -3175,7 +3183,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualdatasetnamebegin); + h5tools_str_append(&buffer, "%s %s", VDS_SRC_DATASET, h5tools_dump_header_format->virtualdatasetnamebegin); h5tools_str_append(&buffer, "%s", dsetname); h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualdatasetnameend); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); @@ -3184,7 +3192,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); h5tools_str_reset(&buffer); - h5tools_print_virtual_selection(&buffer, info, virtual_srcspace, dcpl_id, next); + h5tools_print_virtual_selection(&buffer, info, ctx, virtual_srcspace, dcpl_id, next); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); ctx->indent_level--; diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 45424f6..94b0ff2 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -416,7 +416,7 @@ h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Function: h5tools_str_dump_space_blocks + * Function: h5tools_str_dump_space_slabs * * Purpose: Prints information about a dataspace selection by appending * the information to the specified string. @@ -429,6 +429,78 @@ h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, *------------------------------------------------------------------------- */ void +h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, + const h5tool_format_t *info, h5tools_context_t *ctx) +{ + hsize_t *start; + hsize_t *stride; + hsize_t *count; + hsize_t *block; + int j; + int ndims = H5Sget_simple_extent_ndims(rspace); + + start = (hsize_t *)malloc(sizeof(hsize_t) * ndims); + stride = (hsize_t *)malloc(sizeof(hsize_t) * ndims); + count = (hsize_t *)malloc(sizeof(hsize_t) * ndims); + block = (hsize_t *)malloc(sizeof(hsize_t) * ndims); + + H5Sget_regular_hyperslab(rspace, start, stride, count, block); + + /* Print hyperslab information */ + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); + + /* Start coordinates */ + h5tools_str_append(str, "%s ", START); + for (j = 0; j < ndims; j++) + h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", start[j]); + h5tools_str_append(str, ");"); + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); + + /* Stride coordinates */ + h5tools_str_append(str, "%s ", STRIDE); + for (j = 0; j < ndims; j++) + h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", stride[j]); + h5tools_str_append(str, ");"); + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); + + /* Count coordinates */ + h5tools_str_append(str, "%s ", COUNT); + for (j = 0; j < ndims; j++) + h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", count[j]); + h5tools_str_append(str, ");"); + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); + + /* Block coordinates */ + h5tools_str_append(str, "%s ", BLOCK); + for (j = 0; j < ndims; j++) + h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", block[j]); + h5tools_str_append(str, ");"); + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); + + HDfree(block); + HDfree(count); + HDfree(stride); + HDfree(start); +} + +/*------------------------------------------------------------------------- + * Function: h5tools_str_dump_space_blocks + * + * Purpose: Prints information about a dataspace selection by appending + * the information to the specified string. + * + * Return: none + * + * In/Out: + * h5tools_str_t *str + *------------------------------------------------------------------------- + */ +void h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, const h5tool_format_t *info) { @@ -485,7 +557,6 @@ h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, * Return: none * * In/Out: - * h5tools_context_t *ctx * h5tools_str_t *str *------------------------------------------------------------------------- */ diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 8d4c042..6173b89 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -40,6 +40,7 @@ H5TOOLS_DLL char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_ H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t max_idx[], h5tools_context_t *ctx); +H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5tool_format_t *, h5tools_context_t *ctx); H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *); H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *); H5TOOLS_DLL void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, -- cgit v0.12