summaryrefslogtreecommitdiffstats
path: root/tools/src/h5repack
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/h5repack')
-rw-r--r--tools/src/h5repack/h5repack.c225
-rw-r--r--tools/src/h5repack/h5repack.h199
-rw-r--r--tools/src/h5repack/h5repack_copy.c1485
-rw-r--r--tools/src/h5repack/h5repack_filters.c311
-rw-r--r--tools/src/h5repack/h5repack_main.c410
-rw-r--r--tools/src/h5repack/h5repack_opttable.c106
-rw-r--r--tools/src/h5repack/h5repack_parse.c314
-rw-r--r--tools/src/h5repack/h5repack_refs.c546
-rw-r--r--tools/src/h5repack/h5repack_verify.c366
9 files changed, 2015 insertions, 1947 deletions
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index 4fd163c..a1764df 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -22,10 +22,10 @@
*-------------------------------------------------------------------------
*/
-static int check_options(pack_opt_t *options);
-static int check_objects(const char* fname, pack_opt_t *options);
-static const char* get_sfilter(H5Z_filter_t filtn);
-static int have_request(pack_opt_t *options);
+static int check_options(pack_opt_t *options);
+static int check_objects(const char *fname, pack_opt_t *options);
+static const char *get_sfilter(H5Z_filter_t filtn);
+static int have_request(pack_opt_t *options);
/*-------------------------------------------------------------------------
* Function: h5repack
@@ -42,7 +42,7 @@ static int have_request(pack_opt_t *options);
*-------------------------------------------------------------------------
*/
int
-h5repack(const char* infile, const char* outfile, pack_opt_t *options)
+h5repack(const char *infile, const char *outfile, pack_opt_t *options)
{
/* check input */
if (check_options(options) < 0)
@@ -73,17 +73,17 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest)
int k, n;
HDmemset(options, 0, sizeof(pack_opt_t));
- options->min_comp = 0;
- options->verbose = verbose;
- options->latest = latest;
- options->layout_g = H5D_LAYOUT_ERROR;
- options->low_bound = H5F_LIBVER_EARLIEST;
+ options->min_comp = 0;
+ options->verbose = verbose;
+ options->latest = latest;
+ options->layout_g = H5D_LAYOUT_ERROR;
+ options->low_bound = H5F_LIBVER_EARLIEST;
options->high_bound = H5F_LIBVER_LATEST;
- options->fin_fapl = H5P_DEFAULT;
- options->fout_fapl = H5P_DEFAULT;
+ options->fin_fapl = H5P_DEFAULT;
+ options->fout_fapl = H5P_DEFAULT;
for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) {
- options->filter_g[n].filtn = -1;
+ options->filter_g[n].filtn = -1;
options->filter_g[n].cd_nelmts = 0;
for (k = 0; k < CD_VALUES; k++)
options->filter_g[n].cd_values[k] = 0;
@@ -117,7 +117,7 @@ h5repack_end(pack_opt_t *options)
int
h5repack_addfilter(const char *str, pack_opt_t *options)
{
- obj_list_t *obj_list = NULL; /* one object list for the -f and -l option entry */
+ obj_list_t * obj_list = NULL; /* one object list for the -f and -l option entry */
filter_info_t filter; /* filter info for the current -f option entry */
unsigned n_objs; /* number of objects in the current -f or -l option entry */
int is_glb; /* is the filter global */
@@ -166,7 +166,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options)
init_packobject(&pack);
if (options->all_layout == 1) {
- error_msg( "invalid layout input: 'all' option is present with other objects <%s>\n", str);
+ error_msg("invalid layout input: 'all' option is present with other objects <%s>\n", str);
return ret_value;
}
@@ -222,13 +222,14 @@ h5repack_addlayout(const char *str, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
hid_t
-copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options)
+copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt,
+ pack_opt_t *options)
{
- named_dt_t *dt = *named_dt_head_p; /* Stack pointer */
- named_dt_t *dt_ret = NULL; /* Datatype to return */
- H5O_info2_t oinfo; /* Object info of input dtype */
- int token_cmp;
- hid_t ret_value = H5I_INVALID_HID;
+ named_dt_t *dt = *named_dt_head_p; /* Stack pointer */
+ named_dt_t *dt_ret = NULL; /* Datatype to return */
+ H5O_info2_t oinfo; /* Object info of input dtype */
+ int token_cmp;
+ hid_t ret_value = H5I_INVALID_HID;
if (H5Oget_info3(type_in, &oinfo, H5O_INFO_BASIC) < 0)
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Oget_info failed");
@@ -256,7 +257,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
/* Push onto the stack */
if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t))))
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed");
- dt->next = *named_dt_head_p;
+ dt->next = *named_dt_head_p;
*named_dt_head_p = dt;
/* Update the token/address and id */
@@ -269,8 +270,8 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
if (!token_cmp)
dt_ret = dt;
} /* end if named datatype */
- } /* end for each object in traversal table */
- } /* end else (create the stack) */
+ } /* end for each object in traversal table */
+ } /* end else (create the stack) */
/* Handle the case that the requested datatype was not found. This is
* possible if the datatype was committed anonymously in the input file.
@@ -279,7 +280,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
/* Push the new datatype onto the stack */
if (NULL == (dt_ret = (named_dt_t *)HDmalloc(sizeof(named_dt_t))))
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed");
- dt_ret->next = *named_dt_head_p;
+ dt_ret->next = *named_dt_head_p;
*named_dt_head_p = dt_ret;
/* Update the token/address and id */
@@ -323,8 +324,8 @@ done:
int
named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err)
{
- named_dt_t *dt = *named_dt_head_p;
- int ret_value = -1;
+ named_dt_t *dt = *named_dt_head_p;
+ int ret_value = -1;
while (dt) {
/* Pop the datatype off the stack and free it */
@@ -355,24 +356,24 @@ done:
int
copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options)
{
- hid_t attr_id = H5I_INVALID_HID; /* attr ID */
+ hid_t attr_id = H5I_INVALID_HID; /* attr ID */
hid_t attr_out = H5I_INVALID_HID; /* attr ID */
hid_t space_id = H5I_INVALID_HID; /* space ID */
hid_t ftype_id = H5I_INVALID_HID; /* file type ID */
hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */
- size_t msize; /* size of type */
- void *buf = NULL; /* data buffer */
- hsize_t nelmts; /* number of elements in dataset */
- int rank; /* rank of dataset */
- htri_t is_named; /* Whether the datatype is named */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
+ size_t msize; /* size of type */
+ void * buf = NULL; /* data buffer */
+ hsize_t nelmts; /* number of elements in dataset */
+ int rank; /* rank of dataset */
+ htri_t is_named; /* Whether the datatype is named */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
char name[255];
- H5O_info2_t oinfo; /* object info */
+ H5O_info2_t oinfo; /* object info */
int j;
unsigned u;
- hbool_t is_ref = 0;
+ hbool_t is_ref = 0;
H5T_class_t type_class = -1;
- int ret_value = 0;
+ int ret_value = 0;
if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed");
@@ -381,12 +382,13 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
* copy all attributes
*-------------------------------------------------------------------------
*/
- for (u = 0; u < (unsigned) oinfo.num_attrs; u++) {
+ for (u = 0; u < (unsigned)oinfo.num_attrs; u++) {
/* open attribute */
- if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed");
- if (H5Aget_name(attr_id, (size_t) 255, name) < 0)
+ if (H5Aget_name(attr_id, (size_t)255, name) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
/* get the file datatype */
@@ -442,12 +444,12 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
*---------------------------------------------------------------------
*/
type_class = H5Tget_class(wtype_id);
- is_ref = (type_class == H5T_REFERENCE);
+ is_ref = (type_class == H5T_REFERENCE);
if (type_class == H5T_VLEN || type_class == H5T_ARRAY) {
hid_t base_type = H5I_INVALID_HID;
base_type = H5Tget_super(ftype_id);
- is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE));
+ is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE));
if (H5Tclose(base_type) < 0)
H5TOOLS_ERROR((-1), "H5Tclose base_type failed");
} /* end if type_class is variable length or array */
@@ -456,7 +458,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
int nmembers = H5Tget_nmembers(wtype_id);
for (j = 0; j < nmembers; j++) {
- hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j);
+ hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j);
H5T_class_t mtclass = H5Tget_class(mtid);
if (H5Tclose(mtid) < 0)
H5TOOLS_ERROR((-1), "H5Tclose mtid failed");
@@ -466,7 +468,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
break;
}
} /* end for each member */
- } /* end if type_class is H5T_COMPOUND */
+ } /* end if type_class is H5T_COMPOUND */
if (!is_ref) {
/*-----------------------------------------------------------------
@@ -525,7 +527,8 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
} /* for u (each attribute) */
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
if (buf) {
/* Check if we have VL data and string in the attribute's
* datatype that must be reclaimed
@@ -542,7 +545,8 @@ done:
H5Tclose(wtype_id);
H5Tclose(ftype_id);
H5Aclose(attr_id);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
} /* end copy_attr() */
@@ -571,31 +575,31 @@ check_options(pack_opt_t *options)
if (options->all_layout == 1) {
HDprintf("All objects to modify layout are...\n");
switch (options->layout_g) {
- case H5D_COMPACT:
- strcpy(slayout, "compact");
- break;
- case H5D_CONTIGUOUS:
- strcpy(slayout, "contiguous");
- break;
- case H5D_CHUNKED:
- strcpy(slayout, "chunked");
- break;
- case H5D_VIRTUAL:
- strcpy(slayout, "virtual");
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_NLAYOUTS:
- H5TOOLS_GOTO_ERROR((-1), "invalid layout");
- break;
- default:
- strcpy(slayout, "invalid layout\n");
- H5TOOLS_GOTO_DONE((-1));
+ case H5D_COMPACT:
+ strcpy(slayout, "compact");
+ break;
+ case H5D_CONTIGUOUS:
+ strcpy(slayout, "contiguous");
+ break;
+ case H5D_CHUNKED:
+ strcpy(slayout, "chunked");
+ break;
+ case H5D_VIRTUAL:
+ strcpy(slayout, "virtual");
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
+ H5TOOLS_GOTO_ERROR((-1), "invalid layout");
+ break;
+ default:
+ strcpy(slayout, "invalid layout\n");
+ H5TOOLS_GOTO_DONE((-1));
}
HDprintf(" Apply %s layout to all", slayout);
if (H5D_CHUNKED == options->layout_g) {
HDprintf("with dimension [ ");
for (j = 0; j < options->chunk_g.rank; j++)
- HDprintf("%d ", (int) options->chunk_g.chunk_lengths[j]);
+ HDprintf("%d ", (int)options->chunk_g.chunk_lengths[j]);
HDprintf("]");
}
HDprintf("\n");
@@ -605,13 +609,13 @@ check_options(pack_opt_t *options)
} /* end if verbose */
for (i = 0; i < options->op_tbl->nelems; i++) {
- char* name = options->op_tbl->objs[i].path;
+ char *name = options->op_tbl->objs[i].path;
if (options->op_tbl->objs[i].chunk.rank > 0) {
if (options->verbose) {
HDprintf(" <%s> with chunk size ", name);
for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++)
- HDprintf("%d ", (int) options->op_tbl->objs[i].chunk.chunk_lengths[k]);
+ HDprintf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]);
HDprintf("\n");
}
has_ck = 1;
@@ -641,36 +645,38 @@ check_options(pack_opt_t *options)
continue;
}
switch (filtn) {
- case H5Z_FILTER_NONE:
- HDprintf(" Uncompress all\n");
- break;
- case H5Z_FILTER_SHUFFLE:
- case H5Z_FILTER_FLETCHER32:
- HDprintf(" All with %s\n", get_sfilter(filtn));
- break;
- case H5Z_FILTER_SZIP:
- case H5Z_FILTER_DEFLATE:
- HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn), options->filter_g[k].cd_values[0]);
- break;
- default:
- HDprintf(" User Defined %d\n", filtn);
- break;
+ case H5Z_FILTER_NONE:
+ HDprintf(" Uncompress all\n");
+ break;
+ case H5Z_FILTER_SHUFFLE:
+ case H5Z_FILTER_FLETCHER32:
+ HDprintf(" All with %s\n", get_sfilter(filtn));
+ break;
+ case H5Z_FILTER_SZIP:
+ case H5Z_FILTER_DEFLATE:
+ HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn),
+ options->filter_g[k].cd_values[0]);
+ break;
+ default:
+ HDprintf(" User Defined %d\n", filtn);
+ break;
} /* end switch */
- } /* end for each filter */
- } /* end if options->all_filter == 1 (TODO: meaning) */
+ } /* end for each filter */
+ } /* end if options->all_filter == 1 (TODO: meaning) */
else
HDprintf("No all objects to apply filter\n");
} /* end if verbose */
for (i = 0; i < options->op_tbl->nelems; i++) {
pack_info_t pack = options->op_tbl->objs[i];
- char* name = pack.path;
+ char * name = pack.path;
for (j = 0; j < pack.nfilters; j++) {
if (options->verbose) {
if (pack.filter[j].filtn >= 0) {
if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) {
- HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), pack.filter[j].filtn);
+ HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn),
+ pack.filter[j].filtn);
}
else {
HDprintf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn));
@@ -679,7 +685,7 @@ check_options(pack_opt_t *options)
}
has_cp = 1;
} /* end for each filter */
- } /* end for each object in options table */
+ } /* end for each object in options table */
if (options->all_filter == 1 && has_cp)
H5TOOLS_GOTO_ERROR((-1), "invalid compression input: 'all' option is present with other objects");
@@ -705,7 +711,8 @@ check_options(pack_opt_t *options)
*/
if (options->ublock_filename != NULL && options->ublock_size == 0) {
if (options->verbose) {
- HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename);
+ HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n",
+ options->ublock_filename);
options->ublock_size = 1024;
}
}
@@ -735,14 +742,14 @@ done:
*-------------------------------------------------------------------------
*/
static int
-check_objects(const char* fname, pack_opt_t *options)
+check_objects(const char *fname, pack_opt_t *options)
{
hid_t fid = H5I_INVALID_HID;
hid_t did = H5I_INVALID_HID;
hid_t sid = H5I_INVALID_HID;
unsigned int i;
int ifil;
- trav_table_t *travt = NULL;
+ trav_table_t *travt = NULL;
int ret_value = 0;
/* nothing to do */
@@ -754,7 +761,7 @@ check_objects(const char* fname, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl,
- (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0)
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR);
/*-------------------------------------------------------------------------
@@ -780,8 +787,8 @@ check_objects(const char* fname, pack_opt_t *options)
HDprintf("Opening file. Searching %zu objects to modify ...\n", travt->nobjs);
for (i = 0; i < options->op_tbl->nelems; i++) {
- pack_info_t obj = options->op_tbl->objs[i];
- char* name = obj.path;
+ pack_info_t obj = options->op_tbl->objs[i];
+ char * name = obj.path;
if (options->verbose)
HDprintf(" <%s>", name);
@@ -789,7 +796,7 @@ check_objects(const char* fname, pack_opt_t *options)
/* the input object names are present in the file and are valid */
if (h5trav_getindext(name, travt) < 0)
H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n",
- (options->verbose ? "\n" : ""), name, fname);
+ (options->verbose ? "\n" : ""), name, fname);
if (options->verbose)
HDprintf("...Found\n");
@@ -798,14 +805,13 @@ check_objects(const char* fname, pack_opt_t *options)
H5TOOLS_GOTO_ERROR((-1), "invalid filter");
/* check for extra filter conditions */
switch (obj.filter[ifil].filtn) {
- /* chunk size must be smaller than pixels per block */
- case H5Z_FILTER_SZIP:
- {
- int j;
- hsize_t csize = 1;
- unsigned ppb = obj.filter[ifil].cd_values[0];
- hsize_t dims[H5S_MAX_RANK];
- int rank;
+ /* chunk size must be smaller than pixels per block */
+ case H5Z_FILTER_SZIP: {
+ int j;
+ hsize_t csize = 1;
+ unsigned ppb = obj.filter[ifil].cd_values[0];
+ hsize_t dims[H5S_MAX_RANK];
+ int rank;
if (obj.chunk.rank > 0) {
rank = obj.chunk.rank;
@@ -836,18 +842,20 @@ check_objects(const char* fname, pack_opt_t *options)
}
} /* end case SZIP */
break;
- default:
- break;
+ default:
+ break;
} /* end switch */
- } /* for ifil (each user-defined filter) */
- } /* for i (each object in options traversal table) */
+ } /* for ifil (each user-defined filter) */
+ } /* for i (each object in options traversal table) */
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
if (travt)
trav_table_free(travt);
return ret_value;
@@ -901,4 +909,3 @@ get_sfilter(H5Z_filter_t filtn)
else
return "UD";
} /* end get_sfilter() */
-
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index b124fdb..bcab1be 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -11,7 +11,6 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#ifndef H5REPACK_H__
#define H5REPACK_H__
@@ -19,21 +18,20 @@
#include "hdf5.h"
#include "h5trav.h"
-#define H5FOPENERROR "unable to open file"
-#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/
-#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/
-#define MAX_NC_NAME 256 /* max length of a name */
-#define MAX_VAR_DIMS 32 /* max per variable dimensions */
-#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */
-#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
-#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */
+#define H5FOPENERROR "unable to open file"
+#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/
+#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/
+#define MAX_NC_NAME 256 /* max length of a name */
+#define MAX_VAR_DIMS 32 /* max per variable dimensions */
+#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */
+#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
+#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_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
-#define FS_PERSIST_DEF FALSE
-#define FS_THRESHOLD_DEF 1
-
+#define FS_PAGESIZE_DEF 4096
+#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
+#define FS_PERSIST_DEF FALSE
+#define FS_THRESHOLD_DEF 1
/*-------------------------------------------------------------------------
* data structures for command line options
@@ -42,7 +40,7 @@
/* a list of names */
typedef struct {
- char obj[MAX_NC_NAME];
+ char obj[MAX_NC_NAME];
} obj_list_t;
/*
@@ -60,16 +58,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,22 +76,21 @@ 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;
-
/*-------------------------------------------------------------------------
* command line options
*-------------------------------------------------------------------------
@@ -101,43 +98,42 @@ 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 */
- hbool_t merge; /* Merge external file. */
- hbool_t prune; /* Don't follow external file. */
- 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 */
- H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */
- H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */
- hid_t fin_fapl; /* FAPL to use for opening the input file */
- hid_t fout_fapl; /* FAPL to use for opening/creating the output file */
- 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 */
+ hbool_t merge; /* Merge external file. */
+ hbool_t prune; /* Don't follow external file. */
+ 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 */
+ H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */
+ H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */
+ hid_t fin_fapl; /* FAPL to use for opening the input file */
+ hid_t fout_fapl; /* FAPL to use for opening/creating the output file */
+ 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;
-
typedef struct named_dt_t {
- H5O_token_t obj_token; /* Object token for the named dtype in the in file */
- hid_t id_out; /* Open identifier for the dtype in the out file */
- struct named_dt_t *next; /* Next dtype */
+ H5O_token_t obj_token; /* Object token for the named dtype in the in file */
+ hid_t id_out; /* Open identifier for the dtype in the out file */
+ struct named_dt_t *next; /* Next dtype */
} named_dt_t;
/*-------------------------------------------------------------------------
@@ -149,9 +145,9 @@ typedef struct named_dt_t {
extern "C" {
#endif
-int h5repack(const char* infile, const char* outfile, pack_opt_t *options);
-int h5repack_addfilter(const char* str, pack_opt_t *options);
-int h5repack_addlayout(const char* str, pack_opt_t *options);
+int h5repack(const char *infile, const char *outfile, pack_opt_t *options);
+int h5repack_addfilter(const char *str, pack_opt_t *options);
+int h5repack_addlayout(const char *str, pack_opt_t *options);
int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest);
int h5repack_end(pack_opt_t *options);
int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options);
@@ -164,36 +160,29 @@ int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, h
* However copy_attr() may be obsoleted when H5Acopy is available and put back
* others to static in h5repack_copy.c.
*/
-hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options);
-int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err);
-int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p,
- trav_table_t *travt, pack_opt_t *options);
+hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt,
+ pack_opt_t *options);
+int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err);
+int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt,
+ pack_opt_t *options);
#ifdef __cplusplus
}
#endif
-
-
/*-------------------------------------------------------------------------
* private functions
*-------------------------------------------------------------------------
*/
-
/*-------------------------------------------------------------------------
* copy module
*-------------------------------------------------------------------------
*/
-int copy_objects (const char* fnamein,
- const char* fnameout,
- pack_opt_t *options);
+int copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options);
-int do_copy_refobjs(hid_t fidin,
- hid_t fidout,
- trav_table_t *travt,
- pack_opt_t *options);
+int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options);
/*-------------------------------------------------------------------------
* filters and verify module
@@ -201,56 +190,38 @@ int do_copy_refobjs(hid_t fidin,
*/
void init_packobject(pack_info_t *obj);
-
/*-------------------------------------------------------------------------
* filters and copy module
*-------------------------------------------------------------------------
*/
-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 */
+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 * has_filter); /* (OUT) object NAME has a filter */
/*-------------------------------------------------------------------------
* 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
*-------------------------------------------------------------------------
*/
-obj_list_t* parse_filter(const char *str,
- unsigned *n_objs,
- filter_info_t *filt,
- pack_opt_t *options,
+obj_list_t *parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options,
int *is_glb);
-obj_list_t* parse_layout(const char *str,
- unsigned *n_objs,
- pack_info_t *pack, /* info about object */
+obj_list_t *parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about object */
pack_opt_t *options);
-
-
-
-#endif /* H5REPACK_H__ */
-
+#endif /* H5REPACK_H__ */
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index 8f3496f..d2b0097 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -31,24 +31,21 @@
*/
/* size of buffer/# of bytes to xfer at a time when copying userblock */
-#define USERBLOCK_XFER_SIZE 512
+#define USERBLOCK_XFER_SIZE 512
/*-------------------------------------------------------------------------
* local functions
*-------------------------------------------------------------------------
*/
-static 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);
+static 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);
static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr);
-static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
- pack_opt_t *options);
-static int copy_user_block(const char *infile, const char *outfile,
- hsize_t size);
-#if defined (H5REPACK_DEBUG_USER_BLOCK)
+static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options);
+static int copy_user_block(const char *infile, const char *outfile, hsize_t size);
+#if defined(H5REPACK_DEBUG_USER_BLOCK)
static void print_user_block(const char *filename, hid_t fid);
#endif
-
/*-------------------------------------------------------------------------
* Function: copy_objects
*
@@ -59,33 +56,33 @@ static void print_user_block(const char *filename, hid_t fid);
*-------------------------------------------------------------------------
*/
int
-copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
+copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options)
{
- hid_t fidin = H5I_INVALID_HID;
- hid_t fidout = H5I_INVALID_HID;
- hid_t fcpl_in = H5I_INVALID_HID; /* file creation property list ID for input file */
- hid_t grp_in = H5I_INVALID_HID; /* group ID */
- hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
- hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
- trav_table_t *travt = NULL;
- hsize_t ub_size = 0; /* size of user block */
- H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */
- hbool_t set_persist; /* Persist free-space status to be set in output file */
- hsize_t set_threshold; /* Free-space section threshold to be set in output file */
- hsize_t set_pagesize; /* File space page size to be set in output file */
- H5F_fspace_strategy_t in_strategy; /* Strategy from input file */
- hbool_t in_persist; /* Persist free-space status from input file */
- hsize_t in_threshold; /* Free-space section threshold from input file */
- hsize_t in_pagesize; /* File space page size from input file */
- unsigned crt_order_flags; /* group creation order flag */
- int ret_value = 0;
+ hid_t fidin = H5I_INVALID_HID;
+ hid_t fidout = H5I_INVALID_HID;
+ hid_t fcpl_in = H5I_INVALID_HID; /* file creation property list ID for input file */
+ hid_t grp_in = H5I_INVALID_HID; /* group ID */
+ hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
+ hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
+ trav_table_t * travt = NULL;
+ hsize_t ub_size = 0; /* size of user block */
+ H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */
+ hbool_t set_persist; /* Persist free-space status to be set in output file */
+ hsize_t set_threshold; /* Free-space section threshold to be set in output file */
+ hsize_t set_pagesize; /* File space page size to be set in output file */
+ H5F_fspace_strategy_t in_strategy; /* Strategy from input file */
+ hbool_t in_persist; /* Persist free-space status from input file */
+ hsize_t in_threshold; /* Free-space section threshold from input file */
+ hsize_t in_pagesize; /* File space page size from input file */
+ unsigned crt_order_flags; /* group creation order flag */
+ int ret_value = 0;
/*-------------------------------------------------------------------------
* open input file
*-------------------------------------------------------------------------
*/
if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl,
- (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t) 0)) < 0)
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t)0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR);
/* get user block size and file space strategy/persist/threshold */
@@ -97,11 +94,11 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
H5TOOLS_GOTO_ERROR((-1), "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)
H5TOOLS_GOTO_ERROR((-1), "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)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space threshold");
/* open root group */
@@ -120,7 +117,7 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list");
}
- if(options->latest)
+ if (options->latest)
options->low_bound = options->high_bound = H5F_LIBVER_LATEST;
/* Create file access property list */
@@ -129,7 +126,7 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
/* It can be default, latest or other settings by users */
- if(H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0)
+ if (H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds");
/* Check if we need to create a non-default file creation property list */
@@ -147,8 +144,11 @@ 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)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed to adjust group creation parameters for root group");
+ if (H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact,
+ (unsigned)options->grp_indexed) < 0)
+ H5TOOLS_GOTO_ERROR(
+ (-1),
+ "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) {
@@ -176,26 +176,28 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
default:
break;
} /* end switch */
- min_mesg_sizes[nindex] = (unsigned) options->msg_size[i];
+ min_mesg_sizes[nindex] = (unsigned)options->msg_size[i];
nindex++;
} /* end if */
- } /* end for */
+ } /* end for */
if (nindex > 0) {
if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes");
+ H5TOOLS_GOTO_ERROR((-1), "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)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_index failed to configure the specified shared object header message index");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_index failed to configure the specified "
+ "shared object header message index");
} /* if (nindex>0) */
} /* end if */
- } /* end if */
-#if defined (H5REPACK_DEBUG_USER_BLOCK)
-print_user_block(fnamein, fidin);
+ } /* end if */
+#if defined(H5REPACK_DEBUG_USER_BLOCK)
+ print_user_block(fnamein, fidin);
#endif
/*-------------------------------------------------------------------------
@@ -255,41 +257,41 @@ print_user_block(fnamein, fidin);
if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list");
- if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0)
+ if (H5Pset_link_creation_order(fcpl, crt_order_flags) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed");
/* Set file space info to those from input file */
- set_strategy = in_strategy;
- set_persist = in_persist;
+ set_strategy = in_strategy;
+ set_persist = in_persist;
set_threshold = in_threshold;
- set_pagesize = in_pagesize;
+ set_pagesize = in_pagesize;
- if(options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */
+ if (options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */
set_strategy = FS_STRATEGY_DEF;
- else if(options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */
+ else if (options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */
set_strategy = options->fs_strategy;
- if(options->fs_persist == -1) /* A default "persist" is specified by user */
+ if (options->fs_persist == -1) /* A default "persist" is specified by user */
set_persist = FS_PERSIST_DEF;
- else if(options->fs_persist != 0) /* Set "persist" as specified by user */
+ else if (options->fs_persist != 0) /* Set "persist" as specified by user */
set_persist = (hbool_t)options->fs_persist;
- if(options->fs_threshold == -1) /* A "0" threshold is specified by user */
+ if (options->fs_threshold == -1) /* A "0" threshold is specified by user */
set_threshold = (hsize_t)0;
- else if(options->fs_threshold != 0) /* Set threshold as specified by user */
+ else if (options->fs_threshold != 0) /* Set threshold as specified by user */
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)
H5TOOLS_GOTO_ERROR((-1), "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 */
+ if (options->fs_pagesize == -1) /* A "0" file space page size is specified by user */
set_pagesize = (hsize_t)0;
- else if(options->fs_pagesize != 0) /* Set file space page size as specified by user */
+ else if (options->fs_pagesize != 0) /* Set file space page size as specified by user */
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 (set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */
+ if (H5Pset_file_space_page_size(fcpl, set_pagesize) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_page_size failed to set file space page size");
/*-------------------------------------------------------------------------
@@ -326,19 +328,21 @@ print_user_block(fnamein, fidin);
H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
/*-------------------------------------------------------------------------
- * do the copy
- *-------------------------------------------------------------------------
- */
+ * do the copy
+ *-------------------------------------------------------------------------
+ */
if (do_copy_objects(fidin, fidout, travt, options) < 0)
- H5TOOLS_GOTO_ERROR((-1), "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout);
+ H5TOOLS_GOTO_ERROR((-1), "do_copy_objects from <%s> could not copy data to <%s>", fnamein,
+ fnameout);
/*-------------------------------------------------------------------------
- * do the copy of referenced objects
- * and create hard links
- *-------------------------------------------------------------------------
- */
+ * do the copy of referenced objects
+ * and create hard links
+ *-------------------------------------------------------------------------
+ */
if (do_copy_refobjs(fidin, fidout, travt, options) < 0)
- H5TOOLS_GOTO_ERROR((-1), "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout);
+ H5TOOLS_GOTO_ERROR((-1), "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein,
+ fnameout);
}
/*-------------------------------------------------------------------------
@@ -351,7 +355,8 @@ print_user_block(fnamein, fidin);
H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting...");
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(fcpl_in);
H5Pclose(gcpl_in);
H5Pclose(fcpl);
@@ -360,7 +365,8 @@ done:
H5Fclose(fidout);
H5Fclose(fidin);
H5Fclose(fidout);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
if (travt)
trav_table_free(travt);
@@ -400,20 +406,20 @@ 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)
+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 k;
+ int k;
H5D_layout_t dset_layout;
- 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) */
- hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
- hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */
- hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */
- hsize_t hslab_nbytes; /* size of hyperslab in byte */
- int ret_value = 0;
+ 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) */
+ hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
+ hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */
+ hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */
+ hsize_t hslab_nbytes; /* size of hyperslab in byte */
+ int ret_value = 0;
/* init to set as size of a data element */
hslab_nbytes = size_datum;
@@ -452,7 +458,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
chunk_dims_map[k - 1]++;
/* get mapped hyperslab dims */
- hs_dims_map[k - 1] = MIN (nchunk_fit, chunk_dims_map[k-1]);
+ hs_dims_map[k - 1] = MIN(nchunk_fit, chunk_dims_map[k - 1]);
/* prepare next round */
nchunk_fit = nchunk_fit / chunk_dims_map[k - 1];
@@ -461,7 +467,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
nchunk_fit = 1;
/* get hyperslab dimentions as unmapping to actual size */
- dims_hslab[k - 1] = MIN( (hs_dims_map[k-1] * dims_chunk[k-1]), dims_dset[k-1]);
+ dims_hslab[k - 1] = MIN((hs_dims_map[k - 1] * dims_chunk[k - 1]), dims_dset[k - 1]);
/* calculate total size for the hyperslab */
hslab_nbytes *= dims_hslab[k - 1];
@@ -482,7 +488,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
if (ndatum_fit == 0)
ndatum_fit = 1;
/* get hyperslab dimentions within a chunk boundary */
- dims_hslab[k - 1] = MIN (dims_chunk[k-1], ndatum_fit);
+ dims_hslab[k - 1] = MIN(dims_chunk[k - 1], ndatum_fit);
/* calculate total size for the hyperslab */
hslab_nbytes *= dims_hslab[k - 1];
@@ -578,49 +584,48 @@ done:
*/
int
-do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
- pack_opt_t *options) /* repack options */
+do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */
{
- hid_t grp_in = H5I_INVALID_HID; /* group ID */
- hid_t grp_out = H5I_INVALID_HID; /* group ID */
- hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */
- hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */
- hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
- hid_t gcpl_out = H5I_INVALID_HID; /* group creation property list */
- hid_t type_in = H5I_INVALID_HID; /* named type ID */
- hid_t type_out = H5I_INVALID_HID; /* named type ID */
- hid_t dcpl_in = H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t dcpl_out = H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t f_space_id = H5I_INVALID_HID; /* file space ID */
- hid_t ftype_id = H5I_INVALID_HID; /* file type ID */
- hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */
- hid_t ocpl_id = H5I_INVALID_HID; /* property to pass copy options */
- hid_t lcpl_id = H5I_INVALID_HID; /* link creation property list */
- 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 */
- H5D_space_status_t space_status; /* determines whether space has been allocated for the 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 */
- 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 req_obj_layout = 0; /* request layout to current object */
- unsigned crt_order_flags; /* group creation order flag */
+ hid_t grp_in = H5I_INVALID_HID; /* group ID */
+ hid_t grp_out = H5I_INVALID_HID; /* group ID */
+ hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */
+ hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */
+ hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
+ hid_t gcpl_out = H5I_INVALID_HID; /* group creation property list */
+ hid_t type_in = H5I_INVALID_HID; /* named type ID */
+ hid_t type_out = H5I_INVALID_HID; /* named type ID */
+ hid_t dcpl_in = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t dcpl_out = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t f_space_id = H5I_INVALID_HID; /* file space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file type ID */
+ hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */
+ hid_t ocpl_id = H5I_INVALID_HID; /* property to pass copy options */
+ hid_t lcpl_id = H5I_INVALID_HID; /* link creation property list */
+ 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 */
+ H5D_space_status_t space_status; /* determines whether space has been allocated for the 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 */
+ 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 req_obj_layout = 0; /* request layout to current object */
+ unsigned crt_order_flags; /* group creation order flag */
h5tool_link_info_t linkinfo;
- unsigned i;
- unsigned u;
- int ifil;
- int is_ref = 0;
- htri_t is_named;
- hbool_t limit_maxdims;
- hsize_t size_dset;
- int ret_value = 0;
+ unsigned i;
+ unsigned u;
+ int ifil;
+ int is_ref = 0;
+ htri_t is_named;
+ hbool_t limit_maxdims;
+ hsize_t size_dset;
+ int ret_value = 0;
/* init linkinfo struct */
HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t));
@@ -639,662 +644,689 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
if (travt->objs) {
for (i = 0; i < travt->nobjs; i++) {
/* init variables per obj */
- buf = NULL;
+ buf = NULL;
limit_maxdims = FALSE;
switch (travt->objs[i].type) {
- case H5TRAV_TYPE_UNKNOWN:
- break;
+ case H5TRAV_TYPE_UNKNOWN:
+ break;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_GROUP
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_GROUP:
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "group", travt->objs[i].name);
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_GROUP
+ *-------------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_GROUP:
+ if (options->verbose)
+ HDprintf(FORMAT_OBJ, "group", travt->objs[i].name);
- /* open input group */
- if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
+ /* open input group */
+ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
- /* get input group creation property list */
- if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed");
+ /* get input group creation property list */
+ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed");
- /* query and set the group creation properties */
- if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed");
+ /* query and set the group creation properties */
+ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed");
- /* set up group creation property list */
- if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
+ /* set up group creation property list */
+ if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
- if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed");
+ if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed");
- /*-------------------------------------------------------------------------
- * the root is a special case, we get an ID for the root group
- * and copy its attributes using that ID
- *-------------------------------------------------------------------------
- */
- if (HDstrcmp(travt->objs[i].name, "/") == 0) {
- if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
- }
- else {
- if (options->grp_compact > 0 || options->grp_indexed > 0)
- if (H5Pset_link_phase_change(gcpl_out, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed");
+ /*-------------------------------------------------------------------------
+ * the root is a special case, we get an ID for the root group
+ * and copy its attributes using that ID
+ *-------------------------------------------------------------------------
+ */
+ if (HDstrcmp(travt->objs[i].name, "/") == 0) {
+ if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
+ }
+ else {
+ if (options->grp_compact > 0 || options->grp_indexed > 0)
+ if (H5Pset_link_phase_change(gcpl_out, (unsigned)options->grp_compact,
+ (unsigned)options->grp_indexed) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed");
+
+ if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out,
+ H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 failed");
+ }
- if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 failed");
- }
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
+
+ if (H5Pclose(gcpl_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Pclose(gcpl_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Gclose(grp_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
+ if (H5Gclose(grp_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
+
+ break;
/*-------------------------------------------------------------------------
- * copy attrs
+ * H5TRAV_TYPE_DATASET
*-------------------------------------------------------------------------
*/
- if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0)
- H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
-
- if (H5Pclose(gcpl_out) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- if (H5Pclose(gcpl_in) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- if (H5Gclose(grp_out) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
- if (H5Gclose(grp_in) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
+ case H5TRAV_TYPE_DATASET: {
+ hbool_t use_h5ocopy;
+
+ has_filter = 0;
+ req_filter = 0;
+
+ /* check if global filters were requested */
+ if (options->n_filter_g)
+ req_filter = 1;
+
+ /* check if filters were requested for individual objects */
+ 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)
+ for (ifil = 0; ifil < options->op_tbl->objs[ifil].nfilters; ifil++) {
+ if (options->op_tbl->objs[u].filter[ifil].filtn > 0)
+ req_filter = 1;
+ }
+ }
+ }
- break;
+ /* check if layout change requested individual object */
+ if (options->layout_g != H5D_LAYOUT_ERROR) {
+ pack_info_t *pckinfo;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_DATASET
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_DATASET:
- {
- hbool_t use_h5ocopy;
-
- has_filter = 0;
- req_filter = 0;
-
- /* check if global filters were requested */
- if (options->n_filter_g)
- req_filter = 1;
-
- /* check if filters were requested for individual objects */
- 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)
- for (ifil = 0; ifil < options->op_tbl->objs[ifil].nfilters; ifil++) {
- if (options->op_tbl->objs[u].filter[ifil].filtn > 0)
- req_filter = 1;
- }
+ /* any dataset is specified */
+ if (options->op_tbl->nelems > 0) {
+ /* check if object exist */
+ pckinfo = options_get_object(travt->objs[i].name, options->op_tbl);
+ if (pckinfo)
+ req_obj_layout = 1;
+ }
}
- }
- /* check if layout change requested individual object */
- if (options->layout_g != H5D_LAYOUT_ERROR) {
- pack_info_t *pckinfo;
+ /* early detection of references */
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if ((ftype_id = H5Dget_type(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
+ if (H5T_REFERENCE == H5Tget_class(ftype_id))
+ is_ref = 1;
- /* any dataset is specified */
- if (options->op_tbl->nelems > 0) {
- /* check if object exist */
- pckinfo = options_get_object(travt->objs[i].name, options->op_tbl);
- if (pckinfo)
- req_obj_layout = 1;
- }
- }
+ /* Check if the datatype is committed */
+ if ((is_named = H5Tcommitted(ftype_id)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed");
+ if (is_named)
+ if ((wtype_id =
+ copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
- /* early detection of references */
- if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
- if ((ftype_id = H5Dget_type(dset_in)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
- if (H5T_REFERENCE == H5Tget_class(ftype_id))
- is_ref = 1;
-
- /* Check if the datatype is committed */
- if ((is_named = H5Tcommitted(ftype_id)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed");
- if (is_named)
- if ((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
+ if (H5Tclose(ftype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Dclose(dset_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
- if (H5Tclose(ftype_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if (H5Dclose(dset_in) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ /*-------------------------------------------------------------------------
+ * check if we should use H5Ocopy or not
+ * if there is a request for filters/layout, we read/write the object
+ * otherwise we do a copy using H5Ocopy
+ *-------------------------------------------------------------------------
+ */
+ use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1 ||
+ options->all_layout == 1 || is_ref || is_named);
- /*-------------------------------------------------------------------------
- * check if we should use H5Ocopy or not
- * if there is a request for filters/layout, we read/write the object
- * otherwise we do a copy using H5Ocopy
- *-------------------------------------------------------------------------
- */
- use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref || is_named);
+ /*
+ * Check if we are using different source and destination VOL connectors.
+ * In this case, we currently have to avoid usage of H5Ocopy since it
+ * doesn't support this.
+ */
+ if (use_h5ocopy &&
+ (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) {
+ hid_t in_vol_id;
+ hid_t out_vol_id;
+ hid_t default_vol_id;
- /*
- * Check if we are using different source and destination VOL connectors.
- * In this case, we currently have to avoid usage of H5Ocopy since it
- * doesn't support this.
- */
- if (use_h5ocopy && (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) {
- hid_t in_vol_id;
- hid_t out_vol_id;
- hid_t default_vol_id;
-
- if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
-
- if (options->fin_fapl == H5P_DEFAULT)
- in_vol_id = default_vol_id;
- else
- if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0)
+ if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
- if (options->fout_fapl == H5P_DEFAULT)
- out_vol_id = default_vol_id;
- else
- if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0)
+
+ if (options->fin_fapl == H5P_DEFAULT)
+ in_vol_id = default_vol_id;
+ else if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+ if (options->fout_fapl == H5P_DEFAULT)
+ out_vol_id = default_vol_id;
+ else if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
- if (in_vol_id != out_vol_id)
- use_h5ocopy = FALSE;
+ if (in_vol_id != out_vol_id)
+ use_h5ocopy = FALSE;
- if (in_vol_id != default_vol_id)
- if (H5VLclose(in_vol_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
- if (out_vol_id != default_vol_id)
- if (H5VLclose(out_vol_id) < 0)
+ if (in_vol_id != default_vol_id)
+ if (H5VLclose(in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (out_vol_id != default_vol_id)
+ if (H5VLclose(out_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (H5VLclose(default_vol_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
- if (H5VLclose(default_vol_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
- }
-
- if (!use_h5ocopy) {
- int j;
-
- if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
- if ((f_space_id = H5Dget_space(dset_in)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
- if ((ftype_id = H5Dget_type(dset_in)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
- if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
- if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed");
- HDmemset(dims, 0, sizeof dims);
- if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
- if (H5Dget_space_status(dset_in, &space_status) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dget_space_status failed");
-
- /* If the input dataset has external storage, it must be contiguous.
- * Accordingly, there would be no filter or chunk properties to preserve,
- * so create a new DCPL.
- * Otherwise, copy dcpl_in.
- */
- if (H5Pget_external_count(dcpl_in)) {
- if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
- }
- else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) {
- H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed");
}
- nelmts = 1;
- for (j = 0; j < rank; j++)
- nelmts *= dims[j];
+ if (!use_h5ocopy) {
+ int j;
+
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if ((f_space_id = H5Dget_space(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
+ if ((ftype_id = H5Dget_type(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
+ if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
+ if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed");
+ HDmemset(dims, 0, sizeof dims);
+ if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
+ if (H5Dget_space_status(dset_in, &space_status) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space_status failed");
+
+ /* If the input dataset has external storage, it must be contiguous.
+ * Accordingly, there would be no filter or chunk properties to preserve,
+ * so create a new DCPL.
+ * Otherwise, copy dcpl_in.
+ */
+ if (H5Pget_external_count(dcpl_in)) {
+ if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
+ }
+ else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) {
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed");
+ }
- /* wtype_id will have already been set if using a named dtype */
- if (!is_named) {
- if (options->use_native == 1)
- wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT);
- else
- wtype_id = H5Tcopy(ftype_id);
- }
+ nelmts = 1;
+ for (j = 0; j < rank; j++)
+ nelmts *= dims[j];
- if ((msize = H5Tget_size(wtype_id)) == 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
+ /* wtype_id will have already been set if using a named dtype */
+ if (!is_named) {
+ if (options->use_native == 1)
+ wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT);
+ else
+ wtype_id = H5Tcopy(ftype_id);
+ }
- /* size of current dset */
- size_dset = nelmts * msize;
+ if ((msize = H5Tget_size(wtype_id)) == 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
- /*-------------------------------------------------------------------------
- * check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
- *-------------------------------------------------------------------------
- */
- if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) {
- apply_s = 1;
- apply_f = 1;
+ /* size of current dset */
+ size_dset = nelmts * msize;
/*-------------------------------------------------------------------------
- * references are a special case
- * we cannot just copy the buffers, but instead we recreate the reference
- * in a second traversal of the output file
+ * check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if (H5T_REFERENCE != H5Tget_class(wtype_id)) {
- /* get the storage size of the input dataset */
- dsize_in = H5Dget_storage_size(dset_in);
+ if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) {
+ apply_s = 1;
+ apply_f = 1;
- /* check for small size datasets (less than 1k) except
- * changing to COMPACT. For the reference, COMPACT is limited
- * by size 64K by library.
+ /*-------------------------------------------------------------------------
+ * references are a special case
+ * we cannot just copy the buffers, but instead we recreate the reference
+ * in a second traversal of the output file
+ *-------------------------------------------------------------------------
*/
- if (options->layout_g != H5D_COMPACT)
- if (size_dset < options->min_comp)
- apply_s = 0;
-
- /* apply the filter */
- if (apply_s)
- if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0)
- H5TOOLS_GOTO_ERROR((-1), "apply_filters failed");
-
- /* only if layout change requested for entire file or
- * individual obj */
- if (options->all_layout > 0 || req_obj_layout == 1) {
- /*-------------------------------------------------
- * Unset the unlimited max dims if convert to other
- * than chunk layouts, because unlimited max dims
- * only can be applied to chunk layout.
- * Also perform only for targeted dataset
- * Also check for size limit to convert to compact
- *-------------------------------------------------*/
- if (options->layout_g != H5D_CHUNKED) {
- /* any dataset is specified */
- if (options->op_tbl->nelems > 0) {
- /* if current obj match specified obj */
- if (options_get_object(travt->objs[i].name, options->op_tbl))
+ if (H5T_REFERENCE != H5Tget_class(wtype_id)) {
+ /* get the storage size of the input dataset */
+ dsize_in = H5Dget_storage_size(dset_in);
+
+ /* check for small size datasets (less than 1k) except
+ * changing to COMPACT. For the reference, COMPACT is limited
+ * by size 64K by library.
+ */
+ if (options->layout_g != H5D_COMPACT)
+ if (size_dset < options->min_comp)
+ apply_s = 0;
+
+ /* apply the filter */
+ if (apply_s)
+ if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out,
+ options, &has_filter) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "apply_filters failed");
+
+ /* only if layout change requested for entire file or
+ * individual obj */
+ if (options->all_layout > 0 || req_obj_layout == 1) {
+ /*-------------------------------------------------
+ * Unset the unlimited max dims if convert to other
+ * than chunk layouts, because unlimited max dims
+ * only can be applied to chunk layout.
+ * Also perform only for targeted dataset
+ * Also check for size limit to convert to compact
+ *-------------------------------------------------*/
+ if (options->layout_g != H5D_CHUNKED) {
+ /* any dataset is specified */
+ if (options->op_tbl->nelems > 0) {
+ /* if current obj match specified obj */
+ if (options_get_object(travt->objs[i].name, options->op_tbl))
+ limit_maxdims = TRUE;
+ }
+ else /* no dataset is specified */
limit_maxdims = TRUE;
- }
- else /* no dataset is specified */
- limit_maxdims = TRUE;
- /* if convert to COMPACT */
- if (options->layout_g == H5D_COMPACT)
- if (size_dset > MAX_COMPACT_DSIZE)
- limit_maxdims = FALSE;
+ /* if convert to COMPACT */
+ if (options->layout_g == H5D_COMPACT)
+ if (size_dset > MAX_COMPACT_DSIZE)
+ limit_maxdims = FALSE;
+
+ /* unset unlimited max dims */
+ if (limit_maxdims)
+ H5Sset_extent_simple(f_space_id, rank, dims, NULL);
+ } /* end if not chunked */
+ } /* end if layout change requested for entire file or individual object */
+
+ /*-------------------------------------------------------------------------
+ * create the output dataset;
+ * disable error checking in case the dataset cannot be created with the
+ * modified dcpl; in that case use the original instead
+ *-------------------------------------------------------------------------
+ */
+ dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id,
+ H5P_DEFAULT, dcpl_out, H5P_DEFAULT);
+ if (dset_out == H5I_INVALID_HID) {
+ H5TOOLS_INFO("H5Dcreate2 failed");
+ if (options->verbose)
+ HDprintf(" warning: could not create dataset <%s>. Applying original "
+ "settings\n",
+ travt->objs[i].name);
+
+ if ((dset_out =
+ H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id,
+ H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
+ apply_f = 0;
+ } /* end if retry dataset create */
+
+ /*-------------------------------------------------------------------------
+ * read/write
+ *-------------------------------------------------------------------------
+ */
+ if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) {
+ size_t need = (size_t)(nelmts * msize); /* bytes needed */
- /* unset unlimited max dims */
- if (limit_maxdims)
- H5Sset_extent_simple(f_space_id, rank, dims, NULL);
- } /* end if not chunked */
- } /* end if layout change requested for entire file or individual object */
+ /* have to read the whole dataset if there is only one element in the
+ * dataset */
+ if (need < H5TOOLS_MALLOCSIZE)
+ buf = HDmalloc(need);
- /*-------------------------------------------------------------------------
- * create the output dataset;
- * disable error checking in case the dataset cannot be created with the
- * modified dcpl; in that case use the original instead
- *-------------------------------------------------------------------------
- */
- dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT);
- if (dset_out == H5I_INVALID_HID) {
- H5TOOLS_INFO("H5Dcreate2 failed");
- if (options->verbose)
- HDprintf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name);
+ if (buf != NULL) {
+ if (H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) <
+ 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
+ if (H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) <
+ 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
- if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
- apply_f = 0;
- } /* end if retry dataset create */
+ /* Check if we have VL data in the dataset's
+ * datatype that must be reclaimed */
+ if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
+ if (H5Treclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Treclaim failed");
- /*-------------------------------------------------------------------------
- * read/write
- *-------------------------------------------------------------------------
- */
- if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) {
- size_t need = (size_t)(nelmts * msize); /* bytes needed */
-
- /* have to read the whole dataset if there is only one element in the dataset */
- if (need < H5TOOLS_MALLOCSIZE)
- buf = HDmalloc(need);
-
- if (buf != NULL) {
- if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
- if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
-
- /* Check if we have VL data in the dataset's
- * datatype that must be reclaimed */
- if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
- if (H5Treclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Treclaim failed");
-
- if (buf != NULL) { /* TODO: is buf potentially released by H5Dvlen_reclaim()? */
- HDfree(buf);
- buf = NULL;
+ if (buf != NULL) { /* TODO: is buf potentially released by
+ H5Dvlen_reclaim()? */
+ HDfree(buf);
+ buf = NULL;
+ }
}
- }
- else { /* possibly not enough memory, read/write by hyperslabs */
- size_t p_type_nbytes = msize; /*size of memory type */
- hsize_t p_nelmts = nelmts; /*total elements */
- hsize_t elmtno; /*counter */
- int carry; /*counter carry value */
- unsigned int vl_data = 0; /*contains VL datatypes */
-
- /* hyperslab info */
- hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */
- hsize_t hslab_nbytes; /*bytes per hyperslab */
- hsize_t hslab_nelmts; /*elements per hyperslab*/
- hid_t hslab_space; /*hyperslab data space */
-
- /* hyperslab selection info */
- hsize_t hs_sel_offset[H5S_MAX_RANK];/* selection offset */
- hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */
- hsize_t hs_select_nelmts; /* selected elements */
- hsize_t zero[8]; /*vector of zeros */
- int k;
- H5D_layout_t dset_layout;
- hid_t dcpl_tmp = H5I_INVALID_HID; /* dataset creation property list ID */
-
- /* check if we have VL data in the dataset's datatype */
- if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
- vl_data = TRUE;
-
- /* check first if writing dataset is chunked,
- * if so use its chunk layout for better performance. */
- dset_layout = H5Pget_layout(dcpl_out);
- if (dset_layout == H5D_CHUNKED)
- dcpl_tmp = dcpl_out; /* writing dataset */
- else {
- dset_layout = H5Pget_layout(dcpl_in);
+ else { /* possibly not enough memory, read/write by hyperslabs */
+ size_t p_type_nbytes = msize; /*size of memory type */
+ hsize_t p_nelmts = nelmts; /*total elements */
+ hsize_t elmtno; /*counter */
+ int carry; /*counter carry value */
+ unsigned int vl_data = 0; /*contains VL datatypes */
+
+ /* hyperslab info */
+ hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */
+ hsize_t hslab_nbytes; /*bytes per hyperslab */
+ hsize_t hslab_nelmts; /*elements per hyperslab*/
+ hid_t hslab_space; /*hyperslab data space */
+
+ /* hyperslab selection info */
+ hsize_t hs_sel_offset[H5S_MAX_RANK]; /* selection offset */
+ hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */
+ hsize_t hs_select_nelmts; /* selected elements */
+ hsize_t zero[8]; /*vector of zeros */
+ int k;
+ H5D_layout_t dset_layout;
+ hid_t dcpl_tmp =
+ H5I_INVALID_HID; /* dataset creation property list ID */
+
+ /* check if we have VL data in the dataset's datatype */
+ if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
+ vl_data = TRUE;
+
+ /* check first if writing dataset is chunked,
+ * if so use its chunk layout for better performance. */
+ dset_layout = H5Pget_layout(dcpl_out);
if (dset_layout == H5D_CHUNKED)
- dcpl_tmp = dcpl_in; /* reading dataset */
- }
-
- /* get hyperslab dims and size in byte */
- if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0)
- H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed");
-
- hslab_buf = HDmalloc((size_t)hslab_nbytes);
- if (hslab_buf == NULL)
- H5TOOLS_GOTO_ERROR((-1), "can't allocate space for hyperslab");
-
- hslab_nelmts = hslab_nbytes / p_type_nbytes;
- hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL);
-
- /* the hyperslab selection loop */
- HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset);
- HDmemset(zero, 0, sizeof zero);
-
- for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) {
- if (rank > 0) {
- /* calculate the hyperslab selections.
- * The selection would be same as the hyperslab
- * except for remaining edge portion of the dataset
- * which is smaller then the hyperslab.
- */
- for (k = 0, hs_select_nelmts = 1; k < rank; k++) {
- /* MIN() is used to get the remaining edge portion if exist.
- * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is smaller then the hyperslab.*/
- hs_sel_count[k] = MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]);
- hs_select_nelmts *= hs_sel_count[k];
- }
-
- if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_sel_offset, NULL, hs_sel_count, NULL) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
- if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
- } /* end if rank > 0 */
+ dcpl_tmp = dcpl_out; /* writing dataset */
else {
- H5Sselect_all(f_space_id);
- H5Sselect_all(hslab_space);
- hs_select_nelmts = 1;
- } /* end (else) rank == 0 */
+ dset_layout = H5Pget_layout(dcpl_in);
+ if (dset_layout == H5D_CHUNKED)
+ dcpl_tmp = dcpl_in; /* reading dataset */
+ }
- if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
- if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
+ /* get hyperslab dims and size in byte */
+ if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims,
+ &hslab_nbytes) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed");
+
+ hslab_buf = HDmalloc((size_t)hslab_nbytes);
+ if (hslab_buf == NULL)
+ H5TOOLS_GOTO_ERROR((-1), "can't allocate space for hyperslab");
+
+ hslab_nelmts = hslab_nbytes / p_type_nbytes;
+ hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL);
+
+ /* the hyperslab selection loop */
+ HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset);
+ HDmemset(zero, 0, sizeof zero);
+
+ for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) {
+ if (rank > 0) {
+ /* calculate the hyperslab selections.
+ * The selection would be same as the hyperslab
+ * except for remaining edge portion of the dataset
+ * which is smaller then the hyperslab.
+ */
+ for (k = 0, hs_select_nelmts = 1; k < rank; k++) {
+ /* MIN() is used to get the remaining edge portion if
+ * exist. "dims[k] - hs_sel_offset[k]" is remaining edge
+ * portion that is smaller then the hyperslab.*/
+ hs_sel_count[k] =
+ MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]);
+ hs_select_nelmts *= hs_sel_count[k];
+ }
+
+ if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET,
+ hs_sel_offset, NULL, hs_sel_count,
+ NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
+ if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero,
+ NULL, &hs_select_nelmts, NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
+ } /* end if rank > 0 */
+ else {
+ H5Sselect_all(f_space_id);
+ H5Sselect_all(hslab_space);
+ hs_select_nelmts = 1;
+ } /* end (else) rank == 0 */
+
+ if (H5Dread(dset_in, wtype_id, hslab_space, f_space_id,
+ H5P_DEFAULT, hslab_buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
+ if (H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id,
+ H5P_DEFAULT, hslab_buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
+
+ /* reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Treclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf);
+
+ /* calculate the next hyperslab offset */
+ for (k = rank, carry = 1; k > 0 && carry; --k) {
+ hs_sel_offset[k - 1] += hs_sel_count[k - 1];
+ /* if reached the end of a dim */
+ if (hs_sel_offset[k - 1] == dims[k - 1])
+ hs_sel_offset[k - 1] = 0;
+ else
+ carry = 0;
+ }
+ } /* end for (hyperslab selection loop) */
- /* reclaim any VL memory, if necessary */
- if (vl_data)
- H5Treclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf);
-
- /* calculate the next hyperslab offset */
- for (k = rank, carry = 1; k > 0 && carry; --k) {
- hs_sel_offset[k - 1] += hs_sel_count[k - 1];
- /* if reached the end of a dim */
- if (hs_sel_offset[k - 1] == dims[k - 1])
- hs_sel_offset[k - 1] = 0;
- else
- carry = 0;
+ H5Sclose(hslab_space);
+ if (hslab_buf != NULL) {
+ HDfree(hslab_buf);
+ hslab_buf = NULL;
}
- } /* end for (hyperslab selection loop) */
+ } /* end if reading/writing by hyperslab */
+ } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */
- H5Sclose(hslab_space);
- if (hslab_buf != NULL) {
- HDfree(hslab_buf);
- hslab_buf = NULL;
+ /*-------------------------------------------------------------------------
+ * print amount of compression used
+ *-------------------------------------------------------------------------
+ */
+ if (options->verbose) {
+ double ratio = 0;
+
+ /* only print the compression ration if there was a filter request */
+ if (apply_s && apply_f && req_filter) {
+ /* get the storage size of the output dataset */
+ dsize_out = H5Dget_storage_size(dset_out);
+
+ /* compression ratio = uncompressed size / compressed size */
+ if (dsize_out != 0)
+ ratio = (double)dsize_in / (double)dsize_out;
+ print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1);
}
- } /* end if reading/writing by hyperslab */
- } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */
-
- /*-------------------------------------------------------------------------
- * print amount of compression used
- *-------------------------------------------------------------------------
- */
- if (options->verbose) {
- double ratio = 0;
-
- /* only print the compression ration if there was a filter request */
- if (apply_s && apply_f && req_filter) {
- /* get the storage size of the output dataset */
- dsize_out = H5Dget_storage_size(dset_out);
-
- /* compression ratio = uncompressed size / compressed size */
- if (dsize_out != 0)
- ratio = (double) dsize_in / (double) dsize_out;
- print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1);
- }
- else
- print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0);
-
- /* print a message that the filter was not applied
- * (in case there was a filter)
+ else
+ print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0);
+
+ /* print a message that the filter was not applied
+ * (in case there was a filter)
+ */
+ if (has_filter && apply_s == 0)
+ HDprintf(" <warning: filter not applied to %s. dataset smaller than "
+ "%d bytes>\n",
+ travt->objs[i].name, (int)options->min_comp);
+
+ if (has_filter && apply_f == 0)
+ HDprintf(" <warning: could not apply the filter to %s>\n",
+ travt->objs[i].name);
+ } /* end if verbose (print compression) */
+
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
*/
- if (has_filter && apply_s == 0)
- HDprintf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n", travt->objs[i].name, (int) options->min_comp);
-
- if (has_filter && apply_f == 0)
- HDprintf(" <warning: could not apply the filter to %s>\n", travt->objs[i].name);
- } /* end if verbose (print compression) */
-
- /*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
- if (H5Dclose(dset_out) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
- } /* end if not a reference */
- } /* end if h5tools_canreadf (filter availability check) */
+ if (H5Dclose(dset_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ } /* end if not a reference */
+ } /* end if h5tools_canreadf (filter availability check) */
+ /*-------------------------------------------------------------------------
+ * Close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tclose(ftype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Tclose(wtype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Pclose(dcpl_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Pclose(dcpl_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Sclose(f_space_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
+ if (H5Dclose(dset_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ }
/*-------------------------------------------------------------------------
- * Close
+ * We do not have request for filter/chunking; use H5Ocopy instead
*-------------------------------------------------------------------------
*/
- if (H5Tclose(ftype_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if (H5Tclose(wtype_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if (H5Pclose(dcpl_in) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- if (H5Pclose(dcpl_out) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- if (H5Sclose(f_space_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
- if (H5Dclose(dset_in) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
- }
+ else {
+ /* create property to pass copy options */
+ if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
+
+ /* set options for object copy */
+ if (H5Pset_copy_object(ocpl_id, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed");
+
+ if (H5Ocopy(fidin, /* Source file or group identifier */
+ travt->objs[i].name, /* Name of the source object to be copied */
+ fidout, /* Destination file or group identifier */
+ travt->objs[i].name, /* Name of the destination object */
+ ocpl_id, /* Properties which apply to the copy */
+ H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
+ H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed");
+
+ if (H5Pclose(ocpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ ocpl_id = H5I_INVALID_HID;
+
+ /*-------------------------------------------------------------------------
+ * Copy attrs manually
+ *-------------------------------------------------------------------------
+ */
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
+ if (H5Dclose(dset_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ if (H5Dclose(dset_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+
+ if (options->verbose)
+ HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
+
+ } /* end whether we have request for filter/chunking */
+
+ break;
+ } /* H5TRAV_TYPE_DATASET */
+
/*-------------------------------------------------------------------------
- * We do not have request for filter/chunking; use H5Ocopy instead
+ * H5TRAV_TYPE_NAMED_DATATYPE
*-------------------------------------------------------------------------
*/
- else {
- /* create property to pass copy options */
- if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
+ case H5TRAV_TYPE_NAMED_DATATYPE:
+ if (options->verbose)
+ HDprintf(FORMAT_OBJ, "type", travt->objs[i].name);
- /* set options for object copy */
- if (H5Pset_copy_object(ocpl_id, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed");
+ if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed");
- if (H5Ocopy(fidin, /* Source file or group identifier */
- travt->objs[i].name, /* Name of the source object to be copied */
- fidout, /* Destination file or group identifier */
- travt->objs[i].name, /* Name of the destination object */
- ocpl_id, /* Properties which apply to the copy */
- H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
- H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed");
+ /* Copy the datatype anonymously */
+ if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
- if (H5Pclose(ocpl_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- ocpl_id = H5I_INVALID_HID;
+ /* Link in to group structure */
+ if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) <
+ 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed");
/*-------------------------------------------------------------------------
- * Copy attrs manually
+ * copy attrs
*-------------------------------------------------------------------------
*/
- if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
- if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
- if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0)
H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
- if (H5Dclose(dset_in) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
- if (H5Dclose(dset_out) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
-
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
-
- } /* end whether we have request for filter/chunking */
- break;
- } /* H5TRAV_TYPE_DATASET */
-
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_NAMED_DATATYPE
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_NAMED_DATATYPE:
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "type", travt->objs[i].name);
-
- if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed");
-
- /* Copy the datatype anonymously */
- if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
+ if (H5Tclose(type_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Tclose(type_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ type_out = H5I_INVALID_HID; /* named datatypes stack, named_dt_head, manages allocation */
- /* Link in to group structure */
- if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed");
+ break;
/*-------------------------------------------------------------------------
- * copy attrs
+ * H5TRAV_TYPE_LINK
+ * H5TRAV_TYPE_UDLINK
+ *
+ * Only handles external links; H5Lcopy will fail for other UD link types
+ * since we don't have creation or copy callbacks for them.
*-------------------------------------------------------------------------
*/
- if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0)
- H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
+ case H5TRAV_TYPE_LINK:
+ case H5TRAV_TYPE_UDLINK:
+ if (options->verbose)
+ HDprintf(FORMAT_OBJ, "link", travt->objs[i].name);
+
+ /* Check -X option. */
+ if (options->merge) {
+ if (H5tools_get_symlink_info(fidin, travt->objs[i].name, &linkinfo, 1) == 0) {
+ /* dangling link */
+ if (options->prune) {
+ HDprintf("Pruned %s.\n", travt->objs[i].name);
+ }
+ else {
+ if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name,
+ H5P_DEFAULT, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed");
+ }
+ }
+ else {
+ /* valid link */
+ /* create property to pass copy options */
+ if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate create property failed");
+
+ /* set options for object copy */
+ if (H5Pset_copy_object(ocpl_id, H5O_COPY_EXPAND_EXT_LINK_FLAG) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed");
+
+ /* Create link creation property list */
+ if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate link creation property failed");
+ }
- if (H5Tclose(type_in) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if (H5Tclose(type_out) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- type_out = H5I_INVALID_HID; /* named datatypes stack, named_dt_head, manages allocation */
+ /* Set flag for intermediate group creation */
+ if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_create_intermediate_group failed");
- break;
+ if (H5Ocopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, ocpl_id,
+ lcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed");
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_LINK
- * H5TRAV_TYPE_UDLINK
- *
- * Only handles external links; H5Lcopy will fail for other UD link types
- * since we don't have creation or copy callbacks for them.
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_LINK:
- case H5TRAV_TYPE_UDLINK:
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "link", travt->objs[i].name);
-
- /* Check -X option. */
- if (options->merge) {
- if (H5tools_get_symlink_info(fidin, travt->objs[i].name, &linkinfo, 1) == 0) {
- /* dangling link */
+ if (H5Pclose(lcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+
+ if (H5Pclose(ocpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ }
+
+ /* free link info path */
+ if (linkinfo.trg_path)
+ HDfree(linkinfo.trg_path);
+ linkinfo.trg_path = NULL;
+ } /* options->merge */
+ else {
if (options->prune) {
HDprintf("Pruned %s.\n", travt->objs[i].name);
}
else {
- if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT,
+ H5P_DEFAULT) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed");
}
}
- else {
- /* valid link */
- /* create property to pass copy options */
- if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pcreate create property failed");
-
- /* set options for object copy */
- if (H5Pset_copy_object(ocpl_id, H5O_COPY_EXPAND_EXT_LINK_FLAG) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed");
-
- /* Create link creation property list */
- if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
- H5TOOLS_GOTO_ERROR((-1), "H5Pcreate link creation property failed");
- }
-
- /* Set flag for intermediate group creation */
- if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_create_intermediate_group failed");
-
- if (H5Ocopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, ocpl_id, lcpl_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed");
-
- if (H5Pclose(lcpl_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
-
- if (H5Pclose(ocpl_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- }
+ break;
- /* free link info path */
- if (linkinfo.trg_path)
- HDfree(linkinfo.trg_path);
- linkinfo.trg_path = NULL;
- } /* options->merge */
- else {
- if (options->prune) {
- HDprintf("Pruned %s.\n", travt->objs[i].name);
- }
- else {
- if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed");
- }
- }
- break;
-
- default:
- H5TOOLS_GOTO_ERROR((-1), "Object type not found");
+ default:
+ H5TOOLS_GOTO_ERROR((-1), "Object type not found");
} /* switch */
- } /* end for each object to traverse */
- } /* end if there are objects */
+ } /* end for each object to traverse */
+ } /* end if there are objects */
done:
@@ -1305,9 +1337,8 @@ done:
H5TOOLS_ERROR((-1), "named_datatype_free failed");
}
else {
- H5E_BEGIN_TRY {
- named_datatype_free(&named_dt_head, 1);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { named_datatype_free(&named_dt_head, 1); }
+ H5E_END_TRY;
}
/* free link info path */
@@ -1330,7 +1361,8 @@ done:
H5Tclose(wtype_id);
H5Tclose(type_in);
H5Tclose(type_out);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* free */
if (buf != NULL)
@@ -1350,17 +1382,17 @@ done:
static void
print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
{
- char strfilter[255];
-#if defined (PRINT_DEBUG )
- char temp[255];
+ char strfilter[255];
+#if defined(PRINT_DEBUG)
+ 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");
@@ -1371,8 +1403,8 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
for (i = 0; i < nfilters; i++) {
cd_nelmts = NELMTS(cd_values);
- if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_objname), f_objname, NULL)) < 0) {
+ 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;
}
@@ -1385,11 +1417,11 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
case H5Z_FILTER_DEFLATE:
HDstrcat(strfilter, "GZIP ");
-#if defined (PRINT_DEBUG)
+#if defined(PRINT_DEBUG)
{
unsigned level = cd_values[0];
- HDsprintf(temp,"(%d)", level);
+ HDsprintf(temp, "(%d)", level);
HDstrcat(strfilter, temp);
}
#endif
@@ -1398,12 +1430,12 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
case H5Z_FILTER_SZIP:
HDstrcat(strfilter, "SZIP ");
-#if defined (PRINT_DEBUG)
+#if defined(PRINT_DEBUG)
{
unsigned options_mask = cd_values[0]; /* from dcpl, not filt*/
- unsigned ppb = cd_values[1];
+ unsigned ppb = cd_values[1];
- HDsprintf(temp,"(%d,", ppb);
+ HDsprintf(temp, "(%d,", ppb);
HDstrcat(strfilter, temp);
if (options_mask & H5_SZIP_EC_OPTION_MASK)
HDstrcpy(temp, "EC) ");
@@ -1434,7 +1466,7 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
HDstrcat(strfilter, "UD ");
break;
} /* end switch */
- } /* end for each filter */
+ } /* end for each filter */
if (!pr)
HDprintf(FORMAT_OBJ, "dset", objname);
@@ -1473,9 +1505,9 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
/* Copy the userblock from the input file to the output file */
while (size > 0) {
- ssize_t nread, nbytes; /* # of bytes transfered, etc. */
- char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */
- const char *wbuf; /* Pointer into buffer, for writing */
+ ssize_t nread, nbytes; /* # of bytes transfered, etc. */
+ char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */
+ const char *wbuf; /* Pointer into buffer, for writing */
/* Read buffer from source file */
if (size > USERBLOCK_XFER_SIZE)
@@ -1488,14 +1520,14 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
/* Write buffer to destination file */
/* (compensating for interrupted writes & checking for errors, etc.) */
nbytes = nread;
- wbuf = rbuf;
+ wbuf = rbuf;
while (nbytes > 0) {
ssize_t nwritten; /* # of bytes written */
do {
nwritten = HDwrite(outfid, wbuf, (size_t)nbytes);
} while (-1 == nwritten && EINTR == errno);
- if (-1 == nwritten) /* error */
+ if (-1 == nwritten) /* error */
H5TOOLS_GOTO_ERROR((-1), "HDwrite failed");
HDassert(nwritten > 0);
HDassert(nwritten <= nbytes);
@@ -1507,7 +1539,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
} /* end while */
/* Update size of userblock left to transfer */
- size = size - (hsize_t) nread;
+ size = size - (hsize_t)nread;
} /* end while */
done:
@@ -1527,14 +1559,13 @@ done:
* Return: 0, ok, -1 no
*-------------------------------------------------------------------------
*/
-#if defined (H5REPACK_DEBUG_USER_BLOCK)
-static
-void
+#if defined(H5REPACK_DEBUG_USER_BLOCK)
+static void
print_user_block(const char *filename, hid_t fid)
{
- int fh = -1; /* file handle */
- hsize_t ub_size; /* user block size */
- hsize_t size; /* size read */
+ int fh = -1; /* file handle */
+ hsize_t ub_size; /* user block size */
+ hsize_t size; /* size read */
hid_t fcpl = H5I_INVALID_HID; /* file creation property list ID for HDF5 file */
int i;
int ret_value = 0;
@@ -1561,8 +1592,8 @@ print_user_block(const char *filename, hid_t fid)
/* read file */
while (size > 0) {
- ssize_t nread; /* # of bytes read */
- char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
+ ssize_t nread; /* # of bytes read */
+ char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
/* read buffer */
if (size > USERBLOCK_XFER_SIZE)
@@ -1573,7 +1604,6 @@ print_user_block(const char *filename, hid_t fid)
for (i = 0; i < nread; i++) {
HDprintf("%c ", rbuf[i]);
-
}
HDprintf("\n");
@@ -1592,4 +1622,3 @@ done:
return;
} /* end print_user_block() */
#endif
-
diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c
index d1179fb..0570c0f 100644
--- a/tools/src/h5repack/h5repack_filters.c
+++ b/tools/src/h5repack/h5repack_filters.c
@@ -17,12 +17,12 @@
/* number of members in an array */
#ifndef NELMTS
-# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
+#define NELMTS(X) (sizeof(X) / sizeof(X[0]))
#endif
/* minimum of two values */
#undef MIN
-#define MIN(a,b) (((a)<(b)) ? (a) : (b))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
/*-------------------------------------------------------------------------
* Function: aux_copy_obj
@@ -32,15 +32,16 @@
* 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 */
+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 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 */
+ int rank; /* rank of dataset */
+ hsize_t chsize[64]; /* chunk size in elements */
int i;
unsigned u;
int ret_value = 0;
@@ -50,8 +51,9 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */
H5TOOLS_GOTO_ERROR((-1), "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)
+ 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)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_filter2 failed");
}
@@ -63,7 +65,7 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */
objout->layout = layout;
if (layout == H5D_CHUNKED) {
- if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0)
+ if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed");
objout->chunk.rank = rank;
for (u = 0; u < (unsigned)rank; u++)
@@ -81,30 +83,33 @@ done:
* 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 */
+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 */
{
- char *pdest = NULL;
- const char *pname = NULL;
+ char * pdest = NULL;
+ const char * pname = NULL;
unsigned int i;
for (i = 0; i < options->op_tbl->nelems; i++) {
if (HDstrcmp(options->op_tbl->objs[i].path, name) == 0) {
*obj = options->op_tbl->objs[i];
- return (int) i;
+ return (int)i;
}
pdest = options->op_tbl->objs[i].path;
- if (pdest[0] == '/') pdest++;
+ if (pdest[0] == '/')
+ pdest++;
pname = name;
- if (pname[0] == '/') pname++;
+ if (pname[0] == '/')
+ pname++;
if (HDstrcmp(pdest, pname) == 0) {
*obj = options->op_tbl->objs[i];
- return (int) i;
+ return (int)i;
}
- }/*i*/
+ } /*i*/
return -1;
}
@@ -118,9 +123,10 @@ static int aux_find_obj(const char* name, /* object name from traverse list */
* 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 */
+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 */
{
int idx, i;
pack_info_t tmp;
@@ -136,44 +142,44 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
/* assign the global layout info to the OBJ info */
tmp.layout = options->layout_g;
switch (options->layout_g) {
- 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];
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_COMPACT:
- case H5D_CONTIGUOUS:
- case H5D_VIRTUAL:
- case H5D_NLAYOUTS:
- break;
- default:
- break;
- }/*switch*/
+ 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];
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_COMPACT:
+ case H5D_CONTIGUOUS:
+ case H5D_VIRTUAL:
+ case H5D_NLAYOUTS:
+ break;
+ default:
+ break;
+ } /*switch*/
}
else {
tmp.layout = options->op_tbl->objs[idx].layout;
switch (tmp.layout) {
- 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];
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_COMPACT:
- case H5D_CONTIGUOUS:
- case H5D_VIRTUAL:
- case H5D_NLAYOUTS:
- break;
- default:
- break;
- }/*switch*/
+ 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];
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_COMPACT:
+ case H5D_CONTIGUOUS:
+ case H5D_VIRTUAL:
+ case H5D_NLAYOUTS:
+ break;
+ default:
+ break;
+ } /*switch*/
}
/* applying to all objects */
if (options->all_filter) {
/* assign the global filter */
- tmp.nfilters = 1;
+ tmp.nfilters = 1;
tmp.filter[0] = options->filter_g[0];
} /* if all */
else {
@@ -197,21 +203,20 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
/* assign the global layout info to the OBJ info */
tmp.layout = options->layout_g;
switch (options->layout_g) {
- 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];
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_COMPACT:
- case H5D_CONTIGUOUS:
- case H5D_VIRTUAL:
- case H5D_NLAYOUTS:
- break;
- default:
- break;
- }/*switch*/
+ 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];
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_COMPACT:
+ case H5D_CONTIGUOUS:
+ case H5D_VIRTUAL:
+ case H5D_NLAYOUTS:
+ break;
+ default:
+ break;
+ } /*switch*/
}
}
@@ -230,16 +235,17 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
*-------------------------------------------------------------------------
*/
-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
+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 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;
pack_info_t obj;
@@ -269,7 +275,6 @@ int apply_filters(const char* name, /* object name from traverse list */
if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed");
-
/*-------------------------------------------------------------------------
* check if we have filters in the pipeline
* we want to replace them with the input filters
@@ -281,7 +286,7 @@ int apply_filters(const char* name, /* object name from traverse list */
if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed");
}
- else if(nfilters) {
+ else if (nfilters) {
*has_filter = 1;
if (aux_copy_obj(dcpl_id, name, &filtobj) < 0)
H5TOOLS_GOTO_ERROR((-1), "aux_copy_obj failed");
@@ -297,9 +302,9 @@ int apply_filters(const char* name, /* object name from traverse list */
H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed");
if (layout == H5D_CHUNKED) {
- if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0)
+ if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed");
- obj.layout = H5D_CHUNKED;
+ obj.layout = H5D_CHUNKED;
obj.chunk.rank = rank;
for (i = 0; i < rank; i++)
obj.chunk.chunk_lengths[i] = chsize[i];
@@ -327,7 +332,7 @@ int apply_filters(const char* name, /* object name from traverse list */
if (obj.layout == -1) {
/* stripmine info */
hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */
- hsize_t sm_nbytes; /*bytes per stripmine */
+ hsize_t sm_nbytes; /*bytes per stripmine */
obj.chunk.rank = rank;
@@ -339,7 +344,7 @@ int apply_filters(const char* name, /* object name from traverse list */
sm_nbytes = msize;
for (i = rank; i > 0; --i) {
hsize_t size = 0;
- if(sm_nbytes == 0)
+ if (sm_nbytes == 0)
H5TOOLS_GOTO_ERROR((-1), "number of bytes per stripmine must be > 0");
size = H5TOOLS_BUFSIZE / sm_nbytes;
if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
@@ -358,19 +363,18 @@ int apply_filters(const char* name, /* object name from traverse list */
H5TOOLS_GOTO_ERROR((-1), "invalid filter");
switch (obj.filter[i].filtn) {
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE 0 , uncompress if compressed
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_NONE:
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_DEFLATE:
- {
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NONE 0 , uncompress if compressed
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_NONE:
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_DEFLATE: {
unsigned aggression; /* the deflate level */
aggression = obj.filter[i].cd_values[0];
@@ -379,19 +383,17 @@ int apply_filters(const char* name, /* object name from traverse list */
H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_deflate(dcpl_id, aggression) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_deflate failed");
- }
- break;
+ } break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP 4 , szip compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SZIP:
- {
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP 4 , szip compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SZIP: {
unsigned options_mask;
unsigned pixels_per_block;
- options_mask = obj.filter[i].cd_values[0];
+ options_mask = obj.filter[i].cd_values[0];
pixels_per_block = obj.filter[i].cd_values[1];
/* set up for szip data */
@@ -399,70 +401,64 @@ int apply_filters(const char* name, /* object name from traverse list */
H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_szip(dcpl_id, options_mask, pixels_per_block) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_szip failed");
- }
- break;
+ } break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SHUFFLE:
- if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
- if (H5Pset_shuffle(dcpl_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed");
- break;
-
- /*-------------------------------------------------------------------------
- * 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)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
- if (H5Pset_fletcher32(dcpl_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed");
- break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_NBIT , NBIT compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_NBIT:
- if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
- if (H5Pset_nbit(dcpl_id) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed");
- break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET , scale+offset compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SCALEOFFSET:
- {
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SHUFFLE:
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
+ if (H5Pset_shuffle(dcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed");
+ break;
+
+ /*-------------------------------------------------------------------------
+ * 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
+ if (H5Pset_fletcher32(dcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed");
+ break;
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_NBIT , NBIT compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_NBIT:
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
+ if (H5Pset_nbit(dcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed");
+ break;
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET , scale+offset compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SCALEOFFSET: {
H5Z_SO_scale_type_t scale_type;
- int scale_factor;
+ int scale_factor;
- scale_type = (H5Z_SO_scale_type_t) obj.filter[i].cd_values[0];
- scale_factor = (int) obj.filter[i].cd_values[1];
+ scale_type = (H5Z_SO_scale_type_t)obj.filter[i].cd_values[0];
+ scale_factor = (int)obj.filter[i].cd_values[1];
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_scaleoffset(dcpl_id, scale_type, scale_factor) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_scaleoffset failed");
- }
- break;
- default:
- {
+ } break;
+ default: {
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
H5TOOLS_GOTO_ERROR((-1), "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)
+ 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)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_filter failed");
- }
- break;
+ } break;
} /* switch */
- }/*i*/
+ } /*i*/
}
/*obj.nfilters*/
@@ -474,7 +470,7 @@ int apply_filters(const char* name, /* object name from traverse list */
if (H5Zfilter_avail(filtobj.filter[i].filtn) <= 0)
H5TOOLS_GOTO_ERROR((-1), "%d filter unavailable", filtobj.filter[i].filtn);
} /* for */
- } /* nfilters */
+ } /* nfilters */
/*-------------------------------------------------------------------------
* layout
@@ -504,4 +500,3 @@ int apply_filters(const char* name, /* object name from traverse list */
done:
return ret_value;
}
-
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index cf0c611..c38dd66 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -18,60 +18,57 @@
/* Name of tool */
#define PROGRAMNAME "h5repack"
-static int parse_command_line(int argc, const char **argv, pack_opt_t* options);
+static int parse_command_line(int argc, const char **argv, pack_opt_t *options);
static void leave(int ret) H5_ATTR_NORETURN;
-
/* module-scoped variables */
-static int has_i = 0;
-static int has_o = 0;
-const char *infile = NULL;
+static int has_i = 0;
+static int has_o = 0;
+const char *infile = NULL;
const char *outfile = NULL;
/*
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXW1:2:3:4:5:6:";
-static struct long_options l_opts[] = {
- { "alignment", require_arg, 'a' },
- { "block", require_arg, 'b' },
- { "compact", require_arg, 'c' },
- { "indexed", require_arg, 'd' },
- { "file", require_arg, 'e' },
- { "filter", require_arg, 'f' },
- { "help", no_arg, 'h' },
- { "infile", require_arg, 'i' }, /* for backward compability */
- { "low", require_arg, 'j' },
- { "high", require_arg, 'k' },
- { "layout", require_arg, 'l' },
- { "minimum", require_arg, 'm' },
- { "native", no_arg, 'n' },
- { "outfile", require_arg, 'o' }, /* for backward compability */
- { "sort_by", require_arg, 'q' },
- { "ssize", require_arg, 's' },
- { "threshold", require_arg, 't' },
- { "ublock", require_arg, 'u' },
- { "verbose", no_arg, 'v' },
- { "sort_order", require_arg, 'z' },
- { "enable-error-stack", no_arg, 'E' },
- { "fs_pagesize", require_arg, 'G' },
- { "latest", no_arg, 'L' },
- { "metadata_block_size", require_arg, 'M' },
- { "fs_persist", require_arg, 'P' },
- { "fs_strategy", require_arg, 'S' },
- { "fs_threshold", require_arg, 'T' },
- { "version", no_arg, 'V' },
- { "merge", no_arg, 'X' },
- { "prune", no_arg, 'W' },
- { "src-vol-value", require_arg, '1' },
- { "src-vol-name", require_arg, '2' },
- { "src-vol-info", require_arg, '3' },
- { "dst-vol-value", require_arg, '4' },
- { "dst-vol-name", require_arg, '5' },
- { "dst-vol-info", require_arg, '6' },
- { NULL, 0, '\0' }
-};
+static const char * s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXW1:2:3:4:5:6:";
+static struct long_options l_opts[] = {{"alignment", require_arg, 'a'},
+ {"block", require_arg, 'b'},
+ {"compact", require_arg, 'c'},
+ {"indexed", require_arg, 'd'},
+ {"file", require_arg, 'e'},
+ {"filter", require_arg, 'f'},
+ {"help", no_arg, 'h'},
+ {"infile", require_arg, 'i'}, /* for backward compability */
+ {"low", require_arg, 'j'},
+ {"high", require_arg, 'k'},
+ {"layout", require_arg, 'l'},
+ {"minimum", require_arg, 'm'},
+ {"native", no_arg, 'n'},
+ {"outfile", require_arg, 'o'}, /* for backward compability */
+ {"sort_by", require_arg, 'q'},
+ {"ssize", require_arg, 's'},
+ {"threshold", require_arg, 't'},
+ {"ublock", require_arg, 'u'},
+ {"verbose", no_arg, 'v'},
+ {"sort_order", require_arg, 'z'},
+ {"enable-error-stack", no_arg, 'E'},
+ {"fs_pagesize", require_arg, 'G'},
+ {"latest", no_arg, 'L'},
+ {"metadata_block_size", require_arg, 'M'},
+ {"fs_persist", require_arg, 'P'},
+ {"fs_strategy", require_arg, 'S'},
+ {"fs_threshold", require_arg, 'T'},
+ {"version", no_arg, 'V'},
+ {"merge", no_arg, 'X'},
+ {"prune", no_arg, 'W'},
+ {"src-vol-value", require_arg, '1'},
+ {"src-vol-name", require_arg, '2'},
+ {"src-vol-info", require_arg, '3'},
+ {"dst-vol-value", require_arg, '4'},
+ {"dst-vol-name", require_arg, '5'},
+ {"dst-vol-info", require_arg, '6'},
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -82,7 +79,9 @@ static struct long_options l_opts[] = {
*
*-------------------------------------------------------------------------
*/
-static void usage(const char *prog) {
+static void
+usage(const char *prog)
+{
FLUSHSTREAM(rawoutstream);
PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] file1 file2\n", prog);
PRINTVALSTREAM(rawoutstream, " file1 Input HDF5 File\n");
@@ -92,105 +91,140 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n");
PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n");
- PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
PRINTVALSTREAM(rawoutstream, " occur\n");
- PRINTVALSTREAM(rawoutstream, " --src-vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vol-value Value (ID) of the VOL connector to use for opening the\n");
PRINTVALSTREAM(rawoutstream, " input HDF5 file specified\n");
- PRINTVALSTREAM(rawoutstream, " --src-vol-name Name of the VOL connector to use for opening the input\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vol-name Name of the VOL connector to use for opening the input\n");
PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
- PRINTVALSTREAM(rawoutstream, " --src-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vol-info VOL-specific info to pass to the VOL connector used for\n");
PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n");
- PRINTVALSTREAM(rawoutstream, " --dst-vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vol-value Value (ID) of the VOL connector to use for opening the\n");
PRINTVALSTREAM(rawoutstream, " output HDF5 file specified\n");
- PRINTVALSTREAM(rawoutstream, " --dst-vol-name Name of the VOL connector to use for opening the output\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vol-name Name of the VOL connector to use for opening the output\n");
PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
- PRINTVALSTREAM(rawoutstream, " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n");
PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n");
- PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n");
+ PRINTVALSTREAM(rawoutstream,
+ " This option will take precedence over the options\n");
PRINTVALSTREAM(rawoutstream, " --low and --high\n");
- PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --low=BOUND The low bound for library release versions to use\n");
PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n");
PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_EARLIEST)\n");
- PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --high=BOUND The high bound for library release versions to use\n");
PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n");
PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_LATEST)\n");
- PRINTVALSTREAM(rawoutstream, " --merge Follow external soft link recursively and merge data\n");
- PRINTVALSTREAM(rawoutstream, " --prune Do not follow external soft links and remove link\n");
- PRINTVALSTREAM(rawoutstream, " --merge --prune Follow external link, merge data and remove dangling link\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --merge Follow external soft link recursively and merge data\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --prune Do not follow external soft links and remove link\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --merge --prune Follow external link, merge data and remove dangling link\n");
PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n");
- PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -d L2, --indexed=L2 Minimum number of links in the indexed format\n");
PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n");
- PRINTVALSTREAM(rawoutstream, " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n");
PRINTVALSTREAM(rawoutstream, " -e E, --file=E Name of file E with the -f and -l options\n");
- PRINTVALSTREAM(rawoutstream, " -u U, --ublock=U Name of file U with user block data to be added\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -u U, --ublock=U Name of file U with user block data to be added\n");
PRINTVALSTREAM(rawoutstream, " -b B, --block=B Size of user block to be added\n");
- PRINTVALSTREAM(rawoutstream, " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n");
PRINTVALSTREAM(rawoutstream, " -t T, --threshold=T Threshold value for H5Pset_alignment\n");
PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n");
PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n");
PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n");
PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n");
PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n");
- PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for\n");
PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_strategy\n");
- PRINTVALSTREAM(rawoutstream, " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-\n");
PRINTVALSTREAM(rawoutstream, " space for H5Pset_file_space_strategy\n");
- PRINTVALSTREAM(rawoutstream, " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold\n");
PRINTVALSTREAM(rawoutstream, " for H5Pset_file_space_strategy\n");
PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for\n");
PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_page_size\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n");
PRINTVALSTREAM(rawoutstream, " E - is a filename.\n");
PRINTVALSTREAM(rawoutstream, " S - is an integer\n");
PRINTVALSTREAM(rawoutstream, " U - is a filename.\n");
PRINTVALSTREAM(rawoutstream, " T - is an integer\n");
PRINTVALSTREAM(rawoutstream, " A - is an integer greater than zero\n");
- PRINTVALSTREAM(rawoutstream, " Q - is the sort index type for the input file. It can be \"name\" or\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Q - is the sort index type for the input file. It can be \"name\" or\n");
PRINTVALSTREAM(rawoutstream, " \"creation_order\" (default)\n");
- PRINTVALSTREAM(rawoutstream, " Z - is the sort order type for the input file. It can be \"descending\" or\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Z - is the sort order type for the input file. It can be \"descending\" or\n");
PRINTVALSTREAM(rawoutstream, " \"ascending\" (default)\n");
PRINTVALSTREAM(rawoutstream, " B - is the user block size, any value that is 512 or greater and is\n");
PRINTVALSTREAM(rawoutstream, " a power of 2 (1024 default)\n");
- PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of <dspace|dtype|fill|\n");
+ PRINTVALSTREAM(rawoutstream,
+ " F - is the shared object header message type, any of <dspace|dtype|fill|\n");
PRINTVALSTREAM(rawoutstream, " pline|attr>. If F is not specified, S applies to all messages\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " BOUND is an integer indicating the library release versions to use when\n");
+ PRINTVALSTREAM(rawoutstream,
+ " BOUND is an integer indicating the library release versions to use when\n");
PRINTVALSTREAM(rawoutstream, " creating objects in the file (see H5Pset_libver_bounds()):\n");
PRINTVALSTREAM(rawoutstream, " 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 3: This is H5F_LIBVER_V112 in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 4: This is H5F_LIBVER_V114 in H5F_libver_t struct\n");
- PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release\n");
+ PRINTVALSTREAM(rawoutstream,
+ " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n");
PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are free-space\n");
PRINTVALSTREAM(rawoutstream, " managers, aggregators and virtual file driver.\n");
PRINTVALSTREAM(rawoutstream, " PAGE:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space\n");
- PRINTVALSTREAM(rawoutstream, " managers with embedded paged aggregation and virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are free-space\n");
+ PRINTVALSTREAM(rawoutstream,
+ " managers with embedded paged aggregation and virtual file driver.\n");
PRINTVALSTREAM(rawoutstream, " AGGR:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are aggregators and\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are aggregators and\n");
PRINTVALSTREAM(rawoutstream, " virtual file driver.\n");
PRINTVALSTREAM(rawoutstream, " NONE:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are virtual file\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are virtual file\n");
PRINTVALSTREAM(rawoutstream, " driver.\n");
- PRINTVALSTREAM(rawoutstream, " The default strategy when not set is FSM_AGGR without persisting free-\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The default strategy when not set is FSM_AGGR without persisting free-\n");
PRINTVALSTREAM(rawoutstream, " space.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n");
PRINTVALSTREAM(rawoutstream, " The default when not set is not persisting free-space.\n");
PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be\n");
+ PRINTVALSTREAM(rawoutstream,
+ " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be\n");
PRINTVALSTREAM(rawoutstream, " tracked by the library.\n");
PRINTVALSTREAM(rawoutstream, " The default when not set is 1.\n");
PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when\n");
+ PRINTVALSTREAM(rawoutstream,
+ " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when\n");
PRINTVALSTREAM(rawoutstream, " the file space strategy PAGE is used.\n");
PRINTVALSTREAM(rawoutstream, " The default when not set is 4096.\n");
PRINTVALSTREAM(rawoutstream, "\n");
@@ -198,8 +232,10 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " <list of objects>:<name of filter>=<filter parameters>\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning apply\n");
- PRINTVALSTREAM(rawoutstream, " compression only to those objects. If no names are specified, the filter\n");
+ PRINTVALSTREAM(rawoutstream,
+ " <list of objects> is a comma separated list of object names, meaning apply\n");
+ PRINTVALSTREAM(rawoutstream,
+ " compression only to those objects. If no names are specified, the filter\n");
PRINTVALSTREAM(rawoutstream, " is applied to all objects\n");
PRINTVALSTREAM(rawoutstream, " <name of filter> can be:\n");
PRINTVALSTREAM(rawoutstream, " GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n");
@@ -212,15 +248,19 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " NONE, to remove all filters\n");
PRINTVALSTREAM(rawoutstream, " <filter parameters> is optional filter parameter information\n");
PRINTVALSTREAM(rawoutstream, " GZIP=<deflation level> from 1-9\n");
- PRINTVALSTREAM(rawoutstream, " SZIP=<pixels per block,coding> pixels per block is a even number in\n");
+ PRINTVALSTREAM(rawoutstream,
+ " SZIP=<pixels per block,coding> pixels per block is a even number in\n");
PRINTVALSTREAM(rawoutstream, " 2-32 and coding method is either EC or NN\n");
PRINTVALSTREAM(rawoutstream, " SHUF (no parameter)\n");
PRINTVALSTREAM(rawoutstream, " FLET (no parameter)\n");
PRINTVALSTREAM(rawoutstream, " NBIT (no parameter)\n");
- PRINTVALSTREAM(rawoutstream, " SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n");
+ PRINTVALSTREAM(rawoutstream,
+ " SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n");
PRINTVALSTREAM(rawoutstream, " is either IN or DS\n");
- PRINTVALSTREAM(rawoutstream, " UD=<filter_number,filter_flag,cd_value_count,value1[,value2,...,valueN]>\n");
- PRINTVALSTREAM(rawoutstream, " Required values: filter_number, filter_flag, cd_value_count, value1\n");
+ PRINTVALSTREAM(rawoutstream,
+ " UD=<filter_number,filter_flag,cd_value_count,value1[,value2,...,valueN]>\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Required values: filter_number, filter_flag, cd_value_count, value1\n");
PRINTVALSTREAM(rawoutstream, " Optional values: value2 to valueN\n");
PRINTVALSTREAM(rawoutstream, " NONE (no parameter)\n");
PRINTVALSTREAM(rawoutstream, "\n");
@@ -228,8 +268,10 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " <list of objects>:<layout type>=<layout parameters>\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning that\n");
- PRINTVALSTREAM(rawoutstream, " layout information is supplied for those objects. If no names are\n");
+ PRINTVALSTREAM(rawoutstream,
+ " <list of objects> is a comma separated list of object names, meaning that\n");
+ PRINTVALSTREAM(rawoutstream,
+ " layout information is supplied for those objects. If no names are\n");
PRINTVALSTREAM(rawoutstream, " specified, the layout type is applied to all objects\n");
PRINTVALSTREAM(rawoutstream, " <layout type> can be:\n");
PRINTVALSTREAM(rawoutstream, " CHUNK, to apply chunking layout\n");
@@ -248,11 +290,14 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "2) h5repack -v -f dset1:SZIP=8,NN file1 file2\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " SZIP compression with 8 pixels per block and NN coding method to object dset1\n");
+ PRINTVALSTREAM(rawoutstream,
+ " SZIP compression with 8 pixels per block and NN coding method to object dset1\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n");
+ PRINTVALSTREAM(rawoutstream,
+ "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n");
PRINTVALSTREAM(rawoutstream, " and remove filters to objects dset3, dset4, dset5\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "4) h5repack -L -c 10 -s 20:dtype file1 file2\n");
@@ -283,7 +328,8 @@ static void usage(const char *prog) {
* Return: Does not return
*-------------------------------------------------------------------------
*/
-static void leave(int ret)
+static void
+leave(int ret)
{
h5tools_close();
HDexit(ret);
@@ -297,15 +343,15 @@ static void leave(int ret)
* Return: void, exit on error
*-------------------------------------------------------------------------
*/
-static
-int read_info(const char *filename, pack_opt_t *options)
+static int
+read_info(const char *filename, pack_opt_t *options)
{
- char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- char comp_info[1024];
+ char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ char comp_info[1024];
FILE *fp = NULL;
- char c;
- int i;
- int ret_value = EXIT_SUCCESS;
+ char c;
+ int i;
+ int ret_value = EXIT_SUCCESS;
if (NULL == (fp = HDfopen(filename, "r"))) {
error_msg("cannot open options file %s\n", filename);
@@ -320,7 +366,7 @@ int read_info(const char *filename, pack_opt_t *options)
break;
/* Info indicator must be for layout or filter */
- if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) {
+ if (HDstrcmp(stype, "-l") && HDstrcmp(stype, "-f")) {
error_msg("bad file format for %s", filename);
h5tools_setstatus(EXIT_FAILURE);
ret_value = EXIT_FAILURE;
@@ -434,16 +480,16 @@ set_sort_order(const char *form)
* Purpose: parse command line input
*-------------------------------------------------------------------------
*/
-static
-int parse_command_line(int argc, const char **argv, pack_opt_t* options)
+static int
+parse_command_line(int argc, const char **argv, pack_opt_t *options)
{
h5tools_vol_info_t in_vol_info;
h5tools_vol_info_t out_vol_info;
- hbool_t custom_in_fapl = FALSE;
- hbool_t custom_out_fapl = FALSE;
- hid_t tmp_fapl = H5I_INVALID_HID;
- int bound, opt;
- int ret_value = 0;
+ hbool_t custom_in_fapl = FALSE;
+ hbool_t custom_out_fapl = FALSE;
+ hid_t tmp_fapl = H5I_INVALID_HID;
+ int bound, opt;
+ int ret_value = 0;
/* Initialize fapl info structs */
HDmemset(&in_vol_info, 0, sizeof(h5tools_vol_info_t));
@@ -451,7 +497,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* parse command line options */
while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) {
- switch ((char) opt) {
+ switch ((char)opt) {
/* -i for backward compatibility */
case 'i':
@@ -502,8 +548,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'm':
- options->min_comp = HDstrtoull(opt_arg , NULL, 0);
- if ((int) options->min_comp <= 0) {
+ options->min_comp = HDstrtoull(opt_arg, NULL, 0);
+ if ((int)options->min_comp <= 0) {
error_msg("invalid minimum compress size <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
@@ -559,66 +605,64 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'c':
- options->grp_compact = HDatoi( opt_arg );
+ options->grp_compact = HDatoi(opt_arg);
if (options->grp_compact > 0)
options->latest = TRUE; /* must use latest format */
break;
case 'd':
- options->grp_indexed = HDatoi( opt_arg );
+ options->grp_indexed = HDatoi(opt_arg);
if (options->grp_indexed > 0)
options->latest = TRUE; /* must use latest format */
break;
- case 's':
- {
- int idx = 0;
- int ssize = 0;
- char *msgPtr = HDstrchr(opt_arg, ':');
- options->latest = TRUE; /* must use latest format */
- if (msgPtr == NULL) {
- ssize = HDatoi(opt_arg);
- for (idx = 0; idx < 5; idx++)
- options->msg_size[idx] = ssize;
- }
- else {
- char msgType[10];
-
- HDstrcpy(msgType, msgPtr + 1);
- msgPtr[0] = '\0';
- ssize = HDatoi( opt_arg );
- if (!HDstrncmp(msgType, "dspace", 6))
- options->msg_size[0] = ssize;
- else if (!HDstrncmp(msgType, "dtype", 5))
- options->msg_size[1] = ssize;
- else if (!HDstrncmp(msgType, "fill", 4))
- options->msg_size[2] = ssize;
- else if (!HDstrncmp(msgType, "pline", 5))
- options->msg_size[3] = ssize;
- else if (!HDstrncmp(msgType, "attr", 4))
- options->msg_size[4] = ssize;
- }
+ case 's': {
+ int idx = 0;
+ int ssize = 0;
+ char *msgPtr = HDstrchr(opt_arg, ':');
+ options->latest = TRUE; /* must use latest format */
+ if (msgPtr == NULL) {
+ ssize = HDatoi(opt_arg);
+ for (idx = 0; idx < 5; idx++)
+ options->msg_size[idx] = ssize;
}
- break;
+ else {
+ char msgType[10];
+
+ HDstrcpy(msgType, msgPtr + 1);
+ msgPtr[0] = '\0';
+ ssize = HDatoi(opt_arg);
+ if (!HDstrncmp(msgType, "dspace", 6))
+ options->msg_size[0] = ssize;
+ else if (!HDstrncmp(msgType, "dtype", 5))
+ options->msg_size[1] = ssize;
+ else if (!HDstrncmp(msgType, "fill", 4))
+ options->msg_size[2] = ssize;
+ else if (!HDstrncmp(msgType, "pline", 5))
+ options->msg_size[3] = ssize;
+ else if (!HDstrncmp(msgType, "attr", 4))
+ options->msg_size[4] = ssize;
+ }
+ } break;
case 'u':
options->ublock_filename = opt_arg;
break;
case 'b':
- options->ublock_size = (hsize_t) HDatol( opt_arg );
+ options->ublock_size = (hsize_t)HDatol(opt_arg);
break;
case 'M':
- options->meta_block_size = (hsize_t) HDatol( opt_arg );
+ options->meta_block_size = (hsize_t)HDatol(opt_arg);
break;
case 't':
- options->threshold = (hsize_t) HDatol( opt_arg );
+ options->threshold = (hsize_t)HDatol(opt_arg);
break;
case 'a':
- options->alignment = HDstrtoull(opt_arg , NULL, 0);
+ options->alignment = HDstrtoull(opt_arg, NULL, 0);
if (options->alignment < 1) {
error_msg("invalid alignment size\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
@@ -627,30 +671,28 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
}
break;
- case 'S':
- {
- char strategy[MAX_NC_NAME];
-
- HDstrcpy(strategy, opt_arg);
- if (!HDstrcmp(strategy, "FSM_AGGR"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR;
- else if (!HDstrcmp(strategy, "PAGE"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE;
- else if (!HDstrcmp(strategy, "AGGR"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR;
- else if (!HDstrcmp(strategy, "NONE"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_NONE;
- else {
- error_msg("invalid file space management strategy\n", opt_arg);
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- goto done;
- }
- if (options->fs_strategy == (H5F_fspace_strategy_t)0)
- /* To distinguish the "specified" zero value */
- options->fs_strategy = (H5F_fspace_strategy_t)-1;
+ case 'S': {
+ char strategy[MAX_NC_NAME];
+
+ HDstrcpy(strategy, opt_arg);
+ if (!HDstrcmp(strategy, "FSM_AGGR"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR;
+ else if (!HDstrcmp(strategy, "PAGE"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE;
+ else if (!HDstrcmp(strategy, "AGGR"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR;
+ else if (!HDstrcmp(strategy, "NONE"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_NONE;
+ else {
+ error_msg("invalid file space management strategy\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
}
- break;
+ if (options->fs_strategy == (H5F_fspace_strategy_t)0)
+ /* To distinguish the "specified" zero value */
+ options->fs_strategy = (H5F_fspace_strategy_t)-1;
+ } break;
case 'P':
options->fs_persist = HDatoi(opt_arg);
@@ -670,7 +712,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
options->fs_pagesize = HDstrtoll(opt_arg, NULL, 0);
if (options->fs_pagesize == 0)
/* To distinguish the "specified" zero value */
- options->fs_pagesize = -1;
+ options->fs_pagesize = -1;
break;
case 'q':
@@ -696,15 +738,15 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case '1':
- in_vol_info.type = VOL_BY_VALUE;
+ in_vol_info.type = VOL_BY_VALUE;
in_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg);
- custom_in_fapl = TRUE;
+ custom_in_fapl = TRUE;
break;
case '2':
- in_vol_info.type = VOL_BY_NAME;
+ in_vol_info.type = VOL_BY_NAME;
in_vol_info.u.name = opt_arg;
- custom_in_fapl = TRUE;
+ custom_in_fapl = TRUE;
break;
case '3':
@@ -712,15 +754,15 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case '4':
- out_vol_info.type = VOL_BY_VALUE;
+ out_vol_info.type = VOL_BY_VALUE;
out_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg);
- custom_out_fapl = TRUE;
+ custom_out_fapl = TRUE;
break;
case '5':
- out_vol_info.type = VOL_BY_NAME;
+ out_vol_info.type = VOL_BY_NAME;
out_vol_info.u.name = opt_arg;
- custom_out_fapl = TRUE;
+ custom_out_fapl = TRUE;
break;
case '6':
@@ -730,12 +772,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
default:
break;
} /* end switch */
- } /* end while there are more options to parse */
+ } /* end while there are more options to parse */
/* If neither -i nor -o given, get in and out files positionally */
if (0 == (has_i + has_o)) {
if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
- infile = argv[opt_ind];
+ infile = argv[opt_ind];
outfile = argv[opt_ind + 1];
if (!HDstrcmp(infile, outfile)) {
@@ -814,10 +856,11 @@ done:
* Failure: EXIT_FAILURE(1)
*-------------------------------------------------------------------------
*/
-int main(int argc, const char **argv)
+int
+main(int argc, const char **argv)
{
- pack_opt_t options; /*the global options */
- int parse_ret;
+ pack_opt_t options; /*the global options */
+ int parse_ret;
HDmemset(&options, 0, sizeof(pack_opt_t));
@@ -879,4 +922,3 @@ done:
leave(h5tools_getstatus());
}
-
diff --git a/tools/src/h5repack/h5repack_opttable.c b/tools/src/h5repack/h5repack_opttable.c
index 56fc12d..bb90b58 100644
--- a/tools/src/h5repack/h5repack_opttable.c
+++ b/tools/src/h5repack/h5repack_opttable.c
@@ -21,24 +21,25 @@
* Purpose: initialize a pack_info_t structure
*
* Return: void
- *-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
*/
-void init_packobject(pack_info_t *obj)
+void
+init_packobject(pack_info_t *obj)
{
int j, k;
HDstrcpy(obj->path, "\0");
for (j = 0; j < H5_REPACK_MAX_NFILTERS; j++) {
- obj->filter[j].filtn = -1;
+ 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;
}
obj->chunk.rank = -1;
- obj->refobj_id = -1;
- obj->layout = H5D_LAYOUT_ERROR;
- obj->nfilters = 0;
+ obj->refobj_id = -1;
+ obj->layout = H5D_LAYOUT_ERROR;
+ obj->nfilters = 0;
}
/*-------------------------------------------------------------------------
@@ -50,7 +51,8 @@ void init_packobject(pack_info_t *obj)
*-------------------------------------------------------------------------
*/
-static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt)
+static void
+aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt)
{
if (table->objs[I].nfilters < H5_REPACK_MAX_NFILTERS)
table->objs[I].filter[table->objs[I].nfilters++] = filt;
@@ -66,7 +68,8 @@ static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_in
* Return: void
*-------------------------------------------------------------------------
*/
-static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack)
+static void
+aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack)
{
int k;
@@ -75,15 +78,14 @@ static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info
/* -2 means the NONE option, remove chunking
and set the layout to contiguous */
if (pack->chunk.rank == -2) {
- table->objs[I].layout = H5D_CONTIGUOUS;
+ table->objs[I].layout = H5D_CONTIGUOUS;
table->objs[I].chunk.rank = -2;
}
/* otherwise set the chunking type */
else {
table->objs[I].chunk.rank = pack->chunk.rank;
for (k = 0; k < pack->chunk.rank; k++)
- table->objs[I].chunk.chunk_lengths[k] =
- pack->chunk.chunk_lengths[k];
+ table->objs[I].chunk.chunk_lengths[k] = pack->chunk.chunk_lengths[k];
}
}
}
@@ -100,10 +102,10 @@ static int
aux_inctable(pack_opttbl_t *table, unsigned n_objs)
{
unsigned u;
- int ret_value = 0;
+ int ret_value = 0;
table->size += n_objs;
- table->objs = (pack_info_t*) HDrealloc(table->objs, table->size * sizeof(pack_info_t));
+ table->objs = (pack_info_t *)HDrealloc(table->objs, table->size * sizeof(pack_info_t));
if (table->objs == NULL) {
H5TOOLS_INFO("not enough memory for options table");
ret_value = -1;
@@ -116,27 +118,28 @@ aux_inctable(pack_opttbl_t *table, unsigned n_objs)
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: options_table_init
*
* Purpose: init options table
*
* Return: 0, ok, -1, fail
- *-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
*/
-int options_table_init(pack_opttbl_t **tbl) {
- unsigned int i;
+int
+options_table_init(pack_opttbl_t **tbl)
+{
+ unsigned int i;
pack_opttbl_t *table;
- int ret_value = 0;
+ int ret_value = 0;
- if (NULL == (table = (pack_opttbl_t *) HDmalloc(sizeof(pack_opttbl_t)))) {
+ if (NULL == (table = (pack_opttbl_t *)HDmalloc(sizeof(pack_opttbl_t)))) {
H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table");
}
- table->size = 30;
+ table->size = 30;
table->nelems = 0;
- if (NULL == (table->objs = (pack_info_t*) HDmalloc(table->size * sizeof(pack_info_t)))) {
+ if (NULL == (table->objs = (pack_info_t *)HDmalloc(table->size * sizeof(pack_info_t)))) {
HDfree(table);
H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table");
}
@@ -149,7 +152,6 @@ done:
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: options_table_free
*
@@ -159,7 +161,9 @@ done:
*-------------------------------------------------------------------------
*/
-int options_table_free(pack_opttbl_t *table) {
+int
+options_table_free(pack_opttbl_t *table)
+{
HDfree(table->objs);
HDfree(table);
return 0;
@@ -171,15 +175,15 @@ int options_table_free(pack_opttbl_t *table) {
* Purpose: add a layout option to the option list
*
* Return: 0, ok, -1, fail
- *-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
*/
int
-options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table)
+options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table)
{
unsigned i, j, I;
- unsigned added = 0;
- hbool_t found = FALSE;
- int ret_value = 0;
+ unsigned added = 0;
+ hbool_t found = FALSE;
+ int ret_value = 0;
/* increase the size of the collection by N_OBJS if necessary */
if (table->nelems + n_objs >= table->size)
@@ -193,7 +197,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
/* linear table search */
for (i = 0; i < table->nelems; i++) {
/*already on the table */
- if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) {
+ if (HDstrcmp(obj_list[j].obj, table->objs[i].path) == 0) {
/* already chunk info inserted for this one; exit */
if (table->objs[i].chunk.rank > 0) {
H5TOOLS_INFO("chunk information already inserted for <%s>\n", obj_list[j].obj);
@@ -206,7 +210,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
break;
}
} /* if */
- } /* i */
+ } /* i */
if (!found) {
/* keep the grow in a temp var */
@@ -220,14 +224,13 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
-f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20
dset1 is already inserted, but dset2 must also be
*/
- else
- if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- HDstrcpy(table->objs[I].path, obj_list[j].obj);
- aux_tblinsert_layout(table, I, pack);
- }
+ else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ HDstrcpy(table->objs[I].path, obj_list[j].obj);
+ aux_tblinsert_layout(table, I, pack);
+ }
} /* j */
}
/* first time insertion */
@@ -258,8 +261,8 @@ int
options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pack_opttbl_t *table)
{
unsigned int i, j, I;
- unsigned added = 0;
- hbool_t found = FALSE;
+ unsigned added = 0;
+ hbool_t found = FALSE;
/* increase the size of the collection by N_OBJS if necessary */
if (table->nelems + n_objs >= table->size)
@@ -279,7 +282,7 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa
found = TRUE;
break;
} /* if */
- } /* i */
+ } /* i */
if (!found) {
/* keep the grow in a temp var */
@@ -293,14 +296,13 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa
-l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1
dset1 is already inserted, but dset2 must also be
*/
- else
- if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- HDstrcpy(table->objs[I].path, obj_list[j].obj);
- aux_tblinsert_filter(table, I, filt);
- }
+ else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ HDstrcpy(table->objs[I].path, obj_list[j].obj);
+ aux_tblinsert_filter(table, I, filt);
+ }
} /* j */
}
@@ -329,9 +331,11 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa
*-------------------------------------------------------------------------
*/
-pack_info_t* options_get_object(const char *path, pack_opttbl_t *table) {
+pack_info_t *
+options_get_object(const char *path, pack_opttbl_t *table)
+{
unsigned int i;
- char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */
+ char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */
for (i = 0; i < table->nelems; i++) {
/* make full path (start with "/") to compare correctly */
diff --git a/tools/src/h5repack/h5repack_parse.c b/tools/src/h5repack/h5repack_parse.c
index 50ccd7a..b02f2cf 100644
--- a/tools/src/h5repack/h5repack_parse.c
+++ b/tools/src/h5repack/h5repack_parse.c
@@ -37,8 +37,9 @@
* "A,B:NONE"
*-------------------------------------------------------------------------
*/
-obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
- pack_opt_t *options, int *is_glb) {
+obj_list_t *
+parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb)
+{
size_t i, m, u;
char c;
size_t len = HDstrlen(str);
@@ -48,7 +49,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
char scomp[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char stype[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char smask[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- obj_list_t* obj_list = NULL;
+ obj_list_t *obj_list = NULL;
unsigned pixels_per_block;
/* initialize compression info */
@@ -59,7 +60,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
for (i = 0, n = 0; i < len; i++) {
c = str[i];
if (c == ':') {
- end_obj = (int) i;
+ end_obj = (int)i;
break;
}
if (c == ',')
@@ -71,13 +72,13 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
if (end_obj == -1) {
/* apply to all objects */
options->all_filter = 1;
- *is_glb = 1;
- *n_objs = 1;
+ *is_glb = 1;
+ *n_objs = 1;
}
else
*n_objs = n;
- obj_list = (obj_list_t *) HDmalloc(n * sizeof(obj_list_t));
+ 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;
@@ -85,10 +86,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
/* get object list */
if (end_obj > 0)
- for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) {
- c = str[j];
+ for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) {
+ c = str[j];
sobj[k] = c;
- if (c == ',' || j == (unsigned) (end_obj - 1)) {
+ if (c == ',' || j == (unsigned)(end_obj - 1)) {
if (c == ',')
sobj[k] = '\0';
else
@@ -101,7 +102,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/* nothing after : */
- if (end_obj + 1 == (int) len) {
+ if (end_obj + 1 == (int)len) {
if (obj_list)
HDfree(obj_list);
error_msg("input Error: Invalid compression type in <%s>\n", str);
@@ -111,25 +112,25 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
/* get filter additional parameters */
m = 0;
for (i = (size_t)(end_obj + 1), k = 0, j = 0; i < len; i++, k++) {
- c = str[i];
+ c = str[i];
scomp[k] = c;
if (c == '=' || i == len - 1) {
- if (c == '=') { /*one more parameter */
+ if (c == '=') { /*one more parameter */
scomp[k] = '\0'; /*cut space */
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- * szip has the format SZIP=<pixels per block,coding>
- * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
- * example SZIP=8,NN
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SZIP
+ * szip has the format SZIP=<pixels per block,coding>
+ * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
+ * example SZIP=8,NN
+ *-------------------------------------------------------------------------
+ */
if (HDstrcmp(scomp, "SZIP") == 0) {
l = -1; /* mask index check */
for (m = 0, u = i + 1; u < len; u++, m++) {
if (str[u] == ',') {
stype[m] = '\0'; /* end digit of szip */
- l = 0; /* start EC or NN search */
- u++; /* skip ',' */
+ l = 0; /* start EC or NN search */
+ u++; /* skip ',' */
}
c = str[u];
if (!HDisdigit(c) && l == -1) {
@@ -145,10 +146,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
l++;
if (l == 2) {
smask[l] = '\0';
- i = len - 1; /* end */
- if (HDstrcmp(smask,"NN") == 0)
+ i = len - 1; /* end */
+ if (HDstrcmp(smask, "NN") == 0)
filt->cd_values[j++] = H5_SZIP_NN_OPTION_MASK;
- else if (HDstrcmp(smask,"EC") == 0)
+ else if (HDstrcmp(smask, "EC") == 0)
filt->cd_values[j++] = H5_SZIP_EC_OPTION_MASK;
else {
error_msg("szip mask must be 'NN' or 'EC' \n");
@@ -157,29 +158,29 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
} /* u */
- } /*if */
+ } /*if */
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- * scaleoffset has the format SOFF=<scale_factor,scale_type>
- * scale_type can be
- * integer datatype, H5Z_SO_INT (IN)
- * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
- * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
- * for integer datatypes, scale_factor denotes Minimum Bits
- * for float datatypes, scale_factor denotes decimal scale factor
- * examples
- * SOFF=31,IN
- * SOFF=3,DF
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SCALEOFFSET
+ * scaleoffset has the format SOFF=<scale_factor,scale_type>
+ * scale_type can be
+ * integer datatype, H5Z_SO_INT (IN)
+ * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
+ * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
+ * for integer datatypes, scale_factor denotes Minimum Bits
+ * for float datatypes, scale_factor denotes decimal scale factor
+ * examples
+ * SOFF=31,IN
+ * SOFF=3,DF
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SOFF") == 0) {
l = -1; /* mask index check */
for (m = 0, u = i + 1; u < len; u++, m++) {
if (str[u] == ',') {
stype[m] = '\0'; /* end digit */
- l = 0; /* start 'IN' , 'DS', or 'ES' search */
- u++; /* skip ',' */
+ l = 0; /* start 'IN' , 'DS', or 'ES' search */
+ u++; /* skip ',' */
}
c = str[u];
if (!HDisdigit(c) && l == -1) {
@@ -195,8 +196,8 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
l++;
if (l == 2) {
smask[l] = '\0';
- i = len - 1; /* end */
- if (HDstrcmp(smask,"IN") == 0)
+ i = len - 1; /* end */
+ if (HDstrcmp(smask, "IN") == 0)
filt->cd_values[j++] = H5Z_SO_INT;
else if (HDstrcmp(smask, "DS") == H5Z_SO_FLOAT_DSCALE)
filt->cd_values[j++] = H5Z_SO_FLOAT_DSCALE;
@@ -207,15 +208,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
} /* u */
- } /*if */
+ } /*if */
/*-------------------------------------------------------------------------
- * User Defined
- * has the format UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]>
- * BZIP2 example
- * UD=307,0,1,9
- *-------------------------------------------------------------------------
- */
+ * User Defined
+ * has the format
+ *UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]> BZIP2 example
+ * UD=307,0,1,9
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "UD") == 0) {
l = -1; /* filter number index check */
f = -1; /* filter flag index check */
@@ -225,15 +226,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
stype[q] = '\0'; /* end digit */
if (l == -1) {
filt->filtn = HDatoi(stype);
- l = 0;
+ l = 0;
}
else if (f == -1) {
filt->filt_flag = (unsigned)HDstrtoul(stype, NULL, 0);
- f = 0;
+ f = 0;
}
else if (p == -1) {
filt->cd_nelmts = HDstrtoull(stype, NULL, 0);
- p = 0;
+ p = 0;
}
else {
filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0);
@@ -260,9 +261,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
} /*if */
/*-------------------------------------------------------------------------
- * all other filters
- *-------------------------------------------------------------------------
- */
+ * all other filters
+ *-------------------------------------------------------------------------
+ */
else {
/* here we could have 1 or 2 digits */
for (m = 0, u = i + 1; u < len; u++, m++) {
@@ -279,36 +280,36 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
stype[m] = '\0';
} /*if */
- filt->cd_values[j++] = (unsigned) HDstrtoul(stype, NULL, 0);
- if(filt->cd_nelmts == 0)
+ filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0);
+ if (filt->cd_nelmts == 0)
j = 0;
i += m; /* jump */
}
else if (i == len - 1) { /*no more parameters */
scomp[k + 1] = '\0';
- no_param = 1;
+ no_param = 1;
}
/*-------------------------------------------------------------------------
- * translate from string to filter symbol
- *-------------------------------------------------------------------------
- */
+ * translate from string to filter symbol
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_NONE
+ *-------------------------------------------------------------------------
+ */
if (HDstrcmp(scomp, "NONE") == 0) {
- filt->filtn = H5Z_FILTER_NONE;
+ filt->filtn = H5Z_FILTER_NONE;
filt->cd_nelmts = 0;
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "GZIP") == 0) {
- filt->filtn = H5Z_FILTER_DEFLATE;
+ filt->filtn = H5Z_FILTER_DEFLATE;
filt->cd_nelmts = 1;
if (no_param) { /*no more parameters, GZIP must have parameter */
if (obj_list)
@@ -319,11 +320,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SZIP") == 0) {
- filt->filtn = H5Z_FILTER_SZIP;
+ filt->filtn = H5Z_FILTER_SZIP;
filt->cd_nelmts = 2;
if (no_param) { /*no more parameters, SZIP must have parameter */
if (obj_list)
@@ -334,11 +335,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SHUFFLE
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SHUF") == 0) {
- filt->filtn = H5Z_FILTER_SHUFFLE;
+ filt->filtn = H5Z_FILTER_SHUFFLE;
filt->cd_nelmts = 0;
if (m > 0) { /*shuffle does not have parameter */
if (obj_list)
@@ -348,11 +349,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_FLETCHER32
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "FLET") == 0) {
- filt->filtn = H5Z_FILTER_FLETCHER32;
+ filt->filtn = H5Z_FILTER_FLETCHER32;
filt->cd_nelmts = 0;
if (m > 0) { /*shuffle does not have parameter */
if (obj_list)
@@ -362,11 +363,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_NBIT
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_NBIT
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "NBIT") == 0) {
- filt->filtn = H5Z_FILTER_NBIT;
+ filt->filtn = H5Z_FILTER_NBIT;
filt->cd_nelmts = 0;
if (m > 0) { /*nbit does not have parameter */
if (obj_list)
@@ -376,11 +377,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SOFF") == 0) {
- filt->filtn = H5Z_FILTER_SCALEOFFSET;
+ filt->filtn = H5Z_FILTER_SCALEOFFSET;
filt->cd_nelmts = 2;
if (no_param) { /*no more parameters, SOFF must have parameter */
if (obj_list)
@@ -390,9 +391,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * User Defined Filter
- *-------------------------------------------------------------------------
- */
+ * User Defined Filter
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "UD") == 0) {
/* parameters does not match count */
if (filt->cd_nelmts != j) {
@@ -413,56 +414,55 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
} /*i*/
/*-------------------------------------------------------------------------
- * check valid parameters
- *-------------------------------------------------------------------------
- */
+ * check valid parameters
+ *-------------------------------------------------------------------------
+ */
switch (filt->filtn) {
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_DEFLATE:
- if (filt->cd_values[0] > 9) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("invalid compression parameter in <%s>\n", str);
- HDexit(EXIT_FAILURE);
- }
- break;
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SZIP:
- pixels_per_block = filt->cd_values[0];
- if ((pixels_per_block % 2) == 1) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("pixels_per_block is not even in <%s>\n", str);
- HDexit(EXIT_FAILURE);
- }
- if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("pixels_per_block is too large in <%s>\n", str);
- HDexit(EXIT_FAILURE);
- }
- if ((HDstrcmp(smask,"NN") != 0) && (HDstrcmp(smask,"EC") != 0)) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("szip mask must be 'NN' or 'EC' \n");
- HDexit(EXIT_FAILURE);
- }
- break;
- default:
- break;
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_DEFLATE:
+ if (filt->cd_values[0] > 9) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("invalid compression parameter in <%s>\n", str);
+ HDexit(EXIT_FAILURE);
+ }
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SZIP:
+ pixels_per_block = filt->cd_values[0];
+ if ((pixels_per_block % 2) == 1) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("pixels_per_block is not even in <%s>\n", str);
+ HDexit(EXIT_FAILURE);
+ }
+ if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("pixels_per_block is too large in <%s>\n", str);
+ HDexit(EXIT_FAILURE);
+ }
+ if ((HDstrcmp(smask, "NN") != 0) && (HDstrcmp(smask, "EC") != 0)) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("szip mask must be 'NN' or 'EC' \n");
+ HDexit(EXIT_FAILURE);
+ }
+ break;
+ default:
+ break;
};
return obj_list;
}
-
/*-------------------------------------------------------------------------
* Function: parse_layout
*
@@ -484,9 +484,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
*
*-------------------------------------------------------------------------
*/
-obj_list_t* parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */
-pack_opt_t *options) {
- obj_list_t* obj_list = NULL;
+obj_list_t *
+parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */
+ pack_opt_t *options)
+{
+ obj_list_t *obj_list = NULL;
unsigned i, j, n;
char c;
size_t len = HDstrlen(str);
@@ -503,7 +505,7 @@ pack_opt_t *options) {
for (i = 0, n = 0; i < len; i++) {
c = str[i];
if (c == ':')
- end_obj = (int) i;
+ end_obj = (int)i;
if (c == ',')
n++;
}
@@ -513,7 +515,7 @@ pack_opt_t *options) {
}
n++;
- obj_list = (obj_list_t*) HDmalloc(n * sizeof(obj_list_t));
+ 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;
@@ -522,10 +524,10 @@ pack_opt_t *options) {
/* get object list */
if (end_obj > 0)
- for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) {
- c = str[j];
+ for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) {
+ c = str[j];
sobj[k] = c;
- if (c == ',' || j == (unsigned) (end_obj - 1)) {
+ if (c == ',' || j == (unsigned)(end_obj - 1)) {
if (c == ',')
sobj[k] = '\0';
else
@@ -538,7 +540,7 @@ pack_opt_t *options) {
}
/* nothing after : */
- if (end_obj + 1 == (int) len) {
+ if (end_obj + 1 == (int)len) {
if (obj_list)
HDfree(obj_list);
error_msg("in parse layout, no characters after : in <%s>\n", str);
@@ -546,7 +548,7 @@ pack_opt_t *options) {
}
/* get layout info */
- for (j = (unsigned) (end_obj + 1), n = 0; n <= 5; j++, n++) {
+ for (j = (unsigned)(end_obj + 1), n = 0; n <= 5; j++, n++) {
if (n == 5) {
slayout[n] = '\0'; /*cut string */
if (HDstrcmp(slayout, "COMPA") == 0)
@@ -561,16 +563,16 @@ pack_opt_t *options) {
}
}
else {
- c = str[j];
+ c = str[j];
slayout[n] = c;
}
} /* j */
if (pack->layout == H5D_CHUNKED) {
/*-------------------------------------------------------------------------
- * get chunk info
- *-------------------------------------------------------------------------
- */
+ * get chunk info
+ *-------------------------------------------------------------------------
+ */
k = 0;
if (j > len) {
if (obj_list)
@@ -580,7 +582,7 @@ pack_opt_t *options) {
}
for (i = j, c_index = 0; i < len; i++) {
- c = str[i];
+ c = str[i];
sdim[k] = c;
k++; /*increment sdim index */
@@ -593,8 +595,8 @@ pack_opt_t *options) {
if (c == 'x' || i == len - 1) {
if (c == 'x') {
- sdim[k - 1] = '\0';
- k = 0;
+ sdim[k - 1] = '\0';
+ k = 0;
pack->chunk.chunk_lengths[c_index] = HDstrtoull(sdim, NULL, 0);
if (pack->chunk.chunk_lengths[c_index] == 0) {
if (obj_list)
@@ -606,8 +608,8 @@ pack_opt_t *options) {
}
else if (i == len - 1) { /*no more parameters */
sdim[k] = '\0';
- k = 0;
- if (HDstrcmp(sdim,"NONE") == 0) {
+ k = 0;
+ if (HDstrcmp(sdim, "NONE") == 0) {
pack->chunk.rank = -2;
}
else {
@@ -621,9 +623,9 @@ pack_opt_t *options) {
pack->chunk.rank = c_index + 1;
}
} /*if */
- } /*if c=='x' || i==len-1 */
- } /*i*/
- } /*H5D_CHUNKED*/
+ } /*if c=='x' || i==len-1 */
+ } /*i*/
+ } /*H5D_CHUNKED*/
return obj_list;
}
diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c
index 5baabb6..78957c6 100644
--- a/tools/src/h5repack/h5repack_refs.c
+++ b/tools/src/h5repack/h5repack_refs.c
@@ -15,17 +15,15 @@
#include "h5diff.h"
#include "h5tools.h"
-
/*-------------------------------------------------------------------------
* local functions
*-------------------------------------------------------------------------
*/
-static const char* MapIdToName(hid_t refobj_id,trav_table_t *travt);
-static int copy_refs_attr(hid_t loc_in, hid_t loc_out,
- trav_table_t *travt, hid_t fidout);
-static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
- hid_t fid_out, void *ref_out, trav_table_t *travt);
+static const char *MapIdToName(hid_t refobj_id, trav_table_t *travt);
+static int copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout);
+static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, hid_t fid_out, void *ref_out,
+ trav_table_t *travt);
/*-------------------------------------------------------------------------
* Function: do_copy_refobjs
@@ -37,35 +35,33 @@ static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
*-------------------------------------------------------------------------
*/
-int do_copy_refobjs(hid_t fidin,
- hid_t fidout,
- trav_table_t *travt,
- pack_opt_t *options) /* repack options */
+int
+do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */
{
- hid_t grp_in = H5I_INVALID_HID; /* read group ID */
- hid_t grp_out = H5I_INVALID_HID; /* write group ID */
- hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */
- hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */
- hid_t type_in = H5I_INVALID_HID; /* named type ID */
- hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t space_id = H5I_INVALID_HID; /* space ID */
- hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */
- hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */
- size_t msize; /* memory size of memory type */
- hsize_t nelmts; /* number of elements in dataset */
- int rank; /* rank of dataset */
- hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
+ hid_t grp_in = H5I_INVALID_HID; /* read group ID */
+ hid_t grp_out = H5I_INVALID_HID; /* write group ID */
+ hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */
+ hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */
+ hid_t type_in = H5I_INVALID_HID; /* named type ID */
+ hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t space_id = H5I_INVALID_HID; /* space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */
+ hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */
+ size_t msize; /* memory size of memory type */
+ hsize_t nelmts; /* number of elements in dataset */
+ int rank; /* rank of dataset */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
unsigned int i, j;
- int k;
- named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
- int ret_value = 0;
+ int k;
+ named_dt_t * named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
+ int ret_value = 0;
/*-------------------------------------------------------------------------
- * browse
- *-------------------------------------------------------------------------
- */
- for(i = 0; i < travt->nobjs; i++) {
- switch(travt->objs[i].type) {
+ * browse
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0; i < travt->nobjs; i++) {
+ switch (travt->objs[i].type) {
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_GROUP
*-------------------------------------------------------------------------
@@ -75,27 +71,28 @@ int do_copy_refobjs(hid_t fidin,
* copy referenced objects in attributes
*-------------------------------------------------------------------------
*/
- if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ if ((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
- if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
- if(copy_refs_attr(grp_in, grp_out, travt, fidout) < 0)
+ if (copy_refs_attr(grp_in, grp_out, travt, fidout) < 0)
H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed");
- if(H5Gclose(grp_out) < 0)
+ if (H5Gclose(grp_out) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
- if(H5Gclose(grp_in) < 0)
+ if (H5Gclose(grp_in) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
/*-------------------------------------------------------------------------
* check for hard links
*-------------------------------------------------------------------------
*/
- if(travt->objs[i].nlinks)
- for(j = 0; j < travt->objs[i].nlinks; j++)
- H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
+ if (travt->objs[i].nlinks)
+ for (j = 0; j < travt->objs[i].nlinks; j++)
+ H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC,
+ travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
break;
/*-------------------------------------------------------------------------
@@ -103,26 +100,26 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
case H5TRAV_TYPE_DATASET:
- if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
- if((space_id = H5Dget_space(dset_in)) < 0)
+ if ((space_id = H5Dget_space(dset_in)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
- if((ftype_id = H5Dget_type(dset_in)) < 0)
+ if ((ftype_id = H5Dget_type(dset_in)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
- if((dcpl_id = H5Dget_create_plist(dset_in)) < 0)
+ if ((dcpl_id = H5Dget_create_plist(dset_in)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
- if((rank = H5Sget_simple_extent_ndims(space_id)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(space_id)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed");
- if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
nelmts = 1;
- for(k = 0; k < rank; k++)
+ for (k = 0; k < rank; k++)
nelmts *= dims[k];
- if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
+ if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed");
- if((msize = H5Tget_size(mtype_id)) == 0)
+ if ((msize = H5Tget_size(mtype_id)) == 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
/*-------------------------------------------------------------------------
@@ -132,7 +129,7 @@ int do_copy_refobjs(hid_t fidin,
* 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if(h5tools_canreadf(NULL, dcpl_id) == 1) {
+ if (h5tools_canreadf(NULL, dcpl_id) == 1) {
/*-------------------------------------------------------------------------
* test for a valid output dataset
*-------------------------------------------------------------------------
@@ -144,75 +141,78 @@ int do_copy_refobjs(hid_t fidin,
* we cannot just copy the buffers, but instead we recreate the reference
*-------------------------------------------------------------------------
*/
- if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) {
- hid_t refobj_id = H5I_INVALID_HID;
- hobj_ref_t *refbuf = NULL; /* buffer for object references */
- hobj_ref_t *buf = NULL;
- const char* refname;
- unsigned u;
+ if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) {
+ hid_t refobj_id = H5I_INVALID_HID;
+ hobj_ref_t *refbuf = NULL; /* buffer for object references */
+ hobj_ref_t *buf = NULL;
+ const char *refname;
+ unsigned u;
/*-------------------------------------------------------------------------
* read to memory
*-------------------------------------------------------------------------
*/
- if(nelmts) {
+ if (nelmts) {
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf==NULL) {
- HDprintf("cannot read into memory\n" );
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
- if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
- refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize);
- if(refbuf == NULL){
- HDprintf("cannot allocate memory\n" );
+ refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
+ if (refbuf == NULL) {
+ HDprintf("cannot allocate memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
- for(u = 0; u < nelmts; u++) {
- H5E_BEGIN_TRY {
- if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u])) < 0)
+ for (u = 0; u < nelmts; u++) {
+ H5E_BEGIN_TRY
+ {
+ if ((refobj_id =
+ H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u])) < 0)
continue;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* get the name. a valid name could only occur
* in the second traversal of the file
*/
- if((refname = MapIdToName(refobj_id, travt)) != NULL) {
+ if ((refname = MapIdToName(refobj_id, travt)) != NULL) {
/* create the reference, -1 parameter for objects */
- if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0)
+ if (H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed");
- if(options->verbose) {
- HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name );
+ if (options->verbose) {
+ HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
HDprintf("object <%s> object reference created to <%s>\n",
- travt->objs[i].name,
- refname);
+ travt->objs[i].name, refname);
}
} /*refname*/
if (H5Oclose(refobj_id) < 0)
H5TOOLS_ERROR((-1), "H5Oclose refob failed");
} /* u */
- } /*nelmts*/
+ } /*nelmts*/
/*-------------------------------------------------------------------------
* create/write dataset/close
*-------------------------------------------------------------------------
*/
- if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id,
+ H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
- if(nelmts)
- if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
+ if (nelmts)
+ if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
- if(buf)
+ if (buf)
HDfree(buf);
- if(refbuf)
+ if (refbuf)
HDfree(refbuf);
- /*------------------------------------------------------
- * copy attrs
- *----------------------------------------------------*/
- if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ /*------------------------------------------------------
+ * copy attrs
+ *----------------------------------------------------*/
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
} /*H5T_STD_REF_OBJ*/
@@ -220,87 +220,93 @@ int do_copy_refobjs(hid_t fidin,
* dataset region references
*-------------------------------------------------------------------------
*/
- else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) {
+ else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) {
hid_t refobj_id = H5I_INVALID_HID;
- hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */
- hdset_reg_ref_t *buf = NULL; /* output buffer */
- const char* refname;
+ hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */
+ hdset_reg_ref_t *buf = NULL; /* output buffer */
+ const char * refname;
unsigned u;
/*-------------------------------------------------------------------------
* read input to memory
*-------------------------------------------------------------------------
*/
- if(nelmts) {
+ if (nelmts) {
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf == NULL) {
+ if (buf == NULL) {
HDprintf("cannot read into memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
- if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
/*-------------------------------------------------------------------------
* create output
*-------------------------------------------------------------------------
*/
- refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
- if(refbuf == NULL) {
+ refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t),
+ (size_t)nelmts); /*init to zero */
+ if (refbuf == NULL) {
HDprintf("cannot allocate memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
- for(u = 0; u < nelmts; u++) {
- H5E_BEGIN_TRY {
- if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION, &buf[u])) < 0)
+ for (u = 0; u < nelmts; u++) {
+ H5E_BEGIN_TRY
+ {
+ if ((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION,
+ &buf[u])) < 0)
continue;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* get the name. a valid name could only occur
* in the second traversal of the file
*/
- if((refname = MapIdToName(refobj_id, travt)) != NULL) {
- hid_t region_id = H5I_INVALID_HID; /* region id of the referenced dataset */
+ if ((refname = MapIdToName(refobj_id, travt)) != NULL) {
+ hid_t region_id =
+ H5I_INVALID_HID; /* region id of the referenced dataset */
- if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0)
+ if ((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Rget_region failed");
/* create the reference, we need the space_id */
- if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0)
+ if (H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION,
+ region_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed");
- if(H5Sclose(region_id) < 0)
+ if (H5Sclose(region_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
- if(options->verbose) {
- HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name );
+ if (options->verbose) {
+ HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
HDprintf("object <%s> region reference created to <%s>\n",
- travt->objs[i].name,
- refname);
+ travt->objs[i].name, refname);
}
} /*refname*/
if (H5Oclose(refobj_id) < 0)
H5TOOLS_ERROR((-1), "H5Oclose refobj_id failed");
} /* u */
- } /*nelmts*/
+ } /*nelmts*/
/*-------------------------------------------------------------------------
* create/write dataset/close
*-------------------------------------------------------------------------
*/
- if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id,
+ H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
- if(nelmts)
- if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
+ if (nelmts)
+ if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
- if(buf)
+ if (buf)
HDfree(buf);
- if(refbuf)
+ if (refbuf)
HDfree(refbuf);
- /*-----------------------------------------------------
- * copy attrs
- *----------------------------------------------------*/
- if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ /*-----------------------------------------------------
+ * copy attrs
+ *----------------------------------------------------*/
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
} /* H5T_STD_REF_DSETREG */
/*-------------------------------------------------------------------------
@@ -308,7 +314,7 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
else {
- if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
} /* end else */
@@ -316,18 +322,19 @@ int do_copy_refobjs(hid_t fidin,
* copy referenced objects in attributes
*-------------------------------------------------------------------------
*/
- if(copy_refs_attr(dset_in, dset_out, travt, fidout) < 0)
+ if (copy_refs_attr(dset_in, dset_out, travt, fidout) < 0)
H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed");
/*-------------------------------------------------------------------------
* check for hard links
*-------------------------------------------------------------------------
*/
- if(travt->objs[i].nlinks)
- for(j = 0; j < travt->objs[i].nlinks; j++)
- H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
+ if (travt->objs[i].nlinks)
+ for (j = 0; j < travt->objs[i].nlinks; j++)
+ H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC,
+ travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
- if(H5Dclose(dset_out) < 0)
+ if (H5Dclose(dset_out) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
} /*can_read*/
@@ -335,15 +342,15 @@ int do_copy_refobjs(hid_t fidin,
* close
*-------------------------------------------------------------------------
*/
- if(H5Tclose(ftype_id) < 0)
+ if (H5Tclose(ftype_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if(H5Tclose(mtype_id) < 0)
+ if (H5Tclose(mtype_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if(H5Pclose(dcpl_id) < 0)
+ if (H5Pclose(dcpl_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- if(H5Sclose(space_id) < 0)
+ if (H5Sclose(space_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
- if(H5Dclose(dset_in) < 0)
+ if (H5Dclose(dset_in) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
break;
@@ -352,9 +359,9 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
case H5TRAV_TYPE_NAMED_DATATYPE:
- if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed");
- if(H5Tclose(type_in) < 0)
+ if (H5Tclose(type_in) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
break;
@@ -374,7 +381,7 @@ int do_copy_refobjs(hid_t fidin,
default:
break;
} /* end switch */
- } /* end for */
+ } /* end for */
/* Finalize (link) the stack of named datatypes (if any)
* This function is paired with copy_named_datatype() which is called
@@ -386,7 +393,8 @@ int do_copy_refobjs(hid_t fidin,
return ret_value;
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Gclose(grp_in);
H5Gclose(grp_out);
H5Pclose(dcpl_id);
@@ -397,12 +405,12 @@ done:
H5Tclose(mtype_id);
H5Tclose(type_in);
named_datatype_free(&named_dt_head, 1);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: copy_refs_attr
*
@@ -425,91 +433,87 @@ done:
*-------------------------------------------------------------------------
*/
-static int copy_refs_attr(hid_t loc_in,
- hid_t loc_out,
- trav_table_t *travt,
- hid_t fidout) /* for saving references */
+static int
+copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout) /* for saving references */
{
- hid_t attr_id = H5I_INVALID_HID; /* attr ID */
- hid_t attr_out = H5I_INVALID_HID; /* attr ID */
- hid_t space_id = H5I_INVALID_HID; /* space ID */
- hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */
- hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */
- size_t msize; /* memory size of type */
- hsize_t nelmts; /* number of elements in dataset */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
+ hid_t attr_id = H5I_INVALID_HID; /* attr ID */
+ hid_t attr_out = H5I_INVALID_HID; /* attr ID */
+ hid_t space_id = H5I_INVALID_HID; /* space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */
+ hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */
+ size_t msize; /* memory size of type */
+ hsize_t nelmts; /* number of elements in dataset */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
char name[255];
- H5O_info2_t oinfo; /* Object info */
+ H5O_info2_t oinfo; /* Object info */
unsigned u, i, j;
int rank;
H5T_class_t type_class = -1;
- hbool_t is_ref = 0,
- is_ref_vlen = 0,
- is_ref_array = 0,
- is_ref_comp = 0;
- void *refbuf = NULL;
- void *buf = NULL;
- unsigned *ref_comp_index = NULL;
- size_t *ref_comp_size = NULL;
+ hbool_t is_ref = 0, is_ref_vlen = 0, is_ref_array = 0, is_ref_comp = 0;
+ void * refbuf = NULL;
+ void * buf = NULL;
+ unsigned * ref_comp_index = NULL;
+ size_t * ref_comp_size = NULL;
int ref_comp_field_n = 0;
- int ret_value = 0;
+ int ret_value = 0;
- if(H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
+ if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed");
- for(u = 0; u < (unsigned)oinfo.num_attrs; u++) {
+ for (u = 0; u < (unsigned)oinfo.num_attrs; u++) {
is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0;
/* open attribute */
- if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed");
/* get the file datatype */
- if((ftype_id = H5Aget_type(attr_id)) < 0)
+ if ((ftype_id = H5Aget_type(attr_id)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed");
type_class = H5Tget_class(ftype_id);
- if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
+ if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed");
- if((msize = H5Tget_size(mtype_id)) == 0)
+ if ((msize = H5Tget_size(mtype_id)) == 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
is_ref = (type_class == H5T_REFERENCE);
- if(type_class == H5T_VLEN ) {
+ if (type_class == H5T_VLEN) {
hid_t base_type = H5Tget_super(ftype_id);
is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE);
- msize = H5Tget_size(base_type);
+ msize = H5Tget_size(base_type);
if (H5Tclose(base_type) < 0)
H5TOOLS_ERROR((-1), "H5Tclose base_type failed");
}
- else if(type_class == H5T_ARRAY ) {
+ else if (type_class == H5T_ARRAY) {
hid_t base_type = H5Tget_super(ftype_id);
is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE);
- msize = H5Tget_size(base_type);
+ msize = H5Tget_size(base_type);
if (H5Tclose(base_type) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose base_type failed");
}
- else if(type_class == H5T_COMPOUND) {
- int nmembers = H5Tget_nmembers(ftype_id) ;
+ else if (type_class == H5T_COMPOUND) {
+ int nmembers = H5Tget_nmembers(ftype_id);
if (nmembers < 1)
H5TOOLS_GOTO_ERROR((-1), "H5Tget_nmembers failed");
- ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers*sizeof(unsigned));
- ref_comp_size = (size_t *)HDmalloc((size_t)nmembers*sizeof(ref_comp_size));
+ ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers * sizeof(unsigned));
+ ref_comp_size = (size_t *)HDmalloc((size_t)nmembers * sizeof(ref_comp_size));
ref_comp_field_n = 0;
- for (i=0; i<(unsigned)nmembers; i++) {
+ for (i = 0; i < (unsigned)nmembers; i++) {
hid_t mtid = H5Tget_member_type(ftype_id, i);
if ((H5Tget_class(mtid) == H5T_REFERENCE)) {
ref_comp_index[ref_comp_field_n] = i;
- ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
+ ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
ref_comp_field_n++;
}
if (H5Tclose(mtid) < 0)
@@ -539,7 +543,6 @@ static int copy_refs_attr(hid_t loc_in,
is_ref_comp = (ref_comp_field_n > 0);
}
-
if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) {
if (H5Tclose(mtype_id) < 0)
H5TOOLS_ERROR((-1), "H5Tclose mtype_id failed");
@@ -551,31 +554,30 @@ static int copy_refs_attr(hid_t loc_in,
}
/* get name */
- if(H5Aget_name(attr_id, 255, name) < 0)
+ if (H5Aget_name(attr_id, 255, name) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aget_name failed");
/* get the dataspace handle */
- if((space_id = H5Aget_space(attr_id)) < 0)
+ if ((space_id = H5Aget_space(attr_id)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed");
/* get dimensions */
- if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0)
+ if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
-
/*-------------------------------------------------------------------------
- * elements
- *-------------------------------------------------------------------------
- */
+ * elements
+ *-------------------------------------------------------------------------
+ */
nelmts = 1;
- for(j = 0; j < (unsigned)rank; j++)
+ for (j = 0; j < (unsigned)rank; j++)
nelmts *= dims[j];
if (is_ref_array) {
- unsigned array_rank = 0;
- hsize_t array_size = 1;
- hsize_t array_dims[H5S_MAX_RANK];
- hid_t base_type = H5Tget_super(ftype_id);
+ unsigned array_rank = 0;
+ hsize_t array_size = 1;
+ hsize_t array_dims[H5S_MAX_RANK];
+ hid_t base_type = H5Tget_super(ftype_id);
msize = H5Tget_size(base_type);
if (H5Tclose(base_type) < 0)
@@ -583,153 +585,163 @@ static int copy_refs_attr(hid_t loc_in,
array_rank = (unsigned)H5Tget_array_ndims(mtype_id);
H5Tget_array_dims2(mtype_id, array_dims);
- for(j = 0; j <array_rank; j++)
+ for (j = 0; j < array_rank; j++)
array_size *= array_dims[j];
nelmts *= array_size;
}
- if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed");
- if (nelmts>0) {
+ if (nelmts > 0) {
/* handle object references */
- if((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE==msize)) {
+ if ((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE == msize)) {
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf == NULL) {
+ if (buf == NULL) {
HDprintf("cannot read into memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
- if(H5Aread(attr_id, mtype_id, buf) < 0)
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
- if(refbuf == NULL) {
+ if (refbuf == NULL) {
HDprintf("cannot allocate memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
- for(i = 0; i < (unsigned)nelmts; i++)
- if(update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, &((hobj_ref_t *)refbuf)[i], travt) < 0)
+ for (i = 0; i < (unsigned)nelmts; i++)
+ if (update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout,
+ &((hobj_ref_t *)refbuf)[i], travt) < 0)
continue;
} /* H5T_STD_REF_OBJ */
/* handle region references */
- else if((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) {
+ else if ((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) {
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf == NULL) {
- HDprintf( "cannot read into memory\n" );
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
- if(H5Aread(attr_id, mtype_id, buf) < 0)
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
/*-------------------------------------------------------------------------
* create output
*-------------------------------------------------------------------------
*/
- refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
- if(refbuf == NULL) {
- HDprintf( "cannot allocate memory\n" );
+ refbuf =
+ (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
+ if (refbuf == NULL) {
+ HDprintf("cannot allocate memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
- for(i = 0; i < (unsigned)nelmts; i++)
- if(update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, &((hdset_reg_ref_t *)refbuf)[i], travt) < 0)
+ for (i = 0; i < (unsigned)nelmts; i++)
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout,
+ &((hdset_reg_ref_t *)refbuf)[i], travt) < 0)
continue;
} /* H5T_STD_REF_DSETREG */
else if (is_ref_vlen) {
/* handle VLEN of references */
- buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t)));
+ buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t)));
refbuf = buf; /* reuse the read buffer for write */
- if(buf == NULL) {
- HDprintf( "cannot read into memory\n" );
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
- if(H5Aread(attr_id, mtype_id, buf) < 0)
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
- if (H5R_OBJ_REF_BUF_SIZE==msize) {
+ if (H5R_OBJ_REF_BUF_SIZE == msize) {
hobj_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
+ for (i = 0; i < (unsigned)nelmts; i++) {
hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0)
+ for (j = 0; j < ((hvl_t *)buf)[i].len; j++) {
+ if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt) < 0)
continue;
HDmemcpy(&(ptr[j]), &ref_out, msize);
}
- } /* for (i=0; i<nelems; i++) */
+ } /* for (i=0; i<nelems; i++) */
}
else if (H5R_DSET_REG_REF_BUF_SIZE == msize) {
hdset_reg_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
+ for (i = 0; i < (unsigned)nelmts; i++) {
hdset_reg_ref_t *ptr = (hdset_reg_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, travt)<0)
+ for (j = 0; j < ((hvl_t *)buf)[i].len; j++) {
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out,
+ travt) < 0)
continue;
HDmemcpy(&(ptr[j]), &ref_out, msize);
}
- } /* for (i=0; i<nelems; i++) */
+ } /* for (i=0; i<nelems; i++) */
}
} /* else if (is_ref_vlen) */
else if (is_ref_comp) {
/* handle ref fields in a compound */
- buf = HDmalloc((unsigned)(nelmts * msize));
+ buf = HDmalloc((unsigned)(nelmts * msize));
refbuf = buf; /* reuse the read buffer for write */
- if(buf == NULL) {
- HDprintf( "cannot read into memory\n" );
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
- if(H5Aread(attr_id, mtype_id, buf) < 0)
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
- for (i=0; i<(unsigned)nelmts; i++) {
- for (j=0; j<(unsigned)ref_comp_field_n; j++) {
+ for (i = 0; i < (unsigned)nelmts; i++) {
+ for (j = 0; j < (unsigned)ref_comp_field_n; j++) {
if (ref_comp_size[j] == H5R_OBJ_REF_BUF_SIZE) {
- size_t idx = (i * msize) + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
+ size_t idx = (i * msize) + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
hobj_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_OBJECT, (hobj_ref_t *)((void *)(((char *)buf)+idx)), fidout, &ref_out, travt) < 0) /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */
+ if (update_ref_value(attr_id, H5R_OBJECT,
+ (hobj_ref_t *)((void *)(((char *)buf) + idx)), fidout,
+ &ref_out,
+ travt) < 0) /* Extra (void *) cast to quiet "cast to create
+ alignment" warning - 2019/07/05, QAK */
continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ HDmemcpy(((char *)buf) + idx, &ref_out, ref_comp_size[j]);
} /* if */
else if (ref_comp_size[j] == H5R_DSET_REG_REF_BUF_SIZE) {
size_t idx = i * msize + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
hdset_reg_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_DATASET_REGION, (hdset_reg_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
+ if (update_ref_value(attr_id, H5R_DATASET_REGION,
+ (hdset_reg_ref_t *)(((char *)buf) + idx), fidout, &ref_out,
+ travt) < 0)
continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ HDmemcpy(((char *)buf) + idx, &ref_out, ref_comp_size[j]);
} /* else if */
- } /* j */
- } /* i */
- } /* else if (is_ref_comp) */
+ } /* j */
+ } /* i */
+ } /* else if (is_ref_comp) */
- if(H5Awrite(attr_out, mtype_id, refbuf) < 0)
+ if (H5Awrite(attr_out, mtype_id, refbuf) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed");
if (is_ref_vlen && buf)
- H5Treclaim (mtype_id, space_id, H5P_DEFAULT, buf);
+ H5Treclaim(mtype_id, space_id, H5P_DEFAULT, buf);
} /* if (nelmts) */
if (refbuf == buf)
refbuf = NULL; /* set it to NULL to avoid double free since buf and refbuf are the same. */
- if(buf) {
+ if (buf) {
HDfree(buf);
buf = NULL;
}
- if(refbuf) {
+ if (refbuf) {
HDfree(refbuf);
refbuf = NULL;
}
@@ -744,27 +756,27 @@ static int copy_refs_attr(hid_t loc_in,
ref_comp_size = NULL;
}
- if(H5Aclose(attr_out) < 0)
+ if (H5Aclose(attr_out) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Tclose(ftype_id) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tclose(ftype_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if(H5Tclose(mtype_id) < 0)
+ if (H5Tclose(mtype_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- if(H5Sclose(space_id) < 0)
+ if (H5Sclose(space_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
} /* for(u = 0; u < (unsigned)oinfo.num_attrs; u++) */
done:
- if(refbuf)
+ if (refbuf)
HDfree(refbuf);
- if(buf)
+ if (buf)
HDfree(buf);
if (ref_comp_index)
@@ -773,13 +785,15 @@ done:
if (ref_comp_size)
HDfree(ref_comp_size);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(ftype_id);
H5Tclose(mtype_id);
H5Sclose(space_id);
H5Aclose(attr_id);
H5Aclose(attr_out);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
}
@@ -791,32 +805,32 @@ done:
*
*-------------------------------------------------------------------------
*/
-static const char*
+static const char *
MapIdToName(hid_t refobj_id, trav_table_t *travt)
{
unsigned int u;
- const char *ret = NULL;
+ const char * ret = NULL;
/* linear search */
- for(u = 0; u < travt->nobjs; u++) {
- if(travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET ||
- travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP ||
- travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) {
- H5O_info2_t ref_oinfo; /* Stat for the refobj id */
+ for (u = 0; u < travt->nobjs; u++) {
+ if (travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET ||
+ travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP ||
+ travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) {
+ H5O_info2_t ref_oinfo; /* Stat for the refobj id */
int token_cmp;
/* obtain information to identify the referenced object uniquely */
- if(H5Oget_info3(refobj_id, &ref_oinfo, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(refobj_id, &ref_oinfo, H5O_INFO_BASIC) < 0)
goto out;
- if(H5Otoken_cmp(refobj_id, &ref_oinfo.token, &travt->objs[u].obj_token, &token_cmp) < 0)
+ if (H5Otoken_cmp(refobj_id, &ref_oinfo.token, &travt->objs[u].obj_token, &token_cmp) < 0)
goto out;
- if(!token_cmp) {
+ if (!token_cmp) {
ret = travt->objs[u].name;
goto out;
}
- } /* end if */
- } /* u */
+ } /* end if */
+ } /* u */
out:
return ret;
@@ -828,13 +842,14 @@ out:
* Purpose: Update a reference value
*-------------------------------------------------------------------------
*/
-static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
- hid_t fid_out, void *ref_out, trav_table_t *travt)
+static herr_t
+update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, hid_t fid_out, void *ref_out,
+ trav_table_t *travt)
{
const char *ref_obj_name;
- hid_t space_id = H5I_INVALID_HID;
+ hid_t space_id = H5I_INVALID_HID;
hid_t ref_obj_id = H5I_INVALID_HID;
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in);
if (ref_obj_id < 0)
@@ -850,15 +865,16 @@ static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
H5TOOLS_GOTO_ERROR(FAIL, "H5Rget_region failed");
}
- if(H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0)
+ if (H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Rcreate failed");
done:
- H5E_BEGIN_TRY {
- H5Sclose(space_id);
- H5Oclose(ref_obj_id);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ H5Sclose(space_id);
+ H5Oclose(ref_obj_id);
+ }
+ H5E_END_TRY;
return ret_value;
}
-
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index 7bb5dfd..4149729 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -17,13 +17,12 @@
/* number of members in an array */
#ifndef NELMTS
-# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
+#define NELMTS(X) (sizeof(X) / sizeof(X[0]))
#endif
static int verify_layout(hid_t pid, pack_info_t *obj);
static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter);
-
/*-------------------------------------------------------------------------
* Function: h5repack_verify
*
@@ -39,62 +38,62 @@ 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)
{
- hid_t fidin = H5I_INVALID_HID; /* file ID for input file*/
- hid_t fidout = H5I_INVALID_HID; /* file ID for output file*/
- hid_t did = H5I_INVALID_HID; /* dataset ID */
- hid_t pid = H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t sid = H5I_INVALID_HID; /* space ID */
- hid_t tid = H5I_INVALID_HID; /* type ID */
- int ok = 1; /* step results */
- unsigned int i;
- trav_table_t *travt = NULL;
- hid_t fcpl_in = H5I_INVALID_HID; /* file creation property for input file */
- hid_t fcpl_out = H5I_INVALID_HID; /* 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 */
- int ret_value = 0;
+ hid_t fidin = H5I_INVALID_HID; /* file ID for input file*/
+ hid_t fidout = H5I_INVALID_HID; /* file ID for output file*/
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+ hid_t pid = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t sid = H5I_INVALID_HID; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* type ID */
+ int ok = 1; /* step results */
+ unsigned int i;
+ trav_table_t * travt = NULL;
+ hid_t fcpl_in = H5I_INVALID_HID; /* file creation property for input file */
+ hid_t fcpl_out = H5I_INVALID_HID; /* 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 */
+ int ret_value = 0;
/* open the output file */
- if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
+ if ((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on <%s>", out_fname);
- for(i = 0; i < options->op_tbl->nelems; i++) {
- char *name = options->op_tbl->objs[i].path;
- pack_info_t *obj = &options->op_tbl->objs[i];
+ for (i = 0; i < options->op_tbl->nelems; i++) {
+ char * name = options->op_tbl->objs[i].path;
+ pack_info_t *obj = &options->op_tbl->objs[i];
- /*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
+ /*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name);
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
- if((pid = H5Dget_create_plist(did)) < 0)
+ if ((pid = H5Dget_create_plist(did)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
- /*-------------------------------------------------------------------------
- * filter check
- *-------------------------------------------------------------------------
- */
- if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
+ /*-------------------------------------------------------------------------
+ * filter check
+ *-------------------------------------------------------------------------
+ */
+ if (verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
ok = 0;
- /*-------------------------------------------------------------------------
- * layout check
- *-------------------------------------------------------------------------
- */
- if((obj->layout != -1) && (verify_layout(pid, obj) == 0))
+ /*-------------------------------------------------------------------------
+ * layout check
+ *-------------------------------------------------------------------------
+ */
+ if ((obj->layout != -1) && (verify_layout(pid, obj) == 0))
ok = 0;
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
if (H5Pclose(pid) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Sclose(sid) < 0)
@@ -105,65 +104,65 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
}
- /*-------------------------------------------------------------------------
- * check for the "all" objects option
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * check for the "all" objects option
+ *-------------------------------------------------------------------------
+ */
- if(options->all_filter == 1 || options->all_layout == 1) {
+ if (options->all_filter == 1 || options->all_layout == 1) {
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
trav_table_init(fidout, &travt);
/* get the list of objects in the file */
- if(h5trav_gettable(fidout, travt) < 0)
+ if (h5trav_gettable(fidout, travt) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
- for(i = 0; i < travt->nobjs; i++) {
+ for (i = 0; i < travt->nobjs; i++) {
char *name = travt->objs[i].name;
- if(travt->objs[i].type == H5TRAV_TYPE_DATASET) {
- /*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
+ if (travt->objs[i].type == H5TRAV_TYPE_DATASET) {
+ /*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name);
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
- if((pid = H5Dget_create_plist(did)) < 0)
+ if ((pid = H5Dget_create_plist(did)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
- /*-------------------------------------------------------------------------
- * filter check
- *-------------------------------------------------------------------------
- */
- if(options->all_filter == 1) {
- if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
+ /*-------------------------------------------------------------------------
+ * filter check
+ *-------------------------------------------------------------------------
+ */
+ if (options->all_filter == 1) {
+ if (verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
ok = 0;
}
- /*-------------------------------------------------------------------------
- * layout check
- *-------------------------------------------------------------------------
- */
- if(options->all_layout == 1) {
+ /*-------------------------------------------------------------------------
+ * layout check
+ *-------------------------------------------------------------------------
+ */
+ if (options->all_layout == 1) {
pack_info_t pack;
init_packobject(&pack);
pack.layout = options->layout_g;
- pack.chunk = options->chunk_g;
- if(verify_layout(pid, &pack) == 0)
+ pack.chunk = options->chunk_g;
+ if (verify_layout(pid, &pack) == 0)
ok = 0;
}
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
if (H5Pclose(pid) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Sclose(sid) < 0)
@@ -173,45 +172,47 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
if (H5Tclose(tid) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
} /* if */
- } /* i */
+ } /* i */
/* free table */
trav_table_free(travt);
travt = NULL;
}
- /*-------------------------------------------------------------------------
- * Verify that file space info are set as expected
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Verify that file space info are set as expected
+ *-------------------------------------------------------------------------
+ */
/* open the input file */
- if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on file <%s>", in_fname);
/* Get file creation property list for input file */
- if((fcpl_in = H5Fget_create_plist(fidin)) < 0)
+ if ((fcpl_in = H5Fget_create_plist(fidin)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list");
/* Get file space info for input file */
- if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
+ if (H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
+ H5TOOLS_GOTO_ERROR((-1),
+ "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
/* Get file space page size for input file */
- if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
+ if (H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size");
/* Output file is already opened */
/* Get file creation property list for output file */
- if((fcpl_out = H5Fget_create_plist(fidout)) < 0)
+ if ((fcpl_out = H5Fget_create_plist(fidout)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list");
/* Get file space info for output file */
- if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
+ if (H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0)
+ H5TOOLS_GOTO_ERROR((-1),
+ "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
/* Get file space page size for output file */
- if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0)
+ if (H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size");
/*
@@ -219,12 +220,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* If -S option is not set, the file space handling strategy should be
* the same as the input file's strategy.
*/
- if(options->fs_strategy) {
- if(out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy))
+ if (options->fs_strategy) {
+ if (out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy))
H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected");
}
else {
- if(out_strategy != in_strategy)
+ if (out_strategy != in_strategy)
H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected");
}
@@ -233,12 +234,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* If the -P option is not set, the free-space persist status should be
* the same as the input file's free-space persist status
*/
- if(options->fs_persist) {
- if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist))
+ if (options->fs_persist) {
+ if (out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist))
H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected");
}
else {
- if(out_persist != in_persist)
+ if (out_persist != in_persist)
H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected");
}
@@ -247,12 +248,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* If the -T option is not set, the threshold should be the same as the
* input file's threshold size.
*/
- if(options->fs_threshold) {
- if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold))
+ if (options->fs_threshold) {
+ if (out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold))
H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected");
}
else {
- if(out_threshold != in_threshold)
+ if (out_threshold != in_threshold)
H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected");
}
@@ -261,20 +262,20 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* If the -G option is not set, the file space page size should be
* the same as the input file's file space page size.
*/
- if(options->fs_pagesize) {
- if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize))
+ if (options->fs_pagesize) {
+ if (out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize))
H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected");
}
else { /* "-G" is not set */
- if(out_pagesize != in_pagesize)
+ if (out_pagesize != in_pagesize)
H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected");
-
}
ret_value = ok;
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(fcpl_in);
H5Pclose(fcpl_out);
H5Pclose(pid);
@@ -285,7 +286,8 @@ done:
H5Fclose(fidout);
if (travt)
trav_table_free(travt);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
} /* h5repack_verify() */
@@ -305,13 +307,14 @@ done:
*-------------------------------------------------------------------------
*/
-int verify_layout(hid_t pid, pack_info_t *obj)
+int
+verify_layout(hid_t pid, pack_info_t *obj)
{
- hsize_t chsize[64]; /* chunk size in elements */
- H5D_layout_t layout; /* layout */
- int nfilters; /* number of filters */
- int rank; /* rank */
- int i; /* index */
+ hsize_t chsize[64]; /* chunk size in elements */
+ H5D_layout_t layout; /* layout */
+ int nfilters; /* number of filters */
+ int rank; /* rank */
+ int i; /* index */
/* check if we have filters in the input object */
if ((nfilters = H5Pget_nfilters(pid)) < 0)
@@ -328,8 +331,8 @@ int verify_layout(hid_t pid, pack_info_t *obj)
if (obj->layout != layout)
return 0;
- if (layout==H5D_CHUNKED) {
- if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize/*out*/)) < 0)
+ if (layout == H5D_CHUNKED) {
+ if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize /*out*/)) < 0)
return -1;
if (obj->chunk.rank != rank)
return 0;
@@ -353,49 +356,50 @@ int verify_layout(hid_t pid, pack_info_t *obj)
*-------------------------------------------------------------------------
*/
-int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl)
+int
+h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl)
{
- hid_t fid1 = H5I_INVALID_HID; /* file ID */
- hid_t fid2 = H5I_INVALID_HID; /* file ID */
- hid_t dset1 = H5I_INVALID_HID; /* dataset ID */
- hid_t dset2 = H5I_INVALID_HID; /* dataset ID */
- hid_t gid = H5I_INVALID_HID; /* group ID */
- hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t gcplid = H5I_INVALID_HID; /* group creation property list */
- unsigned crt_order_flag1; /* group creation order flag */
- unsigned crt_order_flag2; /* group creation order flag */
+ hid_t fid1 = H5I_INVALID_HID; /* file ID */
+ hid_t fid2 = H5I_INVALID_HID; /* file ID */
+ hid_t dset1 = H5I_INVALID_HID; /* dataset ID */
+ hid_t dset2 = H5I_INVALID_HID; /* dataset ID */
+ hid_t gid = H5I_INVALID_HID; /* group ID */
+ hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t gcplid = H5I_INVALID_HID; /* 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;
int ret_value = 1;
- /*-------------------------------------------------------------------------
- * open the files
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * open the files
+ *-------------------------------------------------------------------------
+ */
/* Open the files */
if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
- /*-------------------------------------------------------------------------
- * get file table list of objects
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * get file table list of objects
+ *-------------------------------------------------------------------------
+ */
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
trav_table_init(fid1, &trav);
- if(h5trav_gettable(fid1, trav) < 0)
+ if (h5trav_gettable(fid1, trav) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
- /*-------------------------------------------------------------------------
- * traverse the suppplied object list
- *-------------------------------------------------------------------------
- */
- for(i = 0; i < trav->nobjs; i++) {
- if(trav->objs[i].type == H5TRAV_TYPE_GROUP) {
+ /*-------------------------------------------------------------------------
+ * traverse the suppplied object list
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0; i < trav->nobjs; i++) {
+ if (trav->objs[i].type == H5TRAV_TYPE_GROUP) {
if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on first <%s>", trav->objs[i].name);
if ((gcplid = H5Gget_create_plist(gid)) < 0)
@@ -421,40 +425,40 @@ int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, h
if (crt_order_flag1 != crt_order_flag2)
H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name);
}
- else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) {
- if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
+ else if (trav->objs[i].type == H5TRAV_TYPE_DATASET) {
+ if ((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on first <%s>", trav->objs[i].name);
- if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
+ if ((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on second <%s>", trav->objs[i].name);
- if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
+ if ((dcpl1 = H5Dget_create_plist(dset1)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
- if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
+ if ((dcpl2 = H5Dget_create_plist(dset2)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
- /*-------------------------------------------------------------------------
- * compare the property lists
- *-------------------------------------------------------------------------
- */
- if((ret_value = H5Pequal(dcpl1, dcpl2)) < 0)
+ /*-------------------------------------------------------------------------
+ * compare the property lists
+ *-------------------------------------------------------------------------
+ */
+ if ((ret_value = H5Pequal(dcpl1, dcpl2)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pequal failed");
- if(ret_value == 0)
+ if (ret_value == 0)
H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name);
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Pclose(dcpl1) < 0)
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Pclose(dcpl1) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- if(H5Pclose(dcpl2) < 0)
+ if (H5Pclose(dcpl2) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
- if(H5Dclose(dset1) < 0)
+ if (H5Dclose(dset1) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
- if(H5Dclose(dset2) < 0)
+ if (H5Dclose(dset2) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
} /*if*/
- } /*for*/
+ } /*for*/
done:
H5E_BEGIN_TRY
@@ -467,14 +471,14 @@ done:
H5Fclose(fid2);
H5Pclose(gcplid);
H5Gclose(gid);
- if(trav)
+ if (trav)
trav_table_free(trav);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: verify_filters
*
@@ -489,27 +493,25 @@ done:
*-------------------------------------------------------------------------
*/
-static
-int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
+static int
+verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
{
- int nfilters_dcpl; /* number of filters in DCPL*/
- 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_name[256]; /* filter name */
- size_t size; /* type size */
- int i; /* index */
- unsigned j; /* index */
+ int nfilters_dcpl; /* number of filters in DCPL*/
+ 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_name[256]; /* filter name */
+ size_t size; /* type size */
+ int i; /* index */
+ unsigned j; /* index */
/* get information about filters */
- if((nfilters_dcpl = H5Pget_nfilters(pid)) < 0)
+ if ((nfilters_dcpl = H5Pget_nfilters(pid)) < 0)
return -1;
/* if we do not have filters and the requested filter is NONE, return 1 */
- if(!nfilters_dcpl &&
- nfilters == 1 &&
- filter[0].filtn == H5Z_FILTER_NONE)
+ if (!nfilters_dcpl && nfilters == 1 && filter[0].filtn == H5Z_FILTER_NONE)
return 1;
/* else the numbers of filters must match */
@@ -523,8 +525,8 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
for (i = 0; i < nfilters_dcpl; i++) {
cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_name), f_name, NULL);
+ filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name,
+ NULL);
/* filter ID */
if (filtn < 0)
@@ -535,7 +537,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
/* compare client data values. some filters do return local values */
switch (filtn) {
case H5Z_FILTER_NONE:
- break;
+ break;
case H5Z_FILTER_SHUFFLE:
/* 1 private client value is returned by DCPL */
@@ -543,7 +545,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
return 0;
/* get dataset's type size */
- if((size = H5Tget_size(tid)) <= 0)
+ if ((size = H5Tget_size(tid)) <= 0)
return -1;
/* the private client value holds the dataset's type size */