\hypertarget{namespacedyed__obc__tracer}{}\doxysection{dyed\+\_\+obc\+\_\+tracer Module Reference}
\label{namespacedyed__obc__tracer}\index{dyed\_obc\_tracer@{dyed\_obc\_tracer}}


\doxysubsection{Detailed Description}
This tracer package dyes flow through open boundaries. 

By Kate Hedstrom, 2017, copied from D\+O\+ME tracers and also dye\+\_\+example.

This file contains an example of the code that is needed to set up and use a set of dynamically passive tracers. These tracers dye the inflowing water, one per open boundary segment.

A single subroutine is called from within each file to register each of the tracers for reinitialization and advection and to register the subroutine that initializes the tracers and set up their output and the subroutine that does any tracer physics or chemistry along with diapycnal mixing (included here because some tracers may float or swim vertically or dye diapycnal processes). \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structdyed__obc__tracer_1_1dyed__obc__tracer__cs}{dyed\+\_\+obc\+\_\+tracer\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em The control structure for the dyed\+\_\+obc tracer package. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespacedyed__obc__tracer_a968aec7f642a4750d835b0d030c17fe5}{register\+\_\+dyed\+\_\+obc\+\_\+tracer}} (HI, GV, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Register tracer fields and subroutines to be used with M\+OM. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedyed__obc__tracer_ae6775bb4fc321a45c68880edc243fcfa}{initialize\+\_\+dyed\+\_\+obc\+\_\+tracer}} (restart, day, G, GV, h, diag, O\+BC, CS)
\begin{DoxyCompactList}\small\item\em Initializes the CSntr tracer fields in tr(\+:,\+:,\+:,\+:) and sets up the tracer output. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedyed__obc__tracer_a7c9e4c1789bdcebd4f0fa1380eb6df3e}{dyed\+\_\+obc\+\_\+tracer\+\_\+column\+\_\+physics}} (h\+\_\+old, h\+\_\+new, ea, eb, fluxes, dt, G, GV, US, CS, evap\+\_\+\+C\+F\+L\+\_\+limit, minimum\+\_\+forcing\+\_\+depth)
\begin{DoxyCompactList}\small\item\em This subroutine applies diapycnal diffusion and any other column tracer physics or chemistry to the tracers from this file. This is a simple example of a set of advected passive tracers. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedyed__obc__tracer_a00701a980f0ec3042a1d2661287191a4}{dyed\+\_\+obc\+\_\+tracer\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Clean up memory allocations, if any. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacedyed__obc__tracer_a7c9e4c1789bdcebd4f0fa1380eb6df3e}\label{namespacedyed__obc__tracer_a7c9e4c1789bdcebd4f0fa1380eb6df3e}} 
\index{dyed\_obc\_tracer@{dyed\_obc\_tracer}!dyed\_obc\_tracer\_column\_physics@{dyed\_obc\_tracer\_column\_physics}}
\index{dyed\_obc\_tracer\_column\_physics@{dyed\_obc\_tracer\_column\_physics}!dyed\_obc\_tracer@{dyed\_obc\_tracer}}
\doxysubsubsection{\texorpdfstring{dyed\_obc\_tracer\_column\_physics()}{dyed\_obc\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public dyed\+\_\+obc\+\_\+tracer\+::dyed\+\_\+obc\+\_\+tracer\+\_\+column\+\_\+physics (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h\+\_\+old,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h\+\_\+new,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{ea,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{eb,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes,  }\item[{real, intent(in)}]{dt,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structdyed__obc__tracer_1_1dyed__obc__tracer__cs}{dyed\+\_\+obc\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{real, intent(in), optional}]{evap\+\_\+\+C\+F\+L\+\_\+limit,  }\item[{real, intent(in), optional}]{minimum\+\_\+forcing\+\_\+depth }\end{DoxyParamCaption})}



This subroutine applies diapycnal diffusion and any other column tracer physics or chemistry to the tracers from this file. This is a simple example of a set of advected passive tracers. 

The arguments to this subroutine are redundant in that h\+\_\+new(k) = h\+\_\+old(k) + ea(k) -\/ eb(k-\/1) + eb(k) -\/ ea(k+1) 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+old} & Layer thickness before entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+new} & Layer thickness after entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ea} & an array to which the amount of fluid entrained \\
\hline
\mbox{\texttt{ in}}  & {\em eb} & an array to which the amount of fluid entrained \\
\hline
\mbox{\texttt{ in}}  & {\em fluxes} & A structure containing pointers to thermodynamic and tracer forcing fields. Unused fields have N\+U\+LL ptrs. \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time covered by this call \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & The control structure returned by a previous call to dyed\+\_\+obc\+\_\+register\+\_\+tracer. \\
\hline
\mbox{\texttt{ in}}  & {\em evap\+\_\+cfl\+\_\+limit} & Limit on the fraction of the water that can be fluxed out of the top layer in a timestep \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em minimum\+\_\+forcing\+\_\+depth} & The smallest depth over which fluxes can be applied \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 203 of file dyed\+\_\+obc\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{205   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{206   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{207 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{208                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{209 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{210                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{211 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{212                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{213 \textcolor{comment}{                                              !! from the layer above during this call will be}}
\DoxyCodeLine{214 \textcolor{comment}{                                              !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{215 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{216                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{217 \textcolor{comment}{                                              !! from the layer below during this call will be}}
\DoxyCodeLine{218 \textcolor{comment}{                                              !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{219   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}}
\DoxyCodeLine{220 \textcolor{comment}{                                              !! and tracer forcing fields.  Unused fields have NULL ptrs.}}
\DoxyCodeLine{221 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T \string~> s]}}
\DoxyCodeLine{222   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{223   \textcolor{keywordtype}{type}(dyed\_obc\_tracer\_CS), \textcolor{keywordtype}{pointer}   :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{224 \textcolor{comment}{                                              !! call to dyed\_obc\_register\_tracer.}}
\DoxyCodeLine{225 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: evap\_CFL\_limit\textcolor{comment}{ !< Limit on the fraction of the water that can}}
\DoxyCodeLine{226 \textcolor{comment}{                                              !! be fluxed out of the top layer in a timestep [nondim]}}
\DoxyCodeLine{227 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which}}
\DoxyCodeLine{228 \textcolor{comment}{                                              !! fluxes can be applied [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{229 }
\DoxyCodeLine{230 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{231 \textcolor{keywordtype}{  real} :: b1(SZI\_(G))          \textcolor{comment}{! b1 and c1 are variables used by the}}
\DoxyCodeLine{232 \textcolor{keywordtype}{  real} :: c1(SZI\_(G),SZK\_(G))  \textcolor{comment}{! tridiagonal solver.}}
\DoxyCodeLine{233 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}}
\DoxyCodeLine{234   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{235   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{236 }
\DoxyCodeLine{237   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{238   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{239 }
\DoxyCodeLine{240   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{241     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{242       \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{243         h\_work(i,j,k) = h\_old(i,j,k)}
\DoxyCodeLine{244 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{245       \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs\%tr(:,:,:,m), dt, fluxes, h\_work, \&}
\DoxyCodeLine{246                                           evap\_cfl\_limit, minimum\_forcing\_depth)}
\DoxyCodeLine{247       \textcolor{keywordflow}{if} (nz > 1) \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{248 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{249   \textcolor{keywordflow}{else}}
\DoxyCodeLine{250     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{251       \textcolor{keywordflow}{if} (nz > 1) \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{252 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{253 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{254 }

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



Clean up memory allocations, if any. 


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


Definition at line 258 of file dyed\+\_\+obc\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{259   \textcolor{keywordtype}{type}(dyed\_obc\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{260 \textcolor{comment}{                                            !! call to dyed\_obc\_register\_tracer.}}
\DoxyCodeLine{261   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{262 }
\DoxyCodeLine{263   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{264     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%tr)) \textcolor{keyword}{deallocate}(cs\%tr)}
\DoxyCodeLine{265 }
\DoxyCodeLine{266     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{267 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacedyed__obc__tracer_ae6775bb4fc321a45c68880edc243fcfa}\label{namespacedyed__obc__tracer_ae6775bb4fc321a45c68880edc243fcfa}} 
\index{dyed\_obc\_tracer@{dyed\_obc\_tracer}!initialize\_dyed\_obc\_tracer@{initialize\_dyed\_obc\_tracer}}
\index{initialize\_dyed\_obc\_tracer@{initialize\_dyed\_obc\_tracer}!dyed\_obc\_tracer@{dyed\_obc\_tracer}}
\doxysubsubsection{\texorpdfstring{initialize\_dyed\_obc\_tracer()}{initialize\_dyed\_obc\_tracer()}}
{\footnotesize\ttfamily subroutine, public dyed\+\_\+obc\+\_\+tracer\+::initialize\+\_\+dyed\+\_\+obc\+\_\+tracer (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{restart,  }\item[{type(time\+\_\+type), intent(in), target}]{day,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structdyed__obc__tracer_1_1dyed__obc__tracer__cs}{dyed\+\_\+obc\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Initializes the CSntr tracer fields in tr(\+:,\+:,\+:,\+:) and sets up the tracer output. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em restart} & .true. if the fields have already been read from a restart file. \\
\hline
\mbox{\texttt{ in}}  & {\em day} & Time of the start of the run. \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & Structure used to regulate diagnostic output. \\
\hline
 & {\em obc} & Structure specifying open boundary options. \\
\hline
 & {\em cs} & The control structure returned by a previous call to dyed\+\_\+obc\+\_\+register\+\_\+tracer. \\
\hline
\end{DoxyParams}


Definition at line 135 of file dyed\+\_\+obc\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{136   \textcolor{keywordtype}{type}(ocean\_grid\_type),                 \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{137   \textcolor{keywordtype}{type}(verticalGrid\_type),               \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{138   \textcolor{keywordtype}{logical},                               \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}}
\DoxyCodeLine{139 \textcolor{comment}{                                                               !! been read from a restart file.}}
\DoxyCodeLine{140   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target},               \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{     !< Time of the start of the run.}}
\DoxyCodeLine{141 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{142   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},               \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{    !< Structure used to regulate diagnostic output.}}
\DoxyCodeLine{143   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                  \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{     !< Structure specifying open boundary options.}}
\DoxyCodeLine{144   \textcolor{keywordtype}{type}(dyed\_obc\_tracer\_CS),              \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{      !< The control structure returned by a previous}}
\DoxyCodeLine{145 \textcolor{comment}{                                                               !! call to dyed\_obc\_register\_tracer.}}
\DoxyCodeLine{146 }
\DoxyCodeLine{147 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{148 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable} :: temp(:,:,:)}
\DoxyCodeLine{149 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:)} :: \&}
\DoxyCodeLine{150     OBC\_tr1\_u => null(), \& \textcolor{comment}{! These arrays should be allocated and set to}}
\DoxyCodeLine{151     obc\_tr1\_v => null()    \textcolor{comment}{! specify the values of tracer 1 that should come}}
\DoxyCodeLine{152                            \textcolor{comment}{! in through u-\/ and v-\/ points through the open}}
\DoxyCodeLine{153                            \textcolor{comment}{! boundary conditions, in the same units as tr.}}
\DoxyCodeLine{154   \textcolor{keywordtype}{character(len=24)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}}
\DoxyCodeLine{155   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}}
\DoxyCodeLine{156   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}}
\DoxyCodeLine{157   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}}
\DoxyCodeLine{158                             \textcolor{comment}{! kg(tracer) kg(water)-\/1 m3 s-\/1 or kg(tracer) s-\/1.}}
\DoxyCodeLine{159 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{160 \textcolor{keywordtype}{  real} :: h\_neglect         \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{161                             \textcolor{comment}{! in roundoff and can be neglected [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{162 \textcolor{keywordtype}{  real} :: e(SZK\_(G)+1), e\_top, e\_bot, d\_tr}
\DoxyCodeLine{163   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{164   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{165 }
\DoxyCodeLine{166   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{167   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{168   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{169   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{170   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{171   h\_neglect = gv\%H\_subroundoff}
\DoxyCodeLine{172 }
\DoxyCodeLine{173   cs\%Time => day}
\DoxyCodeLine{174   cs\%diag => diag}
\DoxyCodeLine{175 }
\DoxyCodeLine{176   \textcolor{keywordflow}{if} (.not.restart) \textcolor{keywordflow}{then}}
\DoxyCodeLine{177     \textcolor{keywordflow}{if} (len\_trim(cs\%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{178       \textcolor{comment}{!  Read the tracer concentrations from a netcdf file.}}
\DoxyCodeLine{179       \textcolor{keywordflow}{if} (.not.file\_exists(cs\%tracer\_IC\_file, g\%Domain)) \&}
\DoxyCodeLine{180         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}dyed\_obc\_initialize\_tracer: Unable to open "{}}// \&}
\DoxyCodeLine{181                         cs\%tracer\_IC\_file)}
\DoxyCodeLine{182       \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{183         \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name, caller=\textcolor{stringliteral}{"{}initialize\_dyed\_obc\_tracer"{}})}
\DoxyCodeLine{184         \textcolor{keyword}{call }mom\_read\_data(cs\%tracer\_IC\_file, trim(name), cs\%tr(:,:,:,m), g\%Domain)}
\DoxyCodeLine{185 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{186     \textcolor{keywordflow}{else}}
\DoxyCodeLine{187       \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{188         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{189           cs\%tr(i,j,k,m) = 0.0}
\DoxyCodeLine{190 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{191 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{192 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{193 \textcolor{keywordflow}{  endif} \textcolor{comment}{! restart}}
\DoxyCodeLine{194 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacedyed__obc__tracer_a968aec7f642a4750d835b0d030c17fe5}\label{namespacedyed__obc__tracer_a968aec7f642a4750d835b0d030c17fe5}} 
\index{dyed\_obc\_tracer@{dyed\_obc\_tracer}!register\_dyed\_obc\_tracer@{register\_dyed\_obc\_tracer}}
\index{register\_dyed\_obc\_tracer@{register\_dyed\_obc\_tracer}!dyed\_obc\_tracer@{dyed\_obc\_tracer}}
\doxysubsubsection{\texorpdfstring{register\_dyed\_obc\_tracer()}{register\_dyed\_obc\_tracer()}}
{\footnotesize\ttfamily logical function, public dyed\+\_\+obc\+\_\+tracer\+::register\+\_\+dyed\+\_\+obc\+\_\+tracer (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(in)}]{HI,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structdyed__obc__tracer_1_1dyed__obc__tracer__cs}{dyed\+\_\+obc\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}}), pointer}]{tr\+\_\+\+Reg,  }\item[{type(\mbox{\hyperlink{structmom__restart_1_1mom__restart__cs}{mom\+\_\+restart\+\_\+cs}}), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



Register tracer fields and subroutines to be used with M\+OM. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em hi} & A horizontal index type structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module \\
\hline
 & {\em tr\+\_\+reg} & A pointer to the tracer registry. \\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure. \\
\hline
\end{DoxyParams}


Definition at line 54 of file dyed\+\_\+obc\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{55   \textcolor{keywordtype}{type}(hor\_index\_type),       \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type structure.}}
\DoxyCodeLine{56   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{57   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{58   \textcolor{keywordtype}{type}(dyed\_obc\_tracer\_CS),   \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< A pointer that is set to point to the}}
\DoxyCodeLine{59 \textcolor{comment}{                                                 !! control structure for this module}}
\DoxyCodeLine{60   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer to the tracer registry.}}
\DoxyCodeLine{61   \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure.}}
\DoxyCodeLine{62 }
\DoxyCodeLine{63 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{64   \textcolor{keywordtype}{character(len=80)}  :: name, longname}
\DoxyCodeLine{65 \textcolor{comment}{! This include declares and sets the variable "{}version"{}.}}
\DoxyCodeLine{66 \textcolor{preprocessor}{\#include "{}version\_variable.h"{}}}
\DoxyCodeLine{67 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}dyed\_obc\_tracer"{}} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{68   \textcolor{keywordtype}{character(len=200)} :: inputdir}
\DoxyCodeLine{69   \textcolor{keywordtype}{character(len=48)}  :: flux\_units \textcolor{comment}{! The units for tracer fluxes, usually}}
\DoxyCodeLine{70                             \textcolor{comment}{! kg(tracer) kg(water)-\/1 m3 s-\/1 or kg(tracer) s-\/1.}}
\DoxyCodeLine{71 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{72   \textcolor{keywordtype}{logical} :: register\_dyed\_obc\_tracer}
\DoxyCodeLine{73   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{74   isd = hi\%isd ; ied = hi\%ied ; jsd = hi\%jsd ; jed = hi\%jed ; nz = gv\%ke}
\DoxyCodeLine{75 }
\DoxyCodeLine{76   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{77     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"{}dyed\_obc\_register\_tracer called with an "{}}// \&}
\DoxyCodeLine{78                             \textcolor{stringliteral}{"{}associated control structure."{}})}
\DoxyCodeLine{79     \textcolor{keywordflow}{return}}
\DoxyCodeLine{80 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{81   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{82 }
\DoxyCodeLine{83   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{84   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{85   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}NUM\_DYE\_TRACERS"{}}, cs\%ntr, \&}
\DoxyCodeLine{86                  \textcolor{stringliteral}{"{}The number of dye tracers in this run. Each tracer "{}}//\&}
\DoxyCodeLine{87                  \textcolor{stringliteral}{"{}should have a separate boundary segment."{}}, default=0)}
\DoxyCodeLine{88   \textcolor{keyword}{allocate}(cs\%ind\_tr(cs\%ntr))}
\DoxyCodeLine{89   \textcolor{keyword}{allocate}(cs\%tr\_desc(cs\%ntr))}
\DoxyCodeLine{90 }
\DoxyCodeLine{91   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}dyed\_obc\_TRACER\_IC\_FILE"{}}, cs\%tracer\_IC\_file, \&}
\DoxyCodeLine{92                  \textcolor{stringliteral}{"{}The name of a file from which to read the initial "{}}//\&}
\DoxyCodeLine{93                  \textcolor{stringliteral}{"{}conditions for the dyed\_obc tracers, or blank to initialize "{}}//\&}
\DoxyCodeLine{94                  \textcolor{stringliteral}{"{}them internally."{}}, default=\textcolor{stringliteral}{"{} "{}})}
\DoxyCodeLine{95   \textcolor{keywordflow}{if} (len\_trim(cs\%tracer\_IC\_file) >= 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{96     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}INPUTDIR"{}}, inputdir, default=\textcolor{stringliteral}{"{}."{}})}
\DoxyCodeLine{97     inputdir = slasher(inputdir)}
\DoxyCodeLine{98     cs\%tracer\_IC\_file = trim(inputdir)//trim(cs\%tracer\_IC\_file)}
\DoxyCodeLine{99     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"{}INPUTDIR/dyed\_obc\_TRACER\_IC\_FILE"{}}, \&}
\DoxyCodeLine{100                    cs\%tracer\_IC\_file)}
\DoxyCodeLine{101 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{102 }
\DoxyCodeLine{103   \textcolor{keyword}{allocate}(cs\%tr(isd:ied,jsd:jed,nz,cs\%ntr)) ; cs\%tr(:,:,:,:) = 0.0}
\DoxyCodeLine{104 }
\DoxyCodeLine{105   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{106     \textcolor{keyword}{write}(name,\textcolor{stringliteral}{'("{}dye\_"{},I2.2)'}) m}
\DoxyCodeLine{107     \textcolor{keyword}{write}(longname,\textcolor{stringliteral}{'("{}Concentration of dyed\_obc Tracer "{},I2.2)'}) m}
\DoxyCodeLine{108     cs\%tr\_desc(m) = var\_desc(name, units=\textcolor{stringliteral}{"{}kg kg-\/1"{}}, longname=longname, caller=mdl)}
\DoxyCodeLine{109     \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then} ; flux\_units = \textcolor{stringliteral}{"{}kg kg-\/1 m3 s-\/1"{}}}
\DoxyCodeLine{110     \textcolor{keywordflow}{else} ; flux\_units = \textcolor{stringliteral}{"{}kg s-\/1"{}} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{111 }
\DoxyCodeLine{112     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration}}
\DoxyCodeLine{113     \textcolor{comment}{! calls.  Curses on the designers and implementers of Fortran90.}}
\DoxyCodeLine{114     tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{115     \textcolor{comment}{! Register the tracer for horizontal advection, diffusion, and restarts.}}
\DoxyCodeLine{116     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, \&}
\DoxyCodeLine{117                          name=name, longname=longname, units=\textcolor{stringliteral}{"{}kg kg-\/1"{}}, \&}
\DoxyCodeLine{118                          registry\_diags=.true., flux\_units=flux\_units, \&}
\DoxyCodeLine{119                          restart\_cs=restart\_cs)}
\DoxyCodeLine{120 }
\DoxyCodeLine{121     \textcolor{comment}{!   Set coupled\_tracers to be true (hard-\/coded above) to provide the surface}}
\DoxyCodeLine{122     \textcolor{comment}{! values to the coupler (if any).  This is meta-\/code and its arguments will}}
\DoxyCodeLine{123     \textcolor{comment}{! currently (deliberately) give fatal errors if it is used.}}
\DoxyCodeLine{124     \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \&}
\DoxyCodeLine{125       cs\%ind\_tr(m) = aof\_set\_coupler\_flux(trim(name)//\textcolor{stringliteral}{'\_flux'}, \&}
\DoxyCodeLine{126           flux\_type=\textcolor{stringliteral}{' '}, implementation=\textcolor{stringliteral}{' '}, caller=\textcolor{stringliteral}{"{}register\_dyed\_obc\_tracer"{}})}
\DoxyCodeLine{127 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{128 }
\DoxyCodeLine{129   cs\%tr\_Reg => tr\_reg}
\DoxyCodeLine{130   cs\%restart\_CSp => restart\_cs}
\DoxyCodeLine{131   register\_dyed\_obc\_tracer = .true.}

\end{DoxyCode}
