\hypertarget{namespacemom__cvmix__shear}{}\section{mom\+\_\+cvmix\+\_\+shear Module Reference}
\label{namespacemom__cvmix__shear}\index{mom\+\_\+cvmix\+\_\+shear@{mom\+\_\+cvmix\+\_\+shear}}


\subsection{Detailed Description}
Interface to C\+V\+Mix interior shear schemes. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \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}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \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 \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 \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 \hyperlink{namespacemom__cvmix__shear_a0c9f49bd2f832f20f4675b63b85e0e8e}{cvmix\+\_\+shear\+\_\+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__shear_a8a2b801d6b67aa28ccd4782b3e20a0e9}\label{namespacemom__cvmix__shear_a8a2b801d6b67aa28ccd4782b3e20a0e9}} 
character(len=40) \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}


\subsection{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}}
\subsubsection{\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(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(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__shear_1_1cvmix__shear__cs}{cvmix\+\_\+shear\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Subroutine for calculating (internal) vertical diffusivities/viscosities. 


\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 u\+\_\+h} & Initial zonal velocity on T points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em v\+\_\+h} & Initial meridional velocity on T points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\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 out}  & {\em kd} & The vertical diffusivity at each interface (not layer!) \mbox{[}Z2 T-\/1 $\sim$$>$ m2 s-\/1\mbox{]}.\\
\hline
\mbox{\tt 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 60 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+shear.\+F90.


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


\begin{DoxyCode}
329   \textcolor{keywordtype}{type}(cvmix\_shear\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< Control structure for this module that}
330 \textcolor{comment}{                                      !! will be deallocated in this subroutine}
331 
332   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
333 
334   \textcolor{keywordflow}{if} (cs%id\_N2 > 0) \textcolor{keyword}{deallocate}(cs%N2)
335   \textcolor{keywordflow}{if} (cs%id\_S2 > 0) \textcolor{keyword}{deallocate}(cs%S2)
336   \textcolor{keywordflow}{if} (cs%id\_ri\_grad > 0) \textcolor{keyword}{deallocate}(cs%ri\_grad)
337   \textcolor{keyword}{deallocate}(cs)
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}}
\subsubsection{\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(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__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[\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{\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 204 of file M\+O\+M\+\_\+\+C\+V\+Mix\+\_\+shear.\+F90.


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


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


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