\hypertarget{namespacemom__generic__tracer}{}\section{mom\+\_\+generic\+\_\+tracer Module Reference}
\label{namespacemom__generic__tracer}\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}


\subsection{Detailed Description}
Drives the generic version of tracers T\+O\+P\+AZ and C\+FC and other G\+F\+DL B\+GC components. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure for generic tracers. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespacemom__generic__tracer_a5714b64160c8c96b30f1b641de5ff764}{register\+\_\+mom\+\_\+generic\+\_\+tracer}} (HI, GV, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Initializes the generic tracer packages and adds their tracers to the list Adds the tracers in the list of generic tracers to the set of M\+OM tracers (i.\+e., M\+O\+M-\/register them) Register these tracers for restart. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__generic__tracer_a5a103d836debaf2815b39a3ccb8ae850}{initialize\+\_\+mom\+\_\+generic\+\_\+tracer}} (restart, day, G, GV, US, h, param\+\_\+file, diag, O\+BC, CS, sponge\+\_\+\+C\+Sp, A\+L\+E\+\_\+sponge\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initialize phase II\+: Initialize required variables for generic tracers There are some steps of initialization that cannot be done in register\+\_\+\+M\+O\+M\+\_\+generic\+\_\+tracer This is the place and time to do them\+: Set the grid mask and initial time for all generic tracers. Diag\+\_\+register them. Z\+\_\+diag\+\_\+register them. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__generic__tracer_aa0ea1e7080c580a5598b5bede9ebd017}{mom\+\_\+generic\+\_\+tracer\+\_\+column\+\_\+physics}} (h\+\_\+old, h\+\_\+new, ea, eb, fluxes, Hml, dt, G, GV, CS, tv, optics, evap\+\_\+\+C\+F\+L\+\_\+limit, minimum\+\_\+forcing\+\_\+depth)
\begin{DoxyCompactList}\small\item\em Column physics for generic tracers. Get the coupler values for generic tracers that exchange with atmosphere Update generic tracer concentration fields from sources and sinks. Vertically diffuse generic tracer concentration fields. Update generic tracers from bottom and their bottom reservoir. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespacemom__generic__tracer_a873bcaf0549f1840a111f031e549c5cd}{mom\+\_\+generic\+\_\+tracer\+\_\+stock}} (h, stocks, G, GV, CS, names, units, stock\+\_\+index)
\begin{DoxyCompactList}\small\item\em This subroutine calculates mass-\/weighted integral on the PE either of all available tracer concentrations, or of a tracer that is being requested specifically, returning the number of stocks it has calculated. If the stock\+\_\+index is present, only the stock corresponding to that coded index is returned. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespacemom__generic__tracer_af5c635964fd7dfa7aea41fd17b3b3824}{mom\+\_\+generic\+\_\+tracer\+\_\+min\+\_\+max}} (ind\+\_\+start, got\+\_\+minmax, gmin, gmax, xgmin, ygmin, zgmin, xgmax, ygmax, zgmax, G, CS, names, units)
\begin{DoxyCompactList}\small\item\em This subroutine find the global min and max of either of all available tracer concentrations, or of a tracer that is being requested specifically, returning the number of tracers it has gone through. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__generic__tracer_a4ba8950c78d0aef988f00cbf74a691d5}{mom\+\_\+generic\+\_\+tracer\+\_\+surface\+\_\+state}} (sfc\+\_\+state, h, G, CS)
\begin{DoxyCompactList}\small\item\em This subroutine calculates the surface state and sets coupler values for those generic tracers that have flux exchange with atmosphere. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__generic__tracer_ac7ac1e5cc988131c4bcb1ea11e901a29}{mom\+\_\+generic\+\_\+flux\+\_\+init}} (verbosity)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__generic__tracer_ac7e6d764d4df3376baeaf5ae4db7ba90}{mom\+\_\+generic\+\_\+tracer\+\_\+fluxes\+\_\+accumulate}} (flux\+\_\+tmp, weight)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__generic__tracer_a3890163ae69f4c113abd4523c20510e4}{mom\+\_\+generic\+\_\+tracer\+\_\+get}} (name, member, array, CS)
\begin{DoxyCompactList}\small\item\em Copy the requested tracer into an array. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__generic__tracer_ada9424751eae6d320b5de26faa03a923}{end\+\_\+mom\+\_\+generic\+\_\+tracer}} (CS)
\begin{DoxyCompactList}\small\item\em This subroutine deallocates the memory owned by this module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__generic__tracer_adc781c54c3513e29b19d79bd8ef4cba4}\label{namespacemom__generic__tracer_adc781c54c3513e29b19d79bd8ef4cba4}} 
logical \mbox{\hyperlink{namespacemom__generic__tracer_adc781c54c3513e29b19d79bd8ef4cba4}{g\+\_\+registered}} = .false.
\begin{DoxyCompactList}\small\item\em An state hidden in module data that is very much not allowed in M\+O\+M6. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__generic__tracer_ada9424751eae6d320b5de26faa03a923}\label{namespacemom__generic__tracer_ada9424751eae6d320b5de26faa03a923}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!end\+\_\+mom\+\_\+generic\+\_\+tracer@{end\+\_\+mom\+\_\+generic\+\_\+tracer}}
\index{end\+\_\+mom\+\_\+generic\+\_\+tracer@{end\+\_\+mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{end\+\_\+mom\+\_\+generic\+\_\+tracer()}{end\_mom\_generic\_tracer()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+generic\+\_\+tracer\+::end\+\_\+mom\+\_\+generic\+\_\+tracer (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine deallocates the memory owned by this module. 


\begin{DoxyParams}{Parameters}
{\em cs} & Pointer to the control structure for this module. \\
\hline
\end{DoxyParams}


Definition at line 822 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
822     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< Pointer to the control structure for this module.}
823 
824     \textcolor{keyword}{call }generic\_tracer\_end()
825 
826     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
827       \textcolor{keyword}{deallocate}(cs)
828 \textcolor{keywordflow}{    endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_a5a103d836debaf2815b39a3ccb8ae850}\label{namespacemom__generic__tracer_a5a103d836debaf2815b39a3ccb8ae850}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!initialize\+\_\+mom\+\_\+generic\+\_\+tracer@{initialize\+\_\+mom\+\_\+generic\+\_\+tracer}}
\index{initialize\+\_\+mom\+\_\+generic\+\_\+tracer@{initialize\+\_\+mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{initialize\+\_\+mom\+\_\+generic\+\_\+tracer()}{initialize\_mom\_generic\_tracer()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+generic\+\_\+tracer\+::initialize\+\_\+mom\+\_\+generic\+\_\+tracer (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{restart,  }\item[{type(time\+\_\+type), intent(in), target}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{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(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(sponge\+\_\+cs), pointer}]{sponge\+\_\+\+C\+Sp,  }\item[{type(ale\+\_\+sponge\+\_\+cs), pointer}]{A\+L\+E\+\_\+sponge\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Initialize phase II\+: Initialize required variables for generic tracers There are some steps of initialization that cannot be done in register\+\_\+\+M\+O\+M\+\_\+generic\+\_\+tracer This is the place and time to do them\+: Set the grid mask and initial time for all generic tracers. Diag\+\_\+register them. Z\+\_\+diag\+\_\+register them. 

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


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em restart} & .true. if the fields have already been read from a restart file.\\
\hline
\mbox{\tt in}  & {\em day} & Time of the start of the run.\\
\hline
\mbox{\tt in,out}  & {\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 us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt in}  & {\em diag} & Regulates diagnostic output.\\
\hline
 & {\em obc} & This open boundary condition type specifies whether, where, and what open boundary conditions are used.\\
\hline
 & {\em cs} & Pointer to the control structure for this module.\\
\hline
 & {\em sponge\+\_\+csp} & Pointer to the control structure for the sponges.\\
\hline
 & {\em ale\+\_\+sponge\+\_\+csp} & Pointer to the control structure for the A\+LE sponges. \\
\hline
\end{DoxyParams}


Definition at line 232 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
232     \textcolor{keywordtype}{logical},                               \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already been}
233 \textcolor{comment}{                                                                 !! read from a restart file.}
234     \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target},               \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{     !< Time of the start of the run.}
235     \textcolor{keywordtype}{type}(ocean\_grid\_type),                 \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}
236     \textcolor{keywordtype}{type}(verticalGrid\_type),               \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}
237     \textcolor{keywordtype}{type}(unit\_scale\_type),                 \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}
238     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}
239     \textcolor{keywordtype}{type}(param\_file\_type),                 \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time
       parameters}
240     \textcolor{keywordtype}{type}(diag\_ctrl),               \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{    !< Regulates diagnostic output.}
241     \textcolor{keywordtype}{type}(ocean\_OBC\_type),                  \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{     !< This open boundary condition type
       specifies whether,}
242 \textcolor{comment}{                                                                 !! where, and what open boundary
       conditions are used.}
243     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),           \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{      !< Pointer to the control structure for
       this module.}
244     \textcolor{keywordtype}{type}(sponge\_CS),                       \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< Pointer to the control structure for
       the sponges.}
245     \textcolor{keywordtype}{type}(ALE\_sponge\_CS),                   \textcolor{keywordtype}{pointer}    :: ALE\_sponge\_CSp\textcolor{comment}{ !< Pointer  to the control
       structure for the}
246 \textcolor{comment}{                                                                 !! ALE sponges.}
247 
248     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'initialize\_MOM\_generic\_tracer'}
249     \textcolor{keywordtype}{logical} :: OK
250     \textcolor{keywordtype}{integer} :: i, j, k, isc, iec, jsc, jec, nk
251     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}    :: g\_tracer,g\_tracer\_next
252     \textcolor{keywordtype}{character(len=fm\_string\_len)}      :: g\_tracer\_name
253     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field
254     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr
255     \textcolor{keywordtype}{real},    \textcolor{keywordtype}{dimension(G%isd:G%ied, G%jsd:G%jed,1:G%ke)} :: grid\_tmask
256     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(G%isd:G%ied, G%jsd:G%jed)}        :: grid\_kmt
257 
258     \textcolor{comment}{!! 2010/02/04  Add code to re-initialize Generic Tracers if needed during a model simulation}
259     \textcolor{comment}{!! By default, restart cpio should not contain a Generic Tracer IC file and step below will be skipped.}
260     \textcolor{comment}{!! Ideally, the generic tracer IC file should have the tracers on Z levels.}
261 
262     isc = g%isc ; iec = g%iec ; jsc = g%jsc ; jec = g%jec ; nk = g%ke
263 
264     cs%diag=>diag
265     \textcolor{comment}{!Get the tracer list}
266     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs%g\_tracer\_list)) \textcolor{keyword}{call }mom\_error(fatal, trim(sub\_name)//&
267          \textcolor{stringliteral}{": No tracer in the list."})
268     \textcolor{comment}{!For each tracer name get its  fields}
269     g\_tracer=>cs%g\_tracer\_list
270 
271     \textcolor{keywordflow}{do}
272       \textcolor{keywordflow}{if} (index(cs%IC\_file, \textcolor{stringliteral}{'\_NULL\_'}) /= 0) \textcolor{keywordflow}{then}
273         \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"The name of the IC\_file "}//trim(cs%IC\_file)//&
274                               \textcolor{stringliteral}{" indicates no MOM initialization was asked for the generic tracers."}//&
275                               \textcolor{stringliteral}{"Bypassing the MOM initialization of ALL generic tracers!"})
276         \textcolor{keywordflow}{exit}
277 \textcolor{keywordflow}{      endif}
278       \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,g\_tracer\_name)
279       \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'field'},tr\_field)
280       tr\_ptr => tr\_field(:,:,:,1)
281 
282       \textcolor{keywordflow}{if} (.not.restart .or. (cs%tracers\_may\_reinit .and. &
283           .not.query\_initialized(tr\_ptr, g\_tracer\_name, cs%restart\_CSp))) \textcolor{keywordflow}{then}
284 
285        \textcolor{keywordflow}{if} (g\_tracer%requires\_src\_info ) \textcolor{keywordflow}{then}
286          \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//&
287                              \textcolor{stringliteral}{"initializing generic tracer "}//trim(g\_tracer\_name)//&
288                              \textcolor{stringliteral}{" using MOM\_initialize\_tracer\_from\_Z "})
289 
290          \textcolor{keyword}{call }mom\_initialize\_tracer\_from\_z(h, tr\_ptr, g, gv, us, param\_file,               &
291                                 src\_file = g\_tracer%src\_file,                              &
292                                 src\_var\_nam = g\_tracer%src\_var\_name,                       &
293                                 src\_var\_unit\_conversion = g\_tracer%src\_var\_unit\_conversion,&
294                                 src\_var\_record = g\_tracer%src\_var\_record,                  &
295                                 src\_var\_gridspec = g\_tracer%src\_var\_gridspec               )
296 
297          \textcolor{comment}{!Check/apply the bounds for each g\_tracer}
298          \textcolor{keywordflow}{do} k=1,nk ; \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
299            \textcolor{keywordflow}{if} (tr\_ptr(i,j,k) /= cs%tracer\_land\_val) \textcolor{keywordflow}{then}
300              \textcolor{keywordflow}{if} (tr\_ptr(i,j,k) < g\_tracer%src\_var\_valid\_min) tr\_ptr(i,j,k) = g\_tracer%src\_var\_valid\_min
301              \textcolor{comment}{!Jasmin does not want to apply the maximum for now}
302              \textcolor{comment}{!if (tr\_ptr(i,j,k) > g\_tracer%src\_var\_valid\_max) tr\_ptr(i,j,k) = g\_tracer%src\_var\_valid\_max}
303 \textcolor{keywordflow}{           endif}
304 \textcolor{keywordflow}{         enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
305 
306          \textcolor{comment}{!jgj: Reset CASED to 0 below K=1}
307          \textcolor{keywordflow}{if} ( (trim(g\_tracer\_name) == \textcolor{stringliteral}{'cased'}) .or. (trim(g\_tracer\_name) == \textcolor{stringliteral}{'ca13csed'}) ) \textcolor{keywordflow}{then}
308            \textcolor{keywordflow}{do} k=2,nk ; \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
309              \textcolor{keywordflow}{if} (tr\_ptr(i,j,k) /= cs%tracer\_land\_val) \textcolor{keywordflow}{then}
310                tr\_ptr(i,j,k) = 0.0
311 \textcolor{keywordflow}{             endif}
312 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
313 \textcolor{keywordflow}{         endif}
314        \textcolor{keywordflow}{elseif}(.not. g\_tracer%requires\_restart) \textcolor{keywordflow}{then}
315          \textcolor{comment}{!Do nothing for this tracer, it is initialized by the tracer package}
316           \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//&
317                             \textcolor{stringliteral}{"skip initialization of generic tracer "}//trim(g\_tracer\_name))
318        \textcolor{keywordflow}{else} \textcolor{comment}{!Do it old way if the tracer is not registered to start from a specific source file.}
319             \textcolor{comment}{!This path should be deprecated if all generic tracers are required to start from specified
       sources.}
320         \textcolor{keywordflow}{if} (len\_trim(cs%IC\_file) > 0) \textcolor{keywordflow}{then}
321         \textcolor{comment}{!  Read the tracer concentrations from a netcdf file.}
322           \textcolor{keywordflow}{if} (.not.file\_exists(cs%IC\_file)) \textcolor{keyword}{call }mom\_error(fatal, &
323                   \textcolor{stringliteral}{"initialize\_MOM\_Generic\_tracer: Unable to open "}//cs%IC\_file)
324           \textcolor{keywordflow}{if} (cs%Z\_IC\_file) \textcolor{keywordflow}{then}
325             ok = tracer\_z\_init(tr\_ptr, h, cs%IC\_file, g\_tracer\_name, g, us)
326             \textcolor{keywordflow}{if} (.not.ok) \textcolor{keywordflow}{then}
327               ok = tracer\_z\_init(tr\_ptr, h, cs%IC\_file, trim(g\_tracer\_name), g, us)
328               \textcolor{keywordflow}{if} (.not.ok) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_MOM\_Generic\_tracer: "}//&
329                       \textcolor{stringliteral}{"Unable to read "}//trim(g\_tracer\_name)//\textcolor{stringliteral}{" from "}//&
330                       trim(cs%IC\_file)//\textcolor{stringliteral}{"."})
331 \textcolor{keywordflow}{            endif}
332             \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//&
333                             \textcolor{stringliteral}{"initialized generic tracer "}//trim(g\_tracer\_name)//&
334                             \textcolor{stringliteral}{" using Generic Tracer File on Z: "}//cs%IC\_file)
335           \textcolor{keywordflow}{else}
336             \textcolor{comment}{! native grid}
337             \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//&
338                   \textcolor{stringliteral}{"Using Generic Tracer IC file on native grid "}//trim(cs%IC\_file)//&
339                   \textcolor{stringliteral}{" for tracer "}//trim(g\_tracer\_name))
340             \textcolor{keyword}{call }mom\_read\_data(cs%IC\_file, trim(g\_tracer\_name), tr\_ptr, g%Domain)
341 \textcolor{keywordflow}{          endif}
342         \textcolor{keywordflow}{else}
343           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//&
344                   \textcolor{stringliteral}{"check Generic Tracer IC filename "}//trim(cs%IC\_file)//&
345                   \textcolor{stringliteral}{" for tracer "}//trim(g\_tracer\_name))
346 \textcolor{keywordflow}{        endif}
347 
348 \textcolor{keywordflow}{       endif}
349 \textcolor{keywordflow}{      endif}
350 
351       \textcolor{comment}{!traverse the linked list till hit NULL}
352       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)
353       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}
354       g\_tracer=>g\_tracer\_next
355 \textcolor{keywordflow}{    enddo}
356     \textcolor{comment}{!! end section to re-initialize generic tracers}
357 
358 
359     \textcolor{comment}{!Now we can reset the grid mask, axes and time to their true values}
360     \textcolor{comment}{!Note that grid\_tmask must be set correctly on the data domain boundary}
361     \textcolor{comment}{!so that coast mask can be deduced from it.}
362     grid\_tmask(:,:,:) = 0.0
363     grid\_kmt(:,:) = 0
364     \textcolor{keywordflow}{do} j = g%jsd, g%jed ; \textcolor{keywordflow}{do} i = g%isd, g%ied
365       \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}
366         grid\_tmask(i,j,:) = 1.0
367         grid\_kmt(i,j) = g%ke \textcolor{comment}{! Tell the code that a layer thicker than 1m is the bottom layer.}
368 \textcolor{keywordflow}{      endif}
369 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
370     \textcolor{keyword}{call }g\_tracer\_set\_common(g%isc,g%iec,g%jsc,g%jec,g%isd,g%ied,g%jsd,g%jed,&
371                              gv%ke,1,cs%diag%axesTL%handles,grid\_tmask,grid\_kmt,day)
372 
373     \textcolor{comment}{! Register generic tracer modules diagnostics}
374 
375 \textcolor{preprocessor}{#ifdef \_USE\_MOM6\_DIAG}
376 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs%diag)
377 \textcolor{preprocessor}{#endif}
378 \textcolor{preprocessor}{}    \textcolor{keyword}{call }generic\_tracer\_register\_diag()
379 \textcolor{preprocessor}{#ifdef \_USE\_MOM6\_DIAG}
380 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs%diag)
381 \textcolor{preprocessor}{#endif}
382 \textcolor{preprocessor}{}
383     cs%H\_to\_m = gv%H\_to\_m
384 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_ac7ac1e5cc988131c4bcb1ea11e901a29}\label{namespacemom__generic__tracer_ac7ac1e5cc988131c4bcb1ea11e901a29}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+flux\+\_\+init@{mom\+\_\+generic\+\_\+flux\+\_\+init}}
\index{mom\+\_\+generic\+\_\+flux\+\_\+init@{mom\+\_\+generic\+\_\+flux\+\_\+init}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{mom\+\_\+generic\+\_\+flux\+\_\+init()}{mom\_generic\_flux\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+generic\+\_\+tracer\+::mom\+\_\+generic\+\_\+flux\+\_\+init (\begin{DoxyParamCaption}\item[{integer, intent(in), optional}]{verbosity }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em verbosity} & A 0-\/9 integer indicating a level of verbosity. \\
\hline
\end{DoxyParams}


Definition at line 763 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
763     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: verbosity\textcolor{comment}{  !< A 0-9 integer indicating a level of verbosity.}
764 
765     \textcolor{keywordtype}{integer} :: ind
766     \textcolor{keywordtype}{character(len=fm\_string\_len)}   :: g\_tracer\_name,longname, package,units,old\_package,file\_in,file\_out
767     \textcolor{keywordtype}{real} :: const\_init\_value
768     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_flux\_init'}
769     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer} :: g\_tracer\_list,g\_tracer,g\_tracer\_next
770 
771     \textcolor{keywordflow}{if} (.not. g\_registered) \textcolor{keywordflow}{then}
772       \textcolor{keyword}{call }generic\_tracer\_register()
773       g\_registered = .true.
774 \textcolor{keywordflow}{    endif}
775 
776     \textcolor{keyword}{call }generic\_tracer\_get\_list(g\_tracer\_list)
777     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_list)) \textcolor{keywordflow}{then}
778       \textcolor{keyword}{call }mom\_error(warning, trim(sub\_name)// \textcolor{stringliteral}{": No generic tracer in the list."})
779       \textcolor{keywordflow}{return}
780 \textcolor{keywordflow}{    endif}
781 
782     g\_tracer=>g\_tracer\_list
783     \textcolor{keywordflow}{do}
784 
785       \textcolor{keyword}{call }g\_tracer\_flux\_init(g\_tracer) \textcolor{comment}{!, verbosity=verbosity) !### Add this after ocean shared is
       updated.}
786 
787       \textcolor{comment}{! traverse the linked list till hit NULL}
788       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)
789       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}
790       g\_tracer=>g\_tracer\_next
791 
792 \textcolor{keywordflow}{    enddo}
793 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_aa0ea1e7080c580a5598b5bede9ebd017}\label{namespacemom__generic__tracer_aa0ea1e7080c580a5598b5bede9ebd017}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer\+\_\+column\+\_\+physics@{mom\+\_\+generic\+\_\+tracer\+\_\+column\+\_\+physics}}
\index{mom\+\_\+generic\+\_\+tracer\+\_\+column\+\_\+physics@{mom\+\_\+generic\+\_\+tracer\+\_\+column\+\_\+physics}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{mom\+\_\+generic\+\_\+tracer\+\_\+column\+\_\+physics()}{mom\_generic\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+generic\+\_\+tracer\+::mom\+\_\+generic\+\_\+tracer\+\_\+column\+\_\+physics (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h\+\_\+old,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h\+\_\+new,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{ea,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{eb,  }\item[{type(forcing), intent(in)}]{fluxes,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in)}]{Hml,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(optics\+\_\+type), intent(in)}]{optics,  }\item[{real, intent(in), optional}]{evap\+\_\+\+C\+F\+L\+\_\+limit,  }\item[{real, intent(in), optional}]{minimum\+\_\+forcing\+\_\+depth }\end{DoxyParamCaption})}



Column physics for generic tracers. Get the coupler values for generic tracers that exchange with atmosphere Update generic tracer concentration fields from sources and sinks. Vertically diffuse generic tracer concentration fields. Update generic tracers from bottom and their bottom reservoir. 

This subroutine applies diapycnal diffusion and any other column tracer physics or chemistry to the tracers from this file. C\+F\+Cs are relatively simple, as they are passive tracers. with only a surface flux as a source.


\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} & The amount of fluid entrained from the layer\\
\hline
\mbox{\tt in}  & {\em eb} & The amount of fluid entrained from the layer\\
\hline
\mbox{\tt in}  & {\em fluxes} & A structure containing pointers to thermodynamic and tracer forcing fields.\\
\hline
\mbox{\tt in}  & {\em hml} & Mixed layer depth \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time covered by this call \mbox{[}s\mbox{]}\\
\hline
 & {\em cs} & Pointer to the control structure for this module.\\
\hline
\mbox{\tt in}  & {\em tv} & A structure pointing to various thermodynamic variables\\
\hline
\mbox{\tt in}  & {\em optics} & The structure containing optical properties.\\
\hline
\mbox{\tt in}  & {\em evap\+\_\+cfl\+\_\+limit} & Limits how much water can be fluxed out of the top layer Stored previously in diabatic CS.\\
\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 399 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
399     \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{     !< The ocean's grid structure}
400     \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{    !< The ocean's vertical grid structure}
401     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
402                              \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H ~> m or kg m-2].}
403     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
404                              \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H ~> m or kg m-2].}
405     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
406                              \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{    !< The amount of fluid entrained from the layer}
407 \textcolor{comment}{                                                 !! above during this call [H ~> m or kg m-2].}
408     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
409                              \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{    !< The amount of fluid entrained from the layer}
410 \textcolor{comment}{                                                 !! below during this call [H ~> m or kg m-2].}
411     \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}
412 \textcolor{comment}{                                                 !! and tracer forcing fields.}
413     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(in)} :: Hml\textcolor{comment}{  !< Mixed layer depth [Z ~> m]}
414     \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{    !< The amount of time covered by this call [s]}
415     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< Pointer to the control structure for this module.}
416     \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{    !< A structure pointing to various thermodynamic variables}
417     \textcolor{keywordtype}{type}(optics\_type),       \textcolor{keywordtype}{intent(in)} :: optics\textcolor{comment}{ !< The structure containing optical properties.}
418     \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: evap\_CFL\_limit\textcolor{comment}{ !< Limits how much water can be fluxed out of}
419 \textcolor{comment}{                                                 !! the top layer Stored previously in diabatic CS.}
420     \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which fluxes}
421 \textcolor{comment}{                                                 !!  can be applied [H ~> m or kg m-2]}
422                                                  \textcolor{comment}{!   Stored previously in diabatic CS.}
423     \textcolor{comment}{! The arguments to this subroutine are redundant in that}
424     \textcolor{comment}{!     h\_new(k) = h\_old(k) + ea(k) - eb(k-1) + eb(k) - ea(k+1)}
425 
426     \textcolor{comment}{! Local variables}
427     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_column\_physics'}
428 
429     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}  :: g\_tracer, g\_tracer\_next
430     \textcolor{keywordtype}{character(len=fm\_string\_len)}  :: g\_tracer\_name
431     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: stf\_array,trunoff\_array,runoff\_tracer\_flux\_array
432 
433     \textcolor{keywordtype}{real} :: surface\_field(SZI\_(G),SZJ\_(G))
434     \textcolor{keywordtype}{real} :: dz\_ml(SZI\_(G),SZJ\_(G))  \textcolor{comment}{! The mixed layer depth in the MKS units used for generic tracers [m]}
435     \textcolor{keywordtype}{real} :: sosga
436 
437     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed,G%ke)} :: rho\_dzt, dzt
438     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}      :: h\_work
439     \textcolor{keywordtype}{integer} :: i, j, k, isc, iec, jsc, jec, nk
440 
441     isc = g%isc ; iec = g%iec ; jsc = g%jsc ; jec = g%jec ; nk = g%ke
442 
443     \textcolor{comment}{!Get the tracer list}
444     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs%g\_tracer\_list)) \textcolor{keyword}{call }mom\_error(fatal,&
445          trim(sub\_name)//\textcolor{stringliteral}{": No tracer in the list."})
446 
447 \textcolor{preprocessor}{#ifdef \_USE\_MOM6\_DIAG}
448 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs%diag)
449 \textcolor{preprocessor}{#endif}
450 \textcolor{preprocessor}{}
451     \textcolor{comment}{!}
452     \textcolor{comment}{!Extract the tracer surface fields from coupler and update tracer fields from sources}
453     \textcolor{comment}{!}
454     \textcolor{comment}{!call generic\_tracer\_coupler\_get(fluxes%tr\_fluxes)}
455     \textcolor{comment}{!Niki: This is moved out to ocean\_model\_MOM.F90 because if dt\_therm>dt\_cpld we need to average}
456     \textcolor{comment}{!      the fluxes without coming into this subroutine.}
457     \textcolor{comment}{!      MOM5 has to modified to conform.}
458 
459     \textcolor{comment}{!}
460     \textcolor{comment}{!Add contribution of river to surface flux}
461     \textcolor{comment}{!}
462     g\_tracer=>cs%g\_tracer\_list
463     \textcolor{keywordflow}{do}
464        \textcolor{keywordflow}{if} (\_allocated(g\_tracer%trunoff)) \textcolor{keywordflow}{then}
465           \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,g\_tracer\_name)
466           \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'stf'},   stf\_array)
467           \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'trunoff'},trunoff\_array)
468           \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'runoff\_tracer\_flux'},runoff\_tracer\_flux\_array)
469           \textcolor{comment}{!nnz: Why is fluxes%river = 0?}
470           runoff\_tracer\_flux\_array(:,:) = trunoff\_array(:,:) * &
471                    g%US%RZ\_T\_to\_kg\_m2s*fluxes%lrunoff(:,:)
472           stf\_array = stf\_array + runoff\_tracer\_flux\_array
473 \textcolor{keywordflow}{       endif}
474 
475        \textcolor{comment}{!traverse the linked list till hit NULL}
476        \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)
477        \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}
478        g\_tracer=>g\_tracer\_next
479 
480 \textcolor{keywordflow}{    enddo}
481 
482     \textcolor{comment}{!}
483     \textcolor{comment}{!Prepare input arrays for source update}
484     \textcolor{comment}{!}
485 
486     rho\_dzt(:,:,:) = gv%H\_to\_kg\_m2 * gv%Angstrom\_H
487     \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j = jsc, jec ; \textcolor{keywordflow}{do} i = isc, iec  \textcolor{comment}{!\{}
488       rho\_dzt(i,j,k) = gv%H\_to\_kg\_m2 * h\_old(i,j,k)
489 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{!\}}
490 
491     dzt(:,:,:) = 1.0
492     \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j = jsc, jec ; \textcolor{keywordflow}{do} i = isc, iec  \textcolor{comment}{!\{}
493       dzt(i,j,k) = gv%H\_to\_m * h\_old(i,j,k)
494 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{!\}}
495     dz\_ml(:,:) = 0.0
496     \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
497       surface\_field(i,j) = tv%S(i,j,1)
498       dz\_ml(i,j) = g%US%Z\_to\_m * hml(i,j)
499 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
500     sosga = global\_area\_mean(surface\_field, g)
501 
502     \textcolor{comment}{!}
503     \textcolor{comment}{!Calculate tendencies (i.e., field changes at dt) from the sources / sinks}
504     \textcolor{comment}{!}
505     \textcolor{keywordflow}{if} ((g%US%L\_to\_m == 1.0) .and. (g%US%RZ\_to\_kg\_m2 == 1.0) .and. (g%US%s\_to\_T == 1.0)) \textcolor{keywordflow}{then}
506       \textcolor{comment}{! Avoid unnecessary copies when no unit conversion is needed.}
507       \textcolor{keyword}{call }generic\_tracer\_source(tv%T, tv%S, rho\_dzt, dzt, dz\_ml, g%isd, g%jsd, 1, dt, &
508                g%areaT, get\_diag\_time\_end(cs%diag), &
509                optics%nbands, optics%max\_wavelength\_band, optics%sw\_pen\_band, optics%opacity\_band, &
510                internal\_heat=tv%internal\_heat, frunoff=fluxes%frunoff, sosga=sosga)
511     \textcolor{keywordflow}{else}
512       \textcolor{keyword}{call }generic\_tracer\_source(tv%T, tv%S, rho\_dzt, dzt, dz\_ml, g%isd, g%jsd, 1, dt, &
513                g%US%L\_to\_m**2*g%areaT(:,:), get\_diag\_time\_end(cs%diag), &
514                optics%nbands, optics%max\_wavelength\_band, optics%sw\_pen\_band, optics%opacity\_band, &
515                internal\_heat=g%US%RZ\_to\_kg\_m2*tv%internal\_heat(:,:), &
516                frunoff=g%US%RZ\_T\_to\_kg\_m2s*fluxes%frunoff(:,:), sosga=sosga)
517 \textcolor{keywordflow}{    endif}
518 
519     \textcolor{comment}{! This uses applyTracerBoundaryFluxesInOut to handle the change in tracer due to freshwater fluxes}
520     \textcolor{comment}{! usually in ALE mode}
521     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}
522       g\_tracer=>cs%g\_tracer\_list
523       \textcolor{keywordflow}{do}
524         \textcolor{keywordflow}{if} (g\_tracer\_is\_prog(g\_tracer)) \textcolor{keywordflow}{then}
525           \textcolor{keywordflow}{do} k=1,nk ;\textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
526             h\_work(i,j,k) = h\_old(i,j,k)
527 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
528           \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, g\_tracer%field(:,:,:,1), g%US%s\_to\_T*dt, &
529                             fluxes, h\_work, evap\_cfl\_limit, minimum\_forcing\_depth)
530 \textcolor{keywordflow}{        endif}
531 
532          \textcolor{comment}{!traverse the linked list till hit NULL}
533          \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)
534         \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}
535         g\_tracer=>g\_tracer\_next
536 \textcolor{keywordflow}{      enddo}
537 \textcolor{keywordflow}{    endif}
538 
539     \textcolor{comment}{!}
540     \textcolor{comment}{!Update Tr(n)%field from explicit vertical diffusion}
541     \textcolor{comment}{!}
542     \textcolor{comment}{! Use a tridiagonal solver to determine the concentrations after the}
543     \textcolor{comment}{! surface source is applied and diapycnal advection and diffusion occurs.}
544     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}
545       \textcolor{comment}{! Last arg is tau which is always 1 for MOM6}
546       \textcolor{keyword}{call }generic\_tracer\_vertdiff\_g(h\_work, ea, eb, dt, gv%kg\_m2\_to\_H, gv%m\_to\_H, 1)
547     \textcolor{keywordflow}{else}
548       \textcolor{comment}{! Last arg is tau which is always 1 for MOM6}
549       \textcolor{keyword}{call }generic\_tracer\_vertdiff\_g(h\_old, ea, eb, dt, gv%kg\_m2\_to\_H, gv%m\_to\_H, 1)
550 \textcolor{keywordflow}{    endif}
551 
552     \textcolor{comment}{! Update bottom fields after vertical processes}
553 
554     \textcolor{comment}{! Second arg is tau which is always 1 for MOM6}
555     \textcolor{keyword}{call }generic\_tracer\_update\_from\_bottom(dt, 1, get\_diag\_time\_end(cs%diag))
556 
557     \textcolor{comment}{!Output diagnostics via diag\_manager for all generic tracers and their fluxes}
558     \textcolor{keyword}{call }g\_tracer\_send\_diag(cs%g\_tracer\_list, get\_diag\_time\_end(cs%diag), tau=1)
559 \textcolor{preprocessor}{#ifdef \_USE\_MOM6\_DIAG}
560 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs%diag)
561 \textcolor{preprocessor}{#endif}
562 \textcolor{preprocessor}{}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_ac7e6d764d4df3376baeaf5ae4db7ba90}\label{namespacemom__generic__tracer_ac7e6d764d4df3376baeaf5ae4db7ba90}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer\+\_\+fluxes\+\_\+accumulate@{mom\+\_\+generic\+\_\+tracer\+\_\+fluxes\+\_\+accumulate}}
\index{mom\+\_\+generic\+\_\+tracer\+\_\+fluxes\+\_\+accumulate@{mom\+\_\+generic\+\_\+tracer\+\_\+fluxes\+\_\+accumulate}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{mom\+\_\+generic\+\_\+tracer\+\_\+fluxes\+\_\+accumulate()}{mom\_generic\_tracer\_fluxes\_accumulate()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+generic\+\_\+tracer\+::mom\+\_\+generic\+\_\+tracer\+\_\+fluxes\+\_\+accumulate (\begin{DoxyParamCaption}\item[{type(forcing), intent(in)}]{flux\+\_\+tmp,  }\item[{real, intent(in)}]{weight }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em flux\+\_\+tmp} & A structure containing pointers to thermodynamic and tracer forcing fields.\\
\hline
\mbox{\tt in}  & {\em weight} & A weight for accumulating this flux \\
\hline
\end{DoxyParams}


Definition at line 797 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
797     \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(in)}    :: flux\_tmp\textcolor{comment}{  !< A structure containing pointers to}
798 \textcolor{comment}{                                              !! thermodynamic and tracer forcing fields.}
799     \textcolor{keywordtype}{real},          \textcolor{keywordtype}{intent(in)}    :: weight\textcolor{comment}{    !< A weight for accumulating this flux}
800 
801     \textcolor{keyword}{call }generic\_tracer\_coupler\_accumulate(flux\_tmp%tr\_fluxes, weight)
802 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_a3890163ae69f4c113abd4523c20510e4}\label{namespacemom__generic__tracer_a3890163ae69f4c113abd4523c20510e4}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer\+\_\+get@{mom\+\_\+generic\+\_\+tracer\+\_\+get}}
\index{mom\+\_\+generic\+\_\+tracer\+\_\+get@{mom\+\_\+generic\+\_\+tracer\+\_\+get}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{mom\+\_\+generic\+\_\+tracer\+\_\+get()}{mom\_generic\_tracer\_get()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+generic\+\_\+tracer\+::mom\+\_\+generic\+\_\+tracer\+\_\+get (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{name,  }\item[{character(len=$\ast$), intent(in)}]{member,  }\item[{real, dimension(\+:,\+:,\+:), intent(out)}]{array,  }\item[{type(\mbox{\hyperlink{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Copy the requested tracer into an array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em name} & Name of requested tracer.\\
\hline
\mbox{\tt in}  & {\em member} & The tracer element to return.\\
\hline
\mbox{\tt out}  & {\em array} & Array filled by this routine.\\
\hline
 & {\em cs} & Pointer to the control structure for this module. \\
\hline
\end{DoxyParams}


Definition at line 807 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
807     \textcolor{keywordtype}{character(len=*)},         \textcolor{keywordtype}{intent(in)}  :: name\textcolor{comment}{   !< Name of requested tracer.}
808     \textcolor{keywordtype}{character(len=*)},         \textcolor{keywordtype}{intent(in)}  :: member\textcolor{comment}{ !< The tracer element to return.}
809     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)},   \textcolor{keywordtype}{intent(out)} :: array\textcolor{comment}{  !< Array filled by this routine.}
810     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< Pointer to the control structure for this module.}
811 
812     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)},   \textcolor{keywordtype}{pointer} :: array\_ptr
813     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_get'}
814 
815     \textcolor{keyword}{call }g\_tracer\_get\_pointer(cs%g\_tracer\_list,name,member,array\_ptr)
816     array(:,:,:) = array\_ptr(:,:,:)
817 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_af5c635964fd7dfa7aea41fd17b3b3824}\label{namespacemom__generic__tracer_af5c635964fd7dfa7aea41fd17b3b3824}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer\+\_\+min\+\_\+max@{mom\+\_\+generic\+\_\+tracer\+\_\+min\+\_\+max}}
\index{mom\+\_\+generic\+\_\+tracer\+\_\+min\+\_\+max@{mom\+\_\+generic\+\_\+tracer\+\_\+min\+\_\+max}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{mom\+\_\+generic\+\_\+tracer\+\_\+min\+\_\+max()}{mom\_generic\_tracer\_min\_max()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+generic\+\_\+tracer\+::mom\+\_\+generic\+\_\+tracer\+\_\+min\+\_\+max (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{ind\+\_\+start,  }\item[{logical, dimension(\+:), intent(out)}]{got\+\_\+minmax,  }\item[{real, dimension(\+:), intent(out)}]{gmin,  }\item[{real, dimension(\+:), intent(out)}]{gmax,  }\item[{real, dimension(\+:), intent(out)}]{xgmin,  }\item[{real, dimension(\+:), intent(out)}]{ygmin,  }\item[{real, dimension(\+:), intent(out)}]{zgmin,  }\item[{real, dimension(\+:), intent(out)}]{xgmax,  }\item[{real, dimension(\+:), intent(out)}]{ygmax,  }\item[{real, dimension(\+:), intent(out)}]{zgmax,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{character(len=$\ast$), dimension(\+:), intent(out)}]{names,  }\item[{character(len=$\ast$), dimension(\+:), intent(out)}]{units }\end{DoxyParamCaption})}



This subroutine find the global min and max of either of all available tracer concentrations, or of a tracer that is being requested specifically, returning the number of tracers it has gone through. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em ind\+\_\+start} & The index of the tracer to start with\\
\hline
\mbox{\tt out}  & {\em got\+\_\+minmax} & Indicates whether the global min and max are found for each tracer\\
\hline
\mbox{\tt out}  & {\em gmin} & Global minimum of each tracer, in kg times concentration units.\\
\hline
\mbox{\tt out}  & {\em gmax} & Global maximum of each tracer, in kg times concentration units.\\
\hline
\mbox{\tt out}  & {\em xgmin} & The x-\/position of the global minimum\\
\hline
\mbox{\tt out}  & {\em ygmin} & The y-\/position of the global minimum\\
\hline
\mbox{\tt out}  & {\em zgmin} & The z-\/position of the global minimum\\
\hline
\mbox{\tt out}  & {\em xgmax} & The x-\/position of the global maximum\\
\hline
\mbox{\tt out}  & {\em ygmax} & The y-\/position of the global maximum\\
\hline
\mbox{\tt out}  & {\em zgmax} & The z-\/position of the global maximum\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
 & {\em cs} & Pointer to the control structure for this module.\\
\hline
\mbox{\tt out}  & {\em names} & The names of the stocks calculated.\\
\hline
\mbox{\tt out}  & {\em units} & The units of the stocks calculated.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return value, the number of tracers done here. 
\end{DoxyReturn}


Definition at line 636 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
636     \textcolor{keywordtype}{use }mpp\_utilities\_mod, \textcolor{keywordtype}{only}: mpp\_array\_global\_min\_max
637     \textcolor{keywordtype}{integer},                        \textcolor{keywordtype}{intent(in)}    :: ind\_start\textcolor{comment}{ !< The index of the tracer to start with}
638     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(:)},          \textcolor{keywordtype}{intent(out)}   :: got\_minmax\textcolor{comment}{ !< Indicates whether the global min and}
639 \textcolor{comment}{                                                            !! max are found for each tracer}
640     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: gmin\textcolor{comment}{   !< Global minimum of each tracer, in kg}
641 \textcolor{comment}{                                                            !! times concentration units.}
642     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: gmax\textcolor{comment}{   !< Global maximum of each tracer, in kg}
643 \textcolor{comment}{                                                            !! times concentration units.}
644     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: xgmin\textcolor{comment}{  !< The x-position of the global minimum}
645     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: ygmin\textcolor{comment}{  !< The y-position of the global minimum}
646     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: zgmin\textcolor{comment}{  !< The z-position of the global minimum}
647     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: xgmax\textcolor{comment}{  !< The x-position of the global maximum}
648     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: ygmax\textcolor{comment}{  !< The y-position of the global maximum}
649     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: zgmax\textcolor{comment}{  !< The z-position of the global maximum}
650     \textcolor{keywordtype}{type}(ocean\_grid\_type),          \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{      !< The ocean's grid structure}
651     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< Pointer to the control structure for this
       module.}
652     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< The names of the stocks calculated.}
653     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< The units of the stocks calculated.}
654     \textcolor{keywordtype}{integer}                                       :: MOM\_generic\_tracer\_min\_max\textcolor{comment}{ !< Return value, the}
655 \textcolor{comment}{                                                            !! number of tracers done here.}
656 
657 \textcolor{comment}{! Local variables}
658     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}  :: g\_tracer, g\_tracer\_next
659     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field
660     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr
661     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_min\_max'}
662 
663     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)},\textcolor{keywordtype}{pointer} :: grid\_tmask
664     \textcolor{keywordtype}{integer} :: isc,iec,jsc,jec,isd,ied,jsd,jed,nk,ntau
665 
666     \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m
667     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: geo\_z
668 
669     is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
670 
671     mom\_generic\_tracer\_min\_max = 0
672     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
673 
674     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs%g\_tracer\_list)) \textcolor{keywordflow}{return} \textcolor{comment}{! No stocks.}
675 
676 
677     \textcolor{keyword}{call }g\_tracer\_get\_common(isc,iec,jsc,jec,isd,ied,jsd,jed,nk,ntau,grid\_tmask=grid\_tmask)
678 
679     \textcolor{comment}{!  Because the use of a simple z-coordinate can not be assumed, simply}
680     \textcolor{comment}{! use the layer index as the vertical label.}
681     \textcolor{keyword}{allocate}(geo\_z(nk))
682     \textcolor{keywordflow}{do} k=1,nk ; geo\_z(k) = \textcolor{keywordtype}{real(k)} ; enddo
683 
684     m=ind\_start ; g\_tracer=>cs%g\_tracer\_list
685     \textcolor{keywordflow}{do}
686       \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,names(m))
687       \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,names(m),\textcolor{stringliteral}{'units'},units(m))
688       units(m) = trim(units(m))//\textcolor{stringliteral}{" kg"}
689       \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,names(m),\textcolor{stringliteral}{'field'},tr\_field)
690 
691       gmin(m) = -1.0
692       gmax(m) = -1.0
693 
694       tr\_ptr => tr\_field(:,:,:,1)
695 
696       \textcolor{keyword}{call }mpp\_array\_global\_min\_max(tr\_ptr, grid\_tmask,isd,jsd,isc,iec,jsc,jec,nk , gmin(m), gmax(m), &
697                                     g%geoLonT,g%geoLatT,geo\_z,xgmin(m), ygmin(m), zgmin(m), &
698                                     xgmax(m), ygmax(m), zgmax(m))
699 
700       got\_minmax(m) = .true.
701 
702       \textcolor{comment}{!traverse the linked list till hit NULL}
703       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)
704       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}
705       g\_tracer=>g\_tracer\_next
706       m = m+1
707 \textcolor{keywordflow}{    enddo}
708 
709     mom\_generic\_tracer\_min\_max = m
710 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_a873bcaf0549f1840a111f031e549c5cd}\label{namespacemom__generic__tracer_a873bcaf0549f1840a111f031e549c5cd}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer\+\_\+stock@{mom\+\_\+generic\+\_\+tracer\+\_\+stock}}
\index{mom\+\_\+generic\+\_\+tracer\+\_\+stock@{mom\+\_\+generic\+\_\+tracer\+\_\+stock}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{mom\+\_\+generic\+\_\+tracer\+\_\+stock()}{mom\_generic\_tracer\_stock()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+generic\+\_\+tracer\+::mom\+\_\+generic\+\_\+tracer\+\_\+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{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+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})}



This subroutine calculates mass-\/weighted integral on the PE either of all available tracer concentrations, or of a tracer that is being requested specifically, returning the number of stocks it has calculated. If the stock\+\_\+index is present, only the stock corresponding to that coded index is returned. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em stocks} & The mass-\/weighted integrated amount of each tracer, in kg times concentration units \mbox{[}kg conc\mbox{]}.\\
\hline
 & {\em cs} & Pointer to the control structure for this module.\\
\hline
\mbox{\tt out}  & {\em names} & The names of the stocks calculated.\\
\hline
\mbox{\tt out}  & {\em units} & The units of the stocks calculated.\\
\hline
\mbox{\tt in}  & {\em stock\+\_\+index} & The coded index of a specific stock being sought.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return value, the number of stocks calculated here. 
\end{DoxyReturn}


Definition at line 571 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
571     \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}
572     \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}
573     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< Layer thicknesses [H ~> m or kg m-2]}
574     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},                 \textcolor{keywordtype}{intent(out)}   :: stocks\textcolor{comment}{ !< The mass-weighted integrated amount of
       each}
575 \textcolor{comment}{                                                                !! tracer, in kg times concentration units
       [kg conc].}
576     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),        \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< Pointer to the control structure for
       this module.}
577     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< The names of the stocks calculated.}
578     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< The units of the stocks calculated.}
579     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                  \textcolor{keywordtype}{intent(in)}    :: stock\_index\textcolor{comment}{ !< The coded index of a specific stock}
580 \textcolor{comment}{                                                                     !! being sought.}
581     \textcolor{keywordtype}{integer}                                           :: MOM\_generic\_tracer\_stock\textcolor{comment}{ !< Return value, the}
582 \textcolor{comment}{                                                                     !! number of stocks calculated here.}
583 
584 \textcolor{comment}{! Local variables}
585     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}  :: g\_tracer, g\_tracer\_next
586     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field
587     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr
588     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_stock'}
589 
590     \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m
591     is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
592 
593     mom\_generic\_tracer\_stock = 0
594     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
595 
596     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}
597       \textcolor{comment}{! Check whether this stock is available from this routine.}
598 
599       \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}
600       \textcolor{keywordflow}{return}
601 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ endif}
602 
603     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs%g\_tracer\_list)) \textcolor{keywordflow}{return} \textcolor{comment}{! No stocks.}
604 
605     m=1 ; g\_tracer=>cs%g\_tracer\_list
606     \textcolor{keywordflow}{do}
607       \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,names(m))
608       \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,names(m),\textcolor{stringliteral}{'units'},units(m))
609       units(m) = trim(units(m))//\textcolor{stringliteral}{" kg"}
610       \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,names(m),\textcolor{stringliteral}{'field'},tr\_field)
611 
612       stocks(m) = 0.0
613       tr\_ptr => tr\_field(:,:,:,1)
614       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
615         stocks(m) = stocks(m) + tr\_ptr(i,j,k) * &
616                                (g%mask2dT(i,j) * g%US%L\_to\_m**2*g%areaT(i,j) * h(i,j,k))
617 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
618       stocks(m) = gv%H\_to\_kg\_m2 * stocks(m)
619 
620       \textcolor{comment}{!traverse the linked list till hit NULL}
621       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)
622       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}
623       g\_tracer=>g\_tracer\_next
624       m = m+1
625 \textcolor{keywordflow}{    enddo}
626 
627     mom\_generic\_tracer\_stock = m
628 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_a4ba8950c78d0aef988f00cbf74a691d5}\label{namespacemom__generic__tracer_a4ba8950c78d0aef988f00cbf74a691d5}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer\+\_\+surface\+\_\+state@{mom\+\_\+generic\+\_\+tracer\+\_\+surface\+\_\+state}}
\index{mom\+\_\+generic\+\_\+tracer\+\_\+surface\+\_\+state@{mom\+\_\+generic\+\_\+tracer\+\_\+surface\+\_\+state}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{mom\+\_\+generic\+\_\+tracer\+\_\+surface\+\_\+state()}{mom\_generic\_tracer\_surface\_state()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+generic\+\_\+tracer\+::mom\+\_\+generic\+\_\+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{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine calculates the surface state and sets coupler values for those generic tracers that have flux exchange with atmosphere. 

This subroutine sets up the fields that the coupler needs to calculate the C\+FC fluxes between the ocean and atmosphere.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
 & {\em cs} & Pointer to the control structure for this module. \\
\hline
\end{DoxyParams}


Definition at line 720 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
720     \textcolor{keywordtype}{type}(ocean\_grid\_type),                 \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}
721     \textcolor{keywordtype}{type}(surface),                         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
722 \textcolor{comment}{                                                                 !! describe the surface state of the
       ocean.}
723     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}
724     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),           \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< Pointer to the control structure for
       this module.}
725 
726 \textcolor{comment}{! Local variables}
727     \textcolor{keywordtype}{real} :: sosga
728 
729     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_surface\_state'}
730     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed,1:G%ke,1)} :: rho0
731     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed,1:G%ke)} ::  dzt
732     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer} :: g\_tracer
733 
734     \textcolor{comment}{!Set coupler values}
735     \textcolor{comment}{!nnz: fake rho0}
736     rho0=1.0
737 
738     dzt(:,:,:) = cs%H\_to\_m * h(:,:,:)
739 
740     sosga = global\_area\_mean(sfc\_state%SSS, g)
741 
742     \textcolor{keyword}{call }generic\_tracer\_coupler\_set(sfc\_state%tr\_fields,&
743          st=sfc\_state%SST,&
744          ss=sfc\_state%SSS,&
745          rho=rho0,& \textcolor{comment}{!nnz: required for MOM5 and previous versions.}
746          ilb=g%isd, jlb=g%jsd,&
747          dzt=dzt,& \textcolor{comment}{!This is needed for the Mocsy method of carbonate system vars}
748          tau=1,sosga=sosga,model\_time=get\_diag\_time\_end(cs%diag))
749 
750     \textcolor{comment}{!Output diagnostics via diag\_manager for all tracers in this module}
751 \textcolor{comment}{!    if (.NOT. associated(CS%g\_tracer\_list)) call MOM\_error(FATAL, trim(sub\_name)//&}
752 \textcolor{comment}{!         "No tracer in the list.")}
753 \textcolor{comment}{!    call g\_tracer\_send\_diag(CS%g\_tracer\_list, get\_diag\_time\_end(CS%diag), tau=1)}
754     \textcolor{comment}{!Niki: The problem with calling diagnostic outputs here is that this subroutine is called every dt\_cpld}
755     \textcolor{comment}{!      hence if dt\_therm > dt\_cpld we get output (and contribution to the mean) at times that tracers}
756     \textcolor{comment}{!      had not been updated.}
757     \textcolor{comment}{!      Moving this to the end of column physics subrotuine fixes this issue.}
758 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__generic__tracer_a5714b64160c8c96b30f1b641de5ff764}\label{namespacemom__generic__tracer_a5714b64160c8c96b30f1b641de5ff764}} 
\index{mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}!register\+\_\+mom\+\_\+generic\+\_\+tracer@{register\+\_\+mom\+\_\+generic\+\_\+tracer}}
\index{register\+\_\+mom\+\_\+generic\+\_\+tracer@{register\+\_\+mom\+\_\+generic\+\_\+tracer}!mom\+\_\+generic\+\_\+tracer@{mom\+\_\+generic\+\_\+tracer}}
\subsubsection{\texorpdfstring{register\+\_\+mom\+\_\+generic\+\_\+tracer()}{register\_mom\_generic\_tracer()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+generic\+\_\+tracer\+::register\+\_\+mom\+\_\+generic\+\_\+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{structmom__generic__tracer_1_1mom__generic__tracer__cs}{mom\+\_\+generic\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{tr\+\_\+\+Reg,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



Initializes the generic tracer packages and adds their tracers to the list Adds the tracers in the list of generic tracers to the set of M\+OM tracers (i.\+e., M\+O\+M-\/register them) Register these tracers for restart. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi} & Horizontal index ranges\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
 & {\em cs} & Pointer to the control structure for this module\\
\hline
 & {\em tr\+\_\+reg} & Pointer to the control structure for the tracer advection and diffusion module.\\
\hline
 & {\em restart\+\_\+cs} & Pointer to the restart control structure. \\
\hline
\end{DoxyParams}


Definition at line 98 of file M\+O\+M\+\_\+generic\+\_\+tracer.\+F90.


\begin{DoxyCode}
98     \textcolor{keywordtype}{type}(hor\_index\_type),       \textcolor{keywordtype}{intent(in)}   :: HI\textcolor{comment}{         !< Horizontal index ranges}
99     \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)}   :: GV\textcolor{comment}{         !< The ocean's vertical grid structure}
100     \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)}   :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
101     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{         !< Pointer to the control structure for this
       module}
102     \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}      :: tr\_Reg\textcolor{comment}{     !< Pointer to the control structure for the
       tracer}
103 \textcolor{comment}{                                                           !! advection and diffusion module.}
104     \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}      :: restart\_CS\textcolor{comment}{ !< Pointer to the restart control structure.}
105 
106 \textcolor{comment}{! Local variables}
107     \textcolor{keywordtype}{logical} :: register\_MOM\_generic\_tracer
108 
109     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'register\_MOM\_generic\_tracer'}
110     \textcolor{keywordtype}{character(len=200)} :: inputdir \textcolor{comment}{! The directory where NetCDF input files are.}
111     \textcolor{comment}{! These can be overridden later in via the field manager?}
112 
113     \textcolor{keywordtype}{integer} :: ntau, k,i,j,axes(3)
114     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}      :: g\_tracer,g\_tracer\_next
115     \textcolor{keywordtype}{character(len=fm\_string\_len)}      :: g\_tracer\_name,longname,units
116     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field
117     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr
118     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied, HI%jsd:HI%jed,GV%ke)}         :: grid\_tmask
119     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied, HI%jsd:HI%jed)}           :: grid\_kmt
120 
121     register\_mom\_generic\_tracer = .false.
122     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
123       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_MOM\_generic\_tracer called with an "}// &
124             \textcolor{stringliteral}{"associated control structure."})
125       \textcolor{keywordflow}{return}
126 \textcolor{keywordflow}{    endif}
127     \textcolor{keyword}{allocate}(cs)
128 
129 
130     \textcolor{comment}{!Register all the generic tracers used and create the list of them.}
131     \textcolor{comment}{!This can be called by ALL PE's. No array fields allocated.}
132     \textcolor{keywordflow}{if} (.not. g\_registered) \textcolor{keywordflow}{then}
133        \textcolor{keyword}{call }generic\_tracer\_register()
134        g\_registered = .true.
135 \textcolor{keywordflow}{    endif}
136 
137 
138   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
139     \textcolor{keyword}{call }log\_version(param\_file, sub\_name, version, \textcolor{stringliteral}{""})
140     \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"GENERIC\_TRACER\_IC\_FILE"}, cs%IC\_file, &
141                  \textcolor{stringliteral}{"The file in which the generic trcer initial values can "}//&
142                  \textcolor{stringliteral}{"be found, or an empty string for internal initialization."}, &
143                  default=\textcolor{stringliteral}{" "})
144     \textcolor{keywordflow}{if} ((len\_trim(cs%IC\_file) > 0) .and. (scan(cs%IC\_file,\textcolor{stringliteral}{'/'}) == 0)) \textcolor{keywordflow}{then}
145       \textcolor{comment}{! Add the directory if CS%IC\_file is not already a complete path.}
146       \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
147       cs%IC\_file = trim(slasher(inputdir))//trim(cs%IC\_file)
148       \textcolor{keyword}{call }log\_param(param\_file, sub\_name, \textcolor{stringliteral}{"INPUTDIR/GENERIC\_TRACER\_IC\_FILE"}, cs%IC\_file)
149 \textcolor{keywordflow}{    endif}
150     \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"GENERIC\_TRACER\_IC\_FILE\_IS\_Z"}, cs%Z\_IC\_file, &
151                  \textcolor{stringliteral}{"If true, GENERIC\_TRACER\_IC\_FILE is in depth space, not "}//&
152                  \textcolor{stringliteral}{"layer space."},default=.false.)
153     \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"TRACERS\_MAY\_REINIT"}, cs%tracers\_may\_reinit, &
154                  \textcolor{stringliteral}{"If true, tracers may go through the initialization code "}//&
155                  \textcolor{stringliteral}{"if they are not found in the restart files.  Otherwise "}//&
156                  \textcolor{stringliteral}{"it is a fatal error if tracers are not found in the "}//&
157                  \textcolor{stringliteral}{"restart files of a restarted run."}, default=.false.)
158 
159     cs%restart\_CSp => restart\_cs
160 
161 
162     ntau=1 \textcolor{comment}{! MOM needs the fields at only one time step}
163 
164 
165     \textcolor{comment}{!   At this point G%mask2dT and CS%diag%axesTL are not allocated.}
166     \textcolor{comment}{! postpone diag\_registeration to initialize\_MOM\_generic\_tracer}
167 
168     \textcolor{comment}{!Fields cannot be diag registered as they are allocated and have to registered later.}
169     grid\_tmask(:,:,:) = 0.0
170     grid\_kmt(:,:) = 0.0
171     axes(:) = -1
172 
173     \textcolor{comment}{!}
174     \textcolor{comment}{! Initialize all generic tracers}
175     \textcolor{comment}{!}
176     \textcolor{keyword}{call }generic\_tracer\_init(hi%isc,hi%iec,hi%jsc,hi%jec,hi%isd,hi%ied,hi%jsd,hi%jed,&
177          gv%ke,ntau,axes,grid\_tmask,grid\_kmt,set\_time(0,0))
178 
179 
180     \textcolor{comment}{!}
181     \textcolor{comment}{! MOM-register the generic tracers}
182     \textcolor{comment}{!}
183 
184     \textcolor{comment}{!Get the tracer list}
185     \textcolor{keyword}{call }generic\_tracer\_get\_list(cs%g\_tracer\_list)
186     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs%g\_tracer\_list)) \textcolor{keyword}{call }mom\_error(fatal, trim(sub\_name)//&
187          \textcolor{stringliteral}{": No tracer in the list."})
188     \textcolor{comment}{! For each tracer name get its T\_prog index and get its fields}
189 
190     g\_tracer=>cs%g\_tracer\_list
191     \textcolor{keywordflow}{do}
192        \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,g\_tracer\_name)
193 
194        \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'field'},tr\_field)
195        \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'longname'}, longname)
196        \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'units'},units )
197 
198        \textcolor{comment}{!!nnz: MOM field is 3D. Does this affect performance? Need it be override field?}
199        tr\_ptr => tr\_field(:,:,:,1)
200        \textcolor{comment}{! Register prognastic tracer for horizontal advection, diffusion, and restarts.}
201        \textcolor{keywordflow}{if} (g\_tracer\_is\_prog(g\_tracer)) \textcolor{keywordflow}{then}
202          \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, &
203                               name=g\_tracer\_name, longname=longname, units=units, &
204                               registry\_diags=.false., &   \textcolor{comment}{!### CHANGE TO TRUE?}
205                               restart\_cs=restart\_cs, mandatory=.not.cs%tracers\_may\_reinit)
206        \textcolor{keywordflow}{else}
207          \textcolor{keyword}{call }register\_restart\_field(tr\_ptr, g\_tracer\_name, .not.cs%tracers\_may\_reinit, &
208                                      restart\_cs, longname=longname, units=units)
209 \textcolor{keywordflow}{       endif}
210 
211        \textcolor{comment}{!traverse the linked list till hit NULL}
212        \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)
213        \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}
214        g\_tracer=>g\_tracer\_next
215 
216 \textcolor{keywordflow}{    enddo}
217 
218     register\_mom\_generic\_tracer = .true.
\end{DoxyCode}
