Subroutine for computing vertical diffusion coefficients for the double diffusion mixing parameterization.
144 type(ocean_grid_type),
intent(in) :: G
145 type(verticalGrid_type),
intent(in) :: GV
146 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
147 type(thermo_var_ptrs),
intent(in) :: tv
148 type(unit_scale_type),
intent(in) :: US
149 integer,
intent(in) :: j
151 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(inout) :: Kd_T
153 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(inout) :: Kd_S
155 type(CVMix_ddiff_cs),
pointer :: CS
157 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), &
158 optional,
intent(inout) :: R_rho
161 real,
dimension(SZK_(GV)) :: &
162 cellHeight, & !< Height of cell centers [m]
163 dRho_dT, & !< partial derivatives of density wrt temp [R degC-1 ~> kg m-3 degC-1]
164 dRho_dS, & !< partial derivatives of density wrt saln [R ppt-1 ~> kg m-3 ppt-1]
165 pres_int, & !< pressure at each interface [R L2 T-2 ~> Pa]
166 temp_int, & !< temp and at interfaces [degC]
167 salt_int, & !< salt at at interfaces [ppt]
168 alpha_dT, & !< alpha*dT across interfaces [kg m-3]
169 beta_dS, & !< beta*dS across interfaces [kg m-3]
170 dT, & !< temp. difference between adjacent layers [degC]
172 real,
dimension(SZK_(GV)+1) :: &
173 Kd1_T, & !< Diapycanal diffusivity of temperature [m2 s-1].
176 real,
dimension(SZK_(GV)+1) :: iFaceHeight
182 pres_int(:) = 0.0; temp_int(:) = 0.0; salt_int(:) = 0.0
183 alpha_dt(:) = 0.0; beta_ds(:) = 0.0; drho_dt(:) = 0.0
184 drho_ds(:) = 0.0; dt(:) = 0.0; ds(:) = 0.0
198 if (g%mask2dT(i,j) == 0.) cycle
200 pres_int(1) = 0. ;
if (
associated(tv%p_surf)) pres_int(1) = tv%p_surf(i,j)
202 temp_int(1) = tv%T(i,j,1); salt_int(1) = tv%S(i,j,1)
205 pres_int(k) = pres_int(k-1) + (gv%g_Earth * gv%H_to_RZ) * h(i,j,k-1)
208 temp_int(k) = (tv%T(i,j,k-1)*h(i,j,k-1) + tv%T(i,j,k)*h(i,j,k)) / (h(i,j,k-1)+h(i,j,k))
209 salt_int(k) = (tv%S(i,j,k-1)*h(i,j,k-1) + tv%S(i,j,k)*h(i,j,k)) / (h(i,j,k-1)+h(i,j,k))
211 dt(k) = (tv%T(i,j,k-1)-tv%T(i,j,k))
212 ds(k) = (tv%S(i,j,k-1)-tv%S(i,j,k))
215 call calculate_density_derivs(temp_int, salt_int, pres_int, drho_dt, drho_ds, tv%eqn_of_state)
221 alpha_dt(k) = -1.0*us%R_to_kg_m3*drho_dt(k) * dt(k)
222 beta_ds(k) = us%R_to_kg_m3*drho_ds(k) * ds(k)
225 if (
present(r_rho))
then 228 r_rho(i,j,k) = 0.0 ;
if (abs(beta_ds(k)) > 0.0) r_rho(i,j,k) = alpha_dt(k) / beta_ds(k)
230 if (r_rho(i,j,k) /= r_rho(i,j,k)) r_rho(i,j,k) = 0.0
238 dh = h(i,j,k) * gv%H_to_m
240 hcorr = min( dh - cs%min_thickness, 0. )
241 dh = max( dh, cs%min_thickness )
242 cellheight(k) = ifaceheight(k) - 0.5 * dh
243 ifaceheight(k+1) = ifaceheight(k) - dh
249 kd1_t(:) = 0.0 ; kd1_s(:) = 0.0
250 call cvmix_coeffs_ddiff(tdiff_out=kd1_t(:), &
251 sdiff_out=kd1_s(:), &
252 strat_param_num=alpha_dt(:), &
253 strat_param_denom=beta_ds(:), &
257 kd_t(i,j,k) = us%m2_s_to_Z2_T * kd1_t(k)
258 kd_s(i,j,k) = us%m2_s_to_Z2_T * kd1_s(k)