NetCDF安装

NetCDF(Network Common Data Form)是数据访问函数库的接口,以数组的形式存储和检索数据,WRF和CESM数据处理较为常见的是NetCDF数据格式。
NetCDF是一种抽象,支持将数据视图作为可通过简单接口访问的自描述、可移植对象的集合,可以直接访问数组值,无需了解数据存储方式的详细信息。

1、NetCDF 文件格式
NetCDF Classic Format (CDF-1)
NetCDF 64-bit Offset Format (CDF-2)
NetCDF 64-bit Data Format (CDF-5)
NetCDF-4 Format

 

OS: CentOS-7


2、安装编译器

# yum install -y gcc gcc-c++ gcc-gfortran zlib-devel

 


3、安装szip

# wget https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz
# tar zxvf szip-2.1.1.tar.gz
# cd szip-2.1.1
# mkdir build && cd build
# ../configure --prefix=/usr/local/szip
# make -j
# make install
# export LD_LIBRARY_PATH=/usr/local/szip/lib:$LD_LIBRARY_PATH

 


4、安装OpenMPI

# yum install -y hwloc-libs libevent-devel
# wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.0.tar.bz2
# tar jxvf openmpi-4.1.0.tar.bz2
# cd openmpi-4.1.0/
# mkdir build && cd build
# ../configure --prefix=/usr/local/openmpi --enable-shared
# make -j
# make install

 


5、安装HDF5

# yum install -y zlib-devel
# wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz # tar zxvf hdf5-1.10.7.tar.gz # cd hdf5-1.10.7 # mkdir build && cd build # CC=mpicc FC=mpifort F77=mpifort \ ../configure --prefix=/usr/local/hdf5 --enable-fortran --enable-parallel --enable-shared \ --enable-hl --with-zlib=/usr/local/zlib --with-szlib=/usr/local/szip # make -j # make install

 


6、安装PNetCDF

# wget https://parallel-netcdf.github.io/Release/pnetcdf-1.12.2.tar.gz
# tar zxvf pnetcdf-1.12.2.tar.gz
# cd pnetcdf-1.12.2
# mkdir build && cd build
# CFLAGS="-fPIC -DPIC" CXXFLAGS="-fPIC -DPIC" FCFLAGS="-fPIC" FFLAGS="-fPIC" \
    CC=mpicc CXX=mpicxx FC=mpifort F77=mpifort \
    ../configure --prefix=/usr/local/pnetcdf --enable-shared --enable-fortran --enable-large-file-test
# make -j
# make install

 


7、安装NetCDF-C

# wget https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.7.4.tar.gz -O netcdf-c-4.7.4.tar.gz
# tar zxvf netcdf-c-4.7.4.tar.gz
# cd netcdf-c-4.7.4
# mkdir build && cd build
# CFLAGS="-I/usr/local/hdf5/include -I/usr/local/pnetcdf/include" \
    CPPFLAGS="-I/usr/local/hdf5/include -I/usr/local/pnetcdf/include" \
    LDFLAGS="-L/usr/local/hdf5/lib -L/usr/local/pnetcdf/lib" \
    CC=mpicc ../configure --prefix=/usr/local/netcdf \
    --enable-shared --enable-static --enable-pnetcdf --enable-netcdf-4 \
    --enable-largefile --enable-large-file-tests
# make -j
# make install

 


8、安装NetCDF-Fortran
与NetCDF-C安装在同一目录

# wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-fortran-4.5.3.tar.gz
# tar zxvf netcdf-fortran-4.5.3.tar.gz
# cd netcdf-fortran-4.5.3
# mkdir build && cd build
# export NETCDF=/usr/local/netcdf
# export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH
# CFLAGS="-I$HDF5/include -I$NETCDF/include" \
    FCFLAGS="-I$HDF5/include -I$NETCDF/include" \
    FFFLAGS="-I$HDF5/include -I$NETCDF/include" \
    CPPFLAGS="-I$HDF5/include -I$NETCDF/include" \
    LDFLAGS="-L$HDF5/lib -L$NETCDF/lib" \
    CC=mpicc FC=mpifort F77=mpifort \
    ../configure --prefix=/usr/local/netcdf \
    --enable-shared --enable-static --enable-large-file-tests --enable-largefile
# make -j
# make install

 


9、环境变量

# cat .bashrc
## ZLIB-1.2.11
export LD_LIBRARY_PATH=/usr/local/zlib/lib:$LD_LIBRARY_PATH

## SZIP-2.1.1
export LD_LIBRARY_PATH=/usr/local/szip/lib:$LD_LIBRARY_PATH

## OpenMPI-4.1
export PATH=/usr/local/openmpi/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH
export CPATH=/usr/local/openmpi/include:$CPATH

## HDF5-1.10.7
export HDF5=/usr/local/hdf5
export PATH=$HDF5/bin:$PATH
export LD_LIBRARY_PATH=$HDF5/lib:$LD_LIBRARY_PATH
export CPATH=$HDF5/include:$CPATH

## PnetCDF-1.12.2
export PNETCDF=/usr/local/pnetcdf
export PATH=$PNETCDF/bin:$PATH
export LD_LIBRARY_PATH=$PNETCDF/lib:$LD_LIBRARY_PATH
export CPATH=$PNETCDF/include:$CPATH

## netCDF-c-4.7.4 and netCDF-fortran-4.5.3
export NETCDF=/usr/local/netcdf
export PATH=$NETCDF/bin:$PATH
export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH
export CPATH=$NETCDF/include:$CPATH

 

上一篇:数据中心建筑设计的好帮手——BIM


下一篇:NetCDF位置显示错误解决方案