\hypertarget{namespacekelvin__initialization}{}\doxysection{kelvin\+\_\+initialization Module Reference}
\label{namespacekelvin__initialization}\index{kelvin\_initialization@{kelvin\_initialization}}


\doxysubsection{Detailed Description}
Configures the model for the Kelvin wave experiment. 

Kelvin = coastally-\/trapped Kelvin waves from the R\+O\+MS examples. Initialize with level surfaces and drive the wave in at the west, radiate out at the east. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structkelvin__initialization_1_1kelvin__obc__cs}{kelvin\+\_\+obc\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure for Kelvin wave open boundaries. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespacekelvin__initialization_a987148fd20c38f1f4897661a39c3120e}{register\+\_\+kelvin\+\_\+obc}} (param\+\_\+file, CS, O\+B\+C\+\_\+\+Reg)
\begin{DoxyCompactList}\small\item\em Add Kelvin wave to O\+BC registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacekelvin__initialization_a9c8e0745879d099cef92df7f16c67f9c}{kelvin\+\_\+obc\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Clean up the Kelvin wave O\+BC from registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacekelvin__initialization_abddff8dbfe770caf9b7d5564b3a0fc6d}{kelvin\+\_\+initialize\+\_\+topography}} (D, G, param\+\_\+file, max\+\_\+depth, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets up the Kelvin topography and land mask. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacekelvin__initialization_a39f47303961021f5605578c00722add2}{kelvin\+\_\+set\+\_\+obc\+\_\+data}} (O\+BC, CS, G, GV, US, h, Time)
\begin{DoxyCompactList}\small\item\em This subroutine sets the properties of flow at open boundary conditions. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacekelvin__initialization_abddff8dbfe770caf9b7d5564b3a0fc6d}\label{namespacekelvin__initialization_abddff8dbfe770caf9b7d5564b3a0fc6d}} 
\index{kelvin\_initialization@{kelvin\_initialization}!kelvin\_initialize\_topography@{kelvin\_initialize\_topography}}
\index{kelvin\_initialize\_topography@{kelvin\_initialize\_topography}!kelvin\_initialization@{kelvin\_initialization}}
\doxysubsubsection{\texorpdfstring{kelvin\_initialize\_topography()}{kelvin\_initialize\_topography()}}
{\footnotesize\ttfamily subroutine, public kelvin\+\_\+initialization\+::kelvin\+\_\+initialize\+\_\+topography (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{D,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{real, intent(in)}]{max\+\_\+depth,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



This subroutine sets up the Kelvin topography and land mask. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The dynamic horizontal grid type \\
\hline
\mbox{\texttt{ out}}  & {\em d} & Ocean bottom depth in m or Z if US is present \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file structure \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+depth} & Maximum model depth in the units of D \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 121 of file Kelvin\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{121   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),          \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< The dynamic horizontal grid type}}
\DoxyCodeLine{122 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%isd:G\%ied,G\%jsd:G\%jed)}, \&}
\DoxyCodeLine{123                                    \textcolor{keywordtype}{intent(out)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}}
\DoxyCodeLine{124   \textcolor{keywordtype}{type}(param\_file\_type),           \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{125 \textcolor{keywordtype}{  real},                            \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{ !< Maximum model depth in the units of D}}
\DoxyCodeLine{126   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{127 }
\DoxyCodeLine{128   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{129   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"Kelvin\_initialize\_topography"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{130 \textcolor{keywordtype}{  real} :: m\_to\_Z  \textcolor{comment}{! A dimensional rescaling factor.}}
\DoxyCodeLine{131 \textcolor{keywordtype}{  real} :: min\_depth \textcolor{comment}{! The minimum and maximum depths [Z \string~> m].}}
\DoxyCodeLine{132 \textcolor{keywordtype}{  real} :: PI \textcolor{comment}{! 3.1415...}}
\DoxyCodeLine{133 \textcolor{keywordtype}{  real} :: coast\_offset1, coast\_offset2, coast\_angle, right\_angle}
\DoxyCodeLine{134   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{135 }
\DoxyCodeLine{136   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  Kelvin\_initialization.F90, Kelvin\_initialize\_topography: setting topography"}, 5)}
\DoxyCodeLine{137 }
\DoxyCodeLine{138   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us\%m\_to\_Z}
\DoxyCodeLine{139 }
\DoxyCodeLine{140   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, min\_depth, \&}
\DoxyCodeLine{141                  \textcolor{stringliteral}{"The minimum depth of the ocean."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=m\_to\_z)}
\DoxyCodeLine{142   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ROTATED\_COAST\_OFFSET\_1"}, coast\_offset1, \&}
\DoxyCodeLine{143                  default=100.0, do\_not\_log=.true.)}
\DoxyCodeLine{144   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ROTATED\_COAST\_OFFSET\_2"}, coast\_offset2, \&}
\DoxyCodeLine{145                  default=10.0, do\_not\_log=.true.)}
\DoxyCodeLine{146   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ROTATED\_COAST\_ANGLE"}, coast\_angle, \&}
\DoxyCodeLine{147                  default=11.3, do\_not\_log=.true.)}
\DoxyCodeLine{148 }
\DoxyCodeLine{149   coast\_angle = coast\_angle * (atan(1.0)/45.) \textcolor{comment}{! Convert to radians}}
\DoxyCodeLine{150   right\_angle = 2 * atan(1.0)}
\DoxyCodeLine{151 }
\DoxyCodeLine{152   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{153     d(i,j) = max\_depth}
\DoxyCodeLine{154     \textcolor{comment}{! Southern side}}
\DoxyCodeLine{155     \textcolor{keywordflow}{if} ((g\%geoLonT(i,j) -\/ g\%west\_lon > coast\_offset1) .AND. \&}
\DoxyCodeLine{156         (atan2(g\%geoLatT(i,j) -\/ g\%south\_lat + coast\_offset2, \&}
\DoxyCodeLine{157          g\%geoLonT(i,j) -\/ g\%west\_lon -\/ coast\_offset1) < coast\_angle)) \&}
\DoxyCodeLine{158       d(i,j) = 0.5*min\_depth}
\DoxyCodeLine{159     \textcolor{comment}{! Northern side}}
\DoxyCodeLine{160     \textcolor{keywordflow}{if} ((g\%geoLonT(i,j) -\/ g\%west\_lon < g\%len\_lon -\/ coast\_offset1) .AND. \&}
\DoxyCodeLine{161         (atan2(g\%len\_lat + g\%south\_lat + coast\_offset2 -\/ g\%geoLatT(i,j), \&}
\DoxyCodeLine{162          g\%len\_lon + g\%west\_lon -\/ coast\_offset1 -\/ g\%geoLonT(i,j)) < coast\_angle)) \&}
\DoxyCodeLine{163       d(i,j) = 0.5*min\_depth}
\DoxyCodeLine{164 }
\DoxyCodeLine{165     \textcolor{keywordflow}{if} (d(i,j) > max\_depth) d(i,j) = max\_depth}
\DoxyCodeLine{166     \textcolor{keywordflow}{if} (d(i,j) < min\_depth) d(i,j) = 0.5*min\_depth}
\DoxyCodeLine{167 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{168 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacekelvin__initialization_a9c8e0745879d099cef92df7f16c67f9c}\label{namespacekelvin__initialization_a9c8e0745879d099cef92df7f16c67f9c}} 
\index{kelvin\_initialization@{kelvin\_initialization}!kelvin\_obc\_end@{kelvin\_obc\_end}}
\index{kelvin\_obc\_end@{kelvin\_obc\_end}!kelvin\_initialization@{kelvin\_initialization}}
\doxysubsubsection{\texorpdfstring{kelvin\_obc\_end()}{kelvin\_obc\_end()}}
{\footnotesize\ttfamily subroutine, public kelvin\+\_\+initialization\+::kelvin\+\_\+obc\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structkelvin__initialization_1_1kelvin__obc__cs}{kelvin\+\_\+obc\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up the Kelvin wave O\+BC from registry. 


\begin{DoxyParams}{Parameters}
{\em cs} & Kelvin wave control structure. \\
\hline
\end{DoxyParams}


Definition at line 111 of file Kelvin\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{111   \textcolor{keywordtype}{type}(Kelvin\_OBC\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< Kelvin wave control structure.}}
\DoxyCodeLine{112 }
\DoxyCodeLine{113   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{114     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{115 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacekelvin__initialization_a39f47303961021f5605578c00722add2}\label{namespacekelvin__initialization_a39f47303961021f5605578c00722add2}} 
\index{kelvin\_initialization@{kelvin\_initialization}!kelvin\_set\_obc\_data@{kelvin\_set\_obc\_data}}
\index{kelvin\_set\_obc\_data@{kelvin\_set\_obc\_data}!kelvin\_initialization@{kelvin\_initialization}}
\doxysubsubsection{\texorpdfstring{kelvin\_set\_obc\_data()}{kelvin\_set\_obc\_data()}}
{\footnotesize\ttfamily subroutine, public kelvin\+\_\+initialization\+::kelvin\+\_\+set\+\_\+obc\+\_\+data (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structkelvin__initialization_1_1kelvin__obc__cs}{kelvin\+\_\+obc\+\_\+cs}}), pointer}]{CS,  }\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(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})}



This subroutine sets the properties of flow at open boundary conditions. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & This open boundary condition type specifies whether, where, and what open boundary conditions are used. \\
\hline
 & {\em cs} & Kelvin wave control structure. \\
\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 h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em time} & model time. \\
\hline
\end{DoxyParams}


Definition at line 173 of file Kelvin\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{173   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{  !< This open boundary condition type specifies}}
\DoxyCodeLine{174 \textcolor{comment}{                                              !! whether, where, and what open boundary}}
\DoxyCodeLine{175 \textcolor{comment}{                                              !! conditions are used.}}
\DoxyCodeLine{176   \textcolor{keywordtype}{type}(Kelvin\_OBC\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< Kelvin wave control structure.}}
\DoxyCodeLine{177   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{178   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{179   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{    !< A dimensional unit scaling type}}
\DoxyCodeLine{180 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< layer thickness [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{181   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< model time.}}
\DoxyCodeLine{182 }
\DoxyCodeLine{183   \textcolor{comment}{! The following variables are used to set up the transport in the Kelvin example.}}
\DoxyCodeLine{184 \textcolor{keywordtype}{  real} :: time\_sec, cff}
\DoxyCodeLine{185 \textcolor{keywordtype}{  real} :: N0           \textcolor{comment}{! Brunt-\/Vaisala frequency [s-\/1]}}
\DoxyCodeLine{186 \textcolor{keywordtype}{  real} :: plx\textcolor{comment}{          !< Longshore wave parameter}}
\DoxyCodeLine{187 \textcolor{keywordtype}{  real} :: pmz\textcolor{comment}{          !< Vertical wave parameter}}
\DoxyCodeLine{188 \textcolor{keywordtype}{  real} :: lambda\textcolor{comment}{       !< Offshore decay scale}}
\DoxyCodeLine{189 \textcolor{keywordtype}{  real} :: omega\textcolor{comment}{        !< Wave frequency [s-\/1]}}
\DoxyCodeLine{190 \textcolor{keywordtype}{  real} :: PI}
\DoxyCodeLine{191   \textcolor{keywordtype}{integer} :: i, j, k, n, is, ie, js, je, isd, ied, jsd, jed, nz}
\DoxyCodeLine{192   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{193 \textcolor{keywordtype}{  real}    :: fac, x, y, x1, y1}
\DoxyCodeLine{194 \textcolor{keywordtype}{  real}    :: val1, val2, sina, cosa}
\DoxyCodeLine{195   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{196 }
\DoxyCodeLine{197   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{198   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{199   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{200 }
\DoxyCodeLine{201   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'Kelvin\_initialization.F90: '}// \&}
\DoxyCodeLine{202         \textcolor{stringliteral}{'Kelvin\_set\_OBC\_data() was called but OBC type was not initialized!'})}
\DoxyCodeLine{203 }
\DoxyCodeLine{204   time\_sec = time\_type\_to\_real(time)}
\DoxyCodeLine{205   pi = 4.0*atan(1.0)}
\DoxyCodeLine{206   fac = 1.0}
\DoxyCodeLine{207 }
\DoxyCodeLine{208   \textcolor{keywordflow}{if} (cs\%mode == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{209     omega = 2.0 * pi / (12.42 * 3600.0)      \textcolor{comment}{! M2 Tide period}}
\DoxyCodeLine{210     val1 = us\%m\_to\_Z * sin(omega * time\_sec)}
\DoxyCodeLine{211   \textcolor{keywordflow}{else}}
\DoxyCodeLine{212     n0 = us\%L\_to\_m*us\%s\_to\_T * sqrt((cs\%rho\_range / cs\%rho\_0) * gv\%g\_Earth * (us\%m\_to\_Z * cs\%H0))}
\DoxyCodeLine{213     \textcolor{comment}{! Two wavelengths in domain}}
\DoxyCodeLine{214     plx = 4.0 * pi / g\%len\_lon}
\DoxyCodeLine{215     pmz = pi * cs\%mode / cs\%H0}
\DoxyCodeLine{216     lambda = pmz * cs\%F\_0 / n0}
\DoxyCodeLine{217     omega = cs\%F\_0 * plx / lambda}
\DoxyCodeLine{218 }
\DoxyCodeLine{219     \textcolor{comment}{! lambda = PI * CS\%mode * CS\%F\_0 / (CS\%H0 * N0)}}
\DoxyCodeLine{220     \textcolor{comment}{! omega = (4.0 * CS\%H0 * N0)  / (CS\%mode * G\%len\_lon)}}
\DoxyCodeLine{221 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   sina = sin(cs\%coast\_angle)}
\DoxyCodeLine{224   cosa = cos(cs\%coast\_angle)}
\DoxyCodeLine{225   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{226     segment => obc\%segment(n)}
\DoxyCodeLine{227     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{228     \textcolor{comment}{! Apply values to the inflow end only.}}
\DoxyCodeLine{229     \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_e) cycle}
\DoxyCodeLine{230     \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_n) cycle}
\DoxyCodeLine{231 }
\DoxyCodeLine{232     \textcolor{comment}{! This should be somewhere else...}}
\DoxyCodeLine{233     segment\%Velocity\_nudging\_timescale\_in = 1.0/(0.3*86400)}
\DoxyCodeLine{234 }
\DoxyCodeLine{235     \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{236       isdb = segment\%HI\%IsdB ; iedb = segment\%HI\%IedB}
\DoxyCodeLine{237       jsd = segment\%HI\%jsd ; jed = segment\%HI\%jed}
\DoxyCodeLine{238       jsdb = segment\%HI\%JsdB ; jedb = segment\%HI\%JedB}
\DoxyCodeLine{239       \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb}
\DoxyCodeLine{240         x1 = 1000. * g\%geoLonCu(i,j)}
\DoxyCodeLine{241         y1 = 1000. * g\%geoLatCu(i,j)}
\DoxyCodeLine{242         x = (x1 -\/ cs\%coast\_offset1) * cosa + y1 * sina}
\DoxyCodeLine{243         y = -\/ (x1 -\/ cs\%coast\_offset1) * sina + y1 * cosa}
\DoxyCodeLine{244         \textcolor{keywordflow}{if} (cs\%mode == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{245           \textcolor{comment}{! Use inside bathymetry}}
\DoxyCodeLine{246           cff = sqrt(gv\%g\_Earth * g\%bathyT(i+1,j) )}
\DoxyCodeLine{247           val2 = fac * exp(-\/ us\%T\_to\_s*cs\%F\_0 * us\%m\_to\_L*y / cff)}
\DoxyCodeLine{248           segment\%eta(i,j) = val2 * cos(omega * time\_sec)}
\DoxyCodeLine{249           segment\%normal\_vel\_bt(i,j) = (val2 * (val1 * cff * cosa / \&}
\DoxyCodeLine{250                  (g\%bathyT(i+1,j) )) )}
\DoxyCodeLine{251           \textcolor{keywordflow}{if} (segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{252             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{253               segment\%nudged\_normal\_vel(i,j,k) = (val2 * (val1 * cff * cosa / \&}
\DoxyCodeLine{254                      (g\%bathyT(i+1,j))) )}
\DoxyCodeLine{255 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{256           \textcolor{keywordflow}{elseif} (segment\%specified) \textcolor{keywordflow}{then}}
\DoxyCodeLine{257             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{258               segment\%normal\_vel(i,j,k) = (val2 * (val1 * cff * cosa / \&}
\DoxyCodeLine{259                      (g\%bathyT(i+1,j) )) )}
\DoxyCodeLine{260               segment\%normal\_trans(i,j,k) = segment\%normal\_vel(i,j,k) * h(i+1,j,k) * g\%dyCu(i,j)}
\DoxyCodeLine{261 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{262 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{263         \textcolor{keywordflow}{else}}
\DoxyCodeLine{264           \textcolor{comment}{! Not rotated yet}}
\DoxyCodeLine{265           segment\%eta(i,j) = 0.0}
\DoxyCodeLine{266           segment\%normal\_vel\_bt(i,j) = 0.0}
\DoxyCodeLine{267           \textcolor{keywordflow}{if} (segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{268             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{269               segment\%nudged\_normal\_vel(i,j,k) = us\%m\_s\_to\_L\_T * fac * lambda / cs\%F\_0 * \&}
\DoxyCodeLine{270                    exp(-\/ lambda * y) * cos(pi * cs\%mode * (k -\/ 0.5) / nz) * \&}
\DoxyCodeLine{271                    cos(omega * time\_sec)}
\DoxyCodeLine{272 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{273           \textcolor{keywordflow}{elseif} (segment\%specified) \textcolor{keywordflow}{then}}
\DoxyCodeLine{274             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{275               segment\%normal\_vel(i,j,k) = us\%m\_s\_to\_L\_T * fac * lambda / cs\%F\_0 * \&}
\DoxyCodeLine{276                    exp(-\/ lambda * y) * cos(pi * cs\%mode * (k -\/ 0.5) / nz) * \&}
\DoxyCodeLine{277                    cos(omega * time\_sec)}
\DoxyCodeLine{278               segment\%normal\_trans(i,j,k) = segment\%normal\_vel(i,j,k) * h(i+1,j,k) * g\%dyCu(i,j)}
\DoxyCodeLine{279 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{280 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{281 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{282 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{283       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tangential\_vel)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{284         \textcolor{keywordflow}{do} j=jsdb+1,jedb-\/1 ; \textcolor{keywordflow}{do} i=isdb,iedb}
\DoxyCodeLine{285           x1 = 1000. * g\%geoLonBu(i,j)}
\DoxyCodeLine{286           y1 = 1000. * g\%geoLatBu(i,j)}
\DoxyCodeLine{287           x = (x1 -\/ cs\%coast\_offset1) * cosa + y1 * sina}
\DoxyCodeLine{288           y = -\/ (x1 -\/ cs\%coast\_offset1) * sina + y1 * cosa}
\DoxyCodeLine{289           cff =sqrt(gv\%g\_Earth * g\%bathyT(i+1,j) )}
\DoxyCodeLine{290           val2 = fac * exp(-\/ us\%T\_to\_s*cs\%F\_0 * us\%m\_to\_L*y / cff)}
\DoxyCodeLine{291           \textcolor{keywordflow}{if} (cs\%mode == 0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{292             segment\%tangential\_vel(i,j,k) = (val1 * val2 * cff * sina) / \&}
\DoxyCodeLine{293                ( 0.5*(g\%bathyT(i+1,j+1) +  g\%bathyT(i+1,j) ) )}
\DoxyCodeLine{294 }
\DoxyCodeLine{295 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{296 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{297 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{298     \textcolor{keywordflow}{else} \textcolor{comment}{! Must be south}}
\DoxyCodeLine{299       isd = segment\%HI\%isd ; ied = segment\%HI\%ied}
\DoxyCodeLine{300       jsdb = segment\%HI\%JsdB ; jedb = segment\%HI\%JedB}
\DoxyCodeLine{301       \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{302         x1 = 1000. * g\%geoLonCv(i,j)}
\DoxyCodeLine{303         y1 = 1000. * g\%geoLatCv(i,j)}
\DoxyCodeLine{304         x = (x1 -\/ cs\%coast\_offset1) * cosa + y1 * sina}
\DoxyCodeLine{305         y = -\/ (x1 -\/ cs\%coast\_offset1) * sina + y1 * cosa}
\DoxyCodeLine{306         \textcolor{keywordflow}{if} (cs\%mode == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{307           cff = sqrt(gv\%g\_Earth * g\%bathyT(i,j+1) )}
\DoxyCodeLine{308           val2 = fac * exp(-\/ 0.5 * (g\%CoriolisBu(i,j) + g\%CoriolisBu(i-\/1,j)) * us\%m\_to\_L*y / cff)}
\DoxyCodeLine{309           segment\%eta(i,j) = val2 * cos(omega * time\_sec)}
\DoxyCodeLine{310           segment\%normal\_vel\_bt(i,j) = us\%L\_T\_to\_m\_s * (val1 * cff * sina / \&}
\DoxyCodeLine{311                  (g\%bathyT(i,j+1) )) * val2}
\DoxyCodeLine{312           \textcolor{keywordflow}{if} (segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{313             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{314               segment\%nudged\_normal\_vel(i,j,k) = us\%L\_T\_to\_m\_s * (val1 * cff * sina / \&}
\DoxyCodeLine{315                      (g\%bathyT(i,j+1) )) * val2}
\DoxyCodeLine{316 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{317           \textcolor{keywordflow}{elseif} (segment\%specified) \textcolor{keywordflow}{then}}
\DoxyCodeLine{318             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{319               segment\%normal\_vel(i,j,k) = us\%L\_T\_to\_m\_s * (val1 * cff * sina / \&}
\DoxyCodeLine{320                      (g\%bathyT(i,j+1) )) * val2}
\DoxyCodeLine{321               segment\%normal\_trans(i,j,k) = segment\%normal\_vel(i,j,k) * h(i,j+1,k) * g\%dxCv(i,j)}
\DoxyCodeLine{322 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{323 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{324         \textcolor{keywordflow}{else}}
\DoxyCodeLine{325           \textcolor{comment}{! Not rotated yet}}
\DoxyCodeLine{326           segment\%eta(i,j) = 0.0}
\DoxyCodeLine{327           segment\%normal\_vel\_bt(i,j) = 0.0}
\DoxyCodeLine{328           \textcolor{keywordflow}{if} (segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{329             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{330               segment\%nudged\_normal\_vel(i,j,k) = us\%m\_s\_to\_L\_T*fac * lambda / cs\%F\_0 * \&}
\DoxyCodeLine{331                    exp(-\/ lambda * y) * cos(pi * cs\%mode * (k -\/ 0.5) / nz) * cosa}
\DoxyCodeLine{332 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{333           \textcolor{keywordflow}{elseif} (segment\%specified) \textcolor{keywordflow}{then}}
\DoxyCodeLine{334             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{335               segment\%normal\_vel(i,j,k) = us\%m\_s\_to\_L\_T*fac * lambda / cs\%F\_0 * \&}
\DoxyCodeLine{336                    exp(-\/ lambda * y) * cos(pi * cs\%mode * (k -\/ 0.5) / nz) * cosa}
\DoxyCodeLine{337               segment\%normal\_trans(i,j,k) = segment\%normal\_vel(i,j,k) * h(i,j+1,k) * g\%dxCv(i,j)}
\DoxyCodeLine{338 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{339 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{340 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{341 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{342       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tangential\_vel)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{343         \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isdb+1,iedb-\/1}
\DoxyCodeLine{344           x1 = 1000. * g\%geoLonBu(i,j)}
\DoxyCodeLine{345           y1 = 1000. * g\%geoLatBu(i,j)}
\DoxyCodeLine{346           x = (x1 -\/ cs\%coast\_offset1) * cosa + y1 * sina}
\DoxyCodeLine{347           y = -\/ (x1 -\/ cs\%coast\_offset1) * sina + y1 * cosa}
\DoxyCodeLine{348           cff = sqrt(gv\%g\_Earth * g\%bathyT(i,j+1) )}
\DoxyCodeLine{349           val2 = fac * exp(-\/ 0.5 * (g\%CoriolisBu(i,j) + g\%CoriolisBu(i-\/1,j)) * us\%m\_to\_L*y / cff)}
\DoxyCodeLine{350           \textcolor{keywordflow}{if} (cs\%mode == 0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{351             segment\%tangential\_vel(i,j,k) = ((val1 * val2 * cff * sina) / \&}
\DoxyCodeLine{352                 ( 0.5*((g\%bathyT(i+1,j+1)) + g\%bathyT(i,j+1))) )}
\DoxyCodeLine{353 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{354 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{355 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{356 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{357 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{358 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacekelvin__initialization_a987148fd20c38f1f4897661a39c3120e}\label{namespacekelvin__initialization_a987148fd20c38f1f4897661a39c3120e}} 
\index{kelvin\_initialization@{kelvin\_initialization}!register\_kelvin\_obc@{register\_kelvin\_obc}}
\index{register\_kelvin\_obc@{register\_kelvin\_obc}!kelvin\_initialization@{kelvin\_initialization}}
\doxysubsubsection{\texorpdfstring{register\_kelvin\_obc()}{register\_kelvin\_obc()}}
{\footnotesize\ttfamily logical function, public kelvin\+\_\+initialization\+::register\+\_\+kelvin\+\_\+obc (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structkelvin__initialization_1_1kelvin__obc__cs}{kelvin\+\_\+obc\+\_\+cs}}), pointer}]{CS,  }\item[{type(obc\+\_\+registry\+\_\+type), pointer}]{O\+B\+C\+\_\+\+Reg }\end{DoxyParamCaption})}



Add Kelvin wave to O\+BC registry. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & parameter file. \\
\hline
 & {\em cs} & Kelvin wave control structure. \\
\hline
 & {\em obc\+\_\+reg} & O\+BC registry. \\
\hline
\end{DoxyParams}


Definition at line 54 of file Kelvin\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{54   \textcolor{keywordtype}{type}(param\_file\_type),    \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< parameter file.}}
\DoxyCodeLine{55   \textcolor{keywordtype}{type}(Kelvin\_OBC\_CS),      \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< Kelvin wave control structure.}}
\DoxyCodeLine{56   \textcolor{keywordtype}{type}(OBC\_registry\_type),  \textcolor{keywordtype}{pointer}    :: OBC\_Reg\textcolor{comment}{    !< OBC registry.}}
\DoxyCodeLine{57 }
\DoxyCodeLine{58   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{59   \textcolor{keywordtype}{logical} :: register\_Kelvin\_OBC}
\DoxyCodeLine{60   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"register\_Kelvin\_OBC"}\textcolor{comment}{  !< This subroutine's name.}}
\DoxyCodeLine{61   \textcolor{keywordtype}{character(len=32)}  :: casename = \textcolor{stringliteral}{"Kelvin wave"}\textcolor{comment}{     !< This case's name.}}
\DoxyCodeLine{62   \textcolor{keywordtype}{character(len=200)} :: config}
\DoxyCodeLine{63 }
\DoxyCodeLine{64   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{65     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_Kelvin\_OBC called with an "}// \&}
\DoxyCodeLine{66                             \textcolor{stringliteral}{"associated control structure."})}
\DoxyCodeLine{67     \textcolor{keywordflow}{return}}
\DoxyCodeLine{68 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{69   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{70 }
\DoxyCodeLine{71   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{72   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KELVIN\_WAVE\_MODE"}, cs\%mode, \&}
\DoxyCodeLine{73                  \textcolor{stringliteral}{"Vertical Kelvin wave mode imposed at upstream open boundary."}, \&}
\DoxyCodeLine{74                  default=0)}
\DoxyCodeLine{75   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"F\_0"}, cs\%F\_0, \&}
\DoxyCodeLine{76                  default=0.0, do\_not\_log=.true.)}
\DoxyCodeLine{77   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TOPO\_CONFIG"}, config, do\_not\_log=.true.)}
\DoxyCodeLine{78   \textcolor{keywordflow}{if} (trim(config) == \textcolor{stringliteral}{"Kelvin"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{79     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ROTATED\_COAST\_OFFSET\_1"}, cs\%coast\_offset1, \&}
\DoxyCodeLine{80                    \textcolor{stringliteral}{"The distance along the southern and northern boundaries "}//\&}
\DoxyCodeLine{81                    \textcolor{stringliteral}{"at which the coasts angle in."}, \&}
\DoxyCodeLine{82                    units=\textcolor{stringliteral}{"km"}, default=100.0)}
\DoxyCodeLine{83     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ROTATED\_COAST\_OFFSET\_2"}, cs\%coast\_offset2, \&}
\DoxyCodeLine{84                    \textcolor{stringliteral}{"The distance from the southern and northern boundaries "}//\&}
\DoxyCodeLine{85                    \textcolor{stringliteral}{"at which the coasts angle in."}, \&}
\DoxyCodeLine{86                    units=\textcolor{stringliteral}{"km"}, default=10.0)}
\DoxyCodeLine{87     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ROTATED\_COAST\_ANGLE"}, cs\%coast\_angle, \&}
\DoxyCodeLine{88                    \textcolor{stringliteral}{"The angle of the southern bondary beyond X=ROTATED\_COAST\_OFFSET."}, \&}
\DoxyCodeLine{89                    units=\textcolor{stringliteral}{"degrees"}, default=11.3)}
\DoxyCodeLine{90     cs\%coast\_angle = cs\%coast\_angle * (atan(1.0)/45.) \textcolor{comment}{! Convert to radians}}
\DoxyCodeLine{91     cs\%coast\_offset1 = cs\%coast\_offset1 * 1.e3          \textcolor{comment}{! Convert to m}}
\DoxyCodeLine{92     cs\%coast\_offset2 = cs\%coast\_offset2 * 1.e3          \textcolor{comment}{! Convert to m}}
\DoxyCodeLine{93 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{94   \textcolor{keywordflow}{if} (cs\%mode /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{95     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSITY\_RANGE"}, cs\%rho\_range, \&}
\DoxyCodeLine{96                    default=2.0, do\_not\_log=.true.)}
\DoxyCodeLine{97     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs\%rho\_0, \&}
\DoxyCodeLine{98                    default=1035.0, do\_not\_log=.true.)}
\DoxyCodeLine{99     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MAXIMUM\_DEPTH"}, cs\%H0, \&}
\DoxyCodeLine{100                    default=1000.0, do\_not\_log=.true.)}
\DoxyCodeLine{101 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{102 }
\DoxyCodeLine{103   \textcolor{comment}{! Register the Kelvin open boundary.}}
\DoxyCodeLine{104   \textcolor{keyword}{call }register\_obc(casename, param\_file, obc\_reg)}
\DoxyCodeLine{105   register\_kelvin\_obc = .true.}
\DoxyCodeLine{106 }

\end{DoxyCode}
