summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-09-01 10:27:45 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-09-01 10:27:45 (GMT)
commit642f392ba3e2d30ae2a82e32f249461121d17cbc (patch)
treebbce1ae1606153f323156f207b50d88d7fba2ddf /tools/lib
parentc034336452ee48574f0dd65bf053079f9801e269 (diff)
downloadhdf5-642f392ba3e2d30ae2a82e32f249461121d17cbc.zip
hdf5-642f392ba3e2d30ae2a82e32f249461121d17cbc.tar.gz
hdf5-642f392ba3e2d30ae2a82e32f249461121d17cbc.tar.bz2
[svn-r19330] Description:
Bring r19109:19328 from trunk to revise_chunks branch. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/CMakeLists.txt59
-rw-r--r--tools/lib/h5diff.c16
-rw-r--r--tools/lib/h5diff.h1
-rw-r--r--tools/lib/h5diff_array.c8
-rw-r--r--tools/lib/h5diff_util.c70
-rw-r--r--tools/lib/h5tools.c408
-rw-r--r--tools/lib/h5tools.h13
-rw-r--r--tools/lib/h5tools_str.c23
-rw-r--r--tools/lib/h5tools_str.h13
-rw-r--r--tools/lib/h5tools_utils.c193
-rw-r--r--tools/lib/h5tools_utils.h8
-rw-r--r--tools/lib/ph5diff.h2
12 files changed, 576 insertions, 238 deletions
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index e12a7a6..05fd607 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -4,31 +4,31 @@ PROJECT (HDF5_TOOLS_LIB)
#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
-#INCLUDE_DIRECTORIES (${HDF5_TOOLS_SOURCE_DIR}/lib)
+#INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib)
#INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test)
SET (H5_TOOLS_LIB_SRCS
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5diff.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5diff_array.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5diff_attr.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5diff_dset.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5diff_util.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_filters.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_ref.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_str.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_type.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_utils.c
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5trav.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff_array.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff_attr.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff_dset.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff_util.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_filters.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_ref.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_str.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_type.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_utils.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5trav.c
)
SET (H5_TOOLS_LIB_HDRS
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5trav.h
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools.h
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_utils.h
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_str.h
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5tools_ref.h
- ${HDF5_TOOLS_SOURCE_DIR}/lib/h5diff.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5trav.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_utils.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_str.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_ref.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff.h
)
#-- Always build a static library for linking the ${HDF5_LIB_NAME} tools together
@@ -42,6 +42,12 @@ H5_SET_LIB_OPTIONS (
HDF5_TOOLS_LIB_NAME_DEBUG
)
+##############################################################################
+##############################################################################
+### I N S T A L L A T I O N ###
+##############################################################################
+##############################################################################
+
#-----------------------------------------------------------------------------
# Add file(s) to CMake Install
#-----------------------------------------------------------------------------
@@ -55,6 +61,21 @@ INSTALL (
)
#-----------------------------------------------------------------------------
+# Because tools are installed into bin/tools we need to make sure the hdf5tools
+# library will be installed into the proper location.
+#-----------------------------------------------------------------------------
+IF (APPLE)
+ OPTION (HDF5_BUILD_WITH_INSTALL_NAME "Build with library install_name set to the installation path" OFF)
+ IF (HDF5_BUILD_WITH_INSTALL_NAME)
+ SET_TARGET_PROPERTIES(${HDF5_TOOLS_LIB_TARGET} PROPERTIES
+ LINK_FLAGS "-current_version ${HDF5_PACKAGE_VERSION} -compatibility_version ${HDF5_PACKAGE_VERSION}"
+ INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib/tools"
+ BUILD_WITH_INSTALL_RPATH ${HDF5_BUILD_WITH_INSTALL_NAME}
+ )
+ ENDIF (HDF5_BUILD_WITH_INSTALL_NAME)
+ENDIF (APPLE)
+
+#-----------------------------------------------------------------------------
# Add Target(s) to CMake Install for import into other projects
#-----------------------------------------------------------------------------
IF (HDF5_EXPORTED_TARGETS)
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index c3d74b5..5d2343a 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -951,7 +951,7 @@ hsize_t diff_compare(hid_t file1_id,
if (obj1type == H5TRAV_TYPE_LINK)
{
/* get type of target object */
- l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1);
+ l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1, TRUE);
/* dangling link */
if (l_ret == 0)
{
@@ -984,7 +984,7 @@ hsize_t diff_compare(hid_t file1_id,
if (obj2type == H5TRAV_TYPE_LINK)
{
/* get type target object */
- l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2);
+ l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2, TRUE);
/* dangling link */
if (l_ret == 0)
{
@@ -1021,7 +1021,7 @@ hsize_t diff_compare(hid_t file1_id,
if (obj1type == H5TRAV_TYPE_UDLINK)
{
/* get type and name of target object */
- l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1);
+ l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1, TRUE);
/* dangling link */
if (l_ret == 0)
{
@@ -1055,7 +1055,7 @@ hsize_t diff_compare(hid_t file1_id,
if (obj2type == H5TRAV_TYPE_UDLINK)
{
/* get type and name of target object */
- l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2);
+ l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2, TRUE);
/* dangling link */
if (l_ret == 0)
{
@@ -1310,7 +1310,7 @@ hsize_t diff(hid_t file1_id,
case H5TRAV_TYPE_LINK:
{
/* get type and name of target object */
- ret = H5tools_get_link_info(file1_id, path1, &linkinfo1);
+ ret = H5tools_get_link_info(file1_id, path1, &linkinfo1, TRUE);
/* dangling link */
if (ret == 0)
{
@@ -1328,7 +1328,7 @@ hsize_t diff(hid_t file1_id,
goto out;
/* get type and name of target object */
- ret = H5tools_get_link_info(file2_id, path2, &linkinfo2);
+ ret = H5tools_get_link_info(file2_id, path2, &linkinfo2, TRUE);
/* dangling link */
if (ret == 0)
{
@@ -1394,7 +1394,7 @@ hsize_t diff(hid_t file1_id,
case H5TRAV_TYPE_UDLINK:
{
/* get type and name of target object */
- ret = H5tools_get_link_info(file1_id, path1, &linkinfo1);
+ ret = H5tools_get_link_info(file1_id, path1, &linkinfo1, TRUE);
/* dangling link */
if (ret == 0)
{
@@ -1412,7 +1412,7 @@ hsize_t diff(hid_t file1_id,
goto out;
/* get type and name of target object */
- ret = H5tools_get_link_info(file2_id, path2, &linkinfo2);
+ ret = H5tools_get_link_info(file2_id, path2, &linkinfo2, TRUE);
/* dangling link */
if (ret == 0)
{
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index ede6ea0..71993b8 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -154,7 +154,6 @@ hsize_t diff_attr(hid_t loc1_id,
*/
void print_found(hsize_t nfound);
-void parallel_print(const char* format, ... );
void print_type(hid_t type);
const char* diff_basename(const char *name);
const char* get_type(h5trav_type_t type);
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 48e08a5..dc3c9fb 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -5825,8 +5825,6 @@ void print_header(int pp, /* print percentage */
const char *obj1,
const char *obj2 )
{
- int i;
-
/* print header */
parallel_print("%-16s","size:");
print_dimensions (rank,dims);
@@ -5834,8 +5832,7 @@ void print_header(int pp, /* print percentage */
print_dimensions (rank,dims);
parallel_print("\n");
- if (pp)
- {
+ if(pp) {
parallel_print("%-15s %-15s %-15s %-15s %-15s\n",
"position",
(obj1!=NULL) ? obj1 : " ",
@@ -5844,8 +5841,7 @@ void print_header(int pp, /* print percentage */
"relative");
parallel_print("------------------------------------------------------------------------\n");
}
- else
- {
+ else {
parallel_print("%-15s %-15s %-15s %-20s\n",
"position",
(obj1!=NULL) ? obj1 : " ",
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 721c3d7..5df94fa 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -21,76 +21,6 @@
/* global variables */
int g_nTasks = 1;
-unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
-char outBuff[OUTBUFF_SIZE];
-int outBuffOffset;
-FILE* overflow_file = NULL;
-
-/*-------------------------------------------------------------------------
- * Function: parallel_print
- *
- * Purpose: wrapper for printf for use in parallel mode.
- *
- * Programmer: Leon Arber
- *
- * Date: December 1, 2004
- *
- *-------------------------------------------------------------------------
- */
-void parallel_print(const char* format, ...)
-{
- int bytes_written;
- va_list ap;
-
- va_start(ap, format);
-
- if(!g_Parallel)
- vprintf(format, ap);
- else
- {
-
- if(overflow_file == NULL) /*no overflow has occurred yet */
- {
-#if 0
- printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset);
-#endif
- bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
-#if 0
- printf("bytes_written=%ld\n", (long)bytes_written);
-#endif
- va_end(ap);
- va_start(ap, format);
-
-#if 0
- printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset);
-#endif
-
- if ((bytes_written < 0) ||
-#ifdef H5_VSNPRINTF_WORKS
- (bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
-#else
- ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
-#endif
- )
- {
- /* Terminate the outbuff at the end of the previous output */
- outBuff[outBuffOffset] = '\0';
-
- overflow_file = HDtmpfile();
- if(overflow_file == NULL)
- fprintf(stderr, "warning: could not create overflow file. Output may be truncated.\n");
- else
- bytes_written = HDvfprintf(overflow_file, format, ap);
- }
- else
- outBuffOffset += bytes_written;
- }
- else
- bytes_written = HDvfprintf(overflow_file, format, ap);
-
- }
- va_end(ap);
-}
/*-------------------------------------------------------------------------
* Function: print_dimensions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index e997d03..3cfe56b 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -197,8 +197,14 @@ BLOCK, /*blockbegin */
static const h5tools_dump_header_t * h5tools_dump_header_format;
/* local prototypes */
-static int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem);
-static int render_bin_output(FILE *stream, hid_t tid, void *_mem);
+static int do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem);
+static int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem);
+static int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
+ hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
+static hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
+ FILE *stream, hid_t container);
+static hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id,
+ FILE *stream, hid_t container);
static hbool_t h5tools_is_zero(const void *_mem, size_t size);
hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info,
@@ -216,7 +222,7 @@ hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
hsize_t local_elmt_counter/*element counter*/,
hsize_t elmt_counter);
-int h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id,
+static int h5tools_print_region_data_blocks(hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx,
h5tools_str_t *buffer/*string into which to render */, size_t ncols,
int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
@@ -660,8 +666,7 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/* Calculate new prefix */
- h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx->p_min_idx,
- ctx->p_max_idx, ctx);
+ h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx);
/* Write new prefix to output */
if (ctx->indent_level >= 0) {
@@ -750,7 +755,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/* Calculate new prefix */
- h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_min_idx,
+ h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims,
ctx->p_max_idx, ctx);
/* Write new prefix to output */
@@ -866,7 +871,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
/* binary dump */
if (bin_output) {
- do_bin_output(stream, nelmts, type, _mem);
+ do_bin_output(rawdatastream, container, nelmts, type, _mem);
} /* end if */
else {
/* setup */
@@ -947,7 +952,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
- dimension_break = h5tools_render_element(stream, info, ctx, &buffer,
+ dimension_break = h5tools_render_element(rawdatastream, info, ctx, &buffer,
&curr_pos, ncols, i, elmt_counter);
/* Render the data element end*/
@@ -1290,8 +1295,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* hssize_t nblocks is the number of blocks in the region
*-------------------------------------------------------------------------
*/
-int
-h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id,
+static int
+h5tools_print_region_data_blocks(hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx,
h5tools_str_t *buffer/*string into which to render */, size_t ncols,
int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) {
@@ -1575,8 +1580,8 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
ctx->need_prefix = TRUE;
- h5tools_print_region_data_blocks(region_space, region_id,
- stream, info, *ctx, buffer, ncols, ndims, type_id, nblocks, ptdata);
+ h5tools_print_region_data_blocks(region_id, rawdatastream, info, *ctx,
+ buffer, ncols, ndims, type_id, nblocks, ptdata);
done:
free(ptdata);
@@ -1636,12 +1641,11 @@ int
h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx,
h5tools_str_t *buffer, size_t ncols,
- int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) {
+ int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
+{
HERR_INIT(int, SUCCEED)
hbool_t dimension_break = TRUE;
- hsize_t alloc_size;
hsize_t *dims1 = NULL;
- h5tools_context_t region_ctx; /* print context */
hsize_t elmtno; /* elemnt index */
unsigned int region_flags; /* buffer extent flags */
hsize_t curr_pos;
@@ -1878,7 +1882,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
ctx->need_prefix = TRUE;
h5tools_print_region_data_points(region_space, region_id,
- stream, info, *ctx, buffer, ncols, ndims, type_id, npoints, ptdata);
+ rawdatastream, info, *ctx, buffer, ncols, ndims, type_id, npoints, ptdata);
done:
free(ptdata);
@@ -1981,7 +1985,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
if (ctx->ndims > 0)
init_acc_pos(ctx, total_size);
- size_row_block = sset->block[row_dim];
+ size_row_block = sset->block.data[row_dim];
/* display loop */
for (; hyperslab_count > 0; temp_start[row_dim] += temp_stride[row_dim], hyperslab_count--) {
@@ -1989,9 +1993,9 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
cases where block > 1 only and stride > block */
if (size_row_block > 1
&& row_counter == size_row_block
- && sset->stride[row_dim] > sset->block[row_dim]) {
+ && sset->stride.data[row_dim] > sset->block.data[row_dim]) {
- hsize_t increase_rows = sset->stride[row_dim] - sset->block[row_dim];
+ hsize_t increase_rows = sset->stride.data[row_dim] - sset->block.data[row_dim];
temp_start[row_dim] += increase_rows;
row_counter = 0;
}
@@ -2149,22 +2153,22 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
if (ctx->ndims > 2)
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
/* consider block size */
- outer_count = outer_count * sset->count[i] * sset->block[i];
+ outer_count = outer_count * sset->count.data[i] * sset->block.data[i];
}
/* initialize temporary start, count and maximum start */
for (i = 0; i < (size_t) ctx->ndims; i++) {
- temp_start[i] = sset->start[i];
- temp_count[i] = sset->count[i];
- temp_block[i] = sset->block[i];
- temp_stride[i] = sset->stride[i];
+ temp_start[i] = sset->start.data[i];
+ temp_count[i] = sset->count.data[i];
+ temp_block[i] = sset->block.data[i];
+ temp_stride[i] = sset->stride.data[i];
max_start[i] = 0;
}
if (ctx->ndims > 2) {
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
- max_start[i] = temp_start[i] + sset->count[i];
+ max_start[i] = temp_start[i] + sset->count.data[i];
temp_count[i] = 1;
}
@@ -2177,14 +2181,14 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
/* count is the number of iterations to display all the rows,
the block size count times */
- count = sset->count[row_dim] * sset->block[row_dim];
+ count = sset->count.data[row_dim] * sset->block.data[row_dim];
/* always 1 row_counter at a time, that is a block of size 1, 1 time */
temp_count[row_dim] = 1;
temp_block[row_dim] = 1;
/* advance 1 row_counter at a time */
- if (sset->block[row_dim] > 1)
+ if (sset->block.data[row_dim] > 1)
temp_stride[row_dim] = 1;
}
@@ -2203,7 +2207,7 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
/* set start to original from current_outer_dim up */
for (i = current_outer_dim + 1; i < ctx->ndims; i++) {
- temp_start[i] = sset->start[i];
+ temp_start[i] = sset->start.data[i];
}
/* increment start dimension */
@@ -2211,10 +2215,10 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
reset_dim = 0;
temp_start[current_outer_dim]++;
if (temp_start[current_outer_dim] >= max_start[current_outer_dim]) {
- temp_start[current_outer_dim] = sset->start[current_outer_dim];
+ temp_start[current_outer_dim] = sset->start.data[current_outer_dim];
/* consider block */
- if (sset->block[current_outer_dim] > 1)
+ if (sset->block.data[current_outer_dim] > 1)
temp_start[current_outer_dim]++;
current_outer_dim--;
@@ -2622,7 +2626,6 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset,
H5S_class_t space_type;
int status = FAIL;
h5tool_format_t info_dflt;
-
/* Use default values */
if (!stream)
stream = stdout;
@@ -2657,12 +2660,10 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset,
/* Print the data */
if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) {
- if (!sset) {
- status = h5tools_dump_simple_dset(rawdatastream, info, dset, p_type, indentlevel);
- }
- else {
- status = h5tools_dump_simple_subset(rawdatastream, info, dset, p_type, sset, indentlevel);
- }
+ if(!sset)
+ status = h5tools_dump_simple_dset(stream, info, dset, p_type, indentlevel);
+ else
+ status = h5tools_dump_simple_subset(stream, info, dset, p_type, sset, indentlevel);
}
else
/* space is H5S_NULL */
@@ -2711,6 +2712,7 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sis_simple failed")
H5_LEAVE(h5tools_dump_simple_mem(stream, info, obj_id, type, space, mem, indentlevel))
+
CATCH
return ret_value;
}
@@ -2731,7 +2733,7 @@ int
h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info,
h5tools_context_t *ctx, hid_t type)
{
- HERR_INIT(int, FAIL)
+ HERR_INIT(int, SUCCEED)
char *mname;
hid_t mtype, str_type;
unsigned nmembers;
@@ -3032,7 +3034,7 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info,
/* Type doesn't match any of above. */
h5tools_str_append(buffer, "unknown_one_character_type;\n ");
- done:
+ done:
if(H5Tclose(str_type) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Tclose(tmp_type) < 0)
@@ -3495,7 +3497,7 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
*-------------------------------------------------------------------------
*/
static
-int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem)
+int do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem)
{
HERR_INIT(int, SUCCEED)
unsigned char *mem = (unsigned char*)_mem;
@@ -3506,7 +3508,7 @@ int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
for (i = 0; i < nelmts; i++) {
- if (render_bin_output(stream, tid, mem + i * size) < 0) {
+ if (render_bin_output(stream, container, tid, mem + i * size) < 0) {
printf("\nError in writing binary stream\n");
return FAIL;
}
@@ -3526,7 +3528,7 @@ CATCH
*-------------------------------------------------------------------------
*/
static int
-render_bin_output(FILE *stream, hid_t tid, void *_mem)
+render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
{
HERR_INIT(int, SUCCEED)
unsigned char *mem = (unsigned char*)_mem;
@@ -3773,7 +3775,7 @@ render_bin_output(FILE *stream, hid_t tid, void *_mem)
offset = H5Tget_member_offset(tid, j);
memb = H5Tget_member_type(tid, j);
- if (render_bin_output(stream, memb, mem + offset) < 0)
+ if (render_bin_output(stream, container, memb, mem + offset) < 0)
return FAIL;
H5Tclose(memb);
@@ -3821,7 +3823,7 @@ render_bin_output(FILE *stream, hid_t tid, void *_mem)
/* dump the array element */
for (i = 0; i < nelmts; i++) {
- if (render_bin_output(stream, memb, mem + i * size) < 0)
+ if (render_bin_output(stream, container, memb, mem + i * size) < 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
}
@@ -3841,11 +3843,34 @@ render_bin_output(FILE *stream, hid_t tid, void *_mem)
for (i = 0; i < nelmts; i++) {
/* dump the array element */
- if (render_bin_output(stream, memb, ((char *) (((hvl_t *) mem)->p)) + i * size) < 0)
+ if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)) + i * size) < 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
}
H5Tclose(memb);
}
+ else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
+ if (region_output) {
+ /* region data */
+ hid_t region_id, region_space;
+ H5S_sel_type region_type;
+
+ region_id = H5Rdereference(container, H5R_DATASET_REGION, mem);
+ if (region_id >= 0) {
+ region_space = H5Rget_region(container, H5R_DATASET_REGION, mem);
+ if (region_space >= 0) {
+ region_type = H5Sget_select_type(region_space);
+ if(region_type == H5S_SEL_POINTS)
+ render_bin_output_region_points(region_space, region_id, stream, container);
+ else
+ render_bin_output_region_blocks(region_space, region_id, stream, container);
+ H5Sclose(region_space);
+ } /* end if (region_space >= 0) */
+ H5Dclose(region_id);
+ } /* end if (region_id >= 0) */
+ } /* end if (region_output... */
+ }
+ else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
+ }
else {
size_t i;
if (1 == size) {
@@ -3873,6 +3898,299 @@ CATCH
}
/*-------------------------------------------------------------------------
+ * Audience: Public
+ * Chapter: H5Tools Library
+ * Purpose: Print the data values from a dataset referenced by region blocks.
+ *
+ * Description:
+ * This is a special case subfunction to print the data in a region reference of type blocks.
+ *
+ * Return:
+ * The function returns FAIL if there was an error, otherwise SUCEED
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
+ hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata)
+{
+ HERR_INIT(int, SUCCEED)
+ hsize_t *dims1 = NULL;
+ hsize_t *start = NULL;
+ hsize_t *count = NULL;
+ size_t numelem;
+ hsize_t total_size[H5S_MAX_RANK];
+ int jndx;
+ int type_size;
+ hid_t mem_space = -1;
+ void *region_buf = NULL;
+ int blkndx;
+ hid_t sid1 = -1;
+
+ /* Get the dataspace of the dataset */
+ if((sid1 = H5Dget_space(region_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+
+ /* Allocate space for the dimension array */
+ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+
+ /* find the dimensions of each data space from the block coordinates */
+ numelem = 1;
+ for (jndx = 0; jndx < ndims; jndx++) {
+ dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1;
+ numelem = dims1[jndx] * numelem;
+ }
+
+ /* Create dataspace for reading buffer */
+ if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+
+ if((type_size = H5Tget_size(type_id)) == 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+
+ if((region_buf = HDmalloc(type_size * numelem)) == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
+
+ /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
+ /* 1 2 n 1 2 n */
+ if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
+
+ if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
+
+ for (blkndx = 0; blkndx < nblocks; blkndx++) {
+ for (jndx = 0; jndx < ndims; jndx++) {
+ start[jndx] = ptdata[jndx + blkndx * ndims * 2];
+ count[jndx] = dims1[jndx];
+ }
+
+ if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+
+ if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
+
+ if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+
+ for (jndx = 0; jndx < numelem; jndx++) {
+
+ render_bin_output(stream, container, type_id,
+ ((char*)region_buf + jndx * type_size));
+ /* Render the region data element end */
+ } /* end for (jndx = 0; jndx < numelem; jndx++) */
+ } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
+
+ done:
+ HDfree(start);
+ HDfree(count);
+ HDfree(region_buf);
+ HDfree(dims1);
+
+ if(H5Sclose(mem_space) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ if(H5Sclose(sid1) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+
+CATCH
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Audience: Public
+ * Chapter: H5Tools Library
+ * Purpose: Print some values from a dataset referenced by region blocks.
+ *
+ * Description:
+ * This is a special case subfunction to dump a region reference using blocks.
+ *
+ * Return:
+ * The function returns False if ERROR, otherwise True
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
+ FILE *stream, hid_t container)
+{
+ HERR_INIT(hbool_t, TRUE)
+ hssize_t nblocks;
+ hsize_t alloc_size;
+ hsize_t *ptdata = NULL;
+ int ndims;
+ hid_t dtype;
+ hid_t type_id;
+
+ if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
+ H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
+
+ /* Print block information */
+ if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+
+ alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
+ assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
+ if((ptdata = (hsize_t*) malloc((size_t) alloc_size)) == NULL)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+
+ H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
+ if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
+
+ if((dtype = H5Dget_type(region_id)) < 0)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
+ if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
+
+ render_bin_output_region_data_blocks(region_id, stream, container, ndims,
+ type_id, nblocks, ptdata);
+
+ done:
+ free(ptdata);
+
+ if(H5Tclose(type_id) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+
+ if(H5Tclose(dtype) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+
+ H5_LEAVE(TRUE)
+
+ CATCH
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Audience: Public
+ * Chapter: H5Tools Library
+ * Purpose: Print the data values from a dataset referenced by region points.
+ *
+ * Description:
+ * This is a special case subfunction to print the data in a region reference of type points.
+ *
+ * Return:
+ * The function returns FAIL on error, otherwise SUCCEED
+ *
+ * Parameters Description:
+ * h5tools_str_t *buffer is the string into which to render
+ * size_t ncols
+ * int ndims is the number of dimensions of the region element
+ * hssize_t npoints is the number of points in the region
+ *-------------------------------------------------------------------------
+ */
+int
+render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
+ FILE *stream, hid_t container,
+ int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
+{
+ HERR_INIT(int, SUCCEED)
+ hsize_t *dims1 = NULL;
+ int jndx;
+ int type_size;
+ hid_t mem_space = -1;
+ void *region_buf = NULL;
+
+ if((type_size = H5Tget_size(type_id)) == 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+
+ if((region_buf = HDmalloc(type_size * npoints)) == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
+
+ /* Allocate space for the dimension array */
+ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+
+ dims1[0] = npoints;
+ if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+
+ if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ for (jndx = 0; jndx < npoints; jndx++) {
+ if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+
+ render_bin_output(stream, container, type_id,
+ ((char*)region_buf + jndx * type_size));
+ } /* end for (jndx = 0; jndx < npoints; jndx++) */
+
+ done:
+ HDfree(region_buf);
+ HDfree(dims1);
+
+ if(H5Sclose(mem_space) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+CATCH
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Audience: Public
+ * Chapter: H5Tools Library
+ * Purpose: Print some values from a dataset referenced by region points.
+ *
+ * Description:
+ * This is a special case subfunction to dump a region reference using points.
+ *
+ * Return:
+ * The function returns False if the last dimension has been reached, otherwise True
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+render_bin_output_region_points(hid_t region_space, hid_t region_id,
+ FILE *stream, hid_t container)
+{
+ HERR_INIT(hbool_t, TRUE)
+ hssize_t npoints;
+ hsize_t alloc_size;
+ hsize_t *ptdata;
+ int ndims;
+ hid_t dtype;
+ hid_t type_id;
+
+ if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
+ H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
+
+ /* Allocate space for the dimension array */
+ if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+
+ alloc_size = npoints * ndims * sizeof(ptdata[0]);
+ assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
+ if((ptdata = malloc((size_t) alloc_size)) == NULL)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+
+ H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
+ if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
+
+ if((dtype = H5Dget_type(region_id)) < 0)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
+
+ if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
+
+ render_bin_output_region_data_points(region_space, region_id,
+ stream, container, ndims, type_id, npoints, ptdata);
+
+ done:
+ free(ptdata);
+
+ if(H5Tclose(type_id) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+
+ if(H5Tclose(dtype) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+
+ H5_LEAVE(ret_value)
+CATCH
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
* Function: h5tools_is_zero
*
* Purpose: Determines if memory is initialized to all zero bytes.
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index ab72025..b3e3dd2 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -507,12 +507,17 @@ typedef struct h5tools_context_t {
hsize_t sm_pos; /* current stripmine element position */
} h5tools_context_t;
+typedef struct subset_d {
+ hsize_t *data;
+ unsigned int len;
+} subset_d;
+
/* a structure to hold the subsetting particulars for a dataset */
struct subset_t {
- hsize_t *start;
- hsize_t *stride;
- hsize_t *count;
- hsize_t *block;
+ subset_d start;
+ subset_d stride;
+ subset_d count;
+ subset_d block;
};
/* The following include, h5tools_str.h, must be after the
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 55596cd..c5f10b8 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -305,8 +305,7 @@ 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 h5tool_format_t *info,
- hsize_t elmtno, unsigned ndims, hsize_t min_idx[],
- hsize_t max_idx[], h5tools_context_t *ctx)
+ hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx)
{
size_t i = 0;
hsize_t curr_pos = elmtno;
@@ -358,7 +357,7 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
*/
char *
h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[],
+ hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t max_idx[],
h5tools_context_t *ctx)
{
hsize_t p_prod[H5S_MAX_RANK];
@@ -414,7 +413,7 @@ h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
*/
void
h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region,
- const h5tool_format_t *info, h5tools_context_t *ctx)
+ const h5tool_format_t *info)
{
hssize_t nblocks;
hsize_t alloc_size;
@@ -434,7 +433,7 @@ h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region,
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- ptdata = malloc((size_t) alloc_size);
+ ptdata = (hsize_t *)malloc((size_t) alloc_size);
H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata);
@@ -475,7 +474,7 @@ h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region,
*/
void
h5tools_str_dump_region_points(h5tools_str_t *str, hid_t region,
- const h5tool_format_t *info, h5tools_context_t *ctx)
+ const h5tool_format_t *info)
{
hssize_t npoints;
hsize_t alloc_size;
@@ -495,7 +494,7 @@ h5tools_str_dump_region_points(h5tools_str_t *str, hid_t region,
alloc_size = npoints * ndims * sizeof(ptdata[0]);
assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- ptdata = malloc((size_t) alloc_size);
+ ptdata = (hsize_t *)malloc((size_t) alloc_size);
H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata);
@@ -639,7 +638,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
char *name;
unsigned char *ucp_vp = (unsigned char *)vp;
char *cp_vp = (char *)vp;
- hid_t memb, obj, region;
+ hid_t memb, obj;
unsigned nmembs;
static char fmt_llong[8], fmt_ullong[8];
H5T_str_t pad;
@@ -934,7 +933,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, "NULL");
}
else {
- h5tools_str_sprint_region(str, info, container, vp, ctx);
+ h5tools_str_sprint_region(str, info, container, vp);
}
}
else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
@@ -1112,7 +1111,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
*/
void
h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info,
- hid_t container, void *vp, h5tools_context_t *ctx)
+ hid_t container, void *vp)
{
hid_t obj, region;
char ref_name[1024];
@@ -1130,9 +1129,9 @@ h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info,
region_type = H5Sget_select_type(region);
if(region_type==H5S_SEL_POINTS)
- h5tools_str_dump_region_points(str, region, info, ctx);
+ h5tools_str_dump_region_points(str, region, info);
else
- h5tools_str_dump_region_blocks(str, region, info, ctx);
+ h5tools_str_dump_region_blocks(str, region, info);
h5tools_str_append(str, "}");
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index 98dd065..599c7d1 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -33,20 +33,17 @@ extern char *h5tools_str_reset(h5tools_str_t *str);
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 h5tool_format_t *info,
- hsize_t elmtno, unsigned ndims, hsize_t min_idx[],
- hsize_t max_idx[], h5tools_context_t *ctx);
+ hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx);
/*
* new functions needed to display region reference data
*/
extern char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t min_idx[],
+ hsize_t elmtno, hsize_t *ptdata, unsigned ndims,
hsize_t max_idx[], h5tools_context_t *ctx);
-extern void h5tools_str_dump_region_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *,
- h5tools_context_t *ctx);
-extern void h5tools_str_dump_region_points(h5tools_str_t *, hid_t, const h5tool_format_t *,
- h5tools_context_t *ctx);
+extern void h5tools_str_dump_region_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *);
+extern void h5tools_str_dump_region_points(h5tools_str_t *, hid_t, const h5tool_format_t *);
extern void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
- void *vp, h5tools_context_t *ctx);
+ void *vp);
extern char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info,
hid_t container, hid_t type, void *vp,
h5tools_context_t *ctx);
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 04d375d..a0fca8b 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -42,6 +42,12 @@ const char *opt_arg; /*flag argument (or value) */
static int h5tools_d_status = 0;
static const char *h5tools_progname = "h5tools";
+/* ``parallel_print'' variables */
+unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
+char outBuff[OUTBUFF_SIZE];
+int outBuffOffset;
+FILE* overflow_file = NULL;
+
/* local functions */
static void init_table(table_t **tbl);
#ifdef H5DUMP_DEBUG
@@ -49,6 +55,72 @@ static void dump_table(char* tablename, table_t *table);
#endif /* H5DUMP_DEBUG */
static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t recorded);
+/*-------------------------------------------------------------------------
+ * Function: parallel_print
+ *
+ * Purpose: wrapper for printf for use in parallel mode.
+ *
+ * Programmer: Leon Arber
+ *
+ * Date: December 1, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+void parallel_print(const char* format, ...)
+{
+ int bytes_written;
+ va_list ap;
+
+ va_start(ap, format);
+
+ if(!g_Parallel)
+ vprintf(format, ap);
+ else
+ {
+
+ if(overflow_file == NULL) /*no overflow has occurred yet */
+ {
+#if 0
+ printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset);
+#endif
+ bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
+#if 0
+ printf("bytes_written=%ld\n", (long)bytes_written);
+#endif
+ va_end(ap);
+ va_start(ap, format);
+
+#if 0
+ printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset);
+#endif
+
+ if ((bytes_written < 0) ||
+#ifdef H5_VSNPRINTF_WORKS
+ (bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
+#else
+ ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
+#endif
+ )
+ {
+ /* Terminate the outbuff at the end of the previous output */
+ outBuff[outBuffOffset] = '\0';
+
+ overflow_file = HDtmpfile();
+ if(overflow_file == NULL)
+ fprintf(stderr, "warning: could not create overflow file. Output may be truncated.\n");
+ else
+ bytes_written = HDvfprintf(overflow_file, format, ap);
+ }
+ else
+ outBuffOffset += bytes_written;
+ }
+ else
+ bytes_written = HDvfprintf(overflow_file, format, ap);
+
+ }
+ va_end(ap);
+}
+
/*-------------------------------------------------------------------------
* Function: error_msg
@@ -338,11 +410,11 @@ print_version(const char *progname)
static void
init_table(table_t **tbl)
{
- table_t *table = HDmalloc(sizeof(table_t));
+ table_t *table = (table_t *)HDmalloc(sizeof(table_t));
table->size = 20;
table->nobjs = 0;
- table->objs = HDmalloc(table->size * sizeof(obj_t));
+ table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t));
*tbl = table;
}
@@ -591,7 +663,7 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
/* See if we need to make table larger */
if(table->nobjs == table->size) {
table->size *= 2;
- table->objs = HDrealloc(table->objs, table->size * sizeof(table->objs[0]));
+ table->objs = (struct obj_t *)HDrealloc(table->objs, table->size * sizeof(table->objs[0]));
} /* end if */
/* Increment number of objects in table */
@@ -653,112 +725,109 @@ tmpfile(void)
*
* Date: Feb 8, 2010
*-------------------------------------------------------------------------*/
-int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info)
+int
+H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info,
+ hbool_t get_obj_type)
{
- int ret = -1; /* init to fail */
htri_t l_ret;
H5O_info_t trg_oinfo;
- hid_t fapl;
+ hid_t fapl = H5P_DEFAULT;
hid_t lapl = H5P_DEFAULT;
+ int ret = -1; /* init to fail */
/* init */
link_info->trg_type = H5O_TYPE_UNKNOWN;
/* check if link itself exist */
- if((H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0))
- {
- if(link_info->opt.msg_mode==1)
+ if(H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) {
+ if(link_info->opt.msg_mode == 1)
parallel_print("Warning: link <%s> doesn't exist \n",linkpath);
goto out;
- }
+ } /* end if */
/* get info from link */
- if(H5Lget_info(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0)
- {
- if(link_info->opt.msg_mode==1)
+ if(H5Lget_info(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) {
+ if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get link info from <%s>\n",linkpath);
goto out;
- }
+ } /* end if */
/* given path is hard link (object) */
- if (link_info->linfo.type == H5L_TYPE_HARD)
- {
+ if(link_info->linfo.type == H5L_TYPE_HARD) {
ret = 2;
goto out;
- }
+ } /* end if */
/* trg_path must be freed out of this function when finished using */
link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char));
HDassert(link_info->trg_path);
/* get link value */
- if(H5Lget_val(file_id, linkpath, link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0)
- {
- if(link_info->opt.msg_mode==1)
+ if(H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) {
+ if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get link value from <%s>\n",linkpath);
goto out;
- }
+ } /* end if */
/*-----------------------------------------------------
* if link type is external link use different lapl to
* follow object in other file
*/
- if (link_info->linfo.type == H5L_TYPE_EXTERNAL)
- {
+ if(link_info->linfo.type == H5L_TYPE_EXTERNAL) {
fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_sec2(fapl);
lapl = H5Pcreate(H5P_LINK_ACCESS);
H5Pset_elink_fapl(lapl, fapl);
- }
+ } /* end if */
- /*--------------------------------------------------------------
- * if link's target object exist, get type
- */
- /* check if target object exist */
- l_ret = H5Oexists_by_name(file_id, linkpath, lapl);
-
- /* detect dangling link */
- if(l_ret == FALSE)
- {
+ /* Check for retrieving object info */
+ if(get_obj_type) {
+ /*--------------------------------------------------------------
+ * if link's target object exist, get type
+ */
+ /* check if target object exist */
+ l_ret = H5Oexists_by_name(file_id, linkpath, lapl);
+
+ /* detect dangling link */
+ if(l_ret == FALSE) {
ret = 0;
goto out;
- }
- /* function failed */
- else if (l_ret < 0)
- {
- goto out;
- }
-
- /* get target object info */
- if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0)
- {
- if(link_info->opt.msg_mode==1)
- parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
- goto out;
- }
+ } /* end if */
+ /* function failed */
+ else if(l_ret < 0)
+ goto out;
+
+ /* get target object info */
+ if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) {
+ if(link_info->opt.msg_mode == 1)
+ parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
+ goto out;
+ } /* end if */
- /* check unknown type */
- if (trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES)
- {
- if(link_info->opt.msg_mode==1)
- parallel_print("Warning: target object of <%s> is unknown type\n", linkpath);
- goto out;
- }
+ /* check unknown type */
+ if(trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) {
+ if(link_info->opt.msg_mode == 1)
+ parallel_print("Warning: target object of <%s> is unknown type\n", linkpath);
+ goto out;
+ } /* end if */
- /* set target obj type to return */
- link_info->trg_type = trg_oinfo.type;
+ /* set target obj type to return */
+ link_info->trg_type = trg_oinfo.type;
+ } /* end if */
+ else
+ link_info->trg_type = H5O_TYPE_UNKNOWN;
/* succeed */
ret = 1;
+
out:
- if (link_info->linfo.type == H5L_TYPE_EXTERNAL)
- {
+ if(fapl != H5P_DEFAULT)
H5Pclose(fapl);
+ if(lapl != H5P_DEFAULT)
H5Pclose(lapl);
- }
return ret;
-}
+} /* end H5tools_get_link_info() */
/*-------------------------------------------------------------------------
* Audience: Public
@@ -778,12 +847,12 @@ void h5tools_setstatus(int D_status)
h5tools_d_status = D_status;
}
-const char*h5tools_getprogname()
+const char*h5tools_getprogname(void)
{
return h5tools_progname;
}
-int h5tools_getstatus()
+int h5tools_getstatus(void)
{
return h5tools_d_status;
}
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 14a7daa..08451e1 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -28,6 +28,10 @@
extern "C" {
#endif
+/* ``parallel_print'' information */
+#define PRINT_DATA_MAX_SIZE 512
+#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
+
/*
* begin get_option section
*/
@@ -110,6 +114,7 @@ H5TOOLS_DLLVAR int nCols; /*max number of columns for outputti
/* Definitions of useful routines */
H5TOOLS_DLL void indentation(int);
H5TOOLS_DLL void print_version(const char *progname);
+H5TOOLS_DLL void parallel_print(const char* format, ... );
H5TOOLS_DLL void error_msg(const char *fmt, ...);
H5TOOLS_DLL void warn_msg(const char *fmt, ...);
H5TOOLS_DLL void free_table(table_t *table);
@@ -151,7 +156,8 @@ typedef struct {
/* Definitions of routines */
-H5TOOLS_DLL int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info);
+H5TOOLS_DLL int H5tools_get_link_info(hid_t file_id, const char * linkpath,
+ h5tool_link_info_t *link_info, hbool_t get_obj_type);
H5TOOLS_DLL const char *h5tools_getprogname(void);
H5TOOLS_DLL void h5tools_setprogname(const char*progname);
H5TOOLS_DLL int h5tools_getstatus(void);
diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h
index 3ad158f..e48a643 100644
--- a/tools/lib/ph5diff.h
+++ b/tools/lib/ph5diff.h
@@ -16,8 +16,6 @@
#ifndef _PH5DIFF_H__
#define _PH5DIFF_H__
-#define PRINT_DATA_MAX_SIZE 512
-#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
/* Send from manager to workers */
#define MPI_TAG_ARGS 1
#define MPI_TAG_PRINT_TOK 2