\hypertarget{namespacetidal__bay__initialization}{}\section{tidal\+\_\+bay\+\_\+initialization Module Reference}
\label{namespacetidal__bay__initialization}\index{tidal\+\_\+bay\+\_\+initialization@{tidal\+\_\+bay\+\_\+initialization}}


\subsection{Detailed Description}
Configures the model for the \char`\"{}tidal\+\_\+bay\char`\"{} experiment. tidal\+\_\+bay = Tidally resonant bay from Zygmunt Kowalik\textquotesingle{}s class on tides. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structtidal__bay__initialization_1_1tidal__bay__obc__cs}{tidal\+\_\+bay\+\_\+obc\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure for tidal bay open boundaries. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespacetidal__bay__initialization_a6a382dc13d49aa2d37577b8fbf5f7de2}{register\+\_\+tidal\+\_\+bay\+\_\+obc}} (param\+\_\+file, CS, O\+B\+C\+\_\+\+Reg)
\begin{DoxyCompactList}\small\item\em Add tidal bay to O\+BC registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacetidal__bay__initialization_a0c8bd22e72376c9f9af5bc5f628393f9}{tidal\+\_\+bay\+\_\+obc\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Clean up the tidal bay O\+BC from registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacetidal__bay__initialization_a874c04828e2652fbd356c8a89c8179da}{tidal\+\_\+bay\+\_\+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{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacetidal__bay__initialization_a6a382dc13d49aa2d37577b8fbf5f7de2}\label{namespacetidal__bay__initialization_a6a382dc13d49aa2d37577b8fbf5f7de2}} 
\index{tidal\+\_\+bay\+\_\+initialization@{tidal\+\_\+bay\+\_\+initialization}!register\+\_\+tidal\+\_\+bay\+\_\+obc@{register\+\_\+tidal\+\_\+bay\+\_\+obc}}
\index{register\+\_\+tidal\+\_\+bay\+\_\+obc@{register\+\_\+tidal\+\_\+bay\+\_\+obc}!tidal\+\_\+bay\+\_\+initialization@{tidal\+\_\+bay\+\_\+initialization}}
\subsubsection{\texorpdfstring{register\+\_\+tidal\+\_\+bay\+\_\+obc()}{register\_tidal\_bay\_obc()}}
{\footnotesize\ttfamily logical function, public tidal\+\_\+bay\+\_\+initialization\+::register\+\_\+tidal\+\_\+bay\+\_\+obc (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structtidal__bay__initialization_1_1tidal__bay__obc__cs}{tidal\+\_\+bay\+\_\+obc\+\_\+cs}}), pointer}]{CS,  }\item[{type(obc\+\_\+registry\+\_\+type), pointer}]{O\+B\+C\+\_\+\+Reg }\end{DoxyParamCaption})}



Add tidal bay to O\+BC registry. 


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


Definition at line 34 of file tidal\+\_\+bay\+\_\+initialization.\+F90.


\begin{DoxyCode}
34   \textcolor{keywordtype}{type}(param\_file\_type),    \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< parameter file.}
35   \textcolor{keywordtype}{type}(tidal\_bay\_OBC\_CS),   \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< tidal bay control structure.}
36   \textcolor{keywordtype}{type}(OBC\_registry\_type),  \textcolor{keywordtype}{pointer}    :: OBC\_Reg\textcolor{comment}{    !< OBC registry.}
37   \textcolor{keywordtype}{logical}                              :: register\_tidal\_bay\_OBC
38   \textcolor{keywordtype}{character(len=32)}  :: casename = \textcolor{stringliteral}{"tidal bay"}\textcolor{comment}{       !< This case's name.}
39 
40   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
41     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_tidal\_bay\_OBC called with an "}// &
42                             \textcolor{stringliteral}{"associated control structure."})
43     \textcolor{keywordflow}{return}
44 \textcolor{keywordflow}{  endif}
45   \textcolor{keyword}{allocate}(cs)
46 
47   \textcolor{comment}{! Register the open boundaries.}
48   \textcolor{keyword}{call }register\_obc(casename, param\_file, obc\_reg)
49   register\_tidal\_bay\_obc = .true.
50 
\end{DoxyCode}
\mbox{\Hypertarget{namespacetidal__bay__initialization_a0c8bd22e72376c9f9af5bc5f628393f9}\label{namespacetidal__bay__initialization_a0c8bd22e72376c9f9af5bc5f628393f9}} 
\index{tidal\+\_\+bay\+\_\+initialization@{tidal\+\_\+bay\+\_\+initialization}!tidal\+\_\+bay\+\_\+obc\+\_\+end@{tidal\+\_\+bay\+\_\+obc\+\_\+end}}
\index{tidal\+\_\+bay\+\_\+obc\+\_\+end@{tidal\+\_\+bay\+\_\+obc\+\_\+end}!tidal\+\_\+bay\+\_\+initialization@{tidal\+\_\+bay\+\_\+initialization}}
\subsubsection{\texorpdfstring{tidal\+\_\+bay\+\_\+obc\+\_\+end()}{tidal\_bay\_obc\_end()}}
{\footnotesize\ttfamily subroutine, public tidal\+\_\+bay\+\_\+initialization\+::tidal\+\_\+bay\+\_\+obc\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structtidal__bay__initialization_1_1tidal__bay__obc__cs}{tidal\+\_\+bay\+\_\+obc\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up the tidal bay O\+BC from registry. 


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


Definition at line 55 of file tidal\+\_\+bay\+\_\+initialization.\+F90.


\begin{DoxyCode}
55   \textcolor{keywordtype}{type}(tidal\_bay\_OBC\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< tidal bay control structure.}
56 
57   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
58     \textcolor{keyword}{deallocate}(cs)
59 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacetidal__bay__initialization_a874c04828e2652fbd356c8a89c8179da}\label{namespacetidal__bay__initialization_a874c04828e2652fbd356c8a89c8179da}} 
\index{tidal\+\_\+bay\+\_\+initialization@{tidal\+\_\+bay\+\_\+initialization}!tidal\+\_\+bay\+\_\+set\+\_\+obc\+\_\+data@{tidal\+\_\+bay\+\_\+set\+\_\+obc\+\_\+data}}
\index{tidal\+\_\+bay\+\_\+set\+\_\+obc\+\_\+data@{tidal\+\_\+bay\+\_\+set\+\_\+obc\+\_\+data}!tidal\+\_\+bay\+\_\+initialization@{tidal\+\_\+bay\+\_\+initialization}}
\subsubsection{\texorpdfstring{tidal\+\_\+bay\+\_\+set\+\_\+obc\+\_\+data()}{tidal\_bay\_set\_obc\_data()}}
{\footnotesize\ttfamily subroutine, public tidal\+\_\+bay\+\_\+initialization\+::tidal\+\_\+bay\+\_\+set\+\_\+obc\+\_\+data (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structtidal__bay__initialization_1_1tidal__bay__obc__cs}{tidal\+\_\+bay\+\_\+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 64 of file tidal\+\_\+bay\+\_\+initialization.\+F90.


\begin{DoxyCode}
64   \textcolor{keywordtype}{type}(ocean\_OBC\_type),   \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{  !< This open boundary condition type specifies}
65 \textcolor{comment}{                                             !! whether, where, and what open boundary}
66 \textcolor{comment}{                                             !! conditions are used.}
67   \textcolor{keywordtype}{type}(tidal\_bay\_OBC\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< tidal bay control structure.}
68   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure.}
69   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< layer thickness.}
70   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< model time.}
71 
72   \textcolor{comment}{! The following variables are used to set up the transport in the tidal\_bay example.}
73   \textcolor{keywordtype}{real} :: time\_sec, cff
74   \textcolor{keywordtype}{real} :: my\_flux, total\_area
75   \textcolor{keywordtype}{real} :: PI
76   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable} :: my\_area(:,:)
77   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"tidal\_bay\_set\_OBC\_data"} \textcolor{comment}{! This subroutine's name.}
78   \textcolor{keywordtype}{integer} :: i, j, k, itt, is, ie, js, je, isd, ied, jsd, jed, nz, n
79   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB
80   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()
81 
82   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
83   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
84   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
85 
86   pi = 4.0*atan(1.0)
87 
88   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}
89 
90   \textcolor{keyword}{allocate}(my\_area(1:1,js:je))
91 
92   time\_sec = time\_type\_to\_real(time)
93   cff = 0.1*sin(2.0*pi*time\_sec/(12.0*3600.0))
94   my\_area=0.0
95   my\_flux=0.0
96   segment => obc%segment(1)
97 
98   \textcolor{keywordflow}{do} j=segment%HI%jsc,segment%HI%jec ; \textcolor{keywordflow}{do} i=segment%HI%IscB,segment%HI%IecB
99     \textcolor{keywordflow}{if} (obc%segnum\_u(i,j) /= obc\_none) \textcolor{keywordflow}{then}
100       \textcolor{keywordflow}{do} k=1,nz
101         my\_area(1,j) = my\_area(1,j) + h(i,j,k)*g%US%L\_to\_m*g%dyCu(i,j)
102 \textcolor{keywordflow}{      enddo}
103 \textcolor{keywordflow}{    endif}
104 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
105   total\_area = \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}(my\_area)
106   my\_flux = - cs%tide\_flow*sin(2.0*pi*time\_sec/(12.0*3600.0))
107 
108   \textcolor{keywordflow}{do} n = 1, obc%number\_of\_segments
109     segment => obc%segment(n)
110 
111     \textcolor{keywordflow}{if} (.not. segment%on\_pe) cycle
112 
113     segment%normal\_vel\_bt(:,:) = g%US%m\_s\_to\_L\_T*my\_flux/total\_area
114     segment%eta(:,:) = cff
115 
116 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end segment loop}
117 
\end{DoxyCode}
