Skip to content

Instantly share code, notes, and snippets.

@jeffbyrnes
Forked from mainvoid007/installcdo.sh
Last active September 3, 2023 15:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeffbyrnes/e56d294c216fbd30fd2fd32e576db81c to your computer and use it in GitHub Desktop.
Save jeffbyrnes/e56d294c216fbd30fd2fd32e576db81c to your computer and use it in GitHub Desktop.
install cdo with eccodes, hdf5, netcdf4
#!/bin/bash
# This installs CDO with ecCodes, netCDF and HDF5 support. Uses standard locations, with binaries landing in /usr/local/bin
# Forked from https://gist.github.com/mainvoid007/e5f1c82f50eb0459a55dfc4a0953a08e
# Updated to latest versions
# The only “breaking” change for JasPer is the maintainer switched from make to cmake for its build
cdo_path=/opt/cdo-install
apt-get update && apt-get install -y wget build-essential checkinstall unzip m4 curl libcurl4-gnutls-dev
# download, compile and install --> zlib
cd $cdo_path
wget https://zlib.net/zlib-1.2.11.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && sudo make install
# download, compile and install --> hdf5
cd $cdo_path
wget https://www.hdfgroup.org/package/source-gzip-2/?wpdmdl=11810&refresh=5ac7c53570acd1523041589 -O hdf5-1.10.2.tar.gz
tar -xzvf hdf5-1.10.2.tar.gz
cd hdf5-1.10.2
./configure --prefix=/usr/local
make && sudo make install
sudo apt install libcurl4-gnutls-dev -y
# download, compile and install --> netCDF
cd $cdo_path
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.6.1.tar.gz
tar -xzvf netcdf-4.6.1.tar.gz
cd netcdf-4.6.1/
./configure
make && sudo make install
# download, compile and install --> jasper
cd $cdo_path
wget http://www.ece.uvic.ca/~frodo/jasper/software/jasper-2.0.14.tar.gz
tar -xzvf jasper-2.0.14.tar.gz
cd jasper-2.0.14
mkdir release
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../
cd release
make && sudo make install
# download, compile and install --> eccodes
cd $cdo_path
wget https://software.ecmwf.int/wiki/download/attachments/45757960/eccodes-2.7.0-Source.tar.gz?api=v2 -O eccodes-2.7.0-Source.tar.gz
tar -xzvf eccodes-2.7.0-Source.tar.gz
cd eccodes-2.7.0-Source
mkdir build
cd build
cmake ../
make && sudo make install
# download, compile and install --> cdo
cd $cdo_path
wget https://code.mpimet.mpg.de/attachments/download/16435/cdo-1.9.3.tar.gz
tar -xvzf cdo-1.9.3.tar.gz
cd cdo-1.9.3
./configure --with-netcdf=yes --with-hdf5=yes --with-eccodes=yes
make && sudo make install
# Ensure shared libraries are wired up
sudo ldconfig
@Try2Code
Copy link

for linux there are some alternatives:

  • conda: cdo is available in the conda-forge channel in the latest release (pre-built)
  • spack: conda replacement, but everything is built from source

@jeffbyrnes
Copy link
Author

Thanks a lot for this gist. Without it, it would have taken me ages to install CDO correctly.

You’re welcome @pjpetersik!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment