WPS编译和安装

操作步骤

  1. 执行以下命令进入目录解压安装包。

    cd /path/to/hwrf/wrfrun/sorc/
    tar -xvf ../../HWRF_v4.0a_WPS.tar.gz

  2. 执行以下命令新建patch-WPS。

    vim patch-WPS

    输入以下内容并保存。

    diff -Nur WPS/arch/configure.defaults WPS_ok/arch/configure.defaults
    --- WPS/arch/configure.defaults	2018-08-27 02:30:04.000000000 +0800
    +++ WPS_ok/arch/configure.defaults	2023-07-26 14:44:43.247770420 +0800
    @@ -1,4 +1,27 @@
     ########################################################################################################################
    +#ARCH    Linux aarch64, Bisheng HMPI   # serial serial_NO_GRIB2 dmpar dmpar_NO_GRIB2
    +#
    +COMPRESSION_LIBS    = CONFIGURE_COMP_L
    +COMPRESSION_INC     = CONFIGURE_COMP_I
    +FDEFS               = CONFIGURE_FDEFS
    +SFC                 = mpifort -fopenmp
    +SCC                 = mpicc -fopenmp
    +DM_FC               = mpif90 -fopenmp
    +DM_CC               = mpicc -DMPI2_SUPPORT
    +FC                  = $(SFC)
    +CC                  = $(SCC)
    +LD                  = $(FC)
    +FFLAGS              = -ffree-form -O -fconvert=big-endian -frecord-marker=4
    +F77FLAGS            = -ffixed-form -O -fconvert=big-endian -frecord-marker=4
    +FCSUFFIX            =
    +FNGFLAGS            = $(FFLAGS)
    +LDFLAGS             =
    +CFLAGS              =
    +CPP                 = cpp -P -traditional
    +CPPFLAGS            = -D_UNDERSCORE -DBYTESWAP -DLINUX -DIO_NETCDF -DBIT32 -DNO_SIGNAL -L$(HMPI_LIB)
    +RANLIB              = ranlib
    +
    +########################################################################################################################
     #ARCH   Linux ppc64 BG bglxf compiler with blxlc  # dmpar
     #
     COMPRESSION_LIBS    = -L$(JASPERLIB) -ljasper -lpng -lz
    diff -Nur WPS/arch/preamble WPS_ok/arch/preamble
    --- WPS/arch/preamble	2018-08-27 02:30:04.000000000 +0800
    +++ WPS_ok/arch/preamble	2023-07-26 14:45:55.343770420 +0800
    @@ -36,11 +36,7 @@
     # Set path to compiled WRF code, which is assumed to be ../WRF for v4.x, or ../WRFV3 for v3.x
     # To override the path to the compiled WRF code, just set the WRF_DIR variable after the "endif" below
     #
    -ifneq ($(wildcard $(DEV_TOP)/../WRF), ) # Check for WRF v4.x directory
    	WRF_DIR		=	../WRF
    -else
    -	WRF_DIR		=	../WRFV3
    -endif
    
     WRF_INCLUDE     =       -I$(WRF_DIR)/external/io_netcdf \
                             -I$(WRF_DIR)/external/io_grib_share \
    diff -Nur WPS/geogrid/src/Makefile WPS_ok/geogrid/src/Makefile
    --- WPS/geogrid/src/Makefile	2018-08-27 02:30:04.000000000 +0800
    +++ WPS_ok/geogrid/src/Makefile	2023-07-26 14:46:49.523770420 +0800
    @@ -16,7 +16,7 @@
    		$(WRF_DIR)/frame/module_internal_header_util.o \
    		$(WRF_INCLUDE) \
    		$(WRF_LIB) \
    -		$(MPI_LIB)
    +		-L$(MPI_LIB) -lpthread -liomp5
    
     bitarray_module.o: module_debug.o
    
    diff -Nur WPS/metgrid/src/Makefile WPS_ok/metgrid/src/Makefile
    --- WPS/metgrid/src/Makefile	2018-08-27 02:30:04.000000000 +0800
    +++ WPS_ok/metgrid/src/Makefile	2023-07-26 14:47:04.111770420 +0800
    @@ -16,7 +16,7 @@
    		$(WRF_DIR)/frame/module_internal_header_util.o \
                     $(WRF_INCLUDE) \
                     $(WRF_LIB) \
    -                $(MPI_LIB)
    +                -L$(MPI_LIB) -lpthread -liomp5
    
     bitarray_module.o: module_debug.o
    

  3. 执行以下命令打人补丁patch-WPS。

    patch -p0 < ./patch-WPS

  4. 执行以下命令进入目录配置生成编译文件。

    cd WPS
    echo 3 | ./configure

  5. 执行以下命令进行编译。

    ./compile 2>&1 | tee -a build.log

  6. 执行以下命令查看二进制文件。

    ls -l *.exe

    成功编译后将在当前目录生成可执行文件。