Skip to content

Commit

Permalink
This PR adds EXPERIMENTAL support for accessing data in the
Browse files Browse the repository at this point in the history
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".

The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.

More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).

WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:

Platform | Build System | S3 support
------------------------------------
Linux+gcc      | Automake     | yes
Linux+gcc      | CMake        | yes
Visual Studio  | CMake        | no

Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future.  Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.

In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*.  The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
   and the version bumped.
4. An overly complex set of structs was created to support funnelling
   all of the filterx operations thru a single dispatch
   "filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
   to nczarr.

Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
   -- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
   support zarr and to regularize the structure of the fragments
   section of a URL.

Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
   e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
   * Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
   and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.

Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
  • Loading branch information
DennisHeimbigner committed Jun 29, 2020
1 parent ba24e3c commit 59e04ae
Show file tree
Hide file tree
Showing 275 changed files with 31,239 additions and 4,599 deletions.
80 changes: 74 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
cmake_minimum_required(VERSION 3.6.1)

#Project Name
project(netCDF C)
project(netCDF LANGUAGES C CXX)
set(PACKAGE "netCDF" CACHE STRING "")

#####
Expand Down Expand Up @@ -232,7 +232,7 @@ IF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
MESSAGE(STATUS "Coverage Tests: On.")
ENDIF()

# Warnings for 64-to-32 bit conversions.
# Warnings for 64-to-32 bit conversions.
IF(ENABLE_CONVERSION_WARNINGS)
CHECK_C_COMPILER_FLAG(-Wconversion CC_HAS_WCONVERSION)
CHECK_C_COMPILER_FLAG(-Wshorten-64-to-32 CC_HAS_SHORTEN_64_32)
Expand Down Expand Up @@ -270,8 +270,6 @@ SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/libsrc)
# End Compiler Configuration
################################



##
# Configuration for post-install RPath
# Adapted from http://www.cmake.org/Wiki/CMake_RPATH_handling
Expand Down Expand Up @@ -906,6 +904,8 @@ IF(MSVC)
DESTINATION ${netCDF_BINARY_DIR}/ncgen/)
FILE(COPY ${netCDF_SOURCE_DIR}/libsrc/XGetopt.c
DESTINATION ${netCDF_BINARY_DIR}/ncdump/)
FILE(COPY ${netCDF_SOURCE_DIR}/libsrc/XGetopt.c
DESTINATION ${netCDF_BINARY_DIR}/nczarr_test/)
ENDIF()
ENDIF()

Expand All @@ -925,13 +925,49 @@ IF(NOT WIN32)
ENDIF()
ENDIF()

# Option to Build NCZarr clients
OPTION(ENABLE_NCZARR "Enable NCZarr Client." OFF)
OPTION(ENABLE_S3_SDK "Enable NCZarr S3 support." ON)

# See if aws-s3-sdk is available
FIND_LIBRARY(AWS_CPP_SDK_CORE_LIB NAMES aws-cpp-sdk-core)
FIND_LIBRARY(AWS_CPP_SDK_S3_LIB NAMES aws-cpp-sdk-s3)
FIND_LIBRARY(AWS_C_COMMON_LIB NAMES aws-c-common)

IF(NOT AWS_CPP_SDK_CORE_LIB)
SET(AWS_CPP_SDK_CORE_LIB OFF)
ENDIF()
IF(NOT AWS_CPP_SDK_S3_LIB)
SET(AWS_CPP_SDK_S3_LIB OFF)
ENDIF()
IF(NOT AWS_C_COMMON_LIB)
SET(AWS_C_COMMON_LIB OFF)
ENDIF()

IF(ENABLE_S3_SDK)
IF(NOT AWS_CPP_SDK_CORE_LIB
OR NOT AWS_CPP_SDK_S3_LIB
OR NOT AWS_C_COMMON_LIB)
MESSAGE(WARNING "One of aws-c-common, aws-cpp-sdk-s3, aws-cpp-sdk-core libraries is not available: Turning off S3 support")
SET(ENABLE_S3_SDK OFF)
ELSE()
MESSAGE(STATUS "Found aws sdk libraries")
ENDIF()
ENDIF()

IF(ENABLE_S3_SDK)
IF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
# SET(LDFLAGS "${LDFLAGS} ${AWS_CPP_SDK_CORE_LIB} ${AWS_CPP_SDK_S3_LIB} ${AWS_C_COMMON_LIB}")
# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
ENDIF(ENABLE_S3_SDK)

##
# Enable Tests
##
OPTION(ENABLE_TESTS "Enable basic tests, run with 'make test'." ON)
IF(ENABLE_TESTS)
SET(BUILD_TESTSETS ON CACHE BOOL "")

# Options for CTest-based tests, dashboards.
SET(NC_CTEST_PROJECT_NAME "netcdf-c" CACHE STRING "Project Name for CTest-based testing purposes.")
SET(NC_CTEST_DROP_SITE "cdash.unidata.ucar.edu:443" CACHE STRING "Dashboard location for CTest-based testing purposes.")
Expand Down Expand Up @@ -967,6 +1003,10 @@ IF(ENABLE_TESTS)

OPTION(ENABLE_FAILING_TESTS "Run tests which are known to fail, check to see if any have been fixed." OFF)

# There is a special class of tests that currently fail because of memory leaks.
# As with failing tests, they can be enabled to work on them
OPTION(ENABLE_UNFIXED_MEMORY_LEAKS "Run tests with unfixed memory leaks" OFF)

###
# Option to turn on unit testing. See
# https://github.com/Unidata/netcdf-c/pull/1472 for more
Expand Down Expand Up @@ -1325,6 +1365,8 @@ CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H)
CHECK_INCLUDE_FILE("ftw.h" HAVE_FTW_H)
CHECK_INCLUDE_FILE("libgen.h" HAVE_LIBGEN_H)
CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE("dirent.h" HAVE_DIRENT_H)

# Symbol Exists
CHECK_SYMBOL_EXISTS(isfinite "math.h" HAVE_DECL_ISFINITE)
Expand Down Expand Up @@ -1622,6 +1664,23 @@ MACRO(add_bin_test prefix F)
ENDIF()
ENDMACRO()

# Binary tests which are used by a script looking for a specific name.
MACRO(build_bin_test_sourced F)
ADD_EXECUTABLE(${F} ${F}.c ${ARGN})
TARGET_LINK_LIBRARIES(${F} netcdf ${ALL_TLL_LIBS})
IF(MSVC)
SET_TARGET_PROPERTIES(${F}
PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
)
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
ENDIF()
ENDMACRO()

# A cmake script to print out information at the end of the configuration step.
MACRO(print_conf_summary)
MESSAGE("")
Expand Down Expand Up @@ -1785,6 +1844,10 @@ IF(ENABLE_DAP4)
ADD_SUBDIRECTORY(libdap4)
ENDIF()

IF(ENABLE_NCZARR)
ADD_SUBDIRECTORY(libnczarr)
ENDIF()

add_subdirectory(liblib)

IF(ENABLE_FILTER_TESTING)
Expand Down Expand Up @@ -1826,6 +1889,9 @@ IF(ENABLE_TESTS)
IF(ENABLE_DAP4)
ADD_SUBDIRECTORY(dap4_test)
ENDIF()
IF(ENABLE_NCZARR)
ADD_SUBDIRECTORY(nczarr_test)
ENDIF()
IF(ENABLE_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF()
Expand Down Expand Up @@ -2002,6 +2068,8 @@ is_enabled(USE_CDF5 HAS_CDF5)
is_enabled(ENABLE_ERANGE_FILL HAS_ERANGE_FILL)
is_enabled(HAVE_H5Z_SZIP HAS_SZLIB)
is_enabled(HDF5_HAS_PAR_FILTERS HAS_PAR_FILTERS)
is_enabled(ENABLE_NCZARR HAS_NCZARR)
is_enabled(ENABLE_S3_SDK HAS_S3_SDK)

# Generate file from template.
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"
Expand All @@ -2013,7 +2081,7 @@ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"
# might also work on Windows.
FILE(READ "${CMAKE_CURRENT_BINARY_DIR}/libnetcdf.settings"
LIBNETCDF_SETTINGS)
MESSAGE(${LIBNETCDF_SETTINGS})
MESSAGE(STATUS ${LIBNETCDF_SETTINGS})

# Install libnetcdf.settings file into same location
# as the libraries.
Expand Down
11 changes: 9 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ HDF4_TEST_DIR = hdf4_test
LIBHDF4 = libhdf4
endif

# Build Cloud Storage if desired.
if ENABLE_NCZARR
ZARR_TEST_DIR = nczarr_test
ZARR = libnczarr
endif

# Optionally build plugins
if ENABLE_FILTER_TESTING
PLUGIN_DIR = plugins
Expand All @@ -94,14 +100,15 @@ endif # BUILD_BENCHMARKS
# Define Test directories
if BUILD_TESTSETS
TESTDIRS = $(UNIT_TEST) $(V2_TEST) nc_test $(NC_TEST4) \
$(BENCHMARKS_DIR) $(HDF4_TEST_DIR) $(NCDAP2TESTDIR) $(NCDAP4TESTDIR)
$(BENCHMARKS_DIR) $(HDF4_TEST_DIR) $(NCDAP2TESTDIR) $(NCDAP4TESTDIR) \
${ZARR_TEST_DIR}
endif

# This is the list of subdirs for which Makefiles will be constructed
# and run. ncgen must come before ncdump, because their tests
# depend on it.
SUBDIRS = include $(H5_TEST_DIR) libdispatch libsrc $(LIBSRC4_DIR) \
$(LIBSRCP) $(LIBHDF4) $(LIBHDF5) $(OCLIB) $(DAP2) ${DAP4} liblib \
$(LIBSRCP) $(LIBHDF4) $(LIBHDF5) $(OCLIB) $(DAP2) ${DAP4} ${ZARR} liblib \
$(NCGEN3) $(NCGEN) $(NCDUMP) ${PLUGIN_DIR} $(TESTDIRS) docs \
$(EXAMPLES)

Expand Down
3 changes: 2 additions & 1 deletion NUG/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,8 @@ WARN_LOGFILE =
INPUT = guide.dox \
bestpractices.md \
install.md \
DAP2.dox \
nczarr.md \
DAP2.dox \
DAP4.dox \
OPeNDAP.dox \
types.dox \
Expand Down
Loading

0 comments on commit 59e04ae

Please sign in to comment.