Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ script.
- [ParallelIO](https://github.com/NCAR/ParallelIO)
- [nccmp](https://gitlab.com/remikz/nccmp)
- [nco](http://nco.sourceforge.net/)
- [CDO](https://code.mpimet.mpg.de/projects/cdo)
- [FFTW](http://www.fftw.org/)
- [GPTL](https://jmrosinski.github.io/GPTL/)
- [Tau2]()
Expand Down
1 change: 1 addition & 0 deletions build_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ build_lib pnetcdf
build_lib netcdf
build_lib nccmp
build_lib nco
build_lib cdo
build_lib pio

# UFS 3rd party dependencies
Expand Down
4 changes: 4 additions & 0 deletions config/stack_custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ nco:
build: NO
version: 4.9.3

cdo:
build: YES
version: 1.9.8

pio:
build: YES
version: 2.5.1
Expand Down
4 changes: 4 additions & 0 deletions config/stack_gaea.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ nco:
build: NO
version: 4.9.3

cdo:
build: YES
version: 1.9.8

pio:
build: YES
version: 2.5.1
Expand Down
4 changes: 4 additions & 0 deletions config/stack_mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ nco:
build: NO
version: 4.9.3

cdo:
build: YES
version: 1.9.8

pio:
build: YES
version: 2.5.1
Expand Down
4 changes: 4 additions & 0 deletions config/stack_ncar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ nco:
build: NO
version: 4.9.3

cdo:
build: YES
version: 1.9.8

pio:
build: YES
version: 2.5.1
Expand Down
4 changes: 4 additions & 0 deletions config/stack_noaa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ nco:
build: NO
version: 4.9.3

cdo:
build: YES
version: 1.9.8

pio:
build: YES
version: 2.5.1
Expand Down
4 changes: 4 additions & 0 deletions config/stack_ufs_weather_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ nco:
build: NO
version: 4.9.3

cdo:
build: NO
version: 1.9.8

pio:
build: YES
version: 2.5.1
Expand Down
105 changes: 105 additions & 0 deletions libs/build_cdo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

set -eux

name="cdo"
version=${1:-${STACK_cdo_version}}

# Hyphenated version used for install prefix
compiler=$(echo $HPC_COMPILER | sed 's/\//-/g')
mpi=$(echo $HPC_MPI | sed 's/\//-/g')

if $MODULES; then
set +x
source $MODULESHOME/init/bash
module load hpc-$HPC_COMPILER
[[ -z $mpi ]] || module load hpc-$HPC_MPI
module try-load zlib
module try-load szip
module load hdf5
module load netcdf
module try-load udunits
module list
set -x
enable_pnetcdf=$(nc-config --has-pnetcdf)
set +x
[[ $enable_pnetcdf =~ [yYtT] ]] && module load pnetcdf
set -x

prefix="${PREFIX:-"/opt/modules"}/$compiler/$mpi/$name/$version"

if [[ -d $prefix ]]; then
[[ $OVERWRITE =~ [yYtT] ]] && ( echo "WARNING: $prefix EXISTS: OVERWRITING!"; $SUDO rm -rf $prefix ) \
|| ( echo "WARNING: $prefix EXISTS, SKIPPING"; exit 1 )
fi
else
prefix=${CDO_ROOT:-"/usr/local"}
enable_pnetcdf=$(nc-config --has-pnetcdf)
fi

if [[ ! -z $mpi ]]; then
export FC=$MPI_FC
export CC=$MPI_CC
export CXX=$MPI_CXX
else
export FC=$SERIAL_FC
export CC=$SERIAL_CC
export CXX=$SERIAL_CXX
fi

export FFLAGS="${STACK_FFLAGS:-} ${STACK_cdo_FFLAGS:-} -fPIC"
export CFLAGS="${STACK_CFLAGS:-} ${STACK_cdo_CFLAGS:-} -fPIC"
export CXXFLAGS="${STACK_CXXFLAGS:-} ${STACK_cdo_CXXFLAGS:-} -fPIC"

export F77=$FC
export FCFLAGS=$FFLAGS

LDFLAGS1="-L$HDF5_ROOT/lib -lhdf5_hl -lhdf5"
LDFLAGS2=$(cat $HDF5_ROOT/lib/libhdf5.settings | grep AM_LDFLAGS | cut -d: -f2)
LDFLAGS3=$(cat $HDF5_ROOT/lib/libhdf5.settings | grep "Extra libraries" | cut -d: -f2)
if [[ ! -z $mpi ]]; then
[[ $enable_pnetcdf =~ [yYtT] ]] && LDFLAGS4="-L$PNETCDF_ROOT/lib -lpnetcdf"
fi
LDFLAGS5="-L$NETCDF_ROOT/lib -lnetcdf"
export LDFLAGS="${LDFLAGS1:-} ${LDFLAGS2:-} ${LDFLAGS3:-} ${LDFLAGS4:-} ${LDFLAGS5:-}"

cd ${HPC_STACK_ROOT}/${PKGDIR:-"pkg"}

case $version in
1.9.9 )
url="https://code.mpimet.mpg.de/attachments/download/23323/cdo-1.9.9.tar.gz"
;;
1.9.8 )
url="https://code.mpimet.mpg.de/attachments/download/20826/cdo-1.9.8.tar.gz"
;;
1.9.7.1 )
url="https://code.mpimet.mpg.de/attachments/download/20124/cdo-1.9.7.1.tar.gz"
;;
1.9.6 )
url="https://code.mpimet.mpg.de/attachments/download/19299/cdo-1.9.6.tar.gz"
;;
* )
echo "Try using CDO version 1.9.6 and above, ABORT!"
exit 1
;;
esac

software=$name-$version
[[ -d $software ]] || ( $WGET $url; tar -xzf $software.tar.gz && rm -f $software.tar.gz )
[[ ${DOWNLOAD_ONLY} =~ [yYtT] ]] && exit 0
[[ -d $software ]] && cd $software || ( echo "$software does not exist, ABORT!"; exit 1 )
[[ -d build ]] && rm -rf build
mkdir -p build && cd build

../configure --prefix=$prefix \
--with-hdf5=$HDF5_ROOT \
--with-netcdf=$NETCDF_ROOT

VERBOSE=$MAKE_VERBOSE make -j${NTHREADS:-4}
[[ $MAKE_CHECK =~ [yYtT] ]] && make check
$SUDO make install

# generate modulefile from template
[[ -z $mpi ]] && modpath=compiler || modpath=mpi
$MODULES && update_modules $modpath $name $version \
|| echo $name $version >> ${HPC_STACK_ROOT}/hpc-stack-contents.log
28 changes: 28 additions & 0 deletions modulefiles/compiler/compilerName/compilerVersion/cdo/cdo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
help([[
]])

local pkgName = myModuleName()
local pkgVersion = myModuleVersion()
local pkgNameVer = myModuleFullName()

local hierA = hierarchyA(pkgNameVer,1)
local compNameVer = hierA[1]
local compNameVerD = compNameVer:gsub("/","-")

conflict(pkgName)

always_load("netcdf")
prereq("netcdf")

local opt = os.getenv("HPC_OPT") or os.getenv("OPT") or "/opt/modules"

local base = pathJoin(opt,compNameVerD,pkgName,pkgVersion)

prepend_path("PATH", pathJoin(base,"bin"))
setenv("CDO_ROOT", base)
setenv("CDO_VERSION", pkgVersion)

whatis("Name: ".. pkgName)
whatis("Version: " .. pkgVersion)
whatis("Category: Utility")
whatis("Description: Climate Data Operators (CDO) Utility")
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
help([[
]])

local pkgName = myModuleName()
local pkgVersion = myModuleVersion()
local pkgNameVer = myModuleFullName()

local hierA = hierarchyA(pkgNameVer,2)
local mpiNameVer = hierA[1]
local compNameVer = hierA[2]
local mpiNameVerD = mpiNameVer:gsub("/","-")
local compNameVerD = compNameVer:gsub("/","-")

conflict(pkgName)

local opt = os.getenv("HPC_OPT") or os.getenv("OPT") or "/opt/modules"

local base = pathJoin(opt,compNameVerD,mpiNameVerD,pkgName,pkgVersion)

prepend_path("PATH", pathJoin(base,"bin"))

setenv("CDO_ROOT", base)
setenv("CDO_VERSION", pkgVersion)

whatis("Name: ".. pkgName)
whatis("Version: " .. pkgVersion)
whatis("Category: Utilities")
whatis("Description: Climate Data Operators (CDO) Utility")