Skip to content

Commit 0e585ae

Browse files
Merge pull request mom-ocean#1136 from ESMG/dev/esmg
+partial fix for mom-ocean#1130
2 parents c52f4cc + 9077211 commit 0e585ae

3 files changed

Lines changed: 51 additions & 13 deletions

File tree

src/core/MOM.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,8 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
12651265

12661266
call cpu_clock_begin(id_clock_diabatic)
12671267

1268-
call diabatic(u, v, h, tv, CS%Hml, fluxes, CS%visc, CS%ADp, CS%CDp, &
1269-
dtdia, Time_end_thermo, G, GV, US, CS%diabatic_CSp, Waves=Waves)
1268+
call diabatic(u, v, h, tv, CS%Hml, fluxes, CS%visc, CS%ADp, CS%CDp, dtdia, &
1269+
Time_end_thermo, G, GV, US, CS%diabatic_CSp, OBC=CS%OBC, Waves=Waves)
12701270
fluxes%fluxes_used = .true.
12711271

12721272
if (showCallTree) call callTree_waypoint("finished diabatic (step_MOM_thermo)")

src/parameterizations/vertical/MOM_diabatic_driver.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module MOM_diabatic_driver
5353
use MOM_CVMix_KPP, only : KPP_NonLocalTransport_temp, KPP_NonLocalTransport_saln
5454
use MOM_opacity, only : opacity_init, opacity_end, opacity_CS
5555
use MOM_opacity, only : absorbRemainingSW, optics_type, optics_nbands
56+
use MOM_open_boundary, only : ocean_OBC_type
5657
use MOM_regularize_layers, only : regularize_layers, regularize_layers_init, regularize_layers_CS
5758
use MOM_set_diffusivity, only : set_diffusivity, set_BBL_TKE
5859
use MOM_set_diffusivity, only : set_diffusivity_init, set_diffusivity_end
@@ -254,7 +255,7 @@ module MOM_diabatic_driver
254255
!> This subroutine imposes the diapycnal mass fluxes and the
255256
!! accompanying diapycnal advection of momentum and tracers.
256257
subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
257-
G, GV, US, CS, WAVES)
258+
G, GV, US, CS, OBC, WAVES)
258259
type(ocean_grid_type), intent(inout) :: G !< ocean grid structure
259260
type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
260261
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), intent(inout) :: u !< zonal velocity [L T-1 ~> m s-1]
@@ -274,6 +275,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
274275
type(time_type), intent(in) :: Time_end !< Time at the end of the interval
275276
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
276277
type(diabatic_CS), pointer :: CS !< module control structure
278+
type(ocean_OBC_type), optional, pointer :: OBC !< Open boundaries control structure.
277279
type(Wave_parameters_CS), optional, pointer :: Waves !< Surface gravity waves
278280

279281
! local variables
@@ -320,7 +322,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
320322
call diapyc_energy_req_test(h, dt, tv, G, GV, US, CS%diapyc_en_rec_CSp)
321323

322324
call cpu_clock_begin(id_clock_set_diffusivity)
323-
call set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS%set_diff_CSp)
325+
call set_BBL_TKE(u, v, h, fluxes, visc, G, GV, US, CS%set_diff_CSp, OBC=OBC)
324326
call cpu_clock_end(id_clock_set_diffusivity)
325327

326328
! Frazil formation keeps the temperature above the freezing point.

src/parameterizations/vertical/MOM_set_diffusivity.F90

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ module MOM_set_diffusivity
3030
use MOM_CVMix_ddiff, only : compute_ddiff_coeffs
3131
use MOM_bkgnd_mixing, only : calculate_bkgnd_mixing, bkgnd_mixing_init, bkgnd_mixing_cs
3232
use 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
3335
use MOM_string_functions, only : uppercase
3436
use MOM_unit_scaling, only : unit_scale_type
3537
use 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

17741810
end subroutine set_BBL_TKE
17751811

0 commit comments

Comments
 (0)