Skip to content

Commit 94c05f7

Browse files
ldfowler58mgduda
authored andcommitted
* In ./src/core_atmosphere/physics/physics_mmm/sf_sfclayrev.F, limit the maximum
iterations of the zolri loop to 10 if the solution does not converge due to fp roundoff error in function zolri. This zolri convergence limit was added to function zolri in module_sf_sfclayrev.F in the WRF release 4.5.1.
1 parent 88f7494 commit 94c05f7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/core_atmosphere/physics/physics_mmm/sf_sfclayrev.F

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,11 @@ end subroutine sf_sfclayrev_run
964964
!=================================================================================================================
965965
real(kind=kind_phys) function zolri(ri,z,z0)
966966
real(kind=kind_phys),intent(in):: ri,z,z0
967+
968+
integer:: iter
967969
real(kind=kind_phys):: fx1,fx2,x1,x2
968970

971+
969972
if(ri.lt.0.)then
970973
x1=-5.
971974
x2=0.
@@ -976,7 +979,9 @@ real(kind=kind_phys) function zolri(ri,z,z0)
976979

977980
fx1=zolri2(x1,ri,z,z0)
978981
fx2=zolri2(x2,ri,z,z0)
982+
iter = 0
979983
do while (abs(x1 - x2) > 0.01)
984+
if (iter .eq. 10) return
980985
!check added for potential divide by zero (2019/11)
981986
if(fx1.eq.fx2)return
982987
if(abs(fx2).lt.abs(fx1))then
@@ -988,6 +993,7 @@ real(kind=kind_phys) function zolri(ri,z,z0)
988993
fx2=zolri2(x2,ri,z,z0)
989994
zolri=x2
990995
endif
996+
iter = iter + 1
991997
enddo
992998

993999
return

0 commit comments

Comments
 (0)