Skip to content

Commit

Permalink
ECLand: Add manual netcdf build for Intel and NVHPC
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Feb 5, 2025
1 parent 09b22f1 commit ef22289
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 2 deletions.
50 changes: 50 additions & 0 deletions .github/tools/install-netcdf-c.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

version=4.9.2

TEMPORARY_FILES="${TMPDIR:-/tmp}"
export NETCDF_INSTALL_DIR=$(pwd)/netcdf-install
while [ $# != 0 ]; do
case "$1" in
"--prefix")
export NETCDF_INSTALL_DIR="$2"; shift
;;
"--tmpdir")
TEMPORARY_FILES="$2"; shift
;;
"--version")
version="$2"; shift
;;
"--hdf5-root")
export HDF5_ROOT="$2"; shift
;;
*)
echo "Unrecognized argument '$1'"
exit 1
;;
esac
shift
done

NETCDF_MIRROR=https://downloads.unidata.ucar.edu/netcdf-c/
NETCDF_VERSION=${version}

URL=${NETCDF_MIRROR}/${NETCDF_VERSION}/netcdf-c-${NETCDF_VERSION}.tar.gz
FOLDER=netcdf-c-${NETCDF_VERSION}

if [ ! -d "${TEMPORARY_FILES}/${FOLDER}" ]; then
echo "Downloading ${TEMPORARY_FILES}/${FOLDER} from URL [${URL}]"
mkdir -p ${TEMPORARY_FILES}
curl --location \
"${URL}" | tar zx -C "${TEMPORARY_FILES}"
else
echo "Download already present in ${TEMPORARY_FILES}/${FOLDER}"
fi

mkdir -p ${TEMPORARY_FILES}/build-${FOLDER} && cd ${TEMPORARY_FILES}/build-${FOLDER}
rm -rf ./*
cmake -G Ninja ${TEMPORARY_FILES}/${FOLDER} \
-DHDF5_DIR=${HDF5_ROOT}/cmake -DCMAKE_INSTALL_PREFIX="${NETCDF_INSTALL_DIR}" \
-DENABLE_TESTS=OFF
cmake --build . --config Release
cmake --install .
52 changes: 52 additions & 0 deletions .github/tools/install-netcdf-fortran.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

version=4.6.1

TEMPORARY_FILES="${TMPDIR:-/tmp}"
export NETCDF_INSTALL_DIR=$(pwd)/netcdf-install
while [ $# != 0 ]; do
case "$1" in
"--prefix")
export NETCDF_INSTALL_DIR="$2"; shift
;;
"--tmpdir")
TEMPORARY_FILES="$2"; shift
;;
"--version")
version="$2"; shift
;;
"--netcdf-root")
export NETCDF_ROOT="$2"; shift
;;
*)
echo "Unrecognized argument '$1'"
exit 1
;;
esac
shift
done

NETCDF_MIRROR=https://downloads.unidata.ucar.edu/netcdf-fortran/
NETCDF_VERSION=${version}

URL=${NETCDF_MIRROR}/${NETCDF_VERSION}/netcdf-fortran-${NETCDF_VERSION}.tar.gz
FOLDER=/netcdf-fortran-${NETCDF_VERSION}

if [ ! -d "${TEMPORARY_FILES}/${FOLDER}" ]; then
echo "Downloading ${TEMPORARY_FILES}/${FOLDER} from URL [${URL}]"
mkdir -p ${TEMPORARY_FILES}
curl --location \
"${URL}" | tar zx -C "${TEMPORARY_FILES}"
else
echo "Download already present in ${TEMPORARY_FILES}/${FOLDER}"
fi


mkdir -p ${TEMPORARY_FILES}/build-${FOLDER} && cd ${TEMPORARY_FILES}/build-${FOLDER}
rm -rf ./*
NETCDF_LIB_DIR="$(${NETCDF_ROOT}/bin/nc-config --libdir)"
cmake -G Ninja ${TEMPORARY_FILES}/${FOLDER} \
-DnetCDF_LIBRARIES="${NETCDF_LIB_DIR}/libnetcdf.so" -DnetCDF_INCLUDE_DIR="${NETCDF_ROOT}/include" \
-DENABLE_TESTS=OFF -DCMAKE_INSTALL_PREFIX="${NETCDF_INSTALL_DIR}"
cmake --build . --config Release
cmake --install .
19 changes: 17 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,10 @@ jobs:
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
brew install ninja
brew install libomp
brew install netcdf-fortran
brew install coreutils
else
sudo apt-get update
sudo apt-get install ninja-build
sudo apt-get install libnetcdff-dev
fi
pip3 install numpy
Expand Down Expand Up @@ -183,6 +181,23 @@ jobs:
[ -f ${DEPS_DIR}/openmpi/env.sh ] && source ${DEPS_DIR}/openmpi/env.sh
[ -z ${MPI_HOME+x} ] || echo "MPI_HOME=${MPI_HOME}" >> $GITHUB_ENV
- name: Install NetCDF C
run: |
if [[ -f ${{ env.DEPS_DIR }}/netcdf/bin/nc-config ]]; then
echo "::debug::NetCDF C restored from cache"
else
${ECLAND_TOOLS}/install-netcdf-c.sh --prefix ${{ env.DEPS_DIR }}/netcdf --hdf5-root ${HDF5_ROOT}
fi
echo "NETCDF_ROOT=${{ env.DEPS_DIR }}/netcdf" >> $GITHUB_ENV
- name: Install NetCDF Fortran
run: |
if [[ -f ${NETCDF_ROOT}/bin/nf-config ]]; then
echo "::debug::NetCDF Fortran restored from cache"
else
${ECLAND_TOOLS}/install-netcdf-fortran.sh --prefix ${{ env.DEPS_DIR }}/netcdf --netcdf-root ${NETCDF_ROOT}
fi
- name: Set Build & Test Environment
run: |
Expand Down

0 comments on commit ef22289

Please sign in to comment.