\hypertarget{namespacebfb__initialization}{}\section{bfb\+\_\+initialization Module Reference}
\label{namespacebfb__initialization}\index{bfb\+\_\+initialization@{bfb\+\_\+initialization}}


\subsection{Detailed Description}
Initialization of the boundary-\/forced-\/basing configuration. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacebfb__initialization_a4c4812e80bffdd0501b93c123503d913}{bfb\+\_\+set\+\_\+coord}} (Rlay, g\+\_\+prime, GV, US, param\+\_\+file, eqn\+\_\+of\+\_\+state)
\begin{DoxyCompactList}\small\item\em This subroutine specifies the vertical coordinate in terms of temperature at the surface and at the bottom. This case is set up in such a way that the temperature of the topmost layer is equal to the S\+ST at the southern edge of the domain. The temperatures are then converted to densities of the top and bottom layers and linearly interpolated for the intermediate layers. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacebfb__initialization_af1bf4c8e60817f03359d3fd31aab5a90}{bfb\+\_\+initialize\+\_\+sponges\+\_\+southonly}} (G, GV, US, use\+\_\+temperature, tv, param\+\_\+file, C\+Sp, h)
\begin{DoxyCompactList}\small\item\em This subroutine sets up the sponges for the southern bouundary of the domain. Maximum damping occurs within 2 degrees lat of the boundary. The damping linearly decreases northward over the next 2 degrees. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacebfb__initialization_acf4641a95e7aa3b9953db2b04a627c97}{write\+\_\+bfb\+\_\+log}} (param\+\_\+file)
\begin{DoxyCompactList}\small\item\em Write output about the parameter values being used. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
logical \mbox{\hyperlink{namespacebfb__initialization_a8e08501c7f85819406ff2e7f5cc6bb6b}{first\+\_\+call}} = .true.
\begin{DoxyCompactList}\small\item\em Unsafe model variable. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacebfb__initialization_af1bf4c8e60817f03359d3fd31aab5a90}\label{namespacebfb__initialization_af1bf4c8e60817f03359d3fd31aab5a90}} 
\index{bfb\+\_\+initialization@{bfb\+\_\+initialization}!bfb\+\_\+initialize\+\_\+sponges\+\_\+southonly@{bfb\+\_\+initialize\+\_\+sponges\+\_\+southonly}}
\index{bfb\+\_\+initialize\+\_\+sponges\+\_\+southonly@{bfb\+\_\+initialize\+\_\+sponges\+\_\+southonly}!bfb\+\_\+initialization@{bfb\+\_\+initialization}}
\subsubsection{\texorpdfstring{bfb\+\_\+initialize\+\_\+sponges\+\_\+southonly()}{bfb\_initialize\_sponges\_southonly()}}
{\footnotesize\ttfamily subroutine, public bfb\+\_\+initialization\+::bfb\+\_\+initialize\+\_\+sponges\+\_\+southonly (\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[{logical, intent(in)}]{use\+\_\+temperature,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(sponge\+\_\+cs), pointer}]{C\+Sp,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{h }\end{DoxyParamCaption})}



This subroutine sets up the sponges for the southern bouundary of the domain. Maximum damping occurs within 2 degrees lat of the boundary. The damping linearly decreases northward over the next 2 degrees. 


\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 use\+\_\+temperature} & If true, temperature and salinity are used as state variables.\\
\hline
\mbox{\tt in}  & {\em tv} & A structure pointing to various thermodynamic variables\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
 & {\em csp} & A pointer to the sponge control structure\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 80 of file B\+F\+B\+\_\+initialization.\+F90.


\begin{DoxyCode}
80   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< The ocean's grid structure}
81   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< The ocean's vertical grid structure.}
82   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
83   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: use\_temperature\textcolor{comment}{ !< If true, temperature and salinity are used as}
84 \textcolor{comment}{                                            !! state variables.}
85   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic variables}
86   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
87   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}    :: CSp\textcolor{comment}{  !< A pointer to the sponge control structure}
88   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
89                            \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}
90 
91   \textcolor{comment}{! Local variables}
92   \textcolor{keywordtype}{real} :: eta(SZI\_(G),SZJ\_(G),SZK\_(GV)+1) \textcolor{comment}{! A temporary array for eta, in depth units [Z ~> m].}
93   \textcolor{keywordtype}{real} :: Idamp(SZI\_(G),SZJ\_(G))    \textcolor{comment}{! The inverse damping rate [T-1 ~> s-1].}
94   \textcolor{keywordtype}{real} :: H0(SZK\_(GV))              \textcolor{comment}{! Resting layer thicknesses in depth units [Z ~> m].}
95   \textcolor{keywordtype}{real} :: min\_depth                 \textcolor{comment}{! The minimum ocean depth in depth units [Z ~> m].}
96   \textcolor{keywordtype}{real} :: slat, wlon, lenlat, lenlon, nlat
97   \textcolor{keywordtype}{real} :: max\_damping               \textcolor{comment}{! The maximum damping rate [T-1 ~> s-1]}
98   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"BFB\_initialize\_sponges\_southonly"} \textcolor{comment}{! This subroutine's name.}
99   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz
100 
101   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
102   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
103 
104   eta(:,:,:) = 0.0 ; idamp(:,:) = 0.0
105 
106 \textcolor{comment}{!  Here the inverse damping time [T-1 ~> s-1], is set. Set Idamp to 0}
107 \textcolor{comment}{!  wherever there is no sponge, and the subroutines that are called}
108 \textcolor{comment}{!  will automatically set up the sponges only where Idamp is positive}
109 \textcolor{comment}{!  and mask2dT is 1.}
110 
111 \textcolor{comment}{!   Set up sponges for DOME configuration}
112   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, min\_depth, &
113                  \textcolor{stringliteral}{"The minimum depth of the ocean."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us%m\_to\_Z)
114 
115   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SOUTHLAT"}, slat, &
116                  \textcolor{stringliteral}{"The southern latitude of the domain."}, units=\textcolor{stringliteral}{"degrees"})
117   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENLAT"}, lenlat, &
118                  \textcolor{stringliteral}{"The latitudinal length of the domain."}, units=\textcolor{stringliteral}{"degrees"})
119   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WESTLON"}, wlon, &
120                  \textcolor{stringliteral}{"The western longitude of the domain."}, units=\textcolor{stringliteral}{"degrees"}, default=0.0)
121   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENLON"}, lenlon, &
122                  \textcolor{stringliteral}{"The longitudinal length of the domain."}, units=\textcolor{stringliteral}{"degrees"})
123   nlat = slat + lenlat
124   \textcolor{keywordflow}{do} k=1,nz ; h0(k) = -g%max\_depth * \textcolor{keywordtype}{real(k-1)} / \textcolor{keywordtype}{real(nz)} ; enddo
125 
126   \textcolor{comment}{! Use for meridional thickness profile initialization}
127 \textcolor{comment}{!  do k=1,nz ; H0(k) = -G%max\_depth * real(k-1) / real(nz-1) ; enddo}
128 
129   max\_damping = 1.0  / (86400.0*us%s\_to\_T)
130 
131   \textcolor{keywordflow}{do} i=is,ie; \textcolor{keywordflow}{do} j=js,je
132     \textcolor{keywordflow}{if} (g%bathyT(i,j) <= min\_depth) \textcolor{keywordflow}{then} ; idamp(i,j) = 0.0
133     \textcolor{keywordflow}{elseif} (g%geoLatT(i,j) < slat+2.0) \textcolor{keywordflow}{then} ; idamp(i,j) = max\_damping
134     \textcolor{keywordflow}{elseif} (g%geoLatT(i,j) < slat+4.0) \textcolor{keywordflow}{then}
135       idamp(i,j) = max\_damping * (slat+4.0-g%geoLatT(i,j))/2.0
136     \textcolor{keywordflow}{else} ; idamp(i,j) = 0.0
137 \textcolor{keywordflow}{    endif}
138 
139     \textcolor{comment}{! These will be streched inside of apply\_sponge, so they can be in}
140     \textcolor{comment}{! depth space for Boussinesq or non-Boussinesq models.}
141 
142     \textcolor{comment}{! This section is used for uniform thickness initialization}
143     \textcolor{keywordflow}{do} k = 1,nz; eta(i,j,k) = h0(k);\textcolor{keywordflow}{ enddo}
144 
145     \textcolor{comment}{! The below section is used for meridional temperature profile thickness initiation}
146     \textcolor{comment}{! do k = 1,nz; eta(i,j,k) = H0(k); enddo}
147     \textcolor{comment}{! if (G%geoLatT(i,j) > 40.0) then}
148     \textcolor{comment}{!   do k = 1,nz}
149     \textcolor{comment}{!     eta(i,j,k) = -G%Angstrom\_Z*(k-1)}
150     \textcolor{comment}{!   enddo}
151     \textcolor{comment}{! elseif (G%geoLatT(i,j) > 20.0) then}
152     \textcolor{comment}{!   do k = 1,nz}
153     \textcolor{comment}{!     eta(i,j,k) = min(H0(k) + (G%geoLatT(i,j) - 20.0)*(G%max\_depth - nz*G%Angstrom\_Z)/20.0, &}
154     \textcolor{comment}{!                      -(k-1)*G%Angstrom\_Z)}
155     \textcolor{comment}{!   enddo}
156     \textcolor{comment}{! endif}
157     eta(i,j,nz+1) = -g%max\_depth
158 
159 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
160 
161 \textcolor{comment}{!  This call sets up the damping rates and interface heights.}
162 \textcolor{comment}{!  This sets the inverse damping timescale fields in the sponges.    !}
163   \textcolor{keyword}{call }initialize\_sponge(idamp, eta, g, param\_file, csp, gv)
164 
165 \textcolor{comment}{!   Now register all of the fields which are damped in the sponge.   !}
166 \textcolor{comment}{! By default, momentum is advected vertically within the sponge, but !}
167 \textcolor{comment}{! momentum is typically not damped within the sponge.                !}
168 
169   \textcolor{keywordflow}{if} (first\_call) \textcolor{keyword}{call }write\_bfb\_log(param\_file)
170 
\end{DoxyCode}
\mbox{\Hypertarget{namespacebfb__initialization_a4c4812e80bffdd0501b93c123503d913}\label{namespacebfb__initialization_a4c4812e80bffdd0501b93c123503d913}} 
\index{bfb\+\_\+initialization@{bfb\+\_\+initialization}!bfb\+\_\+set\+\_\+coord@{bfb\+\_\+set\+\_\+coord}}
\index{bfb\+\_\+set\+\_\+coord@{bfb\+\_\+set\+\_\+coord}!bfb\+\_\+initialization@{bfb\+\_\+initialization}}
\subsubsection{\texorpdfstring{bfb\+\_\+set\+\_\+coord()}{bfb\_set\_coord()}}
{\footnotesize\ttfamily subroutine, public bfb\+\_\+initialization\+::bfb\+\_\+set\+\_\+coord (\begin{DoxyParamCaption}\item[{real, dimension(gv\%ke), intent(out)}]{Rlay,  }\item[{real, dimension(gv\%ke+1), intent(out)}]{g\+\_\+prime,  }\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(eos\+\_\+type), pointer}]{eqn\+\_\+of\+\_\+state }\end{DoxyParamCaption})}



This subroutine specifies the vertical coordinate in terms of temperature at the surface and at the bottom. This case is set up in such a way that the temperature of the topmost layer is equal to the S\+ST at the southern edge of the domain. The temperatures are then converted to densities of the top and bottom layers and linearly interpolated for the intermediate layers. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt out}  & {\em rlay} & Layer potential density \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em g\+\_\+prime} & The reduced gravity at each interface \mbox{[}L2 Z-\/1 T-\/2 $\sim$$>$ m s-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
 & {\em eqn\+\_\+of\+\_\+state} & Equation of state structure \\
\hline
\end{DoxyParams}


Definition at line 39 of file B\+F\+B\+\_\+initialization.\+F90.


\begin{DoxyCode}
39   \textcolor{keywordtype}{type}(verticalGrid\_type),  \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{      !< The ocean's vertical grid structure}
40   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke)},   \textcolor{keywordtype}{intent(out)} :: Rlay\textcolor{comment}{    !< Layer potential density [R ~> kg m-3].}
41   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke+1)}, \textcolor{keywordtype}{intent(out)} :: g\_prime\textcolor{comment}{ !< The reduced gravity at each}
42 \textcolor{comment}{                                                   !! interface [L2 Z-1 T-2 ~> m s-2].}
43   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{      !< A dimensional unit scaling type}
44   \textcolor{keywordtype}{type}(param\_file\_type),    \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
45   \textcolor{keywordtype}{type}(EOS\_type),           \textcolor{keywordtype}{pointer}     :: eqn\_of\_state\textcolor{comment}{ !< Equation of state structure}
46   \textcolor{comment}{! Local variables}
47   \textcolor{keywordtype}{real}                                 :: drho\_dt, SST\_s, T\_bot, rho\_top, rho\_bot
48   \textcolor{keywordtype}{integer}                              :: k, nz
49   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"BFB\_set\_coord"} \textcolor{comment}{! This subroutine's name.}
50 
51   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DRHO\_DT"}, drho\_dt, &
52           \textcolor{stringliteral}{"Rate of change of density with temperature."}, &
53            units=\textcolor{stringliteral}{"kg m-3 K-1"}, default=-0.2, scale=us%kg\_m3\_to\_R)
54   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SST\_S"}, sst\_s, &
55           \textcolor{stringliteral}{"SST at the suothern edge of the domain."}, units=\textcolor{stringliteral}{"C"}, default=20.0)
56   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"T\_BOT"}, t\_bot, &
57                  \textcolor{stringliteral}{"Bottom Temp"}, units=\textcolor{stringliteral}{"C"}, default=5.0)
58   rho\_top = gv%Rho0 + drho\_dt*sst\_s
59   rho\_bot = gv%Rho0 + drho\_dt*t\_bot
60   nz = gv%ke
61 
62   \textcolor{keywordflow}{do} k = 1,nz
63     rlay(k) = (rho\_bot - rho\_top)/(nz-1)*\textcolor{keywordtype}{real(k-1)} + rho\_top
64     \textcolor{keywordflow}{if} (k >1) \textcolor{keywordflow}{then}
65       g\_prime(k) = (rlay(k) - rlay(k-1)) * gv%g\_Earth / (gv%Rho0)
66     \textcolor{keywordflow}{else}
67       g\_prime(k) = gv%g\_Earth
68 \textcolor{keywordflow}{    endif}
69     \textcolor{comment}{!Rlay(:) = 0.0}
70     \textcolor{comment}{!g\_prime(:) = 0.0}
71 \textcolor{keywordflow}{  enddo}
72 
73   \textcolor{keywordflow}{if} (first\_call) \textcolor{keyword}{call }write\_bfb\_log(param\_file)
74 
\end{DoxyCode}
\mbox{\Hypertarget{namespacebfb__initialization_acf4641a95e7aa3b9953db2b04a627c97}\label{namespacebfb__initialization_acf4641a95e7aa3b9953db2b04a627c97}} 
\index{bfb\+\_\+initialization@{bfb\+\_\+initialization}!write\+\_\+bfb\+\_\+log@{write\+\_\+bfb\+\_\+log}}
\index{write\+\_\+bfb\+\_\+log@{write\+\_\+bfb\+\_\+log}!bfb\+\_\+initialization@{bfb\+\_\+initialization}}
\subsubsection{\texorpdfstring{write\+\_\+bfb\+\_\+log()}{write\_bfb\_log()}}
{\footnotesize\ttfamily subroutine bfb\+\_\+initialization\+::write\+\_\+bfb\+\_\+log (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write output about the parameter values being used. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
\end{DoxyParams}


Definition at line 175 of file B\+F\+B\+\_\+initialization.\+F90.


\begin{DoxyCode}
175   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure indicating the}
176 \textcolor{comment}{                                                  !! open file to parse for model}
177 \textcolor{comment}{                                                  !! parameter values.}
178 
179 \textcolor{comment}{! This include declares and sets the variable "version".}
180 \textcolor{preprocessor}{#include "version\_variable.h"}
181 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"BFB\_initialization"} \textcolor{comment}{! This module's name.}
182 
183   \textcolor{keyword}{call }log\_version(param\_file, mdl, version)
184   first\_call = .false.
185 
\end{DoxyCode}


\subsection{Variable Documentation}
\mbox{\Hypertarget{namespacebfb__initialization_a8e08501c7f85819406ff2e7f5cc6bb6b}\label{namespacebfb__initialization_a8e08501c7f85819406ff2e7f5cc6bb6b}} 
\index{bfb\+\_\+initialization@{bfb\+\_\+initialization}!first\+\_\+call@{first\+\_\+call}}
\index{first\+\_\+call@{first\+\_\+call}!bfb\+\_\+initialization@{bfb\+\_\+initialization}}
\subsubsection{\texorpdfstring{first\+\_\+call}{first\_call}}
{\footnotesize\ttfamily logical bfb\+\_\+initialization\+::first\+\_\+call = .true.\hspace{0.3cm}{\ttfamily [private]}}



Unsafe model variable. 

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000009}{Todo}}]Remove this module variable \end{DoxyRefDesc}


Definition at line 30 of file B\+F\+B\+\_\+initialization.\+F90.


\begin{DoxyCode}
30 \textcolor{keywordtype}{logical} :: first\_call = .true.
\end{DoxyCode}
