Skip to content

Commit

Permalink
Merge pull request #163 from SamuelTrahanNOAA/RRFS_dev_debug
Browse files Browse the repository at this point in the history
RUC LSM precision workaround
  • Loading branch information
SamuelTrahanNOAA authored Sep 28, 2022
2 parents b70c385 + fe57174 commit 1985ee1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions physics/lsm_ruc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,20 @@ subroutine lsm_ruc_run & ! inputs
z0_lnd(i,j) = z0rl_lnd(i)/100.
znt_lnd(i,j) = z0rl_lnd(i)/100.

! Workaround needed for subnormal numbers. This should be
! done after all other sanity checks, in case a sanity check
! results in subnormal numbers.
!
! This bug was caught by the UFS gfortran debug-mode
! regression tests, and the fix is necessary to pass those
! tests.
if(abs(snowh_lnd(i,j))<1e-20) then
snowh_lnd(i,j)=0
endif
if(abs(sneqv_lnd(i,j))<1e-20) then
sneqv_lnd(i,j)=0
endif

!if (debug_print) then
!-- diagnostics for a land test point with known lat/lon
if (kdt < 10) then
Expand Down Expand Up @@ -1417,6 +1431,19 @@ subroutine lsm_ruc_run & ! inputs
z0_ice(i,j) = z0rl_ice(i)/100.
znt_ice(i,j) = z0rl_ice(i)/100.

! Workaround needed for subnormal numbers. This should be
! done after all other sanity checks, in case a sanity check
! results in subnormal numbers.
!
! Although this bug has not been triggered yet, it is expected
! to be, like the _lnd variants many lines up from here.
if(abs(snowh_ice(i,j))<1e-20) then
snowh_ice(i,j)=0
endif
if(abs(sneqv_ice(i,j))<1e-20) then
sneqv_ice(i,j)=0
endif

!> - Call RUC LSM lsmruc() for ice.
call lsmruc(xlat_d(i),xlon_d(i), &
& delt, flag_init, lsm_cold_start, kdt, iter, nsoil, &
Expand Down

0 comments on commit 1985ee1

Please sign in to comment.