summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-10-06 19:36:07 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-10-06 19:36:07 (GMT)
commita07d6b52fb0a231c2c6e60b1ae4d7550894c4b58 (patch)
treeb3242181fab7dcbd4463252edbaea409e8796b5c
parent0cef4c9151010e0e2498e81aa7a9186d3280c399 (diff)
downloadhdf5-a07d6b52fb0a231c2c6e60b1ae4d7550894c4b58.zip
hdf5-a07d6b52fb0a231c2c6e60b1ae4d7550894c4b58.tar.gz
hdf5-a07d6b52fb0a231c2c6e60b1ae4d7550894c4b58.tar.bz2
HDFFV-10297 - fix repack individual objects
includes H5Zfilter_avail() fix
-rw-r--r--src/H5Pocpl.c440
-rw-r--r--src/H5Z.c15
-rw-r--r--tools/src/h5repack/h5repack.c130
-rw-r--r--tools/src/h5repack/h5repack.h106
-rw-r--r--tools/src/h5repack/h5repack_copy.c180
-rw-r--r--tools/src/h5repack/h5repack_filters.c284
-rw-r--r--tools/src/h5repack/h5repack_main.c10
-rw-r--r--tools/src/h5repack/h5repack_opttable.c3
-rw-r--r--tools/src/h5repack/h5repack_parse.c13
-rw-r--r--tools/src/h5repack/h5repack_verify.c113
-rw-r--r--tools/test/h5repack/testfiles/h5repack_filters.h5-gzip_verbose_filters.tst4
11 files changed, 621 insertions, 677 deletions
diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c
index 0393f7f..be41e32 100644
--- a/src/H5Pocpl.c
+++ b/src/H5Pocpl.c
@@ -13,11 +13,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5Pocpl.c
- * Nov 28 2006
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5Pocpl.c
+ * Nov 28 2006
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Object creation property list class routines
+ * Purpose: Object creation property list class routines
*
*-------------------------------------------------------------------------
*/
@@ -26,21 +26,21 @@
/* Module Setup */
/****************/
-#define H5O_FRIEND /*suppress error about including H5Opkg */
+#define H5O_FRIEND /*suppress error about including H5Opkg */
#include "H5Pmodule.h" /* This source code file is part of the H5P module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Opkg.h" /* Object headers */
-#include "H5Ppkg.h" /* Property lists */
-#include "H5PLprivate.h" /* Dynamic plugin */
-#include "H5Zprivate.h" /* Filter pipeline */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Opkg.h" /* Object headers */
+#include "H5Ppkg.h" /* Property lists */
+#include "H5PLprivate.h" /* Dynamic plugin */
+#include "H5Zprivate.h" /* Filter pipeline */
/****************/
@@ -100,7 +100,7 @@ static int H5P__ocrt_pipeline_cmp(const void *value1, const void *value2, size_t
static herr_t H5P__ocrt_pipeline_close(const char *name, size_t size, void *value);
/* Local routines */
-static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter,
+static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter,
unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]);
/*********************/
@@ -109,21 +109,21 @@ static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter,
/* Object creation property list class library initialization object */
const H5P_libclass_t H5P_CLS_OCRT[1] = {{
- "object create", /* Class name for debugging */
- H5P_TYPE_OBJECT_CREATE, /* Class type */
-
- &H5P_CLS_ROOT_g, /* Parent class */
- &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class */
- &H5P_CLS_OBJECT_CREATE_ID_g, /* Pointer to class ID */
- NULL, /* Pointer to default property list ID */
- H5P__ocrt_reg_prop, /* Default property registration routine */
-
- NULL, /* Class creation callback */
- NULL, /* Class creation callback info */
- NULL, /* Class copy callback */
- NULL, /* Class copy callback info */
- NULL, /* Class close callback */
- NULL /* Class close callback info */
+ "object create", /* Class name for debugging */
+ H5P_TYPE_OBJECT_CREATE, /* Class type */
+
+ &H5P_CLS_ROOT_g, /* Parent class */
+ &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class */
+ &H5P_CLS_OBJECT_CREATE_ID_g, /* Pointer to class ID */
+ NULL, /* Pointer to default property list ID */
+ H5P__ocrt_reg_prop, /* Default property registration routine */
+
+ NULL, /* Class creation callback */
+ NULL, /* Class creation callback info */
+ NULL, /* Class copy callback */
+ NULL, /* Class copy callback info */
+ NULL, /* Class close callback */
+ NULL /* Class close callback info */
}};
@@ -165,25 +165,25 @@ H5P__ocrt_reg_prop(H5P_genclass_t *pclass)
FUNC_ENTER_STATIC
/* Register max. compact attribute storage property */
- if(H5P_register_real(pclass, H5O_CRT_ATTR_MAX_COMPACT_NAME, H5O_CRT_ATTR_MAX_COMPACT_SIZE, &H5O_def_attr_max_compact_g,
+ if(H5P_register_real(pclass, H5O_CRT_ATTR_MAX_COMPACT_NAME, H5O_CRT_ATTR_MAX_COMPACT_SIZE, &H5O_def_attr_max_compact_g,
NULL, NULL, NULL, H5O_CRT_ATTR_MAX_COMPACT_ENC, H5O_CRT_ATTR_MAX_COMPACT_DEC,
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register min. dense attribute storage property */
- if(H5P_register_real(pclass, H5O_CRT_ATTR_MIN_DENSE_NAME, H5O_CRT_ATTR_MIN_DENSE_SIZE, &H5O_def_attr_min_dense_g,
+ if(H5P_register_real(pclass, H5O_CRT_ATTR_MIN_DENSE_NAME, H5O_CRT_ATTR_MIN_DENSE_SIZE, &H5O_def_attr_min_dense_g,
NULL, NULL, NULL, H5O_CRT_ATTR_MIN_DENSE_ENC, H5O_CRT_ATTR_MIN_DENSE_DEC,
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register object header flags property */
- if(H5P_register_real(pclass, H5O_CRT_OHDR_FLAGS_NAME, H5O_CRT_OHDR_FLAGS_SIZE, &H5O_def_ohdr_flags_g,
+ if(H5P_register_real(pclass, H5O_CRT_OHDR_FLAGS_NAME, H5O_CRT_OHDR_FLAGS_SIZE, &H5O_def_ohdr_flags_g,
NULL, NULL, NULL, H5O_CRT_OHDR_FLAGS_ENC, H5O_CRT_OHDR_FLAGS_DEC,
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the pipeline property */
- if(H5P_register_real(pclass, H5O_CRT_PIPELINE_NAME, H5O_CRT_PIPELINE_SIZE, &H5O_def_pline_g,
+ if(H5P_register_real(pclass, H5O_CRT_PIPELINE_NAME, H5O_CRT_PIPELINE_SIZE, &H5O_def_pline_g,
NULL, H5O_CRT_PIPELINE_SET, H5O_CRT_PIPELINE_GET, H5O_CRT_PIPELINE_ENC, H5O_CRT_PIPELINE_DEC,
H5O_CRT_PIPELINE_DEL, H5O_CRT_PIPELINE_COPY, H5O_CRT_PIPELINE_CMP, H5O_CRT_PIPELINE_CLOSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
@@ -194,9 +194,9 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pset_attr_phase_change
+ * Function: H5Pset_attr_phase_change
*
- * Purpose: Sets the cutoff values for indexes storing attributes
+ * Purpose: Sets the cutoff values for indexes storing attributes
* in object headers for this file. If more than max_compact
* attributes are in an object header, the attributes will be
* moved to a heap and indexed with a B-tree.
@@ -208,10 +208,10 @@ done:
* never be stored in the object header but will be always be
* stored in a heap.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * Tuesday, November 28, 2006
+ * Programmer: Quincey Koziol
+ * Tuesday, November 28, 2006
*
*-------------------------------------------------------------------------
*/
@@ -248,14 +248,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_attr_phase_change
+ * Function: H5Pget_attr_phase_change
*
- * Purpose: Gets the phase change values for attribute storage
+ * Purpose: Gets the phase change values for attribute storage
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * Tuesday, November 28, 2006
+ * Programmer: Quincey Koziol
+ * Tuesday, November 28, 2006
*
*-------------------------------------------------------------------------
*/
@@ -486,37 +486,37 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5P_modify_filter
- *
- * Purpose: Modifies the specified FILTER in the
- * transient or permanent output filter pipeline
- * depending on whether PLIST is a dataset creation or dataset
- * transfer property list. The FLAGS argument specifies certain
- * general properties of the filter and is documented below.
- * The CD_VALUES is an array of CD_NELMTS integers which are
- * auxiliary data for the filter. The integer vlues will be
- * stored in the dataset object header as part of the filter
- * information.
- *
- * The FLAGS argument is a bit vector of the following fields:
- *
- * H5Z_FLAG_OPTIONAL(0x0001)
- * If this bit is set then the filter is optional. If the
- * filter fails during an H5Dwrite() operation then the filter
- * is just excluded from the pipeline for the chunk for which it
- * failed; the filter will not participate in the pipeline
- * during an H5Dread() of the chunk. If this bit is clear and
- * the filter fails then the entire I/O operation fails.
+ * Function: H5P_modify_filter
+ *
+ * Purpose: Modifies the specified FILTER in the
+ * transient or permanent output filter pipeline
+ * depending on whether PLIST is a dataset creation or dataset
+ * transfer property list. The FLAGS argument specifies certain
+ * general properties of the filter and is documented below.
+ * The CD_VALUES is an array of CD_NELMTS integers which are
+ * auxiliary data for the filter. The integer vlues will be
+ * stored in the dataset object header as part of the filter
+ * information.
+ *
+ * The FLAGS argument is a bit vector of the following fields:
+ *
+ * H5Z_FLAG_OPTIONAL(0x0001)
+ * If this bit is set then the filter is optional. If the
+ * filter fails during an H5Dwrite() operation then the filter
+ * is just excluded from the pipeline for the chunk for which it
+ * failed; the filter will not participate in the pipeline
+ * during an H5Dread() of the chunk. If this bit is clear and
+ * the filter fails then the entire I/O operation fails.
* If this bit is set but encoding is disabled for a filter,
* attempting to write will generate an error.
*
- * Note: This function currently supports only the permanent filter
- * pipeline. That is, PLIST_ID must be a dataset creation
- * property list.
+ * Note: This function currently supports only the permanent filter
+ * pipeline. That is, PLIST_ID must be a dataset creation
+ * property list.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, October 17, 2007
*
*-------------------------------------------------------------------------
@@ -623,33 +623,33 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pset_filter
- *
- * Purpose: Adds the specified FILTER and corresponding properties to the
- * end of the data or link output filter pipeline
- * depending on whether PLIST is a dataset creation or group
- * creation property list. The FLAGS argument specifies certain
- * general properties of the filter and is documented below.
- * The CD_VALUES is an array of CD_NELMTS integers which are
- * auxiliary data for the filter. The integer vlues will be
- * stored in the dataset object header as part of the filter
- * information.
- *
- * The FLAGS argument is a bit vector of the following fields:
- *
- * H5Z_FLAG_OPTIONAL(0x0001)
- * If this bit is set then the filter is optional. If the
- * filter fails during an H5Dwrite() operation then the filter
- * is just excluded from the pipeline for the chunk for which it
- * failed; the filter will not participate in the pipeline
- * during an H5Dread() of the chunk. If this bit is clear and
- * the filter fails then the entire I/O operation fails.
+ * Function: H5Pset_filter
+ *
+ * Purpose: Adds the specified FILTER and corresponding properties to the
+ * end of the data or link output filter pipeline
+ * depending on whether PLIST is a dataset creation or group
+ * creation property list. The FLAGS argument specifies certain
+ * general properties of the filter and is documented below.
+ * The CD_VALUES is an array of CD_NELMTS integers which are
+ * auxiliary data for the filter. The integer vlues will be
+ * stored in the dataset object header as part of the filter
+ * information.
+ *
+ * The FLAGS argument is a bit vector of the following fields:
+ *
+ * H5Z_FLAG_OPTIONAL(0x0001)
+ * If this bit is set then the filter is optional. If the
+ * filter fails during an H5Dwrite() operation then the filter
+ * is just excluded from the pipeline for the chunk for which it
+ * failed; the filter will not participate in the pipeline
+ * during an H5Dread() of the chunk. If this bit is clear and
+ * the filter fails then the entire I/O operation fails.
* If this bit is set but encoding is disabled for a filter,
* attempting to write will generate an error.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
* Modifications:
@@ -668,7 +668,7 @@ done:
*/
herr_t
H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
- size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
+ size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
H5P_genplist_t *plist; /* Property list */
herr_t ret_value=SUCCEED; /* return value */
@@ -698,43 +698,43 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5P__set_filter
- *
- * Purpose: Adds the specified FILTER and corresponding properties to the
- * end of the data or link output filter pipeline
- * depending on whether PLIST is a dataset creation or group
- * creation property list. The FLAGS argument specifies certain
- * general properties of the filter and is documented below.
- * The CD_VALUES is an array of CD_NELMTS integers which are
- * auxiliary data for the filter. The integer vlues will be
- * stored in the dataset object header as part of the filter
- * information.
- *
- * The FLAGS argument is a bit vector of the following fields:
- *
- * H5Z_FLAG_OPTIONAL(0x0001)
- * If this bit is set then the filter is optional. If the
- * filter fails during an H5Dwrite() operation then the filter
- * is just excluded from the pipeline for the chunk for which it
- * failed; the filter will not participate in the pipeline
- * during an H5Dread() of the chunk. If this bit is clear and
- * the filter fails then the entire I/O operation fails.
- * If this bit is set but encoding is disabled for a filter,
- * attempting to write will generate an error.
- *
- * If the filter is not registered, this function tries to load
+ * Function: H5P__set_filter
+ *
+ * Purpose: Adds the specified FILTER and corresponding properties to the
+ * end of the data or link output filter pipeline
+ * depending on whether PLIST is a dataset creation or group
+ * creation property list. The FLAGS argument specifies certain
+ * general properties of the filter and is documented below.
+ * The CD_VALUES is an array of CD_NELMTS integers which are
+ * auxiliary data for the filter. The integer vlues will be
+ * stored in the dataset object header as part of the filter
+ * information.
+ *
+ * The FLAGS argument is a bit vector of the following fields:
+ *
+ * H5Z_FLAG_OPTIONAL(0x0001)
+ * If this bit is set then the filter is optional. If the
+ * filter fails during an H5Dwrite() operation then the filter
+ * is just excluded from the pipeline for the chunk for which it
+ * failed; the filter will not participate in the pipeline
+ * during an H5Dread() of the chunk. If this bit is clear and
+ * the filter fails then the entire I/O operation fails.
+ * If this bit is set but encoding is disabled for a filter,
+ * attempting to write will generate an error.
+ *
+ * If the filter is not registered, this function tries to load
* it dynamically during run time.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags,
- size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
+ size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
H5O_pline_t pline; /* Filter pipeline */
htri_t filter_avail; /* Filter availability */
@@ -746,16 +746,6 @@ H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags,
if((filter_avail = H5Z_filter_avail(filter)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't check filter availability")
- /* If filter is not available, try to dynamically load it */
- if(!filter_avail) {
- const H5Z_class2_t *filter_info;
-
- if(NULL == (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter)))
- HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, FAIL, "failed to load dynamically loaded plugin")
- if(H5Z_register(filter_info) < 0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
- } /* end if */
-
/* Get the pipeline property to append to */
if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline")
@@ -774,21 +764,21 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_nfilters
+ * Function: H5Pget_nfilters
*
- * Purpose: Returns the number of filters in the data or link
- * pipeline depending on whether PLIST_ID is a dataset creation
- * or group creation property list. In each pipeline the
- * filters are numbered from zero through N-1 where N is the
- * value returned by this function. During output to the file
- * the filters of a pipeline are applied in increasing order
- * (the inverse is true for input).
+ * Purpose: Returns the number of filters in the data or link
+ * pipeline depending on whether PLIST_ID is a dataset creation
+ * or group creation property list. In each pipeline the
+ * filters are numbered from zero through N-1 where N is the
+ * value returned by this function. During output to the file
+ * the filters of a pipeline are applied in increasing order
+ * (the inverse is true for input).
*
- * Return: Success: Number of filters or zero if there are none.
+ * Return: Success: Number of filters or zero if there are none.
*
- * Failure: Negative
+ * Failure: Negative
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, August 4, 1998
*
* Modifications:
@@ -827,25 +817,25 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_filter2
- *
- * Purpose: This is the query counterpart of H5Pset_filter() and returns
- * information about a particular filter number in a permanent
- * or transient pipeline depending on whether PLIST_ID is a
- * dataset creation or transfer property list. On input,
- * CD_NELMTS indicates the number of entries in the CD_VALUES
- * array allocated by the caller while on exit it contains the
- * number of values defined by the filter. FILTER_CONFIG is a bit
+ * Function: H5Pget_filter2
+ *
+ * Purpose: This is the query counterpart of H5Pset_filter() and returns
+ * information about a particular filter number in a permanent
+ * or transient pipeline depending on whether PLIST_ID is a
+ * dataset creation or transfer property list. On input,
+ * CD_NELMTS indicates the number of entries in the CD_VALUES
+ * array allocated by the caller while on exit it contains the
+ * number of values defined by the filter. FILTER_CONFIG is a bit
* field contaning encode/decode flags from H5Zpublic.h. The IDX
* should be a value between zero and N-1 as described for
* H5Pget_nfilters() and the function will return failure if the
* filter number is out of range.
*
- * Return: Success: Filter identification number.
+ * Return: Success: Filter identification number.
*
- * Failure: H5Z_FILTER_ERROR (Negative)
+ * Failure: H5Z_FILTER_ERROR (Negative)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
* Modifications:
@@ -859,8 +849,8 @@ done:
*/
H5Z_filter_t
H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/,
- size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
- size_t namelen, char name[]/*out*/,
+ size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
+ size_t namelen, char name[]/*out*/,
unsigned *filter_config /*out*/)
{
H5P_genplist_t *plist; /* Property list */
@@ -921,23 +911,23 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5P_get_filter_by_id
+ * Function: H5P_get_filter_by_id
*
- * Purpose: This is an additional query counterpart of H5Pset_filter() and
+ * Purpose: This is an additional query counterpart of H5Pset_filter() and
* returns information about a particular filter in a permanent
- * or transient pipeline depending on whether PLIST_ID is a
- * dataset creation or transfer property list. On input,
- * CD_NELMTS indicates the number of entries in the CD_VALUES
- * array allocated by the caller while on exit it contains the
- * number of values defined by the filter. FILTER_CONFIG is a bit
+ * or transient pipeline depending on whether PLIST_ID is a
+ * dataset creation or transfer property list. On input,
+ * CD_NELMTS indicates the number of entries in the CD_VALUES
+ * array allocated by the caller while on exit it contains the
+ * number of values defined by the filter. FILTER_CONFIG is a bit
* field contaning encode/decode flags from H5Zpublic.h. The ID
* should be the filter ID to retrieve the parameters for. If the
* filter is not set for the property list, an error will be returned.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Wednesday, October 17, 2007
*
*-------------------------------------------------------------------------
@@ -971,23 +961,23 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_filter_by_id2
+ * Function: H5Pget_filter_by_id2
*
- * Purpose: This is an additional query counterpart of H5Pset_filter() and
+ * Purpose: This is an additional query counterpart of H5Pset_filter() and
* returns information about a particular filter in a permanent
- * or transient pipeline depending on whether PLIST_ID is a
- * dataset creation or transfer property list. On input,
- * CD_NELMTS indicates the number of entries in the CD_VALUES
- * array allocated by the caller while on exit it contains the
- * number of values defined by the filter. FILTER_CONFIG is a bit
+ * or transient pipeline depending on whether PLIST_ID is a
+ * dataset creation or transfer property list. On input,
+ * CD_NELMTS indicates the number of entries in the CD_VALUES
+ * array allocated by the caller while on exit it contains the
+ * number of values defined by the filter. FILTER_CONFIG is a bit
* field contaning encode/decode flags from H5Zpublic.h. The ID
* should be the filter ID to retrieve the parameters for. If the
* filter is not set for the property list, an error will be returned.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Friday, April 5, 2003
*
* Modifications:
@@ -1047,16 +1037,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pall_filters_avail
+ * Function: H5Pall_filters_avail
*
- * Purpose: This is a query routine to verify that all the filters set
+ * Purpose: This is a query routine to verify that all the filters set
* in the dataset creation property list are available currently.
*
- * Return: Success: TRUE if all filters available, FALSE if one or
+ * Return: Success: TRUE if all filters available, FALSE if one or
* more filters not currently available.
- * Failure: FAIL on error
+ * Failure: FAIL on error
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, April 8, 2003
*
* Modifications:
@@ -1096,16 +1086,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5P_filter_in_pline
+ * Function: H5P_filter_in_pline
*
- * Purpose: Check whether the filter is in the pipeline of the object
- * creation property list.
+ * Purpose: Check whether the filter is in the pipeline of the object
+ * creation property list.
*
- * Return: TRUE: found
- * FALSE: not found
- * FAIL: error
+ * Return: TRUE: found
+ * FALSE: not found
+ * FAIL: error
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 26 April 2013
*
*-------------------------------------------------------------------------
@@ -1198,7 +1188,7 @@ done:
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
* Modifications:
@@ -1258,7 +1248,7 @@ done:
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Dec 19, 2002
*
* Modifications:
@@ -1302,13 +1292,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5P_get_filter
+ * Function: H5P_get_filter
*
- * Purpose: Internal component of H5Pget_filter & H5Pget_filter_id
+ * Purpose: Internal component of H5Pget_filter & H5Pget_filter_id
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, October 23, 2006
*
*-------------------------------------------------------------------------
@@ -1330,7 +1320,7 @@ H5P_get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/,
/* Filter parameters */
if(cd_values) {
- size_t i; /* Local index variable */
+ size_t i; /* Local index variable */
for(i = 0; i < filter->cd_nelmts && i < *cd_nelmts; i++)
cd_values[i] = filter->cd_values[i];
@@ -1460,8 +1450,8 @@ done:
* property in the dataset access property list is
* decoded.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
* Programmer: Mohamad Chaarawi
* Monday, October 10, 2011
@@ -1553,15 +1543,15 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size)
* property in the dataset access property list is
* decoded.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
* Programmer: Mohamad Chaarawi
* Monday, October 10, 2011
*
*-------------------------------------------------------------------------
*/
-static herr_t
+static herr_t
H5P__ocrt_pipeline_dec(const void **_pp, void *_value)
{
H5O_pline_t *pline = (H5O_pline_t *)_value; /* Property to set */
@@ -1637,7 +1627,7 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value)
filter.cd_values = (unsigned *)H5MM_xfree(filter.cd_values);
} /* end for */
-done:
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5P__ocrt_pipeline_dec() */
@@ -1830,32 +1820,32 @@ done:
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
- * Function: H5Pget_filter1
- *
- * Purpose: This is the query counterpart of H5Pset_filter() and returns
- * information about a particular filter number in a permanent
- * or transient pipeline depending on whether PLIST_ID is a
- * dataset creation or transfer property list. On input,
- * CD_NELMTS indicates the number of entries in the CD_VALUES
- * array allocated by the caller while on exit it contains the
- * number of values defined by the filter. The IDX
+ * Function: H5Pget_filter1
+ *
+ * Purpose: This is the query counterpart of H5Pset_filter() and returns
+ * information about a particular filter number in a permanent
+ * or transient pipeline depending on whether PLIST_ID is a
+ * dataset creation or transfer property list. On input,
+ * CD_NELMTS indicates the number of entries in the CD_VALUES
+ * array allocated by the caller while on exit it contains the
+ * number of values defined by the filter. The IDX
* should be a value between zero and N-1 as described for
* H5Pget_nfilters() and the function will return failure if the
* filter number is out of range.
*
- * Return: Success: Filter identification number.
+ * Return: Success: Filter identification number.
*
- * Failure: H5Z_FILTER_ERROR (Negative)
+ * Failure: H5Z_FILTER_ERROR (Negative)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
*-------------------------------------------------------------------------
*/
H5Z_filter_t
H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/,
- size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
- size_t namelen, char name[]/*out*/)
+ size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
+ size_t namelen, char name[]/*out*/)
{
H5O_pline_t pline; /* Filter pipeline */
const H5Z_filter_info_t *filter; /* Pointer to filter information */
@@ -1915,22 +1905,22 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_filter_by_id1
+ * Function: H5Pget_filter_by_id1
*
- * Purpose: This is an additional query counterpart of H5Pset_filter() and
+ * Purpose: This is an additional query counterpart of H5Pset_filter() and
* returns information about a particular filter in a permanent
- * or transient pipeline depending on whether PLIST_ID is a
- * dataset creation or transfer property list. On input,
- * CD_NELMTS indicates the number of entries in the CD_VALUES
- * array allocated by the caller while on exit it contains the
- * number of values defined by the filter. The ID
+ * or transient pipeline depending on whether PLIST_ID is a
+ * dataset creation or transfer property list. On input,
+ * CD_NELMTS indicates the number of entries in the CD_VALUES
+ * array allocated by the caller while on exit it contains the
+ * number of values defined by the filter. The ID
* should be the filter ID to retrieve the parameters for. If the
* filter is not set for the property list, an error will be returned.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Friday, April 5, 2003
*
*-------------------------------------------------------------------------
diff --git a/src/H5Z.c b/src/H5Z.c
index 1dc93d8..8dbbdb0 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -609,12 +609,6 @@ H5Zfilter_avail(H5Z_filter_t id)
if((ret_value = H5Z_filter_avail(id)) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter")
- else if(ret_value == FALSE) {
- const H5Z_class2_t *filter_info;
-
- if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id)))
- ret_value = TRUE;
- } /* end if */
done:
FUNC_LEAVE_API(ret_value)
@@ -633,6 +627,7 @@ htri_t
H5Z_filter_avail(H5Z_filter_t id)
{
size_t i; /* Local index variable */
+ const H5Z_class2_t *filter_info;
htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -640,8 +635,12 @@ H5Z_filter_avail(H5Z_filter_t id)
/* Is the filter already registered? */
for(i = 0; i < H5Z_table_used_g; i++)
if(H5Z_table_g[i].id == id)
- HGOTO_DONE(TRUE)
+ HGOTO_DONE(TRUE)
+ if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id)))
+ if(H5Z_register(filter_info) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter")
+ HGOTO_DONE(TRUE)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z_filter_avail() */
@@ -1136,7 +1135,7 @@ H5Z_find(H5Z_filter_t id)
/* Get the index in the global table */
if((idx=H5Z_find_idx(id))<0)
- HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "required filter is not registered")
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "required filter %d is not registered", id)
/* Set return value */
ret_value=H5Z_table_g+idx;
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index 7ed9a90..f34d466 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -284,8 +284,7 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout,
/* Set return value */
ret_value = dt_ret->id_out;
- /* Increment the ref count on id_out, because the calling function will try
- * to close it */
+ /* Increment the ref count on id_out, because the calling function will try to close it */
if(H5Iinc_ref(ret_value) < 0)
ret_value = -1;
@@ -482,24 +481,8 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p,
if (options->verbose)
printf(FORMAT_OBJ_ATTR, "attr", name);
-
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
-
- if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Tclose(wtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Sclose(space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
- if (H5Aclose(attr_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
} /* u */
- return 0;
-
done:
H5E_BEGIN_TRY {
if (buf) {
@@ -541,8 +524,8 @@ static int check_options(pack_opt_t *options) {
*-------------------------------------------------------------------------
*/
if (options->verbose && have_request(options) /* only print if requested */) {
- printf("Objects to modify layout are...\n");
if (options->all_layout == 1) {
+ printf("All objects to modify layout are...\n");
switch (options->layout_g) {
case H5D_COMPACT:
strcpy(slayout, "compact");
@@ -563,14 +546,17 @@ static int check_options(pack_opt_t *options) {
strcpy(slayout, "invalid layout\n");
HGOTO_DONE(FAIL);
}
- printf(" Apply %s layout to all\n", slayout);
+ printf(" Apply %s layout to all", slayout);
if (H5D_CHUNKED == options->layout_g) {
- printf("with dimension [");
+ printf("with dimension [ ");
for (j = 0; j < options->chunk_g.rank; j++)
printf("%d ", (int) options->chunk_g.chunk_lengths[j]);
- printf("]\n");
+ printf("]");
}
+ printf("\n");
}
+ else
+ printf("No all objects to modify layout\n");
}/* verbose */
for (i = 0; i < options->op_tbl->nelems; i++) {
@@ -601,10 +587,14 @@ static int check_options(pack_opt_t *options) {
*/
if (options->verbose && have_request(options) /* only print if requested */) {
- printf("Objects to apply filter are...\n");
if (options->all_filter == 1) {
+ printf("All objects to apply filter are...\n");
for (k = 0; k < options->n_filter_g; k++) {
H5Z_filter_t filtn = options->filter_g[k].filtn;
+ if (filtn < 0) {
+ printf(" Unknown\n");
+ continue;
+ }
switch (filtn) {
case H5Z_FILTER_NONE:
printf(" Uncompress all\n");
@@ -623,6 +613,8 @@ static int check_options(pack_opt_t *options) {
} /* k */
};
}
+ else
+ printf("No all objects to apply filter\n");
} /* verbose */
for (i = 0; i < options->op_tbl->nelems; i++) {
@@ -631,7 +623,12 @@ static int check_options(pack_opt_t *options) {
for (j = 0; j < pack.nfilters; j++) {
if (options->verbose) {
- printf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn));
+ if(pack.filter[j].filtn >= 0) {
+ if(pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET)
+ printf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), pack.filter[j].filtn);
+ else
+ printf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn));
+ }
}
has_cp = 1;
} /* j */
@@ -661,8 +658,7 @@ static int check_options(pack_opt_t *options) {
*/
if (options->ublock_filename != NULL && options->ublock_size == 0) {
if (options->verbose) {
- printf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n",
- options->ublock_filename);
+ printf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename);
options->ublock_size = 1024;
}
}
@@ -692,27 +688,28 @@ done:
*-------------------------------------------------------------------------
*/
static int check_objects(const char* fname, pack_opt_t *options) {
+ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
hid_t fid;
+ hid_t did;
+ hid_t sid;
unsigned int i;
trav_table_t *travt = NULL;
/* nothing to do */
if (options->op_tbl->nelems == 0)
- return 0;
+ HGOTO_DONE(0);
/*-------------------------------------------------------------------------
- * open the file
- *-------------------------------------------------------------------------
- */
- if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) {
- printf("<%s>: %s\n", fname, H5FOPENERROR);
- return -1;
- }
+ * open the file
+ *-------------------------------------------------------------------------
+ */
+ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR);
/*-------------------------------------------------------------------------
- * get the list of objects in the file
- *-------------------------------------------------------------------------
- */
+ * get the list of objects in the file
+ *-------------------------------------------------------------------------
+ */
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
@@ -721,15 +718,15 @@ static int check_objects(const char* fname, pack_opt_t *options) {
/* get the list of objects in the file */
if (h5trav_gettable(fid, travt) < 0)
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
/*-------------------------------------------------------------------------
- * compare with user supplied list
- *-------------------------------------------------------------------------
- */
+ * compare with user supplied list
+ *-------------------------------------------------------------------------
+ */
if (options->verbose)
- printf("Opening file <%s>. Searching for objects to modify...\n", fname);
+ printf("Opening file. Searching %d objects to modify ...\n", travt->nobjs);
for (i = 0; i < options->op_tbl->nelems; i++) {
char* name = options->op_tbl->objs[i].path;
@@ -737,14 +734,14 @@ static int check_objects(const char* fname, pack_opt_t *options) {
printf(" <%s>", name);
/* the input object names are present in the file and are valid */
- if (h5trav_getindext(name, travt) < 0) {
- error_msg("%s Could not find <%s> in file <%s>. Exiting...\n",
+ if (h5trav_getindext(name, travt) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "%s Could not find <%s> in file <%s>. Exiting...\n",
(options->verbose ? "\n" : ""), name, fname);
- goto done;
- }
if (options->verbose)
printf("...Found\n");
+ if (options->op_tbl->objs[i].filter->filtn < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter");
/* check for extra filter conditions */
switch (options->op_tbl->objs[i].filter->filtn) {
/* chunk size must be smaller than pixels per block */
@@ -755,8 +752,6 @@ static int check_objects(const char* fname, pack_opt_t *options) {
unsigned ppb = options->op_tbl->objs[i].filter->cd_values[0];
hsize_t dims[H5S_MAX_RANK];
int rank;
- hid_t did;
- hid_t sid;
if (options->op_tbl->objs[i].chunk.rank > 0) {
rank = options->op_tbl->objs[i].chunk.rank;
@@ -765,25 +760,25 @@ static int check_objects(const char* fname, pack_opt_t *options) {
}
else {
if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if ((sid = H5Dget_space(did)) < 0)
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
HDmemset(dims, 0, sizeof dims);
if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
for (j = 0; j < rank; j++)
csize *= dims[j];
if (H5Sclose(sid) < 0)
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if (H5Dclose(did) < 0)
- goto done;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
}
if (csize < ppb) {
- printf(" <warning: SZIP settins, chunk size is smaller than pixels per block>\n");
- goto done;
+ printf(" <warning: SZIP settings, chunk size is smaller than pixels per block>\n");
+ HGOTO_DONE(0);
}
}
break;
@@ -792,18 +787,15 @@ static int check_objects(const char* fname, pack_opt_t *options) {
}
} /* i */
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- H5Fclose(fid);
- trav_table_free(travt);
- return 0;
-
done:
- H5Fclose(fid);
- trav_table_free(travt);
- return -1;
+ H5E_BEGIN_TRY {
+ H5Fclose(fid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ } H5E_END_TRY;
+ if (travt)
+ trav_table_free(travt);
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -833,7 +825,9 @@ static int have_request(pack_opt_t *options) {
*/
static const char* get_sfilter(H5Z_filter_t filtn) {
- if (filtn == H5Z_FILTER_NONE)
+ if (filtn < 0)
+ return NULL;
+ else if (filtn == H5Z_FILTER_NONE)
return "NONE";
else if (filtn == H5Z_FILTER_DEFLATE)
return "GZIP";
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index c8c6a0e..0252768 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -29,7 +29,7 @@
#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */
/* File space default information */
-#define FS_PAGESIZE_DEF 4096
+#define FS_PAGESIZE_DEF 4096
#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
#define FS_PERSIST_DEF FALSE
#define FS_THRESHOLD_DEF 1
@@ -42,7 +42,7 @@
/* a list of names */
typedef struct {
- char obj[MAX_NC_NAME];
+ char obj[MAX_NC_NAME];
} obj_list_t;
/*
@@ -60,16 +60,16 @@ typedef struct {
#define CD_VALUES 20
typedef struct {
- H5Z_filter_t filtn; /* filter identification number */
- unsigned filt_flag; /* filter definition flag */
- unsigned cd_values[CD_VALUES]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned filt_flag; /* filter definition flag */
+ unsigned cd_values[CD_VALUES]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
} filter_info_t;
/* chunk lengths along each dimension and rank */
typedef struct {
- hsize_t chunk_lengths[MAX_VAR_DIMS];
- int rank;
+ hsize_t chunk_lengths[MAX_VAR_DIMS];
+ int rank;
} chunk_info_t;
/* we currently define a maximum value for the filters array,
@@ -78,19 +78,19 @@ typedef struct {
/* information for one object, contains PATH, CHUNK info and FILTER info */
typedef struct {
- char path[MAX_NC_NAME]; /* name of object */
- filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */
- int nfilters; /* current number of filters */
- H5D_layout_t layout; /* layout information */
- chunk_info_t chunk; /* chunk information */
- hid_t refobj_id; /* object ID, references */
+ char path[MAX_NC_NAME]; /* name of object */
+ filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */
+ int nfilters; /* current number of filters */
+ H5D_layout_t layout; /* layout information */
+ chunk_info_t chunk; /* chunk information */
+ hid_t refobj_id; /* object ID, references */
} pack_info_t;
/* store a table of all objects */
typedef struct {
- unsigned int size;
- unsigned int nelems;
- pack_info_t *objs;
+ unsigned int size;
+ unsigned int nelems;
+ pack_info_t *objs;
} pack_opttbl_t;
@@ -101,30 +101,30 @@ typedef struct {
/* all the above, ready to go to the hrepack call */
typedef struct {
- pack_opttbl_t *op_tbl; /*table with all -c and -f options */
- int all_layout; /*apply the layout to all objects */
- int all_filter; /*apply the filter to all objects */
- filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */
- int n_filter_g; /*number of global filters */
- chunk_info_t chunk_g; /*global chunk INFO for the ALL case */
- H5D_layout_t layout_g; /*global layout information for the ALL case */
- int verbose; /*verbose mode */
- hsize_t min_comp; /*minimum size to compress, in bytes */
- int use_native; /*use a native type in write */
- hbool_t latest; /*pack file with the latest file format */
- int grp_compact; /* Set the maximum number of links to store as header messages in the group */
- int grp_indexed; /* Set the minimum number of links to store in the indexed format */
- int msg_size[8]; /* Minimum size of shared messages: dataspace,
- datatype, fill value, filter pipleline, attribute */
- const char *ublock_filename; /* user block file name */
- hsize_t ublock_size; /* user block size */
- hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */
- hsize_t threshold; /* alignment threshold for H5Pset_alignment */
- hsize_t alignment; /* alignment for H5Pset_alignment */
- H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
- int fs_persist; /* Free space section threshold */
- long fs_threshold; /* Free space section threshold */
- long long fs_pagesize; /* File space page size */
+ pack_opttbl_t *op_tbl; /*table with all -c and -f options */
+ int all_layout; /*apply the layout to all objects */
+ int all_filter; /*apply the filter to all objects */
+ filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */
+ int n_filter_g; /*number of global filters */
+ chunk_info_t chunk_g; /*global chunk INFO for the ALL case */
+ H5D_layout_t layout_g; /*global layout information for the ALL case */
+ int verbose; /*verbose mode */
+ hsize_t min_comp; /*minimum size to compress, in bytes */
+ int use_native; /*use a native type in write */
+ hbool_t latest; /*pack file with the latest file format */
+ int grp_compact; /* Set the maximum number of links to store as header messages in the group */
+ int grp_indexed; /* Set the minimum number of links to store in the indexed format */
+ int msg_size[8]; /* Minimum size of shared messages: dataspace,
+ datatype, fill value, filter pipleline, attribute */
+ const char *ublock_filename; /* user block file name */
+ hsize_t ublock_size; /* user block size */
+ hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */
+ hsize_t threshold; /* alignment threshold for H5Pset_alignment */
+ hsize_t alignment; /* alignment for H5Pset_alignment */
+ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
+ int fs_persist; /* Free space section threshold */
+ long fs_threshold; /* Free space section threshold */
+ long long fs_pagesize; /* File space page size */
} pack_opt_t;
@@ -214,18 +214,18 @@ int apply_filters(const char* name, /* object name from traverse list */
* options table
*-------------------------------------------------------------------------
*/
-int options_table_init( pack_opttbl_t **tbl );
-int options_table_free( pack_opttbl_t *table );
-int options_add_layout( obj_list_t *obj_list,
- unsigned n_objs,
- pack_info_t *pack,
- pack_opttbl_t *table );
-int options_add_filter ( obj_list_t *obj_list,
- unsigned n_objs,
- filter_info_t filt,
- pack_opttbl_t *table );
-pack_info_t* options_get_object( const char *path,
- pack_opttbl_t *table);
+int options_table_init(pack_opttbl_t **tbl);
+int options_table_free(pack_opttbl_t *table);
+int options_add_layout(obj_list_t *obj_list,
+ unsigned n_objs,
+ pack_info_t *pack,
+ pack_opttbl_t *table);
+int options_add_filter(obj_list_t *obj_list,
+ unsigned n_objs,
+ filter_info_t filt,
+ pack_opttbl_t *table);
+pack_info_t* options_get_object(const char *path,
+ pack_opttbl_t *table);
/*-------------------------------------------------------------------------
* parse functions
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index 47cad13..08bce60 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -109,9 +109,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
* open input file
*-------------------------------------------------------------------------
*/
- if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0) {
+ if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR);
- }
/* get user block size and file space strategy/persist/threshold */
{
@@ -119,23 +118,20 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
hid_t grp_in = -1; /* group ID */
hid_t gcpl_in = -1; /* group creation property list */
- if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
+ if ((fcpl_in = H5Fget_create_plist(fidin)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
- }
- if (H5Pget_userblock(fcpl_in, &ub_size) < 0) {
+ if (H5Pget_userblock(fcpl_in, &ub_size) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_userblock failed to retrieve userblock size");
- }
/* If the -S option is not set, get "strategy" from the input file */
- if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) {
+ if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_strategy failed to retrieve file space strategy");
- }
/* If the -G option is not set, get "pagesize" from the input file */
- if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) {
+ if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_page_size failed to retrieve file space threshold");
- }
+
/* open root group */
if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
@@ -148,23 +144,19 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
- if (H5Pclose(fcpl_in) < 0) {
+ if (H5Pclose(fcpl_in) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed to close property list");
- }
}
/* Check if we need to create a non-default file creation property list */
if (options->latest || ub_size > 0) {
/* Create file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list");
- }
- if (ub_size > 0) {
- if (H5Pset_userblock(fcpl, ub_size) < 0) {
+ if (ub_size > 0)
+ if (H5Pset_userblock(fcpl, ub_size) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_userblock failed to set non-default userblock size");
- }
- }
if (options->latest) {
unsigned i = 0, nindex = 0, mesg_type_flags[5], min_mesg_sizes[5];
@@ -172,9 +164,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
/* Adjust group creation parameters for root group */
/* (So that it is created in "dense storage" form) */
if (H5Pset_link_phase_change(fcpl, (unsigned) options->grp_compact,
- (unsigned) options->grp_indexed) < 0) {
+ (unsigned) options->grp_indexed) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_phase_change failed to adjust group creation parameters for root group");
- }
for (i = 0; i < 5; i++) {
if (options->msg_size[i] > 0) {
@@ -209,26 +200,21 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
} /* end for */
if (nindex > 0) {
- if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) {
+ if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes");
- }
/* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */
- for (i = 0; i < (nindex - 1); i++) {
- if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) {
+ for (i = 0; i < (nindex - 1); i++)
+ if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shared_mesg_index failed to configure the specified shared object header message index");
- } /* end if */
- } /* end for */
} /* if (nindex>0) */
/* Create file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list");
- } /* end if */
- if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_libver_bounds failed to set property for using latest version of the format");
- } /* end if */
} /* end if */
} /* end if */
#if defined (H5REPACK_DEBUG_USER_BLOCK)
@@ -241,17 +227,14 @@ print_user_block(fnamein, fidin);
*/
if (options->ublock_size > 0) {
/* either use the FCPL already created or create a new one */
- if (fcpl == H5P_DEFAULT) {
+ if (fcpl == H5P_DEFAULT)
/* create a file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list");
- }
- }
/* set user block size */
- if (H5Pset_userblock(fcpl, options->ublock_size) < 0) {
+ if (H5Pset_userblock(fcpl, options->ublock_size) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_userblock failed to set userblock size");
- }
}
/*-------------------------------------------------------------------------
@@ -260,16 +243,13 @@ print_user_block(fnamein, fidin);
*/
if (options->alignment > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT) {
+ if (fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list");
- }
- }
- if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) {
+ if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_alignment failed to set alignment");
- }
}
/*-------------------------------------------------------------------------
@@ -278,16 +258,13 @@ print_user_block(fnamein, fidin);
*/
if (options->meta_block_size > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT) {
+ if (fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list");
- }
- }
- if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) {
+ if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_meta_block_size failed to set metadata block size");
- }
}
/*-------------------------------------------------------------------------
@@ -296,12 +273,10 @@ print_user_block(fnamein, fidin);
*/
/* either use the FCPL already created or create a new one */
- if (fcpl == H5P_DEFAULT) {
+ if (fcpl == H5P_DEFAULT)
/* create a file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list");
- }
- }
if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed");
@@ -328,9 +303,8 @@ print_user_block(fnamein, fidin);
set_threshold = (hsize_t)options->fs_threshold;
/* Set file space information as specified */
- if(H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0) {
+ if(H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_file_space_strategy failed to set file space strategy");
- }
if(options->fs_pagesize == -1) /* A "0" file space page size is specified by user */
set_pagesize = (hsize_t)0;
@@ -338,30 +312,26 @@ print_user_block(fnamein, fidin);
set_pagesize = (hsize_t)options->fs_pagesize;
if(set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */
- if(H5Pset_file_space_page_size(fcpl, set_pagesize) < 0) {
+ if(H5Pset_file_space_page_size(fcpl, set_pagesize) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_file_space_page_size failed to set file space page size");
- }
/*-------------------------------------------------------------------------
* create the output file
*-------------------------------------------------------------------------
*/
if (options->verbose)
- printf("Making file <%s>...\n", fnameout);
+ printf("Making new file ...\n");
- if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) {
+ if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fcreate could not create file <%s>:", fnameout);
- }
/*-------------------------------------------------------------------------
* write a new user block if requested
*-------------------------------------------------------------------------
*/
- if (options->ublock_size > 0) {
- if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0) {
+ if (options->ublock_size > 0)
+ if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not copy user block. Exiting...");
- }
- }
/*-------------------------------------------------------------------------
* get list of objects
@@ -381,18 +351,16 @@ print_user_block(fnamein, fidin);
* do the copy
*-------------------------------------------------------------------------
*/
- if (do_copy_objects(fidin, fidout, travt, options) < 0) {
+ if (do_copy_objects(fidin, fidout, travt, options) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout);
- } /* end if */
/*-------------------------------------------------------------------------
* do the copy of referenced objects
* and create hard links
*-------------------------------------------------------------------------
*/
- if (do_copy_refobjs(fidin, fidout, travt, options) < 0) {
+ if (do_copy_refobjs(fidin, fidout, travt, options) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout);
- }
/*-------------------------------------------------------------------------
* close
@@ -417,11 +385,9 @@ print_user_block(fnamein, fidin);
*-------------------------------------------------------------------------
*/
- if (ub_size > 0 && options->ublock_size == 0) {
- if (copy_user_block(fnamein, fnameout, ub_size) < 0) {
+ if (ub_size > 0 && options->ublock_size == 0)
+ if (copy_user_block(fnamein, fnameout, ub_size) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not copy user block. Exiting...");
- }
- }
return 0;
@@ -738,7 +704,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
hsize_t size_dset;
/*-------------------------------------------------------------------------
- * copy the suppplied object list
+ * copy the supplied object list
*-------------------------------------------------------------------------
*/
@@ -748,12 +714,13 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
printf("-----------------------------------------\n");
}
- for (i = 0; i < travt->nobjs; i++) {
- /* init variables per obj */
- buf = NULL;
- limit_maxdims = FALSE;
+ if (travt->objs) {
+ for (i = 0; i < travt->nobjs; i++) {
+ /* init variables per obj */
+ buf = NULL;
+ limit_maxdims = FALSE;
- switch (travt->objs[i].type) {
+ switch (travt->objs[i].type) {
case H5TRAV_TYPE_UNKNOWN:
break;
@@ -833,10 +800,13 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
req_filter = 1;
/* check if filters were requested for individual objects */
- for (u = 0; u < options->op_tbl->nelems; u++)
- if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0)
- if (options->op_tbl->objs[u].filter->filtn > 0)
- req_filter = 1;
+ if (options->op_tbl->objs) {
+ for (u = 0; u < options->op_tbl->nelems; u++) {
+ if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0)
+ if (options->op_tbl->objs[u].filter->filtn > 0)
+ req_filter = 1;
+ }
+ }
/* check if layout change requested individual object */
if (options->layout_g != H5D_LAYOUT_ERROR) {
@@ -1012,9 +982,10 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
buf = HDmalloc(need);
if (buf != NULL) {
- /* read/write: use the macro to check error, e.g. memory allocation error inside the library. */
- CHECK_H5DRW_ERROR(H5Dread, FAIL, dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- CHECK_H5DRW_ERROR(H5Dwrite, FAIL, dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
/* Check if we have VL data in the dataset's
* datatype that must be reclaimed */
@@ -1097,9 +1068,10 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
hs_select_nelmts = 1;
} /* rank */
- /* read/write: use the macro to check error, e.g. memory allocation error inside the library. */
- CHECK_H5DRW_ERROR(H5Dread, FAIL, dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf);
- CHECK_H5DRW_ERROR(H5Dwrite, FAIL, dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf);
+ if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
/* reclaim any VL memory, if necessary */
if (vl_data)
@@ -1293,19 +1265,9 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
default:
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Object type not found");
- } /* switch */
-
- /* free */
- if (buf != NULL) {
- HDfree(buf);
- buf = NULL;
- }
- } /* i */
-
- /* Finalize (link) the stack of named datatypes (if any) */
- named_datatype_free(&named_dt_head, 0);
-
- return ret_value;
+ } /* switch */
+ } /* end for */
+ } /* end if */
done:
H5E_BEGIN_TRY
@@ -1322,8 +1284,7 @@ done:
H5Tclose(wtype_id);
H5Tclose(type_in);
H5Tclose(type_out);
- named_datatype_free(&named_dt_head, 1);
- }H5E_END_TRY;
+ } H5E_END_TRY;
/* free */
if (buf != NULL)
@@ -1331,6 +1292,14 @@ done:
if (hslab_buf != NULL)
HDfree(hslab_buf);
+ /* Finalize (link) the stack of named datatypes (if any) */
+ if (0 == ret_value)
+ named_datatype_free(&named_dt_head, 0);
+ else
+ H5E_BEGIN_TRY {
+ named_datatype_free(&named_dt_head, 1);
+ } H5E_END_TRY;
+
return ret_value;
}
@@ -1364,8 +1333,11 @@ static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int p
for (i = 0; i < nfilters; i++) {
cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_objname), f_objname, NULL);
+ if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts,
+ cd_values, sizeof(f_objname), f_objname, NULL)) < 0) {
+ HDstrcat(strfilter, "ERROR ");
+ continue;
+ }
switch (filtn) {
case H5Z_FILTER_NONE:
diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c
index a74e5f3..ec5d672 100644
--- a/tools/src/h5repack/h5repack_filters.c
+++ b/tools/src/h5repack/h5repack_filters.c
@@ -25,23 +25,71 @@
#define MIN(a,b) (((a)<(b)) ? (a) : (b))
/*-------------------------------------------------------------------------
+ * Function: aux_copy_obj
+ *
+ * Purpose: copy the object filters for object copy
+ *
+ * Return: 0 success, -1 failure
+ *-------------------------------------------------------------------------
+ */
+static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */
+ const char* name, /* object name from traverse list */
+ pack_info_t *objout /*OUT*/) /* info about object to filter */
+{
+ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ int nfilters; /* number of filters in DCPL */
+ char f_objname[256]; /* filter objname */
+ H5D_layout_t layout;
+ int rank; /* rank of dataset */
+ hsize_t chsize[64]; /* chunk size in elements */
+ unsigned int i, j;
+
+ /* get information about input filters */
+ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
+ /* copy filter_info_t structure */
+ for (i = 0; i < nfilters; i++) {
+ if ((objout->filter[i].filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts,
+ objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_filter2 failed");
+ }
+
+ objout->nfilters = nfilters;
+ HDstrcpy(objout->path, name);
+
+ if ((layout = H5Pget_layout(dcpl_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed");
+ objout->layout = layout;
+
+ if (layout == H5D_CHUNKED) {
+ if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed");
+ objout->chunk.rank = rank;
+ for (i = 0; i < rank; i++)
+ objout->chunk.chunk_lengths[i] = chsize[i];
+ }
+
+done:
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
* Function: aux_find_obj
*
* Purpose: find the object name NAME (got from the traverse list)
* in the repack options list
- *
*-------------------------------------------------------------------------
*/
static int aux_find_obj(const char* name, /* object name from traverse list */
- pack_opt_t *options, /* repack options */
- pack_info_t *obj /*OUT*/) /* info about object to filter */
+ pack_opt_t *options, /* repack options */
+ pack_info_t *obj /*OUT*/) /* info about object to filter */
{
char *pdest;
int result;
unsigned int i;
for (i = 0; i < options->op_tbl->nelems; i++) {
- if (HDstrcmp(options->op_tbl->objs[i].path,name) == 0) {
+ if (HDstrcmp(options->op_tbl->objs[i].path, name) == 0) {
*obj = options->op_tbl->objs[i];
return (int) i;
}
@@ -66,14 +114,12 @@ static int aux_find_obj(const char* name, /* object name from traverse list */
* in the repack options list; assign the filter information OBJ
*
* Return: 0 not found, 1 found
- *
*-------------------------------------------------------------------------
*/
static int aux_assign_obj(const char* name, /* object name from traverse list */
- pack_opt_t *options, /* repack options */
- pack_info_t *obj /*OUT*/) /* info about object to filter */
+ pack_opt_t *options, /* repack options */
+ pack_info_t *obj /*OUT*/) /* info about object to filter */
{
-
int idx, i;
pack_info_t tmp;
@@ -83,7 +129,6 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
/* name was on input */
if (idx >= 0) {
-
/* applying to all objects */
if (options->all_layout) {
/* assign the global layout info to the OBJ info */
@@ -92,8 +137,7 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
case H5D_CHUNKED:
tmp.chunk.rank = options->chunk_g.rank;
for (i = 0; i < tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i] =
- options->chunk_g.chunk_lengths[i];
+ tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i];
break;
case H5D_LAYOUT_ERROR:
case H5D_COMPACT:
@@ -111,8 +155,7 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
case H5D_CHUNKED:
tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank;
for (i = 0; i < tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i] =
- options->op_tbl->objs[idx].chunk.chunk_lengths[i];
+ tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i];
break;
case H5D_LAYOUT_ERROR:
case H5D_COMPACT:
@@ -123,7 +166,6 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
default:
break;
}/*switch*/
-
}
/* applying to all objects */
@@ -183,28 +225,24 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
* of H5Z_FILTER_NONE present in the PACK_INFO_T filter array
*
* Return: 0 success, -1 an error occured
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 19, 2003
- *
*-------------------------------------------------------------------------
*/
int apply_filters(const char* name, /* object name from traverse list */
- int rank, /* rank of dataset */
- hsize_t *dims, /* dimensions of dataset */
- size_t msize, /* size of type */
- hid_t dcpl_id, /* dataset creation property list */
- pack_opt_t *options, /* repack options */
- int *has_filter) /* (OUT) object NAME has a filter */
+ int rank, /* rank of dataset */
+ hsize_t *dims, /* dimensions of dataset */
+ size_t msize, /* size of type */
+ hid_t dcpl_id, /* dataset creation property list */
+ pack_opt_t *options, /* repack options */
+ int *has_filter) /* (OUT) object NAME has a filter */
{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- int nfilters; /* number of filters in DCPL */
- hsize_t chsize[64]; /* chunk size in elements */
+ int nfilters; /* number of filters in DCPL */
+ hsize_t chsize[64]; /* chunk size in elements */
H5D_layout_t layout;
- int i;
+ int i, j;
pack_info_t obj;
+ pack_info_t filtobj;
*has_filter = 0;
@@ -212,15 +250,16 @@ int apply_filters(const char* name, /* object name from traverse list */
HGOTO_DONE(0);
/*-------------------------------------------------------------------------
- * initialize the assigment object
- *-------------------------------------------------------------------------
- */
+ * initialize the assigment object
+ *-------------------------------------------------------------------------
+ */
init_packobject(&obj);
+ init_packobject(&filtobj);
/*-------------------------------------------------------------------------
- * find options
- *-------------------------------------------------------------------------
- */
+ * find options
+ *-------------------------------------------------------------------------
+ */
if (aux_assign_obj(name, options, &obj) == 0)
HGOTO_DONE(0);
@@ -228,55 +267,61 @@ int apply_filters(const char* name, /* object name from traverse list */
if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
+
/*-------------------------------------------------------------------------
- * check if we have filters in the pipeline
- * we want to replace them with the input filters
- * only remove if we are inserting new ones
- *-------------------------------------------------------------------------
- */
+ * check if we have filters in the pipeline
+ * we want to replace them with the input filters
+ * only remove if we are inserting new ones
+ *-------------------------------------------------------------------------
+ */
if (nfilters && obj.nfilters) {
*has_filter = 1;
if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Premove_filter failed");
- }
- /*-------------------------------------------------------------------------
- * check if there is an existent chunk
- * read it only if there is not a requested layout
- *-------------------------------------------------------------------------
- */
- if (obj.layout == -1) {
- if ((layout = H5Pget_layout(dcpl_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed");
-
- if (layout == H5D_CHUNKED) {
- if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed");
- obj.layout = H5D_CHUNKED;
- obj.chunk.rank = rank;
- for (i = 0; i < rank; i++)
- obj.chunk.chunk_lengths[i] = chsize[i];
+ /*-------------------------------------------------------------------------
+ * check if there is an existent chunk
+ * read it only if there is not a requested layout
+ *-------------------------------------------------------------------------
+ */
+ if (obj.layout == -1) {
+ if ((layout = H5Pget_layout(dcpl_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed");
+
+ if (layout == H5D_CHUNKED) {
+ if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed");
+ obj.layout = H5D_CHUNKED;
+ obj.chunk.rank = rank;
+ for (i = 0; i < rank; i++)
+ obj.chunk.chunk_lengths[i] = chsize[i];
+ }
}
}
+ else if(nfilters) {
+ *has_filter = 1;
+ if (aux_copy_obj(dcpl_id, name, &filtobj) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "aux_copy_obj failed");
+ }
/*-------------------------------------------------------------------------
- * the type of filter and additional parameter
- * type can be one of the filters
- * H5Z_FILTER_NONE 0 , uncompress if compressed
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- * H5Z_FILTER_SZIP 4 , szip compression
- * H5Z_FILTER_NBIT 5 , nbit compression
- * H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression
- *-------------------------------------------------------------------------
- */
+ * the type of filter and additional parameter
+ * type can be one of the filters
+ * H5Z_FILTER_NONE 0 , uncompress if compressed
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ * H5Z_FILTER_SZIP 4 , szip compression
+ * H5Z_FILTER_NBIT 5 , nbit compression
+ * H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression
+ *-------------------------------------------------------------------------
+ */
if (obj.nfilters) {
/*-------------------------------------------------------------------------
- * filters require CHUNK layout; if we do not have one define a default
- *-------------------------------------------------------------------------
- */
+ * filters require CHUNK layout; if we do not have one define a default
+ *-------------------------------------------------------------------------
+ */
if (obj.layout == -1) {
/* stripmine info */
hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */
@@ -285,9 +330,9 @@ int apply_filters(const char* name, /* object name from traverse list */
obj.chunk.rank = rank;
/*
- * determine the strip mine size. The strip mine is
- * a hyperslab whose size is manageable.
- */
+ * determine the strip mine size. The strip mine is
+ * a hyperslab whose size is manageable.
+ */
sm_nbytes = msize;
for (i = rank; i > 0; --i) {
@@ -305,18 +350,21 @@ int apply_filters(const char* name, /* object name from traverse list */
}
for (i = 0; i < obj.nfilters; i++) {
+ if (obj.filter[i].filtn < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter");
+
switch (obj.filter[i].filtn) {
/*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE 0 , uncompress if compressed
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_NONE 0 , uncompress if compressed
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_NONE:
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_DEFLATE:
{
unsigned aggression; /* the deflate level */
@@ -330,10 +378,10 @@ int apply_filters(const char* name, /* object name from traverse list */
}
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP 4 , szip compression
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP 4 , szip compression
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_SZIP:
{
unsigned options_mask;
@@ -350,10 +398,10 @@ int apply_filters(const char* name, /* object name from traverse list */
}
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_SHUFFLE:
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
@@ -361,31 +409,30 @@ int apply_filters(const char* name, /* object name from traverse list */
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shuffle failed");
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_FLETCHER32:
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
if (H5Pset_fletcher32(dcpl_id) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fletcher32 failed");
break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_NBIT , NBIT compression
- *-------------------------------------------------------------------------
- */
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_NBIT , NBIT compression
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_NBIT:
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
if (H5Pset_nbit(dcpl_id) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_nbit failed");
break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET , scale+offset compression
- *-------------------------------------------------------------------------
- */
-
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET , scale+offset compression
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_SCALEOFFSET:
{
H5Z_SO_scale_type_t scale_type;
@@ -402,12 +449,12 @@ int apply_filters(const char* name, /* object name from traverse list */
break;
default:
{
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
if (H5Pset_filter(dcpl_id, obj.filter[i].filtn,
obj.filter[i].filt_flag, obj.filter[i].cd_nelmts,
obj.filter[i].cd_values) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_filter failed");
- if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
}
break;
} /* switch */
@@ -415,31 +462,16 @@ int apply_filters(const char* name, /* object name from traverse list */
}
/*obj.nfilters*/
- /*-------------------------------------------------------------------------
- * layout
- *-------------------------------------------------------------------------
- */
-
- if (obj.layout >= 0) {
- /* a layout was defined */
- if (H5Pset_layout(dcpl_id, obj.layout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_layout failed");
-
- if (H5D_CHUNKED == obj.layout) {
- if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
- }
- else if (H5D_COMPACT == obj.layout) {
- if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_alloc_time failed");
- }
- /* remove filters for the H5D_CONTIGUOUS case */
- else if (H5D_CONTIGUOUS == obj.layout) {
- if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Premove_filter failed");
- }
+ if (filtobj.nfilters) {
+ for (i = 0; i < filtobj.nfilters; i++) {
+ if (filtobj.filter[i].filtn < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter");
+ if (H5Zfilter_avail(filtobj.filter[i].filtn) <= 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "%d filter unavailable", filtobj.filter[i].filtn);
+ }/*for*/
}
+ /*nfilters*/
done:
return ret_value;
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index 3860451..d34c394 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -428,13 +428,13 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char) opt) {
- /* -i for backward compability */
+ /* -i for backward compatibility */
case 'i':
infile = opt_arg;
has_i_o = 1;
break;
- /* -o for backward compability */
+ /* -o for backward compatibility */
case 'o':
outfile = opt_arg;
has_i_o = 1;
@@ -695,8 +695,10 @@ int main(int argc, const char **argv)
}
/* initialize options */
- h5repack_init(&options, 0, FALSE);
-
+ if (h5repack_init(&options, 0, FALSE) < 0) {
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
/* Initialize default indexing options */
sort_by = H5_INDEX_CRT_ORDER;
diff --git a/tools/src/h5repack/h5repack_opttable.c b/tools/src/h5repack/h5repack_opttable.c
index 6c409ec..7ab8c6e 100644
--- a/tools/src/h5repack/h5repack_opttable.c
+++ b/tools/src/h5repack/h5repack_opttable.c
@@ -30,6 +30,7 @@ void init_packobject(pack_info_t *obj) {
HDstrcpy(obj->path, "\0");
for (j = 0; j < H5_REPACK_MAX_NFILTERS; j++) {
obj->filter[j].filtn = -1;
+ obj->filter[j].cd_nelmts = CD_VALUES;
for (k = 0; k < CD_VALUES; k++)
obj->filter[j].cd_values[k] = 0;
}
@@ -261,7 +262,7 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa
/* search if this object is already in the table; "path" is the key */
if (table->nelems > 0) {
- /* go tru the supplied list of names */
+ /* go through the supplied list of names */
for (j = 0; j < n_objs; j++) {
/* linear table search */
for (i = 0; i < table->nelems; i++) {
diff --git a/tools/src/h5repack/h5repack_parse.c b/tools/src/h5repack/h5repack_parse.c
index 4d62723..05af197 100644
--- a/tools/src/h5repack/h5repack_parse.c
+++ b/tools/src/h5repack/h5repack_parse.c
@@ -58,26 +58,30 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
/* check for the end of object list and number of objects */
for (i = 0, n = 0; i < len; i++) {
c = str[i];
- if (c == ':')
+ if (c == ':') {
end_obj = (int) i;
+ break;
+ }
if (c == ',')
n++;
}
+ n++;
/* Check for missing : */
if (end_obj == -1) {
/* apply to all objects */
options->all_filter = 1;
*is_glb = 1;
+ *n_objs = 1;
}
+ else
+ *n_objs = n;
- n++;
obj_list = (obj_list_t *) HDmalloc(n * sizeof(obj_list_t));
if (obj_list == NULL) {
error_msg("could not allocate object list\n");
return NULL;
}
- *n_objs = n;
/* get object list */
if (end_obj > 0)
@@ -89,6 +93,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
sobj[k] = '\0';
else
sobj[k + 1] = '\0';
+
HDstrcpy(obj_list[n].obj, sobj);
HDmemset(sobj, 0, sizeof(sobj));
n++;
@@ -142,7 +147,6 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
if (l == 2) {
smask[l] = '\0';
i = len - 1; /* end */
- (*n_objs)--; /* we counted an extra ',' */
if (HDstrcmp(smask,"NN") == 0)
filt->cd_values[j++] = H5_SZIP_NN_OPTION_MASK;
else if (HDstrcmp(smask,"EC") == 0)
@@ -193,7 +197,6 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
if (l == 2) {
smask[l] = '\0';
i = len - 1; /* end */
- (*n_objs)--; /* we counted an extra ',' */
if (HDstrcmp(smask,"IN") == 0)
filt->cd_values[j++] = H5Z_SO_INT;
else if (HDstrcmp(smask, "DS") == H5Z_SO_FLOAT_DSCALE)
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index e276b7b..bf53bf9 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -39,22 +39,22 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil
int
h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
hid_t fidin = -1; /* file ID for input file*/
hid_t fidout = -1; /* file ID for output file*/
hid_t did = -1; /* dataset ID */
hid_t pid = -1; /* dataset creation property list ID */
hid_t sid = -1; /* space ID */
hid_t tid = -1; /* type ID */
+ int ok = 1; /* step results */
unsigned int i;
trav_table_t *travt = NULL;
- int ok = 1;
- hid_t fcpl_in = -1; /* file creation property for input file */
- hid_t fcpl_out = -1; /* file creation property for output file */
+ hid_t fcpl_in = -1; /* file creation property for input file */
+ hid_t fcpl_out = -1; /* file creation property for output file */
H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */
- hbool_t in_persist, out_persist; /* free-space persist status for in/output file */
- hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */
- hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */
+ hbool_t in_persist, out_persist; /* free-space persist status for in/output file */
+ hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */
+ hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */
/* open the output file */
if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
@@ -84,7 +84,6 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
ok = 0;
-
/*-------------------------------------------------------------------------
* layout check
*-------------------------------------------------------------------------
@@ -104,10 +103,8 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
if (H5Tclose(tid) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
-
}
-
/*-------------------------------------------------------------------------
* check for the "all" objects option
*-------------------------------------------------------------------------
@@ -163,7 +160,6 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
ok = 0;
}
-
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
@@ -177,7 +173,6 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
if (H5Tclose(tid) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
} /* if */
-
} /* i */
/* free table */
@@ -288,17 +283,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
}
}
- /* Closing */
- if (H5Pclose(fcpl_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Pclose(fcpl_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Fclose(fidin) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
- if (H5Fclose(fidout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
-
- return ok;
+ ret_value = ok;
done:
H5E_BEGIN_TRY {
@@ -376,42 +361,29 @@ int verify_layout(hid_t pid, pack_info_t *obj)
int h5repack_cmp_pl(const char *fname1, const char *fname2)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t fid1=-1; /* file ID */
- hid_t fid2=-1; /* file ID */
- hid_t dset1=-1; /* dataset ID */
- hid_t dset2=-1; /* dataset ID */
- hid_t gid=-1; /* group ID */
- hid_t dcpl1=-1; /* dataset creation property list ID */
- hid_t dcpl2=-1; /* dataset creation property list ID */
- hid_t gcplid=-1; /* group creation property list */
- unsigned crt_order_flag1; /* group creation order flag */
- unsigned crt_order_flag2; /* group creation order flag */
- trav_table_t *trav=NULL;
- int ret=1;
+ int ret_value = 1; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ hid_t fid1 =-1; /* file ID */
+ hid_t fid2 =-1; /* file ID */
+ hid_t dset1 =-1; /* dataset ID */
+ hid_t dset2 =-1; /* dataset ID */
+ hid_t gid =-1; /* group ID */
+ hid_t dcpl1 =-1; /* dataset creation property list ID */
+ hid_t dcpl2 =-1; /* dataset creation property list ID */
+ hid_t gcplid =-1; /* group creation property list */
+ unsigned crt_order_flag1; /* group creation order flag */
+ unsigned crt_order_flag2; /* group creation order flag */
+ trav_table_t *trav = NULL;
unsigned int i;
/*-------------------------------------------------------------------------
* open the files
*-------------------------------------------------------------------------
*/
-
- /* disable error reporting */
- H5E_BEGIN_TRY
- {
-
- /* Open the files */
- if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) {
- error_msg("<%s>: %s\n", fname1, H5FOPENERROR );
- return -1;
- }
- if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) {
- error_msg("<%s>: %s\n", fname2, H5FOPENERROR );
- H5Fclose(fid1);
- return -1;
- }
- /* enable error reporting */
- } H5E_END_TRY;
+ /* Open the files */
+ if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
+ if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
/*-------------------------------------------------------------------------
* get file table list of objects
@@ -453,7 +425,7 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
if (crt_order_flag1 != crt_order_flag2) {
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name);
+ HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name);
}
}
else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) {
@@ -470,12 +442,11 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
* compare the property lists
*-------------------------------------------------------------------------
*/
- if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
+ if((ret_value = H5Pequal(dcpl1, dcpl2)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed");
- if(ret == 0) {
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed for <%s> are different",trav->objs[i].name);
- }
+ if(ret_value == 0)
+ HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different",trav->objs[i].name);
/*-------------------------------------------------------------------------
* close
@@ -490,29 +461,8 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
if(H5Dclose(dset2) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
} /*if*/
- } /*i*/
-
- /*-------------------------------------------------------------------------
- * free
- *-------------------------------------------------------------------------
- */
-
- trav_table_free(trav);
+ } /*for*/
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
-
- H5Fclose(fid1);
- H5Fclose(fid2);
-
- return ret;
-
-/*-------------------------------------------------------------------------
-* error
-*-------------------------------------------------------------------------
-*/
done:
H5E_BEGIN_TRY
{
@@ -583,6 +533,8 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
cd_values, sizeof(f_name), f_name, NULL);
/* filter ID */
+ if (filtn < 0)
+ return -1;
if (filtn != filter[i].filtn)
return 0;
@@ -657,4 +609,3 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
return 1;
}
-
diff --git a/tools/test/h5repack/testfiles/h5repack_filters.h5-gzip_verbose_filters.tst b/tools/test/h5repack/testfiles/h5repack_filters.h5-gzip_verbose_filters.tst
index 36e65b9..5a91a28 100644
--- a/tools/test/h5repack/testfiles/h5repack_filters.h5-gzip_verbose_filters.tst
+++ b/tools/test/h5repack/testfiles/h5repack_filters.h5-gzip_verbose_filters.tst
@@ -1,5 +1,5 @@
-Objects to modify layout are...
-Objects to apply filter are...
+No all objects to modify layout
+No all objects to apply filter
</dset_deflate> with GZIP filter
</dset_deflate>...Found
-----------------------------------------