所有库文件均安装在~/util/netcdf4路径下
1. 安装zlib
下载地址:http://www.zlib.net/
解压 tar -zxvf zlib-1.2.12.tar.gz,进入zlib-1.2.12文件夹,配置安装信息:
./configure --prefix=~/util/netcdf4
make
make install
安装完成之后会在~/util/netcdf4这个目录下生成三个文件lib include share
2. 安装HDF5
下载地址:https://portal.hdfgroup.org/display/support/HDF5+1.12.0#files
解压 tar -zxvf hdf5-1.12.0.tar.gz,进入hdf5-1.12.0文件夹,配置安装信息:
./configure --prefix=~/util/netcdf4 --with-zlib=~/util/netcdf4/ --enable-fortran --enable-hl
make
make install
*--enable-hl选项会编译出WRF所需库文件:libhdf5_hl
*--enable-fortran选项会编译出WRF所需的两个库文件:libhdf5_fortran及libhdf5hl_fortran
3. 安装curl
下载地址: https://curl.se/download/
解压 tar -zxvf curl-7.85.0.tar.gz,进入curl-7.85.0,配置安装信息:
CPPFLAGS=-I~/util/netcdf4/include LDFLAGS=-L~/util/netcdf4/lib ./configure --prefix=~/util/netcdf4
如果出现报错就加上 --without-ssl
configure: error: select TLS backend(s) or disable TLS with --without-ssl.
CPPFLAGS=-I~/util/netcdf4/include LDFLAGS=-L~/util/netcdf4/lib ./configure --prefix=~/util/netcdf4 --without-ssl
*CPPFLAGS=-I~/util/netcdf4/include:设置了 C 预处理器的选项-I表示要包含的头文件路径
*LDFLAGS=-L~/util/netcdf4/lib:设置了链接器的选项,-L 指定链接器要搜索库文件的路径
make
make install
4. 安装NetCDF-c
下载地址 https://www.unidata.ucar.edu/software/netcdf/
解压netcdf-c-4.8.1.tar.gz,进入netcdf-c-4.8.1,配置安装信息:
CPPFLAGS=-I~/util/netcdf4/include LDFLAGS=-L~/util/netcdf4/lib ./configure --prefix=~/util/netcdf4 --disable-dap
make
make install
5. 安装NetCDF-fortran
下载地址:https://downloads.unidata.ucar.edu/netcdf/
解压netcdf-fortran-4.6.1.tar.gz,进入netcdf-fortran-4.6.1,配置安装信息:
CPPFLAGS=-I~/util/netcdf4/include LDFLAGS=-L~/util/netcdf4/lib ./configure --prefix=~/util/netcdf4 --disable-dap
这一步可能会出现以下错误:
“configure: error: cannot compute sizeof (off_t) See `config.log' for more details"
则重新配置安装信息:
CPPFLAGS=-I~/util/netcdf4/include LD_LIBRARY_PATH=~/util/netcdf4/lib:${LD_LIBRARY_PATH} LDFLAGS=-L~/util/netcdf4/lib ./configure --prefix=~/util/netcdf4 --disable-dap
通过配置后,
make
make install
6. 完成所有安装步骤后,配置环境变量。
export NETCDF=~/util/netcdf4
export NETCDF_LIB=$NETCDF/lib
export NETCDF_INC=$NETCDF/include
export PATH=$NETCDF/bin:$PATH