Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
1. index of zw_iface should be (k+1) instead of (k)
cvmix_kpp_compute_OBL_depth_low()
2. there are some checks for OBL_depth (is it bigger than minOBLdepth? is it
smaller than maxOBLdepth?) that should be called regardless of value of
lStokesMOST, but they were only in the lStokesMOST = .false. branch of a
conditional

Also, I removed a "if BLdepth > 0" check in cvmix_kpp_compute_StokesXi()
because BLdepth should always be positive given the fixes above.
  • Loading branch information
mnlevy1981 committed Jan 23, 2025
1 parent 369a285 commit 529b922
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/shared/cvmix_kpp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ subroutine cvmix_kpp_compute_OBL_depth_low(Ri_bulk, zw_iface, OBL_depth, &
if (k.eq.0) then
OBL_limit = abs(zt_cntr(1))
elseif (k.lt.kRi) then
OBL_limit = min( OBL_limit, abs(zw_iface(k)) )
OBL_limit = min( OBL_limit, abs(zw_iface(k+1)) )
end if

else
Expand All @@ -1693,7 +1693,6 @@ subroutine cvmix_kpp_compute_OBL_depth_low(Ri_bulk, zw_iface, OBL_depth, &

! (4) OBL_depth must be at or above OBL_limit -zt_cntr(1) < OBL_depth < OBL_limit
OBL_depth = min(OBL_depth, OBL_limit )
kOBL_depth = cvmix_kpp_compute_kOBL_depth(zw_iface, zt_cntr, OBL_depth)

else ! not Stokes_MOST

Expand Down Expand Up @@ -1765,13 +1764,13 @@ subroutine cvmix_kpp_compute_OBL_depth_low(Ri_bulk, zw_iface, OBL_depth, &
! because we know OBL_depth will equal OBL_limit?
OBL_depth = min(OBL_depth, OBL_limit)
end if
end if ! lStokesMOST

OBL_depth = max(OBL_depth, CVmix_kpp_params_in%minOBLdepth)
if (CVmix_kpp_params_in%maxOBLdepth.gt.cvmix_zero) &
OBL_depth = min(OBL_depth, CVmix_kpp_params_in%maxOBLdepth)
kOBL_depth = cvmix_kpp_compute_kOBL_depth(zw_iface, zt_cntr, OBL_depth)
OBL_depth = max(OBL_depth, CVmix_kpp_params_in%minOBLdepth)
if (CVmix_kpp_params_in%maxOBLdepth.gt.cvmix_zero) &
OBL_depth = min(OBL_depth, CVmix_kpp_params_in%maxOBLdepth)
kOBL_depth = cvmix_kpp_compute_kOBL_depth(zw_iface, zt_cntr, OBL_depth)

end if ! lStokesMOST

!EOC

Expand Down Expand Up @@ -3460,15 +3459,9 @@ subroutine cvmix_kpp_compute_StokesXi (zi, zk, kSL, SLDepth, &
! SLdepth can be between cell interfaces kSL and kSL+1
delH = min( max(cvmix_zero, SLdepth - dtop), (zi(ktmp) - zi(ktmp+1) ) )
dbot = MIN( dtop + delH , SLdepth)
if (BLdepth .gt. cvmix_zero) then
sigbot = dbot / BLdepth
Gbot = cvmix_kpp_composite_shape(sigbot)
TauMAG = ustar * ustar * Gbot / sigbot
else
sigbot = cvmix_zero
Gbot = cvmix_zero
TauMAG = cvmix_zero
endif
sigbot = dbot / BLdepth
Gbot = cvmix_kpp_composite_shape(sigbot)
TauMAG = ustar * ustar * Gbot / sigbot
delU = uE(ktmp) - uE(ktmp+1)
delV = vE(ktmp) - vE(ktmp+1)
Omega_E2x= atan2( delV , delU )
Expand Down

0 comments on commit 529b922

Please sign in to comment.