@@ -81,6 +81,7 @@ module MOM_diagnostics
81
81
integer :: id_col_ht = - 1 , id_dh_dt = - 1
82
82
integer :: id_KE = - 1 , id_dKEdt = - 1
83
83
integer :: id_PE_to_KE = - 1 , id_KE_BT = - 1
84
+ integer :: id_KE_SAL = - 1 , id_KE_TIDES = - 1
84
85
integer :: id_KE_BT_PF = - 1 , id_KE_BT_CF = - 1
85
86
integer :: id_KE_BT_WD = - 1
86
87
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
1081
1082
* ((KE_u(I,j) + KE_u(I-1 ,j)) + (KE_v(i,J) + KE_v(i,J-1 )))
1082
1083
enddo ; enddo
1083
1084
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)
1085
1124
endif
1086
1125
1087
1126
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
1740
1779
logical :: better_speed_est ! If true, use a more robust estimate of the first
1741
1780
! mode wave speed as the starting point for iterations.
1742
1781
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
1743
1784
logical :: om4_remap_via_sub_cells ! Use the OM4-era ramap_via_sub_cells for calculating the EBT structure
1744
1785
! This include declares and sets the variable "version".
1745
1786
# include " version_variable.h"
@@ -1797,6 +1838,8 @@ subroutine MOM_diagnostics_init(MIS, ADp, CDp, Time, G, GV, US, param_file, diag
1797
1838
if (.not. GV% Boussinesq) remap_answer_date = max (remap_answer_date, 20230701 )
1798
1839
1799
1840
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. )
1800
1843
1801
1844
thickness_units = get_thickness_units(GV)
1802
1845
flux_units = get_flux_units(GV)
@@ -1993,6 +2036,14 @@ subroutine MOM_diagnostics_init(MIS, ADp, CDp, Time, G, GV, US, param_file, diag
1993
2036
CS% id_PE_to_KE = register_diag_field(' ocean_model' , ' PE_to_KE' , diag% axesTL, Time, &
1994
2037
' Potential to Kinetic Energy Conversion of Layer' , &
1995
2038
' 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)
1996
2047
if (split) then
1997
2048
CS% id_KE_BT = register_diag_field(' ocean_model' , ' KE_BT' , diag% axesTL, Time, &
1998
2049
' Barotropic contribution to Kinetic Energy' , &
@@ -2485,11 +2536,22 @@ subroutine set_dependent_diagnostics(MIS, ADp, CDp, G, GV, CS)
2485
2536
call safe_alloc_ptr(ADp% bt_lwd_v, isd, ied, JsdB, JedB)
2486
2537
endif
2487
2538
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
+
2488
2549
CS% KE_term_on = ((CS% id_dKEdt > 0 ) .or. (CS% id_PE_to_KE > 0 ) .or. (CS% id_KE_BT > 0 ) .or. &
2489
2550
(CS% id_KE_Coradv > 0 ) .or. (CS% id_KE_adv > 0 ) .or. (CS% id_KE_visc > 0 ) .or. &
2490
2551
(CS% id_KE_visc_gl90 > 0 ) .or. (CS% id_KE_stress > 0 ) .or. (CS% id_KE_horvisc > 0 ) .or. &
2491
2552
(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 ))
2493
2555
2494
2556
if (CS% id_h_du_dt > 0 ) call safe_alloc_ptr(ADp% diag_hu,IsdB,IedB,jsd,jed,nz)
2495
2557
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)
2536
2598
if (associated (ADp% bt_lwd_u)) deallocate (ADp% bt_lwd_u)
2537
2599
if (associated (ADp% bt_lwd_v)) deallocate (ADp% bt_lwd_v)
2538
2600
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
+
2539
2608
if (associated (ADp% diag_hfrac_u)) deallocate (ADp% diag_hfrac_u)
2540
2609
if (associated (ADp% diag_hfrac_v)) deallocate (ADp% diag_hfrac_v)
2541
2610
0 commit comments