Skip to content

Commit 8309221

Browse files
committed
Compute vertical structures for khth, khtr, backscatter, and kdgl90 all in VarMix
- Vertical structures including khth_struct, khtr_struct, BS_struct, and kdgl90_struct are now computed in VarMix - Each diffusivity/viscosity have two vertical structure options, equivalent barotropic (EBT) and surface quasigeostrophic (SQG) mode structures - KHTH_USE_EBT_STRUCT, KHTR_USE_EBT_STRUCT, KDGL90_USE_EBT_STRUCT and BS_EBT_POWER parameters, which already existed, still control whether to use the EBT structure for khth, khtr, kdgl90, and backscatter, respectively - Added KHTH_USE_SQG_STRUCT, KHTR_USE_SQG_STRUCT, KDGL90_USE_SQG_STRUCT and BS_USE_SQG parameters to control whether to use the SQG structure for khth, khtr, kdgl90, and backscatter, respectively - If neither EBT nor SQG is called, no vertical structure will be used for that diffusivity/viscosity - An error will be called if both EBT and SQG structures are called for the same diffusivity/viscosity - Added dt as an input of calc_resoln_function. dt is needed for calc_sqg_struct called in calc_resoln_function
1 parent a9dd5f2 commit 8309221

File tree

7 files changed

+190
-71
lines changed

7 files changed

+190
-71
lines changed

src/core/MOM.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
750750

751751
if (CS%VarMix%use_variable_mixing) then
752752
call enable_averages(cycle_time, Time_start + real_to_time(US%T_to_s*cycle_time), CS%diag)
753-
call calc_resoln_function(h, CS%tv, G, GV, US, CS%VarMix, CS%MEKE)
753+
call calc_resoln_function(h, CS%tv, G, GV, US, CS%VarMix, CS%MEKE, dt)
754754
call calc_depth_function(G, CS%VarMix)
755755
call disable_averaging(CS%diag)
756756
endif
@@ -1898,7 +1898,7 @@ subroutine step_offline(forces, fluxes, sfc_state, Time_start, time_interval, CS
18981898
if (.not. skip_diffusion) then
18991899
if (CS%VarMix%use_variable_mixing) then
19001900
call pass_var(CS%h, G%Domain)
1901-
call calc_resoln_function(CS%h, CS%tv, G, GV, US, CS%VarMix, CS%MEKE)
1901+
call calc_resoln_function(CS%h, CS%tv, G, GV, US, CS%VarMix, CS%MEKE, dt_offline)
19021902
call calc_depth_function(G, CS%VarMix)
19031903
call calc_slope_functions(CS%h, CS%tv, dt_offline, G, GV, US, CS%VarMix, OBC=CS%OBC)
19041904
endif
@@ -1925,7 +1925,7 @@ subroutine step_offline(forces, fluxes, sfc_state, Time_start, time_interval, CS
19251925
if (.not. skip_diffusion) then
19261926
if (CS%VarMix%use_variable_mixing) then
19271927
call pass_var(CS%h, G%Domain)
1928-
call calc_resoln_function(CS%h, CS%tv, G, GV, US, CS%VarMix, CS%MEKE)
1928+
call calc_resoln_function(CS%h, CS%tv, G, GV, US, CS%VarMix, CS%MEKE, dt_offline)
19291929
call calc_depth_function(G, CS%VarMix)
19301930
call calc_slope_functions(CS%h, CS%tv, dt_offline, G, GV, US, CS%VarMix, OBC=CS%OBC)
19311931
endif

src/parameterizations/lateral/MOM_MEKE.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module MOM_MEKE
124124
logical :: debug !< If true, write out checksums of data for debugging
125125
integer :: eke_src !< Enum specifying whether EKE is stepped forward prognostically (default),
126126
!! read in from a file, or inferred via a neural network
127-
logical :: sqg_use_MEKE !< If True, use MEKE%Le for the SQG vertical structure.
127+
logical :: sqg_use_MEKE !< If True, use MEKE%Le for the SQG vertical structure.
128128
type(diag_ctrl), pointer :: diag => NULL() !< A type that regulates diagnostics output
129129
!>@{ Diagnostic handles
130130
integer :: id_MEKE = -1, id_Ue = -1, id_Kh = -1, id_src = -1
@@ -1912,7 +1912,7 @@ subroutine MEKE_alloc_register_restart(HI, US, param_file, MEKE, restart_CS)
19121912
call register_restart_field(MEKE%Le, "MEKE_Le", .false., restart_CS, &
19131913
longname="Eddy length scale from Mesoscale Eddy Kinetic Energy", &
19141914
units="m", conversion=US%L_to_m)
1915-
endif
1915+
endif
19161916
if (Use_Kh_in_MEKE) then
19171917
allocate(MEKE%Kh_diff(isd:ied,jsd:jed), source=0.0)
19181918
call register_restart_field(MEKE%Kh_diff, "MEKE_Kh_diff", .false., restart_CS, &

src/parameterizations/lateral/MOM_lateral_mixing_coeffs.F90

Lines changed: 132 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ module MOM_lateral_mixing_coeffs
5252
!! as the vertical structure of thickness diffusivity.
5353
logical :: kdgl90_use_ebt_struct !< If true, uses the equivalent barotropic structure
5454
!! as the vertical structure of diffusivity in the GL90 scheme.
55+
logical :: kdgl90_use_sqg_struct !< If true, uses the surface quasigeostrophic structure
56+
!! as the vertical structure of diffusivity in the GL90 scheme.
57+
logical :: khth_use_sqg_struct !< If true, uses the surface quasigeostrophic structure
58+
!! as the vertical structure of thickness diffusivity.
59+
logical :: khtr_use_ebt_struct !< If true, uses the equivalent barotropic structure
60+
!! as the vertical structure of tracer diffusivity.
61+
logical :: khtr_use_sqg_struct !< If true, uses the surface quasigeostrophic structure
62+
!! as the vertical structure of tracer diffusivity.
5563
logical :: calculate_cg1 !< If true, calls wave_speed() to calculate the first
5664
!! baroclinic wave speed and populate CS%cg1.
5765
!! This parameter is set depending on other parameters.
@@ -117,6 +125,9 @@ module MOM_lateral_mixing_coeffs
117125
real, allocatable :: ebt_struct(:,:,:) !< EBT vertical structure to scale diffusivities with [nondim]
118126
real, allocatable :: sqg_struct(:,:,:) !< SQG vertical structure to scale diffusivities with [nondim]
119127
real, allocatable :: BS_struct(:,:,:) !< Vertical structure function used in backscatter [nondim]
128+
real, allocatable :: khth_struct(:,:,:) !< Vertical structure function used in thickness diffusivity [nondim]
129+
real, allocatable :: khtr_struct(:,:,:) !< Vertical structure function used in tracer diffusivity [nondim]
130+
real, allocatable :: kdgl90_struct(:,:,:) !< Vertical structure function used in GL90 diffusivity [nondim]
120131
real :: BS_EBT_power !< Power to raise EBT vertical structure to. Default 0.0.
121132
real :: sqg_expo !< Exponent for SQG vertical structure [nondim]. Default 0.0
122133
logical :: BS_use_sqg !< If true, use sqg_stuct for backscatter vertical structure.
@@ -168,7 +179,8 @@ module MOM_lateral_mixing_coeffs
168179
integer :: id_N2_u=-1, id_N2_v=-1, id_S2_u=-1, id_S2_v=-1
169180
integer :: id_dzu=-1, id_dzv=-1, id_dzSxN=-1, id_dzSyN=-1
170181
integer :: id_Rd_dx=-1, id_KH_u_QG = -1, id_KH_v_QG = -1
171-
integer :: id_sqg_struct=-1, id_BS_struct=-1
182+
integer :: id_sqg_struct=-1, id_BS_struct=-1, id_khth_struct=-1, id_khtr_struct=-1
183+
integer :: id_kdgl90_struct=-1
172184
type(diag_ctrl), pointer :: diag !< A structure that is used to regulate the
173185
!! timing of diagnostic output.
174186
!>@}
@@ -220,14 +232,15 @@ subroutine calc_depth_function(G, CS)
220232
end subroutine calc_depth_function
221233

222234
!> Calculates and stores the non-dimensional resolution functions
223-
subroutine calc_resoln_function(h, tv, G, GV, US, CS, MEKE)
235+
subroutine calc_resoln_function(h, tv, G, GV, US, CS, MEKE, dt)
224236
type(ocean_grid_type), intent(inout) :: G !< Ocean grid structure
225237
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure
226238
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< Layer thickness [H ~> m or kg m-2]
227239
type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamic variables
228240
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
229241
type(VarMix_CS), intent(inout) :: CS !< Variable mixing control structure
230242
type(MEKE_type), intent(in) :: MEKE !< MEKE struct
243+
real, intent(in) :: dt !< Time increment [T ~> s]
231244

232245
! Local variables
233246
! Depending on the power-function being used, dimensional rescaling may be limited, so some
@@ -237,7 +250,6 @@ subroutine calc_resoln_function(h, tv, G, GV, US, CS, MEKE)
237250
real :: cg1_v ! The gravity wave speed interpolated to v points [L T-1 ~> m s-1] or [m s-1].
238251
real :: dx_term ! A term in the denominator [L2 T-2 ~> m2 s-2] or [m2 s-2]
239252
integer :: power_2
240-
real :: dt !< Time increment [T ~> s]
241253
integer :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz
242254
integer :: i, j, k
243255
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
@@ -249,7 +261,8 @@ subroutine calc_resoln_function(h, tv, G, GV, US, CS, MEKE)
249261
if (CS%calculate_cg1) then
250262
if (.not. allocated(CS%cg1)) call MOM_error(FATAL, &
251263
"calc_resoln_function: %cg1 is not associated with Resoln_scaled_Kh.")
252-
if (CS%khth_use_ebt_struct .or. CS%kdgl90_use_ebt_struct .or. CS%BS_EBT_power>0.) then
264+
if (CS%khth_use_ebt_struct .or. CS%kdgl90_use_ebt_struct &
265+
.or. CS%khtr_use_ebt_struct .or. CS%BS_EBT_power>0.) then
253266
if (.not. allocated(CS%ebt_struct)) call MOM_error(FATAL, &
254267
"calc_resoln_function: %ebt_struct is not associated with RESOLN_USE_EBT.")
255268
if (CS%Resoln_use_ebt) then
@@ -269,12 +282,17 @@ subroutine calc_resoln_function(h, tv, G, GV, US, CS, MEKE)
269282
call create_group_pass(CS%pass_cg1, CS%cg1, G%Domain)
270283
call do_group_pass(CS%pass_cg1, G%Domain)
271284
endif
272-
if (CS%sqg_expo>0.0) then
285+
if (CS%BS_use_sqg .or. CS%khth_use_sqg_struct .or. CS%khtr_use_sqg_struct &
286+
.or. CS%kdgl90_use_sqg_struct .or. CS%id_sqg_struct>0) then
273287
call calc_sqg_struct(h, tv, G, GV, US, CS, dt, MEKE)
274288
call pass_var(CS%sqg_struct, G%Domain)
275289
endif
276290

277-
if (CS%BS_EBT_power>0.) then
291+
if (CS%BS_EBT_power>0. .and. CS%BS_use_sqg) then
292+
call MOM_error(FATAL, &
293+
"calc_resoln_function: BS_EBT_POWER>0. &
294+
and BS_USE_SQG=True cannot be set together")
295+
elseif (CS%BS_EBT_power>0.) then
278296
do k=1,nz ; do j=G%jsd,G%jed ; do i=G%isd,G%ied
279297
CS%BS_struct(i,j,k) = CS%ebt_struct(i,j,k)**CS%BS_EBT_power
280298
enddo ; enddo ; enddo
@@ -284,6 +302,48 @@ subroutine calc_resoln_function(h, tv, G, GV, US, CS, MEKE)
284302
enddo ; enddo ; enddo
285303
endif
286304

305+
if (CS%khth_use_ebt_struct .and. CS%khth_use_sqg_struct) then
306+
call MOM_error(FATAL, &
307+
"calc_resoln_function: Only one of KHTH_USE_EBT_STRUCT &
308+
and KHTH_USE_SQG_STRUCT can be true")
309+
elseif (CS%khth_use_ebt_struct) then
310+
do k=1,nz ; do j=G%jsd,G%jed ; do i=G%isd,G%ied
311+
CS%khth_struct(i,j,k) = CS%ebt_struct(i,j,k)
312+
enddo ; enddo ; enddo
313+
elseif (CS%khth_use_sqg_struct) then
314+
do k=1,nz ; do j=G%jsd,G%jed ; do i=G%isd,G%ied
315+
CS%khth_struct(i,j,k) = CS%sqg_struct(i,j,k)
316+
enddo ; enddo ; enddo
317+
endif
318+
319+
if (CS%khtr_use_ebt_struct .and. CS%khtr_use_sqg_struct) then
320+
call MOM_error(FATAL, &
321+
"calc_resoln_function: Only one of KHTR_USE_EBT_STRUCT &
322+
and KHTR_USE_SQG_STRUCT can be true")
323+
elseif (CS%khtr_use_ebt_struct) then
324+
do k=1,nz ; do j=G%jsd,G%jed ; do i=G%isd,G%ied
325+
CS%khtr_struct(i,j,k) = CS%ebt_struct(i,j,k)
326+
enddo ; enddo ; enddo
327+
elseif (CS%khtr_use_sqg_struct) then
328+
do k=1,nz ; do j=G%jsd,G%jed ; do i=G%isd,G%ied
329+
CS%khtr_struct(i,j,k) = CS%sqg_struct(i,j,k)
330+
enddo ; enddo ; enddo
331+
endif
332+
333+
if (CS%kdgl90_use_ebt_struct .and. CS%kdgl90_use_sqg_struct) then
334+
call MOM_error(FATAL, &
335+
"calc_resoln_function: Only one of KD_GL90_USE_EBT_STRUCT &
336+
and KD_GL90_USE_SQG_STRUCT can be true")
337+
elseif (CS%kdgl90_use_ebt_struct) then
338+
do k=1,nz ; do j=G%jsd,G%jed ; do i=G%isd,G%ied
339+
CS%kdgl90_struct(i,j,k) = CS%ebt_struct(i,j,k)
340+
enddo ; enddo ; enddo
341+
elseif (CS%kdgl90_use_sqg_struct) then
342+
do k=1,nz ; do j=G%jsd,G%jed ; do i=G%isd,G%ied
343+
CS%kdgl90_struct(i,j,k) = CS%sqg_struct(i,j,k)
344+
enddo ; enddo ; enddo
345+
endif
346+
287347
! Calculate and store the ratio between deformation radius and grid-spacing
288348
! at h-points [nondim].
289349
if (CS%calculate_rd_dx) then
@@ -478,6 +538,9 @@ subroutine calc_resoln_function(h, tv, G, GV, US, CS, MEKE)
478538
if (query_averaging_enabled(CS%diag)) then
479539
if (CS%id_Res_fn > 0) call post_data(CS%id_Res_fn, CS%Res_fn_h, CS%diag)
480540
if (CS%id_BS_struct > 0) call post_data(CS%id_BS_struct, CS%BS_struct, CS%diag)
541+
if (CS%id_khth_struct > 0) call post_data(CS%id_khth_struct, CS%khth_struct, CS%diag)
542+
if (CS%id_khtr_struct > 0) call post_data(CS%id_khtr_struct, CS%khtr_struct, CS%diag)
543+
if (CS%id_kdgl90_struct > 0) call post_data(CS%id_kdgl90_struct, CS%kdgl90_struct, CS%diag)
481544
endif
482545

483546
if (CS%debug) then
@@ -534,18 +597,24 @@ subroutine calc_sqg_struct(h, tv, G, GV, US, CS, dt, MEKE)
534597
do j=js,je ; do i=is,ie
535598
Le(i,j) = MEKE%Le(i,j)
536599
f(i,j) = max(0.25*abs(G%CoriolisBu(I,J) + G%CoriolisBu(I-1,J-1) + &
537-
G%CoriolisBu(I-1,J) + G%CoriolisBu(I,J-1)), 1.0e-8)
600+
G%CoriolisBu(I-1,J) + G%CoriolisBu(I,J-1)), 1.0e-8/US%T_to_s)
538601
enddo ; enddo
539602
else
540603
do j=js,je ; do i=is,ie
541604
Le(i,j) = sqrt(G%areaT(i,j))
542605
f(i,j) = max(0.25*abs(G%CoriolisBu(I,J) + G%CoriolisBu(I-1,J-1) + &
543-
G%CoriolisBu(I-1,J) + G%CoriolisBu(I,J-1)), 1.0e-8)
606+
G%CoriolisBu(I-1,J) + G%CoriolisBu(I,J-1)), 1.0e-8*US%T_to_s)
544607
enddo ; enddo
545608
endif
609+
if (CS%debug) then
610+
call hchksum(Le, 'SQG length scale', G%HI, unscale=US%L_to_m)
611+
call hchksum(f, 'Coriolis at h point', G%HI, unscale=US%s_to_T)
612+
call uvchksum( 'MEKE LmixScale', dzu, dzv, G%HI, unscale=US%Z_to_m, scalar_pair=.true.)
613+
endif
546614
do k=2,nz ; do j=js,je ; do i=is,ie
547615
N2 = max(0.25*(N2_u(I-1,j,k) + N2_u(I,j,k) + N2_v(i,J-1,k) + N2_v(i,J,k)),0.0)
548-
dzc = 0.25*(dzu(I-1,j,k) + dzu(I,j,k) + dzv(i,J-1,k) + dzv(i,J,k))*N2**0.5/f(i,j)
616+
dzc = 0.25*(dzu(I-1,j,k) + dzu(I,j,k) + dzv(i,J-1,k) + dzv(i,J,k)) * &
617+
N2**0.5/f(i,j)*US%Z_to_L
549618
! dzs = -N2**0.5/f(i,j)*dzc
550619
CS%sqg_struct(i,j,k) = CS%sqg_struct(i,j,k-1)*exp(-CS%sqg_expo*dzc/Le(i,j))
551620
enddo ; enddo ; enddo
@@ -1353,19 +1422,33 @@ subroutine VarMix_init(Time, G, GV, US, param_file, diag, CS)
13531422
"If true, the SQG vertical structure is used for backscatter "//&
13541423
"on the condition that BS_EBT_power=0", &
13551424
default=.false.)
1356-
if (CS%BS_EBT_power>0.) CS%BS_use_sqg = .false.
13571425
call get_param(param_file, mdl, "SQG_EXPO", CS%sqg_expo, &
13581426
"Nondimensional exponent coeffecient of the SQG mode "// &
1359-
"that is used for the vertical struture of diffusivities.", units="nondim", default=0.0)
1360-
if (CS%sqg_expo==0.) CS%BS_use_sqg = .false.
1427+
"that is used for the vertical struture of diffusivities.", units="nondim", default=1.0)
13611428
call get_param(param_file, mdl, "KHTH_USE_EBT_STRUCT", CS%khth_use_ebt_struct, &
13621429
"If true, uses the equivalent barotropic structure "//&
13631430
"as the vertical structure of thickness diffusivity.",&
13641431
default=.false.)
1432+
call get_param(param_file, mdl, "KHTH_USE_SQG_STRUCT", CS%khth_use_sqg_struct, &
1433+
"If true, uses the surface quasigeostrophic structure "//&
1434+
"as the vertical structure of thickness diffusivity.",&
1435+
default=.false.)
1436+
call get_param(param_file, mdl, "KHTR_USE_EBT_STRUCT", CS%khtr_use_ebt_struct, &
1437+
"If true, uses the equivalent barotropic structure "//&
1438+
"as the vertical structure of tracer diffusivity.",&
1439+
default=.false.)
1440+
call get_param(param_file, mdl, "KHTR_USE_SQG_STRUCT", CS%khtr_use_sqg_struct, &
1441+
"If true, uses the surface quasigeostrophic structure "//&
1442+
"as the vertical structure of tracer diffusivity.",&
1443+
default=.false.)
13651444
call get_param(param_file, mdl, "KD_GL90_USE_EBT_STRUCT", CS%kdgl90_use_ebt_struct, &
13661445
"If true, uses the equivalent barotropic structure "//&
13671446
"as the vertical structure of diffusivity in the GL90 scheme.",&
13681447
default=.false.)
1448+
call get_param(param_file, mdl, "KD_GL90_USE_SQG_STRUCT", CS%kdgl90_use_sqg_struct, &
1449+
"If true, uses the equivalent barotropic structure "//&
1450+
"as the vertical structure of diffusivity in the GL90 scheme.",&
1451+
default=.false.)
13691452
call get_param(param_file, mdl, "KHTH_SLOPE_CFF", KhTh_Slope_Cff, &
13701453
"The nondimensional coefficient in the Visbeck formula "//&
13711454
"for the interface depth diffusivity", units="nondim", default=0.0)
@@ -1409,7 +1492,7 @@ subroutine VarMix_init(Time, G, GV, US, param_file, diag, CS)
14091492
endif
14101493

14111494
if (CS%Resoln_use_ebt .or. CS%khth_use_ebt_struct .or. CS%kdgl90_use_ebt_struct &
1412-
.or. CS%BS_EBT_power>0.) then
1495+
.or. CS%BS_EBT_power>0. .or. CS%khtr_use_ebt_struct) then
14131496
in_use = .true.
14141497
call get_param(param_file, mdl, "RESOLN_N2_FILTER_DEPTH", N2_filter_depth, &
14151498
"The depth below which N2 is monotonized to avoid stratification "//&
@@ -1418,13 +1501,23 @@ subroutine VarMix_init(Time, G, GV, US, param_file, diag, CS)
14181501
units="m", default=-1.0, scale=GV%m_to_H)
14191502
allocate(CS%ebt_struct(isd:ied,jsd:jed,GV%ke), source=0.0)
14201503
endif
1421-
if (CS%sqg_expo>0.0) then
1422-
allocate(CS%sqg_struct(isd:ied,jsd:jed,GV%ke), source=0.0)
1423-
endif
1504+
14241505

14251506
allocate(CS%BS_struct(isd:ied,jsd:jed,GV%ke), source=0.0)
14261507
CS%BS_struct(:,:,:) = 1.0
14271508

1509+
if (CS%khth_use_ebt_struct .or. CS%khth_use_sqg_struct) then
1510+
allocate(CS%khth_struct(isd:ied, jsd:jed, gv%ke), source=0.0)
1511+
endif
1512+
1513+
if (CS%khtr_use_ebt_struct .or. CS%khtr_use_sqg_struct) then
1514+
allocate(CS%khtr_struct(isd:ied, jsd:jed, gv%ke), source=0.0)
1515+
endif
1516+
1517+
if (CS%kdgl90_use_ebt_struct .or. CS%kdgl90_use_sqg_struct) then
1518+
allocate(CS%kdgl90_struct(isd:ied, jsd:jed, gv%ke), source=0.0)
1519+
endif
1520+
14281521
if (CS%use_stored_slopes) then
14291522
if (KhTr_Slope_Cff>0. .or. KhTh_Slope_Cff>0.) then
14301523
call get_param(param_file, mdl, "VISBECK_MAX_SLOPE", CS%Visbeck_S_max, &
@@ -1520,15 +1613,29 @@ subroutine VarMix_init(Time, G, GV, US, param_file, diag, CS)
15201613
'm2', conversion=US%L_to_m**2)
15211614
endif
15221615

1523-
if (CS%sqg_expo>0.0) then
1524-
CS%id_sqg_struct = register_diag_field('ocean_model', 'sqg_struct', diag%axesTl, Time, &
1616+
CS%id_sqg_struct = register_diag_field('ocean_model', 'sqg_struct', diag%axesTl, Time, &
15251617
'Vertical structure of SQG mode', 'nondim')
1618+
if (CS%BS_use_sqg .or. CS%khth_use_sqg_struct .or. CS%khtr_use_sqg_struct &
1619+
.or. CS%kdgl90_use_sqg_struct .or. CS%id_sqg_struct>0) then
1620+
allocate(CS%sqg_struct(isd:ied,jsd:jed,GV%ke), source=0.0)
15261621
endif
15271622

15281623
CS%id_BS_struct = register_diag_field('ocean_model', 'BS_struct', diag%axesTl, Time, &
15291624
'Vertical structure of backscatter', 'nondim')
1625+
if (CS%khth_use_ebt_struct .or. CS%khth_use_sqg_struct) then
1626+
CS%id_khth_struct = register_diag_field('ocean_model', 'khth_struct', diag%axesTl, Time, &
1627+
'Vertical structure of thickness diffusivity', 'nondim')
1628+
endif
1629+
if (CS%khtr_use_ebt_struct .or. CS%khtr_use_sqg_struct) then
1630+
CS%id_khtr_struct = register_diag_field('ocean_model', 'khtr_struct', diag%axesTl, Time, &
1631+
'Vertical structure of tracer diffusivity', 'nondim')
1632+
endif
1633+
if (CS%kdgl90_use_ebt_struct .or. CS%kdgl90_use_sqg_struct) then
1634+
CS%id_kdgl90_struct = register_diag_field('ocean_model', 'kdgl90_struct', diag%axesTl, Time, &
1635+
'Vertical structure of GL90 diffusivity', 'nondim')
1636+
endif
15301637

1531-
if ((CS%calculate_Eady_growth_rate .and. CS%use_stored_slopes) .or. (CS%sqg_expo>0.0)) then
1638+
if ((CS%calculate_Eady_growth_rate .and. CS%use_stored_slopes) ) then
15321639
CS%id_N2_u = register_diag_field('ocean_model', 'N2_u', diag%axesCui, Time, &
15331640
'Square of Brunt-Vaisala frequency, N^2, at u-points, as used in Visbeck et al.', &
15341641
's-2', conversion=(US%L_to_Z*US%s_to_T)**2)
@@ -1780,10 +1887,13 @@ end subroutine VarMix_init
17801887
subroutine VarMix_end(CS)
17811888
type(VarMix_CS), intent(inout) :: CS
17821889

1783-
if (CS%Resoln_use_ebt .or. CS%khth_use_ebt_struct .or. CS%kdgl90_use_ebt_struct .or. CS%BS_EBT_power>0.) &
1784-
deallocate(CS%ebt_struct)
1785-
if (CS%sqg_expo>0.0) deallocate(CS%sqg_struct)
1890+
if (CS%Resoln_use_ebt .or. CS%khth_use_ebt_struct .or. CS%kdgl90_use_ebt_struct &
1891+
.or. CS%BS_EBT_power>0. .or. CS%khtr_use_ebt_struct) deallocate(CS%ebt_struct)
1892+
if (allocated(CS%sqg_struct)) deallocate(CS%sqg_struct)
17861893
if (allocated(CS%BS_struct)) deallocate(CS%BS_struct)
1894+
if (CS%khth_use_ebt_struct .or. CS%khth_use_sqg_struct) deallocate(CS%khth_struct)
1895+
if (CS%khtr_use_ebt_struct .or. CS%khtr_use_sqg_struct) deallocate(CS%khtr_struct)
1896+
if (CS%kdgl90_use_ebt_struct .or. CS%kdgl90_use_sqg_struct) deallocate(CS%kdgl90_struct)
17871897

17881898
if (CS%use_stored_slopes .or. CS%sqg_expo>0.0) then
17891899
deallocate(CS%slope_x)

0 commit comments

Comments
 (0)