Skip to content

Commit

Permalink
Revised MM5 surface layer - Limit zolri convergence loop to a maximum…
Browse files Browse the repository at this point in the history
… of 10 iterations (#1864)

TYPE: bug fix

KEYWORDS: Revised MM5 surface layer

SOURCE: Samm Elliott (TempoQuest Inc.)

DESCRIPTION OF CHANGES:
Problem: see #1859

Solution:
Limit the maximum iterations of the zolri loop to 10 if the solution does not converge due to fp roundoff error.

ISSUE:
Fixes #1859

LIST OF MODIFIED FILES:
phys/module_sf_sfclayrev.F

TESTS CONDUCTED:
Fixed the issue for the test case discussed in #1859 for AceCAST (GPU-accelerated version of WRF developed by TQI). The same case produced B4B results on CPU (when compared to a run using 755fc49).

RELEASE NOTE: Fixed an issue in Revised MM5 (sf_sfclay_physics=1) where the model could potentially encounter an infinite loop. In specific conditions floating point roundoff errors were preventing a convergence condition from ever being met.
  • Loading branch information
sael9740 committed May 23, 2023
1 parent 21c7214 commit 3d2c5c9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phys/module_sf_sfclayrev.F
Expand Up @@ -1212,7 +1212,9 @@ function zolri(ri,z,z0)
!
fx1=zolri2(x1,ri,z,z0)
fx2=zolri2(x2,ri,z,z0)
iter = 0
Do While (abs(x1 - x2) > 0.01)
if (iter .eq. 10) return
! check added for potential divide by zero (2019/11)
if(fx1.eq.fx2)return
if(abs(fx2).lt.abs(fx1))then
Expand All @@ -1225,6 +1227,7 @@ function zolri(ri,z,z0)
zolri=x2
endif
!
iter = iter + 1
enddo
!
Expand Down

0 comments on commit 3d2c5c9

Please sign in to comment.