diff options
author | James Laird <jlaird@hdfgroup.org> | 2004-07-01 17:38:04 (GMT) |
---|---|---|
committer | James Laird <jlaird@hdfgroup.org> | 2004-07-01 17:38:04 (GMT) |
commit | eab58732d86e9219fa9f41f9ab2e30fae94e4a7d (patch) | |
tree | 333b5f2c50c267c14611e042724a7f28d5156ab7 | |
parent | 3f500747fa0f4379e8e03b82f6d679628d55a8c3 (diff) | |
download | hdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.zip hdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.tar.gz hdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.tar.bz2 |
[svn-r8781]
Purpose:
HDF5 now supports SZIP with no encoder.
Description:
SZIP can be configured to have both encoder and decoder or just to have the decoder. HDF5 can now query the configuration of any filter, and will throw errors if users try to write using a filter with encoding disabled.
Solution:
Added H5Zget_filter_info function, changed API for H5Pget_filter and H5P_get_filter_by_id. See SZIP RFC.
Platforms tested:
Copper (fortran, C++, parallel), Sleipnir (C++), Arabica (fortran, C++), Verbena (fortran, C++)
Misc. update:
51 files changed, 1253 insertions, 303 deletions
@@ -960,6 +960,7 @@ ./test/big.c ./test/bittests.c ./test/cmpd_dset.c +./test/createnoenc.c ./test/dangle.c ./test/deflate.h5 ./test/dsets.c @@ -989,6 +990,7 @@ ./test/links.c ./test/mount.c ./test/mtime.c +./test/noencoder.h5 ./test/ntypes.c ./test/ohdr.c ./test/space_overflow.c _DO_NOT_DISTRIBUTE_ @@ -1137,7 +1139,7 @@ ./tools/h5repack/Dependencies ./tools/h5repack/Makefile.in -./tools/h5repack/h5repack.sh +./tools/h5repack/h5repack.sh.in ./tools/h5repack/h5repack.h ./tools/h5repack/h5repack.c ./tools/h5repack/h5repack_layout.c diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index f252151..f4150ac 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -298,16 +298,19 @@ int DSetCreatPropList::getNfilters() const ///\param cd_values - OUT: Array to hold the data; allocated by the user ///\param namelen - OUT: Length of \a name ///\param name - OUT: Name of the filter +///\param filter_config - OUT: Flags indicating whether filter can encode/decode ///\return Filter id ///\exception H5::PropListIException ///\par Description /// Failure occurs when \a filter_number is out of range. //-------------------------------------------------------------------------- -H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[]) const +H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, + unsigned int* cd_values, size_t namelen, char name[], + unsigned int& filter_config) const { H5Z_filter_t filter_id; filter_id = H5Pget_filter( id, filter_number, &flags, &cd_nelmts, - cd_values, namelen, name ); + cd_values, namelen, name, &filter_config); if( filter_id == H5Z_FILTER_ERROR ) { throw PropListIException("DSetCreatPropList::getFilter", @@ -328,12 +331,15 @@ H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, unsigned int &flags ///\param cd_values - OUT: Array to hold the data; allocated by the user ///\param namelen - IN: Length of \a name ///\param name - OUT: Name of the filter +///\param filter_config - OUT: Flags indicating whether filter can encode/decode ///\exception H5::PropListIException //-------------------------------------------------------------------------- -void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[]) const +void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, + unsigned int* cd_values, size_t namelen, char name[], + unsigned int &filter_config) const { herr_t ret_value = H5Pget_filter_by_id(id, filter_id, &flags, &cd_nelmts, - cd_values, namelen, name ); + cd_values, namelen, name, &filter_config ); if (ret_value < 0) { throw PropListIException("DSetCreatPropList::getFilterById", diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 765ce68..6ae1b75 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -67,10 +67,10 @@ class H5_DLLCPP DSetCreatPropList : public PropList { int getNfilters() const; // Returns information about a filter in a pipeline - H5Z_filter_t getFilter( int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[] ) const; + H5Z_filter_t getFilter( int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config ) const; // Returns information about a filter in a pipeline given the filter id - void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[]) const; + void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; // Modifies the specified filter void modifyFilter( H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const; diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 0d58cd0..08ce98e 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -375,7 +375,9 @@ test_tconv( H5File& file) /* This message derives from H5Z */ const H5Z_class_t H5Z_BOGUS[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encode and decode enabled */ "bogus", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ @@ -24694,6 +24694,7 @@ fi USE_FILTER_SZIP="no" + USE_FILTER_SZIP_ENCODER="no" # Check whether --with-szlib or --without-szlib was given. if test "${with_szlib+set}" = set; then @@ -25135,6 +25136,71 @@ _ACEOF USE_FILTER_SZIP="yes" + echo "$as_me:$LINENO: checking for szlib encoder" >&5 +echo $ECHO_N "checking for szlib encoder... $ECHO_C" >&6 + + if test "${hdf5_cv_szlib_can_encode+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 +echo "$as_me: error: cannot run test program while cross compiling" >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + + #include <szlib.h> + + int main(void) + { + /* SZ_encoder_enabled returns 1 if encoder is present */ + if(SZ_encoder_enabled() == 1) + exit(0); + else + exit(1); + } + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + hdf5_cv_szlib_can_encode=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +hdf5_cv_szlib_can_encode=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi + + + if test ${hdf5_cv_szlib_can_encode} = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define SZIP_CAN_ENCODE 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + USE_FILTER_SZIP_ENCODER="yes" + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi + if test "X$EXTERNAL_FILTERS" != "X"; then EXTERNAL_FILTERS="${EXTERNAL_FILTERS}," fi @@ -33727,7 +33793,7 @@ if test "X$HDF_CXX" = "Xyes"; then c++/examples/Makefile" fi -ac_config_files="$ac_config_files src/libhdf5.settings config/depend1 config/depend2 config/depend3 config/depend4 config/dependN config/commence config/conclude Makefile src/Makefile $PABLO_MAKE test/Makefile $PARALLEL_MAKE perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5repack/Makefile tools/h5ls/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/gifconv/Makefile examples/Makefile doc/Makefile doc/html/Makefile doc/html/ed_libs/Makefile doc/html/ed_styles/Makefile doc/html/ADGuide/Makefile doc/html/Graphics/Makefile doc/html/Intro/Makefile doc/html/PSandPDF/Makefile doc/html/TechNotes/Makefile doc/html/Tutor/Makefile doc/html/Tutor/Graphics/Makefile doc/html/Tutor/examples/Makefile doc/html/cpplus/Makefile doc/html/fortran/Makefile $FORTRAN_FILES $CXX_FILES" +ac_config_files="$ac_config_files src/libhdf5.settings config/depend1 config/depend2 config/depend3 config/depend4 config/dependN config/commence config/conclude Makefile src/Makefile $PABLO_MAKE test/Makefile $PARALLEL_MAKE perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/gifconv/Makefile examples/Makefile doc/Makefile doc/html/Makefile doc/html/ed_libs/Makefile doc/html/ed_styles/Makefile doc/html/ADGuide/Makefile doc/html/Graphics/Makefile doc/html/Intro/Makefile doc/html/PSandPDF/Makefile doc/html/TechNotes/Makefile doc/html/Tutor/Makefile doc/html/Tutor/Graphics/Makefile doc/html/Tutor/examples/Makefile doc/html/cpplus/Makefile doc/html/fortran/Makefile $FORTRAN_FILES $CXX_FILES" cat >confcache <<\_ACEOF @@ -34231,6 +34297,7 @@ do "tools/h5import/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/h5import/Makefile" ;; "tools/h5diff/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/h5diff/Makefile" ;; "tools/h5repack/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/h5repack/Makefile" ;; + "tools/h5repack/h5repack.sh" ) CONFIG_FILES="$CONFIG_FILES tools/h5repack/h5repack.sh" ;; "tools/h5ls/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/h5ls/Makefile" ;; "tools/lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/lib/Makefile" ;; "tools/misc/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/misc/Makefile" ;; @@ -34391,6 +34458,7 @@ s,@AR@,$AR,;t t s,@DEPEND@,,;t t s,@USE_FILTER_DEFLATE@,$USE_FILTER_DEFLATE,;t t s,@USE_FILTER_SZIP@,$USE_FILTER_SZIP,;t t +s,@USE_FILTER_SZIP_ENCODER@,$USE_FILTER_SZIP_ENCODER,;t t s,@PABLO@,$PABLO,;t t s,@HAVE_PABLO@,$HAVE_PABLO,;t t s,@SSL@,$SSL,;t t diff --git a/configure.in b/configure.in index 67f6117..3669e63 100644 --- a/configure.in +++ b/configure.in @@ -1029,6 +1029,7 @@ dnl command-line switch. The value is an include path and/or a library path. dnl If the library path is specified then it must be preceded by a comma. dnl AC_SUBST(USE_FILTER_SZIP) USE_FILTER_SZIP="no" +AC_SUBST(USE_FILTER_SZIP_ENCODER) USE_FILTER_SZIP_ENCODER="no" AC_ARG_WITH([szlib], [AC_HELP_STRING([--with-szlib=DIR], [Use szlib library for external szlib I/O @@ -1103,9 +1104,35 @@ if test "x$HAVE_SZLIB" = "xyes" -a "x$HAVE_SZLIB_H" = "xyes"; then [Define if support for szip filter is enabled]) USE_FILTER_SZIP="yes" + dnl SZLIB library is available. Check if it can encode + AC_MSG_CHECKING([for szlib encoder]) + + AC_CACHE_VAL([hdf5_cv_szlib_can_encode], + [AC_TRY_RUN([ + #include <szlib.h> + + int main(void) + { + /* SZ_encoder_enabled returns 1 if encoder is present */ + if(SZ_encoder_enabled() == 1) + exit(0); + else + exit(1); + } + ], [hdf5_cv_szlib_can_encode=yes], [hdf5_cv_szlib_can_encode=no],)]) + + if test ${hdf5_cv_szlib_can_encode} = "yes"; then + AC_DEFINE([SZIP_CAN_ENCODE], [1], + [Define if szip encoder is present]) + AC_MSG_RESULT([yes]) + USE_FILTER_SZIP_ENCODER="yes" + else + AC_MSG_RESULT([no]) + fi + dnl Add "szip" to external filter list if test "X$EXTERNAL_FILTERS" != "X"; then - EXTERNAL_FILTERS="${EXTERNAL_FILTERS}," + EXTERNAL_FILTERS="${EXTERNAL_FILTERS}," fi EXTERNAL_FILTERS="${EXTERNAL_FILTERS}szip" fi @@ -2804,6 +2831,7 @@ AC_CONFIG_FILES([src/libhdf5.settings tools/h5import/Makefile tools/h5diff/Makefile tools/h5repack/Makefile + tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/lib/Makefile tools/misc/Makefile diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index fb175b4..0ae0a19 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -1516,7 +1516,7 @@ nh5pget_filter_c(hid_t_f *prp_id, int_f* filter_number, int_f* flags, size_t_f* */ c_prp_id = (hid_t)*prp_id; c_filter_number = (int)*filter_number; - c_filter = H5Pget_filter(c_prp_id, c_filter_number, &c_flags, &c_cd_nelmts, c_cd_values, c_namelen, c_name); + c_filter = H5Pget_filter(c_prp_id, c_filter_number, &c_flags, &c_cd_nelmts, c_cd_values, c_namelen, c_name, NULL); if (c_filter < 0) goto DONE; @@ -3171,7 +3171,7 @@ nh5pget_filter_by_id_c(hid_t_f *prp_id, int_f* filter_id, int_f* flags, size_t_f */ c_prp_id = (hid_t)*prp_id; c_filter_id = (H5Z_filter_t)*filter_id; - status = H5Pget_filter_by_id(c_prp_id, c_filter_id, &c_flags, &c_cd_nelmts, c_cd_values, c_namelen, c_name); + status = H5Pget_filter_by_id(c_prp_id, c_filter_id, &c_flags, &c_cd_nelmts, c_cd_values, c_namelen, c_name, NULL); if (status < 0) goto DONE; *cd_nelmts = (size_t_f)c_cd_nelmts; diff --git a/fortran/src/H5Zf.c b/fortran/src/H5Zf.c index 70e0dee..8c2b6b6 100644 --- a/fortran/src/H5Zf.c +++ b/fortran/src/H5Zf.c @@ -67,3 +67,29 @@ nh5zfilter_avail_c ( int_f *filter , int_f *flag ) if ( status < 0 ) ret_value = -1; return ret_value; } + +/*---------------------------------------------------------------------------- + * Name: h5zget_filter_info_c + * Purpose: Call H5Zget_filter_info to find if filter has its encoder + * and/or its decoder available + * Inputs: filter - filter identifier + * Outputs: flag - status flag + * Returns: 0 on success, -1 on failure + * Programmer: Nat Furrer and James Laird + * Wednesday, June 16, 2004 + * Modifications: + *---------------------------------------------------------------------------*/ + +int_f +nh5zget_filter_info_c ( int_f *filter , int_f *flag ) +{ + int ret_value = 0; + H5Z_filter_t c_filter; + unsigned int c_flag; + + c_filter = (H5Z_filter_t)*filter; + ret_value = H5Zget_filter_info(c_filter, &c_flag); + *flag = (int_f)c_flag; + + return ret_value; +} diff --git a/fortran/src/H5Zff.f90 b/fortran/src/H5Zff.f90 index 839ab6f..a7f0494 100644 --- a/fortran/src/H5Zff.f90 +++ b/fortran/src/H5Zff.f90 @@ -130,6 +130,68 @@ END SUBROUTINE h5zfilter_avail_f +!---------------------------------------------------------------------- +! Name: h5zfilter_avail_f +! +! Purpose: Queries if filter has its encoder and/or decoder +! available +! +! Inputs: +! filter - filter +! Outputs: +! config_flags - Bit vector possibly containing the +! following values: +! H5Z_FILTER_ENCODE_ENABLED_F +! H5Z_FILTER_DECODE_ENABLED_F +! hdferr: - error code +! Success: 0 +! Failure: -1 +! Optional parameters: +! NONE +! +! Programmer: Nat Furrer and James Laird +! June 16, 2004 +! +! Modifications: +! +!---------------------------------------------------------------------- + SUBROUTINE h5zget_filter_info_f(filter, config_flags, hdferr) +! +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5zget_filter_info_f +!DEC$endif +! + + IMPLICIT NONE + INTEGER, INTENT(IN) :: filter ! Filter; may be one of the following: + ! H5Z_FILTER_DEFLATE_F + ! H5Z_FILTER_SHUFFLE_F + ! H5Z_FILTER_FLETCHER32_F + ! H5Z_FILTER_SZIP_F + INTEGER, INTENT(OUT) :: config_flags! Flag, indicates if filter + ! has its encoder and/or decoder + ! available + INTEGER, INTENT(OUT) :: hdferr ! Error code + +! INTEGER, EXTERNAL :: h5zget_filter_info_c +! MS FORTRAN needs explicit interface for C functions called here. +! + INTERFACE + INTEGER FUNCTION h5zget_filter_info_c(filter, config_flags) + USE H5GLOBAL + !DEC$ IF DEFINED(HDF5F90_WINDOWS) + !MS$ATTRIBUTES C,reference,alias:'_H5ZGET_FILTER_INFO_C'::h5zget_filter_info_c + !DEC$ ENDIF + INTEGER, INTENT(IN) :: filter + INTEGER, INTENT(OUT) :: config_flags + END FUNCTION h5zget_filter_info_c + END INTERFACE + + hdferr = h5zget_filter_info_c(filter, config_flags) + + END SUBROUTINE h5zget_filter_info_f + END MODULE H5Z diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index 9813a4f..d740d29 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -369,6 +369,9 @@ nh5init_flags_c( int_f *h5d_flags, int_f *h5f_flags, h5z_flags[8] = H5Z_NO_EDC; h5z_flags[9] = H5Z_FILTER_SZIP; h5z_flags[10] = H5Z_FLAG_OPTIONAL; + h5z_flags[11] = H5Z_FILTER_CONFIG_ENCODE_ENABLED; + h5z_flags[12] = H5Z_FILTER_CONFIG_DECODE_ENABLED; + ret_value = 0; return ret_value; diff --git a/fortran/src/H5f90global.f90 b/fortran/src/H5f90global.f90 index 0a43523..7eb5732 100644 --- a/fortran/src/H5f90global.f90 +++ b/fortran/src/H5f90global.f90 @@ -514,7 +514,7 @@ ! ! H5Z flags declaration ! - INTEGER, PARAMETER :: H5Z_FLAGS_LEN = 11 + INTEGER, PARAMETER :: H5Z_FLAGS_LEN = 13 INTEGER H5Z_flags(H5Z_FLAGS_LEN) !DEC$if defined(BUILD_HDF5_DLL) !DEC$ ATTRIBUTES DLLEXPORT :: /H5Z_FLAGS/ @@ -523,7 +523,7 @@ INTEGER :: H5Z_FILTER_ERROR_F INTEGER :: H5Z_FILTER_NONE_F - INTEGER :: H5Z_FILTER_ALL_F + INTEGER :: H5Z_FILTER_ALL_F INTEGER :: H5Z_FILTER_DEFLATE_F INTEGER :: H5Z_FILTER_SHUFFLE_F INTEGER :: H5Z_FILTER_FLETCHER32_F @@ -533,10 +533,12 @@ INTEGER :: H5Z_ENABLE_EDC_F INTEGER :: H5Z_NO_EDC_F INTEGER :: H5Z_FLAG_OPTIONAL_F + INTEGER :: H5Z_FILTER_ENCODE_ENABLED_F + INTEGER :: H5Z_FILTER_DECODE_ENABLED_F EQUIVALENCE(H5Z_flags(1), H5Z_FILTER_ERROR_F) EQUIVALENCE(H5Z_flags(2), H5Z_FILTER_NONE_F) - EQUIVALENCE(H5Z_flags(2), H5Z_FILTER_ALL_F) + EQUIVALENCE(H5Z_flags(2), H5Z_FILTER_ALL_F) EQUIVALENCE(H5Z_flags(3), H5Z_FILTER_DEFLATE_F) EQUIVALENCE(H5Z_flags(4), H5Z_FILTER_SHUFFLE_F) EQUIVALENCE(H5Z_flags(5), H5Z_FILTER_FLETCHER32_F) @@ -546,6 +548,8 @@ EQUIVALENCE(H5Z_flags(9), H5Z_NO_EDC_F) EQUIVALENCE(H5Z_flags(10), H5Z_FILTER_SZIP_F) EQUIVALENCE(H5Z_flags(11), H5Z_FLAG_OPTIONAL_F) + EQUIVALENCE(H5Z_flags(12), H5Z_FILTER_ENCODE_ENABLED_F) + EQUIVALENCE(H5Z_flags(13), H5Z_FILTER_DECODE_ENABLED_F) ! diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index 439bac6..d5bc6b9 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -1250,9 +1250,11 @@ H5_FCDLL int_f nh5dont_atexit_c(void); #ifdef DF_CAPFNAMES # define nh5zunregister_c FNAME(H5ZUNREGISTER_C) # define nh5zfilter_avail_c FNAME(H5ZFILTER_AVAIL_C) +# define nh5zget_filter_info_c FNAME(H5ZGET_FILTER_INFO_C) #else # define nh5zunregister_c FNAME(h5zunregister_c) # define nh5zfilter_avail_c FNAME(h5zfilter_avail_c) +# define nh5zget_filter_info_c FNAME(h5zget_filter_info_c) #endif #endif H5_FCDLL int_f nh5zunregister_c (int_f *filter); diff --git a/fortran/test/tH5Z.f90 b/fortran/test/tH5Z.f90 index f6291a2..cb50909 100644 --- a/fortran/test/tH5Z.f90 +++ b/fortran/test/tH5Z.f90 @@ -181,17 +181,37 @@ INTEGER :: num_errors = 0 ! Number of data errors INTEGER :: i, j !general purpose integers + INTEGER :: config_flags ! for h5zget_filter_info_f INTEGER(HSIZE_T), DIMENSION(2) :: data_dims INTEGER(HID_T) :: crp_list INTEGER :: options_mask, pix_per_block LOGICAL :: flag CHARACTER(LEN=4) filter_name - + INTEGER :: filter_flag = -1 INTEGER(SIZE_T) :: cd_nelemnts = 4 INTEGER(SIZE_T) :: filter_name_len = 4 INTEGER, DIMENSION(4) :: cd_values + ! + ! Verify that SZIP exists and has an encoder + ! + CALL h5zfilter_avail_f(H5Z_FILTER_SZIP_F, flag, error) + CALL check("h5zfilter_avail_f", error, total_error) + if(.NOT. flag) then + szip_flag = .FALSE. + total_error = -1 + return + endif + + CALL h5zget_filter_info_f(H5Z_FILTER_SZIP_F, config_flags, error) + CALL check("h5zget_filter_info_f", error, total_error) + if(.NOT. (IAND(config_flags, H5Z_FILTER_ENCODE_ENABLED_F) .eq. 1) ) then + szip_flag = .FALSE. + total_error = -1 + return + endif + options_mask = H5_SZIP_NN_OM_F + H5_SZIP_CHIP_OM_F pix_per_block = 32 ! @@ -235,8 +255,6 @@ CALL h5pclose_f(crp_list, error) CALL h5sclose_f(dspace_id, error) CALL h5fclose_f(file_id, error) - szip_flag = .FALSE. - total_error = -1 return endif diff --git a/perform/chunk.c b/perform/chunk.c index 3c159ca..7e75762 100644 --- a/perform/chunk.c +++ b/perform/chunk.c @@ -83,7 +83,9 @@ counter (unsigned UNUSED flags, size_t cd_nelmts, /* This message derives from H5Z */ const H5Z_class_t H5Z_COUNTER[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ FILTER_COUNTER, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ "counter", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 0136483..8420c89 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -89,6 +89,9 @@ New Features same within a file. QAK - 2003/08/08 - Switched over to new error API. SLU - 2003/07/25 - Added support for user defined identifier types. NF/JL - 2004/06/29 + - Added support for SZIP without encoder. Added H5Zget_filter_info + and changed H5Pget_filter and H5Pget_filter_by_id to support this + change. Parallel Library: ----------------- @@ -2017,6 +2017,10 @@ done: * whether we're working with an external file or not. Between the * two, there is a conditional call to allocate space which isn't * part of updating the cache. + * + * Nat Furrer and James Laird + * June 7, 2004 + * Added checked_filters flag * *------------------------------------------------------------------------- */ @@ -2065,6 +2069,12 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space if(NULL == (new_dset = H5D_new(dcpl_id,TRUE,has_vl_type))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + /* + * Set the dataset's checked_filters flag to enable writing. + * Make sure that H5Z_can_apply is called at the beginning of this function! + */ + new_dset->checked_filters = TRUE; + /* Make the "set local" filter callbacks for this dataset */ if(H5Z_set_local(new_dset->dcpl_id,type_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") @@ -2209,7 +2219,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space assert((unsigned)(new_dset->layout.u.chunk.ndims) <= NELMTS(new_dset->layout.u.chunk.dim)); new_dset->layout.u.chunk.addr = HADDR_UNDEF; /* Initialize to no address */ - + /* * Chunked storage allows any type of data space extension, so we * don't even bother checking. @@ -2267,7 +2277,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size") } /* end case */ break; - + default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ @@ -2288,6 +2298,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space if (H5G_insert(loc, name, &new_dset->ent, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset") + /* Success */ ret_value = new_dset; @@ -2810,10 +2821,14 @@ done: * * Modifications: * - * Raymond Lu - * Tuesday, October 2, 2001 - * Changed the way to retrieve property for generic property - * list. + * Raymond Lu + * Tuesday, October 2, 2001 + * Changed the way to retrieve property for generic property + * list. + * + * Nat Furrer and James Laird + * June 7, 2004 + * Added check for filter encode capability * *------------------------------------------------------------------------- */ @@ -2822,6 +2837,8 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) { int changed; /* Flag to indicate that the dataspace was successfully extended */ H5S_t *space = NULL; /* Dataset's dataspace */ + H5D_fill_value_t fill_status; + H5D_fill_time_t fill_time; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_extend, FAIL) @@ -2830,6 +2847,44 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) assert (dataset); assert (size); + /* Check if the filters in the DCPL will need to encode, and if so, can they? + * Filters need encoding if fill value is defined and a fill policy is set that requires + * writing on an extend. + */ + if(! dataset->checked_filters) + { + + if(H5P_is_fill_value_defined(&(dataset->fill), &fill_status) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset."); + + if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) + { + if( H5Pget_fill_time(dataset->dcpl_id, &fill_time) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset."); + + if(fill_time == H5D_FILL_TIME_ALLOC || + (fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED) ) + { + /* Filters must have encoding enabled. Ensure that all filters can be applied */ + hid_t type_id; + + type_id = H5I_register(H5I_DATATYPE, dataset->type); + if(type_id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type") + + if(H5Z_can_apply(dataset->dcpl_id, type_id) <0) + { + H5I_remove(type_id); + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") + } + + if(H5I_remove(type_id) == NULL) + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id") + dataset->checked_filters = TRUE; + } + } + } + /* * NOTE: Restrictions on extensions were checked when the dataset was * created. All extensions are allowed here since none should be diff --git a/src/H5Dio.c b/src/H5Dio.c index 9cecda7..9585cd8 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -836,6 +836,8 @@ done: * Removed the must_convert parameter and move preconditions to * H5S_<foo>_opt_possible() routine * + * Nat Furrer and James Laird, 2004/6/7 + * Added check for filter encode capability *------------------------------------------------------------------------- */ static herr_t @@ -863,6 +865,27 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, assert(mem_type); assert(buf); + /* All filters in the DCPL must have encoding enabled. */ + if(! dataset->checked_filters) + { + hid_t type_id; + + type_id = H5I_register(H5I_DATATYPE, dataset->type); + if(type_id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type") + + if(H5Z_can_apply(dataset->dcpl_id, type_id) <0) + { + H5I_remove(type_id); + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") + } + + if(H5I_remove(type_id) == NULL) + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id") + + dataset->checked_filters = TRUE; + } + /* If MPI based VFD is used, no VL datatype support yet. */ /* This is because they use the global heap in the file and we don't */ /* support parallel access of that yet */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index b72a13d..18af011 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -83,6 +83,7 @@ struct H5D_t { hid_t dcpl_id; /* dataset creation property id */ H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */ H5O_layout_t layout; /* data layout */ + hbool_t checked_filters;/* TRUE if dataset passes can_apply check */ /* Cache some frequently accessed values from the DCPL */ H5O_efl_t efl; /* External file list information */ diff --git a/src/H5Edefin.h b/src/H5Edefin.h index da79308..2d70e0d 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -90,6 +90,8 @@ hid_t H5E_NOFILTER_g = FAIL; /* Requested filter is not available */ hid_t H5E_CALLBACK_g = FAIL; /* Callback failed */ hid_t H5E_CANAPPLY_g = FAIL; /* Error from filter 'can apply' callback */ hid_t H5E_SETLOCAL_g = FAIL; /* Error from filter 'set local' callback */ +hid_t H5E_NOENCODER_g = FAIL; /* Filter present but encoder not enabled */ +hid_t H5E_NODECODER_g = FAIL; /* Filter present but decoder not enabled */ /* Datatype conversion errors */ hid_t H5E_CANTCONVERT_g = FAIL; /* Can't convert datatypes */ diff --git a/src/H5Einit.h b/src/H5Einit.h index f35e11f..92b7158 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -320,6 +320,16 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'set local' callback HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_SETLOCAL_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_NOENCODER_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'no encoder' callback"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_NOENCODER_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_NODECODER_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'no decoder' callback"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_NODECODER_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /* Datatype conversion errors */ assert(H5E_CANTCONVERT_g==(-1)); diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 86baeb6..958e91c 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -147,10 +147,14 @@ H5_DLLVAR hid_t H5E_CANTALLOC_g; /* Can't allocate from file */ #define H5E_CALLBACK (H5OPEN H5E_CALLBACK_g) #define H5E_CANAPPLY (H5OPEN H5E_CANAPPLY_g) #define H5E_SETLOCAL (H5OPEN H5E_SETLOCAL_g) +#define H5E_NOENCODER (H5OPEN H5E_NOENCODER_g) +#define H5E_NODECODER (H5OPEN H5E_NODECODER_g) H5_DLLVAR hid_t H5E_NOFILTER_g; /* Requested filter is not available */ H5_DLLVAR hid_t H5E_CALLBACK_g; /* Callback failed */ H5_DLLVAR hid_t H5E_CANAPPLY_g; /* Error from filter 'can apply' callback */ H5_DLLVAR hid_t H5E_SETLOCAL_g; /* Error from filter 'set local' callback */ +H5_DLLVAR hid_t H5E_NOENCODER_g; /* Filter present, but encoding disabled */ +H5_DLLVAR hid_t H5E_NODECODER_g; /* Filter present, but decoding disabled */ /* Datatype conversion errors */ #define H5E_CANTCONVERT (H5OPEN H5E_CANTCONVERT_g) diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 1789039..2acd75d 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -92,6 +92,8 @@ H5E_NOFILTER_g= H5E_CALLBACK_g= H5E_CANAPPLY_g= H5E_SETLOCAL_g= +H5E_NOENCODER_g= +H5E_NODECODER_g= /* Datatype conversion errors */ H5E_CANTCONVERT_g= diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h index 867507e..2062f61 100644 --- a/src/H5MPprivate.h +++ b/src/H5MPprivate.h @@ -415,6 +415,7 @@ #define color_H5Zregister "red" #define color_H5Zfilter_avail "red" #define color_H5Zunregister "red" +#define color_H5Zget_filter_info "red" #else #define MPE_LOG_VARS(func_name) /* void */ @@ -5735,4 +5735,3 @@ H5Pclose_class(hid_t cls_id) done: FUNC_LEAVE_API(ret_value); } /* H5Pclose_class() */ - diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index fb5f9a9..48abd21 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -501,6 +501,8 @@ done: * failed; the filter will not participate in the pipeline * during an H5Dread() of the chunk. If this bit is clear and * the filter fails then the entire I/O operation fails. + * If this bit is set but encoding is disabled for a filter, + * attempting to write will generate an error. * * Note: This function currently supports only the permanent filter * pipeline. That is, PLIST_ID must be a dataset creation @@ -577,6 +579,8 @@ done: * failed; the filter will not participate in the pipeline * during an H5Dread() of the chunk. If this bit is clear and * the filter fails then the entire I/O operation fails. + * If this bit is set but encoding is disabled for a filter, + * attempting to write will generate an error. * * Note: This function currently supports only the permanent filter * pipeline. That is, PLIST_ID must be a dataset creation @@ -695,10 +699,11 @@ done: * dataset creation or transfer property list. On input, * CD_NELMTS indicates the number of entries in the CD_VALUES * array allocated by the caller while on exit it contains the - * number of values defined by the filter. The IDX should be a - * value between zero and N-1 as described for H5Pget_nfilters() - * and the function will return failure if the filter number is - * out or range. + * number of values defined by the filter. FILTER_CONFIG is a bit + * field contaning encode/decode flags from H5Zpublic.h. The IDX + * should be a value between zero and N-1 as described for + * H5Pget_nfilters() and the function will return failure if the + * filter number is out of range. * * Return: Success: Filter identification number. * @@ -712,7 +717,11 @@ done: * Raymond Lu * Tuesday, October 2, 2001 * Changed the way to check paramter and set property for - * generic property list. + * generic property list. + * + * James Laird and Nat Furrer + * Tuesday, June 15, 2004 + * Function now retrieves filter_config flags. * *------------------------------------------------------------------------- */ @@ -725,7 +734,8 @@ H5Pget_filter(hid_t plist_id, int idx, unsigned int *flags/*out*/, H5Z_filter_t H5Pget_filter(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/) + size_t namelen, char name[]/*out*/, + unsigned int *filter_config /*out*/) #endif /* H5_WANT_H5_V1_6_COMPAT */ { H5O_pline_t pline; /* Filter pipeline */ @@ -808,7 +818,13 @@ H5Pget_filter(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, else name[0] = '\0'; } - + +#ifndef H5_WANT_H5_V1_6_COMPAT + /* Get filter configuration, assume filter ID has already been checked */ + if(filter_config != NULL) + H5Zget_filter_info(filter->id, filter_config); +#endif + /* Set return value */ ret_value=filter->id; @@ -821,14 +837,15 @@ done: * Function: H5Pget_filter_by_id * * Purpose: This is an additional query counterpart of H5Pset_filter() and - * returns information about a particular filter in a permanent + * returns information about a particular filter in a permanent * or transient pipeline depending on whether PLIST_ID is a * dataset creation or transfer property list. On input, * CD_NELMTS indicates the number of entries in the CD_VALUES * array allocated by the caller while on exit it contains the - * number of values defined by the filter. The ID should be the - * filter ID to retrieve the parameters for. If the filter is not - * set for the property list, an error will be returned. + * number of values defined by the filter. FILTER_CONFIG is a bit + * field contaning encode/decode flags from H5Zpublic.h. The ID + * should be the filter ID to retrieve the parameters for. If the + * filter is not set for the property list, an error will be returned. * * Return: Success: Non-negative * Failure: Negative @@ -837,13 +854,23 @@ done: * Friday, April 5, 2003 * * Modifications: + * James Laird and Nat Furrer + * Tuesday, June 15, 2004 + * Function now retrieves filter_config flags. * *------------------------------------------------------------------------- */ +#ifdef H5_WANT_H5_V1_6_COMPAT herr_t H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/) +#else +herr_t +H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, + size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, + size_t namelen, char name[]/*out*/, unsigned int *filter_config) +#endif /* H5_WANT_H5_V1_6_COMPAT */ { H5O_pline_t pline; /* Filter pipeline */ H5Z_filter_info_t *filter; /* Pointer to filter information */ @@ -911,7 +938,13 @@ H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, else name[0] = '\0'; } - + +#ifndef H5_WANT_H5_V1_6_COMPAT + /* Get filter configuration, assume filter ID has already been checked */ + if(filter_config != NULL) + H5Zget_filter_info(id, filter_config); +#endif + done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_filter_by_id() */ @@ -1032,6 +1065,10 @@ done: * Tuesday, April 1, 2003 * * Modifications: + * Nat Furrer and James Laird + * June 30, 2004 + * Now ensures that SZIP encoding is enabled + * SZIP defaults to k13 compression * *------------------------------------------------------------------------- */ @@ -1041,11 +1078,18 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ unsigned cd_values[2]; /* Filter parameters */ + unsigned int config_flags; herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_szip, FAIL); H5TRACE3("e","iIuIu",plist_id,options_mask,pixels_per_block); - + + if(H5Zget_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't get filter info") + + if(! (config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED)) + HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); + /* Check arguments */ if ((pixels_per_block%2)==1) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even"); @@ -1056,6 +1100,10 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + /* Always set K13 compression (and un-set CHIP compression) */ + options_mask &= (~H5_SZIP_CHIP_OPTION_MASK); + options_mask |= H5_SZIP_ALLOW_K13_OPTION_MASK; + /* Always set "raw" (no szip header) flag for data */ options_mask |= H5_SZIP_RAW_OPTION_MASK; diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 4d1e027..89d3f6c 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -242,13 +242,23 @@ H5_DLL H5Z_filter_t H5Pget_filter(hid_t plist_id, unsigned filter, unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]); + size_t namelen, char name[], + unsigned int *filter_config /*out*/); #endif /* H5_WANT_H5_V1_6_COMPAT */ +#ifdef H5_WANT_H5_V1_6_COMPAT H5_DLL H5Z_filter_t H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]); + size_t namelen, char name[]/*out*/); +#else /* H5_WANT_H5_V1_6_COMPAT */ +H5_DLL H5Z_filter_t H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, + unsigned int *flags/*out*/, + size_t *cd_nelmts/*out*/, + unsigned cd_values[]/*out*/, + size_t namelen, char name[]/*out*/, + unsigned int *filter_config/*out*/); +#endif /* H5_WANT_H5_V1_6_COMPAT */ H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id); H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression); H5_DLL herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block); @@ -216,6 +216,13 @@ H5Zregister(const H5Z_class_t *cls) /* Check args */ if (cls==NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class") + + /* Check H5Z_class_t version number; this is where a function to convert + * from an outdated version should be called. + */ + if(cls->version != H5Z_CLASS_T_VERS) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number"); + if (cls->id<0 || cls->id>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") if (cls->id<H5Z_FILTER_RESERVED) @@ -519,6 +526,11 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Make correct callback */ switch(prelude_type) { case H5Z_PRELUDE_CAN_APPLY: + /* Check if filter is configured to be able to encode */ + if(! fclass->encoder_present) + HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); + + /* Check if there is a "can apply" callback */ if(fclass->can_apply) { /* Make callback to filter's "can apply" function */ @@ -600,7 +612,7 @@ herr_t H5Z_can_apply (hid_t dcpl_id, hid_t type_id) { herr_t ret_value=SUCCEED; /* Return value */ - + FUNC_ENTER_NOAPI(H5Z_can_apply,FAIL) assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id)); @@ -608,7 +620,7 @@ H5Z_can_apply (hid_t dcpl_id, hid_t type_id) /* Make "can apply" callbacks for filters in pipeline */ if(H5Z_prelude_callback(dcpl_id, type_id, H5Z_PRELUDE_CAN_APPLY)<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate") + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1157,3 +1169,49 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) done: FUNC_LEAVE_NOAPI(ret_value) } + +/*------------------------------------------------------------------------- + * Function: H5Zget_filter_info + * + * Purpose: Gets information about a pipeline data filter and stores it + * in filter_config_flags. + * + * Return: zero on success / negative on failure + * + * Programmer: James Laird and Nat Furrer + * Monday, June 7, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) +{ + herr_t ret_value=SUCCEED; + H5Z_class_t * fclass; + + FUNC_ENTER_API(H5Zget_filter_info, FAIL) + + fclass = H5Z_find(filter); + +#ifdef H5_WANT_H5_V1_6_COMPAT + if(fclass == NULL && filter_config_flags != NULL) + *filter_config_flags = 0; +#else + if(fclass == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Filter not defined") +#endif /* H5_WANT_H5_V1_6_COMPAT */ + + if(filter_config_flags != NULL) + { + *filter_config_flags = 0; + + if(fclass->encoder_present) + *filter_config_flags |= H5Z_FILTER_CONFIG_ENCODE_ENABLED; + if(fclass->decoder_present) + *filter_config_flags |= H5Z_FILTER_CONFIG_DECODE_ENABLED; + } + +done: + FUNC_LEAVE_API(ret_value) +} diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index 3202221..16890b0 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -40,7 +40,10 @@ static size_t H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, /* This message derives from H5Z */ const H5Z_class_t H5Z_DEFLATE[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DEFLATE, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ "deflate", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index dfd69cf..38fda53 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -37,7 +37,10 @@ static size_t H5Z_filter_fletcher32 (unsigned flags, size_t cd_nelmts, /* This message derives from H5Z */ const H5Z_class_t H5Z_FLETCHER32[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_FLETCHER32, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ "fletcher32", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ diff --git a/src/H5Zpkg.h b/src/H5Zpkg.h index 4643bbc..7f9fd84 100644 --- a/src/H5Zpkg.h +++ b/src/H5Zpkg.h @@ -47,10 +47,11 @@ H5_DLLVAR const H5Z_class_t H5Z_FLETCHER32[1]; /* * szip filter */ -H5_DLLVAR const H5Z_class_t H5Z_SZIP[1]; +H5_DLLVAR H5Z_class_t H5Z_SZIP[1]; #endif /* H5_HAVE_FILTER_SZIP */ /* Package-local function prototypes */ +H5_DLL void H5Z_update_class_vers(H5Z_class_t * old_vers, H5Z_class_t * curr_vers); #endif /* _H5Zpkg_H */ diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index ee7ad3c..83c2ada 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -58,6 +58,9 @@ typedef int H5Z_filter_t; #define H5_SZIP_NN_OPTION_MASK 32 #define H5_SZIP_MAX_PIXELS_PER_BLOCK 32 +/* Current version of the H5Z_class_t struct */ +#define H5Z_CLASS_T_VERS (1) + /* Values to decide if EDC is enabled for reading data */ typedef enum H5Z_EDC_t { H5Z_ERROR_EDC = -1, /* error value */ @@ -66,6 +69,10 @@ typedef enum H5Z_EDC_t { H5Z_NO_EDC = 2 /* must be the last */ } H5Z_EDC_t; +/* Bit flags for H5Zget_filter_info */ +#define H5Z_FILTER_CONFIG_ENCODE_ENABLED (0x0001) +#define H5Z_FILTER_CONFIG_DECODE_ENABLED (0x0002) + /* Return values for filter callback function */ typedef enum H5Z_cb_return_t { H5Z_CB_ERROR = -1, @@ -77,7 +84,7 @@ typedef enum H5Z_cb_return_t { /* Filter callback function definition */ typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void* buf, size_t buf_size, void* op_data); - + /* Structure for filter callback property */ typedef struct H5Z_cb_t { H5Z_filter_func_t func; @@ -157,7 +164,10 @@ typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, * contain a pointers to the filter function and timing statistics. */ typedef struct H5Z_class_t { + int version; /* Version number of the H5Z_class_t struct */ H5Z_filter_t id; /* Filter ID number */ + unsigned encoder_present; /* Does this filter have an encoder? */ + unsigned decoder_present; /* Does this filter have a decoder? */ const char *name; /* Comment for debugging */ H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ @@ -167,7 +177,7 @@ typedef struct H5Z_class_t { H5_DLL herr_t H5Zregister(const H5Z_class_t *cls); H5_DLL herr_t H5Zunregister(H5Z_filter_t id); H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); - +H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); #ifdef __cplusplus } diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index 36b6f23..75c7c48 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -34,7 +34,10 @@ static size_t H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, /* This message derives from H5Z */ const H5Z_class_t H5Z_SHUFFLE[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_SHUFFLE, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ "shuffle", /* Filter name for debugging */ NULL, /* The "can apply" callback */ H5Z_set_local_shuffle, /* The "set local" callback */ @@ -75,7 +78,11 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id) FUNC_ENTER_NOAPI(H5Z_set_local_shuffle, FAIL) /* Get the filter's current parameters */ +#ifdef H5_WANT_H5_V1_6_COMPAT if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0) +#else + if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL,NULL)<0) +#endif HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") /* Set "local" parameter for this dataset */ diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 6683776..5eafec1 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -40,9 +40,16 @@ static size_t H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ -const H5Z_class_t H5Z_SZIP[1] = {{ +H5Z_class_t H5Z_SZIP[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_SZIP, /* Filter id number */ - "szip", /* Filter name for debugging */ +#ifdef H5_SZIP_CAN_ENCODE + 1, /* Encoder present */ +#else + 0, /* Encoder disabled */ +#endif + 1, /* decoder_present flag (set to true) */ + "szip", /* Filter name for debugging */ H5Z_can_apply_szip, /* The "can apply" callback */ H5Z_set_local_szip, /* The "set local" callback */ H5Z_filter_szip, /* The actual filter function */ @@ -96,8 +103,12 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) FUNC_ENTER_NOAPI(H5Z_can_apply_szip, FAIL) /* Get the filter's current parameters */ +#ifdef H5_WANT_H5_V1_6_COMPAT if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") +#else + if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL,NULL)<0) +#endif + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") /* Get datatype's size, for checking the "bits-per-pixel" */ if((dtype_size=(sizeof(unsigned char)*H5Tget_size(type_id)))==0) @@ -171,7 +182,11 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) FUNC_ENTER_NOAPI(H5Z_set_local_szip, FAIL) /* Get the filter's current parameters */ +#ifdef H5_WANT_H5_V1_6_COMPAT if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0) +#else + if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL,NULL)<0) +#endif HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") /* Get dimensions for dataspace */ @@ -328,5 +343,6 @@ done: H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } + #endif /* H5_HAVE_FILTER_SZIP */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 48af1ba..2aa53c4 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -517,6 +517,9 @@ PTHREAD_SCOPE_SYSTEM) call. */ #undef SYSTEM_SCOPE_THREADS +/* Define if szip encoder is present */ +#undef SZIP_CAN_ENCODE + /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #undef TIME_WITH_SYS_TIME diff --git a/src/H5err.txt b/src/H5err.txt index 2f26e7d..802cccf 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -204,3 +204,4 @@ MINOR, PIPELINE, H5E_NOFILTER, Requested filter is not available MINOR, PIPELINE, H5E_CALLBACK, Callback failed MINOR, PIPELINE, H5E_CANAPPLY, Error from filter 'can apply' callback MINOR, PIPELINE, H5E_SETLOCAL, Error from filter 'set local' callback +MINOR, PIPELINE, H5E_NOENCODER, Filter present but encoding disabled diff --git a/test/createnoenc.c b/test/createnoenc.c new file mode 100644 index 0000000..f444df6 --- /dev/null +++ b/test/createnoenc.c @@ -0,0 +1,80 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "hdf5.h" + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Generates the noencoder.h5 file used to test SZIP without + * an encoder present. + * + * Return: Success: zero + * + * Failure: non-zero + * + * Programmer: James Laird and Nat Furrer + * Thursday, July 1, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +main() +{ + hid_t file_id; + hid_t dset_id; + hid_t dcpl_id; + hid_t space_id; + hsize_t dims, maxdims; + int fill = 0; + int write_buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + file_id = H5Fcreate("noencoder.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + dims = 10; + maxdims = H5S_UNLIMITED; + space_id = H5Screate_simple(1, &dims, &maxdims); + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + H5Pset_chunk(dcpl_id, 1, &dims); + H5Pset_szip(dcpl_id, H5_SZIP_NN_OPTION_MASK, 4); + H5Pset_fill_value(dcpl_id, H5T_NATIVE_INT, &fill); + H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_ALLOC); + + /* Create dataset noencoder_szip_dset.h5 */ + dset_id = H5Dcreate(file_id, "noencoder_szip_dset.h5", H5T_NATIVE_INT, space_id, dcpl_id); + + H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); + + H5Pclose(dcpl_id); + H5Dclose(dset_id); + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + H5Pset_chunk(dcpl_id, 1, &dims); + H5Pset_szip(dcpl_id, H5_SZIP_NN_OPTION_MASK, 4); + H5Pset_shuffle(dcpl_id); + H5Pset_fletcher32(dcpl_id); + H5Pset_fill_value(dcpl_id, H5T_NATIVE_INT, &fill); + H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_ALLOC); + + /* Create dataset noencoder_szip_shuffle_fletcher_dset.h5 */ + dset_id = H5Dcreate(file_id, "noencoder_szip_shuffle_fletcher_dset.h5", H5T_NATIVE_INT, space_id, dcpl_id); + + H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); + + H5Pclose(dcpl_id); + H5Dclose(dset_id); + H5Sclose(space_id); + H5Fclose(file_id); +}
\ No newline at end of file diff --git a/test/dsets.c b/test/dsets.c index 0c9c18d..152dc97 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -1,4 +1,4 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * @@ -25,7 +25,6 @@ #include "h5test.h" #include "H5private.h" - /* * This file needs to access private datatypes from the H5Z package. */ @@ -109,6 +108,11 @@ const char *FILENAME[] = { #define FILTER_HS_SIZE1 4 #define FILTER_HS_SIZE2 50 +/* Names for noencoder test */ +#define NOENCODER_FILENAME "noencoder.h5" +#define NOENCODER_TEST_DATASET "noencoder_tdset.h5" +#define NOENCODER_SZIP_DATASET "noencoder_szip_dset.h5" +#define NOENCODER_SZIP_SHUFF_FLETCH_DATASET "noencoder_szip_shuffle_fletcher_dset.h5" /* Shared global arrays */ #define DSET_DIM1 100 #define DSET_DIM2 200 @@ -955,7 +959,9 @@ test_tconv(hid_t file) /* This message derives from H5Z */ const H5Z_class_t H5Z_BOGUS[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ "bogus", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ @@ -1044,8 +1050,13 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id) add_on=(unsigned)H5Tget_size(type_id); /* Get the filter's current parameters */ +#ifdef H5_WANT_H5_V1_6_COMPAT if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_BOGUS2,&flags,&cd_nelmts, cd_values,0,NULL)<0) +#else + if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_BOGUS2,&flags,&cd_nelmts, + cd_values,0,NULL,NULL)<0) +#endif return(FAIL); /* Check that the parameter values were passed along correctly */ @@ -1128,7 +1139,9 @@ filter_bogus2(unsigned int flags, size_t cd_nelmts, /* This message derives from H5Z */ const H5Z_class_t H5Z_CORRUPT[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_CORRUPT, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ "corrupt", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ @@ -1301,7 +1314,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } TESTING(" filters (setup)"); - + /* Check if all the filters are available */ if(H5Pall_filters_avail(dcpl)!=TRUE) { H5_FAILED(); @@ -1596,7 +1609,134 @@ error: return -1; } - +/*------------------------------------------------------------------------- + * Function: test_filter_noencoder + * + * Purpose: Tests filters with no encoder present. Ensures that data + * can still be decoded correctly and that errors are thrown + * when the application tries to write. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Nat Furrer and James Laird + * Monday, June 7, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filter_noencoder(const char *dset_name) +{ + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t test_dset_id = -1; + hid_t dcpl_id = -1; + hid_t space_id = -1; + hsize_t dims = 10; + herr_t err; + int test_ints[10] = { 12 }; + int read_buf[10]; + int i; + char * srcdir = HDgetenv("srcdir"); /* Source directory */ + char testfile[512]=""; /* Buffer to hold name of test file */ + + /* + * Create the name of the file to open (in case we are using the --srcdir + * option and the file is in a different directory from this test). + */ + if (srcdir && ((HDstrlen(srcdir) + HDstrlen(NOENCODER_FILENAME) + 1) < sizeof(testfile)) ) + { + HDstrcpy(testfile, srcdir); + HDstrcat(testfile, "/"); + } + HDstrcat(testfile, NOENCODER_FILENAME); + + file_id = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT); + if (file_id < 0) goto error; + + dset_id = H5Dopen(file_id, dset_name); + if (dset_id < 0) goto error; + + space_id = H5Screate_simple(1, &dims, NULL); + if (space_id < 0) goto error; + + TESTING(" decoding without encoder"); + + /* Read the dataset and make sure the decoder is working correctly */ + err = H5Dread(dset_id, H5T_NATIVE_INT, space_id, space_id, H5P_DEFAULT, read_buf); + if (err < 0) goto error; + + for(i = 0; i < 10; i++) + if ( read_buf[i] != i ) goto error; + + H5Sclose(space_id); + + PASSED(); + + /* Attempt to copy the DCPL and use it to create a new dataset. + * Since the filter does not have an encoder, the creation + * should fail. + */ + TESTING(" trying to write without encoder"); + + dcpl_id = H5Dget_create_plist(dset_id); + if (dcpl_id < 0) goto error; + + space_id = H5Screate_simple(1, &dims, NULL); + if (space_id < 0) goto error; + + H5E_BEGIN_TRY{ + test_dset_id = H5Dcreate(file_id, NOENCODER_TEST_DATASET, H5T_NATIVE_INT, space_id , dcpl_id); + }H5E_END_TRY + + if (test_dset_id >= 0) goto error; + + /* Attempt to extend the dataset. This should fail because + * the dataset has a fill value and is instructed to fill on + * allocation. + */ + dims = 20; /* Dataset is originally of size 10 */ + H5E_BEGIN_TRY{ + err = H5Dextend(dset_id, &dims); + }H5E_END_TRY + + if (err >= 0) goto error; + + /* Attempt to write to the dataset. This should fail because + * the filter does not have an encoder. + */ + H5E_BEGIN_TRY{ + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, test_ints); + }H5E_END_TRY + + if (err >= 0) goto error; + + H5Fclose(file_id); + H5Dclose(dset_id); + H5Sclose(space_id); + H5Pclose(dcpl_id); + + PASSED(); + + return 0; + +error: + H5_FAILED(); + if (dset_id != -1) + H5Dclose(dset_id); + if (test_dset_id != -1) + H5Dclose(test_dset_id); + if (space_id != -1) + H5Sclose(space_id); + if (dcpl_id != -1) + H5Pclose(dcpl_id); + if (file_id != -1) + H5Fclose(file_id); + return -1; +} + /*------------------------------------------------------------------------- * Function: test_filters * @@ -1634,7 +1774,7 @@ test_filters(hid_t file) hsize_t deflate_size; /* Size of dataset with deflate filter */ #endif /* H5_HAVE_FILTER_DEFLATE */ -#ifdef H5_HAVE_FILTER_SZIP +#if (defined H5_HAVE_FILTER_SZIP) && (defined H5_SZIP_CAN_ENCODE) hsize_t szip_size; /* Size of dataset with szip filter */ unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; unsigned szip_pixels_per_block=4; @@ -1737,13 +1877,26 @@ test_filters(hid_t file) *---------------------------------------------------------- */ #ifdef H5_HAVE_FILTER_SZIP - puts("Testing szip filter"); + TESTING("szip filter (with encoder)"); if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error; if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error; - if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error; +#ifdef H5_SZIP_CAN_ENCODE + puts(""); + if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error; + if(test_filter_internal(file,DSET_SZIP_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&szip_size)<0) goto error; +#else + SKIPPED(); +#endif + + TESTING("szip filter (without encoder)"); +#ifndef H5_SZIP_CAN_ENCODE + puts(""); + if(test_filter_noencoder(NOENCODER_SZIP_DATASET) < 0) goto error; +#else + SKIPPED(); +#endif - if(test_filter_internal(file,DSET_SZIP_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&szip_size)<0) goto error; if (H5Pclose (dc)<0) goto error; #else /* H5_HAVE_FILTER_SZIP */ TESTING("szip filter"); @@ -1755,7 +1908,9 @@ test_filters(hid_t file) * STEP 4: Test shuffling by itself. *---------------------------------------------------------- */ + #ifdef H5_HAVE_FILTER_SHUFFLE + puts("Testing shuffle filter"); if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error; if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error; @@ -1781,6 +1936,7 @@ test_filters(hid_t file) *---------------------------------------------------------- */ #if defined H5_HAVE_FILTER_DEFLATE && defined H5_HAVE_FILTER_SHUFFLE && defined H5_HAVE_FILTER_FLETCHER32 + puts("Testing shuffle+deflate+checksum filters(checksum first)"); if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error; if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error; @@ -1816,29 +1972,52 @@ test_filters(hid_t file) */ #if defined H5_HAVE_FILTER_SZIP && defined H5_HAVE_FILTER_SHUFFLE && defined H5_HAVE_FILTER_FLETCHER32 - puts("Testing shuffle+szip+checksum filters(checksum first)"); + TESTING("shuffle+szip+checksum filters(checksum first, with encoder)"); if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error; if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error; if (H5Pset_fletcher32 (dc)<0) goto error; if (H5Pset_shuffle (dc)<0) goto error; - if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error; - if(test_filter_internal(file,DSET_SHUF_SZIP_FLET_NAME,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size)<0) goto error; + /* Make sure encoding is enabled */ +#ifdef H5_SZIP_CAN_ENCODE + puts(""); + if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error; + if(test_filter_internal(file,DSET_SHUF_SZIP_FLET_NAME,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size)<0) goto error; +#else + SKIPPED(); +#endif + + TESTING("shuffle+szip+checksum filters(checksum first, without encoder)"); +#ifndef H5_SZIP_CAN_ENCODE + puts(""); + if (test_filter_noencoder(NOENCODER_SZIP_SHUFF_FLETCH_DATASET) < 0) goto error; +#else + SKIPPED(); +#endif /* Clean up objects used for this test */ if (H5Pclose (dc)<0) goto error; + + TESTING("shuffle+szip+checksum filters(checksum last, with encoder)"); + /* Make sure encoding is enabled */ +#ifdef H5_SZIP_CAN_ENCODE + + puts(""); + if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error; + if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error; + if (H5Pset_shuffle (dc)<0) goto error; + if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error; + if (H5Pset_fletcher32 (dc)<0) goto error; + + if(test_filter_internal(file,DSET_SHUF_SZIP_FLET_NAME_2,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size)<0) goto error; + + /* Clean up objects used for this test */ + if (H5Pclose (dc)<0) goto error; - puts("Testing shuffle+szip+checksum filters(checksum last)"); - if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error; - if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error; - if (H5Pset_shuffle (dc)<0) goto error; - if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error; - if (H5Pset_fletcher32 (dc)<0) goto error; - - if(test_filter_internal(file,DSET_SHUF_SZIP_FLET_NAME_2,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size)<0) goto error; +#else + SKIPPED(); +#endif /* H5_SZIP_CAN_ENCODE */ - /* Clean up objects used for this test */ - if (H5Pclose (dc)<0) goto error; #else /* H5_HAVE_FILTER_SZIP && H5_HAVE_FILTER_SHUFFLE && H5_HAVE_FILTER_FLETCHER32 */ TESTING("shuffle+szip+fletcher32 filters"); SKIPPED(); @@ -2388,7 +2567,9 @@ test_types(hid_t file) /* This message derives from H5Z */ const H5Z_class_t H5Z_CAN_APPLY[1] = {{ + H5Z_CLASS_T_VERS, H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, "bogus", /* Filter name for debugging */ can_apply_bogus, /* The "can apply" callback */ NULL, /* The "set local" callback */ @@ -2453,7 +2634,7 @@ test_can_apply(hid_t file) } /* end if */ /* Create new dataset */ - /* (Should fail because the 'can apply' filter should indicate inappropriate combination) */ + /* (Should fail because the 'can apply' filter should indicate inappropriate combination) */ H5E_BEGIN_TRY { dsid = H5Dcreate(file, DSET_CAN_APPLY_NAME, H5T_NATIVE_DOUBLE, sid, dcpl); } H5E_END_TRY; @@ -2572,7 +2753,7 @@ UNUSED #endif /* H5_HAVE_FILTER_SSZIP */ file) { -#ifdef H5_HAVE_FILTER_SZIP +#if (defined H5_HAVE_FILTER_SZIP) & (defined H5_SZIP_CAN_ENCODE) hid_t dsid; /* Dataset ID */ hid_t sid; /* Dataspace ID */ hid_t dcpl; /* Dataspace creation property list ID */ @@ -2583,13 +2764,18 @@ file) const hsize_t chunk_dims[2] = {250, 2048}; /* Chunk dimensions */ const hsize_t chunk_dims2[2] = {2, 1}; /* Chunk dimensions */ herr_t ret; /* Status value */ -#else /* H5_HAVE_FILTER_SZIP */ +#else /* H5_HAVE_FILTER_SZIP & H5_SZIP_CAN_ENCODE */ + #ifdef H5_HAVE_FILTER_SZIP + const char *not_supported= " Szip encoding is not enabled."; + #else /* H5_HAVE_FILTER_SZIP */ const char *not_supported= " Szip filter is not enabled."; -#endif /* H5_HAVE_FILTER_SSZIP */ + #endif /* H5_HAVE_FILTER_SZIP */ +#endif /* H5_HAVE_FILTER_SSZIP & H5_SZIP_CAN_ENCODE */ TESTING("dataset szip filter 'can apply' callback"); -#ifdef H5_HAVE_FILTER_SZIP +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + /* Create the data space */ if ((sid = H5Screate_simple(2, dims, NULL))<0) { H5_FAILED(); @@ -2720,7 +2906,7 @@ file) PASSED(); -#else /* H5_HAVE_FILTER_SZIP */ +#else /* H5_HAVE_FILTER_SZIP and H5_SZIP_CAN_ENCODE */ SKIPPED(); puts(not_supported); #endif /* H5_HAVE_FILTER_SZIP */ @@ -2735,7 +2921,9 @@ error: /* This message derives from H5Z */ const H5Z_class_t H5Z_SET_LOCAL[1] = {{ + H5Z_CLASS_T_VERS, H5Z_FILTER_BOGUS2, /* Filter id number */ + 1, 1, "bogus2", /* Filter name for debugging */ NULL, /* The "can apply" callback */ set_local_bogus2, /* The "set local" callback */ @@ -3151,7 +3339,11 @@ test_filter_delete(hid_t file) /* check if filter was deleted */ for (i=0; i<nfilters; i++) { +#ifdef H5_WANT_H5_V1_6_COMPAT filtn = H5Pget_filter(dcpl1,(unsigned)i,0,0,0,0,0); +#else + filtn = H5Pget_filter(dcpl1,(unsigned)i,0,0,0,0,0,NULL); +#endif if (H5Z_FILTER_DEFLATE==filtn) goto error; } diff --git a/test/noencoder.h5 b/test/noencoder.h5 Binary files differnew file mode 100644 index 0000000..add52e3 --- /dev/null +++ b/test/noencoder.h5 diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 2f31dde..ed41369 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2241,6 +2241,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) for (i=0; i<nfilters; i++) { cd_nelmts = NELMTS(cd_values); +#ifdef H5_WANT_H5_V1_6_COMPAT filtn = H5Pget_filter(dcpl_id, (unsigned)i, &filt_flags, @@ -2248,6 +2249,16 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) cd_values, sizeof(f_name), f_name); +#else + filtn = H5Pget_filter(dcpl_id, + (unsigned)i, + &filt_flags, + &cd_nelmts, + cd_values, + sizeof(f_name), + f_name, + NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ switch (filtn) { @@ -5572,9 +5583,15 @@ check_compression(hid_t dcpl) if (nfilt <= 0) return; for (i = 0; i < nfilt; i++) { +#ifdef H5_WANT_H5_V1_6_COMPAT filter = H5Pget_filter(dcpl, i, &flags, (size_t *) &cd_nelmts, &cd_values, 20, namebuf); +#else + filter = H5Pget_filter(dcpl, i, &flags, + (size_t *) &cd_nelmts, + &cd_values, 20, namebuf, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (filter == H5Z_FILTER_DEFLATE) { indentation(indent + COL); printf("<%sCompression />\n",xmlnsprefix); @@ -5614,9 +5631,15 @@ check_filters(hid_t dcpl) if (nfilt <= 0) return; for (i = 0; i < nfilt; i++) { +#ifdef H5_WANT_H5_V1_6_COMPAT filter = H5Pget_filter(dcpl, (unsigned)i, &flags, (size_t *) &cd_nelmts, cd_values, 120, namebuf); +#else + filter = H5Pget_filter(dcpl, (unsigned)i, &flags, + (size_t *) &cd_nelmts, + cd_values, 120, namebuf, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (filter == H5Z_FILTER_DEFLATE) { indentation(indent + COL); printf("<%sDeflate Level=\"",xmlnsprefix); diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 03ef95a..fdd4e5a 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -26,6 +26,10 @@ #include "hdf5.h" #include "H5private.h" +#ifdef H5_HAVE_FILTER_SZIP +#include "szlib.h" +#endif + #define FILE1 "tgroup.h5" #define FILE2 "tdset.h5" #define FILE3 "tattr.h5" @@ -103,8 +107,10 @@ set_local_myfilter(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id); /* This message derives from H5Z */ const H5Z_class_t H5Z_MYFILTER[1] = {{ - MYFILTER_ID, /* Filter id number */ - "myfilter", /* Filter name for debugging */ + H5Z_CLASS_T_VERS, + MYFILTER_ID, /* Filter id number */ + 1, 1, + "myfilter", /* Filter name for debugging */ NULL, /* The "can apply" callback */ set_local_myfilter, /* The "set local" callback */ myfilter, /* The actual filter function */ @@ -4543,17 +4549,17 @@ static void gent_filters(void) * SZIP *------------------------------------------------------------------------- */ -#if defined (H5_HAVE_FILTER_SZIP) - /* remove the filters from the dcpl */ - ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL); - assert(ret>=0); +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + /* remove the filters from the dcpl */ + ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL); + assert(ret>=0); - /* set szip data */ - ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); - assert(ret>=0); + /* set szip data */ + ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + assert(ret>=0); - ret=make_dset(fid,"szip",sid,dcpl,buf1); - assert(ret>=0); + ret=make_dset(fid,"szip",sid,dcpl,buf1); + assert(ret>=0); #endif /*------------------------------------------------------------------------- @@ -4623,11 +4629,11 @@ static void gent_filters(void) assert(ret>=0); #endif -#if defined (H5_HAVE_FILTER_SZIP) - szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; - /* set szip data */ - ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); - assert(ret>=0); +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; + /* set szip data */ + ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + assert(ret>=0); #endif #if defined (H5_HAVE_FILTER_DEFLATE) @@ -4917,7 +4923,11 @@ set_local_myfilter(hid_t dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id) unsigned cd_values[2]={5,6}; /* Filter parameters */ /* Get the filter's current parameters */ +#ifdef H5_WANT_H5_V1_6_COMPAT if(H5Pget_filter_by_id(dcpl_id,MYFILTER_ID,&flags,&cd_nelmts,cd_values,0,NULL)<0) +#else + if(H5Pget_filter_by_id(dcpl_id,MYFILTER_ID,&flags,&cd_nelmts,cd_values,0,NULL,NULL)<0) +#endif /* H5_WANT_H5_V1_6_COMPAT */ return(FAIL); cd_nelmts=2; diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 6bd6f87..ed73af4 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -1602,8 +1602,13 @@ dataset_list2(hid_t dset, const char UNUSED *name) if ((nf = H5Pget_nfilters(dcpl))>0) { for (i=0; i<nf; i++) { cd_nelmts = NELMTS(cd_values); +#ifdef H5_WANT_H5_V1_6_COMPAT filt_id = H5Pget_filter(dcpl, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name); +#else + filt_id = H5Pget_filter(dcpl, (unsigned)i, &filt_flags, &cd_nelmts, + cd_values, sizeof(f_name), f_name, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ f_name[sizeof(f_name)-1] = '\0'; sprintf(s, "Filter-%d:", i); printf(" %-10s %s-%u %s {", s, diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 98f1fea..6e7c61c 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/Makefile.in @@ -28,8 +28,7 @@ CPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/src -I$(top_srcdir)/src \ ## Test programs and scripts. ## TEST_PROGS=h5repacktst -TEST_SCRIPTS=$(srcdir)/h5repack.sh - +TEST_SCRIPTS=./h5repack.sh ## These are our main targets: library and tools. ## @@ -48,6 +47,7 @@ PUB_LIB= ## Temporary files. *.h5 are generated by h5repack. They should ## copied to the testfiles/ directory if update is required. MOSTLYCLEAN=*.h5 +DISTCLEAN=h5repack.sh ## Source and object files for programs... ## diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index bd89ca0..cd7a31b 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -68,7 +68,7 @@ int h5repack(const char* infile, /* check input */ if (check_options(options)<0) return -1; - + /* check for objects in input that are in the file */ if (check_objects(infile,options)<0) return -1; @@ -76,7 +76,6 @@ int h5repack(const char* infile, /* copy the objects */ if (copy_objects(infile,outfile,options)<0) return -1; - return 0; } diff --git a/tools/h5repack/h5repack.sh b/tools/h5repack/h5repack.sh deleted file mode 100644 index f1a6281..0000000 --- a/tools/h5repack/h5repack.sh +++ /dev/null @@ -1,178 +0,0 @@ -#! /bin/sh -# -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. -# -# Tests for the h5repack tool - -H5REPACK=h5repack # The tool name -H5REPACK_BIN=`pwd`/$H5REPACK # The path of the tool binary - -H5DIFF=../h5diff/h5diff # The h5diff tool name -H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary - -nerrors=0 -verbose=yes - -# The build (current) directory might be different than the source directory. -# -if test -z "$srcdir"; then - srcdir=. -fi - -test -d ../testfiles || mkdir ../testfiles - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Verifying". -# -VERIFY() { - SPACES=" " - echo "Testing h5diff output $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Call the h5diff tool -# -DIFFTEST() -{ - VERIFY $@ - if [ "`uname -s`" = "TFLOPS O/S" ]; then - $RUNSERIAL $H5DIFF_BIN $@ - else - $RUNSERIAL $H5DIFF_BIN "$@" - fi - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - fi - -} - -# Call h5repack -# -TOOLTEST() -{ - # Run test. - # Tflops interprets "$@" as "" when no parameter is given (e.g., the - # case of missing file name). Changed it to use $@ till Tflops fixes it. - TESTING $H5REPACK $@ - - infile=$srcdir/../testfiles/$1 - outfile=out.$1 - shift - if [ "`uname -s`" = "TFLOPS O/S" ]; then - $RUNSERIAL $H5REPACK_BIN -i $infile -o $outfile $@ - else - $RUNSERIAL $H5REPACK_BIN -i $infile -o $outfile "$@" - fi - - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - DIFFTEST $infile $outfile - fi - rm -f $outfile -} - - -# -# The tests -# We use the files generated by h5repacktst -# Each run generates "file4.out.h5" and the tool h5diff is used to -# compare the input and output files -# - -# copy files -TOOLTEST test1.h5 -TOOLTEST test3.h5 -TOOLTEST test4.h5 - -#TOOLTEST test5.h5 - -# remove all filters -TOOLTEST test4.h5 -f NONE - -# remove one filter -TOOLTEST test4.h5 -f dset_gzip:NONE - -# gzip -TOOLTEST test4.h5 -f dset1:GZIP=9 -TOOLTEST test4.h5 -f GZIP=1 - -# szip -TOOLTEST test4.h5 -f dset1:SZIP=8 -TOOLTEST test4.h5 -f SZIP=8 - -# shuffle -TOOLTEST test4.h5 -f dset1:SHUF -TOOLTEST test4.h5 -f SHUF - -# fletcher -TOOLTEST test4.h5 -f dset1:FLET -TOOLTEST test4.h5 -f FLET - -#layout chunk -TOOLTEST test4.h5 -l dset1:CHUNK=20x10 -TOOLTEST test4.h5 -l CHUNK=20x10 - -#layout compact -TOOLTEST test4.h5 -l dset1:COMPA -TOOLTEST test4.h5 -l COMPA - -#layout contiguous -TOOLTEST test4.h5 -l dset1:CONTI -TOOLTEST test4.h5 -l CONTI - -#conversions -TOOLTEST test4.h5 -l dset_compact:CONTI -TOOLTEST test4.h5 -l dset_compact:CHUNK=2x5 -TOOLTEST test4.h5 -l dset_compact:COMPA -TOOLTEST test4.h5 -l dset_contiguous:COMPA -TOOLTEST test4.h5 -l dset_contiguous:CHUNK=3x6 -TOOLTEST test4.h5 -l dset_contiguous:CONTI -TOOLTEST test4.h5 -l dset_chunk:COMPA -TOOLTEST test4.h5 -l dset_chunk:CONTI -TOOLTEST test4.h5 -l dset_chunk:CHUNK=18x13 - -#filters -TOOLTEST test4.h5 -f dset1:SHUF -f dset1,dset2:GZIP=6 -TOOLTEST test4.h5 -l dset1:CHUNK=20x10 -f dset1,dset2:SZIP=8 - -#filter conversions -TOOLTEST test4.h5 -f dset_gzip:SZIP=8 -TOOLTEST test4.h5 -f dset_szip:GZIP=1 -TOOLTEST test4.h5 -f dset_all:GZIP=1 - -#limit -TOOLTEST test4.h5 -f GZIP=1 -m 1024 - -#file -TOOLTEST test4.h5 -e ../testfiles/h5repack_info.txt - -if test $nerrors -eq 0 ; then - echo "All $H5REPACK tests passed." -fi - -exit $nerrors diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in new file mode 100755 index 0000000..17c6869 --- /dev/null +++ b/tools/h5repack/h5repack.sh.in @@ -0,0 +1,298 @@ +#! /bin/sh +# +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. +# +# Tests for the h5repack tool + +# Determine if SZIP has the encoder available +USE_FILTER_SZIP_ENCODER="@USE_FILTER_SZIP_ENCODER@" +USE_FILTER_SZIP="@USE_FILTER_SZIP@" + +H5REPACK=h5repack # The tool name +H5REPACK_BIN=`pwd`/$H5REPACK # The path of the tool binary + +H5DIFF=../h5diff/h5diff # The h5diff tool name +H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary + +nerrors=0 +verbose=yes + +# The build (current) directory might be different than the source directory. +# +if test -z "$srcdir"; then + srcdir=. +fi + +test -d ../testfiles || mkdir ../testfiles + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Verifying". +# +VERIFY() { + SPACES=" " + echo "Testing h5diff output $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Print a message that a test has been skipped (because a required filter +# was unavailable) +SKIP() { + TESTING $H5REPACK $@ + echo " -SKIP-" +} + +# Call the h5diff tool +# +DIFFTEST() +{ + VERIFY $@ + if [ "`uname -s`" = "TFLOPS O/S" ]; then + $RUNSERIAL $H5DIFF_BIN $@ + else + $RUNSERIAL $H5DIFF_BIN "$@" + fi + RET=$? + if [ $RET != 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + fi + +} + +# Call h5repack +# +TOOLTEST() +{ + # Run test. + # Tflops interprets "$@" as "" when no parameter is given (e.g., the + # case of missing file name). Changed it to use $@ till Tflops fixes it. + TESTING $H5REPACK $@ + + infile=$srcdir/../testfiles/$1 + outfile=out.$1 + shift + if [ "`uname -s`" = "TFLOPS O/S" ]; then + $RUNSERIAL $H5REPACK_BIN -i $infile -o $outfile $@ + else + $RUNSERIAL $H5REPACK_BIN -i $infile -o $outfile "$@" + fi + + RET=$? + if [ $RET != 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + DIFFTEST $infile $outfile + fi + rm -f $outfile +} + +# +# The tests +# We use the files generated by h5repacktst +# Each run generates "file4.out.h5" and the tool h5diff is used to +# compare the input and output files +# + +# See which filters are usable (and skip tests for filters we +# don't have). Do this by searching H5pubconf.h to see which +# filters are defined. +# A filter value of 3 means the filter can read and write, 2 +# is read-only, 1 is write-only, and 0 is not present. + +# copy files +TOOLTEST test1.h5 +TOOLTEST test3.h5 + + +arg="test4.h5" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg +else + SKIP $arg +fi + +#TOOLTEST test5.h5 + +# remove all filters +TOOLTEST test4.h5 -f NONE + +# remove one filter +arg="test4.h5 -f dset_gzip:NONE" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg +else + SKIP $arg +fi + +# gzip +arg="test4.h5 -f dset1:GZIP=9" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg +else + SKIP $arg +fi +TOOLTEST test4.h5 -f GZIP=1 + +# szip +arg1="test4.h5 -f dset1:SZIP=8" +arg2="test4.h5 -f SZIP=8" +if test $USE_FILTER_SZIP_ENCODER = "yes" -a $USE_FILTER_SZIP = "yes" ; then + TOOLTEST $arg1 + TOOLTEST $arg2 +else + SKIP $arg1 + SKIP $arg2 +fi + +# shuffle +arg="test4.h5 -f dset1:SHUF" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg +else + SKIP $arg +fi +TOOLTEST test4.h5 -f SHUF + +# fletcher +arg="test4.h5 -f dset1:FLET" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg +else + SKIP $arg +fi +TOOLTEST test4.h5 -f FLET + +#layout chunk +arg1="test4.h5 -l dset1:CHUNK=20x10" +arg2="test4.h5 -l CHUNK=20x10" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg1 + TOOLTEST $arg2 +else + SKIP $arg1 + SKIP $arg2 +fi + +#layout compact +arg1="test4.h5 -l dset1:COMPA" +arg2="test4.h5 -l COMPA" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg1 + TOOLTEST $arg2 +else + SKIP $arg1 + SKIP $arg2 +fi + +#layout contiguous +arg1="test4.h5 -l dset1:CONTI" +arg2="test4.h5 -l CONTI" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg1 + TOOLTEST $arg2 +else + SKIP $arg1 + SKIP $arg2 +fi + +#conversions +arg1="test4.h5 -l dset_compact:CONTI" +arg2="test4.h5 -l dset_compact:CHUNK=2x5" +arg3="test4.h5 -l dset_compact:COMPA" +arg4="test4.h5 -l dset_contiguous:COMPA" +arg5="test4.h5 -l dset_contiguous:CHUNK=3x6" +arg6="test4.h5 -l dset_contiguous:CONTI" +arg7="test4.h5 -l dset_chunk:COMPA" +arg8="test4.h5 -l dset_chunk:CONTI" +arg9="test4.h5 -l dset_chunk:CHUNK=18x13" +if test $USE_FILTER_SZIP_ENCODER = "yes" -o $USE_FILTER_SZIP = "no" ; then + TOOLTEST $arg1 + TOOLTEST $arg2 + TOOLTEST $arg3 + TOOLTEST $arg4 + TOOLTEST $arg5 + TOOLTEST $arg6 + TOOLTEST $arg7 + TOOLTEST $arg8 + TOOLTEST $arg9 +else + SKIP $arg1 + SKIP $arg2 + SKIP $arg3 + SKIP $arg4 + SKIP $arg5 + SKIP $arg6 + SKIP $arg7 + SKIP $arg8 + SKIP $arg9 +fi + +#filters +arg1="test4.h5 -f dset1:SHUF -f dset1,dset2:GZIP=6" +arg2="test4.h5 -l dset1:CHUNK=20x10 -f dset1,dset2:SZIP=8" +if test $USE_FILTER_SZIP_ENCODER = "yes" -a $USE_FILTER_SZIP = "yes"; then + TOOLTEST $arg1 + TOOLTEST $arg2 +elif test $USE_FILTER_SZIP = "yes" ; then # SZIP has no encoder + SKIP $arg1 + SKIP $arg2 +else # SZIP is absent + TOOLTEST $arg1 + SKIP $arg2 +fi + +#filter conversions +arg1="test4.h5 -f dset_gzip:SZIP=8" +arg2="test4.h5 -f dset_szip:GZIP=1" +arg3="test4.h5 -f dset_all:GZIP=1" +if test $USE_FILTER_SZIP_ENCODER = "yes" -a $USE_FILTER_SZIP = "yes" ; then + TOOLTEST $arg1 + TOOLTEST $arg2 + TOOLTEST $arg3 +elif test $USE_FILTER_SZIP = "yes" ; then # SZIP has no encoder + SKIP $arg1 + SKIP $arg2 + SKIP $arg3 +else # SZIP is absent + SKIP $arg1 + TOOLTEST $arg2 + TOOLTEST $arg3 +fi + +#limit +TOOLTEST test4.h5 -f GZIP=1 -m 1024 + +#file +arg="test4.h5 -e ../testfiles/h5repack_info.txt" +if test $USE_FILTER_SZIP_ENCODER = "yes" -a $USE_FILTER_SZIP = "yes" ; then + TOOLTEST $arg +else + SKIP $arg +fi + +if test $nerrors -eq 0 ; then + echo "All $H5REPACK tests passed." +fi + +exit $nerrors diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 7763bd2..70d90da 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -299,10 +299,12 @@ int do_copy_objects(hid_t fidin, */ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0) goto error; + if (dsize_in && nelmts) { if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) goto error; } + /*------------------------------------------------------------------------- * copy attrs *------------------------------------------------------------------------- diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index c8b9b5d..18080c6 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -293,6 +293,7 @@ int print_filters(hid_t dcpl_id) for (i=0; i<nfilters; i++) { cd_nelmts = NELMTS(cd_values); +#ifdef H5_WANT_H5_V1_6_COMPAT filtn = H5Pget_filter(dcpl_id, (unsigned)i, &filt_flags, @@ -300,6 +301,16 @@ int print_filters(hid_t dcpl_id) cd_values, sizeof(f_name), f_name); +#else + filtn = H5Pget_filter(dcpl_id, + (unsigned)i, + &filt_flags, + &cd_nelmts, + cd_values, + sizeof(f_name), + f_name, + NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ f_name[sizeof(f_name)-1] = '\0'; sprintf(s, "Filter-%d:", i); diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 4f69d5f..d69465b 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -60,6 +60,7 @@ int has_filter(hid_t dcpl_id, for (i=0; i<nfilters; i++) { cd_nelmts = NELMTS(cd_values); +#ifdef H5_WANT_H5_V1_6_COMPAT filtn = H5Pget_filter(dcpl_id, (unsigned)i, &filt_flags, @@ -67,6 +68,16 @@ int has_filter(hid_t dcpl_id, cd_values, sizeof(f_name), f_name); +#else + filtn = H5Pget_filter(dcpl_id, + (unsigned)i, + &filt_flags, + &cd_nelmts, + cd_values, + sizeof(f_name), + f_name, + NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (filtnin==filtn) have=1; diff --git a/tools/h5repack/testh5repack_filters.c b/tools/h5repack/testh5repack_filters.c index b285b28..597381c 100644 --- a/tools/h5repack/testh5repack_filters.c +++ b/tools/h5repack/testh5repack_filters.c @@ -76,12 +76,15 @@ int make_filters(hid_t loc_id) * SZIP *------------------------------------------------------------------------- */ - /* set szip data */ - if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block)<0) - goto out; - if (make_dset(loc_id,"dset_szip",sid,dcpl,buf)<0) - goto out; +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + /* set szip data */ + if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block)<0) + goto out; + if (make_dset(loc_id,"dset_szip",sid,dcpl,buf)<0) + goto out; + +#endif /* H5_HAVE_FILTER_SZIP && H5_SZIP_CAN_ENCODE */ /*------------------------------------------------------------------------- * GZIP *------------------------------------------------------------------------- @@ -128,18 +131,19 @@ int make_filters(hid_t loc_id) * shuffle + SZIP *------------------------------------------------------------------------- */ - /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL)<0) - goto out; - /* set the shuffle filter */ - if (H5Pset_shuffle(dcpl)<0) - goto out; - /* set szip data */ - if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block)<0) - goto out; - if (make_dset(loc_id,"dset_all",sid,dcpl,buf)<0) - goto out; - +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + /* remove the filters from the dcpl */ + if (H5Premove_filter(dcpl,H5Z_FILTER_ALL)<0) + goto out; + /* set the shuffle filter */ + if (H5Pset_shuffle(dcpl)<0) + goto out; + /* set szip data */ + if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block)<0) + goto out; + if (make_dset(loc_id,"dset_all",sid,dcpl,buf)<0) + goto out; +#endif /*------------------------------------------------------------------------- * close space and dcpl diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c index ddecd98..4c0a8c5 100644 --- a/tools/h5repack/testh5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -203,7 +203,8 @@ int main (void) TESTING(" removing szip filter"); -#ifdef H5_HAVE_FILTER_SZIP +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset_szip:NONE",&pack_options)<0) @@ -216,7 +217,6 @@ int main (void) TEST_ERROR; if (h5repack_end (&pack_options)<0) TEST_ERROR; - PASSED(); #else SKIPPED(); @@ -330,12 +330,11 @@ int main (void) TESTING(" adding szip filter"); -#ifdef H5_HAVE_FILTER_SZIP - /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; @@ -364,7 +363,7 @@ int main (void) */ TESTING(" adding szip filter to all"); -#ifdef H5_HAVE_FILTER_SZIP +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; @@ -379,7 +378,8 @@ TESTING(" adding szip filter to all"); if (h5repack_end (&pack_options)<0) TEST_ERROR; - PASSED(); + PASSED(); + #else SKIPPED(); #endif @@ -522,8 +522,10 @@ TESTING(" addding shuffle filter to all"); #endif if (h5repack_addfilter("dset1:SHUF",&pack_options)<0) TEST_ERROR; - if (h5repack_addfilter("dset1:SZIP=8",&pack_options)<0) - TEST_ERROR; +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + if (h5repack_addfilter("dset1:SZIP=8",&pack_options)<0) + TEST_ERROR; +#endif if (h5repack_addfilter("dset1:GZIP=1",&pack_options)<0) TEST_ERROR; if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0) @@ -542,7 +544,7 @@ TESTING(" addding shuffle filter to all"); * filter conversion from deflate to szip *------------------------------------------------------------------------- */ -#ifdef H5_HAVE_FILTER_DEFLATE +#if defined(H5_HAVE_FILTER_DEFLATE) && defined(H5_HAVE_FILTER_SZIP) && defined(H5_SZIP_CAN_ENCODE) if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset_gzip:SZIP=8",&pack_options)<0) @@ -556,16 +558,18 @@ TESTING(" addding shuffle filter to all"); if (h5repack_end (&pack_options)<0) TEST_ERROR; PASSED(); -#else +#else SKIPPED(); -#endif +#endif + TESTING(" filter conversion from szip to deflate"); /*------------------------------------------------------------------------- * filter conversion from szip to deflate *------------------------------------------------------------------------- */ -#ifdef H5_HAVE_FILTER_SZIP +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset_szip:GZIP=1",&pack_options)<0) @@ -579,6 +583,7 @@ TESTING(" addding shuffle filter to all"); if (h5repack_end (&pack_options)<0) TEST_ERROR; PASSED(); + #else SKIPPED(); #endif @@ -588,7 +593,8 @@ TESTING(" addding shuffle filter to all"); * filter conversion from szip to deflate *------------------------------------------------------------------------- */ -#ifdef H5_HAVE_FILTER_SZIP +#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) + if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addfilter("dset_all:GZIP=1",&pack_options)<0) @@ -601,7 +607,7 @@ TESTING(" addding shuffle filter to all"); TEST_ERROR; if (h5repack_end (&pack_options)<0) TEST_ERROR; - PASSED(); + PASSED(); #else SKIPPED(); #endif diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index bb69798..153c832 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -79,7 +79,11 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr /* check availability of filters */ for (i=0; i<nfilters; i++) { +#ifdef H5_WANT_H5_V1_6_COMPAT if ((filtn = H5Pget_filter(dcpl_id,(unsigned)i,0,0,0,0,0))<0) +#else + if ((filtn = H5Pget_filter(dcpl_id,(unsigned)i,0,0,0,0,0,NULL))<0) +#endif return -1; switch (filtn) |