Skip to content

Commit

Permalink
Fix bug in boundary_k_range if hbl > htot
Browse files Browse the repository at this point in the history
In cases where the boundary layer depth is larger than the column thickness,
the returned indices of the layer would point to the top of the column. This
behavior is fixed such that if hbl > htot, k_bot and z_bot point to the bottom
of the column.
  • Loading branch information
Andrew Shao committed Jan 10, 2020
1 parent 1ae069b commit 31d2941
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tracer/MOM_lateral_boundary_diffusion.F90
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ subroutine boundary_k_range(boundary, nk, h, hbl, k_top, zeta_top, k_bot, zeta_b
k_bot = 1
zeta_bot = 0.
if (hbl == 0.) return
if ( hbl >= htot ); then
k_bot = nk
zeta_bot = 0.
return
endif
do k=1,nk
htot = htot + h(k)
if ( htot >= hbl) then
Expand All @@ -354,10 +359,15 @@ subroutine boundary_k_range(boundary, nk, h, hbl, k_top, zeta_top, k_bot, zeta_b
zeta_bot = 1.
htot = 0.
if (hbl == 0.) return
if (hbl >= htot) then
k_top = 1
zeta_top = 0.
return
endif
do k=nk,1,-1
htot = htot + h(k)
if (htot >= hbl) then
k_top = k
k_top = k
zeta_top = 1 - (htot - hbl)/h(k)
return
endif
Expand Down

0 comments on commit 31d2941

Please sign in to comment.