← back to index

src/diagnostics/MOM_diagnose_KdWork.F90

portedportable, not yet portedexecuted, not portableexecutable, not hit by this run

1! This file is part of MOM6, the Modular Ocean Model version 6.
2! See the LICENSE file for licensing information.
3! SPDX-License-Identifier: Apache-2.0
4
5!> Provides diagnostics of work due to a given diffusivity
6module MOM_diagnose_kdwork
7
8use MOM_diag_mediator, only : diag_ctrl, time_type, post_data, register_diag_field
9use MOM_diag_mediator, only : register_scalar_field
10use MOM_error_handler, only : MOM_error, FATAL, WARNING
11use MOM_grid, only : ocean_grid_type
12use MOM_unit_scaling, only : unit_scale_type
13use MOM_variables, only : thermo_var_ptrs
14use MOM_verticalGrid, only : verticalGrid_type
15use MOM_spatial_means, only : global_area_integral
16
17implicit none ; private
18
19#include <MOM_memory.h>
20
21public vbf_CS
22public kdwork_diagnostics
23public Allocate_VBF_CS
24public Deallocate_VBF_CS
25public KdWork_init
26public KdWork_end
27
28!> This structure has memory for used in calculating diagnostics of diffusivity
29!! many of the diffusivity diagnostics are copies of other 3d arrays. It could
30!! be written more efficiently, but it is less intrusive to copy into this structure
31!! and do all calculations in this module. These diagnostics may be expensive for
32!! routine use.
33type vbf_CS
34 ! 3d varying Kd contributions
35 real, pointer, dimension(:,:,:) :: &
36 Bflx_salt => NULL(), & !< Salinity contribution to buoyancy flux at interfaces
37 !! [H Z T-3 ~> m2 s-3 or W m-3]
38 Bflx_temp => NULL(), & !< Temperature contribution to buoyancy flux at interfaces
39 !! [H Z T-3 ~> m2 s-3 or W m-3]
40 Bflx_salt_dz => NULL(), & !< Salinity contribution to integral of buoyancy flux over layer
41 !! [H Z2 T-3 ~> m3 s-3 or W m-2]
42 Bflx_temp_dz => NULL(), & !< Temperature contribution to integral of buoyancy flux over layer
43 !! [H Z2 T-3 ~> m3 s-3 or W m-2]
44 ! The following are all allocatable arrays that store copies of process driven Kd, so that
45 ! the process driven buoyancy flux and work can be derived at the end of the time step.
46 Kd_salt => NULL(), & !< total diapycnal diffusivity of salt at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
47 Kd_temp => NULL(), & !< total diapycnal diffusivity of heat at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
48 Kd_BBL => NULL(), & !< diapycnal diffusivity due to BBL at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
49 Kd_ePBL => NULL(), & !< diapycnal diffusivity due to ePBL at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
50 Kd_KS => NULL(), & !< diapycnal diffusivity due to Kappa Shear at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
51 Kd_bkgnd => NULL(), & !< diapycnal diffusivity due to Kd_bkgnd at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
52 Kd_ddiff_S => NULL(), &!< diapycnal diffusivity due to double diffusion of salt at interfaces
53 !! [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
54 Kd_ddiff_T => NULL(), &!< diapycnal diffusivity due to double diffusion of heat at interfaces
55 !![H Z T-1 ~> m2 s-1 or kg m-1 s-1]
56 Kd_leak => NULL(), & !< diapycnal diffusivity due to Kd_leak at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
57 Kd_quad => NULL(), & !< diapycnal diffusivity due to Kd_quad at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
58 Kd_itidal => NULL(), & !< diapycnal diffusivity due to Kd_itidal at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
59 Kd_Froude => NULL(), & !< diapycnal diffusivity due to Kd_Froude at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
60 Kd_slope => NULL(), & !< diapycnal diffusivity due to Kd_slope at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
61 Kd_lowmode => NULL(), &!< diapycnal diffusivity due to Kd_lowmode at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
62 Kd_Niku => NULL(), & !< diapycnal diffusivity due to Kd_Niku at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
63 Kd_itides => NULL() !< diapycnal diffusivity due to Kd_itides at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
64
65 ! Constant Kd contributions
66 real :: Kd_add !< spatially uniform additional diapycnal diffusivity at interfaces [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
67 !! a diagnostic for this diffusivity is not yet included, but this makes it straightforward to add
68
69 !>@{ Diagnostic IDs
70 integer :: id_Bdif = -1, id_Bdif_salt = -1, id_Bdif_temp = -1
71 integer :: id_Bdif_dz = -1, id_Bdif_salt_dz = -1, id_Bdif_temp_dz = -1
72 integer :: id_Bdif_idz = -1, id_Bdif_salt_idz = -1, id_Bdif_temp_idz = -1
73 integer :: id_Bdif_idV = -1, id_Bdif_salt_idV = -1, id_Bdif_temp_idV = -1
74 integer :: id_Bdif_ePBL = -1, id_Bdif_dz_ePBL = -1, id_Bdif_idz_ePBL = -1, id_Bdif_idV_ePBL = -1
75 integer :: id_Bdif_BBL = -1, id_Bdif_dz_BBL = -1, id_Bdif_idz_BBL = -1, id_Bdif_idV_BBL = -1
76 integer :: id_Bdif_KS = -1, id_Bdif_dz_KS = -1, id_Bdif_idz_KS = -1, id_Bdif_idV_KS = -1
77 integer :: id_Bdif_bkgnd = -1, id_Bdif_dz_bkgnd = -1, id_Bdif_idz_bkgnd = -1, id_Bdif_idV_bkgnd = -1
78 integer :: id_Bdif_ddiff_temp = -1, id_Bdif_ddiff_salt = -1
79 integer :: id_Bdif_dz_ddiff_temp = -1, id_Bdif_dz_ddiff_salt = -1
80 integer :: id_Bdif_idz_ddiff_temp = -1, id_Bdif_idz_ddiff_salt = -1
81 integer :: id_Bdif_idV_ddiff_temp = -1, id_Bdif_idV_ddiff_salt = -1
82 integer :: id_Bdif_leak = -1, id_Bdif_dz_leak = -1, id_Bdif_idz_leak = -1, id_Bdif_idV_leak = -1
83 integer :: id_Bdif_quad = -1, id_Bdif_dz_quad = -1, id_Bdif_idz_quad = -1, id_Bdif_idV_quad = -1
84 integer :: id_Bdif_itidal = -1, id_Bdif_dz_itidal = -1, id_Bdif_idz_itidal = -1, id_Bdif_idV_itidal = -1
85 integer :: id_Bdif_Froude = -1, id_Bdif_dz_Froude = -1, id_Bdif_idz_Froude = -1, id_Bdif_idV_Froude = -1
86 integer :: id_Bdif_slope = -1, id_Bdif_dz_slope = -1, id_Bdif_idz_slope = -1, id_Bdif_idV_slope = -1
87 integer :: id_Bdif_lowmode = -1, id_Bdif_dz_lowmode = -1, id_Bdif_idz_lowmode = -1, id_Bdif_idV_lowmode = -1
88 integer :: id_Bdif_Niku = -1, id_Bdif_dz_Niku = -1, id_Bdif_idz_Niku = -1, id_Bdif_idV_Niku = -1
89 integer :: id_Bdif_itides = -1, id_Bdif_dz_itides = -1, id_Bdif_idz_itides = -1, id_Bdif_idV_itides = -1
90 !>@}
91
92 logical :: do_bflx_salt = .false. !< Logical flag to indicate if N2_salt should be computed
93 logical :: do_bflx_temp = .false. !< Logical flag to indicate if N2_temp should be computed
94 logical :: do_bflx_salt_dz = .false. !< Logical flag to indicate if N2_salt should be computed
95 logical :: do_bflx_temp_dz = .false. !< Logical flag to indicate if N2_temp should be computed
96
97end type vbf_CS
98
99! A note on unit descriptions in comments: MOM6 uses units that can be rescaled for dimensional
100! consistency testing. These are noted in comments with units like Z, H, L, and T, along with
101! their mks counterparts with notation like "a velocity [Z T-1 ~> m s-1]". If the units
102! vary with the Boussinesq approximation, the Boussinesq variant is given first.
103
104contains
105
106!> Loop over all implemented diffusivities to diagnose and output Kd Work/buoyancy fluxes
1070subroutine KdWork_Diagnostics(G,GV,US,diag,VBF,N2_Salt,N2_Temp,dz)
108 type(ocean_grid_type), intent(in) :: G !< Grid type
109 type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
110 type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
111 type(diag_ctrl), target, intent(inout) :: diag !< regulates diagnostic output
112 type (vbf_CS), intent(inout) :: VBF !< Vertical buoyancy flux structure
113 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), &
114 intent(in) :: N2_Salt !< Buoyancy frequency [T-2 ~> s-2]
115 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), &
116 intent(in) :: N2_Temp !< Buoyancy frequency [T-2 ~> s-2]
117 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
118 intent(in) :: dz !< Grid spacing [Z ~> m]
119
120 ! Work arrays for computing buoyancy flux integrals
1210 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: work3d_i
1220 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: work3d_l
1230 real, dimension(SZI_(G),SZJ_(G)) :: work2d, work2d_salt, work2d_temp
124 real :: work, work_salt, work_temp
125
126 integer :: i, j, k, nz, isc, iec, jsc, jec
127
1280 isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec
129
1300 nz = GV%ke
131
132 ! Compute total fluxes
133 if (VBF%id_Bdif_dz>0 .or. VBF%id_Bdif_salt_dz>0 .or. VBF%id_Bdif_temp_dz>0 .or. &
134 VBF%id_Bdif_idz>0 .or. VBF%id_Bdif_salt_idz>0 .or. VBF%id_Bdif_temp_idz>0 .or. &
1350 VBF%id_Bdif_idV>0 .or. VBF%id_Bdif_salt_idV>0 .or. VBF%id_Bdif_temp_idV>0 ) then ! Doing vertical integrals
136 ! Do Salt
137 if (VBF%id_Bdif_salt_dz>0 .or. VBF%id_Bdif_dz>0 .or. VBF%id_Bdif_salt>0 .or. VBF%id_Bdif>0 .or. &
1380 VBF%id_Bdif_idz>0 .or. VBF%id_Bdif_salt_idz>0 .or. VBF%id_Bdif_idV>0 .or. VBF%id_Bdif_salt_idV>0) &
1390 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_salt, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
140 ! Do Temp
141 if (VBF%id_Bdif_temp_dz>0 .or. VBF%id_Bdif_dz>0 .or. VBF%id_Bdif_temp>0 .or. VBF%id_Bdif>0 .or. &
1420 VBF%id_Bdif_idz>0 .or. VBF%id_Bdif_temp_idz>0 .or. VBF%id_Bdif_idV>0 .or. VBF%id_Bdif_temp_idV>0) &
1430 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_temp, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
1440 if (VBF%id_Bdif_temp_idz>0 .or. VBF%id_Bdif_idz>0) then
1450 work2d_temp(:,:) = 0.0
1460 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
1470 work2d_temp(i,j) = work2d_temp(i,j) + VBF%Bflx_temp_dz(i,j,k)
148 enddo ; enddo ; enddo
149 endif
1500 if (VBF%id_Bdif_temp_idV>0 .or. VBF%id_Bdif_idV>0) then
1510 work_temp = 0.0
1520 do k = 1,nz
153 work_temp = work_temp + global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, &
1540 tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
155 enddo
156 endif
1570 if (VBF%id_Bdif_salt_idz>0 .or. VBF%id_Bdif_idz>0) then
1580 work2d_salt(:,:) = 0.0
1590 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
1600 work2d_salt(i,j) = work2d_salt(i,j) + VBF%Bflx_salt_dz(i,j,k)
161 enddo ; enddo ; enddo
162 endif
1630 if (VBF%id_Bdif_salt_idV>0 .or. VBF%id_Bdif_idV>0) then
1640 work_salt = 0.0
1650 do k = 1,nz
166 work_salt = work_salt + global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, &
1670 tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
168 enddo
169 endif
1700 work = work_temp + work_salt
1710 do j = jsc,jec ; do i = isc,iec
1720 work2d(i,j) = work2d_temp(i,j) + work2d_salt(i,j)
173 enddo ; enddo
1740 elseif (VBF%id_Bdif>0 .or. VBF%id_Bdif_salt>0 .or. VBF%id_Bdif_temp>0) then ! Not doing vertical integrals
175 ! Do Salt
1760 if (VBF%id_Bdif_salt>0 .or. VBF%id_Bdif>0) &
1770 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_salt, VBF%Bflx_salt)
1780 if (VBF%id_Bdif_temp>0 .or. VBF%id_Bdif>0) &
1790 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_temp, VBF%Bflx_temp)
180 endif
181 ! Post total fluxes
1820 if (VBF%id_Bdif_salt>0) call post_data(VBF%id_Bdif_salt, VBF%Bflx_salt, diag)
1830 if (VBF%id_Bdif_temp>0) call post_data(VBF%id_Bdif_temp, VBF%Bflx_temp, diag)
1840 if (VBF%id_Bdif>0) then
1850 work3d_i(:,:,:) = 0.0
1860 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
1870 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
188 enddo ; enddo ; enddo
1890 call post_data(VBF%id_Bdif, work3d_i, diag)
190 endif
1910 if (VBF%id_Bdif_salt_dz>0) call post_data(VBF%id_Bdif_salt_dz, VBF%Bflx_salt_dz, diag)
1920 if (VBF%id_Bdif_temp_dz>0) call post_data(VBF%id_Bdif_temp_dz, VBF%Bflx_temp_dz, diag)
1930 if (VBF%id_Bdif_dz>0) then
1940 work3d_l(:,:,:) = 0.0
1950 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
1960 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
197 enddo ; enddo ; enddo
1980 call post_data(VBF%id_Bdif_dz, work3d_l, diag)
199 endif
2000 if (VBF%id_Bdif_salt_idz>0) call post_data(VBF%id_Bdif_salt_idz, work2d_salt, diag)
2010 if (VBF%id_Bdif_temp_idz>0) call post_data(VBF%id_Bdif_temp_idz, work2d_temp, diag)
2020 if (VBF%id_Bdif_idz>0) call post_data(VBF%id_Bdif_idz, work2d, diag)
2030 if (VBF%id_Bdif_salt_idV>0) call post_data(VBF%id_Bdif_salt_idV, work_salt, diag)
2040 if (VBF%id_Bdif_temp_idV>0) call post_data(VBF%id_Bdif_temp_idV, work_temp, diag)
2050 if (VBF%id_Bdif_idV>0) call post_data(VBF%id_Bdif_idV, work, diag)
206
207 ! Compute ePBL fluxes
2080 if (VBF%id_Bdif_dz_ePBL>0.or.VBF%id_Bdif_idz_ePBL>0.or.VBF%id_Bdif_idV_ePBL>0) then
2090 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ePBL, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
2100 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ePBL, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
2110 if (VBF%id_Bdif_idz_ePBL>0) then
2120 work2d(:,:) = 0.0
2130 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
2140 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
215 enddo ; enddo ; enddo
216 endif
2170 if (VBF%id_Bdif_idV_ePBL>0) then
2180 work = 0.0
2190 do k = 1,nz
220 work = work + &
221 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
2220 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
223 enddo
224 endif
2250 elseif (VBF%id_Bdif_ePBL>0) then
2260 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ePBL, VBF%Bflx_salt)
2270 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ePBL, VBF%Bflx_temp)
228 endif
229 ! Post ePBL fluxes
2300 if (VBF%id_Bdif_ePBL>0) then
2310 work3d_i(:,:,:) = 0.0
2320 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
2330 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
234 enddo ; enddo ; enddo
2350 call post_data(VBF%id_Bdif_ePBL, work3d_i, diag)
236 endif
2370 if (VBF%id_Bdif_dz_ePBL>0) then
2380 work3d_l(:,:,:) = 0.0
2390 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
2400 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
241 enddo ; enddo ; enddo
2420 call post_data(VBF%id_Bdif_dz_ePBL, work3d_l, diag)
243 endif
2440 if (VBF%id_Bdif_idz_ePBL>0) call post_data(VBF%id_Bdif_idz_ePBL, work2d, diag)
2450 if (VBF%id_Bdif_idV_ePBL>0) call post_data(VBF%id_Bdif_idV_ePBL, work, diag)
246
247 ! Compute BBL fluxes
2480 if (VBF%id_Bdif_dz_BBL>0.or.VBF%id_Bdif_idz_BBL>0.or.VBF%id_Bdif_idV_BBL>0) then
2490 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_BBL, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
2500 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_BBL, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
2510 if (VBF%id_Bdif_idz_BBL>0) then
2520 work2d(:,:) = 0.0
2530 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
2540 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
255 enddo ; enddo ; enddo
256 endif
2570 if (VBF%id_Bdif_idV_BBL>0) then
2580 work = 0.0
2590 do k = 1,nz
260 work = work + &
261 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
2620 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
263 enddo
264 endif
2650 elseif (VBF%id_Bdif_BBL>0) then
2660 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_BBL, VBF%Bflx_salt)
2670 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_BBL, VBF%Bflx_temp)
268 endif
269 ! Post BBL fluxes
2700 if (VBF%id_Bdif_BBL>0) then
2710 work3d_i(:,:,:) = 0.0
2720 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
2730 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
274 enddo ; enddo ; enddo
2750 call post_data(VBF%id_Bdif_BBL, work3d_i, diag)
276 endif
2770 if (VBF%id_Bdif_dz_BBL>0) then
2780 work3d_l(:,:,:) = 0.0
2790 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
2800 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
281 enddo ; enddo ; enddo
2820 call post_data(VBF%id_Bdif_dz_BBL, work3d_l, diag)
283 endif
2840 if (VBF%id_Bdif_idz_BBL>0) call post_data(VBF%id_Bdif_idz_BBL, work2d, diag)
2850 if (VBF%id_Bdif_idV_BBL>0) call post_data(VBF%id_Bdif_idV_BBL, work, diag)
286
287 ! Compute Kappa Shear fluxes
2880 if (VBF%id_Bdif_dz_KS>0.or.VBF%id_Bdif_idz_KS>0.or.VBF%id_Bdif_idV_KS>0) then
2890 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_KS, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
2900 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_KS, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
2910 if (VBF%id_Bdif_idz_KS>0) then
2920 work2d(:,:) = 0.0
2930 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
2940 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
295 enddo ; enddo ; enddo
296 endif
2970 if (VBF%id_Bdif_idV_KS>0) then
2980 work = 0.0
2990 do k = 1,nz
300 work = work + &
301 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
3020 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
303 enddo
304 endif
3050 elseif (VBF%id_Bdif_KS>0) then
3060 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_KS, VBF%Bflx_salt)
3070 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_KS, VBF%Bflx_temp)
308 endif
309 ! Post Kappa Shear fluxes
3100 if (VBF%id_Bdif_KS>0) then
3110 work3d_i(:,:,:) = 0.0
3120 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
3130 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
314 enddo ; enddo ; enddo
3150 call post_data(VBF%id_Bdif_KS, work3d_i, diag)
316 endif
3170 if (VBF%id_Bdif_dz_KS>0) then
3180 work3d_l(:,:,:) = 0.0
3190 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
3200 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
321 enddo ; enddo ; enddo
3220 call post_data(VBF%id_Bdif_dz_KS, work3d_l, diag)
323 endif
3240 if (VBF%id_Bdif_idz_KS>0) call post_data(VBF%id_Bdif_idz_KS, work2d, diag)
3250 if (VBF%id_Bdif_idV_KS>0) call post_data(VBF%id_Bdif_idV_KS, work, diag)
326
327 ! Compute bkgnd fluxes
3280 if (VBF%id_Bdif_dz_bkgnd>0.or.VBF%id_Bdif_idz_bkgnd>0.or.VBF%id_Bdif_idV_bkgnd>0) then
3290 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_bkgnd, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
3300 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_bkgnd, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
3310 if (VBF%id_Bdif_idz_bkgnd>0) then
3320 work2d(:,:) = 0.0
3330 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
3340 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
335 enddo ; enddo ; enddo
336 endif
3370 if (VBF%id_Bdif_idV_bkgnd>0) then
3380 work = 0.0
3390 do k = 1,nz
340 work = work + &
341 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
3420 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
343 enddo
344 endif
3450 elseif (VBF%id_Bdif_bkgnd>0) then
3460 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_bkgnd, VBF%Bflx_salt)
3470 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_bkgnd, VBF%Bflx_temp)
348 endif
349 ! Post bkgnd fluxes
3500 if (VBF%id_Bdif_bkgnd>0) then
3510 work3d_i(:,:,:) = 0.0
3520 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
3530 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
354 enddo ; enddo ; enddo
3550 call post_data(VBF%id_Bdif_bkgnd, work3d_i, diag)
356 endif
3570 if (VBF%id_Bdif_dz_bkgnd>0) then
3580 work3d_l(:,:,:) = 0.0
3590 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
3600 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
361 enddo ; enddo ; enddo
3620 call post_data(VBF%id_Bdif_dz_bkgnd, work3d_l, diag)
363 endif
3640 if (VBF%id_Bdif_idz_bkgnd>0) call post_data(VBF%id_Bdif_idz_bkgnd, work2d, diag)
3650 if (VBF%id_Bdif_idV_bkgnd>0) call post_data(VBF%id_Bdif_idV_bkgnd, work, diag)
366
367 ! Compute double diffusion fluxes
3680 if (VBF%id_Bdif_dz_ddiff_temp>0.or.VBF%id_Bdif_idz_ddiff_temp>0.or.VBF%id_Bdif_idV_ddiff_temp>0) then
3690 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ddiff_T, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
3700 if (VBF%id_Bdif_idz_ddiff_temp>0) then
3710 work2d_temp(:,:) = 0.0
3720 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
3730 work2d_temp(i,j) = work2d_temp(i,j) + VBF%Bflx_temp_dz(i,j,k)
374 enddo ; enddo ; enddo
375 endif
3760 if (VBF%id_Bdif_idV_ddiff_temp>0) then
3770 work_temp = 0.0
3780 do k = 1,nz
379 work_temp = work_temp + global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, &
3800 tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
381 enddo
382 endif
3830 elseif (VBF%id_Bdif_ddiff_temp>0) then
3840 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ddiff_T, VBF%Bflx_temp)
385 endif
3860 if (VBF%id_Bdif_dz_ddiff_salt>0.or.VBF%id_Bdif_idz_ddiff_salt>0.or.VBF%id_Bdif_idV_ddiff_salt>0) then
3870 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ddiff_S, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
3880 if (VBF%id_Bdif_idz_ddiff_salt>0) then
3890 work2d_salt(:,:) = 0.0
3900 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
3910 work2d_salt(i,j) = work2d_salt(i,j) + VBF%Bflx_salt_dz(i,j,k)
392 enddo ; enddo ; enddo
393 endif
3940 if (VBF%id_Bdif_idV_ddiff_salt>0) then
3950 work_salt = 0.0
3960 do k = 1,nz
397 work_salt = work_salt + global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, &
3980 tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
399 enddo
400 endif
4010 elseif (VBF%id_Bdif_ddiff_salt>0) then
4020 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ddiff_S, VBF%Bflx_salt)
403 endif
404 ! Post double diffusion fluxes
4050 if (VBF%id_Bdif_ddiff_temp>0) call post_data(VBF%id_Bdif_ddiff_temp, VBF%Bflx_temp, diag)
4060 if (VBF%id_Bdif_dz_ddiff_temp>0) call post_data(VBF%id_Bdif_dz_ddiff_temp, VBF%Bflx_temp_dz, diag)
4070 if (VBF%id_Bdif_idz_ddiff_temp>0) call post_data(VBF%id_Bdif_idz_ddiff_temp, work2d_temp, diag)
4080 if (VBF%id_Bdif_idV_ddiff_temp>0) call post_data(VBF%id_Bdif_idV_ddiff_temp, work_temp, diag)
4090 if (VBF%id_Bdif_ddiff_salt>0) call post_data(VBF%id_Bdif_ddiff_salt, VBF%Bflx_salt, diag)
4100 if (VBF%id_Bdif_dz_ddiff_salt>0) call post_data(VBF%id_Bdif_dz_ddiff_salt, VBF%Bflx_salt_dz, diag)
4110 if (VBF%id_Bdif_idz_ddiff_salt>0) call post_data(VBF%id_Bdif_idz_ddiff_salt, work2d_salt, diag)
4120 if (VBF%id_Bdif_idV_ddiff_salt>0) call post_data(VBF%id_Bdif_idV_ddiff_salt, work_salt, diag)
413
414 ! Compute Kd_leak fluxes
4150 if (VBF%id_Bdif_dz_leak>0.or.VBF%id_Bdif_idz_leak>0.or.VBF%id_Bdif_idV_leak>0) then
4160 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_leak, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
4170 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_leak, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
4180 if (VBF%id_Bdif_idz_leak>0) then
4190 work2d(:,:) = 0.0
4200 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
4210 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
422 enddo ; enddo ; enddo
423 endif
4240 if (VBF%id_Bdif_idV_leak>0) then
4250 work = 0.0
4260 do k = 1,nz
427 work = work + &
428 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
4290 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
430 enddo
431 endif
4320 elseif (VBF%id_Bdif_leak>0) then
4330 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_leak, VBF%Bflx_salt)
4340 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_leak, VBF%Bflx_temp)
435 endif
436 ! Post Kd_leak fluxes
4370 if (VBF%id_Bdif_leak>0) then
4380 work3d_i(:,:,:) = 0.0
4390 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
4400 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
441 enddo ; enddo ; enddo
4420 call post_data(VBF%id_Bdif_leak, work3d_i, diag)
443 endif
4440 if (VBF%id_Bdif_dz_leak>0) then
4450 work3d_l(:,:,:) = 0.0
4460 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
4470 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
448 enddo ; enddo ; enddo
4490 call post_data(VBF%id_Bdif_dz_leak, work3d_l, diag)
450 endif
4510 if (VBF%id_Bdif_idz_leak>0) call post_data(VBF%id_Bdif_idz_leak, work2d, diag)
4520 if (VBF%id_Bdif_idV_leak>0) call post_data(VBF%id_Bdif_idV_leak, work, diag)
453
454 ! Compute Kd_quad fluxes
4550 if (VBF%id_Bdif_dz_quad>0.or.VBF%id_Bdif_idz_quad>0.or.VBF%id_Bdif_idV_quad>0) then
4560 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_quad, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
4570 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_quad, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
4580 if (VBF%id_Bdif_idz_quad>0) then
4590 work2d(:,:) = 0.0
4600 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
4610 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
462 enddo ; enddo ; enddo
463 endif
4640 if (VBF%id_Bdif_idV_quad>0) then
4650 work = 0.0
4660 do k = 1,nz
467 work = work + &
468 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
4690 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
470 enddo
471 endif
4720 elseif (VBF%id_Bdif_quad>0) then
4730 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_quad, VBF%Bflx_salt)
4740 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_quad, VBF%Bflx_temp)
475 endif
476 ! Post Kd_quad fluxes
4770 if (VBF%id_Bdif_quad>0) then
4780 work3d_i(:,:,:) = 0.0
4790 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
4800 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
481 enddo ; enddo ; enddo
4820 call post_data(VBF%id_Bdif_quad, work3d_i, diag)
483 endif
4840 if (VBF%id_Bdif_dz_quad>0) then
4850 work3d_l(:,:,:) = 0.0
4860 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
4870 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
488 enddo ; enddo ; enddo
4890 call post_data(VBF%id_Bdif_dz_quad, work3d_l, diag)
490 endif
4910 if (VBF%id_Bdif_idz_quad>0) call post_data(VBF%id_Bdif_idz_quad, work2d, diag)
4920 if (VBF%id_Bdif_idV_quad>0) call post_data(VBF%id_Bdif_idV_quad, work, diag)
493
494 ! Compute Kd_itidal fluxes
4950 if (VBF%id_Bdif_dz_itidal>0.or.VBF%id_Bdif_idz_itidal>0.or.VBF%id_Bdif_idV_itidal>0) then
4960 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itidal, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
4970 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itidal, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
4980 if (VBF%id_Bdif_idz_itidal>0) then
4990 work2d(:,:) = 0.0
5000 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
5010 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
502 enddo ; enddo ; enddo
503 endif
5040 if (VBF%id_Bdif_idV_itidal>0) then
5050 work = 0.0
5060 do k = 1,nz
507 work = work + &
508 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
5090 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
510 enddo
511 endif
5120 elseif (VBF%id_Bdif_itidal>0) then
5130 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itidal, VBF%Bflx_salt)
5140 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itidal, VBF%Bflx_temp)
515 endif
516 ! Post Kd_itidal fluxes
5170 if (VBF%id_Bdif_itidal>0) then
5180 work3d_i(:,:,:) = 0.0
5190 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
5200 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
521 enddo ; enddo ; enddo
5220 call post_data(VBF%id_Bdif_itidal, work3d_i, diag)
523 endif
5240 if (VBF%id_Bdif_dz_itidal>0) then
5250 work3d_l(:,:,:) = 0.0
5260 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
5270 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k)+VBF%Bflx_salt_dz(i,j,k)
528 enddo ; enddo ; enddo
5290 call post_data(VBF%id_Bdif_dz_itidal, work3d_l, diag)
530 endif
5310 if (VBF%id_Bdif_idz_itidal>0) call post_data(VBF%id_Bdif_idz_itidal, work2d, diag)
5320 if (VBF%id_Bdif_idV_itidal>0) call post_data(VBF%id_Bdif_idV_itidal, work, diag)
533
534 ! Compute Kd_Froude fluxes
5350 if (VBF%id_Bdif_dz_Froude>0.or.VBF%id_Bdif_idz_Froude>0.or.VBF%id_Bdif_idV_Froude>0) then
5360 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Froude, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
5370 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Froude, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
5380 if (VBF%id_Bdif_idz_Froude>0) then
5390 work2d(:,:) = 0.0
5400 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
5410 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
542 enddo ; enddo ; enddo
543 endif
5440 if (VBF%id_Bdif_idV_Froude>0) then
5450 work = 0.0
5460 do k = 1,nz
547 work = work + &
548 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
5490 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
550 enddo
551 endif
5520 elseif (VBF%id_Bdif_Froude>0) then
5530 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Froude, VBF%Bflx_salt)
5540 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Froude, VBF%Bflx_temp)
555 endif
556 ! Post Kd_Froude fluxes
5570 if (VBF%id_Bdif_Froude>0) then
5580 work3d_i(:,:,:) = 0.0
5590 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
5600 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
561 enddo ; enddo ; enddo
5620 call post_data(VBF%id_Bdif_Froude, work3d_i, diag)
563 endif
5640 if (VBF%id_Bdif_dz_Froude>0) then
5650 work3d_l(:,:,:) = 0.0
5660 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
5670 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
568 enddo ; enddo ; enddo
5690 call post_data(VBF%id_Bdif_dz_Froude, work3d_l, diag)
570 endif
5710 if (VBF%id_Bdif_idz_Froude>0) call post_data(VBF%id_Bdif_idz_Froude, work2d, diag)
5720 if (VBF%id_Bdif_idV_Froude>0) call post_data(VBF%id_Bdif_idV_Froude, work, diag)
573
574 ! Compute Kd_slope fluxes
5750 if (VBF%id_Bdif_dz_slope>0.or.VBF%id_Bdif_idz_slope>0.or.VBF%id_Bdif_idV_slope>0) then
5760 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_slope, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
5770 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_slope, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
5780 if (VBF%id_Bdif_idz_slope>0) then
5790 work2d(:,:) = 0.0
5800 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
5810 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
582 enddo ; enddo ; enddo
583 endif
5840 if (VBF%id_Bdif_idV_slope>0) then
5850 work = 0.0
5860 do k = 1,nz
587 work = work + &
588 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
5890 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
590 enddo
591 endif
5920 elseif (VBF%id_Bdif_slope>0) then
5930 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_slope, VBF%Bflx_salt)
5940 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_slope, VBF%Bflx_temp)
595 endif
596 ! Post Kd_slope fluxes
5970 if (VBF%id_Bdif_slope>0) then
5980 work3d_i(:,:,:) = 0.0
5990 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
6000 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
601 enddo ; enddo ; enddo
6020 call post_data(VBF%id_Bdif_slope, work3d_i, diag)
603 endif
6040 if (VBF%id_Bdif_dz_slope>0) then
6050 work3d_l(:,:,:) = 0.0
6060 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
6070 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
608 enddo ; enddo ; enddo
6090 call post_data(VBF%id_Bdif_dz_slope, work3d_l, diag)
610 endif
6110 if (VBF%id_Bdif_idz_slope>0) call post_data(VBF%id_Bdif_idz_slope, work2d, diag)
6120 if (VBF%id_Bdif_idV_slope>0) call post_data(VBF%id_Bdif_idV_slope, work, diag)
613
614 ! Compute Kd_lowmode fluxes
6150 if (VBF%id_Bdif_dz_lowmode>0.or.VBF%id_Bdif_idz_lowmode>0.or.VBF%id_Bdif_idV_lowmode>0) then
6160 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_lowmode, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
6170 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_lowmode, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
6180 if (VBF%id_Bdif_idz_lowmode>0) then
6190 work2d(:,:) = 0.0
6200 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
6210 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
622 enddo ; enddo ; enddo
623 endif
6240 if (VBF%id_Bdif_idV_lowmode>0) then
6250 work = 0.0
6260 do k = 1,nz
627 work = work + &
628 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
6290 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
630 enddo
631 endif
6320 elseif (VBF%id_Bdif_lowmode>0) then
6330 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_lowmode, VBF%Bflx_salt)
6340 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_lowmode, VBF%Bflx_temp)
635 endif
636 ! Post Kd_lowmode fluxes
6370 if (VBF%id_Bdif_lowmode>0) then
6380 work3d_i(:,:,:) = 0.0
6390 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
6400 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
641 enddo ; enddo ; enddo
6420 call post_data(VBF%id_Bdif_lowmode, work3d_i, diag)
643 endif
6440 if (VBF%id_Bdif_dz_lowmode>0) then
6450 work3d_l(:,:,:) = 0.0
6460 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
6470 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
648 enddo ; enddo ; enddo
6490 call post_data(VBF%id_Bdif_dz_lowmode, work3d_l, diag)
650 endif
6510 if (VBF%id_Bdif_idz_lowmode>0) call post_data(VBF%id_Bdif_idz_lowmode, work2d, diag)
6520 if (VBF%id_Bdif_idV_lowmode>0) call post_data(VBF%id_Bdif_idV_lowmode, work, diag)
653
654 ! Compute Kd_Niku fluxes
6550 if (VBF%id_Bdif_dz_Niku>0 .or. VBF%id_Bdif_idz_Niku>0 .or. VBF%id_Bdif_idV_Niku>0) then
6560 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Niku, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
6570 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Niku, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
6580 if (VBF%id_Bdif_idz_Niku>0) then
6590 work2d(:,:) = 0.0
6600 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
6610 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
662 enddo ; enddo ; enddo
663 endif
6640 if (VBF%id_Bdif_idV_Niku>0) then
6650 work = 0.0
6660 do k = 1,nz
667 work = work + &
668 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
6690 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
670 enddo
671 endif
6720 elseif (VBF%id_Bdif_Niku>0) then
6730 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Niku, VBF%Bflx_salt)
6740 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Niku, VBF%Bflx_temp)
675 endif
676 ! Post Kd_Niku fluxes
6770 if (VBF%id_Bdif_Niku>0) then
6780 work3d_i(:,:,:) = 0.0
6790 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
6800 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
681 enddo ; enddo ; enddo
6820 call post_data(VBF%id_Bdif_lowmode, work3d_i, diag)
683 endif
6840 if (VBF%id_Bdif_dz_Niku>0) then
6850 work3d_l(:,:,:) = 0.0
6860 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
6870 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
688 enddo ; enddo ; enddo
6890 call post_data(VBF%id_Bdif_dz_Niku, work3d_l, diag)
690 endif
6910 if (VBF%id_Bdif_idz_Niku>0) call post_data(VBF%id_Bdif_idz_Niku, work2d, diag)
6920 if (VBF%id_Bdif_idV_Niku>0) call post_data(VBF%id_Bdif_idV_Niku, work, diag)
693
694 ! Compute Kd_itides fluxes
6950 if (VBF%id_Bdif_dz_itides>0 .or. VBF%id_Bdif_idz_itides>0 .or. VBF%id_Bdif_idV_itides>0) then
6960 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itides, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz)
6970 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itides, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz)
6980 if (VBF%id_Bdif_idz_itides>0) then
6990 work2d(:,:) = 0.0
7000 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
7010 work2d(i,j) = work2d(i,j) + (VBF%Bflx_salt_dz(i,j,k) + VBF%Bflx_temp_dz(i,j,k))
702 enddo ; enddo ; enddo
703 endif
7040 if (VBF%id_Bdif_idV_itides>0) then
7050 work = 0.0
7060 do k = 1,nz
707 work = work + &
708 (global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) + &
7090 global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3))
710 enddo
711 endif
7120 elseif (VBF%id_Bdif_itides>0) then
7130 call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itides, VBF%Bflx_salt)
7140 call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itides, VBF%Bflx_temp)
715 endif
716 ! Post Kd_itides fluxes
7170 if (VBF%id_Bdif_itides>0) then
7180 work3d_i(:,:,:) = 0.0
7190 do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec
7200 work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k)
721 enddo ; enddo ; enddo
7220 call post_data(VBF%id_Bdif_itides, work3d_i, diag)
723 endif
7240 if (VBF%id_Bdif_dz_itides>0) then
7250 work3d_l(:,:,:) = 0.0
7260 do k = 1,nz ; do j = jsc,jec ; do i = isc,iec
7270 work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k)
728 enddo ; enddo ; enddo
7290 call post_data(VBF%id_Bdif_dz_itides, work3d_l, diag)
730 endif
7310 if (VBF%id_Bdif_idz_itides>0) call post_data(VBF%id_Bdif_idz_itides, work2d, diag)
7320 if (VBF%id_Bdif_idV_itides>0) call post_data(VBF%id_Bdif_idV_itides, work, diag)
733
7340end subroutine KdWork_Diagnostics
735
736!> Diagnose the implied "work", or buoyancy forcing & its integral, due to a given diffusivity and column state.
7370subroutine diagnoseKdWork(G, GV, N2, Kd, Bdif_flx, dz, Bdif_flx_dz)
738 type(ocean_grid_type), intent(in) :: G !< Grid type
739 type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
740 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), &
741 intent(in) :: N2 !< Buoyancy frequency [T-2 ~> s-2]
742 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), &
743 intent(in) :: Kd !< Diffusivity [H Z T-1 ~> m2 s-1 or kg m-1 s-1]
744 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), &
745 intent(out) :: Bdif_flx !< Buoyancy flux [H Z T-3 ~> m2 s-3 or W m-3]
746 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
747 intent(in), optional :: dz !< Grid spacing [Z ~> m]
748 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
749 intent(out), optional :: Bdif_flx_dz !< Buoyancy flux over layer [H Z2 T-3 ~> m3 s-3 or W m-2]
750
751 integer :: i, j, k
752
7530 Bdif_flx(:,:,1) = 0.0
7540 Bdif_flx(:,:,GV%ke+1) = 0.0
755 !$OMP parallel do default(shared)
7560 do K=2,GV%ke ; do j=G%jsc,G%jec ; do i=G%isc,G%iec
7570 Bdif_flx(i,j,K) = - N2(i,j,K) * Kd(i,j,K)
758 enddo ; enddo ; enddo
759
7600 if (present(Bdif_flx_dz) .and. present(dz)) then
761 !$OMP parallel do default(shared)
7620 do K=1,GV%ke ; do j=G%jsc,G%jec ; do i=G%isc,G%iec
7630 Bdif_flx_dz(i,j,k) = 0.5*(Bdif_flx(i,j,K)+Bdif_flx(i,j,K+1))*dz(i,j,k)
764 enddo ; enddo ; enddo
765 endif
766
7670end subroutine diagnoseKdWork
768
769!> Allocates arrays only when needed
7700subroutine Allocate_VBF_CS(G, GV, VBF)
771 type(ocean_grid_type), intent(in) :: G !< ocean grid structure
772 type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
773 type (vbf_CS), intent(inout) :: VBF !< Vertical buoyancy flux structure
774
775 integer :: isd, ied, jsd, jed, nz
776
7770 isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed ; nz = GV%ke
778
7790 if (VBF%do_bflx_salt) &
7800 allocate(VBF%Bflx_salt(isd:ied,jsd:jed,nz+1), source=0.0)
7810 if (VBF%do_bflx_salt_dz) &
7820 allocate(VBF%Bflx_salt_dz(isd:ied,jsd:jed,nz), source=0.0)
7830 if (VBF%do_bflx_temp) &
7840 allocate(VBF%Bflx_temp(isd:ied,jsd:jed,nz+1), source=0.0)
7850 if (VBF%do_bflx_temp_dz) &
7860 allocate(VBF%Bflx_temp_dz(isd:ied,jsd:jed,nz), source=0.0)
787
788 if (VBF%id_Bdif_salt_dz>0 .or. VBF%id_Bdif_dz>0 .or. VBF%id_Bdif_salt>0 .or. VBF%id_Bdif>0 .or. &
7890 VBF%id_Bdif_idz>0 .or. VBF%id_Bdif_salt_idz>0 .or. VBF%id_Bdif_idV>0 .or. VBF%id_Bdif_salt_idV>0) &
7900 allocate(VBF%Kd_salt(isd:ied,jsd:jed,nz+1), source=0.0)
791 if (VBF%id_Bdif_temp_dz>0 .or. VBF%id_Bdif_dz>0 .or. VBF%id_Bdif_temp>0 .or. VBF%id_Bdif>0 .or. &
7920 VBF%id_Bdif_idz>0 .or. VBF%id_Bdif_temp_idz>0 .or. VBF%id_Bdif_idV>0 .or. VBF%id_Bdif_temp_idV>0) &
7930 allocate(VBF%Kd_temp(isd:ied,jsd:jed,nz+1), source=0.0)
794
7950 if (VBF%id_Bdif_BBL>0 .or. VBF%id_Bdif_dz_BBL>0 .or. VBF%id_Bdif_idz_BBL>0 .or. VBF%id_Bdif_idV_BBL>0) &
7960 allocate(VBF%Kd_BBL(isd:ied,jsd:jed,nz+1), source=0.0)
7970 if (VBF%id_Bdif_ePBL>0 .or. VBF%id_Bdif_dz_ePBL>0 .or. VBF%id_Bdif_idz_ePBL>0 .or. VBF%id_Bdif_idV_ePBL>0) &
7980 allocate(VBF%Kd_ePBL(isd:ied,jsd:jed,nz+1), source=0.0)
7990 if (VBF%id_Bdif_KS>0 .or. VBF%id_Bdif_dz_KS>0 .or. VBF%id_Bdif_idz_KS>0 .or. VBF%id_Bdif_idV_KS>0) &
8000 allocate(VBF%Kd_KS(isd:ied,jsd:jed,nz+1), source=0.0)
8010 if (VBF%id_Bdif_bkgnd>0 .or. VBF%id_Bdif_dz_bkgnd>0 .or. VBF%id_Bdif_idz_bkgnd>0 .or. VBF%id_Bdif_idV_bkgnd>0) &
8020 allocate(VBF%Kd_bkgnd(isd:ied,jsd:jed,nz+1), source=0.0)
803 if (VBF%id_Bdif_ddiff_temp>0 .or. VBF%id_Bdif_dz_ddiff_temp>0 .or. VBF%id_Bdif_idz_ddiff_temp>0 &
8040 .or. VBF%id_Bdif_idV_ddiff_temp>0) allocate(VBF%Kd_ddiff_T(isd:ied,jsd:jed,nz+1), source=0.0)
805 if (VBF%id_Bdif_ddiff_salt>0 .or. VBF%id_Bdif_dz_ddiff_salt>0 .or. VBF%id_Bdif_idV_ddiff_salt>0 &
8060 .or. VBF%id_Bdif_idV_ddiff_salt>0) allocate(VBF%Kd_ddiff_S(isd:ied,jsd:jed,nz+1), source=0.0)
8070 if (VBF%id_Bdif_leak>0 .or. VBF%id_Bdif_dz_leak>0 .or. VBF%id_Bdif_idz_leak>0 .or. VBF%id_Bdif_idV_leak>0) &
8080 allocate(VBF%Kd_leak(isd:ied,jsd:jed,nz+1), source=0.0)
8090 if (VBF%id_Bdif_quad>0 .or. VBF%id_Bdif_dz_quad>0 .or. VBF%id_Bdif_idz_quad>0 .or. VBF%id_Bdif_idV_quad>0) &
8100 allocate(VBF%Kd_quad(isd:ied,jsd:jed,nz+1), source=0.0)
8110 if (VBF%id_Bdif_itidal>0 .or. VBF%id_Bdif_dz_itidal>0 .or. VBF%id_Bdif_idz_itidal>0 .or. VBF%id_Bdif_idV_itidal>0) &
8120 allocate(VBF%Kd_itidal(isd:ied,jsd:jed,nz+1), source=0.0)
8130 if (VBF%id_Bdif_Froude>0 .or. VBF%id_Bdif_dz_Froude>0 .or. VBF%id_Bdif_idz_Froude>0 .or. VBF%id_Bdif_idV_Froude>0) &
8140 allocate(VBF%Kd_Froude(isd:ied,jsd:jed,nz+1), source=0.0)
8150 if (VBF%id_Bdif_slope>0 .or. VBF%id_Bdif_dz_slope>0 .or. VBF%id_Bdif_idz_slope>0 .or. VBF%id_Bdif_idV_slope>0) &
8160 allocate(VBF%Kd_slope(isd:ied,jsd:jed,nz+1), source=0.0)
8170 if (VBF%id_Bdif_lowmode>0 .or. VBF%id_Bdif_dz_lowmode>0 .or. VBF%id_Bdif_idz_lowmode>0 .or. &
8180 VBF%id_Bdif_idV_lowmode>0) allocate(VBF%Kd_lowmode(isd:ied,jsd:jed,nz+1), source=0.0)
8190 if (VBF%id_Bdif_Niku>0 .or. VBF%id_Bdif_dz_Niku>0 .or. VBF%id_Bdif_idz_Niku>0 .or. VBF%id_Bdif_idV_Niku>0) &
8200 allocate(VBF%Kd_Niku(isd:ied,jsd:jed,nz+1), source=0.0)
8210 if (VBF%id_Bdif_itides>0 .or. VBF%id_Bdif_dz_itides>0 .or. VBF%id_Bdif_idz_itides>0 .or. VBF%id_Bdif_idV_itides>0) &
8220 allocate(VBF%Kd_itides(isd:ied,jsd:jed,nz+1), source=0.0)
823
8240end subroutine Allocate_VBF_CS
825
826!> Deallocate any arrays that were allocated
8270subroutine Deallocate_VBF_CS(VBF)
828 type (vbf_CS), intent(inout) :: VBF !< Vertical buoyancy flux structure
829
8300 if (associated(VBF%Bflx_salt)) &
8310 deallocate(VBF%Bflx_salt)
8320 if (associated(VBF%Bflx_temp)) &
8330 deallocate(VBF%Bflx_temp)
8340 if (associated(VBF%Bflx_salt_dz)) &
8350 deallocate(VBF%Bflx_salt_dz)
8360 if (associated(VBF%Bflx_temp_dz)) &
8370 deallocate(VBF%Bflx_temp_dz)
8380 if (associated(VBF%Kd_salt)) &
8390 deallocate(VBF%Kd_salt)
8400 if (associated(VBF%Kd_temp)) &
8410 deallocate(VBF%Kd_temp)
8420 if (associated(VBF%Kd_BBL)) &
8430 deallocate(VBF%Kd_BBL)
8440 if (associated(VBF%Kd_ePBL)) &
8450 deallocate(VBF%Kd_ePBL)
8460 if (associated(VBF%Kd_KS)) &
8470 deallocate(VBF%Kd_KS)
8480 if (associated(VBF%Kd_bkgnd)) &
8490 deallocate(VBF%Kd_bkgnd)
8500 if (associated(VBF%Kd_ddiff_T)) &
8510 deallocate(VBF%Kd_ddiff_T)
8520 if (associated(VBF%Kd_ddiff_S)) &
8530 deallocate(VBF%Kd_ddiff_S)
8540 if (associated(VBF%Kd_leak)) &
8550 deallocate(VBF%Kd_leak)
8560 if (associated(VBF%Kd_quad)) &
8570 deallocate(VBF%Kd_quad)
8580 if (associated(VBF%Kd_itidal)) &
8590 deallocate(VBF%Kd_itidal)
8600 if (associated(VBF%Kd_Froude)) &
8610 deallocate(VBF%Kd_Froude)
8620 if (associated(VBF%Kd_slope)) &
8630 deallocate(VBF%Kd_slope)
8640 if (associated(VBF%Kd_lowmode)) &
8650 deallocate(VBF%Kd_lowmode)
8660 if (associated(VBF%Kd_Niku)) &
8670 deallocate(VBF%Kd_Niku)
8680 if (associated(VBF%Kd_itides)) &
8690 deallocate(VBF%Kd_itides)
870
8710end subroutine Deallocate_VBF_CS
872
873!> Handles all KdWork diagnostics and flags which calculations should be done.
8741subroutine KdWork_init(Time, G,GV,US,diag,VBF,Use_KdWork_diag)
875 type(time_type), target :: Time !< model time
876 type(ocean_grid_type), intent(in) :: G !< ocean grid structure
877 type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
878 type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
879 type(diag_ctrl), target, intent(inout) :: diag !< regulates diagnostic output
880 type (vbf_CS), pointer, intent(inout) :: VBF !< Vertical buoyancy flux structure
881 logical, intent(out) :: Use_KdWork_diag !< Flag if any output was turned on
882
8831 allocate(VBF)
884
8851 VBF%do_bflx_salt = .false.
8861 VBF%do_bflx_salt_dz = .false.
8871 VBF%do_bflx_temp = .false.
8881 VBF%do_bflx_temp_dz = .false.
889
890 VBF%id_Bdif = register_diag_field('ocean_model',"Bflx_dia_diff", diag%axesTi, &
891 Time, "Diffusive diapycnal buoyancy flux across interfaces", &
8921 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
893 VBF%id_Bdif_dz = register_diag_field('ocean_model',"Bflx_dia_diff_dz", diag%axesTl, &
894 Time, "Layerwise integral of diffusive diapycnal buoyancy flux.", &
8951 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
896 VBF%id_Bdif_idz = register_diag_field('ocean_model',"Bflx_dia_diff_idz", diag%axesT1, &
897 Time, "Layer integrated diffusive diapycnal buoyancy flux.", &
8981 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
899 VBF%id_Bdif_idV = register_scalar_field('ocean_model',"Bflx_dia_diff_idV", Time, diag, &
900 "Global integrated diffusive diapycnal buoyancy flux.", &
9011 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
902
903 VBF%id_Bdif_salt = register_diag_field('ocean_model',"Bflx_salt_dia_diff", diag%axesTi, &
904 Time, "Salinity contribution to diffusive diapycnal buoyancy flux across interfaces", &
9051 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
906 VBF%id_Bdif_salt_dz = register_diag_field('ocean_model',"Bflx_salt_dia_diff_dz", diag%axesTl, &
907 Time, "Salinity contribution to layer integral of diffusive diapycnal buoyancy flux.", &
9081 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
909 VBF%id_Bdif_salt_idz = register_diag_field('ocean_model',"Bflx_salt_dia_diff_idz", diag%axesT1, &
910 Time, "Salinity contribution to layer integrated diffusive diapycnal buoyancy flux.", &
9111 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
912 VBF%id_Bdif_salt_idV = register_scalar_field('ocean_model',"Bflx_salt_dia_diff_idV", Time, diag, &
913 "Salinity contribution to global integrated diffusive diapycnal buoyancy flux.", &
9141 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
915
916 VBF%id_Bdif_temp = register_diag_field('ocean_model',"Bflx_temp_dia_diff", diag%axesTi, &
917 Time, "Temperature contribution to diffusive diapycnal buoyancy flux across interfaces", &
9181 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
919 VBF%id_Bdif_temp_dz = register_diag_field('ocean_model',"Bflx_temp_dia_diff_dz", diag%axesTl, &
920 Time, "Temperature contribution to layer integral of diffusive diapycnal buoyancy flux.", &
9211 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
922 VBF%id_Bdif_temp_idz = register_diag_field('ocean_model',"Bflx_temp_dia_diff_idz", diag%axesT1, &
923 Time, "Temperature contribution to layer integrated diffusive diapycnal buoyancy flux.", &
9241 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
925 VBF%id_Bdif_temp_idV = register_scalar_field('ocean_model',"Bflx_temp_dia_diff_idV", Time, diag, &
926 "Temperature contribution to global integrated diffusive diapycnal buoyancy flux.", &
9271 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
928
929 VBF%id_Bdif_BBL = register_diag_field('ocean_model',"Bflx_dia_diff_BBL", diag%axesTi, &
930 Time, "Diffusive diapycnal buoyancy flux across interfaces due to the BBL parameterization.", &
9311 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
932 VBF%id_Bdif_dz_BBL = register_diag_field('ocean_model',"Bflx_dia_diff_dz_BBL", diag%axesTl, &
933 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to the BBL parameterization.", &
9341 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
935 VBF%id_Bdif_idz_BBL = register_diag_field('ocean_model',"Bflx_dia_diff_idz_BBL", diag%axesT1, &
936 Time, "Layer integrated diffusive diapycnal buoyancy flux due to the BBL parameterization.", &
9371 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
938 VBF%id_Bdif_idV_BBL = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_BBL", Time, diag, &
939 "Global integrated diffusive diapycnal buoyancy flux due to BBL.", &
9401 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
941
942 VBF%id_Bdif_ePBL = register_diag_field('ocean_model',"Bflx_dia_diff_ePBL", diag%axesTi, &
943 Time, "Diffusive diapycnal buoyancy flux across interfaces due to ePBL", &
9441 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
945 VBF%id_Bdif_dz_ePBL = register_diag_field('ocean_model',"Bflx_dia_diff_dz_ePBL", diag%axesTl, &
946 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to ePBL.", &
9471 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
948 VBF%id_Bdif_idz_ePBL = register_diag_field('ocean_model',"Bflx_dia_diff_idz_ePBL", diag%axesT1, &
949 Time, "Layer integrated diffusive diapycnal buoyancy flux due to ePBL.", &
9501 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
951 VBF%id_Bdif_idV_ePBL = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_ePBL", Time, diag, &
952 "Global integrated diffusive diapycnal buoyancy flux due to ePBL.", &
9531 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
954
955 VBF%id_Bdif_KS = register_diag_field('ocean_model',"Bflx_dia_diff_KS", diag%axesTi, &
956 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kappa Shear", &
9571 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
958 VBF%id_Bdif_dz_KS = register_diag_field('ocean_model',"Bflx_dia_diff_dz_KS", diag%axesTl, &
959 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to Kappa Shear.", &
9601 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
961 VBF%id_Bdif_idz_KS = register_diag_field('ocean_model',"Bflx_dia_diff_idz_KS", diag%axesT1, &
962 Time, "Layer integrated diffusive diapycnal buoyancy flux due to Kappa Shear.", &
9631 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
964 VBF%id_Bdif_idV_KS = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_KS", Time, diag, &
965 "Global integrated diffusive diapycnal buoyancy flux due to Kappa Shear.", &
9661 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
967
968 VBF%id_Bdif_bkgnd = register_diag_field('ocean_model',"Bflx_dia_diff_bkgnd", diag%axesTi, &
969 Time, "Diffusive diapycnal buoyancy flux across interfaces due to bkgnd mixing", &
9701 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
971 VBF%id_Bdif_dz_bkgnd = register_diag_field('ocean_model',"Bflx_dia_diff_dz_bkgnd", diag%axesTl, &
972 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
9731 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
974 VBF%id_Bdif_idz_bkgnd = register_diag_field('ocean_model',"Bflx_dia_diff_idz_bkgnd", diag%axesT1, &
975 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
9761 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
977 VBF%id_Bdif_idV_bkgnd = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_bkgnd", Time, diag, &
978 "Global integrated diffusive diapycnal buoyancy flux due to Kd_bkgnd.", &
9791 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
980
981 VBF%id_Bdif_ddiff_temp = register_diag_field('ocean_model',"Bflx_dia_diff_ddiff_heat", diag%axesTi, &
982 Time, "Diffusive diapycnal buoyancy flux across interfaces due to double diffusion of heat", &
9831 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
984 VBF%id_Bdif_dz_ddiff_temp = register_diag_field('ocean_model',"Bflx_dia_diff_dz_ddiff_heat", diag%axesTl, &
985 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to double diffusion of heat.", &
9861 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
987 VBF%id_Bdif_idz_ddiff_temp = register_diag_field('ocean_model',"Bflx_dia_diff_idz_ddiff_heat", diag%axesT1, &
988 Time, "Layer integrated diffusive diapycnal buoyancy flux due to double diffusion of heat.", &
9891 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
990 VBF%id_Bdif_idV_ddiff_temp = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_ddiff_heat", Time, diag, &
991 "Global integrated diffusive diapycnal buoyancy flux due to double diffusion of heat.", &
9921 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
993
994 VBF%id_Bdif_ddiff_salt = register_diag_field('ocean_model',"Bflx_dia_diff_ddiff_salt", diag%axesTi, &
995 Time, "Diffusive diapycnal buoyancy flux across interfaces due to double diffusion of salt", &
9961 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
997 VBF%id_Bdif_dz_ddiff_salt = register_diag_field('ocean_model',"Bflx_dia_diff_dz_ddiff_salt", diag%axesTl, &
998 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to double diffusion of salt.", &
9991 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1000 VBF%id_Bdif_idz_ddiff_salt = register_diag_field('ocean_model',"Bflx_dia_diff_idz_ddiff_salt", diag%axesT1, &
1001 Time, "Layer integrated diffusive diapycnal buoyancy flux due to double diffusion of salt.", &
10021 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1003 VBF%id_Bdif_idV_ddiff_salt = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_ddiff_salt", Time, diag, &
1004 "Global integrated diffusive diapycnal buoyancy flux due to double diffusion of salt.", &
10051 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1006
1007 VBF%id_Bdif_leak = register_diag_field('ocean_model',"Bflx_dia_diff_leak", diag%axesTi, &
1008 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_leak mixing", &
10091 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1010 VBF%id_Bdif_dz_leak = register_diag_field('ocean_model',"Bflx_dia_diff_dz_leak", diag%axesTl, &
1011 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10121 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1013 VBF%id_Bdif_idz_leak = register_diag_field('ocean_model',"Bflx_dia_diff_idz_leak", diag%axesT1, &
1014 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10151 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1016 VBF%id_Bdif_idV_leak = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_leak", Time, diag, &
1017 "Global integrated diffusive diapycnal buoyancy flux due to Kd_leak.", &
10181 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1019
1020 VBF%id_Bdif_quad = register_diag_field('ocean_model',"Bflx_dia_diff_quad", diag%axesTi, &
1021 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_quad mixing", &
10221 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1023 VBF%id_Bdif_dz_quad = register_diag_field('ocean_model',"Bflx_dia_diff_dz_quad", diag%axesTl, &
1024 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10251 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1026 VBF%id_Bdif_idz_quad = register_diag_field('ocean_model',"Bflx_dia_diff_idz_quad", diag%axesT1, &
1027 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10281 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1029 VBF%id_Bdif_idV_quad = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_quad", Time, diag, &
1030 "Global integrated diffusive diapycnal buoyancy flux due to Kd_quad.", &
10311 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1032
1033 VBF%id_Bdif_itidal = register_diag_field('ocean_model',"Bflx_dia_diff_itidal", diag%axesTi, &
1034 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_itidal mixing", &
10351 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1036 VBF%id_Bdif_dz_itidal = register_diag_field('ocean_model',"Bflx_dia_diff_dz_itidal", diag%axesTl, &
1037 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10381 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1039 VBF%id_Bdif_idz_itidal = register_diag_field('ocean_model',"Bflx_dia_diff_idz_itidal", diag%axesT1, &
1040 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10411 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1042 VBF%id_Bdif_idV_itidal = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_itidal", Time, diag, &
1043 "Global integrated diffusive diapycnal buoyancy flux due to Kd_itidal.", &
10441 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1045
1046 VBF%id_Bdif_Froude = register_diag_field('ocean_model',"Bflx_dia_diff_Froude", diag%axesTi, &
1047 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_Froude mixing", &
10481 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1049 VBF%id_Bdif_dz_Froude = register_diag_field('ocean_model',"Bflx_dia_diff_dz_Froude", diag%axesTl, &
1050 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10511 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1052 VBF%id_Bdif_idz_Froude = register_diag_field('ocean_model',"Bflx_dia_diff_idz_Froude", diag%axesT1, &
1053 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10541 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1055 VBF%id_Bdif_idV_Froude = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_Froude", Time, diag, &
1056 "Global integrated diffusive diapycnal buoyancy flux due to Kd_Froude.", &
10571 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1058
1059 VBF%id_Bdif_slope = register_diag_field('ocean_model',"Bflx_dia_diff_slope", diag%axesTi, &
1060 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_slope mixing", &
10611 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1062 VBF%id_Bdif_dz_slope = register_diag_field('ocean_model',"Bflx_dia_diff_dz_slope", diag%axesTl, &
1063 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10641 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1065 VBF%id_Bdif_idz_slope = register_diag_field('ocean_model',"Bflx_dia_diff_idz_slope", diag%axesT1, &
1066 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10671 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1068 VBF%id_Bdif_idV_slope = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_slope", Time, diag, &
1069 "Global integrated diffusive diapycnal buoyancy flux due to Kd_slope.", &
10701 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1071
1072 VBF%id_Bdif_lowmode = register_diag_field('ocean_model',"Bflx_dia_diff_lowmode", diag%axesTi, &
1073 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_lowmode mixing", &
10741 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1075 VBF%id_Bdif_dz_lowmode = register_diag_field('ocean_model',"Bflx_dia_diff_dz_lowmode", diag%axesTl, &
1076 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10771 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1078 VBF%id_Bdif_idz_lowmode = register_diag_field('ocean_model',"Bflx_dia_diff_idz_lowmode", diag%axesT1, &
1079 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10801 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1081 VBF%id_Bdif_idV_lowmode = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_lowmode", Time, diag, &
1082 "Global integrated diffusive diapycnal buoyancy flux due to Kd_lowmode.", &
10831 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1084
1085 VBF%id_Bdif_Niku = register_diag_field('ocean_model',"Bflx_dia_diff_Niku", diag%axesTi, &
1086 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_Niku mixing", &
10871 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1088 VBF%id_Bdif_dz_Niku = register_diag_field('ocean_model',"Bflx_dia_diff_dz_Niku", diag%axesTl, &
1089 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10901 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1091 VBF%id_Bdif_idz_Niku = register_diag_field('ocean_model',"Bflx_dia_diff_idz_Niku", diag%axesT1, &
1092 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
10931 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1094 VBF%id_Bdif_idV_Niku = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_Niku", Time, diag, &
1095 "Global integrated diffusive diapycnal buoyancy flux due to Kd_Niku.", &
10961 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1097
1098 VBF%id_Bdif_itides = register_diag_field('ocean_model',"Bflx_dia_diff_itides", diag%axesTi, &
1099 Time, "Diffusive diapycnal buoyancy flux across interfaces due to Kd_itides mixing", &
11001 "W m-3", conversion=GV%H_to_kg_m2*US%Z_to_m*US%s_to_T**3)
1101 VBF%id_Bdif_dz_itides = register_diag_field('ocean_model',"Bflx_dia_diff_dz_itides", diag%axesTl, &
1102 Time, "Layerwise integral of diffusive diapycnal buoyancy flux due to bkgnd mixing", &
11031 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1104 VBF%id_Bdif_idz_itides = register_diag_field('ocean_model',"Bflx_dia_diff_idz_itides", diag%axesT1, &
1105 Time, "Layer integrated diffusive diapycnal buoyancy flux due to bkgnd mixing", &
11061 "W m-2", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3)
1107 VBF%id_Bdif_idV_itides = register_scalar_field('ocean_model',"Bflx_dia_diff_idV_itides", Time, diag, &
1108 "Global integrated diffusive diapycnal buoyancy flux due to Kd_itides.", &
11091 units="W", conversion=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3*US%L_to_m**2)
1110
1111 if (VBF%id_Bdif_dz>0 .or. VBF%id_Bdif_salt_dz>0 .or. VBF%id_Bdif_dz_BBL>0 .or. &
1112 VBF%id_Bdif_dz_ePBL>0 .or. VBF%id_Bdif_dz_KS>0 .or. VBF%id_Bdif_dz_bkgnd>0 .or. &
1113 VBF%id_Bdif_dz_ddiff_salt>0 .or. VBF%id_Bdif_dz_leak>0 .or. VBF%id_Bdif_dz_quad>0 .or. &
1114 VBF%id_Bdif_dz_itidal>0 .or. VBF%id_Bdif_dz_Froude>0 .or. VBF%id_Bdif_dz_slope>0 .or. &
1115 VBF%id_Bdif_dz_lowmode>0 .or. VBF%id_Bdif_dz_Niku>0 .or. VBF%id_Bdif_dz_itides>0 .or. &
1116 VBF%id_Bdif_idV>0 .or. VBF%id_Bdif_salt_idV>0 .or. VBF%id_Bdif_idV_BBL>0 .or. &
1117 VBF%id_Bdif_idV_ePBL>0 .or. VBF%id_Bdif_idV_KS>0 .or. VBF%id_Bdif_idV_bkgnd>0 .or. &
1118 VBF%id_Bdif_idV_ddiff_salt>0 .or. VBF%id_Bdif_idV_leak>0 .or. VBF%id_Bdif_idV_quad>0 .or. &
1119 VBF%id_Bdif_idV_itidal>0 .or. VBF%id_Bdif_idV_Froude>0 .or. VBF%id_Bdif_idV_slope>0 .or. &
1120 VBF%id_Bdif_idV_lowmode>0 .or. VBF%id_Bdif_idV_Niku>0 .or. VBF%id_Bdif_idV_itides>0 .or. &
1121 VBF%id_Bdif_idz>0 .or. VBF%id_Bdif_salt_idz>0 .or. VBF%id_Bdif_idz_BBL>0 .or. &
1122 VBF%id_Bdif_idz_ePBL>0 .or. VBF%id_Bdif_idz_KS>0 .or. VBF%id_Bdif_idz_bkgnd>0 .or. &
1123 VBF%id_Bdif_idz_ddiff_salt>0 .or. VBF%id_Bdif_idz_leak>0 .or. VBF%id_Bdif_idz_quad>0 .or. &
1124 VBF%id_Bdif_idz_itidal>0 .or. VBF%id_Bdif_idz_Froude>0 .or. VBF%id_Bdif_idz_slope>0 .or. &
11251 VBF%id_Bdif_idz_lowmode>0 .or. VBF%id_Bdif_idz_Niku>0 .or. VBF%id_Bdif_idz_itides>0 ) then
11260 VBF%do_bflx_salt_dz = .true.
1127 endif
1128 if (VBF%id_Bdif_dz>0 .or. VBF%id_Bdif_temp_dz>0 .or. VBF%id_Bdif_dz_BBL>0 .or. &
1129 VBF%id_Bdif_dz_ePBL>0 .or. VBF%id_Bdif_dz_KS>0 .or. VBF%id_Bdif_dz_bkgnd>0 .or. &
1130 VBF%id_Bdif_dz_ddiff_temp>0 .or. VBF%id_Bdif_dz_leak>0 .or. VBF%id_Bdif_dz_quad>0 .or. &
1131 VBF%id_Bdif_dz_itidal>0 .or. VBF%id_Bdif_dz_Froude>0 .or. VBF%id_Bdif_dz_slope>0 .or. &
1132 VBF%id_Bdif_dz_lowmode>0 .or. VBF%id_Bdif_dz_Niku>0 .or. VBF%id_Bdif_dz_itides>0 .or. &
1133 VBF%id_Bdif_idV>0 .or. VBF%id_Bdif_temp_idV>0 .or. VBF%id_Bdif_idV_BBL>0 .or. &
1134 VBF%id_Bdif_idV_ePBL>0 .or. VBF%id_Bdif_idV_KS>0 .or. VBF%id_Bdif_idV_bkgnd>0 .or. &
1135 VBF%id_Bdif_idV_ddiff_temp>0 .or. VBF%id_Bdif_idV_leak>0 .or. VBF%id_Bdif_idV_quad>0 .or. &
1136 VBF%id_Bdif_idV_itidal>0 .or. VBF%id_Bdif_idV_Froude>0 .or. VBF%id_Bdif_idV_slope>0 .or. &
1137 VBF%id_Bdif_idV_lowmode>0 .or. VBF%id_Bdif_idV_Niku>0 .or. VBF%id_Bdif_idV_itides>0 .or. &
1138 VBF%id_Bdif_idz>0 .or. VBF%id_Bdif_temp_idz>0 .or. VBF%id_Bdif_idz_BBL>0 .or. &
1139 VBF%id_Bdif_idz_ePBL>0 .or. VBF%id_Bdif_idz_KS>0 .or. VBF%id_Bdif_idz_bkgnd>0 .or. &
1140 VBF%id_Bdif_idz_ddiff_temp>0 .or. VBF%id_Bdif_idz_leak>0 .or. VBF%id_Bdif_idz_quad>0 .or. &
1141 VBF%id_Bdif_idz_itidal>0 .or. VBF%id_Bdif_idz_Froude>0 .or. VBF%id_Bdif_idz_slope>0 .or. &
11421 VBF%id_Bdif_idz_lowmode>0 .or. VBF%id_Bdif_idz_Niku>0 .or. VBF%id_Bdif_idz_itides>0 ) then
11430 VBF%do_bflx_temp_dz = .true.
1144 endif
1145 if (VBF%id_Bdif>0 .or. VBF%id_Bdif_salt>0 .or. VBF%id_Bdif_BBL>0 .or. &
1146 VBF%id_Bdif_ePBL>0 .or. VBF%id_Bdif_KS>0 .or. VBF%id_Bdif_bkgnd>0 .or. &
1147 VBF%id_Bdif_ddiff_salt>0 .or. VBF%id_Bdif_leak>0 .or. VBF%id_Bdif_quad>0 .or. &
1148 VBF%id_Bdif_itidal>0 .or. VBF%id_Bdif_Froude>0 .or. VBF%id_Bdif_slope>0 .or. &
11491 VBF%id_Bdif_lowmode>0 .or. VBF%id_Bdif_Niku>0 .or. VBF%id_Bdif_itides>0 .or. &
1150 VBF%do_bflx_salt_dz) then
11510 VBF%do_bflx_salt = .true.
1152 endif
1153 if (VBF%id_Bdif>0 .or. VBF%id_Bdif_temp>0 .or. VBF%id_Bdif_BBL>0 .or. &
1154 VBF%id_Bdif_ePBL>0 .or. VBF%id_Bdif_KS>0 .or. VBF%id_Bdif_bkgnd>0 .or. &
1155 VBF%id_Bdif_ddiff_temp>0 .or. VBF%id_Bdif_leak>0 .or. VBF%id_Bdif_quad>0 .or. &
1156 VBF%id_Bdif_itidal>0 .or. VBF%id_Bdif_Froude>0 .or. VBF%id_Bdif_slope>0 .or. &
11571 VBF%id_Bdif_lowmode>0 .or. VBF%id_Bdif_Niku>0 .or. VBF%id_Bdif_itides>0 .or. &
1158 VBF%do_bflx_temp_dz) then
11590 VBF%do_bflx_temp = .true.
1160 endif
1161
11621 Use_KdWork_diag = (VBF%do_bflx_salt .or. VBF%do_bflx_temp .or. VBF%do_bflx_salt_dz .or. VBF%do_bflx_temp_dz)
1163
11641end subroutine KdWork_init
1165
1166!> Deallocates control structrue
11671subroutine KdWork_end(VBF)
1168 type (vbf_CS), pointer, intent(inout) :: VBF !< Vertical buoyancy flux structure
1169
11701 if (associated(VBF)) deallocate(VBF)
1171
11721end subroutine KdWork_end
1173
1174!> \namespace mom_diagnose_kdwork
1175!!
1176!! The subroutine diagnoseKdWork diagnoses the energetics associated with various vertical diffusivities
1177!! inside MOM6 diabatic routines.
1178!!
1179
11800end module MOM_diagnose_kdwork