From 514873948362f5828ba79a5bbd8bc30bf5dda9db Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Mon, 4 Mar 2024 18:54:00 +1100 Subject: [PATCH 1/2] Backport fix for Unidata/netcdf-c#2674 --- Dockerfile | 2 + patches/netcdf-c/0001-Fix-issue-2674.patch | 53 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 patches/netcdf-c/0001-Fix-issue-2674.patch diff --git a/Dockerfile b/Dockerfile index 44e7e83..cb3f6cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -237,12 +237,14 @@ LABEL com.amazonaws.sdk.version=${AWS_SDK_CPP_REFSPEC} ARG NETCDF_VERSION ENV NETCDF_VERSION="${NETCDF_VERSION:-4.9.2}" ENV NETCDF_SRC_DIR="/usr/local/src/netcdf-c-${NETCDF_VERSION}" +COPY ./patches/netcdf-c /tmp/netcdf-c/patches RUN --mount=target="${NETCDF_SRC_DIR}",type=cache,sharing=locked \ if [ ! -f "${NETCDF_SRC_DIR}/configure" ]; then \ wget -O - https://github.com/Unidata/netcdf-c/archive/refs/tags/v${NETCDF_VERSION}.tar.gz | tar -xz -C /usr/local/src/; \ fi RUN --mount=target="${NETCDF_SRC_DIR}",type=cache,sharing=locked \ cd "${NETCDF_SRC_DIR}" \ + && patch -p1 < /tmp/netcdf-c/patches/0001-Fix-issue-2674.patch \ && CPATH="${MPI_INCLUDE_PATH}" CC=mpicc LDFLAGS="-L/usr/local/lib -laws-cpp-sdk-s3" ./configure \ --prefix=/usr/local \ --enable-hdf5 \ diff --git a/patches/netcdf-c/0001-Fix-issue-2674.patch b/patches/netcdf-c/0001-Fix-issue-2674.patch new file mode 100644 index 0000000..1ac328d --- /dev/null +++ b/patches/netcdf-c/0001-Fix-issue-2674.patch @@ -0,0 +1,53 @@ +Subject: [PATCH] Fix issue #2674 + +--- + libhdf5/hdf5open.c | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/libhdf5/hdf5open.c b/libhdf5/hdf5open.c +index cb2491ff..e00f426e 100644 +--- a/libhdf5/hdf5open.c ++++ b/libhdf5/hdf5open.c +@@ -1205,12 +1205,14 @@ static int get_quantize_info(NC_VAR_INFO_T *var) + { + hid_t attid; + hid_t datasetid; ++ htri_t attr_exists; + + /* Try to open an attribute of the correct name for quantize + * info. */ + datasetid = ((NC_HDF5_VAR_INFO_T *)var->format_var_info)->hdf_datasetid; +- attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITGROOM_ATT_NAME, +- H5P_DEFAULT, H5P_DEFAULT); ++ attr_exists = H5Aexists(datasetid, NC_QUANTIZE_BITGROOM_ATT_NAME); ++ attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITGROOM_ATT_NAME, ++ H5P_DEFAULT, H5P_DEFAULT) : 0; + + if (attid > 0) + { +@@ -1218,16 +1220,18 @@ static int get_quantize_info(NC_VAR_INFO_T *var) + } + else + { +- attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_GRANULARBR_ATT_NAME, +- H5P_DEFAULT, H5P_DEFAULT); ++ attr_exists = H5Aexists(datasetid, NC_QUANTIZE_GRANULARBR_ATT_NAME); ++ attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_GRANULARBR_ATT_NAME, ++ H5P_DEFAULT, H5P_DEFAULT) : 0; + if (attid > 0) + { + var->quantize_mode = NC_QUANTIZE_GRANULARBR; + } + else + { +- attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITROUND_ATT_NAME, +- H5P_DEFAULT, H5P_DEFAULT); ++ attr_exists = H5Aexists(datasetid, NC_QUANTIZE_BITROUND_ATT_NAME); ++ attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITROUND_ATT_NAME, ++ H5P_DEFAULT, H5P_DEFAULT) : 0; + if (attid > 0) + var->quantize_mode = NC_QUANTIZE_BITROUND; + } +-- +2.39.1 + From 4e5c233d84ca4c4be5ef6e2d28c7a2c9f53c4b72 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Tue, 5 Mar 2024 13:32:23 +1100 Subject: [PATCH 2/2] Apply netcdf-c patch as part of the download step It fails the second time around otherwise, due to the build cache. --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index cb3f6cb..1375cfe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -237,14 +237,15 @@ LABEL com.amazonaws.sdk.version=${AWS_SDK_CPP_REFSPEC} ARG NETCDF_VERSION ENV NETCDF_VERSION="${NETCDF_VERSION:-4.9.2}" ENV NETCDF_SRC_DIR="/usr/local/src/netcdf-c-${NETCDF_VERSION}" -COPY ./patches/netcdf-c /tmp/netcdf-c/patches RUN --mount=target="${NETCDF_SRC_DIR}",type=cache,sharing=locked \ + --mount=target="${NETCDF_SRC_DIR}/patches",type=bind,source=./patches/netcdf-c \ if [ ! -f "${NETCDF_SRC_DIR}/configure" ]; then \ wget -O - https://github.com/Unidata/netcdf-c/archive/refs/tags/v${NETCDF_VERSION}.tar.gz | tar -xz -C /usr/local/src/; \ + cd "${NETCDF_SRC_DIR}" ; \ + patch -p1 < "./patches/0001-Fix-issue-2674.patch" ; \ fi RUN --mount=target="${NETCDF_SRC_DIR}",type=cache,sharing=locked \ cd "${NETCDF_SRC_DIR}" \ - && patch -p1 < /tmp/netcdf-c/patches/0001-Fix-issue-2674.patch \ && CPATH="${MPI_INCLUDE_PATH}" CC=mpicc LDFLAGS="-L/usr/local/lib -laws-cpp-sdk-s3" ./configure \ --prefix=/usr/local \ --enable-hdf5 \