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


\subsection{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. \subsection*{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}
\subsection*{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}
\subsection*{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}


\subsection{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}}
\subsubsection{\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{\tt in}  & {\em g} & Grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em restart} & .true. if the fields have already been read from a restart file.\\
\hline
\mbox{\tt in}  & {\em day} & Time of the start of the run.\\
\hline
\mbox{\tt in}  & {\em h} & Layer thickness, in m or kg m-\/2.\\
\hline
\mbox{\tt 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}
156 
157   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< Grid structure.}
158   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< The ocean's vertical grid structure.}
159   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}
160 \textcolor{comment}{                                             !! been read from a restart file.}
161   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{ !< Time of the start of the run.}
162   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
163                            \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< Layer thickness, in m or kg m-2.}
164   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< Structure used to regulate diagnostic output.}
165   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< This open boundary condition type specifies}
166 \textcolor{comment}{                                             !! whether, where, and what open boundary}
167 \textcolor{comment}{                                             !! conditions are used. This is not being used for now.}
168   \textcolor{keywordtype}{type}(RGC\_tracer\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{  !< The control structure returned by a previous}
169 \textcolor{comment}{                                             !!   call to RGC\_register\_tracer.}
170   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}    :: layer\_CSp\textcolor{comment}{  !< A pointer to the control structure}
171   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),     \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< A pointer to the control structure for the}
172 \textcolor{comment}{                                             !! sponges, if they are in use.  Otherwise this may be
       unassociated.}
173 
174   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable} :: temp(:,:,:)
175   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:)} :: &
176     OBC\_tr1\_u => null(), & \textcolor{comment}{! These arrays should be allocated and set to}
177     obc\_tr1\_v => null()    \textcolor{comment}{! specify the values of tracer 1 that should come}
178                            \textcolor{comment}{! in through u- and v- points through the open}
179                            \textcolor{comment}{! boundary conditions, in the same units as tr.}
180   \textcolor{keywordtype}{character(len=16)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}
181   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}
182   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}
183   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}
184                             \textcolor{comment}{! kg(tracer) kg(water)-1 m3 s-1 or kg(tracer) s-1.}
185   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()
186   \textcolor{keywordtype}{real} :: h\_neglect         \textcolor{comment}{! A thickness that is so small it is usually lost}
187                             \textcolor{comment}{! in roundoff and can be neglected [H ~> m or kg-2].}
188   \textcolor{keywordtype}{real} :: e(SZK\_(G)+1), e\_top, e\_bot, d\_tr \textcolor{comment}{! Heights [Z ~> m].}
189   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m
190   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB
191   \textcolor{keywordtype}{integer} :: nzdata
192 
193   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
194   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
195   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
196   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
197   h\_neglect = gv%H\_subroundoff
198 
199   cs%Time => day
200   cs%diag => diag
201 
202   \textcolor{keywordflow}{if} (.not.restart) \textcolor{keywordflow}{then}
203     \textcolor{keywordflow}{if} (len\_trim(cs%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}
204       \textcolor{comment}{!  Read the tracer concentrations from a netcdf file.}
205       \textcolor{keywordflow}{if} (.not.file\_exists(cs%tracer\_IC\_file, g%Domain)) &
206         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"RGC\_initialize\_tracer: Unable to open "}// &
207                         cs%tracer\_IC\_file)
208       \textcolor{keywordflow}{do} m=1,ntr
209         \textcolor{keyword}{call }query\_vardesc(cs%tr\_desc(m), name, caller=\textcolor{stringliteral}{"initialize\_RGC\_tracer"})
210         \textcolor{keyword}{call }mom\_read\_data(cs%tracer\_IC\_file, trim(name), cs%tr(:,:,:,m), g%Domain)
211 \textcolor{keywordflow}{      enddo}
212     \textcolor{keywordflow}{else}
213       \textcolor{keywordflow}{do} m=1,ntr
214         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
215           cs%tr(i,j,k,m) = 0.0
216 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
217 \textcolor{keywordflow}{      enddo}
218       m=1
219       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
220          \textcolor{comment}{!set tracer to 1.0 in the surface of the continental shelf}
221          \textcolor{keywordflow}{if} (g%geoLonT(i,j) <= (cs%CSL)) \textcolor{keywordflow}{then}
222             cs%tr(i,j,1,m) = 1.0 \textcolor{comment}{!first layer}
223 \textcolor{keywordflow}{         endif}
224 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
225 
226 \textcolor{keywordflow}{    endif}
227 \textcolor{keywordflow}{  endif} \textcolor{comment}{! restart}
228 
229   \textcolor{keywordflow}{if} ( cs%use\_sponge ) \textcolor{keywordflow}{then}
230 \textcolor{comment}{!  If sponges are used, this damps values to zero in the offshore boundary.}
231 \textcolor{comment}{!  For any tracers that are not damped in the sponge, the call}
232 \textcolor{comment}{! to set\_up\_sponge\_field can simply be omitted.}
233     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(sponge\_csp)) \textcolor{keywordflow}{then} \textcolor{comment}{!ALE mode}
234       nzdata = get\_ale\_sponge\_nz\_data(sponge\_csp)
235       \textcolor{keywordflow}{if} (nzdata>0) \textcolor{keywordflow}{then}
236         \textcolor{keyword}{allocate}(temp(g%isd:g%ied,g%jsd:g%jed,nzdata))
237         \textcolor{keywordflow}{do} k=1,nzdata ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
238           \textcolor{keywordflow}{if} (g%geoLonT(i,j) >= (cs%lenlon - cs%lensponge) .AND. g%geoLonT(i,j) <= cs%lenlon) \textcolor{keywordflow}{then}
239             temp(i,j,k) = 0.0
240 \textcolor{keywordflow}{          endif}
241 \textcolor{keywordflow}{        enddo} ; enddo;\textcolor{keywordflow}{ enddo}
242         \textcolor{keywordflow}{do} m=1,1
243         \textcolor{comment}{! This is needed to force the compiler not to do a copy in the sponge calls.}
244           tr\_ptr => cs%tr(:,:,:,m)
245           \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(temp, g, tr\_ptr, sponge\_csp)
246 \textcolor{keywordflow}{        enddo}
247         \textcolor{keyword}{deallocate}(temp)
248 \textcolor{keywordflow}{      endif}
249 
250     \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(layer\_csp)) \textcolor{keywordflow}{then} \textcolor{comment}{!layer mode}
251       \textcolor{keywordflow}{if} (nz>0) \textcolor{keywordflow}{then}
252         \textcolor{keyword}{allocate}(temp(g%isd:g%ied,g%jsd:g%jed,nz))
253         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
254           \textcolor{keywordflow}{if} (g%geoLonT(i,j) >= (cs%lenlon - cs%lensponge) .AND. g%geoLonT(i,j) <= cs%lenlon) \textcolor{keywordflow}{then}
255             temp(i,j,k) = 0.0
256 \textcolor{keywordflow}{          endif}
257 \textcolor{keywordflow}{        enddo} ; enddo;\textcolor{keywordflow}{ enddo}
258         \textcolor{keywordflow}{do} m=1,1
259           tr\_ptr => cs%tr(:,:,:,m)
260           \textcolor{keyword}{call }set\_up\_sponge\_field(temp, tr\_ptr, g, nz, layer\_csp)
261 \textcolor{keywordflow}{        enddo}
262         \textcolor{keyword}{deallocate}(temp)
263 \textcolor{keywordflow}{      endif}
264     \textcolor{keywordflow}{else}
265       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"RGC\_initialize\_tracer: "}// &
266         \textcolor{stringliteral}{"The pointer to sponge\_CSp must be associated if SPONGE is defined."})
267 \textcolor{keywordflow}{    endif} \textcolor{comment}{!selecting mode/calling error if no pointer}
268 \textcolor{keywordflow}{  endif} \textcolor{comment}{!using sponge}
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}}
\subsubsection{\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{\tt in}  & {\em hi} & A horizontal index type structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure 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}
68   \textcolor{keywordtype}{type}(hor\_index\_type),       \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type structure.}
69   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}
70   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !<A structure indicating the open file to parse}
71 \textcolor{comment}{                                                 !! for model parameter values.}
72   \textcolor{keywordtype}{type}(RGC\_tracer\_CS),        \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< A pointer that is set to point to the control}
73 \textcolor{comment}{                                                 !! structure for this module (in/out).}
74   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer to the tracer registry.}
75   \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure.}
76 
77   \textcolor{keywordtype}{character(len=80)}  :: name, longname
78 \textcolor{comment}{! This include declares and sets the variable "version".}
79 \textcolor{preprocessor}{#include "version\_variable.h"}
80 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"RGC\_tracer"} \textcolor{comment}{! This module's name.}
81   \textcolor{keywordtype}{character(len=200)} :: inputdir
82   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()
83   \textcolor{keywordtype}{logical} :: register\_RGC\_tracer
84   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m
85   isd = hi%isd ; ied = hi%ied ; jsd = hi%jsd ; jed = hi%jed ; nz = gv%ke
86 
87   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
88     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"RGC\_register\_tracer called with an "}// &
89                             \textcolor{stringliteral}{"associated control structure."})
90     \textcolor{keywordflow}{return}
91 \textcolor{keywordflow}{  endif}
92   \textcolor{keyword}{allocate}(cs)
93 
94   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
95   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
96   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RGC\_TRACER\_IC\_FILE"}, cs%tracer\_IC\_file, &
97                  \textcolor{stringliteral}{"The name of a file from which to read the initial \(\backslash\)n"}//&
98                  \textcolor{stringliteral}{"conditions for the RGC tracers, or blank to initialize \(\backslash\)n"}//&
99                  \textcolor{stringliteral}{"them internally."}, default=\textcolor{stringliteral}{" "})
100   \textcolor{keywordflow}{if} (len\_trim(cs%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}
101     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
102     inputdir = slasher(inputdir)
103     cs%tracer\_IC\_file = trim(inputdir)//trim(cs%tracer\_IC\_file)
104     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/RGC\_TRACER\_IC\_FILE"}, &
105                    cs%tracer\_IC\_file)
106 \textcolor{keywordflow}{  endif}
107   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, cs%use\_sponge, &
108                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. \(\backslash\)n"}//&
109                  \textcolor{stringliteral}{"The exact location and properties of those sponges are \(\backslash\)n"}//&
110                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)
111 
112   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENLAT"}, cs%lenlat, &
113                  \textcolor{stringliteral}{"The latitudinal or y-direction length of the domain"}, &
114                  fail\_if\_missing=.true., do\_not\_log=.true.)
115 
116   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENLON"}, cs%lenlon, &
117                  \textcolor{stringliteral}{"The longitudinal or x-direction length of the domain"}, &
118                  fail\_if\_missing=.true., do\_not\_log=.true.)
119 
120   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONT\_SHELF\_LENGTH"}, cs%CSL, &
121                  \textcolor{stringliteral}{"The length of the continental shelf (x dir, km)."}, &
122                  default=15.0)
123 
124   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LENSPONGE"}, cs%lensponge, &
125                  \textcolor{stringliteral}{"The length of the sponge layer (km)."}, &
126                  default=10.0)
127 
128   \textcolor{keyword}{allocate}(cs%tr(isd:ied,jsd:jed,nz,ntr)) ; cs%tr(:,:,:,:) = 0.0
129   \textcolor{keywordflow}{if} (cs%mask\_tracers) \textcolor{keywordflow}{then}
130     \textcolor{keyword}{allocate}(cs%tr\_aux(isd:ied,jsd:jed,nz,ntr)) ; cs%tr\_aux(:,:,:,:) = 0.0
131 \textcolor{keywordflow}{  endif}
132 
133   \textcolor{keywordflow}{do} m=1,ntr
134     \textcolor{keywordflow}{if} (m < 10) \textcolor{keywordflow}{then} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr\_RGC",I1.1)'}) m
135     \textcolor{keywordflow}{else} ; \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("tr\_RGC",I2.2)'}) m ;\textcolor{keywordflow}{ endif}
136     \textcolor{keyword}{write}(longname,\textcolor{stringliteral}{'("Concentration of RGC Tracer ",I2.2)'}) m
137     cs%tr\_desc(m) = var\_desc(name, units=\textcolor{stringliteral}{"kg kg-1"}, longname=longname, caller=mdl)
138 
139     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration calls.}
140     tr\_ptr => cs%tr(:,:,:,m)
141     \textcolor{comment}{! Register the tracer for horizontal advection & diffusion.}
142     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, &
143                          name=name, longname=longname, units=\textcolor{stringliteral}{"kg kg-1"}, &
144                          registry\_diags=.true., flux\_units=\textcolor{stringliteral}{"kg/s"}, &
145                          restart\_cs=restart\_cs)
146 \textcolor{keywordflow}{  enddo}
147 
148   cs%tr\_Reg => tr\_reg
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}}
\subsubsection{\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{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em h\+\_\+old} & Layer thickness before entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em h\+\_\+new} & Layer thickness after entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em ea} & an array to which the amount of fluid entrained\\
\hline
\mbox{\tt in}  & {\em eb} & an array to which the amount of fluid entrained\\
\hline
\mbox{\tt in}  & {\em fluxes} & A structure containing pointers to any possible forcing fields. Unused fields have N\+U\+LL ptrs.\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time covered by this call \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
 & {\em cs} & The control structure returned by a previous call.\\
\hline
\mbox{\tt in}  & {\em evap\+\_\+cfl\+\_\+limit} & Limit on the fraction of the water that can be fluxed out of the top layer in a timestep \mbox{[}nondim\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em minimum\+\_\+forcing\+\_\+depth} & The smallest depth over which fluxes can be applied \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\end{DoxyParams}


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


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