\hypertarget{namespaceboundary__impulse__tracer}{}\section{boundary\+\_\+impulse\+\_\+tracer Module Reference}
\label{namespaceboundary__impulse__tracer}\index{boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}}


\subsection{Detailed Description}
Implements a boundary impulse response tracer to calculate Green\textquotesingle{}s functions. 

\hypertarget{namespaceboundary__impulse__tracer_section_BIT_desc}{}\subsection{Boundary Impulse Response Tracer and Transit Time Distributions}\label{namespaceboundary__impulse__tracer_section_BIT_desc}
Transit time distributions (T\+TD) are the Green\textquotesingle{}s function solution of the passive tracer equation between the oceanic surface and interior. The name derives from the idea that the \textquotesingle{}age\textquotesingle{} (e.\+g. time since last contact with the atmosphere) of a water parcel is best characterized as a distribution of ages because water parcels leaving the surface arrive at a particular interior point at different times. The more commonly used ideal age tracer is the first moment of the T\+TD, equivalently referred to as the mean age.

A boundary impulse response (B\+IR) is a passive tracer whose surface boundary condition is a rectangle function with width $\Delta t$. In the case of unsteady flow, multiple B\+I\+Rs, initiated at different times in the model can be used to infer the transit time distribution or Green\textquotesingle{}s function between the oceanic surface and interior. In the case of steady or cyclostationary flow, a single B\+IR is sufficient.

In the References section, both the theoretical discussion of T\+T\+Ds and B\+I\+Rs are listed along with modeling studies which have this used framework in scientific investigations\hypertarget{namespaceboundary__impulse__tracer_section_BIT_params}{}\subsection{Run-\/time parameters}\label{namespaceboundary__impulse__tracer_section_BIT_params}
-\/\+D\+O\+\_\+\+B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+I\+M\+P\+U\+L\+S\+E\+\_\+\+T\+R\+A\+C\+ER\+: Enables the boundary impulse tracer model -\/\+I\+M\+P\+U\+L\+S\+E\+\_\+\+S\+O\+U\+R\+C\+E\+\_\+\+T\+I\+ME\+: Length of time that the surface layer acts as a source of the B\+IR tracer\hypertarget{namespaceboundary__impulse__tracer_section_BIT_refs}{}\subsection{References}\label{namespaceboundary__impulse__tracer_section_BIT_refs}
\hypertarget{namespaceboundary__impulse__tracer_TTD}{}\subsubsection{and B\+I\+R Theory}\label{namespaceboundary__impulse__tracer_TTD}
-\/\+Holzer, M., and T.\+M. Hall, 2000\+: Transit-\/time and tracer-\/age distributions in geophysical flows. J. Atmos. Sci., 57, 3539-\/3558, doi\+:10.\+1175/1520-\/0469(2000)057$<$3539\+:T\+T\+A\+T\+AD$>$2.\+0.\+CO;2. -\/\+T.\+W.\+N. Haine, H. Zhang, D.\+W. Waugh, M. Holzer, On transit-\/time distributions in unsteady circulation models, Ocean Modelling, Volume 21, Issues 1–2, 2008, Pages 35-\/45, I\+S\+SN 1463-\/5003 \href{http://dx.doi.org/10.1016/j.ocemod.2007.11.004}{\tt http\+://dx.\+doi.\+org/10.\+1016/j.\+ocemod.\+2007.\+11.\+004}. \hypertarget{namespaceboundary__impulse__tracer_section_BIT_apps}{}\subsubsection{Modelling applications}\label{namespaceboundary__impulse__tracer_section_BIT_apps}
-\/\+Peacock, S., and M. Maltrud (2006), Transit-\/time distributions in a global ocean model, J. Phys. Oceanogr., 36(3), 474–495, doi\+:10.\+1175/\+J\+P\+O2860.1. -\/\+Maltrud, M., Bryan, F. \& Peacock, Boundary impulse response functions in a century-\/long eddying global ocean simulation, S. Environ Fluid Mech (2010) 10\+: 275. doi\+:10.\+1007/s10652-\/009-\/9154-\/3 \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structboundary__impulse__tracer_1_1boundary__impulse__tracer__cs}{boundary\+\_\+impulse\+\_\+tracer\+\_\+cs}
\begin{DoxyCompactList}\small\item\em The control structure for the boundary impulse tracer package. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \hyperlink{namespaceboundary__impulse__tracer_a8c333281de8a3f7a255a0da4187427ad}{register\+\_\+boundary\+\_\+impulse\+\_\+tracer} (HI, GV, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Read in runtime options and add boundary impulse tracer to tracer registry. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceboundary__impulse__tracer_a8e0ee5617450d93cd6bc5ac33298b4d2}{initialize\+\_\+boundary\+\_\+impulse\+\_\+tracer} (restart, day, G, GV, h, diag, O\+BC, CS, sponge\+\_\+\+C\+Sp, tv)
\begin{DoxyCompactList}\small\item\em Initialize tracer from restart or set to 1 at surface to initialize. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceboundary__impulse__tracer_ae5c5e088ee2daf72dfec738fb0d6e1a6}{boundary\+\_\+impulse\+\_\+tracer\+\_\+column\+\_\+physics} (h\+\_\+old, h\+\_\+new, ea, eb, fluxes, dt, G, GV, US, CS, tv, debug, evap\+\_\+\+C\+F\+L\+\_\+limit, minimum\+\_\+forcing\+\_\+depth)
\begin{DoxyCompactList}\small\item\em Apply source or sink at boundary and do vertical diffusion. \end{DoxyCompactList}\item 
integer function, public \hyperlink{namespaceboundary__impulse__tracer_a9c170481eec5074f1a3b2b5e09a142fc}{boundary\+\_\+impulse\+\_\+stock} (h, stocks, G, GV, CS, names, units, stock\+\_\+index)
\begin{DoxyCompactList}\small\item\em Calculate total inventory of tracer. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceboundary__impulse__tracer_aaebcc49c1b19cea2f27b1a0aa2e0d510}{boundary\+\_\+impulse\+\_\+tracer\+\_\+surface\+\_\+state} (sfc\+\_\+state, h, G, CS)
\begin{DoxyCompactList}\small\item\em This subroutine extracts the surface fields from this tracer package that are to be shared with the atmosphere in coupled configurations. This particular tracer package does not report anything back to the coupler. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceboundary__impulse__tracer_a20724ec7b461ae2be28735833169a7ab}{boundary\+\_\+impulse\+\_\+tracer\+\_\+end} (CS)
\begin{DoxyCompactList}\small\item\em Performs finalization of boundary impulse tracer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceboundary__impulse__tracer_ac5642b1edb9e4ada26fb0741e77bf0b8}\label{namespaceboundary__impulse__tracer_ac5642b1edb9e4ada26fb0741e77bf0b8}} 
integer, parameter \hyperlink{namespaceboundary__impulse__tracer_ac5642b1edb9e4ada26fb0741e77bf0b8}{ntr\+\_\+max} = 1
\begin{DoxyCompactList}\small\item\em N\+T\+R\+\_\+\+M\+AX is the maximum number of tracers in this module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceboundary__impulse__tracer_a9c170481eec5074f1a3b2b5e09a142fc}\label{namespaceboundary__impulse__tracer_a9c170481eec5074f1a3b2b5e09a142fc}} 
\index{boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}!boundary\+\_\+impulse\+\_\+stock@{boundary\+\_\+impulse\+\_\+stock}}
\index{boundary\+\_\+impulse\+\_\+stock@{boundary\+\_\+impulse\+\_\+stock}!boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}}
\subsubsection{\texorpdfstring{boundary\+\_\+impulse\+\_\+stock()}{boundary\_impulse\_stock()}}
{\footnotesize\ttfamily integer function, public boundary\+\_\+impulse\+\_\+tracer\+::boundary\+\_\+impulse\+\_\+stock (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{real, dimension(\+:), intent(out)}]{stocks,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(\hyperlink{structboundary__impulse__tracer_1_1boundary__impulse__tracer__cs}{boundary\+\_\+impulse\+\_\+tracer\+\_\+cs}), pointer}]{CS,  }\item[{character(len=$\ast$), dimension(\+:), intent(out)}]{names,  }\item[{character(len=$\ast$), dimension(\+:), intent(out)}]{units,  }\item[{integer, intent(in), optional}]{stock\+\_\+index }\end{DoxyParamCaption})}



Calculate total inventory of tracer. 


\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 h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em stocks} & the mass-\/weighted integrated amount of each tracer, in kg times concentration units \mbox{[}kg conc\mbox{]}.\\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+boundary\+\_\+impulse\+\_\+tracer.\\
\hline
\mbox{\tt out}  & {\em names} & The names of the stocks calculated.\\
\hline
\mbox{\tt out}  & {\em units} & The units of the stocks calculated.\\
\hline
\mbox{\tt in}  & {\em stock\+\_\+index} & The coded index of a specific stock being sought.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return value\+: the number of stocks calculated here. 
\end{DoxyReturn}


Definition at line 287 of file boundary\+\_\+impulse\+\_\+tracer.\+F90.


\begin{DoxyCode}
287   \textcolor{keywordtype}{type}(ocean\_grid\_type),                    \textcolor{keywordtype}{intent(in   )} :: g\textcolor{comment}{    !< The ocean's grid structure}
288   \textcolor{keywordtype}{type}(verticalgrid\_type),                  \textcolor{keywordtype}{intent(in   )} :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
289   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in   )} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}
290   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},                       \textcolor{keywordtype}{intent(  out)} :: stocks\textcolor{comment}{ !< the mass-weighted integrated amount
       of each}
291 \textcolor{comment}{                                                                  !! tracer, in kg times concentration
       units [kg conc].}
292   \textcolor{keywordtype}{type}(boundary\_impulse\_tracer\_cs),         \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< The control structure returned by a
       previous}
293 \textcolor{comment}{                                                                  !! call to
       register\_boundary\_impulse\_tracer.}
294   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},           \textcolor{keywordtype}{intent(  out)} :: names\textcolor{comment}{  !< The names of the stocks calculated.}
295   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},           \textcolor{keywordtype}{intent(  out)} :: units\textcolor{comment}{  !< The units of the stocks calculated.}
296   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                        \textcolor{keywordtype}{intent(in   )} :: stock\_index\textcolor{comment}{ !< The coded index of a specific
       stock}
297 \textcolor{comment}{                                                                  !! being sought.}
298   \textcolor{keywordtype}{integer} :: boundary\_impulse\_stock\textcolor{comment}{  !< Return value: the number of stocks calculated here.}
299 
300 \textcolor{comment}{! This function calculates the mass-weighted integral of all tracer stocks,}
301 \textcolor{comment}{! returning the number of stocks it has calculated.  If the stock\_index}
302 \textcolor{comment}{! is present, only the stock corresponding to that coded index is returned.}
303 
304   \textcolor{comment}{! Local variables}
305   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m
306   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
307 
308   boundary\_impulse\_stock = 0
309   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
310   \textcolor{keywordflow}{if} (cs%ntr < 1) \textcolor{keywordflow}{return}
311 
312   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}
313     \textcolor{comment}{! Check whether this stock is available from this routine.}
314 
315     \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}
316     \textcolor{keywordflow}{return}
317 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}
318 
319   \textcolor{keywordflow}{do} m=1,1
320     \textcolor{keyword}{call }query\_vardesc(cs%tr\_desc(m), name=names(m), units=units(m), caller=\textcolor{stringliteral}{"boundary\_impulse\_stock"})
321     units(m) = trim(units(m))//\textcolor{stringliteral}{" kg"}
322     stocks(m) = 0.0
323     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
324       stocks(m) = stocks(m) + cs%tr(i,j,k,m) * &
325                            (g%mask2dT(i,j) * g%US%L\_to\_m**2*g%areaT(i,j) * h(i,j,k))
326 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
327     stocks(m) = gv%H\_to\_kg\_m2 * stocks(m)
328 \textcolor{keywordflow}{  enddo}
329 
330   boundary\_impulse\_stock = cs%ntr
331 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceboundary__impulse__tracer_ae5c5e088ee2daf72dfec738fb0d6e1a6}\label{namespaceboundary__impulse__tracer_ae5c5e088ee2daf72dfec738fb0d6e1a6}} 
\index{boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}!boundary\+\_\+impulse\+\_\+tracer\+\_\+column\+\_\+physics@{boundary\+\_\+impulse\+\_\+tracer\+\_\+column\+\_\+physics}}
\index{boundary\+\_\+impulse\+\_\+tracer\+\_\+column\+\_\+physics@{boundary\+\_\+impulse\+\_\+tracer\+\_\+column\+\_\+physics}!boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}}
\subsubsection{\texorpdfstring{boundary\+\_\+impulse\+\_\+tracer\+\_\+column\+\_\+physics()}{boundary\_impulse\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public boundary\+\_\+impulse\+\_\+tracer\+::boundary\+\_\+impulse\+\_\+tracer\+\_\+column\+\_\+physics (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h\+\_\+old,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h\+\_\+new,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{ea,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{eb,  }\item[{type(forcing), intent(in)}]{fluxes,  }\item[{real, intent(in)}]{dt,  }\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(\hyperlink{structboundary__impulse__tracer_1_1boundary__impulse__tracer__cs}{boundary\+\_\+impulse\+\_\+tracer\+\_\+cs}), pointer}]{CS,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{logical, intent(in)}]{debug,  }\item[{real, intent(in), optional}]{evap\+\_\+\+C\+F\+L\+\_\+limit,  }\item[{real, intent(in), optional}]{minimum\+\_\+forcing\+\_\+depth }\end{DoxyParamCaption})}



Apply source or sink at boundary and do vertical diffusion. 


\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 h\+\_\+old} & Layer thickness before entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em h\+\_\+new} & Layer thickness after entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em ea} & an array to which the amount of fluid entrained\\
\hline
\mbox{\tt in}  & {\em eb} & an array to which the amount of fluid entrained\\
\hline
\mbox{\tt in}  & {\em fluxes} & A structure containing pointers to thermodynamic and tracer forcing fields. Unused fields have N\+U\+LL ptrs.\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time covered by this call \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+boundary\+\_\+impulse\+\_\+tracer.\\
\hline
\mbox{\tt in}  & {\em tv} & A structure pointing to various thermodynamic variables\\
\hline
\mbox{\tt in}  & {\em debug} & If true calculate checksums\\
\hline
\mbox{\tt in}  & {\em evap\+\_\+cfl\+\_\+limit} & Limit on the fraction of the water that can be fluxed out of the top layer in a timestep \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt in}  & {\em minimum\+\_\+forcing\+\_\+depth} & The smallest depth over which fluxes can be applied \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 209 of file boundary\+\_\+impulse\+\_\+tracer.\+F90.


\begin{DoxyCode}
209   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
210   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
211   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
212                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H ~> m or kg m-2].}
213   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
214                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H ~> m or kg m-2].}
215   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
216                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}
217 \textcolor{comment}{                                              !! from the layer above during this call will be}
218 \textcolor{comment}{                                              !! added [H ~> m or kg m-2].}
219   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
220                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}
221 \textcolor{comment}{                                              !! from the layer below during this call will be}
222 \textcolor{comment}{                                              !! added [H ~> m or kg m-2].}
223   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}
224 \textcolor{comment}{                                              !! and tracer forcing fields.  Unused fields have NULL ptrs.}
225   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T ~> s]}
226   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: us\textcolor{comment}{   !< A dimensional unit scaling type}
227   \textcolor{keywordtype}{type}(boundary\_impulse\_tracer\_cs),  \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< The control structure returned by a previous}
228 \textcolor{comment}{                                              !! call to register\_boundary\_impulse\_tracer.}
229   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure pointing to various}
230 \textcolor{comment}{                                              !! thermodynamic variables}
231   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: debug\textcolor{comment}{ !< If true calculate checksums}
232   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: evap\_cfl\_limit\textcolor{comment}{ !< Limit on the fraction of the water that can}
233 \textcolor{comment}{                                              !! be fluxed out of the top layer in a timestep [nondim]}
234   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which}
235 \textcolor{comment}{                                              !! fluxes can be applied [H ~> m or kg m-2]}
236 
237 \textcolor{comment}{!   This subroutine applies diapycnal diffusion and any other column}
238 \textcolor{comment}{! tracer physics or chemistry to the tracers from this file.}
239 \textcolor{comment}{! This is a simple example of a set of advected passive tracers.}
240 
241 \textcolor{comment}{! The arguments to this subroutine are redundant in that}
242 \textcolor{comment}{!     h\_new(k) = h\_old(k) + ea(k) - eb(k-1) + eb(k) - ea(k+1)}
243 
244   \textcolor{comment}{! Local variables}
245   \textcolor{keywordtype}{real} :: isecs\_per\_year = 1.0 / (365.0*86400.0)
246   \textcolor{keywordtype}{real} :: year, h\_total, scale, htot, ih\_limit
247   \textcolor{keywordtype}{integer} :: secs, days
248   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m, k\_max
249   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}
250 
251   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
252 
253   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
254   \textcolor{keywordflow}{if} (cs%ntr < 1) \textcolor{keywordflow}{return}
255 
256   \textcolor{comment}{! This uses applyTracerBoundaryFluxesInOut, usually in ALE mode}
257   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}
258     \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
259       h\_work(i,j,k) = h\_old(i,j,k)
260 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
261     \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs%tr(:,:,:,1), dt, fluxes, h\_work, &
262                                         evap\_cfl\_limit, minimum\_forcing\_depth)
263     \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs%tr(:,:,:,1), g, gv)
264   \textcolor{keywordflow}{else}
265     \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs%tr(:,:,:,1), g, gv)
266 \textcolor{keywordflow}{  endif}
267 
268   \textcolor{comment}{! Set surface conditions}
269   \textcolor{keywordflow}{do} m=1,1
270     \textcolor{keywordflow}{if} (cs%remaining\_source\_time>0.0) \textcolor{keywordflow}{then}
271       \textcolor{keywordflow}{do} k=1,cs%nkml ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
272         cs%tr(i,j,k,m) = 1.0
273 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
274       cs%remaining\_source\_time = cs%remaining\_source\_time-us%T\_to\_s*dt
275     \textcolor{keywordflow}{else}
276       \textcolor{keywordflow}{do} k=1,cs%nkml ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
277         cs%tr(i,j,k,m) = 0.0
278 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
279 \textcolor{keywordflow}{    endif}
280 
281 \textcolor{keywordflow}{  enddo}
282 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceboundary__impulse__tracer_a20724ec7b461ae2be28735833169a7ab}\label{namespaceboundary__impulse__tracer_a20724ec7b461ae2be28735833169a7ab}} 
\index{boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}!boundary\+\_\+impulse\+\_\+tracer\+\_\+end@{boundary\+\_\+impulse\+\_\+tracer\+\_\+end}}
\index{boundary\+\_\+impulse\+\_\+tracer\+\_\+end@{boundary\+\_\+impulse\+\_\+tracer\+\_\+end}!boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}}
\subsubsection{\texorpdfstring{boundary\+\_\+impulse\+\_\+tracer\+\_\+end()}{boundary\_impulse\_tracer\_end()}}
{\footnotesize\ttfamily subroutine, public boundary\+\_\+impulse\+\_\+tracer\+::boundary\+\_\+impulse\+\_\+tracer\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structboundary__impulse__tracer_1_1boundary__impulse__tracer__cs}{boundary\+\_\+impulse\+\_\+tracer\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Performs finalization of boundary impulse tracer. 


\begin{DoxyParams}{Parameters}
{\em cs} & The control structure returned by a previous call to register\+\_\+boundary\+\_\+impulse\+\_\+tracer. \\
\hline
\end{DoxyParams}


Definition at line 369 of file boundary\+\_\+impulse\+\_\+tracer.\+F90.


\begin{DoxyCode}
369   \textcolor{keywordtype}{type}(boundary\_impulse\_tracer\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{   !< The control structure returned by a previous}
370 \textcolor{comment}{                                                    !! call to register\_boundary\_impulse\_tracer.}
371   \textcolor{keywordtype}{integer} :: m
372 
373   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
374     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tr)) \textcolor{keyword}{deallocate}(cs%tr)
375     \textcolor{keyword}{deallocate}(cs)
376 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespaceboundary__impulse__tracer_aaebcc49c1b19cea2f27b1a0aa2e0d510}\label{namespaceboundary__impulse__tracer_aaebcc49c1b19cea2f27b1a0aa2e0d510}} 
\index{boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}!boundary\+\_\+impulse\+\_\+tracer\+\_\+surface\+\_\+state@{boundary\+\_\+impulse\+\_\+tracer\+\_\+surface\+\_\+state}}
\index{boundary\+\_\+impulse\+\_\+tracer\+\_\+surface\+\_\+state@{boundary\+\_\+impulse\+\_\+tracer\+\_\+surface\+\_\+state}!boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}}
\subsubsection{\texorpdfstring{boundary\+\_\+impulse\+\_\+tracer\+\_\+surface\+\_\+state()}{boundary\_impulse\_tracer\_surface\_state()}}
{\footnotesize\ttfamily subroutine, public boundary\+\_\+impulse\+\_\+tracer\+::boundary\+\_\+impulse\+\_\+tracer\+\_\+surface\+\_\+state (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\hyperlink{structboundary__impulse__tracer_1_1boundary__impulse__tracer__cs}{boundary\+\_\+impulse\+\_\+tracer\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine extracts the surface fields from this tracer package that are to be shared with the atmosphere in coupled configurations. This particular tracer package does not report anything back to the coupler. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+boundary\+\_\+impulse\+\_\+tracer. \\
\hline
\end{DoxyParams}


Definition at line 338 of file boundary\+\_\+impulse\+\_\+tracer.\+F90.


\begin{DoxyCode}
338   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The ocean's grid structure.}
339   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
340 \textcolor{comment}{                                              !! describe the surface state of the ocean.}
341   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
342                           \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thickness [H ~> m or kg m-2].}
343   \textcolor{keywordtype}{type}(boundary\_impulse\_tracer\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< The control structure returned by a previous}
344 \textcolor{comment}{                                              !! call to register\_boundary\_impulse\_tracer.}
345 
346   \textcolor{comment}{! This particular tracer package does not report anything back to the coupler.}
347   \textcolor{comment}{! The code that is here is just a rough guide for packages that would.}
348 
349   \textcolor{keywordtype}{integer} :: m, is, ie, js, je, isd, ied, jsd, jed
350   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
351   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
352 
353   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
354 
355   \textcolor{keywordflow}{if} (cs%coupled\_tracers) \textcolor{keywordflow}{then}
356     \textcolor{keywordflow}{do} m=1,cs%ntr
357       \textcolor{comment}{!   This call loads the surface values into the appropriate array in the}
358       \textcolor{comment}{! coupler-type structure.}
359       \textcolor{keyword}{call }coupler\_type\_set\_data(cs%tr(:,:,1,m), cs%ind\_tr(m), ind\_csurf, &
360                    sfc\_state%tr\_fields, idim=(/isd, is, ie, ied/), &
361                    jdim=(/jsd, js, je, jed/) )
362 \textcolor{keywordflow}{    enddo}
363 \textcolor{keywordflow}{  endif}
364 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceboundary__impulse__tracer_a8e0ee5617450d93cd6bc5ac33298b4d2}\label{namespaceboundary__impulse__tracer_a8e0ee5617450d93cd6bc5ac33298b4d2}} 
\index{boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}!initialize\+\_\+boundary\+\_\+impulse\+\_\+tracer@{initialize\+\_\+boundary\+\_\+impulse\+\_\+tracer}}
\index{initialize\+\_\+boundary\+\_\+impulse\+\_\+tracer@{initialize\+\_\+boundary\+\_\+impulse\+\_\+tracer}!boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}}
\subsubsection{\texorpdfstring{initialize\+\_\+boundary\+\_\+impulse\+\_\+tracer()}{initialize\_boundary\_impulse\_tracer()}}
{\footnotesize\ttfamily subroutine, public boundary\+\_\+impulse\+\_\+tracer\+::initialize\+\_\+boundary\+\_\+impulse\+\_\+tracer (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{restart,  }\item[{type(time\+\_\+type), intent(in), target}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\hyperlink{structboundary__impulse__tracer_1_1boundary__impulse__tracer__cs}{boundary\+\_\+impulse\+\_\+tracer\+\_\+cs}), pointer}]{CS,  }\item[{type(sponge\+\_\+cs), pointer}]{sponge\+\_\+\+C\+Sp,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv }\end{DoxyParamCaption})}



Initialize tracer from restart or set to 1 at surface to initialize. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em restart} & .true. if the fields have already been read from a restart file.\\
\hline
\mbox{\tt in}  & {\em day} & Time of the start of the run.\\
\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 h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em diag} & A structure that is used to regulate diagnostic output.\\
\hline
 & {\em obc} & This open boundary condition type specifies whether, where, and what open boundary conditions are used.\\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+boundary\+\_\+impulse\+\_\+tracer.\\
\hline
 & {\em sponge\+\_\+csp} & Pointer to the control structure for the sponges.\\
\hline
\mbox{\tt in}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\end{DoxyParams}


Definition at line 153 of file boundary\+\_\+impulse\+\_\+tracer.\+F90.


\begin{DoxyCode}
153   \textcolor{keywordtype}{logical},                            \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}
154 \textcolor{comment}{                                                         !! been read from a restart file.}
155   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{  !< Time of the start of the run.}
156   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
157   \textcolor{keywordtype}{type}(verticalgrid\_type),            \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
158   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
159                                       \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}
160   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< A structure that is used to regulate}
161 \textcolor{comment}{                                                         !! diagnostic output.}
162   \textcolor{keywordtype}{type}(ocean\_obc\_type),               \textcolor{keywordtype}{pointer}    :: obc\textcolor{comment}{  !< This open boundary condition type specifies}
163 \textcolor{comment}{                                                         !! whether, where, and what open boundary}
164 \textcolor{comment}{                                                         !! conditions are used.}
165   \textcolor{keywordtype}{type}(boundary\_impulse\_tracer\_cs),   \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< The control structure returned by a previous}
166 \textcolor{comment}{                                                         !! call to register\_boundary\_impulse\_tracer.}
167   \textcolor{keywordtype}{type}(sponge\_cs),                    \textcolor{keywordtype}{pointer}    :: sponge\_csp\textcolor{comment}{ !< Pointer to the control structure for the
       sponges.}
168   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),              \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure pointing to various}
169 \textcolor{comment}{                                                         !! thermodynamic variables}
170   \textcolor{comment}{! Local variables}
171   \textcolor{keywordtype}{character(len=16)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}
172   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}
173   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}
174   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for age tracer fluxes, either}
175                                 \textcolor{comment}{! years m3 s-1 or years kg s-1.}
176   \textcolor{keywordtype}{logical} :: ok
177   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m
178   \textcolor{keywordtype}{integer} :: isdb, iedb, jsdb, jedb
179 
180   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
181   \textcolor{keywordflow}{if} (cs%ntr < 1) \textcolor{keywordflow}{return}
182   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
183   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
184   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
185 
186   cs%Time => day
187   cs%diag => diag
188   name = \textcolor{stringliteral}{"boundary\_impulse"}
189 
190   \textcolor{keywordflow}{do} m=1,cs%ntr
191     \textcolor{keyword}{call }query\_vardesc(cs%tr\_desc(m), name=name, caller=\textcolor{stringliteral}{"initialize\_boundary\_impulse\_tracer"})
192     \textcolor{keywordflow}{if} ((.not.restart) .or. (.not. &
193         query\_initialized(cs%tr(:,:,:,m), name, cs%restart\_CSp))) \textcolor{keywordflow}{then}
194       \textcolor{keywordflow}{do} k=1,cs%nkml ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
195         cs%tr(i,j,k,m) = 1.0
196 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
197 \textcolor{keywordflow}{    endif}
198 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! Tracer loop}
199 
200   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
201   \textcolor{comment}{! Steal from updated DOME in the fullness of time.}
202 \textcolor{keywordflow}{  endif}
203 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceboundary__impulse__tracer_a8c333281de8a3f7a255a0da4187427ad}\label{namespaceboundary__impulse__tracer_a8c333281de8a3f7a255a0da4187427ad}} 
\index{boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}!register\+\_\+boundary\+\_\+impulse\+\_\+tracer@{register\+\_\+boundary\+\_\+impulse\+\_\+tracer}}
\index{register\+\_\+boundary\+\_\+impulse\+\_\+tracer@{register\+\_\+boundary\+\_\+impulse\+\_\+tracer}!boundary\+\_\+impulse\+\_\+tracer@{boundary\+\_\+impulse\+\_\+tracer}}
\subsubsection{\texorpdfstring{register\+\_\+boundary\+\_\+impulse\+\_\+tracer()}{register\_boundary\_impulse\_tracer()}}
{\footnotesize\ttfamily logical function, public boundary\+\_\+impulse\+\_\+tracer\+::register\+\_\+boundary\+\_\+impulse\+\_\+tracer (\begin{DoxyParamCaption}\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structboundary__impulse__tracer_1_1boundary__impulse__tracer__cs}{boundary\+\_\+impulse\+\_\+tracer\+\_\+cs}), pointer}]{CS,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{tr\+\_\+\+Reg,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



Read in runtime options and add boundary impulse tracer to tracer registry. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi} & A horizontal index type structure\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+boundary\+\_\+impulse\+\_\+tracer.\\
\hline
 & {\em tr\+\_\+reg} & A pointer that is set to point to the control structure for the tracer advection and diffusion module\\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure \\
\hline
\end{DoxyParams}


Definition at line 67 of file boundary\+\_\+impulse\+\_\+tracer.\+F90.


\begin{DoxyCode}
67   \textcolor{keywordtype}{type}(hor\_index\_type),             \textcolor{keywordtype}{intent(in   )} :: hi\textcolor{comment}{   !< A horizontal index type structure}
68   \textcolor{keywordtype}{type}(verticalgrid\_type),          \textcolor{keywordtype}{intent(in   )} :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
69   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in   )} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time
       parameters}
70   \textcolor{keywordtype}{type}(boundary\_impulse\_tracer\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< The control structure returned by a previous}
71 \textcolor{comment}{                                                          !! call to register\_boundary\_impulse\_tracer.}
72   \textcolor{keywordtype}{type}(tracer\_registry\_type),       \textcolor{keywordtype}{pointer}       :: tr\_reg\textcolor{comment}{ !< A pointer that is set to point to the
       control}
73 \textcolor{comment}{                                                          !! structure for the tracer advection and}
74 \textcolor{comment}{                                                          !! diffusion module}
75   \textcolor{keywordtype}{type}(mom\_restart\_cs),             \textcolor{keywordtype}{pointer}       :: restart\_cs\textcolor{comment}{ !< A pointer to the restart control
       structure}
76 
77   \textcolor{comment}{! Local variables}
78   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"boundary\_impulse\_tracer"} \textcolor{comment}{! This module's name.}
79   \textcolor{keywordtype}{character(len=200)} :: inputdir \textcolor{comment}{! The directory where the input files are.}
80   \textcolor{keywordtype}{character(len=48)}  :: var\_name \textcolor{comment}{! The variable's name.}
81   \textcolor{keywordtype}{character(len=3)}   :: name\_tag \textcolor{comment}{! String for creating identifying boundary\_impulse}
82   \textcolor{keywordtype}{character(len=48)}  :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}
83                             \textcolor{comment}{! kg(tracer) kg(water)-1 m3 s-1 or kg(tracer) s-1.}
84   \textcolor{comment}{! This include declares and sets the variable "version".}
85 \textcolor{preprocessor}{#include "version\_variable.h"}
86 \textcolor{preprocessor}{}  \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()
87   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: rem\_time\_ptr => null()
88   \textcolor{keywordtype}{logical} :: register\_boundary\_impulse\_tracer
89   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m, i, j
90   isd = hi%isd ; ied = hi%ied ; jsd = hi%jsd ; jed = hi%jed ; nz = gv%ke
91 
92   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
93     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_boundary\_impulse\_tracer called with an "}// &
94                              \textcolor{stringliteral}{"associated control structure."})
95     \textcolor{keywordflow}{return}
96 \textcolor{keywordflow}{  endif}
97   \textcolor{keyword}{allocate}(cs)
98 
99   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
100   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
101   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"IMPULSE\_SOURCE\_TIME"}, cs%remaining\_source\_time, &
102                  \textcolor{stringliteral}{"Length of time for the boundary tracer to be injected "}//&
103                  \textcolor{stringliteral}{"into the mixed layer. After this time has elapsed, the "}//&
104                  \textcolor{stringliteral}{"surface becomes a sink for the boundary impulse tracer."}, &
105                  default=31536000.0)
106   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TRACERS\_MAY\_REINIT"}, cs%tracers\_may\_reinit, &
107                  \textcolor{stringliteral}{"If true, tracers may go through the initialization code "}//&
108                  \textcolor{stringliteral}{"if they are not found in the restart files.  Otherwise "}//&
109                  \textcolor{stringliteral}{"it is a fatal error if the tracers are not found in the "}//&
110                  \textcolor{stringliteral}{"restart files of a restarted run."}, default=.false.)
111   cs%ntr = ntr\_max
112   \textcolor{keyword}{allocate}(cs%tr(isd:ied,jsd:jed,nz,cs%ntr)) ; cs%tr(:,:,:,:) = 0.0
113 
114   cs%nkml = max(gv%nkml,1)
115 
116   \textcolor{keywordflow}{do} m=1,cs%ntr
117     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration}
118     \textcolor{comment}{! calls.  Curses on the designers and implementers of Fortran90.}
119     cs%tr\_desc(m) = var\_desc(trim(\textcolor{stringliteral}{"boundary\_impulse"}), \textcolor{stringliteral}{"kg kg-1"}, &
120         \textcolor{stringliteral}{"Boundary impulse tracer"}, caller=mdl)
121     \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then} ; flux\_units = \textcolor{stringliteral}{"kg kg-1 m3 s-1"}
122     \textcolor{keywordflow}{else} ; flux\_units = \textcolor{stringliteral}{"kg s-1"} ;\textcolor{keywordflow}{ endif}
123 
124     tr\_ptr => cs%tr(:,:,:,m)
125     \textcolor{keyword}{call }query\_vardesc(cs%tr\_desc(m), name=var\_name, caller=\textcolor{stringliteral}{"register\_boundary\_impulse\_tracer"})
126     \textcolor{comment}{! Register the tracer for horizontal advection, diffusion, and restarts.}
127     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, tr\_desc=cs%tr\_desc(m), &
128                          registry\_diags=.true., flux\_units=flux\_units, &
129                          restart\_cs=restart\_cs, mandatory=.not.cs%tracers\_may\_reinit)
130 
131     \textcolor{comment}{!   Set coupled\_tracers to be true (hard-coded above) to provide the surface}
132     \textcolor{comment}{! values to the coupler (if any).  This is meta-code and its arguments will}
133     \textcolor{comment}{! currently (deliberately) give fatal errors if it is used.}
134     \textcolor{keywordflow}{if} (cs%coupled\_tracers) &
135       cs%ind\_tr(m) = aof\_set\_coupler\_flux(trim(var\_name)//\textcolor{stringliteral}{'\_flux'}, &
136           flux\_type=\textcolor{stringliteral}{' '}, implementation=\textcolor{stringliteral}{' '}, caller=\textcolor{stringliteral}{"register\_boundary\_impulse\_tracer"})
137 \textcolor{keywordflow}{  enddo}
138   \textcolor{comment}{! Register remaining source time as a restart field}
139   rem\_time\_ptr => cs%remaining\_source\_time
140   \textcolor{keyword}{call }register\_restart\_field(rem\_time\_ptr, \textcolor{stringliteral}{"bir\_remain\_time"}, &
141                               .not.cs%tracers\_may\_reinit, restart\_cs, &
142                               \textcolor{stringliteral}{"Remaining time to apply BIR source"}, \textcolor{stringliteral}{"s"})
143 
144   cs%tr\_Reg => tr\_reg
145   cs%restart\_CSp => restart\_cs
146   register\_boundary\_impulse\_tracer = .true.
147 
\end{DoxyCode}
