17 use cvmix_ddiff,
only : cvmix_init_ddiff, cvmix_coeffs_ddiff
18 use cvmix_kpp,
only : cvmix_kpp_compute_kobl_depth
19 implicit none ;
private 21 #include <MOM_memory.h> 23 public cvmix_ddiff_init, cvmix_ddiff_end, cvmix_ddiff_is_used, compute_ddiff_coeffs
29 real :: strat_param_max
35 real :: kappa_ddiff_param1
36 real :: kappa_ddiff_param2
37 real :: kappa_ddiff_param3
39 character(len=4) :: diff_conv_type
45 character(len=40) :: mdl =
"MOM_CVMix_ddiff" 50 logical function cvmix_ddiff_init(Time, G, GV, US, param_file, diag, CS)
52 type(time_type),
intent(in) :: time
57 type(
diag_ctrl),
target,
intent(inout) :: diag
61 #include "version_variable.h" 63 if (
associated(cs))
then 64 call mom_error(warning,
"CVMix_ddiff_init called with an associated "// &
71 call get_param(param_file, mdl,
"USE_CVMIX_DDIFF", cvmix_ddiff_init, default=.false., do_not_log=.true.)
73 "Parameterization of mixing due to double diffusion processes via CVMix", &
74 all_default=.not.cvmix_ddiff_init)
75 call get_param(param_file, mdl,
"USE_CVMIX_DDIFF", cvmix_ddiff_init, &
76 "If true, turns on double diffusive processes via CVMix. "//&
77 "Note that double diffusive processes on viscosity are ignored "//&
78 "in CVMix, see http://cvmix.github.io/ for justification.", &
81 if (.not. cvmix_ddiff_init)
return 83 call get_param(param_file, mdl,
'DEBUG', cs%debug, default=.false., do_not_log=.true.)
85 call get_param(param_file, mdl,
'MIN_THICKNESS', cs%min_thickness, default=0.001, do_not_log=.true.)
87 call openparameterblock(param_file,
'CVMIX_DDIFF')
89 call get_param(param_file, mdl,
"STRAT_PARAM_MAX", cs%strat_param_max, &
90 "The maximum value for the double dissusion stratification parameter", &
91 units=
"nondim", default=2.55)
93 call get_param(param_file, mdl,
"KAPPA_DDIFF_S", cs%kappa_ddiff_s, &
94 "Leading coefficient in formula for salt-fingering regime "//&
95 "for salinity diffusion.", units=
"m2 s-1", default=1.0e-4)
97 call get_param(param_file, mdl,
"DDIFF_EXP1", cs%ddiff_exp1, &
98 "Interior exponent in salt-fingering regime formula.", &
99 units=
"nondim", default=1.0)
101 call get_param(param_file, mdl,
"DDIFF_EXP2", cs%ddiff_exp2, &
102 "Exterior exponent in salt-fingering regime formula.", &
103 units=
"nondim", default=3.0)
105 call get_param(param_file, mdl,
"KAPPA_DDIFF_PARAM1", cs%kappa_ddiff_param1, &
106 "Exterior coefficient in diffusive convection regime.", &
107 units=
"nondim", default=0.909)
109 call get_param(param_file, mdl,
"KAPPA_DDIFF_PARAM2", cs%kappa_ddiff_param2, &
110 "Middle coefficient in diffusive convection regime.", &
111 units=
"nondim", default=4.6)
113 call get_param(param_file, mdl,
"KAPPA_DDIFF_PARAM3", cs%kappa_ddiff_param3, &
114 "Interior coefficient in diffusive convection regime.", &
115 units=
"nondim", default=-0.54)
117 call get_param(param_file, mdl,
"MOL_DIFF", cs%mol_diff, &
118 "Molecular diffusivity used in CVMix double diffusion.", &
119 units=
"m2 s-1", default=1.5e-6)
121 call get_param(param_file, mdl,
"DIFF_CONV_TYPE", cs%diff_conv_type, &
122 "type of diffusive convection to use. Options are Marmorino \n" //&
123 "and Caldwell 1976 (MC76) and Kelley 1988, 1990 (K90).", &
126 call closeparameterblock(param_file)
128 call cvmix_init_ddiff(strat_param_max=cs%strat_param_max, &
129 kappa_ddiff_s=cs%kappa_ddiff_s, &
130 ddiff_exp1=cs%ddiff_exp1, &
131 ddiff_exp2=cs%ddiff_exp2, &
132 mol_diff=cs%mol_diff, &
133 kappa_ddiff_param1=cs%kappa_ddiff_param1, &
134 kappa_ddiff_param2=cs%kappa_ddiff_param2, &
135 kappa_ddiff_param3=cs%kappa_ddiff_param3, &
136 diff_conv_type=cs%diff_conv_type)
138 end function cvmix_ddiff_init
142 subroutine compute_ddiff_coeffs(h, tv, G, GV, US, j, Kd_T, Kd_S, CS, R_rho)
146 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
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
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))
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)
269 end subroutine compute_ddiff_coeffs
274 logical function cvmix_ddiff_is_used(param_file)
276 call get_param(param_file, mdl,
"USE_CVMIX_DDIFF", cvmix_ddiff_is_used, &
277 default=.false., do_not_log = .true.)
279 end function cvmix_ddiff_is_used
282 subroutine cvmix_ddiff_end(CS)
288 end subroutine cvmix_ddiff_end
Control structure including parameters for CVMix double diffusion.
Ocean grid type. See mom_grid for details.
A structure that can be parsed to read and document run-time parameters.
Provides the ocean grid type.
The MOM6 facility to parse input files for runtime parameters.
Make a diagnostic available for averaging or output.
Describes various unit conversion factors.
Provides a transparent unit rescaling type to facilitate dimensional consistency testing.
Routines for error handling and I/O management.
Calculate the derivatives of density with temperature and salinity from T, S, and P.
Provides subroutines for quantities specific to the equation of state.
An overloaded interface to log version information about modules.
Describes the vertical ocean grid, including unit conversion factors.
Interface to CVMix double diffusion scheme.
Pointers to an assortment of thermodynamic fields that may be available, including potential temperat...
Provides a transparent vertical ocean grid type and supporting routines.
Provides transparent structures with groups of MOM6 variables and supporting routines.
An overloaded interface to read and log the values of various types of parameters.
Provides checksumming functions for debugging.