\hypertarget{namespaceoil__tracer}{}\doxysection{oil\+\_\+tracer Module Reference}
\label{namespaceoil__tracer}\index{oil\_tracer@{oil\_tracer}}


\doxysubsection{Detailed Description}
A tracer package to mimic dissolved oil. 

By Alistair Adcroft and Robert Hallberg, 2010 $\ast$

In the midst of the Deepwater Horizon oil spill, it became evident that models were needed to predict the long-\/term fate of dissolved oil in the open ocean. This tracer packages mimics the transport, dilution and decay of dissolved oil plumes in the ocean.

This tracer package was central to the simulations used by Adcroft et al., G\+RL 2010, to prove that the Deepwater Horizon spill was an important regional event, with implications for dissolved oxygen levels in the Gulf of Mexico, but not one that would directly impact the East Coast of the U.\+S. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structoil__tracer_1_1oil__tracer__cs}{oil\+\_\+tracer\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em The control structure for the oil tracer package. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
logical function, public \mbox{\hyperlink{namespaceoil__tracer_a3aceaf614d8651772124719e32879e23}{register\+\_\+oil\+\_\+tracer}} (HI, GV, US, param\+\_\+file, CS, tr\+\_\+\+Reg, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Register oil tracer fields and subroutines to be used with M\+OM. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceoil__tracer_a3cb362789ef0ea593f8b7de22016a92e}{initialize\+\_\+oil\+\_\+tracer}} (restart, day, G, GV, US, h, diag, O\+BC, CS, sponge\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initialize the oil tracers and set up tracer output. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceoil__tracer_a2e5cd83c5d5a92a7774d7e6bda53c646}{oil\+\_\+tracer\+\_\+column\+\_\+physics}} (h\+\_\+old, h\+\_\+new, ea, eb, fluxes, dt, G, GV, US, CS, tv, evap\+\_\+\+C\+F\+L\+\_\+limit, minimum\+\_\+forcing\+\_\+depth)
\begin{DoxyCompactList}\small\item\em Apply sources, sinks, diapycnal mixing and rising motions to the oil tracers. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespaceoil__tracer_ac8964b16549dba8fc850e4af15af8029}{oil\+\_\+stock}} (h, stocks, G, GV, CS, names, units, stock\+\_\+index)
\begin{DoxyCompactList}\small\item\em Calculate the mass-\/weighted integral of the oil 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{namespaceoil__tracer_a08f2426138c293029ea1d58b2119c3ce}{oil\+\_\+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{namespaceoil__tracer_a428f70692e0f8a537b73e24ada1e5357}{oil\+\_\+tracer\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Deallocate memory associated with this tracer package. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceoil__tracer_a7d9cefa818e16dd56e1051c3bcff940f}\label{namespaceoil__tracer_a7d9cefa818e16dd56e1051c3bcff940f}} 
integer, parameter \mbox{\hyperlink{namespaceoil__tracer_a7d9cefa818e16dd56e1051c3bcff940f}{ntr\+\_\+max}} = 20
\begin{DoxyCompactList}\small\item\em the maximum number of tracers in this module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceoil__tracer_a3cb362789ef0ea593f8b7de22016a92e}\label{namespaceoil__tracer_a3cb362789ef0ea593f8b7de22016a92e}} 
\index{oil\_tracer@{oil\_tracer}!initialize\_oil\_tracer@{initialize\_oil\_tracer}}
\index{initialize\_oil\_tracer@{initialize\_oil\_tracer}!oil\_tracer@{oil\_tracer}}
\doxysubsubsection{\texorpdfstring{initialize\_oil\_tracer()}{initialize\_oil\_tracer()}}
{\footnotesize\ttfamily subroutine, public oil\+\_\+tracer\+::initialize\+\_\+oil\+\_\+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[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structoil__tracer_1_1oil__tracer__cs}{oil\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(sponge\+\_\+cs), pointer}]{sponge\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Initialize the oil tracers and set up 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 us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & A structure that is 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\+\_\+oil\+\_\+tracer. \\
\hline
 & {\em sponge\+\_\+csp} & Pointer to the control structure for the sponges. \\
\hline
\end{DoxyParams}


Definition at line 206 of file oil\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{206   \textcolor{keywordtype}{logical},                            \textcolor{keywordtype}{intent(in)} :: restart\textcolor{comment}{ !< .true. if the fields have already}}
\DoxyCodeLine{207 \textcolor{comment}{                                                         !! been read from a restart file.}}
\DoxyCodeLine{208   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{  !< Time of the start of the run.}}
\DoxyCodeLine{209   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{210   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{211   \textcolor{keywordtype}{type}(unit\_scale\_type),              \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{212 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{213                                       \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{214   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< A structure that is used to regulate}}
\DoxyCodeLine{215 \textcolor{comment}{                                                         !! diagnostic output.}}
\DoxyCodeLine{216   \textcolor{keywordtype}{type}(ocean\_OBC\_type),               \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{  !< This open boundary condition type specifies}}
\DoxyCodeLine{217 \textcolor{comment}{                                                         !! whether, where, and what open boundary}}
\DoxyCodeLine{218 \textcolor{comment}{                                                         !! conditions are used.}}
\DoxyCodeLine{219   \textcolor{keywordtype}{type}(oil\_tracer\_CS),                \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{220 \textcolor{comment}{                                                       !! call to register\_oil\_tracer.}}
\DoxyCodeLine{221   \textcolor{keywordtype}{type}(sponge\_CS),                    \textcolor{keywordtype}{pointer}    :: sponge\_CSp\textcolor{comment}{ !< Pointer to the control structure for the sponges.}}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{224   \textcolor{keywordtype}{character(len=16)} :: name     \textcolor{comment}{! A variable's name in a NetCDF file.}}
\DoxyCodeLine{225   \textcolor{keywordtype}{character(len=72)} :: longname \textcolor{comment}{! The long name of that variable.}}
\DoxyCodeLine{226   \textcolor{keywordtype}{character(len=48)} :: units    \textcolor{comment}{! The dimensions of the variable.}}
\DoxyCodeLine{227   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for age tracer fluxes, either}}
\DoxyCodeLine{228                                 \textcolor{comment}{! years m3 s-\/1 or years kg s-\/1.}}
\DoxyCodeLine{229   \textcolor{keywordtype}{logical} :: OK}
\DoxyCodeLine{230   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{231   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{232 }
\DoxyCodeLine{233   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{234   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{235   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{236   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{237   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{238 }
\DoxyCodeLine{239   \textcolor{comment}{! Establish location of source}}
\DoxyCodeLine{240   \textcolor{keywordflow}{do} j=g\%jsdB+1,g\%jed ; \textcolor{keywordflow}{do} i=g\%isdB+1,g\%ied}
\DoxyCodeLine{241     \textcolor{comment}{! This test for i,j index is specific to a lat/lon (non-\/rotated grid).}}
\DoxyCodeLine{242     \textcolor{comment}{! and needs to be generalized to work properly on the tri-\/polar grid.}}
\DoxyCodeLine{243     \textcolor{keywordflow}{if} (cs\%oil\_source\_longitude<g\%geoLonBu(i,j) .and. \&}
\DoxyCodeLine{244         cs\%oil\_source\_longitude>=g\%geoLonBu(i-\/1,j) .and. \&}
\DoxyCodeLine{245         cs\%oil\_source\_latitude<g\%geoLatBu(i,j) .and. \&}
\DoxyCodeLine{246         cs\%oil\_source\_latitude>=g\%geoLatBu(i,j-\/1) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{247       cs\%oil\_source\_i=i}
\DoxyCodeLine{248       cs\%oil\_source\_j=j}
\DoxyCodeLine{249 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{250 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{251 }
\DoxyCodeLine{252   cs\%Time => day}
\DoxyCodeLine{253   cs\%diag => diag}
\DoxyCodeLine{254 }
\DoxyCodeLine{255   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{256     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=name, caller=\textcolor{stringliteral}{"initialize\_oil\_tracer"})}
\DoxyCodeLine{257     \textcolor{keywordflow}{if} ((.not.restart) .or. (cs\%oil\_may\_reinit .and. .not. \&}
\DoxyCodeLine{258         query\_initialized(cs\%tr(:,:,:,m), name, cs\%restart\_CSp))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{259 }
\DoxyCodeLine{260       \textcolor{keywordflow}{if} (len\_trim(cs\%IC\_file) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{261   \textcolor{comment}{!  Read the tracer concentrations from a netcdf file.}}
\DoxyCodeLine{262         \textcolor{keywordflow}{if} (.not.file\_exists(cs\%IC\_file, g\%Domain)) \&}
\DoxyCodeLine{263           \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"initialize\_oil\_tracer: "}// \&}
\DoxyCodeLine{264                                  \textcolor{stringliteral}{"Unable to open "}//cs\%IC\_file)}
\DoxyCodeLine{265 }
\DoxyCodeLine{266         \textcolor{keywordflow}{if} (cs\%Z\_IC\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{267           ok = tracer\_z\_init(cs\%tr(:,:,:,m), h, cs\%IC\_file, name, \&}
\DoxyCodeLine{268                              g, us, -\/1e34, 0.0) \textcolor{comment}{! CS\%land\_val(m))}}
\DoxyCodeLine{269           \textcolor{keywordflow}{if} (.not.ok) \textcolor{keywordflow}{then}}
\DoxyCodeLine{270             ok = tracer\_z\_init(cs\%tr(:,:,:,m), h, cs\%IC\_file, \&}
\DoxyCodeLine{271                      trim(name), g, us, -\/1e34, 0.0) \textcolor{comment}{! CS\%land\_val(m))}}
\DoxyCodeLine{272             \textcolor{keywordflow}{if} (.not.ok) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_oil\_tracer: "}//\&}
\DoxyCodeLine{273                     \textcolor{stringliteral}{"Unable to read "}//trim(name)//\textcolor{stringliteral}{" from "}//\&}
\DoxyCodeLine{274                     trim(cs\%IC\_file)//\textcolor{stringliteral}{"."})}
\DoxyCodeLine{275 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{276         \textcolor{keywordflow}{else}}
\DoxyCodeLine{277           \textcolor{keyword}{call }mom\_read\_data(cs\%IC\_file, trim(name), cs\%tr(:,:,:,m), g\%Domain)}
\DoxyCodeLine{278 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{279       \textcolor{keywordflow}{else}}
\DoxyCodeLine{280         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{281           \textcolor{keywordflow}{if} (g\%mask2dT(i,j) < 0.5) \textcolor{keywordflow}{then}}
\DoxyCodeLine{282             cs\%tr(i,j,k,m) = cs\%land\_val(m)}
\DoxyCodeLine{283           \textcolor{keywordflow}{else}}
\DoxyCodeLine{284             cs\%tr(i,j,k,m) = cs\%IC\_val(m)}
\DoxyCodeLine{285 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{286 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{287 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{288 }
\DoxyCodeLine{289 \textcolor{keywordflow}{    endif} \textcolor{comment}{! restart}}
\DoxyCodeLine{290 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! Tracer loop}}
\DoxyCodeLine{291 }
\DoxyCodeLine{292   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{293   \textcolor{comment}{! Put something here...}}
\DoxyCodeLine{294 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{295 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceoil__tracer_ac8964b16549dba8fc850e4af15af8029}\label{namespaceoil__tracer_ac8964b16549dba8fc850e4af15af8029}} 
\index{oil\_tracer@{oil\_tracer}!oil\_stock@{oil\_stock}}
\index{oil\_stock@{oil\_stock}!oil\_tracer@{oil\_tracer}}
\doxysubsubsection{\texorpdfstring{oil\_stock()}{oil\_stock()}}
{\footnotesize\ttfamily integer function, public oil\+\_\+tracer\+::oil\+\_\+stock (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{real, dimension(\+:), intent(out)}]{stocks,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structoil__tracer_1_1oil__tracer__cs}{oil\+\_\+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})}



Calculate the mass-\/weighted integral of the oil 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\+\_\+oil\+\_\+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}
The number of stocks calculated here. 
\end{DoxyReturn}


Definition at line 408 of file oil\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{408   \textcolor{keywordtype}{type}(ocean\_grid\_type),              \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{409   \textcolor{keywordtype}{type}(verticalGrid\_type),            \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{410 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{411 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},                 \textcolor{keywordtype}{intent(out)}   :: stocks\textcolor{comment}{ !< the mass-\/weighted integrated amount of each}}
\DoxyCodeLine{412 \textcolor{comment}{                                                              !! tracer, in kg times concentration units [kg conc].}}
\DoxyCodeLine{413   \textcolor{keywordtype}{type}(oil\_tracer\_CS),                \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{414 \textcolor{comment}{                                                            !! call to register\_oil\_tracer.}}
\DoxyCodeLine{415   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: names\textcolor{comment}{  !< the names of the stocks calculated.}}
\DoxyCodeLine{416   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(out)}   :: units\textcolor{comment}{  !< the units of the stocks calculated.}}
\DoxyCodeLine{417   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},                  \textcolor{keywordtype}{intent(in)}    :: stock\_index\textcolor{comment}{ !< the coded index of a specific stock}}
\DoxyCodeLine{418 \textcolor{comment}{                                                                   !! being sought.}}
\DoxyCodeLine{419   \textcolor{keywordtype}{integer}                                           :: oil\_stock\textcolor{comment}{ !< The number of stocks calculated here.}}
\DoxyCodeLine{420 }
\DoxyCodeLine{421 \textcolor{comment}{! This function calculates the mass-\/weighted integral of all tracer stocks,}}
\DoxyCodeLine{422 \textcolor{comment}{! returning the number of stocks it has calculated.  If the stock\_index}}
\DoxyCodeLine{423 \textcolor{comment}{! is present, only the stock corresponding to that coded index is returned.}}
\DoxyCodeLine{424 }
\DoxyCodeLine{425   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{426   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m}
\DoxyCodeLine{427   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{428 }
\DoxyCodeLine{429   oil\_stock = 0}
\DoxyCodeLine{430   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{431   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{432 }
\DoxyCodeLine{433   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stock\_index)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (stock\_index > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{434     \textcolor{comment}{! Check whether this stock is available from this routine.}}
\DoxyCodeLine{435 }
\DoxyCodeLine{436     \textcolor{comment}{! No stocks from this routine are being checked yet.  Return 0.}}
\DoxyCodeLine{437     \textcolor{keywordflow}{return}}
\DoxyCodeLine{438 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{439 }
\DoxyCodeLine{440   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{441     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=names(m), units=units(m), caller=\textcolor{stringliteral}{"oil\_stock"})}
\DoxyCodeLine{442     units(m) = trim(units(m))//\textcolor{stringliteral}{" kg"}}
\DoxyCodeLine{443     stocks(m) = 0.0}
\DoxyCodeLine{444     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{445       stocks(m) = stocks(m) + cs\%tr(i,j,k,m) * \&}
\DoxyCodeLine{446                              (g\%mask2dT(i,j) * g\%US\%L\_to\_m**2*g\%areaT(i,j) * h(i,j,k))}
\DoxyCodeLine{447 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{448     stocks(m) = gv\%H\_to\_kg\_m2 * stocks(m)}
\DoxyCodeLine{449 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{450   oil\_stock = cs\%ntr}
\DoxyCodeLine{451 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceoil__tracer_a2e5cd83c5d5a92a7774d7e6bda53c646}\label{namespaceoil__tracer_a2e5cd83c5d5a92a7774d7e6bda53c646}} 
\index{oil\_tracer@{oil\_tracer}!oil\_tracer\_column\_physics@{oil\_tracer\_column\_physics}}
\index{oil\_tracer\_column\_physics@{oil\_tracer\_column\_physics}!oil\_tracer@{oil\_tracer}}
\doxysubsubsection{\texorpdfstring{oil\_tracer\_column\_physics()}{oil\_tracer\_column\_physics()}}
{\footnotesize\ttfamily subroutine, public oil\+\_\+tracer\+::oil\+\_\+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(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(\mbox{\hyperlink{structoil__tracer_1_1oil__tracer__cs}{oil\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{real, intent(in), optional}]{evap\+\_\+\+C\+F\+L\+\_\+limit,  }\item[{real, intent(in), optional}]{minimum\+\_\+forcing\+\_\+depth }\end{DoxyParamCaption})}



Apply sources, sinks, diapycnal mixing and rising motions to the oil tracers. 


\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\+\_\+oil\+\_\+tracer. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\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 301 of file oil\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{301   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{302   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{303 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{304                            \textcolor{keywordtype}{intent(in)} :: h\_old\textcolor{comment}{ !< Layer thickness before entrainment [H ~> m or kg m-\/2].}}
\DoxyCodeLine{305 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{306                            \textcolor{keywordtype}{intent(in)} :: h\_new\textcolor{comment}{ !< Layer thickness after entrainment [H ~> m or kg m-\/2].}}
\DoxyCodeLine{307 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{308                            \textcolor{keywordtype}{intent(in)} :: ea\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{309 \textcolor{comment}{                                              !! from the layer above during this call will be}}
\DoxyCodeLine{310 \textcolor{comment}{                                              !! added [H ~> m or kg m-\/2].}}
\DoxyCodeLine{311 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{312                            \textcolor{keywordtype}{intent(in)} :: eb\textcolor{comment}{   !< an array to which the amount of fluid entrained}}
\DoxyCodeLine{313 \textcolor{comment}{                                              !! from the layer below during this call will be}}
\DoxyCodeLine{314 \textcolor{comment}{                                              !! added [H ~> m or kg m-\/2].}}
\DoxyCodeLine{315   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to thermodynamic}}
\DoxyCodeLine{316 \textcolor{comment}{                                              !! and tracer forcing fields.  Unused fields have NULL ptrs.}}
\DoxyCodeLine{317 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{   !< The amount of time covered by this call [T ~> s]}}
\DoxyCodeLine{318   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{319   \textcolor{keywordtype}{type}(oil\_tracer\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< The control structure returned by a previous}}
\DoxyCodeLine{320 \textcolor{comment}{                                              !! call to register\_oil\_tracer.}}
\DoxyCodeLine{321   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{322 \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{323 \textcolor{comment}{                                              !! be fluxed out of the top layer in a timestep [nondim]}}
\DoxyCodeLine{324 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: minimum\_forcing\_depth\textcolor{comment}{ !< The smallest depth over which}}
\DoxyCodeLine{325 \textcolor{comment}{                                              !! fluxes can be applied [H ~> m or kg m-\/2]}}
\DoxyCodeLine{326 \textcolor{comment}{!   This subroutine applies diapycnal diffusion and any other column}}
\DoxyCodeLine{327 \textcolor{comment}{! tracer physics or chemistry to the tracers from this file.}}
\DoxyCodeLine{328 \textcolor{comment}{! This is a simple example of a set of advected passive tracers.}}
\DoxyCodeLine{329 }
\DoxyCodeLine{330 \textcolor{comment}{! The arguments to this subroutine are redundant in that}}
\DoxyCodeLine{331 \textcolor{comment}{!     h\_new(k) = h\_old(k) + ea(k) -\/ eb(k-\/1) + eb(k) -\/ ea(k+1)}}
\DoxyCodeLine{332 }
\DoxyCodeLine{333   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{334 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_work \textcolor{comment}{! Used so that h can be modified}}
\DoxyCodeLine{335 \textcolor{keywordtype}{  real} :: Isecs\_per\_year = 1.0 / (365.0*86400.0)}
\DoxyCodeLine{336 \textcolor{keywordtype}{  real} :: year, h\_total, ldecay}
\DoxyCodeLine{337   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, m, k\_max}
\DoxyCodeLine{338   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{339 }
\DoxyCodeLine{340   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{341   \textcolor{keywordflow}{if} (cs\%ntr < 1) \textcolor{keywordflow}{return}}
\DoxyCodeLine{342 }
\DoxyCodeLine{343   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(evap\_cfl\_limit) .and. \textcolor{keyword}{present}(minimum\_forcing\_depth)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{344     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{345       \textcolor{keywordflow}{do} k=1,nz ;\textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{346         h\_work(i,j,k) = h\_old(i,j,k)}
\DoxyCodeLine{347 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{348       \textcolor{keyword}{call }applytracerboundaryfluxesinout(g, gv, cs\%tr(:,:,:,m), dt, fluxes, h\_work, \&}
\DoxyCodeLine{349                                           evap\_cfl\_limit, minimum\_forcing\_depth)}
\DoxyCodeLine{350       \textcolor{keyword}{call }tracer\_vertdiff(h\_work, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{351 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{352   \textcolor{keywordflow}{else}}
\DoxyCodeLine{353     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{354       \textcolor{keyword}{call }tracer\_vertdiff(h\_old, ea, eb, dt, cs\%tr(:,:,:,m), g, gv)}
\DoxyCodeLine{355 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{356 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{357 }
\DoxyCodeLine{358   year = time\_type\_to\_real(cs\%Time) * isecs\_per\_year}
\DoxyCodeLine{359 }
\DoxyCodeLine{360   \textcolor{comment}{! Decay tracer (limit decay rate to 1/dt -\/ just in case)}}
\DoxyCodeLine{361   \textcolor{keywordflow}{do} m=2,cs\%ntr}
\DoxyCodeLine{362     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{363       \textcolor{comment}{!CS\%tr(i,j,k,m) = CS\%tr(i,j,k,m) -\/ dt*CS\%oil\_decay\_rate(m)*CS\%tr(i,j,k,m) ! Simple}}
\DoxyCodeLine{364       \textcolor{comment}{!CS\%tr(i,j,k,m) = CS\%tr(i,j,k,m) -\/ min(dt*CS\%oil\_decay\_rate(m),1.)*CS\%tr(i,j,k,m) ! Safer}}
\DoxyCodeLine{365       \textcolor{keywordflow}{if} (cs\%oil\_decay\_rate(m)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{366         cs\%tr(i,j,k,m) = g\%mask2dT(i,j)*max(1. -\/ dt*cs\%oil\_decay\_rate(m),0.)*cs\%tr(i,j,k,m) \textcolor{comment}{! Safest}}
\DoxyCodeLine{367       \textcolor{keywordflow}{elseif} (cs\%oil\_decay\_rate(m)<0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{368         ldecay = 12.*(3.0**(-\/(tv\%T(i,j,k)-\/20.)/10.)) \textcolor{comment}{! Timescale [days]}}
\DoxyCodeLine{369         ldecay = 1. / (86400.*us\%s\_to\_T * ldecay) \textcolor{comment}{! Rate [T-\/1 ~> s-\/1]}}
\DoxyCodeLine{370         cs\%tr(i,j,k,m) = g\%mask2dT(i,j)*max(1. -\/ dt*ldecay,0.)*cs\%tr(i,j,k,m)}
\DoxyCodeLine{371 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{372 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{373 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{374 }
\DoxyCodeLine{375   \textcolor{comment}{! Add oil at the source location}}
\DoxyCodeLine{376   \textcolor{keywordflow}{if} (year>=cs\%oil\_start\_year .and. year<=cs\%oil\_end\_year .and. \&}
\DoxyCodeLine{377       cs\%oil\_source\_i>-\/999 .and. cs\%oil\_source\_j>-\/999) \textcolor{keywordflow}{then}}
\DoxyCodeLine{378     i=cs\%oil\_source\_i ; j=cs\%oil\_source\_j}
\DoxyCodeLine{379     k\_max=nz ; h\_total=0.}
\DoxyCodeLine{380     \textcolor{keywordflow}{do} k=nz, 2, -\/1}
\DoxyCodeLine{381       h\_total = h\_total + h\_new(i,j,k)}
\DoxyCodeLine{382       \textcolor{keywordflow}{if} (h\_total<10.) k\_max=k-\/1 \textcolor{comment}{! Find bottom most interface that is 10 m above bottom}}
\DoxyCodeLine{383 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{384     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{385       k=cs\%oil\_source\_k(m)}
\DoxyCodeLine{386       \textcolor{keywordflow}{if} (k>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{387         k=min(k,k\_max) \textcolor{comment}{! Only insert k or first layer with interface 10 m above bottom}}
\DoxyCodeLine{388         cs\%tr(i,j,k,m) = cs\%tr(i,j,k,m) + cs\%oil\_source\_rate*dt / \&}
\DoxyCodeLine{389                 ((h\_new(i,j,k)+gv\%H\_subroundoff) * g\%US\%L\_to\_m**2*g\%areaT(i,j) )}
\DoxyCodeLine{390       \textcolor{keywordflow}{elseif} (k<0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{391         h\_total=gv\%H\_subroundoff}
\DoxyCodeLine{392         \textcolor{keywordflow}{do} k=1, nz}
\DoxyCodeLine{393           h\_total = h\_total + h\_new(i,j,k)}
\DoxyCodeLine{394 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{395         \textcolor{keywordflow}{do} k=1, nz}
\DoxyCodeLine{396           cs\%tr(i,j,k,m) = cs\%tr(i,j,k,m) + cs\%oil\_source\_rate*dt/(h\_total \&}
\DoxyCodeLine{397                                            * g\%US\%L\_to\_m**2*g\%areaT(i,j) )}
\DoxyCodeLine{398 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{399 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{400 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{401 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{402 }

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



Deallocate memory associated with this tracer package. 


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


Definition at line 489 of file oil\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{489   \textcolor{keywordtype}{type}(oil\_tracer\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{490 \textcolor{comment}{                                     !! call to register\_oil\_tracer.}}
\DoxyCodeLine{491   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{492 }
\DoxyCodeLine{493   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{494     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%tr)) \textcolor{keyword}{deallocate}(cs\%tr)}
\DoxyCodeLine{495     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{496 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceoil__tracer_a08f2426138c293029ea1d58b2119c3ce}\label{namespaceoil__tracer_a08f2426138c293029ea1d58b2119c3ce}} 
\index{oil\_tracer@{oil\_tracer}!oil\_tracer\_surface\_state@{oil\_tracer\_surface\_state}}
\index{oil\_tracer\_surface\_state@{oil\_tracer\_surface\_state}!oil\_tracer@{oil\_tracer}}
\doxysubsubsection{\texorpdfstring{oil\_tracer\_surface\_state()}{oil\_tracer\_surface\_state()}}
{\footnotesize\ttfamily subroutine, public oil\+\_\+tracer\+::oil\+\_\+tracer\+\_\+surface\+\_\+state (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structoil__tracer_1_1oil__tracer__cs}{oil\+\_\+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\+\_\+oil\+\_\+tracer. \\
\hline
\end{DoxyParams}


Definition at line 458 of file oil\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{458   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The ocean's grid structure.}}
\DoxyCodeLine{459   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{460 \textcolor{comment}{                                              !! describe the surface state of the ocean.}}
\DoxyCodeLine{461 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{462                           \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thickness [H ~> m or kg m-\/2].}}
\DoxyCodeLine{463   \textcolor{keywordtype}{type}(oil\_tracer\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< The control structure returned by a previous}}
\DoxyCodeLine{464 \textcolor{comment}{                                              !! call to register\_oil\_tracer.}}
\DoxyCodeLine{465 }
\DoxyCodeLine{466   \textcolor{comment}{! This particular tracer package does not report anything back to the coupler.}}
\DoxyCodeLine{467   \textcolor{comment}{! The code that is here is just a rough guide for packages that would.}}
\DoxyCodeLine{468 }
\DoxyCodeLine{469   \textcolor{keywordtype}{integer} :: m, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{470   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{471   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{472 }
\DoxyCodeLine{473   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{474 }
\DoxyCodeLine{475   \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{476     \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{477       \textcolor{comment}{!   This call loads the surface values into the appropriate array in the}}
\DoxyCodeLine{478       \textcolor{comment}{! coupler-\/type structure.}}
\DoxyCodeLine{479       \textcolor{keyword}{call }coupler\_type\_set\_data(cs\%tr(:,:,1,m), cs\%ind\_tr(m), ind\_csurf, \&}
\DoxyCodeLine{480                    sfc\_state\%tr\_fields, idim=(/isd, is, ie, ied/), \&}
\DoxyCodeLine{481                    jdim=(/jsd, js, je, jed/) )}
\DoxyCodeLine{482 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{483 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{484 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceoil__tracer_a3aceaf614d8651772124719e32879e23}\label{namespaceoil__tracer_a3aceaf614d8651772124719e32879e23}} 
\index{oil\_tracer@{oil\_tracer}!register\_oil\_tracer@{register\_oil\_tracer}}
\index{register\_oil\_tracer@{register\_oil\_tracer}!oil\_tracer@{oil\_tracer}}
\doxysubsubsection{\texorpdfstring{register\_oil\_tracer()}{register\_oil\_tracer()}}
{\footnotesize\ttfamily logical function, public oil\+\_\+tracer\+::register\+\_\+oil\+\_\+tracer (\begin{DoxyParamCaption}\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structoil__tracer_1_1oil__tracer__cs}{oil\+\_\+tracer\+\_\+cs}}), pointer}]{CS,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{tr\+\_\+\+Reg,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



Register oil 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 78 of file oil\+\_\+tracer.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{78   \textcolor{keywordtype}{type}(hor\_index\_type),       \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type structure}}
\DoxyCodeLine{79   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{80   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{81   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{82   \textcolor{keywordtype}{type}(oil\_tracer\_CS),        \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< A pointer that is set to point to the control}}
\DoxyCodeLine{83 \textcolor{comment}{                                                 !! structure for this module}}
\DoxyCodeLine{84   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}    :: tr\_Reg\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{85 \textcolor{comment}{                                                 !! structure for the tracer advection and}}
\DoxyCodeLine{86 \textcolor{comment}{                                                 !! diffusion module}}
\DoxyCodeLine{87   \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}    :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure}}
\DoxyCodeLine{88 }
\DoxyCodeLine{89   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{90   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"oil\_tracer"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{91 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{92 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{93 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=200)} :: inputdir \textcolor{comment}{! The directory where the input files are.}}
\DoxyCodeLine{94   \textcolor{keywordtype}{character(len=48)}  :: var\_name \textcolor{comment}{! The variable's name.}}
\DoxyCodeLine{95   \textcolor{keywordtype}{character(len=3)}   :: name\_tag \textcolor{comment}{! String for creating identifying oils}}
\DoxyCodeLine{96   \textcolor{keywordtype}{character(len=48)} :: flux\_units \textcolor{comment}{! The units for tracer fluxes, here}}
\DoxyCodeLine{97                             \textcolor{comment}{! kg(oil) s-\/1 or kg(oil) m-\/3 kg(water) s-\/1.}}
\DoxyCodeLine{98 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: tr\_ptr(:,:,:) => null()}
\DoxyCodeLine{99   \textcolor{keywordtype}{logical} :: register\_oil\_tracer}
\DoxyCodeLine{100   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, m, i, j}
\DoxyCodeLine{101   isd = hi\%isd ; ied = hi\%ied ; jsd = hi\%jsd ; jed = hi\%jed ; nz = gv\%ke}
\DoxyCodeLine{102 }
\DoxyCodeLine{103   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{104     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_oil\_tracer called with an "}// \&}
\DoxyCodeLine{105                              \textcolor{stringliteral}{"associated control structure."})}
\DoxyCodeLine{106     \textcolor{keywordflow}{return}}
\DoxyCodeLine{107 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{108   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{109 }
\DoxyCodeLine{110   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{111   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{112   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_IC\_FILE"}, cs\%IC\_file, \&}
\DoxyCodeLine{113                  \textcolor{stringliteral}{"The file in which the oil tracer initial values can be "}//\&}
\DoxyCodeLine{114                  \textcolor{stringliteral}{"found, or an empty string for internal initialization."}, \&}
\DoxyCodeLine{115                  default=\textcolor{stringliteral}{" "})}
\DoxyCodeLine{116   \textcolor{keywordflow}{if} ((len\_trim(cs\%IC\_file) > 0) .and. (scan(cs\%IC\_file,\textcolor{stringliteral}{'/'}) == 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{117     \textcolor{comment}{! Add the directory if CS\%IC\_file is not already a complete path.}}
\DoxyCodeLine{118     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{119     cs\%IC\_file = trim(slasher(inputdir))//trim(cs\%IC\_file)}
\DoxyCodeLine{120     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/CFC\_IC\_FILE"}, cs\%IC\_file)}
\DoxyCodeLine{121 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{122   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_IC\_FILE\_IS\_Z"}, cs\%Z\_IC\_file, \&}
\DoxyCodeLine{123                  \textcolor{stringliteral}{"If true, OIL\_IC\_FILE is in depth space, not layer space"}, \&}
\DoxyCodeLine{124                  default=.false.)}
\DoxyCodeLine{125 }
\DoxyCodeLine{126   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_MAY\_REINIT"}, cs\%oil\_may\_reinit, \&}
\DoxyCodeLine{127                  \textcolor{stringliteral}{"If true, oil tracers may go through the initialization "}//\&}
\DoxyCodeLine{128                  \textcolor{stringliteral}{"code if they are not found in the restart files. "}//\&}
\DoxyCodeLine{129                  \textcolor{stringliteral}{"Otherwise it is a fatal error if the oil tracers are not "}//\&}
\DoxyCodeLine{130                  \textcolor{stringliteral}{"found in the restart files of a restarted run."}, \&}
\DoxyCodeLine{131                  default=.false.)}
\DoxyCodeLine{132   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_SOURCE\_LONGITUDE"}, cs\%oil\_source\_longitude, \&}
\DoxyCodeLine{133                  \textcolor{stringliteral}{"The geographic longitude of the oil source."}, units=\textcolor{stringliteral}{"degrees E"}, \&}
\DoxyCodeLine{134                  fail\_if\_missing=.true.)}
\DoxyCodeLine{135   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_SOURCE\_LATITUDE"}, cs\%oil\_source\_latitude, \&}
\DoxyCodeLine{136                  \textcolor{stringliteral}{"The geographic latitude of the oil source."}, units=\textcolor{stringliteral}{"degrees N"}, \&}
\DoxyCodeLine{137                  fail\_if\_missing=.true.)}
\DoxyCodeLine{138   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_SOURCE\_LAYER"}, cs\%oil\_source\_k, \&}
\DoxyCodeLine{139                  \textcolor{stringliteral}{"The layer into which the oil is introduced, or a "}//\&}
\DoxyCodeLine{140                  \textcolor{stringliteral}{"negative number for a vertically uniform source, "}//\&}
\DoxyCodeLine{141                  \textcolor{stringliteral}{"or 0 not to use this tracer."}, units=\textcolor{stringliteral}{"Layer"}, default=0)}
\DoxyCodeLine{142   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_SOURCE\_RATE"}, cs\%oil\_source\_rate, \&}
\DoxyCodeLine{143                  \textcolor{stringliteral}{"The rate of oil injection."}, units=\textcolor{stringliteral}{"kg s-\/1"}, scale=us\%T\_to\_s, default=1.0)}
\DoxyCodeLine{144   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_DECAY\_DAYS"}, cs\%oil\_decay\_days, \&}
\DoxyCodeLine{145                  \textcolor{stringliteral}{"The decay timescale in days (if positive), or no decay "}//\&}
\DoxyCodeLine{146                  \textcolor{stringliteral}{"if 0, or use the temperature dependent decay rate of "}//\&}
\DoxyCodeLine{147                  \textcolor{stringliteral}{"Adcroft et al. (GRL, 2010) if negative."}, units=\textcolor{stringliteral}{"days"}, \&}
\DoxyCodeLine{148                  default=0.0)}
\DoxyCodeLine{149   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_DATED\_START\_YEAR"}, cs\%oil\_start\_year, \&}
\DoxyCodeLine{150                  \textcolor{stringliteral}{"The time at which the oil source starts"}, units=\textcolor{stringliteral}{"years"}, \&}
\DoxyCodeLine{151                  default=0.0)}
\DoxyCodeLine{152   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_DATED\_END\_YEAR"}, cs\%oil\_end\_year, \&}
\DoxyCodeLine{153                  \textcolor{stringliteral}{"The time at which the oil source ends"}, units=\textcolor{stringliteral}{"years"}, \&}
\DoxyCodeLine{154                  default=1.0e99)}
\DoxyCodeLine{155 }
\DoxyCodeLine{156   cs\%ntr = 0}
\DoxyCodeLine{157   cs\%oil\_decay\_rate(:) = 0.}
\DoxyCodeLine{158   \textcolor{keywordflow}{do} m=1,ntr\_max}
\DoxyCodeLine{159     \textcolor{keywordflow}{if} (cs\%oil\_source\_k(m)/=0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{160       \textcolor{keyword}{write}(name\_tag(1:3),\textcolor{stringliteral}{'("\_",I2.2)'}) m}
\DoxyCodeLine{161       cs\%ntr = cs\%ntr + 1}
\DoxyCodeLine{162       cs\%tr\_desc(m) = var\_desc(\textcolor{stringliteral}{"oil"}//trim(name\_tag), \textcolor{stringliteral}{"kg m-\/3"}, \textcolor{stringliteral}{"Oil Tracer"}, caller=mdl)}
\DoxyCodeLine{163       cs\%IC\_val(m) = 0.0}
\DoxyCodeLine{164       \textcolor{keywordflow}{if} (cs\%oil\_decay\_days(m)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{165         cs\%oil\_decay\_rate(m) = 1. / (86400.0*us\%s\_to\_T * cs\%oil\_decay\_days(m))}
\DoxyCodeLine{166       \textcolor{keywordflow}{elseif} (cs\%oil\_decay\_days(m)<0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{167         cs\%oil\_decay\_rate(m) = -\/1.}
\DoxyCodeLine{168 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{169 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{170 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{171   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"OIL\_DECAY\_RATE"}, us\%s\_to\_T*cs\%oil\_decay\_rate(1:cs\%ntr))}
\DoxyCodeLine{172 }
\DoxyCodeLine{173   \textcolor{comment}{! This needs to be changed if the units of tracer are changed above.}}
\DoxyCodeLine{174   \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then} ; flux\_units = \textcolor{stringliteral}{"kg s-\/1"}}
\DoxyCodeLine{175   \textcolor{keywordflow}{else} ; flux\_units = \textcolor{stringliteral}{"kg m-\/3 kg s-\/1"} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{176 }
\DoxyCodeLine{177   \textcolor{keyword}{allocate}(cs\%tr(isd:ied,jsd:jed,nz,cs\%ntr)) ; cs\%tr(:,:,:,:) = 0.0}
\DoxyCodeLine{178 }
\DoxyCodeLine{179   \textcolor{keywordflow}{do} m=1,cs\%ntr}
\DoxyCodeLine{180     \textcolor{comment}{! This is needed to force the compiler not to do a copy in the registration}}
\DoxyCodeLine{181     \textcolor{comment}{! calls.  Curses on the designers and implementers of Fortran90.}}
\DoxyCodeLine{182     tr\_ptr => cs\%tr(:,:,:,m)}
\DoxyCodeLine{183     \textcolor{keyword}{call }query\_vardesc(cs\%tr\_desc(m), name=var\_name, caller=\textcolor{stringliteral}{"register\_oil\_tracer"})}
\DoxyCodeLine{184     \textcolor{comment}{! Register the tracer for horizontal advection, diffusion, and restarts.}}
\DoxyCodeLine{185     \textcolor{keyword}{call }register\_tracer(tr\_ptr, tr\_reg, param\_file, hi, gv, tr\_desc=cs\%tr\_desc(m), \&}
\DoxyCodeLine{186                          registry\_diags=.true., flux\_units=flux\_units, restart\_cs=restart\_cs, \&}
\DoxyCodeLine{187                          mandatory=.not.cs\%oil\_may\_reinit)}
\DoxyCodeLine{188 }
\DoxyCodeLine{189     \textcolor{comment}{!   Set coupled\_tracers to be true (hard-\/coded above) to provide the surface}}
\DoxyCodeLine{190     \textcolor{comment}{! values to the coupler (if any).  This is meta-\/code and its arguments will}}
\DoxyCodeLine{191     \textcolor{comment}{! currently (deliberately) give fatal errors if it is used.}}
\DoxyCodeLine{192     \textcolor{keywordflow}{if} (cs\%coupled\_tracers) \&}
\DoxyCodeLine{193       cs\%ind\_tr(m) = aof\_set\_coupler\_flux(trim(var\_name)//\textcolor{stringliteral}{'\_flux'}, \&}
\DoxyCodeLine{194           flux\_type=\textcolor{stringliteral}{' '}, implementation=\textcolor{stringliteral}{' '}, caller=\textcolor{stringliteral}{"register\_oil\_tracer"})}
\DoxyCodeLine{195 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{196 }
\DoxyCodeLine{197   cs\%tr\_Reg => tr\_reg}
\DoxyCodeLine{198   cs\%restart\_CSp => restart\_cs}
\DoxyCodeLine{199   register\_oil\_tracer = .true.}
\DoxyCodeLine{200 }

\end{DoxyCode}
