中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

编译和安装

操作步骤

  1. 使用PuTTY工具,以root用户登录服务器。
  2. 执行以下命令创建并进入安装规划路径。
    mkdir /path/to/ncl
    cd /path/to/ncl
  3. 执行以下命令获取NCL源码包。
    wget https://github.com/chen-shaoheng/NCL-SOURCE/releases/download/ncl-6.6.2/ncl-6.6.2.tar.gz
  4. 执行以下命令解压源码包。
    tar -xvf ncl-6.6.2.tar.gz
  5. 执行以下命令进入源码目录。
    cd ncl-6.6.2/
  6. 执行以下命令修改config/LINUX文件。
    sed -i '21c #define CCompiler   gcc' config/LINUX
    sed -i '22c #define FCompiler   gfortran' config/LINUX
    sed -i '23c #define CtoFLibraries   -lgfortran -lmathlib -ltirpc' config/LINUX
    sed -i '24c #define CtoFLibrariesUser   -lgfortran -lmathlib -ltirpc' config/LINUX
    sed -i '25c #define CcOptions      -ansi -fPIC -fopenmp -std=c99 -fsigned-char -Xlinker -zmuldefs -Wl,--copy-dt-needed-entries' config/LINUX
    sed -i '26c #define FcOptions      -fPIC -fno-second-underscore -fno-range-check -fopenmp -fallow-argument-mismatch -Wl,--copy-dt-needed-entries' config/LINUX

    GCC为10及以上的版本时请在第26行添加-fallow-argument-mismatch参数。

  7. 执行以下命令修改ncarview/src/lib/libncarg_ras/misc.c文件。
    • 在第41和第42行添加如下函数声明语句,即添加位置在第一个函数定义的int关键字之前的位置。
    sed -i '40a void _swapshort (register char *bp, register unsigned n);' ncarview/src/lib/libncarg_ras/misc.c
    sed -i '41a void _swaplong (register char *bp, register unsigned n);' ncarview/src/lib/libncarg_ras/misc.c
    • 修改结果如下图所示,表示修改完成。

  8. 执行以下命令修改yMakefile。
    sed -i "31a #else\nMORE_LIBS      = -lm" ncarview/src/bin/ictrans/yMakefile

    查看如下,表示修改完成。

  9. 执行以下命令进入ncarview/src/bin/ictrans目录修改yMakefile第46行。
    cd /path/to/ncl/ncl-6.6.2/ncarview/src/bin/ictrans
    vim yMakefile

    添加#以注释,如下显示表示修改完成。

  10. 执行以下命令进行编译配置。

    首次编译时,如config目录下存在ymake-filter文件,请执行以下命令删除ymake-filter。

    rm config/ymake-filter -rf
    cd /path/to/ncl/ncl-6.6.2
    ./Configure

    进入安装引导界面,根据实际需要进行配置。

    1. Enter Return to continue, or q(quit) 回车
    2. Build NCL (y)? y
    3. Parent installation directory /path/to/ncl
    4. System temp space directory /tmp
    5. Build NetCDF4 feature support (optional)? (y) y
    6. Build HDF4 support (optional) into NCL? (y) y
    7. Also build HDF4 support (optional) into raster library? (y) y
    8. Did you build HDF4 with szip support? (n) n
    9. Build Triangle support (optional) into NCL (y) n
    10. did you enable NetCDF-4 support (y) y
    11. Did you build NetCDF with OPeNDAP support (y) n
    12. Build GDAL support (optional) into NCL? (n) y
    13. Build EEMD support (optional) into NCL? (y) y
    14. Build Udunits-2 support (optional) into NCL (y) y
    15. Build Vis5d+ support (optional) into NCL (n) y
    16. Build HDF-EOS2 support (optional) into NCL (y) y
    17. Build HDF5 support (optional) into NCL (y) y
    18. Build HDF-EOS5 support (optional) into NCL (y) y
    19. Build GRIB2 support (optional) into NCL (y) y
    20. Enter local library search path(s) /path/to/gcc/lib /path/to/gcc/lib64 /path/to/hmpi/lib /path/to/hdf5/lib /path/to/pnetcdf/lib /path/to/netcdf/lib /path/to/libjpeg/lib /path/to/hdf4/lib /path/to/proj/lib /path/to/libpng/lib /path/to/gdal/lib /path/to/jasper/lib /path/to/g2clib/lib /path/to/udunits/lib /path/to/gsl/lib /path/to/hdf-eos2/lib /path/to/hdf-eos5/lib /path/to/mesa/lib /path/to/vis5d+/lib /path/to/szip/lib /lib64 /usr/lib64 /usr/include/X11
    21. Enter local include search path(s) /path/to/gcc/include /path/to/gcc/lib64/gcc/aarch64-linux-gnu/10.3.1/include /path/to/gcc/lib64/gcc/aarch64-linux-gnu/10.3.1/plugin/include /path/to/gcc/lib64/gcc/aarch64-linux-gnu/10.3.1/install-tools/include /path/to/hmpi/include /path/to/hdf5/include /path/to/pnetcdf/include /path/to/netcdf/include /path/to/libjpeg/include /path/to/hdf4/include /path/to/proj/include /path/to/libpng/include /path/to/gdal/include /path/to/jasper/include /path/to/jasper/include/jasper /path/to/g2clib/include /path/to/udunits/include /path/to/gsl/include /path/to/gsl/include/gsl /path/to/hdf-eos2/include /path/to/hdf-eos5/include /path/to/mesa/include /path/to/mesa/include/GL /path/to/vis5d+/include /path/to/szip/include /usr/include /usr/include/freetype2 /usr/include/freetype2/freetype /usr/include/X11 /usr/include/tirpc
    22. Go back and make more changes or review? (n) 回车
    23. Save current configuration ? (y) 回车

    请务必在配置过程中将所需的依赖库&头文件一并导入。需要在配置第20步配置第21步时准确指定,其中包括毕昇编译器、Hyper MPI的实际安装路径,并注意jasper、gsl、mesa的include目录层级,输入完成均需要手动执行回车键继续。

    回显如下,表示配置完成。

  11. 执行以下命令修改主目录Makefile。
    cd /path/to/ncl/ncl-6.6.2/
    vim Makefile

    将第137、138、139行修改如下图所示。

  12. 执行以下命令编译安装。
    make Everything >& make-output &

    可以通过执行tail -f make-output命令查看编译详情。

    在命令行下执行ll /path/to/ncl/bin 查看文件生成情况,如下图所示,最终编译生成名为ncl的二进制文件即表示编译正常结束。

  13. 执行以下命令建立软连接。
    ln -s /path/to/ncl/share/ncarg/* /path/to/ncl/lib/ncarg
  14. 执行以下命令设置环境变量。
    export NCARG_FONTCAPS=/path/to/ncl/lib/ncarg/fontcaps
    export NCARG_GRAPHCAPS=/path/to/ncl/lib/ncarg/graphcaps
    export NCARG_ROOT=/path/to/ncl
    export NCARG_DATABASE=/path/to/ncl/lib/ncarg/database
    export NCARG_LIB=/path/to/ncl/lib
    export NCARG_NCARG=/path/to/ncl/lib/ncarg
    export PATH=/path/to/ncl:$PATH
    export LD_LIBRARY_PATH=/path/to/ncl/lib:$LD_LIBRARY_PATH