summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2008-09-19 18:57:28 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2008-09-19 18:57:28 (GMT)
commitd8e10727326798447c458d91f1509cc844ecd080 (patch)
tree3ddc03401b9dbcf02dda056b064da11c41a216e4 /tools/h5repack
parent8436735388f192ecc19b76ac043117a3d883fa14 (diff)
downloadhdf5-d8e10727326798447c458d91f1509cc844ecd080.zip
hdf5-d8e10727326798447c458d91f1509cc844ecd080.tar.gz
hdf5-d8e10727326798447c458d91f1509cc844ecd080.tar.bz2
[svn-r15662] Cleaned compiler warnings
Bug fixes: change the options block size variable from int to hsize_t, to match the H5Pset_userblock call, do not print print compression ratio when the requested filter is NONE Tested: windows, linux
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/h5repack.c22
-rw-r--r--tools/h5repack/h5repack_copy.c366
-rw-r--r--tools/h5repack/h5repack_filters.c94
-rw-r--r--tools/h5repack/h5repack_main.c68
-rw-r--r--tools/h5repack/h5repack_opttable.c2
-rw-r--r--tools/h5repack/h5repack_parse.c16
-rw-r--r--tools/h5repack/h5repack_refs.c4
-rw-r--r--tools/h5repack/h5repack_verify.c12
8 files changed, 285 insertions, 299 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 8408778..2d3ff65 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -101,9 +101,9 @@ int h5repack_init (pack_opt_t *options,
for ( n = 0; n < H5_REPACK_MAX_NFILTERS; n++)
{
options->filter_g[n].filtn = -1;
- options->filter_g[n].cd_nelmts = -1;
+ options->filter_g[n].cd_nelmts = 0;
for ( k = 0; k < CD_VALUES; k++)
- options->filter_g[n].cd_values[k] = -1;
+ options->filter_g[n].cd_values[k] = 0;
}
return (options_table_init(&(options->op_tbl)));
@@ -520,18 +520,18 @@ static int check_objects(const char* fname,
/* chunk size must be smaller than pixels per block */
case H5Z_FILTER_SZIP:
{
- int j;
- int csize = 1;
- int ppb = options->op_tbl->objs[i].filter->cd_values[0];
- hsize_t dims[H5S_MAX_RANK];
- int rank;
- hid_t did;
- hid_t sid;
+ int j;
+ hsize_t csize = 1;
+ unsigned ppb = options->op_tbl->objs[i].filter->cd_values[0];
+ hsize_t dims[H5S_MAX_RANK];
+ int rank;
+ hid_t did;
+ hid_t sid;
if(options->op_tbl->objs[i].chunk.rank > 0) {
rank = options->op_tbl->objs[i].chunk.rank;
for(j = 0; j < rank; j++)
- csize *= (int)options->op_tbl->objs[i].chunk.chunk_lengths[j];
+ csize *= options->op_tbl->objs[i].chunk.chunk_lengths[j];
}
else {
if((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
@@ -544,7 +544,7 @@ static int check_objects(const char* fname,
if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
for(j = 0; j < rank; j++)
- csize *= (int)dims[j];
+ csize *= dims[j];
if(H5Sclose(sid) < 0)
goto out;
if(H5Dclose(did) < 0)
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index b9bfce1..a49b2f7 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -41,7 +41,9 @@ 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_attr(hid_t loc_in,hid_t loc_out,pack_opt_t *options);
static int copy_user_block(const char *infile, const char *outfile, hsize_t size);
+#if defined (H5REPACK_DEBUG)
static void print_user_block(const char *filename, hid_t fid);
+#endif
/*-------------------------------------------------------------------------
* Function: copy_objects
@@ -187,11 +189,11 @@ int copy_objects(const char* fnamein,
} /* end if */
} /* end if */
} /* end if */
+
+
-
-
-#if defined (H5REPACK_DEBUG)
+#if defined (H5REPACK_DEBUG)
print_user_block(fnamein,fidin);
#endif
@@ -207,35 +209,35 @@ int copy_objects(const char* fnamein,
if(fcpl != H5P_DEFAULT)
{
/* set user block size */
- if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
+ if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
{
error_msg(progname, "failed to set userblock size\n");
goto out;
- }
-
+ }
+
}
-
+
else
{
-
+
/* create a file creation property list */
- if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
{
error_msg(progname, "fail to create a file creation property list\n");
goto out;
- }
-
+ }
+
/* set user block size */
- if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
+ if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
{
error_msg(progname, "failed to set userblock size\n");
goto out;
- }
-
+ }
+
}
-
-
-
+
+
+
}
@@ -244,39 +246,39 @@ int copy_objects(const char* fnamein,
*-------------------------------------------------------------------------
*/
-
+
if ( options->alignment > 0 )
{
/* either use the FCPL already created or create a new one */
if (fapl != H5P_DEFAULT)
{
-
+
if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
{
error_msg(progname, "failed to set alignment\n");
goto out;
}
-
+
}
-
+
else
{
-
+
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
{
error_msg(progname, "Could not create file access property list\n");
goto out;
- }
-
+ }
+
if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
{
error_msg(progname, "failed to set alignment\n");
goto out;
}
-
- }
-
+
+ }
+
}
@@ -285,24 +287,24 @@ int copy_objects(const char* fnamein,
*-------------------------------------------------------------------------
*/
-
+
if(options->verbose)
printf("Making file <%s>...\n",fnameout);
-
-
- if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+
+
+ if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0)
{
error_msg(progname, "<%s>: Could not create file\n", fnameout );
goto out;
}
-
+
/*-------------------------------------------------------------------------
* write a new user block if requested
*-------------------------------------------------------------------------
*/
if ( options->ublock_size > 0 )
- {
+ {
if ( copy_user_block( options->ublock_filename, fnameout, options->ublock_size) < 0 )
{
error_msg(progname, "Could not copy user block. Exiting...\n");
@@ -311,7 +313,7 @@ int copy_objects(const char* fnamein,
}
}
-
+
/* init table */
trav_table_init(&travt);
@@ -404,7 +406,7 @@ out:
*
* Date: October, 23, 2003
*
- * Modifications:
+ * Modifications:
*
* July 2004: Introduced the extra EC or NN option for SZIP
*
@@ -416,47 +418,47 @@ out:
* October 2006: Read by hyperslabs for big datasets.
*
* A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done
- * i.e., if the memory needed to read a dataset is greater than this limit,
- * then hyperslab I/O is done instead of one operation I/O
+ * i.e., if the memory needed to read a dataset is greater than this limit,
+ * then hyperslab I/O is done instead of one operation I/O
* For each dataset, the memory needed is calculated according to
*
* memory needed = number of elements * size of each element
*
- * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations
+ * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations
* are done
*
* H5Dread( input_dataset1 )
* H5Dread( input_dataset2 )
*
- * with all elements in the datasets selected. If the memory needed is greater than
+ * with all elements in the datasets selected. If the memory needed is greater than
* H5TOOLS_MALLOCSIZE, then the following operations are done instead:
*
- * a strip mine is defined for each dimension k (a strip mine is defined as a
+ * a strip mine is defined for each dimension k (a strip mine is defined as a
* hyperslab whose size is memory manageable) according to the formula
*
* (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type)
*
- * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures
- * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip
- * mine size k is simply defined as its dimension k, but for larger datasets the
+ * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures
+ * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip
+ * mine size k is simply defined as its dimension k, but for larger datasets the
* hyperslab size is still memory manageable.
- * a cycle is done until the number of elements in the dataset is reached. In each
- * iteration, two parameters are defined for the function H5Sselect_hyperslab,
+ * a cycle is done until the number of elements in the dataset is reached. In each
+ * iteration, two parameters are defined for the function H5Sselect_hyperslab,
* the start and size of each hyperslab, according to
*
* (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k])
*
- * where hyperslab_offset [k] is initially set to zero, and later incremented in
- * hyperslab_size[k] offsets. The reason for the operation
+ * where hyperslab_offset [k] is initially set to zero, and later incremented in
+ * hyperslab_size[k] offsets. The reason for the operation
*
* dimension[k] - hyperslab_offset[k]
*
- * in (2) is that, when using the strip mine size, it assures that the "remaining" part
+ * in (2) is that, when using the strip mine size, it assures that the "remaining" part
* of the dataset that does not fill an entire strip mine is processed.
*
- * November 2006: Use H5Ocopy in the copy of objects. The logic for using
- * H5Ocopy or not is if a change of filters or layout is requested by the user
- * then use read/write else use H5Ocopy.
+ * November 2006: Use H5Ocopy in the copy of objects. The logic for using
+ * H5Ocopy or not is if a change of filters or layout is requested by the user
+ * then use read/write else use H5Ocopy.
*
* May, 1, 2008: Add a printing of the compression ratio of old size / new size
*
@@ -491,7 +493,9 @@ int do_copy_objects(hid_t fidin,
void *buf=NULL; /* buffer for raw data */
void *sm_buf=NULL; /* buffer for raw data */
int has_filter; /* current object has a filter */
+ int req_filter; /* there was a request for a filter */
unsigned i;
+ unsigned u;
int is_ref=0;
/*-------------------------------------------------------------------------
@@ -499,16 +503,19 @@ int do_copy_objects(hid_t fidin,
*-------------------------------------------------------------------------
*/
- if (options->verbose) {
+ if (options->verbose)
+ {
printf("-----------------------------------------\n");
printf(" Type Filter (Compression) Name\n");
printf("-----------------------------------------\n");
}
- for ( i = 0; i < travt->nobjs; i++) {
+ for ( i = 0; i < travt->nobjs; i++)
+ {
buf = NULL;
- switch ( travt->objs[i].type ) {
+ switch ( travt->objs[i].type )
+ {
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_GROUP
*-------------------------------------------------------------------------
@@ -522,11 +529,13 @@ int do_copy_objects(hid_t fidin,
* and copy its attributes using that ID
*-------------------------------------------------------------------------
*/
- if(HDstrcmp(travt->objs[i].name, "/") == 0) {
+ if(HDstrcmp(travt->objs[i].name, "/") == 0)
+ {
if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
goto error;
}
- else if (options->grp_compact>0 || options->grp_indexed>0) {
+ else if (options->grp_compact>0 || options->grp_indexed>0)
+ {
/* Set up group creation property list */
if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
goto error;
@@ -535,9 +544,10 @@ int do_copy_objects(hid_t fidin,
goto error;
if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
- goto error;
+ goto error;
}
- else {
+ else
+ {
if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
}
@@ -570,6 +580,24 @@ int do_copy_objects(hid_t fidin,
case H5TRAV_TYPE_DATASET:
has_filter = 0;
+ req_filter = 0;
+
+ /* check if filters were requested */
+ for( u = 0; u < options->op_tbl->nelems; u++)
+ {
+ int k;
+
+ for( k = 0; k < options->op_tbl->objs[u].nfilters; k++)
+ {
+ if ( options->op_tbl->objs[u].filter->filtn > 0 )
+ {
+
+ req_filter = 1;
+
+ }
+
+ }
+ }
/* early detection of references */
if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
@@ -582,7 +610,7 @@ int do_copy_objects(hid_t fidin,
goto error;
if(H5Dclose(dset_in) < 0)
goto error;
-
+
/*-------------------------------------------------------------------------
* check if we should use H5Ocopy or not
@@ -590,10 +618,14 @@ int do_copy_objects(hid_t fidin,
* otherwise we do a copy using H5Ocopy
*-------------------------------------------------------------------------
*/
- if(options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref) {
- int j;
-
+ if ( options->op_tbl->nelems ||
+ options->all_filter == 1 ||
+ options->all_layout == 1 ||
+ is_ref)
+ {
+
+ int j;
+
if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
goto error;
if((f_space_id = H5Dget_space(dset_in)) < 0)
@@ -610,17 +642,19 @@ int do_copy_objects(hid_t fidin,
if(H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0)
goto error;
nelmts = 1;
- for(j = 0; j < rank; j++)
+ for ( j = 0; j < rank; j++)
+ {
nelmts *= dims[j];
+ }
if(options->use_native == 1)
wtype_id = h5tools_get_native_type(ftype_id);
else
- wtype_id = H5Tcopy(ftype_id);
+ wtype_id = H5Tcopy(ftype_id);
if((msize = H5Tget_size(wtype_id)) == 0)
goto error;
-
+
/*-------------------------------------------------------------------------
* check if the dataset creation property list has filters that
* are not registered in the current configuration
@@ -649,7 +683,8 @@ int do_copy_objects(hid_t fidin,
apply_s=0;
/* apply the filter */
- if (apply_s) {
+ if (apply_s)
+ {
if (apply_filters(travt->objs[i].name,rank,dims,dcpl_out,options,&has_filter) < 0)
goto error;
}
@@ -664,7 +699,7 @@ int do_copy_objects(hid_t fidin,
dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT);
} H5E_END_TRY;
- if(dset_out == FAIL)
+ if(dset_out == FAIL)
{
if(options->verbose)
printf(" warning: could not create dataset <%s>. Applying original settings\n",
@@ -691,7 +726,7 @@ int do_copy_objects(hid_t fidin,
goto error;
if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0)
goto error;
- }
+ }
else /* possibly not enough memory, read/write by hyperslabs */
{
@@ -712,7 +747,7 @@ int do_copy_objects(hid_t fidin,
hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */
hsize_t hs_nelmts; /*elements in request */
hsize_t zero[8]; /*vector of zeros */
- int k;
+ int k;
/* check if we have VL data in the dataset's datatype */
if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
@@ -738,12 +773,12 @@ int do_copy_objects(hid_t fidin,
memset(hs_offset, 0, sizeof hs_offset);
memset(zero, 0, sizeof zero);
- for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts)
+ for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts)
{
/* calculate the hyperslab size */
- if (rank > 0)
+ if (rank > 0)
{
- for (k = 0, hs_nelmts = 1; k < rank; k++)
+ for (k = 0, hs_nelmts = 1; k < rank; k++)
{
hs_size[k] = MIN(dims[k] - hs_offset[k], sm_size[k]);
hs_nelmts *= hs_size[k];
@@ -753,8 +788,8 @@ int do_copy_objects(hid_t fidin,
goto error;
if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
goto error;
- }
- else
+ }
+ else
{
H5Sselect_all(f_space_id);
H5Sselect_all(sm_space);
@@ -762,9 +797,9 @@ int do_copy_objects(hid_t fidin,
} /* rank */
/* read/write */
- if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
+ if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
goto error;
- if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
+ if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
goto error;
/* reclaim any VL memory, if necessary */
@@ -772,7 +807,7 @@ int do_copy_objects(hid_t fidin,
H5Dvlen_reclaim(wtype_id, sm_space, H5P_DEFAULT, sm_buf);
/* calculate the next hyperslab offset */
- for (k = rank, carry = 1; k > 0 && carry; --k)
+ for (k = rank, carry = 1; k > 0 && carry; --k)
{
hs_offset[k - 1] += hs_size[k - 1];
if (hs_offset[k - 1] == dims[k - 1])
@@ -796,12 +831,12 @@ int do_copy_objects(hid_t fidin,
* amount of compression used
*-------------------------------------------------------------------------
*/
- if (options->verbose)
+ if (options->verbose)
{
double ratio=0;
- /* only print the compression ration if there was a filter */
- if (apply_s && apply_f && has_filter)
+ /* only print the compression ration if there was a filter request */
+ if (apply_s && apply_f && req_filter)
{
hssize_t a, b;
@@ -813,13 +848,13 @@ int do_copy_objects(hid_t fidin,
a = dsize_in; b = dsize_out;
if (b!=0)
ratio = (double) a / (double) b;
-
+
print_dataset_info(dcpl_out,travt->objs[i].name,ratio,1);
}
else
print_dataset_info(dcpl_id,travt->objs[i].name,ratio,0);
- /* print a message that the filter was not applied
+ /* print a message that the filter was not applied
(in case there was a filter)
*/
if ( has_filter && apply_s == 0 )
@@ -870,16 +905,16 @@ int do_copy_objects(hid_t fidin,
* we do not have request for filter/chunking use H5Ocopy instead
*-------------------------------------------------------------------------
*/
- else
+ else
{
hid_t pid;
/* create property to pass copy options */
- if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
goto error;
/* set options for object copy */
- if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
+ if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
goto error;
/*-------------------------------------------------------------------------
@@ -892,7 +927,7 @@ int do_copy_objects(hid_t fidin,
fidout, /* Destination file or group identifier */
travt->objs[i].name, /* Name of the destination object */
pid, /* Properties which apply to the copy */
- H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
+ H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
goto error;
/* close property */
@@ -918,7 +953,7 @@ int do_copy_objects(hid_t fidin,
if (options->verbose)
printf(FORMAT_OBJ,"dset",travt->objs[i].name );
-
+
} /* end do we have request for filter/chunking */
@@ -955,7 +990,7 @@ int do_copy_objects(hid_t fidin,
if(H5Tclose(type_out) < 0)
goto error;
-
+
break;
@@ -1059,52 +1094,52 @@ int copy_attr(hid_t loc_in,
H5O_info_t oinfo; /* object info */
int j;
unsigned u;
-
+
if(H5Oget_info(loc_in, &oinfo) < 0)
goto error;
-
+
/*-------------------------------------------------------------------------
* copy all attributes
*-------------------------------------------------------------------------
*/
-
+
for ( u = 0; u < (unsigned)oinfo.num_attrs; u++)
{
-
+
buf=NULL;
-
+
/* 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)
goto error;
-
+
/* get name */
if (H5Aget_name( attr_id, (size_t)255, name ) < 0)
goto error;
-
+
/* get the file datatype */
if ((ftype_id = H5Aget_type( attr_id )) < 0 )
goto error;
-
+
/* get the dataspace handle */
if ((space_id = H5Aget_space( attr_id )) < 0 )
goto error;
-
+
/* get dimensions */
if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 )
goto error;
-
+
nelmts=1;
for (j=0; j<rank; j++)
nelmts*=dims[j];
-
+
if (options->use_native==1)
wtype_id = h5tools_get_native_type(ftype_id);
else
- wtype_id = H5Tcopy(ftype_id);
-
+ wtype_id = H5Tcopy(ftype_id);
+
if ((msize=H5Tget_size(wtype_id))==0)
goto error;
-
+
/*-------------------------------------------------------------------------
* object references are a special case
* we cannot just copy the buffers, but instead we recreate the reference
@@ -1112,18 +1147,18 @@ int copy_attr(hid_t loc_in,
* the referenced objects
*-------------------------------------------------------------------------
*/
-
+
if (H5T_REFERENCE==H5Tget_class(wtype_id))
{
;
}
- else
+ else
{
/*-------------------------------------------------------------------------
* read to memory
*-------------------------------------------------------------------------
*/
-
+
buf = (void *)HDmalloc((size_t)(nelmts * msize));
if(buf == NULL) {
error_msg(progname, "cannot read into memory\n" );
@@ -1131,46 +1166,46 @@ int copy_attr(hid_t loc_in,
}
if(H5Aread(attr_id, wtype_id, buf) < 0)
goto error;
-
+
/*-------------------------------------------------------------------------
* copy
*-------------------------------------------------------------------------
*/
-
+
if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
if(H5Awrite(attr_out, wtype_id, buf) < 0)
goto error;
-
+
/*close*/
if(H5Aclose(attr_out) < 0)
goto error;
-
-
+
+
if(buf)
free(buf);
-
+
} /*H5T_REFERENCE*/
-
-
+
+
if(options->verbose)
printf(FORMAT_OBJ_ATTR, "attr", name);
-
+
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
-
+
if (H5Tclose(ftype_id) < 0) goto error;
if (H5Tclose(wtype_id) < 0) goto error;
if (H5Sclose(space_id) < 0) goto error;
if (H5Aclose(attr_id) < 0) goto error;
-
+
} /* u */
-
-
+
+
return 0;
-
+
error:
H5E_BEGIN_TRY {
H5Tclose(ftype_id);
@@ -1210,27 +1245,27 @@ static void print_dataset_info(hid_t dcpl_id,
size_t cd_nelmts; /* filter client number of values */
char f_objname[256]; /* filter objname */
int i;
-
-
+
+
strcpy(strfilter,"\0");
-
+
/* get information about input filters */
if((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
return;
-
+
for(i = 0; i < nfilters; i++) {
cd_nelmts = NELMTS(cd_values);
-
+
filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
cd_values, sizeof(f_objname), f_objname, NULL);
-
+
switch(filtn) {
default:
break;
-
+
case H5Z_FILTER_DEFLATE:
strcat(strfilter,"GZIP ");
-
+
#if defined (PRINT_DEBUG)
{
unsigned level=cd_values[0];
@@ -1239,10 +1274,10 @@ static void print_dataset_info(hid_t dcpl_id,
}
#endif
break;
-
+
case H5Z_FILTER_SZIP:
strcat(strfilter,"SZIP ");
-
+
#if defined (PRINT_DEBUG)
{
unsigned options_mask=cd_values[0]; /* from dcpl, not filt*/
@@ -1255,29 +1290,29 @@ static void print_dataset_info(hid_t dcpl_id,
strcpy(temp,"NN) ");
}
strcat(strfilter,temp);
-
+
#endif
-
+
break;
-
+
case H5Z_FILTER_SHUFFLE:
strcat(strfilter,"SHUF ");
break;
-
+
case H5Z_FILTER_FLETCHER32:
strcat(strfilter,"FLET ");
break;
-
+
case H5Z_FILTER_NBIT:
strcat(strfilter,"NBIT ");
break;
-
+
case H5Z_FILTER_SCALEOFFSET:
strcat(strfilter,"SCALEOFFSET ");
break;
} /* switch */
}/*i*/
-
+
if(!pr)
printf(FORMAT_OBJ,"dset",objname );
else
@@ -1292,13 +1327,13 @@ static void print_dataset_info(hid_t dcpl_id,
}
/*-------------------------------------------------------------------------
- * Function: copy_user_block
+ * Function: copy_user_block
*
* Purpose: copy user block from one file to another
*
* Return: 0, ok, -1 no
*
- * Programmer: Peter Cao
+ * Programmer: Peter Cao
*
* Date: October, 25, 2007
*
@@ -1372,25 +1407,26 @@ done:
if(outfid > 0)
HDclose(outfid);
- return status;
+ return status;
}
/*-------------------------------------------------------------------------
- * Function: print_user_block
+ * Function: print_user_block
*
* Purpose: print user block
*
* Return: 0, ok, -1 no
*
- * Programmer: Pedro Vicente
+ * Programmer: Pedro Vicente
*
* Date: August, 20, 2008
*
*-------------------------------------------------------------------------
*/
-static
+#if defined (H5REPACK_DEBUG)
+static
void print_user_block(const char *filename, hid_t fid)
{
int fh; /* file handle */
@@ -1399,35 +1435,35 @@ void print_user_block(const char *filename, hid_t fid)
hid_t fcpl; /* file creation property list ID for HDF5 file */
int i;
- /* get user block size */
- if(( fcpl = H5Fget_create_plist(fid)) < 0)
+ /* get user block size */
+ if(( fcpl = H5Fget_create_plist(fid)) < 0)
{
error_msg(progname, "failed to retrieve file creation property list\n");
goto done;
- }
-
- if(H5Pget_userblock(fcpl, &ub_size) < 0)
+ }
+
+ if(H5Pget_userblock(fcpl, &ub_size) < 0)
{
error_msg(progname, "failed to retrieve userblock size\n");
goto done;
- }
-
- if(H5Pclose(fcpl) < 0)
+ }
+
+ if(H5Pclose(fcpl) < 0)
{
error_msg(progname, "failed to close property list\n");
goto done;
- }
-
+ }
+
/* open file */
- if((fh = HDopen(filename, O_RDONLY, 0)) < 0)
+ if((fh = HDopen(filename, O_RDONLY, 0)) < 0)
{
goto done;
}
-
+
size = ub_size;
/* read file */
- while(size > 0)
+ while(size > 0)
{
ssize_t nread; /* # of bytes read */
char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
@@ -1438,7 +1474,7 @@ void print_user_block(const char *filename, hid_t fid)
else
nread = HDread(fh, rbuf, (size_t)size);
- for(i = 0; i < nread; i++)
+ for(i = 0; i < nread; i++)
{
printf("%c ", rbuf[i]);
@@ -1446,20 +1482,22 @@ void print_user_block(const char *filename, hid_t fid)
}
printf("\n");
- if(nread < 0)
+ if(nread < 0)
{
goto done;
- }
-
+ }
+
/* update size of userblock left to transfer */
size -= nread;
- }
+ }
done:
if(fh > 0)
HDclose(fh);
+
-
- return;
+ return;
}
+#endif
+
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index cd4693e..98ef07e 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -41,10 +41,10 @@ int aux_find_obj(const char* name, /* object name from traverse list */
*obj = options->op_tbl->objs[i];
return i;
}
-
+
pdest = strstr(name,options->op_tbl->objs[i].path);
result = (int)(pdest - name);
-
+
/* found at position 1, meaning without '/' */
if( pdest != NULL && result==1 )
{
@@ -72,19 +72,19 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
pack_opt_t *options, /* repack options */
pack_info_t *obj /*OUT*/) /* info about object to filter */
{
-
+
int idx, i;
pack_info_t tmp;
-
+
init_packobject(&tmp);
-
+
idx = aux_find_obj(name,options,&tmp);
-
+
/* name was on input */
if (idx>=0)
{
-
-
+
+
/* applying to all objects */
if (options->all_layout)
{
@@ -114,9 +114,9 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
default:
break;
}/*switch*/
-
+
}
-
+
/* applying to all objects */
if (options->all_filter)
{
@@ -132,16 +132,16 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
tmp.filter[i] = options->op_tbl->objs[idx].filter[i];
}
}
-
-
+
+
} /* if idx */
-
-
+
+
/* no input name */
-
+
else
{
-
+
if (options->all_filter)
{
int k;
@@ -167,11 +167,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
}/*switch*/
}
}
-
+
*obj = tmp;
return 1;
-
-}
+
+}
/*-------------------------------------------------------------------------
@@ -206,40 +206,40 @@ int apply_filters(const char* name, /* object name from traverse list */
pack_info_t obj;
*has_filter = 0;
-
+
if (rank==0) /* scalar dataset, do not apply */
return 0;
-
+
/*-------------------------------------------------------------------------
* initialize the assigment object
*-------------------------------------------------------------------------
*/
init_packobject(&obj);
-
+
/*-------------------------------------------------------------------------
* find options
*-------------------------------------------------------------------------
*/
if (aux_assign_obj(name,options,&obj)==0)
return 0;
-
+
/* get information about input filters */
if ((nfilters = H5Pget_nfilters(dcpl_id))<0)
return -1;
-
+
/*-------------------------------------------------------------------------
* check if we have filters in the pipeline
* we want to replace them with the input filters
* only remove if we are inserting new ones
*-------------------------------------------------------------------------
*/
- if (nfilters && obj.nfilters )
+ if (nfilters && obj.nfilters )
{
*has_filter = 1;
if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0)
return -1;
}
-
+
/*-------------------------------------------------------------------------
* check if there is an existent chunk
* read it only if there is not a requested layout
@@ -249,7 +249,7 @@ int apply_filters(const char* name, /* object name from traverse list */
{
if ((layout = H5Pget_layout(dcpl_id))<0)
return -1;
-
+
if (layout==H5D_CHUNKED)
{
if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0)
@@ -260,7 +260,7 @@ int apply_filters(const char* name, /* object name from traverse list */
obj.chunk.chunk_lengths[i] = chsize[i];
}
}
-
+
/*-------------------------------------------------------------------------
* the type of filter and additional parameter
* type can be one of the filters
@@ -273,10 +273,10 @@ int apply_filters(const char* name, /* object name from traverse list */
* H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression
*-------------------------------------------------------------------------
*/
-
+
if (obj.nfilters)
{
-
+
/*-------------------------------------------------------------------------
* filters require CHUNK layout; if we do not have one define a default
*-------------------------------------------------------------------------
@@ -287,14 +287,14 @@ int apply_filters(const char* name, /* object name from traverse list */
for (i=0; i<rank; i++)
obj.chunk.chunk_lengths[i] = dims[i];
}
-
+
for ( i=0; i<obj.nfilters; i++)
{
switch (obj.filter[i].filtn)
{
default:
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_DEFLATE 1 , deflation like gzip
*-------------------------------------------------------------------------
@@ -302,7 +302,7 @@ int apply_filters(const char* name, /* object name from traverse list */
case H5Z_FILTER_DEFLATE:
{
unsigned aggression; /* the deflate level */
-
+
aggression = obj.filter[i].cd_values[0];
/* set up for deflated data */
if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
@@ -311,7 +311,7 @@ int apply_filters(const char* name, /* object name from traverse list */
return -1;
}
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_SZIP 4 , szip compression
*-------------------------------------------------------------------------
@@ -320,19 +320,19 @@ int apply_filters(const char* name, /* object name from traverse list */
{
unsigned options_mask;
unsigned pixels_per_block;
-
+
options_mask = obj.filter[i].cd_values[0];
pixels_per_block = obj.filter[i].cd_values[1];
-
+
/* set up for szip data */
if(H5Pset_chunk(dcpl_id,obj.chunk.rank,obj.chunk.chunk_lengths)<0)
return -1;
if (H5Pset_szip(dcpl_id,options_mask,pixels_per_block)<0)
return -1;
-
+
}
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_SHUFFLE 2 , shuffle the data
*-------------------------------------------------------------------------
@@ -343,7 +343,7 @@ int apply_filters(const char* name, /* object name from traverse list */
if (H5Pset_shuffle(dcpl_id)<0)
return -1;
break;
-
+
/*-------------------------------------------------------------------------
* H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
*-------------------------------------------------------------------------
@@ -368,15 +368,15 @@ int apply_filters(const char* name, /* object name from traverse list */
* H5Z_FILTER_SCALEOFFSET , scale+offset compression
*-------------------------------------------------------------------------
*/
-
+
case H5Z_FILTER_SCALEOFFSET:
{
H5Z_SO_scale_type_t scale_type;
int scale_factor;
-
+
scale_type = obj.filter[i].cd_values[0];
scale_factor = obj.filter[i].cd_values[1];
-
+
if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
return -1;
if (H5Pset_scaleoffset(dcpl_id,scale_type,scale_factor)<0)
@@ -385,21 +385,21 @@ int apply_filters(const char* name, /* object name from traverse list */
break;
} /* switch */
}/*i*/
-
+
}
/*obj.nfilters*/
-
+
/*-------------------------------------------------------------------------
* layout
*-------------------------------------------------------------------------
*/
-
+
if (obj.layout>=0)
{
/* a layout was defined */
if (H5Pset_layout(dcpl_id, obj.layout)<0)
return -1;
-
+
if (H5D_CHUNKED==obj.layout) { /* set up chunk */
if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
return -1;
@@ -408,7 +408,7 @@ int apply_filters(const char* name, /* object name from traverse list */
if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0)
return -1;
}
-
+
}
return 0;
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index dcdce82..1ec8e88 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -22,8 +22,7 @@
static void usage(const char *prog);
-static int parse_number(char *str);
-static void parse_command_line(int argc, const char* argv[], pack_opt_t* options);
+static void parse_command_line(int argc, const char **argv, pack_opt_t* options);
static void read_info(const char *filename,pack_opt_t *options);
@@ -94,10 +93,10 @@ static struct long_options l_opts[] = {
* add options to set alignment (H5Pset_alignment) (switches -t -a)
*-------------------------------------------------------------------------
*/
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
{
- char *infile = NULL;
- char *outfile = NULL;
+ const char *infile = NULL;
+ const char *outfile = NULL;
pack_opt_t options; /*the global options */
int ret=-1;
int i;
@@ -170,7 +169,7 @@ int main(int argc, char **argv)
else if (strcmp(argv[i], "-m") == 0)
{
- options.min_comp = parse_number(argv[i+1]);
+ options.min_comp = atoi(argv[i+1]);
if ((int)options.min_comp<=0)
{
error_msg(progname, "invalid minimum compress size <%s>\n",argv[i+1]);
@@ -207,7 +206,7 @@ int main(int argc, char **argv)
else if (strcmp(argv[i], "-s") == 0)
{
- char *s = argv[++i];
+ const char *s = argv[++i];
int idx = 0;
int ssize = 0;
char *msgPtr = strchr( s, ':');
@@ -431,7 +430,8 @@ static void usage(const char *prog)
*-------------------------------------------------------------------------
*/
-static void parse_command_line(int argc, const char* argv[], pack_opt_t* options)
+static
+void parse_command_line(int argc, const char **argv, pack_opt_t* options)
{
int opt;
@@ -472,7 +472,7 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
case 'm':
- options->min_comp = parse_number( opt_arg );
+ options->min_comp = atoi( opt_arg );
if ((int)options->min_comp<=0)
{
error_msg(progname, "invalid minimum compress size <%s>\n", opt_arg );
@@ -555,22 +555,18 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
case 'b':
- options->ublock_size = atoi( opt_arg );
+ options->ublock_size = atol( opt_arg );
break;
case 't':
- options->threshold = atoi( opt_arg );
- if ( options->threshold < 0 )
- {
- error_msg(progname, "invalid threshold size\n", opt_arg );
- exit(EXIT_FAILURE);
- }
+ options->threshold = atol( opt_arg );
+
break;
case 'a':
- options->alignment = atoi( opt_arg );
+ options->alignment = atol( opt_arg );
if ( options->alignment < 1 )
{
error_msg(progname, "invalid alignment size\n", opt_arg );
@@ -591,47 +587,9 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
exit(EXIT_FAILURE);
}
-
-
-
}
/*-------------------------------------------------------------------------
- * Function: parse_number
- *
- * Purpose: read a number from command line argument
- *
- * Return: number, -1 for FAIL
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September, 23, 2003
- *
- *-------------------------------------------------------------------------
- */
-
-
-int parse_number(char *str)
-{
- unsigned i;
- int n;
- char c;
- size_t len=strlen(str);
-
- for ( i=0; i<len; i++)
- {
- c = str[i];
- if (!isdigit(c)){
- return -1;
- }
- }
- str[i]='\0';
- n=atoi(str);
- return n;
-}
-
-
-/*-------------------------------------------------------------------------
* Function: read_info
*
* Purpose: read comp and chunk options from a file
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index bdcae02..8572837 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -39,7 +39,7 @@ void init_packobject(pack_info_t *obj)
{
obj->filter[j].filtn = -1;
for ( k=0; k<CD_VALUES; k++)
- obj->filter[j].cd_values[k] = -1;
+ obj->filter[j].cd_values[k] = 0;
}
obj->chunk.rank = -1;
obj->refobj_id = -1;
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index f7188bf..d684da8 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -412,7 +412,7 @@ obj_list_t* parse_filter(const char *str,
*/
case H5Z_FILTER_DEFLATE:
- if (filt->cd_values[0]<0 || filt->cd_values[0]>9 )
+ if (filt->cd_values[0]>9 )
{
if (obj_list) free(obj_list);
error_msg(progname, "invalid compression parameter in <%s>\n",str);
@@ -447,19 +447,7 @@ obj_list_t* parse_filter(const char *str,
}
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
-
- case H5Z_FILTER_SCALEOFFSET:
- if (filt->cd_values[0]<0 )
- {
- if (obj_list) free(obj_list);
- error_msg(progname, "invalid compression parameter in <%s>\n",str);
- exit(1);
- }
- break;
+
};
return obj_list;
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index 8f79574..82e8250 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -193,7 +193,7 @@ int do_copy_refobjs(hid_t fidin,
goto error;
if(options->verbose)
{
-
+
printf(FORMAT_OBJ,"dset",travt->objs[i].name );
printf("object <%s> object reference created to <%s>\n",
@@ -277,7 +277,7 @@ int do_copy_refobjs(hid_t fidin,
goto error;
if(options->verbose)
{
-
+
printf(FORMAT_OBJ,"dset",travt->objs[i].name );
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index fed4499..a7454d6 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -19,7 +19,7 @@
extern char *progname;
static int has_layout(hid_t pid, pack_info_t *obj);
-static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *filter);
+static int has_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter);
/*-------------------------------------------------------------------------
@@ -442,16 +442,18 @@ error:
*-------------------------------------------------------------------------
*/
-static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *filter)
+static
+int has_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
{
- unsigned nfilters_dcpl; /* number of filters in DCPL*/
+ 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 */
- unsigned i, j; /* index */
+ int i; /* index */
+ unsigned j; /* index */
/* get information about filters */
if((nfilters_dcpl = H5Pget_nfilters(pid)) < 0)
@@ -475,7 +477,7 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f
for( i = 0; i < nfilters_dcpl; i++)
{
cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(pid, i, &filt_flags, &cd_nelmts,
+ filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts,
cd_values, sizeof(f_name), f_name, NULL);
/* filter ID */