summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-01-27 20:39:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-01-27 20:39:20 (GMT)
commit61a451f89ea2015eac08e361e6ad244bd4af5f25 (patch)
tree0f2dccdca39001329f6004a149e8384fa4e4433f
parent6042adf10b2c00796c52dec2a1f97a4989c42cfd (diff)
downloadhdf5-61a451f89ea2015eac08e361e6ad244bd4af5f25.zip
hdf5-61a451f89ea2015eac08e361e6ad244bd4af5f25.tar.gz
hdf5-61a451f89ea2015eac08e361e6ad244bd4af5f25.tar.bz2
[svn-r8117] Purpose:
Code cleanup Description: Add C++ and FORTRAN wrappers for new H5Pdelete_filter routine, along with documentation and a note in the release notes. Platforms tested: FreeBSD 4.9 (sleipnir) Linux 2.4 (verbena) w/ C++ and FORTRAN Too minor for full h5committest
-rw-r--r--c++/src/H5DcreatProp.cpp11
-rw-r--r--c++/src/H5DcreatProp.h3
-rw-r--r--doc/html/RM_H5P.html58
-rw-r--r--fortran/src/H5Pf.c33
-rw-r--r--fortran/src/H5Pff.f9054
-rw-r--r--fortran/src/H5f90proto.h4
-rw-r--r--fortran/test/tH5Z.f9054
-rw-r--r--release_docs/RELEASE.txt2
-rw-r--r--src/H5Pdcpl.c54
-rw-r--r--src/H5Z.c107
-rw-r--r--test/dsets.c164
11 files changed, 380 insertions, 164 deletions
diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp
index d8327c2..22a8f28 100644
--- a/c++/src/H5DcreatProp.cpp
+++ b/c++/src/H5DcreatProp.cpp
@@ -125,6 +125,17 @@ void DSetCreatPropList::setFilter( H5Z_filter_t filter, unsigned int flags, size
}
}
+// Removes one or more filters to the filter pipeline
+void DSetCreatPropList::deleteFilter( H5Z_filter_t filter) const
+{
+ herr_t ret_value = H5Pdelete_filter( id, filter);
+ if( ret_value < 0 )
+ {
+ throw PropListIException("DSetCreatPropList::deleteFilter",
+ "H5Pdelete_filter failed");
+ }
+}
+
// Returns the number of filters in the pipeline
int DSetCreatPropList::getNfilters() const
{
diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h
index 931a478..3ef647f 100644
--- a/c++/src/H5DcreatProp.h
+++ b/c++/src/H5DcreatProp.h
@@ -57,6 +57,9 @@ class H5_DLLCPP DSetCreatPropList : public PropList {
// Adds a filter to the filter pipeline
void setFilter( H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const;
+ // Remove one or all filters from the filter pipeline
+ void deleteFilter( H5Z_filter_t filter) const;
+
// Returns the number of filters in the pipeline
int getNfilters() const;
diff --git a/doc/html/RM_H5P.html b/doc/html/RM_H5P.html
index 0f4034e..0a67e9e 100644
--- a/doc/html/RM_H5P.html
+++ b/doc/html/RM_H5P.html
@@ -223,6 +223,7 @@ which require many different parameters to be easily manipulated.
<li><a href="#Property-SetExternal">H5Pset_external</a>
<li><a href="#Property-GetExternalCount">H5Pget_external_count</a>
<li><a href="#Property-GetExternal">H5Pget_external</a>
+ <li><a href="#Property-DeleteFilter">H5Pdelete_filter</a>
</ul>
<p><i>Dataset Access, Memory, and <br> Transfer Properties</i>
@@ -282,6 +283,7 @@ See further notes in the description of each function.
<li><a href="#Property-Create">H5Pcreate</a>
<li><a href="#Property-CreateClass">H5Pcreate_class</a>
<li><a href="#Property-CreateList">H5Pcreate_list</a>
+ <li><a href="#Property-Equal">H5Pdelete_filter</a>
<li><a href="#Property-Equal">H5Pequal</a>
<li><a href="#Property-Exist">H5Pexist</a>
<li><a href="#Property-FillValueDefined">H5Pfill_value_defined</a>
@@ -508,6 +510,7 @@ as the corresponding C function.
<li><a href="#Property-SetExternal">h5pset_external_f</a>
<li><a href="#Property-GetExternalCount">h5pget_external_count_f</a>
<li><a href="#Property-GetExternal">h5pget_external_f</a>
+ <li><a href="#Property-DeleteFilter">h5pdelete_filter_f</a>
</ul>
<!--
@@ -1186,6 +1189,61 @@ SUBROUTINE
</dl>
<!-- NEW PAGE -->
+<!-- HEADER RIGHT "H5Pdelete_filter" -->
+<hr>
+<dl>
+ <dt><strong>Name:</strong> <a name="Property-DeleteFilter">H5Pdelete_filter</a>
+ <dt><strong>Signature:</strong>
+ <dd><em>herr_t</em> <code>H5Pdelete_filter</code>(<em>hid_t</em> <code>plist</code>,
+ <em>H5Z_filter_t</em> <code>filter</code>
+ )
+ <dt><strong>Purpose:</strong>
+ <dd>Delete one or more filters in the filter pipeline.
+ <dt><strong>Description:</strong>
+ <dd><code>H5Pdelete_filter</code> removes the specified
+ <code>filter</code> from the filter pipeline.
+ <p>
+ Passing <code>H5Z_FILTER_NONE</code> for the <code>filter</code>
+ parameter removes all the filters from the permanent filter pipeline.
+ <p>
+ Attempting to remove a filter that is not in the permanent filter
+ pipeline is an error.
+ <dt><strong>Note:</strong>
+ <dd>This function currently supports only the permanent filter
+ pipeline; <code>plist</code> must be a dataset creation
+ property list.
+ <dt><strong>Parameters:</strong>
+ <dl>
+ <dt><em>hid_t</em> <code>plist_id</code>
+ <dd>IN: Property list identifier.
+ <dt><em>H5Z_filter_t</em> <code>filter</code>
+ <dd>IN: Type of filter to be deleted.
+ </dl>
+ <dt><strong>Returns:</strong>
+ <dd>Returns a non-negative value if successful;
+ otherwise returns a negative value.
+
+ <dt><strong>Fortran90 Interface:</strong> h5pdelete_filter_f
+ <dd>
+ <pre>
+SUBROUTINE h5pdelete_filter_f(prp_id, filter, hdferr)
+ IMPLICIT NONE
+ INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier
+ INTEGER, INTENT(IN) :: filter ! Filter to be modified
+ INTEGER, INTENT(OUT) :: hdferr ! Error code
+ ! 0 on success and -1 on failure
+END SUBROUTINE h5pdelete_filter_f
+ </pre>
+
+ <!--<dt><strong>Non-C API(s):</strong>
+ <dd>
+
+ <img src="Graphics/Java.gif">
+ <img src="Graphics/C++.gif">
+ -->
+</dl>
+
+<!-- NEW PAGE -->
<!-- HEADER RIGHT "H5Pequal" -->
<hr>
<dl>
diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c
index 14c8b45..f9ad983 100644
--- a/fortran/src/H5Pf.c
+++ b/fortran/src/H5Pf.c
@@ -3237,3 +3237,36 @@ DONE:
return ret_value;
}
+/*----------------------------------------------------------------------------
+ * Name: h5pdelete_filter_c
+ * Purpose: Call H5Pdelete_filter to delete one or more filters
+ * Inputs: prp_id - property list identifier
+ * filter - Filter to be deleted
+ * Returns: 0 on success, -1 on failure
+ * Programmer: Quincey Koziol
+ * January 27 2004
+ * Modifications:
+ *---------------------------------------------------------------------------*/
+int_f
+nh5pdelete_filter_c (hid_t_f *prp_id, int_f* filter)
+{
+ int ret_value = -1;
+ hid_t c_prp_id;
+ herr_t ret;
+ H5Z_filter_t c_filter;
+
+ c_filter = (H5Z_filter_t)*filter;
+ c_prp_id = (hid_t)*prp_id;
+
+ /*
+ * Call H5Pdelety_filter function.
+ */
+ ret = H5Pdelete_filter(c_prp_id, c_filter);
+
+ if (ret < 0) goto DONE;
+ ret_value = 0;
+
+DONE:
+ return ret_value;
+}
+
diff --git a/fortran/src/H5Pff.f90 b/fortran/src/H5Pff.f90
index 5715514..a49b602 100644
--- a/fortran/src/H5Pff.f90
+++ b/fortran/src/H5Pff.f90
@@ -6332,4 +6332,58 @@
hdferr = h5pmodify_filter_c(prp_id, filter, flags, cd_nelmts, cd_values )
END SUBROUTINE h5pmodify_filter_f
+!----------------------------------------------------------------------
+! Name: h5pdelete_filter_f
+!
+! Purpose: Delete one or more filters from the filter pipeline.
+!
+! Inputs:
+! prp_id - data creation or transfer property list
+! identifier
+! filter - filter to be deleted
+! Outputs:
+! hdferr: - error code
+! Success: 0
+! Failure: -1
+! Optional parameters:
+! NONE
+!
+! Programmer: Quincey Koziol
+! January 27 2004
+!
+! Modifications:
+!
+! Comment:
+!----------------------------------------------------------------------
+
+ SUBROUTINE h5pdelete_filter_f(prp_id, filter, hdferr)
+!
+!This definition is needed for Windows DLLs
+!DEC$if defined(BUILD_HDF5_DLL)
+!DEC$attributes dllexport :: h5pdelete_filter_f
+!DEC$endif
+!
+ IMPLICIT NONE
+ INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier
+ INTEGER, INTENT(IN) :: filter !Filter to be modified
+
+ INTEGER, INTENT(OUT) :: hdferr ! Error code
+
+! INTEGER, EXTERNAL :: h5pdelete_filter_c
+! MS FORTRAN needs explicit interface for C functions called here.
+!
+ INTERFACE
+ INTEGER FUNCTION h5pdelete_filter_c(prp_id, filter)
+ USE H5GLOBAL
+ !DEC$ IF DEFINED(HDF5F90_WINDOWS)
+ !MS$ATTRIBUTES C,reference,alias:'_H5PMODIFY_FILTER_C'::h5pdelete_filter_c
+ !DEC$ ENDIF
+ INTEGER(HID_T), INTENT(IN) :: prp_id
+ INTEGER, INTENT(IN) :: filter
+ END FUNCTION h5pdelete_filter_c
+ END INTERFACE
+
+ hdferr = h5pdelete_filter_c(prp_id, filter)
+ END SUBROUTINE h5pdelete_filter_f
+
END MODULE H5P
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index 5b7c180..e42b59a 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -770,6 +770,7 @@ H5_DLL int_f nh5tis_variable_str_c ( hid_t_f *type_id , int_f *flag );
# define nh5pset_layout_c FNAME(H5PSET_LAYOUT_C)
# define nh5pget_layout_c FNAME(H5PGET_LAYOUT_C)
# define nh5pset_filter_c FNAME(H5PSET_FILTER_C)
+# define nh5pdelete_filter_c FNAME(H5PDELETE_FILTER_C)
# define nh5pmodify_filter_c FNAME(H5PMODIFY_FILTER_C)
# define nh5pget_nfilters_c FNAME(H5PGET_NFILTERS_C)
# define nh5pget_filter_c FNAME(H5PGET_FILTER_C)
@@ -876,6 +877,7 @@ H5_DLL int_f nh5tis_variable_str_c ( hid_t_f *type_id , int_f *flag );
# define nh5pset_layout_c FNAME(h5pset_layout_c)
# define nh5pget_layout_c FNAME(h5pget_layout_c)
# define nh5pset_filter_c FNAME(h5pset_filter_c)
+# define nh5pdelete_filter_c FNAME(h5pdelete_filter_c)
# define nh5pmodify_filter_c FNAME(h5pmodify_filter_c)
# define nh5pget_nfilters_c FNAME(h5pget_nfilters_c)
# define nh5pget_filter_c FNAME(h5pget_filter_c)
@@ -1034,6 +1036,8 @@ nh5pget_layout_c (hid_t_f *prp_id, int_f* layout);
H5_DLL int_f
nh5pset_filter_c (hid_t_f *prp_id, int_f* filter, int_f* flags, size_t_f* cd_nelmts, int_f* cd_values );
H5_DLL int_f
+nh5pdelete_filter_c (hid_t_f *prp_id, int_f* filter);
+H5_DLL int_f
nh5pmodify_filter_c (hid_t_f *prp_id, int_f* filter, int_f* flags, size_t_f* cd_nelmts, int_f* cd_values );
H5_DLL int_f
nh5pget_nfilters_c (hid_t_f *prp_id, int_f* nfilters);
diff --git a/fortran/test/tH5Z.f90 b/fortran/test/tH5Z.f90
index 7425f14..6d84139 100644
--- a/fortran/test/tH5Z.f90
+++ b/fortran/test/tH5Z.f90
@@ -23,6 +23,7 @@
INTEGER, INTENT(OUT) :: total_error
LOGICAL :: status, status1
INTEGER(HID_T) :: crtpr_id, xfer_id
+ INTEGER :: nfilters
INTEGER :: error
INTEGER(HSIZE_T) :: ch_dims(2)
INTEGER :: RANK = 2
@@ -92,6 +93,59 @@
endif
+!
+! Verify h5pdelete_filter_f
+!
+ CALL h5zfilter_avail_f(H5Z_FILTER_FLETCHER32_F, status, error)
+ CALL check("h5zfilter_avail_f", error, total_error)
+ if(status) then
+ CALL h5zfilter_avail_f(H5Z_FILTER_SHUFFLE_F, status, error)
+ CALL check("h5zfilter_avail_f", error, total_error)
+ if(status) then
+ CALL h5pcreate_f(H5P_DATASET_CREATE_F, crtpr_id, error)
+ CALL check("h5pcreate_f", error, total_error)
+ CALL h5pset_fletcher32_f(crtpr_id, error)
+ CALL check("h5pset_fletcher32_f", error, total_error)
+ CALL h5pset_shuffle_f(crtpr_id, error)
+ CALL check("h5pset_shuffle_f", error, total_error)
+ CALL h5pget_nfilters_f(crtpr_id, nfilters, error)
+ CALL check("h5pget_nfilters_f", error, total_error)
+
+ ! Verify the correct number of filters
+ if (nfilters .ne. 2) then
+ write(*,*) "number of filters is wrong"
+ total_error = total_error + 1
+ endif
+
+ ! Delete a single filter
+ CALL h5pdelete_filter_f(crtpr_id, H5Z_FILTER_SHUFFLE_F, error)
+ CALL check("h5pset_shuffle_f", error, total_error)
+
+ ! Verify the correct number of filters now
+ CALL h5pget_nfilters_f(crtpr_id, nfilters, error)
+ CALL check("h5pget_nfilters_f", error, total_error)
+ if (nfilters .ne. 1) then
+ write(*,*) "number of filters is wrong"
+ total_error = total_error + 1
+ endif
+
+ ! Delete all filters
+ CALL h5pdelete_filter_f(crtpr_id, H5Z_FILTER_NONE_F, error)
+ CALL check("h5pdelete_filter_f", error, total_error)
+
+ ! Verify the correct number of filters now
+ CALL h5pget_nfilters_f(crtpr_id, nfilters, error)
+ CALL check("h5pget_nfilters_f", error, total_error)
+ if (nfilters .ne. 0) then
+ write(*,*) "number of filters is wrong"
+ total_error = total_error + 1
+ endif
+ CALL h5pclose_f(crtpr_id,error)
+ CALL check("h5pclose_f", error, total_error)
+ endif
+ endif
+
+
RETURN
END SUBROUTINE filters_test
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 8c3d228..700acbc 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -42,6 +42,8 @@ New Features
Library:
--------
+ - Added new H5Pdelete_filter routine to remove I/O pipeline filters
+ from dataset creation property lists. PVN - 2004/01/26
- Added new 'compare' callback parameter to H5Pregister & H5Pinsert
routines. QAK - 2004/01/07
- Data type conversion between integers and floats was added.
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 5ee9c17..f0f1b31 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -1640,33 +1640,33 @@ done:
herr_t
H5Pdelete_filter(hid_t plist_id, H5Z_filter_t filter)
{
- H5P_genplist_t *plist; /* Property list pointer */
- H5O_pline_t pline; /* Filter pipeline */
- herr_t ret_value = SUCCEED; /* return value */
-
- FUNC_ENTER_API(H5Pdelete_filter, FAIL);
- H5TRACE2("e","iZf",plist_id,filter);
-
- /* Get the property list structure */
- if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
-
- /* Get pipeline info */
- if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline");
-
- if (pline.filter)
- {
- /* Delete filter */
- if(H5Z_delete(&pline, filter) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter");
-
- /* Put the I/O pipeline information back into the property list */
- if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline");
- }
-
+ H5P_genplist_t *plist; /* Property list pointer */
+ H5O_pline_t pline; /* Filter pipeline */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(H5Pdelete_filter, FAIL)
+ H5TRACE2("e","iZf",plist_id,filter);
+
+ /* Get the property list structure */
+ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Get pipeline info */
+ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline")
+
+ /* Check if there are any filters */
+ if (pline.filter) {
+ /* Delete filter */
+ if(H5Z_delete(&pline, filter) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter")
+
+ /* Put the I/O pipeline information back into the property list */
+ if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline")
+ } /* end if */
+
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value);
}
diff --git a/src/H5Z.c b/src/H5Z.c
index 6aa984f..d0b3783 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -1104,63 +1104,56 @@ done:
herr_t
H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
{
- size_t idx; /* Index of filter in pipeline */
- herr_t ret_value=SUCCEED; /* Return value */
- size_t i, found=0;
-
- FUNC_ENTER_NOAPI(H5Z_delete, FAIL)
-
- /* Check args */
- assert(pline);
- assert(filter>=0 && filter<=H5Z_FILTER_MAX);
-
- /* if the pipeline has no filters, just return */
- if(pline->nused==0)
- HGOTO_DONE(FALSE)
-
- /* Delete all filters */
- if (H5Z_FILTER_NONE==filter)
- {
- if(H5O_reset(H5O_PLINE_ID, pline)<0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info")
- }
- /* Delete filter */
- else
- {
- /* Locate the filter in the pipeline */
- for(idx=0; idx<pline->nused; idx++)
- {
- if(pline->filter[idx].id==filter)
- {
- found=1;
- break;
- }
- }
- /* filter was not found in the pipeline */
- if (!found)
- HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline")
-
- /* Free, reset */
- H5MM_xfree(pline->filter[idx].name);
- H5MM_xfree(pline->filter[idx].cd_values);
- HDmemset(&pline->filter[idx], 0, sizeof (H5Z_filter_info_t));
-
- /* Reorder array */
- if (idx+1<pline->nused)
- {
- for(i=idx; i<pline->nused; i++)
- {
- pline->filter[i] = pline->filter[i+1];
- }
- }
- /* Decrement number of used filters */
- pline->nused--;
-
- }
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-}
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5Z_delete, FAIL)
+
+ /* Check args */
+ assert(pline);
+ assert(filter>=0 && filter<=H5Z_FILTER_MAX);
+
+ /* if the pipeline has no filters, just return */
+ if(pline->nused==0)
+ HGOTO_DONE(SUCCEED)
+
+ /* Delete all filters */
+ if (H5Z_FILTER_NONE==filter) {
+ if(H5O_reset(H5O_PLINE_ID, pline)<0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info")
+ } /* end if */
+ /* Delete filter */
+ else {
+ size_t idx; /* Index of filter in pipeline */
+ unsigned found=0; /* Indicate filter was found in pipeline */
+ /* Locate the filter in the pipeline */
+ for(idx=0; idx<pline->nused; idx++)
+ if(pline->filter[idx].id==filter) {
+ found=1;
+ break;
+ }
+
+ /* filter was not found in the pipeline */
+ if (!found)
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline")
+
+ /* Free information for deleted filter */
+ H5MM_xfree(pline->filter[idx].name);
+ H5MM_xfree(pline->filter[idx].cd_values);
+
+ /* Remove filter from pipeline array */
+ if((idx+1)<pline->nused)
+ HDmemcpy(&pline->filter[idx], &pline->filter[idx+1],
+ sizeof (H5Z_filter_info_t)*(pline->nused-(idx+1)));
+
+ /* Decrement number of used filters */
+ pline->nused--;
+ /* Reset information for previous last filter in pipeline */
+ HDmemset(&pline->filter[pline->nused], 0, sizeof (H5Z_filter_info_t));
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}
diff --git a/test/dsets.c b/test/dsets.c
index 5121234..e189f9b 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -3074,8 +3074,7 @@ error:
return -1;
} /* end test_compare_dcpl() */
-
-
+
/*-------------------------------------------------------------------------
* Function: test_filter_delete
*
@@ -3094,105 +3093,110 @@ error:
static herr_t
test_filter_delete(hid_t file)
{
- H5Z_filter_t filtn; /* filter identification number */
- hid_t dsid; /* dataset ID */
- hid_t sid; /* dataspace ID */
- hid_t dcpl; /* dataset creation property list ID */
- hid_t dcpl1; /* dataset creation property list ID */
- hsize_t dims[2] = {20,20}; /* dataspace dimensions */
- hsize_t chunk_dims[2] = {10,10}; /* chunk dimensions */
- size_t nfilters; /* number of filters in DCPL */
- size_t i;
-
- TESTING("filter deletion");
-
- /* Create the data space */
- if ((sid = H5Screate_simple(2, dims, NULL))<0) goto error;
-
- /* Create dcpl */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
- if(H5Pset_chunk(dcpl, 2, chunk_dims)<0) goto error;
+ H5Z_filter_t filtn; /* filter identification number */
+ hid_t dsid; /* dataset ID */
+ hid_t sid; /* dataspace ID */
+ hid_t dcpl; /* dataset creation property list ID */
+ hid_t dcpl1; /* dataset creation property list ID */
+ hsize_t dims[2] = {20,20}; /* dataspace dimensions */
+ hsize_t chunk_dims[2] = {10,10}; /* chunk dimensions */
+ size_t nfilters; /* number of filters in DCPL */
+ size_t i;
+ herr_t ret; /* Generic return value */
+
+ TESTING("filter deletion");
+
+ /* Create the data space */
+ if ((sid = H5Screate_simple(2, dims, NULL))<0) goto error;
+
+ /* Create dcpl */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if(H5Pset_chunk(dcpl, 2, chunk_dims)<0) goto error;
#if defined H5_HAVE_FILTER_FLETCHER32
- if (H5Pset_fletcher32 (dcpl)<0) goto error;
+ if (H5Pset_fletcher32 (dcpl)<0) goto error;
#endif
#if defined H5_HAVE_FILTER_DEFLATE
- if (H5Pset_deflate (dcpl, 6)<0) goto error;
+ if (H5Pset_deflate (dcpl, 6)<0) goto error;
#endif
#if defined H5_HAVE_FILTER_SHUFFLE
- if (H5Pset_shuffle (dcpl)<0) goto error;
+ if (H5Pset_shuffle (dcpl)<0) goto error;
#endif
- /* Create a dataset */
- if ((dsid = H5Dcreate(file,"dsetdel", H5T_NATIVE_INT, sid, dcpl)) <0) goto error;
+ /* Create a dataset */
+ if ((dsid = H5Dcreate(file,"dsetdel", H5T_NATIVE_INT, sid, dcpl)) <0) goto error;
- /* Get copy of dataset's dataset creation property list */
- if ((dcpl1=H5Dget_create_plist(dsid))<0) goto error;
-
-/*----------------------------------------------------------------------
- * delete the deflate filter
- *----------------------------------------------------------------------
- */
+ /* Get copy of dataset's dataset creation property list */
+ if ((dcpl1=H5Dget_create_plist(dsid))<0) goto error;
+ /*----------------------------------------------------------------------
+ * delete the deflate filter
+ *----------------------------------------------------------------------
+ */
#if defined H5_HAVE_FILTER_DEFLATE
-
- /* delete the deflate filter */
- if (H5Pdelete_filter(dcpl1,H5Z_FILTER_DEFLATE)<0) goto error;
-
- /* get information about filters */
- if ((nfilters = H5Pget_nfilters(dcpl1))<0) goto error;
+ /* delete the deflate filter */
+ if (H5Pdelete_filter(dcpl1,H5Z_FILTER_DEFLATE)<0) goto error;
- /* check if filter was deleted */
- for (i=0; i<nfilters; i++)
- {
- filtn = H5Pget_filter(dcpl1,i,0,0,0,0,0);
- if (H5Z_FILTER_DEFLATE==filtn)
- goto error;
- }
+ /* get information about filters */
+ if ((nfilters = H5Pget_nfilters(dcpl1))<0) goto error;
+
+ /* check if filter was deleted */
+ for (i=0; i<nfilters; i++) {
+ filtn = H5Pget_filter(dcpl1,i,0,0,0,0,0);
+ if (H5Z_FILTER_DEFLATE==filtn)
+ goto error;
+ }
+
+ /* Try to delete the deflate filter again */
+ H5E_BEGIN_TRY {
+ ret=H5Pdelete_filter(dcpl1,H5Z_FILTER_DEFLATE);
+ } H5E_END_TRY;
+ if (ret >=0) {
+ H5_FAILED();
+ printf(" Line %d: Shouldn't have deleted filter!\n",__LINE__);
+ goto error;
+ } /* end if */
#endif /*H5_HAVE_FILTER_DEFLATE*/
-
-/*----------------------------------------------------------------------
- * delete all filters
- *----------------------------------------------------------------------
- */
- /* delete all filters */
- if (H5Pdelete_filter(dcpl1,H5Z_FILTER_NONE)<0) goto error;
- /* get information about filters */
- if ((nfilters = H5Pget_nfilters(dcpl1))<0) goto error;
+ /*----------------------------------------------------------------------
+ * delete all filters
+ *----------------------------------------------------------------------
+ */
+ /* delete all filters */
+ if (H5Pdelete_filter(dcpl1,H5Z_FILTER_NONE)<0) goto error;
- /* check if filters were deleted */
- if (nfilters)goto error;
-
-/*----------------------------------------------------------------------
- * close
- *----------------------------------------------------------------------
- */
-
- /* clean up objects used for this test */
- if (H5Pclose (dcpl)<0) goto error;
- if (H5Pclose (dcpl1)<0) goto error;
- if (H5Dclose (dsid)<0) goto error;
- if (H5Sclose (sid)<0) goto error;
-
- PASSED();
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Pclose(dcpl);
- H5Pclose(dcpl1);
- H5Dclose(dsid);
- H5Sclose(sid);
- } H5E_END_TRY;
- return -1;
-}
+ /* get information about filters */
+ if ((nfilters = H5Pget_nfilters(dcpl1))<0) goto error;
+
+ /* check if filters were deleted */
+ if (nfilters)goto error;
+ /*----------------------------------------------------------------------
+ * close
+ *----------------------------------------------------------------------
+ */
+ /* clean up objects used for this test */
+ if (H5Pclose (dcpl)<0) goto error;
+ if (H5Pclose (dcpl1)<0) goto error;
+ if (H5Dclose (dsid)<0) goto error;
+ if (H5Sclose (sid)<0) goto error;
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Pclose(dcpl1);
+ H5Dclose(dsid);
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_filter_delete() */
/*-------------------------------------------------------------------------