\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}{0}
\DoxyCodeLine{822     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< Pointer to the control structure for this module.}}
\DoxyCodeLine{823 }
\DoxyCodeLine{824     \textcolor{keyword}{call }generic\_tracer\_end()}
\DoxyCodeLine{825 }
\DoxyCodeLine{826     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{827       \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{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{\texttt{ in}}  & {\em restart} & .true. if the fields have already been read from a restart file. \\
\hline
\mbox{\texttt{ in}}  & {\em day} & Time of the start of the run. \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{232     \textcolor{keywordtype}{logical},                               \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already been}}
\DoxyCodeLine{233 \textcolor{comment}{                                                                 !! read from a restart file.}}
\DoxyCodeLine{234     \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target},               \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{     !< Time of the start of the run.}}
\DoxyCodeLine{235     \textcolor{keywordtype}{type}(ocean\_grid\_type),                 \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{236     \textcolor{keywordtype}{type}(verticalGrid\_type),               \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{237     \textcolor{keywordtype}{type}(unit\_scale\_type),                 \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{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]}}
\DoxyCodeLine{239     \textcolor{keywordtype}{type}(param\_file\_type),                 \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}}
\DoxyCodeLine{240     \textcolor{keywordtype}{type}(diag\_ctrl),               \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{    !< Regulates diagnostic output.}}
\DoxyCodeLine{241     \textcolor{keywordtype}{type}(ocean\_OBC\_type),                  \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{     !< This open boundary condition type specifies whether,}}
\DoxyCodeLine{242 \textcolor{comment}{                                                                 !! where, and what open boundary conditions are used.}}
\DoxyCodeLine{243     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),           \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{      !< Pointer to the control structure for this module.}}
\DoxyCodeLine{244     \textcolor{keywordtype}{type}(sponge\_CS),                       \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< Pointer to the control structure for the sponges.}}
\DoxyCodeLine{245     \textcolor{keywordtype}{type}(ALE\_sponge\_CS),                   \textcolor{keywordtype}{pointer}    :: ALE\_sponge\_CSp\textcolor{comment}{ !< Pointer  to the control structure for the}}
\DoxyCodeLine{246 \textcolor{comment}{                                                                 !! ALE sponges.}}
\DoxyCodeLine{247 }
\DoxyCodeLine{248     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'initialize\_MOM\_generic\_tracer'}}
\DoxyCodeLine{249     \textcolor{keywordtype}{logical} :: OK}
\DoxyCodeLine{250     \textcolor{keywordtype}{integer} :: i, j, k, isc, iec, jsc, jec, nk}
\DoxyCodeLine{251     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}    :: g\_tracer,g\_tracer\_next}
\DoxyCodeLine{252     \textcolor{keywordtype}{character(len=fm\_string\_len)}      :: g\_tracer\_name}
\DoxyCodeLine{253 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field}
\DoxyCodeLine{254 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr}
\DoxyCodeLine{255 \textcolor{keywordtype}{    real},    \textcolor{keywordtype}{dimension(G\%isd:G\%ied, G\%jsd:G\%jed,1:G\%ke)} :: grid\_tmask}
\DoxyCodeLine{256     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(G\%isd:G\%ied, G\%jsd:G\%jed)}        :: grid\_kmt}
\DoxyCodeLine{257 }
\DoxyCodeLine{258     \textcolor{comment}{!! 2010/02/04  Add code to re-initialize Generic Tracers if needed during a model simulation}}
\DoxyCodeLine{259     \textcolor{comment}{!! By default, restart cpio should not contain a Generic Tracer IC file and step below will be skipped.}}
\DoxyCodeLine{260     \textcolor{comment}{!! Ideally, the generic tracer IC file should have the tracers on Z levels.}}
\DoxyCodeLine{261 }
\DoxyCodeLine{262     isc = g\%isc ; iec = g\%iec ; jsc = g\%jsc ; jec = g\%jec ; nk = g\%ke}
\DoxyCodeLine{263 }
\DoxyCodeLine{264     cs\%diag=>diag}
\DoxyCodeLine{265     \textcolor{comment}{!Get the tracer list}}
\DoxyCodeLine{266     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs\%g\_tracer\_list)) \textcolor{keyword}{call }mom\_error(fatal, trim(sub\_name)//\&}
\DoxyCodeLine{267          \textcolor{stringliteral}{": No tracer in the list."})}
\DoxyCodeLine{268     \textcolor{comment}{!For each tracer name get its  fields}}
\DoxyCodeLine{269     g\_tracer=>cs\%g\_tracer\_list}
\DoxyCodeLine{270 }
\DoxyCodeLine{271     \textcolor{keywordflow}{do}}
\DoxyCodeLine{272       \textcolor{keywordflow}{if} (index(cs\%IC\_file, \textcolor{stringliteral}{'\_NULL\_'}) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{273         \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"The name of the IC\_file "}//trim(cs\%IC\_file)//\&}
\DoxyCodeLine{274                               \textcolor{stringliteral}{" indicates no MOM initialization was asked for the generic tracers."}//\&}
\DoxyCodeLine{275                               \textcolor{stringliteral}{"Bypassing the MOM initialization of ALL generic tracers!"})}
\DoxyCodeLine{276         \textcolor{keywordflow}{exit}}
\DoxyCodeLine{277 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{278       \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,g\_tracer\_name)}
\DoxyCodeLine{279       \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'field'},tr\_field)}
\DoxyCodeLine{280       tr\_ptr => tr\_field(:,:,:,1)}
\DoxyCodeLine{281 }
\DoxyCodeLine{282       \textcolor{keywordflow}{if} (.not.restart .or. (cs\%tracers\_may\_reinit .and. \&}
\DoxyCodeLine{283           .not.query\_initialized(tr\_ptr, g\_tracer\_name, cs\%restart\_CSp))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{284 }
\DoxyCodeLine{285        \textcolor{keywordflow}{if} (g\_tracer\%requires\_src\_info ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{286          \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//\&}
\DoxyCodeLine{287                              \textcolor{stringliteral}{"initializing generic tracer "}//trim(g\_tracer\_name)//\&}
\DoxyCodeLine{288                              \textcolor{stringliteral}{" using MOM\_initialize\_tracer\_from\_Z "})}
\DoxyCodeLine{289 }
\DoxyCodeLine{290          \textcolor{keyword}{call }mom\_initialize\_tracer\_from\_z(h, tr\_ptr, g, gv, us, param\_file,               \&}
\DoxyCodeLine{291                                 src\_file = g\_tracer\%src\_file,                              \&}
\DoxyCodeLine{292                                 src\_var\_nam = g\_tracer\%src\_var\_name,                       \&}
\DoxyCodeLine{293                                 src\_var\_unit\_conversion = g\_tracer\%src\_var\_unit\_conversion,\&}
\DoxyCodeLine{294                                 src\_var\_record = g\_tracer\%src\_var\_record,                  \&}
\DoxyCodeLine{295                                 src\_var\_gridspec = g\_tracer\%src\_var\_gridspec               )}
\DoxyCodeLine{296 }
\DoxyCodeLine{297          \textcolor{comment}{!Check/apply the bounds for each g\_tracer}}
\DoxyCodeLine{298          \textcolor{keywordflow}{do} k=1,nk ; \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{299            \textcolor{keywordflow}{if} (tr\_ptr(i,j,k) /= cs\%tracer\_land\_val) \textcolor{keywordflow}{then}}
\DoxyCodeLine{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}
\DoxyCodeLine{301              \textcolor{comment}{!Jasmin does not want to apply the maximum for now}}
\DoxyCodeLine{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}}
\DoxyCodeLine{303 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{304 \textcolor{keywordflow}{         enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{305 }
\DoxyCodeLine{306          \textcolor{comment}{!jgj: Reset CASED to 0 below K=1}}
\DoxyCodeLine{307          \textcolor{keywordflow}{if} ( (trim(g\_tracer\_name) == \textcolor{stringliteral}{'cased'}) .or. (trim(g\_tracer\_name) == \textcolor{stringliteral}{'ca13csed'}) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{308            \textcolor{keywordflow}{do} k=2,nk ; \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{309              \textcolor{keywordflow}{if} (tr\_ptr(i,j,k) /= cs\%tracer\_land\_val) \textcolor{keywordflow}{then}}
\DoxyCodeLine{310                tr\_ptr(i,j,k) = 0.0}
\DoxyCodeLine{311 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{312 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{313 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{314        \textcolor{keywordflow}{elseif}(.not. g\_tracer\%requires\_restart) \textcolor{keywordflow}{then}}
\DoxyCodeLine{315          \textcolor{comment}{!Do nothing for this tracer, it is initialized by the tracer package}}
\DoxyCodeLine{316           \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//\&}
\DoxyCodeLine{317                             \textcolor{stringliteral}{"skip initialization of generic tracer "}//trim(g\_tracer\_name))}
\DoxyCodeLine{318        \textcolor{keywordflow}{else} \textcolor{comment}{!Do it old way if the tracer is not registered to start from a specific source file.}}
\DoxyCodeLine{319             \textcolor{comment}{!This path should be deprecated if all generic tracers are required to start from specified sources.}}
\DoxyCodeLine{320         \textcolor{keywordflow}{if} (len\_trim(cs\%IC\_file) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{321         \textcolor{comment}{!  Read the tracer concentrations from a netcdf file.}}
\DoxyCodeLine{322           \textcolor{keywordflow}{if} (.not.file\_exists(cs\%IC\_file)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{323                   \textcolor{stringliteral}{"initialize\_MOM\_Generic\_tracer: Unable to open "}//cs\%IC\_file)}
\DoxyCodeLine{324           \textcolor{keywordflow}{if} (cs\%Z\_IC\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{325             ok = tracer\_z\_init(tr\_ptr, h, cs\%IC\_file, g\_tracer\_name, g, us)}
\DoxyCodeLine{326             \textcolor{keywordflow}{if} (.not.ok) \textcolor{keywordflow}{then}}
\DoxyCodeLine{327               ok = tracer\_z\_init(tr\_ptr, h, cs\%IC\_file, trim(g\_tracer\_name), g, us)}
\DoxyCodeLine{328               \textcolor{keywordflow}{if} (.not.ok) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_MOM\_Generic\_tracer: "}//\&}
\DoxyCodeLine{329                       \textcolor{stringliteral}{"Unable to read "}//trim(g\_tracer\_name)//\textcolor{stringliteral}{" from "}//\&}
\DoxyCodeLine{330                       trim(cs\%IC\_file)//\textcolor{stringliteral}{"."})}
\DoxyCodeLine{331 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{332             \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//\&}
\DoxyCodeLine{333                             \textcolor{stringliteral}{"initialized generic tracer "}//trim(g\_tracer\_name)//\&}
\DoxyCodeLine{334                             \textcolor{stringliteral}{" using Generic Tracer File on Z: "}//cs\%IC\_file)}
\DoxyCodeLine{335           \textcolor{keywordflow}{else}}
\DoxyCodeLine{336             \textcolor{comment}{! native grid}}
\DoxyCodeLine{337             \textcolor{keyword}{call }mom\_error(note,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//\&}
\DoxyCodeLine{338                   \textcolor{stringliteral}{"Using Generic Tracer IC file on native grid "}//trim(cs\%IC\_file)//\&}
\DoxyCodeLine{339                   \textcolor{stringliteral}{" for tracer "}//trim(g\_tracer\_name))}
\DoxyCodeLine{340             \textcolor{keyword}{call }mom\_read\_data(cs\%IC\_file, trim(g\_tracer\_name), tr\_ptr, g\%Domain)}
\DoxyCodeLine{341 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{342         \textcolor{keywordflow}{else}}
\DoxyCodeLine{343           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_MOM\_generic\_tracer: "}//\&}
\DoxyCodeLine{344                   \textcolor{stringliteral}{"check Generic Tracer IC filename "}//trim(cs\%IC\_file)//\&}
\DoxyCodeLine{345                   \textcolor{stringliteral}{" for tracer "}//trim(g\_tracer\_name))}
\DoxyCodeLine{346 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{347 }
\DoxyCodeLine{348 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{349 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{350 }
\DoxyCodeLine{351       \textcolor{comment}{!traverse the linked list till hit NULL}}
\DoxyCodeLine{352       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)}
\DoxyCodeLine{353       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{354       g\_tracer=>g\_tracer\_next}
\DoxyCodeLine{355 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{356     \textcolor{comment}{!! end section to re-initialize generic tracers}}
\DoxyCodeLine{357 }
\DoxyCodeLine{358 }
\DoxyCodeLine{359     \textcolor{comment}{!Now we can reset the grid mask, axes and time to their true values}}
\DoxyCodeLine{360     \textcolor{comment}{!Note that grid\_tmask must be set correctly on the data domain boundary}}
\DoxyCodeLine{361     \textcolor{comment}{!so that coast mask can be deduced from it.}}
\DoxyCodeLine{362     grid\_tmask(:,:,:) = 0.0}
\DoxyCodeLine{363     grid\_kmt(:,:) = 0}
\DoxyCodeLine{364     \textcolor{keywordflow}{do} j = g\%jsd, g\%jed ; \textcolor{keywordflow}{do} i = g\%isd, g\%ied}
\DoxyCodeLine{365       \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{366         grid\_tmask(i,j,:) = 1.0}
\DoxyCodeLine{367         grid\_kmt(i,j) = g\%ke \textcolor{comment}{! Tell the code that a layer thicker than 1m is the bottom layer.}}
\DoxyCodeLine{368 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{369 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{370     \textcolor{keyword}{call }g\_tracer\_set\_common(g\%isc,g\%iec,g\%jsc,g\%jec,g\%isd,g\%ied,g\%jsd,g\%jed,\&}
\DoxyCodeLine{371                              gv\%ke,1,cs\%diag\%axesTL\%handles,grid\_tmask,grid\_kmt,day)}
\DoxyCodeLine{372 }
\DoxyCodeLine{373     \textcolor{comment}{! Register generic tracer modules diagnostics}}
\DoxyCodeLine{374 }
\DoxyCodeLine{375 \textcolor{preprocessor}{\#ifdef \_USE\_MOM6\_DIAG}}
\DoxyCodeLine{376 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs\%diag)}
\DoxyCodeLine{377 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{378 \textcolor{preprocessor}{}    \textcolor{keyword}{call }generic\_tracer\_register\_diag()}
\DoxyCodeLine{379 \textcolor{preprocessor}{\#ifdef \_USE\_MOM6\_DIAG}}
\DoxyCodeLine{380 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs\%diag)}
\DoxyCodeLine{381 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{382 \textcolor{preprocessor}{}}
\DoxyCodeLine{383     cs\%H\_to\_m = gv\%H\_to\_m}
\DoxyCodeLine{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{\texttt{ 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}{0}
\DoxyCodeLine{763     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: verbosity\textcolor{comment}{  !< A 0-9 integer indicating a level of verbosity.}}
\DoxyCodeLine{764 }
\DoxyCodeLine{765     \textcolor{keywordtype}{integer} :: ind}
\DoxyCodeLine{766     \textcolor{keywordtype}{character(len=fm\_string\_len)}   :: g\_tracer\_name,longname, package,units,old\_package,file\_in,file\_out}
\DoxyCodeLine{767 \textcolor{keywordtype}{    real} :: const\_init\_value}
\DoxyCodeLine{768     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_flux\_init'}}
\DoxyCodeLine{769     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer} :: g\_tracer\_list,g\_tracer,g\_tracer\_next}
\DoxyCodeLine{770 }
\DoxyCodeLine{771     \textcolor{keywordflow}{if} (.not. g\_registered) \textcolor{keywordflow}{then}}
\DoxyCodeLine{772       \textcolor{keyword}{call }generic\_tracer\_register()}
\DoxyCodeLine{773       g\_registered = .true.}
\DoxyCodeLine{774 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{775 }
\DoxyCodeLine{776     \textcolor{keyword}{call }generic\_tracer\_get\_list(g\_tracer\_list)}
\DoxyCodeLine{777     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_list)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{778       \textcolor{keyword}{call }mom\_error(warning, trim(sub\_name)// \textcolor{stringliteral}{": No generic tracer in the list."})}
\DoxyCodeLine{779       \textcolor{keywordflow}{return}}
\DoxyCodeLine{780 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{781 }
\DoxyCodeLine{782     g\_tracer=>g\_tracer\_list}
\DoxyCodeLine{783     \textcolor{keywordflow}{do}}
\DoxyCodeLine{784 }
\DoxyCodeLine{785       \textcolor{keyword}{call }g\_tracer\_flux\_init(g\_tracer) \textcolor{comment}{!, verbosity=verbosity) !\#\#\# Add this after ocean shared is updated.}}
\DoxyCodeLine{786 }
\DoxyCodeLine{787       \textcolor{comment}{! traverse the linked list till hit NULL}}
\DoxyCodeLine{788       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)}
\DoxyCodeLine{789       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{790       g\_tracer=>g\_tracer\_next}
\DoxyCodeLine{791 }
\DoxyCodeLine{792 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{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{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+old} & Layer thickness before entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+new} & Layer thickness after entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ea} & The amount of fluid entrained from the layer \\
\hline
\mbox{\texttt{ in}}  & {\em eb} & The amount of fluid entrained from the layer \\
\hline
\mbox{\texttt{ in}}  & {\em fluxes} & A structure containing pointers to thermodynamic and tracer forcing fields. \\
\hline
\mbox{\texttt{ in}}  & {\em hml} & Mixed layer depth \mbox{[}Z $\sim$$>$ m\mbox{]} \\
\hline
\mbox{\texttt{ 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{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em optics} & The structure containing optical properties. \\
\hline
\mbox{\texttt{ in}}  & {\em evap\+\_\+cfl\+\_\+limit} & Limits how much water can be fluxed out of the top layer Stored previously in diabatic CS. \\
\hline
\mbox{\texttt{ in}}  & {\em minimum\+\_\+forcing\+\_\+depth} & The smallest depth over which fluxes can be applied \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{399     \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{     !< The ocean's grid structure}}
\DoxyCodeLine{400     \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{    !< The ocean's vertical grid structure}}
\DoxyCodeLine{401 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{402                              \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H ~> m or kg m-2].}}
\DoxyCodeLine{403 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{404                              \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H ~> m or kg m-2].}}
\DoxyCodeLine{405 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{406                              \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{    !< The amount of fluid entrained from the layer}}
\DoxyCodeLine{407 \textcolor{comment}{                                                 !! above during this call [H ~> m or kg m-2].}}
\DoxyCodeLine{408 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{409                              \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{    !< The amount of fluid entrained from the layer}}
\DoxyCodeLine{410 \textcolor{comment}{                                                 !! below during this call [H ~> m or kg m-2].}}
\DoxyCodeLine{411     \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}}
\DoxyCodeLine{412 \textcolor{comment}{                                                 !! and tracer forcing fields.}}
\DoxyCodeLine{413 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(in)} :: Hml\textcolor{comment}{  !< Mixed layer depth [Z ~> m]}}
\DoxyCodeLine{414 \textcolor{keywordtype}{    real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{    !< The amount of time covered by this call [s]}}
\DoxyCodeLine{415     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< Pointer to the control structure for this module.}}
\DoxyCodeLine{416     \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{    !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{417     \textcolor{keywordtype}{type}(optics\_type),       \textcolor{keywordtype}{intent(in)} :: optics\textcolor{comment}{ !< The structure containing optical properties.}}
\DoxyCodeLine{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}}
\DoxyCodeLine{419 \textcolor{comment}{                                                 !! the top layer Stored previously in diabatic CS.}}
\DoxyCodeLine{420 \textcolor{keywordtype}{    real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which fluxes}}
\DoxyCodeLine{421 \textcolor{comment}{                                                 !!  can be applied [H ~> m or kg m-2]}}
\DoxyCodeLine{422                                                  \textcolor{comment}{!   Stored previously in diabatic CS.}}
\DoxyCodeLine{423     \textcolor{comment}{! The arguments to this subroutine are redundant in that}}
\DoxyCodeLine{424     \textcolor{comment}{!     h\_new(k) = h\_old(k) + ea(k) - eb(k-1) + eb(k) - ea(k+1)}}
\DoxyCodeLine{425 }
\DoxyCodeLine{426     \textcolor{comment}{! Local variables}}
\DoxyCodeLine{427     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_column\_physics'}}
\DoxyCodeLine{428 }
\DoxyCodeLine{429     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}  :: g\_tracer, g\_tracer\_next}
\DoxyCodeLine{430     \textcolor{keywordtype}{character(len=fm\_string\_len)}  :: g\_tracer\_name}
\DoxyCodeLine{431 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: stf\_array,trunoff\_array,runoff\_tracer\_flux\_array}
\DoxyCodeLine{432 }
\DoxyCodeLine{433 \textcolor{keywordtype}{    real} :: surface\_field(SZI\_(G),SZJ\_(G))}
\DoxyCodeLine{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]}}
\DoxyCodeLine{435 \textcolor{keywordtype}{    real} :: sosga}
\DoxyCodeLine{436 }
\DoxyCodeLine{437 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(G\%isd:G\%ied,G\%jsd:G\%jed,G\%ke)} :: rho\_dzt, dzt}
\DoxyCodeLine{438 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}      :: h\_work}
\DoxyCodeLine{439     \textcolor{keywordtype}{integer} :: i, j, k, isc, iec, jsc, jec, nk}
\DoxyCodeLine{440 }
\DoxyCodeLine{441     isc = g\%isc ; iec = g\%iec ; jsc = g\%jsc ; jec = g\%jec ; nk = g\%ke}
\DoxyCodeLine{442 }
\DoxyCodeLine{443     \textcolor{comment}{!Get the tracer list}}
\DoxyCodeLine{444     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs\%g\_tracer\_list)) \textcolor{keyword}{call }mom\_error(fatal,\&}
\DoxyCodeLine{445          trim(sub\_name)//\textcolor{stringliteral}{": No tracer in the list."})}
\DoxyCodeLine{446 }
\DoxyCodeLine{447 \textcolor{preprocessor}{\#ifdef \_USE\_MOM6\_DIAG}}
\DoxyCodeLine{448 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs\%diag)}
\DoxyCodeLine{449 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{450 \textcolor{preprocessor}{}}
\DoxyCodeLine{451     \textcolor{comment}{!}}
\DoxyCodeLine{452     \textcolor{comment}{!Extract the tracer surface fields from coupler and update tracer fields from sources}}
\DoxyCodeLine{453     \textcolor{comment}{!}}
\DoxyCodeLine{454     \textcolor{comment}{!call generic\_tracer\_coupler\_get(fluxes\%tr\_fluxes)}}
\DoxyCodeLine{455     \textcolor{comment}{!Niki: This is moved out to ocean\_model\_MOM.F90 because if dt\_therm>dt\_cpld we need to average}}
\DoxyCodeLine{456     \textcolor{comment}{!      the fluxes without coming into this subroutine.}}
\DoxyCodeLine{457     \textcolor{comment}{!      MOM5 has to modified to conform.}}
\DoxyCodeLine{458 }
\DoxyCodeLine{459     \textcolor{comment}{!}}
\DoxyCodeLine{460     \textcolor{comment}{!Add contribution of river to surface flux}}
\DoxyCodeLine{461     \textcolor{comment}{!}}
\DoxyCodeLine{462     g\_tracer=>cs\%g\_tracer\_list}
\DoxyCodeLine{463     \textcolor{keywordflow}{do}}
\DoxyCodeLine{464        \textcolor{keywordflow}{if} (\_allocated(g\_tracer\%trunoff)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{465           \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,g\_tracer\_name)}
\DoxyCodeLine{466           \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'stf'},   stf\_array)}
\DoxyCodeLine{467           \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'trunoff'},trunoff\_array)}
\DoxyCodeLine{468           \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'runoff\_tracer\_flux'},runoff\_tracer\_flux\_array)}
\DoxyCodeLine{469           \textcolor{comment}{!nnz: Why is fluxes\%river = 0?}}
\DoxyCodeLine{470           runoff\_tracer\_flux\_array(:,:) = trunoff\_array(:,:) * \&}
\DoxyCodeLine{471                    g\%US\%RZ\_T\_to\_kg\_m2s*fluxes\%lrunoff(:,:)}
\DoxyCodeLine{472           stf\_array = stf\_array + runoff\_tracer\_flux\_array}
\DoxyCodeLine{473 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{474 }
\DoxyCodeLine{475        \textcolor{comment}{!traverse the linked list till hit NULL}}
\DoxyCodeLine{476        \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)}
\DoxyCodeLine{477        \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{478        g\_tracer=>g\_tracer\_next}
\DoxyCodeLine{479 }
\DoxyCodeLine{480 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{481 }
\DoxyCodeLine{482     \textcolor{comment}{!}}
\DoxyCodeLine{483     \textcolor{comment}{!Prepare input arrays for source update}}
\DoxyCodeLine{484     \textcolor{comment}{!}}
\DoxyCodeLine{485 }
\DoxyCodeLine{486     rho\_dzt(:,:,:) = gv\%H\_to\_kg\_m2 * gv\%Angstrom\_H}
\DoxyCodeLine{487     \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j = jsc, jec ; \textcolor{keywordflow}{do} i = isc, iec  \textcolor{comment}{!\{}}
\DoxyCodeLine{488       rho\_dzt(i,j,k) = gv\%H\_to\_kg\_m2 * h\_old(i,j,k)}
\DoxyCodeLine{489 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{!\}}}
\DoxyCodeLine{490 }
\DoxyCodeLine{491     dzt(:,:,:) = 1.0}
\DoxyCodeLine{492     \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j = jsc, jec ; \textcolor{keywordflow}{do} i = isc, iec  \textcolor{comment}{!\{}}
\DoxyCodeLine{493       dzt(i,j,k) = gv\%H\_to\_m * h\_old(i,j,k)}
\DoxyCodeLine{494 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{!\}}}
\DoxyCodeLine{495     dz\_ml(:,:) = 0.0}
\DoxyCodeLine{496     \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{497       surface\_field(i,j) = tv\%S(i,j,1)}
\DoxyCodeLine{498       dz\_ml(i,j) = g\%US\%Z\_to\_m * hml(i,j)}
\DoxyCodeLine{499 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{500     sosga = global\_area\_mean(surface\_field, g)}
\DoxyCodeLine{501 }
\DoxyCodeLine{502     \textcolor{comment}{!}}
\DoxyCodeLine{503     \textcolor{comment}{!Calculate tendencies (i.e., field changes at dt) from the sources / sinks}}
\DoxyCodeLine{504     \textcolor{comment}{!}}
\DoxyCodeLine{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}}
\DoxyCodeLine{506       \textcolor{comment}{! Avoid unnecessary copies when no unit conversion is needed.}}
\DoxyCodeLine{507       \textcolor{keyword}{call }generic\_tracer\_source(tv\%T, tv\%S, rho\_dzt, dzt, dz\_ml, g\%isd, g\%jsd, 1, dt, \&}
\DoxyCodeLine{508                g\%areaT, get\_diag\_time\_end(cs\%diag), \&}
\DoxyCodeLine{509                optics\%nbands, optics\%max\_wavelength\_band, optics\%sw\_pen\_band, optics\%opacity\_band, \&}
\DoxyCodeLine{510                internal\_heat=tv\%internal\_heat, frunoff=fluxes\%frunoff, sosga=sosga)}
\DoxyCodeLine{511     \textcolor{keywordflow}{else}}
\DoxyCodeLine{512       \textcolor{keyword}{call }generic\_tracer\_source(tv\%T, tv\%S, rho\_dzt, dzt, dz\_ml, g\%isd, g\%jsd, 1, dt, \&}
\DoxyCodeLine{513                g\%US\%L\_to\_m**2*g\%areaT(:,:), get\_diag\_time\_end(cs\%diag), \&}
\DoxyCodeLine{514                optics\%nbands, optics\%max\_wavelength\_band, optics\%sw\_pen\_band, optics\%opacity\_band, \&}
\DoxyCodeLine{515                internal\_heat=g\%US\%RZ\_to\_kg\_m2*tv\%internal\_heat(:,:), \&}
\DoxyCodeLine{516                frunoff=g\%US\%RZ\_T\_to\_kg\_m2s*fluxes\%frunoff(:,:), sosga=sosga)}
\DoxyCodeLine{517 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{518 }
\DoxyCodeLine{519     \textcolor{comment}{! This uses applyTracerBoundaryFluxesInOut to handle the change in tracer due to freshwater fluxes}}
\DoxyCodeLine{520     \textcolor{comment}{! usually in ALE mode}}
\DoxyCodeLine{521     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{522       g\_tracer=>cs\%g\_tracer\_list}
\DoxyCodeLine{523       \textcolor{keywordflow}{do}}
\DoxyCodeLine{524         \textcolor{keywordflow}{if} (g\_tracer\_is\_prog(g\_tracer)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{525           \textcolor{keywordflow}{do} k=1,nk ;\textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{526             h\_work(i,j,k) = h\_old(i,j,k)}
\DoxyCodeLine{527 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{528           \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, g\_tracer\%field(:,:,:,1), g\%US\%s\_to\_T*dt, \&}
\DoxyCodeLine{529                             fluxes, h\_work, evap\_cfl\_limit, minimum\_forcing\_depth)}
\DoxyCodeLine{530 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{531 }
\DoxyCodeLine{532          \textcolor{comment}{!traverse the linked list till hit NULL}}
\DoxyCodeLine{533          \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)}
\DoxyCodeLine{534         \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{535         g\_tracer=>g\_tracer\_next}
\DoxyCodeLine{536 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{537 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{538 }
\DoxyCodeLine{539     \textcolor{comment}{!}}
\DoxyCodeLine{540     \textcolor{comment}{!Update Tr(n)\%field from explicit vertical diffusion}}
\DoxyCodeLine{541     \textcolor{comment}{!}}
\DoxyCodeLine{542     \textcolor{comment}{! Use a tridiagonal solver to determine the concentrations after the}}
\DoxyCodeLine{543     \textcolor{comment}{! surface source is applied and diapycnal advection and diffusion occurs.}}
\DoxyCodeLine{544     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{545       \textcolor{comment}{! Last arg is tau which is always 1 for MOM6}}
\DoxyCodeLine{546       \textcolor{keyword}{call }generic\_tracer\_vertdiff\_g(h\_work, ea, eb, dt, gv\%kg\_m2\_to\_H, gv\%m\_to\_H, 1)}
\DoxyCodeLine{547     \textcolor{keywordflow}{else}}
\DoxyCodeLine{548       \textcolor{comment}{! Last arg is tau which is always 1 for MOM6}}
\DoxyCodeLine{549       \textcolor{keyword}{call }generic\_tracer\_vertdiff\_g(h\_old, ea, eb, dt, gv\%kg\_m2\_to\_H, gv\%m\_to\_H, 1)}
\DoxyCodeLine{550 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{551 }
\DoxyCodeLine{552     \textcolor{comment}{! Update bottom fields after vertical processes}}
\DoxyCodeLine{553 }
\DoxyCodeLine{554     \textcolor{comment}{! Second arg is tau which is always 1 for MOM6}}
\DoxyCodeLine{555     \textcolor{keyword}{call }generic\_tracer\_update\_from\_bottom(dt, 1, get\_diag\_time\_end(cs\%diag))}
\DoxyCodeLine{556 }
\DoxyCodeLine{557     \textcolor{comment}{!Output diagnostics via diag\_manager for all generic tracers and their fluxes}}
\DoxyCodeLine{558     \textcolor{keyword}{call }g\_tracer\_send\_diag(cs\%g\_tracer\_list, get\_diag\_time\_end(cs\%diag), tau=1)}
\DoxyCodeLine{559 \textcolor{preprocessor}{\#ifdef \_USE\_MOM6\_DIAG}}
\DoxyCodeLine{560 \textcolor{preprocessor}{}    \textcolor{keyword}{call }g\_tracer\_set\_csdiag(cs\%diag)}
\DoxyCodeLine{561 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{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{\texttt{ in}}  & {\em flux\+\_\+tmp} & A structure containing pointers to thermodynamic and tracer forcing fields.\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{797     \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(in)}    :: flux\_tmp\textcolor{comment}{  !< A structure containing pointers to}}
\DoxyCodeLine{798 \textcolor{comment}{                                              !! thermodynamic and tracer forcing fields.}}
\DoxyCodeLine{799 \textcolor{keywordtype}{    real},          \textcolor{keywordtype}{intent(in)}    :: weight\textcolor{comment}{    !< A weight for accumulating this flux}}
\DoxyCodeLine{800 }
\DoxyCodeLine{801     \textcolor{keyword}{call }generic\_tracer\_coupler\_accumulate(flux\_tmp\%tr\_fluxes, weight)}
\DoxyCodeLine{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{\texttt{ in}}  & {\em name} & Name of requested tracer. \\
\hline
\mbox{\texttt{ in}}  & {\em member} & The tracer element to return. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{807     \textcolor{keywordtype}{character(len=*)},         \textcolor{keywordtype}{intent(in)}  :: name\textcolor{comment}{   !< Name of requested tracer.}}
\DoxyCodeLine{808     \textcolor{keywordtype}{character(len=*)},         \textcolor{keywordtype}{intent(in)}  :: member\textcolor{comment}{ !< The tracer element to return.}}
\DoxyCodeLine{809 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:)},   \textcolor{keywordtype}{intent(out)} :: array\textcolor{comment}{  !< Array filled by this routine.}}
\DoxyCodeLine{810     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< Pointer to the control structure for this module.}}
\DoxyCodeLine{811 }
\DoxyCodeLine{812 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:)},   \textcolor{keywordtype}{pointer} :: array\_ptr}
\DoxyCodeLine{813     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_get'}}
\DoxyCodeLine{814 }
\DoxyCodeLine{815     \textcolor{keyword}{call }g\_tracer\_get\_pointer(cs\%g\_tracer\_list,name,member,array\_ptr)}
\DoxyCodeLine{816     array(:,:,:) = array\_ptr(:,:,:)}
\DoxyCodeLine{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{\texttt{ in}}  & {\em ind\+\_\+start} & The index of the tracer to start with \\
\hline
\mbox{\texttt{ out}}  & {\em got\+\_\+minmax} & Indicates whether the global min and max are found for each tracer \\
\hline
\mbox{\texttt{ out}}  & {\em gmin} & Global minimum of each tracer, in kg times concentration units. \\
\hline
\mbox{\texttt{ out}}  & {\em gmax} & Global maximum of each tracer, in kg times concentration units. \\
\hline
\mbox{\texttt{ out}}  & {\em xgmin} & The x-\/position of the global minimum \\
\hline
\mbox{\texttt{ out}}  & {\em ygmin} & The y-\/position of the global minimum \\
\hline
\mbox{\texttt{ out}}  & {\em zgmin} & The z-\/position of the global minimum \\
\hline
\mbox{\texttt{ out}}  & {\em xgmax} & The x-\/position of the global maximum \\
\hline
\mbox{\texttt{ out}}  & {\em ygmax} & The y-\/position of the global maximum \\
\hline
\mbox{\texttt{ out}}  & {\em zgmax} & The z-\/position of the global maximum \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
 & {\em cs} & Pointer to the control structure for this module. \\
\hline
\mbox{\texttt{ out}}  & {\em names} & The names of the stocks calculated. \\
\hline
\mbox{\texttt{ out}}  & {\em units} & The units of the stocks calculated. \\
\hline
\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}{0}
\DoxyCodeLine{636     \textcolor{keywordtype}{use }mpp\_utilities\_mod, \textcolor{keywordtype}{only}: mpp\_array\_global\_min\_max}
\DoxyCodeLine{637     \textcolor{keywordtype}{integer},                        \textcolor{keywordtype}{intent(in)}    :: ind\_start\textcolor{comment}{ !< The index of the tracer to start with}}
\DoxyCodeLine{638     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(:)},          \textcolor{keywordtype}{intent(out)}   :: got\_minmax\textcolor{comment}{ !< Indicates whether the global min and}}
\DoxyCodeLine{639 \textcolor{comment}{                                                            !! max are found for each tracer}}
\DoxyCodeLine{640 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: gmin\textcolor{comment}{   !< Global minimum of each tracer, in kg}}
\DoxyCodeLine{641 \textcolor{comment}{                                                            !! times concentration units.}}
\DoxyCodeLine{642 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: gmax\textcolor{comment}{   !< Global maximum of each tracer, in kg}}
\DoxyCodeLine{643 \textcolor{comment}{                                                            !! times concentration units.}}
\DoxyCodeLine{644 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: xgmin\textcolor{comment}{  !< The x-position of the global minimum}}
\DoxyCodeLine{645 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: ygmin\textcolor{comment}{  !< The y-position of the global minimum}}
\DoxyCodeLine{646 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: zgmin\textcolor{comment}{  !< The z-position of the global minimum}}
\DoxyCodeLine{647 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: xgmax\textcolor{comment}{  !< The x-position of the global maximum}}
\DoxyCodeLine{648 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: ygmax\textcolor{comment}{  !< The y-position of the global maximum}}
\DoxyCodeLine{649 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},             \textcolor{keywordtype}{intent(out)}   :: zgmax\textcolor{comment}{  !< The z-position of the global maximum}}
\DoxyCodeLine{650     \textcolor{keywordtype}{type}(ocean\_grid\_type),          \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{      !< The ocean's grid structure}}
\DoxyCodeLine{651     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< Pointer to the control structure for this module.}}
\DoxyCodeLine{652     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< The names of the stocks calculated.}}
\DoxyCodeLine{653     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< The units of the stocks calculated.}}
\DoxyCodeLine{654     \textcolor{keywordtype}{integer}                                       :: MOM\_generic\_tracer\_min\_max\textcolor{comment}{ !< Return value, the}}
\DoxyCodeLine{655 \textcolor{comment}{                                                            !! number of tracers done here.}}
\DoxyCodeLine{656 }
\DoxyCodeLine{657 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{658     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}  :: g\_tracer, g\_tracer\_next}
\DoxyCodeLine{659 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field}
\DoxyCodeLine{660 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr}
\DoxyCodeLine{661     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_min\_max'}}
\DoxyCodeLine{662 }
\DoxyCodeLine{663 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:)},\textcolor{keywordtype}{pointer} :: grid\_tmask}
\DoxyCodeLine{664     \textcolor{keywordtype}{integer} :: isc,iec,jsc,jec,isd,ied,jsd,jed,nk,ntau}
\DoxyCodeLine{665 }
\DoxyCodeLine{666     \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{667 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: geo\_z}
\DoxyCodeLine{668 }
\DoxyCodeLine{669     is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{670 }
\DoxyCodeLine{671     mom\_generic\_tracer\_min\_max = 0}
\DoxyCodeLine{672     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{673 }
\DoxyCodeLine{674     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs\%g\_tracer\_list)) \textcolor{keywordflow}{return} \textcolor{comment}{! No stocks.}}
\DoxyCodeLine{675 }
\DoxyCodeLine{676 }
\DoxyCodeLine{677     \textcolor{keyword}{call }g\_tracer\_get\_common(isc,iec,jsc,jec,isd,ied,jsd,jed,nk,ntau,grid\_tmask=grid\_tmask)}
\DoxyCodeLine{678 }
\DoxyCodeLine{679     \textcolor{comment}{!  Because the use of a simple z-coordinate can not be assumed, simply}}
\DoxyCodeLine{680     \textcolor{comment}{! use the layer index as the vertical label.}}
\DoxyCodeLine{681     \textcolor{keyword}{allocate}(geo\_z(nk))}
\DoxyCodeLine{682     \textcolor{keywordflow}{do} k=1,nk ; geo\_z(k) = real(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{683 }
\DoxyCodeLine{684     m=ind\_start ; g\_tracer=>cs\%g\_tracer\_list}
\DoxyCodeLine{685     \textcolor{keywordflow}{do}}
\DoxyCodeLine{686       \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,names(m))}
\DoxyCodeLine{687       \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,names(m),\textcolor{stringliteral}{'units'},units(m))}
\DoxyCodeLine{688       units(m) = trim(units(m))//\textcolor{stringliteral}{" kg"}}
\DoxyCodeLine{689       \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,names(m),\textcolor{stringliteral}{'field'},tr\_field)}
\DoxyCodeLine{690 }
\DoxyCodeLine{691       gmin(m) = -1.0}
\DoxyCodeLine{692       gmax(m) = -1.0}
\DoxyCodeLine{693 }
\DoxyCodeLine{694       tr\_ptr => tr\_field(:,:,:,1)}
\DoxyCodeLine{695 }
\DoxyCodeLine{696       \textcolor{keyword}{call }mpp\_array\_global\_min\_max(tr\_ptr, grid\_tmask,isd,jsd,isc,iec,jsc,jec,nk , gmin(m), gmax(m), \&}
\DoxyCodeLine{697                                     g\%geoLonT,g\%geoLatT,geo\_z,xgmin(m), ygmin(m), zgmin(m), \&}
\DoxyCodeLine{698                                     xgmax(m), ygmax(m), zgmax(m))}
\DoxyCodeLine{699 }
\DoxyCodeLine{700       got\_minmax(m) = .true.}
\DoxyCodeLine{701 }
\DoxyCodeLine{702       \textcolor{comment}{!traverse the linked list till hit NULL}}
\DoxyCodeLine{703       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)}
\DoxyCodeLine{704       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{705       g\_tracer=>g\_tracer\_next}
\DoxyCodeLine{706       m = m+1}
\DoxyCodeLine{707 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{708 }
\DoxyCodeLine{709     mom\_generic\_tracer\_min\_max = m}
\DoxyCodeLine{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{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ 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{\texttt{ out}}  & {\em names} & The names of the stocks calculated. \\
\hline
\mbox{\texttt{ out}}  & {\em units} & The units of the stocks calculated. \\
\hline
\mbox{\texttt{ in}}  & {\em stock\+\_\+index} & The coded index of a specific stock being sought. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return value, the number of stocks calculated here. 
\end{DoxyReturn}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{571     \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{572     \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{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]}}
\DoxyCodeLine{574 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:)},                 \textcolor{keywordtype}{intent(out)}   :: stocks\textcolor{comment}{ !< The mass-weighted integrated amount of each}}
\DoxyCodeLine{575 \textcolor{comment}{                                                                !! tracer, in kg times concentration units [kg conc].}}
\DoxyCodeLine{576     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),        \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< Pointer to the control structure for this module.}}
\DoxyCodeLine{577     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< The names of the stocks calculated.}}
\DoxyCodeLine{578     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< The units of the stocks calculated.}}
\DoxyCodeLine{579     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                  \textcolor{keywordtype}{intent(in)}    :: stock\_index\textcolor{comment}{ !< The coded index of a specific stock}}
\DoxyCodeLine{580 \textcolor{comment}{                                                                     !! being sought.}}
\DoxyCodeLine{581     \textcolor{keywordtype}{integer}                                           :: MOM\_generic\_tracer\_stock\textcolor{comment}{ !< Return value, the}}
\DoxyCodeLine{582 \textcolor{comment}{                                                                     !! number of stocks calculated here.}}
\DoxyCodeLine{583 }
\DoxyCodeLine{584 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{585     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}  :: g\_tracer, g\_tracer\_next}
\DoxyCodeLine{586 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field}
\DoxyCodeLine{587 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr}
\DoxyCodeLine{588     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_stock'}}
\DoxyCodeLine{589 }
\DoxyCodeLine{590     \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{591     is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{592 }
\DoxyCodeLine{593     mom\_generic\_tracer\_stock = 0}
\DoxyCodeLine{594     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{595 }
\DoxyCodeLine{596     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{597       \textcolor{comment}{! Check whether this stock is available from this routine.}}
\DoxyCodeLine{598 }
\DoxyCodeLine{599       \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}}
\DoxyCodeLine{600       \textcolor{keywordflow}{return}}
\DoxyCodeLine{601 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{602 }
\DoxyCodeLine{603     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs\%g\_tracer\_list)) \textcolor{keywordflow}{return} \textcolor{comment}{! No stocks.}}
\DoxyCodeLine{604 }
\DoxyCodeLine{605     m=1 ; g\_tracer=>cs\%g\_tracer\_list}
\DoxyCodeLine{606     \textcolor{keywordflow}{do}}
\DoxyCodeLine{607       \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,names(m))}
\DoxyCodeLine{608       \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,names(m),\textcolor{stringliteral}{'units'},units(m))}
\DoxyCodeLine{609       units(m) = trim(units(m))//\textcolor{stringliteral}{" kg"}}
\DoxyCodeLine{610       \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,names(m),\textcolor{stringliteral}{'field'},tr\_field)}
\DoxyCodeLine{611 }
\DoxyCodeLine{612       stocks(m) = 0.0}
\DoxyCodeLine{613       tr\_ptr => tr\_field(:,:,:,1)}
\DoxyCodeLine{614       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{615         stocks(m) = stocks(m) + tr\_ptr(i,j,k) * \&}
\DoxyCodeLine{616                                (g\%mask2dT(i,j) * g\%US\%L\_to\_m**2*g\%areaT(i,j) * h(i,j,k))}
\DoxyCodeLine{617 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{618       stocks(m) = gv\%H\_to\_kg\_m2 * stocks(m)}
\DoxyCodeLine{619 }
\DoxyCodeLine{620       \textcolor{comment}{!traverse the linked list till hit NULL}}
\DoxyCodeLine{621       \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)}
\DoxyCodeLine{622       \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{623       g\_tracer=>g\_tracer\_next}
\DoxyCodeLine{624       m = m+1}
\DoxyCodeLine{625 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{626 }
\DoxyCodeLine{627     mom\_generic\_tracer\_stock = m}
\DoxyCodeLine{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{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer 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}{0}
\DoxyCodeLine{720     \textcolor{keywordtype}{type}(ocean\_grid\_type),                 \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{721     \textcolor{keywordtype}{type}(surface),                         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{722 \textcolor{comment}{                                                                 !! describe the surface state of the ocean.}}
\DoxyCodeLine{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]}}
\DoxyCodeLine{724     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS),           \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< Pointer to the control structure for this module.}}
\DoxyCodeLine{725 }
\DoxyCodeLine{726 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{727 \textcolor{keywordtype}{    real} :: sosga}
\DoxyCodeLine{728 }
\DoxyCodeLine{729     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'MOM\_generic\_tracer\_surface\_state'}}
\DoxyCodeLine{730 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(G\%isd:G\%ied,G\%jsd:G\%jed,1:G\%ke,1)} :: rho0}
\DoxyCodeLine{731 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(G\%isd:G\%ied,G\%jsd:G\%jed,1:G\%ke)} ::  dzt}
\DoxyCodeLine{732     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer} :: g\_tracer}
\DoxyCodeLine{733 }
\DoxyCodeLine{734     \textcolor{comment}{!Set coupler values}}
\DoxyCodeLine{735     \textcolor{comment}{!nnz: fake rho0}}
\DoxyCodeLine{736     rho0=1.0}
\DoxyCodeLine{737 }
\DoxyCodeLine{738     dzt(:,:,:) = cs\%H\_to\_m * h(:,:,:)}
\DoxyCodeLine{739 }
\DoxyCodeLine{740     sosga = global\_area\_mean(sfc\_state\%SSS, g)}
\DoxyCodeLine{741 }
\DoxyCodeLine{742     \textcolor{keyword}{call }generic\_tracer\_coupler\_set(sfc\_state\%tr\_fields,\&}
\DoxyCodeLine{743          st=sfc\_state\%SST,\&}
\DoxyCodeLine{744          ss=sfc\_state\%SSS,\&}
\DoxyCodeLine{745          rho=rho0,\& \textcolor{comment}{!nnz: required for MOM5 and previous versions.}}
\DoxyCodeLine{746          ilb=g\%isd, jlb=g\%jsd,\&}
\DoxyCodeLine{747          dzt=dzt,\& \textcolor{comment}{!This is needed for the Mocsy method of carbonate system vars}}
\DoxyCodeLine{748          tau=1,sosga=sosga,model\_time=get\_diag\_time\_end(cs\%diag))}
\DoxyCodeLine{749 }
\DoxyCodeLine{750     \textcolor{comment}{!Output diagnostics via diag\_manager for all tracers in this module}}
\DoxyCodeLine{751 \textcolor{comment}{!    if (.NOT. associated(CS\%g\_tracer\_list)) call MOM\_error(FATAL, trim(sub\_name)//\&}}
\DoxyCodeLine{752 \textcolor{comment}{!         "No tracer in the list.")}}
\DoxyCodeLine{753 \textcolor{comment}{!    call g\_tracer\_send\_diag(CS\%g\_tracer\_list, get\_diag\_time\_end(CS\%diag), tau=1)}}
\DoxyCodeLine{754     \textcolor{comment}{!Niki: The problem with calling diagnostic outputs here is that this subroutine is called every dt\_cpld}}
\DoxyCodeLine{755     \textcolor{comment}{!      hence if dt\_therm > dt\_cpld we get output (and contribution to the mean) at times that tracers}}
\DoxyCodeLine{756     \textcolor{comment}{!      had not been updated.}}
\DoxyCodeLine{757     \textcolor{comment}{!      Moving this to the end of column physics subrotuine fixes this issue.}}
\DoxyCodeLine{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{\texttt{ in}}  & {\em hi} & Horizontal index ranges \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
 & {\em cs} & 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}{0}
\DoxyCodeLine{98     \textcolor{keywordtype}{type}(hor\_index\_type),       \textcolor{keywordtype}{intent(in)}   :: HI\textcolor{comment}{         !< Horizontal index ranges}}
\DoxyCodeLine{99     \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)}   :: GV\textcolor{comment}{         !< The ocean's vertical grid structure}}
\DoxyCodeLine{100     \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)}   :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}}
\DoxyCodeLine{101     \textcolor{keywordtype}{type}(MOM\_generic\_tracer\_CS), \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{         !< Pointer to the control structure for this module}}
\DoxyCodeLine{102     \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}      :: tr\_Reg\textcolor{comment}{     !< Pointer to the control structure for the tracer}}
\DoxyCodeLine{103 \textcolor{comment}{                                                           !! advection and diffusion module.}}
\DoxyCodeLine{104     \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}      :: restart\_CS\textcolor{comment}{ !< Pointer to the restart control structure.}}
\DoxyCodeLine{105 }
\DoxyCodeLine{106 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{107     \textcolor{keywordtype}{logical} :: register\_MOM\_generic\_tracer}
\DoxyCodeLine{108 }
\DoxyCodeLine{109     \textcolor{keywordtype}{character(len=128)}, \textcolor{keywordtype}{parameter} :: sub\_name = \textcolor{stringliteral}{'register\_MOM\_generic\_tracer'}}
\DoxyCodeLine{110     \textcolor{keywordtype}{character(len=200)} :: inputdir \textcolor{comment}{! The directory where NetCDF input files are.}}
\DoxyCodeLine{111     \textcolor{comment}{! These can be overridden later in via the field manager?}}
\DoxyCodeLine{112 }
\DoxyCodeLine{113     \textcolor{keywordtype}{integer} :: ntau, k,i,j,axes(3)}
\DoxyCodeLine{114     \textcolor{keywordtype}{type}(g\_tracer\_type), \textcolor{keywordtype}{pointer}      :: g\_tracer,g\_tracer\_next}
\DoxyCodeLine{115     \textcolor{keywordtype}{character(len=fm\_string\_len)}      :: g\_tracer\_name,longname,units}
\DoxyCodeLine{116 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{pointer}   :: tr\_field}
\DoxyCodeLine{117 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}     :: tr\_ptr}
\DoxyCodeLine{118 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied, HI\%jsd:HI\%jed,GV\%ke)}         :: grid\_tmask}
\DoxyCodeLine{119     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied, HI\%jsd:HI\%jed)}           :: grid\_kmt}
\DoxyCodeLine{120 }
\DoxyCodeLine{121     register\_mom\_generic\_tracer = .false.}
\DoxyCodeLine{122     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{123       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_MOM\_generic\_tracer called with an "}// \&}
\DoxyCodeLine{124             \textcolor{stringliteral}{"associated control structure."})}
\DoxyCodeLine{125       \textcolor{keywordflow}{return}}
\DoxyCodeLine{126 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{127     \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{128 }
\DoxyCodeLine{129 }
\DoxyCodeLine{130     \textcolor{comment}{!Register all the generic tracers used and create the list of them.}}
\DoxyCodeLine{131     \textcolor{comment}{!This can be called by ALL PE's. No array fields allocated.}}
\DoxyCodeLine{132     \textcolor{keywordflow}{if} (.not. g\_registered) \textcolor{keywordflow}{then}}
\DoxyCodeLine{133        \textcolor{keyword}{call }generic\_tracer\_register()}
\DoxyCodeLine{134        g\_registered = .true.}
\DoxyCodeLine{135 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{136 }
\DoxyCodeLine{137 }
\DoxyCodeLine{138   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{139     \textcolor{keyword}{call }log\_version(param\_file, sub\_name, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{140     \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"GENERIC\_TRACER\_IC\_FILE"}, cs\%IC\_file, \&}
\DoxyCodeLine{141                  \textcolor{stringliteral}{"The file in which the generic trcer initial values can "}//\&}
\DoxyCodeLine{142                  \textcolor{stringliteral}{"be found, or an empty string for internal initialization."}, \&}
\DoxyCodeLine{143                  default=\textcolor{stringliteral}{" "})}
\DoxyCodeLine{144     \textcolor{keywordflow}{if} ((len\_trim(cs\%IC\_file) > 0) .and. (scan(cs\%IC\_file,\textcolor{stringliteral}{'/'}) == 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{145       \textcolor{comment}{! Add the directory if CS\%IC\_file is not already a complete path.}}
\DoxyCodeLine{146       \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{147       cs\%IC\_file = trim(slasher(inputdir))//trim(cs\%IC\_file)}
\DoxyCodeLine{148       \textcolor{keyword}{call }log\_param(param\_file, sub\_name, \textcolor{stringliteral}{"INPUTDIR/GENERIC\_TRACER\_IC\_FILE"}, cs\%IC\_file)}
\DoxyCodeLine{149 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{150     \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"GENERIC\_TRACER\_IC\_FILE\_IS\_Z"}, cs\%Z\_IC\_file, \&}
\DoxyCodeLine{151                  \textcolor{stringliteral}{"If true, GENERIC\_TRACER\_IC\_FILE is in depth space, not "}//\&}
\DoxyCodeLine{152                  \textcolor{stringliteral}{"layer space."},default=.false.)}
\DoxyCodeLine{153     \textcolor{keyword}{call }get\_param(param\_file, sub\_name, \textcolor{stringliteral}{"TRACERS\_MAY\_REINIT"}, cs\%tracers\_may\_reinit, \&}
\DoxyCodeLine{154                  \textcolor{stringliteral}{"If true, tracers may go through the initialization code "}//\&}
\DoxyCodeLine{155                  \textcolor{stringliteral}{"if they are not found in the restart files.  Otherwise "}//\&}
\DoxyCodeLine{156                  \textcolor{stringliteral}{"it is a fatal error if tracers are not found in the "}//\&}
\DoxyCodeLine{157                  \textcolor{stringliteral}{"restart files of a restarted run."}, default=.false.)}
\DoxyCodeLine{158 }
\DoxyCodeLine{159     cs\%restart\_CSp => restart\_cs}
\DoxyCodeLine{160 }
\DoxyCodeLine{161 }
\DoxyCodeLine{162     ntau=1 \textcolor{comment}{! MOM needs the fields at only one time step}}
\DoxyCodeLine{163 }
\DoxyCodeLine{164 }
\DoxyCodeLine{165     \textcolor{comment}{!   At this point G\%mask2dT and CS\%diag\%axesTL are not allocated.}}
\DoxyCodeLine{166     \textcolor{comment}{! postpone diag\_registeration to initialize\_MOM\_generic\_tracer}}
\DoxyCodeLine{167 }
\DoxyCodeLine{168     \textcolor{comment}{!Fields cannot be diag registered as they are allocated and have to registered later.}}
\DoxyCodeLine{169     grid\_tmask(:,:,:) = 0.0}
\DoxyCodeLine{170     grid\_kmt(:,:) = 0.0}
\DoxyCodeLine{171     axes(:) = -1}
\DoxyCodeLine{172 }
\DoxyCodeLine{173     \textcolor{comment}{!}}
\DoxyCodeLine{174     \textcolor{comment}{! Initialize all generic tracers}}
\DoxyCodeLine{175     \textcolor{comment}{!}}
\DoxyCodeLine{176     \textcolor{keyword}{call }generic\_tracer\_init(hi\%isc,hi\%iec,hi\%jsc,hi\%jec,hi\%isd,hi\%ied,hi\%jsd,hi\%jed,\&}
\DoxyCodeLine{177          gv\%ke,ntau,axes,grid\_tmask,grid\_kmt,set\_time(0,0))}
\DoxyCodeLine{178 }
\DoxyCodeLine{179 }
\DoxyCodeLine{180     \textcolor{comment}{!}}
\DoxyCodeLine{181     \textcolor{comment}{! MOM-register the generic tracers}}
\DoxyCodeLine{182     \textcolor{comment}{!}}
\DoxyCodeLine{183 }
\DoxyCodeLine{184     \textcolor{comment}{!Get the tracer list}}
\DoxyCodeLine{185     \textcolor{keyword}{call }generic\_tracer\_get\_list(cs\%g\_tracer\_list)}
\DoxyCodeLine{186     \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(cs\%g\_tracer\_list)) \textcolor{keyword}{call }mom\_error(fatal, trim(sub\_name)//\&}
\DoxyCodeLine{187          \textcolor{stringliteral}{": No tracer in the list."})}
\DoxyCodeLine{188     \textcolor{comment}{! For each tracer name get its T\_prog index and get its fields}}
\DoxyCodeLine{189 }
\DoxyCodeLine{190     g\_tracer=>cs\%g\_tracer\_list}
\DoxyCodeLine{191     \textcolor{keywordflow}{do}}
\DoxyCodeLine{192        \textcolor{keyword}{call }g\_tracer\_get\_alias(g\_tracer,g\_tracer\_name)}
\DoxyCodeLine{193 }
\DoxyCodeLine{194        \textcolor{keyword}{call }g\_tracer\_get\_pointer(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'field'},tr\_field)}
\DoxyCodeLine{195        \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'longname'}, longname)}
\DoxyCodeLine{196        \textcolor{keyword}{call }g\_tracer\_get\_values(g\_tracer,g\_tracer\_name,\textcolor{stringliteral}{'units'},units )}
\DoxyCodeLine{197 }
\DoxyCodeLine{198        \textcolor{comment}{!!nnz: MOM field is 3D. Does this affect performance? Need it be override field?}}
\DoxyCodeLine{199        tr\_ptr => tr\_field(:,:,:,1)}
\DoxyCodeLine{200        \textcolor{comment}{! Register prognastic tracer for horizontal advection, diffusion, and restarts.}}
\DoxyCodeLine{201        \textcolor{keywordflow}{if} (g\_tracer\_is\_prog(g\_tracer)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{202          \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, \&}
\DoxyCodeLine{203                               name=g\_tracer\_name, longname=longname, units=units, \&}
\DoxyCodeLine{204                               registry\_diags=.false., \&   \textcolor{comment}{!\#\#\# CHANGE TO TRUE?}}
\DoxyCodeLine{205                               restart\_cs=restart\_cs, mandatory=.not.cs\%tracers\_may\_reinit)}
\DoxyCodeLine{206        \textcolor{keywordflow}{else}}
\DoxyCodeLine{207          \textcolor{keyword}{call }register\_restart\_field(tr\_ptr, g\_tracer\_name, .not.cs\%tracers\_may\_reinit, \&}
\DoxyCodeLine{208                                      restart\_cs, longname=longname, units=units)}
\DoxyCodeLine{209 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{210 }
\DoxyCodeLine{211        \textcolor{comment}{!traverse the linked list till hit NULL}}
\DoxyCodeLine{212        \textcolor{keyword}{call }g\_tracer\_get\_next(g\_tracer, g\_tracer\_next)}
\DoxyCodeLine{213        \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(g\_tracer\_next)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{214        g\_tracer=>g\_tracer\_next}
\DoxyCodeLine{215 }
\DoxyCodeLine{216 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{217 }
\DoxyCodeLine{218     register\_mom\_generic\_tracer = .true.}

\end{DoxyCode}
