\hypertarget{namespacemom__tidal__forcing}{}\section{mom\+\_\+tidal\+\_\+forcing Module Reference}
\label{namespacemom__tidal__forcing}\index{mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}}


\subsection{Detailed Description}
Tidal contributions to geopotential. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__tidal__forcing_1_1astro__longitudes}{astro\+\_\+longitudes}
\begin{DoxyCompactList}\small\item\em Simple type to store astronomical longitudes used to calculate tidal phases. \end{DoxyCompactList}\item 
type \hyperlink{structmom__tidal__forcing_1_1tidal__forcing__cs}{tidal\+\_\+forcing\+\_\+cs}
\begin{DoxyCompactList}\small\item\em The control structure for the M\+O\+M\+\_\+tidal\+\_\+forcing module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__tidal__forcing_a216df16546377aec2e546a0c26956320}\label{namespacemom__tidal__forcing_a216df16546377aec2e546a0c26956320}} 
subroutine, public \hyperlink{namespacemom__tidal__forcing_a216df16546377aec2e546a0c26956320}{astro\+\_\+longitudes\+\_\+init} (time\+\_\+ref, longitudes)
\begin{DoxyCompactList}\small\item\em Finds astronomical longitudes s, h, p, and N, the mean longitude of the moon, sun, lunar perigee, and ascending node, respectively, at the specified reference time time\+\_\+ref. These formulas were obtained from Kowalik and Luick, \char`\"{}\+Modern Theory and Practice of Tide Analysis and Tidal Power\char`\"{}, 2019 (their Equation I.\+71), which are based on Schureman, 1958. For simplicity, the time associated with time\+\_\+ref should be at midnight. These formulas also only make sense if the calendar is gregorian. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__tidal__forcing_a75df5ae8ba197cf0cc5584811a28c8c1}\label{namespacemom__tidal__forcing_a75df5ae8ba197cf0cc5584811a28c8c1}} 
real function, public \hyperlink{namespacemom__tidal__forcing_a75df5ae8ba197cf0cc5584811a28c8c1}{eq\+\_\+phase} (constit, longitudes)
\begin{DoxyCompactList}\small\item\em Calculates the equilibrium phase argument for the given tidal constituent constit and the astronomical longitudes and the reference time. These formulas follow Table I.\+4 of Kowalik and Luick, \char`\"{}\+Modern Theory and Practice of Tide Analysis and Tidal Power\char`\"{}, 2019. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__tidal__forcing_a2f0cdbf6e53e72de468abc458b820ae4}\label{namespacemom__tidal__forcing_a2f0cdbf6e53e72de468abc458b820ae4}} 
real function, public \hyperlink{namespacemom__tidal__forcing_a2f0cdbf6e53e72de468abc458b820ae4}{tidal\+\_\+frequency} (constit)
\begin{DoxyCompactList}\small\item\em Looks up angular frequencies for the main tidal constituents. Values used here are from previous versions of M\+OM. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__tidal__forcing_a7bec47c17487d1676e6a64b0729c43b4}\label{namespacemom__tidal__forcing_a7bec47c17487d1676e6a64b0729c43b4}} 
subroutine, public \hyperlink{namespacemom__tidal__forcing_a7bec47c17487d1676e6a64b0729c43b4}{nodal\+\_\+fu} (constit, N, fn, un)
\begin{DoxyCompactList}\small\item\em Find amplitude (f) and phase (u) modulation of tidal constituents by the 18.\+6 year nodal cycle. Values here follow Table I.\+6 in Kowalik and Luick, \char`\"{}\+Modern Theory and Practice of Tide Analysis and Tidal Power\char`\"{}, 2019. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tidal__forcing_aee336a2affeebc78b75845bc6f78a320}{tidal\+\_\+forcing\+\_\+init} (Time, G, param\+\_\+file, CS)
\begin{DoxyCompactList}\small\item\em This subroutine allocates space for the static variables used by this module. The metrics may be effectively 0, 1, or 2-\/D arrays, while fields like the background viscosities are 2-\/D arrays. A\+L\+L\+OC is a macro defined in \hyperlink{MOM__memory_8h}{M\+O\+M\+\_\+memory.\+h} for allocate or nothing with static memory. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__tidal__forcing_a5347fc1f0287018220ceb65d46fc89f9}{find\+\_\+in\+\_\+files} (filenames, varname, array, G)
\begin{DoxyCompactList}\small\item\em This subroutine finds a named variable in a list of files and reads its values into a domain-\/decomposed 2-\/d array. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tidal__forcing_a0a1564c68489a35802c626a07f4629d7}{tidal\+\_\+forcing\+\_\+sensitivity} (G, CS, deta\+\_\+tidal\+\_\+deta)
\begin{DoxyCompactList}\small\item\em This subroutine calculates returns the partial derivative of the local geopotential height with the input sea surface height due to self-\/attraction and loading. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tidal__forcing_a9614ae35fac1d880d5daacbd60f3d47a}{calc\+\_\+tidal\+\_\+forcing} (Time, eta, eta\+\_\+tidal, G, CS, deta\+\_\+tidal\+\_\+deta, m\+\_\+to\+\_\+Z)
\begin{DoxyCompactList}\small\item\em This subroutine calculates the geopotential anomalies that drive the tides, including self-\/attraction and loading. Optionally, it also returns the partial derivative of the local geopotential height with the input sea surface height. For now, eta and eta\+\_\+tidal are both geopotential heights in depth units, but probably the input for eta should really be replaced with the column mass anomalies. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tidal__forcing_a317fadb5312795722889e8ec5cec4dcb}{tidal\+\_\+forcing\+\_\+end} (CS)
\begin{DoxyCompactList}\small\item\em This subroutine deallocates memory associated with the tidal forcing module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__tidal__forcing_a9d0f13c449127ecf48932f449bd4993f}\label{namespacemom__tidal__forcing_a9d0f13c449127ecf48932f449bd4993f}} 
integer, parameter \hyperlink{namespacemom__tidal__forcing_a9d0f13c449127ecf48932f449bd4993f}{max\+\_\+constituents} = 10
\begin{DoxyCompactList}\small\item\em The maximum number of tidal constituents that could be used. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__tidal__forcing_a44caffc5bf5443b16b448cc79cb6680b}\label{namespacemom__tidal__forcing_a44caffc5bf5443b16b448cc79cb6680b}} 
integer \hyperlink{namespacemom__tidal__forcing_a44caffc5bf5443b16b448cc79cb6680b}{id\+\_\+clock\+\_\+tides}
\begin{DoxyCompactList}\small\item\em C\+PU clock for tides. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__tidal__forcing_a9614ae35fac1d880d5daacbd60f3d47a}\label{namespacemom__tidal__forcing_a9614ae35fac1d880d5daacbd60f3d47a}} 
\index{mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}!calc\+\_\+tidal\+\_\+forcing@{calc\+\_\+tidal\+\_\+forcing}}
\index{calc\+\_\+tidal\+\_\+forcing@{calc\+\_\+tidal\+\_\+forcing}!mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}}
\subsubsection{\texorpdfstring{calc\+\_\+tidal\+\_\+forcing()}{calc\_tidal\_forcing()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tidal\+\_\+forcing\+::calc\+\_\+tidal\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{eta,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(out)}]{eta\+\_\+tidal,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\hyperlink{structmom__tidal__forcing_1_1tidal__forcing__cs}{tidal\+\_\+forcing\+\_\+cs}), pointer}]{CS,  }\item[{real, intent(out), optional}]{deta\+\_\+tidal\+\_\+deta,  }\item[{real, intent(in), optional}]{m\+\_\+to\+\_\+Z }\end{DoxyParamCaption})}



This subroutine calculates the geopotential anomalies that drive the tides, including self-\/attraction and loading. Optionally, it also returns the partial derivative of the local geopotential height with the input sea surface height. For now, eta and eta\+\_\+tidal are both geopotential heights in depth units, but probably the input for eta should really be replaced with the column mass anomalies. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em time} & The time for the caluculation.\\
\hline
\mbox{\tt in}  & {\em eta} & The sea surface height anomaly from a time-\/mean geoid \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em eta\+\_\+tidal} & The tidal forcing geopotential height anomalies \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
 & {\em cs} & The control structure returned by a previous call to tidal\+\_\+forcing\+\_\+init.\\
\hline
\mbox{\tt out}  & {\em deta\+\_\+tidal\+\_\+deta} & The partial derivative of eta\+\_\+tidal with the local value of eta \mbox{[}nondim\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em m\+\_\+to\+\_\+z} & A scaling factor from m to the units of eta. \\
\hline
\end{DoxyParams}


Definition at line 583 of file M\+O\+M\+\_\+tidal\+\_\+forcing.\+F90.


\begin{DoxyCode}
583   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{         !< The ocean's grid structure.}
584   \textcolor{keywordtype}{type}(time\_type),                  \textcolor{keywordtype}{intent(in)}  :: time\textcolor{comment}{      !< The time for the caluculation.}
585   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(in)}  :: eta\textcolor{comment}{       !< The sea surface height anomaly from}
586 \textcolor{comment}{                                                             !! a time-mean geoid [Z ~> m].}
587   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)} :: eta\_tidal\textcolor{comment}{ !< The tidal forcing geopotential height}
588 \textcolor{comment}{                                                             !! anomalies [Z ~> m].}
589   \textcolor{keywordtype}{type}(tidal\_forcing\_cs),           \textcolor{keywordtype}{pointer}     :: cs\textcolor{comment}{        !< The control structure returned by a}
590 \textcolor{comment}{                                                             !! previous call to tidal\_forcing\_init.}
591   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional},                   \textcolor{keywordtype}{intent(out)} :: deta\_tidal\_deta\textcolor{comment}{ !< The partial derivative of}
592 \textcolor{comment}{                                                             !! eta\_tidal with the local value of}
593 \textcolor{comment}{                                                             !! eta [nondim].}
594   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional},                   \textcolor{keywordtype}{intent(in)}  :: m\_to\_z\textcolor{comment}{    !< A scaling factor from m to the units of
       eta.}
595 
596   \textcolor{comment}{! Local variables}
597   \textcolor{keywordtype}{real} :: now       \textcolor{comment}{! The relative time in seconds.}
598   \textcolor{keywordtype}{real} :: amp\_cosomegat, amp\_sinomegat
599   \textcolor{keywordtype}{real} :: cosomegat, sinomegat
600   \textcolor{keywordtype}{real} :: m\_z       \textcolor{comment}{! A scaling factor from m to depth units.}
601   \textcolor{keywordtype}{real} :: eta\_prop  \textcolor{comment}{! The nondimenional constant of proportionality beteen eta and eta\_tidal.}
602   \textcolor{keywordtype}{integer} :: i, j, c, m, is, ie, js, je, isq, ieq, jsq, jeq
603   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
604   isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
605 
606   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
607 
608   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_tides)
609 
610   \textcolor{keywordflow}{if} (cs%nc == 0) \textcolor{keywordflow}{then}
611     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1 ; eta\_tidal(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
612     \textcolor{keywordflow}{return}
613 \textcolor{keywordflow}{  endif}
614 
615   now = time\_type\_to\_real(time - cs%time\_ref)
616 
617   \textcolor{keywordflow}{if} (cs%USE\_SAL\_SCALAR .and. cs%USE\_PREV\_TIDES) \textcolor{keywordflow}{then}
618     eta\_prop = 2.0*cs%SAL\_SCALAR
619   \textcolor{keywordflow}{elseif} (cs%USE\_SAL\_SCALAR .or. cs%USE\_PREV\_TIDES) \textcolor{keywordflow}{then}
620     eta\_prop = cs%SAL\_SCALAR
621   \textcolor{keywordflow}{else}
622     eta\_prop = 0.0
623 \textcolor{keywordflow}{  endif}
624 
625   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(deta\_tidal\_deta)) \textcolor{keywordflow}{then}
626     deta\_tidal\_deta = eta\_prop
627     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1 ; eta\_tidal(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
628   \textcolor{keywordflow}{else}
629     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1
630       eta\_tidal(i,j) = eta\_prop*eta(i,j)
631 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
632 \textcolor{keywordflow}{  endif}
633 
634   m\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(m\_to\_z)) m\_z = m\_to\_z
635 
636   \textcolor{keywordflow}{do} c=1,cs%nc
637     m = cs%struct(c)
638     amp\_cosomegat = m\_z*cs%amp(c)*cs%love\_no(c) * cos(cs%freq(c)*now + cs%phase0(c))
639     amp\_sinomegat = m\_z*cs%amp(c)*cs%love\_no(c) * sin(cs%freq(c)*now + cs%phase0(c))
640     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1
641       eta\_tidal(i,j) = eta\_tidal(i,j) + (amp\_cosomegat*cs%cos\_struct(i,j,m) + &
642                                          amp\_sinomegat*cs%sin\_struct(i,j,m))
643 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
644 \textcolor{keywordflow}{  enddo}
645 
646   \textcolor{keywordflow}{if} (cs%tidal\_sal\_from\_file) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} c=1,cs%nc
647     cosomegat = cos(cs%freq(c)*now)
648     sinomegat = sin(cs%freq(c)*now)
649     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1
650       eta\_tidal(i,j) = eta\_tidal(i,j) + m\_z*cs%ampsal(i,j,c) * &
651            (cosomegat*cs%cosphasesal(i,j,c) + sinomegat*cs%sinphasesal(i,j,c))
652 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
653 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
654 
655   \textcolor{keywordflow}{if} (cs%USE\_PREV\_TIDES) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} c=1,cs%nc
656     cosomegat = cos(cs%freq(c)*now)
657     sinomegat = sin(cs%freq(c)*now)
658     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1
659       eta\_tidal(i,j) = eta\_tidal(i,j) - m\_z*cs%SAL\_SCALAR*cs%amp\_prev(i,j,c) * &
660           (cosomegat*cs%cosphase\_prev(i,j,c) + sinomegat*cs%sinphase\_prev(i,j,c))
661 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
662 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
663 
664   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_tides)
665 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tidal__forcing_a5347fc1f0287018220ceb65d46fc89f9}\label{namespacemom__tidal__forcing_a5347fc1f0287018220ceb65d46fc89f9}} 
\index{mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}!find\+\_\+in\+\_\+files@{find\+\_\+in\+\_\+files}}
\index{find\+\_\+in\+\_\+files@{find\+\_\+in\+\_\+files}!mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}}
\subsubsection{\texorpdfstring{find\+\_\+in\+\_\+files()}{find\_in\_files()}}
{\footnotesize\ttfamily subroutine mom\+\_\+tidal\+\_\+forcing\+::find\+\_\+in\+\_\+files (\begin{DoxyParamCaption}\item[{character(len=$\ast$), dimension(\+:), intent(in)}]{filenames,  }\item[{character(len=$\ast$), intent(in)}]{varname,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(out)}]{array,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine finds a named variable in a list of files and reads its values into a domain-\/decomposed 2-\/d array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em filenames} & The names of the files to search for the named variable\\
\hline
\mbox{\tt in}  & {\em varname} & The name of the variable to read\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt out}  & {\em array} & The array to fill with the data \\
\hline
\end{DoxyParams}


Definition at line 530 of file M\+O\+M\+\_\+tidal\+\_\+forcing.\+F90.


\begin{DoxyCode}
530   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}  :: filenames\textcolor{comment}{ !< The names of the files to search for the
       named variable}
531   \textcolor{keywordtype}{character(len=*)},                 \textcolor{keywordtype}{intent(in)}  :: varname\textcolor{comment}{   !< The name of the variable to read}
532   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{         !< The ocean's grid structure}
533   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)} :: array\textcolor{comment}{     !< The array to fill with the data}
534   \textcolor{comment}{! Local variables}
535   \textcolor{keywordtype}{integer} :: nf
536 
537   \textcolor{keywordflow}{do} nf=1,\textcolor{keyword}{size}(filenames)
538     \textcolor{keywordflow}{if} (len\_trim(filenames(nf)) == 0) cycle
539     \textcolor{keywordflow}{if} (field\_exists(filenames(nf), varname, g%Domain%mpp\_domain)) \textcolor{keywordflow}{then}
540       \textcolor{keyword}{call }mom\_read\_data(filenames(nf), varname, array, g%Domain)
541       \textcolor{keywordflow}{return}
542 \textcolor{keywordflow}{    endif}
543 \textcolor{keywordflow}{  enddo}
544 
545   \textcolor{keywordflow}{do} nf=\textcolor{keyword}{size}(filenames),1,-1
546     \textcolor{keywordflow}{if} (file\_exists(filenames(nf), g%Domain)) \textcolor{keywordflow}{then}
547       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_tidal\_forcing.F90: Unable to find "}// &
548          trim(varname)//\textcolor{stringliteral}{" in any of the tidal input files, last tried "}// &
549          trim(filenames(nf)))
550 \textcolor{keywordflow}{    endif}
551 \textcolor{keywordflow}{  enddo}
552 
553   \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_tidal\_forcing.F90: Unable to find any of the "}// &
554                   \textcolor{stringliteral}{"tidal input files, including "}//trim(filenames(1)))
555 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tidal__forcing_a317fadb5312795722889e8ec5cec4dcb}\label{namespacemom__tidal__forcing_a317fadb5312795722889e8ec5cec4dcb}} 
\index{mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}!tidal\+\_\+forcing\+\_\+end@{tidal\+\_\+forcing\+\_\+end}}
\index{tidal\+\_\+forcing\+\_\+end@{tidal\+\_\+forcing\+\_\+end}!mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}}
\subsubsection{\texorpdfstring{tidal\+\_\+forcing\+\_\+end()}{tidal\_forcing\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tidal\+\_\+forcing\+::tidal\+\_\+forcing\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tidal__forcing_1_1tidal__forcing__cs}{tidal\+\_\+forcing\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine deallocates memory associated with the tidal forcing module. 


\begin{DoxyParams}{Parameters}
{\em cs} & The control structure returned by a previous call to tidal\+\_\+forcing\+\_\+init; it is deallocated here. \\
\hline
\end{DoxyParams}


Definition at line 670 of file M\+O\+M\+\_\+tidal\+\_\+forcing.\+F90.


\begin{DoxyCode}
670   \textcolor{keywordtype}{type}(tidal\_forcing\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< The control structure returned by a previous call}
671 \textcolor{comment}{                                        !! to tidal\_forcing\_init; it is deallocated here.}
672 
673   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%sin\_struct)) \textcolor{keyword}{deallocate}(cs%sin\_struct)
674   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%cos\_struct)) \textcolor{keyword}{deallocate}(cs%cos\_struct)
675 
676   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%cosphasesal)) \textcolor{keyword}{deallocate}(cs%cosphasesal)
677   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%sinphasesal)) \textcolor{keyword}{deallocate}(cs%sinphasesal)
678   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%ampsal))      \textcolor{keyword}{deallocate}(cs%ampsal)
679 
680   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%cosphase\_prev)) \textcolor{keyword}{deallocate}(cs%cosphase\_prev)
681   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%sinphase\_prev)) \textcolor{keyword}{deallocate}(cs%sinphase\_prev)
682   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%amp\_prev))      \textcolor{keyword}{deallocate}(cs%amp\_prev)
683 
684   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{deallocate}(cs)
685 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tidal__forcing_aee336a2affeebc78b75845bc6f78a320}\label{namespacemom__tidal__forcing_aee336a2affeebc78b75845bc6f78a320}} 
\index{mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}!tidal\+\_\+forcing\+\_\+init@{tidal\+\_\+forcing\+\_\+init}}
\index{tidal\+\_\+forcing\+\_\+init@{tidal\+\_\+forcing\+\_\+init}!mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}}
\subsubsection{\texorpdfstring{tidal\+\_\+forcing\+\_\+init()}{tidal\_forcing\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tidal\+\_\+forcing\+::tidal\+\_\+forcing\+\_\+init (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structmom__tidal__forcing_1_1tidal__forcing__cs}{tidal\+\_\+forcing\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine allocates space for the static variables used by this module. The metrics may be effectively 0, 1, or 2-\/D arrays, while fields like the background viscosities are 2-\/D arrays. A\+L\+L\+OC is a macro defined in \hyperlink{MOM__memory_8h}{M\+O\+M\+\_\+memory.\+h} for allocate or nothing with static memory. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & The current model time.\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters.\\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module. \\
\hline
\end{DoxyParams}


Definition at line 230 of file M\+O\+M\+\_\+tidal\+\_\+forcing.\+F90.


\begin{DoxyCode}
230   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time.}
231   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
232   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters.}
233   \textcolor{keywordtype}{type}(tidal\_forcing\_cs), \textcolor{keywordtype}{pointer}      :: cs\textcolor{comment}{   !< A pointer that is set to point to the control}
234 \textcolor{comment}{                                               !! structure for this module.}
235   \textcolor{comment}{! Local variables}
236   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G))} :: &
237     phase, &          \textcolor{comment}{! The phase of some tidal constituent.}
238     lat\_rad, lon\_rad  \textcolor{comment}{! Latitudes and longitudes of h-points in radians.}
239   \textcolor{keywordtype}{real} :: deg\_to\_rad
240   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(MAX\_CONSTITUENTS)} :: freq\_def, phase0\_def, amp\_def, love\_def
241   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(3)} :: tide\_ref\_date\textcolor{comment}{ !< Reference date (t = 0) for tidal forcing.}
242   \textcolor{keywordtype}{logical} :: use\_const  \textcolor{comment}{! True if a constituent is being used.}
243   \textcolor{keywordtype}{logical} :: use\_m2, use\_s2, use\_n2, use\_k2, use\_k1, use\_o1, use\_p1, use\_q1
244   \textcolor{keywordtype}{logical} :: use\_mf, use\_mm
245   \textcolor{keywordtype}{logical} :: tides      \textcolor{comment}{! True if a tidal forcing is to be used.}
246   \textcolor{keywordtype}{logical} :: fail\_if\_missing = .true.
247 \textcolor{comment}{! This include declares and sets the variable "version".}
248 \textcolor{preprocessor}{#include "version\_variable.h"}
249 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_tidal\_forcing"} \textcolor{comment}{! This module's name.}
250   \textcolor{keywordtype}{character(len=128)} :: mesg
251   \textcolor{keywordtype}{character(len=200)} :: tidal\_input\_files(4*max\_constituents)
252   \textcolor{keywordtype}{integer} :: i, j, c, is, ie, js, je, isd, ied, jsd, jed, nc
253   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
254   isd = g%isd ; ied = g%ied ; jsd = g%jsd; jed = g%jed
255 
256   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
257     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"tidal\_forcing\_init called with an associated "}// &
258                             \textcolor{stringliteral}{"control structure."})
259     \textcolor{keywordflow}{return}
260 \textcolor{keywordflow}{  endif}
261 
262   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
263   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
264   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDES"}, tides, &
265                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing."}, default=.false.)
266 
267   \textcolor{keywordflow}{if} (.not.tides) \textcolor{keywordflow}{return}
268 
269   \textcolor{keyword}{allocate}(cs)
270 
271   \textcolor{comment}{! Set up the spatial structure functions for the diurnal, semidiurnal, and}
272   \textcolor{comment}{! low-frequency tidal components.}
273   \textcolor{keyword}{allocate}(cs%sin\_struct(isd:ied,jsd:jed,3)) ; cs%sin\_struct(:,:,:) = 0.0
274   \textcolor{keyword}{allocate}(cs%cos\_struct(isd:ied,jsd:jed,3)) ; cs%cos\_struct(:,:,:) = 0.0
275   deg\_to\_rad = 4.0*atan(1.0)/180.0
276   \textcolor{keywordflow}{do} j=js-1,je+1 ; \textcolor{keywordflow}{do} i=is-1,ie+1
277     lat\_rad(i,j) = g%geoLatT(i,j)*deg\_to\_rad
278     lon\_rad(i,j) = g%geoLonT(i,j)*deg\_to\_rad
279 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
280   \textcolor{keywordflow}{do} j=js-1,je+1 ; \textcolor{keywordflow}{do} i=is-1,ie+1
281     cs%sin\_struct(i,j,1) = -sin(2.0*lat\_rad(i,j)) * sin(lon\_rad(i,j))
282     cs%cos\_struct(i,j,1) =  sin(2.0*lat\_rad(i,j)) * cos(lon\_rad(i,j))
283     cs%sin\_struct(i,j,2) = -cos(lat\_rad(i,j))**2 * sin(2.0*lon\_rad(i,j))
284     cs%cos\_struct(i,j,2) =  cos(lat\_rad(i,j))**2 * cos(2.0*lon\_rad(i,j))
285     cs%sin\_struct(i,j,3) =  0.0
286     cs%cos\_struct(i,j,3) = (0.5-1.5*sin(lat\_rad(i,j))**2)
287 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
288 
289   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_M2"}, use\_m2, &
290                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the M2 "}//&
291                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
292                  default=.false.)
293   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_S2"}, use\_s2, &
294                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the S2 "}//&
295                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
296                  default=.false.)
297   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_N2"}, use\_n2, &
298                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the N2 "}//&
299                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
300                  default=.false.)
301   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_K2"}, use\_k2, &
302                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the K2 "}//&
303                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
304                  default=.false.)
305   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_K1"}, use\_k1, &
306                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the K1 "}//&
307                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
308                  default=.false.)
309   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_O1"}, use\_o1, &
310                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the O1 "}//&
311                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
312                  default=.false.)
313   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_P1"}, use\_p1, &
314                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the P1 "}//&
315                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
316                  default=.false.)
317   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_Q1"}, use\_q1, &
318                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the Q1 "}//&
319                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
320                  default=.false.)
321   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_MF"}, use\_mf, &
322                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the MF "}//&
323                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
324                  default=.false.)
325   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_MM"}, use\_mm, &
326                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing at the MM "}//&
327                  \textcolor{stringliteral}{"frequency. This is only used if TIDES is true."}, &
328                  default=.false.)
329 
330   \textcolor{comment}{! Determine how many tidal components are to be used.}
331   nc = 0
332   \textcolor{keywordflow}{if} (use\_m2) nc=nc+1 ; \textcolor{keywordflow}{if} (use\_s2) nc=nc+1
333   \textcolor{keywordflow}{if} (use\_n2) nc=nc+1 ; \textcolor{keywordflow}{if} (use\_k2) nc=nc+1
334   \textcolor{keywordflow}{if} (use\_k1) nc=nc+1 ; \textcolor{keywordflow}{if} (use\_o1) nc=nc+1
335   \textcolor{keywordflow}{if} (use\_p1) nc=nc+1 ; \textcolor{keywordflow}{if} (use\_q1) nc=nc+1
336   \textcolor{keywordflow}{if} (use\_mf) nc=nc+1 ; \textcolor{keywordflow}{if} (use\_mm) nc=nc+1
337   cs%nc = nc
338 
339   \textcolor{keywordflow}{if} (nc == 0) \textcolor{keywordflow}{then}
340     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"tidal\_forcing\_init: "}// &
341         \textcolor{stringliteral}{"TIDES are defined, but no tidal constituents are used."})
342     \textcolor{keywordflow}{return}
343 \textcolor{keywordflow}{  endif}
344 
345   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDAL\_SAL\_FROM\_FILE"}, cs%tidal\_sal\_from\_file, &
346                  \textcolor{stringliteral}{"If true, read the tidal self-attraction and loading "}//&
347                  \textcolor{stringliteral}{"from input files, specified by TIDAL\_INPUT\_FILE. "}//&
348                  \textcolor{stringliteral}{"This is only used if TIDES is true."}, default=.false.)
349   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_PREVIOUS\_TIDES"}, cs%use\_prev\_tides, &
350                  \textcolor{stringliteral}{"If true, use the SAL from the previous iteration of the "}//&
351                  \textcolor{stringliteral}{"tides to facilitate convergent iteration. "}//&
352                  \textcolor{stringliteral}{"This is only used if TIDES is true."}, default=.false.)
353   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_USE\_SAL\_SCALAR"}, cs%use\_sal\_scalar, &
354                  \textcolor{stringliteral}{"If true and TIDES is true, use the scalar approximation "}//&
355                  \textcolor{stringliteral}{"when calculating self-attraction and loading."}, &
356                  default=.not.cs%tidal\_sal\_from\_file)
357   \textcolor{comment}{! If it is being used, sal\_scalar MUST be specified in param\_file.}
358   \textcolor{keywordflow}{if} (cs%use\_sal\_scalar .or. cs%use\_prev\_tides) &
359     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_SAL\_SCALAR\_VALUE"}, cs%sal\_scalar, &
360                  \textcolor{stringliteral}{"The constant of proportionality between sea surface "}//&
361                  \textcolor{stringliteral}{"height (really it should be bottom pressure) anomalies "}//&
362                  \textcolor{stringliteral}{"and bottom geopotential anomalies. This is only used if "}//&
363                  \textcolor{stringliteral}{"TIDES and TIDE\_USE\_SAL\_SCALAR are true."}, units=\textcolor{stringliteral}{"m m-1"}, &
364                  fail\_if\_missing=.true.)
365 
366   \textcolor{keywordflow}{if} (nc > max\_constituents) \textcolor{keywordflow}{then}
367     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Increase MAX\_CONSTITUENTS in MOM\_tidal\_forcing.F90 to at least",I3, &}
368 \textcolor{stringliteral}{}\textcolor{stringliteral}{                &"to accommodate all the registered tidal constituents.")'}) nc
369     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_tidal\_forcing"}//mesg)
370 \textcolor{keywordflow}{  endif}
371 
372   \textcolor{keywordflow}{do} c=1,4*max\_constituents ; tidal\_input\_files(c) = \textcolor{stringliteral}{""} ;\textcolor{keywordflow}{ enddo}
373 
374   \textcolor{keywordflow}{if} (cs%tidal\_sal\_from\_file .or. cs%use\_prev\_tides) \textcolor{keywordflow}{then}
375     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDAL\_INPUT\_FILE"}, tidal\_input\_files, &
376                    \textcolor{stringliteral}{"A list of input files for tidal information."},         &
377                    default = \textcolor{stringliteral}{""}, fail\_if\_missing=.true.)
378 \textcolor{keywordflow}{  endif}
379 
380   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_REF\_DATE"}, tide\_ref\_date, &
381                  \textcolor{stringliteral}{"Year,month,day to use as reference date for tidal forcing. "}//&
382                  \textcolor{stringliteral}{"If not specified, defaults to 0."}, &
383                  default=0)
384 
385   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_USE\_EQ\_PHASE"}, cs%use\_eq\_phase, &
386                  \textcolor{stringliteral}{"Correct phases by calculating equilibrium phase arguments for TIDE\_REF\_DATE. "}, &
387                  default=.false., fail\_if\_missing=.false.)
388 
389   \textcolor{keywordflow}{if} (sum(tide\_ref\_date) == 0) \textcolor{keywordflow}{then}  \textcolor{comment}{! tide\_ref\_date defaults to 0.}
390     cs%time\_ref = set\_date(1, 1, 1)
391   \textcolor{keywordflow}{else}
392     \textcolor{keywordflow}{if}(.not. cs%use\_eq\_phase) \textcolor{keywordflow}{then}
393       \textcolor{comment}{! Using a reference date but not using phase relative to equilibrium.}
394       \textcolor{comment}{! This makes sense as long as either phases are overridden, or}
395       \textcolor{comment}{! correctly simulating tidal phases is not desired.}
396       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'Tidal phases will *not* be corrected with equilibrium arguments.'})
397 \textcolor{keywordflow}{    endif}
398     cs%time\_ref = set\_date(tide\_ref\_date(1), tide\_ref\_date(2), tide\_ref\_date(3))
399 \textcolor{keywordflow}{  endif}
400   \textcolor{comment}{! Set the parameters for all components that are in use.}
401   \textcolor{comment}{! Initialize reference time for tides and}
402   \textcolor{comment}{! find relevant lunar and solar longitudes at the reference time.}
403   \textcolor{keywordflow}{if} (cs%use\_eq\_phase) \textcolor{keyword}{call }astro\_longitudes\_init(cs%time\_ref, cs%tidal\_longitudes)
404   c=0
405   \textcolor{keywordflow}{if} (use\_m2) \textcolor{keywordflow}{then}
406     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"M2"} ; cs%struct(c) = 2
407     cs%love\_no(c) = 0.693 ; cs%amp(c) = 0.242334
408 \textcolor{keywordflow}{  endif}
409 
410   \textcolor{keywordflow}{if} (use\_s2) \textcolor{keywordflow}{then}
411     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"S2"} ; cs%struct(c) = 2
412     cs%love\_no(c) = 0.693 ; cs%amp(c) = 0.112743
413 \textcolor{keywordflow}{  endif}
414 
415   \textcolor{keywordflow}{if} (use\_n2) \textcolor{keywordflow}{then}
416     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"N2"} ; cs%struct(c) = 2
417     cs%love\_no(c) = 0.693 ; cs%amp(c) = 0.046397
418 \textcolor{keywordflow}{  endif}
419 
420   \textcolor{keywordflow}{if} (use\_k2) \textcolor{keywordflow}{then}
421     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"K2"} ; cs%struct(c) = 2
422     cs%love\_no(c) = 0.693 ; cs%amp(c) = 0.030684
423 \textcolor{keywordflow}{  endif}
424 
425   \textcolor{keywordflow}{if} (use\_k1) \textcolor{keywordflow}{then}
426     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"K1"} ; cs%struct(c) = 1
427     cs%love\_no(c) = 0.736 ; cs%amp(c) = 0.141565
428 \textcolor{keywordflow}{  endif}
429 
430   \textcolor{keywordflow}{if} (use\_o1) \textcolor{keywordflow}{then}
431     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"O1"} ; cs%struct(c) = 1
432     cs%love\_no(c) = 0.695 ; cs%amp(c) = 0.100661
433 \textcolor{keywordflow}{  endif}
434 
435   \textcolor{keywordflow}{if} (use\_p1) \textcolor{keywordflow}{then}
436     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"P1"} ; cs%struct(c) = 1
437     cs%love\_no(c) = 0.706 ; cs%amp(c) = 0.046848
438 \textcolor{keywordflow}{  endif}
439 
440   \textcolor{keywordflow}{if} (use\_q1) \textcolor{keywordflow}{then}
441     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"Q1"} ; cs%struct(c) = 1
442     cs%love\_no(c) = 0.695 ; cs%amp(c) = 0.019273
443 \textcolor{keywordflow}{  endif}
444 
445   \textcolor{keywordflow}{if} (use\_mf) \textcolor{keywordflow}{then}
446     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"MF"} ; cs%struct(c) = 3
447     cs%love\_no(c) = 0.693 ; cs%amp(c) = 0.042041
448 \textcolor{keywordflow}{  endif}
449 
450   \textcolor{keywordflow}{if} (use\_mm) \textcolor{keywordflow}{then}
451     c=c+1 ; cs%const\_name(c) = \textcolor{stringliteral}{"MM"} ; cs%struct(c) = 3
452     cs%love\_no(c) = 0.693 ; cs%amp(c) = 0.022191
453 \textcolor{keywordflow}{  endif}
454 
455   \textcolor{comment}{! Set defaults for all included constituents}
456   \textcolor{comment}{! and things that can be set by functions}
457   \textcolor{keywordflow}{do} c=1,nc
458     cs%freq(c) = tidal\_frequency(cs%const\_name(c))
459     freq\_def(c) = cs%freq(c)
460     love\_def(c) = cs%love\_no(c)
461     amp\_def(c) = cs%amp(c)
462     cs%phase0(c) = 0.0
463     \textcolor{keywordflow}{if} (cs%use\_eq\_phase) \textcolor{keywordflow}{then}
464       phase0\_def(c) = eq\_phase(cs%const\_name(c), cs%tidal\_longitudes)
465     \textcolor{keywordflow}{else}
466       phase0\_def(c) = 0.0
467 \textcolor{keywordflow}{    endif}
468 \textcolor{keywordflow}{  enddo}
469 
470   \textcolor{comment}{!  Parse the input file to potentially override the default values for the}
471   \textcolor{comment}{! frequency, amplitude and initial phase of each constituent, and log the}
472   \textcolor{comment}{! values that are actually used.}
473   \textcolor{keywordflow}{do} c=1,nc
474     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_"}//trim(cs%const\_name(c))//\textcolor{stringliteral}{"\_FREQ"}, cs%freq(c), &
475                    \textcolor{stringliteral}{"Frequency of the "}//trim(cs%const\_name(c))//\textcolor{stringliteral}{" tidal constituent. "}//&
476                    \textcolor{stringliteral}{"This is only used if TIDES and TIDE\_"}//trim(cs%const\_name(c))// &
477                    \textcolor{stringliteral}{" are true, or if OBC\_TIDE\_N\_CONSTITUENTS > 0 and "}//trim(cs%const\_name(c))// &
478                    \textcolor{stringliteral}{" is in OBC\_TIDE\_CONSTITUENTS."}, units=\textcolor{stringliteral}{"s-1"}, default=freq\_def(c))
479     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_"}//trim(cs%const\_name(c))//\textcolor{stringliteral}{"\_AMP"}, cs%amp(c), &
480                    \textcolor{stringliteral}{"Amplitude of the "}//trim(cs%const\_name(c))//\textcolor{stringliteral}{" tidal constituent. "}//&
481                    \textcolor{stringliteral}{"This is only used if TIDES and TIDE\_"}//trim(cs%const\_name(c))// &
482                    \textcolor{stringliteral}{" are true."}, units=\textcolor{stringliteral}{"m"}, default=amp\_def(c))
483     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDE\_"}//trim(cs%const\_name(c))//\textcolor{stringliteral}{"\_PHASE\_T0"}, cs%phase0(c), &
484                    \textcolor{stringliteral}{"Phase of the "}//trim(cs%const\_name(c))//\textcolor{stringliteral}{" tidal constituent at time 0. "}//&
485                    \textcolor{stringliteral}{"This is only used if TIDES and TIDE\_"}//trim(cs%const\_name(c))// &
486                    \textcolor{stringliteral}{" are true."}, units=\textcolor{stringliteral}{"radians"}, default=phase0\_def(c))
487 \textcolor{keywordflow}{  enddo}
488 
489   \textcolor{keywordflow}{if} (cs%tidal\_sal\_from\_file) \textcolor{keywordflow}{then}
490     \textcolor{keyword}{allocate}(cs%cosphasesal(isd:ied,jsd:jed,nc))
491     \textcolor{keyword}{allocate}(cs%sinphasesal(isd:ied,jsd:jed,nc))
492     \textcolor{keyword}{allocate}(cs%ampsal(isd:ied,jsd:jed,nc))
493     \textcolor{keywordflow}{do} c=1,nc
494       \textcolor{comment}{! Read variables with names like PHASE\_SAL\_M2 and AMP\_SAL\_M2.}
495       \textcolor{keyword}{call }find\_in\_files(tidal\_input\_files,\textcolor{stringliteral}{"PHASE\_SAL\_"}//trim(cs%const\_name(c)),phase,g)
496       \textcolor{keyword}{call }find\_in\_files(tidal\_input\_files,\textcolor{stringliteral}{"AMP\_SAL\_"}//trim(cs%const\_name(c)),cs%ampsal(:,:,c),g)
497       \textcolor{keyword}{call }pass\_var(phase,           g%domain,complete=.false.)
498       \textcolor{keyword}{call }pass\_var(cs%ampsal(:,:,c),g%domain,complete=.true.)
499       \textcolor{keywordflow}{do} j=js-1,je+1 ; \textcolor{keywordflow}{do} i=is-1,ie+1
500         cs%cosphasesal(i,j,c) = cos(phase(i,j)*deg\_to\_rad)
501         cs%sinphasesal(i,j,c) = sin(phase(i,j)*deg\_to\_rad)
502 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
503 \textcolor{keywordflow}{    enddo}
504 \textcolor{keywordflow}{  endif}
505 
506   \textcolor{keywordflow}{if} (cs%USE\_PREV\_TIDES) \textcolor{keywordflow}{then}
507     \textcolor{keyword}{allocate}(cs%cosphase\_prev(isd:ied,jsd:jed,nc))
508     \textcolor{keyword}{allocate}(cs%sinphase\_prev(isd:ied,jsd:jed,nc))
509     \textcolor{keyword}{allocate}(cs%amp\_prev(isd:ied,jsd:jed,nc))
510     \textcolor{keywordflow}{do} c=1,nc
511       \textcolor{comment}{! Read variables with names like PHASE\_PREV\_M2 and AMP\_PREV\_M2.}
512       \textcolor{keyword}{call }find\_in\_files(tidal\_input\_files,\textcolor{stringliteral}{"PHASE\_PREV\_"}//trim(cs%const\_name(c)),phase,g)
513       \textcolor{keyword}{call }find\_in\_files(tidal\_input\_files,\textcolor{stringliteral}{"AMP\_PREV\_"}//trim(cs%const\_name(c)),cs%amp\_prev(:,:,c),g)
514       \textcolor{keyword}{call }pass\_var(phase,             g%domain,complete=.false.)
515       \textcolor{keyword}{call }pass\_var(cs%amp\_prev(:,:,c),g%domain,complete=.true.)
516       \textcolor{keywordflow}{do} j=js-1,je+1 ; \textcolor{keywordflow}{do} i=is-1,ie+1
517         cs%cosphase\_prev(i,j,c) = cos(phase(i,j)*deg\_to\_rad)
518         cs%sinphase\_prev(i,j,c) = sin(phase(i,j)*deg\_to\_rad)
519 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
520 \textcolor{keywordflow}{    enddo}
521 \textcolor{keywordflow}{  endif}
522 
523   id\_clock\_tides = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean tides)'}, grain=clock\_module)
524 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tidal__forcing_a0a1564c68489a35802c626a07f4629d7}\label{namespacemom__tidal__forcing_a0a1564c68489a35802c626a07f4629d7}} 
\index{mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}!tidal\+\_\+forcing\+\_\+sensitivity@{tidal\+\_\+forcing\+\_\+sensitivity}}
\index{tidal\+\_\+forcing\+\_\+sensitivity@{tidal\+\_\+forcing\+\_\+sensitivity}!mom\+\_\+tidal\+\_\+forcing@{mom\+\_\+tidal\+\_\+forcing}}
\subsubsection{\texorpdfstring{tidal\+\_\+forcing\+\_\+sensitivity()}{tidal\_forcing\_sensitivity()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tidal\+\_\+forcing\+::tidal\+\_\+forcing\+\_\+sensitivity (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\hyperlink{structmom__tidal__forcing_1_1tidal__forcing__cs}{tidal\+\_\+forcing\+\_\+cs}), pointer}]{CS,  }\item[{real, intent(out)}]{deta\+\_\+tidal\+\_\+deta }\end{DoxyParamCaption})}



This subroutine calculates returns the partial derivative of the local geopotential height with the input sea surface height due to self-\/attraction and loading. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
 & {\em cs} & The control structure returned by a previous call to tidal\+\_\+forcing\+\_\+init.\\
\hline
\mbox{\tt out}  & {\em deta\+\_\+tidal\+\_\+deta} & The partial derivative of eta\+\_\+tidal with the local value of eta \mbox{[}nondim\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 562 of file M\+O\+M\+\_\+tidal\+\_\+forcing.\+F90.


\begin{DoxyCode}
562   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{  !< The ocean's grid structure.}
563   \textcolor{keywordtype}{type}(tidal\_forcing\_cs), \textcolor{keywordtype}{pointer}     :: cs\textcolor{comment}{ !< The control structure returned by a previous call to
       tidal\_forcing\_init.}
564   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(out)} :: deta\_tidal\_deta\textcolor{comment}{ !< The partial derivative of eta\_tidal with}
565 \textcolor{comment}{                                            !! the local value of eta [nondim].}
566 
567   \textcolor{keywordflow}{if} (cs%USE\_SAL\_SCALAR .and. cs%USE\_PREV\_TIDES) \textcolor{keywordflow}{then}
568     deta\_tidal\_deta = 2.0*cs%SAL\_SCALAR
569   \textcolor{keywordflow}{elseif} (cs%USE\_SAL\_SCALAR .or. cs%USE\_PREV\_TIDES) \textcolor{keywordflow}{then}
570     deta\_tidal\_deta = cs%SAL\_SCALAR
571   \textcolor{keywordflow}{else}
572     deta\_tidal\_deta = 0.0
573 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
