\hypertarget{namespacedyed__obc__tracer}{}\section{dyed\+\_\+obc\+\_\+tracer Module Reference}
\label{namespacedyed__obc__tracer}\index{dyed\+\_\+obc\+\_\+tracer@{dyed\+\_\+obc\+\_\+tracer}}


\subsection{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). \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \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}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \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 \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 \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 \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}


\subsection{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}}
\subsubsection{\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(forcing), intent(in)}]{fluxes,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\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{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt in}  & {\em h\+\_\+old} & Layer thickness before entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em h\+\_\+new} & Layer thickness after entrainment \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em ea} & an array to which the amount of fluid entrained\\
\hline
\mbox{\tt in}  & {\em eb} & an array to which the amount of fluid entrained\\
\hline
\mbox{\tt in}  & {\em fluxes} & A structure containing pointers to thermodynamic and tracer forcing fields. Unused fields have N\+U\+LL ptrs.\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time covered by this call \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt 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{\tt 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{\tt in}  & {\em minimum\+\_\+forcing\+\_\+depth} & The smallest depth over which fluxes can be applied \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


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


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


\begin{DoxyCode}
259   \textcolor{keywordtype}{type}(dyed\_obc\_tracer\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{   !< The control structure returned by a previous}
260 \textcolor{comment}{                                            !! call to dyed\_obc\_register\_tracer.}
261   \textcolor{keywordtype}{integer} :: m
262 
263   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
264     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tr)) \textcolor{keyword}{deallocate}(cs%tr)
265 
266     \textcolor{keyword}{deallocate}(cs)
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}}
\subsubsection{\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(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\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{\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 restart} & .true. if the fields have already been read from a restart file.\\
\hline
\mbox{\tt in}  & {\em day} & Time of the start of the run.\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt 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 136 of file dyed\+\_\+obc\+\_\+tracer.\+F90.


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



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi} & A horizontal index type structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
 & {\em cs} & 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 55 of file dyed\+\_\+obc\+\_\+tracer.\+F90.


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