[svn-r9614] 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:
This commit is contained in:
Pedro Vicente Nunes 2004-12-03 16:08:57 -05:00
parent 90d937946f
commit 3da8287af6

View File

@ -228,6 +228,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
*
*-------------------------------------------------------------------------
*/
@ -244,6 +246,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 */
@ -254,9 +257,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;
@ -305,6 +305,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)
@ -313,6 +314,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);
@ -321,6 +324,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;
@ -379,17 +385,36 @@ int do_copy_objects(hid_t fidin,
* apply the filter
*-------------------------------------------------------------------------
*/
if (apply_filters(travt->objs[i].name,rank,dims,dcpl_id,mtype_id,options)<0)
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;
@ -402,26 +427,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*/
@ -436,6 +447,8 @@ int do_copy_objects(hid_t fidin,
if (H5Tclose(mtype_id)<0)
goto error;
if (H5Pclose(dcpl_id)<0)
goto error;
if (H5Pclose(dcpl_out)<0)
goto error;
if (H5Sclose(space_id)<0)
goto error;