summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2005-02-08 20:55:17 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2005-02-08 20:55:17 (GMT)
commit983e9a9e267845c80995898fba2bc7e6ebb0e881 (patch)
tree9969499d2f5dda6de472656b1f439732dab95eb1 /tools/lib/h5tools.c
parent70c0ba03cec20ad3c353fcf776f4b48f2ac8da9f (diff)
downloadhdf5-983e9a9e267845c80995898fba2bc7e6ebb0e881.zip
hdf5-983e9a9e267845c80995898fba2bc7e6ebb0e881.tar.gz
hdf5-983e9a9e267845c80995898fba2bc7e6ebb0e881.tar.bz2
[svn-r9961]
Purpose: bug fix, new test file Description: h5dump was not properly displaying array indices > 3D Solution: added the same algorythm and data structure that h5diff uses to calculate the array index from a element number position Platforms tested: linux solaris Misc. update:
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r--tools/lib/h5tools.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 60377c0..3a23059 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -445,7 +445,7 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info,
/* Calculate new prefix */
h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx->p_min_idx,
- ctx->p_max_idx);
+ ctx->p_max_idx, ctx);
/* Write new prefix to output */
if (ctx->indent_level >= 0) {
@@ -746,6 +746,9 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
count = sset->count[ctx.ndims - 1];
sset->count[ctx.ndims - 1] = 1;
+ if(ctx.ndims>0)
+ init_acc_pos(&ctx,total_size);
+
for (; count > 0; sset->start[ctx.ndims - 1] += sset->stride[ctx.ndims - 1],
count--) {
/* calculate the potential number of elements we're going to print */
@@ -954,6 +957,9 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
sm_nelmts = sm_nbytes / p_type_nbytes;
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
+ if(ctx.ndims>0)
+ init_acc_pos(&ctx,total_size);
+
/* The stripmine loop */
memset(hs_offset, 0, sizeof hs_offset);
memset(zero, 0, sizeof zero);
@@ -1081,6 +1087,9 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
else
ctx.size_last_dim = 0;
+ if(ctx.ndims>0)
+ init_acc_pos(&ctx,ctx.p_max_idx);
+
/* Print it */
h5tools_dump_simple_data(stream, info, obj_id, &ctx,
START_OF_DATA | END_OF_DATA, nelmts, type, mem);
@@ -1228,3 +1237,34 @@ h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type,
indentlevel);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: init_acc_pos
+ *
+ * Purpose: initialize accumulator and matrix position
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
+{
+ int i;
+
+ assert(ctx->ndims);
+
+ ctx->acc[ctx->ndims-1]=1;
+ for(i=(ctx->ndims-2); i>=0; i--)
+ {
+ ctx->acc[i]=ctx->acc[i+1] * dims[i+1];
+ }
+ for ( i = 0; i < ctx->ndims; i++)
+ ctx->pos[i]=0;
+}
+
+