Skip to content

Commit e58125b

Browse files
herrwang0Hallberg-NOAA
authored andcommitted
Add diagnostics for tides and SAL
* Add diagnostics "tides_[uv]" and "sal_[uv]" for momentum acceleration due to tides and self-attraction and loading (SAL). These terms are recalculated by taking the gradient of height anomalies. * Accordingly, two new diagnostics for KE contributions from tidal forcing ("KE_tides") and SAL ("KE_SAL") are added. These two terms are components of PE_to_KE. * The new diagnostics are only added to finite volume PGF and not available in Montgomery PGF.
1 parent e7aafdc commit e58125b

8 files changed

+223
-39
lines changed

src/core/MOM_PressureForce.F90

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module MOM_PressureForce
1616
use MOM_self_attr_load, only : SAL_CS
1717
use MOM_tidal_forcing, only : tidal_forcing_CS
1818
use MOM_unit_scaling, only : unit_scale_type
19-
use MOM_variables, only : thermo_var_ptrs
19+
use MOM_variables, only : thermo_var_ptrs, accel_diag_ptrs
2020
use MOM_verticalGrid, only : verticalGrid_type
2121
use MOM_ALE, only: ALE_CS
2222
implicit none ; private
@@ -38,7 +38,7 @@ module MOM_PressureForce
3838
contains
3939

4040
!> A thin layer between the model and the Boussinesq and non-Boussinesq pressure force routines.
41-
subroutine PressureForce(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm, pbce, eta)
41+
subroutine PressureForce(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, ADp, p_atm, pbce, eta)
4242
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
4343
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
4444
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
@@ -51,6 +51,7 @@ subroutine PressureForce(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm, pbce, e
5151
intent(out) :: PFv !< Meridional pressure force acceleration [L T-2 ~> m s-2]
5252
type(PressureForce_CS), intent(inout) :: CS !< Pressure force control structure
5353
type(ALE_CS), pointer :: ALE_CSp !< ALE control structure
54+
type(accel_diag_ptrs), pointer :: ADp !< Acceleration diagnostic pointers
5455
real, dimension(:,:), pointer :: p_atm !< The pressure at the ice-ocean or
5556
!! atmosphere-ocean interface [R L2 T-2 ~> Pa].
5657
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
@@ -63,10 +64,10 @@ subroutine PressureForce(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm, pbce, e
6364
if (CS%Analytic_FV_PGF) then
6465
if (GV%Boussinesq) then
6566
call PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS%PressureForce_FV, &
66-
ALE_CSp, p_atm, pbce, eta)
67+
ALE_CSp, ADp, p_atm, pbce, eta)
6768
else
6869
call PressureForce_FV_nonBouss(h, tv, PFu, PFv, G, GV, US, CS%PressureForce_FV, &
69-
ALE_CSp, p_atm, pbce, eta)
70+
ALE_CSp, ADp, p_atm, pbce, eta)
7071
endif
7172
else
7273
if (GV%Boussinesq) then
@@ -81,14 +82,15 @@ subroutine PressureForce(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm, pbce, e
8182
end subroutine Pressureforce
8283

8384
!> Initialize the pressure force control structure
84-
subroutine PressureForce_init(Time, G, GV, US, param_file, diag, CS, SAL_CSp, tides_CSp)
85+
subroutine PressureForce_init(Time, G, GV, US, param_file, diag, CS, ADp, SAL_CSp, tides_CSp)
8586
type(time_type), target, intent(in) :: Time !< Current model time
8687
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
8788
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure
8889
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
8990
type(param_file_type), intent(in) :: param_file !< Parameter file handles
9091
type(diag_ctrl), target, intent(inout) :: diag !< Diagnostics control structure
9192
type(PressureForce_CS), intent(inout) :: CS !< Pressure force control structure
93+
type(accel_diag_ptrs), pointer :: ADp !< Acceleration diagnostic pointers
9294
type(SAL_CS), intent(in), optional :: SAL_CSp !< SAL control structure
9395
type(tidal_forcing_CS), intent(in), optional :: tides_CSp !< Tide control structure
9496
#include "version_variable.h"
@@ -105,7 +107,7 @@ subroutine PressureForce_init(Time, G, GV, US, param_file, diag, CS, SAL_CSp, ti
105107

106108
if (CS%Analytic_FV_PGF) then
107109
call PressureForce_FV_init(Time, G, GV, US, param_file, diag, &
108-
CS%PressureForce_FV, SAL_CSp, tides_CSp)
110+
CS%PressureForce_FV, ADp, SAL_CSp, tides_CSp)
109111
else
110112
call PressureForce_Mont_init(Time, G, GV, US, param_file, diag, &
111113
CS%PressureForce_Mont, SAL_CSp, tides_CSp)

src/core/MOM_PressureForce_FV.F90

Lines changed: 125 additions & 18 deletions
Large diffs are not rendered by default.

src/core/MOM_dynamics_split_RK2.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ subroutine step_MOM_dyn_split_RK2(u_inst, v_inst, h, tv, visc, Time_local, dt, f
490490
if (CS%begw == 0.0) call enable_averages(dt, Time_local, CS%diag)
491491
call cpu_clock_begin(id_clock_pres)
492492
call PressureForce(h, tv, CS%PFu, CS%PFv, G, GV, US, CS%PressureForce_CSp, &
493-
CS%ALE_CSp, p_surf, CS%pbce, CS%eta_PF)
493+
CS%ALE_CSp, CS%ADp, p_surf, CS%pbce, CS%eta_PF)
494494
if (dyn_p_surf) then
495495
pres_to_eta = 1.0 / (GV%g_Earth * GV%H_to_RZ)
496496
!$OMP parallel do default(shared)
@@ -817,7 +817,7 @@ subroutine step_MOM_dyn_split_RK2(u_inst, v_inst, h, tv, visc, Time_local, dt, f
817817
! pbce = dM/deta
818818
call cpu_clock_begin(id_clock_pres)
819819
call PressureForce(hp, tv, CS%PFu, CS%PFv, G, GV, US, CS%PressureForce_CSp, &
820-
CS%ALE_CSp, p_surf, CS%pbce, CS%eta_PF)
820+
CS%ALE_CSp, CS%ADp, p_surf, CS%pbce, CS%eta_PF)
821821
! Stokes shear force contribution to pressure gradient
822822
Use_Stokes_PGF = present(Waves)
823823
if (Use_Stokes_PGF) then
@@ -1521,7 +1521,7 @@ subroutine initialize_dyn_split_RK2(u, v, h, tv, uh, vh, eta, Time, G, GV, US, p
15211521
else
15221522
HA_CSp => NULL()
15231523
endif
1524-
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, &
1524+
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, CS%ADp, &
15251525
CS%SAL_CSp, CS%tides_CSp)
15261526
call hor_visc_init(Time, G, GV, US, param_file, diag, CS%hor_visc, ADp=CS%ADp)
15271527
call vertvisc_init(MIS, Time, G, GV, US, param_file, diag, CS%ADp, dirs, ntrunc, CS%vertvisc_CSp)

src/core/MOM_dynamics_split_RK2b.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ subroutine step_MOM_dyn_split_RK2b(u_av, v_av, h, tv, visc, Time_local, dt, forc
504504
if (CS%begw == 0.0) call enable_averages(dt, Time_local, CS%diag)
505505
call cpu_clock_begin(id_clock_pres)
506506
call PressureForce(h, tv, CS%PFu, CS%PFv, G, GV, US, CS%PressureForce_CSp, &
507-
CS%ALE_CSp, p_surf, CS%pbce, CS%eta_PF)
507+
CS%ALE_CSp, CS%ADp, p_surf, CS%pbce, CS%eta_PF)
508508
if (dyn_p_surf) then
509509
pres_to_eta = 1.0 / (GV%g_Earth * GV%H_to_RZ)
510510
!$OMP parallel do default(shared)
@@ -827,7 +827,7 @@ subroutine step_MOM_dyn_split_RK2b(u_av, v_av, h, tv, visc, Time_local, dt, forc
827827
! pbce = dM/deta
828828
call cpu_clock_begin(id_clock_pres)
829829
call PressureForce(hp, tv, CS%PFu, CS%PFv, G, GV, US, CS%PressureForce_CSp, &
830-
CS%ALE_CSp, p_surf, CS%pbce, CS%eta_PF)
830+
CS%ALE_CSp, CS%ADp, p_surf, CS%pbce, CS%eta_PF)
831831
! Stokes shear force contribution to pressure gradient
832832
if (present(Waves)) then ; if (associated(Waves)) then ; if (Waves%Stokes_PGF) then
833833
call thickness_to_dz(h, tv, dz, G, GV, US, halo_size=1)
@@ -1434,7 +1434,7 @@ subroutine initialize_dyn_split_RK2b(u, v, h, tv, uh, vh, eta, Time, G, GV, US,
14341434
else
14351435
HA_CSp => NULL()
14361436
endif
1437-
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, &
1437+
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, CS%ADp, &
14381438
CS%SAL_CSp, CS%tides_CSp)
14391439
call hor_visc_init(Time, G, GV, US, param_file, diag, CS%hor_visc, ADp=CS%ADp)
14401440
call vertvisc_init(MIS, Time, G, GV, US, param_file, diag, CS%ADp, dirs, &

src/core/MOM_dynamics_unsplit.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, forces, &
316316
p_surf(i,j) = 0.75*p_surf_begin(i,j) + 0.25*p_surf_end(i,j)
317317
enddo ; enddo ; endif
318318
call PressureForce(h_av, tv, CS%PFu, CS%PFv, G, GV, US, &
319-
CS%PressureForce_CSp, CS%ALE_CSp, p_surf)
319+
CS%PressureForce_CSp, CS%ALE_CSp, CS%ADp, p_surf)
320320
call cpu_clock_end(id_clock_pres)
321321

322322
if (associated(CS%OBC)) then ; if (CS%OBC%update_OBC) then
@@ -383,7 +383,7 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, forces, &
383383
p_surf(i,j) = 0.25*p_surf_begin(i,j) + 0.75*p_surf_end(i,j)
384384
enddo ; enddo ; endif
385385
call PressureForce(h_av, tv, CS%PFu, CS%PFv, G, GV, US, &
386-
CS%PressureForce_CSp, CS%ALE_CSp, p_surf)
386+
CS%PressureForce_CSp, CS%ALE_CSp, CS%ADp, p_surf)
387387
call cpu_clock_end(id_clock_pres)
388388

389389
if (associated(CS%OBC)) then ; if (CS%OBC%update_OBC) then
@@ -476,7 +476,7 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, forces, &
476476
! PFu = d/dx M(h_av,T,S)
477477
call cpu_clock_begin(id_clock_pres)
478478
call PressureForce(h_av, tv, CS%PFu, CS%PFv, G, GV, US, &
479-
CS%PressureForce_CSp, CS%ALE_CSp, p_surf)
479+
CS%PressureForce_CSp, CS%ALE_CSp, CS%ADp, p_surf)
480480
call cpu_clock_end(id_clock_pres)
481481

482482
if (associated(CS%OBC)) then ; if (CS%OBC%update_OBC) then
@@ -709,7 +709,7 @@ subroutine initialize_dyn_unsplit(u, v, h, Time, G, GV, US, param_file, diag, CS
709709
call CoriolisAdv_init(Time, G, GV, US, param_file, diag, CS%ADp, CS%CoriolisAdv)
710710
if (CS%calculate_SAL) call SAL_init(G, GV, US, param_file, CS%SAL_CSp)
711711
if (CS%use_tides) call tidal_forcing_init(Time, G, US, param_file, CS%tides_CSp)
712-
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, &
712+
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, CS%ADp, &
713713
CS%SAL_CSp, CS%tides_CSp)
714714
call hor_visc_init(Time, G, GV, US, param_file, diag, CS%hor_visc)
715715
call vertvisc_init(MIS, Time, G, GV, US, param_file, diag, CS%ADp, dirs, &

src/core/MOM_dynamics_unsplit_RK2.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt,
311311
if (dyn_p_surf) then ; do j=js-2,je+2 ; do i=is-2,ie+2
312312
p_surf(i,j) = 0.5*p_surf_begin(i,j) + 0.5*p_surf_end(i,j)
313313
enddo ; enddo ; endif
314-
call PressureForce(h_in, tv, CS%PFu, CS%PFv, G, GV, US, CS%PressureForce_CSp, CS%ALE_CSp, p_surf)
314+
call PressureForce(h_in, tv, CS%PFu, CS%PFv, G, GV, US, CS%PressureForce_CSp, CS%ALE_CSp, CS%ADp, p_surf)
315315
call cpu_clock_end(id_clock_pres)
316316
call pass_vector(CS%PFu, CS%PFv, G%Domain, clock=id_clock_pass)
317317
call pass_vector(CS%CAu, CS%CAv, G%Domain, clock=id_clock_pass)
@@ -673,7 +673,7 @@ subroutine initialize_dyn_unsplit_RK2(u, v, h, Time, G, GV, US, param_file, diag
673673
call CoriolisAdv_init(Time, G, GV, US, param_file, diag, CS%ADp, CS%CoriolisAdv)
674674
if (CS%calculate_SAL) call SAL_init(G, GV, US, param_file, CS%SAL_CSp)
675675
if (CS%use_tides) call tidal_forcing_init(Time, G, US, param_file, CS%tides_CSp)
676-
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, &
676+
call PressureForce_init(Time, G, GV, US, param_file, diag, CS%PressureForce_CSp, CS%ADp, &
677677
CS%SAL_CSp, CS%tides_CSp)
678678
call hor_visc_init(Time, G, GV, US, param_file, diag, CS%hor_visc)
679679
call vertvisc_init(MIS, Time, G, GV, US, param_file, diag, CS%ADp, dirs, &

src/core/MOM_variables.F90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,13 @@ module MOM_variables
183183
du_dt_dia => NULL(), & !< Zonal acceleration due to diapycnal mixing [L T-2 ~> m s-2]
184184
dv_dt_dia => NULL(), & !< Meridional acceleration due to diapycnal mixing [L T-2 ~> m s-2]
185185
u_accel_bt => NULL(), &!< Pointer to the zonal barotropic-solver acceleration [L T-2 ~> m s-2]
186-
v_accel_bt => NULL() !< Pointer to the meridional barotropic-solver acceleration [L T-2 ~> m s-2]
186+
v_accel_bt => NULL(), &!< Pointer to the meridional barotropic-solver acceleration [L T-2 ~> m s-2]
187+
188+
! sal_[uv] and tide_[uv] are 3D fields because of their baroclinic component in Boussinesq mode.
189+
sal_u => NULL(), & !< Zonal acceleration due to self-attraction and loading [L T-2 ~> m s-2]
190+
sal_v => NULL(), & !< Meridional acceleration due to self-attraction and loading [L T-2 ~> m s-2]
191+
tides_u => NULL(), & !< Zonal acceleration due to astronomical tidal forcing [L T-2 ~> m s-2]
192+
tides_v => NULL() !< Meridional acceleration due to astronomical tidal forcing [L T-2 ~> m s-2]
187193
real, pointer, dimension(:,:,:) :: du_other => NULL()
188194
!< Zonal velocity changes due to any other processes that are
189195
!! not due to any explicit accelerations [L T-1 ~> m s-1].

src/diagnostics/MOM_diagnostics.F90

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ module MOM_diagnostics
8181
integer :: id_col_ht = -1, id_dh_dt = -1
8282
integer :: id_KE = -1, id_dKEdt = -1
8383
integer :: id_PE_to_KE = -1, id_KE_BT = -1
84+
integer :: id_KE_SAL = -1, id_KE_TIDES = -1
8485
integer :: id_KE_BT_PF = -1, id_KE_BT_CF = -1
8586
integer :: id_KE_BT_WD = -1
8687
integer :: id_PE_to_KE_btbc = -1, id_KE_Coradv_btbc = -1
@@ -1081,7 +1082,45 @@ subroutine calculate_energy_diagnostics(u, v, h, uh, vh, ADp, CDp, G, GV, US, CS
10811082
* ((KE_u(I,j) + KE_u(I-1,j)) + (KE_v(i,J) + KE_v(i,J-1)))
10821083
enddo ; enddo
10831084
enddo
1084-
if (CS%id_PE_to_KE > 0) call post_data(CS%id_PE_to_KE, KE_term, CS%diag)
1085+
call post_data(CS%id_PE_to_KE, KE_term, CS%diag)
1086+
endif
1087+
1088+
if (CS%id_KE_SAL > 0) then
1089+
! Calculate the KE source from self-attraction and loading [H L2 T-3 ~> m3 s-3 or W m-2].
1090+
do k=1,nz
1091+
do j=js,je ; do I=Isq,Ieq
1092+
KE_u(I,j) = uh(I,j,k) * G%dxCu(I,j) * ADp%sal_u(I,j,k)
1093+
enddo ; enddo
1094+
do J=Jsq,Jeq ; do i=is,ie
1095+
KE_v(i,J) = vh(i,J,k) * G%dyCv(i,J) * ADp%sal_v(i,J,k)
1096+
enddo ; enddo
1097+
if (.not.G%symmetric) &
1098+
call do_group_pass(CS%pass_KE_uv, G%domain)
1099+
do j=js,je ; do i=is,ie
1100+
KE_term(i,j,k) = 0.5 * G%IareaT(i,j) &
1101+
* ((KE_u(I,j) + KE_u(I-1,j)) + (KE_v(i,J) + KE_v(i,J-1)))
1102+
enddo ; enddo
1103+
enddo
1104+
call post_data(CS%id_KE_SAL, KE_term, CS%diag)
1105+
endif
1106+
1107+
if (CS%id_KE_TIDES > 0) then
1108+
! Calculate the KE source from astronomical tidal forcing [H L2 T-3 ~> m3 s-3 or W m-2].
1109+
do k=1,nz
1110+
do j=js,je ; do I=Isq,Ieq
1111+
KE_u(I,j) = uh(I,j,k) * G%dxCu(I,j) * ADp%tides_u(I,j,k)
1112+
enddo ; enddo
1113+
do J=Jsq,Jeq ; do i=is,ie
1114+
KE_v(i,J) = vh(i,J,k) * G%dyCv(i,J) * ADp%tides_v(i,J,k)
1115+
enddo ; enddo
1116+
if (.not.G%symmetric) &
1117+
call do_group_pass(CS%pass_KE_uv, G%domain)
1118+
do j=js,je ; do i=is,ie
1119+
KE_term(i,j,k) = 0.5 * G%IareaT(i,j) &
1120+
* ((KE_u(I,j) + KE_u(I-1,j)) + (KE_v(i,J) + KE_v(i,J-1)))
1121+
enddo ; enddo
1122+
enddo
1123+
call post_data(CS%id_KE_TIDES, KE_term, CS%diag)
10851124
endif
10861125

10871126
if (CS%id_KE_BT > 0) then
@@ -1740,6 +1779,8 @@ subroutine MOM_diagnostics_init(MIS, ADp, CDp, Time, G, GV, US, param_file, diag
17401779
logical :: better_speed_est ! If true, use a more robust estimate of the first
17411780
! mode wave speed as the starting point for iterations.
17421781
logical :: split ! True if using the barotropic-baroclinic split algorithm
1782+
logical :: calc_tides ! True if using tidal forcing
1783+
logical :: calc_sal ! True if using self-attraction and loading
17431784
logical :: om4_remap_via_sub_cells ! Use the OM4-era ramap_via_sub_cells for calculating the EBT structure
17441785
! This include declares and sets the variable "version".
17451786
# include "version_variable.h"
@@ -1797,6 +1838,8 @@ subroutine MOM_diagnostics_init(MIS, ADp, CDp, Time, G, GV, US, param_file, diag
17971838
if (.not.GV%Boussinesq) remap_answer_date = max(remap_answer_date, 20230701)
17981839

17991840
call get_param(param_file, mdl, "SPLIT", split, default=.true., do_not_log=.true.)
1841+
call get_param(param_file, mdl, "TIDES", calc_tides, default=.false., do_not_log=.true.)
1842+
call get_param(param_file, mdl, "CALCULATE_SAL", calc_sal, default=calc_tides, do_not_log=.true.)
18001843

18011844
thickness_units = get_thickness_units(GV)
18021845
flux_units = get_flux_units(GV)
@@ -1993,6 +2036,14 @@ subroutine MOM_diagnostics_init(MIS, ADp, CDp, Time, G, GV, US, param_file, diag
19932036
CS%id_PE_to_KE = register_diag_field('ocean_model', 'PE_to_KE', diag%axesTL, Time, &
19942037
'Potential to Kinetic Energy Conversion of Layer', &
19952038
'm3 s-3', conversion=GV%H_to_m*(US%L_T_to_m_s**2)*US%s_to_T)
2039+
if (calc_sal) &
2040+
CS%id_KE_SAL = register_diag_field('ocean_model', 'KE_SAL', diag%axesTL, Time, &
2041+
'Kinetic Energy Source from Self-Attraction and Loading', &
2042+
'm3 s-3', conversion=GV%H_to_m*(US%L_T_to_m_s**2)*US%s_to_T)
2043+
if (calc_tides) &
2044+
CS%id_KE_TIDES = register_diag_field('ocean_model', 'KE_tides', diag%axesTL, Time, &
2045+
'Kinetic Energy Source from Astronomical Tidal Forcing', &
2046+
'm3 s-3', conversion=GV%H_to_m*(US%L_T_to_m_s**2)*US%s_to_T)
19962047
if (split) then
19972048
CS%id_KE_BT = register_diag_field('ocean_model', 'KE_BT', diag%axesTL, Time, &
19982049
'Barotropic contribution to Kinetic Energy', &
@@ -2485,11 +2536,22 @@ subroutine set_dependent_diagnostics(MIS, ADp, CDp, G, GV, CS)
24852536
call safe_alloc_ptr(ADp%bt_lwd_v, isd, ied, JsdB, JedB)
24862537
endif
24872538

2539+
if (CS%id_KE_SAL > 0) then
2540+
call safe_alloc_ptr(ADp%sal_u, IsdB, IedB, jsd, jed, nz)
2541+
call safe_alloc_ptr(ADp%sal_v, isd, ied, JsdB, JedB, nz)
2542+
endif
2543+
2544+
if (CS%id_KE_TIDES > 0) then
2545+
call safe_alloc_ptr(ADp%tides_u, IsdB, IedB, jsd, jed, nz)
2546+
call safe_alloc_ptr(ADp%tides_v, isd, ied, JsdB, JedB, nz)
2547+
endif
2548+
24882549
CS%KE_term_on = ((CS%id_dKEdt > 0) .or. (CS%id_PE_to_KE > 0) .or. (CS%id_KE_BT > 0) .or. &
24892550
(CS%id_KE_Coradv > 0) .or. (CS%id_KE_adv > 0) .or. (CS%id_KE_visc > 0) .or. &
24902551
(CS%id_KE_visc_gl90 > 0) .or. (CS%id_KE_stress > 0) .or. (CS%id_KE_horvisc > 0) .or. &
24912552
(CS%id_KE_dia > 0) .or. (CS%id_PE_to_KE_btbc > 0) .or. (CS%id_KE_BT_PF > 0) .or. &
2492-
(CS%id_KE_Coradv_btbc > 0) .or. (CS%id_KE_BT_CF > 0) .or. (CS%id_KE_BT_WD > 0))
2553+
(CS%id_KE_Coradv_btbc > 0) .or. (CS%id_KE_BT_CF > 0) .or. (CS%id_KE_BT_WD > 0) .or. &
2554+
(CS%id_KE_SAL > 0) .or. (CS%id_KE_TIDES > 0))
24932555

24942556
if (CS%id_h_du_dt > 0) call safe_alloc_ptr(ADp%diag_hu,IsdB,IedB,jsd,jed,nz)
24952557
if (CS%id_h_dv_dt > 0) call safe_alloc_ptr(ADp%diag_hv,isd,ied,JsdB,JedB,nz)
@@ -2536,6 +2598,13 @@ subroutine MOM_diagnostics_end(CS, ADp, CDp)
25362598
if (associated(ADp%bt_lwd_u)) deallocate(ADp%bt_lwd_u)
25372599
if (associated(ADp%bt_lwd_v)) deallocate(ADp%bt_lwd_v)
25382600

2601+
! NOTE: sal_[uv] and tide_[uv] may be allocated either here (KE budget diagnostics) or
2602+
! PressureForce module (momentum acceleration diagnostics)
2603+
if (associated(ADp%sal_u)) deallocate(ADp%sal_u)
2604+
if (associated(ADp%sal_v)) deallocate(ADp%sal_v)
2605+
if (associated(ADp%tides_u)) deallocate(ADp%tides_u)
2606+
if (associated(ADp%tides_v)) deallocate(ADp%tides_v)
2607+
25392608
if (associated(ADp%diag_hfrac_u)) deallocate(ADp%diag_hfrac_u)
25402609
if (associated(ADp%diag_hfrac_v)) deallocate(ADp%diag_hfrac_v)
25412610

0 commit comments

Comments
 (0)