\hypertarget{namespaceadvection__test__tracer}{}\doxysection{advection\+\_\+test\+\_\+tracer Module Reference}
\label{namespaceadvection__test__tracer}\index{advection\_test\_tracer@{advection\_test\_tracer}}


\doxysubsection{Detailed Description}
This tracer package is used to test advection schemes. \doxysubsection*{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}
\doxysubsection*{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}
\doxysubsection*{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}


\doxysubsection{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em stocks} & the mass-\/weighted integrated amount of each tracer, in kg times concentration units \mbox{[}kg conc\mbox{]}. \\
\hline
\mbox{\texttt{ 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{\texttt{ out}}  & {\em names} & the names of the stocks calculated. \\
\hline
\mbox{\texttt{ out}}  & {\em units} & the units of the stocks calculated. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{352   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{      !< The ocean's grid structure}}
\DoxyCodeLine{353 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{   !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{354 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},                 \textcolor{keywordtype}{intent(out)}   :: stocks\textcolor{comment}{ !< the mass-\/weighted integrated amount of each}}
\DoxyCodeLine{355 \textcolor{comment}{                                                              !! tracer, in kg times concentration units [kg conc].}}
\DoxyCodeLine{356   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{     !< The ocean's vertical grid structure}}
\DoxyCodeLine{357   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS),     \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< The control structure returned by a previous}}
\DoxyCodeLine{358 \textcolor{comment}{                                                              !! call to register\_advection\_test\_tracer.}}
\DoxyCodeLine{359   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< the names of the stocks calculated.}}
\DoxyCodeLine{360   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< the units of the stocks calculated.}}
\DoxyCodeLine{361   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                  \textcolor{keywordtype}{intent(in)}    :: stock\_index\textcolor{comment}{ !< the coded index of a specific stock being sought.}}
\DoxyCodeLine{362   \textcolor{keywordtype}{integer}                                           :: advection\_test\_stock\textcolor{comment}{ !< the number of stocks calculated here.}}
\DoxyCodeLine{363 }
\DoxyCodeLine{364   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{365   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{366 }
\DoxyCodeLine{367   advection\_test\_stock = 0}
\DoxyCodeLine{368   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{369   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{370 }
\DoxyCodeLine{371   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{372     \textcolor{comment}{! Check whether this stock is available from this routine.}}
\DoxyCodeLine{373 }
\DoxyCodeLine{374     \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}}
\DoxyCodeLine{375     \textcolor{keywordflow}{return}}
\DoxyCodeLine{376 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{377 }
\DoxyCodeLine{378   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{379     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=names(m), units=units(m), caller=\textcolor{stringliteral}{"advection\_test\_stock"})}
\DoxyCodeLine{380     stocks(m) = 0.0}
\DoxyCodeLine{381     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{382       stocks(m) = stocks(m) + cs\%tr(i,j,k,m) * \&}
\DoxyCodeLine{383                              (g\%mask2dT(i,j) * g\%US\%L\_to\_m**2*g\%areaT(i,j) * h(i,j,k))}
\DoxyCodeLine{384 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{385     stocks(m) = gv\%H\_to\_kg\_m2 * stocks(m)}
\DoxyCodeLine{386 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{387   advection\_test\_stock = cs\%ntr}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+old} & Layer thickness before entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+new} & Layer thickness after entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ea} & an array to which the amount of fluid entrained \\
\hline
\mbox{\texttt{ in}}  & {\em eb} & an array to which the amount of fluid entrained \\
\hline
\mbox{\texttt{ in}}  & {\em fluxes} & A structure containing pointers to thermodynamic and tracer forcing fields. Unused fields have N\+U\+LL ptrs. \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time covered by this call \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\mbox{\texttt{ 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{\texttt{ 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{\texttt{ 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}{0}
\DoxyCodeLine{260   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{261   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{262 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{263                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{264 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{265                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{266 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{267                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{268 \textcolor{comment}{                                              !! from the layer above during this call will be}}
\DoxyCodeLine{269 \textcolor{comment}{                                              !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{270 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{271                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{272 \textcolor{comment}{                                              !! from the layer below during this call will be}}
\DoxyCodeLine{273 \textcolor{comment}{                                              !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{274   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}}
\DoxyCodeLine{275 \textcolor{comment}{                                              !! and tracer forcing fields.  Unused fields have NULL ptrs.}}
\DoxyCodeLine{276 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T \string~> s]}}
\DoxyCodeLine{277   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{278   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{279 \textcolor{comment}{                                              !! call to register\_advection\_test\_tracer.}}
\DoxyCodeLine{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}}
\DoxyCodeLine{281 \textcolor{comment}{                                              !! be fluxed out of the top layer in a timestep [nondim]}}
\DoxyCodeLine{282 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which}}
\DoxyCodeLine{283 \textcolor{comment}{                                              !! fluxes can be applied [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{284 \textcolor{comment}{!   This subroutine applies diapycnal diffusion and any other column}}
\DoxyCodeLine{285 \textcolor{comment}{! tracer physics or chemistry to the tracers from this file.}}
\DoxyCodeLine{286 \textcolor{comment}{! This is a simple example of a set of advected passive tracers.}}
\DoxyCodeLine{287 }
\DoxyCodeLine{288 \textcolor{comment}{! The arguments to this subroutine are redundant in that}}
\DoxyCodeLine{289 \textcolor{comment}{!     h\_new(k) = h\_old(k) + ea(k) -\/ eb(k-\/1) + eb(k) -\/ ea(k+1)}}
\DoxyCodeLine{290   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{291 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}}
\DoxyCodeLine{292 \textcolor{keywordtype}{  real} :: b1(SZI\_(G))          \textcolor{comment}{! b1 and c1 are variables used by the}}
\DoxyCodeLine{293 \textcolor{keywordtype}{  real} :: c1(SZI\_(G),SZK\_(G))  \textcolor{comment}{! tridiagonal solver.}}
\DoxyCodeLine{294   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{295   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{296 }
\DoxyCodeLine{297   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{298 }
\DoxyCodeLine{299   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{300     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{301       \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{302         h\_work(i,j,k) = h\_old(i,j,k)}
\DoxyCodeLine{303 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{304       \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs\%tr(:,:,:,m), dt, fluxes, h\_work, \&}
\DoxyCodeLine{305                                           evap\_cfl\_limit, minimum\_forcing\_depth)}
\DoxyCodeLine{306       \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{307 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{308   \textcolor{keywordflow}{else}}
\DoxyCodeLine{309     \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{310       \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{311 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{312 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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}{0}
\DoxyCodeLine{393   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{394 \textcolor{comment}{                                              !! call to register\_advection\_test\_tracer.}}
\DoxyCodeLine{395   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{396 }
\DoxyCodeLine{397   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{398     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%tr)) \textcolor{keyword}{deallocate}(cs\%tr)}
\DoxyCodeLine{399     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{320   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The ocean's grid structure.}}
\DoxyCodeLine{321   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{322 \textcolor{comment}{                                              !! describe the surface state of the ocean.}}
\DoxyCodeLine{323 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{324                           \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thickness [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{325   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{326 \textcolor{comment}{                                              !! call to register\_advection\_test\_tracer.}}
\DoxyCodeLine{327 }
\DoxyCodeLine{328   \textcolor{comment}{! This particular tracer package does not report anything back to the coupler.}}
\DoxyCodeLine{329   \textcolor{comment}{! The code that is here is just a rough guide for packages that would.}}
\DoxyCodeLine{330 }
\DoxyCodeLine{331   \textcolor{keywordtype}{integer} :: m, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{332   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{333   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{334 }
\DoxyCodeLine{335   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{336 }
\DoxyCodeLine{337   \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{338     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{339       \textcolor{comment}{!   This call loads the surface values into the appropriate array in the}}
\DoxyCodeLine{340       \textcolor{comment}{! coupler-\/type structure.}}
\DoxyCodeLine{341       \textcolor{keyword}{call }coupler\_type\_set\_data(cs\%tr(:,:,1,m), cs\%ind\_tr(m), ind\_csurf, \&}
\DoxyCodeLine{342                    sfc\_state\%tr\_fields, idim=(/isd, is, ie, ied/), \&}
\DoxyCodeLine{343                    jdim=(/jsd, js, je, jed/) )}
\DoxyCodeLine{344 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{345 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em restart} & .true. if the fields have already been read from a restart file. \\
\hline
\mbox{\texttt{ in}}  & {\em day} & Time of the start of the run. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{168   \textcolor{keywordtype}{logical},                            \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}}
\DoxyCodeLine{169 \textcolor{comment}{                                                         !! been read from a restart file.}}
\DoxyCodeLine{170   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{  !< Time of the start of the run.}}
\DoxyCodeLine{171   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{172   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{173 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{174                                       \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{175   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< A structure that is used to regulate}}
\DoxyCodeLine{176 \textcolor{comment}{                                                         !! diagnostic output.}}
\DoxyCodeLine{177   \textcolor{keywordtype}{type}(ocean\_OBC\_type),               \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{  !< This open boundary condition type specifies}}
\DoxyCodeLine{178 \textcolor{comment}{                                                         !! whether, where, and what open boundary}}
\DoxyCodeLine{179 \textcolor{comment}{                                                         !! conditions are used.}}
\DoxyCodeLine{180   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{181 \textcolor{comment}{                                                       !! call to register\_advection\_test\_tracer.}}
\DoxyCodeLine{182   \textcolor{keywordtype}{type}(sponge\_CS),                    \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< Pointer to the control structure for the sponges.}}
\DoxyCodeLine{183 }
\DoxyCodeLine{184   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{185 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable} :: temp(:,:,:)}
\DoxyCodeLine{186 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:)} :: \&}
\DoxyCodeLine{187     OBC\_tr1\_u => null(), \& \textcolor{comment}{! These arrays should be allocated and set to}}
\DoxyCodeLine{188     obc\_tr1\_v => null()    \textcolor{comment}{! specify the values of tracer 1 that should come}}
\DoxyCodeLine{189                            \textcolor{comment}{! in through u-\/ and v-\/ points through the open}}
\DoxyCodeLine{190                            \textcolor{comment}{! boundary conditions, in the same units as tr.}}
\DoxyCodeLine{191   \textcolor{keywordtype}{character(len=16)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}}
\DoxyCodeLine{192   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}}
\DoxyCodeLine{193   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}}
\DoxyCodeLine{194   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}}
\DoxyCodeLine{195                             \textcolor{comment}{! kg(tracer) kg(water)-\/1 m3 s-\/1 or kg(tracer) s-\/1.}}
\DoxyCodeLine{196 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{197 \textcolor{keywordtype}{  real} :: h\_neglect         \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{198                             \textcolor{comment}{! in roundoff and can be neglected [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{199   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{200   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{201 \textcolor{keywordtype}{  real} :: tmpx, tmpy, locx, locy}
\DoxyCodeLine{202 }
\DoxyCodeLine{203   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{204   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{205   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{206   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{207   h\_neglect = gv\%H\_subroundoff}
\DoxyCodeLine{208 }
\DoxyCodeLine{209   cs\%diag => diag}
\DoxyCodeLine{210   cs\%ntr = ntr}
\DoxyCodeLine{211   \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{212     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=name, \&}
\DoxyCodeLine{213                        caller=\textcolor{stringliteral}{"initialize\_advection\_test\_tracer"})}
\DoxyCodeLine{214     \textcolor{keywordflow}{if} ((.not.restart) .or. (cs\%tracers\_may\_reinit .and. .not. \&}
\DoxyCodeLine{215         query\_initialized(cs\%tr(:,:,:,m), name, cs\%restart\_CSp))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{216       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{217         cs\%tr(i,j,k,m) = 0.0}
\DoxyCodeLine{218 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{219       k=1 \textcolor{comment}{! Square wave}}
\DoxyCodeLine{220       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{221         \textcolor{keywordflow}{if} (abs(g\%geoLonT(i,j)-\/cs\%x\_origin)<0.5*cs\%x\_width .and. \&}
\DoxyCodeLine{222             abs(g\%geoLatT(i,j)-\/cs\%y\_origin)<0.5*cs\%y\_width) cs\%tr(i,j,k,m) = 1.0}
\DoxyCodeLine{223 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{224       k=2 \textcolor{comment}{! Triangle wave}}
\DoxyCodeLine{225       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{226         locx=abs(g\%geoLonT(i,j)-\/cs\%x\_origin)/cs\%x\_width}
\DoxyCodeLine{227         locy=abs(g\%geoLatT(i,j)-\/cs\%y\_origin)/cs\%y\_width}
\DoxyCodeLine{228         cs\%tr(i,j,k,m) = max(0.0, 1.0-\/locx)*max(0.0, 1.0-\/locy)}
\DoxyCodeLine{229 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{230       k=3 \textcolor{comment}{! Cosine bell}}
\DoxyCodeLine{231       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{232         locx=min(1.0, abs(g\%geoLonT(i,j)-\/cs\%x\_origin)/cs\%x\_width)*(acos(0.0)*2.)}
\DoxyCodeLine{233         locy=min(1.0, abs(g\%geoLatT(i,j)-\/cs\%y\_origin)/cs\%y\_width)*(acos(0.0)*2.)}
\DoxyCodeLine{234         cs\%tr(i,j,k,m) = (1.0+cos(locx))*(1.0+cos(locy))*0.25}
\DoxyCodeLine{235 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{236       k=4 \textcolor{comment}{! Cylinder}}
\DoxyCodeLine{237       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{238         locx=abs(g\%geoLonT(i,j)-\/cs\%x\_origin)/cs\%x\_width}
\DoxyCodeLine{239         locy=abs(g\%geoLatT(i,j)-\/cs\%y\_origin)/cs\%y\_width}
\DoxyCodeLine{240         \textcolor{keywordflow}{if} (locx**2+locy**2<=1.0) cs\%tr(i,j,k,m) = 1.0}
\DoxyCodeLine{241 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{242       k=5 \textcolor{comment}{! Cut cylinder}}
\DoxyCodeLine{243       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{244         locx=(g\%geoLonT(i,j)-\/cs\%x\_origin)/cs\%x\_width}
\DoxyCodeLine{245         locy=(g\%geoLatT(i,j)-\/cs\%y\_origin)/cs\%y\_width}
\DoxyCodeLine{246         \textcolor{keywordflow}{if} (locx**2+locy**2<=1.0) cs\%tr(i,j,k,m) = 1.0}
\DoxyCodeLine{247         \textcolor{keywordflow}{if} (locx>0.0.and.abs(locy)<0.2) cs\%tr(i,j,k,m) = 0.0}
\DoxyCodeLine{248 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{249 \textcolor{keywordflow}{    endif} \textcolor{comment}{! restart}}
\DoxyCodeLine{250 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{251 }
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em hi} & A horizontal index type structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{68   \textcolor{keywordtype}{type}(hor\_index\_type),        \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type structure}}
\DoxyCodeLine{69   \textcolor{keywordtype}{type}(verticalGrid\_type),     \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{70   \textcolor{keywordtype}{type}(param\_file\_type),       \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{71   \textcolor{keywordtype}{type}(advection\_test\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{72 \textcolor{comment}{                                                !! call to register\_advection\_test\_tracer.}}
\DoxyCodeLine{73   \textcolor{keywordtype}{type}(tracer\_registry\_type),  \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{74 \textcolor{comment}{                                                !! structure for the tracer advection and}}
\DoxyCodeLine{75 \textcolor{comment}{                                                !! diffusion module}}
\DoxyCodeLine{76   \textcolor{keywordtype}{type}(MOM\_restart\_CS),        \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure}}
\DoxyCodeLine{77 }
\DoxyCodeLine{78   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{79   \textcolor{keywordtype}{character(len=80)}  :: name, longname}
\DoxyCodeLine{80 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{81 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{82 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"advection\_test\_tracer"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{83   \textcolor{keywordtype}{character(len=200)} :: inputdir}
\DoxyCodeLine{84   \textcolor{keywordtype}{character(len=48)}  :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}}
\DoxyCodeLine{85                             \textcolor{comment}{! kg(tracer) kg(water)-\/1 m3 s-\/1 or kg(tracer) s-\/1.}}
\DoxyCodeLine{86 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{87   \textcolor{keywordtype}{logical} :: register\_advection\_test\_tracer}
\DoxyCodeLine{88   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{89   isd = hi\%isd ; ied = hi\%ied ; jsd = hi\%jsd ; jed = hi\%jed ; nz = gv\%ke}
\DoxyCodeLine{90 }
\DoxyCodeLine{91   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{92     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_advection\_test\_tracer called with an "}// \&}
\DoxyCodeLine{93                             \textcolor{stringliteral}{"associated control structure."})}
\DoxyCodeLine{94     \textcolor{keywordflow}{return}}
\DoxyCodeLine{95 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{96   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{97 }
\DoxyCodeLine{98   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{99   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{100 }
\DoxyCodeLine{101   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_X\_ORIGIN"}, cs\%x\_origin, \&}
\DoxyCodeLine{102         \textcolor{stringliteral}{"The x-\/coordinate of the center of the test-\/functions."}, units=\textcolor{stringliteral}{"same as geoLon"}, default=0.)}
\DoxyCodeLine{103   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_Y\_ORIGIN"}, cs\%y\_origin, \&}
\DoxyCodeLine{104         \textcolor{stringliteral}{"The y-\/coordinate of the center of the test-\/functions."}, units=\textcolor{stringliteral}{"same as geoLat"}, default=0.)}
\DoxyCodeLine{105   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_X\_WIDTH"}, cs\%x\_width, \&}
\DoxyCodeLine{106         \textcolor{stringliteral}{"The x-\/width of the test-\/functions."}, units=\textcolor{stringliteral}{"same as geoLon"}, default=0.)}
\DoxyCodeLine{107   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_Y\_WIDTH"}, cs\%y\_width, \&}
\DoxyCodeLine{108         \textcolor{stringliteral}{"The y-\/width of the test-\/functions."}, units=\textcolor{stringliteral}{"same as geoLat"}, default=0.)}
\DoxyCodeLine{109   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADVECTION\_TEST\_TRACER\_IC\_FILE"}, cs\%tracer\_IC\_file, \&}
\DoxyCodeLine{110                  \textcolor{stringliteral}{"The name of a file from which to read the initial "}//\&}
\DoxyCodeLine{111                  \textcolor{stringliteral}{"conditions for the tracers, or blank to initialize "}//\&}
\DoxyCodeLine{112                  \textcolor{stringliteral}{"them internally."}, default=\textcolor{stringliteral}{" "})}
\DoxyCodeLine{113 }
\DoxyCodeLine{114   \textcolor{keywordflow}{if} (len\_trim(cs\%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{115     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{116     cs\%tracer\_IC\_file = trim(slasher(inputdir))//trim(cs\%tracer\_IC\_file)}
\DoxyCodeLine{117     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/ADVECTION\_TEST\_TRACER\_IC\_FILE"}, \&}
\DoxyCodeLine{118                    cs\%tracer\_IC\_file)}
\DoxyCodeLine{119 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{120   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, cs\%use\_sponge, \&}
\DoxyCodeLine{121                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//\&}
\DoxyCodeLine{122                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//\&}
\DoxyCodeLine{123                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)}
\DoxyCodeLine{124 }
\DoxyCodeLine{125   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TRACERS\_MAY\_REINIT"}, cs\%tracers\_may\_reinit, \&}
\DoxyCodeLine{126                  \textcolor{stringliteral}{"If true, tracers may go through the initialization code "}//\&}
\DoxyCodeLine{127                  \textcolor{stringliteral}{"if they are not found in the restart files.  Otherwise "}//\&}
\DoxyCodeLine{128                  \textcolor{stringliteral}{"it is a fatal error if the tracers are not found in the "}//\&}
\DoxyCodeLine{129                  \textcolor{stringliteral}{"restart files of a restarted run."}, default=.false.)}
\DoxyCodeLine{130 }
\DoxyCodeLine{131 }
\DoxyCodeLine{132   \textcolor{keyword}{allocate}(cs\%tr(isd:ied,jsd:jed,nz,ntr)) ; cs\%tr(:,:,:,:) = 0.0}
\DoxyCodeLine{133 }
\DoxyCodeLine{134   \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{135     \textcolor{keywordflow}{if} (m < 10) \textcolor{keywordflow}{then} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr",I1.1)'}) m}
\DoxyCodeLine{136     \textcolor{keywordflow}{else} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr",I2.2)'}) m ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{137     \textcolor{keyword}{write}(longname,\textcolor{stringliteral}{'("Concentration of Tracer ",I2.2)'}) m}
\DoxyCodeLine{138     cs\%tr\_desc(m) = var\_desc(name, units=\textcolor{stringliteral}{"kg kg-\/1"}, longname=longname, caller=mdl)}
\DoxyCodeLine{139     \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then} ; flux\_units = \textcolor{stringliteral}{"kg kg-\/1 m3 s-\/1"}}
\DoxyCodeLine{140     \textcolor{keywordflow}{else} ; flux\_units = \textcolor{stringliteral}{"kg s-\/1"} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{141 }
\DoxyCodeLine{142 }
\DoxyCodeLine{143     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration}}
\DoxyCodeLine{144     \textcolor{comment}{! calls.  Curses on the designers and implementers of Fortran90.}}
\DoxyCodeLine{145     tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{146     \textcolor{comment}{! Register the tracer for horizontal advection, diffusion, and restarts.}}
\DoxyCodeLine{147     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, \&}
\DoxyCodeLine{148                          name=name, longname=longname, units=\textcolor{stringliteral}{"kg kg-\/1"}, \&}
\DoxyCodeLine{149                          registry\_diags=.true., flux\_units=flux\_units, \&}
\DoxyCodeLine{150                          restart\_cs=restart\_cs, mandatory=.not.cs\%tracers\_may\_reinit)}
\DoxyCodeLine{151 }
\DoxyCodeLine{152     \textcolor{comment}{!   Set coupled\_tracers to be true (hard-\/coded above) to provide the surface}}
\DoxyCodeLine{153     \textcolor{comment}{! values to the coupler (if any).  This is meta-\/code and its arguments will}}
\DoxyCodeLine{154     \textcolor{comment}{! currently (deliberately) give fatal errors if it is used.}}
\DoxyCodeLine{155     \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \&}
\DoxyCodeLine{156       cs\%ind\_tr(m) = aof\_set\_coupler\_flux(trim(name)//\textcolor{stringliteral}{'\_flux'}, \&}
\DoxyCodeLine{157           flux\_type=\textcolor{stringliteral}{' '}, implementation=\textcolor{stringliteral}{' '}, caller=\textcolor{stringliteral}{"register\_advection\_test\_tracer"})}
\DoxyCodeLine{158 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{159 }
\DoxyCodeLine{160   cs\%tr\_Reg => tr\_reg}
\DoxyCodeLine{161   cs\%restart\_CSp => restart\_cs}
\DoxyCodeLine{162   register\_advection\_test\_tracer = .true.}

\end{DoxyCode}
