Skip to content

Commit 6961b10

Browse files
committed
Added more safeguards against out-of-bounds temperature to GP inputs.
1 parent df30cf7 commit 6961b10

7 files changed

+66
-15
lines changed

physics/GFS_rrtmgp_pre.F90

+8-4
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ end subroutine GFS_rrtmgp_pre_init
9898
!!
9999
subroutine GFS_rrtmgp_pre_run(nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhswr, fhlwr, &
100100
xlat, xlon, prsl, tgrs, prslk, prsi, qgrs, tsfc, con_eps, con_epsm1, con_fvirt, &
101-
con_epsqs, minGPpres, minGPtemp, raddt, p_lay, t_lay, p_lev, t_lev, tsfg, tsfa, &
102-
qs_lay, q_lay, tv_lay, relhum, tracer, gas_concentrations, errmsg, errflg)
101+
con_epsqs, minGPpres, minGPtemp, maxGPtemp, raddt, p_lay, t_lay, p_lev, t_lev, tsfg, &
102+
tsfa, qs_lay, q_lay, tv_lay, relhum, tracer, gas_concentrations, errmsg, errflg)
103103

104104
! Inputs
105105
integer, intent(in) :: &
@@ -112,6 +112,7 @@ subroutine GFS_rrtmgp_pre_run(nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhswr, f
112112
lslwr ! Call LW radiation
113113
real(kind_phys), intent(in) :: &
114114
minGPtemp, & ! Minimum temperature allowed in RRTMGP.
115+
maxGPtemp, & ! Maximum temperature allowed in RRTMGP.
115116
minGPpres, & ! Minimum pressure allowed in RRTMGP.
116117
fhswr, & ! Frequency of SW radiation call.
117118
fhlwr ! Frequency of LW radiation call.
@@ -208,11 +209,14 @@ subroutine GFS_rrtmgp_pre_run(nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhswr, f
208209
if (t_lay(iCol,iLay) .le. minGPtemp) then
209210
t_lay(iCol,iLay) = minGPtemp + epsilon(minGPtemp)
210211
endif
212+
if (t_lay(iCol,iLay) .ge. maxGPtemp) then
213+
t_lay(iCol,iLay) = maxGPtemp - epsilon(maxGPtemp)
214+
endif
211215
enddo
212216
enddo
213217

214218
! Temperature at layer-interfaces
215-
call cmp_tlev(nCol,nLev,minGPpres,p_lay,t_lay,p_lev,tsfc,t_lev)
219+
call cmp_tlev(nCol,nLev,minGPpres,minGPtemp,maxGPtemp,p_lay,t_lay,p_lev,tsfc,t_lev)
216220

217221
! Compute a bunch of thermodynamic fields needed by the cloud microphysics schemes.
218222
! Relative humidity, saturation mixing-ratio, vapor mixing-ratio, virtual temperature,
@@ -273,7 +277,7 @@ subroutine GFS_rrtmgp_pre_run(nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhswr, f
273277
! #######################################################################################
274278
! Setup surface ground temperature and ground/air skin temperature if required.
275279
! #######################################################################################
276-
tsfg(1:NCOL) = tsfc(1:NCOL)
280+
tsfg(1:NCOL) = t_lev(1:NCOL,iSFC)
277281
tsfa(1:NCOL) = t_lay(1:NCOL,iSFC)
278282

279283
end subroutine GFS_rrtmgp_pre_run

physics/GFS_rrtmgp_pre.meta

+9
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@
239239
kind = kind_phys
240240
intent = in
241241
optional = F
242+
[maxGPtemp]
243+
standard_name = maximum_temperature_in_RRTMGP
244+
long_name = maximum temperature allowed in RRTMGP
245+
units = K
246+
dimensions = ()
247+
type = real
248+
kind = kind_phys
249+
intent = in
250+
optional = F
242251
[raddt]
243252
standard_name = time_step_for_radiation
244253
long_name = radiation time step

physics/dcyc2.f

+5-4
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ subroutine dcyc2t3_run &
178178
& sfcnirbmu,sfcnirdfu,sfcvisbmu,sfcvisdfu, &
179179
& sfcnirbmd,sfcnirdfd,sfcvisbmd,sfcvisdfd, &
180180
& im, levs, deltim, fhswr, &
181-
& dry, icy, wet, &
181+
& dry, icy, wet, minGPtemp, maxGPtemp, &
182182
& minGPpres, use_LW_jacobian, sfculw, fluxlwUP_jac, &
183183
& t_lay, t_lev, p_lay, p_lev, flux2D_lwUP, flux2D_lwDOWN, &
184184
& pert_radtend, do_sppt,ca_global, &
@@ -216,7 +216,8 @@ subroutine dcyc2t3_run &
216216
logical, intent(in) :: use_LW_jacobian, pert_radtend
217217
logical, intent(in) :: do_sppt,ca_global
218218
real(kind=kind_phys), intent(in) :: solhr, slag, cdec, sdec, &
219-
& deltim, fhswr, minGPpres
219+
& deltim, fhswr, minGPpres, &
220+
& minGPtemp, maxGPtemp
220221

221222
real(kind=kind_phys), dimension(:), intent(in) :: &
222223
& sinlat, coslat, xlon, coszen, tf, tsflw, sfcdlw, &
@@ -372,8 +373,8 @@ subroutine dcyc2t3_run &
372373
!
373374
! Compute temperatute at level interfaces.
374375
!
375-
call cmp_tlev(im, levs, minGPpres, p_lay, t_lay, p_lev, tsfc, &
376-
& t_lev2)
376+
call cmp_tlev(im, levs, minGPpres, minGPtemp, maxGPtemp, p_lay,&
377+
& t_lay, p_lev, tsfc, t_lev2)
377378

378379
!
379380
! Adjust up/downward fluxes (at layer interfaces).

physics/dcyc2.meta

+18
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,24 @@
353353
type = logical
354354
intent = in
355355
optional = F
356+
[minGPtemp]
357+
standard_name = minimum_temperature_in_RRTMGP
358+
long_name = minimum temperature allowed in RRTMGP
359+
units = K
360+
dimensions = ()
361+
type = real
362+
kind = kind_phys
363+
intent = in
364+
optional = F
365+
[maxGPtemp]
366+
standard_name = maximum_temperature_in_RRTMGP
367+
long_name = maximum temperature allowed in RRTMGP
368+
units = K
369+
dimensions = ()
370+
type = real
371+
kind = kind_phys
372+
intent = in
373+
optional = F
356374
[minGPpres]
357375
standard_name = minimum_pressure_in_RRTMGP
358376
long_name = minimum pressure allowed in RRTMGP

physics/radiation_tools.F90

+14-6
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@ module radiation_tools
22
use machine, only: &
33
kind_phys ! Working type
44
implicit none
5-
6-
real(kind_phys) :: &
7-
rrtmgp_minP, & ! Minimum pressure allowed in RRTMGP
8-
rrtmgp_minT ! Minimum temperature allowed in RRTMGP
95
contains
106

117
! #########################################################################################
128
! #########################################################################################
13-
subroutine cmp_tlev(nCol,nLev,minP,p_lay,t_lay,p_lev,tsfc,t_lev)
9+
subroutine cmp_tlev(nCol,nLev,minP,minT,maxT,p_lay,t_lay,p_lev,tsfc,t_lev)
1410
! Inputs
1511
integer, intent(in) :: &
1612
nCol,nLev
1713
real(kind_phys),intent(in) :: &
18-
minP
14+
minP,minT,maxT
1915
real(kind_phys),dimension(nCol),intent(in) :: &
2016
tsfc
2117
real(kind_phys),dimension(nCol,nLev),intent(in) :: &
@@ -78,6 +74,18 @@ subroutine cmp_tlev(nCol,nLev,minP,p_lay,t_lay,p_lev,tsfc,t_lev)
7874
t_lev(1:NCOL,iTOA+1) = t_lay(1:NCOL,iTOA)
7975
endif
8076

77+
! Bound temperature at layer interfaces
78+
do iCol=1,NCOL
79+
do iLay=1,nLev+1
80+
if (t_lev(iCol,iLay) .le. minT) then
81+
t_lev(iCol,iLay) = minT + epsilon(minT)
82+
endif
83+
if (t_lev(iCol,iLay) .ge. maxT) then
84+
t_lev(iCol,iLay) = maxT - epsilon(maxT)
85+
endif
86+
enddo
87+
enddo
88+
8189
end subroutine cmp_tlev
8290

8391
! #########################################################################################

physics/rrtmgp_lw_gas_optics.F90

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module rrtmgp_lw_gas_optics
7676
!! \htmlinclude rrtmgp_lw_gas_optics_init.html
7777
!!
7878
subroutine rrtmgp_lw_gas_optics_init(rrtmgp_root_dir, rrtmgp_lw_file_gas, mpicomm, &
79-
mpirank, mpiroot, gas_concentrations, minGPpres, minGPtemp, errmsg, errflg)
79+
mpirank, mpiroot, gas_concentrations, minGPpres, minGPtemp, maxGPtemp, errmsg, errflg)
8080

8181
! Inputs
8282
type(ty_gas_concs), intent(inout) :: &
@@ -96,6 +96,7 @@ subroutine rrtmgp_lw_gas_optics_init(rrtmgp_root_dir, rrtmgp_lw_file_gas, mpicom
9696
errflg ! CCPP error code
9797
real(kind_phys), intent(out) :: &
9898
minGPtemp, & ! Minimum temperature allowed by RRTMGP.
99+
maxGPtemp, & ! Maximum temperature allowed by RRTMG.
99100
minGPpres ! Minimum pressure allowed by RRTMGP.
100101

101102
! Local variables
@@ -450,6 +451,7 @@ subroutine rrtmgp_lw_gas_optics_init(rrtmgp_root_dir, rrtmgp_lw_file_gas, mpicom
450451
! temperature (GFS_rrtmgp_pre.F90)
451452
minGPpres = lw_gas_props%get_press_min()
452453
minGPtemp = lw_gas_props%get_temp_min()
454+
maxGPtemp = lw_gas_props%get_temp_max()
453455

454456
end subroutine rrtmgp_lw_gas_optics_init
455457

physics/rrtmgp_lw_gas_optics.meta

+9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@
9292
kind = kind_phys
9393
intent = out
9494
optional = F
95+
[maxGPtemp]
96+
standard_name = maximum_temperature_in_RRTMGP
97+
long_name = maximum temperature allowed in RRTMGP
98+
units = K
99+
dimensions = ()
100+
type = real
101+
kind = kind_phys
102+
intent = out
103+
optional = F
95104

96105
########################################################################
97106
[ccpp-arg-table]

0 commit comments

Comments
 (0)