diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2009-04-29 15:30:22 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2009-04-29 15:30:22 (GMT) |
commit | c983debc59422d641129bea2b56a50c1e9d6d065 (patch) | |
tree | 278b607680d2f81324f1d39405446506d8f2f5fa | |
parent | 38ba243d4869d6c6e32060a14388df1c1aba3d37 (diff) | |
download | hdf5-c983debc59422d641129bea2b56a50c1e9d6d065.zip hdf5-c983debc59422d641129bea2b56a50c1e9d6d065.tar.gz hdf5-c983debc59422d641129bea2b56a50c1e9d6d065.tar.bz2 |
[svn-r16889] Improved the h5dump output format for region reference data. The region data index values are correct and there is no output order dependent line break problem. The region data still needs work to display blocks with dimension breaks.
-rw-r--r-- | tools/lib/h5tools.c | 43 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 22 | ||||
-rw-r--r-- | tools/testfiles/tdataregR.ddl | 4 |
3 files changed, 26 insertions, 43 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 3a25972..1ef92a4 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1165,7 +1165,7 @@ hsize_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, */ curr_pos = ctx->sm_pos + i_count; - h5tools_region_simple_prefix(stream, info, ctx, curr_pos, ptdata, secnum); + h5tools_region_simple_prefix(stream, info, ctx, i_count, ptdata, secnum); } else if ((i_count || ctx->continuation) && secnum == 0) { fputs(OPT(info->elmt_suf2, " "), stream); @@ -1336,9 +1336,8 @@ hsize_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, start = (hsize_t *) malloc(sizeof(hsize_t) * ndims); count = (hsize_t *) malloc(sizeof(hsize_t) * ndims); - region_elmtno = 0; region_curr_pos = 0; - for (blkndx = 0; blkndx < nblocks; blkndx++, region_elmtno++) { + for (blkndx = 0; blkndx < nblocks; blkndx++) { memset(®ion_ctx, 0, sizeof(region_ctx)); region_ctx.indent_level = ctx->indent_level; @@ -1361,12 +1360,8 @@ hsize_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, status = H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf); - /* Render the element */ - h5tools_str_reset(buffer); - region_ctx.indent_level++; H5Sget_simple_extent_dims(mem_space, region_total_size, NULL); - region_ctx.size_last_dim = region_total_size[region_ctx.ndims - 1]; /* assume entire data space to be printed */ for (jndx = 0; jndx < (size_t) region_ctx.ndims; jndx++) region_ctx.p_min_idx[jndx] = start[jndx]; @@ -1380,35 +1375,28 @@ hsize_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, for (jndx = 0; jndx < region_ctx.ndims; jndx++) region_ctx.p_max_idx[jndx] = dims1[jndx]; -// /* print array indices. get the lower bound of the hyperslab and calulate -// the element position at the start of hyperslab */ -// H5Sget_select_bounds(mem_space, region_low, region_high); -// region_ctx.sm_pos = 0; -// for (i = 0; i < (size_t) region_ctx.ndims - 1; i++) { -// hsize_t region_offset = 1; /* accumulation of the previous dimensions */ -// for (jndx = i + 1; jndx < (size_t) region_ctx.ndims; jndx++) -// region_offset *= region_total_size[jndx]; -// region_ctx.sm_pos += region_low[i] * region_offset; -// } -// region_ctx.sm_pos += region_low[region_ctx.ndims - 1]; - - region_curr_pos = blkndx*2*ndims; + region_curr_pos = 0; region_ctx.sm_pos = blkndx*2*ndims; + region_ctx.size_last_dim = dims1[ndims-1]; h5tools_region_simple_prefix(stream, info, ®ion_ctx, region_curr_pos, ptdata, 0); - for (jndx = 0; jndx < numelem; jndx++) { + region_elmtno = 0; + for (jndx = 0; jndx < numelem; jndx++, region_elmtno++) { + /* Render the element */ + h5tools_str_reset(buffer); + h5tools_str_append(buffer, "%s", - jndx ? OPTIONAL_LINE_BREAK " " : ""); + jndx ? OPTIONAL_LINE_BREAK "" : ""); h5tools_str_sprint(buffer, info, region_id, type_id, (region_buf + jndx * type_size), ®ion_ctx); if (jndx + 1 < numelem || (flags & END_OF_DATA) == 0) h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ",")); - } - region_curr_pos = h5tools_render_region_element(stream, info, ®ion_ctx, buffer, region_curr_pos, - region_flags, ncols, /*elmt_counter*/®ion_elmtno, ptdata, 0); + region_curr_pos = h5tools_render_region_element(stream, info, ®ion_ctx, buffer, region_curr_pos, + region_flags, ncols, /*elmt_counter*/®ion_elmtno, ptdata, jndx); + } region_ctx.indent_level--; } @@ -1596,9 +1584,6 @@ hsize_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, region_ctx.p_min_idx[i] = 0; H5Sget_simple_extent_dims(region_space, region_ctx.p_max_idx, NULL); -// for (i = 0, region_ctx.sm_pos = 1; region_ctx.ndims != 0 && i < region_ctx.ndims; i++) -// region_ctx.sm_pos *= region_ctx.p_max_idx[i] - region_ctx.p_min_idx[i]; - if (region_ctx.ndims > 0) { region_ctx.size_last_dim = (int) (region_ctx.p_max_idx[region_ctx.ndims - 1]); } /* end if */ @@ -1614,7 +1599,7 @@ hsize_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, if (jndx == npoints - 1) region_flags |= END_OF_DATA; - region_curr_pos = jndx*ndims; + region_curr_pos = 0; /* points requires constant 0 */ region_ctx.sm_pos = jndx*ndims; h5tools_region_simple_prefix(stream, info, ®ion_ctx, region_curr_pos, ptdata, 0); diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 8064d99..45a4ca8 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -313,9 +313,6 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, * Calculate the number of elements represented by a unit change in a * certain index position. */ - for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) - p_prod[i - 1] = (max_idx[i] - min_idx[i]) * p_prod[i]; - for (i = 0; i < (size_t) ndims; i++) { ctx->pos[i] = curr_pos / ctx->acc[i]; curr_pos -= ctx->acc[i] * ctx->pos[i]; @@ -372,22 +369,21 @@ h5tools_str_region_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *i * Calculate the number of elements represented by a unit change in a * certain index position. */ -// for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) -// p_prod[i - 1] = (max_idx[i] - min_idx[i]) * p_prod[i]; -// -// for (i = 0; i < (size_t) ndims; i++) { -// ctx->pos[i] = curr_pos / ctx->acc[i]; -// curr_pos -= ctx->acc[i] * ctx->pos[i]; -// } -// assert(curr_pos == 0); + for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) + p_prod[i - 1] = (max_idx[i]) * p_prod[i]; + + for (i = 0; i < (size_t) ndims; i++) { + ctx->pos[i] = curr_pos / p_prod[i]; + curr_pos -= p_prod[i] * ctx->pos[i]; + ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i]; + } /* Print the index values */ for (i = 0; i < (size_t) ndims; i++) { if (i) h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); -// h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]); - h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (unsigned long) ptdata[curr_pos+i]); + h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]); } } diff --git a/tools/testfiles/tdataregR.ddl b/tools/testfiles/tdataregR.ddl index 5121603..96dc39b 100644 --- a/tools/testfiles/tdataregR.ddl +++ b/tools/testfiles/tdataregR.ddl @@ -11,7 +11,9 @@ GROUP "/" { (0): REGION_TYPE BLOCK (2,2)-(7,7) (0): DATATYPE H5T_STD_U8LE (0): DATA { - (2,2): 66, 69, 72, 75, 78, 81, 96, 99, 102, 105, 108, 111, 126, 129, 132, 135, 138, 141, 156, 159, 162, 165, 168, 171, 186, 189, 192, 195, 198, 201, 216, 219, 222, 225, 228, 231 + (2,2): 66, 69, 72, 75, 78, 81, 96, 99, 102, 105, 108, 111, 126, + (4,3): 129, 132, 135, 138, 141, 156, 159, 162, 165, 168, 171, + (6,2): 186, 189, 192, 195, 198, 201, 216, 219, 222, 225, 228, 231 (0): } (0): } (1): DATASET /Dataset2 { |