\hypertarget{namespacemom__cvmix__ddiff}{}\doxysection{mom\+\_\+cvmix\+\_\+ddiff Module Reference}
\label{namespacemom__cvmix__ddiff}\index{mom\_cvmix\_ddiff@{mom\_cvmix\_ddiff}}


\doxysubsection{Detailed Description}
Interface to C\+V\+Mix double diffusion scheme. \doxysubsection*{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}
\doxysubsection*{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}
\doxysubsection*{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}


\doxysubsection{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & Grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamics structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em j} & Meridional grid index to work on. \\
\hline
\mbox{\texttt{ in,out}}  & {\em kd\+\_\+t} & Interface double diffusion diapycnal diffusivity for temp \mbox{[}Z2 T-\/1 $\sim$$>$ m2 s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ 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{\texttt{ 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}{0}
\DoxyCodeLine{143 }
\DoxyCodeLine{144   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< Grid structure.}}
\DoxyCodeLine{145   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< Vertical grid structure.}}
\DoxyCodeLine{146 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< Layer thickness [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{147   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< Thermodynamics structure.}}
\DoxyCodeLine{148   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{149   \textcolor{keywordtype}{integer},                                    \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{    !< Meridional grid index to work on.}}
\DoxyCodeLine{150   \textcolor{comment}{! Kd\_T and Kd\_S are intent inout because only one j-\/row is set here, but they are essentially outputs.}}
\DoxyCodeLine{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}}
\DoxyCodeLine{152 \textcolor{comment}{                                                                    !! diffusivity for temp [Z2 T-\/1 \string~> m2 s-\/1].}}
\DoxyCodeLine{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}}
\DoxyCodeLine{154 \textcolor{comment}{                                                                    !! diffusivity for salt [Z2 T-\/1 \string~> m2 s-\/1].}}
\DoxyCodeLine{155   \textcolor{keywordtype}{type}(CVMix\_ddiff\_cs),                       \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< The control structure returned}}
\DoxyCodeLine{156 \textcolor{comment}{                                                                    !! by a previous call to CVMix\_ddiff\_init.}}
\DoxyCodeLine{157 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, \&}
\DoxyCodeLine{158                                     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: R\_rho\textcolor{comment}{ !< The density ratios at interfaces [nondim].}}
\DoxyCodeLine{159 }
\DoxyCodeLine{160   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{161 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: \&}
\DoxyCodeLine{162     cellHeight, \&  !< Height of cell centers [m]}
\DoxyCodeLine{163     dRho\_dT,    \&  !< partial derivatives of density wrt temp [R degC-\/1 \string~> kg m-\/3 degC-\/1]}
\DoxyCodeLine{164     dRho\_dS,    \&  !< partial derivatives of density wrt saln [R ppt-\/1 \string~> kg m-\/3 ppt-\/1]}
\DoxyCodeLine{165     pres\_int,   \&  !< pressure at each interface [R L2 T-\/2 \string~> Pa]}
\DoxyCodeLine{166     temp\_int,   \&  !< temp and at interfaces [degC]}
\DoxyCodeLine{167     salt\_int,   \&  !< salt at at interfaces [ppt]}
\DoxyCodeLine{168     alpha\_dT,   \&  !< alpha*dT across interfaces [kg m-\/3]}
\DoxyCodeLine{169     beta\_dS,    \&  !< beta*dS across interfaces [kg m-\/3]}
\DoxyCodeLine{170     dT,         \&  !< temp. difference between adjacent layers [degC]}
\DoxyCodeLine{171     dS\textcolor{comment}{             !< salt difference between adjacent layers [ppt]}}
\DoxyCodeLine{172 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: \&}
\DoxyCodeLine{173     Kd1\_T,      \&  !< Diapycanal diffusivity of temperature [m2 s-\/1].}
\DoxyCodeLine{174     Kd1\_S\textcolor{comment}{          !< Diapycanal diffusivity of salinity [m2 s-\/1].}}
\DoxyCodeLine{175 }
\DoxyCodeLine{176 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: iFaceHeight\textcolor{comment}{ !< Height of interfaces [m]}}
\DoxyCodeLine{177   \textcolor{keywordtype}{integer} :: kOBL\textcolor{comment}{                        !< level of OBL extent}}
\DoxyCodeLine{178 \textcolor{keywordtype}{  real} :: dh, hcorr}
\DoxyCodeLine{179   \textcolor{keywordtype}{integer} :: i, k}
\DoxyCodeLine{180 }
\DoxyCodeLine{181   \textcolor{comment}{! initialize dummy variables}}
\DoxyCodeLine{182   pres\_int(:) = 0.0; temp\_int(:) = 0.0; salt\_int(:) = 0.0}
\DoxyCodeLine{183   alpha\_dt(:) = 0.0; beta\_ds(:) = 0.0; drho\_dt(:) = 0.0}
\DoxyCodeLine{184   drho\_ds(:) = 0.0; dt(:) = 0.0; ds(:) = 0.0}
\DoxyCodeLine{185 }
\DoxyCodeLine{186 }
\DoxyCodeLine{187   \textcolor{comment}{! GMM, I am leaving some code commented below. We need to pass BLD to}}
\DoxyCodeLine{188   \textcolor{comment}{! this soubroutine to avoid adding diffusivity above that. This needs}}
\DoxyCodeLine{189   \textcolor{comment}{! to be done once we re-\/structure the order of the calls.}}
\DoxyCodeLine{190   \textcolor{comment}{!if (.not. associated(hbl)) then}}
\DoxyCodeLine{191   \textcolor{comment}{!  allocate(hbl(SZI\_(G), SZJ\_(G)));}}
\DoxyCodeLine{192   \textcolor{comment}{!  hbl(:,:) = 0.0}}
\DoxyCodeLine{193   \textcolor{comment}{!endif}}
\DoxyCodeLine{194 }
\DoxyCodeLine{195   \textcolor{keywordflow}{do} i = g\%isc, g\%iec}
\DoxyCodeLine{196 }
\DoxyCodeLine{197     \textcolor{comment}{! skip calling at land points}}
\DoxyCodeLine{198     \textcolor{keywordflow}{if} (g\%mask2dT(i,j) == 0.) cycle}
\DoxyCodeLine{199 }
\DoxyCodeLine{200     pres\_int(1) = 0. ;  \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%p\_surf)) pres\_int(1) = tv\%p\_surf(i,j)}
\DoxyCodeLine{201     \textcolor{comment}{! we don't have SST and SSS, so let's use values at top-\/most layer}}
\DoxyCodeLine{202     temp\_int(1) = tv\%T(i,j,1); salt\_int(1) = tv\%S(i,j,1)}
\DoxyCodeLine{203     \textcolor{keywordflow}{do} k=2,g\%ke}
\DoxyCodeLine{204       \textcolor{comment}{! pressure at interface}}
\DoxyCodeLine{205       pres\_int(k) = pres\_int(k-\/1) + (gv\%g\_Earth * gv\%H\_to\_RZ) * h(i,j,k-\/1)}
\DoxyCodeLine{206       \textcolor{comment}{! temp and salt at interface}}
\DoxyCodeLine{207       \textcolor{comment}{! for temp: (t1*h1 + t2*h2)/(h1+h2)}}
\DoxyCodeLine{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))}
\DoxyCodeLine{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))}
\DoxyCodeLine{210       \textcolor{comment}{! dT and dS}}
\DoxyCodeLine{211       dt(k) = (tv\%T(i,j,k-\/1)-\/tv\%T(i,j,k))}
\DoxyCodeLine{212       ds(k) = (tv\%S(i,j,k-\/1)-\/tv\%S(i,j,k))}
\DoxyCodeLine{213 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! k-\/loop finishes}}
\DoxyCodeLine{214 }
\DoxyCodeLine{215     \textcolor{keyword}{call }calculate\_density\_derivs(temp\_int, salt\_int, pres\_int, drho\_dt, drho\_ds, tv\%eqn\_of\_state)}
\DoxyCodeLine{216 }
\DoxyCodeLine{217     \textcolor{comment}{! The "-\/1.0" below is needed so that the following criteria is satisfied:}}
\DoxyCodeLine{218     \textcolor{comment}{! if ((alpha\_dT > beta\_dS) .and. (beta\_dS > 0.0)) then "salt finger"}}
\DoxyCodeLine{219     \textcolor{comment}{! if ((alpha\_dT < 0.) .and. (beta\_dS < 0.) .and. (alpha\_dT > beta\_dS)) then "diffusive convection"}}
\DoxyCodeLine{220     \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{221       alpha\_dt(k) = -\/1.0*us\%R\_to\_kg\_m3*drho\_dt(k) * dt(k)}
\DoxyCodeLine{222       beta\_ds(k)  = us\%R\_to\_kg\_m3*drho\_ds(k) * ds(k)}
\DoxyCodeLine{223 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{224 }
\DoxyCodeLine{225     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(r\_rho))  \textcolor{keywordflow}{then}}
\DoxyCodeLine{226       \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{227         \textcolor{comment}{! Set R\_rho using Adcroft's rule of reciprocals.}}
\DoxyCodeLine{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)}
\DoxyCodeLine{229         \textcolor{comment}{! avoid NaN's again for safety, perhaps unnecessarily.}}
\DoxyCodeLine{230         \textcolor{keywordflow}{if} (r\_rho(i,j,k) /= r\_rho(i,j,k)) r\_rho(i,j,k) = 0.0}
\DoxyCodeLine{231 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{232 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{233 }
\DoxyCodeLine{234     ifaceheight(1) = 0.0 \textcolor{comment}{! BBL is all relative to the surface}}
\DoxyCodeLine{235     hcorr = 0.0}
\DoxyCodeLine{236     \textcolor{comment}{! compute heights at cell center and interfaces}}
\DoxyCodeLine{237     \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{238       dh = h(i,j,k) * gv\%H\_to\_m \textcolor{comment}{! Nominal thickness to use for increment}}
\DoxyCodeLine{239       dh = dh + hcorr \textcolor{comment}{! Take away the accumulated error (could temporarily make dh<0)}}
\DoxyCodeLine{240       hcorr = min( dh -\/ cs\%min\_thickness, 0. ) \textcolor{comment}{! If inflating then hcorr<0}}
\DoxyCodeLine{241       dh = max( dh, cs\%min\_thickness ) \textcolor{comment}{! Limit increment dh>=min\_thickness}}
\DoxyCodeLine{242       cellheight(k)    = ifaceheight(k) -\/ 0.5 * dh}
\DoxyCodeLine{243       ifaceheight(k+1) = ifaceheight(k) -\/ dh}
\DoxyCodeLine{244 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{245 }
\DoxyCodeLine{246     \textcolor{comment}{! gets index of the level and interface above hbl}}
\DoxyCodeLine{247     \textcolor{comment}{!kOBL = CVmix\_kpp\_compute\_kOBL\_depth(iFaceHeight, cellHeight,hbl(i,j))}}
\DoxyCodeLine{248 }
\DoxyCodeLine{249     kd1\_t(:) = 0.0 ; kd1\_s(:) = 0.0}
\DoxyCodeLine{250     \textcolor{keyword}{call }cvmix\_coeffs\_ddiff(tdiff\_out=kd1\_t(:), \&}
\DoxyCodeLine{251                             sdiff\_out=kd1\_s(:), \&}
\DoxyCodeLine{252                             strat\_param\_num=alpha\_dt(:), \&}
\DoxyCodeLine{253                             strat\_param\_denom=beta\_ds(:), \&}
\DoxyCodeLine{254                             nlev=g\%ke,    \&}
\DoxyCodeLine{255                             max\_nlev=g\%ke)}
\DoxyCodeLine{256     \textcolor{keywordflow}{do} k=1,g\%ke+1}
\DoxyCodeLine{257       kd\_t(i,j,k) = us\%m2\_s\_to\_Z2\_T * kd1\_t(k)}
\DoxyCodeLine{258       kd\_s(i,j,k) = us\%m2\_s\_to\_Z2\_T * kd1\_s(k)}
\DoxyCodeLine{259 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{260 }
\DoxyCodeLine{261     \textcolor{comment}{! Do not apply mixing due to convection within the boundary layer}}
\DoxyCodeLine{262     \textcolor{comment}{!do k=1,kOBL}}
\DoxyCodeLine{263     \textcolor{comment}{!  Kd\_T(i,j,k) = 0.0}}
\DoxyCodeLine{264     \textcolor{comment}{!  Kd\_S(i,j,k) = 0.0}}
\DoxyCodeLine{265     \textcolor{comment}{!enddo}}
\DoxyCodeLine{266 }
\DoxyCodeLine{267 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! i-\/loop}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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}{0}
\DoxyCodeLine{283   \textcolor{keywordtype}{type}(CVMix\_ddiff\_cs), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< Control structure for this module that}}
\DoxyCodeLine{284 \textcolor{comment}{                                      !! will be deallocated in this subroutine}}
\DoxyCodeLine{285 }
\DoxyCodeLine{286   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em time} & The current time. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Run-\/time parameter file handle \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{51 }
\DoxyCodeLine{52   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{       !< The current time.}}
\DoxyCodeLine{53   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{          !< Grid structure.}}
\DoxyCodeLine{54   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{         !< Vertical grid structure.}}
\DoxyCodeLine{55   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{         !< A dimensional unit scaling type}}
\DoxyCodeLine{56   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Run-\/time parameter file handle}}
\DoxyCodeLine{57   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{       !< Diagnostics control structure.}}
\DoxyCodeLine{58   \textcolor{keywordtype}{type}(CVMix\_ddiff\_cs),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{         !< This module's control structure.}}
\DoxyCodeLine{59 }
\DoxyCodeLine{60 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{61 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{62 \textcolor{preprocessor}{}}
\DoxyCodeLine{63   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{64     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"CVMix\_ddiff\_init called with an associated "}// \&}
\DoxyCodeLine{65                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{66     \textcolor{keywordflow}{return}}
\DoxyCodeLine{67 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{68   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{69 }
\DoxyCodeLine{70   \textcolor{comment}{! Read parameters}}
\DoxyCodeLine{71   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMIX\_DDIFF"}, cvmix\_ddiff\_init, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{72   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \&}
\DoxyCodeLine{73            \textcolor{stringliteral}{"Parameterization of mixing due to double diffusion processes via CVMix"}, \&}
\DoxyCodeLine{74            all\_default=.not.cvmix\_ddiff\_init)}
\DoxyCodeLine{75   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMIX\_DDIFF"}, cvmix\_ddiff\_init, \&}
\DoxyCodeLine{76                  \textcolor{stringliteral}{"If true, turns on double diffusive processes via CVMix. "}//\&}
\DoxyCodeLine{77                  \textcolor{stringliteral}{"Note that double diffusive processes on viscosity are ignored "}//\&}
\DoxyCodeLine{78                  \textcolor{stringliteral}{"in CVMix, see http://cvmix.github.io/ for justification."}, \&}
\DoxyCodeLine{79                  default=.false.)}
\DoxyCodeLine{80 }
\DoxyCodeLine{81   \textcolor{keywordflow}{if} (.not. cvmix\_ddiff\_init) \textcolor{keywordflow}{return}}
\DoxyCodeLine{82 }
\DoxyCodeLine{83   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'DEBUG'}, cs\%debug, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{84 }
\DoxyCodeLine{85   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'MIN\_THICKNESS'}, cs\%min\_thickness, default=0.001, do\_not\_log=.true.)}
\DoxyCodeLine{86 }
\DoxyCodeLine{87   \textcolor{keyword}{call }openparameterblock(param\_file,\textcolor{stringliteral}{'CVMIX\_DDIFF'})}
\DoxyCodeLine{88 }
\DoxyCodeLine{89   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"STRAT\_PARAM\_MAX"}, cs\%strat\_param\_max, \&}
\DoxyCodeLine{90                  \textcolor{stringliteral}{"The maximum value for the double dissusion stratification parameter"}, \&}
\DoxyCodeLine{91                  units=\textcolor{stringliteral}{"nondim"}, default=2.55)}
\DoxyCodeLine{92 }
\DoxyCodeLine{93   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_S"}, cs\%kappa\_ddiff\_s, \&}
\DoxyCodeLine{94                  \textcolor{stringliteral}{"Leading coefficient in formula for salt-\/fingering regime "}//\&}
\DoxyCodeLine{95                  \textcolor{stringliteral}{"for salinity diffusion."}, units=\textcolor{stringliteral}{"m2 s-\/1"}, default=1.0e-\/4)}
\DoxyCodeLine{96 }
\DoxyCodeLine{97   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DDIFF\_EXP1"}, cs\%ddiff\_exp1, \&}
\DoxyCodeLine{98                  \textcolor{stringliteral}{"Interior exponent in salt-\/fingering regime formula."}, \&}
\DoxyCodeLine{99                  units=\textcolor{stringliteral}{"nondim"}, default=1.0)}
\DoxyCodeLine{100 }
\DoxyCodeLine{101   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DDIFF\_EXP2"}, cs\%ddiff\_exp2, \&}
\DoxyCodeLine{102                  \textcolor{stringliteral}{"Exterior exponent in salt-\/fingering regime formula."}, \&}
\DoxyCodeLine{103                  units=\textcolor{stringliteral}{"nondim"}, default=3.0)}
\DoxyCodeLine{104 }
\DoxyCodeLine{105   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_PARAM1"}, cs\%kappa\_ddiff\_param1, \&}
\DoxyCodeLine{106                 \textcolor{stringliteral}{"Exterior coefficient in diffusive convection regime."}, \&}
\DoxyCodeLine{107                  units=\textcolor{stringliteral}{"nondim"}, default=0.909)}
\DoxyCodeLine{108 }
\DoxyCodeLine{109   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_PARAM2"}, cs\%kappa\_ddiff\_param2, \&}
\DoxyCodeLine{110                 \textcolor{stringliteral}{"Middle coefficient in diffusive convection regime."}, \&}
\DoxyCodeLine{111                  units=\textcolor{stringliteral}{"nondim"}, default=4.6)}
\DoxyCodeLine{112 }
\DoxyCodeLine{113   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_DDIFF\_PARAM3"}, cs\%kappa\_ddiff\_param3, \&}
\DoxyCodeLine{114                 \textcolor{stringliteral}{"Interior coefficient in diffusive convection regime."}, \&}
\DoxyCodeLine{115                  units=\textcolor{stringliteral}{"nondim"}, default=-\/0.54)}
\DoxyCodeLine{116 }
\DoxyCodeLine{117   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MOL\_DIFF"}, cs\%mol\_diff, \&}
\DoxyCodeLine{118                  \textcolor{stringliteral}{"Molecular diffusivity used in CVMix double diffusion."}, \&}
\DoxyCodeLine{119                  units=\textcolor{stringliteral}{"m2 s-\/1"}, default=1.5e-\/6)}
\DoxyCodeLine{120 }
\DoxyCodeLine{121   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DIFF\_CONV\_TYPE"}, cs\%diff\_conv\_type, \&}
\DoxyCodeLine{122                  \textcolor{stringliteral}{"type of diffusive convection to use. Options are Marmorino \(\backslash\)n"} //\&}
\DoxyCodeLine{123                  \textcolor{stringliteral}{"and Caldwell 1976 (MC76) and Kelley 1988, 1990 (K90)."}, \&}
\DoxyCodeLine{124                  default=\textcolor{stringliteral}{"MC76"})}
\DoxyCodeLine{125 }
\DoxyCodeLine{126   \textcolor{keyword}{call }closeparameterblock(param\_file)}
\DoxyCodeLine{127 }
\DoxyCodeLine{128   \textcolor{keyword}{call }cvmix\_init\_ddiff(strat\_param\_max=cs\%strat\_param\_max,          \&}
\DoxyCodeLine{129                         kappa\_ddiff\_s=cs\%kappa\_ddiff\_s,           \&}
\DoxyCodeLine{130                         ddiff\_exp1=cs\%ddiff\_exp1,                 \&}
\DoxyCodeLine{131                         ddiff\_exp2=cs\%ddiff\_exp2,                 \&}
\DoxyCodeLine{132                         mol\_diff=cs\%mol\_diff,                     \&}
\DoxyCodeLine{133                         kappa\_ddiff\_param1=cs\%kappa\_ddiff\_param1, \&}
\DoxyCodeLine{134                         kappa\_ddiff\_param2=cs\%kappa\_ddiff\_param2, \&}
\DoxyCodeLine{135                         kappa\_ddiff\_param3=cs\%kappa\_ddiff\_param3, \&}
\DoxyCodeLine{136                         diff\_conv\_type=cs\%diff\_conv\_type)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ 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}{0}
\DoxyCodeLine{275   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{276   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_CVMIX\_DDIFF"}, cvmix\_ddiff\_is\_used, \&}
\DoxyCodeLine{277                  default=.false., do\_not\_log = .true.)}
\DoxyCodeLine{278 }

\end{DoxyCode}
