安装CDO需要依赖的库有zlib, hdf5, netCDF, jasper 以及cdo。没有安装grib_api, 但cdo的命令还是可以用的

设置下载路径,在$HOME中新建文件夹software_package, 进入文件夹以后下载需要用的库准备安装:

如果有anaconda3,将路径里所有的local改成anaconda3

cd software_package
# download zlib
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-1.2.8.tar.gz
# download hdf5
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-1.8.13.tar.gz
# download netCDF
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.5.0.tar.gz
# download jasper
wget http://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.1.zip
# download cdo
wget https://code.mpimet.mpg.de/attachments/download/15653/cdo-1.9.1.tar.gz

在/home下新建local文件夹,路径为$HOME/local

  1. compile and install zlib
tar -xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=$HOME/anaconda3
make
make check
make install
  1. compile and install hdf5
tar -xzvf hdf5-1.8.13.tar.gz
cd hdf5-1.8.13
./configure -with-zlib=$HOME/anaconda3 --prefix=$HOME/anaconda3 CFLAGS=-fPIC
make
make check
make install
  1. compile and install netCDF
tar -xzvf netcdf-4.5.0.tar.gz 
cd netcdf-4.5.0
CPPFLAGS=-I$HOME/anaconda3/include LDFLAGS=-L$HOME/anaconda3/lib ./configure --prefix=$HOME/anaconda3 CFLAGS=-fPIC
make
make check
make install
  1. compile and install jasper
unzip jasper-1.900.1.zip
cd jasper-1.900.1
./configure --prefix=$HOME/anaconda3 CFLAGS=-fPIC
make
make check
make install
  1. compile and install cdo
tar -xvzf cdo-1.9.1.tar.gz
cd cdo-1.9.1
./configure --prefix=$HOME/anaconda3 CFLAGS=-fPIC -with-netcdf=$HOME/anaconda3 -with-jasper=$HOME/anaconda3 -with-hdf5=$HOME/anaconda3
make
make check
make install

如果在使用ncdump的时候遇到Error:ncdump: ncopen failed on <filename>
可能的原因是文件大于2G没有办法打开。
解决方法:重新安装一遍cdo,在编译netCDF的时候将命令改成:
CPPFLAGS=-I$HOME/anaconda3/include LDFLAGS=-L$HOME/anaconda3/lib ./configure --prefix=$HOME/anaconda3 -with-zlib=$HOME/anaconda3 -with-hdf5=$HOME/anaconda3 -enable-large-file-tests CFLAGS=-fPIC
好像是因为只有hdf5支持大于2G的nc文件阅读。

Logo

更多推荐