Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 74 additions & 109 deletions sorc/ncep_post.fd/SURFCE.f
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,27 @@ SUBROUTINE SURFCE
real, allocatable, dimension(:,:,:) :: sleet, rain, freezr, snow
! real, dimension(im,jm,nalg) :: sleet, rain, freezr, snow
real, allocatable, dimension(:,:) :: ylat, xlon
real, allocatable, dimension(:) :: msclon, msclat
!GSD
REAL totprcp, snowratio,t2,rainl

!
integer NLON,NLAT,NTOT,var_scale
integer NLON,NLAT,NTOT
integer I,J,IWX,ITMAXMIN,IFINCR,ISVALUE,II,JJ, &
ITPREC,ITSRFC,L,LS,IVEG,LLMH, &
IVG,IRTN,ISEED, icat, cnt_snowratio(10),icnt_snow_rain_mixed, &
NX,NY,NZ,MSCNLON,MSCNLAT,MSCNLEV,HEIGHT
NX,NY,NZ,MSCNLON,MSCNLAT,HEIGHT

real RDTPHS,TLOW,TSFCK,QSAT,DTOP,DBOT,SNEQV,RRNUM,SFCPRS,SFCQ, &
RC,SFCTMP,SNCOVR,FACTRS,SOLAR, s,tk,tl,w,t2c,dlt,APE, &
qv,e,dwpt,dum1,dum2,dum3,dum1s,dum3s,dum21,dum216,es, &
RLONMIN,RLATMAX,RLAT,RLON
RLONMIN,RLATMAX

real*8 RDX,RDY,DLON,DLAT,LONMIN,LATMIN,LONMAX,LATMAX
real*8 RDX,RDY

character(len=256) :: ffgfile

logical file_exists

logical, parameter :: debugprint = .false.

!****************************************************************************
Expand Down Expand Up @@ -3674,33 +3675,24 @@ SUBROUTINE SURFCE
! thresholds
IF (IGET(913).GT.0) THEN
ffgfile='ffg_01h.grib2'
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
var_scale=1
mscNlon=nx
mscNlat=ny
mscNlev=nz
dlon=rdx
dlat=rdy
lonMin=rlonmin
lonMax=lonMin+dlon*(mscNlon-1)
latMax=rlatmax
latMin=latMax-dlat*(mscNlat-1)
if (.not. allocated(msclon)) then
allocate(msclon(mscNlon))
allocate(msclat(mscNlat))
allocate(mscValue(mscNlon,mscNlat))
INQUIRE(FILE=ffgfile, EXIST=file_exists)
if (file_exists) then
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
mscNlon=nx
mscNlat=ny
if (.not. allocated(mscValue)) then
allocate(mscValue(mscNlon,mscNlat))
endif
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
else
write(*,*) 'WARNING: 1h FFG file not available'
! In this case, set mscValue to a large number
mscValue = AVGPREC_CONT*FLOAT(IFHR)*3600.*10000./DTQ2
endif
DO i=1,mscNlon
msclon(i)=lonMin+(i-1)*dlon
ENDDO
DO i=1,mscNlat
msclat(i)=latMin+(i-1)*dlat
ENDDO
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
write(*,*) '1H FFG MAX, MIN:', &
maxval(mscValue),minval(mscValue)
! write(*,*) '1H FFG MAX, MIN:', &
! maxval(mscValue),minval(mscValue)
ID(1:25) = 0
ITPREC = NINT(TPREC)
!mp
Expand Down Expand Up @@ -3766,33 +3758,24 @@ SUBROUTINE SURFCE
ENDIF
IF (IGET(914).GT.0) THEN
ffgfile='ffg_03h.grib2'
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
var_scale=1
mscNlon=nx
mscNlat=ny
mscNlev=nz
dlon=rdx
dlat=rdy
lonMin=rlonmin
lonMax=lonMin+dlon*(mscNlon-1)
latMax=rlatmax
latMin=latMax-dlat*(mscNlat-1)
if (.not. allocated(msclon)) then
allocate(msclon(mscNlon))
allocate(msclat(mscNlat))
allocate(mscValue(mscNlon,mscNlat))
INQUIRE(FILE=ffgfile, EXIST=file_exists)
if (file_exists) then
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
mscNlon=nx
mscNlat=ny
if (.not. allocated(mscValue)) then
allocate(mscValue(mscNlon,mscNlat))
endif
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
else
write(*,*) 'WARNING: 3h FFG file not available'
! In this case, set mscValue to a large number
mscValue = AVGPREC*FLOAT(IFHR)*3600.*10000./DTQ2
endif
DO i=1,mscNlon
msclon(i)=lonMin+(i-1)*dlon
ENDDO
DO i=1,mscNlat
msclat(i)=latMin+(i-1)*dlat
ENDDO
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
write(*,*) '3H FFG MAX, MIN:', &
maxval(mscValue),minval(mscValue)
! write(*,*) '3H FFG MAX, MIN:', &
! maxval(mscValue),minval(mscValue)
ID(1:25) = 0
ITPREC = NINT(TPREC)
!mp
Expand Down Expand Up @@ -3851,33 +3834,24 @@ SUBROUTINE SURFCE
ENDIF
IF (IGET(915).GT.0) THEN
ffgfile='ffg_06h.grib2'
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
var_scale=1
mscNlon=nx
mscNlat=ny
mscNlev=nz
dlon=rdx
dlat=rdy
lonMin=rlonmin
lonMax=lonMin+dlon*(mscNlon-1)
latMax=rlatmax
latMin=latMax-dlat*(mscNlat-1)
if (.not. allocated(msclon)) then
allocate(msclon(mscNlon))
allocate(msclat(mscNlat))
allocate(mscValue(mscNlon,mscNlat))
INQUIRE(FILE=ffgfile, EXIST=file_exists)
if (file_exists) then
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
mscNlon=nx
mscNlat=ny
if (.not. allocated(mscValue)) then
allocate(mscValue(mscNlon,mscNlat))
endif
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
else
write(*,*) 'WARNING: 6h FFG file not available'
! In this case, set mscValue to a large number
mscValue = AVGPREC*FLOAT(IFHR)*3600.*10000./DTQ2
endif
DO i=1,mscNlon
msclon(i)=lonMin+(i-1)*dlon
ENDDO
DO i=1,mscNlat
msclat(i)=latMin+(i-1)*dlat
ENDDO
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
write(*,*) '6H FFG MAX, MIN:', &
maxval(mscValue),minval(mscValue)
! write(*,*) '6H FFG MAX, MIN:', &
! maxval(mscValue),minval(mscValue)
ID(1:25) = 0
ITPREC = NINT(TPREC)
!mp
Expand Down Expand Up @@ -3935,33 +3909,24 @@ SUBROUTINE SURFCE
ENDIF
IF (IGET(916).GT.0) THEN
ffgfile='ffg_12h.grib2'
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
var_scale=1
mscNlon=nx
mscNlat=ny
mscNlev=nz
dlon=rdx
dlat=rdy
lonMin=rlonmin
lonMax=lonMin+dlon*(mscNlon-1)
latMax=rlatmax
latMin=latMax-dlat*(mscNlat-1)
if (.not. allocated(msclon)) then
allocate(msclon(mscNlon))
allocate(msclat(mscNlat))
allocate(mscValue(mscNlon,mscNlat))
INQUIRE(FILE=ffgfile, EXIST=file_exists)
if (file_exists) then
call read_grib2_head(ffgfile,nx,ny,nz,rlonmin,rlatmax,&
rdx,rdy)
mscNlon=nx
mscNlat=ny
if (.not. allocated(mscValue)) then
allocate(mscValue(mscNlon,mscNlat))
endif
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
else
write(*,*) 'WARNING: 12h FFG file not available'
! In this case, set mscValue to a large number
mscValue = AVGPREC*FLOAT(IFHR)*3600.*10000./DTQ2
endif
DO i=1,mscNlon
msclon(i)=lonMin+(i-1)*dlon
ENDDO
DO i=1,mscNlat
msclat(i)=latMin+(i-1)*dlat
ENDDO
ntot = nx*ny
call read_grib2_sngle(ffgfile,ntot,height,mscValue)
write(*,*) '12H FFG MAX, MIN:', &
maxval(mscValue),minval(mscValue)
! write(*,*) '12H FFG MAX, MIN:', &
! maxval(mscValue),minval(mscValue)
ID(1:25) = 0
ITPREC = NINT(TPREC)
!mp
Expand Down
21 changes: 21 additions & 0 deletions sorc/ncep_post.fd/grib2_module.f
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,17 @@ subroutine read_grib2_head(filenameG2,nx,ny,nz,rlonmin,rlatmax,rdx,rdy)
rlonmin = gfld%igdtmpl(13)/scale_factor
! write(*,*) 'nx,ny=',nx,ny
! write(*,*) 'dx,dy=',rdx,rdy
! write(*,*) 'lat1,lon1=',rlatmax,rlonmin
else if (gfld%igdtnum.eq.1) then ! Rotated Lat Lon Grid (RRFS_NA)
nx = gfld%igdtmpl(8)
ny = gfld%igdtmpl(9)
nz = 1
rdx = gfld%igdtmpl(17)/scale_factor
rdy = gfld%igdtmpl(18)/scale_factor
rlatmax = gfld%igdtmpl(12)/scale_factor
rlonmin = gfld%igdtmpl(13)/scale_factor
! write(*,*) 'nx,ny=',nx,ny
! write(*,*) 'dx,dy=',rdx,rdy
! write(*,*) 'lat1,lon1=',rlatmax,rlonmin
else if (gfld%igdtnum.eq.30) then ! Lambert Conformal Grid (HRRR)
nx = gfld%igdtmpl(8)
Expand Down Expand Up @@ -1249,6 +1260,16 @@ subroutine read_grib2_sngle(filenameG2,ntot,height,var)
! write(*,*) 'nx,ny=',nx,ny
! write(*,*) 'dx,dy=',dx,dy
! write(*,*) 'lat1,lon1=',lat1,lon1
else if (gfld%igdtnum.eq.1) then ! Rotated Lat Lon Grid (RRFS_NA)
nx = gfld%igdtmpl(8)
ny = gfld%igdtmpl(9)
dx = gfld%igdtmpl(17)/scale_factor
dy = gfld%igdtmpl(18)/scale_factor
lat1 = gfld%igdtmpl(12)/scale_factor
lon1 = gfld%igdtmpl(13)/scale_factor
! write(*,*) 'nx,ny=',nx,ny
! write(*,*) 'dx,dy=',rdx,rdy
! write(*,*) 'lat1,lon1=',rlatmax,rlonmin
else if (gfld%igdtnum.eq.30) then ! Lambert Conformal Grid (HRRR)
nx = gfld%igdtmpl(8)
ny = gfld%igdtmpl(9)
Expand Down