diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-03-01 17:01:02 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-03-01 17:01:31 (GMT) |
commit | eae9f6b209c998c1f6a24adbcfb7c49f25203ebb (patch) | |
tree | 8e725335d7d789702c2b0f2a81406d35f137acd5 | |
parent | 561af682429998c170cde5c20f6caf3750fcdf42 (diff) | |
download | hdf5-eae9f6b209c998c1f6a24adbcfb7c49f25203ebb.zip hdf5-eae9f6b209c998c1f6a24adbcfb7c49f25203ebb.tar.gz hdf5-eae9f6b209c998c1f6a24adbcfb7c49f25203ebb.tar.bz2 |
Fixed region refs
-rw-r--r-- | tools/lib/h5tools_dump.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 0b01ce6..32db875 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -3927,7 +3927,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * H5TOOLS_GOTO_DONE_NO_RET(); } } - for (i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) { + for (i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) { void *memref = region_buf + i * nsize; H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos); @@ -3938,15 +3938,70 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * h5tools_str_sprint(&buffer, &outputformat, obj_id, f_type, memref, &datactx); h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - region_id = H5Rdereference2(obj_id, H5P_DEFAULT, H5R_OBJECT, memref); - if (region_id >= 0) { + if ((region_id = H5Rdereference2(obj_id, H5P_DEFAULT, H5R_OBJECT, memref)) >= 0) { datactx.indent_level++; h5tools_dump_data(stream, &outputformat, &datactx, region_id, TRUE); datactx.indent_level--; } + else { + if ((region_id = H5Rdereference2(obj_id, H5P_DEFAULT, H5R_DATASET_REGION, memref)) >= 0) { + if ((region_space = H5Rget_region(obj_id, H5R_DATASET_REGION, memref)) >= 0) { + if (h5tools_is_zero(memref, H5Tget_size(f_type))) { + H5TOOLS_DEBUG("NULL H5R_DATASET_REGION"); + + 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.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.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(region_space); + if(region_type == H5S_SEL_POINTS) { + /* Print point information */ + H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION"); + h5tools_dump_region_data_points( + region_space, region_id, stream, &outputformat, &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_REGION"); + h5tools_dump_region_data_blocks( + region_space, region_id, stream, &outputformat, &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(region_space) < 0) + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION failed"); + } /* end if (region_space >= 0) */ + else + H5TOOLS_INFO("H5Rget_region H5R_DATASET_REGION failed"); + if(H5Dclose(region_id) < 0) + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION failed"); + } /* if (region_id >= 0) */ + else { + /* if (region_id < 0) - could mean that no reference was written do not throw failure */ + H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed"); + } + } H5TOOLS_DEBUG("finished reference loop:%d",i); - } /* end for (i = 0; i < nelmts... */ + } /* end for(i = 0; i < ndims; i++, datactx->cur_elmt++, elmt_counter++) */ HDfree(region_buf); } ctx->indent_level--; |