\hypertarget{namespacemom__cvmix__ddiff}{}\section{mom\+\_\+cvmix\+\_\+ddiff Module Reference}
\label{namespacemom__cvmix__ddiff}\index{mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}}


\subsection{Detailed Description}
Interface to C\+V\+Mix double diffusion scheme. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__cvmix__ddiff_1_1cvmix__ddiff__cs}{cvmix\+\_\+ddiff\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure including parameters for C\+V\+Mix double diffusion. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespacemom__cvmix__ddiff_a5b2654f12c65c29ecadab1b57430a5e4}{cvmix\+\_\+ddiff\+\_\+init}} (Time, G, GV, US, param\+\_\+file, diag, CS)
\begin{DoxyCompactList}\small\item\em Initialized the C\+V\+Mix double diffusion module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__cvmix__ddiff_a4f0d21853b3eedee1bc8de7cf5356da0}{compute\+\_\+ddiff\+\_\+coeffs}} (h, tv, G, GV, US, j, Kd\+\_\+T, Kd\+\_\+S, CS, R\+\_\+rho)
\begin{DoxyCompactList}\small\item\em Subroutine for computing vertical diffusion coefficients for the double diffusion mixing parameterization. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__cvmix__ddiff_a8f7ea8f60fe6775caadf68b29108b064}{cvmix\+\_\+ddiff\+\_\+is\+\_\+used}} (param\+\_\+file)
\begin{DoxyCompactList}\small\item\em Reads the parameter \char`\"{}\+U\+S\+E\+\_\+\+C\+V\+M\+I\+X\+\_\+\+D\+D\+I\+F\+F\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 \mbox{\hyperlink{namespacemom__cvmix__ddiff_a2f016a94bf1554a9ccc19c9c5bf11d69}{cvmix\+\_\+ddiff\+\_\+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__ddiff_a5f5cf331c590f46f48970d2b9025a120}\label{namespacemom__cvmix__ddiff_a5f5cf331c590f46f48970d2b9025a120}} 
character(len=40) \mbox{\hyperlink{namespacemom__cvmix__ddiff_a5f5cf331c590f46f48970d2b9025a120}{mdl}} = \char`\"{}M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+ddiff\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__cvmix__ddiff_a4f0d21853b3eedee1bc8de7cf5356da0}\label{namespacemom__cvmix__ddiff_a4f0d21853b3eedee1bc8de7cf5356da0}} 
\index{mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}!compute\+\_\+ddiff\+\_\+coeffs@{compute\+\_\+ddiff\+\_\+coeffs}}
\index{compute\+\_\+ddiff\+\_\+coeffs@{compute\+\_\+ddiff\+\_\+coeffs}!mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}}
\subsubsection{\texorpdfstring{compute\+\_\+ddiff\+\_\+coeffs()}{compute\_ddiff\_coeffs()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+cvmix\+\_\+ddiff\+::compute\+\_\+ddiff\+\_\+coeffs (\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[{integer, intent(in)}]{j,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke+1), intent(inout)}]{Kd\+\_\+T,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke+1), intent(inout)}]{Kd\+\_\+S,  }\item[{type(\mbox{\hyperlink{structmom__cvmix__ddiff_1_1cvmix__ddiff__cs}{cvmix\+\_\+ddiff\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke+1), intent(inout), optional}]{R\+\_\+rho }\end{DoxyParamCaption})}



Subroutine for computing vertical diffusion coefficients for the double diffusion mixing parameterization. 


\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 h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em tv} & Thermodynamics structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em j} & Meridional grid index to work on.\\
\hline
\mbox{\tt in,out}  & {\em kd\+\_\+t} & Interface double diffusion diapycnal diffusivity for temp \mbox{[}Z2 T-\/1 $\sim$$>$ m2 s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em kd\+\_\+s} & Interface double diffusion diapycnal diffusivity for salt \mbox{[}Z2 T-\/1 $\sim$$>$ m2 s-\/1\mbox{]}.\\
\hline
 & {\em cs} & The control structure returned by a previous call to C\+V\+Mix\+\_\+ddiff\+\_\+init.\\
\hline
\mbox{\tt in,out}  & {\em r\+\_\+rho} & The density ratios at interfaces \mbox{[}nondim\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 143 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+ddiff.\+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}{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].}
147   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< Thermodynamics structure.}
148   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}
149   \textcolor{keywordtype}{integer},                                    \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{    !< Meridional grid index to work on.}
150   \textcolor{comment}{! Kd\_T and Kd\_S are intent inout because only one j-row is set here, but they are essentially outputs.}
151   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, \textcolor{keywordtype}{intent(inout)} :: Kd\_T\textcolor{comment}{ !< Interface double diffusion
       diapycnal}
152 \textcolor{comment}{                                                                    !! diffusivity for temp [Z2 T-1 ~> m2
       s-1].}
153   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, \textcolor{keywordtype}{intent(inout)} :: Kd\_S\textcolor{comment}{ !< Interface double diffusion
       diapycnal}
154 \textcolor{comment}{                                                                    !! diffusivity for salt [Z2 T-1 ~> m2
       s-1].}
155   \textcolor{keywordtype}{type}(CVMix\_ddiff\_cs),                       \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< The control structure returned}
156 \textcolor{comment}{                                                                    !! by a previous call to
       CVMix\_ddiff\_init.}
157   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
158                                     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: R\_rho\textcolor{comment}{ !< The density ratios at interfaces
       [nondim].}
159 
160   \textcolor{comment}{! Local variables}
161   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{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]
171     dS\textcolor{comment}{             !< salt difference between adjacent layers [ppt]}
172   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: &
173     Kd1\_T,      &  !< Diapycanal diffusivity of temperature [m2 s-1].
174     Kd1\_S\textcolor{comment}{          !< Diapycanal diffusivity of salinity [m2 s-1].}
175 
176   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: iFaceHeight\textcolor{comment}{ !< Height of interfaces [m]}
177   \textcolor{keywordtype}{integer} :: kOBL\textcolor{comment}{                        !< level of OBL extent}
178   \textcolor{keywordtype}{real} :: dh, hcorr
179   \textcolor{keywordtype}{integer} :: i, k
180 
181   \textcolor{comment}{! initialize dummy variables}
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
185 
186 
187   \textcolor{comment}{! GMM, I am leaving some code commented below. We need to pass BLD to}
188   \textcolor{comment}{! this soubroutine to avoid adding diffusivity above that. This needs}
189   \textcolor{comment}{! to be done once we re-structure the order of the calls.}
190   \textcolor{comment}{!if (.not. associated(hbl)) then}
191   \textcolor{comment}{!  allocate(hbl(SZI\_(G), SZJ\_(G)));}
192   \textcolor{comment}{!  hbl(:,:) = 0.0}
193   \textcolor{comment}{!endif}
194 
195   \textcolor{keywordflow}{do} i = g%isc, g%iec
196 
197     \textcolor{comment}{! skip calling at land points}
198     \textcolor{keywordflow}{if} (g%mask2dT(i,j) == 0.) cycle
199 
200     pres\_int(1) = 0. ;  \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%p\_surf)) pres\_int(1) = tv%p\_surf(i,j)
201     \textcolor{comment}{! we don't have SST and SSS, so let's use values at top-most layer}
202     temp\_int(1) = tv%T(i,j,1); salt\_int(1) = tv%S(i,j,1)
203     \textcolor{keywordflow}{do} k=2,g%ke
204       \textcolor{comment}{! pressure at interface}
205       pres\_int(k) = pres\_int(k-1) + (gv%g\_Earth * gv%H\_to\_RZ) * h(i,j,k-1)
206       \textcolor{comment}{! temp and salt at interface}
207       \textcolor{comment}{! for temp: (t1*h1 + t2*h2)/(h1+h2)}
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))
210       \textcolor{comment}{! dT and dS}
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))
213 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! k-loop finishes}
214 
215     \textcolor{keyword}{call }calculate\_density\_derivs(temp\_int, salt\_int, pres\_int, drho\_dt, drho\_ds, tv%eqn\_of\_state)
216 
217     \textcolor{comment}{! The "-1.0" below is needed so that the following criteria is satisfied:}
218     \textcolor{comment}{! if ((alpha\_dT > beta\_dS) .and. (beta\_dS > 0.0)) then "salt finger"}
219     \textcolor{comment}{! if ((alpha\_dT < 0.) .and. (beta\_dS < 0.) .and. (alpha\_dT > beta\_dS)) then "diffusive convection"}
220     \textcolor{keywordflow}{do} k=1,g%ke
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)
223 \textcolor{keywordflow}{    enddo}
224 
225     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(r\_rho))  \textcolor{keywordflow}{then}
226       \textcolor{keywordflow}{do} k=1,g%ke
227         \textcolor{comment}{! Set R\_rho using Adcroft's rule of reciprocals.}
228         r\_rho(i,j,k) = 0.0 ; \textcolor{keywordflow}{if} (abs(beta\_ds(k)) > 0.0) r\_rho(i,j,k) = alpha\_dt(k) / beta\_ds(k)
229         \textcolor{comment}{! avoid NaN's again for safety, perhaps unnecessarily.}
230         \textcolor{keywordflow}{if} (r\_rho(i,j,k) /= r\_rho(i,j,k)) r\_rho(i,j,k) = 0.0
231 \textcolor{keywordflow}{      enddo}
232 \textcolor{keywordflow}{    endif}
233 
234     ifaceheight(1) = 0.0 \textcolor{comment}{! BBL is all relative to the surface}
235     hcorr = 0.0
236     \textcolor{comment}{! compute heights at cell center and interfaces}
237     \textcolor{keywordflow}{do} k=1,g%ke
238       dh = h(i,j,k) * gv%H\_to\_m \textcolor{comment}{! Nominal thickness to use for increment}
239       dh = dh + hcorr \textcolor{comment}{! Take away the accumulated error (could temporarily make dh<0)}
240       hcorr = min( dh - cs%min\_thickness, 0. ) \textcolor{comment}{! If inflating then hcorr<0}
241       dh = max( dh, cs%min\_thickness ) \textcolor{comment}{! Limit increment dh>=min\_thickness}
242       cellheight(k)    = ifaceheight(k) - 0.5 * dh
243       ifaceheight(k+1) = ifaceheight(k) - dh
244 \textcolor{keywordflow}{    enddo}
245 
246     \textcolor{comment}{! gets index of the level and interface above hbl}
247     \textcolor{comment}{!kOBL = CVmix\_kpp\_compute\_kOBL\_depth(iFaceHeight, cellHeight,hbl(i,j))}
248 
249     kd1\_t(:) = 0.0 ; kd1\_s(:) = 0.0
250     \textcolor{keyword}{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(:), &
254                             nlev=g%ke,    &
255                             max\_nlev=g%ke)
256     \textcolor{keywordflow}{do} k=1,g%ke+1
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)
259 \textcolor{keywordflow}{    enddo}
260 
261     \textcolor{comment}{! Do not apply mixing due to convection within the boundary layer}
262     \textcolor{comment}{!do k=1,kOBL}
263     \textcolor{comment}{!  Kd\_T(i,j,k) = 0.0}
264     \textcolor{comment}{!  Kd\_S(i,j,k) = 0.0}
265     \textcolor{comment}{!enddo}
266 
267 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! i-loop}
268 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__ddiff_a2f016a94bf1554a9ccc19c9c5bf11d69}\label{namespacemom__cvmix__ddiff_a2f016a94bf1554a9ccc19c9c5bf11d69}} 
\index{mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}!cvmix\+\_\+ddiff\+\_\+end@{cvmix\+\_\+ddiff\+\_\+end}}
\index{cvmix\+\_\+ddiff\+\_\+end@{cvmix\+\_\+ddiff\+\_\+end}!mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}}
\subsubsection{\texorpdfstring{cvmix\+\_\+ddiff\+\_\+end()}{cvmix\_ddiff\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+cvmix\+\_\+ddiff\+::cvmix\+\_\+ddiff\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__cvmix__ddiff_1_1cvmix__ddiff__cs}{cvmix\+\_\+ddiff\+\_\+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 283 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+ddiff.\+F90.


\begin{DoxyCode}
283   \textcolor{keywordtype}{type}(CVMix\_ddiff\_cs), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< Control structure for this module that}
284 \textcolor{comment}{                                      !! will be deallocated in this subroutine}
285 
286   \textcolor{keyword}{deallocate}(cs)
287 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__ddiff_a5b2654f12c65c29ecadab1b57430a5e4}\label{namespacemom__cvmix__ddiff_a5b2654f12c65c29ecadab1b57430a5e4}} 
\index{mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}!cvmix\+\_\+ddiff\+\_\+init@{cvmix\+\_\+ddiff\+\_\+init}}
\index{cvmix\+\_\+ddiff\+\_\+init@{cvmix\+\_\+ddiff\+\_\+init}!mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}}
\subsubsection{\texorpdfstring{cvmix\+\_\+ddiff\+\_\+init()}{cvmix\_ddiff\_init()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+cvmix\+\_\+ddiff\+::cvmix\+\_\+ddiff\+\_\+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(\mbox{\hyperlink{structmom__cvmix__ddiff_1_1cvmix__ddiff__cs}{cvmix\+\_\+ddiff\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Initialized the C\+V\+Mix double diffusion module. 


\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\+\_\+ddiff.\+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\_ddiff\_cs),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{         !< This module's control structure.}
59 
60 \textcolor{comment}{! This include declares and sets the variable "version".}
61 \textcolor{preprocessor}{#include "version\_variable.h"}
62 \textcolor{preprocessor}{}
63   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
64     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"CVMix\_ddiff\_init called with an associated "}// &
65                             \textcolor{stringliteral}{"control structure."})
66     \textcolor{keywordflow}{return}
67 \textcolor{keywordflow}{  endif}
68   \textcolor{keyword}{allocate}(cs)
69 
70   \textcolor{comment}{! Read parameters}
71   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMIX\_DDIFF"}, cvmix\_ddiff\_init, default=.false., do\_not\_log=.true.)
72   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, &
73            \textcolor{stringliteral}{"Parameterization of mixing due to double diffusion processes via CVMix"}, &
74            all\_default=.not.cvmix\_ddiff\_init)
75   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMIX\_DDIFF"}, cvmix\_ddiff\_init, &
76                  \textcolor{stringliteral}{"If true, turns on double diffusive processes via CVMix. "}//&
77                  \textcolor{stringliteral}{"Note that double diffusive processes on viscosity are ignored "}//&
78                  \textcolor{stringliteral}{"in CVMix, see http://cvmix.github.io/ for justification."}, &
79                  default=.false.)
80 
81   \textcolor{keywordflow}{if} (.not. cvmix\_ddiff\_init) \textcolor{keywordflow}{return}
82 
83   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'DEBUG'}, cs%debug, default=.false., do\_not\_log=.true.)
84 
85   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'MIN\_THICKNESS'}, cs%min\_thickness, default=0.001, do\_not\_log=.true.)
86 
87   \textcolor{keyword}{call }openparameterblock(param\_file,\textcolor{stringliteral}{'CVMIX\_DDIFF'})
88 
89   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"STRAT\_PARAM\_MAX"}, cs%strat\_param\_max, &
90                  \textcolor{stringliteral}{"The maximum value for the double dissusion stratification parameter"}, &
91                  units=\textcolor{stringliteral}{"nondim"}, default=2.55)
92 
93   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_S"}, cs%kappa\_ddiff\_s, &
94                  \textcolor{stringliteral}{"Leading coefficient in formula for salt-fingering regime "}//&
95                  \textcolor{stringliteral}{"for salinity diffusion."}, units=\textcolor{stringliteral}{"m2 s-1"}, default=1.0e-4)
96 
97   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DDIFF\_EXP1"}, cs%ddiff\_exp1, &
98                  \textcolor{stringliteral}{"Interior exponent in salt-fingering regime formula."}, &
99                  units=\textcolor{stringliteral}{"nondim"}, default=1.0)
100 
101   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DDIFF\_EXP2"}, cs%ddiff\_exp2, &
102                  \textcolor{stringliteral}{"Exterior exponent in salt-fingering regime formula."}, &
103                  units=\textcolor{stringliteral}{"nondim"}, default=3.0)
104 
105   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_PARAM1"}, cs%kappa\_ddiff\_param1, &
106                 \textcolor{stringliteral}{"Exterior coefficient in diffusive convection regime."}, &
107                  units=\textcolor{stringliteral}{"nondim"}, default=0.909)
108 
109   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_PARAM2"}, cs%kappa\_ddiff\_param2, &
110                 \textcolor{stringliteral}{"Middle coefficient in diffusive convection regime."}, &
111                  units=\textcolor{stringliteral}{"nondim"}, default=4.6)
112 
113   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_PARAM3"}, cs%kappa\_ddiff\_param3, &
114                 \textcolor{stringliteral}{"Interior coefficient in diffusive convection regime."}, &
115                  units=\textcolor{stringliteral}{"nondim"}, default=-0.54)
116 
117   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MOL\_DIFF"}, cs%mol\_diff, &
118                  \textcolor{stringliteral}{"Molecular diffusivity used in CVMix double diffusion."}, &
119                  units=\textcolor{stringliteral}{"m2 s-1"}, default=1.5e-6)
120 
121   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DIFF\_CONV\_TYPE"}, cs%diff\_conv\_type, &
122                  \textcolor{stringliteral}{"type of diffusive convection to use. Options are Marmorino \(\backslash\)n"} //&
123                  \textcolor{stringliteral}{"and Caldwell 1976 (MC76) and Kelley 1988, 1990 (K90)."}, &
124                  default=\textcolor{stringliteral}{"MC76"})
125 
126   \textcolor{keyword}{call }closeparameterblock(param\_file)
127 
128   \textcolor{keyword}{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)
137 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__ddiff_a8f7ea8f60fe6775caadf68b29108b064}\label{namespacemom__cvmix__ddiff_a8f7ea8f60fe6775caadf68b29108b064}} 
\index{mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}!cvmix\+\_\+ddiff\+\_\+is\+\_\+used@{cvmix\+\_\+ddiff\+\_\+is\+\_\+used}}
\index{cvmix\+\_\+ddiff\+\_\+is\+\_\+used@{cvmix\+\_\+ddiff\+\_\+is\+\_\+used}!mom\+\_\+cvmix\+\_\+ddiff@{mom\+\_\+cvmix\+\_\+ddiff}}
\subsubsection{\texorpdfstring{cvmix\+\_\+ddiff\+\_\+is\+\_\+used()}{cvmix\_ddiff\_is\_used()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+cvmix\+\_\+ddiff\+::cvmix\+\_\+ddiff\+\_\+is\+\_\+used (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}



Reads the parameter \char`\"{}\+U\+S\+E\+\_\+\+C\+V\+M\+I\+X\+\_\+\+D\+D\+I\+F\+F\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 275 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+ddiff.\+F90.


\begin{DoxyCode}
275   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
276   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMIX\_DDIFF"}, cvmix\_ddiff\_is\_used, &
277                  default=.false., do\_not\_log = .true.)
278 
\end{DoxyCode}
