summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_copy.c
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2017-07-06 19:16:57 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2017-07-06 19:16:57 (GMT)
commit23a702e7bad93fc4f14eab07678c75d276e2d0ad (patch)
treeafb57ddaeca17021342fa09b8999c15569630e71 /tools/h5repack/h5repack_copy.c
parent03dbcb75918b2cbf39800d9edf5665d3471a1fee (diff)
parentc15238a38fdb3692466bc1218de4c5aeb420fdcc (diff)
downloadhdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.zip
hdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.tar.gz
hdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.tar.bz2
Merge pull request #593 in HDFFV/hdf5 from hdf5_1_8_19 to 1.8/masterhdf5-1_8_19
* commit 'c15238a38fdb3692466bc1218de4c5aeb420fdcc': (153 commits) Commit changes to release version strings in README.txt and RELEASE.txt from release. Put back link targets for dynamically loaded libraries in Makefile.ams that avoid linking with libhdf5 dependencies. Some configurations failed unnecessarily to find and link with lz and lsz when these targets were removed. Update URL for obtaining source inINSTALL file. Disable building of libdynlib* dynamically loaded plugin test libraries on CYGWIN. Added known problem entry to RELEASE.txt. Set version for 1.8.19 release. Barbara updated contents of README.txt file. Moved libdynlib* plugin test libraries to noist_LT_LIBRARIES with added flag '-rpath /nowhere' to stop them being installed while keeping them from linking with libhdf5, etc. Incremented version to 1.8.19-pre1 and ran bin/release to create tar and zip files for testing. HDF5 1.8.19-pre1 released. Add RELEASE.txt entry for H5Dget_chunk_size. Remove test entries Ran bin/reconfigure after so number change. Update hl lib .so numbers: new function was added. Update RELEASE.txt: move H5DOread_chunks entry to new features, clarify entry for HDFFV-10051. Updated notes for test fixes and added bug fix for h5diff help text. Update h5vers and release scripts for 1.8.19 branch, set version to 1.8.19-pre1. Make script name consistent across product versions Update version to 1.8.19-pre1. Propagate .so number changes to Makefile.ins with bin/reconfigure. Add toolset option Update so version numbers according to the interface compatibility report. Update supported Platforms section. Remove empty sub-sections of New Features and Bugs Fixed sections. Add entries for HDFFV-10051 and HDFFV-9934 to RELEASE.txt. Correct spelling ...
Diffstat (limited to 'tools/h5repack/h5repack_copy.c')
-rw-r--r--tools/h5repack/h5repack_copy.c133
1 files changed, 70 insertions, 63 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 9573ee8..b41f7be 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
@@ -76,36 +74,28 @@ static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t
/*-------------------------------------------------------------------------
* Function: copy_objects
*
- * Purpose: duplicate all HDF5 objects in the file
+ * Purpose: duplicate all HDF5 objects in the file
*
- * Return: 0, ok, -1 no
+ * Return: 0, ok,
+ * -1 no
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: October, 23, 2003
*
- * Modification:
- * Peter Cao, June 13, 2007
- * Add "-L, --latest" and other options to pack a file with the latest file format
- *
- * Peter Cao, September 25, 2007
- * Copy user block when repacking a file
- *
- * Pedro Vicente, August 20, 2008
- * Add a user block to file if requested
- *
*-------------------------------------------------------------------------
*/
int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t fidin;
- hid_t fidout = -1;
- trav_table_t *travt = NULL;
- hsize_t ub_size = 0; /* size of user block */
- hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
- hid_t fapl = H5P_DEFAULT; /* file access property list ID */
+ int ret_value = 0; /* no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ hid_t fidin;
+ hid_t fidout = -1;
+ trav_table_t *travt = NULL;
+ hsize_t ub_size = 0; /* size of user block */
+ hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
+ hid_t fapl = H5P_DEFAULT; /* file access property list ID */
+ unsigned crt_order_flags; /* group creation order flag */
/*-------------------------------------------------------------------------
* open input file
@@ -119,6 +109,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
/* get user block size and file space strategy/threshold */
{
hid_t fcpl_in; /* file creation property list ID for input file */
+ hid_t grp_in = -1; /* group ID */
+ hid_t gcpl_in = -1; /* group creation property list */
if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
error_msg("failed to retrieve file creation property list\n");
@@ -130,6 +122,18 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
+ /* open root group */
+ if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+
+ /* get root group creation property list */
+ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+
+ /* query and set the group creation properties */
+ 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) {
error_msg("failed to close property list\n");
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
@@ -300,6 +304,9 @@ print_user_block(fnamein, fidin);
}
}
+ if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed");
+
/*-------------------------------------------------------------------------
* create the output file
*-------------------------------------------------------------------------
@@ -328,6 +335,8 @@ print_user_block(fnamein, fidin);
*-------------------------------------------------------------------------
*/
+ /* Initialize indexing options */
+ h5trav_set_index(sort_by, sort_order);
/* init table */
trav_table_init(&travt);
@@ -444,10 +453,10 @@ done:
int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- int k;
+ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ int k;
H5D_layout_t dset_layout;
- int rank_chunk;
+ int rank_chunk;
hsize_t dims_chunk[H5S_MAX_RANK];
hsize_t size_chunk = 1;
hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
@@ -662,33 +671,33 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t grp_in = -1; /* group ID */
- hid_t grp_out = -1; /* group ID */
- hid_t dset_in = -1; /* read dataset ID */
+ hid_t grp_in = -1; /* group ID */
+ hid_t grp_out = -1; /* group ID */
+ hid_t dset_in = -1; /* read dataset ID */
hid_t dset_out = -1; /* write dataset ID */
- hid_t gcpl_in = -1; /* group creation property list */
+ hid_t gcpl_in = -1; /* group creation property list */
hid_t gcpl_out = -1; /* group creation property list */
- hid_t type_in = -1; /* named type ID */
+ hid_t type_in = -1; /* named type ID */
hid_t type_out = -1; /* named type ID */
- hid_t dcpl_in = -1; /* dataset creation property list ID */
+ hid_t dcpl_in = -1; /* dataset creation property list ID */
hid_t dcpl_out = -1; /* dataset creation property list ID */
hid_t f_space_id = -1; /* file space ID */
hid_t ftype_id = -1; /* file type ID */
hid_t wtype_id = -1; /* read/write type ID */
named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
- size_t msize; /* size of type */
- hsize_t nelmts; /* number of elements in dataset */
+ size_t msize; /* size of type */
+ hsize_t nelmts; /* number of elements in dataset */
H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */
- int rank; /* rank of dataset */
+ int rank; /* rank of dataset */
hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
- hsize_t dsize_in; /* input dataset size before filter */
- hsize_t dsize_out; /* output dataset size after filter */
- int apply_s; /* flag for apply filter to small dataset sizes */
- int apply_f; /* flag for apply filter to return error on H5Dcreate */
- void *buf = NULL; /* buffer for raw data */
+ hsize_t dsize_in; /* input dataset size before filter */
+ hsize_t dsize_out; /* output dataset size after filter */
+ int apply_s; /* flag for apply filter to small dataset sizes */
+ int apply_f; /* flag for apply filter to return error on H5Dcreate */
+ void *buf = NULL; /* buffer for raw data */
void *hslab_buf = NULL; /* hyperslab buffer for raw data */
- int has_filter; /* current object has a filter */
- int req_filter; /* there was a request for a filter */
+ int has_filter; /* current object has a filter */
+ int req_filter; /* there was a request for a filter */
int req_obj_layout = 0; /* request layout to current object */
unsigned crt_order_flags; /* group creation order flag */
unsigned i;
@@ -869,7 +878,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
/* wtype_id will have already been set if using a named dtype */
if (!is_named) {
if (options->use_native == 1)
- wtype_id = h5tools_get_native_type(ftype_id);
+ wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT);
else
wtype_id = H5Tcopy(ftype_id);
} /* end if */
@@ -1303,20 +1312,19 @@ done:
*
*-------------------------------------------------------------------------
*/
-static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio,
- int pr)
+static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
{
- char strfilter[255];
+ char strfilter[255];
#if defined (PRINT_DEBUG )
- char temp[255];
+ char temp[255];
#endif
- int nfilters; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- char f_objname[256]; /* filter objname */
- int i;
+ int nfilters; /* number of filters */
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ char f_objname[256]; /* filter objname */
+ int i;
HDstrcpy(strfilter, "\0");
@@ -1415,10 +1423,9 @@ static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio,
*
*-------------------------------------------------------------------------
*/
-static int copy_user_block(const char *infile, const char *outfile,
- hsize_t size)
+static int copy_user_block(const char *infile, const char *outfile, hsize_t size)
{
- 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) */
int infid = -1, outfid = -1; /* File descriptors */
/* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */
@@ -1495,12 +1502,12 @@ done:
static
void print_user_block(const char *filename, hid_t fid)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- int fh; /* file handle */
+ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ int fh; /* file handle */
hsize_t ub_size; /* user block size */
hsize_t size; /* size read */
- hid_t fcpl; /* file creation property list ID for HDF5 file */
- int i;
+ hid_t fcpl; /* file creation property list ID for HDF5 file */
+ int i;
/* get user block size */
if(( fcpl = H5Fget_create_plist(fid)) < 0) {