前言
之前CDO安装一直踩了很多坑,在linux系统上采用:
sudo apt install
安装之后显示包依赖不全,可知CDO处理netcdf4, hdf等文件还需要自行配置环境(compile),编译(make)和安装(make install),经过了两天的折磨之后,终于成功在ubuntu子系统上安装了CDO,先将方法总结如下:
方法总结
需要的软件包
已给出百度云链接(主要需要的包有:NetCDF, Grib API, zlib, HDF5, CDO, Jasper, libcurl)
步骤
以下步骤务必按照顺序安装
-
在opt根目录创建一个文件夹,请将之前下载的所有包全部复制到该文件夹中,该文件夹也将存放之后下载过程中产生的include和libs文件。为了演示方便,我们使用/opt/cdo-install
-
安装zlib:1)进入zlib的文件夹;2)./configure --prefix=/opt/cdo-install;3) make; 4) make install;
-
安装hdf5:1)进入hdf5文件夹;2)./configure –with-zlib=/opt/cdo-install –prefix=/opt/cdo-install CFLAGS=-fPIC;3)make;4) make install;
-
安装libcurl:1)进入libcurl文件夹;2)./configure --prefix=/opt/cdo-install;3)make;4)make install;
-
安装NetCDF:1)进入NetCDF文件夹;2)CPPFLAGS=-I/opt/cdo-install/include LDFLAGS=-L/opt/cdo-install/lib ./configure –prefix=/opt/cdo-install CFLAGS=-fPIC;3)make;4)make install;
-
安装Jasper:1)进入Jasper文件夹;2)./configure –prefix=/opt/cdo-install CFLAGS=-fPIC;3)make;4)make isntall;
-
安装grib:1)进入grib-API文件夹;2)./configure –prefix=/opt/cdo-install CFLAGS=-fPIC –with-netcdf=/opt/cdo-install –with-jasper=/opt/cdo-install;3)make;4)make install;
-
安装cdo:1)进入cdo文件夹;2)./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;3)make;4)make install;
问题与解决方案
- 碰到 permission denied:
- 方案一:su root,申请root权限,输入密码;
- 方案二:chmod 777 FILE(FILE改成permission denied的文件名),升级aceess该文件名的权限;
- 方案三:如果是./configure配置过程出现permission denied,那么请输入bash ./configure,而不是./configure;
- 遇到报错API_version=v18,重新下载编译该报错的包,注意在编译过程中加上末尾的default-api-version=v18
`LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include ./configure --enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local --with-curl=/usr/local --with-default-api-version=v18`