安装netcdf

操作步骤

  1. 执行以下命令下载netcdf安装包。

    cd /path/to/netcdf
    wget https://codeload.github.com/Unidata/netcdf-fortran/tar.gz/refs/tags/v4.5.3 -O netcdf-fortran-4.5.3.tar.gz
    wget https://codeload.github.com/Unidata/netcdf-c/tar.gz/refs/tags/v4.7.4 -O netcdf-c-4.7.4.tar.gz
    wget https://downloads.unidata.ucar.edu/netcdf-cxx/4.2/netcdf-cxx-4.2.tar.gz

  2. 执行以下命令解压安装包。

    tar xf netcdf-fortran-4.5.3.tar.gz
    tar xf netcdf-c-4.7.4.tar.gz
    tar xf netcdf-cxx-4.2.tar.gz

  3. 执行以下命令进入netcdf-c-4.7.4目录。

    cd netcdf-c-4.7.4

  4. 执行以下命令生成makefile。

    CC=mpicc CXX=mpicxx FC=mpifort ./configure --prefix=/path/to/netcdf --build=aarch64-unknown-linux-gnu --enable-shared --enable-netcdf-4 --disable-dap --with-pic --disable-doxygen --enable-static --enable-pnetcdf --enable-largefile CPPFLAGS="-O3 -I${HDF5_PATH}/include -I${PNETCDF_PATH}/include" LDFLAGS="-L${HDF5_PATH}/lib -L${PNETCDF_PATH}/lib -Wl,-rpath=${HDF5_PATH}/lib -Wl,-rpath=${PNETCDF_PATH}/lib" CFLAGS="-O3 -L${HDF5_PATH}/lib -L${PNETCDF_PATH}/lib -I${HDF5_PATH}/include -I${PNETCDF_PATH}/include"

  5. 执行以下命令编译安装。

    make -j
    make install

  6. 执行以下命令设置环境变量。

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

  7. 执行以下命令进入netcdf-fortran-4.5.3目录。

    cd /path/to/netcdf/netcdf-fortran-4.5.3

  8. 执行以下命令生成makefile。

    CC=mpicc CXX=mpicxx FC=mpifort ./configure --prefix=${NETCDF_PATH} --build=aarch64-unknown-linux-gnu --enable-shared --with-pic --disable-doxygen --enable-largefile --enable-static CPPFLAGS="-O3 -I${HDF5_PATH}/include -I${NETCDF_PATH}/include" LDFLAGS="-L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -Wl,-rpath=${HDF5_PATH}/lib -Wl,-rpath=${NETCDF_PATH}/lib" CFLAGS="-O3 -L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -I${HDF5_PATH}/include -I${NETCDF_PATH}/include" CXXFLAGS="-O3 -L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -I${HDF5_PATH}/include -I${NETCDF_PATH}/include" FCFLAGS="-O3 -L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -I${HDF5_PATH}/include -I${NETCDF_PATH}/include"

  9. 执行以下命令修改相关文件。

    sed -i '11686c wl="-Wl,"' libtool
    sed -i '11838c wl="-Wl,"' libtool

  10. 执行以下命令编译安装。

    make -j
    make install

  11. 执行以下命令进入netcdf-cxx-4.2目录。

    cd /path/to/netcdf/netcdf-cxx-4.2

  12. 执行以下命令生成makefile。

    CC=mpicc CXX=mpicxx FC=mpifort ./configure --prefix=${NETCDF_PATH} --build=aarch64-unknown-linux-gnu --enable-shared --with-pic --enable-largefile --enable-static CPPFLAGS="-O3 -I${HDF5_PATH}/include -I${NETCDF_PATH}/include" LDFLAGS="-L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -Wl,-rpath=${HDF5_PATH}/lib -Wl,-rpath=${NETCDF_PATH}/lib" CFLAGS="-O3 -L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -I${HDF5_PATH}/include -I${NETCDF_PATH}/include" CXXFLAGS="-O3 -L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -I${HDF5_PATH}/include -I${NETCDF_PATH}/include" FCFLAGS="-O3 -L${HDF5_PATH}/lib -L${NETCDF_PATH}/lib -I${HDF5_PATH}/include -I${NETCDF_PATH}/include"

  13. 执行以下命令编译安装。

    make -j
    make install