Skip to content

Commit 884fbe7

Browse files
authored
Fix for divide-by-zero problem in Shin-Hong PBL (#1698)
TYPE: bug fix KEYWORDS: Shin-Hong PBL divide by zero SOURCE: internal, reported by CWB, Taiwan DESCRIPTION OF CHANGES: Problem: Rare case of divide by zero. Solution: Avoided by use of if test. Note that an algorithm fix may be needed later. LIST OF MODIFIED FILES: M phys/module_bl_shinhong.F TESTS CONDUCTED: compile only (should fix problem) The Jenkins tests are all passing. RELEASE NOTE: minor bug-fix in Shin-Hong PBL to avoid rare divide by zero
1 parent 2be1982 commit 884fbe7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

phys/module_bl_shinhong.F

+8-1
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ subroutine shinhong2d(j,ux,vx,tx,qx,p2d,p2di,pi2d, &
440440
real :: prnumfac,bfx0,hfx0,qfx0,delb,dux,dvx, &
441441
dsdzu,dsdzv,wm3,dthx,dqx,wspd10,ross,tem1,dsig,tvcon,conpr, &
442442
prfac,prfac2,phim8z
443+
real :: cenlfrac
443444
!
444445
integer, dimension( its:ite ) :: kpbl
445446
real, dimension( its:ite ) :: hol
@@ -972,7 +973,13 @@ subroutine shinhong2d(j,ux,vx,tx,qx,p2d,p2di,pi2d, &
972973
rigs(i) = rigsmax
973974
endif
974975
rigs(i) = max(min(rigs(i), rigsmax),rimin)
975-
enlfrac2(i) = max(min(wm3/wstar3(i)/(1.+cpent/rigs(i)),entfmax), entfmin)
976+
if((rigs(i).gt.0) .and. (abs(rigs(i)+cpent) .le. 1.e-6))then
977+
cenlfrac = entfmax
978+
else
979+
cenlfrac = rigs(i)/(rigs(i)+cpent)
980+
endif
981+
cenlfrac = min(cenlfrac,entfmax)
982+
enlfrac2(i) = max(wm3/wstar3(i)*cenlfrac, entfmin)
976983
enlfrac2(i) = enlfrac2(i)*enlfrac
977984
endif
978985
enddo

0 commit comments

Comments
 (0)