\hypertarget{namespacemom__ale__sponge}{}\doxysection{mom\+\_\+ale\+\_\+sponge Module Reference}
\label{namespacemom__ale__sponge}\index{mom\_ale\_sponge@{mom\_ale\_sponge}}


\doxysubsection{Detailed Description}
This module contains the routines used to apply sponge layers when using the A\+LE mode. 

Applying sponges requires the following\+:
\begin{DoxyEnumerate}
\item initialize\+\_\+\+A\+L\+E\+\_\+sponge
\item set\+\_\+up\+\_\+\+A\+L\+E\+\_\+sponge\+\_\+field (tracers) and set\+\_\+up\+\_\+\+A\+L\+E\+\_\+sponge\+\_\+vel\+\_\+field (vel)
\item apply\+\_\+\+A\+L\+E\+\_\+sponge
\item init\+\_\+\+A\+L\+E\+\_\+sponge\+\_\+diags (not being used for now)
\item A\+L\+E\+\_\+sponge\+\_\+end (not being used for now) 
\end{DoxyEnumerate}\doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em A\+LE sponge control structure. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__ale__sponge_1_1initialize__ale__sponge}{initialize\+\_\+ale\+\_\+sponge}}
\begin{DoxyCompactList}\small\item\em Ddetermine the number of points which are within sponges in this computational domain. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__ale__sponge_1_1p2d}{p2d}}
\begin{DoxyCompactList}\small\item\em A structure for creating arrays of pointers to 2D arrays with extra gridding information. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__ale__sponge_1_1p3d}{p3d}}
\begin{DoxyCompactList}\small\item\em A structure for creating arrays of pointers to 3D arrays with extra gridding information. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__ale__sponge_1_1set__up__ale__sponge__field}{set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+field}}
\begin{DoxyCompactList}\small\item\em Store the reference profile at h points for a variable. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__ale__sponge_1_1set__up__ale__sponge__vel__field}{set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+vel\+\_\+field}}
\begin{DoxyCompactList}\small\item\em This subroutine stores the reference profile at u and v points for a vector. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{namespacemom__ale__sponge_a15129d167423dc162d22ef7cf4742651}{initialize\+\_\+ale\+\_\+sponge\+\_\+fixed}} (Iresttime, G, param\+\_\+file, CS, data\+\_\+h, nz\+\_\+data)
\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 
integer function, public \mbox{\hyperlink{namespacemom__ale__sponge_a30b98598d25129c9fbb6e7c4b3480e7a}{get\+\_\+ale\+\_\+sponge\+\_\+nz\+\_\+data}} (CS)
\begin{DoxyCompactList}\small\item\em Return the number of layers in the data with a fixed A\+LE sponge, or 0 if there are no sponge columns on this PE. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale__sponge_a56eb18da6c1d40f6abb544e5b7114293}{get\+\_\+ale\+\_\+sponge\+\_\+thicknesses}} (G, data\+\_\+h, sponge\+\_\+mask, CS)
\begin{DoxyCompactList}\small\item\em Return the thicknesses used for the data with a fixed A\+LE sponge. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ale__sponge_a0febb96fb2fd40a72580d078ca023098}{initialize\+\_\+ale\+\_\+sponge\+\_\+varying}} (Iresttime, G, param\+\_\+file, CS)
\begin{DoxyCompactList}\small\item\em This subroutine determines the number of points which are to be restoref in the computational domain. Only points that have positive values of Iresttime and which mask2dT indicates are ocean points are included in the sponges. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale__sponge_aed1ab3e7a8063222f1c9b0d3d2336cbe}{init\+\_\+ale\+\_\+sponge\+\_\+diags}} (Time, G, diag, CS)
\begin{DoxyCompactList}\small\item\em Initialize diagnostics for the A\+L\+E\+\_\+sponge module. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ale__sponge_a7b00598b2cf45b865f56515ed5d2ed0a}{set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+field\+\_\+fixed}} (sp\+\_\+val, G, f\+\_\+ptr, CS)
\begin{DoxyCompactList}\small\item\em This subroutine stores the reference profile at h points for the variable whose address is given by f\+\_\+ptr. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ale__sponge_a5222905f5cfddd07b77e05428e88dd85}{set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+field\+\_\+varying}} (filename, fieldname, Time, G, GV, US, f\+\_\+ptr, CS)
\begin{DoxyCompactList}\small\item\em This subroutine stores the reference profile at h points for the variable whose address is given by filename and fieldname. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ale__sponge_a6eb21c5a149d573ba0d67fdb3a932115}{set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+vel\+\_\+field\+\_\+fixed}} (u\+\_\+val, v\+\_\+val, G, u\+\_\+ptr, v\+\_\+ptr, CS)
\begin{DoxyCompactList}\small\item\em This subroutine stores the reference profile at u and v points for the variable whose address is given by u\+\_\+ptr and v\+\_\+ptr. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ale__sponge_a551051d11b239eeef807fb88ab31aba6}{set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+vel\+\_\+field\+\_\+varying}} (filename\+\_\+u, fieldname\+\_\+u, filename\+\_\+v, fieldname\+\_\+v, Time, G, US, CS, u\+\_\+ptr, v\+\_\+ptr)
\begin{DoxyCompactList}\small\item\em This subroutine stores the reference profile at uand v points for the variable whose address is given by u\+\_\+ptr and v\+\_\+ptr. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale__sponge_a1f297a8680a56b92ad1ac4e09f375d05}{apply\+\_\+ale\+\_\+sponge}} (h, dt, G, GV, US, CS, Time)
\begin{DoxyCompactList}\small\item\em This subroutine applies damping to the layers thicknesses, temp, salt and a variety of tracers for every column where there is damping. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale__sponge_a0c718798e303111ea3110d5ff07bad5c}{rotate\+\_\+ale\+\_\+sponge}} (sponge\+\_\+in, G\+\_\+in, sponge, G, turns, param\+\_\+file)
\begin{DoxyCompactList}\small\item\em Rotate the A\+LE sponge fields from the input to the model index map. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale__sponge_ab843ab7a29e992d83973c8f9ad6003b1}{update\+\_\+ale\+\_\+sponge\+\_\+field}} (sponge, p\+\_\+old, G, GV, p\+\_\+new)
\begin{DoxyCompactList}\small\item\em Scan the A\+LE sponge variables and replace a prescribed pointer to a new value. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale__sponge_ada4339e461d4b916fc4585ed6fa1482c}{ale\+\_\+sponge\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em This subroutine deallocates any memory associated with the A\+L\+E\+\_\+sponge module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__ale__sponge_ada4339e461d4b916fc4585ed6fa1482c}\label{namespacemom__ale__sponge_ada4339e461d4b916fc4585ed6fa1482c}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!ale\_sponge\_end@{ale\_sponge\_end}}
\index{ale\_sponge\_end@{ale\_sponge\_end}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{ale\_sponge\_end()}{ale\_sponge\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+\_\+sponge\+::ale\+\_\+sponge\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine deallocates any memory associated with the A\+L\+E\+\_\+sponge module. 


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


Definition at line 1169 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1169   \textcolor{keywordtype}{type}(ALE\_sponge\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< A pointer to the control structure that is}}
\DoxyCodeLine{1170 \textcolor{comment}{                                     !! set by a previous call to initialize\_ALE\_sponge.}}
\DoxyCodeLine{1171 }
\DoxyCodeLine{1172   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{1173 }
\DoxyCodeLine{1174   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1175 }
\DoxyCodeLine{1176   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_i)) \textcolor{keyword}{deallocate}(cs\%col\_i)}
\DoxyCodeLine{1177   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_i\_u)) \textcolor{keyword}{deallocate}(cs\%col\_i\_u)}
\DoxyCodeLine{1178   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_i\_v)) \textcolor{keyword}{deallocate}(cs\%col\_i\_v)}
\DoxyCodeLine{1179   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_j)) \textcolor{keyword}{deallocate}(cs\%col\_j)}
\DoxyCodeLine{1180   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_j\_u)) \textcolor{keyword}{deallocate}(cs\%col\_j\_u)}
\DoxyCodeLine{1181   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%col\_j\_v)) \textcolor{keyword}{deallocate}(cs\%col\_j\_v)}
\DoxyCodeLine{1182 }
\DoxyCodeLine{1183   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Iresttime\_col)) \textcolor{keyword}{deallocate}(cs\%Iresttime\_col)}
\DoxyCodeLine{1184   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Iresttime\_col\_u)) \textcolor{keyword}{deallocate}(cs\%Iresttime\_col\_u)}
\DoxyCodeLine{1185   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Iresttime\_col\_v)) \textcolor{keyword}{deallocate}(cs\%Iresttime\_col\_v)}
\DoxyCodeLine{1186 }
\DoxyCodeLine{1187   \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{1188     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%Ref\_val(m)\%p)) \textcolor{keyword}{deallocate}(cs\%Ref\_val(m)\%p)}
\DoxyCodeLine{1189 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1190 }
\DoxyCodeLine{1191   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{1192 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a1f297a8680a56b92ad1ac4e09f375d05}\label{namespacemom__ale__sponge_a1f297a8680a56b92ad1ac4e09f375d05}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!apply\_ale\_sponge@{apply\_ale\_sponge}}
\index{apply\_ale\_sponge@{apply\_ale\_sponge}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{apply\_ale\_sponge()}{apply\_ale\_sponge()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+\_\+sponge\+::apply\+\_\+ale\+\_\+sponge (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), 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[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS,  }\item[{type(time\+\_\+type), intent(in), optional}]{Time }\end{DoxyParamCaption})}



This subroutine applies damping to the layers thicknesses, temp, salt 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 (in). \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} (in) \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time covered by this call \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
 & {\em cs} & A pointer to the control structure for this module that is set by a previous call to initialize\+\_\+\+A\+L\+E\+\_\+sponge (in). \\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model date \\
\hline
\end{DoxyParams}


Definition at line 788 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{788   \textcolor{keywordtype}{type}(ocean\_grid\_type),     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The ocean's grid structure (in).}}
\DoxyCodeLine{789   \textcolor{keywordtype}{type}(verticalGrid\_type),   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< ocean vertical grid structure}}
\DoxyCodeLine{790   \textcolor{keywordtype}{type}(unit\_scale\_type),     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{791 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{792                              \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{  !< Layer thickness [H \string~> m or kg m-\/2] (in)}}
\DoxyCodeLine{793 \textcolor{keywordtype}{  real},                      \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{ !< The amount of time covered by this call [T \string~> s].}}
\DoxyCodeLine{794   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),       \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< A pointer to the control structure for this module}}
\DoxyCodeLine{795 \textcolor{comment}{                                                 !! that is set by a previous call to initialize\_ALE\_sponge (in).}}
\DoxyCodeLine{796   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model date}}
\DoxyCodeLine{797 }
\DoxyCodeLine{798 \textcolor{keywordtype}{  real} :: damp                                  \textcolor{comment}{! The timestep times the local damping coefficient [nondim].}}
\DoxyCodeLine{799 \textcolor{keywordtype}{  real} :: I1pdamp                               \textcolor{comment}{! I1pdamp is 1/(1 + damp). [nondim].}}
\DoxyCodeLine{800 \textcolor{keywordtype}{  real} :: m\_to\_Z                                \textcolor{comment}{! A unit conversion factor from m to Z.}}
\DoxyCodeLine{801 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: tmp\_val2   \textcolor{comment}{! data values on the original grid}}
\DoxyCodeLine{802 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(G))} :: tmp\_val1          \textcolor{comment}{! data values remapped to model grid}}
\DoxyCodeLine{803 \textcolor{keywordtype}{  real} :: hu(SZIB\_(G), SZJ\_(G), SZK\_(G))        \textcolor{comment}{! A temporary array for h at u pts}}
\DoxyCodeLine{804 \textcolor{keywordtype}{  real} :: hv(SZI\_(G), SZJB\_(G), SZK\_(G))        \textcolor{comment}{! A temporary array for h at v pts}}
\DoxyCodeLine{805 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: sp\_val \textcolor{comment}{! A temporary array for fields}}
\DoxyCodeLine{806 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: mask\_z \textcolor{comment}{! A temporary array for field mask at h pts}}
\DoxyCodeLine{807 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: hsrc       \textcolor{comment}{! Source thicknesses [Z \string~> m].}}
\DoxyCodeLine{808   \textcolor{comment}{! Local variables for ALE remapping}}
\DoxyCodeLine{809 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: tmpT1d}
\DoxyCodeLine{810   \textcolor{keywordtype}{integer} :: c, m, nkmb, i, j, k, is, ie, js, je, nz, nz\_data}
\DoxyCodeLine{811   \textcolor{keywordtype}{integer} :: col, total\_sponge\_cols}
\DoxyCodeLine{812 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{target} :: z\_in, z\_edges\_in}
\DoxyCodeLine{813 \textcolor{keywordtype}{  real} :: missing\_value}
\DoxyCodeLine{814 \textcolor{keywordtype}{  real} :: h\_neglect, h\_neglect\_edge}
\DoxyCodeLine{815 \textcolor{keywordtype}{  real} :: zTopOfCell, zBottomOfCell \textcolor{comment}{! Heights [Z \string~> m].}}
\DoxyCodeLine{816   \textcolor{keywordtype}{integer} :: nPoints}
\DoxyCodeLine{817 }
\DoxyCodeLine{818   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{819   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{820 }
\DoxyCodeLine{821   \textcolor{keywordflow}{if} (.not.cs\%remap\_answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{822     h\_neglect = gv\%H\_subroundoff ; h\_neglect\_edge = gv\%H\_subroundoff}
\DoxyCodeLine{823   \textcolor{keywordflow}{elseif} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{824     h\_neglect = gv\%m\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%m\_to\_H*1.0e-\/10}
\DoxyCodeLine{825   \textcolor{keywordflow}{else}}
\DoxyCodeLine{826     h\_neglect = gv\%kg\_m2\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%kg\_m2\_to\_H*1.0e-\/10}
\DoxyCodeLine{827 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{828 }
\DoxyCodeLine{829   \textcolor{keywordflow}{if} (cs\%time\_varying\_sponges) \textcolor{keywordflow}{then}}
\DoxyCodeLine{830     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{present}(time)) \&}
\DoxyCodeLine{831       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"apply\_ALE\_sponge: No time information provided"})}
\DoxyCodeLine{832     \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{833        nz\_data = cs\%Ref\_val(m)\%nz\_data}
\DoxyCodeLine{834        \textcolor{keyword}{allocate}(sp\_val(g\%isd:g\%ied,g\%jsd:g\%jed,1:nz\_data))}
\DoxyCodeLine{835        \textcolor{keyword}{allocate}(mask\_z(g\%isd:g\%ied,g\%jsd:g\%jed,1:nz\_data))}
\DoxyCodeLine{836        sp\_val(:,:,:) = 0.0}
\DoxyCodeLine{837        mask\_z(:,:,:) = 0.0}
\DoxyCodeLine{838        \textcolor{keyword}{call }horiz\_interp\_and\_extrap\_tracer(cs\%Ref\_val(m)\%id, time, 1.0, g, sp\_val, mask\_z, z\_in, \&}
\DoxyCodeLine{839                       z\_edges\_in,  missing\_value, .true., .false., .false., \&}
\DoxyCodeLine{840                       spongeongrid=cs\%SpongeDataOngrid, m\_to\_z=us\%m\_to\_Z, \&}
\DoxyCodeLine{841                       answers\_2018=cs\%hor\_regrid\_answers\_2018)}
\DoxyCodeLine{842        \textcolor{keyword}{allocate}( hsrc(nz\_data) )}
\DoxyCodeLine{843        \textcolor{keyword}{allocate}( tmpt1d(nz\_data) )}
\DoxyCodeLine{844        \textcolor{keywordflow}{do} c=1,cs\%num\_col}
\DoxyCodeLine{845           i = cs\%col\_i(c) ; j = cs\%col\_j(c)}
\DoxyCodeLine{846           cs\%Ref\_val(m)\%p(1:nz\_data,c) = sp\_val(i,j,1:nz\_data)}
\DoxyCodeLine{847           \textcolor{comment}{! Build the source grid}}
\DoxyCodeLine{848           ztopofcell = 0. ; zbottomofcell = 0. ; npoints = 0; hsrc(:) = 0.0; tmpt1d(:) = -\/99.9}
\DoxyCodeLine{849           \textcolor{keywordflow}{do} k=1,nz\_data}
\DoxyCodeLine{850              \textcolor{keywordflow}{if} (mask\_z(cs\%col\_i(c),cs\%col\_j(c),k) == 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{851                 zbottomofcell = -\/min( z\_edges\_in(k+1), g\%bathyT(cs\%col\_i(c),cs\%col\_j(c)) )}
\DoxyCodeLine{852                 tmpt1d(k) = sp\_val(cs\%col\_i(c),cs\%col\_j(c),k)}
\DoxyCodeLine{853              \textcolor{keywordflow}{elseif} (k>1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{854                 zbottomofcell = -\/g\%bathyT(cs\%col\_i(c),cs\%col\_j(c))}
\DoxyCodeLine{855                 tmpt1d(k) = tmpt1d(k-\/1)}
\DoxyCodeLine{856              \textcolor{keywordflow}{else} \textcolor{comment}{! This next block should only ever be reached over land}}
\DoxyCodeLine{857                 tmpt1d(k) = -\/99.9}
\DoxyCodeLine{858 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{859              hsrc(k) = ztopofcell -\/ zbottomofcell}
\DoxyCodeLine{860              \textcolor{keywordflow}{if} (hsrc(k)>0.) npoints = npoints + 1}
\DoxyCodeLine{861              ztopofcell = zbottomofcell \textcolor{comment}{! Bottom becomes top for next value of k}}
\DoxyCodeLine{862 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{863           \textcolor{comment}{! In case data is deeper than model}}
\DoxyCodeLine{864           hsrc(nz\_data) = hsrc(nz\_data) + ( ztopofcell + g\%bathyT(cs\%col\_i(c),cs\%col\_j(c)) )}
\DoxyCodeLine{865           cs\%Ref\_val(m)\%h(1:nz\_data,c) = gv\%Z\_to\_H*hsrc(1:nz\_data)}
\DoxyCodeLine{866           cs\%Ref\_val(m)\%p(1:nz\_data,c) = tmpt1d(1:nz\_data)}
\DoxyCodeLine{867           \textcolor{keywordflow}{do} k=2,nz\_data}
\DoxyCodeLine{868              \textcolor{comment}{!          if (mask\_z(i,j,k)==0.) \&}}
\DoxyCodeLine{869              \textcolor{keywordflow}{if} (cs\%Ref\_val(m)\%h(k,c) <= 0.001*gv\%m\_to\_H) \&}
\DoxyCodeLine{870                   \textcolor{comment}{! some confusion here about why the masks are not correct returning from horiz\_interp}}
\DoxyCodeLine{871                   \textcolor{comment}{! reverting to using a minimum thickness criteria}}
\DoxyCodeLine{872                   cs\%Ref\_val(m)\%p(k,c) = cs\%Ref\_val(m)\%p(k-\/1,c)}
\DoxyCodeLine{873 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{874 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{875       \textcolor{keyword}{deallocate}(sp\_val, mask\_z, hsrc, tmpt1d)}
\DoxyCodeLine{876 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{877   \textcolor{keywordflow}{else}}
\DoxyCodeLine{878     nz\_data = cs\%nz\_data}
\DoxyCodeLine{879 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{880 }
\DoxyCodeLine{881   \textcolor{keyword}{allocate}(tmp\_val2(nz\_data))}
\DoxyCodeLine{882   \textcolor{keywordflow}{do} m=1,cs\%fldno}
\DoxyCodeLine{883     \textcolor{keywordflow}{do} c=1,cs\%num\_col}
\DoxyCodeLine{884 \textcolor{comment}{! c is an index for the next 3 lines but a multiplier for the rest of the loop}}
\DoxyCodeLine{885 \textcolor{comment}{! Therefore we use c as per C code and increment the index where necessary.}}
\DoxyCodeLine{886       i = cs\%col\_i(c) ; j = cs\%col\_j(c)}
\DoxyCodeLine{887       damp = dt * cs\%Iresttime\_col(c)}
\DoxyCodeLine{888       i1pdamp = 1.0 / (1.0 + damp)}
\DoxyCodeLine{889       tmp\_val2(1:nz\_data) = cs\%Ref\_val(m)\%p(1:nz\_data,c)}
\DoxyCodeLine{890       \textcolor{keywordflow}{if} (cs\%time\_varying\_sponges) \textcolor{keywordflow}{then}}
\DoxyCodeLine{891         \textcolor{keyword}{call }remapping\_core\_h(cs\%remap\_cs, nz\_data, cs\%Ref\_val(m)\%h(1:nz\_data,c), tmp\_val2, \&}
\DoxyCodeLine{892                               cs\%nz, h(i,j,:), tmp\_val1, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{893       \textcolor{keywordflow}{else}}
\DoxyCodeLine{894         \textcolor{keyword}{call }remapping\_core\_h(cs\%remap\_cs,nz\_data, cs\%Ref\_h\%p(1:nz\_data,c), tmp\_val2, \&}
\DoxyCodeLine{895                               cs\%nz, h(i,j,:), tmp\_val1, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{896 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{897       \textcolor{comment}{!Backward Euler method}}
\DoxyCodeLine{898       cs\%var(m)\%p(i,j,1:cs\%nz) = i1pdamp * (cs\%var(m)\%p(i,j,1:cs\%nz) + tmp\_val1 * damp)}
\DoxyCodeLine{899 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{900 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{901 }
\DoxyCodeLine{902   \textcolor{comment}{! for debugging}}
\DoxyCodeLine{903   \textcolor{comment}{!c=CS\%num\_col}}
\DoxyCodeLine{904   \textcolor{comment}{!do m=1,CS\%fldno}}
\DoxyCodeLine{905   \textcolor{comment}{!   write(*,*) 'APPLY SPONGE,m,CS\%Ref\_h(:,c),h(i,j,:),tmp\_val2,tmp\_val1',\&}}
\DoxyCodeLine{906   \textcolor{comment}{!               m,CS\%Ref\_h(:,c),h(i,j,:),tmp\_val2,tmp\_val1}}
\DoxyCodeLine{907   \textcolor{comment}{!enddo}}
\DoxyCodeLine{908 }
\DoxyCodeLine{909   \textcolor{keywordflow}{if} (cs\%sponge\_uv) \textcolor{keywordflow}{then}}
\DoxyCodeLine{910     \textcolor{comment}{! u points}}
\DoxyCodeLine{911     \textcolor{keywordflow}{do} j=cs\%jsc,cs\%jec; \textcolor{keywordflow}{do} i=cs\%iscB,cs\%iecB; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{912       hu(i,j,k) = 0.5 * (h(i,j,k) + h(i+1,j,k))}
\DoxyCodeLine{913 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{914     \textcolor{keywordflow}{if} (cs\%time\_varying\_sponges) \textcolor{keywordflow}{then}}
\DoxyCodeLine{915       \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{present}(time)) \&}
\DoxyCodeLine{916          \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"apply\_ALE\_sponge: No time information provided"})}
\DoxyCodeLine{917 }
\DoxyCodeLine{918       nz\_data = cs\%Ref\_val\_u\%nz\_data}
\DoxyCodeLine{919       \textcolor{keyword}{allocate}(sp\_val(g\%isdB:g\%iedB,g\%jsd:g\%jed,1:nz\_data))}
\DoxyCodeLine{920       \textcolor{keyword}{allocate}(mask\_z(g\%isdB:g\%iedB,g\%jsd:g\%jed,1:nz\_data))}
\DoxyCodeLine{921       \textcolor{comment}{! Interpolate from the external horizontal grid and in time}}
\DoxyCodeLine{922       \textcolor{keyword}{call }horiz\_interp\_and\_extrap\_tracer(cs\%Ref\_val\_u\%id, time, 1.0, g, sp\_val, mask\_z, z\_in, \&}
\DoxyCodeLine{923                                           z\_edges\_in, missing\_value, .true., .false., .false., \&}
\DoxyCodeLine{924                                           m\_to\_z=us\%m\_to\_Z, answers\_2018=cs\%hor\_regrid\_answers\_2018)}
\DoxyCodeLine{925 \textcolor{comment}{!     call pass\_var(sp\_val,G\%Domain)}}
\DoxyCodeLine{926 \textcolor{comment}{!     call pass\_var(mask\_z,G\%Domain)}}
\DoxyCodeLine{927       \textcolor{keywordflow}{do} c=1,cs\%num\_col}
\DoxyCodeLine{928         \textcolor{comment}{! c is an index for the next 3 lines but a multiplier for the rest of the loop}}
\DoxyCodeLine{929         \textcolor{comment}{! Therefore we use c as per C code and increment the index where necessary.}}
\DoxyCodeLine{930         i = cs\%col\_i(c) ; j = cs\%col\_j(c)}
\DoxyCodeLine{931         cs\%Ref\_val\_u\%p(1:nz\_data,c) = sp\_val(i,j,1:nz\_data)}
\DoxyCodeLine{932 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{933 }
\DoxyCodeLine{934       \textcolor{keyword}{deallocate} (sp\_val, mask\_z)}
\DoxyCodeLine{935 }
\DoxyCodeLine{936       nz\_data = cs\%Ref\_val\_v\%nz\_data}
\DoxyCodeLine{937       \textcolor{keyword}{allocate}(sp\_val(g\%isd:g\%ied,g\%jsdB:g\%jedB,1:nz\_data))}
\DoxyCodeLine{938       \textcolor{keyword}{allocate}(mask\_z(g\%isd:g\%ied,g\%jsdB:g\%jedB,1:nz\_data))}
\DoxyCodeLine{939       \textcolor{comment}{! Interpolate from the external horizontal grid and in time}}
\DoxyCodeLine{940       \textcolor{keyword}{call }horiz\_interp\_and\_extrap\_tracer(cs\%Ref\_val\_v\%id, time, 1.0, g, sp\_val, mask\_z, z\_in, \&}
\DoxyCodeLine{941                                           z\_edges\_in, missing\_value, .true., .false., .false., \&}
\DoxyCodeLine{942                                           m\_to\_z=us\%m\_to\_Z, answers\_2018=cs\%hor\_regrid\_answers\_2018)}
\DoxyCodeLine{943 }
\DoxyCodeLine{944 \textcolor{comment}{!     call pass\_var(sp\_val,G\%Domain)}}
\DoxyCodeLine{945 \textcolor{comment}{!     call pass\_var(mask\_z,G\%Domain)}}
\DoxyCodeLine{946 }
\DoxyCodeLine{947       \textcolor{keywordflow}{do} c=1,cs\%num\_col}
\DoxyCodeLine{948         \textcolor{comment}{! c is an index for the next 3 lines but a multiplier for the rest of the loop}}
\DoxyCodeLine{949         \textcolor{comment}{! Therefore we use c as per C code and increment the index where necessary.}}
\DoxyCodeLine{950         i = cs\%col\_i(c) ; j = cs\%col\_j(c)}
\DoxyCodeLine{951         cs\%Ref\_val\_v\%p(1:nz\_data,c) = sp\_val(i,j,1:nz\_data)}
\DoxyCodeLine{952 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{953 }
\DoxyCodeLine{954       \textcolor{keyword}{deallocate} (sp\_val, mask\_z)}
\DoxyCodeLine{955 }
\DoxyCodeLine{956     \textcolor{keywordflow}{else}}
\DoxyCodeLine{957       nz\_data = cs\%nz\_data}
\DoxyCodeLine{958 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{959 }
\DoxyCodeLine{960     \textcolor{keywordflow}{do} c=1,cs\%num\_col\_u}
\DoxyCodeLine{961       i = cs\%col\_i\_u(c) ; j = cs\%col\_j\_u(c)}
\DoxyCodeLine{962       damp = dt * cs\%Iresttime\_col\_u(c)}
\DoxyCodeLine{963       i1pdamp = 1.0 / (1.0 + damp)}
\DoxyCodeLine{964       \textcolor{keywordflow}{if} (cs\%time\_varying\_sponges) nz\_data = cs\%Ref\_val(m)\%nz\_data}
\DoxyCodeLine{965       tmp\_val2(1:nz\_data) = cs\%Ref\_val\_u\%p(1:nz\_data,c)}
\DoxyCodeLine{966       \textcolor{keywordflow}{if} (cs\%time\_varying\_sponges) \textcolor{keywordflow}{then}}
\DoxyCodeLine{967         \textcolor{keyword}{call }remapping\_core\_h(cs\%remap\_cs, nz\_data, cs\%Ref\_val\_u\%h(:,c), tmp\_val2, \&}
\DoxyCodeLine{968                  cs\%nz, hu(i,j,:), tmp\_val1, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{969       \textcolor{keywordflow}{else}}
\DoxyCodeLine{970         \textcolor{keyword}{call }remapping\_core\_h(cs\%remap\_cs, nz\_data, cs\%Ref\_hu\%p(:,c), tmp\_val2, \&}
\DoxyCodeLine{971                  cs\%nz, hu(i,j,:), tmp\_val1, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{972 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{973       \textcolor{comment}{!Backward Euler method}}
\DoxyCodeLine{974       cs\%var\_u\%p(i,j,:) = i1pdamp * (cs\%var\_u\%p(i,j,:) + tmp\_val1 * damp)}
\DoxyCodeLine{975 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{976 }
\DoxyCodeLine{977     \textcolor{comment}{! v points}}
\DoxyCodeLine{978     \textcolor{keywordflow}{do} j=cs\%jscB,cs\%jecB; \textcolor{keywordflow}{do} i=cs\%isc,cs\%iec; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{979       hv(i,j,k) = 0.5 * (h(i,j,k) + h(i,j+1,k))}
\DoxyCodeLine{980 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{981 }
\DoxyCodeLine{982     \textcolor{keywordflow}{do} c=1,cs\%num\_col\_v}
\DoxyCodeLine{983       i = cs\%col\_i\_v(c) ; j = cs\%col\_j\_v(c)}
\DoxyCodeLine{984       damp = dt * cs\%Iresttime\_col\_v(c)}
\DoxyCodeLine{985       i1pdamp = 1.0 / (1.0 + damp)}
\DoxyCodeLine{986       tmp\_val2(1:nz\_data) = cs\%Ref\_val\_v\%p(1:nz\_data,c)}
\DoxyCodeLine{987       \textcolor{keywordflow}{if} (cs\%time\_varying\_sponges) \textcolor{keywordflow}{then}}
\DoxyCodeLine{988         \textcolor{keyword}{call }remapping\_core\_h(cs\%remap\_cs, cs\%nz\_data, cs\%Ref\_val\_v\%h(:,c), tmp\_val2, \&}
\DoxyCodeLine{989                  cs\%nz, hv(i,j,:), tmp\_val1, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{990       \textcolor{keywordflow}{else}}
\DoxyCodeLine{991         \textcolor{keyword}{call }remapping\_core\_h(cs\%remap\_cs, cs\%nz\_data, cs\%Ref\_hv\%p(:,c), tmp\_val2, \&}
\DoxyCodeLine{992                  cs\%nz, hv(i,j,:), tmp\_val1, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{993 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{994       \textcolor{comment}{!Backward Euler method}}
\DoxyCodeLine{995       cs\%var\_v\%p(i,j,:) = i1pdamp * (cs\%var\_v\%p(i,j,:) + tmp\_val1 * damp)}
\DoxyCodeLine{996 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{997 }
\DoxyCodeLine{998 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{999 }
\DoxyCodeLine{1000   \textcolor{keyword}{deallocate}(tmp\_val2)}
\DoxyCodeLine{1001 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a30b98598d25129c9fbb6e7c4b3480e7a}\label{namespacemom__ale__sponge_a30b98598d25129c9fbb6e7c4b3480e7a}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!get\_ale\_sponge\_nz\_data@{get\_ale\_sponge\_nz\_data}}
\index{get\_ale\_sponge\_nz\_data@{get\_ale\_sponge\_nz\_data}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{get\_ale\_sponge\_nz\_data()}{get\_ale\_sponge\_nz\_data()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+ale\+\_\+sponge\+::get\+\_\+ale\+\_\+sponge\+\_\+nz\+\_\+data (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Return the number of layers in the data with a fixed A\+LE sponge, or 0 if there are no sponge columns on this PE. 


\begin{DoxyParams}{Parameters}
{\em cs} & A pointer that is set to point to the control structure for the A\+L\+E\+\_\+sponge module. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of layers in the fixed sponge data. 
\end{DoxyReturn}


Definition at line 347 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{347   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),   \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{348 \textcolor{comment}{                                             !! structure for the ALE\_sponge module.}}
\DoxyCodeLine{349   \textcolor{keywordtype}{integer} :: get\_ALE\_sponge\_nz\_data\textcolor{comment}{  !< The number of layers in the fixed sponge data.}}
\DoxyCodeLine{350 }
\DoxyCodeLine{351   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{352     get\_ale\_sponge\_nz\_data = cs\%nz\_data}
\DoxyCodeLine{353   \textcolor{keywordflow}{else}}
\DoxyCodeLine{354     get\_ale\_sponge\_nz\_data = 0}
\DoxyCodeLine{355 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a56eb18da6c1d40f6abb544e5b7114293}\label{namespacemom__ale__sponge_a56eb18da6c1d40f6abb544e5b7114293}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!get\_ale\_sponge\_thicknesses@{get\_ale\_sponge\_thicknesses}}
\index{get\_ale\_sponge\_thicknesses@{get\_ale\_sponge\_thicknesses}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{get\_ale\_sponge\_thicknesses()}{get\_ale\_sponge\_thicknesses()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+\_\+sponge\+::get\+\_\+ale\+\_\+sponge\+\_\+thicknesses (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout), allocatable}]{data\+\_\+h,  }\item[{logical, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(out)}]{sponge\+\_\+mask,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Return the thicknesses used for the data with a fixed A\+LE sponge. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure (in). \\
\hline
\mbox{\texttt{ in,out}}  & {\em data\+\_\+h} & The thicknesses of the sponge input layers \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em sponge\+\_\+mask} & A logical mask that is true where \\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for the A\+L\+E\+\_\+sponge module. \\
\hline
\end{DoxyParams}


Definition at line 360 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{360   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{ !< The ocean's grid structure (in).}}
\DoxyCodeLine{361 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)}, \&}
\DoxyCodeLine{362                          \textcolor{keywordtype}{intent(inout)} :: data\_h\textcolor{comment}{ !< The thicknesses of the sponge input layers [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{363   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{364                          \textcolor{keywordtype}{intent(out)}   :: sponge\_mask\textcolor{comment}{ !< A logical mask that is true where}}
\DoxyCodeLine{365 \textcolor{comment}{                                                 !! sponges are being applied.}}
\DoxyCodeLine{366   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),   \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{367 \textcolor{comment}{                                             !! structure for the ALE\_sponge module.}}
\DoxyCodeLine{368   \textcolor{keywordtype}{integer} :: c, i, j, k}
\DoxyCodeLine{369 }
\DoxyCodeLine{370   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(data\_h)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{371     \textcolor{stringliteral}{"get\_ALE\_sponge\_thicknesses called with an allocated data\_h."})}
\DoxyCodeLine{372 }
\DoxyCodeLine{373   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{374     \textcolor{comment}{! There are no sponge points on this PE.}}
\DoxyCodeLine{375     \textcolor{keyword}{allocate}(data\_h(g\%isd:g\%ied,g\%jsd:g\%jed,1)) ; data\_h(:,:,:) = -\/1.0}
\DoxyCodeLine{376     sponge\_mask(:,:) = .false.}
\DoxyCodeLine{377     \textcolor{keywordflow}{return}}
\DoxyCodeLine{378 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{379 }
\DoxyCodeLine{380   \textcolor{keyword}{allocate}(data\_h(g\%isd:g\%ied,g\%jsd:g\%jed,cs\%nz\_data)) ; data\_h(:,:,:) = -\/1.0}
\DoxyCodeLine{381   sponge\_mask(:,:) = .false.}
\DoxyCodeLine{382 }
\DoxyCodeLine{383   \textcolor{keywordflow}{do} c=1,cs\%num\_col}
\DoxyCodeLine{384     i = cs\%col\_i(c) ; j = cs\%col\_j(c)}
\DoxyCodeLine{385     sponge\_mask(i,j) = .true.}
\DoxyCodeLine{386     \textcolor{keywordflow}{do} k=1,cs\%nz\_data}
\DoxyCodeLine{387       data\_h(i,j,k) = cs\%Ref\_h\%p(k,c)}
\DoxyCodeLine{388 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{389 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{390 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_aed1ab3e7a8063222f1c9b0d3d2336cbe}\label{namespacemom__ale__sponge_aed1ab3e7a8063222f1c9b0d3d2336cbe}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!init\_ale\_sponge\_diags@{init\_ale\_sponge\_diags}}
\index{init\_ale\_sponge\_diags@{init\_ale\_sponge\_diags}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{init\_ale\_sponge\_diags()}{init\_ale\_sponge\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+\_\+sponge\+::init\+\_\+ale\+\_\+sponge\+\_\+diags (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Initialize diagnostics for the A\+L\+E\+\_\+sponge module. 


\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,out}}  & {\em diag} & A structure that is used to regulate diagnostic output. \\
\hline
 & {\em cs} & A\+LE sponge control structure \\
\hline
\end{DoxyParams}


Definition at line 549 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{549   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{550   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{551   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< A structure that is used to regulate diagnostic}}
\DoxyCodeLine{552 \textcolor{comment}{                                                 !! output.}}
\DoxyCodeLine{553   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),     \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< ALE sponge control structure}}
\DoxyCodeLine{554 }
\DoxyCodeLine{555   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{556 }
\DoxyCodeLine{557   cs\%diag => diag}
\DoxyCodeLine{558 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a15129d167423dc162d22ef7cf4742651}\label{namespacemom__ale__sponge_a15129d167423dc162d22ef7cf4742651}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!initialize\_ale\_sponge\_fixed@{initialize\_ale\_sponge\_fixed}}
\index{initialize\_ale\_sponge\_fixed@{initialize\_ale\_sponge\_fixed}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{initialize\_ale\_sponge\_fixed()}{initialize\_ale\_sponge\_fixed()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge\+\_\+fixed (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{Iresttime,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),nz\+\_\+data), intent(in)}]{data\+\_\+h,  }\item[{integer, intent(in)}]{nz\+\_\+data }\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 nz\+\_\+data} & The total number of sponge input layers. \\
\hline
\mbox{\texttt{ in}}  & {\em iresttime} & The inverse of the restoring time \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module (in/out). \\
\hline
\mbox{\texttt{ in}}  & {\em data\+\_\+h} & The thicknesses of the sponge input layers \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 149 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{149 }
\DoxyCodeLine{150   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The ocean's grid structure.}}
\DoxyCodeLine{151   \textcolor{keywordtype}{integer},                          \textcolor{keywordtype}{intent(in)} :: nz\_data\textcolor{comment}{ !< The total number of sponge input layers.}}
\DoxyCodeLine{152 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(in)} :: Iresttime\textcolor{comment}{ !< The inverse of the restoring time [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{153   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure indicating the open file}}
\DoxyCodeLine{154 \textcolor{comment}{                                                             !! to parse for model parameter values.}}
\DoxyCodeLine{155   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),              \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{156 \textcolor{comment}{                                                     !! structure for this module (in/out).}}
\DoxyCodeLine{157 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),nz\_data)}, \textcolor{keywordtype}{intent(in)} :: data\_h\textcolor{comment}{ !< The thicknesses of the sponge}}
\DoxyCodeLine{158 \textcolor{comment}{                                                     !! input layers [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{159 }
\DoxyCodeLine{160 }
\DoxyCodeLine{161 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{162 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{163 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_sponge"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{164   \textcolor{keywordtype}{logical} :: use\_sponge}
\DoxyCodeLine{165 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: data\_hu\textcolor{comment}{ !< thickness at u points [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{166 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: data\_hv\textcolor{comment}{ !< thickness at v points [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{167 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_u\textcolor{comment}{ !< inverse of the restoring time at u points [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{168 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_v\textcolor{comment}{ !< inverse of the restoring time at v points [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{169   \textcolor{keywordtype}{logical} :: bndExtrapolation = .true. \textcolor{comment}{! If true, extrapolate boundaries}}
\DoxyCodeLine{170   \textcolor{keywordtype}{logical} :: default\_2018\_answers}
\DoxyCodeLine{171   \textcolor{keywordtype}{integer} :: i, j, k, col, total\_sponge\_cols, total\_sponge\_cols\_u, total\_sponge\_cols\_v}
\DoxyCodeLine{172   \textcolor{keywordtype}{character(len=10)}  :: remapScheme}
\DoxyCodeLine{173   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{174     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_ALE\_sponge\_fixed called with an associated "}// \&}
\DoxyCodeLine{175                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{176     \textcolor{keywordflow}{return}}
\DoxyCodeLine{177 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{178 }
\DoxyCodeLine{179 \textcolor{comment}{! Set default, read and log parameters}}
\DoxyCodeLine{180   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{181   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, use\_sponge, \&}
\DoxyCodeLine{182                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//\&}
\DoxyCodeLine{183                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//\&}
\DoxyCodeLine{184                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)}
\DoxyCodeLine{185 }
\DoxyCodeLine{186   \textcolor{keywordflow}{if} (.not.use\_sponge) \textcolor{keywordflow}{return}}
\DoxyCodeLine{187 }
\DoxyCodeLine{188   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{189 }
\DoxyCodeLine{190   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_UV"}, cs\%sponge\_uv, \&}
\DoxyCodeLine{191                  \textcolor{stringliteral}{"Apply sponges in u and v, in addition to tracers."}, \&}
\DoxyCodeLine{192                  default=.false.)}
\DoxyCodeLine{193 }
\DoxyCodeLine{194   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, remapscheme, \&}
\DoxyCodeLine{195                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//\&}
\DoxyCodeLine{196                  \textcolor{stringliteral}{" for vertical remapping for all variables."}, \&}
\DoxyCodeLine{197                  default=\textcolor{stringliteral}{"PLM"}, do\_not\_log=.true.)}
\DoxyCodeLine{198 }
\DoxyCodeLine{199   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BOUNDARY\_EXTRAPOLATION"}, bndextrapolation, \&}
\DoxyCodeLine{200                  \textcolor{stringliteral}{"When defined, a proper high-\/order reconstruction "}//\&}
\DoxyCodeLine{201                  \textcolor{stringliteral}{"scheme is used within boundary cells rather "}//\&}
\DoxyCodeLine{202                  \textcolor{stringliteral}{"than PCM. E.g., if PPM is used for remapping, a "}//\&}
\DoxyCodeLine{203                  \textcolor{stringliteral}{"PPM reconstruction will also be used within boundary cells."}, \&}
\DoxyCodeLine{204                  default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{205   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{206                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{207                  default=.false.)}
\DoxyCodeLine{208   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs\%remap\_answers\_2018, \&}
\DoxyCodeLine{209                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//\&}
\DoxyCodeLine{210                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//\&}
\DoxyCodeLine{211                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"HOR\_REGRID\_2018\_ANSWERS"}, cs\%hor\_regrid\_answers\_2018, \&}
\DoxyCodeLine{213                  \textcolor{stringliteral}{"If true, use the order of arithmetic for horizonal regridding that recovers "}//\&}
\DoxyCodeLine{214                  \textcolor{stringliteral}{"the answers from the end of 2018.  Otherwise, use rotationally symmetric "}//\&}
\DoxyCodeLine{215                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{216 }
\DoxyCodeLine{217   cs\%time\_varying\_sponges = .false.}
\DoxyCodeLine{218   cs\%nz = g\%ke}
\DoxyCodeLine{219   cs\%isc = g\%isc ; cs\%iec = g\%iec ; cs\%jsc = g\%jsc ; cs\%jec = g\%jec}
\DoxyCodeLine{220   cs\%isd = g\%isd ; cs\%ied = g\%ied ; cs\%jsd = g\%jsd ; cs\%jed = g\%jed}
\DoxyCodeLine{221   cs\%iscB = g\%iscB ; cs\%iecB = g\%iecB; cs\%jscB = g\%jscB ; cs\%jecB = g\%jecB}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   \textcolor{comment}{! number of columns to be restored}}
\DoxyCodeLine{224   cs\%num\_col = 0 ; cs\%fldno = 0}
\DoxyCodeLine{225   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{226     \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g\%mask2dT(i,j)>0)) \&}
\DoxyCodeLine{227       cs\%num\_col = cs\%num\_col + 1}
\DoxyCodeLine{228 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{229 }
\DoxyCodeLine{230   \textcolor{keywordflow}{if} (cs\%num\_col > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{231     \textcolor{keyword}{allocate}(cs\%Iresttime\_col(cs\%num\_col)) ; cs\%Iresttime\_col = 0.0}
\DoxyCodeLine{232     \textcolor{keyword}{allocate}(cs\%col\_i(cs\%num\_col))         ; cs\%col\_i = 0}
\DoxyCodeLine{233     \textcolor{keyword}{allocate}(cs\%col\_j(cs\%num\_col))         ; cs\%col\_j = 0}
\DoxyCodeLine{234     \textcolor{comment}{! pass indices, restoring time to the CS structure}}
\DoxyCodeLine{235     col = 1}
\DoxyCodeLine{236     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{237       \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g\%mask2dT(i,j)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{238         cs\%col\_i(col) = i ; cs\%col\_j(col) = j}
\DoxyCodeLine{239         cs\%Iresttime\_col(col) = iresttime(i,j)}
\DoxyCodeLine{240         col = col +1}
\DoxyCodeLine{241 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{242 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{243     \textcolor{comment}{! same for total number of arbritary layers and correspondent data}}
\DoxyCodeLine{244     cs\%nz\_data = nz\_data}
\DoxyCodeLine{245     \textcolor{keyword}{allocate}(cs\%Ref\_h\%p(cs\%nz\_data,cs\%num\_col))}
\DoxyCodeLine{246     \textcolor{keywordflow}{do} col=1,cs\%num\_col ; \textcolor{keywordflow}{do} k=1,cs\%nz\_data}
\DoxyCodeLine{247       cs\%Ref\_h\%p(k,col) = data\_h(cs\%col\_i(col),cs\%col\_j(col),k)}
\DoxyCodeLine{248 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{249 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{250 }
\DoxyCodeLine{251   total\_sponge\_cols = cs\%num\_col}
\DoxyCodeLine{252   \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols)}
\DoxyCodeLine{253 }
\DoxyCodeLine{254 \textcolor{comment}{! Call the constructor for remapping control structure}}
\DoxyCodeLine{255   \textcolor{keyword}{call }initialize\_remapping(cs\%remap\_cs, remapscheme, boundary\_extrapolation=bndextrapolation, \&}
\DoxyCodeLine{256                             answers\_2018=cs\%remap\_answers\_2018)}
\DoxyCodeLine{257 }
\DoxyCodeLine{258   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at h points"}, total\_sponge\_cols, \&}
\DoxyCodeLine{259                  \textcolor{stringliteral}{"The total number of columns where sponges are applied at h points."}, like\_default=.true.)}
\DoxyCodeLine{260 }
\DoxyCodeLine{261   \textcolor{keywordflow}{if} (cs\%sponge\_uv) \textcolor{keywordflow}{then}}
\DoxyCodeLine{262 }
\DoxyCodeLine{263     \textcolor{keyword}{allocate}(data\_hu(g\%isdB:g\%iedB,g\%jsd:g\%jed,nz\_data)) ; data\_hu(:,:,:) = 0.0}
\DoxyCodeLine{264     \textcolor{keyword}{allocate}(data\_hv(g\%isd:g\%ied,g\%jsdB:g\%jedB,nz\_data)) ; data\_hv(:,:,:) = 0.0}
\DoxyCodeLine{265     \textcolor{keyword}{allocate}(iresttime\_u(g\%isdB:g\%iedB,g\%jsd:g\%jed)) ; iresttime\_u(:,:) = 0.0}
\DoxyCodeLine{266     \textcolor{keyword}{allocate}(iresttime\_v(g\%isd:g\%ied,g\%jsdB:g\%jedB)) ; iresttime\_v(:,:) = 0.0}
\DoxyCodeLine{267 }
\DoxyCodeLine{268     \textcolor{comment}{! u points}}
\DoxyCodeLine{269     cs\%num\_col\_u = 0 ; \textcolor{comment}{!CS\%fldno\_u = 0}}
\DoxyCodeLine{270     \textcolor{keywordflow}{do} j=cs\%jsc,cs\%jec ; \textcolor{keywordflow}{do} i=cs\%iscB,cs\%iecB}
\DoxyCodeLine{271        data\_hu(i,j,:) = 0.5 * (data\_h(i,j,:) + data\_h(i+1,j,:))}
\DoxyCodeLine{272        iresttime\_u(i,j) = 0.5 * (iresttime(i,j) + iresttime(i+1,j))}
\DoxyCodeLine{273        \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g\%mask2dCu(i,j)>0)) \&}
\DoxyCodeLine{274           cs\%num\_col\_u = cs\%num\_col\_u + 1}
\DoxyCodeLine{275 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{276 }
\DoxyCodeLine{277     \textcolor{keywordflow}{if} (cs\%num\_col\_u > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{278 }
\DoxyCodeLine{279        \textcolor{keyword}{allocate}(cs\%Iresttime\_col\_u(cs\%num\_col\_u)) ; cs\%Iresttime\_col\_u(:) = 0.0}
\DoxyCodeLine{280        \textcolor{keyword}{allocate}(cs\%col\_i\_u(cs\%num\_col\_u))         ; cs\%col\_i\_u(:) = 0}
\DoxyCodeLine{281        \textcolor{keyword}{allocate}(cs\%col\_j\_u(cs\%num\_col\_u))         ; cs\%col\_j\_u(:) = 0}
\DoxyCodeLine{282 }
\DoxyCodeLine{283        \textcolor{comment}{! pass indices, restoring time to the CS structure}}
\DoxyCodeLine{284        col = 1}
\DoxyCodeLine{285        \textcolor{keywordflow}{do} j=cs\%jsc,cs\%jec ; \textcolor{keywordflow}{do} i=cs\%iscB,cs\%iecB}
\DoxyCodeLine{286          \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g\%mask2dCu(i,j)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{287            cs\%col\_i\_u(col) = i ; cs\%col\_j\_u(col) = j}
\DoxyCodeLine{288            cs\%Iresttime\_col\_u(col) = iresttime\_u(i,j)}
\DoxyCodeLine{289            col = col + 1}
\DoxyCodeLine{290 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{291 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{292 }
\DoxyCodeLine{293        \textcolor{comment}{! same for total number of arbritary layers and correspondent data}}
\DoxyCodeLine{294 }
\DoxyCodeLine{295        \textcolor{keyword}{allocate}(cs\%Ref\_hu\%p(cs\%nz\_data,cs\%num\_col\_u))}
\DoxyCodeLine{296        \textcolor{keywordflow}{do} col=1,cs\%num\_col\_u ; \textcolor{keywordflow}{do} k=1,cs\%nz\_data}
\DoxyCodeLine{297          cs\%Ref\_hu\%p(k,col) = data\_hu(cs\%col\_i\_u(col),cs\%col\_j\_u(col),k)}
\DoxyCodeLine{298 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{299 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{300     total\_sponge\_cols\_u = cs\%num\_col\_u}
\DoxyCodeLine{301     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_u)}
\DoxyCodeLine{302     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at u points"}, total\_sponge\_cols\_u, \&}
\DoxyCodeLine{303                 \textcolor{stringliteral}{"The total number of columns where sponges are applied at u points."}, like\_default=.true.)}
\DoxyCodeLine{304 }
\DoxyCodeLine{305     \textcolor{comment}{! v points}}
\DoxyCodeLine{306     cs\%num\_col\_v = 0 ; \textcolor{comment}{!CS\%fldno\_v = 0}}
\DoxyCodeLine{307     \textcolor{keywordflow}{do} j=cs\%jscB,cs\%jecB; \textcolor{keywordflow}{do} i=cs\%isc,cs\%iec}
\DoxyCodeLine{308       data\_hv(i,j,:) = 0.5 * (data\_h(i,j,:) + data\_h(i,j+1,:))}
\DoxyCodeLine{309       iresttime\_v(i,j) = 0.5 * (iresttime(i,j) + iresttime(i,j+1))}
\DoxyCodeLine{310       \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g\%mask2dCv(i,j)>0)) \&}
\DoxyCodeLine{311         cs\%num\_col\_v = cs\%num\_col\_v + 1}
\DoxyCodeLine{312 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{313 }
\DoxyCodeLine{314     \textcolor{keywordflow}{if} (cs\%num\_col\_v > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{315 }
\DoxyCodeLine{316       \textcolor{keyword}{allocate}(cs\%Iresttime\_col\_v(cs\%num\_col\_v)) ; cs\%Iresttime\_col\_v = 0.0}
\DoxyCodeLine{317       \textcolor{keyword}{allocate}(cs\%col\_i\_v(cs\%num\_col\_v))         ; cs\%col\_i\_v = 0}
\DoxyCodeLine{318       \textcolor{keyword}{allocate}(cs\%col\_j\_v(cs\%num\_col\_v))         ; cs\%col\_j\_v = 0}
\DoxyCodeLine{319 }
\DoxyCodeLine{320       \textcolor{comment}{! pass indices, restoring time to the CS structure}}
\DoxyCodeLine{321       col = 1}
\DoxyCodeLine{322       \textcolor{keywordflow}{do} j=cs\%jscB,cs\%jecB ; \textcolor{keywordflow}{do} i=cs\%isc,cs\%iec}
\DoxyCodeLine{323         \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g\%mask2dCv(i,j)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{324           cs\%col\_i\_v(col) = i ; cs\%col\_j\_v(col) = j}
\DoxyCodeLine{325           cs\%Iresttime\_col\_v(col) = iresttime\_v(i,j)}
\DoxyCodeLine{326           col = col + 1}
\DoxyCodeLine{327 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{328 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{329 }
\DoxyCodeLine{330       \textcolor{comment}{! same for total number of arbritary layers and correspondent data}}
\DoxyCodeLine{331       \textcolor{keyword}{allocate}(cs\%Ref\_hv\%p(cs\%nz\_data,cs\%num\_col\_v))}
\DoxyCodeLine{332       \textcolor{keywordflow}{do} col=1,cs\%num\_col\_v ; \textcolor{keywordflow}{do} k=1,cs\%nz\_data}
\DoxyCodeLine{333         cs\%Ref\_hv\%p(k,col) = data\_hv(cs\%col\_i\_v(col),cs\%col\_j\_v(col),k)}
\DoxyCodeLine{334 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{335 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{336     total\_sponge\_cols\_v = cs\%num\_col\_v}
\DoxyCodeLine{337     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_v)}
\DoxyCodeLine{338     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at v points"}, total\_sponge\_cols\_v, \&}
\DoxyCodeLine{339                  \textcolor{stringliteral}{"The total number of columns where sponges are applied at v points."}, like\_default=.true.)}
\DoxyCodeLine{340 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{341 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a0febb96fb2fd40a72580d078ca023098}\label{namespacemom__ale__sponge_a0febb96fb2fd40a72580d078ca023098}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!initialize\_ale\_sponge\_varying@{initialize\_ale\_sponge\_varying}}
\index{initialize\_ale\_sponge\_varying@{initialize\_ale\_sponge\_varying}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{initialize\_ale\_sponge\_varying()}{initialize\_ale\_sponge\_varying()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge\+\_\+varying (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in)}]{Iresttime,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine determines the number of points which are to be restoref in the computational domain. Only points that have positive values of Iresttime and which mask2dT indicates are ocean points are included in the sponges. 


\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 param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module (in/out). \\
\hline
\end{DoxyParams}


Definition at line 397 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{397 }
\DoxyCodeLine{398   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The ocean's grid structure.}}
\DoxyCodeLine{399 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(in)} :: Iresttime\textcolor{comment}{ !< The inverse of the restoring time [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{400   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure indicating the open file to parse}}
\DoxyCodeLine{401 \textcolor{comment}{                                                             !! for model parameter values.}}
\DoxyCodeLine{402   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),              \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< A pointer that is set to point to the control}}
\DoxyCodeLine{403 \textcolor{comment}{                                                     !! structure for this module (in/out).}}
\DoxyCodeLine{404 }
\DoxyCodeLine{405 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{406 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{407 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_sponge"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{408   \textcolor{keywordtype}{logical} :: use\_sponge}
\DoxyCodeLine{409 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_u\textcolor{comment}{ !< inverse of the restoring time at u points [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{410 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_v\textcolor{comment}{ !< inverse of the restoring time at v points [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{411   \textcolor{keywordtype}{logical} :: bndExtrapolation = .true. \textcolor{comment}{! If true, extrapolate boundaries}}
\DoxyCodeLine{412   \textcolor{keywordtype}{logical} :: default\_2018\_answers}
\DoxyCodeLine{413   \textcolor{keywordtype}{logical} :: spongeDataOngrid = .false.}
\DoxyCodeLine{414   \textcolor{keywordtype}{integer} :: i, j, k, col, total\_sponge\_cols, total\_sponge\_cols\_u, total\_sponge\_cols\_v}
\DoxyCodeLine{415   \textcolor{keywordtype}{character(len=10)}  :: remapScheme}
\DoxyCodeLine{416 }
\DoxyCodeLine{417   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{418     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_ALE\_sponge\_varying called with an associated "}// \&}
\DoxyCodeLine{419                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{420     \textcolor{keywordflow}{return}}
\DoxyCodeLine{421 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{422 \textcolor{comment}{! Set default, read and log parameters}}
\DoxyCodeLine{423   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{424   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, use\_sponge, \&}
\DoxyCodeLine{425                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//\&}
\DoxyCodeLine{426                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//\&}
\DoxyCodeLine{427                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)}
\DoxyCodeLine{428   \textcolor{keywordflow}{if} (.not.use\_sponge) \textcolor{keywordflow}{return}}
\DoxyCodeLine{429   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{430   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_UV"}, cs\%sponge\_uv, \&}
\DoxyCodeLine{431                  \textcolor{stringliteral}{"Apply sponges in u and v, in addition to tracers."}, \&}
\DoxyCodeLine{432                  default=.false.)}
\DoxyCodeLine{433   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, remapscheme, \&}
\DoxyCodeLine{434                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//\&}
\DoxyCodeLine{435                  \textcolor{stringliteral}{" for vertical remapping for all variables."}, \&}
\DoxyCodeLine{436                  default=\textcolor{stringliteral}{"PLM"}, do\_not\_log=.true.)}
\DoxyCodeLine{437   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BOUNDARY\_EXTRAPOLATION"}, bndextrapolation, \&}
\DoxyCodeLine{438                  \textcolor{stringliteral}{"When defined, a proper high-\/order reconstruction "}//\&}
\DoxyCodeLine{439                  \textcolor{stringliteral}{"scheme is used within boundary cells rather "}//\&}
\DoxyCodeLine{440                  \textcolor{stringliteral}{"than PCM. E.g., if PPM is used for remapping, a "}//\&}
\DoxyCodeLine{441                  \textcolor{stringliteral}{"PPM reconstruction will also be used within boundary cells."}, \&}
\DoxyCodeLine{442                  default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{443   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{444                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{445                  default=.false.)}
\DoxyCodeLine{446   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs\%remap\_answers\_2018, \&}
\DoxyCodeLine{447                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//\&}
\DoxyCodeLine{448                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//\&}
\DoxyCodeLine{449                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{450   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_DATA\_ONGRID"}, cs\%spongeDataOngrid, \&}
\DoxyCodeLine{451                  \textcolor{stringliteral}{"When defined, the incoming sponge data are "}//\&}
\DoxyCodeLine{452                  \textcolor{stringliteral}{"assumed to be on the model grid "} , \&}
\DoxyCodeLine{453                  default=.false.)}
\DoxyCodeLine{454   cs\%time\_varying\_sponges = .true.}
\DoxyCodeLine{455   cs\%nz = g\%ke}
\DoxyCodeLine{456   cs\%isc = g\%isc ; cs\%iec = g\%iec ; cs\%jsc = g\%jsc ; cs\%jec = g\%jec}
\DoxyCodeLine{457   cs\%isd = g\%isd ; cs\%ied = g\%ied ; cs\%jsd = g\%jsd ; cs\%jed = g\%jed}
\DoxyCodeLine{458   cs\%iscB = g\%iscB ; cs\%iecB = g\%iecB; cs\%jscB = g\%jscB ; cs\%jecB = g\%jecB}
\DoxyCodeLine{459 }
\DoxyCodeLine{460   \textcolor{comment}{! number of columns to be restored}}
\DoxyCodeLine{461   cs\%num\_col = 0 ; cs\%fldno = 0}
\DoxyCodeLine{462   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{463     \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g\%mask2dT(i,j)>0)) \&}
\DoxyCodeLine{464       cs\%num\_col = cs\%num\_col + 1}
\DoxyCodeLine{465 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{466   \textcolor{keywordflow}{if} (cs\%num\_col > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{467     \textcolor{keyword}{allocate}(cs\%Iresttime\_col(cs\%num\_col)) ; cs\%Iresttime\_col = 0.0}
\DoxyCodeLine{468     \textcolor{keyword}{allocate}(cs\%col\_i(cs\%num\_col))         ; cs\%col\_i = 0}
\DoxyCodeLine{469     \textcolor{keyword}{allocate}(cs\%col\_j(cs\%num\_col))         ; cs\%col\_j = 0}
\DoxyCodeLine{470     \textcolor{comment}{! pass indices, restoring time to the CS structure}}
\DoxyCodeLine{471     col = 1}
\DoxyCodeLine{472     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{473       \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g\%mask2dT(i,j)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{474         cs\%col\_i(col) = i ; cs\%col\_j(col) = j}
\DoxyCodeLine{475         cs\%Iresttime\_col(col) = iresttime(i,j)}
\DoxyCodeLine{476         col = col +1}
\DoxyCodeLine{477 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{478 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{479 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{480   total\_sponge\_cols = cs\%num\_col}
\DoxyCodeLine{481   \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols)}
\DoxyCodeLine{482 }
\DoxyCodeLine{483 \textcolor{comment}{! Call the constructor for remapping control structure}}
\DoxyCodeLine{484   \textcolor{keyword}{call }initialize\_remapping(cs\%remap\_cs, remapscheme, boundary\_extrapolation=bndextrapolation, \&}
\DoxyCodeLine{485                             answers\_2018=cs\%remap\_answers\_2018)}
\DoxyCodeLine{486   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at h points"}, total\_sponge\_cols, \&}
\DoxyCodeLine{487                  \textcolor{stringliteral}{"The total number of columns where sponges are applied at h points."}, like\_default=.true.)}
\DoxyCodeLine{488   \textcolor{keywordflow}{if} (cs\%sponge\_uv) \textcolor{keywordflow}{then}}
\DoxyCodeLine{489     \textcolor{keyword}{allocate}(iresttime\_u(g\%isdB:g\%iedB,g\%jsd:g\%jed)) ; iresttime\_u(:,:) = 0.0}
\DoxyCodeLine{490     \textcolor{keyword}{allocate}(iresttime\_v(g\%isd:g\%ied,g\%jsdB:g\%jedB)) ; iresttime\_v(:,:) = 0.0}
\DoxyCodeLine{491     \textcolor{comment}{! u points}}
\DoxyCodeLine{492     cs\%num\_col\_u = 0 ; \textcolor{comment}{!CS\%fldno\_u = 0}}
\DoxyCodeLine{493     \textcolor{keywordflow}{do} j=cs\%jsc,cs\%jec; \textcolor{keywordflow}{do} i=cs\%iscB,cs\%iecB}
\DoxyCodeLine{494       iresttime\_u(i,j) = 0.5 * (iresttime(i,j) + iresttime(i+1,j))}
\DoxyCodeLine{495       \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g\%mask2dCu(i,j)>0)) \&}
\DoxyCodeLine{496         cs\%num\_col\_u = cs\%num\_col\_u + 1}
\DoxyCodeLine{497 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{498     \textcolor{keywordflow}{if} (cs\%num\_col\_u > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{499       \textcolor{keyword}{allocate}(cs\%Iresttime\_col\_u(cs\%num\_col\_u)) ; cs\%Iresttime\_col\_u = 0.0}
\DoxyCodeLine{500       \textcolor{keyword}{allocate}(cs\%col\_i\_u(cs\%num\_col\_u))         ; cs\%col\_i\_u = 0}
\DoxyCodeLine{501       \textcolor{keyword}{allocate}(cs\%col\_j\_u(cs\%num\_col\_u))         ; cs\%col\_j\_u = 0}
\DoxyCodeLine{502       \textcolor{comment}{! pass indices, restoring time to the CS structure}}
\DoxyCodeLine{503       col = 1}
\DoxyCodeLine{504       \textcolor{keywordflow}{do} j=cs\%jsc,cs\%jec ; \textcolor{keywordflow}{do} i=cs\%iscB,cs\%iecB}
\DoxyCodeLine{505         \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g\%mask2dCu(i,j)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{506           cs\%col\_i\_u(col) = i ; cs\%col\_j\_u(col) = j}
\DoxyCodeLine{507           cs\%Iresttime\_col\_u(col) = iresttime\_u(i,j)}
\DoxyCodeLine{508           col = col +1}
\DoxyCodeLine{509 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{510 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{511       \textcolor{comment}{! same for total number of arbritary layers and correspondent data}}
\DoxyCodeLine{512 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{513     total\_sponge\_cols\_u = cs\%num\_col\_u}
\DoxyCodeLine{514     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_u)}
\DoxyCodeLine{515     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at u points"}, total\_sponge\_cols\_u, \&}
\DoxyCodeLine{516                 \textcolor{stringliteral}{"The total number of columns where sponges are applied at u points."}, like\_default=.true.)}
\DoxyCodeLine{517     \textcolor{comment}{! v points}}
\DoxyCodeLine{518     cs\%num\_col\_v = 0 ; \textcolor{comment}{!CS\%fldno\_v = 0}}
\DoxyCodeLine{519     \textcolor{keywordflow}{do} j=cs\%jscB,cs\%jecB; \textcolor{keywordflow}{do} i=cs\%isc,cs\%iec}
\DoxyCodeLine{520       iresttime\_v(i,j) = 0.5 * (iresttime(i,j) + iresttime(i,j+1))}
\DoxyCodeLine{521       \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g\%mask2dCv(i,j)>0)) \&}
\DoxyCodeLine{522         cs\%num\_col\_v = cs\%num\_col\_v + 1}
\DoxyCodeLine{523 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{524     \textcolor{keywordflow}{if} (cs\%num\_col\_v > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{525       \textcolor{keyword}{allocate}(cs\%Iresttime\_col\_v(cs\%num\_col\_v)) ; cs\%Iresttime\_col\_v = 0.0}
\DoxyCodeLine{526       \textcolor{keyword}{allocate}(cs\%col\_i\_v(cs\%num\_col\_v))         ; cs\%col\_i\_v = 0}
\DoxyCodeLine{527       \textcolor{keyword}{allocate}(cs\%col\_j\_v(cs\%num\_col\_v))         ; cs\%col\_j\_v = 0}
\DoxyCodeLine{528       \textcolor{comment}{! pass indices, restoring time to the CS structure}}
\DoxyCodeLine{529       col = 1}
\DoxyCodeLine{530       \textcolor{keywordflow}{do} j=cs\%jscB,cs\%jecB ; \textcolor{keywordflow}{do} i=cs\%isc,cs\%iec}
\DoxyCodeLine{531         \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g\%mask2dCv(i,j)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{532           cs\%col\_i\_v(col) = i ; cs\%col\_j\_v(col) = j}
\DoxyCodeLine{533           cs\%Iresttime\_col\_v(col) = iresttime\_v(i,j)}
\DoxyCodeLine{534           col = col +1}
\DoxyCodeLine{535 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{536 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{537 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{538     total\_sponge\_cols\_v = cs\%num\_col\_v}
\DoxyCodeLine{539     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_v)}
\DoxyCodeLine{540     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at v points"}, total\_sponge\_cols\_v, \&}
\DoxyCodeLine{541                 \textcolor{stringliteral}{"The total number of columns where sponges are applied at v points."}, like\_default=.true.)}
\DoxyCodeLine{542 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{543 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a0c718798e303111ea3110d5ff07bad5c}\label{namespacemom__ale__sponge_a0c718798e303111ea3110d5ff07bad5c}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!rotate\_ale\_sponge@{rotate\_ale\_sponge}}
\index{rotate\_ale\_sponge@{rotate\_ale\_sponge}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{rotate\_ale\_sponge()}{rotate\_ale\_sponge()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+\_\+sponge\+::rotate\+\_\+ale\+\_\+sponge (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), intent(in)}]{sponge\+\_\+in,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{sponge,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{integer, intent(in)}]{turns,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}



Rotate the A\+LE sponge fields from the input to the model index map. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em sponge\+\_\+in} & The control structure for this module with the original grid rotation \\
\hline
\mbox{\texttt{ in}}  & {\em g\+\_\+in} & The ocean\textquotesingle{}s grid structure with the original rotation. \\
\hline
 & {\em sponge} & A pointer to the control that will be set up with the new grid rotation \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure with the new rotation. \\
\hline
\mbox{\texttt{ in}}  & {\em turns} & The number of 90-\/degree turns between grids \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
\end{DoxyParams}


Definition at line 1006 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1006   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),   \textcolor{keywordtype}{intent(in)} :: sponge\_in\textcolor{comment}{ !< The control structure for this module with the}}
\DoxyCodeLine{1007 \textcolor{comment}{                                                 !! original grid rotation}}
\DoxyCodeLine{1008   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\_in\textcolor{comment}{      !< The ocean's grid structure with the original rotation.}}
\DoxyCodeLine{1009   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),   \textcolor{keywordtype}{pointer}    :: sponge\textcolor{comment}{    !< A pointer to the control that will be set up with}}
\DoxyCodeLine{1010 \textcolor{comment}{                                                 !! the new grid rotation}}
\DoxyCodeLine{1011   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{         !< The ocean's grid structure with the new rotation.}}
\DoxyCodeLine{1012   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: turns\textcolor{comment}{     !< The number of 90-\/degree turns between grids}}
\DoxyCodeLine{1013   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure indicating the open file}}
\DoxyCodeLine{1014 \textcolor{comment}{                                                 !! to parse for model parameter values.}}
\DoxyCodeLine{1015 }
\DoxyCodeLine{1016   \textcolor{comment}{! First part: Index construction}}
\DoxyCodeLine{1017   \textcolor{comment}{!   1. Reconstruct Iresttime(:,:) from sponge\_in}}
\DoxyCodeLine{1018   \textcolor{comment}{!   2. rotate Iresttime(:,:)}}
\DoxyCodeLine{1019   \textcolor{comment}{!   3. Call initialize\_ALE\_sponge using new grid and rotated Iresttime(:,:)}}
\DoxyCodeLine{1020   \textcolor{comment}{! All the index adjustment should follow from the Iresttime rotation}}
\DoxyCodeLine{1021 }
\DoxyCodeLine{1022 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable} :: Iresttime\_in, Iresttime}
\DoxyCodeLine{1023 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: data\_h\_in, data\_h}
\DoxyCodeLine{1024 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: sp\_val\_in, sp\_val}
\DoxyCodeLine{1025 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: sp\_ptr => null()}
\DoxyCodeLine{1026   \textcolor{keywordtype}{integer} :: c, c\_i, c\_j}
\DoxyCodeLine{1027   \textcolor{keywordtype}{integer} :: k, nz\_data}
\DoxyCodeLine{1028   \textcolor{keywordtype}{integer} :: n}
\DoxyCodeLine{1029   \textcolor{keywordtype}{logical} :: fixed\_sponge}
\DoxyCodeLine{1030 }
\DoxyCodeLine{1031   fixed\_sponge = .not. sponge\_in\%time\_varying\_sponges}
\DoxyCodeLine{1032   \textcolor{comment}{! NOTE: nz\_data is only conditionally set when fixed\_sponge is true.}}
\DoxyCodeLine{1033 }
\DoxyCodeLine{1034   \textcolor{keyword}{allocate}(iresttime\_in(g\_in\%isd:g\_in\%ied, g\_in\%jsd:g\_in\%jed))}
\DoxyCodeLine{1035   \textcolor{keyword}{allocate}(iresttime(g\%isd:g\%ied, g\%jsd:g\%jed))}
\DoxyCodeLine{1036   iresttime\_in(:,:) = 0.0}
\DoxyCodeLine{1037 }
\DoxyCodeLine{1038   \textcolor{keywordflow}{if} (fixed\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1039     nz\_data = sponge\_in\%nz\_data}
\DoxyCodeLine{1040     \textcolor{keyword}{allocate}(data\_h\_in(g\_in\%isd:g\_in\%ied, g\_in\%jsd:g\_in\%jed, nz\_data))}
\DoxyCodeLine{1041     \textcolor{keyword}{allocate}(data\_h(g\%isd:g\%ied, g\%jsd:g\%jed, nz\_data))}
\DoxyCodeLine{1042     data\_h\_in(:,:,:) = 0.}
\DoxyCodeLine{1043 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1044 }
\DoxyCodeLine{1045   \textcolor{comment}{! Re-\/populate the 2D Iresttime and data\_h arrays on the original grid}}
\DoxyCodeLine{1046   \textcolor{keywordflow}{do} c=1,sponge\_in\%num\_col}
\DoxyCodeLine{1047     c\_i = sponge\_in\%col\_i(c)}
\DoxyCodeLine{1048     c\_j = sponge\_in\%col\_j(c)}
\DoxyCodeLine{1049     iresttime\_in(c\_i, c\_j) = sponge\_in\%Iresttime\_col(c)}
\DoxyCodeLine{1050     \textcolor{keywordflow}{if} (fixed\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1051       \textcolor{keywordflow}{do} k = 1, nz\_data}
\DoxyCodeLine{1052         data\_h(c\_i, c\_j, k) = sponge\_in\%Ref\_h\%p(k,c)}
\DoxyCodeLine{1053 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1054 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1055 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1056 }
\DoxyCodeLine{1057   \textcolor{keyword}{call }rotate\_array(iresttime\_in, turns, iresttime)}
\DoxyCodeLine{1058   \textcolor{keywordflow}{if} (fixed\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1059     \textcolor{keyword}{call }rotate\_array(data\_h\_in, turns, data\_h)}
\DoxyCodeLine{1060     \textcolor{keyword}{call }initialize\_ale\_sponge\_fixed(iresttime, g, param\_file, sponge, \&}
\DoxyCodeLine{1061                                      data\_h, nz\_data)}
\DoxyCodeLine{1062   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1063     \textcolor{keyword}{call }initialize\_ale\_sponge\_varying(iresttime, g, param\_file, sponge)}
\DoxyCodeLine{1064 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1065 }
\DoxyCodeLine{1066   \textcolor{keyword}{deallocate}(iresttime\_in)}
\DoxyCodeLine{1067   \textcolor{keyword}{deallocate}(iresttime)}
\DoxyCodeLine{1068   \textcolor{keywordflow}{if} (fixed\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1069     \textcolor{keyword}{deallocate}(data\_h\_in)}
\DoxyCodeLine{1070     \textcolor{keyword}{deallocate}(data\_h)}
\DoxyCodeLine{1071 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1072 }
\DoxyCodeLine{1073   \textcolor{comment}{! Second part: Provide rotated fields for which relaxation is applied}}
\DoxyCodeLine{1074 }
\DoxyCodeLine{1075   sponge\%fldno = sponge\_in\%fldno}
\DoxyCodeLine{1076 }
\DoxyCodeLine{1077   \textcolor{keywordflow}{if} (fixed\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1078     \textcolor{keyword}{allocate}(sp\_val\_in(g\_in\%isd:g\_in\%ied, g\_in\%jsd:g\_in\%jed, nz\_data))}
\DoxyCodeLine{1079     \textcolor{keyword}{allocate}(sp\_val(g\%isd:g\%ied, g\%jsd:g\%jed, nz\_data))}
\DoxyCodeLine{1080 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1081 }
\DoxyCodeLine{1082   \textcolor{keywordflow}{do} n=1,sponge\_in\%fldno}
\DoxyCodeLine{1083     \textcolor{comment}{! Assume that tracers are pointers and are remapped in other functions(?)}}
\DoxyCodeLine{1084     sp\_ptr => sponge\_in\%var(n)\%p}
\DoxyCodeLine{1085     \textcolor{keywordflow}{if} (fixed\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1086       sp\_val\_in(:,:,:) = 0.0}
\DoxyCodeLine{1087       \textcolor{keywordflow}{do} c = 1, sponge\_in\%num\_col}
\DoxyCodeLine{1088         c\_i = sponge\_in\%col\_i(c)}
\DoxyCodeLine{1089         c\_j = sponge\_in\%col\_j(c)}
\DoxyCodeLine{1090         \textcolor{keywordflow}{do} k = 1, nz\_data}
\DoxyCodeLine{1091           sp\_val\_in(c\_i, c\_j, k) = sponge\_in\%Ref\_val(n)\%p(k,c)}
\DoxyCodeLine{1092 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{1093 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1094 }
\DoxyCodeLine{1095       \textcolor{keyword}{call }rotate\_array(sp\_val\_in, turns, sp\_val)}
\DoxyCodeLine{1096 }
\DoxyCodeLine{1097       \textcolor{comment}{! NOTE: This points sp\_val with the unrotated field.  See note below.}}
\DoxyCodeLine{1098       \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(sp\_val, g, sp\_ptr, sponge)}
\DoxyCodeLine{1099 }
\DoxyCodeLine{1100       \textcolor{keyword}{deallocate}(sp\_val\_in)}
\DoxyCodeLine{1101     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1102       \textcolor{comment}{! We don't want to repeat FMS init in set\_up\_ALE\_sponge\_field\_varying()}}
\DoxyCodeLine{1103       \textcolor{comment}{! (time\_interp\_external\_init, init\_external\_field, etc), so we manually}}
\DoxyCodeLine{1104       \textcolor{comment}{! do a portion of this function below.}}
\DoxyCodeLine{1105       sponge\%Ref\_val(n)\%id = sponge\_in\%Ref\_val(n)\%id}
\DoxyCodeLine{1106       sponge\%Ref\_val(n)\%num\_tlevs = sponge\_in\%Ref\_val(n)\%num\_tlevs}
\DoxyCodeLine{1107 }
\DoxyCodeLine{1108       nz\_data = sponge\_in\%Ref\_val(n)\%nz\_data}
\DoxyCodeLine{1109       sponge\%Ref\_val(n)\%nz\_data = nz\_data}
\DoxyCodeLine{1110 }
\DoxyCodeLine{1111       \textcolor{keyword}{allocate}(sponge\%Ref\_val(n)\%p(nz\_data, sponge\_in\%num\_col))}
\DoxyCodeLine{1112       \textcolor{keyword}{allocate}(sponge\%Ref\_val(n)\%h(nz\_data, sponge\_in\%num\_col))}
\DoxyCodeLine{1113       sponge\%Ref\_val(n)\%p(:,:) = 0.0}
\DoxyCodeLine{1114       sponge\%Ref\_val(n)\%h(:,:) = 0.0}
\DoxyCodeLine{1115 }
\DoxyCodeLine{1116       \textcolor{comment}{! TODO: There is currently no way to associate a generic field pointer to}}
\DoxyCodeLine{1117       \textcolor{comment}{!   its rotated equivalent without introducing a new data structure which}}
\DoxyCodeLine{1118       \textcolor{comment}{!   explicitly tracks the pairing.}}
\DoxyCodeLine{1119       \textcolor{comment}{!}}
\DoxyCodeLine{1120       \textcolor{comment}{!   As a temporary fix, we store the pointer to the unrotated field in}}
\DoxyCodeLine{1121       \textcolor{comment}{!   the rotated sponge, and use this reference to replace the pointer}}
\DoxyCodeLine{1122       \textcolor{comment}{!   to the rotated field update\_ALE\_sponge field.}}
\DoxyCodeLine{1123       \textcolor{comment}{!}}
\DoxyCodeLine{1124       \textcolor{comment}{!   This makes a lot of unverifiable assumptions, and should not be}}
\DoxyCodeLine{1125       \textcolor{comment}{!   considered the final solution.}}
\DoxyCodeLine{1126       sponge\%var(n)\%p => sp\_ptr}
\DoxyCodeLine{1127 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1128 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1129 }
\DoxyCodeLine{1130   \textcolor{comment}{! TODO: var\_u and var\_v sponge dampling is not yet supported.}}
\DoxyCodeLine{1131   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(sponge\_in\%var\_u\%p) .or. \textcolor{keyword}{associated}(sponge\_in\%var\_v\%p)) \&}
\DoxyCodeLine{1132     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Rotation of ALE sponge velocities is not yet "} \&}
\DoxyCodeLine{1133       // \textcolor{stringliteral}{"implemented."})}
\DoxyCodeLine{1134 }
\DoxyCodeLine{1135   \textcolor{comment}{! Transfer any existing diag\_CS reference pointer}}
\DoxyCodeLine{1136   sponge\%diag => sponge\_in\%diag}
\DoxyCodeLine{1137 }
\DoxyCodeLine{1138   \textcolor{comment}{! NOTE: initialize\_ALE\_sponge\_* resolves remap\_cs}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a7b00598b2cf45b865f56515ed5d2ed0a}\label{namespacemom__ale__sponge_a7b00598b2cf45b865f56515ed5d2ed0a}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!set\_up\_ale\_sponge\_field\_fixed@{set\_up\_ale\_sponge\_field\_fixed}}
\index{set\_up\_ale\_sponge\_field\_fixed@{set\_up\_ale\_sponge\_field\_fixed}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{set\_up\_ale\_sponge\_field\_fixed()}{set\_up\_ale\_sponge\_field\_fixed()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+field\+\_\+fixed (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,cs\%nz\+\_\+data), intent(in)}]{sp\+\_\+val,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in), target}]{f\+\_\+ptr,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine stores the reference profile at h points for the variable whose address is given by f\+\_\+ptr. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Grid structure \\
\hline
 & {\em cs} & A\+LE sponge control structure (in/out). \\
\hline
\mbox{\texttt{ in}}  & {\em sp\+\_\+val} & Field to be used in the sponge, it has arbitrary number of layers. \\
\hline
\mbox{\texttt{ in}}  & {\em f\+\_\+ptr} & Pointer to the field to be damped \\
\hline
\end{DoxyParams}


Definition at line 564 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{564   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< Grid structure}}
\DoxyCodeLine{565   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),   \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< ALE sponge control structure (in/out).}}
\DoxyCodeLine{566 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),CS\%nz\_data)}, \&}
\DoxyCodeLine{567                          \textcolor{keywordtype}{intent(in)} :: sp\_val\textcolor{comment}{ !< Field to be used in the sponge, it has arbitrary number of layers.}}
\DoxyCodeLine{568 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{569                  \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: f\_ptr\textcolor{comment}{ !< Pointer to the field to be damped}}
\DoxyCodeLine{570 }
\DoxyCodeLine{571   \textcolor{keywordtype}{integer} :: j, k, col}
\DoxyCodeLine{572   \textcolor{keywordtype}{character(len=256)} :: mesg \textcolor{comment}{! String for error messages}}
\DoxyCodeLine{573 }
\DoxyCodeLine{574   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{575 }
\DoxyCodeLine{576   cs\%fldno = cs\%fldno + 1}
\DoxyCodeLine{577 }
\DoxyCodeLine{578   \textcolor{keywordflow}{if} (cs\%fldno > max\_fields\_) \textcolor{keywordflow}{then}}
\DoxyCodeLine{579     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Increase MAX\_FIELDS\_ to at least ",I3," in MOM\_memory.h or decrease \&}}
\DoxyCodeLine{580 \textcolor{stringliteral}{}\textcolor{stringliteral}{           \&the number of fields to be damped in the call to \&}}
\DoxyCodeLine{581 \textcolor{stringliteral}{}\textcolor{stringliteral}{           \&initialize\_ALE\_sponge." )'}) cs\%fldno}
\DoxyCodeLine{582     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"set\_up\_ALE\_sponge\_field: "}//mesg)}
\DoxyCodeLine{583 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{584 }
\DoxyCodeLine{585   \textcolor{comment}{! stores the reference profile}}
\DoxyCodeLine{586   \textcolor{keyword}{allocate}(cs\%Ref\_val(cs\%fldno)\%p(cs\%nz\_data,cs\%num\_col))}
\DoxyCodeLine{587   cs\%Ref\_val(cs\%fldno)\%p(:,:) = 0.0}
\DoxyCodeLine{588   \textcolor{keywordflow}{do} col=1,cs\%num\_col}
\DoxyCodeLine{589     \textcolor{keywordflow}{do} k=1,cs\%nz\_data}
\DoxyCodeLine{590       cs\%Ref\_val(cs\%fldno)\%p(k,col) = sp\_val(cs\%col\_i(col),cs\%col\_j(col),k)}
\DoxyCodeLine{591 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{592 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{593 }
\DoxyCodeLine{594   cs\%var(cs\%fldno)\%p => f\_ptr}
\DoxyCodeLine{595 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a5222905f5cfddd07b77e05428e88dd85}\label{namespacemom__ale__sponge_a5222905f5cfddd07b77e05428e88dd85}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!set\_up\_ale\_sponge\_field\_varying@{set\_up\_ale\_sponge\_field\_varying}}
\index{set\_up\_ale\_sponge\_field\_varying@{set\_up\_ale\_sponge\_field\_varying}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{set\_up\_ale\_sponge\_field\_varying()}{set\_up\_ale\_sponge\_field\_varying()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+field\+\_\+varying (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{fieldname,  }\item[{type(time\+\_\+type), intent(in)}]{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[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in), target}]{f\+\_\+ptr,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine stores the reference profile at h points for the variable whose address is given by filename and fieldname. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file with the time varying field data \\
\hline
\mbox{\texttt{ in}}  & {\em fieldname} & The name of the field in the file with the time varying field data \\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Grid structure (in). \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em f\+\_\+ptr} & Pointer to the field to be damped (in). \\
\hline
 & {\em cs} & Sponge control structure (in/out). \\
\hline
\end{DoxyParams}


Definition at line 601 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{601   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: filename\textcolor{comment}{ !< The name of the file with the}}
\DoxyCodeLine{602 \textcolor{comment}{                                                  !! time varying field data}}
\DoxyCodeLine{603   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: fieldname\textcolor{comment}{ !< The name of the field in the file}}
\DoxyCodeLine{604 \textcolor{comment}{                                                  !! with the time varying field data}}
\DoxyCodeLine{605   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{  !< The current model time}}
\DoxyCodeLine{606   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{     !< Grid structure (in).}}
\DoxyCodeLine{607   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{    !< ocean vertical grid structure}}
\DoxyCodeLine{608   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{    !< A dimensional unit scaling type}}
\DoxyCodeLine{609 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{610                    \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: f\_ptr\textcolor{comment}{ !< Pointer to the field to be damped (in).}}
\DoxyCodeLine{611   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{    !< Sponge control structure (in/out).}}
\DoxyCodeLine{612 }
\DoxyCodeLine{613   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{614 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: sp\_val\textcolor{comment}{ !< Field to be used in the sponge}}
\DoxyCodeLine{615 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: mask\_z\textcolor{comment}{ !< Field mask for the sponge data}}
\DoxyCodeLine{616 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{target} :: z\_in, z\_edges\_in \textcolor{comment}{! Heights [Z \string~> m].}}
\DoxyCodeLine{617 \textcolor{keywordtype}{  real} :: missing\_value}
\DoxyCodeLine{618   \textcolor{keywordtype}{integer} :: j, k, col}
\DoxyCodeLine{619   \textcolor{keywordtype}{integer} :: isd,ied,jsd,jed}
\DoxyCodeLine{620   \textcolor{keywordtype}{integer} :: nPoints}
\DoxyCodeLine{621   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(4)} :: fld\_sz}
\DoxyCodeLine{622   \textcolor{keywordtype}{integer} :: nz\_data\textcolor{comment}{ !< the number of vertical levels in this input field}}
\DoxyCodeLine{623   \textcolor{keywordtype}{character(len=256)} :: mesg \textcolor{comment}{! String for error messages}}
\DoxyCodeLine{624   \textcolor{comment}{! Local variables for ALE remapping}}
\DoxyCodeLine{625 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: tmpT1d}
\DoxyCodeLine{626 \textcolor{keywordtype}{  real} :: zTopOfCell, zBottomOfCell \textcolor{comment}{! Heights [Z \string~> m].}}
\DoxyCodeLine{627   \textcolor{keywordtype}{type}(remapping\_CS) :: remapCS \textcolor{comment}{! Remapping parameters and work arrays}}
\DoxyCodeLine{628 }
\DoxyCodeLine{629   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{630   \textcolor{comment}{! initialize time interpolator module}}
\DoxyCodeLine{631   \textcolor{keyword}{call }time\_interp\_external\_init()}
\DoxyCodeLine{632   isd = g\%isd; ied = g\%ied; jsd = g\%jsd; jed = g\%jed}
\DoxyCodeLine{633   cs\%fldno = cs\%fldno + 1}
\DoxyCodeLine{634   \textcolor{keywordflow}{if} (cs\%fldno > max\_fields\_) \textcolor{keywordflow}{then}}
\DoxyCodeLine{635     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Increase MAX\_FIELDS\_ to at least ",I3," in MOM\_memory.h or decrease \&}}
\DoxyCodeLine{636 \textcolor{stringliteral}{}\textcolor{stringliteral}{           \&the number of fields to be damped in the call to \&}}
\DoxyCodeLine{637 \textcolor{stringliteral}{}\textcolor{stringliteral}{           \&initialize\_ALE\_sponge." )'}) cs\%fldno}
\DoxyCodeLine{638     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"set\_up\_ALE\_sponge\_field: "}//mesg)}
\DoxyCodeLine{639 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{640   \textcolor{comment}{! get a unique time interp id for this field. If sponge data is ongrid, then setup}}
\DoxyCodeLine{641   \textcolor{comment}{! to only read on the computational domain}}
\DoxyCodeLine{642   \textcolor{keywordflow}{if} (cs\%spongeDataOngrid) \textcolor{keywordflow}{then}}
\DoxyCodeLine{643     cs\%Ref\_val(cs\%fldno)\%id = init\_external\_field(filename, fieldname,domain=g\%Domain\%mpp\_domain)}
\DoxyCodeLine{644   \textcolor{keywordflow}{else}}
\DoxyCodeLine{645     cs\%Ref\_val(cs\%fldno)\%id = init\_external\_field(filename, fieldname)}
\DoxyCodeLine{646 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{647   fld\_sz(1:4)=-\/1}
\DoxyCodeLine{648   fld\_sz = get\_external\_field\_size(cs\%Ref\_val(cs\%fldno)\%id)}
\DoxyCodeLine{649   nz\_data = fld\_sz(3)}
\DoxyCodeLine{650   cs\%Ref\_val(cs\%fldno)\%nz\_data = nz\_data \textcolor{comment}{!< individual sponge fields may reside on a different vertical grid}}
\DoxyCodeLine{651   cs\%Ref\_val(cs\%fldno)\%num\_tlevs = fld\_sz(4)}
\DoxyCodeLine{652   \textcolor{comment}{! initializes the target profile array for this field}}
\DoxyCodeLine{653   \textcolor{comment}{! for all columns which will be masked}}
\DoxyCodeLine{654   \textcolor{keyword}{allocate}(cs\%Ref\_val(cs\%fldno)\%p(nz\_data,cs\%num\_col))}
\DoxyCodeLine{655   cs\%Ref\_val(cs\%fldno)\%p(:,:) = 0.0}
\DoxyCodeLine{656   \textcolor{keyword}{allocate}( cs\%Ref\_val(cs\%fldno)\%h(nz\_data,cs\%num\_col) )}
\DoxyCodeLine{657   cs\%Ref\_val(cs\%fldno)\%h(:,:) = 0.0}
\DoxyCodeLine{658   cs\%var(cs\%fldno)\%p => f\_ptr}
\DoxyCodeLine{659 }
\DoxyCodeLine{660 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a6eb21c5a149d573ba0d67fdb3a932115}\label{namespacemom__ale__sponge_a6eb21c5a149d573ba0d67fdb3a932115}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!set\_up\_ale\_sponge\_vel\_field\_fixed@{set\_up\_ale\_sponge\_vel\_field\_fixed}}
\index{set\_up\_ale\_sponge\_vel\_field\_fixed@{set\_up\_ale\_sponge\_vel\_field\_fixed}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{set\_up\_ale\_sponge\_vel\_field\_fixed()}{set\_up\_ale\_sponge\_vel\_field\_fixed()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+vel\+\_\+field\+\_\+fixed (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed,cs\%nz\+\_\+data), intent(in)}]{u\+\_\+val,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb,cs\%nz\+\_\+data), intent(in)}]{v\+\_\+val,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in), target}]{u\+\_\+ptr,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in), target}]{v\+\_\+ptr,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine stores the reference profile at u and v points for the variable whose address is given by u\+\_\+ptr and v\+\_\+ptr. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Grid structure (in). \\
\hline
 & {\em cs} & Sponge structure (in/out). \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+val} & u field to be used in the sponge, it has arbritary number of layers. \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+val} & v field to be used in the sponge, it has arbritary number of layers. \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+ptr} & u pointer to the field to be damped \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+ptr} & v pointer to the field to be damped \\
\hline
\end{DoxyParams}


Definition at line 666 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{666   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< Grid structure (in).}}
\DoxyCodeLine{667   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),   \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< Sponge structure (in/out).}}
\DoxyCodeLine{668 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),CS\%nz\_data)}, \&}
\DoxyCodeLine{669                          \textcolor{keywordtype}{intent(in)} :: u\_val\textcolor{comment}{ !< u field to be used in the sponge, it has arbritary number of layers.}}
\DoxyCodeLine{670 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),CS\%nz\_data)}, \&}
\DoxyCodeLine{671                          \textcolor{keywordtype}{intent(in)} :: v\_val\textcolor{comment}{ !< v field to be used in the sponge, it has arbritary number of layers.}}
\DoxyCodeLine{672 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: u\_ptr\textcolor{comment}{ !< u pointer to the field to be damped}}
\DoxyCodeLine{673 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: v\_ptr\textcolor{comment}{ !< v pointer to the field to be damped}}
\DoxyCodeLine{674 }
\DoxyCodeLine{675   \textcolor{keywordtype}{integer} :: j, k, col}
\DoxyCodeLine{676   \textcolor{keywordtype}{character(len=256)} :: mesg \textcolor{comment}{! String for error messages}}
\DoxyCodeLine{677 }
\DoxyCodeLine{678   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{679 }
\DoxyCodeLine{680   \textcolor{comment}{! stores the reference profile}}
\DoxyCodeLine{681   \textcolor{keyword}{allocate}(cs\%Ref\_val\_u\%p(cs\%nz\_data,cs\%num\_col\_u))}
\DoxyCodeLine{682   cs\%Ref\_val\_u\%p(:,:) = 0.0}
\DoxyCodeLine{683   \textcolor{keywordflow}{do} col=1,cs\%num\_col\_u}
\DoxyCodeLine{684     \textcolor{keywordflow}{do} k=1,cs\%nz\_data}
\DoxyCodeLine{685       cs\%Ref\_val\_u\%p(k,col) = u\_val(cs\%col\_i\_u(col),cs\%col\_j\_u(col),k)}
\DoxyCodeLine{686 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{687 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{688   cs\%var\_u\%p => u\_ptr}
\DoxyCodeLine{689   \textcolor{keyword}{allocate}(cs\%Ref\_val\_v\%p(cs\%nz\_data,cs\%num\_col\_v))}
\DoxyCodeLine{690   cs\%Ref\_val\_v\%p(:,:) = 0.0}
\DoxyCodeLine{691   \textcolor{keywordflow}{do} col=1,cs\%num\_col\_v}
\DoxyCodeLine{692     \textcolor{keywordflow}{do} k=1,cs\%nz\_data}
\DoxyCodeLine{693       cs\%Ref\_val\_v\%p(k,col) = v\_val(cs\%col\_i\_v(col),cs\%col\_j\_v(col),k)}
\DoxyCodeLine{694 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{695 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{696   cs\%var\_v\%p => v\_ptr}
\DoxyCodeLine{697 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_a551051d11b239eeef807fb88ab31aba6}\label{namespacemom__ale__sponge_a551051d11b239eeef807fb88ab31aba6}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!set\_up\_ale\_sponge\_vel\_field\_varying@{set\_up\_ale\_sponge\_vel\_field\_varying}}
\index{set\_up\_ale\_sponge\_vel\_field\_varying@{set\_up\_ale\_sponge\_vel\_field\_varying}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{set\_up\_ale\_sponge\_vel\_field\_varying()}{set\_up\_ale\_sponge\_vel\_field\_varying()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::set\+\_\+up\+\_\+ale\+\_\+sponge\+\_\+vel\+\_\+field\+\_\+varying (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename\+\_\+u,  }\item[{character(len=$\ast$), intent(in)}]{fieldname\+\_\+u,  }\item[{character(len=$\ast$), intent(in)}]{filename\+\_\+v,  }\item[{character(len=$\ast$), intent(in)}]{fieldname\+\_\+v,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in), target}]{u\+\_\+ptr,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in), target}]{v\+\_\+ptr }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine stores the reference profile at uand v points for the variable whose address is given by u\+\_\+ptr and v\+\_\+ptr. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename\+\_\+u} & File name for u field \\
\hline
\mbox{\texttt{ in}}  & {\em fieldname\+\_\+u} & Name of u variable in file \\
\hline
\mbox{\texttt{ in}}  & {\em filename\+\_\+v} & File name for v field \\
\hline
\mbox{\texttt{ in}}  & {\em fieldname\+\_\+v} & Name of v variable in file \\
\hline
\mbox{\texttt{ in}}  & {\em time} & Model time \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid (in) \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & Sponge structure (in/out). \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+ptr} & u pointer to the field to be damped (in). \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+ptr} & v pointer to the field to be damped (in). \\
\hline
\end{DoxyParams}


Definition at line 704 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{704   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}    :: filename\_u\textcolor{comment}{  !< File name for u field}}
\DoxyCodeLine{705   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}    :: fieldname\_u\textcolor{comment}{ !< Name of u variable in file}}
\DoxyCodeLine{706   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}    :: filename\_v\textcolor{comment}{  !< File name for v field}}
\DoxyCodeLine{707   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}    :: fieldname\_v\textcolor{comment}{ !< Name of v variable in file}}
\DoxyCodeLine{708   \textcolor{keywordtype}{type}(time\_type),  \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{        !< Model time}}
\DoxyCodeLine{709   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< Ocean grid (in)}}
\DoxyCodeLine{710   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{     !< A dimensional unit scaling type}}
\DoxyCodeLine{711   \textcolor{keywordtype}{type}(ALE\_sponge\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{          !< Sponge structure (in/out).}}
\DoxyCodeLine{712 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: u\_ptr\textcolor{comment}{ !< u pointer to the field to be damped (in).}}
\DoxyCodeLine{713 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: v\_ptr\textcolor{comment}{ !< v pointer to the field to be damped (in).}}
\DoxyCodeLine{714   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{715 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: u\_val\textcolor{comment}{ !< U field to be used in the sponge.}}
\DoxyCodeLine{716 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: mask\_u\textcolor{comment}{ !< U field mask for the sponge data.}}
\DoxyCodeLine{717 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: v\_val\textcolor{comment}{ !< V field to be used in the sponge.}}
\DoxyCodeLine{718 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: mask\_v\textcolor{comment}{ !< V field mask for the sponge data.}}
\DoxyCodeLine{719 }
\DoxyCodeLine{720 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{target} :: z\_in, z\_edges\_in}
\DoxyCodeLine{721 \textcolor{keywordtype}{  real} :: missing\_value}
\DoxyCodeLine{722 }
\DoxyCodeLine{723   \textcolor{keywordtype}{integer} :: j, k, col}
\DoxyCodeLine{724   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{725   \textcolor{keywordtype}{integer} :: isdB, iedB, jsdB, jedB}
\DoxyCodeLine{726   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(4)} :: fld\_sz}
\DoxyCodeLine{727   \textcolor{keywordtype}{character(len=256)} :: mesg \textcolor{comment}{! String for error messages}}
\DoxyCodeLine{728 }
\DoxyCodeLine{729   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{730 }
\DoxyCodeLine{731   isd = g\%isd; ied = g\%ied; jsd = g\%jsd; jed = g\%jed}
\DoxyCodeLine{732   isdb = g\%isdB; iedb = g\%iedB; jsdb = g\%jsdB; jedb = g\%jedB}
\DoxyCodeLine{733   \textcolor{comment}{! get a unique id for this field which will allow us to return an array}}
\DoxyCodeLine{734   \textcolor{comment}{! containing time-\/interpolated values from an external file corresponding}}
\DoxyCodeLine{735   \textcolor{comment}{! to the current model date.}}
\DoxyCodeLine{736   cs\%Ref\_val\_u\%id = init\_external\_field(filename\_u, fieldname\_u)}
\DoxyCodeLine{737   fld\_sz(1:4)=-\/1}
\DoxyCodeLine{738   fld\_sz = get\_external\_field\_size(cs\%Ref\_val\_u\%id)}
\DoxyCodeLine{739   cs\%Ref\_val\_u\%nz\_data = fld\_sz(3)}
\DoxyCodeLine{740   cs\%Ref\_val\_u\%num\_tlevs = fld\_sz(4)}
\DoxyCodeLine{741   cs\%Ref\_val\_v\%id = init\_external\_field(filename\_v, fieldname\_v)}
\DoxyCodeLine{742   fld\_sz(1:4)=-\/1}
\DoxyCodeLine{743   fld\_sz = get\_external\_field\_size(cs\%Ref\_val\_v\%id)}
\DoxyCodeLine{744   cs\%Ref\_val\_v\%nz\_data = fld\_sz(3)}
\DoxyCodeLine{745   cs\%Ref\_val\_v\%num\_tlevs = fld\_sz(4)}
\DoxyCodeLine{746   \textcolor{keyword}{allocate}( u\_val(isdb:iedb,jsd:jed, fld\_sz(3)) )}
\DoxyCodeLine{747   \textcolor{keyword}{allocate}( mask\_u(isdb:iedb,jsd:jed, fld\_sz(3)) )}
\DoxyCodeLine{748   \textcolor{keyword}{allocate}( v\_val(isd:ied,jsdb:jedb, fld\_sz(3)) )}
\DoxyCodeLine{749   \textcolor{keyword}{allocate}( mask\_v(isd:ied,jsdb:jedb, fld\_sz(3)) )}
\DoxyCodeLine{750   \textcolor{comment}{! Interpolate external file data to the model grid}}
\DoxyCodeLine{751   \textcolor{comment}{! I am hard-\/wiring this call to assume that the input grid is zonally re-\/entrant}}
\DoxyCodeLine{752   \textcolor{comment}{! In the future, this should be generalized using an interface to return the}}
\DoxyCodeLine{753   \textcolor{comment}{! modulo attribute of the zonal axis (mjh).}}
\DoxyCodeLine{754   \textcolor{keyword}{call }horiz\_interp\_and\_extrap\_tracer(cs\%Ref\_val\_u\%id, time, 1.0, g, u\_val, mask\_u, z\_in, z\_edges\_in, \&}
\DoxyCodeLine{755                                       missing\_value, .true., .false., .false., m\_to\_z=us\%m\_to\_Z, \&}
\DoxyCodeLine{756                                       answers\_2018=cs\%hor\_regrid\_answers\_2018)}
\DoxyCodeLine{757   \textcolor{comment}{!!! TODO: add a velocity interface! (mjh)}}
\DoxyCodeLine{758   \textcolor{comment}{! Interpolate external file data to the model grid}}
\DoxyCodeLine{759   \textcolor{comment}{! I am hard-\/wiring this call to assume that the input grid is zonally re-\/entrant}}
\DoxyCodeLine{760   \textcolor{comment}{! In the future, this should be generalized using an interface to return the}}
\DoxyCodeLine{761   \textcolor{comment}{! modulo attribute of the zonal axis (mjh).}}
\DoxyCodeLine{762   \textcolor{keyword}{call }horiz\_interp\_and\_extrap\_tracer(cs\%Ref\_val\_v\%id, time, 1.0, g, v\_val, mask\_v, z\_in, z\_edges\_in, \&}
\DoxyCodeLine{763                                       missing\_value, .true., .false., .false., m\_to\_z=us\%m\_to\_Z, \&}
\DoxyCodeLine{764                                       answers\_2018=cs\%hor\_regrid\_answers\_2018)}
\DoxyCodeLine{765   \textcolor{comment}{! stores the reference profile}}
\DoxyCodeLine{766   \textcolor{keyword}{allocate}(cs\%Ref\_val\_u\%p(fld\_sz(3),cs\%num\_col\_u))}
\DoxyCodeLine{767   cs\%Ref\_val\_u\%p(:,:) = 0.0}
\DoxyCodeLine{768   \textcolor{keywordflow}{do} col=1,cs\%num\_col\_u}
\DoxyCodeLine{769     \textcolor{keywordflow}{do} k=1,fld\_sz(3)}
\DoxyCodeLine{770       cs\%Ref\_val\_u\%p(k,col) = u\_val(cs\%col\_i\_u(col),cs\%col\_j\_u(col),k)}
\DoxyCodeLine{771 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{772 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{773   cs\%var\_u\%p => u\_ptr}
\DoxyCodeLine{774   \textcolor{keyword}{allocate}(cs\%Ref\_val\_v\%p(fld\_sz(3),cs\%num\_col\_v))}
\DoxyCodeLine{775   cs\%Ref\_val\_v\%p(:,:) = 0.0}
\DoxyCodeLine{776   \textcolor{keywordflow}{do} col=1,cs\%num\_col\_v}
\DoxyCodeLine{777     \textcolor{keywordflow}{do} k=1,fld\_sz(3)}
\DoxyCodeLine{778       cs\%Ref\_val\_v\%p(k,col) = v\_val(cs\%col\_i\_v(col),cs\%col\_j\_v(col),k)}
\DoxyCodeLine{779 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{780 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{781   cs\%var\_v\%p => v\_ptr}
\DoxyCodeLine{782 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale__sponge_ab843ab7a29e992d83973c8f9ad6003b1}\label{namespacemom__ale__sponge_ab843ab7a29e992d83973c8f9ad6003b1}} 
\index{mom\_ale\_sponge@{mom\_ale\_sponge}!update\_ale\_sponge\_field@{update\_ale\_sponge\_field}}
\index{update\_ale\_sponge\_field@{update\_ale\_sponge\_field}!mom\_ale\_sponge@{mom\_ale\_sponge}}
\doxysubsubsection{\texorpdfstring{update\_ale\_sponge\_field()}{update\_ale\_sponge\_field()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+\_\+sponge\+::update\+\_\+ale\+\_\+sponge\+\_\+field (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{sponge,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), target}]{p\+\_\+old,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in), target}]{p\+\_\+new }\end{DoxyParamCaption})}



Scan the A\+LE sponge variables and replace a prescribed pointer to a new value. 


\begin{DoxyParams}[1]{Parameters}
 & {\em sponge} & A pointer to the control structure for this module that is set by a previous call to initialize\+\_\+\+A\+L\+E\+\_\+sponge. \\
\hline
\mbox{\texttt{ in}}  & {\em p\+\_\+old} & The previous array of target values \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The updated ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em p\+\_\+new} & The new array of target values \\
\hline
\end{DoxyParams}


Definition at line 1147 of file M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1147   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),     \textcolor{keywordtype}{pointer}    :: sponge\textcolor{comment}{ !< A pointer to the control structure for this module}}
\DoxyCodeLine{1148 \textcolor{comment}{                                               !! that is set by a previous call to initialize\_ALE\_sponge.}}
\DoxyCodeLine{1149 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \&}
\DoxyCodeLine{1150                    \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: p\_old\textcolor{comment}{ !< The previous array of target values}}
\DoxyCodeLine{1151   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{     !< The updated ocean grid structure}}
\DoxyCodeLine{1152   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{    !< ocean vertical grid structure}}
\DoxyCodeLine{1153 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1154                    \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: p\_new\textcolor{comment}{ !< The new array of target values}}
\DoxyCodeLine{1155 }
\DoxyCodeLine{1156   \textcolor{keywordtype}{integer} :: n}
\DoxyCodeLine{1157 }
\DoxyCodeLine{1158   \textcolor{keywordflow}{do} n=1,sponge\%fldno}
\DoxyCodeLine{1159     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(sponge\%var(n)\%p, p\_old)) sponge\%var(n)\%p => p\_new}
\DoxyCodeLine{1160 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1161 }

\end{DoxyCode}
