\hypertarget{namespaceshelfwave__initialization}{}\section{shelfwave\+\_\+initialization Module Reference}
\label{namespaceshelfwave__initialization}\index{shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}}


\subsection{Detailed Description}
Configures the model for the idealized shelfwave test case. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structshelfwave__initialization_1_1shelfwave__obc__cs}{shelfwave\+\_\+obc\+\_\+cs}
\begin{DoxyCompactList}\small\item\em Control structure for shelfwave open boundaries. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \hyperlink{namespaceshelfwave__initialization_a00e944446bb66181ac86fd959534d043}{register\+\_\+shelfwave\+\_\+obc} (param\+\_\+file, CS, O\+B\+C\+\_\+\+Reg)
\begin{DoxyCompactList}\small\item\em Add shelfwave to O\+BC registry. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceshelfwave__initialization_ae1b5550c3ac2a4ae131c504d4765905d}{shelfwave\+\_\+obc\+\_\+end} (CS)
\begin{DoxyCompactList}\small\item\em Clean up the shelfwave O\+BC from registry. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceshelfwave__initialization_ac2db4043726cb7eed851c69d6190b8dd}{shelfwave\+\_\+initialize\+\_\+topography} (D, G, param\+\_\+file, max\+\_\+depth, US)
\begin{DoxyCompactList}\small\item\em Initialization of topography. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceshelfwave__initialization_a237669eac665275c69ede1c64c139956}{shelfwave\+\_\+set\+\_\+obc\+\_\+data} (O\+BC, CS, G, h, Time)
\begin{DoxyCompactList}\small\item\em This subroutine sets the properties of flow at open boundary conditions. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceshelfwave__initialization_afe4d5b9d225219ff02cf99e70bf4f519}\label{namespaceshelfwave__initialization_afe4d5b9d225219ff02cf99e70bf4f519}} 
character(len=40) \hyperlink{namespaceshelfwave__initialization_afe4d5b9d225219ff02cf99e70bf4f519}{mdl} = \char`\"{}shelfwave\+\_\+initialization\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceshelfwave__initialization_a00e944446bb66181ac86fd959534d043}\label{namespaceshelfwave__initialization_a00e944446bb66181ac86fd959534d043}} 
\index{shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}!register\+\_\+shelfwave\+\_\+obc@{register\+\_\+shelfwave\+\_\+obc}}
\index{register\+\_\+shelfwave\+\_\+obc@{register\+\_\+shelfwave\+\_\+obc}!shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}}
\subsubsection{\texorpdfstring{register\+\_\+shelfwave\+\_\+obc()}{register\_shelfwave\_obc()}}
{\footnotesize\ttfamily logical function, public shelfwave\+\_\+initialization\+::register\+\_\+shelfwave\+\_\+obc (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structshelfwave__initialization_1_1shelfwave__obc__cs}{shelfwave\+\_\+obc\+\_\+cs}), pointer}]{CS,  }\item[{type(obc\+\_\+registry\+\_\+type), pointer}]{O\+B\+C\+\_\+\+Reg }\end{DoxyParamCaption})}



Add shelfwave to O\+BC registry. 


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


Definition at line 44 of file shelfwave\+\_\+initialization.\+F90.


\begin{DoxyCode}
44   \textcolor{keywordtype}{type}(param\_file\_type),    \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< parameter file.}
45   \textcolor{keywordtype}{type}(shelfwave\_obc\_cs),   \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{         !< shelfwave control structure.}
46   \textcolor{keywordtype}{type}(obc\_registry\_type),  \textcolor{keywordtype}{pointer}    :: obc\_reg\textcolor{comment}{    !< OBC registry.}
47   \textcolor{keywordtype}{logical}                              :: register\_shelfwave\_obc
48   \textcolor{comment}{! Local variables}
49   \textcolor{keywordtype}{real} :: kk, ll, pi, len\_lat
50 
51   \textcolor{keywordtype}{character(len=32)}  :: casename = \textcolor{stringliteral}{"shelfwave"}\textcolor{comment}{       !< This case's name.}
52 
53   pi = 4.0*atan(1.0)
54 
55   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
56     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_shelfwave\_OBC called with an "}// &
57                             \textcolor{stringliteral}{"associated control structure."})
58     \textcolor{keywordflow}{return}
59 \textcolor{keywordflow}{  endif}
60   \textcolor{keyword}{allocate}(cs)
61 
62   \textcolor{comment}{! Register the tracer for horizontal advection & diffusion.}
63   \textcolor{keyword}{call }register\_obc(casename, param\_file, obc\_reg)
64   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"F\_0"},cs%f0, &
65                  do\_not\_log=.true.)
66   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"LENLAT"},len\_lat, &
67                  do\_not\_log=.true.)
68   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"SHELFWAVE\_X\_WAVELENGTH"},cs%Lx, &
69                  \textcolor{stringliteral}{"Length scale of shelfwave in x-direction."},&
70                  units=\textcolor{stringliteral}{"Same as x,y"}, default=100.)
71   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"SHELFWAVE\_Y\_LENGTH\_SCALE"},cs%Ly, &
72                  \textcolor{stringliteral}{"Length scale of exponential dropoff of topography "}//&
73                  \textcolor{stringliteral}{"in the y-direction."}, &
74                  units=\textcolor{stringliteral}{"Same as x,y"}, default=50.)
75   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"SHELFWAVE\_Y\_MODE"},cs%jj, &
76                  \textcolor{stringliteral}{"Cross-shore wave mode."},               &
77                  units=\textcolor{stringliteral}{"nondim"}, default=1.)
78   cs%alpha = 1. / cs%Ly
79   cs%ll = 2. * pi / cs%Lx
80   cs%kk = cs%jj * pi / len\_lat
81   cs%omega = 2 * cs%alpha * cs%f0 * cs%ll / &
82              (cs%kk*cs%kk + cs%alpha*cs%alpha + cs%ll*cs%ll)
83   register\_shelfwave\_obc = .true.
84 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceshelfwave__initialization_ac2db4043726cb7eed851c69d6190b8dd}\label{namespaceshelfwave__initialization_ac2db4043726cb7eed851c69d6190b8dd}} 
\index{shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}!shelfwave\+\_\+initialize\+\_\+topography@{shelfwave\+\_\+initialize\+\_\+topography}}
\index{shelfwave\+\_\+initialize\+\_\+topography@{shelfwave\+\_\+initialize\+\_\+topography}!shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}}
\subsubsection{\texorpdfstring{shelfwave\+\_\+initialize\+\_\+topography()}{shelfwave\_initialize\_topography()}}
{\footnotesize\ttfamily subroutine, public shelfwave\+\_\+initialization\+::shelfwave\+\_\+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})}



Initialization of topography. 


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


Definition at line 98 of file shelfwave\+\_\+initialization.\+F90.


\begin{DoxyCode}
98   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),          \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{ !< The dynamic horizontal grid type}
99   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
100                                    \textcolor{keywordtype}{intent(out)} :: d\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}
101   \textcolor{keywordtype}{type}(param\_file\_type),           \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}
102   \textcolor{keywordtype}{real},                            \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{ !< Maximum model depth in the units of D}
103   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{ !< A dimensional unit scaling type}
104 
105   \textcolor{comment}{! Local variables}
106   \textcolor{keywordtype}{real} :: m\_to\_z  \textcolor{comment}{! A dimensional rescaling factor.}
107   \textcolor{keywordtype}{integer}   :: i, j
108   \textcolor{keywordtype}{real}      :: y, rly, ly, h0
109 
110   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us%m\_to\_Z
111 
112   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"SHELFWAVE\_Y\_LENGTH\_SCALE"},ly, &
113                  default=50., do\_not\_log=.true.)
114   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"MINIMUM\_DEPTH"}, h0, &
115                  default=10., units=\textcolor{stringliteral}{"m"}, scale=m\_to\_z, do\_not\_log=.true.)
116 
117   rly = 0. ; \textcolor{keywordflow}{if} (ly>0.) rly = 1. / ly
118 
119   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
120     \textcolor{comment}{! Compute normalized zonal coordinates (x,y=0 at center of domain)}
121     y = ( g%geoLatT(i,j) - g%south\_lat )
122     d(i,j) = h0 * exp(2 * rly * y)
123 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
124 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceshelfwave__initialization_ae1b5550c3ac2a4ae131c504d4765905d}\label{namespaceshelfwave__initialization_ae1b5550c3ac2a4ae131c504d4765905d}} 
\index{shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}!shelfwave\+\_\+obc\+\_\+end@{shelfwave\+\_\+obc\+\_\+end}}
\index{shelfwave\+\_\+obc\+\_\+end@{shelfwave\+\_\+obc\+\_\+end}!shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}}
\subsubsection{\texorpdfstring{shelfwave\+\_\+obc\+\_\+end()}{shelfwave\_obc\_end()}}
{\footnotesize\ttfamily subroutine, public shelfwave\+\_\+initialization\+::shelfwave\+\_\+obc\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structshelfwave__initialization_1_1shelfwave__obc__cs}{shelfwave\+\_\+obc\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up the shelfwave O\+BC from registry. 


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


Definition at line 89 of file shelfwave\+\_\+initialization.\+F90.


\begin{DoxyCode}
89   \textcolor{keywordtype}{type}(shelfwave\_obc\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{         !< shelfwave control structure.}
90 
91   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
92     \textcolor{keyword}{deallocate}(cs)
93 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespaceshelfwave__initialization_a237669eac665275c69ede1c64c139956}\label{namespaceshelfwave__initialization_a237669eac665275c69ede1c64c139956}} 
\index{shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}!shelfwave\+\_\+set\+\_\+obc\+\_\+data@{shelfwave\+\_\+set\+\_\+obc\+\_\+data}}
\index{shelfwave\+\_\+set\+\_\+obc\+\_\+data@{shelfwave\+\_\+set\+\_\+obc\+\_\+data}!shelfwave\+\_\+initialization@{shelfwave\+\_\+initialization}}
\subsubsection{\texorpdfstring{shelfwave\+\_\+set\+\_\+obc\+\_\+data()}{shelfwave\_set\_obc\_data()}}
{\footnotesize\ttfamily subroutine, public shelfwave\+\_\+initialization\+::shelfwave\+\_\+set\+\_\+obc\+\_\+data (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\hyperlink{structshelfwave__initialization_1_1shelfwave__obc__cs}{shelfwave\+\_\+obc\+\_\+cs}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\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} & tidal bay control structure.\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em h} & layer thickness.\\
\hline
\mbox{\tt in}  & {\em time} & model time. \\
\hline
\end{DoxyParams}


Definition at line 129 of file shelfwave\+\_\+initialization.\+F90.


\begin{DoxyCode}
129   \textcolor{keywordtype}{type}(ocean\_obc\_type),   \textcolor{keywordtype}{pointer}    :: obc\textcolor{comment}{  !< This open boundary condition type specifies}
130 \textcolor{comment}{                                             !! whether, where, and what open boundary}
131 \textcolor{comment}{                                             !! conditions are used.}
132   \textcolor{keywordtype}{type}(shelfwave\_obc\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< tidal bay control structure.}
133   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
134   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< layer thickness.}
135   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)} :: time\textcolor{comment}{ !< model time.}
136 
137   \textcolor{comment}{! The following variables are used to set up the transport in the shelfwave example.}
138   \textcolor{keywordtype}{real} :: my\_amp, time\_sec
139   \textcolor{keywordtype}{real} :: cos\_wt, cos\_ky, sin\_wt, sin\_ky, omega, alpha
140   \textcolor{keywordtype}{real} :: x, y, jj, kk, ll
141   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"shelfwave\_set\_OBC\_data"} \textcolor{comment}{! This subroutine's name.}
142   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, n
143   \textcolor{keywordtype}{integer} :: isdb, iedb, jsdb, jedb
144   \textcolor{keywordtype}{type}(obc\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()
145 
146   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
147   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
148   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
149 
150   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}
151 
152   time\_sec = time\_type\_to\_real(time)
153   omega = cs%omega
154   alpha = cs%alpha
155   my\_amp = 1.0
156   jj = cs%jj
157   kk = cs%kk
158   ll = cs%ll
159   \textcolor{keywordflow}{do} n = 1, obc%number\_of\_segments
160     segment => obc%segment(n)
161     \textcolor{keywordflow}{if} (.not. segment%on\_pe) cycle
162     \textcolor{keywordflow}{if} (segment%direction /= obc\_direction\_w) cycle
163 
164     isdb = segment%HI%IsdB ; iedb = segment%HI%IedB
165     jsd = segment%HI%jsd ; jed = segment%HI%jed
166     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
167       x = g%geoLonCu(i,j) - g%west\_lon
168       y = g%geoLatCu(i,j) - g%south\_lat
169       sin\_wt = sin(ll*x - omega*time\_sec)
170       cos\_wt = cos(ll*x - omega*time\_sec)
171       sin\_ky = sin(kk * y)
172       cos\_ky = cos(kk * y)
173       segment%normal\_vel\_bt(i,j) = g%US%m\_s\_to\_L\_T*my\_amp * exp(- alpha * y) * cos\_wt * &
174            (alpha * sin\_ky + kk * cos\_ky)
175 \textcolor{comment}{!     segment%tangential\_vel\_bt(I,j) = G%US%m\_s\_to\_L\_T*my\_amp * ll * exp(- alpha * y) * sin\_wt * sin\_ky}
176 \textcolor{comment}{!     segment%vorticity\_bt(I,j) = my\_amp * exp(- alpha * y) * cos\_wt * sin\_ky&}
177 \textcolor{comment}{!           (ll*ll + kk*kk + alpha*alpha)}
178 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
179 \textcolor{keywordflow}{  enddo}
180 
\end{DoxyCode}
