summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-12-03 21:08:18 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-12-03 21:08:18 (GMT)
commitb3eb10fa6e4d523be44bb646a3b7c8d208cb6e95 (patch)
tree8756bae7afa0b9f60875f5718293ee057918a42a /tools
parentaaa9290be192523fc50b2623930b9b5a026b60ab (diff)
downloadhdf5-b3eb10fa6e4d523be44bb646a3b7c8d208cb6e95.zip
hdf5-b3eb10fa6e4d523be44bb646a3b7c8d208cb6e95.tar.gz
hdf5-b3eb10fa6e4d523be44bb646a3b7c8d208cb6e95.tar.bz2
[svn-r9613] Purpose:
new feature Description: when requesting a filter for all datasets and the filter cannot be applied for one dataset use the original dcpl withou filter and print a warning this check was done previously with buit in functions for szip that are now in the library Solution: Platforms tested: linux solaris aix Misc. update:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5repack/h5repack_copy.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 7f61d7a..a0fd1c9 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -201,9 +201,6 @@ out:
return -1;
}
-
-
-
/*-------------------------------------------------------------------------
* Function: do_copy_objects
*
@@ -214,6 +211,8 @@ out:
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: October, 23, 2003
+ * Modified: December, 03, 2004 - added a check for H5Dcreate; if the dataset
+ * cannot be created with the requested filter, use the input one
*
*-------------------------------------------------------------------------
*/
@@ -230,6 +229,7 @@ int do_copy_objects(hid_t fidin,
hid_t type_in; /* named type ID */
hid_t type_out; /* named type ID */
hid_t dcpl_id; /* dataset creation property list ID */
+ hid_t dcpl_out; /* dataset creation property list ID */
hid_t space_id; /* space ID */
hid_t ftype_id; /* file data type ID */
hid_t mtype_id; /* memory data type ID */
@@ -240,9 +240,6 @@ int do_copy_objects(hid_t fidin,
hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
hsize_t dsize_in; /* input dataset size before filter */
int next; /* external files */
-#ifdef LATER
- hsize_t dsize_out; /* output dataset size after filter */
-#endif /* LATER */
int i, j;
int wrote=0;
@@ -291,6 +288,7 @@ int do_copy_objects(hid_t fidin,
*-------------------------------------------------------------------------
*/
case H5G_DATASET:
+
if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
goto error;
if ((space_id=H5Dget_space(dset_in))<0)
@@ -299,6 +297,8 @@ int do_copy_objects(hid_t fidin,
goto error;
if ((dcpl_id=H5Dget_create_plist(dset_in))<0)
goto error;
+ if ((dcpl_out = H5Pcopy (dcpl_id))<0)
+ goto error;
if ( (rank=H5Sget_simple_extent_ndims(space_id))<0)
goto error;
HDmemset(dims, 0, sizeof dims);
@@ -307,6 +307,9 @@ int do_copy_objects(hid_t fidin,
nelmts=1;
for (j=0; j<rank; j++)
nelmts*=dims[j];
+
+ if (options->verbose)
+ print_obj(dcpl_id,travt->objs[i].name );
if ((mtype_id=h5tools_get_native_type(ftype_id))<0)
goto error;
@@ -343,9 +346,6 @@ int do_copy_objects(hid_t fidin,
*/
if ( (H5T_REFERENCE!=H5Tget_class(mtype_id)))
{
- /* the information about the object to be filtered/"layouted" */
- pack_info_t obj;
- init_packobject(&obj);
/* get the storage size of the input dataset */
dsize_in=H5Dget_storage_size(dset_in);
@@ -363,22 +363,41 @@ int do_copy_objects(hid_t fidin,
}
if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
goto error;
-
- /*-------------------------------------------------------------------------
- * apply the filter
- *-------------------------------------------------------------------------
- */
- if (apply_filters(travt->objs[i].name,rank,dims,dcpl_id,mtype_id,options)<0)
+
+ /*-------------------------------------------------------------------------
+ * apply the filter
+ *-------------------------------------------------------------------------
+ */
+ if (apply_filters(travt->objs[i].name,rank,dims,dcpl_out,mtype_id,options)<0)
goto error;
}/*nelmts*/
/*-------------------------------------------------------------------------
- * create/write dataset/close
+ * create;
+ * disable error checking in case the dataset cannot be created with the
+ * modified dcpl; in that case use the original instead
*-------------------------------------------------------------------------
*/
- if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0)
- goto error;
+
+ H5E_BEGIN_TRY {
+ dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_out);
+ } H5E_END_TRY;
+
+ if (dset_out==FAIL)
+ {
+ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0)
+ goto error;
+
+ if (options->verbose)
+ printf("Warning: Could not apply the filter to <%s>\n", travt->objs[i].name);
+ }
+
+ /*-------------------------------------------------------------------------
+ * write dataset
+ *-------------------------------------------------------------------------
+ */
+
if (dsize_in && nelmts) {
if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
goto error;
@@ -391,26 +410,12 @@ int do_copy_objects(hid_t fidin,
if (copy_attr(dset_in,dset_out,options)<0)
goto error;
-#ifdef LATER
- /*-------------------------------------------------------------------------
- * store the storage sizes
- *-------------------------------------------------------------------------
- */
-
- dsize_out=H5Dget_storage_size(dset_out);
-#endif /* LATER */
-
/*close */
if (H5Dclose(dset_out)<0)
goto error;
if (buf)
free(buf);
-
- if (options->verbose && wrote)
- print_obj(dcpl_id,travt->objs[i].name );
-
-
}/*H5T_STD_REF_OBJ*/
}/*can_read*/
@@ -426,6 +431,8 @@ int do_copy_objects(hid_t fidin,
goto error;
if (H5Pclose(dcpl_id)<0)
goto error;
+ if (H5Pclose(dcpl_out)<0)
+ goto error;
if (H5Sclose(space_id)<0)
goto error;
if (H5Dclose(dset_in)<0)
@@ -550,6 +557,7 @@ error:
}
+
/*-------------------------------------------------------------------------
* Function: copy_attr
*