summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5tools.c42
-rw-r--r--tools/lib/h5tools.h10
-rw-r--r--tools/lib/h5tools_str.c14
-rw-r--r--tools/lib/h5tools_str.h2
-rw-r--r--tools/lib/h5tools_utils.c1
5 files changed, 63 insertions, 6 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;
+}
+
+
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 9254359..e0db05e 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -413,10 +413,13 @@ typedef struct h5tools_context_t {
*row */
int indent_level; /*the number of times we need some
*extra indentation */
- int default_indent_level; /*this is used when the indent
- *level gets changed */
+ int default_indent_level; /*this is used when the indent level gets changed */
+ hsize_t acc[H5S_MAX_RANK]; /* accumulator position */
+ hsize_t pos[H5S_MAX_RANK]; /* matrix position */
} h5tools_context_t;
+
+
/* a structure to hold the subsetting particulars for a dataset */
struct subset_t {
hsize_t *start;
@@ -511,4 +514,7 @@ extern int h5tools_canreadf(const char* name,
hid_t dcpl_id);
extern int h5tools_can_encode(H5Z_filter_t filtn);
+void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims);
+
+
#endif /* H5TOOLS_H__ */
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 */
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index d0883fd..db7c1b3 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -33,7 +33,7 @@ extern char *h5tools_str_trunc(h5tools_str_t *str, size_t size);
extern char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt);
extern char *h5tools_str_prefix(h5tools_str_t *str, 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);
extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5dump_t *);
extern void h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch);
extern char *h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info,
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 7a92f9d..e92f972 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -665,3 +665,4 @@ add_obj(table_t *table, haddr_t objno, char *objname)
free(table->objs[i].objname);
table->objs[i].objname = HDstrdup(objname);
}
+