\hypertarget{interfacemom__ale__sponge_1_1initialize__ale__sponge}{}\section{mom\+\_\+ale\+\_\+sponge\+:\+:initialize\+\_\+ale\+\_\+sponge Interface Reference}
\label{interfacemom__ale__sponge_1_1initialize__ale__sponge}\index{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge@{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge}}


\subsection{Detailed Description}
Ddetermine 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. 

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

\subsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{interfacemom__ale__sponge_1_1initialize__ale__sponge_a463cd22c6fdd61d2e0918bb6c830c570}{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 
subroutine \mbox{\hyperlink{interfacemom__ale__sponge_1_1initialize__ale__sponge_a11a5638d0ed823f984ff4dbdfdc8f354}{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}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Ddetermine 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. 

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



\subsection{Functions and subroutines}
\mbox{\Hypertarget{interfacemom__ale__sponge_1_1initialize__ale__sponge_a463cd22c6fdd61d2e0918bb6c830c570}\label{interfacemom__ale__sponge_1_1initialize__ale__sponge_a463cd22c6fdd61d2e0918bb6c830c570}} 
\index{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge@{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge}!initialize\+\_\+ale\+\_\+sponge\+\_\+fixed@{initialize\+\_\+ale\+\_\+sponge\+\_\+fixed}}
\index{initialize\+\_\+ale\+\_\+sponge\+\_\+fixed@{initialize\+\_\+ale\+\_\+sponge\+\_\+fixed}!mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge@{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge}}
\subsubsection{\texorpdfstring{initialize\+\_\+ale\+\_\+sponge\+\_\+fixed()}{initialize\_ale\_sponge\_fixed()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+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})\hspace{0.3cm}{\ttfamily [private]}}



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{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em nz\+\_\+data} & The total number of sponge input layers.\\
\hline
\mbox{\tt in}  & {\em iresttime} & The inverse of the restoring time \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}.\\
\hline
\mbox{\tt 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{\tt 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}
149 
150   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The ocean's grid structure.}
151   \textcolor{keywordtype}{integer},                          \textcolor{keywordtype}{intent(in)} :: nz\_data\textcolor{comment}{ !< The total number of sponge input layers.}
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 ~>
       s-1].}
153   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure indicating the open file}
154 \textcolor{comment}{                                                             !! to parse for model parameter values.}
155   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),              \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< A pointer that is set to point to the control}
156 \textcolor{comment}{                                                     !! structure for this module (in/out).}
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}
158 \textcolor{comment}{                                                     !! input layers [H ~> m or kg m-2].}
159 
160 
161 \textcolor{comment}{! This include declares and sets the variable "version".}
162 \textcolor{preprocessor}{#include "version\_variable.h"}
163 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_sponge"}  \textcolor{comment}{! This module's name.}
164   \textcolor{keywordtype}{logical} :: use\_sponge
165   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: data\_hu\textcolor{comment}{ !< thickness at u points [H ~> m or kg m-2]}
166   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: data\_hv\textcolor{comment}{ !< thickness at v points [H ~> m or kg m-2]}
167   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_u\textcolor{comment}{ !< inverse of the restoring time at u points [T-1 ~>
       s-1]}
168   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_v\textcolor{comment}{ !< inverse of the restoring time at v points [T-1 ~>
       s-1]}
169   \textcolor{keywordtype}{logical} :: bndExtrapolation = .true. \textcolor{comment}{! If true, extrapolate boundaries}
170   \textcolor{keywordtype}{logical} :: default\_2018\_answers
171   \textcolor{keywordtype}{integer} :: i, j, k, col, total\_sponge\_cols, total\_sponge\_cols\_u, total\_sponge\_cols\_v
172   \textcolor{keywordtype}{character(len=10)}  :: remapScheme
173   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
174     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_ALE\_sponge\_fixed called with an associated "}// &
175                             \textcolor{stringliteral}{"control structure."})
176     \textcolor{keywordflow}{return}
177 \textcolor{keywordflow}{  endif}
178 
179 \textcolor{comment}{! Set default, read and log parameters}
180   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
181   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, use\_sponge, &
182                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//&
183                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//&
184                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)
185 
186   \textcolor{keywordflow}{if} (.not.use\_sponge) \textcolor{keywordflow}{return}
187 
188   \textcolor{keyword}{allocate}(cs)
189 
190   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_UV"}, cs%sponge\_uv, &
191                  \textcolor{stringliteral}{"Apply sponges in u and v, in addition to tracers."}, &
192                  default=.false.)
193 
194   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, remapscheme, &
195                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//&
196                  \textcolor{stringliteral}{" for vertical remapping for all variables."}, &
197                  default=\textcolor{stringliteral}{"PLM"}, do\_not\_log=.true.)
198 
199   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BOUNDARY\_EXTRAPOLATION"}, bndextrapolation, &
200                  \textcolor{stringliteral}{"When defined, a proper high-order reconstruction "}//&
201                  \textcolor{stringliteral}{"scheme is used within boundary cells rather "}//&
202                  \textcolor{stringliteral}{"than PCM. E.g., if PPM is used for remapping, a "}//&
203                  \textcolor{stringliteral}{"PPM reconstruction will also be used within boundary cells."}, &
204                  default=.false., do\_not\_log=.true.)
205   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
206                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
207                  default=.false.)
208   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs%remap\_answers\_2018, &
209                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//&
210                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//&
211                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"HOR\_REGRID\_2018\_ANSWERS"}, cs%hor\_regrid\_answers\_2018, &
213                  \textcolor{stringliteral}{"If true, use the order of arithmetic for horizonal regridding that recovers "}//&
214                  \textcolor{stringliteral}{"the answers from the end of 2018.  Otherwise, use rotationally symmetric "}//&
215                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
216 
217   cs%time\_varying\_sponges = .false.
218   cs%nz = g%ke
219   cs%isc = g%isc ; cs%iec = g%iec ; cs%jsc = g%jsc ; cs%jec = g%jec
220   cs%isd = g%isd ; cs%ied = g%ied ; cs%jsd = g%jsd ; cs%jed = g%jed
221   cs%iscB = g%iscB ; cs%iecB = g%iecB; cs%jscB = g%jscB ; cs%jecB = g%jecB
222 
223   \textcolor{comment}{! number of columns to be restored}
224   cs%num\_col = 0 ; cs%fldno = 0
225   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
226     \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g%mask2dT(i,j)>0)) &
227       cs%num\_col = cs%num\_col + 1
228 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
229 
230   \textcolor{keywordflow}{if} (cs%num\_col > 0) \textcolor{keywordflow}{then}
231     \textcolor{keyword}{allocate}(cs%Iresttime\_col(cs%num\_col)) ; cs%Iresttime\_col = 0.0
232     \textcolor{keyword}{allocate}(cs%col\_i(cs%num\_col))         ; cs%col\_i = 0
233     \textcolor{keyword}{allocate}(cs%col\_j(cs%num\_col))         ; cs%col\_j = 0
234     \textcolor{comment}{! pass indices, restoring time to the CS structure}
235     col = 1
236     \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
237       \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g%mask2dT(i,j)>0)) \textcolor{keywordflow}{then}
238         cs%col\_i(col) = i ; cs%col\_j(col) = j
239         cs%Iresttime\_col(col) = iresttime(i,j)
240         col = col +1
241 \textcolor{keywordflow}{      endif}
242 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
243     \textcolor{comment}{! same for total number of arbritary layers and correspondent data}
244     cs%nz\_data = nz\_data
245     \textcolor{keyword}{allocate}(cs%Ref\_h%p(cs%nz\_data,cs%num\_col))
246     \textcolor{keywordflow}{do} col=1,cs%num\_col ; \textcolor{keywordflow}{do} k=1,cs%nz\_data
247       cs%Ref\_h%p(k,col) = data\_h(cs%col\_i(col),cs%col\_j(col),k)
248 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
249 \textcolor{keywordflow}{  endif}
250 
251   total\_sponge\_cols = cs%num\_col
252   \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols)
253 
254 \textcolor{comment}{! Call the constructor for remapping control structure}
255   \textcolor{keyword}{call }initialize\_remapping(cs%remap\_cs, remapscheme, boundary\_extrapolation=bndextrapolation, &
256                             answers\_2018=cs%remap\_answers\_2018)
257 
258   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at h points"}, total\_sponge\_cols, &
259                  \textcolor{stringliteral}{"The total number of columns where sponges are applied at h points."}, like\_default=.true.)
260 
261   \textcolor{keywordflow}{if} (cs%sponge\_uv) \textcolor{keywordflow}{then}
262 
263     \textcolor{keyword}{allocate}(data\_hu(g%isdB:g%iedB,g%jsd:g%jed,nz\_data)) ; data\_hu(:,:,:) = 0.0
264     \textcolor{keyword}{allocate}(data\_hv(g%isd:g%ied,g%jsdB:g%jedB,nz\_data)) ; data\_hv(:,:,:) = 0.0
265     \textcolor{keyword}{allocate}(iresttime\_u(g%isdB:g%iedB,g%jsd:g%jed)) ; iresttime\_u(:,:) = 0.0
266     \textcolor{keyword}{allocate}(iresttime\_v(g%isd:g%ied,g%jsdB:g%jedB)) ; iresttime\_v(:,:) = 0.0
267 
268     \textcolor{comment}{! u points}
269     cs%num\_col\_u = 0 ; \textcolor{comment}{!CS%fldno\_u = 0}
270     \textcolor{keywordflow}{do} j=cs%jsc,cs%jec ; \textcolor{keywordflow}{do} i=cs%iscB,cs%iecB
271        data\_hu(i,j,:) = 0.5 * (data\_h(i,j,:) + data\_h(i+1,j,:))
272        iresttime\_u(i,j) = 0.5 * (iresttime(i,j) + iresttime(i+1,j))
273        \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g%mask2dCu(i,j)>0)) &
274           cs%num\_col\_u = cs%num\_col\_u + 1
275 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
276 
277     \textcolor{keywordflow}{if} (cs%num\_col\_u > 0) \textcolor{keywordflow}{then}
278 
279        \textcolor{keyword}{allocate}(cs%Iresttime\_col\_u(cs%num\_col\_u)) ; cs%Iresttime\_col\_u(:) = 0.0
280        \textcolor{keyword}{allocate}(cs%col\_i\_u(cs%num\_col\_u))         ; cs%col\_i\_u(:) = 0
281        \textcolor{keyword}{allocate}(cs%col\_j\_u(cs%num\_col\_u))         ; cs%col\_j\_u(:) = 0
282 
283        \textcolor{comment}{! pass indices, restoring time to the CS structure}
284        col = 1
285        \textcolor{keywordflow}{do} j=cs%jsc,cs%jec ; \textcolor{keywordflow}{do} i=cs%iscB,cs%iecB
286          \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g%mask2dCu(i,j)>0)) \textcolor{keywordflow}{then}
287            cs%col\_i\_u(col) = i ; cs%col\_j\_u(col) = j
288            cs%Iresttime\_col\_u(col) = iresttime\_u(i,j)
289            col = col + 1
290 \textcolor{keywordflow}{         endif}
291 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}
292 
293        \textcolor{comment}{! same for total number of arbritary layers and correspondent data}
294 
295        \textcolor{keyword}{allocate}(cs%Ref\_hu%p(cs%nz\_data,cs%num\_col\_u))
296        \textcolor{keywordflow}{do} col=1,cs%num\_col\_u ; \textcolor{keywordflow}{do} k=1,cs%nz\_data
297          cs%Ref\_hu%p(k,col) = data\_hu(cs%col\_i\_u(col),cs%col\_j\_u(col),k)
298 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}
299 \textcolor{keywordflow}{    endif}
300     total\_sponge\_cols\_u = cs%num\_col\_u
301     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_u)
302     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at u points"}, total\_sponge\_cols\_u, &
303                 \textcolor{stringliteral}{"The total number of columns where sponges are applied at u points."}, like\_default=.true.)
304 
305     \textcolor{comment}{! v points}
306     cs%num\_col\_v = 0 ; \textcolor{comment}{!CS%fldno\_v = 0}
307     \textcolor{keywordflow}{do} j=cs%jscB,cs%jecB; \textcolor{keywordflow}{do} i=cs%isc,cs%iec
308       data\_hv(i,j,:) = 0.5 * (data\_h(i,j,:) + data\_h(i,j+1,:))
309       iresttime\_v(i,j) = 0.5 * (iresttime(i,j) + iresttime(i,j+1))
310       \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g%mask2dCv(i,j)>0)) &
311         cs%num\_col\_v = cs%num\_col\_v + 1
312 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
313 
314     \textcolor{keywordflow}{if} (cs%num\_col\_v > 0) \textcolor{keywordflow}{then}
315 
316       \textcolor{keyword}{allocate}(cs%Iresttime\_col\_v(cs%num\_col\_v)) ; cs%Iresttime\_col\_v = 0.0
317       \textcolor{keyword}{allocate}(cs%col\_i\_v(cs%num\_col\_v))         ; cs%col\_i\_v = 0
318       \textcolor{keyword}{allocate}(cs%col\_j\_v(cs%num\_col\_v))         ; cs%col\_j\_v = 0
319 
320       \textcolor{comment}{! pass indices, restoring time to the CS structure}
321       col = 1
322       \textcolor{keywordflow}{do} j=cs%jscB,cs%jecB ; \textcolor{keywordflow}{do} i=cs%isc,cs%iec
323         \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g%mask2dCv(i,j)>0)) \textcolor{keywordflow}{then}
324           cs%col\_i\_v(col) = i ; cs%col\_j\_v(col) = j
325           cs%Iresttime\_col\_v(col) = iresttime\_v(i,j)
326           col = col + 1
327 \textcolor{keywordflow}{        endif}
328 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
329 
330       \textcolor{comment}{! same for total number of arbritary layers and correspondent data}
331       \textcolor{keyword}{allocate}(cs%Ref\_hv%p(cs%nz\_data,cs%num\_col\_v))
332       \textcolor{keywordflow}{do} col=1,cs%num\_col\_v ; \textcolor{keywordflow}{do} k=1,cs%nz\_data
333         cs%Ref\_hv%p(k,col) = data\_hv(cs%col\_i\_v(col),cs%col\_j\_v(col),k)
334 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
335 \textcolor{keywordflow}{    endif}
336     total\_sponge\_cols\_v = cs%num\_col\_v
337     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_v)
338     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at v points"}, total\_sponge\_cols\_v, &
339                  \textcolor{stringliteral}{"The total number of columns where sponges are applied at v points."}, like\_default=.true.)
340 \textcolor{keywordflow}{  endif}
341 
\end{DoxyCode}
\mbox{\Hypertarget{interfacemom__ale__sponge_1_1initialize__ale__sponge_a11a5638d0ed823f984ff4dbdfdc8f354}\label{interfacemom__ale__sponge_1_1initialize__ale__sponge_a11a5638d0ed823f984ff4dbdfdc8f354}} 
\index{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge@{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge}!initialize\+\_\+ale\+\_\+sponge\+\_\+varying@{initialize\+\_\+ale\+\_\+sponge\+\_\+varying}}
\index{initialize\+\_\+ale\+\_\+sponge\+\_\+varying@{initialize\+\_\+ale\+\_\+sponge\+\_\+varying}!mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge@{mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+ale\+\_\+sponge}}
\subsubsection{\texorpdfstring{initialize\+\_\+ale\+\_\+sponge\+\_\+varying()}{initialize\_ale\_sponge\_varying()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+\_\+sponge\+::initialize\+\_\+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{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em iresttime} & The inverse of the restoring time \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}.\\
\hline
\mbox{\tt 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}
397 
398   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The ocean's grid structure.}
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 ~>
       s-1].}
400   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure indicating the open file to
       parse}
401 \textcolor{comment}{                                                             !! for model parameter values.}
402   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),              \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< A pointer that is set to point to the control}
403 \textcolor{comment}{                                                     !! structure for this module (in/out).}
404 
405 \textcolor{comment}{! This include declares and sets the variable "version".}
406 \textcolor{preprocessor}{#include "version\_variable.h"}
407 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_sponge"}  \textcolor{comment}{! This module's name.}
408   \textcolor{keywordtype}{logical} :: use\_sponge
409     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_u\textcolor{comment}{ !< inverse of the restoring time at u points [T-1 ~>
       s-1]}
410   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: Iresttime\_v\textcolor{comment}{ !< inverse of the restoring time at v points [T-1 ~>
       s-1]}
411   \textcolor{keywordtype}{logical} :: bndExtrapolation = .true. \textcolor{comment}{! If true, extrapolate boundaries}
412   \textcolor{keywordtype}{logical} :: default\_2018\_answers
413   \textcolor{keywordtype}{logical} :: spongeDataOngrid = .false.
414   \textcolor{keywordtype}{integer} :: i, j, k, col, total\_sponge\_cols, total\_sponge\_cols\_u, total\_sponge\_cols\_v
415   \textcolor{keywordtype}{character(len=10)}  :: remapScheme
416 
417   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
418     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_ALE\_sponge\_varying called with an associated "}// &
419                             \textcolor{stringliteral}{"control structure."})
420     \textcolor{keywordflow}{return}
421 \textcolor{keywordflow}{  endif}
422 \textcolor{comment}{! Set default, read and log parameters}
423   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
424   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE"}, use\_sponge, &
425                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//&
426                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//&
427                  \textcolor{stringliteral}{"specified from MOM\_initialization.F90."}, default=.false.)
428   \textcolor{keywordflow}{if} (.not.use\_sponge) \textcolor{keywordflow}{return}
429   \textcolor{keyword}{allocate}(cs)
430   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_UV"}, cs%sponge\_uv, &
431                  \textcolor{stringliteral}{"Apply sponges in u and v, in addition to tracers."}, &
432                  default=.false.)
433   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, remapscheme, &
434                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//&
435                  \textcolor{stringliteral}{" for vertical remapping for all variables."}, &
436                  default=\textcolor{stringliteral}{"PLM"}, do\_not\_log=.true.)
437   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BOUNDARY\_EXTRAPOLATION"}, bndextrapolation, &
438                  \textcolor{stringliteral}{"When defined, a proper high-order reconstruction "}//&
439                  \textcolor{stringliteral}{"scheme is used within boundary cells rather "}//&
440                  \textcolor{stringliteral}{"than PCM. E.g., if PPM is used for remapping, a "}//&
441                  \textcolor{stringliteral}{"PPM reconstruction will also be used within boundary cells."}, &
442                  default=.false., do\_not\_log=.true.)
443   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
444                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
445                  default=.false.)
446   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs%remap\_answers\_2018, &
447                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//&
448                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//&
449                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
450   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_DATA\_ONGRID"}, cs%spongeDataOngrid, &
451                  \textcolor{stringliteral}{"When defined, the incoming sponge data are "}//&
452                  \textcolor{stringliteral}{"assumed to be on the model grid "} , &
453                  default=.false.)
454   cs%time\_varying\_sponges = .true.
455   cs%nz = g%ke
456   cs%isc = g%isc ; cs%iec = g%iec ; cs%jsc = g%jsc ; cs%jec = g%jec
457   cs%isd = g%isd ; cs%ied = g%ied ; cs%jsd = g%jsd ; cs%jed = g%jed
458   cs%iscB = g%iscB ; cs%iecB = g%iecB; cs%jscB = g%jscB ; cs%jecB = g%jecB
459 
460   \textcolor{comment}{! number of columns to be restored}
461   cs%num\_col = 0 ; cs%fldno = 0
462   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
463     \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g%mask2dT(i,j)>0)) &
464       cs%num\_col = cs%num\_col + 1
465 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
466   \textcolor{keywordflow}{if} (cs%num\_col > 0) \textcolor{keywordflow}{then}
467     \textcolor{keyword}{allocate}(cs%Iresttime\_col(cs%num\_col)) ; cs%Iresttime\_col = 0.0
468     \textcolor{keyword}{allocate}(cs%col\_i(cs%num\_col))         ; cs%col\_i = 0
469     \textcolor{keyword}{allocate}(cs%col\_j(cs%num\_col))         ; cs%col\_j = 0
470     \textcolor{comment}{! pass indices, restoring time to the CS structure}
471     col = 1
472     \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
473       \textcolor{keywordflow}{if} ((iresttime(i,j)>0.0) .and. (g%mask2dT(i,j)>0)) \textcolor{keywordflow}{then}
474         cs%col\_i(col) = i ; cs%col\_j(col) = j
475         cs%Iresttime\_col(col) = iresttime(i,j)
476         col = col +1
477 \textcolor{keywordflow}{      endif}
478 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
479 \textcolor{keywordflow}{  endif}
480   total\_sponge\_cols = cs%num\_col
481   \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols)
482 
483 \textcolor{comment}{! Call the constructor for remapping control structure}
484   \textcolor{keyword}{call }initialize\_remapping(cs%remap\_cs, remapscheme, boundary\_extrapolation=bndextrapolation, &
485                             answers\_2018=cs%remap\_answers\_2018)
486   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at h points"}, total\_sponge\_cols, &
487                  \textcolor{stringliteral}{"The total number of columns where sponges are applied at h points."}, like\_default=.true.)
488   \textcolor{keywordflow}{if} (cs%sponge\_uv) \textcolor{keywordflow}{then}
489     \textcolor{keyword}{allocate}(iresttime\_u(g%isdB:g%iedB,g%jsd:g%jed)) ; iresttime\_u(:,:) = 0.0
490     \textcolor{keyword}{allocate}(iresttime\_v(g%isd:g%ied,g%jsdB:g%jedB)) ; iresttime\_v(:,:) = 0.0
491     \textcolor{comment}{! u points}
492     cs%num\_col\_u = 0 ; \textcolor{comment}{!CS%fldno\_u = 0}
493     \textcolor{keywordflow}{do} j=cs%jsc,cs%jec; \textcolor{keywordflow}{do} i=cs%iscB,cs%iecB
494       iresttime\_u(i,j) = 0.5 * (iresttime(i,j) + iresttime(i+1,j))
495       \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g%mask2dCu(i,j)>0)) &
496         cs%num\_col\_u = cs%num\_col\_u + 1
497 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
498     \textcolor{keywordflow}{if} (cs%num\_col\_u > 0) \textcolor{keywordflow}{then}
499       \textcolor{keyword}{allocate}(cs%Iresttime\_col\_u(cs%num\_col\_u)) ; cs%Iresttime\_col\_u = 0.0
500       \textcolor{keyword}{allocate}(cs%col\_i\_u(cs%num\_col\_u))         ; cs%col\_i\_u = 0
501       \textcolor{keyword}{allocate}(cs%col\_j\_u(cs%num\_col\_u))         ; cs%col\_j\_u = 0
502       \textcolor{comment}{! pass indices, restoring time to the CS structure}
503       col = 1
504       \textcolor{keywordflow}{do} j=cs%jsc,cs%jec ; \textcolor{keywordflow}{do} i=cs%iscB,cs%iecB
505         \textcolor{keywordflow}{if} ((iresttime\_u(i,j)>0.0) .and. (g%mask2dCu(i,j)>0)) \textcolor{keywordflow}{then}
506           cs%col\_i\_u(col) = i ; cs%col\_j\_u(col) = j
507           cs%Iresttime\_col\_u(col) = iresttime\_u(i,j)
508           col = col +1
509 \textcolor{keywordflow}{        endif}
510 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
511       \textcolor{comment}{! same for total number of arbritary layers and correspondent data}
512 \textcolor{keywordflow}{    endif}
513     total\_sponge\_cols\_u = cs%num\_col\_u
514     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_u)
515     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at u points"}, total\_sponge\_cols\_u, &
516                 \textcolor{stringliteral}{"The total number of columns where sponges are applied at u points."}, like\_default=.true.)
517     \textcolor{comment}{! v points}
518     cs%num\_col\_v = 0 ; \textcolor{comment}{!CS%fldno\_v = 0}
519     \textcolor{keywordflow}{do} j=cs%jscB,cs%jecB; \textcolor{keywordflow}{do} i=cs%isc,cs%iec
520       iresttime\_v(i,j) = 0.5 * (iresttime(i,j) + iresttime(i,j+1))
521       \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g%mask2dCv(i,j)>0)) &
522         cs%num\_col\_v = cs%num\_col\_v + 1
523 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
524     \textcolor{keywordflow}{if} (cs%num\_col\_v > 0) \textcolor{keywordflow}{then}
525       \textcolor{keyword}{allocate}(cs%Iresttime\_col\_v(cs%num\_col\_v)) ; cs%Iresttime\_col\_v = 0.0
526       \textcolor{keyword}{allocate}(cs%col\_i\_v(cs%num\_col\_v))         ; cs%col\_i\_v = 0
527       \textcolor{keyword}{allocate}(cs%col\_j\_v(cs%num\_col\_v))         ; cs%col\_j\_v = 0
528       \textcolor{comment}{! pass indices, restoring time to the CS structure}
529       col = 1
530       \textcolor{keywordflow}{do} j=cs%jscB,cs%jecB ; \textcolor{keywordflow}{do} i=cs%isc,cs%iec
531         \textcolor{keywordflow}{if} ((iresttime\_v(i,j)>0.0) .and. (g%mask2dCv(i,j)>0)) \textcolor{keywordflow}{then}
532           cs%col\_i\_v(col) = i ; cs%col\_j\_v(col) = j
533           cs%Iresttime\_col\_v(col) = iresttime\_v(i,j)
534           col = col +1
535 \textcolor{keywordflow}{        endif}
536 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
537 \textcolor{keywordflow}{    endif}
538     total\_sponge\_cols\_v = cs%num\_col\_v
539     \textcolor{keyword}{call }sum\_across\_pes(total\_sponge\_cols\_v)
540     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!Total sponge columns at v points"}, total\_sponge\_cols\_v, &
541                 \textcolor{stringliteral}{"The total number of columns where sponges are applied at v points."}, like\_default=.true.)
542 \textcolor{keywordflow}{  endif}
543 
\end{DoxyCode}


The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/home/cermak/src/\+M\+O\+M6.\+devrob/src/parameterizations/vertical/M\+O\+M\+\_\+\+A\+L\+E\+\_\+sponge.\+F90\end{DoxyCompactItemize}
