Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into separate-seaice-melt
Browse files Browse the repository at this point in the history
  • Loading branch information
Henri Drake committed Dec 11, 2024
2 parents ac855f9 + 61e3bcf commit 791521c
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/parameterizations/vertical/MOM_set_diffusivity.F90
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ module MOM_set_diffusivity
integer :: id_Kd_quad = -1, id_Kd_itidal = -1, id_Kd_Froude = -1, id_Kd_slope = -1
integer :: id_prof_leak = -1, id_prof_quad = -1, id_prof_itidal= -1
integer :: id_prof_Froude= -1, id_prof_slope = -1, id_bbl_thick = -1, id_kbbl = -1
integer :: id_Kd_Work_added = -1
!>@}

end type set_diffusivity_CS
Expand All @@ -192,7 +193,8 @@ module MOM_set_diffusivity
N2_3d => NULL(), & !< squared buoyancy frequency at interfaces [T-2 ~> s-2]
Kd_user => NULL(), & !< user-added diffusivity at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
Kd_BBL => NULL(), & !< BBL diffusivity at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
Kd_work => NULL(), & !< layer integrated work by diapycnal mixing [R Z3 T-3 ~> W m-2]
Kd_Work => NULL(), & !< layer integrated work by diapycnal mixing [R Z3 T-3 ~> W m-2]
Kd_Work_added => NULL(), & !< layer integrated work by added mixing [R Z3 T-3 ~> W m-2]
maxTKE => NULL(), & !< energy required to entrain to h_max [H Z2 T-3 ~> m3 s-3 or W m-2]
Kd_bkgnd => NULL(), & !< Background diffusivity at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
Kv_bkgnd => NULL(), & !< Viscosity from background diffusivity at interfaces [H Z T-1 ~> m2 s-1 or Pa s]
Expand Down Expand Up @@ -359,7 +361,8 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, Kd_i

if (CS%id_N2 > 0) allocate(dd%N2_3d(isd:ied,jsd:jed,nz+1), source=0.0)
if (CS%id_Kd_user > 0) allocate(dd%Kd_user(isd:ied,jsd:jed,nz+1), source=0.0)
if (CS%id_Kd_work > 0) allocate(dd%Kd_work(isd:ied,jsd:jed,nz), source=0.0)
if (CS%id_Kd_Work > 0) allocate(dd%Kd_Work(isd:ied,jsd:jed,nz), source=0.0)
if (CS%id_Kd_Work_added > 0) allocate(dd%Kd_Work_added(isd:ied,jsd:jed,nz), source=0.0)
if (CS%id_maxTKE > 0) allocate(dd%maxTKE(isd:ied,jsd:jed,nz), source=0.0)
if (CS%id_TKE_to_Kd > 0) allocate(dd%TKE_to_Kd(isd:ied,jsd:jed,nz), source=0.0)
if ((CS%double_diffusion) .and. (CS%id_KT_extra > 0)) &
Expand Down Expand Up @@ -549,7 +552,7 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, Kd_i
enddo ; enddo
endif

if (CS%ML_radiation .or. CS%use_tidal_mixing .or. associated(dd%Kd_work)) then
if (CS%ML_radiation .or. CS%use_tidal_mixing .or. associated(dd%Kd_Work)) then
call thickness_to_dz(h, tv, dz, j, G, GV)
endif

Expand Down Expand Up @@ -662,7 +665,7 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, Kd_i
enddo ; enddo
endif

if (associated(dd%Kd_work)) then
if (associated(dd%Kd_Work)) then
do k=1,nz ; do i=is,ie
dd%Kd_Work(i,j,k) = GV%H_to_RZ * Kd_lay_2d(i,k) * N2_lay(i,k) * dz(i,k) ! Watt m-2 = kg s-3
enddo ; enddo
Expand All @@ -675,6 +678,12 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, Kd_i
enddo ; enddo
endif

if (associated(dd%Kd_Work_added)) then
do k=1,nz ; do i=is,ie
dd%Kd_Work_added(i,j,k) = GV%H_to_RZ * CS%Kd_add * N2_lay(i,k) * dz(i,k) ! Watt m-2 = kg s-3
enddo ; enddo
endif

! Copy the 2-d slices into the 3-d array that is exported; this was done above for Kd_int.
if (present(Kd_lay)) then ; do k=1,nz ; do i=is,ie
Kd_lay(i,j,k) = Kd_lay_2d(i,k)
Expand Down Expand Up @@ -754,12 +763,13 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, Kd_i
if (CS%use_tidal_mixing) &
call post_tidal_diagnostics(G, GV, h, CS%tidal_mixing)

if (CS%id_N2 > 0) call post_data(CS%id_N2, dd%N2_3d, CS%diag)
if (CS%id_Kd_Work > 0) call post_data(CS%id_Kd_Work, dd%Kd_Work, CS%diag)
if (CS%id_maxTKE > 0) call post_data(CS%id_maxTKE, dd%maxTKE, CS%diag)
if (CS%id_TKE_to_Kd > 0) call post_data(CS%id_TKE_to_Kd, dd%TKE_to_Kd, CS%diag)
if (CS%id_N2 > 0) call post_data(CS%id_N2, dd%N2_3d, CS%diag)
if (CS%id_Kd_Work > 0) call post_data(CS%id_Kd_Work, dd%Kd_Work, CS%diag)
if (CS%id_Kd_Work_added > 0) call post_data(CS%id_Kd_Work_added, dd%Kd_Work_added, CS%diag)
if (CS%id_maxTKE > 0) call post_data(CS%id_maxTKE, dd%maxTKE, CS%diag)
if (CS%id_TKE_to_Kd > 0) call post_data(CS%id_TKE_to_Kd, dd%TKE_to_Kd, CS%diag)

if (CS%id_Kd_user > 0) call post_data(CS%id_Kd_user, dd%Kd_user, CS%diag)
if (CS%id_Kd_user > 0) call post_data(CS%id_Kd_user, dd%Kd_user, CS%diag)

! double diffusive mixing
if (CS%double_diffusion) then
Expand All @@ -773,7 +783,8 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, Kd_i
if (CS%id_Kd_BBL > 0) call post_data(CS%id_Kd_BBL, dd%Kd_BBL, CS%diag)

if (associated(dd%N2_3d)) deallocate(dd%N2_3d)
if (associated(dd%Kd_work)) deallocate(dd%Kd_work)
if (associated(dd%Kd_Work)) deallocate(dd%Kd_Work)
if (associated(dd%Kd_Work_added)) deallocate(dd%Kd_Work_added)
if (associated(dd%Kd_user)) deallocate(dd%Kd_user)
if (associated(dd%maxTKE)) deallocate(dd%maxTKE)
if (associated(dd%TKE_to_Kd)) deallocate(dd%TKE_to_Kd)
Expand Down Expand Up @@ -2517,6 +2528,8 @@ subroutine set_diffusivity_init(Time, G, GV, US, param_file, diag, CS, int_tide_
if (CS%use_tidal_mixing) then
CS%id_Kd_Work = register_diag_field('ocean_model', 'Kd_Work', diag%axesTL, Time, &
'Work done by Diapycnal Mixing', 'W m-2', conversion=US%RZ3_T3_to_W_m2)
CS%id_Kd_Work_added = register_diag_field('ocean_model', 'Kd_Work_added', diag%axesTL, Time, &
'Work done by additional mixing Kd_add', 'W m-2', conversion=US%RZ3_T3_to_W_m2)
CS%id_maxTKE = register_diag_field('ocean_model', 'maxTKE', diag%axesTL, Time, &
'Maximum layer TKE', 'm3 s-3', conversion=(GV%H_to_m*US%Z_to_m**2*US%s_to_T**3))
CS%id_TKE_to_Kd = register_diag_field('ocean_model', 'TKE_to_Kd', diag%axesTL, Time, &
Expand Down

0 comments on commit 791521c

Please sign in to comment.