@@ -30,6 +30,8 @@ module MOM_set_diffusivity
3030use MOM_CVMix_ddiff, only : compute_ddiff_coeffs
3131use MOM_bkgnd_mixing, only : calculate_bkgnd_mixing, bkgnd_mixing_init, bkgnd_mixing_cs
3232use MOM_bkgnd_mixing, only : bkgnd_mixing_end, sfc_bkgnd_mixing
33+ use MOM_open_boundary, only : ocean_OBC_type, OBC_segment_type, OBC_NONE
34+ use MOM_open_boundary, only : OBC_DIRECTION_E, OBC_DIRECTION_W, OBC_DIRECTION_N, OBC_DIRECTION_S
3335use MOM_string_functions, only : uppercase
3436use MOM_unit_scaling, only : unit_scale_type
3537use MOM_variables, only : thermo_var_ptrs, vertvisc_type, p3d
@@ -1636,7 +1638,7 @@ end subroutine add_MLrad_diffusivity
16361638
16371639! > This subroutine calculates several properties related to bottom
16381640! ! boundary layer turbulence.
1639- subroutine set_BBL_TKE (u , v , h , fluxes , visc , G , GV , US , CS )
1641+ subroutine set_BBL_TKE (u , v , h , fluxes , visc , G , GV , US , CS , OBC )
16401642 type (ocean_grid_type), intent (in ) :: G ! < The ocean's grid structure
16411643 type (verticalGrid_type), intent (in ) :: GV ! < The ocean's vertical grid structure
16421644 type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
@@ -1650,6 +1652,7 @@ subroutine set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS)
16501652 type (vertvisc_type), intent (in ) :: visc ! < Structure containing vertical viscosities, bottom
16511653 ! ! boundary layer properies, and related fields.
16521654 type (set_diffusivity_CS), pointer :: CS ! < Diffusivity control structure
1655+ type (ocean_OBC_type), optional , pointer :: OBC ! < Open boundaries control structure.
16531656
16541657 ! This subroutine calculates several properties related to bottom
16551658 ! boundary layer turbulence.
@@ -1674,6 +1677,15 @@ subroutine set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS)
16741677
16751678 logical :: domore, do_i(SZI_(G))
16761679 integer :: i, j, k, is, ie, js, je, nz
1680+ logical :: local_open_u_BC, local_open_v_BC
1681+
1682+ local_open_u_BC = .false.
1683+ local_open_v_BC = .false.
1684+ if (present (OBC)) then ; if (associated (OBC)) then
1685+ local_open_u_BC = OBC% open_u_BCs_exist_globally
1686+ local_open_v_BC = OBC% open_v_BCs_exist_globally
1687+ endif ; endif
1688+
16771689 is = G% isc ; ie = G% iec ; js = G% jsc ; je = G% jec ; nz = G% ke
16781690
16791691 if (.not. associated (CS)) call MOM_error(FATAL," set_BBL_TKE: " // &
@@ -1691,10 +1703,8 @@ subroutine set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS)
16911703
16921704 cdrag_sqrt = sqrt (CS% cdrag)
16931705
1694- ! $OMP parallel default(none) shared(cdrag_sqrt,is,ie,js,je,nz,visc,CS,G,GV,US,vstar,h,v, &
1695- ! $OMP v2_bbl,u) &
1696- ! $OMP private(do_i,vhtot,htot,domore,hvel,uhtot,ustar,u2_bbl)
1697- ! $OMP do
1706+ ! $OMP parallel default(shared) private(do_i,vhtot,htot,domore,hvel,uhtot,ustar,u2_bbl)
1707+ ! $OMP do
16981708 do J= js-1 ,je
16991709 ! Determine ustar and the square magnitude of the velocity in the
17001710 ! bottom boundary layer. Together these give the TKE source and
@@ -1708,7 +1718,20 @@ subroutine set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS)
17081718 do k= nz,1 ,- 1
17091719 domore = .false.
17101720 do i= is,ie ; if (do_i(i)) then
1711- hvel = 0.5 * GV% H_to_Z* (h(i,j,k) + h(i,j+1 ,k))
1721+ if (local_open_v_BC) then
1722+ if (OBC% segment(OBC% segnum_v(i,J))% open ) then
1723+ if (OBC% segment(OBC% segnum_v(i,J))% direction == OBC_DIRECTION_N) then
1724+ hvel = GV% H_to_Z* h(i,j,k)
1725+ else
1726+ hvel = GV% H_to_Z* h(i,j+1 ,k)
1727+ endif
1728+ else
1729+ hvel = 0.5 * GV% H_to_Z* (h(i,j,k) + h(i,j+1 ,k))
1730+ endif
1731+ else
1732+ hvel = 0.5 * GV% H_to_Z* (h(i,j,k) + h(i,j+1 ,k))
1733+ endif
1734+
17121735 if ((htot(i) + hvel) >= visc% bbl_thick_v(i,J)) then
17131736 vhtot(i) = vhtot(i) + (visc% bbl_thick_v(i,J) - htot(i))* v(i,J,k)
17141737 htot(i) = visc% bbl_thick_v(i,J)
@@ -1727,7 +1750,7 @@ subroutine set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS)
17271750 v2_bbl(i,J) = 0.0
17281751 endif ; enddo
17291752 enddo
1730- ! $OMP do
1753+ ! $OMP do
17311754 do j= js,je
17321755 do I= is-1 ,ie ; if ((G% mask2dCu(I,j) > 0.5 ) .and. (cdrag_sqrt* visc% bbl_thick_u(I,j) > 0.0 )) then
17331756 do_i(I) = .true. ; uhtot(I) = 0.0 ; htot(I) = 0.0
@@ -1737,7 +1760,20 @@ subroutine set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS)
17371760 endif ; enddo
17381761 do k= nz,1 ,- 1 ; domore = .false.
17391762 do I= is-1 ,ie ; if (do_i(I)) then
1740- hvel = 0.5 * GV% H_to_Z* (h(i,j,k) + h(i+1 ,j,k))
1763+ if (local_open_u_BC) then
1764+ if (OBC% segment(OBC% segnum_u(I,j))% open ) then
1765+ if (OBC% segment(OBC% segnum_u(I,j))% direction == OBC_DIRECTION_E) then
1766+ hvel = GV% H_to_Z* h(i,j,k)
1767+ else
1768+ hvel = GV% H_to_Z* h(i+1 ,j,k)
1769+ endif
1770+ else
1771+ hvel = 0.5 * GV% H_to_Z* (h(i,j,k) + h(i+1 ,j,k))
1772+ endif
1773+ else
1774+ hvel = 0.5 * GV% H_to_Z* (h(i,j,k) + h(i+1 ,j,k))
1775+ endif
1776+
17411777 if ((htot(I) + hvel) >= visc% bbl_thick_u(I,j)) then
17421778 uhtot(I) = uhtot(I) + (visc% bbl_thick_u(I,j) - htot(I))* u(I,j,k)
17431779 htot(I) = visc% bbl_thick_u(I,j)
@@ -1769,7 +1805,7 @@ subroutine set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS)
17691805 G% areaCv(i,J) * (vstar(i,J)* v2_bbl(i,J))) )* G% IareaT(i,j))
17701806 enddo
17711807 enddo
1772- ! $OMP end parallel
1808+ ! $OMP end parallel
17731809
17741810end subroutine set_BBL_TKE
17751811
0 commit comments