\hypertarget{namespacemom__sponge}{}\doxysection{mom\+\_\+sponge Module Reference}
\label{namespacemom__sponge}\index{mom\_sponge@{mom\_sponge}}


\doxysubsection{Detailed Description}
Implements sponge regions in isopycnal mode. 

By Robert Hallberg, March 1999-\/June 2000

This program contains the subroutines that implement sponge regions, in which the stratification and water mass properties are damped toward some profiles. There are three externally callable subroutines in this file.

initialize\+\_\+sponge determines the mapping from the model variables into the arrays of damped columns. This remapping is done for efficiency and to conserve memory. Only columns which have positive inverse damping times and which are deeper than a supplied depth are placed in sponges. The inverse damping time is also stored in this subroutine, and memory is allocated for all of the reference profiles which will subsequently be provided through calls to set\+\_\+up\+\_\+sponge\+\_\+field. The first two arguments are a two-\/dimensional array containing the damping rates, and the interface heights to damp towards.

set\+\_\+up\+\_\+sponge\+\_\+field is called to provide a reference profile and the location of the field that will be damped back toward that reference profile. A third argument, the number of layers in the field is also provided, but this should always be nz.

Apply\+\_\+sponge damps all of the fields that have been registered with set\+\_\+up\+\_\+sponge\+\_\+field toward their reference profiles. The four arguments are the thickness to be damped, the amount of time over which the damping occurs, and arrays to which the movement of fluid into a layer from above and below will be added. The effect on momentum of the sponge may be accounted for later using the movement of water recorded in these later arrays. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__sponge_1_1p2d}{p2d}}
\begin{DoxyCompactList}\small\item\em A structure for creating arrays of pointers to 2D arrays. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__sponge_1_1p3d}{p3d}}
\begin{DoxyCompactList}\small\item\em A structure for creating arrays of pointers to 3D arrays. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em This control structure holds memory and parameters for the M\+O\+M\+\_\+sponge module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__sponge_a2c3c6a03d98c13221031af667b42428d}{initialize\+\_\+sponge}} (Iresttime, int\+\_\+height, G, param\+\_\+file, CS, GV, Iresttime\+\_\+i\+\_\+mean, int\+\_\+height\+\_\+i\+\_\+mean)
\begin{DoxyCompactList}\small\item\em This subroutine determines the number of points which are within sponges in this computational domain. Only points that have positive values of Iresttime and which mask2dT indicates are ocean points are included in the sponges. It also stores the target interface heights. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__sponge_ad4b2c0efb73f14a43936a11b39027f57}{init\+\_\+sponge\+\_\+diags}} (Time, G, GV, US, diag, CS)
\begin{DoxyCompactList}\small\item\em This subroutine sets up diagnostics for the sponges. It is separate from initialize\+\_\+sponge because it requires fields that are not readily available where initialize\+\_\+sponge is called. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__sponge_af3da4a8b352c4130919d7bfedf1a5a3e}{set\+\_\+up\+\_\+sponge\+\_\+field}} (sp\+\_\+val, f\+\_\+ptr, G, nlay, CS, sp\+\_\+val\+\_\+i\+\_\+mean)
\begin{DoxyCompactList}\small\item\em This subroutine stores the reference profile for the variable whose address is given by f\+\_\+ptr. nlay is the number of layers in this variable. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__sponge_ac5a144fffdfc612c6e3de802261cc85c}{set\+\_\+up\+\_\+sponge\+\_\+ml\+\_\+density}} (sp\+\_\+val, G, CS, sp\+\_\+val\+\_\+i\+\_\+mean)
\begin{DoxyCompactList}\small\item\em This subroutine stores the reference value for mixed layer density. It is handled differently from other values because it is only used in determining which layers can be inflated. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__sponge_a0b8b22a1b577bdcf336c8d22b85b45d7}{apply\+\_\+sponge}} (h, dt, G, GV, US, ea, eb, CS, Rcv\+\_\+ml)
\begin{DoxyCompactList}\small\item\em This subroutine applies damping to the layers thicknesses, mixed layer buoyancy, and a variety of tracers for every column where there is damping. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__sponge_a9b62e032925716da3a7b099364ddd720}{sponge\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em This call deallocates any memory in the sponge control structure. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__sponge_a0b8b22a1b577bdcf336c8d22b85b45d7}\label{namespacemom__sponge_a0b8b22a1b577bdcf336c8d22b85b45d7}} 
\index{mom\_sponge@{mom\_sponge}!apply\_sponge@{apply\_sponge}}
\index{apply\_sponge@{apply\_sponge}!mom\_sponge@{mom\_sponge}}
\doxysubsubsection{\texorpdfstring{apply\_sponge()}{apply\_sponge()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+sponge\+::apply\+\_\+sponge (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{h,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{ea,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{eb,  }\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(inout), optional}]{Rcv\+\_\+ml }\end{DoxyParamCaption})}



This subroutine applies damping to the layers thicknesses, mixed layer buoyancy, and a variety of tracers for every column where there is damping. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\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,out}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time covered by this call \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em ea} & An array to which the amount of fluid entrained \\
\hline
\mbox{\texttt{ in,out}}  & {\em eb} & An array to which the amount of fluid entrained \\
\hline
 & {\em cs} & A pointer to the control structure for this module that is set by a previous call to initialize\+\_\+sponge. \\
\hline
\mbox{\texttt{ in,out}}  & {\em rcv\+\_\+ml} & The coordinate density of the mixed layer \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 324 of file M\+O\+M\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{324   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< The ocean's grid structure}}
\DoxyCodeLine{325   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< The ocean's vertical grid structure}}
\DoxyCodeLine{326   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{327 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{328                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{329 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< The amount of time covered by this call [T \string~> s].}}
\DoxyCodeLine{330 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{331                            \textcolor{keywordtype}{intent(inout)} :: ea\textcolor{comment}{  !< An array to which the amount of fluid entrained}}
\DoxyCodeLine{332 \textcolor{comment}{                                                !! from the layer above during this call will be}}
\DoxyCodeLine{333 \textcolor{comment}{                                                !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{334 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{335                            \textcolor{keywordtype}{intent(inout)} :: eb\textcolor{comment}{  !< An array to which the amount of fluid entrained}}
\DoxyCodeLine{336 \textcolor{comment}{                                                !! from the layer below during this call will be}}
\DoxyCodeLine{337 \textcolor{comment}{                                                !! added [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{338   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< A pointer to the control structure for this module}}
\DoxyCodeLine{339 \textcolor{comment}{                                                !! that is set by a previous call to initialize\_sponge.}}
\DoxyCodeLine{340 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{341                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: Rcv\_ml\textcolor{comment}{ !<  The coordinate density of the mixed layer [R \string~> kg m-\/3].}}
\DoxyCodeLine{342 }
\DoxyCodeLine{343 \textcolor{comment}{! This subroutine applies damping to the layers thicknesses, mixed}}
\DoxyCodeLine{344 \textcolor{comment}{! layer buoyancy, and a variety of tracers for every column where}}
\DoxyCodeLine{345 \textcolor{comment}{! there is damping.}}
\DoxyCodeLine{346 }
\DoxyCodeLine{347   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{348 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(G)+1)} :: \&}
\DoxyCodeLine{349     w\_int, \&       \textcolor{comment}{! Water moved upward across an interface within a timestep,}}
\DoxyCodeLine{350                    \textcolor{comment}{! [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{351     e\_d            \textcolor{comment}{! Interface heights that are dilated to have a value of 0}}
\DoxyCodeLine{352                    \textcolor{comment}{! at the surface [Z \string~> m].}}
\DoxyCodeLine{353 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G))} :: \&}
\DoxyCodeLine{354     eta\_anom, \&    \textcolor{comment}{! Anomalies in the interface height, relative to the i-\/mean}}
\DoxyCodeLine{355                    \textcolor{comment}{! target value [Z \string~> m].}}
\DoxyCodeLine{356     fld\_anom       \textcolor{comment}{! Anomalies in a tracer concentration, relative to the}}
\DoxyCodeLine{357                    \textcolor{comment}{! i-\/mean target value.}}
\DoxyCodeLine{358 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZJ\_(G), SZK\_(G)+1)} :: \&}
\DoxyCodeLine{359     eta\_mean\_anom  \textcolor{comment}{! The i-\/mean interface height anomalies [Z \string~> m].}}
\DoxyCodeLine{360 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: \&}
\DoxyCodeLine{361     fld\_mean\_anom  \textcolor{comment}{! THe i-\/mean tracer concentration anomalies.}}
\DoxyCodeLine{362 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZK\_(G)+1)} :: \&}
\DoxyCodeLine{363     h\_above, \&     \textcolor{comment}{! The total thickness above an interface [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{364     h\_below        \textcolor{comment}{! The total thickness below an interface [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{365 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G))} :: \&}
\DoxyCodeLine{366     dilate         \textcolor{comment}{! A nondimensional factor by which to dilate layers to}}
\DoxyCodeLine{367                    \textcolor{comment}{! give 0 at the surface [nondim].}}
\DoxyCodeLine{368 }
\DoxyCodeLine{369 \textcolor{keywordtype}{  real} :: e(SZK\_(G)+1)  \textcolor{comment}{! The interface heights [Z \string~> m], usually negative.}}
\DoxyCodeLine{370 \textcolor{keywordtype}{  real} :: e0       \textcolor{comment}{! The height of the free surface [Z \string~> m].}}
\DoxyCodeLine{371 \textcolor{keywordtype}{  real} :: e\_str    \textcolor{comment}{! A nondimensional amount by which the reference}}
\DoxyCodeLine{372                    \textcolor{comment}{! profile must be stretched for the free surfaces}}
\DoxyCodeLine{373                    \textcolor{comment}{! heights in the two profiles to agree.}}
\DoxyCodeLine{374 \textcolor{keywordtype}{  real} :: w        \textcolor{comment}{! The thickness of water moving upward through an}}
\DoxyCodeLine{375                    \textcolor{comment}{! interface within 1 timestep [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{376 \textcolor{keywordtype}{  real} :: wm       \textcolor{comment}{! wm is w if w is negative and 0 otherwise [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{377 \textcolor{keywordtype}{  real} :: wb       \textcolor{comment}{! w at the interface below a layer [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{378 \textcolor{keywordtype}{  real} :: wpb      \textcolor{comment}{! wpb is wb if wb is positive and 0 otherwise [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{379 \textcolor{keywordtype}{  real} :: ea\_k, eb\_k \textcolor{comment}{! [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{380 \textcolor{keywordtype}{  real} :: damp     \textcolor{comment}{! The timestep times the local damping  coefficient [nondim].}}
\DoxyCodeLine{381 \textcolor{keywordtype}{  real} :: I1pdamp  \textcolor{comment}{! I1pdamp is 1/(1 + damp). [nondim]}}
\DoxyCodeLine{382 \textcolor{keywordtype}{  real} :: damp\_1pdamp \textcolor{comment}{! damp\_1pdamp is damp/(1 + damp). [nondim]}}
\DoxyCodeLine{383 \textcolor{keywordtype}{  real} :: Idt      \textcolor{comment}{! 1.0/dt times a height unit conversion factor [m H-\/1 T-\/1 \string~> s-\/1 or m3 kg-\/1 s-\/1].}}
\DoxyCodeLine{384   \textcolor{keywordtype}{integer} :: c, m, nkmb, i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{385   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{386 }
\DoxyCodeLine{387   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{388   \textcolor{keywordflow}{if} (cs\%bulkmixedlayer) nkmb = gv\%nk\_rho\_varies}
\DoxyCodeLine{389   \textcolor{keywordflow}{if} (cs\%bulkmixedlayer .and. (.not.\textcolor{keyword}{present}(rcv\_ml))) \&}
\DoxyCodeLine{390     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Rml must be provided to apply\_sponge when using "}//\&}
\DoxyCodeLine{391                            \textcolor{stringliteral}{"a bulk mixed layer."})}
\DoxyCodeLine{392 }
\DoxyCodeLine{393   \textcolor{keywordflow}{if} ((cs\%id\_w\_sponge > 0) .or. cs\%do\_i\_mean\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{394     \textcolor{keywordflow}{do} k=1,nz+1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{395       w\_int(i,j,k) = 0.0}
\DoxyCodeLine{396 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{397 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{398 }
\DoxyCodeLine{399   \textcolor{keywordflow}{if} (cs\%do\_i\_mean\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{400     \textcolor{comment}{! Apply forcing to restore the zonal-\/mean properties to prescribed values.}}
\DoxyCodeLine{401 }
\DoxyCodeLine{402     \textcolor{keywordflow}{if} (cs\%bulkmixedlayer) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"apply\_sponge is not yet set up to "}//\&}
\DoxyCodeLine{403                   \textcolor{stringliteral}{"work properly with i-\/mean sponges and a bulk mixed layer."})}
\DoxyCodeLine{404 }
\DoxyCodeLine{405     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; e\_d(i,j,nz+1) = -\/g\%bathyT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{406     \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{407       e\_d(i,j,k) = e\_d(i,j,k+1) + h(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{408 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{409     \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{410       \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{411         dilate(i) = g\%bathyT(i,j) / (e\_d(i,j,1) + g\%bathyT(i,j))}
\DoxyCodeLine{412 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{413       \textcolor{keywordflow}{do} k=1,nz+1 ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{414         e\_d(i,j,k) = dilate(i) * (e\_d(i,j,k) + g\%bathyT(i,j)) -\/ g\%bathyT(i,j)}
\DoxyCodeLine{415 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{416 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{417 }
\DoxyCodeLine{418     \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{419       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{420         eta\_anom(i,j) = e\_d(i,j,k) -\/ cs\%Ref\_eta\_im(j,k)}
\DoxyCodeLine{421         \textcolor{keywordflow}{if} (cs\%Ref\_eta\_im(j,k) < -\/g\%bathyT(i,j)) eta\_anom(i,j) = 0.0}
\DoxyCodeLine{422 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{423       \textcolor{keyword}{call }global\_i\_mean(eta\_anom(:,:), eta\_mean\_anom(:,k), g, tmp\_scale=us\%Z\_to\_m)}
\DoxyCodeLine{424 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{425 }
\DoxyCodeLine{426     \textcolor{keywordflow}{if} (cs\%fldno > 0) \textcolor{keyword}{allocate}(fld\_mean\_anom(g\%isd:g\%ied,nz,cs\%fldno))}
\DoxyCodeLine{427     \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{428       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{429         fld\_anom(i,j) = cs\%var(m)\%p(i,j,k) -\/ cs\%Ref\_val\_im(m)\%p(j,k)}
\DoxyCodeLine{430 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{431       \textcolor{keyword}{call }global\_i\_mean(fld\_anom(:,:), fld\_mean\_anom(:,k,m), g, h(:,:,k))}
\DoxyCodeLine{432 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{433 }
\DoxyCodeLine{434     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{if} (cs\%Iresttime\_im(j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{435       damp = dt * cs\%Iresttime\_im(j) ; damp\_1pdamp = damp / (1.0 + damp)}
\DoxyCodeLine{436 }
\DoxyCodeLine{437       \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{438         h\_above(i,1) = 0.0 ; h\_below(i,nz+1) = 0.0}
\DoxyCodeLine{439 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{440       \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{441         h\_below(i,k) = h\_below(i,k+1) + max(h(i,j,k)-\/gv\%Angstrom\_H, 0.0)}
\DoxyCodeLine{442 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{443       \textcolor{keywordflow}{do} k=2,nz+1 ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{444         h\_above(i,k) = h\_above(i,k-\/1) + max(h(i,j,k-\/1)-\/gv\%Angstrom\_H, 0.0)}
\DoxyCodeLine{445 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{446       \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{447         \textcolor{comment}{! w is positive for an upward (lightward) flux of mass, resulting}}
\DoxyCodeLine{448         \textcolor{comment}{! in the downward movement of an interface.}}
\DoxyCodeLine{449         w = damp\_1pdamp * eta\_mean\_anom(j,k) * gv\%Z\_to\_H}
\DoxyCodeLine{450         \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{451           \textcolor{keywordflow}{if} (w > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{452             w\_int(i,j,k) = min(w, h\_below(i,k))}
\DoxyCodeLine{453             eb(i,j,k-\/1) = eb(i,j,k-\/1) + w\_int(i,j,k)}
\DoxyCodeLine{454           \textcolor{keywordflow}{else}}
\DoxyCodeLine{455             w\_int(i,j,k) = max(w, -\/h\_above(i,k))}
\DoxyCodeLine{456             ea(i,j,k) = ea(i,j,k) -\/ w\_int(i,j,k)}
\DoxyCodeLine{457 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{458 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{459 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{460       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{461         ea\_k = max(0.0, -\/w\_int(i,j,k))}
\DoxyCodeLine{462         eb\_k = max(0.0, w\_int(i,j,k+1))}
\DoxyCodeLine{463         \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{464           cs\%var(m)\%p(i,j,k) = (h(i,j,k)*cs\%var(m)\%p(i,j,k) + \&}
\DoxyCodeLine{465               cs\%Ref\_val\_im(m)\%p(j,k) * (ea\_k + eb\_k)) / \&}
\DoxyCodeLine{466                      (h(i,j,k) + (ea\_k + eb\_k)) -\/ \&}
\DoxyCodeLine{467               damp\_1pdamp * fld\_mean\_anom(j,k,m)}
\DoxyCodeLine{468 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{469 }
\DoxyCodeLine{470         h(i,j,k) = max(h(i,j,k) + (w\_int(i,j,k+1) -\/ w\_int(i,j,k)), \&}
\DoxyCodeLine{471                        min(h(i,j,k), gv\%Angstrom\_H))}
\DoxyCodeLine{472 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{473 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{474 }
\DoxyCodeLine{475     \textcolor{keywordflow}{if} (cs\%fldno > 0) \textcolor{keyword}{deallocate}(fld\_mean\_anom)}
\DoxyCodeLine{476 }
\DoxyCodeLine{477 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{478 }
\DoxyCodeLine{479   \textcolor{keywordflow}{do} c=1,cs\%num\_col}
\DoxyCodeLine{480 \textcolor{comment}{! c is an index for the next 3 lines but a multiplier for the rest of the loop}}
\DoxyCodeLine{481 \textcolor{comment}{! Therefore we use c as per C code and increment the index where necessary.}}
\DoxyCodeLine{482     i = cs\%col\_i(c) ; j = cs\%col\_j(c)}
\DoxyCodeLine{483     damp = dt * cs\%Iresttime\_col(c)}
\DoxyCodeLine{484 }
\DoxyCodeLine{485     e(1) = 0.0 ; e0 = 0.0}
\DoxyCodeLine{486     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{487       e(k+1) = e(k) -\/ h(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{488 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{489     e\_str = e(nz+1) / cs\%Ref\_eta(nz+1,c)}
\DoxyCodeLine{490 }
\DoxyCodeLine{491     \textcolor{keywordflow}{if} ( cs\%bulkmixedlayer ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{492       i1pdamp = 1.0 / (1.0 + damp)}
\DoxyCodeLine{493       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Rcv\_ml\_ref)) \&}
\DoxyCodeLine{494         rcv\_ml(i,j) = i1pdamp * (rcv\_ml(i,j) + cs\%Rcv\_ml\_ref(c)*damp)}
\DoxyCodeLine{495       \textcolor{keywordflow}{do} k=1,nkmb}
\DoxyCodeLine{496         \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{497           cs\%var(m)\%p(i,j,k) = i1pdamp * \&}
\DoxyCodeLine{498               (cs\%var(m)\%p(i,j,k) + cs\%Ref\_val(m)\%p(k,c)*damp)}
\DoxyCodeLine{499 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{500 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{501 }
\DoxyCodeLine{502       wpb = 0.0; wb = 0.0}
\DoxyCodeLine{503       \textcolor{keywordflow}{do} k=nz,nkmb+1,-\/1}
\DoxyCodeLine{504         \textcolor{keywordflow}{if} (gv\%Rlay(k) > rcv\_ml(i,j)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{505           w = min((((e(k)-\/e0) -\/ e\_str*cs\%Ref\_eta(k,c)) * damp)*gv\%Z\_to\_H, \&}
\DoxyCodeLine{506                     ((wb + h(i,j,k)) -\/ gv\%Angstrom\_H))}
\DoxyCodeLine{507           wm = 0.5*(w-\/abs(w))}
\DoxyCodeLine{508           \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{509             cs\%var(m)\%p(i,j,k) = (h(i,j,k)*cs\%var(m)\%p(i,j,k) + \&}
\DoxyCodeLine{510                      cs\%Ref\_val(m)\%p(k,c)*(damp*h(i,j,k) + (wpb -\/ wm))) / \&}
\DoxyCodeLine{511                      (h(i,j,k)*(1.0 + damp) + (wpb -\/ wm))}
\DoxyCodeLine{512 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{513         \textcolor{keywordflow}{else}}
\DoxyCodeLine{514           \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{515             cs\%var(m)\%p(i,j,k) = i1pdamp * \&}
\DoxyCodeLine{516               (cs\%var(m)\%p(i,j,k) + cs\%Ref\_val(m)\%p(k,c)*damp)}
\DoxyCodeLine{517 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{518           w = wb + (h(i,j,k) -\/ gv\%Angstrom\_H)}
\DoxyCodeLine{519           wm = 0.5*(w-\/abs(w))}
\DoxyCodeLine{520 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{521         eb(i,j,k) = eb(i,j,k) + wpb}
\DoxyCodeLine{522         ea(i,j,k) = ea(i,j,k) -\/ wm}
\DoxyCodeLine{523         h(i,j,k)  = h(i,j,k)  + (wb -\/ w)}
\DoxyCodeLine{524         wb = w}
\DoxyCodeLine{525         wpb = w -\/ wm}
\DoxyCodeLine{526 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{527 }
\DoxyCodeLine{528       \textcolor{keywordflow}{if} (wb < 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{529         \textcolor{keywordflow}{do} k=nkmb,1,-\/1}
\DoxyCodeLine{530           w = min((wb + (h(i,j,k) -\/ gv\%Angstrom\_H)),0.0)}
\DoxyCodeLine{531           h(i,j,k)  = h(i,j,k)  + (wb -\/ w)}
\DoxyCodeLine{532           ea(i,j,k) = ea(i,j,k) -\/ w}
\DoxyCodeLine{533           wb = w}
\DoxyCodeLine{534 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{535       \textcolor{keywordflow}{else}}
\DoxyCodeLine{536         w = wb}
\DoxyCodeLine{537         \textcolor{keywordflow}{do} k=gv\%nkml,nkmb}
\DoxyCodeLine{538           eb(i,j,k) = eb(i,j,k) + w}
\DoxyCodeLine{539 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{540 }
\DoxyCodeLine{541         k = gv\%nkml}
\DoxyCodeLine{542         h(i,j,k) = h(i,j,k) + w}
\DoxyCodeLine{543         \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{544           cs\%var(m)\%p(i,j,k) = (cs\%var(m)\%p(i,j,k)*h(i,j,k) + \&}
\DoxyCodeLine{545                                 cs\%Ref\_val(m)\%p(k,c)*w) / (h(i,j,k) + w)}
\DoxyCodeLine{546 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{547 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{548 }
\DoxyCodeLine{549       \textcolor{keywordflow}{do} k=1,nkmb}
\DoxyCodeLine{550         \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{551           cs\%var(m)\%p(i,j,k) = i1pdamp * \&}
\DoxyCodeLine{552               (cs\%var(m)\%p(i,j,k) + cs\%Ref\_val(m)\%p(gv\%nkml,c)*damp)}
\DoxyCodeLine{553 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{554 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{555 }
\DoxyCodeLine{556     \textcolor{keywordflow}{else}                                          \textcolor{comment}{! not BULKMIXEDLAYER}}
\DoxyCodeLine{557 }
\DoxyCodeLine{558       wpb = 0.0}
\DoxyCodeLine{559       wb = 0.0}
\DoxyCodeLine{560       \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{561         w = min((((e(k)-\/e0) -\/ e\_str*cs\%Ref\_eta(k,c)) * damp)*gv\%Z\_to\_H, \&}
\DoxyCodeLine{562                   ((wb + h(i,j,k)) -\/ gv\%Angstrom\_H))}
\DoxyCodeLine{563         wm = 0.5*(w -\/ abs(w))}
\DoxyCodeLine{564         \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{565           cs\%var(m)\%p(i,j,k) = (h(i,j,k)*cs\%var(m)\%p(i,j,k) + \&}
\DoxyCodeLine{566               cs\%Ref\_val(m)\%p(k,c) * (damp*h(i,j,k) + (wpb -\/ wm))) / \&}
\DoxyCodeLine{567                      (h(i,j,k)*(1.0 + damp) + (wpb -\/ wm))}
\DoxyCodeLine{568 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{569         eb(i,j,k) = eb(i,j,k) + wpb}
\DoxyCodeLine{570         ea(i,j,k) = ea(i,j,k) -\/ wm}
\DoxyCodeLine{571         h(i,j,k)  = h(i,j,k)  + (wb -\/ w)}
\DoxyCodeLine{572         wb = w}
\DoxyCodeLine{573         wpb = w -\/ wm}
\DoxyCodeLine{574 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{575 }
\DoxyCodeLine{576 \textcolor{keywordflow}{    endif}                                         \textcolor{comment}{! end BULKMIXEDLAYER}}
\DoxyCodeLine{577 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end of c loop}}
\DoxyCodeLine{578 }
\DoxyCodeLine{579   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%diag)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (query\_averaging\_enabled(cs\%diag)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{580     \textcolor{keywordflow}{if} (cs\%id\_w\_sponge > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{581       idt = gv\%H\_to\_m / dt  \textcolor{comment}{! Do any height unit conversion here for efficiency.}}
\DoxyCodeLine{582       \textcolor{keywordflow}{do} k=1,nz+1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{583         w\_int(i,j,k) = w\_int(i,j,k) * idt \textcolor{comment}{! Scale values by clobbering array since it is local}}
\DoxyCodeLine{584 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{585       \textcolor{keyword}{call }post\_data(cs\%id\_w\_sponge, w\_int(:,:,:), cs\%diag)}
\DoxyCodeLine{586 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{587 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{588 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__sponge_ad4b2c0efb73f14a43936a11b39027f57}\label{namespacemom__sponge_ad4b2c0efb73f14a43936a11b39027f57}} 
\index{mom\_sponge@{mom\_sponge}!init\_sponge\_diags@{init\_sponge\_diags}}
\index{init\_sponge\_diags@{init\_sponge\_diags}!mom\_sponge@{mom\_sponge}}
\doxysubsubsection{\texorpdfstring{init\_sponge\_diags()}{init\_sponge\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+sponge\+::init\+\_\+sponge\+\_\+diags (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\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(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine sets up diagnostics for the sponges. It is separate from initialize\+\_\+sponge because it requires fields that are not readily available where initialize\+\_\+sponge is called. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\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,out}}  & {\em diag} & A structure that is used to regulate diagnostic output \\
\hline
 & {\em cs} & A pointer to the control structure for this module that is set by a previous call to initialize\+\_\+sponge. \\
\hline
\end{DoxyParams}


Definition at line 194 of file M\+O\+M\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{194   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{195   \textcolor{keywordtype}{type}(ocean\_grid\_type),         \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{196   \textcolor{keywordtype}{type}(verticalGrid\_type),       \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{197   \textcolor{keywordtype}{type}(unit\_scale\_type),         \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{198   \textcolor{keywordtype}{type}(diag\_ctrl),       \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< A structure that is used to regulate diagnostic output}}
\DoxyCodeLine{199   \textcolor{keywordtype}{type}(sponge\_CS),               \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< A pointer to the control structure for this module that}}
\DoxyCodeLine{200 \textcolor{comment}{                                                       !! is set by a previous call to initialize\_sponge.}}
\DoxyCodeLine{201 }
\DoxyCodeLine{202   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{203 }
\DoxyCodeLine{204   cs\%diag => diag}
\DoxyCodeLine{205   cs\%id\_w\_sponge = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'w\_sponge'}, diag\%axesTi, \&}
\DoxyCodeLine{206       time, \textcolor{stringliteral}{'The diapycnal motion due to the sponges'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%s\_to\_T)}
\DoxyCodeLine{207 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__sponge_a2c3c6a03d98c13221031af667b42428d}\label{namespacemom__sponge_a2c3c6a03d98c13221031af667b42428d}} 
\index{mom\_sponge@{mom\_sponge}!initialize\_sponge@{initialize\_sponge}}
\index{initialize\_sponge@{initialize\_sponge}!mom\_sponge@{mom\_sponge}}
\doxysubsubsection{\texorpdfstring{initialize\_sponge()}{initialize\_sponge()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+sponge\+::initialize\+\_\+sponge (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{Iresttime,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)+1), intent(in)}]{int\+\_\+height,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{CS,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension( g \%jsd\+: g \%jed), intent(in), optional}]{Iresttime\+\_\+i\+\_\+mean,  }\item[{real, dimension( g \%jsd\+: g \%jed, g \%ke+1), intent(in), optional}]{int\+\_\+height\+\_\+i\+\_\+mean }\end{DoxyParamCaption})}



This subroutine determines the number of points which are within sponges in this computational domain. Only points that have positive values of Iresttime and which mask2dT indicates are ocean points are included in the sponges. It also stores the target interface heights. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em iresttime} & The inverse of the restoring time \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em int\+\_\+height} & The interface heights to damp back toward \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\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
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em iresttime\+\_\+i\+\_\+mean} & The inverse of the restoring time for \\
\hline
\mbox{\texttt{ in}}  & {\em int\+\_\+height\+\_\+i\+\_\+mean} & The interface heights toward which to \\
\hline
\end{DoxyParams}


Definition at line 90 of file M\+O\+M\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{90   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{          !< The ocean's grid structure}}
\DoxyCodeLine{91 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{92                            \textcolor{keywordtype}{intent(in)} :: Iresttime\textcolor{comment}{  !< The inverse of the restoring time [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{93 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \&}
\DoxyCodeLine{94                            \textcolor{keywordtype}{intent(in)} :: int\_height\textcolor{comment}{ !< The interface heights to damp back toward [Z \string~> m].}}
\DoxyCodeLine{95   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{96   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< A pointer that is set to point to the control}}
\DoxyCodeLine{97 \textcolor{comment}{                                                    !! structure for this module}}
\DoxyCodeLine{98   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{         !< The ocean's vertical grid structure}}
\DoxyCodeLine{99 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZJ\_(G))}, \&}
\DoxyCodeLine{100                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: Iresttime\_i\_mean\textcolor{comment}{ !< The inverse of the restoring time for}}
\DoxyCodeLine{101 \textcolor{comment}{                                                          !! the zonal mean properties [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{102 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZJ\_(G),SZK\_(G)+1)}, \&}
\DoxyCodeLine{103                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: int\_height\_i\_mean\textcolor{comment}{ !< The interface heights toward which to}}
\DoxyCodeLine{104 \textcolor{comment}{                                                           !! damp the zonal mean heights [Z \string~> m].}}
\DoxyCodeLine{105 }
\DoxyCodeLine{106 }
\DoxyCodeLine{107 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{108 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{109 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_sponge"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{110   \textcolor{keywordtype}{logical} :: use\_sponge}
\DoxyCodeLine{111   \textcolor{keywordtype}{integer} :: i, j, k, col, total\_sponge\_cols}
\DoxyCodeLine{112 }
\DoxyCodeLine{113   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{114     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_sponge called with an associated "}// \&}
\DoxyCodeLine{115                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{116     \textcolor{keywordflow}{return}}
\DoxyCodeLine{117 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{118 }
\DoxyCodeLine{119 \textcolor{comment}{! Set default, read and log parameters}}
\DoxyCodeLine{120   \textcolor{keyword}{call }log\_version(param\_file, mdl, version)}
\DoxyCodeLine{121   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, use\_sponge, \&}
\DoxyCodeLine{122                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//\&}
\DoxyCodeLine{123                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//\&}
\DoxyCodeLine{124                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)}
\DoxyCodeLine{125 }
\DoxyCodeLine{126   \textcolor{keywordflow}{if} (.not.use\_sponge) \textcolor{keywordflow}{return}}
\DoxyCodeLine{127   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{128 }
\DoxyCodeLine{129   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(iresttime\_i\_mean) .neqv. \textcolor{keyword}{present}(int\_height\_i\_mean)) \&}
\DoxyCodeLine{130     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"initialize\_sponge:  The optional arguments \(\backslash\)n"}//\&}
\DoxyCodeLine{131            \textcolor{stringliteral}{"Iresttime\_i\_mean and int\_height\_i\_mean must both be present \(\backslash\)n"}//\&}
\DoxyCodeLine{132            \textcolor{stringliteral}{"if either one is."})}
\DoxyCodeLine{133 }
\DoxyCodeLine{134   cs\%do\_i\_mean\_sponge = \textcolor{keyword}{present}(iresttime\_i\_mean)}
\DoxyCodeLine{135 }
\DoxyCodeLine{136   cs\%nz = g\%ke}
\DoxyCodeLine{137 \textcolor{comment}{!  CS\%isc = G\%isc ; CS\%iec = G\%iec ; CS\%jsc = G\%jsc ; CS\%jec = G\%jec}}
\DoxyCodeLine{138 \textcolor{comment}{!  CS\%isd = G\%isd ; CS\%ied = G\%ied ; CS\%jsd = G\%jsd ; CS\%jed = G\%jed}}
\DoxyCodeLine{139   \textcolor{comment}{! CS\%bulkmixedlayer may be set later via a call to set\_up\_sponge\_ML\_density.}}
\DoxyCodeLine{140   cs\%bulkmixedlayer = .false.}
\DoxyCodeLine{141 }
\DoxyCodeLine{142   cs\%num\_col = 0 ; cs\%fldno = 0}
\DoxyCodeLine{143   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{144     \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g\%mask2dT(i,j)>0)) \&}
\DoxyCodeLine{145       cs\%num\_col = cs\%num\_col + 1}
\DoxyCodeLine{146 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{147 }
\DoxyCodeLine{148   \textcolor{keywordflow}{if} (cs\%num\_col > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{149 }
\DoxyCodeLine{150     \textcolor{keyword}{allocate}(cs\%Iresttime\_col(cs\%num\_col)) ; cs\%Iresttime\_col = 0.0}
\DoxyCodeLine{151     \textcolor{keyword}{allocate}(cs\%col\_i(cs\%num\_col))         ; cs\%col\_i = 0}
\DoxyCodeLine{152     \textcolor{keyword}{allocate}(cs\%col\_j(cs\%num\_col))         ; cs\%col\_j = 0}
\DoxyCodeLine{153 }
\DoxyCodeLine{154     col = 1}
\DoxyCodeLine{155     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{156       \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g\%mask2dT(i,j)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{157         cs\%col\_i(col) = i ; cs\%col\_j(col) = j}
\DoxyCodeLine{158         cs\%Iresttime\_col(col) = iresttime(i,j)}
\DoxyCodeLine{159         col = col +1}
\DoxyCodeLine{160 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{161 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{162 }
\DoxyCodeLine{163     \textcolor{keyword}{allocate}(cs\%Ref\_eta(cs\%nz+1,cs\%num\_col))}
\DoxyCodeLine{164     \textcolor{keywordflow}{do} col=1,cs\%num\_col ; \textcolor{keywordflow}{do} k=1,cs\%nz+1}
\DoxyCodeLine{165       cs\%Ref\_eta(k,col) = int\_height(cs\%col\_i(col),cs\%col\_j(col),k)}
\DoxyCodeLine{166 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{167 }
\DoxyCodeLine{168 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{169 }
\DoxyCodeLine{170   \textcolor{keywordflow}{if} (cs\%do\_i\_mean\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{171     \textcolor{keyword}{allocate}(cs\%Iresttime\_im(g\%jsd:g\%jed)) ; cs\%Iresttime\_im(:) = 0.0}
\DoxyCodeLine{172     \textcolor{keyword}{allocate}(cs\%Ref\_eta\_im(g\%jsd:g\%jed,g\%ke+1)) ; cs\%Ref\_eta\_im(:,:) = 0.0}
\DoxyCodeLine{173 }
\DoxyCodeLine{174     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec}
\DoxyCodeLine{175       cs\%Iresttime\_im(j) = iresttime\_i\_mean(j)}
\DoxyCodeLine{176 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{177     \textcolor{keywordflow}{do} k=1,cs\%nz+1 ; \textcolor{keywordflow}{do} j=g\%jsc,g\%jec}
\DoxyCodeLine{178       cs\%Ref\_eta\_im(j,k) = int\_height\_i\_mean(j,k)}
\DoxyCodeLine{179 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{180 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{181 }
\DoxyCodeLine{182   total\_sponge\_cols = cs\%num\_col}
\DoxyCodeLine{183   \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols)}
\DoxyCodeLine{184 }
\DoxyCodeLine{185   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns"}, total\_sponge\_cols, \&}
\DoxyCodeLine{186                  \textcolor{stringliteral}{"The total number of columns where sponges are applied."})}
\DoxyCodeLine{187 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__sponge_af3da4a8b352c4130919d7bfedf1a5a3e}\label{namespacemom__sponge_af3da4a8b352c4130919d7bfedf1a5a3e}} 
\index{mom\_sponge@{mom\_sponge}!set\_up\_sponge\_field@{set\_up\_sponge\_field}}
\index{set\_up\_sponge\_field@{set\_up\_sponge\_field}!mom\_sponge@{mom\_sponge}}
\doxysubsubsection{\texorpdfstring{set\_up\_sponge\_field()}{set\_up\_sponge\_field()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+sponge\+::set\+\_\+up\+\_\+sponge\+\_\+field (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{sp\+\_\+val,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in), target}]{f\+\_\+ptr,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{integer, intent(in)}]{nlay,  }\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension( g \%jsd\+: g \%jed, g \%ke), intent(in), optional}]{sp\+\_\+val\+\_\+i\+\_\+mean }\end{DoxyParamCaption})}



This subroutine stores the reference profile for the variable whose address is given by f\+\_\+ptr. nlay is the number of layers in this variable. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em sp\+\_\+val} & The reference profiles of the quantity being registered. \\
\hline
\mbox{\texttt{ in}}  & {\em f\+\_\+ptr} & a pointer to the field which will be damped \\
\hline
\mbox{\texttt{ in}}  & {\em nlay} & the number of layers in this quantity \\
\hline
 & {\em cs} & A pointer to the control structure for this module that is set by a previous call to initialize\+\_\+sponge. \\
\hline
\mbox{\texttt{ in}}  & {\em sp\+\_\+val\+\_\+i\+\_\+mean} & The i-\/mean reference value for \\
\hline
\end{DoxyParams}


Definition at line 214 of file M\+O\+M\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{214   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{      !< The ocean's grid structure}}
\DoxyCodeLine{215 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{216                          \textcolor{keywordtype}{intent(in)} :: sp\_val\textcolor{comment}{ !< The reference profiles of the quantity being registered.}}
\DoxyCodeLine{217 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{218                  \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: f\_ptr\textcolor{comment}{  !< a pointer to the field which will be damped}}
\DoxyCodeLine{219   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: nlay\textcolor{comment}{   !< the number of layers in this quantity}}
\DoxyCodeLine{220   \textcolor{keywordtype}{type}(sponge\_CS),       \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{     !< A pointer to the control structure for this module that}}
\DoxyCodeLine{221 \textcolor{comment}{                                              !! is set by a previous call to initialize\_sponge.}}
\DoxyCodeLine{222 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZJ\_(G),SZK\_(G))},\&}
\DoxyCodeLine{223                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: sp\_val\_i\_mean\textcolor{comment}{ !< The i-\/mean reference value for}}
\DoxyCodeLine{224 \textcolor{comment}{                                              !! this field with i-\/mean sponges.}}
\DoxyCodeLine{225 }
\DoxyCodeLine{226   \textcolor{keywordtype}{integer} :: j, k, col}
\DoxyCodeLine{227   \textcolor{keywordtype}{character(len=256)} :: mesg \textcolor{comment}{! String for error messages}}
\DoxyCodeLine{228 }
\DoxyCodeLine{229   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{230 }
\DoxyCodeLine{231   cs\%fldno = cs\%fldno + 1}
\DoxyCodeLine{232 }
\DoxyCodeLine{233   \textcolor{keywordflow}{if} (cs\%fldno > max\_fields\_) \textcolor{keywordflow}{then}}
\DoxyCodeLine{234     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Increase MAX\_FIELDS\_ to at least ",I3," in MOM\_memory.h or decrease \&}}
\DoxyCodeLine{235 \textcolor{stringliteral}{}\textcolor{stringliteral}{           \&the number of fields to be damped in the call to \&}}
\DoxyCodeLine{236 \textcolor{stringliteral}{}\textcolor{stringliteral}{           \&initialize\_sponge." )'}) cs\%fldno}
\DoxyCodeLine{237     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"set\_up\_sponge\_field: "}//mesg)}
\DoxyCodeLine{238 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{239 }
\DoxyCodeLine{240   \textcolor{keyword}{allocate}(cs\%Ref\_val(cs\%fldno)\%p(cs\%nz,cs\%num\_col))}
\DoxyCodeLine{241   cs\%Ref\_val(cs\%fldno)\%p(:,:) = 0.0}
\DoxyCodeLine{242   \textcolor{keywordflow}{do} col=1,cs\%num\_col}
\DoxyCodeLine{243     \textcolor{keywordflow}{do} k=1,nlay}
\DoxyCodeLine{244       cs\%Ref\_val(cs\%fldno)\%p(k,col) = sp\_val(cs\%col\_i(col),cs\%col\_j(col),k)}
\DoxyCodeLine{245 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{246     \textcolor{keywordflow}{do} k=nlay+1,cs\%nz}
\DoxyCodeLine{247       cs\%Ref\_val(cs\%fldno)\%p(k,col) = 0.0}
\DoxyCodeLine{248 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{249 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{250 }
\DoxyCodeLine{251   cs\%var(cs\%fldno)\%p => f\_ptr}
\DoxyCodeLine{252 }
\DoxyCodeLine{253   \textcolor{keywordflow}{if} (nlay/=cs\%nz) \textcolor{keywordflow}{then}}
\DoxyCodeLine{254     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Danger: Sponge reference fields require nz (",I3,") layers.\&}}
\DoxyCodeLine{255 \textcolor{stringliteral}{}\textcolor{stringliteral}{        \& A field with ",I3," layers was passed to set\_up\_sponge\_field.")'}) \&}
\DoxyCodeLine{256           cs\%nz, nlay}
\DoxyCodeLine{257     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"set\_up\_sponge\_field: "}//mesg)}
\DoxyCodeLine{258 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{259 }
\DoxyCodeLine{260   \textcolor{keywordflow}{if} (cs\%do\_i\_mean\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{261     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{present}(sp\_val\_i\_mean)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{262       \textcolor{stringliteral}{"set\_up\_sponge\_field: sp\_val\_i\_mean must be present with i-\/mean sponges."})}
\DoxyCodeLine{263 }
\DoxyCodeLine{264     \textcolor{keyword}{allocate}(cs\%Ref\_val\_im(cs\%fldno)\%p(cs\%jsd:cs\%jed,cs\%nz))}
\DoxyCodeLine{265     cs\%Ref\_val(cs\%fldno)\%p(:,:) = 0.0}
\DoxyCodeLine{266     \textcolor{keywordflow}{do} k=1,cs\%nz ; \textcolor{keywordflow}{do} j=cs\%jsc,cs\%jec}
\DoxyCodeLine{267       cs\%Ref\_val\_im(cs\%fldno)\%p(j,k) = sp\_val\_i\_mean(j,k)}
\DoxyCodeLine{268 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{269 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{270 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__sponge_ac5a144fffdfc612c6e3de802261cc85c}\label{namespacemom__sponge_ac5a144fffdfc612c6e3de802261cc85c}} 
\index{mom\_sponge@{mom\_sponge}!set\_up\_sponge\_ml\_density@{set\_up\_sponge\_ml\_density}}
\index{set\_up\_sponge\_ml\_density@{set\_up\_sponge\_ml\_density}!mom\_sponge@{mom\_sponge}}
\doxysubsubsection{\texorpdfstring{set\_up\_sponge\_ml\_density()}{set\_up\_sponge\_ml\_density()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+sponge\+::set\+\_\+up\+\_\+sponge\+\_\+ml\+\_\+density (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{sp\+\_\+val,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension(szj\+\_\+(g)), intent(in), optional}]{sp\+\_\+val\+\_\+i\+\_\+mean }\end{DoxyParamCaption})}



This subroutine stores the reference value for mixed layer density. It is handled differently from other values because it is only used in determining which layers can be inflated. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em sp\+\_\+val} & The reference values of the mixed layer density \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} \\
\hline
 & {\em cs} & A pointer to the control structure for this module that is set by a previous call to initialize\+\_\+sponge. \\
\hline
\mbox{\texttt{ in}}  & {\em sp\+\_\+val\+\_\+i\+\_\+mean} & the reference values of the zonal mean mixed \\
\hline
\end{DoxyParams}


Definition at line 277 of file M\+O\+M\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{277   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{278 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{279                          \textcolor{keywordtype}{intent(in)} :: sp\_val\textcolor{comment}{ !< The reference values of the mixed layer density [R \string~> kg m-\/3]}}
\DoxyCodeLine{280   \textcolor{keywordtype}{type}(sponge\_CS),       \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< A pointer to the control structure for this module that is}}
\DoxyCodeLine{281 \textcolor{comment}{                                            !! set by a previous call to initialize\_sponge.}}
\DoxyCodeLine{282 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZJ\_(G))}, \&}
\DoxyCodeLine{283                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: sp\_val\_i\_mean\textcolor{comment}{ !< the reference values of the zonal mean mixed}}
\DoxyCodeLine{284 \textcolor{comment}{                                            !! layer density [R \string~> kg m-\/3], for use if Iresttime\_i\_mean > 0.}}
\DoxyCodeLine{285 \textcolor{comment}{!   This subroutine stores the reference value for mixed layer density.  It is}}
\DoxyCodeLine{286 \textcolor{comment}{! handled differently from other values because it is only used in determining}}
\DoxyCodeLine{287 \textcolor{comment}{! which layers can be inflated.}}
\DoxyCodeLine{288 }
\DoxyCodeLine{289 \textcolor{comment}{! Arguments: sp\_val -\/ The reference values of the mixed layer density.}}
\DoxyCodeLine{290 \textcolor{comment}{!  (in/out)  CS -\/ A pointer to the control structure for this module that is}}
\DoxyCodeLine{291 \textcolor{comment}{!                 set by a previous call to initialize\_sponge.}}
\DoxyCodeLine{292 }
\DoxyCodeLine{293   \textcolor{keywordtype}{integer} :: j, col}
\DoxyCodeLine{294   \textcolor{keywordtype}{character(len=256)} :: mesg \textcolor{comment}{! String for error messages}}
\DoxyCodeLine{295 }
\DoxyCodeLine{296   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{297 }
\DoxyCodeLine{298   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Rcv\_ml\_ref)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{299     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"set\_up\_sponge\_ML\_density appears to have been "}//\&}
\DoxyCodeLine{300                            \textcolor{stringliteral}{"called twice."})}
\DoxyCodeLine{301 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{302 }
\DoxyCodeLine{303   cs\%bulkmixedlayer = .true.}
\DoxyCodeLine{304   \textcolor{keyword}{allocate}(cs\%Rcv\_ml\_ref(cs\%num\_col)) ; cs\%Rcv\_ml\_ref(:) = 0.0}
\DoxyCodeLine{305   \textcolor{keywordflow}{do} col=1,cs\%num\_col}
\DoxyCodeLine{306     cs\%Rcv\_ml\_ref(col) = sp\_val(cs\%col\_i(col),cs\%col\_j(col))}
\DoxyCodeLine{307 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{308 }
\DoxyCodeLine{309   \textcolor{keywordflow}{if} (cs\%do\_i\_mean\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{310     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{present}(sp\_val\_i\_mean)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{311       \textcolor{stringliteral}{"set\_up\_sponge\_field: sp\_val\_i\_mean must be present with i-\/mean sponges."})}
\DoxyCodeLine{312 }
\DoxyCodeLine{313     \textcolor{keyword}{allocate}(cs\%Rcv\_ml\_ref\_im(cs\%jsd:cs\%jed)) ; cs\%Rcv\_ml\_ref\_im(:) = 0.0}
\DoxyCodeLine{314     \textcolor{keywordflow}{do} j=cs\%jsc,cs\%jec}
\DoxyCodeLine{315       cs\%Rcv\_ml\_ref\_im(j) = sp\_val\_i\_mean(j)}
\DoxyCodeLine{316 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{317 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{318 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__sponge_a9b62e032925716da3a7b099364ddd720}\label{namespacemom__sponge_a9b62e032925716da3a7b099364ddd720}} 
\index{mom\_sponge@{mom\_sponge}!sponge\_end@{sponge\_end}}
\index{sponge\_end@{sponge\_end}!mom\_sponge@{mom\_sponge}}
\doxysubsubsection{\texorpdfstring{sponge\_end()}{sponge\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+sponge\+::sponge\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This call deallocates any memory in the sponge control structure. 


\begin{DoxyParams}{Parameters}
{\em cs} & A pointer to the control structure for this module that is set by a previous call to initialize\+\_\+sponge. \\
\hline
\end{DoxyParams}


Definition at line 593 of file M\+O\+M\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{593   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< A pointer to the control structure for this module}}
\DoxyCodeLine{594 \textcolor{comment}{                                              !! that is set by a previous call to initialize\_sponge.}}
\DoxyCodeLine{595   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{596 }
\DoxyCodeLine{597   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{598 }
\DoxyCodeLine{599   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_i)) \textcolor{keyword}{deallocate}(cs\%col\_i)}
\DoxyCodeLine{600   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_j)) \textcolor{keyword}{deallocate}(cs\%col\_j)}
\DoxyCodeLine{601 }
\DoxyCodeLine{602   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Iresttime\_col)) \textcolor{keyword}{deallocate}(cs\%Iresttime\_col)}
\DoxyCodeLine{603   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Rcv\_ml\_ref)) \textcolor{keyword}{deallocate}(cs\%Rcv\_ml\_ref)}
\DoxyCodeLine{604   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Ref\_eta)) \textcolor{keyword}{deallocate}(cs\%Ref\_eta)}
\DoxyCodeLine{605 }
\DoxyCodeLine{606   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Iresttime\_im)) \textcolor{keyword}{deallocate}(cs\%Iresttime\_im)}
\DoxyCodeLine{607   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Rcv\_ml\_ref\_im)) \textcolor{keyword}{deallocate}(cs\%Rcv\_ml\_ref\_im)}
\DoxyCodeLine{608   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Ref\_eta\_im)) \textcolor{keyword}{deallocate}(cs\%Ref\_eta\_im)}
\DoxyCodeLine{609 }
\DoxyCodeLine{610   \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{611     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Ref\_val(cs\%fldno)\%p)) \textcolor{keyword}{deallocate}(cs\%Ref\_val(cs\%fldno)\%p)}
\DoxyCodeLine{612     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Ref\_val\_im(cs\%fldno)\%p)) \&}
\DoxyCodeLine{613       \textcolor{keyword}{deallocate}(cs\%Ref\_val\_im(cs\%fldno)\%p)}
\DoxyCodeLine{614 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{615 }
\DoxyCodeLine{616   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{617 }

\end{DoxyCode}
