\hypertarget{namespaceideal__age__example}{}\doxysection{ideal\+\_\+age\+\_\+example Module Reference}
\label{namespaceideal__age__example}\index{ideal\_age\_example@{ideal\_age\_example}}


\doxysubsection{Detailed Description}
A tracer package of ideal age tracers. 

Originally by Robert Hallberg, 2002

This file contains an example of the code that is needed to set up and use a set (in this case two) of dynamically passive tracers for diagnostic purposes. The tracers here are an ideal age tracer that ages at a rate of 1/year once it is isolated from the surface, and a vintage tracer, whose surface concentration grows exponen-\/ with time with a 30-\/year timescale (similar to C\+F\+Cs). \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structideal__age__example_1_1ideal__age__tracer__cs}{ideal\+\_\+age\+\_\+tracer\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em The control structure for the ideal\+\_\+age\+\_\+tracer package. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespaceideal__age__example_a58d550a02148b87b1d1ce979fcaf6c00}{register\+\_\+ideal\+\_\+age\+\_\+tracer}} (HI, GV, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Register the ideal age tracer fields to be used with M\+OM. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceideal__age__example_ae8c12d0128c24a491f7af62d4dd6ec5d}{initialize\+\_\+ideal\+\_\+age\+\_\+tracer}} (restart, day, G, GV, US, h, diag, O\+BC, CS, sponge\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Sets the ideal age traces to their initial values and sets up the tracer output. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceideal__age__example_a6c2fb023e159a153d56220585b57ceb5}{ideal\+\_\+age\+\_\+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, aging and regeneration at the surface to the ideal age tracers. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespaceideal__age__example_a2300d82e30802a3127f4a63277d37776}{ideal\+\_\+age\+\_\+stock}} (h, stocks, G, GV, CS, names, units, stock\+\_\+index)
\begin{DoxyCompactList}\small\item\em Calculates the mass-\/weighted integral of all tracer stocks, returning the number of stocks it has calculated. If stock\+\_\+index is present, only the stock corresponding to that coded index is found. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceideal__age__example_aea477e25ddf0fdc4f05fd45a102eb7c0}{ideal\+\_\+age\+\_\+tracer\+\_\+surface\+\_\+state}} (sfc\+\_\+state, h, G, CS)
\begin{DoxyCompactList}\small\item\em This subroutine extracts the surface fields from this tracer package that are to be shared with the atmosphere in coupled configurations. This particular tracer package does not report anything back to the coupler. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceideal__age__example_aa60b31c0f0a31db75ba3522f52c8d648}{ideal\+\_\+age\+\_\+example\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Deallocate any memory associated with this tracer package. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceideal__age__example_a50d4c454d945cfb178a50dcad0f4ae15}\label{namespaceideal__age__example_a50d4c454d945cfb178a50dcad0f4ae15}} 
integer, parameter \mbox{\hyperlink{namespaceideal__age__example_a50d4c454d945cfb178a50dcad0f4ae15}{ntr\+\_\+max}} = 3
\begin{DoxyCompactList}\small\item\em the maximum number of tracers in this module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceideal__age__example_aa60b31c0f0a31db75ba3522f52c8d648}\label{namespaceideal__age__example_aa60b31c0f0a31db75ba3522f52c8d648}} 
\index{ideal\_age\_example@{ideal\_age\_example}!ideal\_age\_example\_end@{ideal\_age\_example\_end}}
\index{ideal\_age\_example\_end@{ideal\_age\_example\_end}!ideal\_age\_example@{ideal\_age\_example}}
\doxysubsubsection{\texorpdfstring{ideal\_age\_example\_end()}{ideal\_age\_example\_end()}}
{\footnotesize\ttfamily subroutine, public ideal\+\_\+age\+\_\+example\+::ideal\+\_\+age\+\_\+example\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structideal__age__example_1_1ideal__age__tracer__cs}{ideal\+\_\+age\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Deallocate any memory associated with this tracer package. 


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


Definition at line 455 of file ideal\+\_\+age\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{455   \textcolor{keywordtype}{type}(ideal\_age\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{456 \textcolor{comment}{                                           !! call to register\_ideal\_age\_tracer.}}
\DoxyCodeLine{457 }
\DoxyCodeLine{458   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{459 }
\DoxyCodeLine{460   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{461     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%tr)) \textcolor{keyword}{deallocate}(cs\%tr)}
\DoxyCodeLine{462     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{463 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceideal__age__example_a2300d82e30802a3127f4a63277d37776}\label{namespaceideal__age__example_a2300d82e30802a3127f4a63277d37776}} 
\index{ideal\_age\_example@{ideal\_age\_example}!ideal\_age\_stock@{ideal\_age\_stock}}
\index{ideal\_age\_stock@{ideal\_age\_stock}!ideal\_age\_example@{ideal\_age\_example}}
\doxysubsubsection{\texorpdfstring{ideal\_age\_stock()}{ideal\_age\_stock()}}
{\footnotesize\ttfamily integer function, public ideal\+\_\+age\+\_\+example\+::ideal\+\_\+age\+\_\+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{structideal__age__example_1_1ideal__age__tracer__cs}{ideal\+\_\+age\+\_\+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})}



Calculates the mass-\/weighted integral of all tracer stocks, returning the number of stocks it has calculated. If stock\+\_\+index is present, only the stock corresponding to that coded index is found. 


\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\+\_\+ideal\+\_\+age\+\_\+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 375 of file ideal\+\_\+age\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{375   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{376 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{377                                       \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{378 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},                 \textcolor{keywordtype}{intent(out)}   :: stocks\textcolor{comment}{ !< the mass-\/weighted integrated amount of each}}
\DoxyCodeLine{379 \textcolor{comment}{                                                            !! tracer, in kg times concentration units [kg conc].}}
\DoxyCodeLine{380   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{381   \textcolor{keywordtype}{type}(ideal\_age\_tracer\_CS),          \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{382 \textcolor{comment}{                                                            !! call to register\_ideal\_age\_tracer.}}
\DoxyCodeLine{383   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< the names of the stocks calculated.}}
\DoxyCodeLine{384   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< the units of the stocks calculated.}}
\DoxyCodeLine{385   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                  \textcolor{keywordtype}{intent(in)}    :: stock\_index\textcolor{comment}{ !< the coded index of a specific stock}}
\DoxyCodeLine{386 \textcolor{comment}{                                                                   !! being sought.}}
\DoxyCodeLine{387   \textcolor{keywordtype}{integer}                                           :: ideal\_age\_stock\textcolor{comment}{ !< The number of stocks calculated here.}}
\DoxyCodeLine{388 \textcolor{comment}{! This function calculates the mass-\/weighted integral of all tracer stocks,}}
\DoxyCodeLine{389 \textcolor{comment}{! returning the number of stocks it has calculated.  If the stock\_index}}
\DoxyCodeLine{390 \textcolor{comment}{! is present, only the stock corresponding to that coded index is returned.}}
\DoxyCodeLine{391 }
\DoxyCodeLine{392   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{393   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{394 }
\DoxyCodeLine{395   ideal\_age\_stock = 0}
\DoxyCodeLine{396   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{397   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{398 }
\DoxyCodeLine{399   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{400     \textcolor{comment}{! Check whether this stock is available from this routine.}}
\DoxyCodeLine{401 }
\DoxyCodeLine{402     \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}}
\DoxyCodeLine{403     \textcolor{keywordflow}{return}}
\DoxyCodeLine{404 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{405 }
\DoxyCodeLine{406   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{407     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=names(m), units=units(m), caller=\textcolor{stringliteral}{"ideal\_age\_stock"})}
\DoxyCodeLine{408     units(m) = trim(units(m))//\textcolor{stringliteral}{" kg"}}
\DoxyCodeLine{409     stocks(m) = 0.0}
\DoxyCodeLine{410     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{411       stocks(m) = stocks(m) + cs\%tr(i,j,k,m) * \&}
\DoxyCodeLine{412                              (g\%mask2dT(i,j) * g\%US\%L\_to\_m**2*g\%areaT(i,j) * h(i,j,k))}
\DoxyCodeLine{413 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{414     stocks(m) = gv\%H\_to\_kg\_m2 * stocks(m)}
\DoxyCodeLine{415 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{416   ideal\_age\_stock = cs\%ntr}
\DoxyCodeLine{417 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceideal__age__example_a6c2fb023e159a153d56220585b57ceb5}\label{namespaceideal__age__example_a6c2fb023e159a153d56220585b57ceb5}} 
\index{ideal\_age\_example@{ideal\_age\_example}!ideal\_age\_tracer\_column\_physics@{ideal\_age\_tracer\_column\_physics}}
\index{ideal\_age\_tracer\_column\_physics@{ideal\_age\_tracer\_column\_physics}!ideal\_age\_example@{ideal\_age\_example}}
\doxysubsubsection{\texorpdfstring{ideal\_age\_tracer\_column\_physics()}{ideal\_age\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public ideal\+\_\+age\+\_\+example\+::ideal\+\_\+age\+\_\+tracer\+\_\+column\+\_\+physics (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h\+\_\+old,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h\+\_\+new,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{ea,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{eb,  }\item[{type(forcing), intent(in)}]{fluxes,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structideal__age__example_1_1ideal__age__tracer__cs}{ideal\+\_\+age\+\_\+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, aging and regeneration at the surface to the ideal age 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\+\_\+ideal\+\_\+age\+\_\+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 286 of file ideal\+\_\+age\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{286   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{287   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{288 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{289                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H ~> m or kg m-\/2].}}
\DoxyCodeLine{290 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{291                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H ~> m or kg m-\/2].}}
\DoxyCodeLine{292 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{293                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{294 \textcolor{comment}{                                              !! from the layer above during this call will be}}
\DoxyCodeLine{295 \textcolor{comment}{                                              !! added [H ~> m or kg m-\/2].}}
\DoxyCodeLine{296 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{297                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{298 \textcolor{comment}{                                              !! from the layer below during this call will be}}
\DoxyCodeLine{299 \textcolor{comment}{                                              !! added [H ~> m or kg m-\/2].}}
\DoxyCodeLine{300   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}}
\DoxyCodeLine{301 \textcolor{comment}{                                              !! and tracer forcing fields.  Unused fields have NULL ptrs.}}
\DoxyCodeLine{302 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T ~> s]}}
\DoxyCodeLine{303   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{304   \textcolor{keywordtype}{type}(ideal\_age\_tracer\_CS), \textcolor{keywordtype}{pointer}  :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{305 \textcolor{comment}{                                              !! call to register\_ideal\_age\_tracer.}}
\DoxyCodeLine{306 \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{307 \textcolor{comment}{                                              !! be fluxed out of the top layer in a timestep [nondim]}}
\DoxyCodeLine{308 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which}}
\DoxyCodeLine{309 \textcolor{comment}{                                              !! fluxes can be applied [H ~> m or kg m-\/2]}}
\DoxyCodeLine{310 \textcolor{comment}{!   This subroutine applies diapycnal diffusion and any other column}}
\DoxyCodeLine{311 \textcolor{comment}{! tracer physics or chemistry to the tracers from this file.}}
\DoxyCodeLine{312 \textcolor{comment}{! This is a simple example of a set of advected passive tracers.}}
\DoxyCodeLine{313 }
\DoxyCodeLine{314 \textcolor{comment}{! The arguments to this subroutine are redundant in that}}
\DoxyCodeLine{315 \textcolor{comment}{!     h\_new(k) = h\_old(k) + ea(k) -\/ eb(k-\/1) + eb(k) -\/ ea(k+1)}}
\DoxyCodeLine{316   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{317 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}}
\DoxyCodeLine{318 \textcolor{keywordtype}{  real} :: sfc\_val  \textcolor{comment}{! The surface value for the tracers.}}
\DoxyCodeLine{319 \textcolor{keywordtype}{  real} :: Isecs\_per\_year  \textcolor{comment}{! The inverse of the amount of time in a year [T-\/1 ~> s-\/1]}}
\DoxyCodeLine{320 \textcolor{keywordtype}{  real} :: year            \textcolor{comment}{! The time in years.}}
\DoxyCodeLine{321   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{322   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{323 }
\DoxyCodeLine{324   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{325   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{326 }
\DoxyCodeLine{327   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{328     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{329       \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{330         h\_work(i,j,k) = h\_old(i,j,k)}
\DoxyCodeLine{331 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{332       \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs\%tr(:,:,:,m), dt, fluxes, h\_work, \&}
\DoxyCodeLine{333                                           evap\_cfl\_limit, minimum\_forcing\_depth)}
\DoxyCodeLine{334       \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{335 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{336   \textcolor{keywordflow}{else}}
\DoxyCodeLine{337     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{338       \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{339 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{340 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{341 }
\DoxyCodeLine{342   isecs\_per\_year = 1.0 / (365.0*86400.0*us\%s\_to\_T)}
\DoxyCodeLine{343   \textcolor{comment}{!   Set the surface value of tracer 1 to increase exponentially}}
\DoxyCodeLine{344   \textcolor{comment}{! with a 30 year time scale.}}
\DoxyCodeLine{345   year = us\%s\_to\_T*time\_type\_to\_real(cs\%Time) * isecs\_per\_year}
\DoxyCodeLine{346 }
\DoxyCodeLine{347   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{348     \textcolor{keywordflow}{if} (cs\%sfc\_growth\_rate(m) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{349       sfc\_val = cs\%young\_val(m)}
\DoxyCodeLine{350     \textcolor{keywordflow}{else}}
\DoxyCodeLine{351       sfc\_val = cs\%young\_val(m) * \&}
\DoxyCodeLine{352           exp((year-\/cs\%tracer\_start\_year(m)) * cs\%sfc\_growth\_rate(m))}
\DoxyCodeLine{353 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{354     \textcolor{keywordflow}{do} k=1,cs\%nkml ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{355       \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0.5) \textcolor{keywordflow}{then}}
\DoxyCodeLine{356         cs\%tr(i,j,k,m) = sfc\_val}
\DoxyCodeLine{357       \textcolor{keywordflow}{else}}
\DoxyCodeLine{358         cs\%tr(i,j,k,m) = cs\%land\_val(m)}
\DoxyCodeLine{359 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{360 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{361 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{362   \textcolor{keywordflow}{do} m=1,cs\%ntr ; \textcolor{keywordflow}{if} (cs\%tracer\_ages(m) .and. \&}
\DoxyCodeLine{363                       (year>=cs\%tracer\_start\_year(m))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{364 \textcolor{comment}{!\$OMP parallel do default(none) shared(is,ie,js,je,CS,nz,G,dt,Isecs\_per\_year,m)}}
\DoxyCodeLine{365     \textcolor{keywordflow}{do} k=cs\%nkml+1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{366       cs\%tr(i,j,k,m) = cs\%tr(i,j,k,m) + g\%mask2dT(i,j)*dt*isecs\_per\_year}
\DoxyCodeLine{367 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{368 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{369 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceideal__age__example_aea477e25ddf0fdc4f05fd45a102eb7c0}\label{namespaceideal__age__example_aea477e25ddf0fdc4f05fd45a102eb7c0}} 
\index{ideal\_age\_example@{ideal\_age\_example}!ideal\_age\_tracer\_surface\_state@{ideal\_age\_tracer\_surface\_state}}
\index{ideal\_age\_tracer\_surface\_state@{ideal\_age\_tracer\_surface\_state}!ideal\_age\_example@{ideal\_age\_example}}
\doxysubsubsection{\texorpdfstring{ideal\_age\_tracer\_surface\_state()}{ideal\_age\_tracer\_surface\_state()}}
{\footnotesize\ttfamily subroutine, public ideal\+\_\+age\+\_\+example\+::ideal\+\_\+age\+\_\+tracer\+\_\+surface\+\_\+state (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structideal__age__example_1_1ideal__age__tracer__cs}{ideal\+\_\+age\+\_\+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\+\_\+ideal\+\_\+age\+\_\+tracer. \\
\hline
\end{DoxyParams}


Definition at line 424 of file ideal\+\_\+age\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{424   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The ocean's grid structure.}}
\DoxyCodeLine{425   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{426 \textcolor{comment}{                                              !! describe the surface state of the ocean.}}
\DoxyCodeLine{427 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{428                           \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thickness [H ~> m or kg m-\/2].}}
\DoxyCodeLine{429   \textcolor{keywordtype}{type}(ideal\_age\_tracer\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{430 \textcolor{comment}{                                              !! call to register\_ideal\_age\_tracer.}}
\DoxyCodeLine{431 }
\DoxyCodeLine{432   \textcolor{comment}{! This particular tracer package does not report anything back to the coupler.}}
\DoxyCodeLine{433   \textcolor{comment}{! The code that is here is just a rough guide for packages that would.}}
\DoxyCodeLine{434 }
\DoxyCodeLine{435   \textcolor{keywordtype}{integer} :: m, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{436   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{437   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{438 }
\DoxyCodeLine{439   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{440 }
\DoxyCodeLine{441   \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{442     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{443       \textcolor{comment}{!   This call loads the surface values into the appropriate array in the}}
\DoxyCodeLine{444       \textcolor{comment}{! coupler-\/type structure.}}
\DoxyCodeLine{445       \textcolor{keyword}{call }coupler\_type\_set\_data(cs\%tr(:,:,1,m), cs\%ind\_tr(m), ind\_csurf, \&}
\DoxyCodeLine{446                    sfc\_state\%tr\_fields, idim=(/isd, is, ie, ied/), \&}
\DoxyCodeLine{447                    jdim=(/jsd, js, je, jed/) )}
\DoxyCodeLine{448 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{449 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{450 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceideal__age__example_ae8c12d0128c24a491f7af62d4dd6ec5d}\label{namespaceideal__age__example_ae8c12d0128c24a491f7af62d4dd6ec5d}} 
\index{ideal\_age\_example@{ideal\_age\_example}!initialize\_ideal\_age\_tracer@{initialize\_ideal\_age\_tracer}}
\index{initialize\_ideal\_age\_tracer@{initialize\_ideal\_age\_tracer}!ideal\_age\_example@{ideal\_age\_example}}
\doxysubsubsection{\texorpdfstring{initialize\_ideal\_age\_tracer()}{initialize\_ideal\_age\_tracer()}}
{\footnotesize\ttfamily subroutine, public ideal\+\_\+age\+\_\+example\+::initialize\+\_\+ideal\+\_\+age\+\_\+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[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structideal__age__example_1_1ideal__age__tracer__cs}{ideal\+\_\+age\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(sponge\+\_\+cs), pointer}]{sponge\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Sets the ideal age traces to their initial values and 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 us} & A dimensional unit scaling type \\
\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\+\_\+ideal\+\_\+age\+\_\+tracer. \\
\hline
 & {\em sponge\+\_\+csp} & Pointer to the control structure for the sponges. \\
\hline
\end{DoxyParams}


Definition at line 198 of file ideal\+\_\+age\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{198   \textcolor{keywordtype}{logical},                            \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}}
\DoxyCodeLine{199 \textcolor{comment}{                                                         !! been read from a restart file.}}
\DoxyCodeLine{200   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{  !< Time of the start of the run.}}
\DoxyCodeLine{201   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{202   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{203   \textcolor{keywordtype}{type}(unit\_scale\_type),              \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{204 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{205                                       \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{206   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< A structure that is used to regulate}}
\DoxyCodeLine{207 \textcolor{comment}{                                                         !! diagnostic output.}}
\DoxyCodeLine{208   \textcolor{keywordtype}{type}(ocean\_OBC\_type),               \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{  !< This open boundary condition type specifies}}
\DoxyCodeLine{209 \textcolor{comment}{                                                         !! whether, where, and what open boundary}}
\DoxyCodeLine{210 \textcolor{comment}{                                                         !! conditions are used.}}
\DoxyCodeLine{211   \textcolor{keywordtype}{type}(ideal\_age\_tracer\_CS),          \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{212 \textcolor{comment}{                                                       !! call to register\_ideal\_age\_tracer.}}
\DoxyCodeLine{213   \textcolor{keywordtype}{type}(sponge\_CS),                    \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< Pointer to the control structure for the sponges.}}
\DoxyCodeLine{214 }
\DoxyCodeLine{215 \textcolor{comment}{!   This subroutine initializes the CS\%ntr tracer fields in tr(:,:,:,:)}}
\DoxyCodeLine{216 \textcolor{comment}{! and it sets up the tracer output.}}
\DoxyCodeLine{217 }
\DoxyCodeLine{218   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{219   \textcolor{keywordtype}{character(len=24)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}}
\DoxyCodeLine{220   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}}
\DoxyCodeLine{221   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}}
\DoxyCodeLine{222   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for age tracer fluxes, either}}
\DoxyCodeLine{223                                 \textcolor{comment}{! years m3 s-\/1 or years kg s-\/1.}}
\DoxyCodeLine{224   \textcolor{keywordtype}{character(len=72)} :: cmorname \textcolor{comment}{! The CMOR name of that variable.}}
\DoxyCodeLine{225   \textcolor{keywordtype}{logical} :: OK}
\DoxyCodeLine{226   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{227   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{228 }
\DoxyCodeLine{229   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{230   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{231   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{232   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{233   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{234 }
\DoxyCodeLine{235   cs\%Time => day}
\DoxyCodeLine{236   cs\%diag => diag}
\DoxyCodeLine{237   cs\%nkml = max(gv\%nkml,1)}
\DoxyCodeLine{238 }
\DoxyCodeLine{239   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{240     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=name, \&}
\DoxyCodeLine{241                        caller=\textcolor{stringliteral}{"initialize\_ideal\_age\_tracer"})}
\DoxyCodeLine{242     \textcolor{keywordflow}{if} ((.not.restart) .or. (cs\%tracers\_may\_reinit .and. .not. \&}
\DoxyCodeLine{243         query\_initialized(cs\%tr(:,:,:,m), name, cs\%restart\_CSp))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{244 }
\DoxyCodeLine{245       \textcolor{keywordflow}{if} (len\_trim(cs\%IC\_file) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{246   \textcolor{comment}{!  Read the tracer concentrations from a netcdf file.}}
\DoxyCodeLine{247         \textcolor{keywordflow}{if} (.not.file\_exists(cs\%IC\_file, g\%Domain)) \&}
\DoxyCodeLine{248           \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"initialize\_ideal\_age\_tracer: "}// \&}
\DoxyCodeLine{249                                  \textcolor{stringliteral}{"Unable to open "}//cs\%IC\_file)}
\DoxyCodeLine{250 }
\DoxyCodeLine{251         \textcolor{keywordflow}{if} (cs\%Z\_IC\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{252           ok = tracer\_z\_init(cs\%tr(:,:,:,m), h, cs\%IC\_file, name,\&}
\DoxyCodeLine{253                              g, us, -\/1e34, 0.0) \textcolor{comment}{! CS\%land\_val(m))}}
\DoxyCodeLine{254           \textcolor{keywordflow}{if} (.not.ok) \textcolor{keywordflow}{then}}
\DoxyCodeLine{255             ok = tracer\_z\_init(cs\%tr(:,:,:,m), h, cs\%IC\_file, \&}
\DoxyCodeLine{256                      trim(name), g, us, -\/1e34, 0.0) \textcolor{comment}{! CS\%land\_val(m))}}
\DoxyCodeLine{257             \textcolor{keywordflow}{if} (.not.ok) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_ideal\_age\_tracer: "}//\&}
\DoxyCodeLine{258                     \textcolor{stringliteral}{"Unable to read "}//trim(name)//\textcolor{stringliteral}{" from "}//\&}
\DoxyCodeLine{259                     trim(cs\%IC\_file)//\textcolor{stringliteral}{"."})}
\DoxyCodeLine{260 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{261         \textcolor{keywordflow}{else}}
\DoxyCodeLine{262           \textcolor{keyword}{call }mom\_read\_data(cs\%IC\_file, trim(name), cs\%tr(:,:,:,m), g\%Domain)}
\DoxyCodeLine{263 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{264       \textcolor{keywordflow}{else}}
\DoxyCodeLine{265         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{266           \textcolor{keywordflow}{if} (g\%mask2dT(i,j) < 0.5) \textcolor{keywordflow}{then}}
\DoxyCodeLine{267             cs\%tr(i,j,k,m) = cs\%land\_val(m)}
\DoxyCodeLine{268           \textcolor{keywordflow}{else}}
\DoxyCodeLine{269             cs\%tr(i,j,k,m) = cs\%IC\_val(m)}
\DoxyCodeLine{270 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{271 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{272 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{273 }
\DoxyCodeLine{274 \textcolor{keywordflow}{    endif} \textcolor{comment}{! restart}}
\DoxyCodeLine{275 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! Tracer loop}}
\DoxyCodeLine{276 }
\DoxyCodeLine{277   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{278   \textcolor{comment}{! Steal from updated DOME in the fullness of time.}}
\DoxyCodeLine{279 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{280 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceideal__age__example_a58d550a02148b87b1d1ce979fcaf6c00}\label{namespaceideal__age__example_a58d550a02148b87b1d1ce979fcaf6c00}} 
\index{ideal\_age\_example@{ideal\_age\_example}!register\_ideal\_age\_tracer@{register\_ideal\_age\_tracer}}
\index{register\_ideal\_age\_tracer@{register\_ideal\_age\_tracer}!ideal\_age\_example@{ideal\_age\_example}}
\doxysubsubsection{\texorpdfstring{register\_ideal\_age\_tracer()}{register\_ideal\_age\_tracer()}}
{\footnotesize\ttfamily logical function, public ideal\+\_\+age\+\_\+example\+::register\+\_\+ideal\+\_\+age\+\_\+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{structideal__age__example_1_1ideal__age__tracer__cs}{ideal\+\_\+age\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{tr\+\_\+\+Reg,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



Register the ideal age tracer fields 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\+\_\+ideal\+\_\+age\+\_\+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 73 of file ideal\+\_\+age\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{73   \textcolor{keywordtype}{type}(hor\_index\_type),       \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type structure}}
\DoxyCodeLine{74   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{75   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{76   \textcolor{keywordtype}{type}(ideal\_age\_tracer\_CS),  \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{77 \textcolor{comment}{                                               !! call to register\_ideal\_age\_tracer.}}
\DoxyCodeLine{78   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{79 \textcolor{comment}{                                                  !! structure for the tracer advection and}}
\DoxyCodeLine{80 \textcolor{comment}{                                                  !! diffusion module}}
\DoxyCodeLine{81   \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure}}
\DoxyCodeLine{82 }
\DoxyCodeLine{83 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{84 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{85 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"ideal\_age\_example"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{86   \textcolor{keywordtype}{character(len=200)} :: inputdir \textcolor{comment}{! The directory where the input files are.}}
\DoxyCodeLine{87   \textcolor{keywordtype}{character(len=48)}  :: var\_name \textcolor{comment}{! The variable's name.}}
\DoxyCodeLine{88 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{89   \textcolor{keywordtype}{logical} :: register\_ideal\_age\_tracer}
\DoxyCodeLine{90   \textcolor{keywordtype}{logical} :: do\_ideal\_age, do\_vintage, do\_ideal\_age\_dated}
\DoxyCodeLine{91   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{92   isd = hi\%isd ; ied = hi\%ied ; jsd = hi\%jsd ; jed = hi\%jed ; nz = gv\%ke}
\DoxyCodeLine{93 }
\DoxyCodeLine{94   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{95     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_ideal\_age\_tracer called with an "}// \&}
\DoxyCodeLine{96                              \textcolor{stringliteral}{"associated control structure."})}
\DoxyCodeLine{97     \textcolor{keywordflow}{return}}
\DoxyCodeLine{98 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{99   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{100 }
\DoxyCodeLine{101   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{102   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{103   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DO\_IDEAL\_AGE"}, do\_ideal\_age, \&}
\DoxyCodeLine{104                  \textcolor{stringliteral}{"If true, use an ideal age tracer that is set to 0 age "}//\&}
\DoxyCodeLine{105                  \textcolor{stringliteral}{"in the mixed layer and ages at unit rate in the interior."}, \&}
\DoxyCodeLine{106                  default=.true.)}
\DoxyCodeLine{107   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DO\_IDEAL\_VINTAGE"}, do\_vintage, \&}
\DoxyCodeLine{108                  \textcolor{stringliteral}{"If true, use an ideal vintage tracer that is set to an "}//\&}
\DoxyCodeLine{109                  \textcolor{stringliteral}{"exponentially increasing value in the mixed layer and "}//\&}
\DoxyCodeLine{110                  \textcolor{stringliteral}{"is conserved thereafter."}, default=.false.)}
\DoxyCodeLine{111   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DO\_IDEAL\_AGE\_DATED"}, do\_ideal\_age\_dated, \&}
\DoxyCodeLine{112                  \textcolor{stringliteral}{"If true, use an ideal age tracer that is everywhere 0 "}//\&}
\DoxyCodeLine{113                  \textcolor{stringliteral}{"before IDEAL\_AGE\_DATED\_START\_YEAR, but the behaves like "}//\&}
\DoxyCodeLine{114                  \textcolor{stringliteral}{"the standard ideal age tracer -\/ i.e. is set to 0 age in "}//\&}
\DoxyCodeLine{115                  \textcolor{stringliteral}{"the mixed layer and ages at unit rate in the interior."}, \&}
\DoxyCodeLine{116                  default=.false.)}
\DoxyCodeLine{117 }
\DoxyCodeLine{118 }
\DoxyCodeLine{119   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"AGE\_IC\_FILE"}, cs\%IC\_file, \&}
\DoxyCodeLine{120                  \textcolor{stringliteral}{"The file in which the age-\/tracer initial values can be "}//\&}
\DoxyCodeLine{121                  \textcolor{stringliteral}{"found, or an empty string for internal initialization."}, \&}
\DoxyCodeLine{122                  default=\textcolor{stringliteral}{" "})}
\DoxyCodeLine{123   \textcolor{keywordflow}{if} ((len\_trim(cs\%IC\_file) > 0) .and. (scan(cs\%IC\_file,\textcolor{stringliteral}{'/'}) == 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{124     \textcolor{comment}{! Add the directory if CS\%IC\_file is not already a complete path.}}
\DoxyCodeLine{125     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{126     cs\%IC\_file = trim(slasher(inputdir))//trim(cs\%IC\_file)}
\DoxyCodeLine{127     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/AGE\_IC\_FILE"}, cs\%IC\_file)}
\DoxyCodeLine{128 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{129   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"AGE\_IC\_FILE\_IS\_Z"}, cs\%Z\_IC\_file, \&}
\DoxyCodeLine{130                  \textcolor{stringliteral}{"If true, AGE\_IC\_FILE is in depth space, not layer space"}, \&}
\DoxyCodeLine{131                  default=.false.)}
\DoxyCodeLine{132   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TRACERS\_MAY\_REINIT"}, cs\%tracers\_may\_reinit, \&}
\DoxyCodeLine{133                  \textcolor{stringliteral}{"If true, tracers may go through the initialization code "}//\&}
\DoxyCodeLine{134                  \textcolor{stringliteral}{"if they are not found in the restart files.  Otherwise "}//\&}
\DoxyCodeLine{135                  \textcolor{stringliteral}{"it is a fatal error if the tracers are not found in the "}//\&}
\DoxyCodeLine{136                  \textcolor{stringliteral}{"restart files of a restarted run."}, default=.false.)}
\DoxyCodeLine{137 }
\DoxyCodeLine{138   cs\%ntr = 0}
\DoxyCodeLine{139   \textcolor{keywordflow}{if} (do\_ideal\_age) \textcolor{keywordflow}{then}}
\DoxyCodeLine{140     cs\%ntr = cs\%ntr + 1 ; m = cs\%ntr}
\DoxyCodeLine{141     cs\%tr\_desc(m) = var\_desc(\textcolor{stringliteral}{"age"}, \textcolor{stringliteral}{"yr"}, \textcolor{stringliteral}{"Ideal Age Tracer"}, cmor\_field\_name=\textcolor{stringliteral}{"agessc"}, caller=mdl)}
\DoxyCodeLine{142     cs\%tracer\_ages(m) = .true. ; cs\%sfc\_growth\_rate(m) = 0.0}
\DoxyCodeLine{143     cs\%IC\_val(m) = 0.0 ; cs\%young\_val(m) = 0.0 ; cs\%tracer\_start\_year(m) = 0.0}
\DoxyCodeLine{144 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{145 }
\DoxyCodeLine{146   \textcolor{keywordflow}{if} (do\_vintage) \textcolor{keywordflow}{then}}
\DoxyCodeLine{147     cs\%ntr = cs\%ntr + 1 ; m = cs\%ntr}
\DoxyCodeLine{148     cs\%tr\_desc(m) = var\_desc(\textcolor{stringliteral}{"vintage"}, \textcolor{stringliteral}{"yr"}, \textcolor{stringliteral}{"Exponential Vintage Tracer"}, \&}
\DoxyCodeLine{149                             caller=mdl)}
\DoxyCodeLine{150     cs\%tracer\_ages(m) = .false. ; cs\%sfc\_growth\_rate(m) = 1.0/30.0}
\DoxyCodeLine{151     cs\%IC\_val(m) = 0.0 ; cs\%young\_val(m) = 1e-\/20 ; cs\%tracer\_start\_year(m) = 0.0}
\DoxyCodeLine{152     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"IDEAL\_VINTAGE\_START\_YEAR"}, cs\%tracer\_start\_year(m), \&}
\DoxyCodeLine{153                  \textcolor{stringliteral}{"The date at which the ideal vintage tracer starts."}, \&}
\DoxyCodeLine{154                  units=\textcolor{stringliteral}{"years"}, default=0.0)}
\DoxyCodeLine{155 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{156 }
\DoxyCodeLine{157   \textcolor{keywordflow}{if} (do\_ideal\_age\_dated) \textcolor{keywordflow}{then}}
\DoxyCodeLine{158     cs\%ntr = cs\%ntr + 1 ; m = cs\%ntr}
\DoxyCodeLine{159     cs\%tr\_desc(m) = var\_desc(\textcolor{stringliteral}{"age\_dated"},\textcolor{stringliteral}{"yr"},\textcolor{stringliteral}{"Ideal Age Tracer with a Start Date"},\&}
\DoxyCodeLine{160                             caller=mdl)}
\DoxyCodeLine{161     cs\%tracer\_ages(m) = .true. ; cs\%sfc\_growth\_rate(m) = 0.0}
\DoxyCodeLine{162     cs\%IC\_val(m) = 0.0 ; cs\%young\_val(m) = 0.0 ; cs\%tracer\_start\_year(m) = 0.0}
\DoxyCodeLine{163     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"IDEAL\_AGE\_DATED\_START\_YEAR"}, cs\%tracer\_start\_year(m), \&}
\DoxyCodeLine{164                  \textcolor{stringliteral}{"The date at which the dated ideal age tracer starts."}, \&}
\DoxyCodeLine{165                  units=\textcolor{stringliteral}{"years"}, default=0.0)}
\DoxyCodeLine{166 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{167 }
\DoxyCodeLine{168   \textcolor{keyword}{allocate}(cs\%tr(isd:ied,jsd:jed,nz,cs\%ntr)) ; cs\%tr(:,:,:,:) = 0.0}
\DoxyCodeLine{169 }
\DoxyCodeLine{170   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{171     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration}}
\DoxyCodeLine{172     \textcolor{comment}{! calls.  Curses on the designers and implementers of Fortran90.}}
\DoxyCodeLine{173     tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{174     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=var\_name, \&}
\DoxyCodeLine{175                        caller=\textcolor{stringliteral}{"register\_ideal\_age\_tracer"})}
\DoxyCodeLine{176     \textcolor{comment}{! Register the tracer for horizontal advection, diffusion, and restarts.}}
\DoxyCodeLine{177     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, tr\_desc=cs\%tr\_desc(m), \&}
\DoxyCodeLine{178                          registry\_diags=.true., restart\_cs=restart\_cs, \&}
\DoxyCodeLine{179                          mandatory=.not.cs\%tracers\_may\_reinit, \&}
\DoxyCodeLine{180                          flux\_scale=gv\%H\_to\_m)}
\DoxyCodeLine{181 }
\DoxyCodeLine{182     \textcolor{comment}{!   Set coupled\_tracers to be true (hard-\/coded above) to provide the surface}}
\DoxyCodeLine{183     \textcolor{comment}{! values to the coupler (if any).  This is meta-\/code and its arguments will}}
\DoxyCodeLine{184     \textcolor{comment}{! currently (deliberately) give fatal errors if it is used.}}
\DoxyCodeLine{185     \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \&}
\DoxyCodeLine{186       cs\%ind\_tr(m) = aof\_set\_coupler\_flux(trim(var\_name)//\textcolor{stringliteral}{'\_flux'}, \&}
\DoxyCodeLine{187           flux\_type=\textcolor{stringliteral}{' '}, implementation=\textcolor{stringliteral}{' '}, caller=\textcolor{stringliteral}{"register\_ideal\_age\_tracer"})}
\DoxyCodeLine{188 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{189 }
\DoxyCodeLine{190   cs\%tr\_Reg => tr\_reg}
\DoxyCodeLine{191   cs\%restart\_CSp => restart\_cs}
\DoxyCodeLine{192   register\_ideal\_age\_tracer = .true.}

\end{DoxyCode}
