UPP编译和安装

操作步骤

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

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

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

    vim patch-UPP

    输入以下内容并保存。

    diff -Nur UPP/arch/configure.defaults UPP_ok/arch/configure.defaults
    --- UPP/arch/configure.defaults	2018-07-21 04:50:21.286793000 +0800
    +++ UPP_ok/arch/configure.defaults	2023-07-26 16:28:31.555770420 +0800
    @@ -7,6 +7,46 @@
     # IBM4, IBM8, LINUX, CRAY90, HP, SGI, LINUXF90, VPP500
     # VERBOSE
     ###########################################################
    +#ARCH   Linux aarch64, gfortran compiler # serial dmpar
    +#
    +FORMAT_FREE = -ffree-form -ffree-line-length-none
    +
    +SFC     = mpifort
    +SF90    = mpif90 $(FORMAT_FREE)
    +SCC     = mpicc
    +
    +DM_FC    = mpifort
    +DM_F90   = mpif90 $(FORMAT_FREE)
    +DM_CC    = mpicc
    +
    +FC      = $(DM_FC)
    +F90     = $(DM_F90)
    +CC      = $(DM_CC)
    +CPP     = cpp
    +
    +LINUX_OBJ  = TIMEF.o
    +BYTE_ORDER = UPPLITTLEENDIAN
    +SIZE_I8R8  = #-fdefault-integer-8 -fdefault-real-8
    +SIZE_I4R8  = #-fdefault-real-8
    +SIZE_I4R4  =
    +SIZE       =
    +
    +PPDEFINE   = -DCOMMCODE -DLINUX -D$(BYTE_ORDER)
    +FPPDEFINE  = $(PPDEFINE)
    +
    +FDEBUG  = -g -O3 -ffpe-trap=overflow,zero -fbounds-check -ftrapv  -Wall
    +CRTMDBUG=
    +CDEBUG  = -g -O3 -Wall
    +
    +CPP_FLAGS = -P -traditional $(FPPDEFINE)
    +INC_FLAGS =
    +LDFLAGS   = -Wl,-noinhibit-exec
    +FFLAGS    = -fconvert=big-endian  $(FPPDEFINE) $(SIZE)  CONFIGURE_FFLAGS #-lpthread -liomp5
    +CFLAGS    = $(PPDEFINE) -D_OPENMP CONFIGURE_CFLAGS
    +ARFLAGS   =
    +FFLAGS_CRTM = -c -fconvert=big-endian  -ggdb -static $(SIZE) CONFIGURE_FFLAGS_CRTM
    +FL_CRTM     =
    +###########################################################
     #ARCH	AIX  #serial dmpar
     #
     SFC     = xlf_r 
    diff -Nur UPP/configure UPP_ok/configure
    --- UPP/configure	2018-10-24 23:06:18.573917000 +0800
    +++ UPP_ok/configure	2023-07-26 16:29:19.459770420 +0800
    @@ -48,8 +48,8 @@
          #
          # System default
         "1" )
    -        if [ -d /usr/local/netcdf ] ; then
    -          NETCDF=/usr/local/netcdf
    +        if [ -d ${NETCDF} ] ; then
    +          NETCDF=${NETCDF}
             else
               echo $SCRIPT ': /usr/local/netcdf not found'
               exit 2   #ERROR
    diff -Nur UPP/src/cnvgrib/makefile UPP_ok/src/cnvgrib/makefile
    --- UPP/src/cnvgrib/makefile	2015-11-06 01:50:56.616252000 +0800
    +++ UPP_ok/src/cnvgrib/makefile	2023-07-26 16:27:21.059770420 +0800
    @@ -36,7 +36,7 @@
    	$(CP) $(TARGET) $(BINDIR)
    
     $(TARGET): $(SRC)
    -	$(SFC) -o $@ $(SRC) $(FFLAGS) $(EXTRA_FFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LIBS)
    +	$(SFC) -o $@ $(SRC) $(FFLAGS) $(EXTRA_FFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -L$(LIBDIR) -lg2 -lw3nco -lbacio -L$(LIBDIR)/../src/lib/w3emc -lw3emc $(GRIB2SUPT_LIB)
    
     clean:
    	@ echo -e "\n <><><><> CLEAN <><><><>\n"
    diff -Nur UPP/src/unipost/makefile UPP_ok/src/unipost/makefile
    --- UPP/src/unipost/makefile	2017-11-21 07:12:42.882452000 +0800
    +++ UPP_ok/src/unipost/makefile	2023-07-26 16:30:36.291770420 +0800
    @@ -30,11 +30,12 @@
     UPPLIBS     = -lnemsio -lsigio -lsfcio -lgfsio -lsp -lw3nco -lw3emc -lbacio -lCRTM $(SERIAL_MPI_LIB)
     WRFEXTLIBS  = $(WRF_LIB) $(WRF_LIB_EXTRA) $(WRF_LIB2)
     NCDFLIBS    = -L$(NETCDFPATH)/lib $(NETCDFLIBS)
    +PNCDFLIBS   = -L$(PNETCDF_LIB) -lpnetcdf
    
    -LIBS        = $(LLIBDIR) $(UPPLIBS) $(GRIB2LIBS) $(WRFEXTLIBS) $(NCDFLIBS)
    +LIBS        = $(LLIBDIR) $(UPPLIBS) $(GRIB2LIBS) $(WRFEXTLIBS) -L$(WRF_DIR)/external/io_grib2 -lio_grib2 -L$(WRF_DIR)/external/io_pnetcdf -lwrfio_pnf $(NCDFLIBS) $(PNCDFLIBS) -fopenmp
    
     MODULES     = $(WRF_MODS)
    -
    + 
     #
     # Compilation / Link Flag Configuration
     EXTRA_CPPFLAGS = 

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

    patch -p0 < ./patch-UPP

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

    cd UPP
    echo 2 | ./configure

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

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

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

    ls -l bin/*.exe

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