summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dumpgentest.c18
-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
-rw-r--r--tools/testfiles/taindices.h5bin16736 -> 19264 bytes
-rw-r--r--tools/testfiles/tindicesno.ddl60
-rw-r--r--tools/testfiles/tindicesyes.ddl60
9 files changed, 198 insertions, 9 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index d0df063..e438572 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -5197,10 +5197,12 @@ static void gent_aindices(void)
hsize_t dims1[1] = {100};
hsize_t dims2[2] = {2,100};
hsize_t dims3[3] = {2,2,100};
+ hsize_t dims4[4] = {2,3,4,5};
int buf1[100];
int buf2[2][100];
int buf3[2][2][100];
- int i, j, k, n, ret;
+ int buf4[2][3][4][5];
+ int i, j, k, l, n, ret;
for (i=n=0; i<100; i++){
buf1[i]=n++;
@@ -5218,7 +5220,16 @@ static void gent_aindices(void)
}
}
}
-
+ for (i=n=0; i<2; i++){
+ for (j=0; j<3; j++){
+ for (k=0; k<4; k++){
+ for (l=0; l<5; l++){
+ buf4[i][j][k][l]=n++;
+ }
+ }
+ }
+ }
+
/* create a file */
fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
assert(fid>=0);
@@ -5230,6 +5241,7 @@ static void gent_aindices(void)
write_dset(fid,1,dims1,"1d",H5T_NATIVE_INT,buf1);
write_dset(fid,2,dims2,"2d",H5T_NATIVE_INT,buf2);
write_dset(fid,3,dims3,"3d",H5T_NATIVE_INT,buf3);
+ write_dset(fid,4,dims4,"4d",H5T_NATIVE_INT,buf4);
/*-------------------------------------------------------------------------
* test with group indentation
@@ -5244,6 +5256,7 @@ static void gent_aindices(void)
write_dset(gid[5],1,dims1,"1d",H5T_NATIVE_INT,buf1);
write_dset(gid[5],2,dims2,"2d",H5T_NATIVE_INT,buf2);
write_dset(gid[5],3,dims3,"3d",H5T_NATIVE_INT,buf3);
+ write_dset(gid[5],4,dims4,"4d",H5T_NATIVE_INT,buf4);
for (i=0; i<6; i++)
H5Gclose(gid[i]);
@@ -5262,7 +5275,6 @@ static void gent_aindices(void)
*-------------------------------------------------------------------------
*/
-
int main(void)
{
gent_group();
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);
}
+
diff --git a/tools/testfiles/taindices.h5 b/tools/testfiles/taindices.h5
index e13a69c..a7cb470 100644
--- a/tools/testfiles/taindices.h5
+++ b/tools/testfiles/taindices.h5
Binary files differ
diff --git a/tools/testfiles/tindicesno.ddl b/tools/testfiles/tindicesno.ddl
index efdbe5e..a3ba33b 100644
--- a/tools/testfiles/tindicesno.ddl
+++ b/tools/testfiles/tindicesno.ddl
@@ -71,6 +71,36 @@ GROUP "/" {
398, 399
}
}
+ DATASET "4d" {
+ DATATYPE H5T_STD_I32LE
+ DATASPACE SIMPLE { ( 2, 3, 4, 5 ) / ( 2, 3, 4, 5 ) }
+ DATA {
+ 0, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49,
+ 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69,
+ 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84,
+ 85, 86, 87, 88, 89,
+ 90, 91, 92, 93, 94,
+ 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109,
+ 110, 111, 112, 113, 114,
+ 115, 116, 117, 118, 119
+ }
+ }
GROUP "g1" {
GROUP "g2" {
GROUP "g3" {
@@ -159,6 +189,36 @@ GROUP "/" {
390, 391, 392, 393, 394, 395, 396, 397, 398, 399
}
}
+ DATASET "4d" {
+ DATATYPE H5T_STD_I32LE
+ DATASPACE SIMPLE { ( 2, 3, 4, 5 ) / ( 2, 3, 4, 5 ) }
+ DATA {
+ 0, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49,
+ 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69,
+ 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84,
+ 85, 86, 87, 88, 89,
+ 90, 91, 92, 93, 94,
+ 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109,
+ 110, 111, 112, 113, 114,
+ 115, 116, 117, 118, 119
+ }
+ }
}
}
}
diff --git a/tools/testfiles/tindicesyes.ddl b/tools/testfiles/tindicesyes.ddl
index ba6624e..2db5c7d 100644
--- a/tools/testfiles/tindicesyes.ddl
+++ b/tools/testfiles/tindicesyes.ddl
@@ -78,6 +78,36 @@ GROUP "/" {
(1,1,96): 396, 397, 398, 399
}
}
+ DATASET "4d" {
+ DATATYPE H5T_STD_I32LE
+ DATASPACE SIMPLE { ( 2, 3, 4, 5 ) / ( 2, 3, 4, 5 ) }
+ DATA {
+ (0,0,0,0): 0, 1, 2, 3, 4,
+ (0,0,1,0): 5, 6, 7, 8, 9,
+ (0,0,2,0): 10, 11, 12, 13, 14,
+ (0,0,3,0): 15, 16, 17, 18, 19,
+ (0,1,0,0): 20, 21, 22, 23, 24,
+ (0,1,1,0): 25, 26, 27, 28, 29,
+ (0,1,2,0): 30, 31, 32, 33, 34,
+ (0,1,3,0): 35, 36, 37, 38, 39,
+ (0,2,0,0): 40, 41, 42, 43, 44,
+ (0,2,1,0): 45, 46, 47, 48, 49,
+ (0,2,2,0): 50, 51, 52, 53, 54,
+ (0,2,3,0): 55, 56, 57, 58, 59,
+ (1,0,0,0): 60, 61, 62, 63, 64,
+ (1,0,1,0): 65, 66, 67, 68, 69,
+ (1,0,2,0): 70, 71, 72, 73, 74,
+ (1,0,3,0): 75, 76, 77, 78, 79,
+ (1,1,0,0): 80, 81, 82, 83, 84,
+ (1,1,1,0): 85, 86, 87, 88, 89,
+ (1,1,2,0): 90, 91, 92, 93, 94,
+ (1,1,3,0): 95, 96, 97, 98, 99,
+ (1,2,0,0): 100, 101, 102, 103, 104,
+ (1,2,1,0): 105, 106, 107, 108, 109,
+ (1,2,2,0): 110, 111, 112, 113, 114,
+ (1,2,3,0): 115, 116, 117, 118, 119
+ }
+ }
GROUP "g1" {
GROUP "g2" {
GROUP "g3" {
@@ -180,6 +210,36 @@ GROUP "/" {
(1,1,98): 398, 399
}
}
+ DATASET "4d" {
+ DATATYPE H5T_STD_I32LE
+ DATASPACE SIMPLE { ( 2, 3, 4, 5 ) / ( 2, 3, 4, 5 ) }
+ DATA {
+ (0,0,0,0): 0, 1, 2, 3, 4,
+ (0,0,1,0): 5, 6, 7, 8, 9,
+ (0,0,2,0): 10, 11, 12, 13, 14,
+ (0,0,3,0): 15, 16, 17, 18, 19,
+ (0,1,0,0): 20, 21, 22, 23, 24,
+ (0,1,1,0): 25, 26, 27, 28, 29,
+ (0,1,2,0): 30, 31, 32, 33, 34,
+ (0,1,3,0): 35, 36, 37, 38, 39,
+ (0,2,0,0): 40, 41, 42, 43, 44,
+ (0,2,1,0): 45, 46, 47, 48, 49,
+ (0,2,2,0): 50, 51, 52, 53, 54,
+ (0,2,3,0): 55, 56, 57, 58, 59,
+ (1,0,0,0): 60, 61, 62, 63, 64,
+ (1,0,1,0): 65, 66, 67, 68, 69,
+ (1,0,2,0): 70, 71, 72, 73, 74,
+ (1,0,3,0): 75, 76, 77, 78, 79,
+ (1,1,0,0): 80, 81, 82, 83, 84,
+ (1,1,1,0): 85, 86, 87, 88, 89,
+ (1,1,2,0): 90, 91, 92, 93, 94,
+ (1,1,3,0): 95, 96, 97, 98, 99,
+ (1,2,0,0): 100, 101, 102, 103, 104,
+ (1,2,1,0): 105, 106, 107, 108, 109,
+ (1,2,2,0): 110, 111, 112, 113, 114,
+ (1,2,3,0): 115, 116, 117, 118, 119
+ }
+ }
}
}
}