summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_str.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_str.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_str.c')
-rw-r--r--tools/lib/h5tools_str.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index f5a1690..32fea3d 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -310,10 +310,12 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
char *
h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5dump_t *info,
hsize_t elmtno, int ndims, hsize_t min_idx[],
- hsize_t max_idx[])
+ hsize_t max_idx[], h5tools_context_t *ctx)
{
hsize_t p_prod[H5S_MAX_RANK], p_idx[H5S_MAX_RANK];
hsize_t n, i = 0;
+ hsize_t curr_pos=elmtno;
+
h5tools_str_reset(str);
@@ -330,6 +332,14 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5dump_t *info,
p_idx[i] = n / p_prod[i] + min_idx[i];
n %= p_prod[i];
}
+
+
+ for ( i = 0; i < (hsize_t)ndims; i++)
+ {
+ ctx->pos[i] = curr_pos/ctx->acc[i];
+ curr_pos -= ctx->acc[i]*ctx->pos[i];
+ }
+ assert( curr_pos == 0 );
/* Print the index values */
for (i = 0; i < (hsize_t)ndims; i++) {
@@ -337,7 +347,7 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5dump_t *info,
h5tools_str_append(str, "%s", OPT(info->idx_sep, ","));
h5tools_str_append(str, OPT(info->idx_n_fmt, "%lu"),
- (unsigned long)p_idx[i]);
+ (unsigned long)ctx->pos[i]);
}
} else {
/* Scalar */