\hypertarget{namespaceadvection__test__tracer}{}\section{advection\+\_\+test\+\_\+tracer Module Reference}
\label{namespaceadvection__test__tracer}\index{advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}}


\subsection{Detailed Description}
This tracer package is used to test advection schemes. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structadvection__test__tracer_1_1advection__test__tracer__cs}{advection\+\_\+test\+\_\+tracer\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em The control structure for the advect\+\_\+test\+\_\+tracer module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespaceadvection__test__tracer_a6cc3e00a5d5cb9e31339c784eb966c91}{register\+\_\+advection\+\_\+test\+\_\+tracer}} (HI, GV, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Register tracer fields and subroutines to be used with M\+OM. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceadvection__test__tracer_a1d5fcff30ba8ec9f30012aa4d6cec981}{initialize\+\_\+advection\+\_\+test\+\_\+tracer}} (restart, day, G, GV, h, diag, O\+BC, CS, sponge\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initializes the N\+TR tracer fields in tr(\+:,\+:,\+:,\+:) and it sets up the tracer output. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceadvection__test__tracer_a475d1016ef9ccf0151bc3b40ccd89931}{advection\+\_\+test\+\_\+tracer\+\_\+column\+\_\+physics}} (h\+\_\+old, h\+\_\+new, ea, eb, fluxes, dt, G, GV, US, CS, evap\+\_\+\+C\+F\+L\+\_\+limit, minimum\+\_\+forcing\+\_\+depth)
\begin{DoxyCompactList}\small\item\em Applies diapycnal diffusion and any other column tracer physics or chemistry to the tracers from this package. This is a simple example of a set of advected passive tracers. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceadvection__test__tracer_a73a401f469c9cd5db07d879f149ecfe0}{advection\+\_\+test\+\_\+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 
integer function, public \mbox{\hyperlink{namespaceadvection__test__tracer_a1e3884b030df6c5107380b4ddd2fbce2}{advection\+\_\+test\+\_\+stock}} (h, stocks, G, GV, CS, names, units, stock\+\_\+index)
\begin{DoxyCompactList}\small\item\em Calculate the mass-\/weighted integral of all tracer stocks, returning the number of stocks it has calculated. If the stock\+\_\+index is present, only the stock corresponding to that coded index is returned. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceadvection__test__tracer_aba7ee03a503e5f5518cc364c223ba693}{advection\+\_\+test\+\_\+tracer\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Deallocate memory associated with this module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceadvection__test__tracer_a2b788090d4a86e77f9f18eed5c68995e}\label{namespaceadvection__test__tracer_a2b788090d4a86e77f9f18eed5c68995e}} 
integer, parameter \mbox{\hyperlink{namespaceadvection__test__tracer_a2b788090d4a86e77f9f18eed5c68995e}{ntr}} = 11
\begin{DoxyCompactList}\small\item\em The number of tracers in this module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceadvection__test__tracer_a1e3884b030df6c5107380b4ddd2fbce2}\label{namespaceadvection__test__tracer_a1e3884b030df6c5107380b4ddd2fbce2}} 
\index{advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}!advection\+\_\+test\+\_\+stock@{advection\+\_\+test\+\_\+stock}}
\index{advection\+\_\+test\+\_\+stock@{advection\+\_\+test\+\_\+stock}!advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}}
\subsubsection{\texorpdfstring{advection\+\_\+test\+\_\+stock()}{advection\_test\_stock()}}
{\footnotesize\ttfamily integer function, public advection\+\_\+test\+\_\+tracer\+::advection\+\_\+test\+\_\+stock (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), 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(\mbox{\hyperlink{structadvection__test__tracer_1_1advection__test__tracer__cs}{advection\+\_\+test\+\_\+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 the mass-\/weighted integral of all tracer stocks, returning the number of stocks it has calculated. If the stock\+\_\+index is present, only the stock corresponding to that coded index is returned. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s 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
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+advection\+\_\+test\+\_\+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}
the number of stocks calculated here. 
\end{DoxyReturn}


Definition at line 352 of file advection\+\_\+test\+\_\+tracer.\+F90.


\begin{DoxyCode}
352   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{      !< The ocean's grid structure}
353   \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]}
354   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},                 \textcolor{keywordtype}{intent(out)}   :: stocks\textcolor{comment}{ !< the mass-weighted integrated amount of
       each}
355 \textcolor{comment}{                                                              !! tracer, in kg times concentration units
       [kg conc].}
356   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{     !< The ocean's vertical grid structure}
357   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS),     \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< The control structure returned by a
       previous}
358 \textcolor{comment}{                                                              !! call to register\_advection\_test\_tracer.}
359   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< the names of the stocks calculated.}
360   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< the units of the stocks calculated.}
361   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                  \textcolor{keywordtype}{intent(in)}    :: stock\_index\textcolor{comment}{ !< the coded index of a specific stock
       being sought.}
362   \textcolor{keywordtype}{integer}                                           :: advection\_test\_stock\textcolor{comment}{ !< the number of stocks
       calculated here.}
363 
364   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m
365   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
366 
367   advection\_test\_stock = 0
368   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
369   \textcolor{keywordflow}{if} (cs%ntr < 1) \textcolor{keywordflow}{return}
370 
371   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}
372     \textcolor{comment}{! Check whether this stock is available from this routine.}
373 
374     \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}
375     \textcolor{keywordflow}{return}
376 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}
377 
378   \textcolor{keywordflow}{do} m=1,cs%ntr
379     \textcolor{keyword}{call }query\_vardesc(cs%tr\_desc(m), name=names(m), units=units(m), caller=\textcolor{stringliteral}{"advection\_test\_stock"})
380     stocks(m) = 0.0
381     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
382       stocks(m) = stocks(m) + cs%tr(i,j,k,m) * &
383                              (g%mask2dT(i,j) * g%US%L\_to\_m**2*g%areaT(i,j) * h(i,j,k))
384 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
385     stocks(m) = gv%H\_to\_kg\_m2 * stocks(m)
386 \textcolor{keywordflow}{  enddo}
387   advection\_test\_stock = cs%ntr
388 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceadvection__test__tracer_a475d1016ef9ccf0151bc3b40ccd89931}\label{namespaceadvection__test__tracer_a475d1016ef9ccf0151bc3b40ccd89931}} 
\index{advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}!advection\+\_\+test\+\_\+tracer\+\_\+column\+\_\+physics@{advection\+\_\+test\+\_\+tracer\+\_\+column\+\_\+physics}}
\index{advection\+\_\+test\+\_\+tracer\+\_\+column\+\_\+physics@{advection\+\_\+test\+\_\+tracer\+\_\+column\+\_\+physics}!advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}}
\subsubsection{\texorpdfstring{advection\+\_\+test\+\_\+tracer\+\_\+column\+\_\+physics()}{advection\_test\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public advection\+\_\+test\+\_\+tracer\+::advection\+\_\+test\+\_\+tracer\+\_\+column\+\_\+physics (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h\+\_\+old,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h\+\_\+new,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{ea,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), 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(\mbox{\hyperlink{structadvection__test__tracer_1_1advection__test__tracer__cs}{advection\+\_\+test\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{real, intent(in), optional}]{evap\+\_\+\+C\+F\+L\+\_\+limit,  }\item[{real, intent(in), optional}]{minimum\+\_\+forcing\+\_\+depth }\end{DoxyParamCaption})}



Applies diapycnal diffusion and any other column tracer physics or chemistry to the tracers from this package. This is a simple example of a set of advected passive tracers. 


\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\+\_\+advection\+\_\+test\+\_\+tracer.\\
\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 260 of file advection\+\_\+test\+\_\+tracer.\+F90.


\begin{DoxyCode}
260   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}
261   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}
262   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
263                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H ~> m or kg m-2].}
264   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
265                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H ~> m or kg m-2].}
266   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
267                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}
268 \textcolor{comment}{                                              !! from the layer above during this call will be}
269 \textcolor{comment}{                                              !! added [H ~> m or kg m-2].}
270   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
271                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}
272 \textcolor{comment}{                                              !! from the layer below during this call will be}
273 \textcolor{comment}{                                              !! added [H ~> m or kg m-2].}
274   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}
275 \textcolor{comment}{                                              !! and tracer forcing fields.  Unused fields have NULL ptrs.}
276   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T ~> s]}
277   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}
278   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}
279 \textcolor{comment}{                                              !! call to register\_advection\_test\_tracer.}
280   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: evap\_CFL\_limit\textcolor{comment}{ !< Limit on the fraction of the water that can}
281 \textcolor{comment}{                                              !! be fluxed out of the top layer in a timestep [nondim]}
282   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which}
283 \textcolor{comment}{                                              !! fluxes can be applied [H ~> m or kg m-2]}
284 \textcolor{comment}{!   This subroutine applies diapycnal diffusion and any other column}
285 \textcolor{comment}{! tracer physics or chemistry to the tracers from this file.}
286 \textcolor{comment}{! This is a simple example of a set of advected passive tracers.}
287 
288 \textcolor{comment}{! The arguments to this subroutine are redundant in that}
289 \textcolor{comment}{!     h\_new(k) = h\_old(k) + ea(k) - eb(k-1) + eb(k) - ea(k+1)}
290   \textcolor{comment}{! Local variables}
291   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}
292   \textcolor{keywordtype}{real} :: b1(SZI\_(G))          \textcolor{comment}{! b1 and c1 are variables used by the}
293   \textcolor{keywordtype}{real} :: c1(SZI\_(G),SZK\_(G))  \textcolor{comment}{! tridiagonal solver.}
294   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m
295   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
296 
297   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
298 
299   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}
300     \textcolor{keywordflow}{do} m=1,cs%ntr
301       \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
302         h\_work(i,j,k) = h\_old(i,j,k)
303 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
304       \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs%tr(:,:,:,m), dt, fluxes, h\_work, &
305                                           evap\_cfl\_limit, minimum\_forcing\_depth)
306       \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs%tr(:,:,:,m), g, gv)
307 \textcolor{keywordflow}{    enddo}
308   \textcolor{keywordflow}{else}
309     \textcolor{keywordflow}{do} m=1,ntr
310       \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs%tr(:,:,:,m), g, gv)
311 \textcolor{keywordflow}{    enddo}
312 \textcolor{keywordflow}{  endif}
313 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceadvection__test__tracer_aba7ee03a503e5f5518cc364c223ba693}\label{namespaceadvection__test__tracer_aba7ee03a503e5f5518cc364c223ba693}} 
\index{advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}!advection\+\_\+test\+\_\+tracer\+\_\+end@{advection\+\_\+test\+\_\+tracer\+\_\+end}}
\index{advection\+\_\+test\+\_\+tracer\+\_\+end@{advection\+\_\+test\+\_\+tracer\+\_\+end}!advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}}
\subsubsection{\texorpdfstring{advection\+\_\+test\+\_\+tracer\+\_\+end()}{advection\_test\_tracer\_end()}}
{\footnotesize\ttfamily subroutine, public advection\+\_\+test\+\_\+tracer\+::advection\+\_\+test\+\_\+tracer\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structadvection__test__tracer_1_1advection__test__tracer__cs}{advection\+\_\+test\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Deallocate memory associated with this module. 


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


Definition at line 393 of file advection\+\_\+test\+\_\+tracer.\+F90.


\begin{DoxyCode}
393   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}
394 \textcolor{comment}{                                              !! call to register\_advection\_test\_tracer.}
395   \textcolor{keywordtype}{integer} :: m
396 
397   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
398     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tr)) \textcolor{keyword}{deallocate}(cs%tr)
399     \textcolor{keyword}{deallocate}(cs)
400 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespaceadvection__test__tracer_a73a401f469c9cd5db07d879f149ecfe0}\label{namespaceadvection__test__tracer_a73a401f469c9cd5db07d879f149ecfe0}} 
\index{advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}!advection\+\_\+test\+\_\+tracer\+\_\+surface\+\_\+state@{advection\+\_\+test\+\_\+tracer\+\_\+surface\+\_\+state}}
\index{advection\+\_\+test\+\_\+tracer\+\_\+surface\+\_\+state@{advection\+\_\+test\+\_\+tracer\+\_\+surface\+\_\+state}!advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}}
\subsubsection{\texorpdfstring{advection\+\_\+test\+\_\+tracer\+\_\+surface\+\_\+state()}{advection\_test\_tracer\_surface\_state()}}
{\footnotesize\ttfamily subroutine, public advection\+\_\+test\+\_\+tracer\+::advection\+\_\+test\+\_\+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(\mbox{\hyperlink{structadvection__test__tracer_1_1advection__test__tracer__cs}{advection\+\_\+test\+\_\+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\+\_\+advection\+\_\+test\+\_\+tracer. \\
\hline
\end{DoxyParams}


Definition at line 320 of file advection\+\_\+test\+\_\+tracer.\+F90.


\begin{DoxyCode}
320   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The ocean's grid structure.}
321   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
322 \textcolor{comment}{                                              !! describe the surface state of the ocean.}
323   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
324                           \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thickness [H ~> m or kg m-2].}
325   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}
326 \textcolor{comment}{                                              !! call to register\_advection\_test\_tracer.}
327 
328   \textcolor{comment}{! This particular tracer package does not report anything back to the coupler.}
329   \textcolor{comment}{! The code that is here is just a rough guide for packages that would.}
330 
331   \textcolor{keywordtype}{integer} :: m, is, ie, js, je, isd, ied, jsd, jed
332   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
333   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
334 
335   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
336 
337   \textcolor{keywordflow}{if} (cs%coupled\_tracers) \textcolor{keywordflow}{then}
338     \textcolor{keywordflow}{do} m=1,cs%ntr
339       \textcolor{comment}{!   This call loads the surface values into the appropriate array in the}
340       \textcolor{comment}{! coupler-type structure.}
341       \textcolor{keyword}{call }coupler\_type\_set\_data(cs%tr(:,:,1,m), cs%ind\_tr(m), ind\_csurf, &
342                    sfc\_state%tr\_fields, idim=(/isd, is, ie, ied/), &
343                    jdim=(/jsd, js, je, jed/) )
344 \textcolor{keywordflow}{    enddo}
345 \textcolor{keywordflow}{  endif}
346 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceadvection__test__tracer_a1d5fcff30ba8ec9f30012aa4d6cec981}\label{namespaceadvection__test__tracer_a1d5fcff30ba8ec9f30012aa4d6cec981}} 
\index{advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}!initialize\+\_\+advection\+\_\+test\+\_\+tracer@{initialize\+\_\+advection\+\_\+test\+\_\+tracer}}
\index{initialize\+\_\+advection\+\_\+test\+\_\+tracer@{initialize\+\_\+advection\+\_\+test\+\_\+tracer}!advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}}
\subsubsection{\texorpdfstring{initialize\+\_\+advection\+\_\+test\+\_\+tracer()}{initialize\_advection\_test\_tracer()}}
{\footnotesize\ttfamily subroutine, public advection\+\_\+test\+\_\+tracer\+::initialize\+\_\+advection\+\_\+test\+\_\+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(\mbox{\hyperlink{structadvection__test__tracer_1_1advection__test__tracer__cs}{advection\+\_\+test\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(sponge\+\_\+cs), pointer}]{sponge\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Initializes the N\+TR tracer fields in tr(\+:,\+:,\+:,\+:) and it sets up the tracer output. 


\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\+\_\+advection\+\_\+test\+\_\+tracer.\\
\hline
 & {\em sponge\+\_\+csp} & Pointer to the control structure for the sponges. \\
\hline
\end{DoxyParams}


Definition at line 168 of file advection\+\_\+test\+\_\+tracer.\+F90.


\begin{DoxyCode}
168   \textcolor{keywordtype}{logical},                            \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}
169 \textcolor{comment}{                                                         !! been read from a restart file.}
170   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{  !< Time of the start of the run.}
171   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}
172   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}
173   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
174                                       \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}
175   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< A structure that is used to regulate}
176 \textcolor{comment}{                                                         !! diagnostic output.}
177   \textcolor{keywordtype}{type}(ocean\_OBC\_type),               \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{  !< This open boundary condition type specifies}
178 \textcolor{comment}{                                                         !! whether, where, and what open boundary}
179 \textcolor{comment}{                                                         !! conditions are used.}
180   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< The control structure returned by a previous}
181 \textcolor{comment}{                                                       !! call to register\_advection\_test\_tracer.}
182   \textcolor{keywordtype}{type}(sponge\_CS),                    \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< Pointer to the control structure for the
       sponges.}
183 
184   \textcolor{comment}{! Local variables}
185   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable} :: temp(:,:,:)
186   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:)} :: &
187     OBC\_tr1\_u => null(), & \textcolor{comment}{! These arrays should be allocated and set to}
188     obc\_tr1\_v => null()    \textcolor{comment}{! specify the values of tracer 1 that should come}
189                            \textcolor{comment}{! in through u- and v- points through the open}
190                            \textcolor{comment}{! boundary conditions, in the same units as tr.}
191   \textcolor{keywordtype}{character(len=16)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}
192   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}
193   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}
194   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}
195                             \textcolor{comment}{! kg(tracer) kg(water)-1 m3 s-1 or kg(tracer) s-1.}
196   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()
197   \textcolor{keywordtype}{real} :: h\_neglect         \textcolor{comment}{! A thickness that is so small it is usually lost}
198                             \textcolor{comment}{! in roundoff and can be neglected [H ~> m or kg m-2].}
199   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m
200   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB
201   \textcolor{keywordtype}{real} :: tmpx, tmpy, locx, locy
202 
203   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
204   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
205   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
206   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
207   h\_neglect = gv%H\_subroundoff
208 
209   cs%diag => diag
210   cs%ntr = ntr
211   \textcolor{keywordflow}{do} m=1,ntr
212     \textcolor{keyword}{call }query\_vardesc(cs%tr\_desc(m), name=name, &
213                        caller=\textcolor{stringliteral}{"initialize\_advection\_test\_tracer"})
214     \textcolor{keywordflow}{if} ((.not.restart) .or. (cs%tracers\_may\_reinit .and. .not. &
215         query\_initialized(cs%tr(:,:,:,m), name, cs%restart\_CSp))) \textcolor{keywordflow}{then}
216       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
217         cs%tr(i,j,k,m) = 0.0
218 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
219       k=1 \textcolor{comment}{! Square wave}
220       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
221         \textcolor{keywordflow}{if} (abs(g%geoLonT(i,j)-cs%x\_origin)<0.5*cs%x\_width .and. &
222             abs(g%geoLatT(i,j)-cs%y\_origin)<0.5*cs%y\_width) cs%tr(i,j,k,m) = 1.0
223 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
224       k=2 \textcolor{comment}{! Triangle wave}
225       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
226         locx=abs(g%geoLonT(i,j)-cs%x\_origin)/cs%x\_width
227         locy=abs(g%geoLatT(i,j)-cs%y\_origin)/cs%y\_width
228         cs%tr(i,j,k,m) = max(0.0, 1.0-locx)*max(0.0, 1.0-locy)
229 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
230       k=3 \textcolor{comment}{! Cosine bell}
231       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
232         locx=min(1.0, abs(g%geoLonT(i,j)-cs%x\_origin)/cs%x\_width)*(acos(0.0)*2.)
233         locy=min(1.0, abs(g%geoLatT(i,j)-cs%y\_origin)/cs%y\_width)*(acos(0.0)*2.)
234         cs%tr(i,j,k,m) = (1.0+cos(locx))*(1.0+cos(locy))*0.25
235 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
236       k=4 \textcolor{comment}{! Cylinder}
237       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
238         locx=abs(g%geoLonT(i,j)-cs%x\_origin)/cs%x\_width
239         locy=abs(g%geoLatT(i,j)-cs%y\_origin)/cs%y\_width
240         \textcolor{keywordflow}{if} (locx**2+locy**2<=1.0) cs%tr(i,j,k,m) = 1.0
241 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
242       k=5 \textcolor{comment}{! Cut cylinder}
243       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
244         locx=(g%geoLonT(i,j)-cs%x\_origin)/cs%x\_width
245         locy=(g%geoLatT(i,j)-cs%y\_origin)/cs%y\_width
246         \textcolor{keywordflow}{if} (locx**2+locy**2<=1.0) cs%tr(i,j,k,m) = 1.0
247         \textcolor{keywordflow}{if} (locx>0.0.and.abs(locy)<0.2) cs%tr(i,j,k,m) = 0.0
248 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
249 \textcolor{keywordflow}{    endif} \textcolor{comment}{! restart}
250 \textcolor{keywordflow}{  enddo}
251 
252 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceadvection__test__tracer_a6cc3e00a5d5cb9e31339c784eb966c91}\label{namespaceadvection__test__tracer_a6cc3e00a5d5cb9e31339c784eb966c91}} 
\index{advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}!register\+\_\+advection\+\_\+test\+\_\+tracer@{register\+\_\+advection\+\_\+test\+\_\+tracer}}
\index{register\+\_\+advection\+\_\+test\+\_\+tracer@{register\+\_\+advection\+\_\+test\+\_\+tracer}!advection\+\_\+test\+\_\+tracer@{advection\+\_\+test\+\_\+tracer}}
\subsubsection{\texorpdfstring{register\+\_\+advection\+\_\+test\+\_\+tracer()}{register\_advection\_test\_tracer()}}
{\footnotesize\ttfamily logical function, public advection\+\_\+test\+\_\+tracer\+::register\+\_\+advection\+\_\+test\+\_\+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(\mbox{\hyperlink{structadvection__test__tracer_1_1advection__test__tracer__cs}{advection\+\_\+test\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{tr\+\_\+\+Reg,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



Register tracer fields and subroutines to be used with M\+OM. 


\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\+\_\+advection\+\_\+test\+\_\+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 68 of file advection\+\_\+test\+\_\+tracer.\+F90.


\begin{DoxyCode}
68   \textcolor{keywordtype}{type}(hor\_index\_type),        \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type structure}
69   \textcolor{keywordtype}{type}(verticalGrid\_type),     \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}
70   \textcolor{keywordtype}{type}(param\_file\_type),       \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
71   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}
72 \textcolor{comment}{                                                !! call to register\_advection\_test\_tracer.}
73   \textcolor{keywordtype}{type}(tracer\_registry\_type),  \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer that is set to point to the control}
74 \textcolor{comment}{                                                !! structure for the tracer advection and}
75 \textcolor{comment}{                                                !! diffusion module}
76   \textcolor{keywordtype}{type}(MOM\_restart\_CS),        \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure}
77 
78   \textcolor{comment}{! Local variables}
79   \textcolor{keywordtype}{character(len=80)}  :: name, longname
80 \textcolor{comment}{! This include declares and sets the variable "version".}
81 \textcolor{preprocessor}{#include "version\_variable.h"}
82 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"advection\_test\_tracer"} \textcolor{comment}{! This module's name.}
83   \textcolor{keywordtype}{character(len=200)} :: inputdir
84   \textcolor{keywordtype}{character(len=48)}  :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}
85                             \textcolor{comment}{! kg(tracer) kg(water)-1 m3 s-1 or kg(tracer) s-1.}
86   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()
87   \textcolor{keywordtype}{logical} :: register\_advection\_test\_tracer
88   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m
89   isd = hi%isd ; ied = hi%ied ; jsd = hi%jsd ; jed = hi%jed ; nz = gv%ke
90 
91   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
92     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_advection\_test\_tracer called with an "}// &
93                             \textcolor{stringliteral}{"associated control structure."})
94     \textcolor{keywordflow}{return}
95 \textcolor{keywordflow}{  endif}
96   \textcolor{keyword}{allocate}(cs)
97 
98   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
99   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
100 
101   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_X\_ORIGIN"}, cs%x\_origin, &
102         \textcolor{stringliteral}{"The x-coordinate of the center of the test-functions."}, units=\textcolor{stringliteral}{"same as geoLon"}, default=0.)
103   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_Y\_ORIGIN"}, cs%y\_origin, &
104         \textcolor{stringliteral}{"The y-coordinate of the center of the test-functions."}, units=\textcolor{stringliteral}{"same as geoLat"}, default=0.)
105   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_X\_WIDTH"}, cs%x\_width, &
106         \textcolor{stringliteral}{"The x-width of the test-functions."}, units=\textcolor{stringliteral}{"same as geoLon"}, default=0.)
107   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_Y\_WIDTH"}, cs%y\_width, &
108         \textcolor{stringliteral}{"The y-width of the test-functions."}, units=\textcolor{stringliteral}{"same as geoLat"}, default=0.)
109   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_TRACER\_IC\_FILE"}, cs%tracer\_IC\_file, &
110                  \textcolor{stringliteral}{"The name of a file from which to read the initial "}//&
111                  \textcolor{stringliteral}{"conditions for the tracers, or blank to initialize "}//&
112                  \textcolor{stringliteral}{"them internally."}, default=\textcolor{stringliteral}{" "})
113 
114   \textcolor{keywordflow}{if} (len\_trim(cs%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}
115     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
116     cs%tracer\_IC\_file = trim(slasher(inputdir))//trim(cs%tracer\_IC\_file)
117     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/ADVECTION\_TEST\_TRACER\_IC\_FILE"}, &
118                    cs%tracer\_IC\_file)
119 \textcolor{keywordflow}{  endif}
120   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, cs%use\_sponge, &
121                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//&
122                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//&
123                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)
124 
125   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TRACERS\_MAY\_REINIT"}, cs%tracers\_may\_reinit, &
126                  \textcolor{stringliteral}{"If true, tracers may go through the initialization code "}//&
127                  \textcolor{stringliteral}{"if they are not found in the restart files.  Otherwise "}//&
128                  \textcolor{stringliteral}{"it is a fatal error if the tracers are not found in the "}//&
129                  \textcolor{stringliteral}{"restart files of a restarted run."}, default=.false.)
130 
131 
132   \textcolor{keyword}{allocate}(cs%tr(isd:ied,jsd:jed,nz,ntr)) ; cs%tr(:,:,:,:) = 0.0
133 
134   \textcolor{keywordflow}{do} m=1,ntr
135     \textcolor{keywordflow}{if} (m < 10) \textcolor{keywordflow}{then} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr",I1.1)'}) m
136     \textcolor{keywordflow}{else} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr",I2.2)'}) m ;\textcolor{keywordflow}{ endif}
137     \textcolor{keyword}{write}(longname,\textcolor{stringliteral}{'("Concentration of Tracer ",I2.2)'}) m
138     cs%tr\_desc(m) = var\_desc(name, units=\textcolor{stringliteral}{"kg kg-1"}, longname=longname, caller=mdl)
139     \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then} ; flux\_units = \textcolor{stringliteral}{"kg kg-1 m3 s-1"}
140     \textcolor{keywordflow}{else} ; flux\_units = \textcolor{stringliteral}{"kg s-1"} ;\textcolor{keywordflow}{ endif}
141 
142 
143     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration}
144     \textcolor{comment}{! calls.  Curses on the designers and implementers of Fortran90.}
145     tr\_ptr => cs%tr(:,:,:,m)
146     \textcolor{comment}{! Register the tracer for horizontal advection, diffusion, and restarts.}
147     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, &
148                          name=name, longname=longname, units=\textcolor{stringliteral}{"kg kg-1"}, &
149                          registry\_diags=.true., flux\_units=flux\_units, &
150                          restart\_cs=restart\_cs, mandatory=.not.cs%tracers\_may\_reinit)
151 
152     \textcolor{comment}{!   Set coupled\_tracers to be true (hard-coded above) to provide the surface}
153     \textcolor{comment}{! values to the coupler (if any).  This is meta-code and its arguments will}
154     \textcolor{comment}{! currently (deliberately) give fatal errors if it is used.}
155     \textcolor{keywordflow}{if} (cs%coupled\_tracers) &
156       cs%ind\_tr(m) = aof\_set\_coupler\_flux(trim(name)//\textcolor{stringliteral}{'\_flux'}, &
157           flux\_type=\textcolor{stringliteral}{' '}, implementation=\textcolor{stringliteral}{' '}, caller=\textcolor{stringliteral}{"register\_advection\_test\_tracer"})
158 \textcolor{keywordflow}{  enddo}
159 
160   cs%tr\_Reg => tr\_reg
161   cs%restart\_CSp => restart\_cs
162   register\_advection\_test\_tracer = .true.
\end{DoxyCode}
