Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions src/parameterizations/vertical/MOM_diabatic_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module MOM_diabatic_driver
use MOM_sponge, only : apply_sponge, sponge_CS
use MOM_ALE_sponge, only : apply_ALE_sponge, ALE_sponge_CS
use MOM_time_manager, only : time_type, real_to_time, operator(-), operator(<=)
use MOM_tracer_flow_control, only : call_tracer_column_fns, tracer_flow_control_CS
use MOM_tracer_flow_control, only : call_tracer_column_fns, tracer_flow_control_CS, extract_tracer_flow_member
use MOM_tracer_diabatic, only : tracer_vertdiff, tracer_vertdiff_Eulerian
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : thermo_var_ptrs, vertvisc_type, accel_diag_ptrs
Expand Down Expand Up @@ -183,6 +183,10 @@ module MOM_diabatic_driver
logical :: Use_KdWork_diag = .false. !< Logical flag to indicate if any Kd_work diagnostics are on.
logical :: Use_N2_diag = .false. !< Logical flag to indicate if any N2 diagnostics are on.

! MARBL needs T & S from before the tracer_vertdiff call
real, allocatable, dimension(:,:,:) :: prediabatic_T !< Temperature prior to calling diabatic driver [C ~> degC]
real, allocatable, dimension(:,:,:) :: prediabatic_S !< Salinity prior to calling diabatic driver [S ~> ppt]

!>@{ Diagnostic IDs
integer :: id_ea = -1, id_eb = -1 ! used by layer diabatic
integer :: id_ea_t = -1, id_eb_t = -1, id_ea_s = -1, id_eb_s = -1
Expand Down Expand Up @@ -637,6 +641,22 @@ subroutine diabatic_ALE_legacy(u, v, h, tv, BLD, fluxes, visc, ADp, CDp, dt, Tim
showCallTree = callTree_showQuery()
if (showCallTree) call callTree_enter("diabatic_ALE_legacy(), MOM_diabatic_driver.F90")

! Some tracer packages require T & S from the beginning of the diabatic step to
! provide forcing consistent with the passive tracer values. The initialization
! routine will allocate prediabatic_T and prediabatic_S if the tracer flow control
! structure indicates it is necessary. If these arrays are allocated, they will store
! a copy of tv%T & tv%S before this subroutine modifies the tv structure.
if (allocated(CS%prediabatic_T)) then
do k=1,nz ; do j=js,je ; do i=is,ie
CS%prediabatic_T(i,j,k) = tv%T(i,j,k)
enddo ; enddo ; enddo
endif
if (allocated(CS%prediabatic_S)) then
do k=1,nz ; do j=js,je ; do i=is,ie
CS%prediabatic_S(i,j,k) = tv%S(i,j,k)
enddo ; enddo ; enddo
endif

! For all other diabatic subroutines, the averaging window should be the entire diabatic timestep
call enable_averages(dt, Time_end, CS%diag)

Expand Down Expand Up @@ -1192,7 +1212,8 @@ subroutine diabatic_ALE_legacy(u, v, h, tv, BLD, fluxes, visc, ADp, CDp, dt, Tim
KPP_CSp=CS%KPP_CSp, &
nonLocalTrans=KPP_NLTscalar, &
evap_CFL_limit=CS%evap_CFL_limit, &
minimum_forcing_depth=CS%minimum_forcing_depth, h_BL=visc%h_ML)
minimum_forcing_depth=CS%minimum_forcing_depth, h_BL=visc%h_ML, &
prediabatic_T=CS%prediabatic_T, prediabatic_S=CS%prediabatic_S)

call cpu_clock_end(id_clock_tracers)

Expand Down Expand Up @@ -1352,6 +1373,22 @@ subroutine diabatic_ALE(u, v, h, tv, BLD, fluxes, visc, ADp, CDp, dt, Time_end,
if (.not. (CS%useALEalgorithm)) call MOM_error(FATAL, "MOM_diabatic_driver: "// &
"The ALE algorithm must be enabled when using MOM_diabatic_driver.")

! Some tracer packages require T & S from the beginning of the diabatic step to
! provide forcing consistent with the passive tracer values. The initialization
! routine will allocate prediabatic_T and prediabatic_S if the tracer flow control
! structure indicates it is necessary. If these arrays are allocated, they will store
! a copy of tv%T & tv%S before this subroutine modifies the tv structure.
if (allocated(CS%prediabatic_T)) then
do k=1,nz ; do j=js,je ; do i=is,ie
CS%prediabatic_T(i,j,k) = tv%T(i,j,k)
enddo ; enddo ; enddo
endif
if (allocated(CS%prediabatic_S)) then
do k=1,nz ; do j=js,je ; do i=is,ie
CS%prediabatic_S(i,j,k) = tv%S(i,j,k)
enddo ; enddo ; enddo
endif

! For all other diabatic subroutines, the averaging window should be the entire diabatic timestep
call enable_averages(dt, Time_end, CS%diag)

Expand Down Expand Up @@ -1818,7 +1855,8 @@ subroutine diabatic_ALE(u, v, h, tv, BLD, fluxes, visc, ADp, CDp, dt, Time_end,
KPP_CSp=CS%KPP_CSp, &
nonLocalTrans=KPP_NLTscalar, &
evap_CFL_limit=CS%evap_CFL_limit, &
minimum_forcing_depth=CS%minimum_forcing_depth, h_BL=visc%h_ML)
minimum_forcing_depth=CS%minimum_forcing_depth, h_BL=visc%h_ML, &
prediabatic_T=CS%prediabatic_T, prediabatic_S=CS%prediabatic_S)

call cpu_clock_end(id_clock_tracers)

Expand Down Expand Up @@ -3227,7 +3265,7 @@ subroutine diabatic_driver_init(Time, G, GV, US, param_file, useALEalgorithm, di

! Local variables
real :: Kd ! A diffusivity used in the default for other tracer diffusivities [Z2 T-1 ~> m2 s-1]
logical :: use_temperature
logical :: use_temperature, use_MARBL_tracers
character(len=20) :: EN1, EN2, EN3

! This "include" declares and sets the variable "version".
Expand All @@ -3246,7 +3284,12 @@ subroutine diabatic_driver_init(Time, G, GV, US, param_file, useALEalgorithm, di
CS%diag => diag
CS%Time => Time

if (associated(tracer_flow_CSp)) CS%tracer_flow_CSp => tracer_flow_CSp
if (associated(tracer_flow_CSp)) then
CS%tracer_flow_CSp => tracer_flow_CSp
call extract_tracer_flow_member(tracer_flow_CSp, use_MARBL_tracers=use_MARBL_tracers)
if (use_MARBL_tracers) &
allocate(CS%prediabatic_T(SZI_(G),SZJ_(G), SZK_(G)), CS%prediabatic_S(SZI_(G),SZJ_(G), SZK_(G)))
end if
if (associated(sponge_CSp)) CS%sponge_CSp => sponge_CSp
if (associated(ALE_sponge_CSp)) CS%ALE_sponge_CSp => ALE_sponge_CSp
if (associated(oda_incupd_CSp)) CS%oda_incupd_CSp => oda_incupd_CSp
Expand Down Expand Up @@ -3842,6 +3885,9 @@ subroutine diabatic_driver_end(CS)
deallocate(CS%optics)
endif

if (allocated(CS%prediabatic_T)) deallocate(CS%prediabatic_T)
if (allocated(CS%prediabatic_S)) deallocate(CS%prediabatic_S)

if (CS%debug_energy_req) &
call diapyc_energy_req_end(CS%diapyc_en_rec_CSp)

Expand Down
Loading
Loading