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 | |
| 6 | module MOM_diagnose_kdwork | |
| 7 | ||
| 8 | use MOM_diag_mediator, only : diag_ctrl, time_type, post_data, register_diag_field | |
| 9 | use MOM_diag_mediator, only : register_scalar_field | |
| 10 | use MOM_error_handler, only : MOM_error, FATAL, WARNING | |
| 11 | use MOM_grid, only : ocean_grid_type | |
| 12 | use MOM_unit_scaling, only : unit_scale_type | |
| 13 | use MOM_variables, only : thermo_var_ptrs | |
| 14 | use MOM_verticalGrid, only : verticalGrid_type | |
| 15 | use MOM_spatial_means, only : global_area_integral | |
| 16 | ||
| 17 | implicit none ; private | |
| 18 | ||
| 19 | #include <MOM_memory.h> | |
| 20 | ||
| 21 | public vbf_CS | |
| 22 | public kdwork_diagnostics | |
| 23 | public Allocate_VBF_CS | |
| 24 | public Deallocate_VBF_CS | |
| 25 | public KdWork_init | |
| 26 | public 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. | |
| 33 | type 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 | ||
| 97 | end 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 | ||
| 104 | contains | |
| 105 | ||
| 106 | !> Loop over all implemented diffusivities to diagnose and output Kd Work/buoyancy fluxes | |
| 107 | 0 | subroutine 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 | |
| 121 | 0 | real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: work3d_i |
| 122 | 0 | real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: work3d_l |
| 123 | 0 | 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 | ||
| 128 | 0 | isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec |
| 129 | ||
| 130 | 0 | 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. & | |
| 135 | 0 | 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. & | |
| 138 | 0 | 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) & |
| 139 | 0 | 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. & | |
| 142 | 0 | 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) & |
| 143 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_temp, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 144 | 0 | if (VBF%id_Bdif_temp_idz>0 .or. VBF%id_Bdif_idz>0) then |
| 145 | 0 | work2d_temp(:,:) = 0.0 |
| 146 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 147 | 0 | work2d_temp(i,j) = work2d_temp(i,j) + VBF%Bflx_temp_dz(i,j,k) |
| 148 | enddo ; enddo ; enddo | |
| 149 | endif | |
| 150 | 0 | if (VBF%id_Bdif_temp_idV>0 .or. VBF%id_Bdif_idV>0) then |
| 151 | 0 | work_temp = 0.0 |
| 152 | 0 | do k = 1,nz |
| 153 | work_temp = work_temp + global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, & | |
| 154 | 0 | tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) |
| 155 | enddo | |
| 156 | endif | |
| 157 | 0 | if (VBF%id_Bdif_salt_idz>0 .or. VBF%id_Bdif_idz>0) then |
| 158 | 0 | work2d_salt(:,:) = 0.0 |
| 159 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 160 | 0 | work2d_salt(i,j) = work2d_salt(i,j) + VBF%Bflx_salt_dz(i,j,k) |
| 161 | enddo ; enddo ; enddo | |
| 162 | endif | |
| 163 | 0 | if (VBF%id_Bdif_salt_idV>0 .or. VBF%id_Bdif_idV>0) then |
| 164 | 0 | work_salt = 0.0 |
| 165 | 0 | do k = 1,nz |
| 166 | work_salt = work_salt + global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, & | |
| 167 | 0 | tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) |
| 168 | enddo | |
| 169 | endif | |
| 170 | 0 | work = work_temp + work_salt |
| 171 | 0 | do j = jsc,jec ; do i = isc,iec |
| 172 | 0 | work2d(i,j) = work2d_temp(i,j) + work2d_salt(i,j) |
| 173 | enddo ; enddo | |
| 174 | 0 | 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 | |
| 176 | 0 | if (VBF%id_Bdif_salt>0 .or. VBF%id_Bdif>0) & |
| 177 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_salt, VBF%Bflx_salt) |
| 178 | 0 | if (VBF%id_Bdif_temp>0 .or. VBF%id_Bdif>0) & |
| 179 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_temp, VBF%Bflx_temp) |
| 180 | endif | |
| 181 | ! Post total fluxes | |
| 182 | 0 | if (VBF%id_Bdif_salt>0) call post_data(VBF%id_Bdif_salt, VBF%Bflx_salt, diag) |
| 183 | 0 | if (VBF%id_Bdif_temp>0) call post_data(VBF%id_Bdif_temp, VBF%Bflx_temp, diag) |
| 184 | 0 | if (VBF%id_Bdif>0) then |
| 185 | 0 | work3d_i(:,:,:) = 0.0 |
| 186 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 187 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 188 | enddo ; enddo ; enddo | |
| 189 | 0 | call post_data(VBF%id_Bdif, work3d_i, diag) |
| 190 | endif | |
| 191 | 0 | if (VBF%id_Bdif_salt_dz>0) call post_data(VBF%id_Bdif_salt_dz, VBF%Bflx_salt_dz, diag) |
| 192 | 0 | if (VBF%id_Bdif_temp_dz>0) call post_data(VBF%id_Bdif_temp_dz, VBF%Bflx_temp_dz, diag) |
| 193 | 0 | if (VBF%id_Bdif_dz>0) then |
| 194 | 0 | work3d_l(:,:,:) = 0.0 |
| 195 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 196 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 197 | enddo ; enddo ; enddo | |
| 198 | 0 | call post_data(VBF%id_Bdif_dz, work3d_l, diag) |
| 199 | endif | |
| 200 | 0 | if (VBF%id_Bdif_salt_idz>0) call post_data(VBF%id_Bdif_salt_idz, work2d_salt, diag) |
| 201 | 0 | if (VBF%id_Bdif_temp_idz>0) call post_data(VBF%id_Bdif_temp_idz, work2d_temp, diag) |
| 202 | 0 | if (VBF%id_Bdif_idz>0) call post_data(VBF%id_Bdif_idz, work2d, diag) |
| 203 | 0 | if (VBF%id_Bdif_salt_idV>0) call post_data(VBF%id_Bdif_salt_idV, work_salt, diag) |
| 204 | 0 | if (VBF%id_Bdif_temp_idV>0) call post_data(VBF%id_Bdif_temp_idV, work_temp, diag) |
| 205 | 0 | if (VBF%id_Bdif_idV>0) call post_data(VBF%id_Bdif_idV, work, diag) |
| 206 | ||
| 207 | ! Compute ePBL fluxes | |
| 208 | 0 | if (VBF%id_Bdif_dz_ePBL>0.or.VBF%id_Bdif_idz_ePBL>0.or.VBF%id_Bdif_idV_ePBL>0) then |
| 209 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ePBL, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 210 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ePBL, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 211 | 0 | if (VBF%id_Bdif_idz_ePBL>0) then |
| 212 | 0 | work2d(:,:) = 0.0 |
| 213 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 214 | 0 | 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 | |
| 217 | 0 | if (VBF%id_Bdif_idV_ePBL>0) then |
| 218 | 0 | work = 0.0 |
| 219 | 0 | 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) + & | |
| 222 | 0 | 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 | |
| 225 | 0 | elseif (VBF%id_Bdif_ePBL>0) then |
| 226 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ePBL, VBF%Bflx_salt) |
| 227 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ePBL, VBF%Bflx_temp) |
| 228 | endif | |
| 229 | ! Post ePBL fluxes | |
| 230 | 0 | if (VBF%id_Bdif_ePBL>0) then |
| 231 | 0 | work3d_i(:,:,:) = 0.0 |
| 232 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 233 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 234 | enddo ; enddo ; enddo | |
| 235 | 0 | call post_data(VBF%id_Bdif_ePBL, work3d_i, diag) |
| 236 | endif | |
| 237 | 0 | if (VBF%id_Bdif_dz_ePBL>0) then |
| 238 | 0 | work3d_l(:,:,:) = 0.0 |
| 239 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 240 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 241 | enddo ; enddo ; enddo | |
| 242 | 0 | call post_data(VBF%id_Bdif_dz_ePBL, work3d_l, diag) |
| 243 | endif | |
| 244 | 0 | if (VBF%id_Bdif_idz_ePBL>0) call post_data(VBF%id_Bdif_idz_ePBL, work2d, diag) |
| 245 | 0 | if (VBF%id_Bdif_idV_ePBL>0) call post_data(VBF%id_Bdif_idV_ePBL, work, diag) |
| 246 | ||
| 247 | ! Compute BBL fluxes | |
| 248 | 0 | if (VBF%id_Bdif_dz_BBL>0.or.VBF%id_Bdif_idz_BBL>0.or.VBF%id_Bdif_idV_BBL>0) then |
| 249 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_BBL, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 250 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_BBL, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 251 | 0 | if (VBF%id_Bdif_idz_BBL>0) then |
| 252 | 0 | work2d(:,:) = 0.0 |
| 253 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 254 | 0 | 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 | |
| 257 | 0 | if (VBF%id_Bdif_idV_BBL>0) then |
| 258 | 0 | work = 0.0 |
| 259 | 0 | 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) + & | |
| 262 | 0 | 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 | |
| 265 | 0 | elseif (VBF%id_Bdif_BBL>0) then |
| 266 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_BBL, VBF%Bflx_salt) |
| 267 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_BBL, VBF%Bflx_temp) |
| 268 | endif | |
| 269 | ! Post BBL fluxes | |
| 270 | 0 | if (VBF%id_Bdif_BBL>0) then |
| 271 | 0 | work3d_i(:,:,:) = 0.0 |
| 272 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 273 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 274 | enddo ; enddo ; enddo | |
| 275 | 0 | call post_data(VBF%id_Bdif_BBL, work3d_i, diag) |
| 276 | endif | |
| 277 | 0 | if (VBF%id_Bdif_dz_BBL>0) then |
| 278 | 0 | work3d_l(:,:,:) = 0.0 |
| 279 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 280 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 281 | enddo ; enddo ; enddo | |
| 282 | 0 | call post_data(VBF%id_Bdif_dz_BBL, work3d_l, diag) |
| 283 | endif | |
| 284 | 0 | if (VBF%id_Bdif_idz_BBL>0) call post_data(VBF%id_Bdif_idz_BBL, work2d, diag) |
| 285 | 0 | if (VBF%id_Bdif_idV_BBL>0) call post_data(VBF%id_Bdif_idV_BBL, work, diag) |
| 286 | ||
| 287 | ! Compute Kappa Shear fluxes | |
| 288 | 0 | if (VBF%id_Bdif_dz_KS>0.or.VBF%id_Bdif_idz_KS>0.or.VBF%id_Bdif_idV_KS>0) then |
| 289 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_KS, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 290 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_KS, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 291 | 0 | if (VBF%id_Bdif_idz_KS>0) then |
| 292 | 0 | work2d(:,:) = 0.0 |
| 293 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 294 | 0 | 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 | |
| 297 | 0 | if (VBF%id_Bdif_idV_KS>0) then |
| 298 | 0 | work = 0.0 |
| 299 | 0 | 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) + & | |
| 302 | 0 | 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 | |
| 305 | 0 | elseif (VBF%id_Bdif_KS>0) then |
| 306 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_KS, VBF%Bflx_salt) |
| 307 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_KS, VBF%Bflx_temp) |
| 308 | endif | |
| 309 | ! Post Kappa Shear fluxes | |
| 310 | 0 | if (VBF%id_Bdif_KS>0) then |
| 311 | 0 | work3d_i(:,:,:) = 0.0 |
| 312 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 313 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 314 | enddo ; enddo ; enddo | |
| 315 | 0 | call post_data(VBF%id_Bdif_KS, work3d_i, diag) |
| 316 | endif | |
| 317 | 0 | if (VBF%id_Bdif_dz_KS>0) then |
| 318 | 0 | work3d_l(:,:,:) = 0.0 |
| 319 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 320 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 321 | enddo ; enddo ; enddo | |
| 322 | 0 | call post_data(VBF%id_Bdif_dz_KS, work3d_l, diag) |
| 323 | endif | |
| 324 | 0 | if (VBF%id_Bdif_idz_KS>0) call post_data(VBF%id_Bdif_idz_KS, work2d, diag) |
| 325 | 0 | if (VBF%id_Bdif_idV_KS>0) call post_data(VBF%id_Bdif_idV_KS, work, diag) |
| 326 | ||
| 327 | ! Compute bkgnd fluxes | |
| 328 | 0 | if (VBF%id_Bdif_dz_bkgnd>0.or.VBF%id_Bdif_idz_bkgnd>0.or.VBF%id_Bdif_idV_bkgnd>0) then |
| 329 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_bkgnd, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 330 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_bkgnd, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 331 | 0 | if (VBF%id_Bdif_idz_bkgnd>0) then |
| 332 | 0 | work2d(:,:) = 0.0 |
| 333 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 334 | 0 | 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 | |
| 337 | 0 | if (VBF%id_Bdif_idV_bkgnd>0) then |
| 338 | 0 | work = 0.0 |
| 339 | 0 | 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) + & | |
| 342 | 0 | 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 | |
| 345 | 0 | elseif (VBF%id_Bdif_bkgnd>0) then |
| 346 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_bkgnd, VBF%Bflx_salt) |
| 347 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_bkgnd, VBF%Bflx_temp) |
| 348 | endif | |
| 349 | ! Post bkgnd fluxes | |
| 350 | 0 | if (VBF%id_Bdif_bkgnd>0) then |
| 351 | 0 | work3d_i(:,:,:) = 0.0 |
| 352 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 353 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 354 | enddo ; enddo ; enddo | |
| 355 | 0 | call post_data(VBF%id_Bdif_bkgnd, work3d_i, diag) |
| 356 | endif | |
| 357 | 0 | if (VBF%id_Bdif_dz_bkgnd>0) then |
| 358 | 0 | work3d_l(:,:,:) = 0.0 |
| 359 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 360 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 361 | enddo ; enddo ; enddo | |
| 362 | 0 | call post_data(VBF%id_Bdif_dz_bkgnd, work3d_l, diag) |
| 363 | endif | |
| 364 | 0 | if (VBF%id_Bdif_idz_bkgnd>0) call post_data(VBF%id_Bdif_idz_bkgnd, work2d, diag) |
| 365 | 0 | if (VBF%id_Bdif_idV_bkgnd>0) call post_data(VBF%id_Bdif_idV_bkgnd, work, diag) |
| 366 | ||
| 367 | ! Compute double diffusion fluxes | |
| 368 | 0 | 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 |
| 369 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ddiff_T, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 370 | 0 | if (VBF%id_Bdif_idz_ddiff_temp>0) then |
| 371 | 0 | work2d_temp(:,:) = 0.0 |
| 372 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 373 | 0 | work2d_temp(i,j) = work2d_temp(i,j) + VBF%Bflx_temp_dz(i,j,k) |
| 374 | enddo ; enddo ; enddo | |
| 375 | endif | |
| 376 | 0 | if (VBF%id_Bdif_idV_ddiff_temp>0) then |
| 377 | 0 | work_temp = 0.0 |
| 378 | 0 | do k = 1,nz |
| 379 | work_temp = work_temp + global_area_integral(VBF%Bflx_temp_dz(:,:,k), G, & | |
| 380 | 0 | tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) |
| 381 | enddo | |
| 382 | endif | |
| 383 | 0 | elseif (VBF%id_Bdif_ddiff_temp>0) then |
| 384 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_ddiff_T, VBF%Bflx_temp) |
| 385 | endif | |
| 386 | 0 | 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 |
| 387 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ddiff_S, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 388 | 0 | if (VBF%id_Bdif_idz_ddiff_salt>0) then |
| 389 | 0 | work2d_salt(:,:) = 0.0 |
| 390 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 391 | 0 | work2d_salt(i,j) = work2d_salt(i,j) + VBF%Bflx_salt_dz(i,j,k) |
| 392 | enddo ; enddo ; enddo | |
| 393 | endif | |
| 394 | 0 | if (VBF%id_Bdif_idV_ddiff_salt>0) then |
| 395 | 0 | work_salt = 0.0 |
| 396 | 0 | do k = 1,nz |
| 397 | work_salt = work_salt + global_area_integral(VBF%Bflx_salt_dz(:,:,k), G, & | |
| 398 | 0 | tmp_scale=GV%H_to_kg_m2*US%Z_to_m**2*US%s_to_T**3) |
| 399 | enddo | |
| 400 | endif | |
| 401 | 0 | elseif (VBF%id_Bdif_ddiff_salt>0) then |
| 402 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_ddiff_S, VBF%Bflx_salt) |
| 403 | endif | |
| 404 | ! Post double diffusion fluxes | |
| 405 | 0 | if (VBF%id_Bdif_ddiff_temp>0) call post_data(VBF%id_Bdif_ddiff_temp, VBF%Bflx_temp, diag) |
| 406 | 0 | if (VBF%id_Bdif_dz_ddiff_temp>0) call post_data(VBF%id_Bdif_dz_ddiff_temp, VBF%Bflx_temp_dz, diag) |
| 407 | 0 | if (VBF%id_Bdif_idz_ddiff_temp>0) call post_data(VBF%id_Bdif_idz_ddiff_temp, work2d_temp, diag) |
| 408 | 0 | if (VBF%id_Bdif_idV_ddiff_temp>0) call post_data(VBF%id_Bdif_idV_ddiff_temp, work_temp, diag) |
| 409 | 0 | if (VBF%id_Bdif_ddiff_salt>0) call post_data(VBF%id_Bdif_ddiff_salt, VBF%Bflx_salt, diag) |
| 410 | 0 | if (VBF%id_Bdif_dz_ddiff_salt>0) call post_data(VBF%id_Bdif_dz_ddiff_salt, VBF%Bflx_salt_dz, diag) |
| 411 | 0 | if (VBF%id_Bdif_idz_ddiff_salt>0) call post_data(VBF%id_Bdif_idz_ddiff_salt, work2d_salt, diag) |
| 412 | 0 | 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 | |
| 415 | 0 | if (VBF%id_Bdif_dz_leak>0.or.VBF%id_Bdif_idz_leak>0.or.VBF%id_Bdif_idV_leak>0) then |
| 416 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_leak, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 417 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_leak, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 418 | 0 | if (VBF%id_Bdif_idz_leak>0) then |
| 419 | 0 | work2d(:,:) = 0.0 |
| 420 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 421 | 0 | 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 | |
| 424 | 0 | if (VBF%id_Bdif_idV_leak>0) then |
| 425 | 0 | work = 0.0 |
| 426 | 0 | 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) + & | |
| 429 | 0 | 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 | |
| 432 | 0 | elseif (VBF%id_Bdif_leak>0) then |
| 433 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_leak, VBF%Bflx_salt) |
| 434 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_leak, VBF%Bflx_temp) |
| 435 | endif | |
| 436 | ! Post Kd_leak fluxes | |
| 437 | 0 | if (VBF%id_Bdif_leak>0) then |
| 438 | 0 | work3d_i(:,:,:) = 0.0 |
| 439 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 440 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 441 | enddo ; enddo ; enddo | |
| 442 | 0 | call post_data(VBF%id_Bdif_leak, work3d_i, diag) |
| 443 | endif | |
| 444 | 0 | if (VBF%id_Bdif_dz_leak>0) then |
| 445 | 0 | work3d_l(:,:,:) = 0.0 |
| 446 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 447 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 448 | enddo ; enddo ; enddo | |
| 449 | 0 | call post_data(VBF%id_Bdif_dz_leak, work3d_l, diag) |
| 450 | endif | |
| 451 | 0 | if (VBF%id_Bdif_idz_leak>0) call post_data(VBF%id_Bdif_idz_leak, work2d, diag) |
| 452 | 0 | if (VBF%id_Bdif_idV_leak>0) call post_data(VBF%id_Bdif_idV_leak, work, diag) |
| 453 | ||
| 454 | ! Compute Kd_quad fluxes | |
| 455 | 0 | if (VBF%id_Bdif_dz_quad>0.or.VBF%id_Bdif_idz_quad>0.or.VBF%id_Bdif_idV_quad>0) then |
| 456 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_quad, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 457 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_quad, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 458 | 0 | if (VBF%id_Bdif_idz_quad>0) then |
| 459 | 0 | work2d(:,:) = 0.0 |
| 460 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 461 | 0 | 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 | |
| 464 | 0 | if (VBF%id_Bdif_idV_quad>0) then |
| 465 | 0 | work = 0.0 |
| 466 | 0 | 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) + & | |
| 469 | 0 | 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 | |
| 472 | 0 | elseif (VBF%id_Bdif_quad>0) then |
| 473 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_quad, VBF%Bflx_salt) |
| 474 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_quad, VBF%Bflx_temp) |
| 475 | endif | |
| 476 | ! Post Kd_quad fluxes | |
| 477 | 0 | if (VBF%id_Bdif_quad>0) then |
| 478 | 0 | work3d_i(:,:,:) = 0.0 |
| 479 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 480 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 481 | enddo ; enddo ; enddo | |
| 482 | 0 | call post_data(VBF%id_Bdif_quad, work3d_i, diag) |
| 483 | endif | |
| 484 | 0 | if (VBF%id_Bdif_dz_quad>0) then |
| 485 | 0 | work3d_l(:,:,:) = 0.0 |
| 486 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 487 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 488 | enddo ; enddo ; enddo | |
| 489 | 0 | call post_data(VBF%id_Bdif_dz_quad, work3d_l, diag) |
| 490 | endif | |
| 491 | 0 | if (VBF%id_Bdif_idz_quad>0) call post_data(VBF%id_Bdif_idz_quad, work2d, diag) |
| 492 | 0 | if (VBF%id_Bdif_idV_quad>0) call post_data(VBF%id_Bdif_idV_quad, work, diag) |
| 493 | ||
| 494 | ! Compute Kd_itidal fluxes | |
| 495 | 0 | if (VBF%id_Bdif_dz_itidal>0.or.VBF%id_Bdif_idz_itidal>0.or.VBF%id_Bdif_idV_itidal>0) then |
| 496 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itidal, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 497 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itidal, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 498 | 0 | if (VBF%id_Bdif_idz_itidal>0) then |
| 499 | 0 | work2d(:,:) = 0.0 |
| 500 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 501 | 0 | 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 | |
| 504 | 0 | if (VBF%id_Bdif_idV_itidal>0) then |
| 505 | 0 | work = 0.0 |
| 506 | 0 | 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) + & | |
| 509 | 0 | 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 | |
| 512 | 0 | elseif (VBF%id_Bdif_itidal>0) then |
| 513 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itidal, VBF%Bflx_salt) |
| 514 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itidal, VBF%Bflx_temp) |
| 515 | endif | |
| 516 | ! Post Kd_itidal fluxes | |
| 517 | 0 | if (VBF%id_Bdif_itidal>0) then |
| 518 | 0 | work3d_i(:,:,:) = 0.0 |
| 519 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 520 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 521 | enddo ; enddo ; enddo | |
| 522 | 0 | call post_data(VBF%id_Bdif_itidal, work3d_i, diag) |
| 523 | endif | |
| 524 | 0 | if (VBF%id_Bdif_dz_itidal>0) then |
| 525 | 0 | work3d_l(:,:,:) = 0.0 |
| 526 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 527 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k)+VBF%Bflx_salt_dz(i,j,k) |
| 528 | enddo ; enddo ; enddo | |
| 529 | 0 | call post_data(VBF%id_Bdif_dz_itidal, work3d_l, diag) |
| 530 | endif | |
| 531 | 0 | if (VBF%id_Bdif_idz_itidal>0) call post_data(VBF%id_Bdif_idz_itidal, work2d, diag) |
| 532 | 0 | if (VBF%id_Bdif_idV_itidal>0) call post_data(VBF%id_Bdif_idV_itidal, work, diag) |
| 533 | ||
| 534 | ! Compute Kd_Froude fluxes | |
| 535 | 0 | if (VBF%id_Bdif_dz_Froude>0.or.VBF%id_Bdif_idz_Froude>0.or.VBF%id_Bdif_idV_Froude>0) then |
| 536 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Froude, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 537 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Froude, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 538 | 0 | if (VBF%id_Bdif_idz_Froude>0) then |
| 539 | 0 | work2d(:,:) = 0.0 |
| 540 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 541 | 0 | 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 | |
| 544 | 0 | if (VBF%id_Bdif_idV_Froude>0) then |
| 545 | 0 | work = 0.0 |
| 546 | 0 | 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) + & | |
| 549 | 0 | 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 | |
| 552 | 0 | elseif (VBF%id_Bdif_Froude>0) then |
| 553 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Froude, VBF%Bflx_salt) |
| 554 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Froude, VBF%Bflx_temp) |
| 555 | endif | |
| 556 | ! Post Kd_Froude fluxes | |
| 557 | 0 | if (VBF%id_Bdif_Froude>0) then |
| 558 | 0 | work3d_i(:,:,:) = 0.0 |
| 559 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 560 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 561 | enddo ; enddo ; enddo | |
| 562 | 0 | call post_data(VBF%id_Bdif_Froude, work3d_i, diag) |
| 563 | endif | |
| 564 | 0 | if (VBF%id_Bdif_dz_Froude>0) then |
| 565 | 0 | work3d_l(:,:,:) = 0.0 |
| 566 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 567 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 568 | enddo ; enddo ; enddo | |
| 569 | 0 | call post_data(VBF%id_Bdif_dz_Froude, work3d_l, diag) |
| 570 | endif | |
| 571 | 0 | if (VBF%id_Bdif_idz_Froude>0) call post_data(VBF%id_Bdif_idz_Froude, work2d, diag) |
| 572 | 0 | if (VBF%id_Bdif_idV_Froude>0) call post_data(VBF%id_Bdif_idV_Froude, work, diag) |
| 573 | ||
| 574 | ! Compute Kd_slope fluxes | |
| 575 | 0 | if (VBF%id_Bdif_dz_slope>0.or.VBF%id_Bdif_idz_slope>0.or.VBF%id_Bdif_idV_slope>0) then |
| 576 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_slope, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 577 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_slope, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 578 | 0 | if (VBF%id_Bdif_idz_slope>0) then |
| 579 | 0 | work2d(:,:) = 0.0 |
| 580 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 581 | 0 | 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 | |
| 584 | 0 | if (VBF%id_Bdif_idV_slope>0) then |
| 585 | 0 | work = 0.0 |
| 586 | 0 | 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) + & | |
| 589 | 0 | 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 | |
| 592 | 0 | elseif (VBF%id_Bdif_slope>0) then |
| 593 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_slope, VBF%Bflx_salt) |
| 594 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_slope, VBF%Bflx_temp) |
| 595 | endif | |
| 596 | ! Post Kd_slope fluxes | |
| 597 | 0 | if (VBF%id_Bdif_slope>0) then |
| 598 | 0 | work3d_i(:,:,:) = 0.0 |
| 599 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 600 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 601 | enddo ; enddo ; enddo | |
| 602 | 0 | call post_data(VBF%id_Bdif_slope, work3d_i, diag) |
| 603 | endif | |
| 604 | 0 | if (VBF%id_Bdif_dz_slope>0) then |
| 605 | 0 | work3d_l(:,:,:) = 0.0 |
| 606 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 607 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 608 | enddo ; enddo ; enddo | |
| 609 | 0 | call post_data(VBF%id_Bdif_dz_slope, work3d_l, diag) |
| 610 | endif | |
| 611 | 0 | if (VBF%id_Bdif_idz_slope>0) call post_data(VBF%id_Bdif_idz_slope, work2d, diag) |
| 612 | 0 | if (VBF%id_Bdif_idV_slope>0) call post_data(VBF%id_Bdif_idV_slope, work, diag) |
| 613 | ||
| 614 | ! Compute Kd_lowmode fluxes | |
| 615 | 0 | if (VBF%id_Bdif_dz_lowmode>0.or.VBF%id_Bdif_idz_lowmode>0.or.VBF%id_Bdif_idV_lowmode>0) then |
| 616 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_lowmode, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 617 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_lowmode, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 618 | 0 | if (VBF%id_Bdif_idz_lowmode>0) then |
| 619 | 0 | work2d(:,:) = 0.0 |
| 620 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 621 | 0 | 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 | |
| 624 | 0 | if (VBF%id_Bdif_idV_lowmode>0) then |
| 625 | 0 | work = 0.0 |
| 626 | 0 | 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) + & | |
| 629 | 0 | 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 | |
| 632 | 0 | elseif (VBF%id_Bdif_lowmode>0) then |
| 633 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_lowmode, VBF%Bflx_salt) |
| 634 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_lowmode, VBF%Bflx_temp) |
| 635 | endif | |
| 636 | ! Post Kd_lowmode fluxes | |
| 637 | 0 | if (VBF%id_Bdif_lowmode>0) then |
| 638 | 0 | work3d_i(:,:,:) = 0.0 |
| 639 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 640 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 641 | enddo ; enddo ; enddo | |
| 642 | 0 | call post_data(VBF%id_Bdif_lowmode, work3d_i, diag) |
| 643 | endif | |
| 644 | 0 | if (VBF%id_Bdif_dz_lowmode>0) then |
| 645 | 0 | work3d_l(:,:,:) = 0.0 |
| 646 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 647 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 648 | enddo ; enddo ; enddo | |
| 649 | 0 | call post_data(VBF%id_Bdif_dz_lowmode, work3d_l, diag) |
| 650 | endif | |
| 651 | 0 | if (VBF%id_Bdif_idz_lowmode>0) call post_data(VBF%id_Bdif_idz_lowmode, work2d, diag) |
| 652 | 0 | if (VBF%id_Bdif_idV_lowmode>0) call post_data(VBF%id_Bdif_idV_lowmode, work, diag) |
| 653 | ||
| 654 | ! Compute Kd_Niku fluxes | |
| 655 | 0 | if (VBF%id_Bdif_dz_Niku>0 .or. VBF%id_Bdif_idz_Niku>0 .or. VBF%id_Bdif_idV_Niku>0) then |
| 656 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Niku, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 657 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Niku, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 658 | 0 | if (VBF%id_Bdif_idz_Niku>0) then |
| 659 | 0 | work2d(:,:) = 0.0 |
| 660 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 661 | 0 | 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 | |
| 664 | 0 | if (VBF%id_Bdif_idV_Niku>0) then |
| 665 | 0 | work = 0.0 |
| 666 | 0 | 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) + & | |
| 669 | 0 | 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 | |
| 672 | 0 | elseif (VBF%id_Bdif_Niku>0) then |
| 673 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_Niku, VBF%Bflx_salt) |
| 674 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_Niku, VBF%Bflx_temp) |
| 675 | endif | |
| 676 | ! Post Kd_Niku fluxes | |
| 677 | 0 | if (VBF%id_Bdif_Niku>0) then |
| 678 | 0 | work3d_i(:,:,:) = 0.0 |
| 679 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 680 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 681 | enddo ; enddo ; enddo | |
| 682 | 0 | call post_data(VBF%id_Bdif_lowmode, work3d_i, diag) |
| 683 | endif | |
| 684 | 0 | if (VBF%id_Bdif_dz_Niku>0) then |
| 685 | 0 | work3d_l(:,:,:) = 0.0 |
| 686 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 687 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 688 | enddo ; enddo ; enddo | |
| 689 | 0 | call post_data(VBF%id_Bdif_dz_Niku, work3d_l, diag) |
| 690 | endif | |
| 691 | 0 | if (VBF%id_Bdif_idz_Niku>0) call post_data(VBF%id_Bdif_idz_Niku, work2d, diag) |
| 692 | 0 | if (VBF%id_Bdif_idV_Niku>0) call post_data(VBF%id_Bdif_idV_Niku, work, diag) |
| 693 | ||
| 694 | ! Compute Kd_itides fluxes | |
| 695 | 0 | if (VBF%id_Bdif_dz_itides>0 .or. VBF%id_Bdif_idz_itides>0 .or. VBF%id_Bdif_idV_itides>0) then |
| 696 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itides, VBF%Bflx_salt, dz=dz, Bdif_flx_dz=VBF%Bflx_salt_dz) |
| 697 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itides, VBF%Bflx_temp, dz=dz, Bdif_flx_dz=VBF%Bflx_temp_dz) |
| 698 | 0 | if (VBF%id_Bdif_idz_itides>0) then |
| 699 | 0 | work2d(:,:) = 0.0 |
| 700 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 701 | 0 | 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 | |
| 704 | 0 | if (VBF%id_Bdif_idV_itides>0) then |
| 705 | 0 | work = 0.0 |
| 706 | 0 | 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) + & | |
| 709 | 0 | 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 | |
| 712 | 0 | elseif (VBF%id_Bdif_itides>0) then |
| 713 | 0 | call diagnoseKdWork(G, GV, N2_salt, VBF%Kd_itides, VBF%Bflx_salt) |
| 714 | 0 | call diagnoseKdWork(G, GV, N2_temp, VBF%Kd_itides, VBF%Bflx_temp) |
| 715 | endif | |
| 716 | ! Post Kd_itides fluxes | |
| 717 | 0 | if (VBF%id_Bdif_itides>0) then |
| 718 | 0 | work3d_i(:,:,:) = 0.0 |
| 719 | 0 | do k = 1,nz+1 ; do j = jsc,jec ; do i = isc,iec |
| 720 | 0 | work3d_i(i,j,k) = VBF%Bflx_temp(i,j,k) + VBF%Bflx_salt(i,j,k) |
| 721 | enddo ; enddo ; enddo | |
| 722 | 0 | call post_data(VBF%id_Bdif_itides, work3d_i, diag) |
| 723 | endif | |
| 724 | 0 | if (VBF%id_Bdif_dz_itides>0) then |
| 725 | 0 | work3d_l(:,:,:) = 0.0 |
| 726 | 0 | do k = 1,nz ; do j = jsc,jec ; do i = isc,iec |
| 727 | 0 | work3d_l(i,j,k) = VBF%Bflx_temp_dz(i,j,k) + VBF%Bflx_salt_dz(i,j,k) |
| 728 | enddo ; enddo ; enddo | |
| 729 | 0 | call post_data(VBF%id_Bdif_dz_itides, work3d_l, diag) |
| 730 | endif | |
| 731 | 0 | if (VBF%id_Bdif_idz_itides>0) call post_data(VBF%id_Bdif_idz_itides, work2d, diag) |
| 732 | 0 | if (VBF%id_Bdif_idV_itides>0) call post_data(VBF%id_Bdif_idV_itides, work, diag) |
| 733 | ||
| 734 | 0 | end subroutine KdWork_Diagnostics |
| 735 | ||
| 736 | !> Diagnose the implied "work", or buoyancy forcing & its integral, due to a given diffusivity and column state. | |
| 737 | 0 | subroutine 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 | ||
| 753 | 0 | Bdif_flx(:,:,1) = 0.0 |
| 754 | 0 | Bdif_flx(:,:,GV%ke+1) = 0.0 |
| 755 | !$OMP parallel do default(shared) | |
| 756 | 0 | do K=2,GV%ke ; do j=G%jsc,G%jec ; do i=G%isc,G%iec |
| 757 | 0 | Bdif_flx(i,j,K) = - N2(i,j,K) * Kd(i,j,K) |
| 758 | enddo ; enddo ; enddo | |
| 759 | ||
| 760 | 0 | if (present(Bdif_flx_dz) .and. present(dz)) then |
| 761 | !$OMP parallel do default(shared) | |
| 762 | 0 | do K=1,GV%ke ; do j=G%jsc,G%jec ; do i=G%isc,G%iec |
| 763 | 0 | 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 | ||
| 767 | 0 | end subroutine diagnoseKdWork |
| 768 | ||
| 769 | !> Allocates arrays only when needed | |
| 770 | 0 | subroutine 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 | ||
| 777 | 0 | isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed ; nz = GV%ke |
| 778 | ||
| 779 | 0 | if (VBF%do_bflx_salt) & |
| 780 | 0 | allocate(VBF%Bflx_salt(isd:ied,jsd:jed,nz+1), source=0.0) |
| 781 | 0 | if (VBF%do_bflx_salt_dz) & |
| 782 | 0 | allocate(VBF%Bflx_salt_dz(isd:ied,jsd:jed,nz), source=0.0) |
| 783 | 0 | if (VBF%do_bflx_temp) & |
| 784 | 0 | allocate(VBF%Bflx_temp(isd:ied,jsd:jed,nz+1), source=0.0) |
| 785 | 0 | if (VBF%do_bflx_temp_dz) & |
| 786 | 0 | 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. & | |
| 789 | 0 | 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) & |
| 790 | 0 | 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. & | |
| 792 | 0 | 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) & |
| 793 | 0 | allocate(VBF%Kd_temp(isd:ied,jsd:jed,nz+1), source=0.0) |
| 794 | ||
| 795 | 0 | 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) & |
| 796 | 0 | allocate(VBF%Kd_BBL(isd:ied,jsd:jed,nz+1), source=0.0) |
| 797 | 0 | 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) & |
| 798 | 0 | allocate(VBF%Kd_ePBL(isd:ied,jsd:jed,nz+1), source=0.0) |
| 799 | 0 | 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) & |
| 800 | 0 | allocate(VBF%Kd_KS(isd:ied,jsd:jed,nz+1), source=0.0) |
| 801 | 0 | 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) & |
| 802 | 0 | 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 & | |
| 804 | 0 | .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 & | |
| 806 | 0 | .or. VBF%id_Bdif_idV_ddiff_salt>0) allocate(VBF%Kd_ddiff_S(isd:ied,jsd:jed,nz+1), source=0.0) |
| 807 | 0 | 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) & |
| 808 | 0 | allocate(VBF%Kd_leak(isd:ied,jsd:jed,nz+1), source=0.0) |
| 809 | 0 | 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) & |
| 810 | 0 | allocate(VBF%Kd_quad(isd:ied,jsd:jed,nz+1), source=0.0) |
| 811 | 0 | 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) & |
| 812 | 0 | allocate(VBF%Kd_itidal(isd:ied,jsd:jed,nz+1), source=0.0) |
| 813 | 0 | 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) & |
| 814 | 0 | allocate(VBF%Kd_Froude(isd:ied,jsd:jed,nz+1), source=0.0) |
| 815 | 0 | 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) & |
| 816 | 0 | allocate(VBF%Kd_slope(isd:ied,jsd:jed,nz+1), source=0.0) |
| 817 | 0 | if (VBF%id_Bdif_lowmode>0 .or. VBF%id_Bdif_dz_lowmode>0 .or. VBF%id_Bdif_idz_lowmode>0 .or. & |
| 818 | 0 | VBF%id_Bdif_idV_lowmode>0) allocate(VBF%Kd_lowmode(isd:ied,jsd:jed,nz+1), source=0.0) |
| 819 | 0 | 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) & |
| 820 | 0 | allocate(VBF%Kd_Niku(isd:ied,jsd:jed,nz+1), source=0.0) |
| 821 | 0 | 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) & |
| 822 | 0 | allocate(VBF%Kd_itides(isd:ied,jsd:jed,nz+1), source=0.0) |
| 823 | ||
| 824 | 0 | end subroutine Allocate_VBF_CS |
| 825 | ||
| 826 | !> Deallocate any arrays that were allocated | |
| 827 | 0 | subroutine Deallocate_VBF_CS(VBF) |
| 828 | type (vbf_CS), intent(inout) :: VBF !< Vertical buoyancy flux structure | |
| 829 | ||
| 830 | 0 | if (associated(VBF%Bflx_salt)) & |
| 831 | 0 | deallocate(VBF%Bflx_salt) |
| 832 | 0 | if (associated(VBF%Bflx_temp)) & |
| 833 | 0 | deallocate(VBF%Bflx_temp) |
| 834 | 0 | if (associated(VBF%Bflx_salt_dz)) & |
| 835 | 0 | deallocate(VBF%Bflx_salt_dz) |
| 836 | 0 | if (associated(VBF%Bflx_temp_dz)) & |
| 837 | 0 | deallocate(VBF%Bflx_temp_dz) |
| 838 | 0 | if (associated(VBF%Kd_salt)) & |
| 839 | 0 | deallocate(VBF%Kd_salt) |
| 840 | 0 | if (associated(VBF%Kd_temp)) & |
| 841 | 0 | deallocate(VBF%Kd_temp) |
| 842 | 0 | if (associated(VBF%Kd_BBL)) & |
| 843 | 0 | deallocate(VBF%Kd_BBL) |
| 844 | 0 | if (associated(VBF%Kd_ePBL)) & |
| 845 | 0 | deallocate(VBF%Kd_ePBL) |
| 846 | 0 | if (associated(VBF%Kd_KS)) & |
| 847 | 0 | deallocate(VBF%Kd_KS) |
| 848 | 0 | if (associated(VBF%Kd_bkgnd)) & |
| 849 | 0 | deallocate(VBF%Kd_bkgnd) |
| 850 | 0 | if (associated(VBF%Kd_ddiff_T)) & |
| 851 | 0 | deallocate(VBF%Kd_ddiff_T) |
| 852 | 0 | if (associated(VBF%Kd_ddiff_S)) & |
| 853 | 0 | deallocate(VBF%Kd_ddiff_S) |
| 854 | 0 | if (associated(VBF%Kd_leak)) & |
| 855 | 0 | deallocate(VBF%Kd_leak) |
| 856 | 0 | if (associated(VBF%Kd_quad)) & |
| 857 | 0 | deallocate(VBF%Kd_quad) |
| 858 | 0 | if (associated(VBF%Kd_itidal)) & |
| 859 | 0 | deallocate(VBF%Kd_itidal) |
| 860 | 0 | if (associated(VBF%Kd_Froude)) & |
| 861 | 0 | deallocate(VBF%Kd_Froude) |
| 862 | 0 | if (associated(VBF%Kd_slope)) & |
| 863 | 0 | deallocate(VBF%Kd_slope) |
| 864 | 0 | if (associated(VBF%Kd_lowmode)) & |
| 865 | 0 | deallocate(VBF%Kd_lowmode) |
| 866 | 0 | if (associated(VBF%Kd_Niku)) & |
| 867 | 0 | deallocate(VBF%Kd_Niku) |
| 868 | 0 | if (associated(VBF%Kd_itides)) & |
| 869 | 0 | deallocate(VBF%Kd_itides) |
| 870 | ||
| 871 | 0 | end subroutine Deallocate_VBF_CS |
| 872 | ||
| 873 | !> Handles all KdWork diagnostics and flags which calculations should be done. | |
| 874 | 1 | subroutine 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 | ||
| 883 | 1 | allocate(VBF) |
| 884 | ||
| 885 | 1 | VBF%do_bflx_salt = .false. |
| 886 | 1 | VBF%do_bflx_salt_dz = .false. |
| 887 | 1 | VBF%do_bflx_temp = .false. |
| 888 | 1 | 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", & | |
| 892 | 1 | "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.", & | |
| 895 | 1 | "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.", & | |
| 898 | 1 | "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.", & | |
| 901 | 1 | 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", & | |
| 905 | 1 | "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.", & | |
| 908 | 1 | "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.", & | |
| 911 | 1 | "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.", & | |
| 914 | 1 | 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", & | |
| 918 | 1 | "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.", & | |
| 921 | 1 | "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.", & | |
| 924 | 1 | "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.", & | |
| 927 | 1 | 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.", & | |
| 931 | 1 | "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.", & | |
| 934 | 1 | "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.", & | |
| 937 | 1 | "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.", & | |
| 940 | 1 | 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", & | |
| 944 | 1 | "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.", & | |
| 947 | 1 | "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.", & | |
| 950 | 1 | "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.", & | |
| 953 | 1 | 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", & | |
| 957 | 1 | "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.", & | |
| 960 | 1 | "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.", & | |
| 963 | 1 | "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.", & | |
| 966 | 1 | 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", & | |
| 970 | 1 | "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", & | |
| 973 | 1 | "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", & | |
| 976 | 1 | "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.", & | |
| 979 | 1 | 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", & | |
| 983 | 1 | "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.", & | |
| 986 | 1 | "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.", & | |
| 989 | 1 | "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.", & | |
| 992 | 1 | 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", & | |
| 996 | 1 | "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.", & | |
| 999 | 1 | "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.", & | |
| 1002 | 1 | "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.", & | |
| 1005 | 1 | 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", & | |
| 1009 | 1 | "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", & | |
| 1012 | 1 | "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", & | |
| 1015 | 1 | "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.", & | |
| 1018 | 1 | 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", & | |
| 1022 | 1 | "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", & | |
| 1025 | 1 | "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", & | |
| 1028 | 1 | "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.", & | |
| 1031 | 1 | 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", & | |
| 1035 | 1 | "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", & | |
| 1038 | 1 | "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", & | |
| 1041 | 1 | "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.", & | |
| 1044 | 1 | 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", & | |
| 1048 | 1 | "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", & | |
| 1051 | 1 | "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", & | |
| 1054 | 1 | "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.", & | |
| 1057 | 1 | 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", & | |
| 1061 | 1 | "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", & | |
| 1064 | 1 | "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", & | |
| 1067 | 1 | "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.", & | |
| 1070 | 1 | 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", & | |
| 1074 | 1 | "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", & | |
| 1077 | 1 | "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", & | |
| 1080 | 1 | "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.", & | |
| 1083 | 1 | 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", & | |
| 1087 | 1 | "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", & | |
| 1090 | 1 | "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", & | |
| 1093 | 1 | "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.", & | |
| 1096 | 1 | 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", & | |
| 1100 | 1 | "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", & | |
| 1103 | 1 | "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", & | |
| 1106 | 1 | "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.", & | |
| 1109 | 1 | 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. & | |
| 1125 | 1 | VBF%id_Bdif_idz_lowmode>0 .or. VBF%id_Bdif_idz_Niku>0 .or. VBF%id_Bdif_idz_itides>0 ) then |
| 1126 | 0 | 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. & | |
| 1142 | 1 | VBF%id_Bdif_idz_lowmode>0 .or. VBF%id_Bdif_idz_Niku>0 .or. VBF%id_Bdif_idz_itides>0 ) then |
| 1143 | 0 | 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. & | |
| 1149 | 1 | 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 | |
| 1151 | 0 | 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. & | |
| 1157 | 1 | 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 | |
| 1159 | 0 | VBF%do_bflx_temp = .true. |
| 1160 | endif | |
| 1161 | ||
| 1162 | 1 | 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 | ||
| 1164 | 1 | end subroutine KdWork_init |
| 1165 | ||
| 1166 | !> Deallocates control structrue | |
| 1167 | 1 | subroutine KdWork_end(VBF) |
| 1168 | type (vbf_CS), pointer, intent(inout) :: VBF !< Vertical buoyancy flux structure | |
| 1169 | ||
| 1170 | 1 | if (associated(VBF)) deallocate(VBF) |
| 1171 | ||
| 1172 | 1 | end 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 | ||
| 1180 | 0 | end module MOM_diagnose_kdwork |