安装netCDF-c和netCDF-f

操作步骤

  1. 使用MobaXterm工具,以root用户登录服务器。
  2. 执行以下命令加载环境。

    export CC=mpicc CXX=mpicxx FC=mpifort F77=mpifort

  3. 执行以下命令创建目录。

    mkdir -p /path/to/netcdf

  4. 执行以下命令解压软件包。

    tar -zxvf netcdf-c-4.7.4.tar.gz
    tar -zxvf netcdf-fortran-4.5.2.tar.gz

  5. 执行以下命令安装netcdf-c。

    cd netcdf-c-4.7.4/
    export install_dir=/path/to/netcdf
    export build_type="--build=aarch64-unknown-linux-gnu"
    ./configure --prefix=${install_dir} ${build_type} --enable-shared --enable-netcdf-4 --enable-dap --with-pic --disable-doxygen --enable-static --enable-pnetcdf --enable-largefile CPPFLAGS="-I${HDF5_DIR}/include -I${PNETCDF_DIR}/include" LDFLAGS="-L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib -Wl,-rpath=${HDF5_DIR}/lib -Wl,-rpath=${PNETCDF_DIR}/lib" CFLAGS="-I${HDF5_DIR}/include -I${PNETCDF_DIR}/include -L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib"
    make clean
    make -j
    make install

  6. 执行以下命令安装netcdf-f。

    cd ..
    export PATH=${install_dir}/bin:$PATH
    export INCLUDE=${install_dir}/include:$INCLUDE
    export LD_LIBRARY_PATH=${install_dir}/lib:$LD_LIBRARY_PATH
    cd netcdf-fortran-4.5.2
    ./configure --prefix=${install_dir} ${build_type} --enable-shared --with-pic --disable-doxygen --enable-largefile --enable-static CPPFLAGS="-I${HDF5_DIR}/include -I${PNETCDF_DIR}/include -I${install_dir}/include" LDFLAGS="-L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib -L${install_dir}/lib -Wl,-rpath=${HDF5_DIR}/lib -Wl,-rpath=${PNETCDF_DIR}/lib -Wl,-rpath=${install_dir}/lib" CFLAGS="-fPIC -I${HDF5_DIR}/include -I${PNETCDF_DIR}/include -I${install_dir}/include -L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib -L${install_dir}/lib" CXXFLAGS="-I${HDF5_DIR}/include -I${PNETCDF_DIR}/include -I${install_dir}/include -L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib -L${install_dir}/lib" FCFLAGS="-I${HDF5_DIR}/include -I${PNETCDF_DIR}/include -I${install_dir}/include -L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib -L${install_dir}/lib"
    sed -i '11787c wl="-Wl,"' libtool
    sed -i '11939c wl="-Wl,"' libtool
    make
    make install

  7. 执行以下加载环境变量。

    export NETCDF_DIR=/path/to/netcdf
    export PATH=${NETCDF_DIR}/bin:$PATH
    export LD_LIBRARY_PATH=${NETCDF_DIR}/lib:${NETCDF_DIR}/lib64:$LD_LIBRARY_PATH
    export INCLUDE=${NETCDF_DIR}/include:$INCLUDE