17 use cvmix_convection
, only : cvmix_init_conv, cvmix_coeffs_conv
18 use cvmix_kpp
, only : cvmix_kpp_compute_kobl_depth
20 implicit none ;
private 22 #include <MOM_memory.h> 24 public cvmix_conv_init, calculate_cvmix_conv, cvmix_conv_end, cvmix_conv_is_used
40 integer :: id_n2 = -1, id_kd_conv = -1, id_kv_conv = -1
44 real,
allocatable,
dimension(:,:,:) :: n2
45 real,
allocatable,
dimension(:,:,:) :: kd_conv
46 real,
allocatable,
dimension(:,:,:) :: kv_conv
50 character(len=40) :: mdl =
"MOM_CVMix_conv" 55 logical function cvmix_conv_init(Time, G, GV, US, param_file, diag, CS)
57 type(time_type),
intent(in) :: Time
62 type(
diag_ctrl),
target,
intent(inout) :: diag
69 #include "version_variable.h" 71 if (
associated(cs))
then 72 call mom_error(warning,
"CVMix_conv_init called with an associated "// &
79 call get_param(param_file, mdl,
"USE_CVMix_CONVECTION", cvmix_conv_init, default=.false., do_not_log=.true.)
81 "Parameterization of enhanced mixing due to convection via CVMix", &
82 all_default=.not.cvmix_conv_init)
83 call get_param(param_file, mdl,
"USE_CVMix_CONVECTION", cvmix_conv_init, &
84 "If true, turns on the enhanced mixing due to convection "//&
85 "via CVMix. This scheme increases diapycnal diffs./viscs. "//&
86 "at statically unstable interfaces. Relevant parameters are "//&
87 "contained in the CVMix_CONVECTION% parameter block.", &
90 if (.not. cvmix_conv_init)
return 92 call get_param(param_file, mdl,
"ENERGETICS_SFC_PBL", useepbl, default=.false., &
98 call mom_error(warning,
'MOM_CVMix_conv_init: '// &
99 'CVMix convection may not be properly applied when ENERGETICS_SFC_PBL = True'//&
100 'as convective mixing might occur in the boundary layer.')
103 call get_param(param_file, mdl,
'DEBUG', cs%debug, default=.false., do_not_log=.true.)
105 call get_param(param_file, mdl,
'MIN_THICKNESS', cs%min_thickness, default=0.001, do_not_log=.true.)
107 call openparameterblock(param_file,
'CVMix_CONVECTION')
109 call get_param(param_file, mdl,
"PRANDTL_CONV", prandtl_conv, &
110 "The turbulent Prandtl number applied to convective "//&
111 "instabilities (i.e., used to convert KD_CONV into KV_CONV)", &
112 units=
"nondim", default=1.0)
114 call get_param(param_file, mdl,
'KD_CONV', cs%kd_conv_const, &
115 "Diffusivity used in convective regime. Corresponding viscosity "//&
116 "(KV_CONV) will be set to KD_CONV * PRANDTL_TURB.", &
117 units=
'm2/s', default=1.00)
119 call get_param(param_file, mdl,
'BV_SQR_CONV', cs%bv_sqr_conv, &
120 "Threshold for squared buoyancy frequency needed to trigger "//&
121 "Brunt-Vaisala parameterization.", &
122 units=
'1/s^2', default=0.0)
124 call closeparameterblock(param_file)
127 cs%kv_conv_const = cs%kd_conv_const * prandtl_conv
130 allocate(cs%N2(szi_(g), szj_(g), szk_(g)+1)); cs%N2(:,:,:) = 0.
131 allocate(cs%kd_conv(szi_(g), szj_(g), szk_(g)+1)); cs%kd_conv(:,:,:) = 0.
132 allocate(cs%kv_conv(szi_(g), szj_(g), szk_(g)+1)); cs%kv_conv(:,:,:) = 0.
136 cs%id_N2 = register_diag_field(
'ocean_model',
'N2_conv', diag%axesTi, time, &
137 'Square of Brunt-Vaisala frequency used by MOM_CVMix_conv module',
'1/s2')
138 cs%id_kd_conv = register_diag_field(
'ocean_model',
'kd_conv', diag%axesTi, time, &
139 'Additional diffusivity added by MOM_CVMix_conv module',
'm2/s', conversion=us%Z2_T_to_m2_s)
140 cs%id_kv_conv = register_diag_field(
'ocean_model',
'kv_conv', diag%axesTi, time, &
141 'Additional viscosity added by MOM_CVMix_conv module',
'm2/s', conversion=us%Z2_T_to_m2_s)
143 call cvmix_init_conv(convect_diff=cs%kd_conv_const, &
144 convect_visc=cs%kv_conv_const, &
145 lbruntvaisala=.true., &
146 bvsqr_convect=cs%bv_sqr_conv)
148 end function cvmix_conv_init
152 subroutine calculate_cvmix_conv(h, tv, G, GV, US, CS, hbl)
157 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(in) :: h
161 real,
dimension(SZI_(G),SZJ_(G)),
intent(in) :: hbl
163 real,
dimension(SZK_(G)) :: rho_lwr
166 real,
dimension(SZK_(G)) :: rho_1d
168 real,
dimension(SZK_(G)+1) :: kv_col
169 real,
dimension(SZK_(G)+1) :: kd_col
170 real,
dimension(SZK_(G)+1) :: iFaceHeight
171 real,
dimension(SZK_(G)) :: cellHeight
182 g_o_rho0 = us%L_to_Z**2*us%s_to_T**2 * gv%g_Earth / gv%Rho0
185 rho_lwr(:) = 0.0; rho_1d(:) = 0.0
192 cs%N2(i,j,g%ke+1) = 0.
197 pref = 0. ;
if (
associated(tv%p_surf)) pref = tv%p_surf(i,j)
202 pref = pref + (gv%H_to_RZ*gv%g_Earth) * h(i,j,k)
204 call calculate_density(tv%t(i,j,k-1), tv%s(i,j,k-1), pref, rhokm1, tv%eqn_of_state)
206 dz = ((0.5*(h(i,j,k-1) + h(i,j,k))+gv%H_subroundoff)*gv%H_to_Z)
207 cs%N2(i,j,k) = g_o_rho0 * (rhok - rhokm1) / dz
215 dh = h(i,j,k) * gv%H_to_m
217 hcorr = min( dh - cs%min_thickness, 0. )
218 dh = max( dh, cs%min_thickness )
219 cellheight(k) = ifaceheight(k) - 0.5 * dh
220 ifaceheight(k+1) = ifaceheight(k) - dh
224 hbl_kpp = us%Z_to_m*hbl(i,j)
225 kobl = cvmix_kpp_compute_kobl_depth(ifaceheight, cellheight, hbl_kpp)
227 kv_col(:) = 0.0 ; kd_col(:) = 0.0
228 call cvmix_coeffs_conv(mdiff_out=kv_col(:), &
229 tdiff_out=kd_col(:), &
232 dens_lwr=rho_lwr(:), &
238 cs%kv_conv(i,j,k) = us%m2_s_to_Z2_T * kv_col(k)
239 cs%Kd_conv(i,j,k) = us%m2_s_to_Z2_T * kd_col(k)
243 cs%kv_conv(i,j,k) = 0.0
244 cs%kd_conv(i,j,k) = 0.0
251 call hchksum(cs%N2,
"MOM_CVMix_conv: N2",g%HI,haloshift=0)
252 call hchksum(cs%kd_conv,
"MOM_CVMix_conv: kd_conv",g%HI,haloshift=0,scale=us%Z2_T_to_m2_s)
253 call hchksum(cs%kv_conv,
"MOM_CVMix_conv: kv_conv",g%HI,haloshift=0,scale=us%m2_s_to_Z2_T)
257 if (cs%id_N2 > 0)
call post_data(cs%id_N2, cs%N2, cs%diag)
258 if (cs%id_kd_conv > 0)
call post_data(cs%id_kd_conv, cs%kd_conv, cs%diag)
259 if (cs%id_kv_conv > 0)
call post_data(cs%id_kv_conv, cs%kv_conv, cs%diag)
261 end subroutine calculate_cvmix_conv
266 logical function cvmix_conv_is_used(param_file)
268 call get_param(param_file, mdl,
"USE_CVMix_CONVECTION", cvmix_conv_is_used, &
269 default=.false., do_not_log = .true.)
271 end function cvmix_conv_is_used
274 subroutine cvmix_conv_end(CS)
278 if (.not.
associated(cs))
return 281 deallocate(cs%kd_conv)
282 deallocate(cs%kv_conv)
285 end subroutine cvmix_conv_end
Ocean grid type. See mom_grid for details.
Calculates density of sea water from T, S and P.
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.
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.
Control structure including parameters for CVMix convection.
Pointers to an assortment of thermodynamic fields that may be available, including potential temperat...
Provides a transparent vertical ocean grid type and supporting routines.
Interface to CVMix convection scheme.
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.