\hypertarget{namespacemom__cvmix__conv}{}\section{mom\+\_\+cvmix\+\_\+conv Module Reference}
\label{namespacemom__cvmix__conv}\index{mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}}


\subsection{Detailed Description}
Interface to C\+V\+Mix convection scheme. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__cvmix__conv_1_1cvmix__conv__cs}{cvmix\+\_\+conv\+\_\+cs}
\begin{DoxyCompactList}\small\item\em Control structure including parameters for C\+V\+Mix convection. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \hyperlink{namespacemom__cvmix__conv_a96b32166eb7623c206f18549da8224ca}{cvmix\+\_\+conv\+\_\+init} (Time, G, GV, US, param\+\_\+file, diag, CS)
\begin{DoxyCompactList}\small\item\em Initialized the C\+V\+Mix convection mixing routine. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__cvmix__conv_ace5bb8e12704ee4d46e4cfb67e6f63f8}{calculate\+\_\+cvmix\+\_\+conv} (h, tv, G, GV, US, CS, hbl, Kd, Kv, Kd\+\_\+aux)
\begin{DoxyCompactList}\small\item\em Subroutine for calculating enhanced diffusivity/viscosity due to convection via C\+V\+Mix. \end{DoxyCompactList}\item 
logical function, public \hyperlink{namespacemom__cvmix__conv_a5e741c84ad14fae3e5801d00a9867bba}{cvmix\+\_\+conv\+\_\+is\+\_\+used} (param\+\_\+file)
\begin{DoxyCompactList}\small\item\em Reads the parameter \char`\"{}\+U\+S\+E\+\_\+\+C\+V\+Mix\+\_\+\+C\+O\+N\+V\+E\+C\+T\+I\+O\+N\char`\"{} and returns state. This function allows other modules to know whether this parameterization will be used without needing to duplicate the log entry. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__cvmix__conv_a4f35df3a407ded91cd67384a14da3a3c}{cvmix\+\_\+conv\+\_\+end} (CS)
\begin{DoxyCompactList}\small\item\em Clear pointers and dealocate memory. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__cvmix__conv_a877a4beb2eff515d903a17b5779adbee}\label{namespacemom__cvmix__conv_a877a4beb2eff515d903a17b5779adbee}} 
character(len=40) \hyperlink{namespacemom__cvmix__conv_a877a4beb2eff515d903a17b5779adbee}{mdl} = \char`\"{}M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+conv\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__cvmix__conv_ace5bb8e12704ee4d46e4cfb67e6f63f8}\label{namespacemom__cvmix__conv_ace5bb8e12704ee4d46e4cfb67e6f63f8}} 
\index{mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}!calculate\+\_\+cvmix\+\_\+conv@{calculate\+\_\+cvmix\+\_\+conv}}
\index{calculate\+\_\+cvmix\+\_\+conv@{calculate\+\_\+cvmix\+\_\+conv}!mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}}
\subsubsection{\texorpdfstring{calculate\+\_\+cvmix\+\_\+conv()}{calculate\_cvmix\_conv()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+cvmix\+\_\+conv\+::calculate\+\_\+cvmix\+\_\+conv (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\hyperlink{structmom__cvmix__conv_1_1cvmix__conv__cs}{cvmix\+\_\+conv\+\_\+cs}), pointer}]{CS,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in)}]{hbl,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke+1), intent(inout), optional}]{Kd,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke+1), intent(inout), optional}]{Kv,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke+1), intent(inout), optional}]{Kd\+\_\+aux }\end{DoxyParamCaption})}



Subroutine for calculating enhanced diffusivity/viscosity due to convection via C\+V\+Mix. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & Grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & Vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em tv} & Thermodynamics structure.\\
\hline
 & {\em cs} & The control structure returned by a previous call to C\+V\+Mix\+\_\+conv\+\_\+init.\\
\hline
\mbox{\tt in}  & {\em hbl} & Depth of ocean boundary layer \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em kd} & Diapycnal diffusivity at each interface that\\
\hline
\mbox{\tt in,out}  & {\em kv} & Viscosity at each interface that will be\\
\hline
\mbox{\tt in,out}  & {\em kd\+\_\+aux} & A second diapycnal diffusivity at each \\
\hline
\end{DoxyParams}


Definition at line 143 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+conv.\+F90.


\begin{DoxyCode}
143 
144   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{  !< Grid structure.}
145   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{ !< Vertical grid structure.}
146   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{ !< A dimensional unit scaling type}
147   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{  !< Layer thickness [H ~> m or kg m-2].}
148   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                     \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{ !< Thermodynamics structure.}
149   \textcolor{keywordtype}{type}(cvmix\_conv\_cs),                       \textcolor{keywordtype}{pointer}     :: cs\textcolor{comment}{ !< The control structure returned}
150 \textcolor{comment}{                                                                !! by a previous call to CVMix\_conv\_init.}
151   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},          \textcolor{keywordtype}{intent(in)}  :: hbl\textcolor{comment}{ !< Depth of ocean boundary layer [Z ~> m]}
152   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, &
153                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: kd\textcolor{comment}{ !< Diapycnal diffusivity at each interface
       that}
154 \textcolor{comment}{                                                                 !! will be incremented here [Z2 T-1 ~> m2
       s-1].}
155   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, &
156                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: kv\textcolor{comment}{ !< Viscosity at each interface that will
       be}
157 \textcolor{comment}{                                                                 !! incremented here [Z2 T-1 ~> m2 s-1].}
158   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, &
159                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: kd\_aux\textcolor{comment}{ !< A second diapycnal diffusivity at
       each}
160 \textcolor{comment}{                                                                 !! interface that will also be incremented}
161 \textcolor{comment}{                                                                 !! here [Z2 T-1 ~> m2 s-1].}
162 
163   \textcolor{comment}{! local variables}
164   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: rho\_lwr\textcolor{comment}{ !< Adiabatic Water Density, this is a dummy}
165 \textcolor{comment}{                                       !! variable since here convection is always}
166 \textcolor{comment}{                                       !! computed based on Brunt Vaisala.}
167   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: rho\_1d\textcolor{comment}{  !< water density in a column, this is also}
168 \textcolor{comment}{                                       !! a dummy variable, same reason as above.}
169   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: n2\textcolor{comment}{    !< Squared buoyancy frequency [s-2]}
170   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: kv\_col\textcolor{comment}{ !< Viscosities at interfaces in the column [m2 s-1]}
171   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: kd\_col\textcolor{comment}{ !< Diffusivities at interfaces in the column [m2 s-1]}
172   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: ifaceheight\textcolor{comment}{ !< Height of interfaces [m]}
173   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}   :: cellheight\textcolor{comment}{  !< Height of cell centers [m]}
174   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: &
175     kd\_conv, &                         !< Diffusivity added by convection for diagnostics [Z2 T-1 ~> m2 s-1
      ]
176     kv\_conv, &                         !< Viscosity added by convection for diagnostics [Z2 T-1 ~> m2 s-1]
177     n2\_3d\textcolor{comment}{                              !< Squared buoyancy frequency for diagnostics [N-2 ~> s-2]}
178   \textcolor{keywordtype}{integer} :: kobl\textcolor{comment}{                      !< level of OBL extent}
179   \textcolor{keywordtype}{real} :: g\_o\_rho0  \textcolor{comment}{! Gravitational acceleration divided by density times unit convserion factors}
180                     \textcolor{comment}{! [Z s-2 R-1 ~> m4 s-2 kg-1]}
181   \textcolor{keywordtype}{real} :: pref      \textcolor{comment}{! Interface pressures [R L2 T-2 ~> Pa]}
182   \textcolor{keywordtype}{real} :: rhok, rhokm1 \textcolor{comment}{! In situ densities of the layers above and below at the interface pressure [R ~> kg
       m-3]}
183   \textcolor{keywordtype}{real} :: hbl\_kpp   \textcolor{comment}{! The depth of the ocean boundary as used by KPP [m]}
184   \textcolor{keywordtype}{real} :: dz        \textcolor{comment}{! A thickness [Z ~> m]}
185   \textcolor{keywordtype}{real} :: dh, hcorr \textcolor{comment}{! Two thicknesses [m]}
186   \textcolor{keywordtype}{integer} :: i, j, k
187 
188   g\_o\_rho0 = us%L\_to\_Z**2*us%s\_to\_T**2 * gv%g\_Earth / gv%Rho0
189 
190   \textcolor{comment}{! initialize dummy variables}
191   rho\_lwr(:) = 0.0 ; rho\_1d(:) = 0.0
192 
193   \textcolor{comment}{! set N2 to zero at the top- and bottom-most interfaces}
194   n2(1) = 0.0 ; n2(gv%ke+1) = 0.0
195 
196   \textcolor{keywordflow}{if} (cs%id\_N2 > 0) n2\_3d(:,:,:) = 0.0
197   \textcolor{keywordflow}{if} (cs%id\_kv\_conv > 0) kv\_conv(:,:,:) = 0.0
198   \textcolor{keywordflow}{if} (cs%id\_kd\_conv > 0) kd\_conv(:,:,:) = 0.0
199 
200   \textcolor{keywordflow}{do} j = g%jsc, g%jec
201     \textcolor{keywordflow}{do} i = g%isc, g%iec
202 
203       \textcolor{comment}{! skip calling at land points}
204       \textcolor{comment}{!if (G%mask2dT(i,j) == 0.) cycle}
205 
206       pref = 0. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%p\_surf)) pref = tv%p\_surf(i,j)
207       \textcolor{comment}{! Compute Brunt-Vaisala frequency (static stability) on interfaces}
208       \textcolor{keywordflow}{do} k=2,gv%ke
209 
210         \textcolor{comment}{! pRef is pressure at interface between k and km1 [R L2 T-2 ~> Pa].}
211         pref = pref + (gv%H\_to\_RZ*gv%g\_Earth) * h(i,j,k)
212         \textcolor{keyword}{call }calculate\_density(tv%t(i,j,k), tv%s(i,j,k), pref, rhok, tv%eqn\_of\_state)
213         \textcolor{keyword}{call }calculate\_density(tv%t(i,j,k-1), tv%s(i,j,k-1), pref, rhokm1, tv%eqn\_of\_state)
214 
215         dz = ((0.5*(h(i,j,k-1) + h(i,j,k))+gv%H\_subroundoff)*gv%H\_to\_Z)
216         n2(k) = g\_o\_rho0 * (rhok - rhokm1) / dz \textcolor{comment}{! Can be negative}
217 
218 \textcolor{keywordflow}{      enddo}
219 
220       ifaceheight(1) = 0.0 \textcolor{comment}{! BBL is all relative to the surface}
221       hcorr = 0.0
222       \textcolor{comment}{! compute heights at cell center and interfaces}
223       \textcolor{keywordflow}{do} k=1,gv%ke
224         dh = h(i,j,k) * gv%H\_to\_m \textcolor{comment}{! Nominal thickness to use for increment, in the units used by CVMix.}
225         dh = dh + hcorr \textcolor{comment}{! Take away the accumulated error (could temporarily make dh<0)}
226         hcorr = min( dh - cs%min\_thickness, 0. ) \textcolor{comment}{! If inflating then hcorr<0}
227         dh = max( dh, cs%min\_thickness ) \textcolor{comment}{! Limit increment dh>=min\_thickness}
228         cellheight(k)    = ifaceheight(k) - 0.5 * dh
229         ifaceheight(k+1) = ifaceheight(k) - dh
230 \textcolor{keywordflow}{      enddo}
231 
232       \textcolor{comment}{! gets index of the level and interface above hbl}
233       hbl\_kpp = us%Z\_to\_m*hbl(i,j)  \textcolor{comment}{! Convert to the units used by CVMix.}
234       kobl = cvmix\_kpp\_compute\_kobl\_depth(ifaceheight, cellheight, hbl\_kpp)
235 
236       kv\_col(:) = 0.0 ; kd\_col(:) = 0.0
237       \textcolor{keyword}{call }cvmix\_coeffs\_conv(mdiff\_out=kv\_col(:), &
238                              tdiff\_out=kd\_col(:), &
239                              nsqr=n2(:), &
240                              dens=rho\_1d(:), &
241                              dens\_lwr=rho\_lwr(:), &
242                              nlev=gv%ke,    &
243                              max\_nlev=gv%ke, &
244                              obl\_ind=kobl)
245 
246       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(kd)) \textcolor{keywordflow}{then}
247         \textcolor{comment}{! Increment the diffusivity outside of the boundary layer.}
248         \textcolor{keywordflow}{do} k=max(1,kobl+1),gv%ke+1
249           kd(i,j,k) = kd(i,j,k) + us%m2\_s\_to\_Z2\_T * kd\_col(k)
250 \textcolor{keywordflow}{        enddo}
251 \textcolor{keywordflow}{      endif}
252       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(kd\_aux)) \textcolor{keywordflow}{then}
253         \textcolor{comment}{! Increment the other diffusivity outside of the boundary layer.}
254         \textcolor{keywordflow}{do} k=max(1,kobl+1),gv%ke+1
255           kd\_aux(i,j,k) = kd\_aux(i,j,k) + us%m2\_s\_to\_Z2\_T * kd\_col(k)
256 \textcolor{keywordflow}{        enddo}
257 \textcolor{keywordflow}{      endif}
258 
259       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(kv)) \textcolor{keywordflow}{then}
260         \textcolor{comment}{! Increment the viscosity outside of the boundary layer.}
261         \textcolor{keywordflow}{do} k=max(1,kobl+1),gv%ke+1
262           kv(i,j,k) = kv(i,j,k) + us%m2\_s\_to\_Z2\_T * kv\_col(k)
263 \textcolor{keywordflow}{        enddo}
264 \textcolor{keywordflow}{      endif}
265 
266       \textcolor{comment}{! Store 3-d arrays for diagnostics.}
267       \textcolor{keywordflow}{if} (cs%id\_kv\_conv > 0) \textcolor{keywordflow}{then}
268         \textcolor{comment}{! Do not apply mixing due to convection within the boundary layer}
269         \textcolor{keywordflow}{do} k=max(1,kobl+1),gv%ke+1
270           kv\_conv(i,j,k) = us%m2\_s\_to\_Z2\_T * kv\_col(k)
271 \textcolor{keywordflow}{        enddo}
272 \textcolor{keywordflow}{      endif}
273       \textcolor{keywordflow}{if} (cs%id\_kd\_conv > 0) \textcolor{keywordflow}{then}
274         \textcolor{comment}{! Do not apply mixing due to convection within the boundary layer}
275         \textcolor{keywordflow}{do} k=max(1,kobl+1),gv%ke+1
276           kd\_conv(i,j,k) = us%m2\_s\_to\_Z2\_T * kd\_col(k)
277 \textcolor{keywordflow}{        enddo}
278 \textcolor{keywordflow}{      endif}
279 
280       \textcolor{keywordflow}{if} (cs%id\_N2 > 0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=2,gv%ke ; n2\_3d(i,j,k) = us%T\_to\_s**2*n2(k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
281 
282 \textcolor{keywordflow}{    enddo}
283 \textcolor{keywordflow}{  enddo}
284 
285   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
286     \textcolor{comment}{! if (CS%id\_N2 > 0) call hchksum(N2\_3d, "MOM\_CVMix\_conv: N2",G%HI,haloshift=0)}
287     \textcolor{comment}{! if (CS%id\_kd\_conv > 0) &}
288     \textcolor{comment}{!   call hchksum(Kd\_conv, "MOM\_CVMix\_conv: Kd\_conv", G%HI, haloshift=0, scale=US%Z2\_T\_to\_m2\_s)}
289     \textcolor{comment}{! if (CS%id\_kv\_conv > 0) &}
290     \textcolor{comment}{!   call hchksum(Kv\_conv, "MOM\_CVMix\_conv: Kv\_conv", G%HI, haloshift=0, scale=US%m2\_s\_to\_Z2\_T)}
291     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(kd)) \textcolor{keyword}{call }hchksum(kv, \textcolor{stringliteral}{"MOM\_CVMix\_conv: Kd"}, g%HI, haloshift=0, scale=us%m2\_s\_to\_Z2\_T)
292     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(kv)) \textcolor{keyword}{call }hchksum(kv, \textcolor{stringliteral}{"MOM\_CVMix\_conv: Kv"}, g%HI, haloshift=0, scale=us%m2\_s\_to\_Z2\_T)
293 \textcolor{keywordflow}{  endif}
294 
295   \textcolor{comment}{! send diagnostics to post\_data}
296   \textcolor{keywordflow}{if} (cs%id\_N2 > 0) \textcolor{keyword}{call }post\_data(cs%id\_N2, n2\_3d, cs%diag)
297   \textcolor{keywordflow}{if} (cs%id\_kd\_conv > 0) \textcolor{keyword}{call }post\_data(cs%id\_kd\_conv, kd\_conv, cs%diag)
298   \textcolor{keywordflow}{if} (cs%id\_kv\_conv > 0) \textcolor{keyword}{call }post\_data(cs%id\_kv\_conv, kv\_conv, cs%diag)
299 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__conv_a4f35df3a407ded91cd67384a14da3a3c}\label{namespacemom__cvmix__conv_a4f35df3a407ded91cd67384a14da3a3c}} 
\index{mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}!cvmix\+\_\+conv\+\_\+end@{cvmix\+\_\+conv\+\_\+end}}
\index{cvmix\+\_\+conv\+\_\+end@{cvmix\+\_\+conv\+\_\+end}!mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}}
\subsubsection{\texorpdfstring{cvmix\+\_\+conv\+\_\+end()}{cvmix\_conv\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+cvmix\+\_\+conv\+::cvmix\+\_\+conv\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__cvmix__conv_1_1cvmix__conv__cs}{cvmix\+\_\+conv\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Clear pointers and dealocate memory. 


\begin{DoxyParams}{Parameters}
{\em cs} & Control structure for this module that will be deallocated in this subroutine \\
\hline
\end{DoxyParams}


Definition at line 314 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+conv.\+F90.


\begin{DoxyCode}
314   \textcolor{keywordtype}{type}(cvmix\_conv\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< Control structure for this module that}
315 \textcolor{comment}{                                     !! will be deallocated in this subroutine}
316 
317   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
318 
319   \textcolor{keyword}{deallocate}(cs)
320 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__conv_a96b32166eb7623c206f18549da8224ca}\label{namespacemom__cvmix__conv_a96b32166eb7623c206f18549da8224ca}} 
\index{mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}!cvmix\+\_\+conv\+\_\+init@{cvmix\+\_\+conv\+\_\+init}}
\index{cvmix\+\_\+conv\+\_\+init@{cvmix\+\_\+conv\+\_\+init}!mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}}
\subsubsection{\texorpdfstring{cvmix\+\_\+conv\+\_\+init()}{cvmix\_conv\_init()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+cvmix\+\_\+conv\+::cvmix\+\_\+conv\+\_\+init (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(\hyperlink{structmom__cvmix__conv_1_1cvmix__conv__cs}{cvmix\+\_\+conv\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Initialized the C\+V\+Mix convection mixing routine. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & The current time.\\
\hline
\mbox{\tt in}  & {\em g} & Grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & Vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Run-\/time parameter file handle\\
\hline
\mbox{\tt in,out}  & {\em diag} & Diagnostics control structure.\\
\hline
 & {\em cs} & This module\textquotesingle{}s control structure. \\
\hline
\end{DoxyParams}


Definition at line 51 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+conv.\+F90.


\begin{DoxyCode}
51 
52   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{       !< The current time.}
53   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{          !< Grid structure.}
54   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{         !< Vertical grid structure.}
55   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{         !< A dimensional unit scaling type}
56   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Run-time parameter file handle}
57   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{       !< Diagnostics control structure.}
58   \textcolor{keywordtype}{type}(cvmix\_conv\_cs),     \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{         !< This module's control structure.}
59   \textcolor{comment}{! Local variables}
60   \textcolor{keywordtype}{real}    :: prandtl\_conv\textcolor{comment}{ !< Turbulent Prandtl number used in convective instabilities.}
61   \textcolor{keywordtype}{logical} :: useepbl\textcolor{comment}{      !< If True, use the ePBL boundary layer scheme.}
62 
63 \textcolor{comment}{! This include declares and sets the variable "version".}
64 \textcolor{preprocessor}{#include "version\_variable.h"}
65 \textcolor{preprocessor}{}
66   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
67     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"CVMix\_conv\_init called with an associated "}// &
68                             \textcolor{stringliteral}{"control structure."})
69     \textcolor{keywordflow}{return}
70 \textcolor{keywordflow}{  endif}
71   \textcolor{keyword}{allocate}(cs)
72 
73   \textcolor{comment}{! Read parameters}
74   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMix\_CONVECTION"}, cvmix\_conv\_init, default=.false., do\_not\_log=.
      true.)
75   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, &
76            \textcolor{stringliteral}{"Parameterization of enhanced mixing due to convection via CVMix"}, &
77            all\_default=.not.cvmix\_conv\_init)
78   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMix\_CONVECTION"}, cvmix\_conv\_init, &
79                  \textcolor{stringliteral}{"If true, turns on the enhanced mixing due to convection "}//&
80                  \textcolor{stringliteral}{"via CVMix. This scheme increases diapycnal diffs./viscs. "}//&
81                  \textcolor{stringliteral}{"at statically unstable interfaces. Relevant parameters are "}//&
82                  \textcolor{stringliteral}{"contained in the CVMix\_CONVECTION% parameter block."}, &
83                  default=.false.)
84 
85   \textcolor{keywordflow}{if} (.not. cvmix\_conv\_init) \textcolor{keywordflow}{return}
86 
87   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ENERGETICS\_SFC\_PBL"}, useepbl, default=.false., &
88                 do\_not\_log=.true.)
89 
90   \textcolor{comment}{! Warn user if EPBL is being used, since in this case mixing due to convection will}
91   \textcolor{comment}{! be aplied in the boundary layer}
92   \textcolor{keywordflow}{if} (useepbl) \textcolor{keywordflow}{then}
93      \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{'MOM\_CVMix\_conv\_init: '}// &
94            \textcolor{stringliteral}{'CVMix convection may not be properly applied when ENERGETICS\_SFC\_PBL = True'}//&
95            \textcolor{stringliteral}{'as convective mixing might occur in the boundary layer.'})
96 \textcolor{keywordflow}{  endif}
97 
98   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'DEBUG'}, cs%debug, default=.false., do\_not\_log=.true.)
99 
100   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'MIN\_THICKNESS'}, cs%min\_thickness, default=0.001, do\_not\_log=.true.)
101 
102   \textcolor{keyword}{call }openparameterblock(param\_file,\textcolor{stringliteral}{'CVMix\_CONVECTION'})
103 
104   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"PRANDTL\_CONV"}, prandtl\_conv, &
105                  \textcolor{stringliteral}{"The turbulent Prandtl number applied to convective "}//&
106                  \textcolor{stringliteral}{"instabilities (i.e., used to convert KD\_CONV into KV\_CONV)"}, &
107                  units=\textcolor{stringliteral}{"nondim"}, default=1.0)
108 
109   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'KD\_CONV'}, cs%kd\_conv\_const, &
110                  \textcolor{stringliteral}{"Diffusivity used in convective regime. Corresponding viscosity "}//&
111                  \textcolor{stringliteral}{"(KV\_CONV) will be set to KD\_CONV * PRANDTL\_TURB."}, &
112                  units=\textcolor{stringliteral}{'m2/s'}, default=1.00)
113 
114   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'BV\_SQR\_CONV'}, cs%bv\_sqr\_conv, &
115                  \textcolor{stringliteral}{"Threshold for squared buoyancy frequency needed to trigger "}//&
116                  \textcolor{stringliteral}{"Brunt-Vaisala parameterization."}, &
117                  units=\textcolor{stringliteral}{'1/s^2'}, default=0.0)
118 
119   \textcolor{keyword}{call }closeparameterblock(param\_file)
120 
121   \textcolor{comment}{! set kv\_conv\_const based on kd\_conv\_const and prandtl\_conv}
122   cs%kv\_conv\_const = cs%kd\_conv\_const * prandtl\_conv
123 
124   \textcolor{comment}{! Register diagnostics}
125   cs%diag => diag
126   cs%id\_N2 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'N2\_conv'}, diag%axesTi, time, &
127       \textcolor{stringliteral}{'Square of Brunt-Vaisala frequency used by MOM\_CVMix\_conv module'}, \textcolor{stringliteral}{'1/s2'}, conversion=us%s\_to\_T**2)
128   cs%id\_kd\_conv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'kd\_conv'}, diag%axesTi, time, &
129       \textcolor{stringliteral}{'Additional diffusivity added by MOM\_CVMix\_conv module'}, \textcolor{stringliteral}{'m2/s'}, conversion=us%Z2\_T\_to\_m2\_s)
130   cs%id\_kv\_conv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'kv\_conv'}, diag%axesTi, time, &
131       \textcolor{stringliteral}{'Additional viscosity added by MOM\_CVMix\_conv module'}, \textcolor{stringliteral}{'m2/s'}, conversion=us%Z2\_T\_to\_m2\_s)
132 
133   \textcolor{keyword}{call }cvmix\_init\_conv(convect\_diff=cs%kd\_conv\_const, &
134                        convect\_visc=cs%kv\_conv\_const, &
135                        lbruntvaisala=.true.,    &
136                        bvsqr\_convect=cs%bv\_sqr\_conv)
137 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__conv_a5e741c84ad14fae3e5801d00a9867bba}\label{namespacemom__cvmix__conv_a5e741c84ad14fae3e5801d00a9867bba}} 
\index{mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}!cvmix\+\_\+conv\+\_\+is\+\_\+used@{cvmix\+\_\+conv\+\_\+is\+\_\+used}}
\index{cvmix\+\_\+conv\+\_\+is\+\_\+used@{cvmix\+\_\+conv\+\_\+is\+\_\+used}!mom\+\_\+cvmix\+\_\+conv@{mom\+\_\+cvmix\+\_\+conv}}
\subsubsection{\texorpdfstring{cvmix\+\_\+conv\+\_\+is\+\_\+used()}{cvmix\_conv\_is\_used()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+cvmix\+\_\+conv\+::cvmix\+\_\+conv\+\_\+is\+\_\+used (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}



Reads the parameter \char`\"{}\+U\+S\+E\+\_\+\+C\+V\+Mix\+\_\+\+C\+O\+N\+V\+E\+C\+T\+I\+O\+N\char`\"{} and returns state. This function allows other modules to know whether this parameterization will be used without needing to duplicate the log entry. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\end{DoxyParams}


Definition at line 306 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+conv.\+F90.


\begin{DoxyCode}
306   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
307   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMix\_CONVECTION"}, cvmix\_conv\_is\_used, &
308                  default=.false., do\_not\_log = .true.)
309 
\end{DoxyCode}
