\hypertarget{namespacedome__initialization}{}\section{dome\+\_\+initialization Module Reference}
\label{namespacedome__initialization}\index{dome\+\_\+initialization@{dome\+\_\+initialization}}


\subsection{Detailed Description}
Configures the model for the \char`\"{}\+D\+O\+M\+E\char`\"{} experiment. D\+O\+ME = Dynamics of Overflows and Mixing Experiment. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacedome__initialization_a80775c1d93b437bb2cc4c75c3c99ecb4}{dome\+\_\+initialize\+\_\+topography}} (D, G, param\+\_\+file, max\+\_\+depth, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets up the D\+O\+ME topography. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedome__initialization_a1b4bfeba991ebd8b460ae6b6a998320d}{dome\+\_\+initialize\+\_\+thickness}} (h, G, GV, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em This subroutine initializes layer thicknesses for the D\+O\+ME experiment. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedome__initialization_a41b5a1805fffbbcbdce1ac7bfc7623f1}{dome\+\_\+initialize\+\_\+sponges}} (G, GV, US, tv, PF, C\+Sp)
\begin{DoxyCompactList}\small\item\em This subroutine sets the inverse restoration time (Idamp), and ! the values towards which the interface heights and an arbitrary ! number of tracers should be restored within each sponge. The ! interface height is always subject to damping, and must always be ! the first registered field. ! \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedome__initialization_a7f1f259541709210b38665ea779e623c}{dome\+\_\+set\+\_\+obc\+\_\+data}} (O\+BC, tv, G, GV, US, param\+\_\+file, tr\+\_\+\+Reg)
\begin{DoxyCompactList}\small\item\em This subroutine sets the properties of flow at open boundary conditions. This particular example is for the D\+O\+ME inflow describe in Legg et al. 2006. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacedome__initialization_a41b5a1805fffbbcbdce1ac7bfc7623f1}\label{namespacedome__initialization_a41b5a1805fffbbcbdce1ac7bfc7623f1}} 
\index{dome\+\_\+initialization@{dome\+\_\+initialization}!dome\+\_\+initialize\+\_\+sponges@{dome\+\_\+initialize\+\_\+sponges}}
\index{dome\+\_\+initialize\+\_\+sponges@{dome\+\_\+initialize\+\_\+sponges}!dome\+\_\+initialization@{dome\+\_\+initialization}}
\subsubsection{\texorpdfstring{dome\+\_\+initialize\+\_\+sponges()}{dome\_initialize\_sponges()}}
{\footnotesize\ttfamily subroutine, public dome\+\_\+initialization\+::dome\+\_\+initialize\+\_\+sponges (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF,  }\item[{type(sponge\+\_\+cs), pointer}]{C\+Sp }\end{DoxyParamCaption})}



This subroutine sets the inverse restoration time (Idamp), and ! the values towards which the interface heights and an arbitrary ! number of tracers should be restored within each sponge. The ! interface height is always subject to damping, and must always be ! the first registered field. ! 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em tv} & A structure containing pointers to any available thermodynamic fields, including potential temperature and salinity or mixed layer density. Absent fields have N\+U\+LL ptrs.\\
\hline
\mbox{\tt in}  & {\em pf} & A structure indicating the open file to parse for model parameter values.\\
\hline
 & {\em csp} & A pointer that is set to point to the control structure for this module. \\
\hline
\end{DoxyParams}


Definition at line 149 of file D\+O\+M\+E\+\_\+initialization.\+F90.


\begin{DoxyCode}
149   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure.}
150   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< The ocean's vertical grid structure.}
151   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
152   \textcolor{keywordtype}{type}(thermo\_var\_ptrs), \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure containing pointers to any available}
153 \textcolor{comment}{                               !! thermodynamic fields, including potential temperature and}
154 \textcolor{comment}{                               !! salinity or mixed layer density. Absent fields have NULL ptrs.}
155   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: PF\textcolor{comment}{   !< A structure indicating the open file to}
156 \textcolor{comment}{                                            !! parse for model parameter values.}
157   \textcolor{keywordtype}{type}(sponge\_CS),       \textcolor{keywordtype}{pointer}    :: CSp\textcolor{comment}{  !< A pointer that is set to point to the control}
158 \textcolor{comment}{                                            !! structure for this module.}
159 
160   \textcolor{keywordtype}{real} :: eta(SZI\_(G),SZJ\_(G),SZK\_(G)+1) \textcolor{comment}{! A temporary array for eta [Z ~> m].}
161   \textcolor{keywordtype}{real} :: temp(SZI\_(G),SZJ\_(G),SZK\_(G))  \textcolor{comment}{! A temporary array for other variables. !}
162   \textcolor{keywordtype}{real} :: Idamp(SZI\_(G),SZJ\_(G))    \textcolor{comment}{! The inverse damping rate [T-1 ~> s-1].}
163 
164   \textcolor{keywordtype}{real} :: H0(SZK\_(G))  \textcolor{comment}{! Interface heights [Z ~> m].}
165   \textcolor{keywordtype}{real} :: min\_depth    \textcolor{comment}{! The minimum depth at which to apply damping [Z ~> m]}
166   \textcolor{keywordtype}{real} :: damp, damp\_new \textcolor{comment}{! Damping rates in the sponge [days]}
167   \textcolor{keywordtype}{real} :: e\_dense      \textcolor{comment}{! The depth of the densest interfaces [Z ~> m]}
168   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"DOME\_initialize\_sponges"} \textcolor{comment}{! This subroutine's name.}
169   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz
170 
171   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
172   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
173 
174   eta(:,:,:) = 0.0 ; temp(:,:,:) = 0.0 ; idamp(:,:) = 0.0
175 
176 \textcolor{comment}{!  Here the inverse damping time [s-1], is set. Set Idamp to 0     !}
177 \textcolor{comment}{!  wherever there is no sponge, and the subroutines that are called  !}
178 \textcolor{comment}{!  will automatically set up the sponges only where Idamp is positive!}
179 \textcolor{comment}{!  and mask2dT is 1.                                                   !}
180 
181 \textcolor{comment}{!   Set up sponges for DOME configuration}
182   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, min\_depth, &
183                  \textcolor{stringliteral}{"The minimum depth of the ocean."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us%m\_to\_Z)
184 
185   h0(1) = 0.0
186   \textcolor{keywordflow}{do} k=2,nz ; h0(k) = -(\textcolor{keywordtype}{real}(k-1)-0.5)*G%max\_depth / \textcolor{keywordtype}{real(nz-1)} ; enddo
187   \textcolor{keywordflow}{do} i=is,ie; \textcolor{keywordflow}{do} j=js,je
188     \textcolor{keywordflow}{if} (g%geoLonT(i,j) < 100.0) \textcolor{keywordflow}{then} ; damp = 10.0
189     \textcolor{keywordflow}{elseif} (g%geoLonT(i,j) < 200.0) \textcolor{keywordflow}{then}
190       damp = 10.0 * (200.0-g%geoLonT(i,j))/100.0
191     \textcolor{keywordflow}{else} ; damp=0.0
192 \textcolor{keywordflow}{    endif}
193 
194     \textcolor{keywordflow}{if} (g%geoLonT(i,j) > 1400.0) \textcolor{keywordflow}{then} ; damp\_new = 10.0
195     \textcolor{keywordflow}{elseif} (g%geoLonT(i,j) > 1300.0) \textcolor{keywordflow}{then}
196        damp\_new = 10.0 * (g%geoLonT(i,j)-1300.0)/100.0
197     \textcolor{keywordflow}{else} ; damp\_new = 0.0
198 \textcolor{keywordflow}{    endif}
199 
200     \textcolor{keywordflow}{if} (damp <= damp\_new) damp = damp\_new
201     damp = us%T\_to\_s*damp
202 
203     \textcolor{comment}{! These will be stretched inside of apply\_sponge, so they can be in}
204     \textcolor{comment}{! depth space for Boussinesq or non-Boussinesq models.}
205     eta(i,j,1) = 0.0
206     \textcolor{keywordflow}{do} k=2,nz
207 \textcolor{comment}{!     eta(i,j,K)=max(H0(k), -G%bathyT(i,j), GV%Angstrom\_Z*(nz-k+1) - G%bathyT(i,j))}
208       e\_dense = -g%bathyT(i,j)
209       \textcolor{keywordflow}{if} (e\_dense >= h0(k)) \textcolor{keywordflow}{then} ; eta(i,j,k) = e\_dense
210       \textcolor{keywordflow}{else} ; eta(i,j,k) = h0(k) ;\textcolor{keywordflow}{ endif}
211       \textcolor{keywordflow}{if} (eta(i,j,k) < gv%Angstrom\_Z*(nz-k+1) - g%bathyT(i,j)) &
212           eta(i,j,k) = gv%Angstrom\_Z*(nz-k+1) - g%bathyT(i,j)
213 \textcolor{keywordflow}{    enddo}
214     eta(i,j,nz+1) = -g%bathyT(i,j)
215 
216     \textcolor{keywordflow}{if} (g%bathyT(i,j) > min\_depth) \textcolor{keywordflow}{then}
217       idamp(i,j) = damp / 86400.0
218     \textcolor{keywordflow}{else} ; idamp(i,j) = 0.0 ;\textcolor{keywordflow}{ endif}
219 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
220 
221 \textcolor{comment}{!  This call sets up the damping rates and interface heights.}
222 \textcolor{comment}{!  This sets the inverse damping timescale fields in the sponges.    !}
223   \textcolor{keyword}{call }initialize\_sponge(idamp, eta, g, pf, csp, gv)
224 
225 \textcolor{comment}{!   Now register all of the fields which are damped in the sponge.   !}
226 \textcolor{comment}{! By default, momentum is advected vertically within the sponge, but !}
227 \textcolor{comment}{! momentum is typically not damped within the sponge.                !}
228 
229 \textcolor{comment}{! At this point, the DOME configuration is done. The following are here as a}
230 \textcolor{comment}{! template for other configurations.}
231 
232 \textcolor{comment}{!  The remaining calls to set\_up\_sponge\_field can be in any order. !}
233   \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(tv%T) ) \textcolor{keywordflow}{then}
234     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"DOME\_initialize\_sponges is not set up for use with"}//&
235                          \textcolor{stringliteral}{" a temperatures defined."})
236     \textcolor{comment}{! This should use the target values of T in temp.}
237     \textcolor{keyword}{call }set\_up\_sponge\_field(temp, tv%T, g, nz, csp)
238     \textcolor{comment}{! This should use the target values of S in temp.}
239     \textcolor{keyword}{call }set\_up\_sponge\_field(temp, tv%S, g, nz, csp)
240 \textcolor{keywordflow}{  endif}
241 
\end{DoxyCode}
\mbox{\Hypertarget{namespacedome__initialization_a1b4bfeba991ebd8b460ae6b6a998320d}\label{namespacedome__initialization_a1b4bfeba991ebd8b460ae6b6a998320d}} 
\index{dome\+\_\+initialization@{dome\+\_\+initialization}!dome\+\_\+initialize\+\_\+thickness@{dome\+\_\+initialize\+\_\+thickness}}
\index{dome\+\_\+initialize\+\_\+thickness@{dome\+\_\+initialize\+\_\+thickness}!dome\+\_\+initialization@{dome\+\_\+initialization}}
\subsubsection{\texorpdfstring{dome\+\_\+initialize\+\_\+thickness()}{dome\_initialize\_thickness()}}
{\footnotesize\ttfamily subroutine, public dome\+\_\+initialization\+::dome\+\_\+initialize\+\_\+thickness (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(out)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



This subroutine initializes layer thicknesses for the D\+O\+ME experiment. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt out}  & {\em h} & The thickness that is being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values.\\
\hline
\mbox{\tt in}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 91 of file D\+O\+M\+E\+\_\+initialization.\+F90.


\begin{DoxyCode}
91   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{           !< The ocean's grid structure.}
92   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{          !< The ocean's vertical grid structure.}
93   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
94                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{           !< The thickness that is being initialized [H ~> m or
       kg m-2].}
95   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}
96 \textcolor{comment}{                                                      !! to parse for model parameter values.}
97   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}
98 \textcolor{comment}{                                                      !! only read parameters without changing h.}
99 
100   \textcolor{keywordtype}{real} :: e0(SZK\_(GV)+1)    \textcolor{comment}{! The resting interface heights [Z ~> m], usually}
101                             \textcolor{comment}{! negative because it is positive upward [Z ~> m].}
102   \textcolor{keywordtype}{real} :: eta1D(SZK\_(GV)+1) \textcolor{comment}{! Interface height relative to the sea surface}
103                             \textcolor{comment}{! positive upward [Z ~> m].}
104   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}
105   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"DOME\_initialize\_thickness"} \textcolor{comment}{! This subroutine's name.}
106   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz
107 
108   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
109 
110   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params
111 
112   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! This subroutine has no run-time parameters.}
113 
114   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  DOME\_initialization.F90, DOME\_initialize\_thickness: setting thickness"}, 5)
115 
116   e0(1)=0.0
117   \textcolor{keywordflow}{do} k=2,nz
118     e0(k) = -g%max\_depth * (\textcolor{keywordtype}{real}(k-1)-0.5)/\textcolor{keywordtype}{real}(nz-1)
119 \textcolor{keywordflow}{  enddo}
120 
121   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
122 \textcolor{comment}{!    This sets the initial thickness (in m) of the layers.  The      !}
123 \textcolor{comment}{!  thicknesses are set to insure that: 1.  each layer is at least an !}
124 \textcolor{comment}{!  Angstrom thick, and 2.  the interfaces are where they should be   !}
125 \textcolor{comment}{!  based on the resting depths and interface height perturbations,   !}
126 \textcolor{comment}{!  as long at this doesn't interfere with 1.                         !}
127     eta1d(nz+1) = -g%bathyT(i,j)
128     \textcolor{keywordflow}{do} k=nz,1,-1
129       eta1d(k) = e0(k)
130       \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + gv%Angstrom\_Z)) \textcolor{keywordflow}{then}
131         eta1d(k) = eta1d(k+1) + gv%Angstrom\_Z
132         h(i,j,k) = gv%Angstrom\_H
133       \textcolor{keywordflow}{else}
134         h(i,j,k) = gv%Z\_to\_H * (eta1d(k) - eta1d(k+1))
135 \textcolor{keywordflow}{      endif}
136 \textcolor{keywordflow}{    enddo}
137 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
138 
\end{DoxyCode}
\mbox{\Hypertarget{namespacedome__initialization_a80775c1d93b437bb2cc4c75c3c99ecb4}\label{namespacedome__initialization_a80775c1d93b437bb2cc4c75c3c99ecb4}} 
\index{dome\+\_\+initialization@{dome\+\_\+initialization}!dome\+\_\+initialize\+\_\+topography@{dome\+\_\+initialize\+\_\+topography}}
\index{dome\+\_\+initialize\+\_\+topography@{dome\+\_\+initialize\+\_\+topography}!dome\+\_\+initialization@{dome\+\_\+initialization}}
\subsubsection{\texorpdfstring{dome\+\_\+initialize\+\_\+topography()}{dome\_initialize\_topography()}}
{\footnotesize\ttfamily subroutine, public dome\+\_\+initialization\+::dome\+\_\+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 D\+O\+ME 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 41 of file D\+O\+M\+E\+\_\+initialization.\+F90.


\begin{DoxyCode}
41   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),          \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
42   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
43                                    \textcolor{keywordtype}{intent(out)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}
44   \textcolor{keywordtype}{type}(param\_file\_type),           \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}
45   \textcolor{keywordtype}{real},                            \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{ !< Maximum model depth in the units of D}
46   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}
47 
48   \textcolor{comment}{! Local variables}
49   \textcolor{keywordtype}{real} :: m\_to\_Z  \textcolor{comment}{! A dimensional rescaling factor.}
50   \textcolor{keywordtype}{real} :: min\_depth \textcolor{comment}{! The minimum and maximum depths [Z ~> m].}
51   \textcolor{comment}{! This include declares and sets the variable "version".}
52 \textcolor{preprocessor}{# include "version\_variable.h"}
53 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"DOME\_initialize\_topography"} \textcolor{comment}{! This subroutine's name.}
54   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
55   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
56   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
57 
58   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  DOME\_initialization.F90, DOME\_initialize\_topography: setting topography"}, 5)
59 
60   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us%m\_to\_Z
61 
62   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
63   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, min\_depth, &
64                  \textcolor{stringliteral}{"The minimum depth of the ocean."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=m\_to\_z)
65 
66   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
67     \textcolor{keywordflow}{if} (g%geoLatT(i,j) < 600.0) \textcolor{keywordflow}{then}
68       \textcolor{keywordflow}{if} (g%geoLatT(i,j) < 300.0) \textcolor{keywordflow}{then}
69         d(i,j) = max\_depth
70       \textcolor{keywordflow}{else}
71         d(i,j) = max\_depth - 10.0*m\_to\_z * (g%geoLatT(i,j)-300.0)
72 \textcolor{keywordflow}{      endif}
73     \textcolor{keywordflow}{else}
74       \textcolor{keywordflow}{if} ((g%geoLonT(i,j) > 1000.0) .AND. (g%geoLonT(i,j) < 1100.0)) \textcolor{keywordflow}{then}
75         d(i,j) = 600.0*m\_to\_z
76       \textcolor{keywordflow}{else}
77         d(i,j) = 0.5*min\_depth
78 \textcolor{keywordflow}{      endif}
79 \textcolor{keywordflow}{    endif}
80 
81     \textcolor{keywordflow}{if} (d(i,j) > max\_depth) d(i,j) = max\_depth
82     \textcolor{keywordflow}{if} (d(i,j) < min\_depth) d(i,j) = 0.5*min\_depth
83 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
84 
\end{DoxyCode}
\mbox{\Hypertarget{namespacedome__initialization_a7f1f259541709210b38665ea779e623c}\label{namespacedome__initialization_a7f1f259541709210b38665ea779e623c}} 
\index{dome\+\_\+initialization@{dome\+\_\+initialization}!dome\+\_\+set\+\_\+obc\+\_\+data@{dome\+\_\+set\+\_\+obc\+\_\+data}}
\index{dome\+\_\+set\+\_\+obc\+\_\+data@{dome\+\_\+set\+\_\+obc\+\_\+data}!dome\+\_\+initialization@{dome\+\_\+initialization}}
\subsubsection{\texorpdfstring{dome\+\_\+set\+\_\+obc\+\_\+data()}{dome\_set\_obc\_data()}}
{\footnotesize\ttfamily subroutine, public dome\+\_\+initialization\+::dome\+\_\+set\+\_\+obc\+\_\+data (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{tr\+\_\+\+Reg }\end{DoxyParamCaption})}



This subroutine sets the properties of flow at open boundary conditions. This particular example is for the D\+O\+ME inflow describe in Legg et al. 2006. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & This open boundary condition type specifies whether, where, and what open boundary conditions are used.\\
\hline
\mbox{\tt in}  & {\em tv} & A structure containing pointers to any available thermodynamic fields, including potential temperature and salinity or mixed layer density. Absent fields have N\+U\+LL ptrs.\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values.\\
\hline
 & {\em tr\+\_\+reg} & Tracer registry. \\
\hline
\end{DoxyParams}


Definition at line 247 of file D\+O\+M\+E\+\_\+initialization.\+F90.


\begin{DoxyCode}
247   \textcolor{keywordtype}{type}(ocean\_OBC\_type),       \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< This open boundary condition type specifies}
248 \textcolor{comment}{                                                !! whether, where, and what open boundary}
249 \textcolor{comment}{                                                !! conditions are used.}
250   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),      \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{  !< A structure containing pointers to any}
251 \textcolor{comment}{                              !! available thermodynamic fields, including potential}
252 \textcolor{comment}{                              !! temperature and salinity or mixed layer density. Absent}
253 \textcolor{comment}{                              !! fields have NULL ptrs.}
254   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< The ocean's grid structure.}
255   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{  !< The ocean's vertical grid structure.}
256   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{  !< A dimensional unit scaling type}
257   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure indicating the open file}
258 \textcolor{comment}{                              !! to parse for model parameter values.}
259   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< Tracer registry.}
260 
261 \textcolor{comment}{! Local variables}
262   \textcolor{comment}{! The following variables are used to set the target temperature and salinity.}
263   \textcolor{keywordtype}{real} :: T0(SZK\_(G)), S0(SZK\_(G))
264   \textcolor{keywordtype}{real} :: pres(SZK\_(G))      \textcolor{comment}{! An array of the reference pressure [R L2 T-2 ~> Pa].}
265   \textcolor{keywordtype}{real} :: drho\_dT(SZK\_(G))   \textcolor{comment}{! Derivative of density with temperature [R degC-1 ~> kg m-3 degC-1].}
266   \textcolor{keywordtype}{real} :: drho\_dS(SZK\_(G))   \textcolor{comment}{! Derivative of density with salinity [R ppt-1 ~> kg m-3 ppt-1].}
267   \textcolor{keywordtype}{real} :: rho\_guess(SZK\_(G)) \textcolor{comment}{! Potential density at T0 & S0 [R ~> kg m-3].}
268   \textcolor{comment}{! The following variables are used to set up the transport in the DOME example.}
269   \textcolor{keywordtype}{real} :: tr\_0, y1, y2, tr\_k, rst, rsb, rc, v\_k, lon\_im1
270   \textcolor{keywordtype}{real} :: D\_edge            \textcolor{comment}{! The thickness [Z ~> m], of the dense fluid at the}
271                             \textcolor{comment}{! inner edge of the inflow.}
272   \textcolor{keywordtype}{real} :: g\_prime\_tot       \textcolor{comment}{! The reduced gravity across all layers [L2 Z-1 T-2 ~> m s-2].}
273   \textcolor{keywordtype}{real} :: Def\_Rad           \textcolor{comment}{! The deformation radius, based on fluid of}
274                             \textcolor{comment}{! thickness D\_edge, in the same units as lat [m].}
275   \textcolor{keywordtype}{real} :: Ri\_trans          \textcolor{comment}{! The shear Richardson number in the transition}
276                             \textcolor{comment}{! region of the specified shear profile.}
277   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"DOME\_set\_OBC\_data"} \textcolor{comment}{! This subroutine's name.}
278   \textcolor{keywordtype}{character(len=32)}  :: name
279   \textcolor{keywordtype}{integer} :: i, j, k, itt, is, ie, js, je, isd, ied, jsd, jed, m, nz, NTR
280   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB
281   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()
282   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer}      :: tr\_ptr => null()
283 
284   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
285   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
286   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
287 
288   \textcolor{comment}{! The following variables should be transformed into runtime parameters.}
289   d\_edge = 300.0*us%m\_to\_Z  \textcolor{comment}{! The thickness of dense fluid in the inflow.}
290   ri\_trans = 1.0/3.0 \textcolor{comment}{! The shear Richardson number in the transition region}
291                      \textcolor{comment}{! region of the specified shear profile.}
292 
293   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}
294 
295   g\_prime\_tot = (gv%g\_Earth / gv%Rho0) * 2.0*us%kg\_m3\_to\_R
296   def\_rad = us%L\_to\_m*sqrt(d\_edge*g\_prime\_tot) / (1.0e-4*us%T\_to\_s * 1000.0)
297   tr\_0 = (-d\_edge*sqrt(d\_edge*g\_prime\_tot)*0.5e3*us%m\_to\_L*def\_rad) * gv%Z\_to\_H
298 
299   \textcolor{keywordflow}{if} (obc%number\_of\_segments /= 1) \textcolor{keywordflow}{then}
300     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{'Error in DOME OBC segment setup'}, .true.)
301     \textcolor{keywordflow}{return}   \textcolor{comment}{!!! Need a better error message here}
302 \textcolor{keywordflow}{  endif}
303 
304   ntr = tr\_reg%NTR
305 
306   \textcolor{comment}{! Stash this information away for the messy tracer restarts.}
307   obc%ntr = ntr
308   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc%tracer\_x\_reservoirs\_used)) \textcolor{keywordflow}{then}
309     \textcolor{keyword}{allocate}(obc%tracer\_x\_reservoirs\_used(ntr))
310     \textcolor{keyword}{allocate}(obc%tracer\_y\_reservoirs\_used(ntr))
311     obc%tracer\_x\_reservoirs\_used(:) = .false.
312     obc%tracer\_y\_reservoirs\_used(:) = .false.
313     obc%tracer\_y\_reservoirs\_used(1) = .true.
314 \textcolor{keywordflow}{  endif}
315 
316   segment => obc%segment(1)
317   \textcolor{keywordflow}{if} (.not. segment%on\_pe) \textcolor{keywordflow}{return}
318 
319   \textcolor{keyword}{allocate}(segment%field(ntr))
320 
321   \textcolor{keywordflow}{do} k=1,nz
322     rst = -1.0
323     \textcolor{keywordflow}{if} (k>1) rst = -1.0 + (\textcolor{keywordtype}{real}(k-1)-0.5)/\textcolor{keywordtype}{real}(nz-1)
324 
325     rsb = 0.0
326     \textcolor{keywordflow}{if} (k<nz) rsb = -1.0 + (\textcolor{keywordtype}{real}(k-1)+0.5)/\textcolor{keywordtype}{real}(nz-1)
327     rc = -1.0 + \textcolor{keywordtype}{real}(k-1)/\textcolor{keywordtype}{real}(nz-1)
328 
329     \textcolor{comment}{! These come from assuming geostrophy and a constant Ri profile.}
330     y1 = (2.0*ri\_trans*rst + ri\_trans + 2.0)/(2.0 - ri\_trans)
331     y2 = (2.0*ri\_trans*rsb + ri\_trans + 2.0)/(2.0 - ri\_trans)
332     tr\_k = tr\_0 * (2.0/(ri\_trans*(2.0-ri\_trans))) * &
333            ((log(y1)+1.0)/y1 - (log(y2)+1.0)/y2)
334     v\_k = -sqrt(d\_edge*g\_prime\_tot)*log((2.0 + ri\_trans*(1.0 + 2.0*rc)) / &
335                                         (2.0 - ri\_trans))
336     \textcolor{keywordflow}{if} (k == nz)  tr\_k = tr\_k + tr\_0 * (2.0/(ri\_trans*(2.0+ri\_trans))) * &
337                                        log((2.0+ri\_trans)/(2.0-ri\_trans))
338     \textcolor{comment}{! New way}
339     isd = segment%HI%isd ; ied = segment%HI%ied
340     jsdb = segment%HI%JsdB ; jedb = segment%HI%JedB
341     \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
342       lon\_im1 = 2.0*g%geoLonCv(i,j) - g%geoLonBu(i,j)
343       segment%normal\_trans(i,j,k) = tr\_k * (exp(-2.0*(lon\_im1 - 1000.0)/def\_rad) -&
344                                   exp(-2.0*(g%geoLonBu(i,j) - 1000.0)/def\_rad))
345       segment%normal\_vel(i,j,k) = v\_k * exp(-2.0*(g%geoLonCv(i,j) - 1000.0)/def\_rad)
346 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
347 \textcolor{keywordflow}{  enddo}
348 
349   \textcolor{comment}{!   The inflow values of temperature and salinity also need to be set here if}
350   \textcolor{comment}{! these variables are used.  The following code is just a naive example.}
351   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%S)) \textcolor{keywordflow}{then}
352     \textcolor{comment}{! In this example, all S inflows have values of 35 psu.}
353     name = \textcolor{stringliteral}{'salt'}
354     \textcolor{keyword}{call }tracer\_name\_lookup(tr\_reg, tr\_ptr, name)
355     \textcolor{keyword}{call }register\_segment\_tracer(tr\_ptr, param\_file, gv, segment, obc\_scalar=35.0)
356 \textcolor{keywordflow}{  endif}
357   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%T)) \textcolor{keywordflow}{then}
358     \textcolor{comment}{! In this example, the T values are set to be consistent with the layer}
359     \textcolor{comment}{! target density and a salinity of 35 psu.  This code is taken from}
360     \textcolor{comment}{! USER\_initialize\_temp\_sal.}
361     pres(:) = tv%P\_Ref ; s0(:) = 35.0 ; t0(1) = 25.0
362     \textcolor{keyword}{call }calculate\_density(t0(1), s0(1), pres(1), rho\_guess(1), tv%eqn\_of\_state)
363     \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, tv%eqn\_of\_state, (/1,1/) )
364 
365     \textcolor{keywordflow}{do} k=1,nz ; t0(k) = t0(1) + (gv%Rlay(k)-rho\_guess(1)) / drho\_dt(1) ;\textcolor{keywordflow}{ enddo}
366     \textcolor{keywordflow}{do} itt=1,6
367       \textcolor{keyword}{call }calculate\_density(t0, s0, pres, rho\_guess, tv%eqn\_of\_state)
368       \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, tv%eqn\_of\_state)
369       \textcolor{keywordflow}{do} k=1,nz ; t0(k) = t0(k) + (gv%Rlay(k)-rho\_guess(k)) / drho\_dt(k) ;\textcolor{keywordflow}{ enddo}
370 \textcolor{keywordflow}{    enddo}
371 
372     \textcolor{comment}{! Temperature on tracer 1???}
373     \textcolor{keyword}{allocate}(segment%field(1)%buffer\_src(segment%HI%isd:segment%HI%ied,segment%HI%JsdB:segment%HI%JedB,nz))
374     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
375       segment%field(1)%buffer\_src(i,j,k) = t0(k)
376 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
377     name = \textcolor{stringliteral}{'temp'}
378     \textcolor{keyword}{call }tracer\_name\_lookup(tr\_reg, tr\_ptr, name)
379     \textcolor{keyword}{call }register\_segment\_tracer(tr\_ptr, param\_file, gv, segment, obc\_array=.true.)
380 \textcolor{keywordflow}{  endif}
381 
382   \textcolor{comment}{! Dye tracers - fight with T,S???}
383   \textcolor{comment}{! First dye - only one with OBC values}
384   \textcolor{comment}{! This field(1) requires tr\_D1 to be the first tracer.}
385   \textcolor{keyword}{allocate}(segment%field(1)%buffer\_src(segment%HI%isd:segment%HI%ied,segment%HI%JsdB:segment%HI%JedB,nz))
386   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment%HI%jsd,segment%HI%jed ; \textcolor{keywordflow}{do} i=segment%HI%isd,segment%HI%ied
387     \textcolor{keywordflow}{if} (k < nz/2) \textcolor{keywordflow}{then} ; segment%field(1)%buffer\_src(i,j,k) = 0.0
388     \textcolor{keywordflow}{else} ; segment%field(1)%buffer\_src(i,j,k) = 1.0 ;\textcolor{keywordflow}{ endif}
389 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
390   name = \textcolor{stringliteral}{'tr\_D1'}
391   \textcolor{keyword}{call }tracer\_name\_lookup(tr\_reg, tr\_ptr, name)
392   \textcolor{keyword}{call }register\_segment\_tracer(tr\_ptr, param\_file, gv, &
393                                obc%segment(1), obc\_array=.true.)
394 
395   \textcolor{comment}{! All tracers but the first have 0 concentration in their inflows. As this}
396   \textcolor{comment}{! is the default value, the following calls are unnecessary.}
397   \textcolor{keywordflow}{do} m=2,ntr
398     \textcolor{keywordflow}{if} (m < 10) \textcolor{keywordflow}{then} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr\_D",I1.1)'}) m
399     \textcolor{keywordflow}{else} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr\_D",I2.2)'}) m ;\textcolor{keywordflow}{ endif}
400     \textcolor{keyword}{call }tracer\_name\_lookup(tr\_reg, tr\_ptr, name)
401     \textcolor{keyword}{call }register\_segment\_tracer(tr\_ptr, param\_file, gv, &
402                                  obc%segment(1), obc\_scalar=0.0)
403 \textcolor{keywordflow}{  enddo}
404 
\end{DoxyCode}
