Skip to content

Commit cd0f169

Browse files
authored
Merge pull request #2245 from DennisHeimbigner/filterenhance.dmh
2 parents c8a7a22 + bbdfec2 commit cd0f169

File tree

98 files changed

+2422
-1322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2422
-1322
lines changed

.github/workflows/mingw.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/run_tests_ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
name: Run Ubuntu/Linux netCDF Tests
66

7-
on: [pull_request]
7+
on: [ pull_request ]
88

99
jobs:
1010

.github/workflows/run_tests_win_mingw.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
name: Run MSYS2, MinGW64-based Tests
88

99

10-
on: [ pull_request ]
10+
on: [pull_request]
1111

1212
jobs:
1313

CMakeLists.txt

Lines changed: 85 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SET(PACKAGE_VERSION ${VERSION})
4242

4343
# Version of the dispatch table. This must match the value in
4444
# configure.ac.
45-
SET(NC_DISPATCH_VERSION 4)
45+
SET(NC_DISPATCH_VERSION 5)
4646

4747
# Get system configuration, Use it to determine osname, os release, cpu. These
4848
# will be used when committing to CDash.
@@ -601,6 +601,33 @@ ENDIF(ENABLE_STRICT_NULL_BYTE_HEADER_PADDING)
601601
# SET(BUILD_RPC ON CACHE BOOL "")
602602
#ENDIF()
603603

604+
# Note that szip management is tricky.
605+
# This is because we have three things to consider:
606+
# 1. is libsz available?
607+
# 2. is szip enabled in HDF5?
608+
# 3. is nczarr enabled?
609+
# We need separate flags for cases 1 and 2
610+
611+
# We need to determine if libsz is available both for HDF5 and NCZarr
612+
# If user has specified the `SZIP_LIBRARY`, use it; otherwise try to find...
613+
IF(NOT SZIP_LIBRARY)
614+
FIND_LIBRARY(SZIP PATH NAMES szip sz sz2)
615+
IF(SZIP)
616+
SET(SZIP_LIBRARY ${SZIP})
617+
ELSE()
618+
UNSET(SZIP_LIBRARY)
619+
UNSET(SZIP)
620+
ENDIF()
621+
ENDIF()
622+
623+
IF(SZIP_LIBRARY)
624+
SET(SZIP_FOUND yes)
625+
SET(HAVE_SZ yes)
626+
ELSE()
627+
SET(SZIP_FOUND no)
628+
SET(HAVE_SZ no)
629+
ENDIF()
630+
604631
##
605632
# Option to Enable HDF5
606633
#
@@ -860,19 +887,18 @@ IF(USE_HDF5)
860887
#error
861888
#endif
862889
int main() {
863-
int x = 1;}" USE_SZIP)
864-
IF(USE_SZIP)
890+
int x = 1;}" USE_HDF5_SZIP)
891+
IF(USE_HDF5_SZIP)
892+
SET(HAVE_H5Z_SZIP yes)
865893
# If user has specified the `SZIP_LIBRARY`, use it; otherwise try to find...
866-
IF(NOT SZIP_LIBRARY)
867-
FIND_LIBRARY(SZIP PATH NAMES szip sz)
868-
SET(SZIP_LIBRARY ${SZIP})
869-
IF(NOT SZIP)
894+
IF(SZIP_FOUND)
895+
SET(CMAKE_REQUIRED_LIBRARIES ${SZIP_LIBRARY} ${CMAKE_REQUIRED_LIBRARIES})
896+
MESSAGE(STATUS "HDF5 has szip.")
897+
ELSE()
870898
MESSAGE(FATAL_ERROR "HDF5 Requires SZIP, but cannot find libszip or libsz.")
871-
ENDIF()
872899
ENDIF()
873-
SET(HAVE_H5Z_SZIP 1)
874-
SET(CMAKE_REQUIRED_LIBRARIES ${SZIP_LIBRARY} ${CMAKE_REQUIRED_LIBRARIES})
875-
MESSAGE(STATUS "HDF5 has szip.")
900+
ELSE()
901+
SET(HAVE_H5Z_SZIP no)
876902
ENDIF()
877903

878904
####
@@ -904,9 +930,6 @@ IF(USE_HDF5)
904930

905931
#Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0)
906932
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_all_coll_metadata_ops "" HDF5_HAS_COLL_METADATA_OPS)
907-
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5free_memory "" HAVE_H5FREE_MEMORY)
908-
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5allocate_memory "" HAVE_H5ALLOCATE_MEMORY)
909-
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5resize_memory "" HAVE_H5RESIZE_MEMORY)
910933

911934
IF(HDF5_PARALLEL)
912935
SET(HDF5_CC h5pcc)
@@ -1068,30 +1091,33 @@ ELSE()
10681091
SET(ENABLE_ZLIB FALSE)
10691092
ENDIF()
10701093

1071-
# See if we have libblosc
1072-
IF(!MSVC)
1073-
FIND_PACKAGE(Blosc)
1074-
ENDIF()
1075-
# Define a test flag for have blosc library
1076-
IF(Blosc_FOUND)
1077-
INCLUDE_DIRECTORIES(${Blosc_INCLUDE_DIRS})
1078-
SET(ENABLE_BLOSC TRUE)
1094+
macro(set_std_filter filter)
1095+
# Upper case the filter name
1096+
string(TOUPPER "${filter}" upfilter)
1097+
string(TOLOWER "${filter}" downfilter)
1098+
# Define a test flag for filter
1099+
IF(${filter}_FOUND)
1100+
INCLUDE_DIRECTORIES(${filter}_INCLUDE_DIRS})
1101+
SET(ENABLE_${upfilter} TRUE)
1102+
SET(STD_FILTERS "${STD_FILTERS},${downfilter}")
10791103
ELSE()
1080-
SET(ENABLE_BLOSC FALSE)
1104+
SET(ENABLE_${upfilter} FALSE)
10811105
ENDIF()
1106+
endmacro(set_std_filter)
10821107

1083-
# See if we have libszip
1084-
IF(!MSVC)
1085-
#FIND_PACKAGE(SZIP)
1086-
#FIND_LIBRARY(SZIP PATH NAMES szip sz)
1087-
SET(SZIP_LIBRARY ${SZIP})
1088-
ENDIF()
1089-
# Define a test flag for have szip library
1090-
IF(SZIP_FOUND)
1091-
INCLUDE_DIRECTORIES(${SZIP_INCLUDE_DIRS})
1092-
SET(ENABLE_SZIP TRUE)
1093-
ELSE()
1094-
SET(ENABLE_SZIP FALSE)
1108+
# Locate some compressors
1109+
FIND_PACKAGE(Bz2)
1110+
FIND_PACKAGE(Blosc)
1111+
FIND_PACKAGE(Zstd)
1112+
1113+
# Accumulate standard filters
1114+
set(STD_FILTERS "deflate") # Always have deflate */
1115+
set_std_filter(SZIP)
1116+
set_std_filter(Blosc)
1117+
set_std_filter(Zstd)
1118+
set_std_filter(Bz2)
1119+
IF(NOT Bz2_FOUND)
1120+
set(STD_FILTERS "${STD_FILTERS},bzip2") # Always have bzip2 */
10951121
ENDIF()
10961122

10971123
# See if we have libzip
@@ -1173,21 +1199,22 @@ IF(ENABLE_NCZARR_S3_TESTS AND NOT ENABLE_NCZARR_S3)
11731199
SET(ENABLE_NCZARR_S3_TESTS OFF CACHE BOOL "NCARR S3 TESTS" FORCE)
11741200
ENDIF()
11751201

1176-
# See if aws-s3-sdk is available
1177-
# But only if enabled
1202+
# Note we check for the library after checking for enable_nczarr_s3
1203+
# because for some reason this screws up if we unconditionally test for sdk
1204+
# and it is not available. Fix someday
11781205
IF(ENABLE_NCZARR_S3)
1179-
find_package(AWSSDK REQUIRED COMPONENTS s3;core)
1180-
IF(AWSSDK_FOUND)
1181-
SET(service s3;core)
1182-
AWSSDK_DETERMINE_LIBS_TO_LINK(service AWS_LINK_LIBRARIES)
1183-
SET(ENABLE_S3_SDK ON CACHE BOOL "S3 SDK" FORCE)
1206+
# See if aws-s3-sdk is available
1207+
find_package(AWSSDK REQUIRED COMPONENTS s3;core)
1208+
IF(AWSSDK_FOUND)
1209+
SET(service s3;core)
1210+
AWSSDK_DETERMINE_LIBS_TO_LINK(service AWS_LINK_LIBRARIES)
1211+
SET(ENABLE_S3_SDK ON CACHE BOOL "S3 SDK" FORCE)
1212+
ELSE()
1213+
SET(ENABLE_S3_SDK OFF CACHE BOOL "S3 SDK" FORCE)
1214+
ENDIF()
11841215
ELSE()
11851216
SET(ENABLE_S3_SDK OFF CACHE BOOL "S3 SDK" FORCE)
11861217
ENDIF()
1187-
ELSE(ENABLE_NCZARR_S3)
1188-
# Unconditionally disable
1189-
SET(ENABLE_S3_SDK OFF CACHE BOOL "S3 SDK" FORCE)
1190-
ENDIF(ENABLE_NCZARR_S3)
11911218

11921219
IF(NOT ENABLE_S3_SDK)
11931220
IF(ENABLE_NCZARR_S3 OR ENABLE_NCZARR_S3_TESTS)
@@ -1506,11 +1533,19 @@ IF(NOT BUILD_SHARED_LIBS)
15061533
ENDIF()
15071534

15081535
OPTION(ENABLE_NCZARR_FILTERS "Enable NCZarr filters" yes)
1536+
OPTION(ENABLE_NCZARR_FILTERS_TESTING "Enable NCZarr filter testing." yes)
1537+
1538+
# Constraints
15091539
IF (NOT ENABLE_PLUGINS)
1510-
SET(ENABLE_NCZARR_FILTERS OFF CACHE BOOL "Enable NCZarr Filters." FORCE)
1540+
MESSAGE(WARNING "ENABLE_FILTER_TESTING requires shared libraries. Disabling.")
1541+
SET(ENABLE_NCZARR_FILTERS OFF CACHE BOOL "Enable NCZarr Filters." FORCE)
1542+
ENDIF()
1543+
1544+
IF (NOT ENABLE_NCZARR)
1545+
MESSAGE(WARNING "ENABLE_NCZARR==NO => ENABLE_NCZARR_FILTERS==NO AND ENABLE_NCZARR_FILTER_TESTING==NO")
1546+
SET(ENABLE_NCZARR_FILTERS OFF CACHE BOOL "Disable NCZARR_FILTERS" FORCE)
15111547
ENDIF()
15121548

1513-
OPTION(ENABLE_NCZARR_FILTERS_TESTING "Enable NCZarr filter testing." yes)
15141549
IF (NOT ENABLE_NCZARR_FILTERS)
15151550
SET(ENABLE_NCZARR_FILTER_TESTING OFF CACHE BOOL "Enable NCZarr Filter Testing" FORCE)
15161551
ENDIF()
@@ -2370,9 +2405,6 @@ is_enabled(ENABLE_V2_API HAS_NC2)
23702405
is_enabled(ENABLE_NETCDF_4 HAS_NC4)
23712406
is_enabled(ENABLE_HDF4 HAS_HDF4)
23722407
is_enabled(USE_HDF5 HAS_HDF5)
2373-
is_enabled(USE_SZIP HAS_SZIP)
2374-
is_enabled(USE_SZIP HAS_SZIP_WRITE)
2375-
is_enabled(USE_SZIP HAS_SZLIB_WRITE)
23762408
is_enabled(STATUS_PNETCDF HAS_PNETCDF)
23772409
is_enabled(STATUS_PARALLEL HAS_PARALLEL)
23782410
is_enabled(ENABLE_PARALLEL4 HAS_PARALLEL4)
@@ -2386,7 +2418,6 @@ is_enabled(JNA HAS_JNA)
23862418
is_enabled(ENABLE_ZERO_LENGTH_COORD_BOUND RELAX_COORD_BOUND)
23872419
is_enabled(USE_CDF5 HAS_CDF5)
23882420
is_enabled(ENABLE_ERANGE_FILL HAS_ERANGE_FILL)
2389-
is_enabled(HAVE_H5Z_SZIP HAS_SZLIB)
23902421
is_enabled(HDF5_HAS_PAR_FILTERS HAS_PAR_FILTERS)
23912422
is_enabled(ENABLE_NCZARR HAS_NCZARR)
23922423
is_enabled(ENABLE_NCZARR_S3_TESTS DO_NCZARR_S3_TESTS)
@@ -2395,7 +2426,8 @@ is_enabled(ENABLE_NCZARR_ZIP DO_NCZARR_ZIP_TESTS)
23952426
is_enabled(ENABLE_QUANTIZE HAS_QUANTIZE)
23962427
is_enabled(ENABLE_LOGGING HAS_LOGGING)
23972428
is_enabled(ENABLE_FILTER_TESTING DO_FILTER_TESTS)
2398-
is_enabled(ENABLE_BLOSC HAS_BLOSC)
2429+
is_enabled(HAVE_SZ HAS_SZIP)
2430+
is_enabled(HAVE_SZ HAS_SZLIB_WRITE)
23992431

24002432
# Generate file from template.
24012433
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release
77

88
## 4.8.2 - TBD
99

10+
* [Enhancement] Improve filter support. More specifically (1) add nc_inq_filter_avail to check if a filter is available, (2) add the notion of standard filters, (3) cleanup szip support to fix interaction with NCZarr. See [Github #2245](https://github.com/Unidata/netcdf-c/pull/2245).
1011
* [Bug Fix] Require that the type of the variable in nc_def_var_filter is not variable length. See [Github #/2231](https://github.com/Unidata/netcdf-c/pull/2231).
1112
* [File Change] Apply HDF5 v1.8 format compatibility when writing to previous files, as well as when creating new files. The superblock version remains at 2 for newly created files. Full backward read/write compatibility for netCDF-4 is maintained in all cases. See [Github #2176](https://github.com/Unidata/netcdf-c/issues/2176).
1213
* [Enhancement] Add ability to set dataset alignment for netcdf-4/HDF5 files. See [Github #2206](https://github.com/Unidata/netcdf-c/pull/2206).

cmake/modules/FindBz2.cmake

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Searches for an installation of the bz2 library. On success, it sets the following variables:
2+
#
3+
# Bz2_FOUND Set to true to indicate the bz2 library was found
4+
# Bz2_INCLUDE_DIRS The directory containing the header file bz2/bz2.h
5+
# Bz2_LIBRARIES The libraries needed to use the bz2 library
6+
#
7+
# To specify an additional directory to search, set Bz2_ROOT.
8+
#
9+
# Author: Siddhartha Chaudhuri, 2009
10+
#
11+
12+
# Look for the header, first in the user-specified location and then in the system locations
13+
SET(Bz2_INCLUDE_DOC "The directory containing the header file bz2.h")
14+
FIND_PATH(Bz2_INCLUDE_DIRS NAMES bz2.h bz2/bz2.h PATHS ${Bz2_ROOT} ${Bz2_ROOT}/include DOC ${Bz2_INCLUDE_DOC} NO_DEFAULT_PATH)
15+
IF(NOT Bz2_INCLUDE_DIRS) # now look in system locations
16+
FIND_PATH(Bz2_INCLUDE_DIRS NAMES bzlib.h DOC ${Bz2_INCLUDE_DOC})
17+
ENDIF(NOT Bz2_INCLUDE_DIRS)
18+
19+
SET(Bz2_FOUND FALSE)
20+
21+
IF(Bz2_INCLUDE_DIRS)
22+
SET(Bz2_LIBRARY_DIRS ${Bz2_INCLUDE_DIRS})
23+
24+
IF("${Bz2_LIBRARY_DIRS}" MATCHES "/include$")
25+
# Strip off the trailing "/include" in the path.
26+
GET_FILENAME_COMPONENT(Bz2_LIBRARY_DIRS ${Bz2_LIBRARY_DIRS} PATH)
27+
ENDIF("${Bz2_LIBRARY_DIRS}" MATCHES "/include$")
28+
29+
IF(EXISTS "${Bz2_LIBRARY_DIRS}/lib")
30+
SET(Bz2_LIBRARY_DIRS ${Bz2_LIBRARY_DIRS}/lib)
31+
ENDIF(EXISTS "${Bz2_LIBRARY_DIRS}/lib")
32+
33+
# Find Bz2 libraries
34+
FIND_LIBRARY(Bz2_DEBUG_LIBRARY NAMES bz2d bz2_d libbz2d libbz2_d libbz2
35+
PATH_SUFFIXES Debug ${CMAKE_LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_ARCHITECTURE}/Debug
36+
PATHS ${Bz2_LIBRARY_DIRS} NO_DEFAULT_PATH)
37+
FIND_LIBRARY(Bz2_RELEASE_LIBRARY NAMES bz2 libbz2
38+
PATH_SUFFIXES Release ${CMAKE_LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_ARCHITECTURE}/Release
39+
PATHS ${Bz2_LIBRARY_DIRS} NO_DEFAULT_PATH)
40+
41+
SET(Bz2_LIBRARIES )
42+
IF(Bz2_DEBUG_LIBRARY AND Bz2_RELEASE_LIBRARY)
43+
SET(Bz2_LIBRARIES debug ${Bz2_DEBUG_LIBRARY} optimized ${Bz2_RELEASE_LIBRARY})
44+
ELSEIF(Bz2_DEBUG_LIBRARY)
45+
SET(Bz2_LIBRARIES ${Bz2_DEBUG_LIBRARY})
46+
ELSEIF(Bz2_RELEASE_LIBRARY)
47+
SET(Bz2_LIBRARIES ${Bz2_RELEASE_LIBRARY})
48+
ENDIF(Bz2_DEBUG_LIBRARY AND Bz2_RELEASE_LIBRARY)
49+
50+
IF(Bz2_LIBRARIES)
51+
SET(Bz2_FOUND TRUE)
52+
ENDIF(Bz2_LIBRARIES)
53+
ENDIF(Bz2_INCLUDE_DIRS)
54+
55+
IF(Bz2_FOUND)
56+
# IF(NOT Bz2_FIND_QUIETLY)
57+
MESSAGE(STATUS "Found Bz2: headers at ${Bz2_INCLUDE_DIRS}, libraries at ${Bz2_LIBRARY_DIRS}")
58+
MESSAGE(STATUS " library is ${Bz2_LIBRARIES}")
59+
# ENDIF(NOT Bz2_FIND_QUIETLY)
60+
ELSE(Bz2_FOUND)
61+
IF(Bz2_FIND_REQUIRED)
62+
MESSAGE(FATAL_ERROR "Bz2 library not found")
63+
ENDIF(Bz2_FIND_REQUIRED)
64+
ENDIF(Bz2_FOUND)

0 commit comments

Comments
 (0)