\hypertarget{namespacemom__cvmix__shear}{}\doxysection{mom\+\_\+cvmix\+\_\+shear Module Reference}
\label{namespacemom__cvmix__shear}\index{mom\_cvmix\_shear@{mom\_cvmix\_shear}}


\doxysubsection{Detailed Description}
Interface to C\+V\+Mix interior shear schemes. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__cvmix__shear_1_1cvmix__shear__cs}{cvmix\+\_\+shear\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure including parameters for C\+V\+Mix interior shear schemes. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__cvmix__shear_ad140c81d83dbd827728f6f43dee90d57}{calculate\+\_\+cvmix\+\_\+shear}} (u\+\_\+H, v\+\_\+H, h, tv, kd, kv, G, GV, US, CS)
\begin{DoxyCompactList}\small\item\em Subroutine for calculating (internal) vertical diffusivities/viscosities. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__cvmix__shear_aec86faeb6ba106f8c9584dd3b6368a41}{cvmix\+\_\+shear\+\_\+init}} (Time, G, GV, US, param\+\_\+file, diag, CS)
\begin{DoxyCompactList}\small\item\em Initialized the C\+V\+Mix internal shear mixing routine. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__cvmix__shear_aa8084ded891a4e6e33ceeec0f240233f}{cvmix\+\_\+shear\+\_\+is\+\_\+used}} (param\+\_\+file)
\begin{DoxyCompactList}\small\item\em Reads the parameters \char`\"{}\+L\+M\+D94\char`\"{} and \char`\"{}\+P\+P81\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__shear_a0c9f49bd2f832f20f4675b63b85e0e8e}{cvmix\+\_\+shear\+\_\+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__shear_a8a2b801d6b67aa28ccd4782b3e20a0e9}\label{namespacemom__cvmix__shear_a8a2b801d6b67aa28ccd4782b3e20a0e9}} 
character(len=40) \mbox{\hyperlink{namespacemom__cvmix__shear_a8a2b801d6b67aa28ccd4782b3e20a0e9}{mdl}} = \char`\"{}M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+shear\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__cvmix__shear_ad140c81d83dbd827728f6f43dee90d57}\label{namespacemom__cvmix__shear_ad140c81d83dbd827728f6f43dee90d57}} 
\index{mom\_cvmix\_shear@{mom\_cvmix\_shear}!calculate\_cvmix\_shear@{calculate\_cvmix\_shear}}
\index{calculate\_cvmix\_shear@{calculate\_cvmix\_shear}!mom\_cvmix\_shear@{mom\_cvmix\_shear}}
\doxysubsubsection{\texorpdfstring{calculate\_cvmix\_shear()}{calculate\_cvmix\_shear()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+cvmix\+\_\+shear\+::calculate\+\_\+cvmix\+\_\+shear (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{u\+\_\+H,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{v\+\_\+H,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)+1), intent(out)}]{kd,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)+1), intent(out)}]{kv,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__cvmix__shear_1_1cvmix__shear__cs}{cvmix\+\_\+shear\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Subroutine for calculating (internal) vertical diffusivities/viscosities. 


\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 us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+h} & Initial zonal velocity on T points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+h} & Initial meridional velocity on T points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\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{ out}}  & {\em kd} & The vertical diffusivity at each interface (not layer!) \mbox{[}Z2 T-\/1 $\sim$$>$ m2 s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em kv} & The vertical viscosity at each interface (not layer!) \mbox{[}Z2 T-\/1 $\sim$$>$ m2 s-\/1\mbox{]}. \\
\hline
 & {\em cs} & The control structure returned by a previous call to C\+V\+Mix\+\_\+shear\+\_\+init. \\
\hline
\end{DoxyParams}


Definition at line 59 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+shear.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{60   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{   !< Grid structure.}}
\DoxyCodeLine{61   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{  !< Vertical grid structure.}}
\DoxyCodeLine{62   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{63 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}  :: u\_H\textcolor{comment}{ !< Initial zonal velocity on T points [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{64 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}  :: v\_H\textcolor{comment}{ !< Initial meridional velocity on T}}
\DoxyCodeLine{65 \textcolor{comment}{                                                                 !! points [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{66 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{   !< Layer thickness [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{67   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{  !< Thermodynamics structure.}}
\DoxyCodeLine{68 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \textcolor{keywordtype}{intent(out)} :: kd\textcolor{comment}{  !< The vertical diffusivity at each interface}}
\DoxyCodeLine{69 \textcolor{comment}{                                                                 !! (not layer!) [Z2 T-\/1 \string~> m2 s-\/1].}}
\DoxyCodeLine{70 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \textcolor{keywordtype}{intent(out)} :: kv\textcolor{comment}{  !< The vertical viscosity at each interface}}
\DoxyCodeLine{71 \textcolor{comment}{                                                                 !! (not layer!) [Z2 T-\/1 \string~> m2 s-\/1].}}
\DoxyCodeLine{72   \textcolor{keywordtype}{type}(CVMix\_shear\_cs),                       \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{  !< The control structure returned by a previous}}
\DoxyCodeLine{73 \textcolor{comment}{                                                                 !! call to CVMix\_shear\_init.}}
\DoxyCodeLine{74   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{75   \textcolor{keywordtype}{integer} :: i, j, k, kk, km1}
\DoxyCodeLine{76 \textcolor{keywordtype}{  real} :: GoRho  \textcolor{comment}{! Gravitational acceleration divided by density [Z T-\/2 R-\/1 \string~> m4 s-\/2 kg-\/2]}}
\DoxyCodeLine{77 \textcolor{keywordtype}{  real} :: pref   \textcolor{comment}{! Interface pressures [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{78 \textcolor{keywordtype}{  real} :: DU, DV \textcolor{comment}{! Velocity differences [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{79 \textcolor{keywordtype}{  real} :: DZ     \textcolor{comment}{! Grid spacing around an interface [Z \string~> m]}}
\DoxyCodeLine{80 \textcolor{keywordtype}{  real} :: N2     \textcolor{comment}{! Buoyancy frequency at an interface [T-\/2 \string~> s-\/2]}}
\DoxyCodeLine{81 \textcolor{keywordtype}{  real} :: S2     \textcolor{comment}{! Shear squared at an interface [T-\/2 \string~> s-\/2]}}
\DoxyCodeLine{82 \textcolor{keywordtype}{  real} :: dummy  \textcolor{comment}{! A dummy variable [nondim]}}
\DoxyCodeLine{83 \textcolor{keywordtype}{  real} :: dRho   \textcolor{comment}{! Buoyancy differences [Z T-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{84 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2*(G\%ke))} :: pres\_1d \textcolor{comment}{! A column of interface pressures [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{85 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2*(G\%ke))} :: temp\_1d \textcolor{comment}{! A column of temperatures [degC]}}
\DoxyCodeLine{86 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2*(G\%ke))} :: salt\_1d \textcolor{comment}{! A column of salinities [ppt]}}
\DoxyCodeLine{87 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2*(G\%ke))} :: rho\_1d  \textcolor{comment}{! A column of densities at interface pressures [R \string~> kg m-\/3]}}
\DoxyCodeLine{88 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%ke+1)} :: Ri\_Grad\textcolor{comment}{ !< Gradient Richardson number [nondim]}}
\DoxyCodeLine{89 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%ke+1)} :: Kvisc\textcolor{comment}{   !< Vertical viscosity at interfaces [m2 s-\/1]}}
\DoxyCodeLine{90 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%ke+1)} :: Kdiff\textcolor{comment}{   !< Diapycnal diffusivity at interfaces [m2 s-\/1]}}
\DoxyCodeLine{91 \textcolor{keywordtype}{  real} :: epsln\textcolor{comment}{  !< Threshold to identify vanished layers [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{92 }
\DoxyCodeLine{93   \textcolor{comment}{! some constants}}
\DoxyCodeLine{94   gorho = us\%L\_to\_Z**2 * gv\%g\_Earth / gv\%Rho0}
\DoxyCodeLine{95   epsln = 1.e-\/10 * gv\%m\_to\_H}
\DoxyCodeLine{96 }
\DoxyCodeLine{97   \textcolor{keywordflow}{do} j = g\%jsc, g\%jec}
\DoxyCodeLine{98     \textcolor{keywordflow}{do} i = g\%isc, g\%iec}
\DoxyCodeLine{99 }
\DoxyCodeLine{100       \textcolor{comment}{! skip calling for land points}}
\DoxyCodeLine{101       \textcolor{keywordflow}{if} (g\%mask2dT(i,j)==0.) cycle}
\DoxyCodeLine{102 }
\DoxyCodeLine{103       \textcolor{comment}{! Richardson number computed for each cell in a column.}}
\DoxyCodeLine{104       pref = 0. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%p\_surf)) pref = tv\%p\_surf(i,j)}
\DoxyCodeLine{105       ri\_grad(:)=1.e8 \textcolor{comment}{!Initialize w/ large Richardson value}}
\DoxyCodeLine{106       \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{107         \textcolor{comment}{! pressure, temp, and saln for EOS}}
\DoxyCodeLine{108         \textcolor{comment}{! kk+1 = k fields}}
\DoxyCodeLine{109         \textcolor{comment}{! kk+2 = km1 fields}}
\DoxyCodeLine{110         km1  = max(1, k-\/1)}
\DoxyCodeLine{111         kk   = 2*(k-\/1)}
\DoxyCodeLine{112         pres\_1d(kk+1) = pref}
\DoxyCodeLine{113         pres\_1d(kk+2) = pref}
\DoxyCodeLine{114         temp\_1d(kk+1) = tv\%T(i,j,k)}
\DoxyCodeLine{115         temp\_1d(kk+2) = tv\%T(i,j,km1)}
\DoxyCodeLine{116         salt\_1d(kk+1) = tv\%S(i,j,k)}
\DoxyCodeLine{117         salt\_1d(kk+2) = tv\%S(i,j,km1)}
\DoxyCodeLine{118 }
\DoxyCodeLine{119         \textcolor{comment}{! pRef is pressure at interface between k and km1.}}
\DoxyCodeLine{120         \textcolor{comment}{! iterate pRef for next pass through k-\/loop.}}
\DoxyCodeLine{121         pref = pref + (gv\%g\_Earth * gv\%H\_to\_RZ) * h(i,j,k)}
\DoxyCodeLine{122 }
\DoxyCodeLine{123 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! k-\/loop finishes}}
\DoxyCodeLine{124 }
\DoxyCodeLine{125       \textcolor{comment}{! compute in-\/situ density [R \string~> kg m-\/3]}}
\DoxyCodeLine{126       \textcolor{keyword}{call }calculate\_density(temp\_1d, salt\_1d, pres\_1d, rho\_1d, tv\%eqn\_of\_state)}
\DoxyCodeLine{127 }
\DoxyCodeLine{128       \textcolor{comment}{! N2 (can be negative) on interface}}
\DoxyCodeLine{129       \textcolor{keywordflow}{do} k = 1, g\%ke}
\DoxyCodeLine{130         km1 = max(1, k-\/1)}
\DoxyCodeLine{131         kk = 2*(k-\/1)}
\DoxyCodeLine{132         du = u\_h(i,j,k) -\/ u\_h(i,j,km1)}
\DoxyCodeLine{133         dv = v\_h(i,j,k) -\/ v\_h(i,j,km1)}
\DoxyCodeLine{134         drho = gorho * (rho\_1d(kk+1) -\/ rho\_1d(kk+2))}
\DoxyCodeLine{135         dz = (0.5*(h(i,j,km1) + h(i,j,k))+gv\%H\_subroundoff)*gv\%H\_to\_Z}
\DoxyCodeLine{136         n2 = drho / dz}
\DoxyCodeLine{137         s2 = us\%L\_to\_Z**2*(du*du+dv*dv)/(dz*dz)}
\DoxyCodeLine{138         ri\_grad(k) = max(0., n2) / max(s2, 1.e-\/10*us\%T\_to\_s**2)}
\DoxyCodeLine{139 }
\DoxyCodeLine{140         \textcolor{comment}{! fill 3d arrays, if user asks for diagsnostics}}
\DoxyCodeLine{141         \textcolor{keywordflow}{if} (cs\%id\_N2 > 0) cs\%N2(i,j,k) = n2}
\DoxyCodeLine{142         \textcolor{keywordflow}{if} (cs\%id\_S2 > 0) cs\%S2(i,j,k) = s2}
\DoxyCodeLine{143 }
\DoxyCodeLine{144 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{145 }
\DoxyCodeLine{146       ri\_grad(g\%ke+1) = ri\_grad(g\%ke)}
\DoxyCodeLine{147 }
\DoxyCodeLine{148       \textcolor{keywordflow}{if} (cs\%id\_ri\_grad > 0) cs\%ri\_grad(i,j,:) = ri\_grad(:)}
\DoxyCodeLine{149 }
\DoxyCodeLine{150       \textcolor{keywordflow}{if} (cs\%smooth\_ri) \textcolor{keywordflow}{then}}
\DoxyCodeLine{151         \textcolor{comment}{! 1) fill Ri\_grad in vanished layers with adjacent value}}
\DoxyCodeLine{152         \textcolor{keywordflow}{do} k = 2, g\%ke}
\DoxyCodeLine{153           \textcolor{keywordflow}{if} (h(i,j,k) <= epsln) ri\_grad(k) = ri\_grad(k-\/1)}
\DoxyCodeLine{154 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{155 }
\DoxyCodeLine{156         ri\_grad(g\%ke+1) = ri\_grad(g\%ke)}
\DoxyCodeLine{157 }
\DoxyCodeLine{158         \textcolor{comment}{! 2) vertically smooth Ri with 1-\/2-\/1 filter}}
\DoxyCodeLine{159         dummy =  0.25 * ri\_grad(2)}
\DoxyCodeLine{160         ri\_grad(g\%ke+1) = ri\_grad(g\%ke)}
\DoxyCodeLine{161         \textcolor{keywordflow}{do} k = 3, g\%ke}
\DoxyCodeLine{162           ri\_grad(k) = dummy + 0.5 * ri\_grad(k) + 0.25 * ri\_grad(k+1)}
\DoxyCodeLine{163           dummy = 0.25 * ri\_grad(k)}
\DoxyCodeLine{164 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{165 }
\DoxyCodeLine{166         \textcolor{keywordflow}{if} (cs\%id\_ri\_grad\_smooth > 0) cs\%ri\_grad\_smooth(i,j,:) = ri\_grad(:)}
\DoxyCodeLine{167 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{168 }
\DoxyCodeLine{169       \textcolor{keywordflow}{do} k=1,g\%ke+1}
\DoxyCodeLine{170         kvisc(k) = us\%Z2\_T\_to\_m2\_s * kv(i,j,k)}
\DoxyCodeLine{171         kdiff(k) = us\%Z2\_T\_to\_m2\_s * kd(i,j,k)}
\DoxyCodeLine{172 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{173 }
\DoxyCodeLine{174       \textcolor{comment}{! Call to CVMix wrapper for computing interior mixing coefficients.}}
\DoxyCodeLine{175       \textcolor{keyword}{call  }cvmix\_coeffs\_shear(mdiff\_out=kvisc(:), \&}
\DoxyCodeLine{176                                    tdiff\_out=kdiff(:), \&}
\DoxyCodeLine{177                                    rich=ri\_grad(:), \&}
\DoxyCodeLine{178                                    nlev=g\%ke,    \&}
\DoxyCodeLine{179                                    max\_nlev=g\%ke)}
\DoxyCodeLine{180       \textcolor{keywordflow}{do} k=1,g\%ke+1}
\DoxyCodeLine{181         kv(i,j,k) = us\%m2\_s\_to\_Z2\_T * kvisc(k)}
\DoxyCodeLine{182         kd(i,j,k) = us\%m2\_s\_to\_Z2\_T * kdiff(k)}
\DoxyCodeLine{183 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{184 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{185 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{186 }
\DoxyCodeLine{187   \textcolor{comment}{! write diagnostics}}
\DoxyCodeLine{188   \textcolor{keywordflow}{if} (cs\%id\_kd > 0) \textcolor{keyword}{call }post\_data(cs\%id\_kd, kd, cs\%diag)}
\DoxyCodeLine{189   \textcolor{keywordflow}{if} (cs\%id\_kv > 0) \textcolor{keyword}{call }post\_data(cs\%id\_kv, kv, cs\%diag)}
\DoxyCodeLine{190   \textcolor{keywordflow}{if} (cs\%id\_N2 > 0) \textcolor{keyword}{call }post\_data(cs\%id\_N2, cs\%N2, cs\%diag)}
\DoxyCodeLine{191   \textcolor{keywordflow}{if} (cs\%id\_S2 > 0) \textcolor{keyword}{call }post\_data(cs\%id\_S2, cs\%S2, cs\%diag)}
\DoxyCodeLine{192   \textcolor{keywordflow}{if} (cs\%id\_ri\_grad > 0) \textcolor{keyword}{call }post\_data(cs\%id\_ri\_grad, cs\%ri\_grad, cs\%diag)}
\DoxyCodeLine{193   \textcolor{keywordflow}{if} (cs\%id\_ri\_grad\_smooth > 0) \textcolor{keyword}{call }post\_data(cs\%id\_ri\_grad\_smooth ,cs\%ri\_grad\_smooth, cs\%diag)}
\DoxyCodeLine{194 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__shear_a0c9f49bd2f832f20f4675b63b85e0e8e}\label{namespacemom__cvmix__shear_a0c9f49bd2f832f20f4675b63b85e0e8e}} 
\index{mom\_cvmix\_shear@{mom\_cvmix\_shear}!cvmix\_shear\_end@{cvmix\_shear\_end}}
\index{cvmix\_shear\_end@{cvmix\_shear\_end}!mom\_cvmix\_shear@{mom\_cvmix\_shear}}
\doxysubsubsection{\texorpdfstring{cvmix\_shear\_end()}{cvmix\_shear\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+cvmix\+\_\+shear\+::cvmix\+\_\+shear\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__cvmix__shear_1_1cvmix__shear__cs}{cvmix\+\_\+shear\+\_\+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 328 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+shear.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{329   \textcolor{keywordtype}{type}(CVMix\_shear\_cs), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< Control structure for this module that}}
\DoxyCodeLine{330 \textcolor{comment}{                                      !! will be deallocated in this subroutine}}
\DoxyCodeLine{331 }
\DoxyCodeLine{332   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{333 }
\DoxyCodeLine{334   \textcolor{keywordflow}{if} (cs\%id\_N2 > 0) \textcolor{keyword}{deallocate}(cs\%N2)}
\DoxyCodeLine{335   \textcolor{keywordflow}{if} (cs\%id\_S2 > 0) \textcolor{keyword}{deallocate}(cs\%S2)}
\DoxyCodeLine{336   \textcolor{keywordflow}{if} (cs\%id\_ri\_grad > 0) \textcolor{keyword}{deallocate}(cs\%ri\_grad)}
\DoxyCodeLine{337   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{338 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__shear_aec86faeb6ba106f8c9584dd3b6368a41}\label{namespacemom__cvmix__shear_aec86faeb6ba106f8c9584dd3b6368a41}} 
\index{mom\_cvmix\_shear@{mom\_cvmix\_shear}!cvmix\_shear\_init@{cvmix\_shear\_init}}
\index{cvmix\_shear\_init@{cvmix\_shear\_init}!mom\_cvmix\_shear@{mom\_cvmix\_shear}}
\doxysubsubsection{\texorpdfstring{cvmix\_shear\_init()}{cvmix\_shear\_init()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+cvmix\+\_\+shear\+::cvmix\+\_\+shear\+\_\+init (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__cvmix__shear_1_1cvmix__shear__cs}{cvmix\+\_\+shear\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Initialized the C\+V\+Mix internal shear mixing routine. 

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000004}{Todo}}]Does this note require emphasis? \end{DoxyRefDesc}
\begin{DoxyNote}{Note}
{\itshape This is where we test to make sure multiple internal shear mixing routines (including J\+HL) are not enabled at the same time.} (returns) C\+V\+Mix\+\_\+shear\+\_\+init -\/ True if module is to be used, False otherwise 
\end{DoxyNote}

\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 203 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+shear.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{204   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current time.}}
\DoxyCodeLine{205   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< Grid structure.}}
\DoxyCodeLine{206   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< Vertical grid structure.}}
\DoxyCodeLine{207   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{208   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Run-\/time parameter file handle}}
\DoxyCodeLine{209   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< Diagnostics control structure.}}
\DoxyCodeLine{210   \textcolor{keywordtype}{type}(CVMix\_shear\_cs),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< This module's control structure.}}
\DoxyCodeLine{211   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{212   \textcolor{keywordtype}{integer} :: NumberTrue=0}
\DoxyCodeLine{213   \textcolor{keywordtype}{logical} :: use\_JHL}
\DoxyCodeLine{214 \textcolor{comment}{! This include declares and sets the variable "{}version"{}.}}
\DoxyCodeLine{215 \textcolor{preprocessor}{\#include "{}version\_variable.h"{}}}
\DoxyCodeLine{216 \textcolor{preprocessor}{}}
\DoxyCodeLine{217   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{218     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"{}CVMix\_shear\_init called with an associated "{}}// \&}
\DoxyCodeLine{219                             \textcolor{stringliteral}{"{}control structure."{}})}
\DoxyCodeLine{220     \textcolor{keywordflow}{return}}
\DoxyCodeLine{221 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{222   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{223 }
\DoxyCodeLine{224 \textcolor{comment}{! Set default, read and log parameters}}
\DoxyCodeLine{225   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}USE\_LMD94"{}}, cs\%use\_LMD94, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{226   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}USE\_PP81"{}}, cs\%use\_PP81, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{227   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \&}
\DoxyCodeLine{228            \textcolor{stringliteral}{"{}Parameterization of shear-\/driven turbulence via CVMix (various options)"{}}, \&}
\DoxyCodeLine{229             all\_default=.not.(cs\%use\_PP81.or.cs\%use\_LMD94))}
\DoxyCodeLine{230   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}USE\_LMD94"{}}, cs\%use\_LMD94, \&}
\DoxyCodeLine{231                  \textcolor{stringliteral}{"{}If true, use the Large-\/McWilliams-\/Doney (JGR 1994) "{}}//\&}
\DoxyCodeLine{232                  \textcolor{stringliteral}{"{}shear mixing parameterization."{}}, default=.false.)}
\DoxyCodeLine{233   \textcolor{keywordflow}{if} (cs\%use\_LMD94) \textcolor{keywordflow}{then}}
\DoxyCodeLine{234      numbertrue=numbertrue + 1}
\DoxyCodeLine{235      cs\%Mix\_Scheme=\textcolor{stringliteral}{'KPP'}}
\DoxyCodeLine{236 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{237   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}USE\_PP81"{}}, cs\%use\_PP81, \&}
\DoxyCodeLine{238                  \textcolor{stringliteral}{"{}If true, use the Pacanowski and Philander (JPO 1981) "{}}//\&}
\DoxyCodeLine{239                  \textcolor{stringliteral}{"{}shear mixing parameterization."{}}, default=.false.)}
\DoxyCodeLine{240   \textcolor{keywordflow}{if} (cs\%use\_PP81) \textcolor{keywordflow}{then}}
\DoxyCodeLine{241      numbertrue = numbertrue + 1}
\DoxyCodeLine{242      cs\%Mix\_Scheme=\textcolor{stringliteral}{'PP'}}
\DoxyCodeLine{243 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{244   use\_jhl=kappa\_shear\_is\_used(param\_file)}
\DoxyCodeLine{245   \textcolor{keywordflow}{if} (use\_jhl) numbertrue = numbertrue + 1}
\DoxyCodeLine{246   \textcolor{comment}{! After testing for interior schemes, make sure only 0 or 1 are enabled.}}
\DoxyCodeLine{247   \textcolor{comment}{! Otherwise, warn user and kill job.}}
\DoxyCodeLine{248   \textcolor{keywordflow}{if} ((numbertrue) > 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{249      \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'MOM\_CVMix\_shear\_init: '}// \&}
\DoxyCodeLine{250            \textcolor{stringliteral}{'Multiple shear driven internal mixing schemes selected,'}//\&}
\DoxyCodeLine{251            \textcolor{stringliteral}{' please disable all but one scheme to proceed.'})}
\DoxyCodeLine{252 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{253   cvmix\_shear\_init=(cs\%use\_PP81.or.cs\%use\_LMD94)}
\DoxyCodeLine{254 }
\DoxyCodeLine{255 \textcolor{comment}{! Forego remainder of initialization if not using this scheme}}
\DoxyCodeLine{256   \textcolor{keywordflow}{if} (.not. cvmix\_shear\_init) \textcolor{keywordflow}{return}}
\DoxyCodeLine{257   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}NU\_ZERO"{}}, cs\%Nu\_Zero, \&}
\DoxyCodeLine{258                  \textcolor{stringliteral}{"{}Leading coefficient in KPP shear mixing."{}}, \&}
\DoxyCodeLine{259                  units=\textcolor{stringliteral}{"{}nondim"{}}, default=5.e-\/3)}
\DoxyCodeLine{260   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}RI\_ZERO"{}}, cs\%Ri\_Zero, \&}
\DoxyCodeLine{261                  \textcolor{stringliteral}{"{}Critical Richardson for KPP shear mixing, "{}}// \&}
\DoxyCodeLine{262                  \textcolor{stringliteral}{"{}NOTE this the internal mixing and this is "{}}// \&}
\DoxyCodeLine{263                  \textcolor{stringliteral}{"{}not for setting the boundary layer depth."{}} \&}
\DoxyCodeLine{264                  ,units=\textcolor{stringliteral}{"{}nondim"{}}, default=0.8)}
\DoxyCodeLine{265   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}KPP\_EXP"{}}, cs\%KPP\_exp, \&}
\DoxyCodeLine{266                  \textcolor{stringliteral}{"{}Exponent of unitless factor of diffusivities, "{}}// \&}
\DoxyCodeLine{267                  \textcolor{stringliteral}{"{}for KPP internal shear mixing scheme."{}} \&}
\DoxyCodeLine{268                  ,units=\textcolor{stringliteral}{"{}nondim"{}}, default=3.0)}
\DoxyCodeLine{269   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}SMOOTH\_RI"{}}, cs\%smooth\_ri, \&}
\DoxyCodeLine{270                  \textcolor{stringliteral}{"{}If true, vertically smooth the Richardson "{}}// \&}
\DoxyCodeLine{271                  \textcolor{stringliteral}{"{}number by applying a 1-\/2-\/1 filter once."{}}, \&}
\DoxyCodeLine{272                  default = .false.)}
\DoxyCodeLine{273   \textcolor{keyword}{call }cvmix\_init\_shear(mix\_scheme=cs\%Mix\_Scheme, \&}
\DoxyCodeLine{274                         kpp\_nu\_zero=cs\%Nu\_Zero,   \&}
\DoxyCodeLine{275                         kpp\_ri\_zero=cs\%Ri\_zero,   \&}
\DoxyCodeLine{276                         kpp\_exp=cs\%KPP\_exp)}
\DoxyCodeLine{277 }
\DoxyCodeLine{278   \textcolor{comment}{! Register diagnostics; allocation and initialization}}
\DoxyCodeLine{279   cs\%diag => diag}
\DoxyCodeLine{280 }
\DoxyCodeLine{281   cs\%id\_N2 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'N2\_shear'}, diag\%axesTi, time, \&}
\DoxyCodeLine{282       \textcolor{stringliteral}{'Square of Brunt-\/Vaisala frequency used by MOM\_CVMix\_shear module'}, \textcolor{stringliteral}{'1/s2'}, conversion=us\%s\_to\_T**2)}
\DoxyCodeLine{283   \textcolor{keywordflow}{if} (cs\%id\_N2 > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{284     \textcolor{keyword}{allocate}( cs\%N2( szi\_(g), szj\_(g), szk\_(g)+1 ) ) ; cs\%N2(:,:,:) = 0.}
\DoxyCodeLine{285 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{286 }
\DoxyCodeLine{287   cs\%id\_S2 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'S2\_shear'}, diag\%axesTi, time, \&}
\DoxyCodeLine{288       \textcolor{stringliteral}{'Square of vertical shear used by MOM\_CVMix\_shear module'},\textcolor{stringliteral}{'1/s2'}, conversion=us\%s\_to\_T**2)}
\DoxyCodeLine{289   \textcolor{keywordflow}{if} (cs\%id\_S2 > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{290     \textcolor{keyword}{allocate}( cs\%S2( szi\_(g), szj\_(g), szk\_(g)+1 ) ) ; cs\%S2(:,:,:) = 0.}
\DoxyCodeLine{291 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{292 }
\DoxyCodeLine{293   cs\%id\_ri\_grad = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ri\_grad\_shear'}, diag\%axesTi, time, \&}
\DoxyCodeLine{294       \textcolor{stringliteral}{'Gradient Richarson number used by MOM\_CVMix\_shear module'},\textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{295   \textcolor{keywordflow}{if} (cs\%id\_ri\_grad > 0) \textcolor{keywordflow}{then} \textcolor{comment}{!Initialize w/ large Richardson value}}
\DoxyCodeLine{296     \textcolor{keyword}{allocate}( cs\%ri\_grad( szi\_(g), szj\_(g), szk\_(g)+1 )) ; cs\%ri\_grad(:,:,:) = 1.e8}
\DoxyCodeLine{297 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{298 }
\DoxyCodeLine{299   cs\%id\_ri\_grad\_smooth = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ri\_grad\_shear\_smooth'}, \&}
\DoxyCodeLine{300        diag\%axesTi, time, \&}
\DoxyCodeLine{301       \textcolor{stringliteral}{'Smoothed gradient Richarson number used by MOM\_CVMix\_shear module'},\textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{302   \textcolor{keywordflow}{if} (cs\%id\_ri\_grad\_smooth > 0) \textcolor{keywordflow}{then} \textcolor{comment}{!Initialize w/ large Richardson value}}
\DoxyCodeLine{303     \textcolor{keyword}{allocate}( cs\%ri\_grad\_smooth( szi\_(g), szj\_(g), szk\_(g)+1 )) ; cs\%ri\_grad\_smooth(:,:,:) = 1.e8}
\DoxyCodeLine{304 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{305 }
\DoxyCodeLine{306   cs\%id\_kd = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'kd\_shear\_CVMix'}, diag\%axesTi, time, \&}
\DoxyCodeLine{307       \textcolor{stringliteral}{'Vertical diffusivity added by MOM\_CVMix\_shear module'}, \textcolor{stringliteral}{'m2/s'}, conversion=us\%Z2\_T\_to\_m2\_s)}
\DoxyCodeLine{308   cs\%id\_kv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'kv\_shear\_CVMix'}, diag\%axesTi, time, \&}
\DoxyCodeLine{309       \textcolor{stringliteral}{'Vertical viscosity added by MOM\_CVMix\_shear module'}, \textcolor{stringliteral}{'m2/s'}, conversion=us\%Z2\_T\_to\_m2\_s)}
\DoxyCodeLine{310 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__cvmix__shear_aa8084ded891a4e6e33ceeec0f240233f}\label{namespacemom__cvmix__shear_aa8084ded891a4e6e33ceeec0f240233f}} 
\index{mom\_cvmix\_shear@{mom\_cvmix\_shear}!cvmix\_shear\_is\_used@{cvmix\_shear\_is\_used}}
\index{cvmix\_shear\_is\_used@{cvmix\_shear\_is\_used}!mom\_cvmix\_shear@{mom\_cvmix\_shear}}
\doxysubsubsection{\texorpdfstring{cvmix\_shear\_is\_used()}{cvmix\_shear\_is\_used()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+cvmix\+\_\+shear\+::cvmix\+\_\+shear\+\_\+is\+\_\+used (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}



Reads the parameters \char`\"{}\+L\+M\+D94\char`\"{} and \char`\"{}\+P\+P81\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} & Run-\/time parameter files handle. \\
\hline
\end{DoxyParams}


Definition at line 316 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+shear.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{317   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Run-\/time parameter files handle.}}
\DoxyCodeLine{318   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{319   \textcolor{keywordtype}{logical} :: LMD94, PP81}
\DoxyCodeLine{320   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}USE\_LMD94"{}}, lmd94, \&}
\DoxyCodeLine{321        default=.false., do\_not\_log = .true.)}
\DoxyCodeLine{322   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}Use\_PP81"{}}, pp81, \&}
\DoxyCodeLine{323        default=.false., do\_not\_log = .true.)}
\DoxyCodeLine{324   cvmix\_shear\_is\_used = (lmd94 .or. pp81)}

\end{DoxyCode}
