\hypertarget{namespacemom__tracer__registry}{}\section{mom\+\_\+tracer\+\_\+registry Module Reference}
\label{namespacemom__tracer__registry}\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}


\subsection{Detailed Description}
This module contains the \hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type} and the subroutines that handle registration of tracers and related subroutines. The primary subroutine, register\+\_\+tracer, is called to indicate the tracers advected and diffused. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}
\begin{DoxyCompactList}\small\item\em Type to carry basic tracer information. \end{DoxyCompactList}\item 
type \hyperlink{structmom__tracer__registry_1_1tracer__type}{tracer\+\_\+type}
\begin{DoxyCompactList}\small\item\em The tracer type. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_a97a70989bd0318f51d90c2fc6f87c6f5}{register\+\_\+tracer} (tr\+\_\+ptr, Reg, param\+\_\+file, HI, GV, name, longname, units, cmor\+\_\+name, cmor\+\_\+units, cmor\+\_\+longname, tr\+\_\+desc, O\+B\+C\+\_\+inflow, O\+B\+C\+\_\+in\+\_\+u, O\+B\+C\+\_\+in\+\_\+v, ad\+\_\+x, ad\+\_\+y, df\+\_\+x, df\+\_\+y, ad\+\_\+2d\+\_\+x, ad\+\_\+2d\+\_\+y, df\+\_\+2d\+\_\+x, df\+\_\+2d\+\_\+y, advection\+\_\+xy, registry\+\_\+diags, flux\+\_\+nameroot, flux\+\_\+longname, flux\+\_\+units, flux\+\_\+scale, convergence\+\_\+units, convergence\+\_\+scale, cmor\+\_\+tendprefix, diag\+\_\+form, restart\+\_\+\+CS, mandatory)
\begin{DoxyCompactList}\small\item\em This subroutine registers a tracer to be advected and laterally diffused. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_af9889848c1f3801951b0c79cace52e8d}{lock\+\_\+tracer\+\_\+registry} (Reg)
\begin{DoxyCompactList}\small\item\em This subroutine locks the tracer registry to prevent the addition of more tracers. After locked=.true., can then register common diagnostics. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_a6210cf64994a49ae3c14e3500c957fb1}{register\+\_\+tracer\+\_\+diagnostics} (Reg, h, Time, diag, G, GV, US, use\+\_\+\+A\+LE)
\begin{DoxyCompactList}\small\item\em register\+\_\+tracer\+\_\+diagnostics does a set of register\+\_\+diag\+\_\+field calls for any previously registered in a tracer registry with a value of registry\+\_\+diags set to .true. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_a32c2b2e308a5183cd7681084e07d1624}{preale\+\_\+tracer\+\_\+diagnostics} (Reg, G, GV)
\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_ada71d85c8d29e91166c59601c0e799ef}{postale\+\_\+tracer\+\_\+diagnostics} (Reg, G, GV, diag, dt)
\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_a6840b8bb4ec1b2a2f023046ea47f509c}{post\+\_\+tracer\+\_\+diagnostics\+\_\+at\+\_\+sync} (Reg, h, diag\+\_\+prev, diag, G, GV, dt)
\begin{DoxyCompactList}\small\item\em Post tracer diganostics when that should only be posted when M\+OM\textquotesingle{}s state is self-\/consistent (also referred to as \textquotesingle{}synchronized\textquotesingle{}) \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_afac59be6855cac7e3021295ae1e501b4}{post\+\_\+tracer\+\_\+transport\+\_\+diagnostics} (G, GV, Reg, h\+\_\+diag, diag)
\begin{DoxyCompactList}\small\item\em Post the advective and diffusive tendencies. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_ad350bb834bb3dcfd6e603bb136bd8098}{mom\+\_\+tracer\+\_\+chksum} (mesg, Tr, ntr, G)
\begin{DoxyCompactList}\small\item\em This subroutine writes out chksums for tracers. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_a86cd924ede0ff77b15065f5b3bd2cb29}{mom\+\_\+tracer\+\_\+chkinv} (mesg, G, h, Tr, ntr)
\begin{DoxyCompactList}\small\item\em Calculates and prints the global inventory of all tracers in the registry. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_a67e71e90d3747dd97a917f6541f39b56}{tracer\+\_\+name\+\_\+lookup} (Reg, tr\+\_\+ptr, name)
\begin{DoxyCompactList}\small\item\em Find a tracer in the tracer registry by name. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_a452937bf1f9d01a47d1a80793e317b33}{tracer\+\_\+registry\+\_\+init} (param\+\_\+file, Reg)
\begin{DoxyCompactList}\small\item\em Initialize the tracer registry. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__tracer__registry_aaca7f6bcdb5f1d8cb247e24719d37df9}{tracer\+\_\+registry\+\_\+end} (Reg)
\begin{DoxyCompactList}\small\item\em This routine closes the tracer registry module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__tracer__registry_af9889848c1f3801951b0c79cace52e8d}\label{namespacemom__tracer__registry_af9889848c1f3801951b0c79cace52e8d}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!lock\+\_\+tracer\+\_\+registry@{lock\+\_\+tracer\+\_\+registry}}
\index{lock\+\_\+tracer\+\_\+registry@{lock\+\_\+tracer\+\_\+registry}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{lock\+\_\+tracer\+\_\+registry()}{lock\_tracer\_registry()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::lock\+\_\+tracer\+\_\+registry (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg }\end{DoxyParamCaption})}



This subroutine locks the tracer registry to prevent the addition of more tracers. After locked=.true., can then register common diagnostics. 


\begin{DoxyParams}{Parameters}
{\em reg} & pointer to the tracer registry \\
\hline
\end{DoxyParams}


Definition at line 332 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
332   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{    !< pointer to the tracer registry}
333 
334   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(reg)) \textcolor{keyword}{call }mom\_error(warning, &
335     \textcolor{stringliteral}{"lock\_tracer\_registry called with an unassociated registry."})
336 
337   reg%locked = .true.
338 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_a86cd924ede0ff77b15065f5b3bd2cb29}\label{namespacemom__tracer__registry_a86cd924ede0ff77b15065f5b3bd2cb29}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!mom\+\_\+tracer\+\_\+chkinv@{mom\+\_\+tracer\+\_\+chkinv}}
\index{mom\+\_\+tracer\+\_\+chkinv@{mom\+\_\+tracer\+\_\+chkinv}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{mom\+\_\+tracer\+\_\+chkinv()}{mom\_tracer\_chkinv()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::mom\+\_\+tracer\+\_\+chkinv (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__type}{tracer\+\_\+type}), dimension(\+:), intent(in)}]{Tr,  }\item[{integer, intent(in)}]{ntr }\end{DoxyParamCaption})}



Calculates and prints the global inventory of all tracers in the registry. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & message that appears on the chksum lines\\
\hline
\mbox{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em tr} & array of all of registered tracers\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses\\
\hline
\mbox{\tt in}  & {\em ntr} & number of registered tracers \\
\hline
\end{DoxyParams}


Definition at line 826 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
826   \textcolor{keywordtype}{character(len=*)},                         \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< message that appears on the chksum lines}
827   \textcolor{keywordtype}{type}(ocean\_grid\_type),                    \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< ocean grid structure}
828   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{dimension(:)},          \textcolor{keywordtype}{intent(in)} :: tr\textcolor{comment}{   !< array of all of registered tracers}
829   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses}
830   \textcolor{keywordtype}{integer},                                  \textcolor{keywordtype}{intent(in)} :: ntr\textcolor{comment}{  !< number of registered tracers}
831 
832   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: tr\_inv\textcolor{comment}{ !< Tracer inventory}
833   \textcolor{keywordtype}{real} :: total\_inv
834   \textcolor{keywordtype}{integer} :: is, ie, js, je, nz
835   \textcolor{keywordtype}{integer} :: i, j, k, m
836 
837   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
838   \textcolor{keywordflow}{do} m=1,ntr
839     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
840       tr\_inv(i,j,k) = tr(m)%t(i,j,k)*h(i,j,k)*g%US%L\_to\_m**2*g%areaT(i,j)*g%mask2dT(i,j)
841 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
842     total\_inv = \hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}(tr\_inv, is+(1-g%isd), ie+(1-g%isd), js+(1-g%jsd), je+(1-g
      %jsd))
843     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(A,1X,A5,1X,ES25.16,1X,A)'}) \textcolor{stringliteral}{"h-point: inventory"}, tr(m)%name, total\_inv, 
      mesg
844 \textcolor{keywordflow}{  enddo}
845 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_ad350bb834bb3dcfd6e603bb136bd8098}\label{namespacemom__tracer__registry_ad350bb834bb3dcfd6e603bb136bd8098}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!mom\+\_\+tracer\+\_\+chksum@{mom\+\_\+tracer\+\_\+chksum}}
\index{mom\+\_\+tracer\+\_\+chksum@{mom\+\_\+tracer\+\_\+chksum}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{mom\+\_\+tracer\+\_\+chksum()}{mom\_tracer\_chksum()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::mom\+\_\+tracer\+\_\+chksum (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__type}{tracer\+\_\+type}), dimension(\+:), intent(in)}]{Tr,  }\item[{integer, intent(in)}]{ntr,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G }\end{DoxyParamCaption})}



This subroutine writes out chksums for tracers. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & message that appears on the chksum lines\\
\hline
\mbox{\tt in}  & {\em tr} & array of all of registered tracers\\
\hline
\mbox{\tt in}  & {\em ntr} & number of registered tracers\\
\hline
\mbox{\tt in}  & {\em g} & ocean grid structure \\
\hline
\end{DoxyParams}


Definition at line 809 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
809   \textcolor{keywordtype}{character(len=*)},         \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< message that appears on the chksum lines}
810   \textcolor{keywordtype}{type}(tracer\_type),        \textcolor{keywordtype}{intent(in)} :: tr(:)\textcolor{comment}{  !< array of all of registered tracers}
811   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{intent(in)} :: ntr\textcolor{comment}{    !< number of registered tracers}
812   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{      !< ocean grid structure}
813 
814   \textcolor{keywordtype}{integer} :: is, ie, js, je, nz
815   \textcolor{keywordtype}{integer} :: i, j, k, m
816 
817   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
818   \textcolor{keywordflow}{do} m=1,ntr
819     \textcolor{keyword}{call }hchksum(tr(m)%t, mesg//trim(tr(m)%name), g%HI)
820 \textcolor{keywordflow}{  enddo}
821 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_a6840b8bb4ec1b2a2f023046ea47f509c}\label{namespacemom__tracer__registry_a6840b8bb4ec1b2a2f023046ea47f509c}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!post\+\_\+tracer\+\_\+diagnostics\+\_\+at\+\_\+sync@{post\+\_\+tracer\+\_\+diagnostics\+\_\+at\+\_\+sync}}
\index{post\+\_\+tracer\+\_\+diagnostics\+\_\+at\+\_\+sync@{post\+\_\+tracer\+\_\+diagnostics\+\_\+at\+\_\+sync}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{post\+\_\+tracer\+\_\+diagnostics\+\_\+at\+\_\+sync()}{post\_tracer\_diagnostics\_at\_sync()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::post\+\_\+tracer\+\_\+diagnostics\+\_\+at\+\_\+sync (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h,  }\item[{type(diag\+\_\+grid\+\_\+storage), intent(in)}]{diag\+\_\+prev,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, intent(in)}]{dt }\end{DoxyParamCaption})}



Post tracer diganostics when that should only be posted when M\+OM\textquotesingle{}s state is self-\/consistent (also referred to as \textquotesingle{}synchronized\textquotesingle{}) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
 & {\em reg} & pointer to the tracer registry\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+prev} & Contains diagnostic grids from previous timestep\\
\hline
\mbox{\tt in,out}  & {\em diag} & structure to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em dt} & total time step for tracer updates \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 718 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
718   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
719   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
720   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{  !< pointer to the tracer registry}
721   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
722                               \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses}
723   \textcolor{keywordtype}{type}(diag\_grid\_storage),    \textcolor{keywordtype}{intent(in)} :: diag\_prev\textcolor{comment}{ !< Contains diagnostic grids from previous timestep}
724   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< structure to regulate diagnostic output}
725   \textcolor{keywordtype}{real},                       \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< total time step for tracer updates [T ~> s]}
726 
727   \textcolor{keywordtype}{real}    :: work3d(szi\_(g),szj\_(g),szk\_(gv))
728   \textcolor{keywordtype}{real}    :: work2d(szi\_(g),szj\_(g))
729   \textcolor{keywordtype}{real}    :: idt \textcolor{comment}{! The inverse of the time step [T-1 ~> s-1]}
730   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer} :: tr=>null()
731   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m
732   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
733 
734   idt = 0.; \textcolor{keywordflow}{if} (dt/=0.) idt = 1.0 / dt \textcolor{comment}{! The "if" is in case the diagnostic is called for a zero length
       interval}
735 
736   \textcolor{comment}{! Tendency diagnostics need to be posted on the grid from the last call to this routine}
737   \textcolor{keyword}{call }diag\_save\_grids(diag)
738   \textcolor{keyword}{call }diag\_copy\_storage\_to\_diag(diag, diag\_prev)
739   \textcolor{keywordflow}{do} m=1,reg%ntr ; \textcolor{keywordflow}{if} (reg%Tr(m)%registry\_diags) \textcolor{keywordflow}{then}
740     tr => reg%Tr(m)
741     \textcolor{keywordflow}{if} (tr%id\_tr > 0) \textcolor{keyword}{call }post\_data(tr%id\_tr, tr%t, diag)
742     \textcolor{keywordflow}{if} (tr%id\_tendency > 0) \textcolor{keywordflow}{then}
743       work3d(:,:,:) = 0.0
744       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
745         work3d(i,j,k)    = (tr%t(i,j,k) - tr%t\_prev(i,j,k))*idt
746         tr%t\_prev(i,j,k) =  tr%t(i,j,k)
747 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
748       \textcolor{keyword}{call }post\_data(tr%id\_tendency, work3d, diag, alt\_h=diag\_prev%h\_state)
749 \textcolor{keywordflow}{    endif}
750     \textcolor{keywordflow}{if} ((tr%id\_trxh\_tendency > 0) .or. (tr%id\_trxh\_tendency\_2d > 0)) \textcolor{keywordflow}{then}
751       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
752         work3d(i,j,k)     = (tr%t(i,j,k)*h(i,j,k) - tr%Trxh\_prev(i,j,k)) * idt
753         tr%Trxh\_prev(i,j,k) =  tr%t(i,j,k) * h(i,j,k)
754 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
755       \textcolor{keywordflow}{if} (tr%id\_trxh\_tendency > 0) \textcolor{keyword}{call }post\_data(tr%id\_trxh\_tendency, work3d, diag, alt\_h=diag\_prev
      %h\_state)
756       \textcolor{keywordflow}{if} (tr%id\_trxh\_tendency\_2d > 0) \textcolor{keywordflow}{then}
757         work2d(:,:) = 0.0
758         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
759           work2d(i,j) = work2d(i,j) + work3d(i,j,k)
760 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
761         \textcolor{keyword}{call }post\_data(tr%id\_trxh\_tendency\_2d, work2d, diag)
762 \textcolor{keywordflow}{      endif}
763 \textcolor{keywordflow}{    endif}
764 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo}
765   \textcolor{keyword}{call }diag\_restore\_grids(diag)
766 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_afac59be6855cac7e3021295ae1e501b4}\label{namespacemom__tracer__registry_afac59be6855cac7e3021295ae1e501b4}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!post\+\_\+tracer\+\_\+transport\+\_\+diagnostics@{post\+\_\+tracer\+\_\+transport\+\_\+diagnostics}}
\index{post\+\_\+tracer\+\_\+transport\+\_\+diagnostics@{post\+\_\+tracer\+\_\+transport\+\_\+diagnostics}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{post\+\_\+tracer\+\_\+transport\+\_\+diagnostics()}{post\_tracer\_transport\_diagnostics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::post\+\_\+tracer\+\_\+transport\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h\+\_\+diag,  }\item[{type(diag\+\_\+ctrl), intent(in)}]{diag }\end{DoxyParamCaption})}



Post the advective and diffusive tendencies. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
 & {\em reg} & pointer to the tracer registry\\
\hline
\mbox{\tt in}  & {\em h\+\_\+diag} & Layer thicknesses on which to post fields\\
\hline
\mbox{\tt in}  & {\em diag} & structure to regulate diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 771 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
771   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
772   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
773   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{  !< pointer to the tracer registry}
774   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
775                               \textcolor{keywordtype}{intent(in)} :: h\_diag\textcolor{comment}{ !< Layer thicknesses on which to post fields}
776   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< structure to regulate diagnostic output}
777 
778   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m
779   \textcolor{keywordtype}{real}    :: work2d(szi\_(g),szj\_(g))
780   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer} :: tr=>null()
781 
782   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
783 
784   \textcolor{keywordflow}{do} m=1,reg%ntr ; \textcolor{keywordflow}{if} (reg%Tr(m)%registry\_diags) \textcolor{keywordflow}{then}
785     tr => reg%Tr(m)
786     \textcolor{keywordflow}{if} (tr%id\_tr\_post\_horzn> 0) \textcolor{keyword}{call }post\_data(tr%id\_tr\_post\_horzn, tr%t, diag)
787     \textcolor{keywordflow}{if} (tr%id\_adx > 0) \textcolor{keyword}{call }post\_data(tr%id\_adx, tr%ad\_x, diag, alt\_h=h\_diag)
788     \textcolor{keywordflow}{if} (tr%id\_ady > 0) \textcolor{keyword}{call }post\_data(tr%id\_ady, tr%ad\_y, diag, alt\_h=h\_diag)
789     \textcolor{keywordflow}{if} (tr%id\_dfx > 0) \textcolor{keyword}{call }post\_data(tr%id\_dfx, tr%df\_x, diag, alt\_h=h\_diag)
790     \textcolor{keywordflow}{if} (tr%id\_dfy > 0) \textcolor{keyword}{call }post\_data(tr%id\_dfy, tr%df\_y, diag, alt\_h=h\_diag)
791     \textcolor{keywordflow}{if} (tr%id\_adx\_2d > 0) \textcolor{keyword}{call }post\_data(tr%id\_adx\_2d, tr%ad2d\_x, diag)
792     \textcolor{keywordflow}{if} (tr%id\_ady\_2d > 0) \textcolor{keyword}{call }post\_data(tr%id\_ady\_2d, tr%ad2d\_y, diag)
793     \textcolor{keywordflow}{if} (tr%id\_dfx\_2d > 0) \textcolor{keyword}{call }post\_data(tr%id\_dfx\_2d, tr%df2d\_x, diag)
794     \textcolor{keywordflow}{if} (tr%id\_dfy\_2d > 0) \textcolor{keyword}{call }post\_data(tr%id\_dfy\_2d, tr%df2d\_y, diag)
795     \textcolor{keywordflow}{if} (tr%id\_adv\_xy > 0) \textcolor{keyword}{call }post\_data(tr%id\_adv\_xy, tr%advection\_xy, diag, alt\_h=h\_diag)
796     \textcolor{keywordflow}{if} (tr%id\_adv\_xy\_2d > 0) \textcolor{keywordflow}{then}
797       work2d(:,:) = 0.0
798       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
799         work2d(i,j) = work2d(i,j) + tr%advection\_xy(i,j,k)
800 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
801       \textcolor{keyword}{call }post\_data(tr%id\_adv\_xy\_2d, work2d, diag)
802 \textcolor{keywordflow}{    endif}
803 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo}
804 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_ada71d85c8d29e91166c59601c0e799ef}\label{namespacemom__tracer__registry_ada71d85c8d29e91166c59601c0e799ef}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!postale\+\_\+tracer\+\_\+diagnostics@{postale\+\_\+tracer\+\_\+diagnostics}}
\index{postale\+\_\+tracer\+\_\+diagnostics@{postale\+\_\+tracer\+\_\+diagnostics}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{postale\+\_\+tracer\+\_\+diagnostics()}{postale\_tracer\_diagnostics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::postale\+\_\+tracer\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(diag\+\_\+ctrl), intent(in)}]{diag,  }\item[{real, intent(in)}]{dt }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
 & {\em reg} & pointer to the tracer registry\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em diag} & regulates diagnostic output\\
\hline
\mbox{\tt in}  & {\em dt} & total time interval for these diagnostics \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 689 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
689   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{  !< pointer to the tracer registry}
690   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
691   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{   !< ocean vertical grid structure}
692   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< regulates diagnostic output}
693   \textcolor{keywordtype}{real},                       \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< total time interval for these diagnostics [T ~> s]}
694 
695   \textcolor{keywordtype}{real}    :: work(szi\_(g),szj\_(g),szk\_(g))
696   \textcolor{keywordtype}{real}    :: idt \textcolor{comment}{! The inverse of the time step [T-1 ~> s-1]}
697   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m, m2
698   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
699 
700   \textcolor{comment}{! The "if" is to avoid NaNs if the diagnostic is called for a zero length interval}
701   idt = 0.0 ; \textcolor{keywordflow}{if} (dt /= 0.0) idt = 1.0 / dt
702 
703   \textcolor{keywordflow}{do} m=1,reg%ntr ; \textcolor{keywordflow}{if} (reg%Tr(m)%id\_tr\_vardec > 0) \textcolor{keywordflow}{then}
704     m2 = reg%Tr(m)%ind\_tr\_squared
705     \textcolor{keywordflow}{if} (m2 < 1) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Bad value of Tr%ind\_tr\_squared for "}//trim(reg%Tr(m)%name))
706   \textcolor{comment}{! Update squared quantities}
707     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
708       work(i,j,k) = (reg%Tr(m2)%T(i,j,k) - reg%Tr(m)%T(i,j,k)**2) * idt
709 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
710     \textcolor{keyword}{call }post\_data(reg%Tr(m)%id\_tr\_vardec, work, diag)
711 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo}
712 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_a32c2b2e308a5183cd7681084e07d1624}\label{namespacemom__tracer__registry_a32c2b2e308a5183cd7681084e07d1624}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!preale\+\_\+tracer\+\_\+diagnostics@{preale\+\_\+tracer\+\_\+diagnostics}}
\index{preale\+\_\+tracer\+\_\+diagnostics@{preale\+\_\+tracer\+\_\+diagnostics}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{preale\+\_\+tracer\+\_\+diagnostics()}{preale\_tracer\_diagnostics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::preale\+\_\+tracer\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
 & {\em reg} & pointer to the tracer registry\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure \\
\hline
\end{DoxyParams}


Definition at line 671 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
671   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{  !< pointer to the tracer registry}
672   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
673   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{   !< ocean vertical grid structure}
674 
675   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m, m2
676   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
677 
678   \textcolor{keywordflow}{do} m=1,reg%ntr ; \textcolor{keywordflow}{if} (reg%Tr(m)%ind\_tr\_squared > 0) \textcolor{keywordflow}{then}
679     m2 = reg%Tr(m)%ind\_tr\_squared
680   \textcolor{comment}{! Update squared quantities}
681     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
682       reg%Tr(m2)%T(i,j,k) = reg%Tr(m)%T(i,j,k)**2
683 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
684 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo}
685 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_a97a70989bd0318f51d90c2fc6f87c6f5}\label{namespacemom__tracer__registry_a97a70989bd0318f51d90c2fc6f87c6f5}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!register\+\_\+tracer@{register\+\_\+tracer}}
\index{register\+\_\+tracer@{register\+\_\+tracer}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{register\+\_\+tracer()}{register\_tracer()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::register\+\_\+tracer (\begin{DoxyParamCaption}\item[{real, dimension( hi \%isd\+: hi \%ied, hi \%jsd\+: hi \%jed, gv \%ke), target}]{tr\+\_\+ptr,  }\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{character(len=$\ast$), intent(in), optional}]{name,  }\item[{character(len=$\ast$), intent(in), optional}]{longname,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+longname,  }\item[{type(vardesc), intent(in), optional}]{tr\+\_\+desc,  }\item[{real, intent(in), optional}]{O\+B\+C\+\_\+inflow,  }\item[{real, dimension(\+:,\+:,\+:), optional, pointer}]{O\+B\+C\+\_\+in\+\_\+u,  }\item[{real, dimension(\+:,\+:,\+:), optional, pointer}]{O\+B\+C\+\_\+in\+\_\+v,  }\item[{real, dimension(\+:,\+:,\+:), optional, pointer}]{ad\+\_\+x,  }\item[{real, dimension(\+:,\+:,\+:), optional, pointer}]{ad\+\_\+y,  }\item[{real, dimension(\+:,\+:,\+:), optional, pointer}]{df\+\_\+x,  }\item[{real, dimension(\+:,\+:,\+:), optional, pointer}]{df\+\_\+y,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{ad\+\_\+2d\+\_\+x,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{ad\+\_\+2d\+\_\+y,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{df\+\_\+2d\+\_\+x,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{df\+\_\+2d\+\_\+y,  }\item[{real, dimension(\+:,\+:,\+:), optional, pointer}]{advection\+\_\+xy,  }\item[{logical, intent(in), optional}]{registry\+\_\+diags,  }\item[{character(len=$\ast$), intent(in), optional}]{flux\+\_\+nameroot,  }\item[{character(len=$\ast$), intent(in), optional}]{flux\+\_\+longname,  }\item[{character(len=$\ast$), intent(in), optional}]{flux\+\_\+units,  }\item[{real, intent(in), optional}]{flux\+\_\+scale,  }\item[{character(len=$\ast$), intent(in), optional}]{convergence\+\_\+units,  }\item[{real, intent(in), optional}]{convergence\+\_\+scale,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+tendprefix,  }\item[{integer, intent(in), optional}]{diag\+\_\+form,  }\item[{type(mom\+\_\+restart\+\_\+cs), optional, pointer}]{restart\+\_\+\+CS,  }\item[{logical, intent(in), optional}]{mandatory }\end{DoxyParamCaption})}



This subroutine registers a tracer to be advected and laterally diffused. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi} & horizontal index type\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
 & {\em reg} & pointer to the tracer registry\\
\hline
 & {\em tr\+\_\+ptr} & target or pointer to the tracer array\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & file to parse for model parameter values\\
\hline
\mbox{\tt in}  & {\em name} & Short tracer name\\
\hline
\mbox{\tt in}  & {\em longname} & The long tracer name\\
\hline
\mbox{\tt in}  & {\em units} & The units of this tracer\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+name} & C\+M\+OR name\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+units} & C\+M\+OR physical dimensions of variable\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+longname} & C\+M\+OR long name\\
\hline
\mbox{\tt in}  & {\em tr\+\_\+desc} & A structure with metadata about the tracer\\
\hline
\mbox{\tt in}  & {\em obc\+\_\+inflow} & the tracer for all inflows via O\+BC for which O\+B\+C\+\_\+in\+\_\+u or O\+B\+C\+\_\+in\+\_\+v are not specified (units of tracer C\+O\+NC)\\
\hline
 & {\em obc\+\_\+in\+\_\+u} & tracer at inflows through u-\/faces of tracer cells (units of tracer C\+O\+NC)\\
\hline
 & {\em obc\+\_\+in\+\_\+v} & tracer at inflows through v-\/faces of tracer cells (units of tracer C\+O\+NC)\\
\hline
 & {\em ad\+\_\+x} & diagnostic x-\/advective flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em ad\+\_\+y} & diagnostic y-\/advective flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em df\+\_\+x} & diagnostic x-\/diffusive flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em df\+\_\+y} & diagnostic y-\/diffusive flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em ad\+\_\+2d\+\_\+x} & vert sum of diagnostic x-\/advect flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em ad\+\_\+2d\+\_\+y} & vert sum of diagnostic y-\/advect flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em df\+\_\+2d\+\_\+x} & vert sum of diagnostic x-\/diffuse flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em df\+\_\+2d\+\_\+y} & vert sum of diagnostic y-\/diffuse flux \mbox{[}conc H L2 T-\/1 $\sim$$>$ C\+O\+NC m3 s-\/1 or C\+O\+NC kg s-\/1\mbox{]}\\
\hline
 & {\em advection\+\_\+xy} & convergence of lateral advective tracer fluxes\\
\hline
\mbox{\tt in}  & {\em registry\+\_\+diags} & If present and true, use the registry for the diagnostics of this tracer.\\
\hline
\mbox{\tt in}  & {\em flux\+\_\+nameroot} & Short tracer name snippet used construct the names of flux diagnostics.\\
\hline
\mbox{\tt in}  & {\em flux\+\_\+longname} & A word or phrase used construct the long names of flux diagnostics.\\
\hline
\mbox{\tt in}  & {\em flux\+\_\+units} & The units for the fluxes of this tracer.\\
\hline
\mbox{\tt in}  & {\em flux\+\_\+scale} & A scaling factor used to convert the fluxes of this tracer to its desired units.\\
\hline
\mbox{\tt in}  & {\em convergence\+\_\+units} & The units for the flux convergence of this tracer.\\
\hline
\mbox{\tt in}  & {\em convergence\+\_\+scale} & A scaling factor used to convert the flux convergence of this tracer to its desired units.\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+tendprefix} & The C\+M\+OR name for the layer-\/integrated tendencies of this tracer.\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+form} & An integer (1 or 2, 1 by default) indicating the character string template to use in labeling diagnostics\\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure this tracer will be registered for restarts if this argument is present\\
\hline
\mbox{\tt in}  & {\em mandatory} & If true, this tracer must be read from a restart file. \\
\hline
\end{DoxyParams}


Definition at line 158 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
158   \textcolor{keywordtype}{type}(hor\_index\_type),           \textcolor{keywordtype}{intent(in)}    :: hi\textcolor{comment}{           !< horizontal index type}
159   \textcolor{keywordtype}{type}(verticalgrid\_type),        \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{           !< ocean vertical grid structure}
160   \textcolor{keywordtype}{type}(tracer\_registry\_type),     \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{          !< pointer to the tracer registry}
161   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(HI),SZJ\_(HI),SZK\_(GV))}, &
162                                   \textcolor{keywordtype}{target}        :: tr\_ptr\textcolor{comment}{       !< target or pointer to the tracer array}
163   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)}             :: param\_file\textcolor{comment}{   !< file to parse for model parameter values}
164   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: name\textcolor{comment}{         !< Short tracer name}
165   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: longname\textcolor{comment}{     !< The long tracer name}
166   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: units\textcolor{comment}{        !< The units of this tracer}
167   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_name\textcolor{comment}{    !< CMOR name}
168   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_units\textcolor{comment}{   !< CMOR physical dimensions of variable}
169   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_longname\textcolor{comment}{ !< CMOR long name}
170   \textcolor{keywordtype}{type}(vardesc),        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: tr\_desc\textcolor{comment}{      !< A structure with metadata about the
       tracer}
171 
172   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: obc\_inflow\textcolor{comment}{   !< the tracer for all inflows via OBC for
       which OBC\_in\_u}
173 \textcolor{comment}{                                                                !! or OBC\_in\_v are not specified (units of
       tracer CONC)}
174   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: obc\_in\_u\textcolor{comment}{     !< tracer at inflows through u-faces of}
175 \textcolor{comment}{                                                                !! tracer cells (units of tracer CONC)}
176   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: obc\_in\_v\textcolor{comment}{     !< tracer at inflows through v-faces of}
177 \textcolor{comment}{                                                                !! tracer cells (units of tracer CONC)}
178 
179   \textcolor{comment}{! The following are probably not necessary if registry\_diags is present and true.}
180   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: ad\_x\textcolor{comment}{         !< diagnostic x-advective flux}
181 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
182   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: ad\_y\textcolor{comment}{         !< diagnostic y-advective flux}
183 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
184   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: df\_x\textcolor{comment}{         !< diagnostic x-diffusive flux}
185 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
186   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: df\_y\textcolor{comment}{         !< diagnostic y-diffusive flux}
187 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
188   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: ad\_2d\_x\textcolor{comment}{      !< vert sum of diagnostic x-advect flux}
189 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
190   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: ad\_2d\_y\textcolor{comment}{      !< vert sum of diagnostic y-advect flux}
191 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
192   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: df\_2d\_x\textcolor{comment}{      !< vert sum of diagnostic x-diffuse flux}
193 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
194   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: df\_2d\_y\textcolor{comment}{      !< vert sum of diagnostic y-diffuse flux}
195 \textcolor{comment}{                                                                !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg
       s-1]}
196 
197   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: advection\_xy\textcolor{comment}{ !< convergence of lateral advective tracer
       fluxes}
198   \textcolor{keywordtype}{logical},              \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: registry\_diags\textcolor{comment}{ !< If present and true, use the registry
       for}
199 \textcolor{comment}{                                                                !! the diagnostics of this tracer.}
200   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: flux\_nameroot\textcolor{comment}{ !< Short tracer name snippet used
       construct the}
201 \textcolor{comment}{                                                                !! names of flux diagnostics.}
202   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: flux\_longname\textcolor{comment}{ !< A word or phrase used construct the
       long}
203 \textcolor{comment}{                                                                !! names of flux diagnostics.}
204   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: flux\_units\textcolor{comment}{   !< The units for the fluxes of this tracer.}
205   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: flux\_scale\textcolor{comment}{   !< A scaling factor used to convert the
       fluxes}
206 \textcolor{comment}{                                                                !! of this tracer to its desired units.}
207   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: convergence\_units\textcolor{comment}{ !< The units for the flux convergence
       of}
208 \textcolor{comment}{                                                                !! this tracer.}
209   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: convergence\_scale\textcolor{comment}{ !< A scaling factor used to convert
       the flux}
210 \textcolor{comment}{                                                                !! convergence of this tracer to its
       desired units.}
211   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_tendprefix\textcolor{comment}{ !< The CMOR name for the
       layer-integrated}
212 \textcolor{comment}{                                                                !! tendencies of this tracer.}
213   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: diag\_form\textcolor{comment}{    !< An integer (1 or 2, 1 by default)
       indicating the}
214 \textcolor{comment}{                                                                !! character string template to use in}
215 \textcolor{comment}{                                                                !! labeling diagnostics}
216   \textcolor{keywordtype}{type}(mom\_restart\_cs), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: restart\_cs\textcolor{comment}{   !< A pointer to the restart control
       structure}
217 \textcolor{comment}{                                                                !! this tracer will be registered for}
218 \textcolor{comment}{                                                                !! restarts if this argument is present}
219   \textcolor{keywordtype}{logical},              \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: mandatory\textcolor{comment}{    !< If true, this tracer must be read}
220 \textcolor{comment}{                                                                !! from a restart file.}
221 
222   \textcolor{keywordtype}{logical} :: mand
223   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer} :: tr=>null()
224   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}
225 
226   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(reg)) \textcolor{keyword}{call }tracer\_registry\_init(param\_file, reg)
227 
228   \textcolor{keywordflow}{if} (reg%ntr>=max\_fields\_) \textcolor{keywordflow}{then}
229     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Increase MAX\_FIELDS\_ in MOM\_memory.h to at least ",I3," to allow for &}
230 \textcolor{stringliteral}{}\textcolor{stringliteral}{        &all the tracers being registered via register\_tracer.")'}) reg%ntr+1
231     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM register\_tracer: "}//mesg)
232 \textcolor{keywordflow}{  endif}
233   reg%ntr = reg%ntr + 1
234 
235   tr => reg%Tr(reg%ntr)
236 
237   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(name)) \textcolor{keywordflow}{then}
238     tr%name = name
239     tr%longname = name ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(longname)) tr%longname = longname
240     tr%units = \textcolor{stringliteral}{"Conc"} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units)) tr%units = units
241 
242     tr%cmor\_name = \textcolor{stringliteral}{""}
243     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_name)) tr%cmor\_name = cmor\_name
244 
245     tr%cmor\_units = tr%units
246     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_units)) tr%cmor\_units = cmor\_units
247 
248     tr%cmor\_longname = \textcolor{stringliteral}{""}
249     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_longname)) tr%cmor\_longname = cmor\_longname
250 
251     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(tr\_desc)) \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM register\_tracer: "}//&
252       \textcolor{stringliteral}{"It is a bad idea to use both name and tr\_desc when registring "}//trim(name))
253   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(tr\_desc)) \textcolor{keywordflow}{then}
254     \textcolor{keyword}{call }query\_vardesc(tr\_desc, name=tr%name, units=tr%units, &
255                        longname=tr%longname, cmor\_field\_name=tr%cmor\_name, &
256                        cmor\_longname=tr%cmor\_longname, caller=\textcolor{stringliteral}{"register\_tracer"})
257     tr%cmor\_units = tr%units
258   \textcolor{keywordflow}{else}
259     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM register\_tracer: Either name or "}//&
260                    \textcolor{stringliteral}{"tr\_desc must be present when registering a tracer."})
261 \textcolor{keywordflow}{  endif}
262 
263   \textcolor{keywordflow}{if} (reg%locked) \textcolor{keyword}{call }mom\_error(fatal, &
264       \textcolor{stringliteral}{"MOM register\_tracer was called for variable "}//trim(tr%name)//&
265       \textcolor{stringliteral}{" with a locked tracer registry."})
266 
267   tr%flux\_nameroot = tr%name
268   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(flux\_nameroot)) \textcolor{keywordflow}{then}
269     \textcolor{keywordflow}{if} (len\_trim(flux\_nameroot) > 0) tr%flux\_nameroot = flux\_nameroot
270 \textcolor{keywordflow}{  endif}
271 
272   tr%flux\_longname = tr%longname
273   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(flux\_longname)) \textcolor{keywordflow}{then}
274     \textcolor{keywordflow}{if} (len\_trim(flux\_longname) > 0) tr%flux\_longname = flux\_longname
275 \textcolor{keywordflow}{  endif}
276 
277   tr%flux\_units = \textcolor{stringliteral}{""}
278   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(flux\_units)) tr%flux\_units = flux\_units
279 
280   tr%flux\_scale = 1.0
281   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(flux\_scale)) tr%flux\_scale = flux\_scale
282 
283   tr%conv\_units = \textcolor{stringliteral}{""}
284   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(convergence\_units)) tr%conv\_units = convergence\_units
285 
286   tr%cmor\_tendprefix = \textcolor{stringliteral}{""}
287   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_tendprefix)) tr%cmor\_tendprefix = cmor\_tendprefix
288 
289   tr%conv\_scale = 1.0
290   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(convergence\_scale)) \textcolor{keywordflow}{then}
291     tr%conv\_scale = convergence\_scale
292   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(flux\_scale)) \textcolor{keywordflow}{then}
293     tr%conv\_scale = flux\_scale
294 \textcolor{keywordflow}{  endif}
295 
296   tr%diag\_form = 1
297   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(diag\_form)) tr%diag\_form = diag\_form
298 
299   tr%t => tr\_ptr
300 
301   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(registry\_diags)) tr%registry\_diags = registry\_diags
302 
303   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ad\_x)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\_x)) tr%ad\_x => ad\_x ;\textcolor{keywordflow}{ endif}
304   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ad\_y)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\_y)) tr%ad\_y => ad\_y ;\textcolor{keywordflow}{ endif}
305   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(df\_x)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(df\_x)) tr%df\_x => df\_x ;\textcolor{keywordflow}{ endif}
306   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(df\_y)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(df\_y)) tr%df\_y => df\_y ;\textcolor{keywordflow}{ endif}
307 \textcolor{comment}{! if (present(OBC\_inflow)) Tr%OBC\_inflow\_conc = OBC\_inflow}
308 \textcolor{comment}{! if (present(OBC\_in\_u)) then ; if (associated(OBC\_in\_u)) &}
309 \textcolor{comment}{!                                   Tr%OBC\_in\_u => OBC\_in\_u ; endif}
310 \textcolor{comment}{! if (present(OBC\_in\_v)) then ; if (associated(OBC\_in\_v)) &}
311 \textcolor{comment}{!                                   Tr%OBC\_in\_v => OBC\_in\_v ; endif}
312   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ad\_2d\_x)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\_2d\_x)) tr%ad2d\_x => ad\_2d\_x ;\textcolor{keywordflow}{ endif}
313   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ad\_2d\_y)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\_2d\_y)) tr%ad2d\_y => ad\_2d\_y ;\textcolor{keywordflow}{ endif}
314   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(df\_2d\_x)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(df\_2d\_x)) tr%df2d\_x => df\_2d\_x ;\textcolor{keywordflow}{ endif}
315 
316   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(advection\_xy)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(advection\_xy)) tr%advection\_xy => advection\_xy ;\textcolor{keywordflow}{ endif}
317 
318   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(restart\_cs)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(restart\_cs)) \textcolor{keywordflow}{then}
319     \textcolor{comment}{! Register this tracer to be read from and written to restart files.}
320     mand = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mandatory)) mand = mandatory
321 
322     \textcolor{keyword}{call }register\_restart\_field(tr\_ptr, tr%name, mand, restart\_cs, &
323                                 longname=tr%longname, units=tr%units)
324 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}
325 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_a6210cf64994a49ae3c14e3500c957fb1}\label{namespacemom__tracer__registry_a6210cf64994a49ae3c14e3500c957fb1}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!register\+\_\+tracer\+\_\+diagnostics@{register\+\_\+tracer\+\_\+diagnostics}}
\index{register\+\_\+tracer\+\_\+diagnostics@{register\+\_\+tracer\+\_\+diagnostics}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{register\+\_\+tracer\+\_\+diagnostics()}{register\_tracer\_diagnostics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::register\+\_\+tracer\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{h,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(diag\+\_\+ctrl), intent(in)}]{diag,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{logical, intent(in)}]{use\+\_\+\+A\+LE }\end{DoxyParamCaption})}



register\+\_\+tracer\+\_\+diagnostics does a set of register\+\_\+diag\+\_\+field calls for any previously registered in a tracer registry with a value of registry\+\_\+diags set to .true. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
 & {\em reg} & pointer to the tracer registry\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses\\
\hline
\mbox{\tt in}  & {\em time} & current model time\\
\hline
\mbox{\tt in}  & {\em diag} & structure to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em use\+\_\+ale} & If true active diagnostics that only apply to A\+LE configurations \\
\hline
\end{DoxyParams}


Definition at line 344 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
344   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
345   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
346   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)} :: us\textcolor{comment}{   !< A dimensional unit scaling type}
347   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{  !< pointer to the tracer registry}
348   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
349                               \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses}
350   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)} :: time\textcolor{comment}{ !< current model time}
351   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< structure to regulate diagnostic output}
352   \textcolor{keywordtype}{logical},                    \textcolor{keywordtype}{intent(in)} :: use\_ale\textcolor{comment}{ !< If true active diagnostics that only}
353 \textcolor{comment}{                                                 !! apply to ALE configurations}
354 
355   \textcolor{keywordtype}{character(len=24)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}
356   \textcolor{keywordtype}{character(len=24)} :: shortnm  \textcolor{comment}{! A shortened version of a variable's name for}
357                                 \textcolor{comment}{! creating additional diagnostics.}
358   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that tracer variable.}
359   \textcolor{keywordtype}{character(len=72)} :: flux\_longname \textcolor{comment}{! The tracer name in the long names of fluxes.}
360   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the tracer.}
361   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for fluxes, either}
362                                 \textcolor{comment}{! [units] m3 s-1 or [units] kg s-1.}
363   \textcolor{keywordtype}{character(len=48)} :: conv\_units \textcolor{comment}{! The units for flux convergences, either}
364                                 \textcolor{comment}{! [units] m2 s-1 or [units] kg s-1.}
365   \textcolor{keywordtype}{character(len=48)} :: unit2    \textcolor{comment}{! The dimensions of the tracer squared}
366   \textcolor{keywordtype}{character(len=72)}  :: cmorname \textcolor{comment}{! The CMOR name of this tracer.}
367   \textcolor{keywordtype}{character(len=120)} :: cmor\_longname \textcolor{comment}{! The CMOR long name of that variable.}
368   \textcolor{keywordtype}{character(len=120)} :: var\_lname      \textcolor{comment}{! A temporary longname for a diagnostic.}
369   \textcolor{keywordtype}{character(len=120)} :: cmor\_var\_lname \textcolor{comment}{! The temporary CMOR long name for a diagnostic}
370   \textcolor{keywordtype}{character(len=72)}  :: cmor\_varname \textcolor{comment}{! The temporary CMOR name for a diagnostic}
371   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer} :: tr=>null()
372   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m, m2, ntr\_in
373   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
374   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
375   isd  = g%isd  ; ied  = g%ied  ; jsd  = g%jsd  ; jed  = g%jed
376   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
377 
378   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(reg)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"register\_tracer\_diagnostics: "}//&
379        \textcolor{stringliteral}{"register\_tracer must be called before register\_tracer\_diagnostics"})
380 
381   ntr\_in = reg%ntr
382 
383   \textcolor{keywordflow}{do} m=1,ntr\_in ; \textcolor{keywordflow}{if} (reg%Tr(m)%registry\_diags) \textcolor{keywordflow}{then}
384     tr => reg%Tr(m)
385 \textcolor{comment}{!    call query\_vardesc(Tr%vd, name, units=units, longname=longname, &}
386 \textcolor{comment}{!                       cmor\_field\_name=cmorname, cmor\_longname=cmor\_longname, &}
387 \textcolor{comment}{!                       caller="register\_tracer\_diagnostics")}
388     name = tr%name ; units=adjustl(tr%units) ; longname = tr%longname
389     cmorname = tr%cmor\_name ; cmor\_longname = tr%cmor\_longname
390     shortnm = tr%flux\_nameroot
391     flux\_longname = tr%flux\_longname
392     \textcolor{keywordflow}{if} (len\_trim(cmor\_longname) == 0) cmor\_longname = longname
393 
394     \textcolor{keywordflow}{if} (len\_trim(tr%flux\_units) > 0) \textcolor{keywordflow}{then} ; flux\_units = tr%flux\_units
395     \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then} ; flux\_units = trim(units)//\textcolor{stringliteral}{" m3 s-1"}
396     \textcolor{keywordflow}{else} ; flux\_units = trim(units)//\textcolor{stringliteral}{" kg s-1"} ;\textcolor{keywordflow}{ endif}
397 
398     \textcolor{keywordflow}{if} (len\_trim(tr%conv\_units) > 0) \textcolor{keywordflow}{then} ; conv\_units = tr%conv\_units
399     \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then} ; conv\_units = trim(units)//\textcolor{stringliteral}{" m s-1"}
400     \textcolor{keywordflow}{else} ; conv\_units = trim(units)//\textcolor{stringliteral}{" kg m-2 s-1"} ;\textcolor{keywordflow}{ endif}
401 
402     \textcolor{keywordflow}{if} (len\_trim(cmorname) == 0) \textcolor{keywordflow}{then}
403       tr%id\_tr = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(name), diag%axesTL, &
404         time, trim(longname), trim(units))
405     \textcolor{keywordflow}{else}
406       tr%id\_tr = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(name), diag%axesTL, &
407         time, trim(longname), trim(units), cmor\_field\_name=cmorname, &
408         cmor\_long\_name=cmor\_longname, cmor\_units=tr%cmor\_units, &
409         cmor\_standard\_name=cmor\_long\_std(cmor\_longname))
410 \textcolor{keywordflow}{    endif}
411     tr%id\_tr\_post\_horzn = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"},                &
412       trim(name)//\textcolor{stringliteral}{"\_post\_horzn"}, diag%axesTL, time,                         &
413       trim(longname)//\textcolor{stringliteral}{" after horizontal transport (advection/diffusion) "}//&
414       \textcolor{stringliteral}{"has occurred"}, trim(units))
415     \textcolor{keywordflow}{if} (tr%diag\_form == 1) \textcolor{keywordflow}{then}
416       tr%id\_adx = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_adx"}, &
417           diag%axesCuL, time, trim(flux\_longname)//\textcolor{stringliteral}{" advective zonal flux"} , &
418           trim(flux\_units), v\_extensive = .true., y\_cell\_method = \textcolor{stringliteral}{'sum'}, &
419           conversion=tr%flux\_scale*(us%L\_to\_m**2)*us%s\_to\_T)
420       tr%id\_ady = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_ady"}, &
421           diag%axesCvL, time, trim(flux\_longname)//\textcolor{stringliteral}{" advective meridional flux"} , &
422           trim(flux\_units), v\_extensive = .true., x\_cell\_method = \textcolor{stringliteral}{'sum'}, &
423           conversion=tr%flux\_scale*(us%L\_to\_m**2)*us%s\_to\_T)
424       tr%id\_dfx = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_dfx"}, &
425           diag%axesCuL, time, trim(flux\_longname)//\textcolor{stringliteral}{" diffusive zonal flux"} , &
426           trim(flux\_units), v\_extensive = .true., y\_cell\_method = \textcolor{stringliteral}{'sum'}, &
427           conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T)
428       tr%id\_dfy = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_dfy"}, &
429           diag%axesCvL, time, trim(flux\_longname)//\textcolor{stringliteral}{" diffusive zonal flux"} , &
430           trim(flux\_units), v\_extensive = .true., x\_cell\_method = \textcolor{stringliteral}{'sum'}, &
431           conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T)
432       tr%id\_lbd\_dfx = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_diffx"}, &
433           diag%axesCuL, time, trim(flux\_longname)//\textcolor{stringliteral}{" diffusive zonal flux from the lateral boundary
       diffusion "}//&
434           \textcolor{stringliteral}{"scheme"}, trim(flux\_units), v\_extensive = .true., y\_cell\_method = \textcolor{stringliteral}{'sum'}, &
435           conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T)
436       tr%id\_lbd\_dfy = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_diffy"}, &
437           diag%axesCvL, time, trim(flux\_longname)//\textcolor{stringliteral}{" diffusive meridional flux from the lateral boundary
       diffusion "}//&
438           \textcolor{stringliteral}{"scheme"}, trim(flux\_units), v\_extensive = .true., x\_cell\_method = \textcolor{stringliteral}{'sum'}, &
439           conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T)
440     \textcolor{keywordflow}{else}
441       tr%id\_adx = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_adx"}, &
442           diag%axesCuL, time, \textcolor{stringliteral}{"Advective (by residual mean) Zonal Flux of "}//trim(flux\_longname), &
443           flux\_units, v\_extensive=.true., conversion=tr%flux\_scale*(us%L\_to\_m**2)*us%s\_to\_T, y\_cell\_method 
      = \textcolor{stringliteral}{'sum'})
444       tr%id\_ady = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_ady"}, &
445           diag%axesCvL, time, \textcolor{stringliteral}{"Advective (by residual mean) Meridional Flux of "}//trim(flux\_longname), &
446           flux\_units, v\_extensive=.true., conversion=tr%flux\_scale*(us%L\_to\_m**2)*us%s\_to\_T, x\_cell\_method 
      = \textcolor{stringliteral}{'sum'})
447       tr%id\_dfx = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_diffx"}, &
448           diag%axesCuL, time, \textcolor{stringliteral}{"Diffusive Zonal Flux of "}//trim(flux\_longname), &
449           flux\_units, v\_extensive=.true., conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
450           y\_cell\_method=\textcolor{stringliteral}{'sum'})
451       tr%id\_dfy = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_diffy"}, &
452           diag%axesCvL, time, \textcolor{stringliteral}{"Diffusive Meridional Flux of "}//trim(flux\_longname), &
453           flux\_units, v\_extensive=.true., conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
454           x\_cell\_method=\textcolor{stringliteral}{'sum'})
455       tr%id\_lbd\_dfx = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_diffx"}, &
456           diag%axesCuL, time, \textcolor{stringliteral}{"Lateral Boundary Diffusive Zonal Flux of "}//trim(flux\_longname), &
457           flux\_units, v\_extensive=.true., conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
458           y\_cell\_method=\textcolor{stringliteral}{'sum'})
459       tr%id\_lbd\_dfy = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_diffy"}, &
460           diag%axesCvL, time, \textcolor{stringliteral}{"Lateral Boundary Diffusive Meridional Flux of "}//trim(flux\_longname), &
461           flux\_units, v\_extensive=.true., conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
462           x\_cell\_method=\textcolor{stringliteral}{'sum'})
463 \textcolor{keywordflow}{    endif}
464     \textcolor{keywordflow}{if} (tr%id\_adx > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%ad\_x,isdb,iedb,jsd,jed,nz)
465     \textcolor{keywordflow}{if} (tr%id\_ady > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%ad\_y,isd,ied,jsdb,jedb,nz)
466     \textcolor{keywordflow}{if} (tr%id\_dfx > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%df\_x,isdb,iedb,jsd,jed,nz)
467     \textcolor{keywordflow}{if} (tr%id\_dfy > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%df\_y,isd,ied,jsdb,jedb,nz)
468     \textcolor{keywordflow}{if} (tr%id\_lbd\_dfx > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%lbd\_dfx,isdb,iedb,jsd,jed,nz)
469     \textcolor{keywordflow}{if} (tr%id\_lbd\_dfy > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%lbd\_dfy,isd,ied,jsdb,jedb,nz)
470 
471     tr%id\_adx\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_adx\_2d"}, &
472         diag%axesCu1, time, &
473         \textcolor{stringliteral}{"Vertically Integrated Advective Zonal Flux of "}//trim(flux\_longname), &
474         flux\_units, conversion=tr%flux\_scale*(us%L\_to\_m**2)*us%s\_to\_T, y\_cell\_method = \textcolor{stringliteral}{'sum'})
475     tr%id\_ady\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_ady\_2d"}, &
476         diag%axesCv1, time, &
477         \textcolor{stringliteral}{"Vertically Integrated Advective Meridional Flux of "}//trim(flux\_longname), &
478         flux\_units, conversion=tr%flux\_scale*(us%L\_to\_m**2)*us%s\_to\_T, x\_cell\_method = \textcolor{stringliteral}{'sum'})
479     tr%id\_dfx\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_diffx\_2d"}, &
480         diag%axesCu1, time, &
481         \textcolor{stringliteral}{"Vertically Integrated Diffusive Zonal Flux of "}//trim(flux\_longname), &
482         flux\_units, conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
483         y\_cell\_method=\textcolor{stringliteral}{'sum'})
484     tr%id\_dfy\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_diffy\_2d"}, &
485         diag%axesCv1, time, &
486         \textcolor{stringliteral}{"Vertically Integrated Diffusive Meridional Flux of "}//trim(flux\_longname), &
487         flux\_units, conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
488         x\_cell\_method=\textcolor{stringliteral}{'sum'})
489     tr%id\_lbd\_bulk\_dfx = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_bulk\_diffx"}, &
490         diag%axesCu1, time, &
491         \textcolor{stringliteral}{"Total Bulk Diffusive Zonal Flux of "}//trim(flux\_longname), &
492         flux\_units, conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
493         y\_cell\_method=\textcolor{stringliteral}{'sum'})
494     tr%id\_lbd\_bulk\_dfy = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_bulk\_diffy"}, &
495         diag%axesCv1, time, &
496         \textcolor{stringliteral}{"Total Bulk Diffusive Meridional Flux of "}//trim(flux\_longname), &
497         flux\_units, conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T, &
498         x\_cell\_method=\textcolor{stringliteral}{'sum'})
499     tr%id\_lbd\_dfx\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_diffx\_2d"}, &
500           diag%axesCu1, time, \textcolor{stringliteral}{"Vertically-integrated zonal diffusive flux from the lateral boundary
       diffusion "}//&
501           \textcolor{stringliteral}{"scheme for "}//trim(flux\_longname), flux\_units, conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T
      , &
502           y\_cell\_method = \textcolor{stringliteral}{'sum'})
503     tr%id\_lbd\_dfy\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{"\_lbd\_diffy\_2d"}, &
504           diag%axesCv1, time, \textcolor{stringliteral}{"Vertically-integrated meridional diffusive flux from the lateral boundary
       diffusion "}//&
505           \textcolor{stringliteral}{"scheme for "}//trim(flux\_longname), flux\_units, conversion=(us%L\_to\_m**2)*tr%flux\_scale*us%s\_to\_T
      , &
506            x\_cell\_method = \textcolor{stringliteral}{'sum'})
507 
508     \textcolor{keywordflow}{if} (tr%id\_adx\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%ad2d\_x,isdb,iedb,jsd,jed)
509     \textcolor{keywordflow}{if} (tr%id\_ady\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%ad2d\_y,isd,ied,jsdb,jedb)
510     \textcolor{keywordflow}{if} (tr%id\_dfx\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%df2d\_x,isdb,iedb,jsd,jed)
511     \textcolor{keywordflow}{if} (tr%id\_dfy\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%df2d\_y,isd,ied,jsdb,jedb)
512     \textcolor{keywordflow}{if} (tr%id\_lbd\_bulk\_dfx > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%lbd\_bulk\_df\_x,isdb,iedb,jsd,jed)
513     \textcolor{keywordflow}{if} (tr%id\_lbd\_bulk\_dfy > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%lbd\_bulk\_df\_y,isd,ied,jsdb,jedb)
514     \textcolor{keywordflow}{if} (tr%id\_lbd\_dfx\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%lbd\_dfx\_2d,isdb,iedb,jsd,jed)
515     \textcolor{keywordflow}{if} (tr%id\_lbd\_dfy\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(tr%lbd\_dfy\_2d,isd,ied,jsdb,jedb)
516 
517     tr%id\_adv\_xy = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{"\_advection\_xy"}, &
518         diag%axesTL, time, &
519         \textcolor{stringliteral}{'Horizontal convergence of residual mean advective fluxes of '}//&
520         trim(lowercase(flux\_longname)), conv\_units, v\_extensive=.true., &
521         conversion=tr%conv\_scale*us%s\_to\_T)
522     tr%id\_adv\_xy\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{"\_advection\_xy\_2d"}, &
523         diag%axesT1, time, &
524         \textcolor{stringliteral}{'Vertical sum of horizontal convergence of residual mean advective fluxes of '}//&
525         trim(lowercase(flux\_longname)), conv\_units, conversion=tr%conv\_scale*us%s\_to\_T)
526     \textcolor{keywordflow}{if} ((tr%id\_adv\_xy > 0) .or. (tr%id\_adv\_xy\_2d > 0)) &
527       \textcolor{keyword}{call }safe\_alloc\_ptr(tr%advection\_xy,isd,ied,jsd,jed,nz)
528 
529     tr%id\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{'\_tendency'}, &
530         diag%axesTL, time, &
531         \textcolor{stringliteral}{'Net time tendency for '}//trim(lowercase(longname)), trim(units)//\textcolor{stringliteral}{' s-1'}, conversion=us%s\_to\_T)
532 
533     \textcolor{keywordflow}{if} (tr%id\_tendency > 0) \textcolor{keywordflow}{then}
534       \textcolor{keyword}{call }safe\_alloc\_ptr(tr%t\_prev,isd,ied,jsd,jed,nz)
535       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
536         tr%t\_prev(i,j,k) = tr%t(i,j,k)
537 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
538 \textcolor{keywordflow}{    endif}
539 
540     \textcolor{comment}{! Neutral/Lateral diffusion convergence tendencies}
541     \textcolor{keywordflow}{if} (tr%diag\_form == 1) \textcolor{keywordflow}{then}
542       tr%id\_dfxy\_cont = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_dfxy\_cont\_tendency'}, &
543           diag%axesTL, time, \textcolor{stringliteral}{"Neutral diffusion tracer content tendency for "}//trim(shortnm), &
544           conv\_units, conversion=tr%conv\_scale*us%s\_to\_T, x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'}, 
      v\_extensive=.true.)
545 
546       tr%id\_dfxy\_cont\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_dfxy\_cont\_tendency\_2d'}, &
547           diag%axesT1, time, \textcolor{stringliteral}{"Depth integrated neutral diffusion tracer content "}//&
548           \textcolor{stringliteral}{"tendency for "}//trim(shortnm), conv\_units, conversion=tr%conv\_scale*us%s\_to\_T, &
549           x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method= \textcolor{stringliteral}{'sum'})
550 
551       tr%id\_lbdxy\_cont = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_lbdxy\_cont\_tendency'}, &
552           diag%axesTL, time, \textcolor{stringliteral}{"Lateral diffusion tracer content tendency for "}//trim(shortnm), &
553           conv\_units, conversion=tr%conv\_scale*us%s\_to\_T, x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'}, 
      v\_extensive=.true.)
554 
555       tr%id\_lbdxy\_cont\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_lbdxy\_cont\_tendency\_2d'}, &
556           diag%axesT1, time, \textcolor{stringliteral}{"Depth integrated lateral diffusion tracer content "}//&
557           \textcolor{stringliteral}{"tendency for "}//trim(shortnm), conv\_units, conversion=tr%conv\_scale*us%s\_to\_T, &
558           x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method= \textcolor{stringliteral}{'sum'})
559     \textcolor{keywordflow}{else}
560       cmor\_var\_lname = \textcolor{stringliteral}{'Tendency of '}//trim(lowercase(cmor\_longname))//&
561            \textcolor{stringliteral}{' expressed as '}//trim(lowercase(flux\_longname))//&
562            \textcolor{stringliteral}{' content due to parameterized mesoscale neutral diffusion'}
563       tr%id\_dfxy\_cont = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_dfxy\_cont\_tendency'}, &
564           diag%axesTL, time, \textcolor{stringliteral}{"Neutral diffusion tracer content tendency for "}//trim(shortnm), &
565           conv\_units, conversion=tr%conv\_scale*us%s\_to\_T, cmor\_field\_name = trim(tr%cmor\_tendprefix)//\textcolor{stringliteral}{
      'pmdiff'}, &
566           cmor\_long\_name = trim(cmor\_var\_lname), cmor\_standard\_name = trim(cmor\_long\_std(cmor\_var\_lname)), 
      &
567           x\_cell\_method = \textcolor{stringliteral}{'sum'}, y\_cell\_method = \textcolor{stringliteral}{'sum'}, v\_extensive = .true.)
568 
569       cmor\_var\_lname = \textcolor{stringliteral}{'Tendency of '}//trim(lowercase(cmor\_longname))//\textcolor{stringliteral}{' expressed as '}//&
570                        trim(lowercase(flux\_longname))//\textcolor{stringliteral}{' content due to parameterized mesoscale neutral
       diffusion'}
571       tr%id\_dfxy\_cont\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_dfxy\_cont\_tendency\_2d'}, &
572           diag%axesT1, time, \textcolor{stringliteral}{"Depth integrated neutral diffusion tracer "}//&
573           \textcolor{stringliteral}{"content tendency for "}//trim(shortnm), conv\_units, &
574           conversion=tr%conv\_scale*us%s\_to\_T, cmor\_field\_name=trim(tr%cmor\_tendprefix)//\textcolor{stringliteral}{'pmdiff\_2d'}, &
575           cmor\_long\_name=trim(cmor\_var\_lname), cmor\_standard\_name=trim(cmor\_long\_std(cmor\_var\_lname)), &
576           x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'})
577 
578       tr%id\_lbdxy\_cont = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_lbdxy\_cont\_tendency'}, &
579           diag%axesTL, time, \textcolor{stringliteral}{"Lateral diffusion tracer content tendency for "}//trim(shortnm), &
580           conv\_units, conversion=tr%conv\_scale*us%s\_to\_T, &
581           x\_cell\_method = \textcolor{stringliteral}{'sum'}, y\_cell\_method = \textcolor{stringliteral}{'sum'}, v\_extensive = .true.)
582 
583       tr%id\_lbdxy\_cont\_2d = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_lbdxy\_cont\_tendency\_2d'}, &
584           diag%axesT1, time, \textcolor{stringliteral}{"Depth integrated lateral diffusion tracer "}//&
585           \textcolor{stringliteral}{"content tendency for "}//trim(shortnm), conv\_units, &
586           conversion=tr%conv\_scale*us%s\_to\_T, x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'})
587 \textcolor{keywordflow}{    endif}
588     tr%id\_dfxy\_conc = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_dfxy\_conc\_tendency'}, &
589         diag%axesTL, time, \textcolor{stringliteral}{"Neutral diffusion tracer concentration tendency for "}//trim(shortnm), &
590         trim(units)//\textcolor{stringliteral}{' s-1'}, conversion=us%s\_to\_T)
591 
592     tr%id\_lbdxy\_conc = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(shortnm)//\textcolor{stringliteral}{'\_lbdxy\_conc\_tendency'}, &
593         diag%axesTL, time, \textcolor{stringliteral}{"Lateral diffusion tracer concentration tendency for "}//trim(shortnm), &
594         trim(units)//\textcolor{stringliteral}{' s-1'}, conversion=us%s\_to\_T)
595 
596     var\_lname = \textcolor{stringliteral}{"Net time tendency for "}//lowercase(flux\_longname)
597     \textcolor{keywordflow}{if} (len\_trim(tr%cmor\_tendprefix) == 0) \textcolor{keywordflow}{then}
598       tr%id\_trxh\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{'h\_tendency'}, &
599           diag%axesTL, time, var\_lname, conv\_units, v\_extensive=.true., &
600           conversion=tr%conv\_scale*us%s\_to\_T)
601       tr%id\_trxh\_tendency\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{'h\_tendency\_2d'}, &
602           diag%axesT1, time, \textcolor{stringliteral}{"Vertical sum of "}//trim(lowercase(var\_lname)), conv\_units, &
603           conversion=tr%conv\_scale*us%s\_to\_T)
604     \textcolor{keywordflow}{else}
605       cmor\_var\_lname = \textcolor{stringliteral}{"Tendency of "}//trim(cmor\_longname)//\textcolor{stringliteral}{" Expressed as "}//&
606                         trim(flux\_longname)//\textcolor{stringliteral}{" Content"}
607       tr%id\_trxh\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{'h\_tendency'}, &
608           diag%axesTL, time, var\_lname, conv\_units, &
609           cmor\_field\_name=trim(tr%cmor\_tendprefix)//\textcolor{stringliteral}{"tend"}, &
610           cmor\_standard\_name=cmor\_long\_std(cmor\_var\_lname), cmor\_long\_name=cmor\_var\_lname, &
611           v\_extensive=.true., conversion=tr%conv\_scale*us%s\_to\_T)
612       cmor\_var\_lname = trim(cmor\_var\_lname)//\textcolor{stringliteral}{" Vertical Sum"}
613       tr%id\_trxh\_tendency\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{'h\_tendency\_2d'}, &
614           diag%axesT1, time, \textcolor{stringliteral}{"Vertical sum of "}//trim(lowercase(var\_lname)), conv\_units, &
615           cmor\_field\_name=trim(tr%cmor\_tendprefix)//\textcolor{stringliteral}{"tend\_2d"}, &
616           cmor\_standard\_name=cmor\_long\_std(cmor\_var\_lname), cmor\_long\_name=cmor\_var\_lname, &
617           conversion=tr%conv\_scale*us%s\_to\_T)
618 \textcolor{keywordflow}{    endif}
619     \textcolor{keywordflow}{if} ((tr%id\_trxh\_tendency > 0) .or. (tr%id\_trxh\_tendency\_2d > 0)) \textcolor{keywordflow}{then}
620       \textcolor{keyword}{call }safe\_alloc\_ptr(tr%Trxh\_prev,isd,ied,jsd,jed,nz)
621       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
622         tr%Trxh\_prev(i,j,k) = tr%t(i,j,k) * h(i,j,k)
623 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
624 \textcolor{keywordflow}{    endif}
625 
626     \textcolor{comment}{! Vertical regridding/remapping tendencies}
627     \textcolor{keywordflow}{if} (use\_ale .and. tr%remap\_tr) \textcolor{keywordflow}{then}
628       var\_lname = \textcolor{stringliteral}{"Vertical remapping tracer concentration tendency for "}//trim(reg%Tr(m)%name)
629       tr%id\_remap\_conc= register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},                          &
630         trim(tr%flux\_nameroot)//\textcolor{stringliteral}{'\_tendency\_vert\_remap'}, diag%axesTL, time, var\_lname, &
631         trim(units)//\textcolor{stringliteral}{' s-1'}, conversion=us%s\_to\_T)
632 
633       var\_lname = \textcolor{stringliteral}{"Vertical remapping tracer content tendency for "}//trim(reg%Tr(m)%flux\_longname)
634       tr%id\_remap\_cont = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, &
635         trim(tr%flux\_nameroot)//\textcolor{stringliteral}{'h\_tendency\_vert\_remap'},         &
636         diag%axesTL, time, var\_lname, flux\_units, v\_extensive=.true., conversion=tr%conv\_scale*us%s\_to\_T)
637 
638       var\_lname = \textcolor{stringliteral}{"Vertical sum of vertical remapping tracer content tendency for "}//&
639                   trim(reg%Tr(m)%flux\_longname)
640       tr%id\_remap\_cont\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, &
641         trim(tr%flux\_nameroot)//\textcolor{stringliteral}{'h\_tendency\_vert\_remap\_2d'},         &
642         diag%axesT1, time, var\_lname, flux\_units, conversion=tr%conv\_scale*us%s\_to\_T)
643 
644 \textcolor{keywordflow}{    endif}
645 
646     \textcolor{keywordflow}{if} (use\_ale .and. (reg%ntr<max\_fields\_) .and. tr%remap\_tr) \textcolor{keywordflow}{then}
647       unit2 = trim(units)//\textcolor{stringliteral}{"2"}
648       \textcolor{keywordflow}{if} (index(units(1:len\_trim(units)),\textcolor{stringliteral}{" "}) > 0) unit2 = \textcolor{stringliteral}{"("}//trim(units)//\textcolor{stringliteral}{")2"}
649       tr%id\_tr\_vardec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, trim(shortnm)//\textcolor{stringliteral}{"\_vardec"}, diag%axesTL, &
650         time, \textcolor{stringliteral}{"ALE variance decay for "}//lowercase(longname), trim(unit2)//\textcolor{stringliteral}{" s-1"}, conversion=us%s\_to\_T)
651       \textcolor{keywordflow}{if} (tr%id\_tr\_vardec > 0) \textcolor{keywordflow}{then}
652         \textcolor{comment}{! Set up a new tracer for this tracer squared}
653         m2 = reg%ntr+1
654         tr%ind\_tr\_squared = m2
655         \textcolor{keyword}{call }safe\_alloc\_ptr(reg%Tr(m2)%t,isd,ied,jsd,jed,nz) ; reg%Tr(m2)%t(:,:,:) = 0.0
656         reg%Tr(m2)%name = trim(shortnm)//\textcolor{stringliteral}{"2"}
657         reg%Tr(m2)%longname = \textcolor{stringliteral}{"Squared "}//trim(longname)
658         reg%Tr(m2)%units = unit2
659         reg%Tr(m2)%registry\_diags = .false.
660         reg%Tr(m2)%ind\_tr\_squared = -1
661         \textcolor{comment}{! Augment the total number of tracers, including the squared tracers.}
662         reg%ntr = reg%ntr + 1
663 \textcolor{keywordflow}{      endif}
664 \textcolor{keywordflow}{    endif}
665 
666 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo}
667 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_a67e71e90d3747dd97a917f6541f39b56}\label{namespacemom__tracer__registry_a67e71e90d3747dd97a917f6541f39b56}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!tracer\+\_\+name\+\_\+lookup@{tracer\+\_\+name\+\_\+lookup}}
\index{tracer\+\_\+name\+\_\+lookup@{tracer\+\_\+name\+\_\+lookup}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{tracer\+\_\+name\+\_\+lookup()}{tracer\_name\_lookup()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::tracer\+\_\+name\+\_\+lookup (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg,  }\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__type}{tracer\+\_\+type}), pointer}]{tr\+\_\+ptr,  }\item[{character(len=32), intent(in)}]{name }\end{DoxyParamCaption})}



Find a tracer in the tracer registry by name. 


\begin{DoxyParams}[1]{Parameters}
 & {\em reg} & pointer to tracer registry\\
\hline
 & {\em tr\+\_\+ptr} & target or pointer to the tracer array\\
\hline
\mbox{\tt in}  & {\em name} & tracer name \\
\hline
\end{DoxyParams}


Definition at line 850 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
850   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{     !< pointer to tracer registry}
851   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer}             :: tr\_ptr\textcolor{comment}{  !< target or pointer to the tracer array}
852   \textcolor{keywordtype}{character(len=32)}, \textcolor{keywordtype}{intent(in)}          :: name\textcolor{comment}{    !< tracer name}
853 
854   \textcolor{keywordtype}{integer} n
855   \textcolor{keywordflow}{do} n=1,reg%ntr
856     \textcolor{keywordflow}{if} (lowercase(reg%Tr(n)%name) == lowercase(name)) tr\_ptr => reg%Tr(n)
857 \textcolor{keywordflow}{  enddo}
858 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_aaca7f6bcdb5f1d8cb247e24719d37df9}\label{namespacemom__tracer__registry_aaca7f6bcdb5f1d8cb247e24719d37df9}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!tracer\+\_\+registry\+\_\+end@{tracer\+\_\+registry\+\_\+end}}
\index{tracer\+\_\+registry\+\_\+end@{tracer\+\_\+registry\+\_\+end}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{tracer\+\_\+registry\+\_\+end()}{tracer\_registry\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::tracer\+\_\+registry\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg }\end{DoxyParamCaption})}



This routine closes the tracer registry module. 


\begin{DoxyParams}{Parameters}
{\em reg} & The tracer registry that will be deallocated \\
\hline
\end{DoxyParams}


Definition at line 891 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
891   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer} :: reg\textcolor{comment}{ !< The tracer registry that will be deallocated}
892   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(reg)) \textcolor{keyword}{deallocate}(reg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__tracer__registry_a452937bf1f9d01a47d1a80793e317b33}\label{namespacemom__tracer__registry_a452937bf1f9d01a47d1a80793e317b33}} 
\index{mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}!tracer\+\_\+registry\+\_\+init@{tracer\+\_\+registry\+\_\+init}}
\index{tracer\+\_\+registry\+\_\+init@{tracer\+\_\+registry\+\_\+init}!mom\+\_\+tracer\+\_\+registry@{mom\+\_\+tracer\+\_\+registry}}
\subsubsection{\texorpdfstring{tracer\+\_\+registry\+\_\+init()}{tracer\_registry\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+tracer\+\_\+registry\+::tracer\+\_\+registry\+\_\+init (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}), pointer}]{Reg }\end{DoxyParamCaption})}



Initialize the tracer registry. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em param\+\_\+file} & open file to parse for model parameters\\
\hline
 & {\em reg} & pointer to tracer registry \\
\hline
\end{DoxyParams}


Definition at line 863 of file M\+O\+M\+\_\+tracer\+\_\+registry.\+F90.


\begin{DoxyCode}
863   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< open file to parse for model parameters}
864   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: reg\textcolor{comment}{        !< pointer to tracer registry}
865 
866   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{save} :: init\_calls = 0
867 
868 \textcolor{comment}{! This include declares and sets the variable "version".}
869 \textcolor{preprocessor}{#include "version\_variable.h"}
870 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_tracer\_registry"} \textcolor{comment}{! This module's name.}
871   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}
872 
873   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(reg)) \textcolor{keywordflow}{then} ; \textcolor{keyword}{allocate}(reg)
874   \textcolor{keywordflow}{else} ; \textcolor{keywordflow}{return} ;\textcolor{keywordflow}{ endif}
875 
876   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
877   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""}, all\_default=.true.)
878 
879   init\_calls = init\_calls + 1
880   \textcolor{keywordflow}{if} (init\_calls > 1) \textcolor{keywordflow}{then}
881     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("tracer\_registry\_init called ",I3, &}
882 \textcolor{stringliteral}{}\textcolor{stringliteral}{      &" times with different registry pointers.")'}) init\_calls
883     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"MOM\_tracer"}//mesg)
884 \textcolor{keywordflow}{  endif}
885 
\end{DoxyCode}
