配置环境变量

操作步骤

  1. 执行以下命令新建所有基础环境变量的modulefile。

    mkdir -p /path/to/hwrf/modulefile
    vim /path/to/hwrf/modulfile/all
    文件中添加以下内容。
    #%Module1.0#####################################################################
    # bisheng
    set     prefix_bisheng  /path/to/bisheng
    set     version_bisheng                     3.0.0
    
    setenv    BISHENG_PATH /path/to/bisheng
    
    prepend-path    PATH              $prefix_bisheng/lib/clang/15.0.4/bin:$prefix_bisheng/bin
    prepend-path    LD_LIBRARY_PATH            $prefix_bisheng/lib:$prefix_bisheng/lib/clang/15.0.4/lib
    prepend-path    INCLUDE    $prefix_bisheng/include:$prefix_bisheng/lib/clang/15.0.4/include
    
    # hmpi
    set     prefix_hmpi  /path/to/hmpi
    set     version_hmpi                     1.3.0
    
    setenv    HMPI_PATH /path/to/hmpi
    setenv    OPAL_PREFIX /path/to/hmpi
    setenv    HMPI_DIR ${prefix_hmpi}
    setenv    HMPI_LIB ${prefix_hmpi}/lib
    setenv    HMPI_INC ${prefix_hmpi}/include
    setenv    MPI_DIR ${prefix_hmpi}
    setenv    MPI_LIB ${prefix_hmpi}/lib
    setenv    MPI_INC ${prefix_hmpi}/include
    
    prepend-path    PATH              $prefix_hmpi/hucx/bin:$prefix_hmpi/xucg/bin:$prefix_hmpi/bin
    prepend-path    LD_LIBRARY_PATH            $prefix_hmpi/hucx/lib:$prefix_hmpi/lib:$prefix_hmpi/xucg/lib
    prepend-path    INCLUDE    $prefix_hmpi/include:$prefix_hmpi/include/openmpi/opal/mca/hwloc/hwloc201/hwloc/include:$prefix_hmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include:$prefix_hmpi/include/pmix/src/include:$prefix_hmpi/hucx/include:$prefix_hmpi/xucg/include
    
    # kml
    set     prefix_kml  /path/to/kml
    set     version_kml                     2.0.0
    
    setenv    KML_BISHENG_PATH /path/to/kml
    setenv    KML_LIB ${prefix_kml}/lib
    
    prepend-path    LD_LIBRARY_PATH            $prefix_kml/lib
    prepend-path    INCLUDE    $prefix_kml/include
    
    # hdf5
    set     prefix_hdf5  /path/to/hdf5
    set     version_hdf5                     1.12.0
    
    setenv    HDF5_CLANG_PATH /path/to/hdf5
    setenv    HDF5 ${prefix_hdf5}
    setenv    HDF5_DIR ${prefix_hdf5}
    setenv    HDF5_LIB ${prefix_hdf5}/lib
    setenv    HDF5_INC ${prefix_hdf5}/include
    setenv    PHDF5 ${prefix_hdf5}
    setenv    PHDF5_DIR ${prefix_hdf5}
    setenv    PHDF5_LIB ${prefix_hdf5}/lib
    setenv    PHDF5_INC ${prefix_hdf5}/include
    
    prepend-path    PATH              $prefix_hdf5/bin
    prepend-path    LD_LIBRARY_PATH            $prefix_hdf5/lib
    prepend-path    INCLUDE    $prefix_hdf5/include
    
    # pnetcdf
    set     prefix_pnetcdf  /path/to/pnetcdf
    set     version_pnetcdf                     1.12.1
    
    setenv    PNETCDF_PATH /path/to/pnetcdf
    setenv    PNETCDF ${prefix_pnetcdf}
    setenv    PNETCDF_DIR ${prefix_pnetcdf}
    setenv    PNETCDF_LIB ${prefix_pnetcdf}/lib
    setenv    PNETCDF_INC ${prefix_pnetcdf}/include
    
    prepend-path    PATH              $prefix_pnetcdf/bin
    prepend-path    LD_LIBRARY_PATH            $prefix_pnetcdf/lib
    prepend-path    INCLUDE    $prefix_pnetcdf/include
    
    # netcdf
    set     prefix_netcdf  /path/to/netcdf
    set     version_netcdf                     c_4.7.4_fortran_4.5.3_cxx_4.2
    
    setenv    NETCDF_CLANG_PATH /path/to/netcdf
    setenv    NETCDF ${prefix_netcdf}
    setenv    NETCDF_DIR ${prefix_netcdf}
    setenv    NETCDF_LIB ${prefix_netcdf}/lib
    setenv    NETCDF_INC ${prefix_netcdf}/include
    
    prepend-path    PATH              $prefix_netcdf/bin
    prepend-path    LD_LIBRARY_PATH            $prefix_netcdf/lib
    prepend-path    INCLUDE    $prefix_netcdf/include
    
    # jasper
    set     prefix_jasper  /path/to/jasper
    set     version_jasper                     1.900.2
    
    setenv    JASPER_PATH /path/to/jasper
    setenv    JASPER ${prefix_jasper}
    setenv    JASPER_DIR ${prefix_jasper}
    setenv    JASPER_LIB ${prefix_jasper}/lib
    setenv    JASPER_INC ${prefix_jasper}/include
    setenv    JASPERLIB ${prefix_jasper}/lib
    setenv    JASPERINC ${prefix_jasper}/include
    
    prepend-path    PATH              $prefix_jasper/bin
    prepend-path    LD_LIBRARY_PATH            $prefix_jasper/lib
    prepend-path    INCLUDE    $prefix_jasper/include
    
    # libpng
    set     prefix_libpng  /path/to/libpng
    set     version_libpng                     1.2.29
    
    setenv    LIBPNG_PATH /path/to/libpng
    setenv    LIBPNG /path/to/libpng
    setenv    LIBPNG_DIR ${prefix_libpng}
    setenv    LIBPNG_LIB ${prefix_libpng}/lib
    setenv    LIBPNG_INC ${prefix_libpng}/include
    
    
    prepend-path    PATH              $prefix_libpng/bin
    prepend-path    LD_LIBRARY_PATH            $prefix_libpng/lib
    prepend-path    INCLUDE    $prefix_libpng/include
    
    # zlib
    set     prefix_zlib  /path/to/zlib
    set     version_zlib                     1.2.13
    
    setenv    ZLIB_CLANG_PATH /path/to/zlib
    setenv    ZLIB ${prefix_zlib}
    setenv    ZLIB_DIR ${prefix_zlib}
    setenv    ZLIB_LIB ${prefix_zlib}/lib
    setenv    ZLIB_INC ${prefix_zlib}/include
    
    prepend-path    LD_LIBRARY_PATH            $prefix_zlib/lib
    prepend-path    INCLUDE    $prefix_zlib/include
    
    # other variables
    setenv    C_INCLUDE_PATH ${prefix_bisheng}/include:${prefix_hmpi}/include:${prefix_kml}/include:${prefix_hdf5}/include:${prefix_pnetcdf}/include:${prefix_netcdf}/include:${prefix_libpng}/include:${prefix_jasper}/include:${prefix_zlib}/include
    setenv    CXX_INCLUDE_PATH ${prefix_bisheng}/include:${prefix_hmpi}/include:${prefix_kml}/include:${prefix_hdf5}/include:${prefix_pnetcdf}/include:${prefix_netcdf}/include:${prefix_libpng}/include:${prefix_jasper}/include:${prefix_zlib}/include
    setenv    CPLUS_INCLUDE_PATH ${prefix_bisheng}/include:${prefix_hmpi}/include:${prefix_kml}/include:${prefix_hdf5}/include:${prefix_pnetcdf}/include:${prefix_netcdf}/include:${prefix_libpng}/include:${prefix_jasper}/include:${prefix_zlib}/include
    
    setenv    CPPFLAGS "-I${prefix_hdf5}/include -I${prefix_pnetcdf}/include -I${prefix_netcdf}/include"
    setenv    LDFLAGS "-L${prefix_hdf5}/lib -L${prefix_pnetcdf}/lib -L${prefix_netcdf}/lib -lnetcdf -lnetcdff -lpnetcdf -lhdf5_hl -lhdf5 -lz -L${prefix_hmpi}/lib -lmpi -L${prefix_bisheng}/lib -lomp"
    
    setenv    HWRF_DIR /path/to/hwrf
    setenv    HWRF 1
    setenv    WRF_DIR /path/to/hwrf/hwrfrun/sorc/WRF
    setenv    WRFIO_NCD_LARGE_FILE_SUPPORT 1
    setenv    CC mpicc
    setenv    CXX mpicxx
    setenv    FC mpif90
    setenv    F77 mpif90
    setenv    F90 mpif90

  2. 执行以下命令安装module工具。

    yum install -y environment-modules
    source /usr/share/Modules/init/bash

  3. 执行以下命令加载环境。

    module use /path/to/wrf/modulefile
    module load all