---
title: hwrf-utilities编译和安装
description: "1. 执行以下命令进入目录解压安装包。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kylin_kunpeng_hwrf_v40a_02_0019.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/kylin_kunpeng_hwrf_v40a_02_0019.html
indexId: f26afcc5d4cbf00e78137ea871a21299d2b0c84cfe69471726dec32172d49b0a78
---
# hwrf-utilities编译和安装

#### 操作步骤

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

```
cd
/path/to/hwrf/wrfrun/sorc/
tar -xvf ../../HWRF_v4.0a_hwrf-utilities.tar.gz
```


2. 执行以下命令设置编译变量。

```
export LAPACK_PATH=${KML_LIB}
```


3. 执行以下命令新建补丁patch-hwrf-utilities。

```
vim patch-hwrf-utilities
```


  输入以下内容并保存。

```
diff -Nur hwrf-utilities/arch/configure.defaults hwrf-utilities_ok/arch/configure.defaults
--- hwrf-utilities/arch/configure.defaults	2018-07-21 04:53:22.144299000 +0800
+++ hwrf-utilities_ok/arch/configure.defaults	2023-07-21 14:51:24.575770420 +0800
@@ -1,4 +1,52 @@
###########################################################
+#ARCH	Linux aarch64, Kunpeng Bisheng compiler HyperMPI KML	# dmpar
+DESCRIPTION     = BISHENG
+WRF_PNETCDF     = -L$(WRF_DIR)/external/io_pnetcdf -lwrfio_pnf -L$(PNETCDF_LIB) -lpnetcdf
+NETCDF_INCLUDE  = -I$(NETCDF_INC)
+NETCDF_LDFLAGS  = -L$(NETCDF_LIB) -lnetcdf -lnetcdff
+HMPI            = -L$(MPI_LIB) -I$(MPI_INC)
+MATHLIB         = -L$(KML_LIB) -lkm_l9 -lmathlib -lm
+
+BYTE_ORDER     =  BIG_ENDIAN
+SFC            =  mpifort $(HMPI) $(MATHLIB) -fopenmp -DLINUX -L$(LIBPNG_LIB) -lpng -L$(JASPER_LIB) -ljasper -std=legacy  #  -fno-range-check -ffree-line-length-none -fdefault-double-8
+SF90           =  $(SFC)
+SCC            =  mpicc $(HMPI) $(MATHLIB) -fopenmp -DLINUX -L$(LIBPNG_LIB) -lpng -L$(JASPER_LIB) -ljasper -Wno-int-conversion
+OMP_FFLAGS     =  -fopenmp
+DEBUG_FLAGS    =  -g -traceback
+FFLAGS_TRACKER =  -O3 -convert big_endian -qcheck -qarch=auto -qflttrap=ov:zero:inv:enbale # $(DEBUG_FLAGS)
+CPP            =  cpp
+CPPFLAGS       =  -P -traditional-cpp -D$(BYTE_ORDER) -DWRF -DLINUX -I$(WRF_DIR)/inc
+FPPFLAGS       =  $(CPPFLAGS)
+FPP	       =  cpp -P -traditional-cpp
+ARFLAGS        =  ru
+M4             =  m4 -G
+RANLIB         =  ranlib
+
+DM_FC          =  mpifort $(MATHLIB) -DLINUX -std=legacy -fopenmp -DLINUX -L$(LIBPNG_LIB) -lpng -L$(JASPER_LIB) -ljasper # -fno-range-check -ffree-line-length-none -fdefault-double-8
+DM_F90         =  $(DM_FC)
+DM_CC          =  mpicc $(MATHLIB) -DMPI2_SUPPORT -DLINUX -L$(LIBPNG_LIB) -lpng -L$(JASPER_LIB) -ljasper -Wno-int-conversion
+
+FC             =  $(SFC)
+F90            =  mpifort $(HMPI) $(MATHLIB) -ffree-form -ffree-line-length-none -std=legacy -fopenmp -DLINUX  -L$(LIBPNG_LIB) -lpng -L$(JASPER_LIB) -ljasper
+CC             =  $(SCC)
+
+CFLAGS         =  -O0 -DLINUX -DUNDERSCORE -Dfunder -DFortranByte=char \
+                  -DFortranInt=int -DFortranLlong='long long'
+FCFALGS        =  -ffree-line-length-none -std=legacy
+
+DEBUG_CFLAGS   =
+
+ESSLLIB        =  -L$(KML_LIB)/kblas/omp -lkblas
+MASSLIB        =  #-I$(R_LIB)/MASS
+SED_FTN        =  $(WRF_DIR)/tools/standard.exe
+LIB_EXTERNAL   =  -L$(WRF_DIR)/external/io_grib1 -lio_grib1 \
+                  -L$(WRF_DIR)/external/io_grib_share -lio_grib_share \
+                  -L$(WRF_DIR)/external/io_int -lwrfio_int \
+                  -L$(WRF_DIR)/external/esmf_time_f90 -lesmf_time \
+                  -L$(WRF_DIR)/external/RSL_LITE -lrsl_lite \
+                  -L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \
+                  -L$(WRF_DIR)/external/fftpack/fftpack5 -lfftpack
+###########################################################
#ARCH	AIX  #dmpar
#
@@ -736,3 +784,4 @@
##################################################################
#ARCH	NULL
+
diff -Nur hwrf-utilities/libs/src/g2/intmath.f hwrf-utilities_ok/libs/src/g2/intmath.f
--- hwrf-utilities/libs/src/g2/intmath.f	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/g2/intmath.f	2023-07-21 14:51:10.647770420 +0800
@@ -165,7 +165,8 @@
function ilog2_2(i_in)
implicit none
integer(kind=2), value :: i_in
-      integer(kind=2)::ilog2_2,i
+      integer(kind=2)::ilog2_2
+      integer::i
ilog2_2=0
i=i_in
if(i<=0) return
@@ -200,7 +201,8 @@
function ilog2_1(i_in)
implicit none
integer(kind=1), value :: i_in
-      integer(kind=1)::ilog2_1,i
+      integer(kind=1)::ilog2_1
+      integer::i
ilog2_1=0
i=i_in
if(i<=0) return
diff -Nur hwrf-utilities/libs/src/hwrfutil/decomp_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/decomp_module.f90
--- hwrf-utilities/libs/src/hwrfutil/decomp_module.f90	2014-02-22 09:25:07.110185000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/decomp_module.f90	2023-07-21 14:51:10.647770420 +0800
@@ -16,18 +16,18 @@
integer :: ips,ipe,jps,jpe,kps,kpe
contains
procedure same_dims
-     procedure free => free_decomp
-     procedure memdims => memdims_decomp
-     procedure validate_dims => validate_dims_decomp
-     procedure my_rank => my_rank_decomp
-     procedure ranks_for => ranks_for_decomp
-     procedure decomp_rank => decomp_rank_decomp
+     procedure::free => free_decomp
+     procedure::memdims => memdims_decomp
+     procedure::validate_dims => validate_dims_decomp
+     procedure::my_rank => my_rank_decomp
+     procedure::ranks_for => ranks_for_decomp
+     procedure::decomp_rank => decomp_rank_decomp
end type decomp
type, extends(decomp) :: decomp_dummy
! This exists as a workaround for an Intel compiler bug
contains
-     procedure free => free_decomp_dummy
+     procedure::free => free_decomp_dummy
end type decomp_dummy
contains
diff -Nur hwrf-utilities/libs/src/hwrfutil/fileop_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/fileop_module.f90
--- hwrf-utilities/libs/src/hwrfutil/fileop_module.f90	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/fileop_module.f90	2023-07-21 14:51:10.647770420 +0800
@@ -352,7 +352,8 @@
logical, intent(in) :: lstat,quiet
! locals
character(len=flen+1) :: cfilename
-    integer(kind=C_INT64_T) :: iflags,ilstat,iquiet
+    integer(kind=C_INT64_T) :: ilstat,iquiet
+    integer :: iflags
s%lstat_flag=lstat
s%initialized=.true.
diff -Nur hwrf-utilities/libs/src/hwrfutil/interp_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/interp_module.f90
--- hwrf-utilities/libs/src/hwrfutil/interp_module.f90	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/interp_module.f90	2023-07-21 14:51:10.647770420 +0800
@@ -34,11 +34,11 @@
type interpolator
contains
-     procedure clear => clear_interpolator
-     procedure free => free_interpolator
-     procedure prep => prep_interpolator
-     procedure scalar => scalar_interpolator ! scalar (not wind) interpolation
-     procedure hwind => hwind_interpolator  ! horizontal wind interpolation
+     procedure::clear => clear_interpolator
+     procedure::free => free_interpolator
+     procedure::prep => prep_interpolator
+     procedure::scalar => scalar_interpolator ! scalar (not wind) interpolation
+     procedure::hwind => hwind_interpolator  ! horizontal wind interpolation
end type interpolator
type, extends(interpolator) :: averager2d_real
@@ -51,10 +51,10 @@
class(decomp), pointer :: dec=>NULL()
real, pointer :: lat(:,:,:)=>NULL(), lon(:,:,:)=>NULL()
contains
-     procedure clear => clear_averager2d_real
-     procedure free => free_averager2d_real
-     procedure prep => prep_averager2d_real
-     procedure scalar => scalar_averager2d_real
+     procedure::clear => clear_averager2d_real
+     procedure::free => free_averager2d_real
+     procedure::prep => prep_averager2d_real
+     procedure::scalar => scalar_averager2d_real
end type averager2d_real
type, extends(interpolator) :: bilinear_real
@@ -86,13 +86,13 @@
logical, pointer :: ihave(:)=>NULL(), jhave(:)=>NULL()
contains
-     procedure free => free_bilinear_real
-     procedure prep => prep_bilinear_real
-     procedure scalar => scalar_bilinear_real
-     procedure hwind => hwind_bilinear_real
+     procedure::free => free_bilinear_real
+     procedure::prep => prep_bilinear_real
+     procedure::scalar => scalar_bilinear_real
+     procedure::hwind => hwind_bilinear_real
-     procedure masked_interp => masked_bilinear_real
-     procedure unmasked_interp => unmasked_bilinear_real
+     procedure::masked_interp => masked_bilinear_real
+     procedure::unmasked_interp => unmasked_bilinear_real
end type bilinear_real
interface init_bilinear_real
diff -Nur hwrf-utilities/libs/src/hwrfutil/Makefile hwrf-utilities_ok/libs/src/hwrfutil/Makefile
--- hwrf-utilities/libs/src/hwrfutil/Makefile	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/Makefile	2023-07-21 14:51:10.647770420 +0800
@@ -5,7 +5,7 @@
include ../../../configure.hwrf
CFLAGS+=$(NETCDF_INCLUDE)
-FFLAGS+=-I. $(NETCDF_INCLUDE)
+FFLAGS+=-I. $(NETCDF_INCLUDE) -I../../../tools/hwrf_afos
LDFLAGS+=$(NETCDF_LDFLAGS) $(NETCDF_INCLUDE)
include ../../../pure-openmp.inc
diff -Nur hwrf-utilities/libs/src/hwrfutil/out4wave_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/out4wave_module.f90
--- hwrf-utilities/libs/src/hwrfutil/out4wave_module.f90	2014-02-22 09:25:07.110185000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/out4wave_module.f90	2023-07-21 14:51:10.647770420 +0800
@@ -19,11 +19,11 @@
! NOTE: If you add pointers, make sure you update
! invalidate4wave, close4wave and open4wave
contains
-     procedure free => close4wave
-     procedure close => close4wave
-     procedure invalidate => invalidate4wave
-     procedure write => write4wave
-     procedure read => read4wave
+     procedure::free => close4wave
+     procedure::close => close4wave
+     procedure::invalidate => invalidate4wave
+     procedure::write => write4wave
+     procedure::read => read4wave
end type data4wave
interface init_data4wave
diff -Nur hwrf-utilities/libs/src/hwrfutil/projection_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/projection_module.f90
--- hwrf-utilities/libs/src/hwrfutil/projection_module.f90	2014-03-11 03:10:00.878970000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/projection_module.f90	2023-07-21 14:51:10.651770420 +0800
@@ -718,7 +718,7 @@
else
clat=sqrt(1-slat**2)
clon=min(1.,max(-1.,(this%clat0*clatr*clonr - this%slat0*slatr)/clat))
-       hs=hi*sign(1.,this%x0+1-this%is1)
+       hs=hi*sign(0.1D0,this%x0+1-this%is1)
if(abs(hs)/=1) hs=1
this%lon1=mod(this%lon0+hs*RADDEG*acos(min(1.,max(-1.,clon)))+3600,360.)
this%lat1=asin(max(-1.,min(1.,slat)))*RADDEG
@@ -822,7 +822,7 @@
this%slat1=sin(this%lat1*DEGRAD)
this%clat1=cos(this%lat1*DEGRAD)
-    this%HS0=sign(1.,mod(this%lon1-this%lon0+180+3600,360.)-180)
+    this%HS0=sign(0.1D0,mod(this%lon1-this%lon0+180+3600,360.)-180)
this%clon1=cos((this%lon1-this%lon0)*DEGRAD)
this%slatr=this%clat0*this%slat1-this%slat0*this%clat1*this%clon1
@@ -928,7 +928,7 @@
bigi: do i=ips,ipe
vlat=lat(i,j,k)*DEGRAD
vlon=lon(i,j,k)*DEGRAD
-                hs=sign(1.,mod(lon(i,j,k)-this%lon0+180+3600,360.)-180.)
+                hs=sign(0.1D0,mod(lon(i,j,k)-this%lon0+180+3600,360.)-180.)
clon=cos(vlon-cenlon)
slat=sin(vlat)
clat=cos(vlat)
@@ -952,7 +952,7 @@
rot: if(present(crot)) then
if_grid_winds: if(.not. this%earth_winds) then
rotpole: if(clatr<=0) then
-                         crot(i,j,k)=-sign(1.,slatr*this%slat0)
+                         crot(i,j,k)=-sign(0.1D0,slatr*this%slat0)
srot(i,j,k)=0
else
slon=sin(vlon-cenlon)
diff -Nur hwrf-utilities/libs/src/hwrfutil/swathgen_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/swathgen_module.f90
--- hwrf-utilities/libs/src/hwrfutil/swathgen_module.f90	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/swathgen_module.f90	2023-07-21 14:51:10.651770420 +0800
@@ -254,7 +254,7 @@
endif
allocate(character(len=writesize) :: writeme)
-    !$OMP PARALLEL DO PRIVATE(lengrib,i,ivar) DEFAULT(SHARED)
+    !OMP PARALLEL DO PRIVATE(lengrib,i,ivar) DEFAULT(SHARED)
do ivar=1,num_vars
!write(0,*) 'copy var',ivar
lengrib=lengribs(ivar)
@@ -274,7 +274,7 @@
writeme(i+4+lengrib:i+4+lengrib+3)=writeme(i:i+3)
endif
enddo
-    !$OMP END PARALLEL DO
+    !OMP END PARALLEL DO
19  format('Write ',I0,' bytes to grib file at pos=',I0,'.')
write(0,19) len(writeme),this%grib_pos
@@ -390,7 +390,7 @@
enddo
enddo
-20  format('var ',A,': mean=',F0.3,', lon=',I,' ... ',I0,' by ',I0,', lat=',I0,' ... ',I0,' by ',I0,', iscan=',I0,', nmask=',I0)
+20  format('var ',A,': mean=',F0.3,', lon=',I0,' ... ',I0,' by ',I0,', lat=',I0,' ... ',I0,' by ',I0,', iscan=',I0,', nmask=',I0)
if(nmask>0) then
print 20,trim(swath_wrfname(ivar)),sum/nmask,ilon0,ilon1,idlon, ilat0,ilat1,idlat, iscan, nmask
else
diff -Nur hwrf-utilities/libs/src/hwrfutil/tcf_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/tcf_module.f90
--- hwrf-utilities/libs/src/hwrfutil/tcf_module.f90	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/tcf_module.f90	2023-07-21 14:51:10.651770420 +0800
@@ -193,8 +193,8 @@
type(atcf), intent(in) :: atcf0
integer :: istmtyp
character*(*) :: model_name
-    character*(19), parameter, dimension(3) :: stmtyp= &
-         (/'TROPICAL DEPRESSION','TROPICAL STORM','HURRICANE'/)
+    character(len=19), parameter, dimension(3) :: stmtyp= &
+         (/character(len=19) :: 'TROPICAL DEPRESSION','TROPICAL STORM','HURRICANE'/)
integer :: imonth
character*(3), parameter :: month(12) = &
diff -Nur hwrf-utilities/libs/src/hwrfutil/vardata_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/vardata_module.f90
--- hwrf-utilities/libs/src/hwrfutil/vardata_module.f90	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/vardata_module.f90	2023-07-21 14:51:10.651770420 +0800
@@ -18,18 +18,18 @@
logical, pointer :: mask(:,:,:)=>NULL()  ! mask: optional, allocated by alloc_mask
logical :: ownmask = .true.              ! am I responsible for deallocating mask?
contains
-     procedure alloc => alloc_vardata
-     procedure getmask => getmask_vardata
-     procedure getreal => getreal_vardata
-     procedure getint => getint_vardata
-     procedure alloc_mask => alloc_mask_vardata
-     procedure is_masked => is_masked_vardata
-     procedure is_loaded => is_loaded_vardata
+     procedure::alloc => alloc_vardata
+     procedure::getmask => getmask_vardata
+     procedure::getreal => getreal_vardata
+     procedure::getint => getint_vardata
+     procedure::alloc_mask => alloc_mask_vardata
+     procedure::is_masked => is_masked_vardata
+     procedure::is_loaded => is_loaded_vardata
!procedure load => load_vardata
!procedure save => save_vardata
-     procedure free => free_vardata
-     procedure average => average_vardata
-     procedure fill_mask => fill_mask_vardata
+     procedure::free => free_vardata
+     procedure::average => average_vardata
+     procedure::fill_mask => fill_mask_vardata
end type vardata
interface init_vardata
@@ -41,11 +41,11 @@
real, pointer :: rdata(:,:,:)
logical :: owns
contains
-     procedure getreal => getreal_vardata_real
-     procedure alloc => alloc_vardata_real
-     procedure free => free_vardata_real
-     procedure average => average_vardata_real
-     procedure is_loaded => is_loaded_vardata_real
+     procedure::getreal => getreal_vardata_real
+     procedure::alloc => alloc_vardata_real
+     procedure::free => free_vardata_real
+     procedure::average => average_vardata_real
+     procedure::is_loaded => is_loaded_vardata_real
end type vardata_real
interface init_vardata_real
@@ -58,11 +58,11 @@
integer, pointer :: idata(:,:,:)
logical :: owns
contains
-     procedure getint => getint_vardata_int
-     procedure alloc => alloc_vardata_int
-     procedure free => free_vardata_int
-     procedure average => average_vardata_int
-     procedure is_loaded => is_loaded_vardata_int
+     procedure::getint => getint_vardata_int
+     procedure::alloc => alloc_vardata_int
+     procedure::free => free_vardata_int
+     procedure::average => average_vardata_int
+     procedure::is_loaded => is_loaded_vardata_int
end type vardata_int
interface init_vardata_int
diff -Nur hwrf-utilities/libs/src/hwrfutil/wrfdiag_module.f90 hwrf-utilities_ok/libs/src/hwrfutil/wrfdiag_module.f90
--- hwrf-utilities/libs/src/hwrfutil/wrfdiag_module.f90	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/libs/src/hwrfutil/wrfdiag_module.f90	2023-07-21 14:51:10.651770420 +0800
@@ -69,9 +69,9 @@
type(proj_nmme), pointer :: eproj(:)
type(decomp) :: de_ij, de_ijk_masswind, de_ijk_interface
contains
-     procedure close => close_file
-     procedure free => close_file ! to match other classes
-     procedure open => open_file
+     procedure::close => close_file
+     procedure::free => close_file ! to match other classes
+     procedure::open => open_file
procedure free_latlonrot
procedure make_latlonrot
procedure latlon_bounds
@@ -105,9 +105,9 @@
real, pointer :: rdata(:,:,:)=>NULL()
integer, pointer :: idata(:,:,:)=>NULL()
contains
-     procedure open => open_var
-     procedure load => load_var
-     procedure free => free_wrfdiag_var
+     procedure::open => open_var
+     procedure::load => load_var
+     procedure::free => free_wrfdiag_var
procedure set_time
procedure alloc_real
procedure alloc_int
diff -Nur hwrf-utilities/libs/src/w3nco/gbyte.f hwrf-utilities_ok/libs/src/w3nco/gbyte.f
--- hwrf-utilities/libs/src/w3nco/gbyte.f	2016-04-01 22:25:17.669181000 +0800
+++ hwrf-utilities_ok/libs/src/w3nco/gbyte.f	2023-07-21 14:51:10.651770420 +0800
@@ -66,7 +66,7 @@
MASKS(NBITSW) = -1
IFIRST = 0
ENDIF
-!$OMP CRITICAL
+!$OMP END CRITICAL
ENDIF
C
C NBITS MUST BE LESS THAN OR EQUAL TO NBITSW
diff -Nur hwrf-utilities/tools/bufr_remorest/remorest.f hwrf-utilities_ok/tools/bufr_remorest/remorest.f
--- hwrf-utilities/tools/bufr_remorest/remorest.f	2013-12-04 01:41:22.539598000 +0800
+++ hwrf-utilities_ok/tools/bufr_remorest/remorest.f	2023-07-21 14:51:10.651770420 +0800
@@ -199,7 +199,9 @@
CALL W3TAGB('BUFR_REMOREST',2013,0074,0061,'NP22')
-      READ(11,'(Q,A)',END=1) NBYTES,FILE(1:NBYTES)
+C      READ(11,'(Q,A)',END=1) NBYTES,FILE(1:NBYTES)
+      READ(11,'(A)',END=1) FILE
+      NBYTES=LEN_TRIM(FILE)
1 CONTINUE
diff -Nur hwrf-utilities/tools/grb2index/grb2index.f hwrf-utilities_ok/tools/grb2index/grb2index.f
--- hwrf-utilities/tools/grb2index/grb2index.f	2017-07-21 02:22:23.346804000 +0800
+++ hwrf-utilities_ok/tools/grb2index/grb2index.f	2023-07-21 14:51:10.651770420 +0800
@@ -180,7 +180,7 @@
C
C$$$
CHARACTER CGB*(*)
-      CHARACTER CD8*8,CT10*10,HOSTNAM*15
+      CHARACTER CD8*8,CT10*10,HOSTNAME*15
CHARACTER CHEAD(2)*81
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
C  FILL FIRST 81-BYTE HEADER
@@ -197,7 +197,7 @@
CHEAD(1)(42:47)='GB2IX1'
!CHEAD(1)(49:54)=CGB(NCGB2:NCGB1-2)
CHEAD(1)(49:54)='      '
-      CHEAD(1)(56:70)=HOSTNAM(HOSTNAME)
+      CHEAD(1)(56:70)=HOSTNAME
CHEAD(1)(72:80)='grb2index'
CHEAD(1)(81:81)=CHAR(10)
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff -Nur hwrf-utilities/tools/hwrf_aux_rw/Makefile hwrf-utilities_ok/tools/hwrf_aux_rw/Makefile
--- hwrf-utilities/tools/hwrf_aux_rw/Makefile	2012-11-20 00:16:14.474329000 +0800
+++ hwrf-utilities_ok/tools/hwrf_aux_rw/Makefile	2023-07-21 14:51:10.651770420 +0800
@@ -18,7 +18,7 @@
-L$(WRF_DIR)/external/io_grib_share -lio_grib_share \
-L$(WRF_DIR)/external/esmf_time_f90 -lesmf_time \
-L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \
- -L$(WRF_DIR)/external/atm_ocn -latm_ocn
+# -L$(WRF_DIR)/external/atm_ocn -latm_ocn
LIBS = $(WRF_LIB) $(NETCDF_LDFLAGS)
diff -Nur hwrf-utilities/tools/hwrf_bdy_update/Makefile hwrf-utilities_ok/tools/hwrf_bdy_update/Makefile
--- hwrf-utilities/tools/hwrf_bdy_update/Makefile	2013-10-02 05:54:12.817535000 +0800
+++ hwrf-utilities_ok/tools/hwrf_bdy_update/Makefile	2023-07-21 14:51:10.651770420 +0800
@@ -23,6 +23,11 @@
${WRF_DIR}/frame/module_internal_header_util.o \
${WRF_DIR}/frame/pack_utils.o \
${WRF_DIR}/external/esmf_time_f90/module_utility.o \
+			${WRF_DIR}/external/io_grib2/*.o\
+			${WRF_DIR}/external/io_grib2/g2lib/*.o \
+			${WRF_DIR}/external/atm_ocn/*.o \
+			${WRF_DIR}/external/io_grib2/bacio-1.3/*.o\
+			../../libs/src/w3nco/w3fi71.o ../../libs/src/w3nco/r63w72.o\
$(WRF_GRIB2) $(WRF_PNETCDF)
EXEC =		../../exec/hwrf_bdy_update.exe
diff -Nur hwrf-utilities/tools/hwrf_ensemble/mpi-interface.f90 hwrf-utilities_ok/tools/hwrf_ensemble/mpi-interface.f90
--- hwrf-utilities/tools/hwrf_ensemble/mpi-interface.f90	2016-10-26 05:18:54.227314000 +0800
+++ hwrf-utilities_ok/tools/hwrf_ensemble/mpi-interface.f90	2023-07-21 14:51:10.651770420 +0800
@@ -236,8 +236,8 @@
! Define format statements
-500 format('MPI_INTERFACE_DEADLOCK: Processor ID: ', i6, ' Sent: ', f, &
-         & ' Received: ', f)
+500 format('MPI_INTERFACE_DEADLOCK: Processor ID: ', i6, ' Sent: ', f6.0, &
+         & ' Received: ', f6.0)
!=================================================================
diff -Nur hwrf-utilities/tools/hwrf_ens_prob/atcf_prob_module.F90 hwrf-utilities_ok/tools/hwrf_ens_prob/atcf_prob_module.F90
--- hwrf-utilities/tools/hwrf_ens_prob/atcf_prob_module.F90	2016-03-17 01:03:27.136076000 +0800
+++ hwrf-utilities_ok/tools/hwrf_ens_prob/atcf_prob_module.F90	2023-07-21 14:51:10.651770420 +0800
@@ -491,7 +491,7 @@
ierr=gerr
return
endif
-    do while(search.next())
+    do while(search%next())
if(ensid<=m%ensmax) then
call m%atcf(ensid)%read_atcf(search%match,max_atcf_records,ierr1,&
reflon,have_reflon,minlat,maxlat,minlon,maxlon,atime)
diff -Nur hwrf-utilities/tools/hwrf_ens_prob/ens_prob_module.F90 hwrf-utilities_ok/tools/hwrf_ens_prob/ens_prob_module.F90
--- hwrf-utilities/tools/hwrf_ens_prob/ens_prob_module.F90	2016-03-17 01:03:27.136076000 +0800
+++ hwrf-utilities_ok/tools/hwrf_ens_prob/ens_prob_module.F90	2023-07-21 14:51:10.651770420 +0800
@@ -1858,6 +1858,8 @@
real, parameter :: s2pi=2.50662827463 ! sqrt(2*pi)
integer :: istart,istop
real :: ilonmax,ilonmin,norm1,norm2
+      real :: RAD
+      RAD=PI/180.
10    format('Get dist from P=(',F0.1,',',F0.1,') to L1=(',F0.1,',',F0.1, &
') L2=(',F0.1,',',F0.1,').')
@@ -1899,7 +1901,7 @@
!$OMP PARALLEL DO PRIVATE(i,j,px,py,dist,prob,istart,istop)
do j=1,ny
-            dist=abs(maxdist*1.1*cosd(lats(j))/Rearth*180/pi / (lons(2)-lons(1)))
+            dist=abs(maxdist*1.1*cos(lats(j)*RAD)/Rearth*180/pi / (lons(2)-lons(1)))
istart=min(nx,max(1, floor(ilonmin-dist) ))
istop=min(nx,max(1, floor(ilonmax+dist) ))
@@ -1932,7 +1934,7 @@
!$OMP                     dy2,prob,istart,istop)
do j=1,ny
-         dist=abs(maxdist*1.1*cosd(lats(j))/Rearth*180/pi / (lons(2)-lons(1)))
+         dist=abs(maxdist*1.1*cos(lats(j)*RAD)/Rearth*180/pi / (lons(2)-lons(1)))
istart=min(nx,max(1, floor(ilonmin-dist) ))
istop=min(nx,max(1, floor(ilonmax+dist) ))
diff -Nur hwrf-utilities/tools/hwrf_ens_prob/Makefile hwrf-utilities_ok/tools/hwrf_ens_prob/Makefile
--- hwrf-utilities/tools/hwrf_ens_prob/Makefile	2016-04-09 02:08:44.944706000 +0800
+++ hwrf-utilities_ok/tools/hwrf_ens_prob/Makefile	2023-07-21 14:51:10.651770420 +0800
@@ -1,9 +1,9 @@
include ../../configure.hwrf
-PROBOBJS = hwrf_ens_prob.o ens_prob_module.o ens_output_module.o
+PROBOBJS = hwrf_ens_prob.o ens_prob_module.o ens_output_module.o ../hwrf_afos/ATAN2D.o
PROBEXEC=../../exec/hwrf_ens_prob.exe
-ATCFOBJS = atcf_prob_module.o atcf_prob.o ens_prob_module.o ens_output_module.o
+ATCFOBJS = atcf_prob_module.o atcf_prob.o ens_prob_module.o ens_output_module.o ../hwrf_afos/ATAN2D.o
ATCFEXEC=../../exec/hwrf_atcf_prob.exe
EXECS=$(PROBEXEC) $(ATCFEXEC)
diff -Nur hwrf-utilities/tools/hwrf_htcfstats/stats.f90 hwrf-utilities_ok/tools/hwrf_htcfstats/stats.f90
--- hwrf-utilities/tools/hwrf_htcfstats/stats.f90	2012-04-30 23:55:45.465906000 +0800
+++ hwrf-utilities_ok/tools/hwrf_htcfstats/stats.f90	2023-07-21 14:51:10.651770420 +0800
@@ -243,7 +243,7 @@
inited=.true.
endif
-    call etime(ymdh,temp)
+    call etime_(ymdh,temp)
epochtime=real(temp,kind=8)
end function epochtime
@@ -820,7 +820,7 @@
real, intent(in) :: hourstep, trackwidth, intenswidth
integer :: iwindlat,iwindlon,ipreslat,ipreslon,icentlat,icentlon
-    type(data) :: data
+    type(data) :: data1
integer :: ndata
real(kind=8), parameter :: s2h=3600.0
real(kind=8) :: start,now
@@ -856,20 +856,20 @@
now=start+hour*real(3600.0,kind=8)
! Get the "peak" wind and pressure:
-       data=htcf_get(hs,nh,now-intenswidth/2,now+intenswidth/2,now, &
+       data1=htcf_get(hs,nh,now-intenswidth/2,now+intenswidth/2,now, &
locs=.false.,vals=.true.,sort=.true.)
-       windpeak=data%swind(1+nint(windpercentile/100.0*data%N))
-       prespeak=data%spres(1+nint(prespercentile/100.0*data%N))
-       call free_data(data)
+       windpeak=data1%swind(1+nint(windpercentile/100.0*data1%N))
+       prespeak=data1%spres(1+nint(prespercentile/100.0*data1%N))
+       call free_data(data1)
! Get the wind, pressure and center positions:
-       data=htcf_get(hs,nh,now-trackwidth/2,now+trackwidth/2,now, &
+       data1=htcf_get(hs,nh,now-trackwidth/2,now+trackwidth/2,now, &
locs=.true.,vals=.false.,sort=.false.)
! Calculate the mean locations and output the track
if(present(windfile)) then
-          iwindlat=nint(meanreal(data%N,data%wlat)*10.0)
-          iwindlon=nint(meanreal(data%N,data%wlon)*10.0)
+          iwindlat=nint(meanreal(data1%N,data1%wlat)*10.0)
+          iwindlon=nint(meanreal(data1%N,data1%wlon)*10.0)
write(windunit,1500) as(1)%basin2,as(1)%storm2,as(1)%ymdh, &
as(1)%method2,as(1)%model4,nint(hour), &
abs(iwindlat),snn(sign(1,iwindlat)), &
@@ -878,8 +878,8 @@
endif
if(present(presfile)) then
-          ipreslat=nint(meanreal(data%N,data%plat)*10.0)
-          ipreslon=nint(meanreal(data%N,data%plon)*10.0)
+          ipreslat=nint(meanreal(data1%N,data1%plat)*10.0)
+          ipreslon=nint(meanreal(data1%N,data1%plon)*10.0)
write(presunit,1500) as(1)%basin2,as(1)%storm2,as(1)%ymdh, &
as(1)%method2,as(1)%model4,nint(hour), &
abs(ipreslat),snn(sign(1,ipreslat)), &
@@ -888,8 +888,8 @@
endif
if(present(centfile)) then
-          icentlat=nint(meanreal(data%N,data%clat)*10.0)
-          icentlon=nint(meanreal(data%N,data%clon)*10.0)
+          icentlat=nint(meanreal(data1%N,data1%clat)*10.0)
+          icentlon=nint(meanreal(data1%N,data1%clon)*10.0)
write(centunit,1500) as(1)%basin2,as(1)%storm2,as(1)%ymdh, &
as(1)%method2,as(1)%model4,nint(hour), &
abs(icentlat),snn(sign(1,icentlat)), &
@@ -897,7 +897,7 @@
windpeak,prespeak
endif
-       call free_data(data)
+       call free_data(data1)
hour=hour+hourstep
enddo hourloop
diff -Nur hwrf-utilities/tools/hwrf_nhc_products/Makefile hwrf-utilities_ok/tools/hwrf_nhc_products/Makefile
--- hwrf-utilities/tools/hwrf_nhc_products/Makefile	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/tools/hwrf_nhc_products/Makefile	2023-07-21 14:51:10.655770420 +0800
@@ -1,7 +1,7 @@
include ../../configure.hwrf
include ../../pure-openmp.inc
-OBJS = products.o
+OBJS = products.o ../hwrf_afos/ATAN2D.o
EXEC = ../../exec/hwrf_nhc_products.exe
LIBS = -L../../libs -lhwrfutil_i4r4 $(NETCDF_LDFLAGS) -lg2 $(LDFLAGS_GRIB2_LIB)
diff -Nur hwrf-utilities/tools/hwrf_nhc_products/products.f90 hwrf-utilities_ok/tools/hwrf_nhc_products/products.f90
--- hwrf-utilities/tools/hwrf_nhc_products/products.f90	2016-08-16 01:45:31.326580000 +0800
+++ hwrf-utilities_ok/tools/hwrf_nhc_products/products.f90	2023-07-21 14:51:10.655770420 +0800
@@ -393,6 +393,17 @@
character*200 :: message
real, parameter :: deg2rad=0.017453292519943295
+    namelist/nhc_products/ &
+         intcvitals, inatcf, outpre, want_stid, want_centername, write_grib, &
+         want_ymdh, mdstatus, coupler_dt, fcst_len, grace_period, &
+         ide_moad, jde_moad, out4wave_out, dlmd_moad, dphd_moad, clat, clon, &
+         nesting_level, parent_nest_ratio, nauxphr,nunint, grads_byteswap, &
+         time_step_fract_num, time_step_fract_den, time_step, inhifreq, &
+         model, submodel, htcf_distcutoff, htcf_hourstep, &
+         header_coupled, header_uncoupled, moad_resolution, resolution_cutoffs, &
+         min_swath_hours, outlist, realtime, inwrfdiag, swath_latpad, &
+         swath_lonpad, swath_latres, swath_lonres
+
outlist='outlist'
mdstatus='MDstatus'
intcvitals='in.tcvitals'
@@ -439,17 +450,7 @@
nunint=3
grads_byteswap=.true.
min_swath_hours=6.0
-    namelist/nhc_products/ &
-         intcvitals, inatcf, outpre, want_stid, want_centername, write_grib, &
-         want_ymdh, mdstatus, coupler_dt, fcst_len, grace_period, &
-         ide_moad, jde_moad, out4wave_out, dlmd_moad, dphd_moad, clat, clon, &
-         nesting_level, parent_nest_ratio, nauxphr,nunint, grads_byteswap, &
-         time_step_fract_num, time_step_fract_den, time_step, inhifreq, &
-         model, submodel, htcf_distcutoff, htcf_hourstep, &
-         header_coupled, header_uncoupled, moad_resolution, resolution_cutoffs, &
-         min_swath_hours, outlist, realtime, inwrfdiag, swath_latpad, &
-         swath_lonpad, swath_latres, swath_lonres
-
+
if(nesting_level>maxdom-1 .or. nesting_level<0) then
308    format("Invalid nesting_level ",I0,": it must be between ",I0," and ",I0," inclusive.")
write(message,308) nesting_level,0,maxdom-1
diff -Nur hwrf-utilities/tools/hwrf_obstobufr/obs_to_bufr_interface.F90 hwrf-utilities_ok/tools/hwrf_obstobufr/obs_to_bufr_interface.F90
--- hwrf-utilities/tools/hwrf_obstobufr/obs_to_bufr_interface.F90	2018-03-04 05:58:08.443753000 +0800
+++ hwrf-utilities_ok/tools/hwrf_obstobufr/obs_to_bufr_interface.F90	2023-07-21 14:51:10.655770420 +0800
@@ -427,8 +427,8 @@
! Check local variable and proceed accordingly
-          if(obs_plev .gt. interp_spline%xa(i) .and. obs_plev .gt.        &
-               & obs_plev .le. interp_spline%xa(i+1)) then
+          if(obs_plev .gt. interp_spline%xa(i) .and. &
+              &  obs_plev .le. interp_spline%xa(i+1)) then
! Define local variables
diff -Nur hwrf-utilities/tools/wgrib2/wgrib2.c hwrf-utilities_ok/tools/wgrib2/wgrib2.c
--- hwrf-utilities/tools/wgrib2/wgrib2.c	2016-03-29 07:29:09.060878000 +0800
+++ hwrf-utilities_ok/tools/wgrib2/wgrib2.c	2023-07-21 14:51:10.655770420 +0800
@@ -88,7 +88,7 @@
const char *end_inv;	/* string to write after end of inventory */
/* current grib location */
-long int pos;
+long int pos1;
unsigned long int len;
int submsg, msg_no, inv_no;
@@ -330,7 +330,7 @@
msg_no = 1;
inv_no = 0;
-    len = pos = 0;
+    len = pos1 = 0;
submsg = 0;
msg = NULL;
@@ -340,14 +340,14 @@
/* if dump mode .. position io stream */
if (input == dump_mode) {
while (msg_no < dump_msg) {
-// //	    if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos, &len, &num_submsgs);
-//	    if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
-//	    else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos, &len, &num_submsgs);
+// //	    if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos1, &len, &num_submsgs);
+//	    if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
+//	    else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos1, &len, &num_submsgs);
-	    msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
+	    msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
if (msg == NULL) fatal_error_i("record %d not found", dump_msg);
-            last_pos = pos;
-            pos += len;
+            last_pos = pos1;
+            pos1 += len;
msg_no++;
}
#ifdef DEBUG
@@ -368,8 +368,8 @@
/* need position and submessage number of message */
if (input == inv_mode || input == dump_mode) {
if (input == inv_mode) {
-                if (rd_inventory(&msg_no,&submsg, &pos, &rd_inventory_input)) break;
-		if (fseek_file(&in_file, pos,SEEK_SET) != 0) fatal_error("fseek_file failed","");
+                if (rd_inventory(&msg_no,&submsg, &pos1, &rd_inventory_input)) break;
+		if (fseek_file(&in_file, pos1,SEEK_SET) != 0) fatal_error("fseek_file failed","");
}
else if (input == dump_mode) {
if (dump_msg == -1) break;
@@ -377,20 +377,20 @@
dump_msg = -1;
}
-            if (pos != last_pos) {
-// //	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos, &len, &num_submsgs);
-//	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
-//		else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos, &len, &num_submsgs);
-	        msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
+            if (pos1 != last_pos) {
+// //	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos1, &len, &num_submsgs);
+//	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
+//		else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos1, &len, &num_submsgs);
+	        msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
if (msg == NULL) {
fatal_error_i("grib message #%d not found", msg_no);
break;
}
-                last_pos = pos;
+                last_pos = pos1;
last_submsg = -1;
}
-            if (pos == last_pos && submsg == last_submsg + 1) {
+            if (pos1 == last_pos && submsg == last_submsg + 1) {
/* read previous submessage */
if (parse_next_msg(sec) != 0) {
fprintf(stderr,"\n*** grib message #%d.%d not found ***\n\n", msg_no, submsg);
@@ -414,20 +414,20 @@
}
else if (input == all_mode) {
if (submsg == 0) {
-// //	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos, &len, &num_submsgs);
-//	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
-//		else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos, &len, &num_submsgs);
-	        msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
+// //	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos1, &len, &num_submsgs);
+//	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
+//		else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos1, &len, &num_submsgs);
+	        msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
if (msg == NULL) break;
submsg = 1;
}
else if (submsg > num_submsgs) {
-		pos += len;
+		pos1 += len;
msg_no++;
-// //	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos, &len, &num_submsgs);
-//	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
-//		else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos, &len, &num_submsgs);
-	        msg = rd_grib2_msg_seq_file(sec, &in_file, &pos, &len, &num_submsgs);
+// //	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq(sec, in, &pos1, &len, &num_submsgs);
+//	        if (in_file.file_type == PIPE) msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
+//		else if (in_file.file_type == DISK) msg = rd_grib2_msg(sec, in, &pos1, &len, &num_submsgs);
+	        msg = rd_grib2_msg_seq_file(sec, &in_file, &pos1, &len, &num_submsgs);
if (msg == NULL) break;
submsg = 1;
}
@@ -702,13 +702,13 @@
use_scale = scaling(sec, &ref, &dec_scale, &bin_scale, &i) == 0;
-	/* make sure msg_no:pos is put in inv_out so that -last will work */
+	/* make sure msg_no:pos1 is put in inv_out so that -last will work */
new_inv_out();	// inv_out[0] = 0;
if (num_submsgs > 1) {
-	    sprintf(inv_out, "%d.%d%s%ld", msg_no, submsg, ":", pos);
+	    sprintf(inv_out, "%d.%d%s%ld", msg_no, submsg, ":", pos1);
}
else {
-	    sprintf(inv_out, "%d%s%ld", msg_no, ":", pos);
+	    sprintf(inv_out, "%d%s%ld", msg_no, ":", pos1);
}
// fprintf(inv_file, "%s", inv_out);
fwrite_file(inv_out, 1, strnlen(inv_out,INV_BUFFER), &inv_file);
@@ -863,3 +863,4 @@
void set_mode(int new_mode) {
mode = new_mode;
}
+
```


4. 执行以下命令打入补丁patch-hwrf-utilities。

```
patch -p0 < ./patch-hwrf-utilities
```


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

```
cd
hwrf-utilities
echo 1 | ./configure
```


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

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


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

```
ls -l exec
/*.exe
```


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