\hypertarget{namespacergc__tracer}{}\doxysection{rgc\+\_\+tracer Module Reference}
\label{namespacergc__tracer}\index{rgc\_tracer@{rgc\_tracer}}


\doxysubsection{Detailed Description}
This module contains the routines used to set up a dynamically passive tracer. Set up and use passive tracers requires the following\+: (1) register\+\_\+\+R\+G\+C\+\_\+tracer (2) apply diffusion, physics/chemistry and advect the tracer. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structrgc__tracer_1_1rgc__tracer__cs}{rgc\+\_\+tracer\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em tracer control structure \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespacergc__tracer_a39b5d56f4cb8c161dd9744e0c2b256de}{register\+\_\+rgc\+\_\+tracer}} (HI, GV, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em This subroutine is used to register tracer fields. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacergc__tracer_ad2da37dd791644961aab6e66a2452793}{initialize\+\_\+rgc\+\_\+tracer}} (restart, day, G, GV, h, diag, O\+BC, CS, layer\+\_\+\+C\+Sp, 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{namespacergc__tracer_ad4ef1aeae0c30402bc2e4d0a2ec248c2}{rgc\+\_\+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 This subroutine applies diapycnal diffusion and any other column tracer physics or chemistry to the tracers from this file. This is a simple example of a set of advected passive tracers. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacergc__tracer_ac32f863f5b15037d5b44b51ed461c2cd}{rgc\+\_\+tracer\+\_\+end}} (CS)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacergc__tracer_a92ad5e7af13730e9f0717ff898146982}\label{namespacergc__tracer_a92ad5e7af13730e9f0717ff898146982}} 
integer, parameter \mbox{\hyperlink{namespacergc__tracer_a92ad5e7af13730e9f0717ff898146982}{ntr}} = 1
\begin{DoxyCompactList}\small\item\em The number of tracers in this module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacergc__tracer_ad2da37dd791644961aab6e66a2452793}\label{namespacergc__tracer_ad2da37dd791644961aab6e66a2452793}} 
\index{rgc\_tracer@{rgc\_tracer}!initialize\_rgc\_tracer@{initialize\_rgc\_tracer}}
\index{initialize\_rgc\_tracer@{initialize\_rgc\_tracer}!rgc\_tracer@{rgc\_tracer}}
\doxysubsubsection{\texorpdfstring{initialize\_rgc\_tracer()}{initialize\_rgc\_tracer()}}
{\footnotesize\ttfamily subroutine, public rgc\+\_\+tracer\+::initialize\+\_\+rgc\+\_\+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( 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{structrgc__tracer_1_1rgc__tracer__cs}{rgc\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(sponge\+\_\+cs), pointer}]{layer\+\_\+\+C\+Sp,  }\item[{type(ale\+\_\+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 g} & Grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\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 h} & Layer thickness, in m or kg m-\/2. \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & Structure used to regulate diagnostic output. \\
\hline
 & {\em obc} & This open boundary condition type specifies whether, where, and what open boundary conditions are used. This is not being used for now. \\
\hline
 & {\em cs} & The control structure returned by a previous call to R\+G\+C\+\_\+register\+\_\+tracer. \\
\hline
 & {\em layer\+\_\+csp} & A pointer to the control structure \\
\hline
 & {\em sponge\+\_\+csp} & A pointer to the control structure for the sponges, if they are in use. Otherwise this may be unassociated. \\
\hline
\end{DoxyParams}


Definition at line 156 of file R\+G\+C\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{156 }
\DoxyCodeLine{157   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< Grid structure.}}
\DoxyCodeLine{158   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< The ocean's vertical grid structure.}}
\DoxyCodeLine{159   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}}
\DoxyCodeLine{160 \textcolor{comment}{                                             !! been read from a restart file.}}
\DoxyCodeLine{161   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{ !< Time of the start of the run.}}
\DoxyCodeLine{162 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{163                            \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< Layer thickness, in m or kg m-\/2.}}
\DoxyCodeLine{164   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< Structure used to regulate diagnostic output.}}
\DoxyCodeLine{165   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< This open boundary condition type specifies}}
\DoxyCodeLine{166 \textcolor{comment}{                                             !! whether, where, and what open boundary}}
\DoxyCodeLine{167 \textcolor{comment}{                                             !! conditions are used. This is not being used for now.}}
\DoxyCodeLine{168   \textcolor{keywordtype}{type}(RGC\_tracer\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{  !< The control structure returned by a previous}}
\DoxyCodeLine{169 \textcolor{comment}{                                             !!   call to RGC\_register\_tracer.}}
\DoxyCodeLine{170   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}    :: layer\_CSp\textcolor{comment}{  !< A pointer to the control structure}}
\DoxyCodeLine{171   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),     \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< A pointer to the control structure for the}}
\DoxyCodeLine{172 \textcolor{comment}{                                             !! sponges, if they are in use.  Otherwise this may be unassociated.}}
\DoxyCodeLine{173 }
\DoxyCodeLine{174 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable} :: temp(:,:,:)}
\DoxyCodeLine{175 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:)} :: \&}
\DoxyCodeLine{176     OBC\_tr1\_u => null(), \& \textcolor{comment}{! These arrays should be allocated and set to}}
\DoxyCodeLine{177     obc\_tr1\_v => null()    \textcolor{comment}{! specify the values of tracer 1 that should come}}
\DoxyCodeLine{178                            \textcolor{comment}{! in through u-\/ and v-\/ points through the open}}
\DoxyCodeLine{179                            \textcolor{comment}{! boundary conditions, in the same units as tr.}}
\DoxyCodeLine{180   \textcolor{keywordtype}{character(len=16)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}}
\DoxyCodeLine{181   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}}
\DoxyCodeLine{182   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}}
\DoxyCodeLine{183   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}}
\DoxyCodeLine{184                             \textcolor{comment}{! kg(tracer) kg(water)-\/1 m3 s-\/1 or kg(tracer) s-\/1.}}
\DoxyCodeLine{185 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{186 \textcolor{keywordtype}{  real} :: h\_neglect         \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{187                             \textcolor{comment}{! in roundoff and can be neglected [H ~> m or kg-\/2].}}
\DoxyCodeLine{188 \textcolor{keywordtype}{  real} :: e(SZK\_(G)+1), e\_top, e\_bot, d\_tr \textcolor{comment}{! Heights [Z ~> m].}}
\DoxyCodeLine{189   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{190   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{191   \textcolor{keywordtype}{integer} :: nzdata}
\DoxyCodeLine{192 }
\DoxyCodeLine{193   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{194   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{195   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{196   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{197   h\_neglect = gv\%H\_subroundoff}
\DoxyCodeLine{198 }
\DoxyCodeLine{199   cs\%Time => day}
\DoxyCodeLine{200   cs\%diag => diag}
\DoxyCodeLine{201 }
\DoxyCodeLine{202   \textcolor{keywordflow}{if} (.not.restart) \textcolor{keywordflow}{then}}
\DoxyCodeLine{203     \textcolor{keywordflow}{if} (len\_trim(cs\%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{204       \textcolor{comment}{!  Read the tracer concentrations from a netcdf file.}}
\DoxyCodeLine{205       \textcolor{keywordflow}{if} (.not.file\_exists(cs\%tracer\_IC\_file, g\%Domain)) \&}
\DoxyCodeLine{206         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"RGC\_initialize\_tracer: Unable to open "}// \&}
\DoxyCodeLine{207                         cs\%tracer\_IC\_file)}
\DoxyCodeLine{208       \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{209         \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name, caller=\textcolor{stringliteral}{"initialize\_RGC\_tracer"})}
\DoxyCodeLine{210         \textcolor{keyword}{call }mom\_read\_data(cs\%tracer\_IC\_file, trim(name), cs\%tr(:,:,:,m), g\%Domain)}
\DoxyCodeLine{211 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{212     \textcolor{keywordflow}{else}}
\DoxyCodeLine{213       \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{214         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{215           cs\%tr(i,j,k,m) = 0.0}
\DoxyCodeLine{216 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{217 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{218       m=1}
\DoxyCodeLine{219       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{220          \textcolor{comment}{!set tracer to 1.0 in the surface of the continental shelf}}
\DoxyCodeLine{221          \textcolor{keywordflow}{if} (g\%geoLonT(i,j) <= (cs\%CSL)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{222             cs\%tr(i,j,1,m) = 1.0 \textcolor{comment}{!first layer}}
\DoxyCodeLine{223 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{224 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{225 }
\DoxyCodeLine{226 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{227 \textcolor{keywordflow}{  endif} \textcolor{comment}{! restart}}
\DoxyCodeLine{228 }
\DoxyCodeLine{229   \textcolor{keywordflow}{if} ( cs\%use\_sponge ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{230 \textcolor{comment}{!  If sponges are used, this damps values to zero in the offshore boundary.}}
\DoxyCodeLine{231 \textcolor{comment}{!  For any tracers that are not damped in the sponge, the call}}
\DoxyCodeLine{232 \textcolor{comment}{! to set\_up\_sponge\_field can simply be omitted.}}
\DoxyCodeLine{233     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(sponge\_csp)) \textcolor{keywordflow}{then} \textcolor{comment}{!ALE mode}}
\DoxyCodeLine{234       nzdata = get\_ale\_sponge\_nz\_data(sponge\_csp)}
\DoxyCodeLine{235       \textcolor{keywordflow}{if} (nzdata>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{236         \textcolor{keyword}{allocate}(temp(g\%isd:g\%ied,g\%jsd:g\%jed,nzdata))}
\DoxyCodeLine{237         \textcolor{keywordflow}{do} k=1,nzdata ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{238           \textcolor{keywordflow}{if} (g\%geoLonT(i,j) >= (cs\%lenlon -\/ cs\%lensponge) .AND. g\%geoLonT(i,j) <= cs\%lenlon) \textcolor{keywordflow}{then}}
\DoxyCodeLine{239             temp(i,j,k) = 0.0}
\DoxyCodeLine{240 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{241 \textcolor{keywordflow}{        enddo} ; enddo;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{242         \textcolor{keywordflow}{do} m=1,1}
\DoxyCodeLine{243         \textcolor{comment}{! This is needed to force the compiler not to do a copy in the sponge calls.}}
\DoxyCodeLine{244           tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{245           \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(temp, g, tr\_ptr, sponge\_csp)}
\DoxyCodeLine{246 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{247         \textcolor{keyword}{deallocate}(temp)}
\DoxyCodeLine{248 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{249 }
\DoxyCodeLine{250     \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(layer\_csp)) \textcolor{keywordflow}{then} \textcolor{comment}{!layer mode}}
\DoxyCodeLine{251       \textcolor{keywordflow}{if} (nz>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{252         \textcolor{keyword}{allocate}(temp(g\%isd:g\%ied,g\%jsd:g\%jed,nz))}
\DoxyCodeLine{253         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{254           \textcolor{keywordflow}{if} (g\%geoLonT(i,j) >= (cs\%lenlon -\/ cs\%lensponge) .AND. g\%geoLonT(i,j) <= cs\%lenlon) \textcolor{keywordflow}{then}}
\DoxyCodeLine{255             temp(i,j,k) = 0.0}
\DoxyCodeLine{256 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{257 \textcolor{keywordflow}{        enddo} ; enddo;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{258         \textcolor{keywordflow}{do} m=1,1}
\DoxyCodeLine{259           tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{260           \textcolor{keyword}{call }set\_up\_sponge\_field(temp, tr\_ptr, g, nz, layer\_csp)}
\DoxyCodeLine{261 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{262         \textcolor{keyword}{deallocate}(temp)}
\DoxyCodeLine{263 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{264     \textcolor{keywordflow}{else}}
\DoxyCodeLine{265       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"RGC\_initialize\_tracer: "}// \&}
\DoxyCodeLine{266         \textcolor{stringliteral}{"The pointer to sponge\_CSp must be associated if SPONGE is defined."})}
\DoxyCodeLine{267 \textcolor{keywordflow}{    endif} \textcolor{comment}{!selecting mode/calling error if no pointer}}
\DoxyCodeLine{268 \textcolor{keywordflow}{  endif} \textcolor{comment}{!using sponge}}
\DoxyCodeLine{269 }

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



This subroutine is used to register tracer fields. 


\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 indicating the open file to parse for model parameter values. \\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module (in/out). \\
\hline
 & {\em tr\+\_\+reg} & A pointer to the tracer registry. \\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure. \\
\hline
\end{DoxyParams}


Definition at line 68 of file R\+G\+C\+\_\+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 indicating the open file to parse}}
\DoxyCodeLine{71 \textcolor{comment}{                                                 !! for model parameter values.}}
\DoxyCodeLine{72   \textcolor{keywordtype}{type}(RGC\_tracer\_CS),        \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< A pointer that is set to point to the control}}
\DoxyCodeLine{73 \textcolor{comment}{                                                 !! structure for this module (in/out).}}
\DoxyCodeLine{74   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer to the tracer registry.}}
\DoxyCodeLine{75   \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure.}}
\DoxyCodeLine{76 }
\DoxyCodeLine{77   \textcolor{keywordtype}{character(len=80)}  :: name, longname}
\DoxyCodeLine{78 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{79 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{80 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"RGC\_tracer"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{81   \textcolor{keywordtype}{character(len=200)} :: inputdir}
\DoxyCodeLine{82 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{83   \textcolor{keywordtype}{logical} :: register\_RGC\_tracer}
\DoxyCodeLine{84   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{85   isd = hi\%isd ; ied = hi\%ied ; jsd = hi\%jsd ; jed = hi\%jed ; nz = gv\%ke}
\DoxyCodeLine{86 }
\DoxyCodeLine{87   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{88     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"RGC\_register\_tracer called with an "}// \&}
\DoxyCodeLine{89                             \textcolor{stringliteral}{"associated control structure."})}
\DoxyCodeLine{90     \textcolor{keywordflow}{return}}
\DoxyCodeLine{91 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{92   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{93 }
\DoxyCodeLine{94   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{95   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{96   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RGC\_TRACER\_IC\_FILE"}, cs\%tracer\_IC\_file, \&}
\DoxyCodeLine{97                  \textcolor{stringliteral}{"The name of a file from which to read the initial \(\backslash\)n"}//\&}
\DoxyCodeLine{98                  \textcolor{stringliteral}{"conditions for the RGC tracers, or blank to initialize \(\backslash\)n"}//\&}
\DoxyCodeLine{99                  \textcolor{stringliteral}{"them internally."}, default=\textcolor{stringliteral}{" "})}
\DoxyCodeLine{100   \textcolor{keywordflow}{if} (len\_trim(cs\%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{101     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{102     inputdir = slasher(inputdir)}
\DoxyCodeLine{103     cs\%tracer\_IC\_file = trim(inputdir)//trim(cs\%tracer\_IC\_file)}
\DoxyCodeLine{104     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/RGC\_TRACER\_IC\_FILE"}, \&}
\DoxyCodeLine{105                    cs\%tracer\_IC\_file)}
\DoxyCodeLine{106 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{107   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, cs\%use\_sponge, \&}
\DoxyCodeLine{108                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. \(\backslash\)n"}//\&}
\DoxyCodeLine{109                  \textcolor{stringliteral}{"The exact location and properties of those sponges are \(\backslash\)n"}//\&}
\DoxyCodeLine{110                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)}
\DoxyCodeLine{111 }
\DoxyCodeLine{112   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENLAT"}, cs\%lenlat, \&}
\DoxyCodeLine{113                  \textcolor{stringliteral}{"The latitudinal or y-\/direction length of the domain"}, \&}
\DoxyCodeLine{114                  fail\_if\_missing=.true., do\_not\_log=.true.)}
\DoxyCodeLine{115 }
\DoxyCodeLine{116   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENLON"}, cs\%lenlon, \&}
\DoxyCodeLine{117                  \textcolor{stringliteral}{"The longitudinal or x-\/direction length of the domain"}, \&}
\DoxyCodeLine{118                  fail\_if\_missing=.true., do\_not\_log=.true.)}
\DoxyCodeLine{119 }
\DoxyCodeLine{120   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONT\_SHELF\_LENGTH"}, cs\%CSL, \&}
\DoxyCodeLine{121                  \textcolor{stringliteral}{"The length of the continental shelf (x dir, km)."}, \&}
\DoxyCodeLine{122                  default=15.0)}
\DoxyCodeLine{123 }
\DoxyCodeLine{124   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENSPONGE"}, cs\%lensponge, \&}
\DoxyCodeLine{125                  \textcolor{stringliteral}{"The length of the sponge layer (km)."}, \&}
\DoxyCodeLine{126                  default=10.0)}
\DoxyCodeLine{127 }
\DoxyCodeLine{128   \textcolor{keyword}{allocate}(cs\%tr(isd:ied,jsd:jed,nz,ntr)) ; cs\%tr(:,:,:,:) = 0.0}
\DoxyCodeLine{129   \textcolor{keywordflow}{if} (cs\%mask\_tracers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{130     \textcolor{keyword}{allocate}(cs\%tr\_aux(isd:ied,jsd:jed,nz,ntr)) ; cs\%tr\_aux(:,:,:,:) = 0.0}
\DoxyCodeLine{131 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{132 }
\DoxyCodeLine{133   \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{134     \textcolor{keywordflow}{if} (m < 10) \textcolor{keywordflow}{then} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr\_RGC",I1.1)'}) m}
\DoxyCodeLine{135     \textcolor{keywordflow}{else} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr\_RGC",I2.2)'}) m ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{136     \textcolor{keyword}{write}(longname,\textcolor{stringliteral}{'("Concentration of RGC Tracer ",I2.2)'}) m}
\DoxyCodeLine{137     cs\%tr\_desc(m) = var\_desc(name, units=\textcolor{stringliteral}{"kg kg-\/1"}, longname=longname, caller=mdl)}
\DoxyCodeLine{138 }
\DoxyCodeLine{139     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration calls.}}
\DoxyCodeLine{140     tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{141     \textcolor{comment}{! Register the tracer for horizontal advection \& diffusion.}}
\DoxyCodeLine{142     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, \&}
\DoxyCodeLine{143                          name=name, longname=longname, units=\textcolor{stringliteral}{"kg kg-\/1"}, \&}
\DoxyCodeLine{144                          registry\_diags=.true., flux\_units=\textcolor{stringliteral}{"kg/s"}, \&}
\DoxyCodeLine{145                          restart\_cs=restart\_cs)}
\DoxyCodeLine{146 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{147 }
\DoxyCodeLine{148   cs\%tr\_Reg => tr\_reg}
\DoxyCodeLine{149   register\_rgc\_tracer = .true.}

\end{DoxyCode}
\mbox{\Hypertarget{namespacergc__tracer_ad4ef1aeae0c30402bc2e4d0a2ec248c2}\label{namespacergc__tracer_ad4ef1aeae0c30402bc2e4d0a2ec248c2}} 
\index{rgc\_tracer@{rgc\_tracer}!rgc\_tracer\_column\_physics@{rgc\_tracer\_column\_physics}}
\index{rgc\_tracer\_column\_physics@{rgc\_tracer\_column\_physics}!rgc\_tracer@{rgc\_tracer}}
\doxysubsubsection{\texorpdfstring{rgc\_tracer\_column\_physics()}{rgc\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public rgc\+\_\+tracer\+::rgc\+\_\+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{structrgc__tracer_1_1rgc__tracer__cs}{rgc\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{real, intent(in), optional}]{evap\+\_\+\+C\+F\+L\+\_\+limit,  }\item[{real, intent(in), optional}]{minimum\+\_\+forcing\+\_\+depth }\end{DoxyParamCaption})}



This subroutine applies diapycnal diffusion and any other column tracer physics or chemistry to the tracers from this file. 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 any possible 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. \\
\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 277 of file R\+G\+C\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{277   \textcolor{keywordtype}{type}(ocean\_grid\_type),                 \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The ocean's grid structure.}}
\DoxyCodeLine{278   \textcolor{keywordtype}{type}(verticalGrid\_type),               \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< The ocean's vertical grid structure.}}
\DoxyCodeLine{279 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{280                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H ~> m or kg m-\/2].}}
\DoxyCodeLine{281 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{282                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H ~> m or kg m-\/2].}}
\DoxyCodeLine{283 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{284                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{285 \textcolor{comment}{                                              !! from the layer above during this call will be}}
\DoxyCodeLine{286 \textcolor{comment}{                                              !! added [H ~> m or kg m-\/2].}}
\DoxyCodeLine{287 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{288                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{289 \textcolor{comment}{                                              !! from the layer below during this call will be}}
\DoxyCodeLine{290 \textcolor{comment}{                                              !! added [H ~> m or kg m-\/2].}}
\DoxyCodeLine{291   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to any possible}}
\DoxyCodeLine{292 \textcolor{comment}{                                              !! forcing fields.  Unused fields have NULL ptrs.}}
\DoxyCodeLine{293 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T ~> s].}}
\DoxyCodeLine{294   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{295   \textcolor{keywordtype}{type}(RGC\_tracer\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< The control structure returned by a previous call.}}
\DoxyCodeLine{296 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: evap\_CFL\_limit\textcolor{comment}{ !< Limit on the fraction of the water that can be}}
\DoxyCodeLine{297 \textcolor{comment}{                                               !! fluxed out of the top layer in a timestep [nondim].}}
\DoxyCodeLine{298 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which fluxes}}
\DoxyCodeLine{299 \textcolor{comment}{                                               !! can be applied [H ~> m or kg m-\/2].}}
\DoxyCodeLine{300 }
\DoxyCodeLine{301 \textcolor{comment}{! The arguments to this subroutine are redundant in that}}
\DoxyCodeLine{302 \textcolor{comment}{!     h\_new[k] = h\_old[k] + ea[k] -\/ eb[k-\/1] + eb[k] -\/ ea[k+1]}}
\DoxyCodeLine{303 }
\DoxyCodeLine{304 \textcolor{keywordtype}{  real} :: b1(SZI\_(G))          \textcolor{comment}{! b1 and c1 are variables used by the}}
\DoxyCodeLine{305 \textcolor{keywordtype}{  real} :: c1(SZI\_(G),SZK\_(G))  \textcolor{comment}{! tridiagonal solver.}}
\DoxyCodeLine{306 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}}
\DoxyCodeLine{307 \textcolor{keywordtype}{  real} :: in\_flux(SZI\_(G),SZJ\_(G),2)  \textcolor{comment}{! total amount of tracer to be injected}}
\DoxyCodeLine{308 }
\DoxyCodeLine{309   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{310   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{311 }
\DoxyCodeLine{312   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{313 }
\DoxyCodeLine{314   in\_flux(:,:,:) = 0.0}
\DoxyCodeLine{315   m=1}
\DoxyCodeLine{316   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{317      \textcolor{comment}{!set tracer to 1.0 in the surface of the continental shelf}}
\DoxyCodeLine{318      \textcolor{keywordflow}{if} (g\%geoLonT(i,j) <= (cs\%CSL)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{319         cs\%tr(i,j,1,m) = 1.0 \textcolor{comment}{!first layer}}
\DoxyCodeLine{320 \textcolor{keywordflow}{     endif}}
\DoxyCodeLine{321 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{322 }
\DoxyCodeLine{323   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{324     \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{325       \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{326         h\_work(i,j,k) = h\_old(i,j,k)}
\DoxyCodeLine{327 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ; enddo;}
\DoxyCodeLine{328       \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs\%tr(:,:,:,m) , dt, fluxes, h\_work, \&}
\DoxyCodeLine{329                                           evap\_cfl\_limit, minimum\_forcing\_depth, in\_flux(:,:,m))}
\DoxyCodeLine{330 }
\DoxyCodeLine{331       \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{332 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{333   \textcolor{keywordflow}{else}}
\DoxyCodeLine{334     \textcolor{keywordflow}{do} m=1,ntr}
\DoxyCodeLine{335       \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{336 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{337 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{338 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacergc__tracer_ac32f863f5b15037d5b44b51ed461c2cd}\label{namespacergc__tracer_ac32f863f5b15037d5b44b51ed461c2cd}} 
\index{rgc\_tracer@{rgc\_tracer}!rgc\_tracer\_end@{rgc\_tracer\_end}}
\index{rgc\_tracer\_end@{rgc\_tracer\_end}!rgc\_tracer@{rgc\_tracer}}
\doxysubsubsection{\texorpdfstring{rgc\_tracer\_end()}{rgc\_tracer\_end()}}
{\footnotesize\ttfamily subroutine, public rgc\+\_\+tracer\+::rgc\+\_\+tracer\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structrgc__tracer_1_1rgc__tracer__cs}{rgc\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}


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


Definition at line 342 of file R\+G\+C\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{342   \textcolor{keywordtype}{type}(RGC\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous call to RGC\_register\_tracer.}}
\DoxyCodeLine{343   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{344 }
\DoxyCodeLine{345   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{346     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%tr)) \textcolor{keyword}{deallocate}(cs\%tr)}
\DoxyCodeLine{347     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{348 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
