Skip to content

Instantly share code, notes, and snippets.

@mainvoid007
Last active November 4, 2021 15:37
Show Gist options
  • Save mainvoid007/e5f1c82f50eb0459a55dfc4a0953a08e to your computer and use it in GitHub Desktop.
Save mainvoid007/e5f1c82f50eb0459a55dfc4a0953a08e to your computer and use it in GitHub Desktop.
install cdo with grib2, hdf5, netcdf4
#!/bin/bash
# Institut für Wetter- und Klimakommunikation GmbH / Qmet
# O. Maywald <[email protected]>
# This should install CDO with grib2, netcdf and HDF5 support. Note that the binaries are in /opt/cdo-install/bin.
# For further information look:
# http://www.studytrails.com/blog/install-climate-data-operator-cdo-with-netcdf-grib2-and-hdf5-support/
# docker-command
# use this command to start a docker container
# docker run -it --name cdo --rm -v $(pwd):/opt/cdo-install -w /opt/cdo-install ubuntu:latest bash
home=/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 $home
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-1.2.8.tar.gz
tar -xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure -prefix=/opt/cdo-install
make && make check && make install
# download, compile and install --> hdf5
cd $home
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-1.8.13.tar.gz
tar -xzvf hdf5-1.8.13.tar.gz
cd hdf5-1.8.13
./configure -with-zlib=/opt/cdo-install -prefix=/opt/cdo-install CFLAGS=-fPIC
make && make check && make install
# download, compile and install --> netCDF
cd $home
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.5.0.tar.gz
tar -xzvf netcdf-4.5.0.tar.gz
cd netcdf-4.5.0/
CPPFLAGS=-I/opt/cdo-install/include LDFLAGS=-L/opt/cdo-install/lib ./configure -prefix=/opt/cdo-install CFLAGS=-fPIC
make && make check && make install
# download, compile and install --> jasper
cd $home
wget http://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.1.zip
unzip jasper-1.900.1.zip
cd jasper-1.900.1
./configure -prefix=/opt/cdo-install CFLAGS=-fPIC
make && make check && make install
# download, compile and install --> grib_api
cd $home
wget https://software.ecmwf.int/wiki/download/attachments/3473437/grib_api-1.24.0-Source.tar.gz?api=v2 -O grib_api-1.24.0.tar.gz
tar -xzvf grib_api-1.24.0.tar.gz
cd grib_api-1.24.0-Source
./configure -prefix=/opt/cdo-install CFLAGS=-fPIC -with-netcdf=/opt/cdo-install -with-jasper=/opt/cdo-install
make && make check && make install
# download, compile and install --> cdo
cd $home
wget https://code.mpimet.mpg.de/attachments/download/15653/cdo-1.9.1.tar.gz
tar -xvzf cdo-1.9.1.tar.gz
cd cdo-1.9.1
./configure -prefix=/opt/cdo-install CFLAGS=-fPIC -with-netcdf=/opt/cdo-install -with-jasper=/opt/cdo-install -with-hdf5=/opt/cdo-install -with-grib_api=/opt/cdo-install/grib_api-1.24.0-Source
make && make check && make install
# set PATH
#echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/cdo-install/bin\"" > /etc/environment
@steeve88
Copy link

Hello, that's great work and thank you. However I get the following errors when running the last part of the code which is about cdo

make[3]: Leaving directory '/opt/cdo-install/cdo-1.9.1/test'
make[2]: Leaving directory '/opt/cdo-install/cdo-1.9.1/test'
make[1]: Leaving directory '/opt/cdo-install/cdo-1.9.1/test'
make[1]: Entering directory '/opt/cdo-install/cdo-1.9.1'
make[1]: Nothing to be done for 'check-am'.
make[1]: Leaving directory '/opt/cdo-install/cdo-1.9.1'
Making install in libcdi
make[1]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi'
Making install in src
make[2]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
make[3]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
make install-exec-hook
make[4]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
rmdir: failed to remove '/opt/cdo-install/lib': Directory not empty
Makefile:1080: recipe for target 'install-exec-hook' failed
make[4]: [install-exec-hook] Error 1 (ignored)
make[4]: Leaving directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
make install-data-hook
make[4]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
rmdir: failed to remove '/opt/cdo-install/include': Directory not empty
Makefile:1082: recipe for target 'install-data-hook' failed
make[4]: [install-data-hook] Error 1 (ignored)

Could you please give me a hand with that?

@marvingabler
Copy link

Hello, that's great work and thank you. However I get the following errors when running the last part of the code which is about cdo

make[3]: Leaving directory '/opt/cdo-install/cdo-1.9.1/test'
make[2]: Leaving directory '/opt/cdo-install/cdo-1.9.1/test'
make[1]: Leaving directory '/opt/cdo-install/cdo-1.9.1/test'
make[1]: Entering directory '/opt/cdo-install/cdo-1.9.1'
make[1]: Nothing to be done for 'check-am'.
make[1]: Leaving directory '/opt/cdo-install/cdo-1.9.1'
Making install in libcdi
make[1]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi'
Making install in src
make[2]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
make[3]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
make install-exec-hook
make[4]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
rmdir: failed to remove '/opt/cdo-install/lib': Directory not empty
Makefile:1080: recipe for target 'install-exec-hook' failed
make[4]: [install-exec-hook] Error 1 (ignored)
make[4]: Leaving directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
make install-data-hook
make[4]: Entering directory '/opt/cdo-install/cdo-1.9.1/libcdi/src'
rmdir: failed to remove '/opt/cdo-install/include': Directory not empty
Makefile:1082: recipe for target 'install-data-hook' failed
make[4]: [install-data-hook] Error 1 (ignored)

Could you please give me a hand with that?

Do you use gribapi or eccodes?

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