\hypertarget{namespacemom__int__tide__input}{}\section{mom\+\_\+int\+\_\+tide\+\_\+input Module Reference}
\label{namespacemom__int__tide__input}\index{mom\_int\_tide\_input@{mom\_int\_tide\_input}}


\subsection{Detailed Description}
Calculates energy input to the internal tides. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__int__tide__input_1_1int__tide__input__cs}{int\+\_\+tide\+\_\+input\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em This control structure holds parameters that regulate internal tide energy inputs. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__int__tide__input_1_1int__tide__input__type}{int\+\_\+tide\+\_\+input\+\_\+type}}
\begin{DoxyCompactList}\small\item\em This type is used to exchange fields related to the internal tides. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__int__tide__input_a33db0008342a1b2af532fa9501296d81}{set\+\_\+int\+\_\+tide\+\_\+input}} (u, v, h, tv, fluxes, itide, dt, G, GV, US, CS)
\begin{DoxyCompactList}\small\item\em Sets the model-\/state dependent internal tide energy sources. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__int__tide__input_aac35fcf23f86c82c43dc27445743de04}{find\+\_\+n2\+\_\+bottom}} (h, tv, T\+\_\+f, S\+\_\+f, h2, fluxes, G, GV, US, N2\+\_\+bot)
\begin{DoxyCompactList}\small\item\em Estimates the near-\/bottom buoyancy frequency (N$^\wedge$2). \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__int__tide__input_a134b589adde1907265c096afdb9a23b8}{int\+\_\+tide\+\_\+input\+\_\+init}} (Time, G, GV, US, param\+\_\+file, diag, CS, itide)
\begin{DoxyCompactList}\small\item\em Initializes the data related to the internal tide input module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__int__tide__input_a5d3501718d33ac915cb9595f9d51b089}{int\+\_\+tide\+\_\+input\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Deallocates any memory related to the internal tide input module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__int__tide__input_aac35fcf23f86c82c43dc27445743de04}\label{namespacemom__int__tide__input_aac35fcf23f86c82c43dc27445743de04}} 
\index{mom\_int\_tide\_input@{mom\_int\_tide\_input}!find\_n2\_bottom@{find\_n2\_bottom}}
\index{find\_n2\_bottom@{find\_n2\_bottom}!mom\_int\_tide\_input@{mom\_int\_tide\_input}}
\subsubsection{\texorpdfstring{find\_n2\_bottom()}{find\_n2\_bottom()}}
{\footnotesize\ttfamily subroutine mom\+\_\+int\+\_\+tide\+\_\+input\+::find\+\_\+n2\+\_\+bottom (\begin{DoxyParamCaption}\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)), intent(in)}]{T\+\_\+f,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{S\+\_\+f,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{h2,  }\item[{type(forcing), intent(in)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(out)}]{N2\+\_\+bot }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Estimates the near-\/bottom buoyancy frequency (N$^\wedge$2). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure containing pointers to the thermodynamic fields \\
\hline
\mbox{\texttt{ in}}  & {\em t\+\_\+f} & Temperature after vertical filtering to smooth out the values in thin layers \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s\+\_\+f} & Salinity after vertical filtering to smooth out the values in thin layers \mbox{[}ppt\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em h2} & Bottom topographic roughness \mbox{[}Z2 $\sim$$>$ m2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em fluxes} & A structure of thermodynamic surface fluxes \\
\hline
\mbox{\texttt{ out}}  & {\em n2\+\_\+bot} & The squared buoyancy freqency at the ocean bottom \mbox{[}T-\/2 $\sim$$>$ s-\/2\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 151 of file M\+O\+M\+\_\+internal\+\_\+tide\+\_\+input.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{151   \textcolor{keywordtype}{type}(ocean\_grid\_type),                    \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{152   \textcolor{keywordtype}{type}(verticalGrid\_type),                  \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{153   \textcolor{keywordtype}{type}(unit\_scale\_type),                    \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{154 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}}
\DoxyCodeLine{155   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                    \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{   !< A structure containing pointers to the}}
\DoxyCodeLine{156 \textcolor{comment}{                                                                !! thermodynamic fields}}
\DoxyCodeLine{157 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}  :: T\_f\textcolor{comment}{  !< Temperature after vertical filtering to}}
\DoxyCodeLine{158 \textcolor{comment}{                                                                !! smooth out the values in thin layers [degC].}}
\DoxyCodeLine{159 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}  :: S\_f\textcolor{comment}{  !< Salinity after vertical filtering to}}
\DoxyCodeLine{160 \textcolor{comment}{                                                                !! smooth out the values in thin layers [ppt].}}
\DoxyCodeLine{161 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},         \textcolor{keywordtype}{intent(in)}  :: h2\textcolor{comment}{   !< Bottom topographic roughness [Z2 ~> m2].}}
\DoxyCodeLine{162   \textcolor{keywordtype}{type}(forcing),                            \textcolor{keywordtype}{intent(in)}  :: fluxes\textcolor{comment}{ !< A structure of thermodynamic surface fluxes}}
\DoxyCodeLine{163   \textcolor{keywordtype}{type}(int\_tide\_input\_CS),                  \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{    !<  This module's control structure.}}
\DoxyCodeLine{164 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},         \textcolor{keywordtype}{intent(out)} :: N2\_bot\textcolor{comment}{ !< The squared buoyancy freqency at the}}
\DoxyCodeLine{165 \textcolor{comment}{                                                                 !! ocean bottom [T-2 ~> s-2].}}
\DoxyCodeLine{166   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{167 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(G)+1)} :: \&}
\DoxyCodeLine{168     dRho\_int      \textcolor{comment}{! The unfiltered density differences across interfaces [R ~> kg m-3].}}
\DoxyCodeLine{169 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G))} :: \&}
\DoxyCodeLine{170     pres, \&       \textcolor{comment}{! The pressure at each interface [R L2 T-2 ~> Pa].}}
\DoxyCodeLine{171     Temp\_int, \&   \textcolor{comment}{! The temperature at each interface [degC].}}
\DoxyCodeLine{172     Salin\_int, \&  \textcolor{comment}{! The salinity at each interface [ppt].}}
\DoxyCodeLine{173     drho\_bot, \&   \textcolor{comment}{! The density difference at the bottom of a layer [R ~> kg m-3]}}
\DoxyCodeLine{174     h\_amp, \&      \textcolor{comment}{! The amplitude of topographic roughness [Z ~> m].}}
\DoxyCodeLine{175     hb, \&         \textcolor{comment}{! The depth below a layer [Z ~> m].}}
\DoxyCodeLine{176     z\_from\_bot, \& \textcolor{comment}{! The height of a layer center above the bottom [Z ~> m].}}
\DoxyCodeLine{177     dRho\_dT, \&    \textcolor{comment}{! The partial derivative of density with temperature [R degC-1 ~> kg m-3 degC-1]}}
\DoxyCodeLine{178     dRho\_dS       \textcolor{comment}{! The partial derivative of density with salinity [R ppt-1 ~> kg m-3 ppt-1].}}
\DoxyCodeLine{179 }
\DoxyCodeLine{180 \textcolor{keywordtype}{  real} :: dz\_int  \textcolor{comment}{! The thickness associated with an interface [Z ~> m].}}
\DoxyCodeLine{181 \textcolor{keywordtype}{  real} :: G\_Rho0  \textcolor{comment}{! The gravitation acceleration divided by the Boussinesq}}
\DoxyCodeLine{182                   \textcolor{comment}{! density [Z T-2 R-1 ~> m4 s-2 kg-1].}}
\DoxyCodeLine{183   \textcolor{keywordtype}{logical} :: do\_i(SZI\_(G)), do\_any}
\DoxyCodeLine{184   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The i-computational domain for the equation of state}}
\DoxyCodeLine{185   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{186 }
\DoxyCodeLine{187   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{188   g\_rho0 = (us\%L\_to\_Z**2*gv\%g\_Earth) / gv\%Rho0}
\DoxyCodeLine{189   eosdom(:) = eos\_domain(g\%HI)}
\DoxyCodeLine{190 }
\DoxyCodeLine{191   \textcolor{comment}{! Find the (limited) density jump across each interface.}}
\DoxyCodeLine{192   \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{193     drho\_int(i,1) = 0.0 ; drho\_int(i,nz+1) = 0.0}
\DoxyCodeLine{194 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{195 \textcolor{comment}{!\$OMP parallel do default(none) shared(is,ie,js,je,nz,tv,fluxes,G,GV,US,h,T\_f,S\_f, \&}}
\DoxyCodeLine{196 \textcolor{comment}{!\$OMP                                  h2,N2\_bot,G\_Rho0,EOSdom) \&}}
\DoxyCodeLine{197 \textcolor{comment}{!\$OMP                          private(pres,Temp\_Int,Salin\_Int,dRho\_dT,dRho\_dS, \&}}
\DoxyCodeLine{198 \textcolor{comment}{!\$OMP                                  hb,dRho\_bot,z\_from\_bot,do\_i,h\_amp,       \&}}
\DoxyCodeLine{199 \textcolor{comment}{!\$OMP                                  do\_any,dz\_int) \&}}
\DoxyCodeLine{200 \textcolor{comment}{!\$OMP                     firstprivate(dRho\_int)}}
\DoxyCodeLine{201   \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{202     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{203       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%p\_surf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{204         \textcolor{keywordflow}{do} i=is,ie ; pres(i) = fluxes\%p\_surf(i,j) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{205       \textcolor{keywordflow}{else}}
\DoxyCodeLine{206         \textcolor{keywordflow}{do} i=is,ie ; pres(i) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{207 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{208       \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{209         \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{210           pres(i) = pres(i) + (gv\%g\_Earth*gv\%H\_to\_RZ)*h(i,j,k-1)}
\DoxyCodeLine{211           temp\_int(i) = 0.5 * (t\_f(i,j,k) + t\_f(i,j,k-1))}
\DoxyCodeLine{212           salin\_int(i) = 0.5 * (s\_f(i,j,k) + s\_f(i,j,k-1))}
\DoxyCodeLine{213 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{214         \textcolor{keyword}{call }calculate\_density\_derivs(temp\_int, salin\_int, pres, drho\_dt(:), drho\_ds(:), \&}
\DoxyCodeLine{215                                       tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{216         \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{217           drho\_int(i,k) = max(drho\_dt(i)*(t\_f(i,j,k) - t\_f(i,j,k-1)) + \&}
\DoxyCodeLine{218                               drho\_ds(i)*(s\_f(i,j,k) - s\_f(i,j,k-1)), 0.0)}
\DoxyCodeLine{219 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{220 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{221     \textcolor{keywordflow}{else}}
\DoxyCodeLine{222       \textcolor{keywordflow}{do} k=2,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{223         drho\_int(i,k) = (gv\%Rlay(k) - gv\%Rlay(k-1))}
\DoxyCodeLine{224 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{225 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{226 }
\DoxyCodeLine{227     \textcolor{comment}{! Find the bottom boundary layer stratification.}}
\DoxyCodeLine{228     \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{229       hb(i) = 0.0 ; drho\_bot(i) = 0.0}
\DoxyCodeLine{230       z\_from\_bot(i) = 0.5*gv\%H\_to\_Z*h(i,j,nz)}
\DoxyCodeLine{231       do\_i(i) = (g\%mask2dT(i,j) > 0.5)}
\DoxyCodeLine{232       h\_amp(i) = sqrt(h2(i,j))}
\DoxyCodeLine{233 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{234 }
\DoxyCodeLine{235     \textcolor{keywordflow}{do} k=nz,2,-1}
\DoxyCodeLine{236       do\_any = .false.}
\DoxyCodeLine{237       \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (do\_i(i)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{238         dz\_int = 0.5*gv\%H\_to\_Z*(h(i,j,k) + h(i,j,k-1))}
\DoxyCodeLine{239         z\_from\_bot(i) = z\_from\_bot(i) + dz\_int \textcolor{comment}{! middle of the layer above}}
\DoxyCodeLine{240 }
\DoxyCodeLine{241         hb(i) = hb(i) + dz\_int}
\DoxyCodeLine{242         drho\_bot(i) = drho\_bot(i) + drho\_int(i,k)}
\DoxyCodeLine{243 }
\DoxyCodeLine{244         \textcolor{keywordflow}{if} (z\_from\_bot(i) > h\_amp(i)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{245           \textcolor{keywordflow}{if} (k>2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{246             \textcolor{comment}{! Always include at least one full layer.}}
\DoxyCodeLine{247             hb(i) = hb(i) + 0.5*gv\%H\_to\_Z*(h(i,j,k-1) + h(i,j,k-2))}
\DoxyCodeLine{248             drho\_bot(i) = drho\_bot(i) + drho\_int(i,k-1)}
\DoxyCodeLine{249 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{250           do\_i(i) = .false.}
\DoxyCodeLine{251         \textcolor{keywordflow}{else}}
\DoxyCodeLine{252           do\_any = .true.}
\DoxyCodeLine{253 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{254 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{255       \textcolor{keywordflow}{if} (.not.do\_any) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{256 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{257 }
\DoxyCodeLine{258     \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{259       \textcolor{keywordflow}{if} (hb(i) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{260         n2\_bot(i,j) = (g\_rho0 * drho\_bot(i)) / hb(i)}
\DoxyCodeLine{261       \textcolor{keywordflow}{else} ;  n2\_bot(i,j) = 0.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{262 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{263 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{264 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__int__tide__input_a5d3501718d33ac915cb9595f9d51b089}\label{namespacemom__int__tide__input_a5d3501718d33ac915cb9595f9d51b089}} 
\index{mom\_int\_tide\_input@{mom\_int\_tide\_input}!int\_tide\_input\_end@{int\_tide\_input\_end}}
\index{int\_tide\_input\_end@{int\_tide\_input\_end}!mom\_int\_tide\_input@{mom\_int\_tide\_input}}
\subsubsection{\texorpdfstring{int\_tide\_input\_end()}{int\_tide\_input\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+int\+\_\+tide\+\_\+input\+::int\+\_\+tide\+\_\+input\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__int__tide__input_1_1int__tide__input__cs}{int\+\_\+tide\+\_\+input\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Deallocates any memory related to the internal tide input module. 


\begin{DoxyParams}{Parameters}
{\em cs} & This module\textquotesingle{}s control structure, which is deallocated here. \\
\hline
\end{DoxyParams}


Definition at line 426 of file M\+O\+M\+\_\+internal\+\_\+tide\+\_\+input.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{426   \textcolor{keywordtype}{type}(int\_tide\_input\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< This module's control structure, which is deallocated here.}}
\DoxyCodeLine{427 }
\DoxyCodeLine{428   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{429 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__int__tide__input_a134b589adde1907265c096afdb9a23b8}\label{namespacemom__int__tide__input_a134b589adde1907265c096afdb9a23b8}} 
\index{mom\_int\_tide\_input@{mom\_int\_tide\_input}!int\_tide\_input\_init@{int\_tide\_input\_init}}
\index{int\_tide\_input\_init@{int\_tide\_input\_init}!mom\_int\_tide\_input@{mom\_int\_tide\_input}}
\subsubsection{\texorpdfstring{int\_tide\_input\_init()}{int\_tide\_input\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+int\+\_\+tide\+\_\+input\+::int\+\_\+tide\+\_\+input\+\_\+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__int__tide__input_1_1int__tide__input__cs}{int\+\_\+tide\+\_\+input\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__int__tide__input_1_1int__tide__input__type}{int\+\_\+tide\+\_\+input\+\_\+type}}), pointer}]{itide }\end{DoxyParamCaption})}



Initializes the data related to the internal tide input module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & structure used to regulate diagnostic output. \\
\hline
 & {\em cs} & This module\textquotesingle{}s control structure, which is initialized here. \\
\hline
 & {\em itide} & A structure containing fields related to the internal tide sources. \\
\hline
\end{DoxyParams}


Definition at line 269 of file M\+O\+M\+\_\+internal\+\_\+tide\+\_\+input.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{269   \textcolor{keywordtype}{type}(time\_type),           \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{270   \textcolor{keywordtype}{type}(ocean\_grid\_type),     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{271   \textcolor{keywordtype}{type}(verticalGrid\_type),   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{272   \textcolor{keywordtype}{type}(unit\_scale\_type),     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{273   \textcolor{keywordtype}{type}(param\_file\_type),     \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}}
\DoxyCodeLine{274   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< structure used to regulate diagnostic output.}}
\DoxyCodeLine{275   \textcolor{keywordtype}{type}(int\_tide\_input\_CS),   \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< This module's control structure, which is initialized here.}}
\DoxyCodeLine{276   \textcolor{keywordtype}{type}(int\_tide\_input\_type), \textcolor{keywordtype}{pointer}       :: itide\textcolor{comment}{ !< A structure containing fields related}}
\DoxyCodeLine{277 \textcolor{comment}{                                                   !! to the internal tide sources.}}
\DoxyCodeLine{278   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{279   \textcolor{keywordtype}{type}(vardesc) :: vd}
\DoxyCodeLine{280   \textcolor{keywordtype}{logical} :: read\_tideamp}
\DoxyCodeLine{281   \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{282 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{283 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_int\_tide\_input"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{284   \textcolor{keywordtype}{character(len=20)}  :: tmpstr}
\DoxyCodeLine{285   \textcolor{keywordtype}{character(len=200)} :: filename, tideamp\_file, h2\_file}
\DoxyCodeLine{286 }
\DoxyCodeLine{287 \textcolor{keywordtype}{  real} :: mask\_itidal        \textcolor{comment}{! A multiplicative land mask, 0 or 1 [nondim]}}
\DoxyCodeLine{288 \textcolor{keywordtype}{  real} :: max\_frac\_rough     \textcolor{comment}{! The fraction relating the maximum topographic roughness}}
\DoxyCodeLine{289                              \textcolor{comment}{! to the mean depth [nondim]}}
\DoxyCodeLine{290 \textcolor{keywordtype}{  real} :: utide              \textcolor{comment}{! constant tidal amplitude [L T-1 ~> m s-1] to be used if}}
\DoxyCodeLine{291                              \textcolor{comment}{! tidal amplitude file is not present.}}
\DoxyCodeLine{292 \textcolor{keywordtype}{  real} :: kappa\_h2\_factor    \textcolor{comment}{! factor for the product of wavenumber * rms sgs height [nondim].}}
\DoxyCodeLine{293 \textcolor{keywordtype}{  real} :: kappa\_itides       \textcolor{comment}{! topographic wavenumber and non-dimensional scaling [L-1 ~> m-1]}}
\DoxyCodeLine{294 \textcolor{keywordtype}{  real} :: min\_zbot\_itides    \textcolor{comment}{! Minimum ocean depth for internal tide conversion [Z ~> m].}}
\DoxyCodeLine{295   \textcolor{keywordtype}{integer} :: tlen\_days\textcolor{comment}{       !< Time interval from start for adding wave source}}
\DoxyCodeLine{296 \textcolor{comment}{                             !! for testing internal tides (BDM)}}
\DoxyCodeLine{297   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{298 }
\DoxyCodeLine{299   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{300     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"int\_tide\_input\_init called with an associated "}// \&}
\DoxyCodeLine{301                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{302     \textcolor{keywordflow}{return}}
\DoxyCodeLine{303 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{304   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(itide)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{305     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"int\_tide\_input\_init called with an associated "}// \&}
\DoxyCodeLine{306                             \textcolor{stringliteral}{"internal tide input type."})}
\DoxyCodeLine{307     \textcolor{keywordflow}{return}}
\DoxyCodeLine{308 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{309   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{310   \textcolor{keyword}{allocate}(itide)}
\DoxyCodeLine{311 }
\DoxyCodeLine{312   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{313   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{314 }
\DoxyCodeLine{315   cs\%diag => diag}
\DoxyCodeLine{316 }
\DoxyCodeLine{317   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{318   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{319 }
\DoxyCodeLine{320   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, cs\%inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{321   cs\%inputdir = slasher(cs\%inputdir)}
\DoxyCodeLine{322 }
\DoxyCodeLine{323   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, cs\%debug, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{324 }
\DoxyCodeLine{325   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_ZBOT\_ITIDES"}, min\_zbot\_itides, \&}
\DoxyCodeLine{326                \textcolor{stringliteral}{"Turn off internal tidal dissipation when the total "}//\&}
\DoxyCodeLine{327                \textcolor{stringliteral}{"ocean depth is less than this value."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us\%m\_to\_Z)}
\DoxyCodeLine{328   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KD\_SMOOTH"}, cs\%kappa\_fill, \&}
\DoxyCodeLine{329                  \textcolor{stringliteral}{"A diapycnal diffusivity that is used to interpolate "}//\&}
\DoxyCodeLine{330                  \textcolor{stringliteral}{"more sensible values of T \& S into thin layers."}, \&}
\DoxyCodeLine{331                  units=\textcolor{stringliteral}{"m2 s-1"}, default=1.0e-6, scale=us\%m2\_s\_to\_Z2\_T)}
\DoxyCodeLine{332 }
\DoxyCodeLine{333   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"UTIDE"}, utide, \&}
\DoxyCodeLine{334                \textcolor{stringliteral}{"The constant tidal amplitude used with INT\_TIDE\_DISSIPATION."}, \&}
\DoxyCodeLine{335                units=\textcolor{stringliteral}{"m s-1"}, default=0.0, scale=us\%m\_s\_to\_L\_T)}
\DoxyCodeLine{336 }
\DoxyCodeLine{337   \textcolor{keyword}{allocate}(itide\%Nb(isd:ied,jsd:jed))  ; itide\%Nb(:,:) = 0.0}
\DoxyCodeLine{338   \textcolor{keyword}{allocate}(itide\%h2(isd:ied,jsd:jed))  ; itide\%h2(:,:) = 0.0}
\DoxyCodeLine{339   \textcolor{keyword}{allocate}(itide\%TKE\_itidal\_input(isd:ied,jsd:jed)) ; itide\%TKE\_itidal\_input(:,:) = 0.0}
\DoxyCodeLine{340   \textcolor{keyword}{allocate}(itide\%tideamp(isd:ied,jsd:jed)) ; itide\%tideamp(:,:) = utide}
\DoxyCodeLine{341   \textcolor{keyword}{allocate}(cs\%TKE\_itidal\_coef(isd:ied,jsd:jed)) ; cs\%TKE\_itidal\_coef(:,:) = 0.0}
\DoxyCodeLine{342 }
\DoxyCodeLine{343   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_ITIDES"}, kappa\_itides, \&}
\DoxyCodeLine{344                \textcolor{stringliteral}{"A topographic wavenumber used with INT\_TIDE\_DISSIPATION. "}//\&}
\DoxyCodeLine{345                \textcolor{stringliteral}{"The default is 2pi/10 km, as in St.Laurent et al. 2002."}, \&}
\DoxyCodeLine{346                units=\textcolor{stringliteral}{"m-1"}, default=8.e-4*atan(1.0), scale=us\%L\_to\_m)}
\DoxyCodeLine{347 }
\DoxyCodeLine{348   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KAPPA\_H2\_FACTOR"}, kappa\_h2\_factor, \&}
\DoxyCodeLine{349                \textcolor{stringliteral}{"A scaling factor for the roughness amplitude with n"}//\&}
\DoxyCodeLine{350                \textcolor{stringliteral}{"INT\_TIDE\_DISSIPATION."},  units=\textcolor{stringliteral}{"nondim"}, default=1.0)}
\DoxyCodeLine{351   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TKE\_ITIDE\_MAX"}, cs\%TKE\_itide\_max, \&}
\DoxyCodeLine{352                \textcolor{stringliteral}{"The maximum internal tide energy source available to mix "}//\&}
\DoxyCodeLine{353                \textcolor{stringliteral}{"above the bottom boundary layer with INT\_TIDE\_DISSIPATION."}, \&}
\DoxyCodeLine{354                units=\textcolor{stringliteral}{"W m-2"}, default=1.0e3, scale=us\%W\_m2\_to\_RZ3\_T3)}
\DoxyCodeLine{355 }
\DoxyCodeLine{356   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"READ\_TIDEAMP"}, read\_tideamp, \&}
\DoxyCodeLine{357                \textcolor{stringliteral}{"If true, read a file (given by TIDEAMP\_FILE) containing "}//\&}
\DoxyCodeLine{358                \textcolor{stringliteral}{"the tidal amplitude with INT\_TIDE\_DISSIPATION."}, default=.false.)}
\DoxyCodeLine{359   \textcolor{keywordflow}{if} (read\_tideamp) \textcolor{keywordflow}{then}}
\DoxyCodeLine{360     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDEAMP\_FILE"}, tideamp\_file, \&}
\DoxyCodeLine{361                \textcolor{stringliteral}{"The path to the file containing the spatially varying "}//\&}
\DoxyCodeLine{362                \textcolor{stringliteral}{"tidal amplitudes with INT\_TIDE\_DISSIPATION."}, default=\textcolor{stringliteral}{"tideamp.nc"})}
\DoxyCodeLine{363     filename = trim(cs\%inputdir) // trim(tideamp\_file)}
\DoxyCodeLine{364     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/TIDEAMP\_FILE"}, filename)}
\DoxyCodeLine{365     \textcolor{keyword}{call }mom\_read\_data(filename, \textcolor{stringliteral}{'tideamp'}, itide\%tideamp, g\%domain, timelevel=1, scale=us\%m\_s\_to\_L\_T)}
\DoxyCodeLine{366 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{367 }
\DoxyCodeLine{368   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"H2\_FILE"}, h2\_file, \&}
\DoxyCodeLine{369                \textcolor{stringliteral}{"The path to the file containing the sub-grid-scale "}//\&}
\DoxyCodeLine{370                \textcolor{stringliteral}{"topographic roughness amplitude with INT\_TIDE\_DISSIPATION."}, \&}
\DoxyCodeLine{371                fail\_if\_missing=.true.)}
\DoxyCodeLine{372   filename = trim(cs\%inputdir) // trim(h2\_file)}
\DoxyCodeLine{373   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/H2\_FILE"}, filename)}
\DoxyCodeLine{374   \textcolor{keyword}{call }mom\_read\_data(filename, \textcolor{stringliteral}{'h2'}, itide\%h2, g\%domain, timelevel=1, scale=us\%m\_to\_Z**2)}
\DoxyCodeLine{375 }
\DoxyCodeLine{376   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FRACTIONAL\_ROUGHNESS\_MAX"}, max\_frac\_rough, \&}
\DoxyCodeLine{377                  \textcolor{stringliteral}{"The maximum topographic roughness amplitude as a fraction of the mean depth, "}//\&}
\DoxyCodeLine{378                  \textcolor{stringliteral}{"or a negative value for no limitations on roughness."}, \&}
\DoxyCodeLine{379                  units=\textcolor{stringliteral}{"nondim"}, default=0.1)}
\DoxyCodeLine{380 }
\DoxyCodeLine{381   \textcolor{comment}{! The following parameters are used in testing the internal tide code.}}
\DoxyCodeLine{382   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERNAL\_TIDE\_SOURCE\_TEST"}, cs\%int\_tide\_source\_test, \&}
\DoxyCodeLine{383                  \textcolor{stringliteral}{"If true, apply an arbitrary generation site for internal tide testing"}, \&}
\DoxyCodeLine{384                  default=.false.)}
\DoxyCodeLine{385   \textcolor{keywordflow}{if} (cs\%int\_tide\_source\_test)\textcolor{keywordflow}{then}}
\DoxyCodeLine{386     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERNAL\_TIDE\_SOURCE\_X"}, cs\%int\_tide\_source\_x, \&}
\DoxyCodeLine{387                  \textcolor{stringliteral}{"X Location of generation site for internal tide"}, default=1.)}
\DoxyCodeLine{388     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERNAL\_TIDE\_SOURCE\_Y"}, cs\%int\_tide\_source\_y, \&}
\DoxyCodeLine{389                  \textcolor{stringliteral}{"Y Location of generation site for internal tide"}, default=1.)}
\DoxyCodeLine{390     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERNAL\_TIDE\_SOURCE\_TLEN\_DAYS"}, tlen\_days, \&}
\DoxyCodeLine{391                  \textcolor{stringliteral}{"Time interval from start of experiment for adding wave source"}, \&}
\DoxyCodeLine{392                  units=\textcolor{stringliteral}{"days"}, default=0)}
\DoxyCodeLine{393     cs\%time\_max\_source = time + set\_time(0, days=tlen\_days)}
\DoxyCodeLine{394 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{395 }
\DoxyCodeLine{396   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{397     mask\_itidal = 1.0}
\DoxyCodeLine{398     \textcolor{keywordflow}{if} (g\%bathyT(i,j) < min\_zbot\_itides) mask\_itidal = 0.0}
\DoxyCodeLine{399 }
\DoxyCodeLine{400     itide\%tideamp(i,j) = itide\%tideamp(i,j) * mask\_itidal * g\%mask2dT(i,j)}
\DoxyCodeLine{401 }
\DoxyCodeLine{402     \textcolor{comment}{! Restrict rms topo to a fraction (often 10 percent) of the column depth.}}
\DoxyCodeLine{403     \textcolor{keywordflow}{if} (max\_frac\_rough >= 0.0) \&}
\DoxyCodeLine{404       itide\%h2(i,j) = min((max\_frac\_rough*g\%bathyT(i,j))**2, itide\%h2(i,j))}
\DoxyCodeLine{405 }
\DoxyCodeLine{406     \textcolor{comment}{! Compute the fixed part of internal tidal forcing; units are [R Z3 T-2 ~> J m-2] here.}}
\DoxyCodeLine{407     cs\%TKE\_itidal\_coef(i,j) = 0.5*us\%L\_to\_Z*kappa\_h2\_factor*gv\%Rho0*\&}
\DoxyCodeLine{408          kappa\_itides * itide\%h2(i,j) * itide\%tideamp(i,j)**2}
\DoxyCodeLine{409 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{410 }
\DoxyCodeLine{411 }
\DoxyCodeLine{412   cs\%id\_TKE\_itidal = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'TKE\_itidal\_itide'},diag\%axesT1,time, \&}
\DoxyCodeLine{413       \textcolor{stringliteral}{'Internal Tide Driven Turbulent Kinetic Energy'}, \&}
\DoxyCodeLine{414       \textcolor{stringliteral}{'W m-2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{415 }
\DoxyCodeLine{416   cs\%id\_Nb = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'Nb\_itide'},diag\%axesT1,time, \&}
\DoxyCodeLine{417        \textcolor{stringliteral}{'Bottom Buoyancy Frequency'}, \textcolor{stringliteral}{'s-1'}, conversion=us\%s\_to\_T)}
\DoxyCodeLine{418 }
\DoxyCodeLine{419   cs\%id\_N2\_bot = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'N2\_b\_itide'},diag\%axesT1,time, \&}
\DoxyCodeLine{420        \textcolor{stringliteral}{'Bottom Buoyancy frequency squared'}, \textcolor{stringliteral}{'s-2'}, conversion=us\%s\_to\_T**2)}
\DoxyCodeLine{421 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__int__tide__input_a33db0008342a1b2af532fa9501296d81}\label{namespacemom__int__tide__input_a33db0008342a1b2af532fa9501296d81}} 
\index{mom\_int\_tide\_input@{mom\_int\_tide\_input}!set\_int\_tide\_input@{set\_int\_tide\_input}}
\index{set\_int\_tide\_input@{set\_int\_tide\_input}!mom\_int\_tide\_input@{mom\_int\_tide\_input}}
\subsubsection{\texorpdfstring{set\_int\_tide\_input()}{set\_int\_tide\_input()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+int\+\_\+tide\+\_\+input\+::set\+\_\+int\+\_\+tide\+\_\+input (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in)}]{v,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(forcing), intent(in)}]{fluxes,  }\item[{type(\mbox{\hyperlink{structmom__int__tide__input_1_1int__tide__input__type}{int\+\_\+tide\+\_\+input\+\_\+type}}), intent(inout)}]{itide,  }\item[{real, intent(in)}]{dt,  }\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(\mbox{\hyperlink{structmom__int__tide__input_1_1int__tide__input__cs}{int\+\_\+tide\+\_\+input\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Sets the model-\/state dependent internal tide energy sources. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em u} & The zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em v} & The meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure containing pointers to the thermodynamic fields \\
\hline
\mbox{\texttt{ in}}  & {\em fluxes} & A structure of thermodynamic surface fluxes \\
\hline
\mbox{\texttt{ in,out}}  & {\em itide} & A structure containing fields related to the internal tide sources. \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The time increment \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
 & {\em cs} & This module\textquotesingle{}s control structure. \\
\hline
\end{DoxyParams}


Definition at line 75 of file M\+O\+M\+\_\+internal\+\_\+tide\+\_\+input.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{75   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The ocean's grid structure}}
\DoxyCodeLine{76   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< The ocean's vertical grid structure}}
\DoxyCodeLine{77   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{78 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{  !< The zonal velocity [L T-1 ~> m s-1]}}
\DoxyCodeLine{79 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: v\textcolor{comment}{  !< The meridional velocity [L T-1 ~> m s-1]}}
\DoxyCodeLine{80 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thicknesses [H ~> m or kg m-2]}}
\DoxyCodeLine{81   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                     \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{ !< A structure containing pointers to the}}
\DoxyCodeLine{82 \textcolor{comment}{                                                                 !! thermodynamic fields}}
\DoxyCodeLine{83   \textcolor{keywordtype}{type}(forcing),                             \textcolor{keywordtype}{intent(in)}    :: fluxes\textcolor{comment}{ !< A structure of thermodynamic surface fluxes}}
\DoxyCodeLine{84   \textcolor{keywordtype}{type}(int\_tide\_input\_type),                 \textcolor{keywordtype}{intent(inout)} :: itide\textcolor{comment}{ !< A structure containing fields related}}
\DoxyCodeLine{85 \textcolor{comment}{                                                                 !! to the internal tide sources.}}
\DoxyCodeLine{86 \textcolor{keywordtype}{  real},                                      \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{ !< The time increment [T ~> s].}}
\DoxyCodeLine{87   \textcolor{keywordtype}{type}(int\_tide\_input\_CS),                   \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< This module's control structure.}}
\DoxyCodeLine{88   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{89 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{90     N2\_bot        \textcolor{comment}{! The bottom squared buoyancy frequency [T-2 ~> s-2].}}
\DoxyCodeLine{91 }
\DoxyCodeLine{92 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: \&}
\DoxyCodeLine{93     T\_f, S\_f      \textcolor{comment}{! The temperature and salinity in [degC] and [ppt] with the values in}}
\DoxyCodeLine{94                   \textcolor{comment}{! the massless layers filled vertically by diffusion.}}
\DoxyCodeLine{95   \textcolor{keywordtype}{logical} :: use\_EOS    \textcolor{comment}{! If true, density is calculated from T \& S using an}}
\DoxyCodeLine{96                         \textcolor{comment}{! equation of state.}}
\DoxyCodeLine{97   \textcolor{keywordtype}{logical} :: avg\_enabled  \textcolor{comment}{! for testing internal tides (BDM)}}
\DoxyCodeLine{98   \textcolor{keywordtype}{type}(time\_type) :: time\_end\textcolor{comment}{        !< For use in testing internal tides (BDM)}}
\DoxyCodeLine{99 }
\DoxyCodeLine{100   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, isd, ied, jsd, jed}
\DoxyCodeLine{101 }
\DoxyCodeLine{102   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{103   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{104 }
\DoxyCodeLine{105   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"set\_diffusivity: "}//\&}
\DoxyCodeLine{106          \textcolor{stringliteral}{"Module must be initialized before it is used."})}
\DoxyCodeLine{107 }
\DoxyCodeLine{108   use\_eos = \textcolor{keyword}{associated}(tv\%eqn\_of\_state)}
\DoxyCodeLine{109 }
\DoxyCodeLine{110   \textcolor{comment}{! Smooth the properties through massless layers.}}
\DoxyCodeLine{111   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{112     \textcolor{keyword}{call }vert\_fill\_ts(h, tv\%T, tv\%S, cs\%kappa\_fill*dt, t\_f, s\_f, g, gv, larger\_h\_denom=.true.)}
\DoxyCodeLine{113 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{114 }
\DoxyCodeLine{115   \textcolor{keyword}{call }find\_n2\_bottom(h, tv, t\_f, s\_f, itide\%h2, fluxes, g, gv, us, n2\_bot)}
\DoxyCodeLine{116 }
\DoxyCodeLine{117   \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{118   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{119     itide\%Nb(i,j) = g\%mask2dT(i,j) * sqrt(n2\_bot(i,j))}
\DoxyCodeLine{120     itide\%TKE\_itidal\_input(i,j) = min(cs\%TKE\_itidal\_coef(i,j)*itide\%Nb(i,j), cs\%TKE\_itide\_max)}
\DoxyCodeLine{121 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{122 }
\DoxyCodeLine{123   \textcolor{keywordflow}{if} (cs\%int\_tide\_source\_test) \textcolor{keywordflow}{then}}
\DoxyCodeLine{124     itide\%TKE\_itidal\_input(:,:) = 0.0}
\DoxyCodeLine{125     avg\_enabled = query\_averaging\_enabled(cs\%diag, time\_end=time\_end)}
\DoxyCodeLine{126     \textcolor{keywordflow}{if} (time\_end <= cs\%time\_max\_source) \textcolor{keywordflow}{then}}
\DoxyCodeLine{127       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{128         \textcolor{comment}{! Input  an arbitrary energy point source.id\_}}
\DoxyCodeLine{129         \textcolor{keywordflow}{if} (((g\%geoLonCu(i-1,j)-cs\%int\_tide\_source\_x) * (g\%geoLonBu(i,j)-cs\%int\_tide\_source\_x) <= 0.0) .and. \&}
\DoxyCodeLine{130             ((g\%geoLatCv(i,j-1)-cs\%int\_tide\_source\_y) * (g\%geoLatCv(i,j)-cs\%int\_tide\_source\_y) <= 0.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{131           itide\%TKE\_itidal\_input(i,j) = 1.0*us\%kg\_m3\_to\_R*us\%m\_to\_Z**3*us\%T\_to\_s**3}
\DoxyCodeLine{132 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{133 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{134 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{135 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{136 }
\DoxyCodeLine{137   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{138     \textcolor{keyword}{call }hchksum(n2\_bot,\textcolor{stringliteral}{"N2\_bot"},g\%HI,haloshift=0, scale=us\%s\_to\_T**2)}
\DoxyCodeLine{139     \textcolor{keyword}{call }hchksum(itide\%TKE\_itidal\_input,\textcolor{stringliteral}{"TKE\_itidal\_input"},g\%HI,haloshift=0, \&}
\DoxyCodeLine{140                  scale=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{141 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{142 }
\DoxyCodeLine{143   \textcolor{keywordflow}{if} (cs\%id\_TKE\_itidal > 0) \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_itidal, itide\%TKE\_itidal\_input, cs\%diag)}
\DoxyCodeLine{144   \textcolor{keywordflow}{if} (cs\%id\_Nb > 0) \textcolor{keyword}{call }post\_data(cs\%id\_Nb, itide\%Nb, cs\%diag)}
\DoxyCodeLine{145   \textcolor{keywordflow}{if} (cs\%id\_N2\_bot > 0 ) \textcolor{keyword}{call }post\_data(cs\%id\_N2\_bot, n2\_bot, cs\%diag)}
\DoxyCodeLine{146 }

\end{DoxyCode}
