\hypertarget{namespaceregional__dyes}{}\doxysection{regional\+\_\+dyes Module Reference}
\label{namespaceregional__dyes}\index{regional\_dyes@{regional\_dyes}}


\doxysubsection{Detailed Description}
A tracer package for using dyes to diagnose regional flows. 

This file contains an example of the code that is needed to set up and use a set (in this case two) of dynamically passive tracers for diagnostic purposes. The tracers here are dye tracers which are set to 1 within the geographical region specified. The depth which a tracer is set is determined by calculating the depth from the seafloor upwards through the column. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structregional__dyes_1_1dye__tracer__cs}{dye\+\_\+tracer\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em The control structure for the regional dyes tracer package. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespaceregional__dyes_a50f9b2b06f258fc67ffabed45901bf76}{register\+\_\+dye\+\_\+tracer}} (HI, GV, US, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em This subroutine is used to register tracer fields and subroutines to be used with M\+OM. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregional__dyes_a4200969a80e51071559453d2ce03bebe}{initialize\+\_\+dye\+\_\+tracer}} (restart, day, G, GV, h, diag, O\+BC, CS, sponge\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em This subroutine initializes the CSntr tracer fields in tr(\+:,\+:,\+:,\+:) and it sets up the tracer output. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregional__dyes_ae9a84fcf1505f825e711c1fc9bc86c70}{dye\+\_\+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. 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) \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespaceregional__dyes_a0641ff9c663bcfacdd597a79f63d15e0}{dye\+\_\+stock}} (h, stocks, G, GV, CS, names, units, stock\+\_\+index)
\begin{DoxyCompactList}\small\item\em This function calculates the mass-\/weighted integral of all tracer stocks, returning the number of stocks it has calculated. If the stock\+\_\+index is present, only the stock corresponding to that coded index is returned. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregional__dyes_a45055502f5a7a266f72e274dcc2bec49}{dye\+\_\+tracer\+\_\+surface\+\_\+state}} (sfc\+\_\+state, h, G, CS)
\begin{DoxyCompactList}\small\item\em This subroutine extracts the surface fields from this tracer package that are to be shared with the atmosphere in coupled configurations. This particular tracer package does not report anything back to the coupler. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregional__dyes_a6cd17eb6c648ec6c2a7a43de383846be}{regional\+\_\+dyes\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Clean up any allocated memory after the run. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceregional__dyes_a0641ff9c663bcfacdd597a79f63d15e0}\label{namespaceregional__dyes_a0641ff9c663bcfacdd597a79f63d15e0}} 
\index{regional\_dyes@{regional\_dyes}!dye\_stock@{dye\_stock}}
\index{dye\_stock@{dye\_stock}!regional\_dyes@{regional\_dyes}}
\doxysubsubsection{\texorpdfstring{dye\_stock()}{dye\_stock()}}
{\footnotesize\ttfamily integer function, public regional\+\_\+dyes\+::dye\+\_\+stock (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h,  }\item[{real, dimension(\+:), intent(out)}]{stocks,  }\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{structregional__dyes_1_1dye__tracer__cs}{dye\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{character(len=$\ast$), dimension(\+:), intent(out)}]{names,  }\item[{character(len=$\ast$), dimension(\+:), intent(out)}]{units,  }\item[{integer, intent(in), optional}]{stock\+\_\+index }\end{DoxyParamCaption})}



This function calculates the mass-\/weighted integral of all tracer stocks, returning the number of stocks it has calculated. If the stock\+\_\+index is present, only the stock corresponding to that coded index is returned. 


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


Definition at line 328 of file dye\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{329   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{330   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{331 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{  !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{332 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},                 \textcolor{keywordtype}{intent(out)}   :: stocks\textcolor{comment}{ !< the mass-\/weighted integrated amount of}}
\DoxyCodeLine{333 \textcolor{comment}{                                                            !! each tracer, in kg times concentration units [kg conc].}}
\DoxyCodeLine{334   \textcolor{keywordtype}{type}(dye\_tracer\_CS),                \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< The control structure returned by a}}
\DoxyCodeLine{335 \textcolor{comment}{                                                            !! previous call to register\_dye\_tracer.}}
\DoxyCodeLine{336   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{ !< the names of the stocks calculated.}}
\DoxyCodeLine{337   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{ !< the units of the stocks calculated.}}
\DoxyCodeLine{338   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                  \textcolor{keywordtype}{intent(in)}    :: stock\_index\textcolor{comment}{ !< the coded index of a specific stock}}
\DoxyCodeLine{339 \textcolor{comment}{                                                                   !! being sought.}}
\DoxyCodeLine{340   \textcolor{keywordtype}{integer}                                           :: dye\_stock\textcolor{comment}{   !< Return value: the number of stocks}}
\DoxyCodeLine{341 \textcolor{comment}{                                                                   !! calculated here.}}
\DoxyCodeLine{342 }
\DoxyCodeLine{343 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{344   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{345   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{346 }
\DoxyCodeLine{347   dye\_stock = 0}
\DoxyCodeLine{348   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{349   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{350 }
\DoxyCodeLine{351   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{352     \textcolor{comment}{! Check whether this stock is available from this routine.}}
\DoxyCodeLine{353 }
\DoxyCodeLine{354     \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}}
\DoxyCodeLine{355     \textcolor{keywordflow}{return}}
\DoxyCodeLine{356 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{357 }
\DoxyCodeLine{358   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{359     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=names(m), units=units(m), caller=\textcolor{stringliteral}{"{}dye\_stock"{}})}
\DoxyCodeLine{360     units(m) = trim(units(m))//\textcolor{stringliteral}{"{} kg"{}}}
\DoxyCodeLine{361     stocks(m) = 0.0}
\DoxyCodeLine{362     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{363       stocks(m) = stocks(m) + cs\%tr(i,j,k,m) * \&}
\DoxyCodeLine{364                              (g\%mask2dT(i,j) * g\%US\%L\_to\_m**2*g\%areaT(i,j) * h(i,j,k))}
\DoxyCodeLine{365 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{366     stocks(m) = gv\%H\_to\_kg\_m2 * stocks(m)}
\DoxyCodeLine{367 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{368   dye\_stock = cs\%ntr}
\DoxyCodeLine{369 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregional__dyes_ae9a84fcf1505f825e711c1fc9bc86c70}\label{namespaceregional__dyes_ae9a84fcf1505f825e711c1fc9bc86c70}} 
\index{regional\_dyes@{regional\_dyes}!dye\_tracer\_column\_physics@{dye\_tracer\_column\_physics}}
\index{dye\_tracer\_column\_physics@{dye\_tracer\_column\_physics}!regional\_dyes@{regional\_dyes}}
\doxysubsubsection{\texorpdfstring{dye\_tracer\_column\_physics()}{dye\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public regional\+\_\+dyes\+::dye\+\_\+tracer\+\_\+column\+\_\+physics (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h\+\_\+old,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h\+\_\+new,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{ea,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{eb,  }\item[{type(\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{structregional__dyes_1_1dye__tracer__cs}{dye\+\_\+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 register\+\_\+dye\+\_\+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 246 of file dye\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{248   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{249   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{250 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{251                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{252 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{253                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{254 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{255                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{256 \textcolor{comment}{                                              !! from the layer above during this call will be}}
\DoxyCodeLine{257 \textcolor{comment}{                                              !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{258 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{259                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{260 \textcolor{comment}{                                              !! from the layer below during this call will be}}
\DoxyCodeLine{261 \textcolor{comment}{                                              !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{262   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}}
\DoxyCodeLine{263 \textcolor{comment}{                                              !! and tracer forcing fields.  Unused fields have NULL ptrs.}}
\DoxyCodeLine{264 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T \string~> s]}}
\DoxyCodeLine{265   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{266   \textcolor{keywordtype}{type}(dye\_tracer\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{267 \textcolor{comment}{                                              !! call to register\_dye\_tracer.}}
\DoxyCodeLine{268 \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{269 \textcolor{comment}{                                              !! be fluxed out of the top layer in a timestep [nondim]}}
\DoxyCodeLine{270 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which}}
\DoxyCodeLine{271 \textcolor{comment}{                                              !! fluxes can be applied [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{272 }
\DoxyCodeLine{273 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{274 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}}
\DoxyCodeLine{275 \textcolor{keywordtype}{  real} :: sfc\_val  \textcolor{comment}{! The surface value for the tracers.}}
\DoxyCodeLine{276 \textcolor{keywordtype}{  real} :: Isecs\_per\_year  \textcolor{comment}{! The number of seconds in a year.}}
\DoxyCodeLine{277 \textcolor{keywordtype}{  real} :: year            \textcolor{comment}{! The time in years.}}
\DoxyCodeLine{278   \textcolor{keywordtype}{integer} :: secs, days   \textcolor{comment}{! Integer components of the time type.}}
\DoxyCodeLine{279   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{280 \textcolor{keywordtype}{  real}    :: z\_bot, z\_center}
\DoxyCodeLine{281 }
\DoxyCodeLine{282   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{283 }
\DoxyCodeLine{284   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{285   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{286 }
\DoxyCodeLine{287   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{288     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{289       \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{290         h\_work(i,j,k) = h\_old(i,j,k)}
\DoxyCodeLine{291 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{292       \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs\%tr(:,:,:,m), dt, fluxes, h\_work, \&}
\DoxyCodeLine{293                                           evap\_cfl\_limit, minimum\_forcing\_depth)}
\DoxyCodeLine{294       \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{295 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{296   \textcolor{keywordflow}{else}}
\DoxyCodeLine{297     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{298       \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{299 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{300 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{301 }
\DoxyCodeLine{302   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{303     \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{304       \textcolor{comment}{! A dye is set dependent on the center of the cell being inside the rectangular box.}}
\DoxyCodeLine{305       \textcolor{keywordflow}{if} (cs\%dye\_source\_minlon(m)<g\%geoLonT(i,j) .and. \&}
\DoxyCodeLine{306           cs\%dye\_source\_maxlon(m)>=g\%geoLonT(i,j) .and. \&}
\DoxyCodeLine{307           cs\%dye\_source\_minlat(m)<g\%geoLatT(i,j) .and. \&}
\DoxyCodeLine{308           cs\%dye\_source\_maxlat(m)>=g\%geoLatT(i,j) .and. \&}
\DoxyCodeLine{309           g\%mask2dT(i,j) > 0.0 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{310         z\_bot = -\/g\%bathyT(i,j)}
\DoxyCodeLine{311         \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{312           z\_center = z\_bot + 0.5*h\_new(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{313           \textcolor{keywordflow}{if} ( z\_center > -\/cs\%dye\_source\_maxdepth(m) .and. \&}
\DoxyCodeLine{314                z\_center < -\/cs\%dye\_source\_mindepth(m) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{315             cs\%tr(i,j,k,m) = 1.0}
\DoxyCodeLine{316 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{317           z\_bot = z\_bot + h\_new(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{318 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{319 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{320 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{321 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{322 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregional__dyes_a45055502f5a7a266f72e274dcc2bec49}\label{namespaceregional__dyes_a45055502f5a7a266f72e274dcc2bec49}} 
\index{regional\_dyes@{regional\_dyes}!dye\_tracer\_surface\_state@{dye\_tracer\_surface\_state}}
\index{dye\_tracer\_surface\_state@{dye\_tracer\_surface\_state}!regional\_dyes@{regional\_dyes}}
\doxysubsubsection{\texorpdfstring{dye\_tracer\_surface\_state()}{dye\_tracer\_surface\_state()}}
{\footnotesize\ttfamily subroutine, public regional\+\_\+dyes\+::dye\+\_\+tracer\+\_\+surface\+\_\+state (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__variables_1_1surface}{surface}}), intent(inout)}]{sfc\+\_\+state,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structregional__dyes_1_1dye__tracer__cs}{dye\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine extracts the surface fields from this tracer package that are to be shared with the atmosphere in coupled configurations. This particular tracer package does not report anything back to the coupler. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+dye\+\_\+tracer. \\
\hline
\end{DoxyParams}


Definition at line 375 of file dye\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{376   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The ocean's grid structure.}}
\DoxyCodeLine{377   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{378 \textcolor{comment}{                                              !! describe the surface state of the ocean.}}
\DoxyCodeLine{379 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{380                           \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thickness [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{381   \textcolor{keywordtype}{type}(dye\_tracer\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{382 \textcolor{comment}{                                              !! call to register\_dye\_tracer.}}
\DoxyCodeLine{383 }
\DoxyCodeLine{384   \textcolor{comment}{! This particular tracer package does not report anything back to the coupler.}}
\DoxyCodeLine{385   \textcolor{comment}{! The code that is here is just a rough guide for packages that would.}}
\DoxyCodeLine{386 }
\DoxyCodeLine{387   \textcolor{keywordtype}{integer} :: m, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{388   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{389   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{390 }
\DoxyCodeLine{391   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{392 }
\DoxyCodeLine{393   \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{394     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{395       \textcolor{comment}{!   This call loads the surface values into the appropriate array in the}}
\DoxyCodeLine{396       \textcolor{comment}{! coupler-\/type structure.}}
\DoxyCodeLine{397       \textcolor{keyword}{call }coupler\_type\_set\_data(cs\%tr(:,:,1,m), cs\%ind\_tr(m), ind\_csurf, \&}
\DoxyCodeLine{398                    sfc\_state\%tr\_fields, idim=(/isd, is, ie, ied/), \&}
\DoxyCodeLine{399                    jdim=(/jsd, js, je, jed/) )}
\DoxyCodeLine{400 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{401 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{402 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregional__dyes_a4200969a80e51071559453d2ce03bebe}\label{namespaceregional__dyes_a4200969a80e51071559453d2ce03bebe}} 
\index{regional\_dyes@{regional\_dyes}!initialize\_dye\_tracer@{initialize\_dye\_tracer}}
\index{initialize\_dye\_tracer@{initialize\_dye\_tracer}!regional\_dyes@{regional\_dyes}}
\doxysubsubsection{\texorpdfstring{initialize\_dye\_tracer()}{initialize\_dye\_tracer()}}
{\footnotesize\ttfamily subroutine, public regional\+\_\+dyes\+::initialize\+\_\+dye\+\_\+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( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), 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{structregional__dyes_1_1dye__tracer__cs}{dye\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{sponge\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em restart} & .true. if the fields have already been read from a restart file. \\
\hline
\mbox{\texttt{ in}}  & {\em day} & Time of the start of the run. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & Structure used to regulate diagnostic output. \\
\hline
 & {\em obc} & This open boundary condition type specifies whether, where, and what open boundary conditions are used. \\
\hline
 & {\em cs} & The control structure returned by a previous call to register\+\_\+dye\+\_\+tracer. \\
\hline
 & {\em sponge\+\_\+csp} & A pointer to the control structure for the sponges, if they are in use. \\
\hline
\end{DoxyParams}


Definition at line 186 of file dye\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{187   \textcolor{keywordtype}{logical},                            \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already been}}
\DoxyCodeLine{188 \textcolor{comment}{                                                            !! read from a restart file.}}
\DoxyCodeLine{189   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target},            \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{  !< Time of the start of the run.}}
\DoxyCodeLine{190   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{191   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{192 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{193   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},            \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< Structure used to regulate diagnostic output.}}
\DoxyCodeLine{194   \textcolor{keywordtype}{type}(ocean\_OBC\_type),               \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{  !< This open boundary condition type specifies}}
\DoxyCodeLine{195 \textcolor{comment}{                                                         !! whether, where, and what open boundary}}
\DoxyCodeLine{196 \textcolor{comment}{                                                         !! conditions are used.}}
\DoxyCodeLine{197   \textcolor{keywordtype}{type}(dye\_tracer\_CS),                \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{198 \textcolor{comment}{                                                         !! call to register\_dye\_tracer.}}
\DoxyCodeLine{199   \textcolor{keywordtype}{type}(sponge\_CS),                    \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{    !< A pointer to the control structure}}
\DoxyCodeLine{200 \textcolor{comment}{                                                                  !! for the sponges, if they are in use.}}
\DoxyCodeLine{201 }
\DoxyCodeLine{202 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{203   \textcolor{keywordtype}{character(len=24)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}}
\DoxyCodeLine{204   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}}
\DoxyCodeLine{205   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}}
\DoxyCodeLine{206   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for age tracer fluxes, either}}
\DoxyCodeLine{207                                 \textcolor{comment}{! years m3 s-\/1 or years kg s-\/1.}}
\DoxyCodeLine{208   \textcolor{keywordtype}{logical} :: OK}
\DoxyCodeLine{209   \textcolor{keywordtype}{integer} :: i, j, k, m}
\DoxyCodeLine{210 \textcolor{keywordtype}{  real}    :: z\_bot, z\_center}
\DoxyCodeLine{211 }
\DoxyCodeLine{212   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{213   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{214 }
\DoxyCodeLine{215   cs\%diag => diag}
\DoxyCodeLine{216 }
\DoxyCodeLine{217   \textcolor{comment}{! Establish location of source}}
\DoxyCodeLine{218   \textcolor{keywordflow}{do} m= 1, cs\%ntr}
\DoxyCodeLine{219     \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{220       \textcolor{comment}{! A dye is set dependent on the center of the cell being inside the rectangular box.}}
\DoxyCodeLine{221       \textcolor{keywordflow}{if} (cs\%dye\_source\_minlon(m)<g\%geoLonT(i,j) .and. \&}
\DoxyCodeLine{222           cs\%dye\_source\_maxlon(m)>=g\%geoLonT(i,j) .and. \&}
\DoxyCodeLine{223           cs\%dye\_source\_minlat(m)<g\%geoLatT(i,j) .and. \&}
\DoxyCodeLine{224           cs\%dye\_source\_maxlat(m)>=g\%geoLatT(i,j) .and. \&}
\DoxyCodeLine{225           g\%mask2dT(i,j) > 0.0 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{226         z\_bot = -\/g\%bathyT(i,j)}
\DoxyCodeLine{227         \textcolor{keywordflow}{do} k = gv\%ke, 1, -\/1}
\DoxyCodeLine{228           z\_center = z\_bot + 0.5*h(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{229           \textcolor{keywordflow}{if} ( z\_center > -\/cs\%dye\_source\_maxdepth(m) .and. \&}
\DoxyCodeLine{230                z\_center < -\/cs\%dye\_source\_mindepth(m) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{231             cs\%tr(i,j,k,m) = 1.0}
\DoxyCodeLine{232 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{233           z\_bot = z\_bot + h(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{234 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{235 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{236 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{237 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{238 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregional__dyes_a6cd17eb6c648ec6c2a7a43de383846be}\label{namespaceregional__dyes_a6cd17eb6c648ec6c2a7a43de383846be}} 
\index{regional\_dyes@{regional\_dyes}!regional\_dyes\_end@{regional\_dyes\_end}}
\index{regional\_dyes\_end@{regional\_dyes\_end}!regional\_dyes@{regional\_dyes}}
\doxysubsubsection{\texorpdfstring{regional\_dyes\_end()}{regional\_dyes\_end()}}
{\footnotesize\ttfamily subroutine, public regional\+\_\+dyes\+::regional\+\_\+dyes\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structregional__dyes_1_1dye__tracer__cs}{dye\+\_\+tracer\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up any allocated memory after the run. 


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


Definition at line 406 of file dye\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{407   \textcolor{keywordtype}{type}(dye\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{408 \textcolor{comment}{                                     !! call to register\_dye\_tracer.}}
\DoxyCodeLine{409   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{410 }
\DoxyCodeLine{411   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{412     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%tr)) \textcolor{keyword}{deallocate}(cs\%tr)}
\DoxyCodeLine{413     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{414 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregional__dyes_a50f9b2b06f258fc67ffabed45901bf76}\label{namespaceregional__dyes_a50f9b2b06f258fc67ffabed45901bf76}} 
\index{regional\_dyes@{regional\_dyes}!register\_dye\_tracer@{register\_dye\_tracer}}
\index{register\_dye\_tracer@{register\_dye\_tracer}!regional\_dyes@{regional\_dyes}}
\doxysubsubsection{\texorpdfstring{register\_dye\_tracer()}{register\_dye\_tracer()}}
{\footnotesize\ttfamily logical function, public regional\+\_\+dyes\+::register\+\_\+dye\+\_\+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__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structregional__dyes_1_1dye__tracer__cs}{dye\+\_\+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})}



This subroutine is used to 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 us} & A dimensional unit scaling type \\
\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 that is set to point to the control structure for the tracer advection and diffusion module. \\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure. \\
\hline
\end{DoxyParams}


Definition at line 68 of file dye\+\_\+example.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{69   \textcolor{keywordtype}{type}(hor\_index\_type),       \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type structure.}}
\DoxyCodeLine{70   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{71   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{72   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{73   \textcolor{keywordtype}{type}(dye\_tracer\_CS),        \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< A pointer that is set to point to the control}}
\DoxyCodeLine{74 \textcolor{comment}{                                                 !! structure for this module}}
\DoxyCodeLine{75   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{76 \textcolor{comment}{                                                 !! structure for the tracer advection and diffusion module.}}
\DoxyCodeLine{77   \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure.}}
\DoxyCodeLine{78 }
\DoxyCodeLine{79 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{80 \textcolor{comment}{! This include declares and sets the variable "{}version"{}.}}
\DoxyCodeLine{81 \textcolor{preprocessor}{\#include "{}version\_variable.h"{}}}
\DoxyCodeLine{82 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}regional\_dyes"{}} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{83   \textcolor{keywordtype}{character(len=200)} :: inputdir \textcolor{comment}{! The directory where the input files are.}}
\DoxyCodeLine{84   \textcolor{keywordtype}{character(len=48)}  :: var\_name \textcolor{comment}{! The variable's name.}}
\DoxyCodeLine{85   \textcolor{keywordtype}{character(len=48)}  :: desc\_name \textcolor{comment}{! The variable's descriptor.}}
\DoxyCodeLine{86 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{87   \textcolor{keywordtype}{logical} :: register\_dye\_tracer}
\DoxyCodeLine{88   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{89   isd = hi\%isd ; ied = hi\%ied ; jsd = hi\%jsd ; jed = hi\%jed ; nz = gv\%ke}
\DoxyCodeLine{90 }
\DoxyCodeLine{91   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{92     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"{}register\_dye\_tracer called with an "{}}// \&}
\DoxyCodeLine{93                              \textcolor{stringliteral}{"{}associated control structure."{}})}
\DoxyCodeLine{94     \textcolor{keywordflow}{return}}
\DoxyCodeLine{95 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{96   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{97 }
\DoxyCodeLine{98   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{99   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{100   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}NUM\_DYE\_TRACERS"{}}, cs\%ntr, \&}
\DoxyCodeLine{101                  \textcolor{stringliteral}{"{}The number of dye tracers in this run. Each tracer "{}}//\&}
\DoxyCodeLine{102                  \textcolor{stringliteral}{"{}should have a separate region."{}}, default=0)}
\DoxyCodeLine{103   \textcolor{keyword}{allocate}(cs\%dye\_source\_minlon(cs\%ntr), \&}
\DoxyCodeLine{104            cs\%dye\_source\_maxlon(cs\%ntr), \&}
\DoxyCodeLine{105            cs\%dye\_source\_minlat(cs\%ntr), \&}
\DoxyCodeLine{106            cs\%dye\_source\_maxlat(cs\%ntr), \&}
\DoxyCodeLine{107            cs\%dye\_source\_mindepth(cs\%ntr), \&}
\DoxyCodeLine{108            cs\%dye\_source\_maxdepth(cs\%ntr))}
\DoxyCodeLine{109   \textcolor{keyword}{allocate}(cs\%ind\_tr(cs\%ntr))}
\DoxyCodeLine{110   \textcolor{keyword}{allocate}(cs\%tr\_desc(cs\%ntr))}
\DoxyCodeLine{111 }
\DoxyCodeLine{112   cs\%dye\_source\_minlon(:) = -\/1.e30}
\DoxyCodeLine{113   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DYE\_SOURCE\_MINLON"{}}, cs\%dye\_source\_minlon, \&}
\DoxyCodeLine{114                  \textcolor{stringliteral}{"{}This is the starting longitude at which we start injecting dyes."{}}, \&}
\DoxyCodeLine{115                  fail\_if\_missing=.true.)}
\DoxyCodeLine{116   \textcolor{keywordflow}{if} (minval(cs\%dye\_source\_minlon(:)) < -\/1.e29) \&}
\DoxyCodeLine{117     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}register\_dye\_tracer: Not enough values provided for DYE\_SOURCE\_MINLON "{}})}
\DoxyCodeLine{118 }
\DoxyCodeLine{119   cs\%dye\_source\_maxlon(:) = -\/1.e30}
\DoxyCodeLine{120   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DYE\_SOURCE\_MAXLON"{}}, cs\%dye\_source\_maxlon, \&}
\DoxyCodeLine{121                  \textcolor{stringliteral}{"{}This is the ending longitude at which we finish injecting dyes."{}}, \&}
\DoxyCodeLine{122                  fail\_if\_missing=.true.)}
\DoxyCodeLine{123   \textcolor{keywordflow}{if} (minval(cs\%dye\_source\_maxlon(:)) < -\/1.e29) \&}
\DoxyCodeLine{124     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}register\_dye\_tracer: Not enough values provided for DYE\_SOURCE\_MAXLON "{}})}
\DoxyCodeLine{125 }
\DoxyCodeLine{126   cs\%dye\_source\_minlat(:) = -\/1.e30}
\DoxyCodeLine{127   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DYE\_SOURCE\_MINLAT"{}}, cs\%dye\_source\_minlat, \&}
\DoxyCodeLine{128                  \textcolor{stringliteral}{"{}This is the starting latitude at which we start injecting dyes."{}}, \&}
\DoxyCodeLine{129                  fail\_if\_missing=.true.)}
\DoxyCodeLine{130   \textcolor{keywordflow}{if} (minval(cs\%dye\_source\_minlat(:)) < -\/1.e29) \&}
\DoxyCodeLine{131     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}register\_dye\_tracer: Not enough values provided for DYE\_SOURCE\_MINLAT "{}})}
\DoxyCodeLine{132 }
\DoxyCodeLine{133   cs\%dye\_source\_maxlat(:) = -\/1.e30}
\DoxyCodeLine{134   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DYE\_SOURCE\_MAXLAT"{}}, cs\%dye\_source\_maxlat, \&}
\DoxyCodeLine{135                  \textcolor{stringliteral}{"{}This is the ending latitude at which we finish injecting dyes."{}}, \&}
\DoxyCodeLine{136                  fail\_if\_missing=.true.)}
\DoxyCodeLine{137   \textcolor{keywordflow}{if} (minval(cs\%dye\_source\_maxlat(:)) < -\/1.e29) \&}
\DoxyCodeLine{138     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}register\_dye\_tracer: Not enough values provided for DYE\_SOURCE\_MAXLAT "{}})}
\DoxyCodeLine{139 }
\DoxyCodeLine{140   cs\%dye\_source\_mindepth(:) = -\/1.e30}
\DoxyCodeLine{141   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DYE\_SOURCE\_MINDEPTH"{}}, cs\%dye\_source\_mindepth, \&}
\DoxyCodeLine{142                  \textcolor{stringliteral}{"{}This is the minimum depth at which we inject dyes."{}}, \&}
\DoxyCodeLine{143                  units=\textcolor{stringliteral}{"{}m"{}}, scale=us\%m\_to\_Z, fail\_if\_missing=.true.)}
\DoxyCodeLine{144   \textcolor{keywordflow}{if} (minval(cs\%dye\_source\_mindepth(:)) < -\/1.e29*us\%m\_to\_Z) \&}
\DoxyCodeLine{145     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}register\_dye\_tracer: Not enough values provided for DYE\_SOURCE\_MINDEPTH"{}})}
\DoxyCodeLine{146 }
\DoxyCodeLine{147   cs\%dye\_source\_maxdepth(:) = -\/1.e30}
\DoxyCodeLine{148   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DYE\_SOURCE\_MAXDEPTH"{}}, cs\%dye\_source\_maxdepth, \&}
\DoxyCodeLine{149                  \textcolor{stringliteral}{"{}This is the maximum depth at which we inject dyes."{}}, \&}
\DoxyCodeLine{150                  units=\textcolor{stringliteral}{"{}m"{}}, scale=us\%m\_to\_Z, fail\_if\_missing=.true.)}
\DoxyCodeLine{151   \textcolor{keywordflow}{if} (minval(cs\%dye\_source\_maxdepth(:)) < -\/1.e29*us\%m\_to\_Z) \&}
\DoxyCodeLine{152     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}register\_dye\_tracer: Not enough values provided for DYE\_SOURCE\_MAXDEPTH "{}})}
\DoxyCodeLine{153 }
\DoxyCodeLine{154   \textcolor{keyword}{allocate}(cs\%tr(isd:ied,jsd:jed,nz,cs\%ntr)) ; cs\%tr(:,:,:,:) = 0.0}
\DoxyCodeLine{155 }
\DoxyCodeLine{156   \textcolor{keywordflow}{do} m = 1, cs\%ntr}
\DoxyCodeLine{157     \textcolor{keyword}{write}(var\_name(:),\textcolor{stringliteral}{'(A,I3.3)'}) \textcolor{stringliteral}{"{}dye"{}},m}
\DoxyCodeLine{158     \textcolor{keyword}{write}(desc\_name(:),\textcolor{stringliteral}{'(A,I3.3)'}) \textcolor{stringliteral}{"{}Dye Tracer "{}},m}
\DoxyCodeLine{159     cs\%tr\_desc(m) = var\_desc(trim(var\_name), \textcolor{stringliteral}{"{}conc"{}}, trim(desc\_name), caller=mdl)}
\DoxyCodeLine{160 }
\DoxyCodeLine{161     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration}}
\DoxyCodeLine{162     \textcolor{comment}{! calls.  Curses on the designers and implementers of Fortran90.}}
\DoxyCodeLine{163     tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{164     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=var\_name, \&}
\DoxyCodeLine{165                        caller=\textcolor{stringliteral}{"{}register\_dye\_tracer"{}})}
\DoxyCodeLine{166     \textcolor{comment}{! Register the tracer for horizontal advection, diffusion, and restarts.}}
\DoxyCodeLine{167     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, \&}
\DoxyCodeLine{168                          tr\_desc=cs\%tr\_desc(m), registry\_diags=.true., \&}
\DoxyCodeLine{169                          restart\_cs=restart\_cs, mandatory=.not.cs\%tracers\_may\_reinit)}
\DoxyCodeLine{170 }
\DoxyCodeLine{171     \textcolor{comment}{!   Set coupled\_tracers to be true (hard-\/coded above) to provide the surface}}
\DoxyCodeLine{172     \textcolor{comment}{! values to the coupler (if any).  This is meta-\/code and its arguments will}}
\DoxyCodeLine{173     \textcolor{comment}{! currently (deliberately) give fatal errors if it is used.}}
\DoxyCodeLine{174     \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \&}
\DoxyCodeLine{175       cs\%ind\_tr(m) = aof\_set\_coupler\_flux(trim(var\_name)//\textcolor{stringliteral}{'\_flux'}, \&}
\DoxyCodeLine{176           flux\_type=\textcolor{stringliteral}{' '}, implementation=\textcolor{stringliteral}{' '}, caller=\textcolor{stringliteral}{"{}register\_dye\_tracer"{}})}
\DoxyCodeLine{177 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{178 }
\DoxyCodeLine{179   cs\%tr\_Reg => tr\_reg}
\DoxyCodeLine{180   cs\%restart\_CSp => restart\_cs}
\DoxyCodeLine{181   register\_dye\_tracer = .true.}

\end{DoxyCode}
