summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/h5tools_dump.c')
-rw-r--r--tools/lib/h5tools_dump.c531
1 files changed, 266 insertions, 265 deletions
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 2477de2..4ba89fa 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -253,9 +253,8 @@ h5tools_dump_init(void)
*-------------------------------------------------------------------------
*/
int
-h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
- h5tools_context_t *ctx, /* in,out */
- unsigned flags, hsize_t nelmts, hid_t type, void *_mem)
+h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */
+ hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem)
{
unsigned char *mem = (unsigned char*) _mem;
hsize_t i; /* element counter */
@@ -568,9 +567,11 @@ h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_for
ctx.indent_level++;
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
/* assume entire data space to be printed */
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
+
+ /* reset data space to be printed */
for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
ctx.p_min_idx[indx] = start[indx];
- init_acc_pos(&ctx, total_size);
/* print the data */
region_flags = START_OF_DATA;
@@ -939,9 +940,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
/* assume entire data space to be printed */
- for (indx = 0; indx < ctx.ndims; indx++)
- ctx.p_min_idx[indx] = 0;
- init_acc_pos(&ctx, total_size);
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
/* print the data */
region_flags = START_OF_DATA;
@@ -1253,7 +1252,6 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
size_t j; /* counters */
hsize_t zero[1] = {0}; /* vector of zeros */
unsigned int flags; /* buffer extent flags */
- hsize_t elmtno; /* elemnt index */
hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */
hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */
size_t p_type_nbytes; /* size of memory type */
@@ -1274,9 +1272,6 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
if ((size_t) ctx->ndims > NELMTS(sm_size))
H5TOOLS_THROW(FAIL, "ndims and sm_size comparision failed");
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
-
size_row_block = ctx->sset->block.data[row_dim];
/* Check if we have VL data in the dataset's datatype */
@@ -1347,27 +1342,25 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
for (i = 0; i < ctx->ndims; i++)
ctx->p_max_idx[i] = ctx->p_min_idx[i] + MIN(total_size[i], sm_size[i]);
- /* print array indices. get the lower bound of the hyperslab and calulate
- the element position at the start of hyperslab */
+ /* print array indices. get the lower bound of the hyperslab and calculate
+ the element position at the start of hyperslab */
if(H5Sget_select_bounds(f_space, low, high) < 0)
H5TOOLS_THROW(FAIL, "H5Sget_select_bounds failed");
- elmtno = 0;
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ ctx->sm_pos = 0;
for (i = 0; i < (size_t) ctx->ndims - 1; i++) {
hsize_t offset = 1; /* accumulation of the previous dimensions */
for (j = i + 1; j < (size_t) ctx->ndims; j++)
offset *= total_size[j];
- elmtno += low[i] * offset;
+ ctx->sm_pos += low[i] * offset;
}
- elmtno += low[ctx->ndims - 1];
+ ctx->sm_pos += low[ctx->ndims - 1];
- /* initialize the current stripmine position; this is necessary to print the array
- indices */
- ctx->sm_pos = elmtno;
ctx->need_prefix = TRUE;
- if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf) < 0)
+ if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, sm_nelmts, p_type, sm_buf) < 0)
H5TOOLS_THROW(FAIL, "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
@@ -1571,9 +1564,8 @@ static herr_t
h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type)
{
int sndims;
- hid_t f_space = H5I_INVALID_HID; /* file data space */
- size_t i; /* counters */
- hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
hbool_t past_catch = FALSE;
herr_t ret_value = SUCCEED;
@@ -1586,12 +1578,10 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co
ctx->ndims = (unsigned)sndims;
/* assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t) ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
-
if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_dims failed");
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
+
ctx->size_last_dim = total_size[ctx->ndims - 1];
/* Set the compound datatype field list for display */
@@ -1623,38 +1613,37 @@ CATCH
*-------------------------------------------------------------------------
*/
static int
-h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t p_type)
+h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type)
{
- hid_t f_space = H5I_INVALID_HID; /* file data space */
- hsize_t elmtno; /* counter */
- size_t i; /* counter */
- int sndims; /* rank of dataspace */
- int carry; /* counter carry value */
- hsize_t zero[8]; /* vector of zeros */
- unsigned int flags; /* buffer extent flags */
- hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
- hbool_t past_catch = FALSE;
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
+ hsize_t elmtno; /* counter */
+ size_t i = 0; /* counter */
+ int sndims; /* rank of dataspace */
+ int carry; /* counter carry value */
+ hsize_t zero[8]; /* vector of zeros */
+ unsigned int flags; /* buffer extent flags */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
+ hbool_t past_catch = FALSE;
/* Print info */
- size_t p_type_nbytes; /* size of memory type */
- hsize_t p_nelmts; /* total selected elmts */
+ size_t p_type_nbytes; /* size of memory type */
+ hsize_t p_nelmts; /* total selected elmts */
/* Stripmine info */
- hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
- hsize_t sm_nbytes; /* bytes per stripmine */
- hsize_t sm_nelmts; /* elements per stripmine*/
- unsigned char *sm_buf = NULL; /* buffer for raw data */
- hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
+ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
+ hsize_t sm_nbytes; /* bytes per stripmine */
+ hsize_t sm_nelmts; /* elements per stripmine*/
+ unsigned char *sm_buf = NULL; /* buffer for raw data */
+ hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
/* Hyperslab info */
- hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
- hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */
- hsize_t hs_nelmts; /* elements in request */
+ hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
+ hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */
+ hsize_t hs_nelmts; /* elements in request */
/* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
- int ret_value = 0;
+ unsigned int vl_data = 0; /* contains VL datatypes */
+ int ret_value = 0;
H5TOOLS_START_DEBUG("");
if (H5I_INVALID_HID == (f_space = H5Dget_space(dset)))
@@ -1670,11 +1659,8 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
H5TOOLS_GOTO_ERROR((-1), "ctx->ndims > NELMTS(sm_size) failed");
/* Assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t)ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(f_space, total_size, NULL);
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
/* calculate the number of elements we're going to print */
p_nelmts = 1;
@@ -1720,8 +1706,6 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
H5TOOLS_DEBUG("sm_nelmts size:%ld", sm_nelmts);
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims);
/* The stripmine loop */
@@ -1762,7 +1746,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
indices */
ctx->sm_pos = elmtno;
- if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0)
+ if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, hs_nelmts, p_type, sm_buf) < 0)
H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
@@ -1841,11 +1825,8 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
H5TOOLS_THROW((-1), "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
/* Assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t)ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(f_space, total_size, NULL);
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
/* calculate the number of elements we're going to print */
p_nelmts = 1;
@@ -1868,14 +1849,12 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
alloc_size = p_nelmts * H5Tget_size(p_type);
HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
if (NULL != (buf = (unsigned char *)HDmalloc((size_t)alloc_size))) {
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims);
H5TOOLS_DEBUG("Read the data");
/* Read the data */
if (H5Aread(attr_id, p_type, buf) >= 0) {
- if(h5tools_dump_simple_data(stream, info, attr_id, ctx, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0)
+ if(h5tools_dump_simple_data(stream, info, ctx, attr_id, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0)
H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
@@ -3987,6 +3966,226 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool
}
/*-------------------------------------------------------------------------
+ * Function: dump_reference
+ *
+ * Purpose: Dump reference data
+ *
+ * Return: void
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, H5R_ref_t *ref_buf, int ndims)
+{
+ hid_t new_obj_id = H5I_INVALID_HID;
+ hid_t new_obj_sid = H5I_INVALID_HID;
+ hsize_t elmt_counter = 0; /*counts the # elements printed. */
+ size_t ncols = 80; /* available output width */
+ int i;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t datactx; /* print context */
+
+ H5TOOLS_START_DEBUG("");
+
+ datactx = *ctx; /* print context */
+ /* Assume entire data space to be printed */
+ datactx.need_prefix = TRUE;
+
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+ for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) {
+ H5O_type_t obj_type = -1; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
+
+ H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos);
+
+ datactx.need_prefix = TRUE;
+ h5tools_str_reset(&buffer);
+ H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i);
+ h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx);
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims);
+
+ ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]);
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ switch (obj_type) {
+ case H5O_TYPE_DATASET:
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ //h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ break;
+
+ case H5O_TYPE_GROUP:
+ case H5O_TYPE_NAMED_DATATYPE:
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ }
+ else
+ H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed");
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ //h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ break;
+
+ case H5O_TYPE_DATASET:
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ //h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if(H5Oclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed");
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ }
+ else
+ H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed");
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
+
+ if (info->line_ncols > 0)
+ ncols = info->line_ncols;
+
+ /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
+ else {
+ if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ datactx.need_prefix = TRUE;
+ datactx.indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ datactx.indent_level--;
+ datactx.need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "}");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ }
+ else {
+ H5S_sel_type region_type;
+
+ region_type = H5Sget_select_type(new_obj_sid);
+ if(region_type == H5S_SEL_POINTS) {
+ /* Print point information */
+ H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info, &datactx,
+ &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
+ }
+ else if(region_type == H5S_SEL_HYPERSLABS) {
+ /* Print block information */
+ H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info, &datactx,
+ &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
+ }
+ else
+ H5TOOLS_INFO("invalid region type");
+ } /* end else to if (h5tools_is_zero(... */
+ if(H5Sclose(new_obj_sid) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
+ if(H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
+ }
+ break;
+ case H5R_ATTR:
+ H5TOOLS_DEBUG("ref_type is H5R_ATTR");
+ if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ if(H5Aclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
+ }
+ else {
+ H5TOOLS_DEBUG("NULL H5R_ATTR");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ datactx.need_prefix = TRUE;
+ datactx.indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ datactx.indent_level--;
+ datactx.need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "}");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
+ }
+ break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ } /* end switch */
+
+ if(H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_INFO("H5Rdestroy failed");
+
+ H5TOOLS_DEBUG("finished reference loop:%d",i);
+ } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */
+
+ h5tools_str_close(&buffer);
+
+ H5TOOLS_ENDDEBUG("");
+}
+
+/*-------------------------------------------------------------------------
* Function: dump_data
*
* Purpose: Dump attribute, obj_data is FALSE, or dataset data, obj_data is TRUE
@@ -3999,13 +4198,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
{
H5S_class_t space_type;
int ndims;
- size_t i;
hid_t space = H5I_INVALID_HID;
hid_t f_type = H5I_INVALID_HID;
- hid_t new_obj_id = H5I_INVALID_HID;
- hid_t new_obj_sid = H5I_INVALID_HID;
hsize_t total_size[H5S_MAX_RANK];
- hsize_t elmt_counter = 0; /*counts the # elements printed. */
int status = -1;
h5tools_context_t datactx; /* print context */
h5tools_str_t buffer; /* string into which to render */
@@ -4070,13 +4265,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
H5TOOLS_DEBUG("ndims=%d - datactx.ndims=%d", ndims, datactx.ndims);
/* Assume entire data space to be printed */
- if (datactx.ndims > 0)
- for (i = 0; i < (size_t)datactx.ndims; i++)
- datactx.p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(space, total_size, NULL);
- if (datactx.ndims > 0)
- init_acc_pos(&datactx, total_size);
+ init_acc_pos(datactx.ndims, total_size, datactx.acc, datactx.pos, datactx.p_min_idx);
+
datactx.need_prefix = TRUE;
if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
@@ -4094,197 +4285,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
H5TOOLS_GOTO_DONE_NO_RET();
}
}
- for (i = 0; i < (size_t)ndims; i++, datactx.cur_elmt++, elmt_counter++) {
- H5O_type_t obj_type = -1; /* Object type */
- H5R_type_t ref_type; /* Reference type */
-
- H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos);
-
- datactx.need_prefix = TRUE;
- h5tools_str_reset(&buffer);
- H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i);
- h5tools_str_sprint(&buffer, &outputformat, obj_id, H5T_STD_REF, &ref_buf[i], &datactx);
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims);
-
- ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]);
- switch (ref_type) {
- case H5R_OBJECT1:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
- if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
- switch (obj_type) {
- case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- datactx.indent_level++;
- h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
- datactx.indent_level--;
- if(H5Dclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed");
- break;
-
- case H5O_TYPE_GROUP:
- case H5O_TYPE_NAMED_DATATYPE:
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- break;
- } /* end switch */
- }
- else
- H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed");
- break;
- case H5R_DATASET_REGION1:
- H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
- if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- datactx.indent_level++;
- h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
- datactx.indent_level--;
- if(H5Dclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
- break;
- case H5R_OBJECT2:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
- if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
- switch (obj_type) {
- case H5O_TYPE_GROUP:
- break;
-
- case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- datactx.indent_level++;
- h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
- datactx.indent_level--;
- if(H5Oclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed");
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- break;
-
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- break;
- } /* end switch */
- }
- else
- H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed");
- break;
- case H5R_DATASET_REGION2:
- H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
-
- if (outputformat.line_ncols > 0)
- ncols = outputformat.line_ncols;
-
- /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
- if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
- H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
- else {
- if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
- H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " {");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- datactx.indent_level++;
- datactx.need_prefix = TRUE;
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NULL");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- datactx.indent_level--;
- datactx.need_prefix = TRUE;
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "}");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- }
- else {
- H5S_sel_type region_type;
-
- region_type = H5Sget_select_type(new_obj_sid);
- if(region_type == H5S_SEL_POINTS) {
- /* Print point information */
- H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2");
- h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, &outputformat, &datactx,
- &buffer, &curr_pos, ncols, i, elmt_counter);
- }
- else if(region_type == H5S_SEL_HYPERSLABS) {
- /* Print block information */
- H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2");
- h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, &outputformat, &datactx,
- &buffer, &curr_pos, ncols, i, elmt_counter);
- }
- else
- H5TOOLS_INFO("invalid region type");
- } /* end else to if (h5tools_is_zero(... */
- if(H5Sclose(new_obj_sid) < 0)
- H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
- if(H5Dclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
- }
- break;
- case H5R_ATTR:
- H5TOOLS_DEBUG("ref_type is H5R_ATTR");
- if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- h5tools_dump_region_attribute(new_obj_id, stream, &outputformat, &datactx,
- &buffer, &curr_pos, ncols, i, elmt_counter);
- if(H5Aclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
- }
- else {
- H5TOOLS_DEBUG("NULL H5R_ATTR");
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " {");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- datactx.indent_level++;
- datactx.need_prefix = TRUE;
-
- datactx.indent_level++;
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NULL");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- datactx.indent_level--;
-
- datactx.indent_level--;
- datactx.need_prefix = TRUE;
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "}");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
- }
- break;
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- default:
- break;
- } /* end switch */
-
- if(H5Rdestroy(&ref_buf[i]) < 0)
- H5TOOLS_INFO("H5Rdestroy failed");
-
- H5TOOLS_DEBUG("finished reference loop:%d",i);
- } /* end for(i = 0; i < ndims; i++, datactx->cur_elmt++, elmt_counter++) */
+ h5tools_dump_reference(stream, &outputformat, &datactx, obj_id, ref_buf, ndims);
HDfree(ref_buf);
}
ctx->indent_level--;