summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff_array.c96
-rw-r--r--tools/lib/h5tools.c2
-rw-r--r--tools/lib/h5tools_str.c2
-rw-r--r--tools/lib/h5tools_utils.c6
4 files changed, 61 insertions, 45 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index d9616e1..f97ef50 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -472,9 +472,7 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co
size_t size = 0;
hbool_t iszero1;
hbool_t iszero2;
- hsize_t nfound = 0; /* differences found */
- double per;
- hbool_t both_zero;
+ hsize_t nfound = 0; /* differences found */
diff_err_t ret_value = opts->err_stat;
H5TOOLS_START_DEBUG("ph:%d elemtno:%d - errstat:%d", opts->print_header, elemtno, opts->err_stat);
@@ -3364,48 +3362,66 @@ print_pos(diff_opt_t *opts, hsize_t idx, size_t u)
hsize_t curr_pos = idx;
parallel_print("[ ");
- H5TOOLS_DEBUG("do calc_acc_pos[%ld] nelmts:%d - errstat:%d", i, opts->hs_nelmts, opts->err_stat);
+ H5TOOLS_DEBUG("do calc_acc_pos[%ld] nelmts:%d - errstat:%d", idx, opts->hs_nelmts,
+ opts->err_stat);
if (opts->sset[0] != NULL) {
/* Subsetting is used - calculate total position */
- hsize_t elmnt_cnt = 1;
- hsize_t dim_cnt = 0; /* previous dim size */
- hsize_t str_cnt = 0; /* previous dim stride */
- hsize_t curr_idx = idx; /* calculated running position */
- hsize_t str_idx = 0;
- hsize_t blk_idx = 0;
- hsize_t cnt_idx = 0;
- hsize_t hs_idx = 0;
- j = opts->rank - 1;
+ hsize_t prev_dim_size = 0; /* previous dim size */
+ hsize_t prev_str = 0; /* previouw stride idx*/
+ hsize_t str_cnt = 0; /* stride multiplier*/
+ hsize_t curr_idx = 0; /* calculated running position */
+ hsize_t str_idx = 0;
+ hsize_t blk_idx = 0;
+ hsize_t cnt_idx = 0;
+ hsize_t dim_size = 0; /* current dim size */
+ hsize_t elmnt_cnt = 1;
+ hsize_t next_idx = idx;
+ hsize_t data_idx = 0;
+ j = opts->rank - 1;
+ H5TOOLS_DEBUG("...begin:%ld=> opts->rank:%ld (idx:%ld)", j, opts->rank, idx);
do {
- cnt_idx = opts->sset[0]->count.data[j]; /* Count value for current dim */
- H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - count:%ld", j,
- curr_pos, curr_idx, cnt_idx);
- blk_idx = opts->sset[0]->block.data[j]; /* Block value for current dim */
- H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - block:%ld", j,
- curr_pos, curr_idx, blk_idx);
- hs_idx = cnt_idx * blk_idx; /* hyperslab area value for current dim */
- H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - hs:%ld", j, curr_pos,
- curr_idx, hs_idx);
- str_idx = opts->sset[0]->stride.data[j]; /* Stride value for current dim */
- H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - stride:%ld", j,
- curr_pos, curr_idx, str_idx);
- elmnt_cnt *= opts->dims[j]; /* Total number of elements in dimension */
- H5TOOLS_DEBUG("... sset loop:%d with elmnt_cnt:%ld", j, elmnt_cnt);
- if (str_idx > blk_idx)
- curr_idx += dim_cnt * (str_idx - blk_idx); /* */
- else if (curr_idx >= hs_idx)
- curr_idx += dim_cnt * str_cnt;
- H5TOOLS_DEBUG("... sset loop:%d with idx:%ld (curr_idx:%ld) - stride:%ld", j, idx,
- curr_idx, str_idx);
- dim_cnt = elmnt_cnt; /* */
- if (str_idx > blk_idx)
- str_cnt = str_idx - blk_idx; /* */
- else
- str_cnt = str_idx; /* */
- H5TOOLS_DEBUG("... sset loop:%d with dim_cnt:%ld - str_cnt:%ld", j, dim_cnt, str_cnt);
+ curr_idx = next_idx; /* New current data position */
+ cnt_idx = opts->sset[0]->count.data[j]; /* Count value for current dim */
+ blk_idx = opts->sset[0]->block.data[j]; /* Block value for current dim */
+ str_idx = opts->sset[0]->stride.data[j]; /* Stride value for current dim */
+ H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - c:%ld b:%ld s:%ld", j,
+ curr_pos, curr_idx, cnt_idx, blk_idx, str_idx);
+ dim_size = opts->dims[j]; /* Current dimension size */
+ // elmnt_cnt *= dim_size; /* Total number of elements in dimension */
+ H5TOOLS_DEBUG("... sset loop:%d with elmnt_cnt:%ld - (prev_dim_size:%ld - dim_size:%ld) "
+ "- str_cnt:%ld",
+ j, elmnt_cnt, prev_dim_size, dim_size, str_cnt);
+ data_idx = elmnt_cnt * dim_size;
+ H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (data_idx:%ld)", j, curr_pos, data_idx);
+ for (i = 0; i < cnt_idx; i++) {
+ H5TOOLS_DEBUG("... ... data loop:%d with cnt_idx:%ld - str_cnt:%ld (curr_idx:%ld - "
+ "data_idx:%ld)",
+ i, cnt_idx, str_cnt, curr_idx, data_idx);
+ if (curr_idx >= data_idx) {
+ /* get to next block */
+ data_idx += str_idx * dim_size;
+ /* get next block */
+ str_cnt++;
+ H5TOOLS_DEBUG(
+ "... ... data loop:%d with cnt_idx:%ld - str_cnt:%ld - data_idx:%ld", i,
+ cnt_idx, str_cnt, data_idx);
+ }
+ H5TOOLS_DEBUG("... ... end data loop:%d with dim_cnt:%ld - str_cnt:%ld - "
+ "(curr_idx:%ld - data_idx:%ld)",
+ i, dim_size, str_cnt, curr_idx, data_idx);
+ }
+ next_idx += dim_size * str_cnt; // + prev_dim_size;
+ H5TOOLS_DEBUG("... sset loop:%d with curr_idx:%ld (next_idx:%ld)", j, curr_idx, next_idx);
+ str_cnt = 0;
+ prev_str = str_idx;
+ prev_dim_size = dim_size;
+ H5TOOLS_DEBUG("... end sset loop:%d with prev_dim_size:%ld (curr_idx:%ld - data_idx:%ld) "
+ "- str_cnt:%ld",
+ j, prev_dim_size, curr_idx, data_idx, str_cnt);
+ elmnt_cnt *= dim_size; /* Total number of elements in dimension */
j--;
- } while (curr_idx >= elmnt_cnt && j >= 0);
+ } while (next_idx >= elmnt_cnt && j >= 0);
curr_pos = curr_idx; /* New current position */
H5TOOLS_DEBUG("pos loop:%d,%d with elmnt_cnt:%ld - curr_pos:%ld", i, j, elmnt_cnt, curr_pos);
} /* if (opts->sset[0] != NULL) */
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index f6566d9..3b78491 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1778,7 +1778,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
} break;
case H5T_ARRAY: {
int k, ndims;
- hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts;
+ hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts = 0;
hid_t memb = H5I_INVALID_HID;
H5TOOLS_DEBUG("H5T_ARRAY");
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index dd3ae67..212b13e 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -705,7 +705,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
long double templdouble;
HDmemcpy(&templdouble, vp, sizeof(long double));
- h5tools_str_append(str, OPT(info->fmt_double, "%Lf"), templdouble);
+ h5tools_str_append(str, "%Lg", templdouble);
#endif
}
break;
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 708fb2c..b33d908 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -196,7 +196,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
/* long command line option */
int i;
const char ch = '=';
- char * arg = &argv[opt_ind][2];
+ char * arg = HDstrdup(&argv[opt_ind][2]);
size_t arg_len = 0;
opt_arg = strchr(&argv[opt_ind][2], ch);
@@ -208,8 +208,6 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
arg[arg_len] = 0;
for (i = 0; l_opts && l_opts[i].name; i++) {
- size_t len = HDstrlen(l_opts[i].name);
-
if (HDstrcmp(arg, l_opts[i].name) == 0) {
/* we've found a matching long command line flag */
opt_opt = l_opts[i].shortval;
@@ -253,6 +251,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
opt_ind++;
sp = 1;
+
+ HDfree(arg);
}
else {
register char *cp; /* pointer into current token */