\hypertarget{namespacemom__ice__shelf__dynamics}{}\section{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics Module Reference}
\label{namespacemom__ice__shelf__dynamics}\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}


\subsection{Detailed Description}
Implements a crude placeholder for a later implementation of full ice shelf dynamics. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}
\begin{DoxyCompactList}\small\item\em The control structure for the ice shelf dynamics. \end{DoxyCompactList}\item 
type \hyperlink{structmom__ice__shelf__dynamics_1_1loop__bounds__type}{loop\+\_\+bounds\+\_\+type}
\begin{DoxyCompactList}\small\item\em A container for loop bounds. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
real function \hyperlink{namespacemom__ice__shelf__dynamics_a0e3d8eb91b7cbea4bb6b5063f5b1aada}{slope\+\_\+limiter} (num, denom)
\begin{DoxyCompactList}\small\item\em used for flux limiting in advective subroutines Van Leer limiter (source\+: Wikipedia) The return value is between 0 and 2 \mbox{[}nondim\mbox{]}. \end{DoxyCompactList}\item 
real function \hyperlink{namespacemom__ice__shelf__dynamics_a44ac16282b7667409d32e7eb3e667822}{quad\+\_\+area} (X, Y)
\begin{DoxyCompactList}\small\item\em Calculate area of quadrilateral. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__ice__shelf__dynamics_a12331ec885577ea541129393928b838e}{register\+\_\+ice\+\_\+shelf\+\_\+dyn\+\_\+restarts} (G, param\+\_\+file, CS, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em This subroutine is used to register any fields related to the ice shelf dynamics that should be written to or read from the restart file. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__ice__shelf__dynamics_a214304391d90b046fd3756249be46afb}{initialize\+\_\+ice\+\_\+shelf\+\_\+dyn} (param\+\_\+file, Time, I\+SS, CS, G, US, diag, new\+\_\+sim, solo\+\_\+ice\+\_\+sheet\+\_\+in)
\begin{DoxyCompactList}\small\item\em Initializes shelf model data, parameters and diagnostics. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a65c987944c65ba5ab4c88ce809698a88}{initialize\+\_\+diagnostic\+\_\+fields} (CS, I\+SS, G, US, Time)
\item 
real function, public \hyperlink{namespacemom__ice__shelf__dynamics_af151ce3690653c467dd78e4ca552cac9}{ice\+\_\+time\+\_\+step\+\_\+cfl} (CS, I\+SS, G)
\begin{DoxyCompactList}\small\item\em This function returns the global maximum advective timestep that can be taken based on the current ice velocities. Because it involves finding a global minimum, it can be surprisingly expensive. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__ice__shelf__dynamics_adb908b77efa101749be0be069916139c}{update\+\_\+ice\+\_\+shelf} (CS, I\+SS, G, US, time\+\_\+step, Time, ocean\+\_\+mass, coupled\+\_\+grounding, must\+\_\+update\+\_\+vel)
\begin{DoxyCompactList}\small\item\em This subroutine updates the ice shelf velocities, mass, stresses and properties due to the ice shelf dynamics. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a00b61e0e4f3a40d2e6d6cb8a5d5b3ada}{ice\+\_\+shelf\+\_\+advect} (CS, I\+SS, G, time\+\_\+step, Time)
\begin{DoxyCompactList}\small\item\em This subroutine takes the velocity (on the Bgrid) and timesteps h\+\_\+t = -\/ div (uh) once. Additionally, it will update the volume of ice in partially-\/filled cells, and update hmask accordingly. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_adb9d6c268c8acbd29ffab94087100099}{ice\+\_\+shelf\+\_\+solve\+\_\+outer} (CS, I\+SS, G, US, u\+\_\+shlf, v\+\_\+shlf, iters, time)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_af0560b5ebc88617568bd5d580dec7822}{ice\+\_\+shelf\+\_\+solve\+\_\+inner} (CS, I\+SS, G, US, u\+\_\+shlf, v\+\_\+shlf, taudx, taudy, H\+\_\+node, float\+\_\+cond, hmask, conv\+\_\+flag, iters, time, Phi, Phisub)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_ae89ddd9d8c7e9bafea88207d9cd24c6b}{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+x} (CS, G, LB, time\+\_\+step, hmask, h0, h\+\_\+after\+\_\+uflux, uh\+\_\+ice)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a18adb0486d65da9602b6669fbc486db9}{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+y} (CS, G, LB, time\+\_\+step, hmask, h0, h\+\_\+after\+\_\+vflux, vh\+\_\+ice)
\item 
subroutine, public \hyperlink{namespacemom__ice__shelf__dynamics_a780c301ee73b99c7258b784efb8af172}{shelf\+\_\+advance\+\_\+front} (CS, I\+SS, G, hmask, uh\+\_\+ice, vh\+\_\+ice)
\item 
subroutine, public \hyperlink{namespacemom__ice__shelf__dynamics_a48cfc9a51fb6a9e37cd004c818bea077}{ice\+\_\+shelf\+\_\+min\+\_\+thickness\+\_\+calve} (G, h\+\_\+shelf, area\+\_\+shelf\+\_\+h, hmask, thickness\+\_\+calve, halo)
\begin{DoxyCompactList}\small\item\em Apply a very simple calving law using a minimum thickness rule. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__ice__shelf__dynamics_a5c1d3896958689e3bd2086b539d2b3bc}{calve\+\_\+to\+\_\+mask} (G, h\+\_\+shelf, area\+\_\+shelf\+\_\+h, hmask, calve\+\_\+mask)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a5b068cac79ab7726c0d7198ca153e890}{calc\+\_\+shelf\+\_\+driving\+\_\+stress} (CS, I\+SS, G, US, taudx, taudy, OD)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_aca798d728879d0f253dab89e4cd20b1e}{init\+\_\+boundary\+\_\+values} (CS, G, time, hmask, input\+\_\+flux, input\+\_\+thick, new\+\_\+sim)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_aa9b77c181afc790a35ea48ea3f2849e1}{cg\+\_\+action} (uret, vret, u\+\_\+shlf, v\+\_\+shlf, Phi, Phisub, umask, vmask, hmask, H\+\_\+node, ice\+\_\+visc, float\+\_\+cond, bathyT, basal\+\_\+trac, G, US, is, ie, js, je, dens\+\_\+ratio)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_aad8e6045696a2ff49453364b2e888bca}{cg\+\_\+action\+\_\+subgrid\+\_\+basal} (Phisub, H, U, V, bathyT, dens\+\_\+ratio, Ucontr, Vcontr)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a24ddff05700505a0ee7e011271b7ef8f}{matrix\+\_\+diagonal} (CS, G, US, float\+\_\+cond, H\+\_\+node, ice\+\_\+visc, basal\+\_\+trac, hmask, dens\+\_\+ratio, Phisub, u\+\_\+diagonal, v\+\_\+diagonal)
\begin{DoxyCompactList}\small\item\em returns the diagonal entries of the matrix for a Jacobi preconditioning \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a12746eb7c6f5e5644b844d3aaacafc1f}{cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal} (Phisub, H\+\_\+node, bathyT, dens\+\_\+ratio, sub\+\_\+grnd)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_acf575459314c276121b9fef20c119455}{apply\+\_\+boundary\+\_\+values} (CS, I\+SS, G, US, time, Phisub, H\+\_\+node, ice\+\_\+visc, basal\+\_\+trac, float\+\_\+cond, dens\+\_\+ratio, u\+\_\+bdry\+\_\+contr, v\+\_\+bdry\+\_\+contr)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a1146169c357f7a7fd444fe6dfbf8f794}{calc\+\_\+shelf\+\_\+visc} (CS, I\+SS, G, US, u\+\_\+shlf, v\+\_\+shlf)
\begin{DoxyCompactList}\small\item\em Update depth integrated viscosity, based on horizontal strain rates, and also update the nonlinear part of the basal traction. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_af4d6d4d402d1660aa068ab12d3a7d745}{update\+\_\+od\+\_\+ffrac} (CS, G, US, ocean\+\_\+mass, find\+\_\+avg)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a4f860e8b97ca0400263678b1470c3e20}{update\+\_\+od\+\_\+ffrac\+\_\+uncoupled} (CS, G, h\+\_\+shelf)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a257855320072cd237f07d325331e4ecf}{bilinear\+\_\+shape\+\_\+functions} (X, Y, Phi, area)
\begin{DoxyCompactList}\small\item\em This subroutine calculates the gradients of bilinear basis elements that that are centered at the vertices of the cell. Values are calculated at points of gaussian quadrature. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_ab82d8ee14b2eff3599a1648814d59db5}{bilinear\+\_\+shape\+\_\+fn\+\_\+grid} (G, i, j, Phi)
\begin{DoxyCompactList}\small\item\em This subroutine calculates the gradients of bilinear basis elements that are centered at the vertices of the cell using a locally orthogoal M\+O\+M6 grid. Values are calculated at points of gaussian quadrature. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_ad57b8fb98fdef287509cea5d1ef25c2e}{bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid} (Phisub, nsub)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a4f87da4ad4dafef238d6f55a4c0d9d8d}{update\+\_\+velocity\+\_\+masks} (CS, G, hmask, umask, vmask, u\+\_\+face\+\_\+mask, v\+\_\+face\+\_\+mask)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a92ddf971169ef3b1e28c6dde0f3a66f2}{interpolate\+\_\+h\+\_\+to\+\_\+b} (G, h\+\_\+shelf, hmask, H\+\_\+node)
\begin{DoxyCompactList}\small\item\em Interpolate the ice shelf thickness from tracer point to nodal points, subject to a mask. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__ice__shelf__dynamics_a78c690be8b27b627bc228f1aba28164d}{ice\+\_\+shelf\+\_\+dyn\+\_\+end} (CS)
\begin{DoxyCompactList}\small\item\em Deallocates all memory associated with the ice shelf dynamics module. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_aed75a750ef5f5f2ca0d53b3a1d804073}{ice\+\_\+shelf\+\_\+temp} (CS, I\+SS, G, US, time\+\_\+step, melt\+\_\+rate, Time)
\begin{DoxyCompactList}\small\item\em This subroutine updates the vertically averaged ice shelf temperature. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a972c5ef280e662f96c8fbe696442a15a}{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x} (CS, G, time\+\_\+step, hmask, h0, h\+\_\+after\+\_\+uflux)
\item 
subroutine \hyperlink{namespacemom__ice__shelf__dynamics_a063954c33ef89113686bd79b94a742e9}{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y} (CS, G, time\+\_\+step, hmask, h\+\_\+after\+\_\+uflux, h\+\_\+after\+\_\+vflux)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_acf575459314c276121b9fef20c119455}\label{namespacemom__ice__shelf__dynamics_acf575459314c276121b9fef20c119455}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!apply\+\_\+boundary\+\_\+values@{apply\+\_\+boundary\+\_\+values}}
\index{apply\+\_\+boundary\+\_\+values@{apply\+\_\+boundary\+\_\+values}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{apply\+\_\+boundary\+\_\+values()}{apply\_boundary\_values()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::apply\+\_\+boundary\+\_\+values (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(time\+\_\+type), intent(in)}]{time,  }\item[{real, dimension(\+:,\+:,\+:,\+:,\+:,\+:), intent(in)}]{Phisub,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{H\+\_\+node,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{ice\+\_\+visc,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{basal\+\_\+trac,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{float\+\_\+cond,  }\item[{real, intent(in)}]{dens\+\_\+ratio,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{u\+\_\+bdry\+\_\+contr,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{v\+\_\+bdry\+\_\+contr }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em time} & The current model time\\
\hline
\mbox{\tt in}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\tt in}  & {\em h\+\_\+node} & The ice shelf thickness at nodal\\
\hline
\mbox{\tt in}  & {\em ice\+\_\+visc} & A field related to the ice viscosity from Glen\textquotesingle{}s\\
\hline
\mbox{\tt in}  & {\em basal\+\_\+trac} & A field related to the nonlinear part of the\\
\hline
\mbox{\tt in}  & {\em float\+\_\+cond} & An array indicating where the ice\\
\hline
\mbox{\tt in}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater, nondimensional\\
\hline
\mbox{\tt in,out}  & {\em u\+\_\+bdry\+\_\+contr} & Zonal force contributions due to the\\
\hline
\mbox{\tt in,out}  & {\em v\+\_\+bdry\+\_\+contr} & Meridional force contributions due to the \\
\hline
\end{DoxyParams}


Definition at line 2310 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2310 
2311   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
2312   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{ !< A structure with elements that describe}
2313 \textcolor{comment}{                                               !! the ice-shelf state}
2314   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2315   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
2316   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
2317   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, &
2318                           \textcolor{keywordtype}{intent(in)}    :: phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}
2319 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}
2320   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2321                           \textcolor{keywordtype}{intent(in)}    :: h\_node\textcolor{comment}{ !< The ice shelf thickness at nodal}
2322 \textcolor{comment}{                                                 !! (corner) points [Z ~> m].}
2323   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2324                           \textcolor{keywordtype}{intent(in)}    :: ice\_visc\textcolor{comment}{ !< A field related to the ice viscosity from Glen's}
2325 \textcolor{comment}{                                                !! flow law. The exact form and units depend on the}
2326 \textcolor{comment}{                                                !! basal law exponent.  [R L4 Z T-1 ~> kg m2 s-1].}
2327   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2328                           \textcolor{keywordtype}{intent(in)}    :: basal\_trac\textcolor{comment}{ !< A field related to the nonlinear part of the}
2329 \textcolor{comment}{                                                !! "linearized" basal stress [R Z T-1 ~> kg m-2 s-1].}
2330   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2331                           \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}
2332 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}
2333   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}
2334 \textcolor{comment}{                                                     !! of seawater, nondimensional}
2335   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2336                           \textcolor{keywordtype}{intent(inout)} :: u\_bdry\_contr\textcolor{comment}{ !< Zonal force contributions due to the}
2337 \textcolor{comment}{                                                        !! open boundaries [R L3 Z T-2 ~> kg m s-2]}
2338   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2339                           \textcolor{keywordtype}{intent(inout)} :: v\_bdry\_contr\textcolor{comment}{ !< Meridional force contributions due to the}
2340 \textcolor{comment}{                                                        !! open boundaries [R L3 Z T-2 ~> kg m s-2]}
2341 
2342 \textcolor{comment}{! this will be a per-setup function. the boundary values of thickness and velocity}
2343 \textcolor{comment}{! (and possibly other variables) will be updated in this function}
2344 
2345   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(8,4)}  :: phi
2346   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2)} :: xquad
2347   \textcolor{keywordtype}{real} :: ux, uy, vx, vy \textcolor{comment}{! Components of velocity shears or divergence [T-1 ~> s-1]}
2348   \textcolor{keywordtype}{real} :: uq, vq  \textcolor{comment}{! Interpolated velocities [L T-1 ~> m s-1]}
2349   \textcolor{keywordtype}{real} :: area
2350   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)} :: ucell,vcell,hcell,usubcontr,vsubcontr
2351   \textcolor{keywordtype}{integer} :: i, j, isc, jsc, iec, jec, iq, jq, iphi, jphi, ilq, jlq, itgt, jtgt
2352 
2353   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
2354 
2355   xquad(1) = .5 * (1-sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))
2356 
2357   \textcolor{keywordflow}{do} j=jsc-1,jec+1 ; \textcolor{keywordflow}{do} i=isc-1,iec+1 ; \textcolor{keywordflow}{if} (iss%hmask(i,j) == 1) \textcolor{keywordflow}{then}
2358 
2359     \textcolor{comment}{! process this cell if any corners have umask set to non-dirichlet bdry.}
2360     \textcolor{comment}{! NOTE: vmask not considered, probably should be}
2361 
2362     \textcolor{keywordflow}{if} ((cs%umask(i-1,j-1) == 3) .OR. (cs%umask(i,j-1) == 3) .OR. &
2363         (cs%umask(i-1,j) == 3) .OR. (cs%umask(i,j) == 3)) \textcolor{keywordflow}{then}
2364 
2365       \textcolor{keyword}{call }bilinear\_shape\_fn\_grid(g, i, j, phi)
2366 
2367       \textcolor{comment}{! Phi(2*i-1,j) gives d(Phi\_i)/dx at quadrature point j}
2368       \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}
2369 
2370       \textcolor{keywordflow}{do} iq=1,2 ; \textcolor{keywordflow}{do} jq=1,2
2371 
2372         uq = cs%u\_bdry\_val(i-1,j-1) * xquad(3-iq) * xquad(3-jq) + &
2373              cs%u\_bdry\_val(i,j-1) * xquad(iq) * xquad(3-jq) + &
2374              cs%u\_bdry\_val(i-1,j) * xquad(3-iq) * xquad(jq) + &
2375              cs%u\_bdry\_val(i,j) * xquad(iq) * xquad(jq)
2376 
2377         vq = cs%v\_bdry\_val(i-1,j-1) * xquad(3-iq) * xquad(3-jq) + &
2378              cs%v\_bdry\_val(i,j-1) * xquad(iq) * xquad(3-jq) + &
2379              cs%v\_bdry\_val(i-1,j) * xquad(3-iq) * xquad(jq) + &
2380              cs%v\_bdry\_val(i,j) * xquad(iq) * xquad(jq)
2381 
2382         ux = cs%u\_bdry\_val(i-1,j-1) * phi(1,2*(jq-1)+iq) + &
2383              cs%u\_bdry\_val(i,j-1) * phi(3,2*(jq-1)+iq) + &
2384              cs%u\_bdry\_val(i-1,j) * phi(5,2*(jq-1)+iq) + &
2385              cs%u\_bdry\_val(i,j) * phi(7,2*(jq-1)+iq)
2386 
2387         vx = cs%v\_bdry\_val(i-1,j-1) * phi(1,2*(jq-1)+iq) + &
2388              cs%v\_bdry\_val(i,j-1) * phi(3,2*(jq-1)+iq) + &
2389              cs%v\_bdry\_val(i-1,j) * phi(5,2*(jq-1)+iq) + &
2390              cs%v\_bdry\_val(i,j) * phi(7,2*(jq-1)+iq)
2391 
2392         uy = cs%u\_bdry\_val(i-1,j-1) * phi(2,2*(jq-1)+iq) + &
2393              cs%u\_bdry\_val(i,j-1) * phi(4,2*(jq-1)+iq) + &
2394              cs%u\_bdry\_val(i-1,j) * phi(6,2*(jq-1)+iq) + &
2395              cs%u\_bdry\_val(i,j) * phi(8,2*(jq-1)+iq)
2396 
2397         vy = cs%v\_bdry\_val(i-1,j-1) * phi(2,2*(jq-1)+iq) + &
2398              cs%v\_bdry\_val(i,j-1) * phi(4,2*(jq-1)+iq) + &
2399              cs%v\_bdry\_val(i-1,j) * phi(6,2*(jq-1)+iq) + &
2400              cs%v\_bdry\_val(i,j) * phi(8,2*(jq-1)+iq)
2401 
2402         \textcolor{keywordflow}{do} iphi=1,2 ; \textcolor{keywordflow}{do} jphi=1,2 ; itgt = i-2+iphi ; jtgt = j-2-jphi
2403           ilq = 1 ; \textcolor{keywordflow}{if} (iq == iphi) ilq = 2
2404           jlq = 1 ; \textcolor{keywordflow}{if} (jq == jphi) jlq = 2
2405 
2406           \textcolor{keywordflow}{if} (cs%umask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}
2407             u\_bdry\_contr(itgt,jtgt) = u\_bdry\_contr(itgt,jtgt) + &
2408                0.25 * ice\_visc(i,j) * ( (4*ux+2*vy) * phi(2*(2*(jphi-1)+iphi)-1,2*(jq-1)+iq) + &
2409                                             (uy+vx) * phi(2*(2*(jphi-1)+iphi),2*(jq-1)+iq) )
2410 
2411             \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}
2412               u\_bdry\_contr(itgt,jtgt) = u\_bdry\_contr(itgt,jtgt) + &
2413                 0.25 * basal\_trac(i,j) * uq * xquad(ilq) * xquad(jlq)
2414 \textcolor{keywordflow}{            endif}
2415 \textcolor{keywordflow}{          endif}
2416 
2417           \textcolor{keywordflow}{if} (cs%vmask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}
2418             v\_bdry\_contr(itgt,jtgt) = v\_bdry\_contr(itgt,jtgt) + &
2419                 0.25 *  ice\_visc(i,j) * ( (uy+vx) * phi(2*(2*(jphi-1)+iphi)-1,2*(jq-1)+iq) + &
2420                                       (4*vy+2*ux) * phi(2*(2*(jphi-1)+iphi),2*(jq-1)+iq) )
2421 
2422             \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}
2423               v\_bdry\_contr(itgt,jtgt) = v\_bdry\_contr(itgt,jtgt) + &
2424                   0.25 * basal\_trac(i,j) * vq * xquad(ilq) * xquad(jlq)
2425 \textcolor{keywordflow}{            endif}
2426 \textcolor{keywordflow}{          endif}
2427 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
2428 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2429 
2430       \textcolor{keywordflow}{if} (float\_cond(i,j) == 1) \textcolor{keywordflow}{then}
2431         ucell(:,:) = cs%u\_bdry\_val(i-1:i,j-1:j) ; vcell(:,:) = cs%v\_bdry\_val(i-1:i,j-1:j)
2432         hcell(:,:) = h\_node(i-1:i,j-1:j)
2433         \textcolor{keyword}{call }cg\_action\_subgrid\_basal(phisub, hcell, ucell, vcell, g%bathyT(i,j), &
2434                                      dens\_ratio, usubcontr, vsubcontr)
2435 
2436         \textcolor{keywordflow}{if} (cs%umask(i-1,j-1)==1) u\_bdry\_contr(i-1,j-1) = u\_bdry\_contr(i-1,j-1) + usubcontr(1,1) * 
      basal\_trac(i,j)
2437         \textcolor{keywordflow}{if} (cs%umask(i-1,j) == 1) u\_bdry\_contr(i-1,j) = u\_bdry\_contr(i-1,j) + usubcontr(1,2) * basal\_trac(i
      ,j)
2438         \textcolor{keywordflow}{if} (cs%umask(i,j-1) == 1) u\_bdry\_contr(i,j-1) = u\_bdry\_contr(i,j-1) + usubcontr(2,1) * basal\_trac(i
      ,j)
2439         \textcolor{keywordflow}{if} (cs%umask(i,j) == 1)   u\_bdry\_contr(i,j)   = u\_bdry\_contr(i,j) + usubcontr(2,2) * basal\_trac(i,j
      )
2440 
2441         \textcolor{keywordflow}{if} (cs%vmask(i-1,j-1)==1) v\_bdry\_contr(i-1,j-1) = v\_bdry\_contr(i-1,j-1) + vsubcontr(1,1) * 
      basal\_trac(i,j)
2442         \textcolor{keywordflow}{if} (cs%vmask(i-1,j) == 1) v\_bdry\_contr(i-1,j) = v\_bdry\_contr(i-1,j) + vsubcontr(1,2) * basal\_trac(i
      ,j)
2443         \textcolor{keywordflow}{if} (cs%vmask(i,j-1) == 1) v\_bdry\_contr(i,j-1) = v\_bdry\_contr(i,j-1) + vsubcontr(2,1) * basal\_trac(i
      ,j)
2444         \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1)   v\_bdry\_contr(i,j)   = v\_bdry\_contr(i,j) + vsubcontr(2,2) * basal\_trac(i,j
      )
2445 \textcolor{keywordflow}{      endif}
2446 \textcolor{keywordflow}{    endif}
2447 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
2448 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_ab82d8ee14b2eff3599a1648814d59db5}\label{namespacemom__ice__shelf__dynamics_ab82d8ee14b2eff3599a1648814d59db5}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!bilinear\+\_\+shape\+\_\+fn\+\_\+grid@{bilinear\+\_\+shape\+\_\+fn\+\_\+grid}}
\index{bilinear\+\_\+shape\+\_\+fn\+\_\+grid@{bilinear\+\_\+shape\+\_\+fn\+\_\+grid}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{bilinear\+\_\+shape\+\_\+fn\+\_\+grid()}{bilinear\_shape\_fn\_grid()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::bilinear\+\_\+shape\+\_\+fn\+\_\+grid (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{integer, intent(in)}]{i,  }\item[{integer, intent(in)}]{j,  }\item[{real, dimension(8,4), intent(inout)}]{Phi }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine calculates the gradients of bilinear basis elements that are centered at the vertices of the cell using a locally orthogoal M\+O\+M6 grid. Values are calculated at points of gaussian quadrature. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em i} & The i-\/index in the grid to work on.\\
\hline
\mbox{\tt in}  & {\em j} & The j-\/index in the grid to work on.\\
\hline
\mbox{\tt in,out}  & {\em phi} & The gradients of bilinear basis elements at Gaussian quadrature points surrounding the cell vertices \mbox{[}L-\/1 $\sim$$>$ m-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 2650 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2650   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2651   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: i\textcolor{comment}{   !< The i-index in the grid to work on.}
2652   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{   !< The j-index in the grid to work on.}
2653   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(8,4)},  \textcolor{keywordtype}{intent(inout)} :: phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}
2654 \textcolor{comment}{                                              !! quadrature points surrounding the cell vertices [L-1 ~>
       m-1].}
2655 
2656 \textcolor{comment}{! This subroutine calculates the gradients of bilinear basis elements that}
2657 \textcolor{comment}{! that are centered at the vertices of the cell.  The values are calculated at}
2658 \textcolor{comment}{! points of gaussian quadrature. (in 1D: .5 * (1 +/- sqrt(1/3)) for [0,1])}
2659 \textcolor{comment}{!     (ordered in same way as vertices)}
2660 \textcolor{comment}{!}
2661 \textcolor{comment}{! Phi(2*i-1,j) gives d(Phi\_i)/dx at quadrature point j}
2662 \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}
2663 \textcolor{comment}{! Phi\_i is equal to 1 at vertex i, and 0 at vertex k /= i, and bilinear}
2664 \textcolor{comment}{!}
2665 \textcolor{comment}{! This should be a one-off; once per nonlinear solve? once per lifetime?}
2666 
2667   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(4)} :: xquad, yquad \textcolor{comment}{! [nondim]}
2668   \textcolor{keywordtype}{real} :: a, d       \textcolor{comment}{! Interpolated grid spacings [L ~> m]}
2669   \textcolor{keywordtype}{real} :: xexp, yexp \textcolor{comment}{! [nondim]}
2670   \textcolor{keywordtype}{integer} :: node, qpoint, xnode, xq, ynode, yq
2671 
2672   xquad(1:3:2) = .5 * (1-sqrt(1./3)) ; yquad(1:2) = .5 * (1-sqrt(1./3))
2673   xquad(2:4:2) = .5 * (1+sqrt(1./3)) ; yquad(3:4) = .5 * (1+sqrt(1./3))
2674 
2675   \textcolor{keywordflow}{do} qpoint=1,4
2676     a = g%dxCv(i,j-1) * (1-yquad(qpoint)) + g%dxCv(i,j) * yquad(qpoint) \textcolor{comment}{! d(x)/d(x*)}
2677     d = g%dyCu(i-1,j) * (1-xquad(qpoint)) + g%dyCu(i,j) * xquad(qpoint) \textcolor{comment}{! d(y)/d(y*)}
2678 
2679     \textcolor{keywordflow}{do} node=1,4
2680       xnode = 2-mod(node,2) ; ynode = ceiling(\textcolor{keywordtype}{REAL}(node)/2)
2681 
2682       \textcolor{keywordflow}{if} (ynode == 1) \textcolor{keywordflow}{then}
2683         yexp = 1-yquad(qpoint)
2684       \textcolor{keywordflow}{else}
2685         yexp = yquad(qpoint)
2686 \textcolor{keywordflow}{      endif}
2687 
2688       \textcolor{keywordflow}{if} (1 == xnode) \textcolor{keywordflow}{then}
2689         xexp = 1-xquad(qpoint)
2690       \textcolor{keywordflow}{else}
2691         xexp = xquad(qpoint)
2692 \textcolor{keywordflow}{      endif}
2693 
2694       phi(2*node-1,qpoint) = ( d * (2 * xnode - 3) * yexp ) / (a*d)
2695       phi(2*node,qpoint)   = ( a * (2 * ynode - 3) * xexp ) / (a*d)
2696 
2697 \textcolor{keywordflow}{    enddo}
2698 \textcolor{keywordflow}{  enddo}
2699 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a257855320072cd237f07d325331e4ecf}\label{namespacemom__ice__shelf__dynamics_a257855320072cd237f07d325331e4ecf}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!bilinear\+\_\+shape\+\_\+functions@{bilinear\+\_\+shape\+\_\+functions}}
\index{bilinear\+\_\+shape\+\_\+functions@{bilinear\+\_\+shape\+\_\+functions}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{bilinear\+\_\+shape\+\_\+functions()}{bilinear\_shape\_functions()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::bilinear\+\_\+shape\+\_\+functions (\begin{DoxyParamCaption}\item[{real, dimension(4), intent(in)}]{X,  }\item[{real, dimension(4), intent(in)}]{Y,  }\item[{real, dimension(8,4), intent(inout)}]{Phi,  }\item[{real, intent(out)}]{area }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine calculates the gradients of bilinear basis elements that that are centered at the vertices of the cell. Values are calculated at points of gaussian quadrature. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & The x-\/positions of the vertices of the quadrilateral \mbox{[}L $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em y} & The y-\/positions of the vertices of the quadrilateral \mbox{[}L $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em phi} & The gradients of bilinear basis elements at Gaussian quadrature points surrounding the cell vertices \mbox{[}L-\/1 $\sim$$>$ m-\/1\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em area} & The quadrilateral cell area \mbox{[}L2 $\sim$$>$ m2\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 2582 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2582   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(4)},   \textcolor{keywordtype}{intent(in)}    :: x\textcolor{comment}{   !< The x-positions of the vertices of the quadrilateral [L ~>
       m].}
2583   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(4)},   \textcolor{keywordtype}{intent(in)}    :: y\textcolor{comment}{   !< The y-positions of the vertices of the quadrilateral [L ~>
       m].}
2584   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(8,4)}, \textcolor{keywordtype}{intent(inout)} :: phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}
2585 \textcolor{comment}{                                             !! quadrature points surrounding the cell vertices [L-1 ~>
       m-1].}
2586   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(out)}   :: area\textcolor{comment}{ !< The quadrilateral cell area [L2 ~> m2].}
2587 
2588 \textcolor{comment}{! X and Y must be passed in the form}
2589     \textcolor{comment}{!  3 - 4}
2590     \textcolor{comment}{!  |   |}
2591     \textcolor{comment}{!  1 - 2}
2592 
2593 \textcolor{comment}{! this subroutine calculates the gradients of bilinear basis elements that}
2594 \textcolor{comment}{! that are centered at the vertices of the cell. values are calculated at}
2595 \textcolor{comment}{! points of gaussian quadrature. (in 1D: .5 * (1 +/- sqrt(1/3)) for [0,1])}
2596 \textcolor{comment}{!     (ordered in same way as vertices)}
2597 \textcolor{comment}{!}
2598 \textcolor{comment}{! Phi(2*i-1,j) gives d(Phi\_i)/dx at quadrature point j}
2599 \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}
2600 \textcolor{comment}{! Phi\_i is equal to 1 at vertex i, and 0 at vertex k /= i, and bilinear}
2601 \textcolor{comment}{!}
2602 \textcolor{comment}{! This should be a one-off; once per nonlinear solve? once per lifetime?}
2603 \textcolor{comment}{! ... will all cells have the same shape and dimension?}
2604 
2605   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(4)} :: xquad, yquad \textcolor{comment}{! [nondim]}
2606   \textcolor{keywordtype}{real} :: a,b,c,d  \textcolor{comment}{! Various lengths [L ~> m]}
2607   \textcolor{keywordtype}{real} :: xexp, yexp \textcolor{comment}{! [nondim]}
2608   \textcolor{keywordtype}{integer} :: node, qpoint, xnode, xq, ynode, yq
2609 
2610   xquad(1:3:2) = .5 * (1-sqrt(1./3)) ; yquad(1:2) = .5 * (1-sqrt(1./3))
2611   xquad(2:4:2) = .5 * (1+sqrt(1./3)) ; yquad(3:4) = .5 * (1+sqrt(1./3))
2612 
2613   \textcolor{keywordflow}{do} qpoint=1,4
2614 
2615     a = -x(1)*(1-yquad(qpoint)) + x(2)*(1-yquad(qpoint)) - x(3)*yquad(qpoint) + x(4)*yquad(qpoint) \textcolor{comment}{!
       d(x)/d(x*)}
2616     b = -y(1)*(1-yquad(qpoint)) + y(2)*(1-yquad(qpoint)) - y(3)*yquad(qpoint) + y(4)*yquad(qpoint) \textcolor{comment}{!
       d(y)/d(x*)}
2617     c = -x(1)*(1-xquad(qpoint)) - x(2)*(xquad(qpoint)) + x(3)*(1-xquad(qpoint)) + x(4)*(xquad(qpoint)) \textcolor{comment}{!
       d(x)/d(y*)}
2618     d = -y(1)*(1-xquad(qpoint)) - y(2)*(xquad(qpoint)) + y(3)*(1-xquad(qpoint)) + y(4)*(xquad(qpoint)) \textcolor{comment}{!
       d(y)/d(y*)}
2619 
2620     \textcolor{keywordflow}{do} node=1,4
2621 
2622       xnode = 2-mod(node,2) ; ynode = ceiling(\textcolor{keywordtype}{REAL}(node)/2)
2623 
2624       \textcolor{keywordflow}{if} (ynode == 1) \textcolor{keywordflow}{then}
2625         yexp = 1-yquad(qpoint)
2626       \textcolor{keywordflow}{else}
2627         yexp = yquad(qpoint)
2628 \textcolor{keywordflow}{      endif}
2629 
2630       \textcolor{keywordflow}{if} (1 == xnode) \textcolor{keywordflow}{then}
2631         xexp = 1-xquad(qpoint)
2632       \textcolor{keywordflow}{else}
2633         xexp = xquad(qpoint)
2634 \textcolor{keywordflow}{      endif}
2635 
2636       phi(2*node-1,qpoint) = ( d * (2 * xnode - 3) * yexp - b * (2 * ynode - 3) * xexp) / (a*d-b*c)
2637       phi(2*node,qpoint)   = (-c * (2 * xnode - 3) * yexp + a * (2 * ynode - 3) * xexp) / (a*d-b*c)
2638 
2639 \textcolor{keywordflow}{    enddo}
2640 \textcolor{keywordflow}{  enddo}
2641 
2642   area = quad\_area(x, y)
2643 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_ad57b8fb98fdef287509cea5d1ef25c2e}\label{namespacemom__ice__shelf__dynamics_ad57b8fb98fdef287509cea5d1ef25c2e}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid@{bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid}}
\index{bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid@{bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid()}{bilinear\_shape\_functions\_subgrid()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid (\begin{DoxyParamCaption}\item[{real, dimension(nsub,nsub,2,2,2,2), intent(inout)}]{Phisub,  }\item[{integer, intent(in)}]{nsub }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\tt in}  & {\em nsub} & The number of subgridscale quadrature locations in each direction \\
\hline
\end{DoxyParams}


Definition at line 2704 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2704   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(nsub,nsub,2,2,2,2)}, &
2705            \textcolor{keywordtype}{intent(inout)} :: phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}
2706 \textcolor{comment}{                                   !! locations for finite element calculations [nondim]}
2707   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}    :: nsub\textcolor{comment}{   !< The number of subgridscale quadrature locations in each direction}
2708 
2709   \textcolor{comment}{! this subroutine is a helper for interpolation of floatation condition}
2710   \textcolor{comment}{! for the purposes of evaluating the terms \(\backslash\)int (u,v) \(\backslash\)phi\_i dx dy in a cell that is}
2711   \textcolor{comment}{!     in partial floatation}
2712   \textcolor{comment}{! the array Phisub contains the values of \(\backslash\)phi\_i (where i is a node of the cell)}
2713   \textcolor{comment}{!     at quad point j}
2714   \textcolor{comment}{! i think this general approach may not work for nonrectangular elements...}
2715   \textcolor{comment}{!}
2716 
2717   \textcolor{comment}{! Phisub(i,j,k,l,q1,q2)}
2718   \textcolor{comment}{!  i: subgrid index in x-direction}
2719   \textcolor{comment}{!  j: subgrid index in y-direction}
2720   \textcolor{comment}{!  k: basis function x-index}
2721   \textcolor{comment}{!  l: basis function y-index}
2722   \textcolor{comment}{!  q1: quad point x-index}
2723   \textcolor{comment}{!  q2: quad point y-index}
2724 
2725   \textcolor{comment}{! e.g. k=1,l=1 => node 1}
2726   \textcolor{comment}{!      q1=2,q2=1 => quad point 2}
2727 
2728     \textcolor{comment}{!  3 - 4}
2729     \textcolor{comment}{!  |   |}
2730     \textcolor{comment}{!  1 - 2}
2731 
2732   \textcolor{keywordtype}{integer} :: i, j, k, l, qx, qy, indx, indy
2733   \textcolor{keywordtype}{real},\textcolor{keywordtype}{dimension(2)}    :: xquad
2734   \textcolor{keywordtype}{real}                 :: x0, y0, x, y, val, fracx
2735 
2736   xquad(1) = .5 * (1-sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))
2737   fracx = 1.0/\textcolor{keywordtype}{real}(nsub)
2738 
2739   \textcolor{keywordflow}{do} j=1,nsub ; \textcolor{keywordflow}{do} i=1,nsub
2740     x0 = (i-1) * fracx ; y0 = (j-1) * fracx
2741     \textcolor{keywordflow}{do} qy=1,2 ; \textcolor{keywordflow}{do} qx=1,2
2742       x = x0 + fracx*xquad(qx)
2743       y = y0 + fracx*xquad(qy)
2744       phisub(i,j,1,1,qx,qy) = (1.0-x) * (1.0-y)
2745       phisub(i,j,1,2,qx,qy) = (1.0-x) * y
2746       phisub(i,j,2,1,qx,qy) = x * (1.0-y)
2747       phisub(i,j,2,2,qx,qy) = x * y
2748 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2749 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
2750 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a5b068cac79ab7726c0d7198ca153e890}\label{namespacemom__ice__shelf__dynamics_a5b068cac79ab7726c0d7198ca153e890}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!calc\+\_\+shelf\+\_\+driving\+\_\+stress@{calc\+\_\+shelf\+\_\+driving\+\_\+stress}}
\index{calc\+\_\+shelf\+\_\+driving\+\_\+stress@{calc\+\_\+shelf\+\_\+driving\+\_\+stress}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{calc\+\_\+shelf\+\_\+driving\+\_\+stress()}{calc\_shelf\_driving\_stress()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::calc\+\_\+shelf\+\_\+driving\+\_\+stress (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{taudx,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{taudy,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{OD }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em od} & ocean floor depth at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em taudx} & X-\/direction driving stress at q-\/points \mbox{[}kg L s-\/2 $\sim$$>$ kg m s-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em taudy} & Y-\/direction driving stress at q-\/points \mbox{[}kg L s-\/2 $\sim$$>$ kg m s-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1707 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1707   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}   :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
1708   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{ !< A structure with elements that describe}
1709 \textcolor{comment}{                                             !! the ice-shelf state}
1710   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1711   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
1712   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1713                          \textcolor{keywordtype}{intent(in)}    :: od\textcolor{comment}{  !< ocean floor depth at tracer points [Z ~> m].}
1714   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1715                          \textcolor{keywordtype}{intent(inout)} :: taudx\textcolor{comment}{  !< X-direction driving stress at q-points [kg L s-2 ~> kg
       m s-2]}
1716   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1717                          \textcolor{keywordtype}{intent(inout)} :: taudy\textcolor{comment}{  !< Y-direction driving stress at q-points [kg L s-2 ~> kg
       m s-2]}
1718                                                   \textcolor{comment}{! This will become [R L3 Z T-2 ~> kg m s-2]}
1719 
1720 \textcolor{comment}{! driving stress!}
1721 
1722 \textcolor{comment}{! ! taudx and taudy will hold driving stress in the x- and y- directions when done.}
1723 \textcolor{comment}{!    they will sit on the BGrid, and so their size depends on whether the grid is symmetric}
1724 \textcolor{comment}{!}
1725 \textcolor{comment}{! Since this is a finite element solve, they will actually have the form \(\backslash\)int \(\backslash\)Phi\_i rho g h \(\backslash\)nabla s}
1726 \textcolor{comment}{!}
1727 \textcolor{comment}{! OD -this is important and we do not yet know where (in MOM) it will come from. It represents}
1728 \textcolor{comment}{!     "average" ocean depth -- and is needed to find surface elevation}
1729 \textcolor{comment}{!    (it is assumed that base\_ice = bed + OD)}
1730 
1731   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SIZE(OD,1),SIZE(OD,2))}  :: s, &     \textcolor{comment}{! surface elevation [Z ~> m].}
1732                             base     \textcolor{comment}{! basal elevation of shelf/stream [Z ~> m].}
1733 
1734 
1735   \textcolor{keywordtype}{real}    :: rho, rhow \textcolor{comment}{! Ice and ocean densities [R ~> kg m-3]}
1736   \textcolor{keywordtype}{real}    :: sx, sy    \textcolor{comment}{! Ice shelf top slopes [Z L-1 ~> m s-1]}
1737   \textcolor{keywordtype}{real}    :: neumann\_val \textcolor{comment}{! [R Z L2 T-2 ~> kg s-2]}
1738   \textcolor{keywordtype}{real}    :: dxh, dyh  \textcolor{comment}{! Local grid spacing [L ~> m]}
1739   \textcolor{keywordtype}{real}    :: grav      \textcolor{comment}{! The gravitational acceleration [L2 Z-1 T-2 ~> m s-2]}
1740 
1741   \textcolor{keywordtype}{integer} :: i, j, iscq, iecq, jscq, jecq, isd, jsd, is, js, iegq, jegq
1742   \textcolor{keywordtype}{integer} :: giec, gjec, gisc, gjsc, cnt, isc, jsc, iec, jec
1743   \textcolor{keywordtype}{integer} :: i\_off, j\_off
1744 
1745   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
1746   iscq = g%iscB ; iecq = g%iecB ; jscq = g%jscB ; jecq = g%jecB
1747   isd = g%isd ; jsd = g%jsd
1748   iegq = g%iegB ; jegq = g%jegB
1749   gisc = g%domain%nihalo+1 ; gjsc = g%domain%njhalo+1
1750   giec = g%domain%niglobal+g%domain%nihalo ; gjec = g%domain%njglobal+g%domain%njhalo
1751   is = iscq - 1; js = jscq - 1
1752   i\_off = g%idg\_offset ; j\_off = g%jdg\_offset
1753 
1754   rho =  cs%density\_ice
1755   rhow = cs%density\_ocean\_avg
1756   grav = cs%g\_Earth
1757 
1758   \textcolor{comment}{! prelim - go through and calculate S}
1759 
1760   \textcolor{comment}{! or is this faster?}
1761   base(:,:) = -g%bathyT(:,:) + od(:,:)
1762   s(:,:) = base(:,:) + iss%h\_shelf(:,:)
1763 
1764   \textcolor{keywordflow}{do} j=jsc-1,jec+1
1765     \textcolor{keywordflow}{do} i=isc-1,iec+1
1766       cnt = 0
1767       sx = 0
1768       sy = 0
1769       dxh = g%dxT(i,j)
1770       dyh = g%dyT(i,j)
1771 
1772       \textcolor{keywordflow}{if} (iss%hmask(i,j) == 1) \textcolor{keywordflow}{then} \textcolor{comment}{! we are inside the global computational bdry, at an ice-filled cell}
1773 
1774         \textcolor{comment}{! calculate sx}
1775         \textcolor{keywordflow}{if} ((i+i\_off) == gisc) \textcolor{keywordflow}{then} \textcolor{comment}{! at left computational bdry}
1776           \textcolor{keywordflow}{if} (iss%hmask(i+1,j) == 1) \textcolor{keywordflow}{then}
1777             sx = (s(i+1,j)-s(i,j))/dxh
1778           \textcolor{keywordflow}{else}
1779             sx = 0
1780 \textcolor{keywordflow}{          endif}
1781         \textcolor{keywordflow}{elseif} ((i+i\_off) == giec) \textcolor{keywordflow}{then} \textcolor{comment}{! at east computational bdry}
1782           \textcolor{keywordflow}{if} (iss%hmask(i-1,j) == 1) \textcolor{keywordflow}{then}
1783             sx = (s(i,j)-s(i-1,j))/dxh
1784           \textcolor{keywordflow}{else}
1785             sx = 0
1786 \textcolor{keywordflow}{          endif}
1787         \textcolor{keywordflow}{else} \textcolor{comment}{! interior}
1788           \textcolor{keywordflow}{if} (iss%hmask(i+1,j) == 1) \textcolor{keywordflow}{then}
1789             cnt = cnt+1
1790             sx = s(i+1,j)
1791           \textcolor{keywordflow}{else}
1792             sx = s(i,j)
1793 \textcolor{keywordflow}{          endif}
1794           \textcolor{keywordflow}{if} (iss%hmask(i-1,j) == 1) \textcolor{keywordflow}{then}
1795             cnt = cnt+1
1796             sx = sx - s(i-1,j)
1797           \textcolor{keywordflow}{else}
1798             sx = sx - s(i,j)
1799 \textcolor{keywordflow}{          endif}
1800           \textcolor{keywordflow}{if} (cnt == 0) \textcolor{keywordflow}{then}
1801             sx = 0
1802           \textcolor{keywordflow}{else}
1803             sx = sx / (cnt * dxh)
1804 \textcolor{keywordflow}{          endif}
1805 \textcolor{keywordflow}{        endif}
1806 
1807         cnt = 0
1808 
1809         \textcolor{comment}{! calculate sy, similarly}
1810         \textcolor{keywordflow}{if} ((j+j\_off) == gjsc) \textcolor{keywordflow}{then} \textcolor{comment}{! at south computational bdry}
1811           \textcolor{keywordflow}{if} (iss%hmask(i,j+1) == 1) \textcolor{keywordflow}{then}
1812             sy = (s(i,j+1)-s(i,j))/dyh
1813           \textcolor{keywordflow}{else}
1814             sy = 0
1815 \textcolor{keywordflow}{          endif}
1816         \textcolor{keywordflow}{elseif} ((j+j\_off) == gjec) \textcolor{keywordflow}{then} \textcolor{comment}{! at nprth computational bdry}
1817           \textcolor{keywordflow}{if} (iss%hmask(i,j-1) == 1) \textcolor{keywordflow}{then}
1818             sy = (s(i,j)-s(i,j-1))/dyh
1819           \textcolor{keywordflow}{else}
1820             sy = 0
1821 \textcolor{keywordflow}{          endif}
1822         \textcolor{keywordflow}{else} \textcolor{comment}{! interior}
1823           \textcolor{keywordflow}{if} (iss%hmask(i,j+1) == 1) \textcolor{keywordflow}{then}
1824             cnt = cnt+1
1825             sy = s(i,j+1)
1826           \textcolor{keywordflow}{else}
1827             sy = s(i,j)
1828 \textcolor{keywordflow}{          endif}
1829           \textcolor{keywordflow}{if} (iss%hmask(i,j-1) == 1) \textcolor{keywordflow}{then}
1830             cnt = cnt+1
1831             sy = sy - s(i,j-1)
1832           \textcolor{keywordflow}{else}
1833             sy = sy - s(i,j)
1834 \textcolor{keywordflow}{          endif}
1835           \textcolor{keywordflow}{if} (cnt == 0) \textcolor{keywordflow}{then}
1836             sy = 0
1837           \textcolor{keywordflow}{else}
1838             sy = sy / (cnt * dyh)
1839 \textcolor{keywordflow}{          endif}
1840 \textcolor{keywordflow}{        endif}
1841 
1842         \textcolor{comment}{! SW vertex}
1843         taudx(i-1,j-1) = taudx(i-1,j-1) - .25 * rho * grav * iss%h\_shelf(i,j) * sx * g%areaT(i,j)
1844         taudy(i-1,j-1) = taudy(i-1,j-1) - .25 * rho * grav * iss%h\_shelf(i,j) * sy * g%areaT(i,j)
1845 
1846         \textcolor{comment}{! SE vertex}
1847         taudx(i,j-1) = taudx(i,j-1) - .25 * rho * grav * iss%h\_shelf(i,j) * sx * g%areaT(i,j)
1848         taudy(i,j-1) = taudy(i,j-1) - .25 * rho * grav * iss%h\_shelf(i,j) * sy * g%areaT(i,j)
1849 
1850         \textcolor{comment}{! NW vertex}
1851         taudx(i-1,j) = taudx(i-1,j) - .25 * rho * grav * iss%h\_shelf(i,j) * sx * g%areaT(i,j)
1852         taudy(i-1,j) = taudy(i-1,j) - .25 * rho * grav * iss%h\_shelf(i,j) * sy * g%areaT(i,j)
1853 
1854         \textcolor{comment}{! NE vertex}
1855         taudx(i,j) = taudx(i,j) - .25 * rho * grav * iss%h\_shelf(i,j) * sx * g%areaT(i,j)
1856         taudy(i,j) = taudy(i,j) - .25 * rho * grav * iss%h\_shelf(i,j) * sy * g%areaT(i,j)
1857 
1858         \textcolor{keywordflow}{if} (cs%ground\_frac(i,j) == 1) \textcolor{keywordflow}{then}
1859           neumann\_val = .5 * grav * (rho * iss%h\_shelf(i,j)**2 - rhow * g%bathyT(i,j)**2)
1860         \textcolor{keywordflow}{else}
1861           neumann\_val = .5 * grav * (1-rho/rhow) * rho * iss%h\_shelf(i,j)**2
1862 \textcolor{keywordflow}{        endif}
1863 
1864         \textcolor{keywordflow}{if} ((cs%u\_face\_mask(i-1,j) == 2) .OR. (iss%hmask(i-1,j) == 0) .OR. (iss%hmask(i-1,j) == 2) ) \textcolor{keywordflow}{then}
1865           \textcolor{comment}{! left face of the cell is at a stress boundary}
1866           \textcolor{comment}{! the depth-integrated longitudinal stress is equal to the difference of depth-integrated}
1867           \textcolor{comment}{! pressure on either side of the face}
1868           \textcolor{comment}{! on the ice side, it is rho g h^2 / 2}
1869           \textcolor{comment}{! on the ocean side, it is rhow g (delta OD)^2 / 2}
1870           \textcolor{comment}{! OD can be zero under the ice; but it is ASSUMED on the ice-free side of the face, topography
       elevation}
1871           \textcolor{comment}{!     is not above the base of the ice in the current cell}
1872 
1873           \textcolor{comment}{! Note the negative sign due to the direction of the normal vector}
1874           taudx(i-1,j-1) = taudx(i-1,j-1) - .5 * dyh * neumann\_val
1875           taudx(i-1,j) = taudx(i-1,j) - .5 * dyh * neumann\_val
1876 \textcolor{keywordflow}{        endif}
1877 
1878         \textcolor{keywordflow}{if} ((cs%u\_face\_mask(i,j) == 2) .OR. (iss%hmask(i+1,j) == 0) .OR. (iss%hmask(i+1,j) == 2) ) \textcolor{keywordflow}{then}
1879           \textcolor{comment}{! east face of the cell is at a stress boundary}
1880           taudx(i,j-1) = taudx(i,j-1) + .5 * dyh * neumann\_val
1881           taudx(i,j) = taudx(i,j) + .5 * dyh * neumann\_val
1882 \textcolor{keywordflow}{        endif}
1883 
1884         \textcolor{keywordflow}{if} ((cs%v\_face\_mask(i,j-1) == 2) .OR. (iss%hmask(i,j-1) == 0) .OR. (iss%hmask(i,j-1) == 2) ) \textcolor{keywordflow}{then}
1885           \textcolor{comment}{! south face of the cell is at a stress boundary}
1886           taudy(i-1,j-1) = taudy(i-1,j-1) - .5 * dxh * neumann\_val
1887           taudy(i,j-1) = taudy(i,j-1) - .5 * dxh * neumann\_val
1888 \textcolor{keywordflow}{        endif}
1889 
1890         \textcolor{keywordflow}{if} ((cs%v\_face\_mask(i,j) == 2) .OR. (iss%hmask(i,j+1) == 0) .OR. (iss%hmask(i,j+1) == 2) ) \textcolor{keywordflow}{then}
1891           \textcolor{comment}{! north face of the cell is at a stress boundary}
1892           taudy(i-1,j) = taudy(i-1,j) + .5 * dxh * neumann\_val
1893           taudy(i,j) = taudy(i,j) + .5 * dxh * neumann\_val
1894 \textcolor{keywordflow}{        endif}
1895 
1896 \textcolor{keywordflow}{      endif}
1897 \textcolor{keywordflow}{    enddo}
1898 \textcolor{keywordflow}{  enddo}
1899 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a1146169c357f7a7fd444fe6dfbf8f794}\label{namespacemom__ice__shelf__dynamics_a1146169c357f7a7fd444fe6dfbf8f794}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!calc\+\_\+shelf\+\_\+visc@{calc\+\_\+shelf\+\_\+visc}}
\index{calc\+\_\+shelf\+\_\+visc@{calc\+\_\+shelf\+\_\+visc}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{calc\+\_\+shelf\+\_\+visc()}{calc\_shelf\_visc()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::calc\+\_\+shelf\+\_\+visc (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(g\%isdb\+:g\%iedb,g\%jsdb\+:g\%jedb), intent(inout)}]{u\+\_\+shlf,  }\item[{real, dimension(g\%isdb\+:g\%iedb,g\%jsdb\+:g\%jedb), intent(inout)}]{v\+\_\+shlf }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Update depth integrated viscosity, based on horizontal strain rates, and also update the nonlinear part of the basal traction. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in,out}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em v\+\_\+shlf} & The meridional ice shelf velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 2454 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2454   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
2455   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{ !< A structure with elements that describe}
2456 \textcolor{comment}{                                               !! the ice-shelf state}
2457   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2458   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
2459   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)}, &
2460                           \textcolor{keywordtype}{intent(inout)} :: u\_shlf\textcolor{comment}{ !< The zonal ice shelf velocity [L T-1 ~> m s-1].}
2461   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)}, &
2462                           \textcolor{keywordtype}{intent(inout)} :: v\_shlf\textcolor{comment}{ !< The meridional ice shelf velocity [L T-1 ~> m s-1].}
2463 
2464 \textcolor{comment}{! update DEPTH\_INTEGRATED viscosity, based on horizontal strain rates - this is for bilinear FEM solve}
2465 \textcolor{comment}{! so there is an "upper" and "lower" bilinear viscosity}
2466 
2467 \textcolor{comment}{! also this subroutine updates the nonlinear part of the basal traction}
2468 
2469 \textcolor{comment}{! this may be subject to change later... to make it "hybrid"}
2470 
2471   \textcolor{keywordtype}{integer} :: i, j, iscq, iecq, jscq, jecq, isd, jsd, ied, jed, iegq, jegq
2472   \textcolor{keywordtype}{integer} :: giec, gjec, gisc, gjsc, cnt, isc, jsc, iec, jec, is, js
2473   \textcolor{keywordtype}{real} :: visc\_coef, n\_g
2474   \textcolor{keywordtype}{real} :: ux, uy, vx, vy, eps\_min \textcolor{comment}{! Velocity shears [T-1 ~> s-1]}
2475   \textcolor{keywordtype}{real} :: umid, vmid, unorm \textcolor{comment}{! Velocities [L T-1 ~> m s-1]}
2476 
2477   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
2478   iscq = g%iscB ; iecq = g%iecB ; jscq = g%jscB ; jecq = g%jecB
2479   isd = g%isd ; jsd = g%jsd ; ied = g%ied ; jed = g%jed
2480   iegq = g%iegB ; jegq = g%jegB
2481   gisc = g%domain%nihalo+1 ; gjsc = g%domain%njhalo+1
2482   giec = g%domain%niglobal+gisc ; gjec = g%domain%njglobal+gjsc
2483   is = iscq - 1; js = jscq - 1
2484 
2485   n\_g = cs%n\_glen; eps\_min = cs%eps\_glen\_min
2486 
2487   visc\_coef = us%kg\_m2s\_to\_RZ\_T*us%m\_to\_L*us%Z\_to\_L*(cs%A\_glen\_isothermal)**(1./cs%n\_glen)
2488 
2489   \textcolor{keywordflow}{do} j=jsd+1,jed-1
2490     \textcolor{keywordflow}{do} i=isd+1,ied-1
2491 
2492       \textcolor{keywordflow}{if} (iss%hmask(i,j) == 1) \textcolor{keywordflow}{then}
2493         ux = ((u\_shlf(i,j) + u\_shlf(i,j-1)) - (u\_shlf(i-1,j) + u\_shlf(i-1,j-1))) / (2*g%dxT(i,j))
2494         vx = ((v\_shlf(i,j) + v\_shlf(i,j-1)) - (v\_shlf(i-1,j) + v\_shlf(i-1,j-1))) / (2*g%dxT(i,j))
2495         uy = ((u\_shlf(i,j) + u\_shlf(i-1,j)) - (u\_shlf(i,j-1) + u\_shlf(i-1,j-1))) / (2*g%dyT(i,j))
2496         vy = ((v\_shlf(i,j) + v\_shlf(i-1,j)) - (v\_shlf(i,j-1) + v\_shlf(i-1,j-1))) / (2*g%dyT(i,j))
2497         cs%ice\_visc(i,j) = 0.5 * visc\_coef * (g%areaT(i,j) * iss%h\_shelf(i,j)) * &
2498              (us%s\_to\_T**2 * (ux**2 + vy**2 + ux*vy + 0.25*(uy+vx)**2 + eps\_min**2))**((1.-n\_g)/(2.*n\_g))
2499 
2500         umid = ((u\_shlf(i,j) + u\_shlf(i-1,j-1)) + (u\_shlf(i,j-1) + u\_shlf(i-1,j))) * 0.25
2501         vmid = ((v\_shlf(i,j) + v\_shlf(i-1,j-1)) + (v\_shlf(i,j-1) + v\_shlf(i-1,j))) * 0.25
2502         unorm = sqrt(umid**2 + vmid**2 + eps\_min**2*(g%dxT(i,j)**2 + g%dyT(i,j)**2))
2503         cs%basal\_traction(i,j) = g%areaT(i,j) * cs%C\_basal\_friction * (us%L\_T\_to\_m\_s*unorm)**(cs
      %n\_basal\_fric-1)
2504 \textcolor{keywordflow}{      endif}
2505 \textcolor{keywordflow}{    enddo}
2506 \textcolor{keywordflow}{  enddo}
2507 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a5c1d3896958689e3bd2086b539d2b3bc}\label{namespacemom__ice__shelf__dynamics_a5c1d3896958689e3bd2086b539d2b3bc}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!calve\+\_\+to\+\_\+mask@{calve\+\_\+to\+\_\+mask}}
\index{calve\+\_\+to\+\_\+mask@{calve\+\_\+to\+\_\+mask}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{calve\+\_\+to\+\_\+mask()}{calve\_to\_mask()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::calve\+\_\+to\+\_\+mask (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{h\+\_\+shelf,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{area\+\_\+shelf\+\_\+h,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{hmask,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{calve\+\_\+mask }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+shelf} & The ice shelf thickness \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em area\+\_\+shelf\+\_\+h} & The area per cell covered by the ice shelf \mbox{[}L2 $\sim$$>$ m2\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em hmask} & A mask indicating which tracer points are partly or fully covered by an ice-\/shelf\\
\hline
\mbox{\tt in}  & {\em calve\+\_\+mask} & A mask that indicates where the ice shelf can exist, and where it will calve. \\
\hline
\end{DoxyParams}


Definition at line 1685 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1685   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1686   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: h\_shelf\textcolor{comment}{ !< The ice shelf thickness [Z ~> m].}
1687   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: area\_shelf\_h\textcolor{comment}{ !< The area per cell covered by}
1688 \textcolor{comment}{                                                             !! the ice shelf [L2 ~> m2].}
1689   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
1690 \textcolor{comment}{                                                             !! partly or fully covered by an ice-shelf}
1691   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(in)}    :: calve\_mask\textcolor{comment}{ !< A mask that indicates where the ice}
1692 \textcolor{comment}{                                                             !! shelf can exist, and where it will calve.}
1693 
1694   \textcolor{keywordtype}{integer}                        :: i,j
1695 
1696   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
1697     \textcolor{keywordflow}{if} ((calve\_mask(i,j) == 0.0) .and. (hmask(i,j) /= 0.0)) \textcolor{keywordflow}{then}
1698       h\_shelf(i,j) = 0.0
1699       area\_shelf\_h(i,j) = 0.0
1700       hmask(i,j) = 0.0
1701 \textcolor{keywordflow}{    endif}
1702 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1703 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_aa9b77c181afc790a35ea48ea3f2849e1}\label{namespacemom__ice__shelf__dynamics_aa9b77c181afc790a35ea48ea3f2849e1}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!cg\+\_\+action@{cg\+\_\+action}}
\index{cg\+\_\+action@{cg\+\_\+action}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{cg\+\_\+action()}{cg\_action()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::cg\+\_\+action (\begin{DoxyParamCaption}\item[{real, dimension(g\%isdb\+:g\%iedb,g\%jsdb\+:g\%jedb), intent(inout)}]{uret,  }\item[{real, dimension(g\%isdb\+:g\%iedb,g\%jsdb\+:g\%jedb), intent(inout)}]{vret,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{u\+\_\+shlf,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{v\+\_\+shlf,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g),8,4), intent(in)}]{Phi,  }\item[{real, dimension(\+:,\+:,\+:,\+:,\+:,\+:), intent(in)}]{Phisub,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{umask,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{vmask,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{H\+\_\+node,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{ice\+\_\+visc,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{float\+\_\+cond,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{bathyT,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{basal\+\_\+trac,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{integer, intent(in)}]{is,  }\item[{integer, intent(in)}]{ie,  }\item[{integer, intent(in)}]{js,  }\item[{integer, intent(in)}]{je,  }\item[{real, intent(in)}]{dens\+\_\+ratio }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in,out}  & {\em uret} & The retarding stresses working at u-\/points \mbox{[}R L3 Z T-\/2 $\sim$$>$ kg m s-\/2\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em vret} & The retarding stresses working at v-\/points \mbox{[}R L3 Z T-\/2 $\sim$$>$ kg m s-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em phi} & The gradients of bilinear basis elements at Gaussian\\
\hline
\mbox{\tt in}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\tt in}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em v\+\_\+shlf} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em umask} & A coded mask indicating the nature of the\\
\hline
\mbox{\tt in}  & {\em vmask} & A coded mask indicating the nature of the\\
\hline
\mbox{\tt in}  & {\em h\+\_\+node} & The ice shelf thickness at nodal (corner)\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in}  & {\em ice\+\_\+visc} & A field related to the ice viscosity from Glen\textquotesingle{}s\\
\hline
\mbox{\tt in}  & {\em float\+\_\+cond} & An array indicating where the ice\\
\hline
\mbox{\tt in}  & {\em bathyt} & The depth of ocean bathymetry at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em basal\+\_\+trac} & A field related to the nonlinear part of the\\
\hline
\mbox{\tt in}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater, nondimensional\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em is} & The starting i-\/index to work on\\
\hline
\mbox{\tt in}  & {\em ie} & The ending i-\/index to work on\\
\hline
\mbox{\tt in}  & {\em js} & The starting j-\/index to work on\\
\hline
\mbox{\tt in}  & {\em je} & The ending j-\/index to work on \\
\hline
\end{DoxyParams}


Definition at line 1973 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1973 
1974   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1975   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)}, &
1976                          \textcolor{keywordtype}{intent(inout)} :: uret\textcolor{comment}{ !< The retarding stresses working at u-points [R L3 Z T-2 ~>
       kg m s-2].}
1977   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)}, &
1978                          \textcolor{keywordtype}{intent(inout)} :: vret\textcolor{comment}{ !< The retarding stresses working at v-points [R L3 Z T-2 ~>
       kg m s-2].}
1979   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G),8,4)}, &
1980                          \textcolor{keywordtype}{intent(in)}   :: phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}
1981 \textcolor{comment}{                                             !! quadrature points surrounding the cell vertices [L-1 ~>
       m-1].}
1982   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, &
1983                          \textcolor{keywordtype}{intent(in)}    :: phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}
1984 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}
1985   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1986                          \textcolor{keywordtype}{intent(in)}    :: u\_shlf\textcolor{comment}{  !< The zonal ice shelf velocity at vertices [L T-1 ~> m
       s-1]}
1987   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1988                          \textcolor{keywordtype}{intent(in)}    :: v\_shlf\textcolor{comment}{  !< The meridional ice shelf velocity at vertices [L T-1
       ~> m s-1]}
1989   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1990                          \textcolor{keywordtype}{intent(in)}    :: umask\textcolor{comment}{ !< A coded mask indicating the nature of the}
1991 \textcolor{comment}{                                             !! zonal flow at the corner point}
1992   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1993                          \textcolor{keywordtype}{intent(in)}    :: vmask\textcolor{comment}{ !< A coded mask indicating the nature of the}
1994 \textcolor{comment}{                                             !! meridional flow at the corner point}
1995   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1996                          \textcolor{keywordtype}{intent(in)}    :: h\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}
1997 \textcolor{comment}{                                             !! points [Z ~> m].}
1998   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1999                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
2000 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
2001   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2002                          \textcolor{keywordtype}{intent(in)}    :: ice\_visc\textcolor{comment}{ !< A field related to the ice viscosity from Glen's}
2003 \textcolor{comment}{                                               !! flow law [R L4 Z T-1 ~> kg m2 s-1]. The exact form}
2004 \textcolor{comment}{                                               !!  and units depend on the basal law exponent.}
2005   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2006                          \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}
2007 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}
2008   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2009                          \textcolor{keywordtype}{intent(in)}    :: bathyt\textcolor{comment}{ !< The depth of ocean bathymetry at tracer points [Z ~>
       m].}
2010   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2011                          \textcolor{keywordtype}{intent(in)}    :: basal\_trac\textcolor{comment}{  !< A field related to the nonlinear part of the}
2012 \textcolor{comment}{                                                !! "linearized" basal stress [R Z T-1 ~> kg m-2 s-1].}
2013                 \textcolor{comment}{! and/or whether flow is "hybridized"}
2014   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}
2015 \textcolor{comment}{                                                     !! of seawater, nondimensional}
2016   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{  !< A structure containing unit conversion factors}
2017   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: is\textcolor{comment}{  !< The starting i-index to work on}
2018   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: ie\textcolor{comment}{  !< The ending i-index to work on}
2019   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: js\textcolor{comment}{  !< The starting j-index to work on}
2020   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: je\textcolor{comment}{  !< The ending j-index to work on}
2021 
2022 \textcolor{comment}{! the linear action of the matrix on (u,v) with bilinear finite elements}
2023 \textcolor{comment}{! as of now everything is passed in so no grid pointers or anything of the sort have to be dereferenced,}
2024 \textcolor{comment}{! but this may change pursuant to conversations with others}
2025 \textcolor{comment}{!}
2026 \textcolor{comment}{! is & ie are the cells over which the iteration is done; this may change between calls to this subroutine}
2027 \textcolor{comment}{!     in order to make less frequent halo updates}
2028 
2029 \textcolor{comment}{! the linear action of the matrix on (u,v) with bilinear finite elements}
2030 \textcolor{comment}{! Phi has the form}
2031 \textcolor{comment}{! Phi(k,q,i,j) - applies to cell i,j}
2032 
2033     \textcolor{comment}{!  3 - 4}
2034     \textcolor{comment}{!  |   |}
2035     \textcolor{comment}{!  1 - 2}
2036 
2037 \textcolor{comment}{! Phi(2*k-1,q,i,j) gives d(Phi\_k)/dx at quadrature point q}
2038 \textcolor{comment}{! Phi(2*k,q,i,j) gives d(Phi\_k)/dy at quadrature point q}
2039 \textcolor{comment}{! Phi\_k is equal to 1 at vertex k, and 0 at vertex l /= k, and bilinear}
2040 
2041   \textcolor{keywordtype}{real} :: ux, uy, vx, vy \textcolor{comment}{! Components of velocity shears or divergence [T-1 ~> s-1]}
2042   \textcolor{keywordtype}{real} :: uq, vq  \textcolor{comment}{! Interpolated velocities [L T-1 ~> m s-1]}
2043   \textcolor{keywordtype}{integer} :: iq, jq, iphi, jphi, i, j, ilq, jlq, itgt, jtgt
2044   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2)} :: xquad
2045   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)} :: ucell, vcell, hcell, usub, vsub
2046 
2047   xquad(1) = .5 * (1-sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))
2048 
2049   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}
2050 
2051       \textcolor{keywordflow}{do} iq=1,2 ; \textcolor{keywordflow}{do} jq=1,2
2052 
2053         uq = u\_shlf(i-1,j-1) * xquad(3-iq) * xquad(3-jq) + &
2054              u\_shlf(i,j-1) * xquad(iq) * xquad(3-jq) + &
2055              u\_shlf(i-1,j) * xquad(3-iq) * xquad(jq) + &
2056              u\_shlf(i,j) * xquad(iq) * xquad(jq)
2057 
2058         vq = v\_shlf(i-1,j-1) * xquad(3-iq) * xquad(3-jq) + &
2059              v\_shlf(i,j-1) * xquad(iq) * xquad(3-jq) + &
2060              v\_shlf(i-1,j) * xquad(3-iq) * xquad(jq) + &
2061              v\_shlf(i,j) * xquad(iq) * xquad(jq)
2062 
2063         ux = u\_shlf(i-1,j-1) * phi(1,2*(jq-1)+iq,i,j) + &
2064              u\_shlf(i,j-1) * phi(3,2*(jq-1)+iq,i,j) + &
2065              u\_shlf(i-1,j) * phi(5,2*(jq-1)+iq,i,j) + &
2066              u\_shlf(i,j) * phi(7,2*(jq-1)+iq,i,j)
2067 
2068         vx = v\_shlf(i-1,j-1) * phi(1,2*(jq-1)+iq,i,j) + &
2069              v\_shlf(i,j-1) * phi(3,2*(jq-1)+iq,i,j) + &
2070              v\_shlf(i-1,j) * phi(5,2*(jq-1)+iq,i,j) + &
2071              v\_shlf(i,j) * phi(7,2*(jq-1)+iq,i,j)
2072 
2073         uy = u\_shlf(i-1,j-1) * phi(2,2*(jq-1)+iq,i,j) + &
2074              u\_shlf(i,j-1) * phi(4,2*(jq-1)+iq,i,j) + &
2075              u\_shlf(i-1,j) * phi(6,2*(jq-1)+iq,i,j) + &
2076              u\_shlf(i,j) * phi(8,2*(jq-1)+iq,i,j)
2077 
2078         vy = v\_shlf(i-1,j-1) * phi(2,2*(jq-1)+iq,i,j) + &
2079              v\_shlf(i,j-1) * phi(4,2*(jq-1)+iq,i,j) + &
2080              v\_shlf(i-1,j) * phi(6,2*(jq-1)+iq,i,j) + &
2081              v\_shlf(i,j) * phi(8,2*(jq-1)+iq,i,j)
2082 
2083         \textcolor{keywordflow}{do} iphi=1,2 ; \textcolor{keywordflow}{do} jphi=1,2 ; itgt = i-2+iphi ; jtgt = j-2-jphi
2084           \textcolor{keywordflow}{if} (umask(itgt,jtgt) == 1) uret(itgt,jtgt) = uret(itgt,jtgt) + 0.25 * ice\_visc(i,j) * &
2085                                ((4*ux+2*vy) * phi(2*(2*(jphi-1)+iphi)-1,2*(jq-1)+iq,i,j) + &
2086                                     (uy+vx) * phi(2*(2*(jphi-1)+iphi),2*(jq-1)+iq,i,j))
2087           \textcolor{keywordflow}{if} (vmask(itgt,jtgt) == 1) vret(itgt,jtgt) = vret(itgt,jtgt) + 0.25 * ice\_visc(i,j) * &
2088                                    ((uy+vx) * phi(2*(2*(jphi-1)+iphi)-1,2*(jq-1)+iq,i,j) + &
2089                                 (4*vy+2*ux) * phi(2*(2*(jphi-1)+iphi),2*(jq-1)+iq,i,j))
2090 
2091           \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}
2092             ilq = 1 ; \textcolor{keywordflow}{if} (iq == iphi) ilq = 2
2093             jlq = 1 ; \textcolor{keywordflow}{if} (jq == jphi) jlq = 2
2094             \textcolor{keywordflow}{if} (umask(itgt,jtgt) == 1) uret(itgt,jtgt) = uret(itgt,jtgt) +  &
2095                   0.25 * basal\_trac(i,j) * uq * xquad(ilq) * xquad(jlq)
2096             \textcolor{keywordflow}{if} (vmask(itgt,jtgt) == 1) vret(itgt,jtgt) = vret(itgt,jtgt) +  &
2097                   0.25 * basal\_trac(i,j) * vq * xquad(ilq) * xquad(jlq)
2098 \textcolor{keywordflow}{          endif}
2099 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
2100 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2101 
2102       \textcolor{keywordflow}{if} (float\_cond(i,j) == 1) \textcolor{keywordflow}{then}
2103         ucell(:,:) = u\_shlf(i-1:i,j-1:j) ; vcell(:,:) = v\_shlf(i-1:i,j-1:j)
2104         hcell(:,:) = h\_node(i-1:i,j-1:j)
2105         \textcolor{keyword}{call }cg\_action\_subgrid\_basal(phisub, hcell, ucell, vcell, bathyt(i,j), dens\_ratio, usub, vsub)
2106 
2107         \textcolor{keywordflow}{if} (umask(i-1,j-1)==1) uret(i-1,j-1) = uret(i-1,j-1) + usub(1,1) * basal\_trac(i,j)
2108         \textcolor{keywordflow}{if} (umask(i-1,j) == 1) uret(i-1,j) = uret(i-1,j) + usub(1,2) * basal\_trac(i,j)
2109         \textcolor{keywordflow}{if} (umask(i,j-1) == 1) uret(i,j-1) = uret(i,j-1) + usub(2,1) * basal\_trac(i,j)
2110         \textcolor{keywordflow}{if} (umask(i,j) == 1)   uret(i,j)   = uret(i,j) + usub(2,2) * basal\_trac(i,j)
2111 
2112         \textcolor{keywordflow}{if} (vmask(i-1,j-1)==1) vret(i-1,j-1) = vret(i-1,j-1) + vsub(1,1) * basal\_trac(i,j)
2113         \textcolor{keywordflow}{if} (vmask(i-1,j) == 1) vret(i-1,j) = vret(i-1,j) + vsub(1,2) * basal\_trac(i,j)
2114         \textcolor{keywordflow}{if} (vmask(i,j-1) == 1) vret(i,j-1) = vret(i,j-1) + vsub(2,1) * basal\_trac(i,j)
2115         \textcolor{keywordflow}{if} (vmask(i,j) == 1)   vret(i,j)   = vret(i,j) + vsub(2,2) * basal\_trac(i,j)
2116 \textcolor{keywordflow}{      endif}
2117 
2118 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
2119 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_aad8e6045696a2ff49453364b2e888bca}\label{namespacemom__ice__shelf__dynamics_aad8e6045696a2ff49453364b2e888bca}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!cg\+\_\+action\+\_\+subgrid\+\_\+basal@{cg\+\_\+action\+\_\+subgrid\+\_\+basal}}
\index{cg\+\_\+action\+\_\+subgrid\+\_\+basal@{cg\+\_\+action\+\_\+subgrid\+\_\+basal}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{cg\+\_\+action\+\_\+subgrid\+\_\+basal()}{cg\_action\_subgrid\_basal()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::cg\+\_\+action\+\_\+subgrid\+\_\+basal (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:,\+:,\+:,\+:), intent(in)}]{Phisub,  }\item[{real, dimension(2,2), intent(in)}]{H,  }\item[{real, dimension(2,2), intent(in)}]{U,  }\item[{real, dimension(2,2), intent(in)}]{V,  }\item[{real, intent(in)}]{bathyT,  }\item[{real, intent(in)}]{dens\+\_\+ratio,  }\item[{real, dimension(2,2), intent(out)}]{Ucontr,  }\item[{real, dimension(2,2), intent(out)}]{Vcontr }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\tt in}  & {\em h} & The ice shelf thickness at nodal (corner) points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em u} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em v} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em bathyt} & The depth of ocean bathymetry at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt out}  & {\em ucontr} & The areal average of u-\/velocities where the ice shelf is grounded, or 0 where it is floating \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em vcontr} & The areal average of v-\/velocities where the ice shelf is grounded, or 0 where it is floating \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 2123 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2123   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, &
2124                         \textcolor{keywordtype}{intent(in)}    :: phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}
2125 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}
2126   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< The ice shelf thickness at nodal (corner) points [Z ~> m].}
2127   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{  !< The zonal ice shelf velocity at vertices [L T-1 ~> m s-1]}
2128   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(in)}    :: v\textcolor{comment}{  !< The meridional ice shelf velocity at vertices [L T-1 ~> m
       s-1]}
2129   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}    :: bathyt\textcolor{comment}{ !< The depth of ocean bathymetry at tracer points [Z ~> m].}
2130   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}
2131 \textcolor{comment}{                                            !! of seawater [nondim]}
2132   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(out)}   :: ucontr\textcolor{comment}{ !< The areal average of u-velocities where the ice shelf}
2133 \textcolor{comment}{                                            !! is grounded, or 0 where it is floating [L T-1 ~> m s-1].}
2134   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(out)}   :: vcontr\textcolor{comment}{ !< The areal average of v-velocities where the ice shelf}
2135 \textcolor{comment}{                                            !! is grounded, or 0 where it is floating [L T-1 ~> m s-1].}
2136 
2137   \textcolor{keywordtype}{real}    :: subarea \textcolor{comment}{! The fractional sub-cell area [nondim]}
2138   \textcolor{keywordtype}{real}    :: hloc    \textcolor{comment}{! The local sub-cell ice thickness [Z ~> m]}
2139   \textcolor{keywordtype}{integer} :: nsub, i, j, qx, qy, m, n
2140 
2141   nsub = \textcolor{keyword}{size}(phisub,1)
2142   subarea = 1.0 / (nsub**2)
2143 
2144   \textcolor{keywordflow}{do} n=1,2 ; \textcolor{keywordflow}{do} m=1,2
2145     ucontr(m,n) = 0.0 ; vcontr(m,n) = 0.0
2146     \textcolor{keywordflow}{do} qy=1,2 ; \textcolor{keywordflow}{do} qx=1,2 ; \textcolor{keywordflow}{do} j=1,nsub ; \textcolor{keywordflow}{do} i=1,nsub
2147       hloc = (phisub(i,j,1,1,qx,qy)*h(1,1) + phisub(i,j,2,2,qx,qy)*h(2,2)) + &
2148              (phisub(i,j,1,2,qx,qy)*h(1,2) + phisub(i,j,2,1,qx,qy)*h(2,1))
2149       \textcolor{keywordflow}{if} (dens\_ratio * hloc - bathyt > 0) \textcolor{keywordflow}{then}
2150         ucontr(m,n) = ucontr(m,n) + subarea * 0.25 * phisub(i,j,m,n,qx,qy) * &
2151              ((phisub(i,j,1,1,qx,qy) * u(1,1) + phisub(i,j,2,2,qx,qy) * u(2,2)) + &
2152               (phisub(i,j,1,2,qx,qy) * u(1,2) + phisub(i,j,2,1,qx,qy) * u(2,1)))
2153         vcontr(m,n) = vcontr(m,n) + subarea * 0.25 * phisub(i,j,m,n,qx,qy) * &
2154              ((phisub(i,j,1,1,qx,qy) * v(1,1) + phisub(i,j,2,2,qx,qy) * v(2,2)) + &
2155               (phisub(i,j,1,2,qx,qy) * v(1,2) + phisub(i,j,2,1,qx,qy) * v(2,1)))
2156 \textcolor{keywordflow}{      endif}
2157 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
2158 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
2159 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a12746eb7c6f5e5644b844d3aaacafc1f}\label{namespacemom__ice__shelf__dynamics_a12746eb7c6f5e5644b844d3aaacafc1f}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal@{cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal}}
\index{cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal@{cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal()}{cg\_diagonal\_subgrid\_basal()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:,\+:,\+:,\+:), intent(in)}]{Phisub,  }\item[{real, dimension(2,2), intent(in)}]{H\+\_\+node,  }\item[{real, intent(in)}]{bathyT,  }\item[{real, intent(in)}]{dens\+\_\+ratio,  }\item[{real, dimension(2,2), intent(out)}]{sub\+\_\+grnd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\tt in}  & {\em h\+\_\+node} & The ice shelf thickness at nodal (corner) points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em bathyt} & The depth of ocean bathymetry at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt out}  & {\em sub\+\_\+grnd} & The weighted fraction of the sub-\/cell where the ice shelf is grounded \mbox{[}nondim\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 2273 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2273   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, &
2274                         \textcolor{keywordtype}{intent(in)} :: phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}
2275 \textcolor{comment}{                                             !! locations for finite element calculations [nondim]}
2276   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(in)} :: h\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}
2277 \textcolor{comment}{                                             !! points [Z ~> m].}
2278   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)}    :: bathyt\textcolor{comment}{ !< The depth of ocean bathymetry at tracer points [Z ~> m].}
2279   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}
2280 \textcolor{comment}{                                                 !! of seawater [nondim]}
2281   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(out)} :: sub\_grnd\textcolor{comment}{ !< The weighted fraction of the sub-cell where the ice
       shelf}
2282 \textcolor{comment}{                                                !! is grounded [nondim]}
2283 
2284   \textcolor{comment}{! bathyT = cellwise-constant bed elevation}
2285 
2286   \textcolor{keywordtype}{real}    :: subarea \textcolor{comment}{! The fractional sub-cell area [nondim]}
2287   \textcolor{keywordtype}{real}    :: hloc    \textcolor{comment}{! The local sub-region thickness [Z ~> m]}
2288   \textcolor{keywordtype}{integer} :: nsub, i, j, k, l, qx, qy, m, n
2289 
2290   nsub = \textcolor{keyword}{size}(phisub,1)
2291   subarea = 1.0 / (nsub**2)
2292 
2293   sub\_grnd(:,:) = 0.0
2294   \textcolor{keywordflow}{do} m=1,2 ; \textcolor{keywordflow}{do} n=1,2 ; \textcolor{keywordflow}{do} j=1,nsub ; \textcolor{keywordflow}{do} i=1,nsub ; \textcolor{keywordflow}{do} qx=1,2 ; \textcolor{keywordflow}{do} qy = 1,2
2295 
2296     hloc = (phisub(i,j,1,1,qx,qy)*h\_node(1,1) + phisub(i,j,2,2,qx,qy)*h\_node(2,2)) + &
2297            (phisub(i,j,1,2,qx,qy)*h\_node(1,2) + phisub(i,j,2,1,qx,qy)*h\_node(2,1))
2298 
2299     \textcolor{keywordflow}{if} (dens\_ratio * hloc - bathyt > 0) \textcolor{keywordflow}{then}
2300       sub\_grnd(m,n) = sub\_grnd(m,n) + subarea * 0.25 * phisub(i,j,m,n,qx,qy)**2
2301 \textcolor{keywordflow}{    endif}
2302 
2303 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
2304 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a00b61e0e4f3a40d2e6d6cb8a5d5b3ada}\label{namespacemom__ice__shelf__dynamics_a00b61e0e4f3a40d2e6d6cb8a5d5b3ada}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+advect@{ice\+\_\+shelf\+\_\+advect}}
\index{ice\+\_\+shelf\+\_\+advect@{ice\+\_\+shelf\+\_\+advect}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+advect()}{ice\_shelf\_advect()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+advect (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(inout)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine takes the velocity (on the Bgrid) and timesteps h\+\_\+t = -\/ div (uh) once. Additionally, it will update the volume of ice in partially-\/filled cells, and update hmask accordingly. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & The ice shelf dynamics control structure\\
\hline
\mbox{\tt in,out}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & time step \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em time} & The current model time \\
\hline
\end{DoxyParams}


Definition at line 695 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
695   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< The ice shelf dynamics control structure}
696   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< A structure with elements that describe}
697 \textcolor{comment}{                                               !! the ice-shelf state}
698   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
699   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< time step [T ~> s]}
700   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
701 
702 
703 \textcolor{comment}{! 3/8/11 DNG}
704 \textcolor{comment}{!}
705 \textcolor{comment}{!    This subroutine takes the velocity (on the Bgrid) and timesteps h\_t = - div (uh) once.}
706 \textcolor{comment}{!    ADDITIONALLY, it will update the volume of ice in partially-filled cells, and update}
707 \textcolor{comment}{!        hmask accordingly}
708 \textcolor{comment}{!}
709 \textcolor{comment}{!    The flux overflows are included here. That is because they will be used to advect 3D scalars}
710 \textcolor{comment}{!    into partial cells}
711 
712   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}   :: h\_after\_uflux, h\_after\_vflux \textcolor{comment}{! Ice thicknesses [Z ~> m].}
713   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}  :: uh\_ice  \textcolor{comment}{! The accumulated zonal ice volume flux [Z L2 ~> m3]}
714   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}  :: vh\_ice  \textcolor{comment}{! The accumulated meridional ice volume flux [Z L2 ~> m3]}
715   \textcolor{keywordtype}{type}(loop\_bounds\_type) :: lb
716   \textcolor{keywordtype}{integer}                           :: isd, ied, jsd, jed, i, j, isc, iec, jsc, jec, stencil
717 
718   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
719   isc = g%isc ; iec = g%iec ; jsc = g%jsc ; jec = g%jec
720 
721   uh\_ice(:,:) = 0.0
722   vh\_ice(:,:) = 0.0
723 
724   h\_after\_uflux(:,:) = 0.0
725   h\_after\_vflux(:,:) = 0.0
726   \textcolor{comment}{! call MOM\_mesg("MOM\_ice\_shelf.F90: ice\_shelf\_advect called")}
727 
728   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied ; \textcolor{keywordflow}{if} (cs%thickness\_bdry\_val(i,j) /= 0.0) \textcolor{keywordflow}{then}
729     iss%h\_shelf(i,j) = cs%thickness\_bdry\_val(i,j)
730 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
731 
732   stencil = 2
733   lb%ish = g%isc ; lb%ieh = g%iec ; lb%jsh = g%jsc-stencil ; lb%jeh = g%jec+stencil
734   \textcolor{keywordflow}{if} (lb%jsh < jsd) \textcolor{keyword}{call }mom\_error(fatal, &
735     \textcolor{stringliteral}{"ice\_shelf\_advect:  Halo is too small for the ice thickness advection stencil."})
736 
737   \textcolor{keyword}{call }ice\_shelf\_advect\_thickness\_x(cs, g, lb, time\_step, iss%hmask, iss%h\_shelf, h\_after\_uflux, uh\_ice)
738 
739 \textcolor{comment}{!  call enable\_averages(time\_step, Time, CS%diag)}
740 \textcolor{comment}{!  call pass\_var(h\_after\_uflux, G%domain)}
741 \textcolor{comment}{!  if (CS%id\_h\_after\_uflux > 0) call post\_data(CS%id\_h\_after\_uflux, h\_after\_uflux, CS%diag)}
742 \textcolor{comment}{!  call disable\_averaging(CS%diag)}
743 
744   lb%ish = g%isc ; lb%ieh = g%iec ; lb%jsh = g%jsc ; lb%jeh = g%jec
745   \textcolor{keyword}{call }ice\_shelf\_advect\_thickness\_y(cs, g, lb, time\_step, iss%hmask, h\_after\_uflux, h\_after\_vflux, vh\_ice)
746 
747 \textcolor{comment}{!  call enable\_averages(time\_step, Time, CS%diag)}
748 \textcolor{comment}{!  call pass\_var(h\_after\_vflux, G%domain)}
749 \textcolor{comment}{!  if (CS%id\_h\_after\_vflux > 0) call post\_data(CS%id\_h\_after\_vflux, h\_after\_vflux, CS%diag)}
750 \textcolor{comment}{!  call disable\_averaging(CS%diag)}
751 
752   \textcolor{keywordflow}{do} j=jsd,jed
753     \textcolor{keywordflow}{do} i=isd,ied
754       \textcolor{keywordflow}{if} (iss%hmask(i,j) == 1) iss%h\_shelf(i,j) = h\_after\_vflux(i,j)
755 \textcolor{keywordflow}{    enddo}
756 \textcolor{keywordflow}{  enddo}
757 
758   \textcolor{keywordflow}{if} (cs%moving\_shelf\_front) \textcolor{keywordflow}{then}
759     \textcolor{keyword}{call }shelf\_advance\_front(cs, iss, g, iss%hmask, uh\_ice, vh\_ice)
760     \textcolor{keywordflow}{if} (cs%min\_thickness\_simple\_calve > 0.0) \textcolor{keywordflow}{then}
761       \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, iss%h\_shelf, iss%area\_shelf\_h, iss%hmask, &
762                                          cs%min\_thickness\_simple\_calve)
763 \textcolor{keywordflow}{    endif}
764     \textcolor{keywordflow}{if} (cs%calve\_to\_mask) \textcolor{keywordflow}{then}
765       \textcolor{keyword}{call }calve\_to\_mask(g, iss%h\_shelf, iss%area\_shelf\_h, iss%hmask, cs%calve\_mask)
766 \textcolor{keywordflow}{    endif}
767 \textcolor{keywordflow}{  endif}
768 
769   \textcolor{comment}{!call enable\_averages(time\_step, Time, CS%diag)}
770   \textcolor{comment}{!if (CS%id\_h\_after\_adv > 0) call post\_data(CS%id\_h\_after\_adv, ISS%h\_shelf, CS%diag)}
771   \textcolor{comment}{!call disable\_averaging(CS%diag)}
772 
773   \textcolor{comment}{!call change\_thickness\_using\_melt(ISS, G, time\_step, fluxes, CS%density\_ice)}
774 
775   \textcolor{keyword}{call }update\_velocity\_masks(cs, g, iss%hmask, cs%umask, cs%vmask, cs%u\_face\_mask, cs%v\_face\_mask)
776 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a972c5ef280e662f96c8fbe696442a15a}\label{namespacemom__ice__shelf__dynamics_a972c5ef280e662f96c8fbe696442a15a}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x@{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x}}
\index{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x@{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x()}{ice\_shelf\_advect\_temp\_x()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{h0,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{h\+\_\+after\+\_\+uflux }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in}  & {\em h0} & The initial ice shelf thicknesses \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+after\+\_\+uflux} & The ice shelf thicknesses after \\
\hline
\end{DoxyParams}


Definition at line 3070 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
3070   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
3071   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
3072   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}
3073   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
3074                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
3075 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
3076   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
3077                           \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{ !< The initial ice shelf thicknesses [Z ~> m].}
3078   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
3079                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_uflux\textcolor{comment}{ !< The ice shelf thicknesses after}
3080 \textcolor{comment}{                                              !! the zonal mass fluxes [Z ~> m].}
3081 
3082   \textcolor{comment}{! use will be made of ISS%hmask here - its value at the boundary will be zero, just like uncovered cells}
3083   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}
3084 
3085   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, gjed, gied
3086   \textcolor{keywordtype}{integer} :: i\_off, j\_off
3087   \textcolor{keywordtype}{logical} :: at\_east\_bdry, at\_west\_bdry, one\_off\_west\_bdry, one\_off\_east\_bdry
3088   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(-2:2)} :: stencil
3089   \textcolor{keywordtype}{real} :: u\_face     \textcolor{comment}{! Zonal velocity at a face, positive if out \{L T-1 ~> m s-1]}
3090   \textcolor{keywordtype}{real} :: flux\_diff, phi
3091 
3092   \textcolor{keywordtype}{character (len=1)}        :: debug\_str
3093 
3094 
3095   is = g%isc-2 ; ie = g%iec+2 ; js = g%jsc ; je = g%jec ; isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g
      %jed
3096   i\_off = g%idg\_offset ; j\_off = g%jdg\_offset
3097 
3098   \textcolor{keywordflow}{do} j=jsd+1,jed-1
3099     \textcolor{keywordflow}{if} (((j+j\_off) <= g%domain%njglobal+g%domain%njhalo) .AND. &
3100         ((j+j\_off) >= g%domain%njhalo+1)) \textcolor{keywordflow}{then} \textcolor{comment}{! based on mehmet's code - only if btw north & south
       boundaries}
3101 
3102       stencil(:) = -1
3103 \textcolor{comment}{!     if (i+i\_off == G%domain%nihalo+G%domain%nihalo)}
3104       \textcolor{keywordflow}{do} i=is,ie
3105 
3106         \textcolor{keywordflow}{if} (((i+i\_off) <= g%domain%niglobal+g%domain%nihalo) .AND. &
3107              ((i+i\_off) >= g%domain%nihalo+1)) \textcolor{keywordflow}{then}
3108 
3109           \textcolor{keywordflow}{if} (i+i\_off == g%domain%nihalo+1) \textcolor{keywordflow}{then}
3110             at\_west\_bdry=.true.
3111           \textcolor{keywordflow}{else}
3112             at\_west\_bdry=.false.
3113 \textcolor{keywordflow}{          endif}
3114 
3115           \textcolor{keywordflow}{if} (i+i\_off == g%domain%niglobal+g%domain%nihalo) \textcolor{keywordflow}{then}
3116             at\_east\_bdry=.true.
3117           \textcolor{keywordflow}{else}
3118             at\_east\_bdry=.false.
3119 \textcolor{keywordflow}{          endif}
3120 
3121           \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}
3122 
3123             h\_after\_uflux(i,j) = h0(i,j)
3124 
3125             stencil(:) = h0(i-2:i+2,j)  \textcolor{comment}{! fine as long has nx\_halo >= 2}
3126 
3127             flux\_diff = 0
3128 
3129             \textcolor{comment}{! 1ST DO LEFT FACE}
3130 
3131             \textcolor{keywordflow}{if} (cs%u\_face\_mask(i-1,j) == 4.) \textcolor{keywordflow}{then}
3132 
3133               flux\_diff = flux\_diff + g%dyCu(i-1,j) * time\_step * cs%u\_flux\_bdry\_val(i-1,j) * &
3134                                cs%t\_bdry\_val(i-1,j) / g%areaT(i,j)
3135             \textcolor{keywordflow}{else}
3136 
3137               \textcolor{comment}{! get u-velocity at center of left face}
3138               u\_face = 0.5 * (cs%u\_shelf(i-1,j-1) + cs%u\_shelf(i-1,j))
3139 
3140               \textcolor{keywordflow}{if} (u\_face > 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is into cell - we need info from h(i-2), h(i-1) if available}
3141 
3142               \textcolor{comment}{! i may not cover all the cases.. but i cover the realistic ones}
3143 
3144                 \textcolor{keywordflow}{if} (at\_west\_bdry .AND. (hmask(i-1,j) == 3)) \textcolor{keywordflow}{then} \textcolor{comment}{! at western bdry but there is a}
3145                               \textcolor{comment}{! thickness bdry condition, and the stencil contains it}
3146                   flux\_diff = flux\_diff + abs(u\_face) * g%dyCu(i-1,j) * time\_step * stencil(-1) / g%areaT(i
      ,j)
3147 
3148                 \textcolor{keywordflow}{elseif} (hmask(i-1,j) * hmask(i-2,j) == 1) \textcolor{keywordflow}{then}  \textcolor{comment}{! h(i-2) and h(i-1) are valid}
3149                   phi = slope\_limiter(stencil(-1)-stencil(-2), stencil(0)-stencil(-1))
3150                   flux\_diff = flux\_diff + abs(u\_face) * g%dyCu(i-1,j)* time\_step / g%areaT(i,j) * &
3151                            (stencil(-1) - phi * (stencil(-1)-stencil(0))/2)
3152 
3153                 \textcolor{keywordflow}{else}                            \textcolor{comment}{! h(i-1) is valid}
3154                                     \textcolor{comment}{! (o.w. flux would most likely be out of cell)}
3155                                     \textcolor{comment}{!  but h(i-2) is not}
3156 
3157                   flux\_diff = flux\_diff + abs(u\_face) * g%dyCu(i-1,j) * time\_step / g%areaT(i,j) * stencil(
      -1)
3158 
3159 \textcolor{keywordflow}{                endif}
3160 
3161               \textcolor{keywordflow}{elseif} (u\_face < 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is out of cell - we need info from h(i-1), h(i+1) if available}
3162                 \textcolor{keywordflow}{if} (hmask(i-1,j) * hmask(i+1,j) == 1) \textcolor{keywordflow}{then}         \textcolor{comment}{! h(i-1) and h(i+1) are both valid}
3163                   phi = slope\_limiter(stencil(0)-stencil(1), stencil(-1)-stencil(0))
3164                   flux\_diff = flux\_diff - abs(u\_face) * g%dyCu(i-1,j) * time\_step / g%areaT(i,j) * &
3165                              (stencil(0) - phi * (stencil(0)-stencil(-1))/2)
3166 
3167                 \textcolor{keywordflow}{else}
3168                   flux\_diff = flux\_diff - abs(u\_face) * g%dyCu(i-1,j) * time\_step / g%areaT(i,j) * stencil(
      0)
3169 \textcolor{keywordflow}{                endif}
3170 \textcolor{keywordflow}{              endif}
3171 \textcolor{keywordflow}{            endif}
3172 
3173             \textcolor{comment}{! NEXT DO RIGHT FACE}
3174 
3175             \textcolor{comment}{! get u-velocity at center of eastern face}
3176 
3177             \textcolor{keywordflow}{if} (cs%u\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then}
3178 
3179               flux\_diff = flux\_diff + g%dyCu(i,j) * time\_step * cs%u\_flux\_bdry\_val(i,j) *&
3180                                cs%t\_bdry\_val(i+1,j) / g%areaT(i,j)
3181             \textcolor{keywordflow}{else}
3182 
3183               u\_face = 0.5 * (cs%u\_shelf(i,j-1) + cs%u\_shelf(i,j))
3184 
3185               \textcolor{keywordflow}{if} (u\_face < 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is into cell - we need info from h(i+2), h(i+1) if available}
3186 
3187                 \textcolor{keywordflow}{if} (at\_east\_bdry .AND. (hmask(i+1,j) == 3)) \textcolor{keywordflow}{then} \textcolor{comment}{! at eastern bdry but there is a}
3188                                             \textcolor{comment}{! thickness bdry condition, and the stencil contains it}
3189 
3190                   flux\_diff = flux\_diff + abs(u\_face) * g%dyCu(i,j) * time\_step * stencil(1) / g%areaT(i,j)
3191 
3192                 \textcolor{keywordflow}{elseif} (hmask(i+1,j) * hmask(i+2,j) == 1) \textcolor{keywordflow}{then}  \textcolor{comment}{! h(i+2) and h(i+1) are valid}
3193 
3194                   phi = slope\_limiter(stencil(1)-stencil(2), stencil(0)-stencil(1))
3195                   flux\_diff = flux\_diff + abs(u\_face) * g%dyCu(i,j) * time\_step / g%areaT(i,j) * &
3196                       (stencil(1) - phi * (stencil(1)-stencil(0))/2)
3197 
3198                 \textcolor{keywordflow}{else}                            \textcolor{comment}{! h(i+1) is valid}
3199                                             \textcolor{comment}{! (o.w. flux would most likely be out of cell)}
3200                                             \textcolor{comment}{!  but h(i+2) is not}
3201 
3202                   flux\_diff = flux\_diff + abs(u\_face) * g%dyCu(i,j) * time\_step / g%areaT(i,j) * stencil(1)
3203 
3204 \textcolor{keywordflow}{                endif}
3205 
3206               \textcolor{keywordflow}{elseif} (u\_face > 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is out of cell - we need info from h(i-1), h(i+1) if available}
3207 
3208                 \textcolor{keywordflow}{if} (hmask(i-1,j) * hmask(i+1,j) == 1) \textcolor{keywordflow}{then}         \textcolor{comment}{! h(i-1) and h(i+1) are both valid}
3209 
3210                   phi = slope\_limiter(stencil(0)-stencil(-1), stencil(1)-stencil(0))
3211                   flux\_diff = flux\_diff - abs(u\_face) * g%dyCu(i,j) * time\_step / g%areaT(i,j) * &
3212                       (stencil(0) - phi * (stencil(0)-stencil(1))/2)
3213 
3214                 \textcolor{keywordflow}{else}  \textcolor{comment}{! h(i+1) is valid (o.w. flux would most likely be out of cell) but h(i+2) is not}
3215 
3216                   flux\_diff = flux\_diff - abs(u\_face) * g%dyCu(i,j) * time\_step / g%areaT(i,j) * stencil(0)
3217 
3218 \textcolor{keywordflow}{                endif}
3219 
3220 \textcolor{keywordflow}{              endif}
3221 
3222               h\_after\_uflux(i,j) = h\_after\_uflux(i,j) + flux\_diff
3223 
3224 \textcolor{keywordflow}{            endif}
3225 
3226 \textcolor{keywordflow}{          endif}
3227 
3228 \textcolor{keywordflow}{        endif}
3229 
3230 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! i loop}
3231 
3232 \textcolor{keywordflow}{    endif}
3233 
3234 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! j loop}
3235 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a063954c33ef89113686bd79b94a742e9}\label{namespacemom__ice__shelf__dynamics_a063954c33ef89113686bd79b94a742e9}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y@{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y}}
\index{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y@{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y()}{ice\_shelf\_advect\_temp\_y()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{h\+\_\+after\+\_\+uflux,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{h\+\_\+after\+\_\+vflux }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in}  & {\em h\+\_\+after\+\_\+uflux} & The ice shelf thicknesses after\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+after\+\_\+vflux} & The ice shelf thicknesses after \\
\hline
\end{DoxyParams}


Definition at line 3239 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
3239   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
3240   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
3241   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}
3242   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
3243                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
3244 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
3245   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
3246                           \textcolor{keywordtype}{intent(in)}    :: h\_after\_uflux\textcolor{comment}{ !< The ice shelf thicknesses after}
3247 \textcolor{comment}{                                              !! the zonal mass fluxes [Z ~> m].}
3248   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
3249                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_vflux\textcolor{comment}{ !< The ice shelf thicknesses after}
3250 \textcolor{comment}{                                              !! the meridional mass fluxes [Z ~> m].}
3251 
3252   \textcolor{comment}{! use will be made of ISS%hmask here - its value at the boundary will be zero, just like uncovered cells}
3253   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}
3254 
3255   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, gjed, gied
3256   \textcolor{keywordtype}{integer} :: i\_off, j\_off
3257   \textcolor{keywordtype}{logical} :: at\_north\_bdry, at\_south\_bdry, one\_off\_west\_bdry, one\_off\_east\_bdry
3258   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(-2:2)} :: stencil
3259   \textcolor{keywordtype}{real} :: v\_face     \textcolor{comment}{! Pseudo-meridional velocity at a cell face, positive if out \{L T-1 ~> m s-1]}
3260   \textcolor{keywordtype}{real} :: flux\_diff, phi
3261   \textcolor{keywordtype}{character(len=1)}        :: debug\_str
3262 
3263   is = g%isc ; ie = g%iec ; js = g%jsc-1 ; je = g%jec+1 ; isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g
      %jed
3264   i\_off = g%idg\_offset ; j\_off = g%jdg\_offset
3265 
3266   \textcolor{keywordflow}{do} i=isd+2,ied-2
3267     \textcolor{keywordflow}{if} (((i+i\_off) <= g%domain%niglobal+g%domain%nihalo) .AND. &
3268        ((i+i\_off) >= g%domain%nihalo+1)) \textcolor{keywordflow}{then}  \textcolor{comment}{! based on mehmet's code - only if btw east & west
       boundaries}
3269 
3270       stencil(:) = -1
3271 
3272       \textcolor{keywordflow}{do} j=js,je
3273 
3274         \textcolor{keywordflow}{if} (((j+j\_off) <= g%domain%njglobal+g%domain%njhalo) .AND. &
3275              ((j+j\_off) >= g%domain%njhalo+1)) \textcolor{keywordflow}{then}
3276 
3277           \textcolor{keywordflow}{if} (j+j\_off == g%domain%njhalo+1) \textcolor{keywordflow}{then}
3278             at\_south\_bdry=.true.
3279           \textcolor{keywordflow}{else}
3280             at\_south\_bdry=.false.
3281 \textcolor{keywordflow}{          endif}
3282           \textcolor{keywordflow}{if} (j+j\_off == g%domain%njglobal+g%domain%njhalo) \textcolor{keywordflow}{then}
3283             at\_north\_bdry=.true.
3284           \textcolor{keywordflow}{else}
3285             at\_north\_bdry=.false.
3286 \textcolor{keywordflow}{          endif}
3287 
3288           \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}
3289             h\_after\_vflux(i,j) = h\_after\_uflux(i,j)
3290 
3291             stencil(:) = h\_after\_uflux(i,j-2:j+2)  \textcolor{comment}{! fine as long has ny\_halo >= 2}
3292             flux\_diff = 0
3293 
3294             \textcolor{comment}{! 1ST DO south FACE}
3295 
3296             \textcolor{keywordflow}{if} (cs%v\_face\_mask(i,j-1) == 4.) \textcolor{keywordflow}{then}
3297 
3298               flux\_diff = flux\_diff + g%dxCv(i,j-1) * time\_step * cs%v\_flux\_bdry\_val(i,j-1) * &
3299                                  cs%t\_bdry\_val(i,j-1)/ g%areaT(i,j)
3300             \textcolor{keywordflow}{else}
3301 
3302               \textcolor{comment}{! get u-velocity at center of west face}
3303               v\_face = 0.5 * (cs%v\_shelf(i-1,j-1) + cs%v\_shelf(i,j-1))
3304 
3305               \textcolor{keywordflow}{if} (v\_face > 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is into cell - we need info from h(j-2), h(j-1) if available}
3306 
3307                 \textcolor{comment}{! i may not cover all the cases.. but i cover the realistic ones}
3308 
3309                 \textcolor{keywordflow}{if} (at\_south\_bdry .AND. (hmask(i,j-1) == 3)) \textcolor{keywordflow}{then} \textcolor{comment}{! at western bdry but there is a}
3310                                             \textcolor{comment}{! thickness bdry condition, and the stencil contains it}
3311                   flux\_diff = flux\_diff + abs(v\_face) * g%dxCv(i,j-1) * time\_step * stencil(-1) / g%areaT(i
      ,j)
3312 
3313                 \textcolor{keywordflow}{elseif} (hmask(i,j-1) * hmask(i,j-2) == 1) \textcolor{keywordflow}{then}  \textcolor{comment}{! h(j-2) and h(j-1) are valid}
3314 
3315                   phi = slope\_limiter(stencil(-1)-stencil(-2), stencil(0)-stencil(-1))
3316                   flux\_diff = flux\_diff + abs(v\_face) * g%dxCv(i,j-1) * time\_step / g%areaT(i,j) * &
3317                       (stencil(-1) - phi * (stencil(-1)-stencil(0))/2)
3318 
3319                 \textcolor{keywordflow}{else}     \textcolor{comment}{! h(j-1) is valid}
3320                          \textcolor{comment}{! (o.w. flux would most likely be out of cell)}
3321                          \textcolor{comment}{!  but h(j-2) is not}
3322                   flux\_diff = flux\_diff + abs(v\_face) * g%dxCv(i,j-1) * time\_step / g%areaT(i,j) * stencil(
      -1)
3323 \textcolor{keywordflow}{                endif}
3324 
3325               \textcolor{keywordflow}{elseif} (v\_face < 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is out of cell - we need info from h(j-1), h(j+1) if available}
3326 
3327                 \textcolor{keywordflow}{if} (hmask(i,j-1) * hmask(i,j+1) == 1) \textcolor{keywordflow}{then}  \textcolor{comment}{! h(j-1) and h(j+1) are both valid}
3328                   phi = slope\_limiter(stencil(0)-stencil(1), stencil(-1)-stencil(0))
3329                   flux\_diff = flux\_diff - abs(v\_face) * g%dxCv(i,j-1) * time\_step / g%areaT(i,j) * &
3330                       (stencil(0) - phi * (stencil(0)-stencil(-1))/2)
3331                 \textcolor{keywordflow}{else}
3332                   flux\_diff = flux\_diff - abs(v\_face) * g%dxCv(i,j-1) * time\_step / g%areaT(i,j) * stencil(
      0)
3333 \textcolor{keywordflow}{                endif}
3334 
3335 \textcolor{keywordflow}{              endif}
3336 
3337 \textcolor{keywordflow}{            endif}
3338 
3339             \textcolor{comment}{! NEXT DO north FACE}
3340 
3341             \textcolor{keywordflow}{if} (cs%v\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then}
3342               flux\_diff = flux\_diff + g%dxCv(i,j) * time\_step * cs%v\_flux\_bdry\_val(i,j) *&
3343                                cs%t\_bdry\_val(i,j+1)/ g%areaT(i,j)
3344             \textcolor{keywordflow}{else}
3345 
3346             \textcolor{comment}{! get u-velocity at center of east face}
3347               v\_face = 0.5 * (cs%v\_shelf(i-1,j) + cs%v\_shelf(i,j))
3348 
3349               \textcolor{keywordflow}{if} (v\_face < 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is into cell - we need info from h(j+2), h(j+1) if available}
3350 
3351                 \textcolor{keywordflow}{if} (at\_north\_bdry .AND. (hmask(i,j+1) == 3)) \textcolor{keywordflow}{then} \textcolor{comment}{! at eastern bdry but there is a}
3352                                             \textcolor{comment}{! thickness bdry condition, and the stencil contains it}
3353                   flux\_diff = flux\_diff + abs(v\_face) * g%dxCv(i,j) * time\_step * stencil(1) / g%areaT(i,j)
3354                 \textcolor{keywordflow}{elseif} (hmask(i,j+1) * hmask(i,j+2) == 1) \textcolor{keywordflow}{then}  \textcolor{comment}{! h(j+2) and h(j+1) are valid}
3355                   phi = slope\_limiter(stencil(1)-stencil(2), stencil(0)-stencil(1))
3356                   flux\_diff = flux\_diff + abs(v\_face) * g%dxCv(i,j) * time\_step / g%areaT(i,j) * &
3357                       (stencil(1) - phi * (stencil(1)-stencil(0))/2)
3358                 \textcolor{keywordflow}{else}     \textcolor{comment}{! h(j+1) is valid}
3359                          \textcolor{comment}{! (o.w. flux would most likely be out of cell)}
3360                          \textcolor{comment}{!  but h(j+2) is not}
3361                   flux\_diff = flux\_diff + abs(v\_face) * g%dxCv(i,j) * time\_step / g%areaT(i,j) * stencil(1)
3362 \textcolor{keywordflow}{                endif}
3363 
3364               \textcolor{keywordflow}{elseif} (v\_face > 0) \textcolor{keywordflow}{then} \textcolor{comment}{!flux is out of cell - we need info from h(j-1), h(j+1) if available}
3365 
3366                 \textcolor{keywordflow}{if} (hmask(i,j-1) * hmask(i,j+1) == 1) \textcolor{keywordflow}{then}         \textcolor{comment}{! h(j-1) and h(j+1) are both valid}
3367                   phi = slope\_limiter(stencil(0)-stencil(-1), stencil(1)-stencil(0))
3368                   flux\_diff = flux\_diff - abs(v\_face) * g%dxCv(i,j) * time\_step / g%areaT(i,j) * &
3369                       (stencil(0) - phi * (stencil(0)-stencil(1))/2)
3370                 \textcolor{keywordflow}{else}   \textcolor{comment}{! h(j+1) is valid}
3371                        \textcolor{comment}{! (o.w. flux would most likely be out of cell)}
3372                        \textcolor{comment}{!  but h(j+2) is not}
3373                   flux\_diff = flux\_diff - abs(v\_face) * g%dxCv(i,j) * time\_step / g%areaT(i,j) * stencil(0)
3374 \textcolor{keywordflow}{                endif}
3375 
3376 \textcolor{keywordflow}{              endif}
3377 
3378 \textcolor{keywordflow}{            endif}
3379 
3380             h\_after\_vflux(i,j) = h\_after\_vflux(i,j) + flux\_diff
3381 \textcolor{keywordflow}{          endif}
3382 \textcolor{keywordflow}{        endif}
3383 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! j loop}
3384 \textcolor{keywordflow}{    endif}
3385 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! i loop}
3386 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_ae89ddd9d8c7e9bafea88207d9cd24c6b}\label{namespacemom__ice__shelf__dynamics_ae89ddd9d8c7e9bafea88207d9cd24c6b}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+x@{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+x}}
\index{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+x@{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+x}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+x()}{ice\_shelf\_advect\_thickness\_x()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+x (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1loop__bounds__type}{loop\+\_\+bounds\+\_\+type}), intent(in)}]{LB,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{hmask,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{h0,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{h\+\_\+after\+\_\+uflux,  }\item[{real, dimension(szdib\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{uh\+\_\+ice }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em lb} & Loop bounds structure.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in}  & {\em h0} & The initial ice shelf thicknesses \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+after\+\_\+uflux} & The ice shelf thicknesses after\\
\hline
\mbox{\tt in,out}  & {\em uh\+\_\+ice} & The accumulated zonal ice volume flux \mbox{[}Z L2 $\sim$$>$ m3\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1300 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1300   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
1301   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1302   \textcolor{keywordtype}{type}(loop\_bounds\_type), \textcolor{keywordtype}{intent(in)}    :: lb\textcolor{comment}{   !< Loop bounds structure.}
1303   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}
1304   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1305                           \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
1306 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
1307   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1308                           \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{ !< The initial ice shelf thicknesses [Z ~> m].}
1309   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1310                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_uflux\textcolor{comment}{ !< The ice shelf thicknesses after}
1311 \textcolor{comment}{                                              !! the zonal mass fluxes [Z ~> m].}
1312   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}, &
1313                           \textcolor{keywordtype}{intent(inout)} :: uh\_ice\textcolor{comment}{ !< The accumulated zonal ice volume flux [Z L2 ~> m3]}
1314 
1315   \textcolor{comment}{! use will be made of ISS%hmask here - its value at the boundary will be zero, just like uncovered cells}
1316   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}
1317 
1318 
1319   \textcolor{keywordtype}{integer} :: i, j
1320   \textcolor{keywordtype}{integer} :: ish, ieh, jsh, jeh
1321   \textcolor{keywordtype}{real} :: u\_face     \textcolor{comment}{! Zonal velocity at a face [L Z-1 ~> m s-1]}
1322   \textcolor{keywordtype}{real} :: h\_face     \textcolor{comment}{! Thickness at a face for transport [Z ~> m]}
1323   \textcolor{keywordtype}{real} :: slope\_lim  \textcolor{comment}{! The value of the slope limiter, in the range of 0 to 2 [nondim]}
1324 
1325 \textcolor{comment}{!  is = G%isc-2 ; ie = G%iec+2 ; js = G%jsc ; je = G%jec}
1326 \textcolor{comment}{!  isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed}
1327 \textcolor{comment}{!  i\_off = G%idg\_offset ; j\_off = G%jdg\_offset}
1328 
1329   ish = lb%ish ; ieh = lb%ieh ; jsh = lb%jsh ; jeh = lb%jeh
1330 
1331   \textcolor{comment}{! hmask coded values: 1) fully covered; 2) partly covered - no export; 3) Specified boundary condition}
1332   \textcolor{comment}{! relevant u\_face\_mask coded values: 1) Normal interior point; 4) Specified flux BC}
1333 
1334   \textcolor{keywordflow}{do} j=jsh,jeh ; \textcolor{keywordflow}{do} i=ish-1,ieh
1335     \textcolor{keywordflow}{if} (cs%u\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then} \textcolor{comment}{! The flux itself is a specified boundary condition.}
1336       uh\_ice(i,j) = time\_step * g%dyCu(i,j) * cs%u\_flux\_bdry\_val(i,j)
1337     \textcolor{keywordflow}{elseif} ((hmask(i,j)==1) .or. (hmask(i+1,j) == 1)) \textcolor{keywordflow}{then}
1338       u\_face = 0.5 * (cs%u\_shelf(i,j-1) + cs%u\_shelf(i,j))
1339       h\_face = 0.0 \textcolor{comment}{! This will apply when the source cell is iceless or not fully ice covered.}
1340 
1341       \textcolor{keywordflow}{if} (u\_face > 0) \textcolor{keywordflow}{then}
1342         \textcolor{keywordflow}{if} (hmask(i,j) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the west}
1343           h\_face = cs%thickness\_bdry\_val(i,j)
1344         \textcolor{keywordflow}{elseif} (hmask(i,j) == 1) \textcolor{keywordflow}{then} \textcolor{comment}{! There can be eastward flow through this face.}
1345           \textcolor{keywordflow}{if} ((hmask(i-1,j) == 1) .and. (hmask(i+1,j) == 1)) \textcolor{keywordflow}{then}
1346             slope\_lim = slope\_limiter(h0(i,j)-h0(i-1,j), h0(i+1,j)-h0(i,j))
1347             \textcolor{comment}{! This is a 2nd-order centered scheme with a slope limiter.  We could try PPM here.}
1348             h\_face = h0(i,j) - slope\_lim * 0.5 * (h0(i,j)-h0(i+1,j))
1349           \textcolor{keywordflow}{else}
1350             h\_face = h0(i,j)
1351 \textcolor{keywordflow}{          endif}
1352 \textcolor{keywordflow}{        endif}
1353       \textcolor{keywordflow}{else}
1354         \textcolor{keywordflow}{if} (hmask(i+1,j) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the east}
1355           h\_face = cs%thickness\_bdry\_val(i+1,j)
1356         \textcolor{keywordflow}{elseif} (hmask(i+1,j) == 1) \textcolor{keywordflow}{then}
1357           \textcolor{keywordflow}{if} ((hmask(i,j) == 1) .and. (hmask(i+2,j) == 1)) \textcolor{keywordflow}{then}
1358             slope\_lim = slope\_limiter(h0(i+1,j)-h0(i,j), h0(i+2,j)-h0(i+1,j))
1359             h\_face = h0(i+1,j) - slope\_lim * 0.5 * (h0(i+1,j)-h0(i,j))
1360           \textcolor{keywordflow}{else}
1361             h\_face = h0(i+1,j)
1362 \textcolor{keywordflow}{          endif}
1363 \textcolor{keywordflow}{        endif}
1364 \textcolor{keywordflow}{      endif}
1365 
1366       uh\_ice(i,j) = time\_step * g%dyCu(i,j) * u\_face * h\_face
1367     \textcolor{keywordflow}{else}
1368       uh\_ice(i,j) = 0.0
1369 \textcolor{keywordflow}{    endif}
1370 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1371 
1372   \textcolor{keywordflow}{do} j=jsh,jeh ; \textcolor{keywordflow}{do} i=ish,ieh
1373     \textcolor{keywordflow}{if} (hmask(i,j) /= 3) &
1374       h\_after\_uflux(i,j) = h0(i,j) + (uh\_ice(i-1,j) - uh\_ice(i,j)) * g%IareaT(i,j)
1375 
1376      \textcolor{comment}{! Update the masks of cells that have gone from no ice to partial ice.}
1377     \textcolor{keywordflow}{if} ((hmask(i,j) == 0) .and. ((uh\_ice(i-1,j) > 0.0) .or. (uh\_ice(i,j) < 0.0))) hmask(i,j) = 2
1378 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1379 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a18adb0486d65da9602b6669fbc486db9}\label{namespacemom__ice__shelf__dynamics_a18adb0486d65da9602b6669fbc486db9}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+y@{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+y}}
\index{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+y@{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+y}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+y()}{ice\_shelf\_advect\_thickness\_y()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+advect\+\_\+thickness\+\_\+y (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1loop__bounds__type}{loop\+\_\+bounds\+\_\+type}), intent(in)}]{LB,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{hmask,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{h0,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{h\+\_\+after\+\_\+vflux,  }\item[{real, dimension(szdi\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{vh\+\_\+ice }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em lb} & Loop bounds structure.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in}  & {\em h0} & The initial ice shelf thicknesses \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+after\+\_\+vflux} & The ice shelf thicknesses after\\
\hline
\mbox{\tt in,out}  & {\em vh\+\_\+ice} & The accumulated meridional ice volume flux \mbox{[}Z L2 $\sim$$>$ m3\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1383 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1383   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
1384   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1385   \textcolor{keywordtype}{type}(loop\_bounds\_type), \textcolor{keywordtype}{intent(in)}    :: lb\textcolor{comment}{ !< Loop bounds structure.}
1386   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}
1387   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1388                           \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
1389 \textcolor{comment}{                                              !! partly or fully covered by an ice-shelf}
1390   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1391                           \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{ !< The initial ice shelf thicknesses [Z ~> m].}
1392   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1393                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_vflux\textcolor{comment}{ !< The ice shelf thicknesses after}
1394 \textcolor{comment}{                                              !! the meridional mass fluxes [Z ~> m].}
1395   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}, &
1396                           \textcolor{keywordtype}{intent(inout)} :: vh\_ice\textcolor{comment}{ !< The accumulated meridional ice volume flux [Z L2 ~>
       m3]}
1397 
1398   \textcolor{comment}{! use will be made of ISS%hmask here - its value at the boundary will be zero, just like uncovered cells}
1399   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}
1400 
1401 
1402   \textcolor{keywordtype}{integer} :: i, j
1403   \textcolor{keywordtype}{integer} :: ish, ieh, jsh, jeh
1404   \textcolor{keywordtype}{real} :: v\_face     \textcolor{comment}{! Pseudo-meridional velocity at a face [L Z-1 ~> m s-1]}
1405   \textcolor{keywordtype}{real} :: h\_face     \textcolor{comment}{! Thickness at a face for transport [Z ~> m]}
1406   \textcolor{keywordtype}{real} :: slope\_lim  \textcolor{comment}{! The value of the slope limiter, in the range of 0 to 2 [nondim]}
1407 
1408   ish = lb%ish ; ieh = lb%ieh ; jsh = lb%jsh ; jeh = lb%jeh
1409 
1410   \textcolor{comment}{! hmask coded values: 1) fully covered; 2) partly covered - no export; 3) Specified boundary condition}
1411   \textcolor{comment}{! relevant u\_face\_mask coded values: 1) Normal interior point; 4) Specified flux BC}
1412 
1413   \textcolor{keywordflow}{do} j=jsh-1,jeh ; \textcolor{keywordflow}{do} i=ish,ieh
1414     \textcolor{keywordflow}{if} (cs%v\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then} \textcolor{comment}{! The flux itself is a specified boundary condition.}
1415       vh\_ice(i,j) = time\_step * g%dxCv(i,j) * cs%v\_flux\_bdry\_val(i,j)
1416     \textcolor{keywordflow}{elseif} ((hmask(i,j)==1) .or. (hmask(i,j+1) == 1)) \textcolor{keywordflow}{then}
1417 
1418       v\_face = 0.5 * (cs%v\_shelf(i-1,j) + cs%v\_shelf(i,j))
1419       h\_face = 0.0 \textcolor{comment}{! This will apply when the source cell is iceless or not fully ice covered.}
1420 
1421       \textcolor{keywordflow}{if} (v\_face > 0) \textcolor{keywordflow}{then}
1422         \textcolor{keywordflow}{if} (hmask(i,j) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the south}
1423           h\_face = cs%thickness\_bdry\_val(i,j)
1424         \textcolor{keywordflow}{elseif} (hmask(i,j) == 1) \textcolor{keywordflow}{then} \textcolor{comment}{! There can be northtward flow through this face.}
1425           \textcolor{keywordflow}{if} ((hmask(i,j-1) == 1) .and. (hmask(i,j+1) == 1)) \textcolor{keywordflow}{then}
1426             slope\_lim = slope\_limiter(h0(i,j)-h0(i,j-1), h0(i,j+1)-h0(i,j))
1427             \textcolor{comment}{! This is a 2nd-order centered scheme with a slope limiter.  We could try PPM here.}
1428             h\_face = h0(i,j) - slope\_lim * 0.5 * (h0(i,j)-h0(i,j+1))
1429           \textcolor{keywordflow}{else}
1430             h\_face = h0(i,j)
1431 \textcolor{keywordflow}{          endif}
1432 \textcolor{keywordflow}{        endif}
1433       \textcolor{keywordflow}{else}
1434         \textcolor{keywordflow}{if} (hmask(i,j+1) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the north}
1435           h\_face = cs%thickness\_bdry\_val(i,j+1)
1436         \textcolor{keywordflow}{elseif} (hmask(i,j+1) == 1) \textcolor{keywordflow}{then}
1437           \textcolor{keywordflow}{if} ((hmask(i,j) == 1) .and. (hmask(i,j+2) == 1)) \textcolor{keywordflow}{then}
1438             slope\_lim = slope\_limiter(h0(i,j+1)-h0(i,j), h0(i,j+2)-h0(i,j+1))
1439             h\_face = h0(i,j+1) - slope\_lim * 0.5 * (h0(i,j+1)-h0(i,j))
1440           \textcolor{keywordflow}{else}
1441             h\_face = h0(i,j+1)
1442 \textcolor{keywordflow}{          endif}
1443 \textcolor{keywordflow}{        endif}
1444 \textcolor{keywordflow}{      endif}
1445 
1446       vh\_ice(i,j) = time\_step * g%dxCv(i,j) * v\_face * h\_face
1447     \textcolor{keywordflow}{else}
1448       vh\_ice(i,j) = 0.0
1449 \textcolor{keywordflow}{    endif}
1450 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1451 
1452   \textcolor{keywordflow}{do} j=jsh,jeh ; \textcolor{keywordflow}{do} i=ish,ieh
1453     \textcolor{keywordflow}{if} (hmask(i,j) /= 3) &
1454       h\_after\_vflux(i,j) = h0(i,j) + (vh\_ice(i,j-1) - vh\_ice(i,j)) * g%IareaT(i,j)
1455 
1456     \textcolor{comment}{! Update the masks of cells that have gone from no ice to partial ice.}
1457     \textcolor{keywordflow}{if} ((hmask(i,j) == 0) .and. ((vh\_ice(i,j-1) > 0.0) .or. (vh\_ice(i,j) < 0.0))) hmask(i,j) = 2
1458 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1459 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a78c690be8b27b627bc228f1aba28164d}\label{namespacemom__ice__shelf__dynamics_a78c690be8b27b627bc228f1aba28164d}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+dyn\+\_\+end@{ice\+\_\+shelf\+\_\+dyn\+\_\+end}}
\index{ice\+\_\+shelf\+\_\+dyn\+\_\+end@{ice\+\_\+shelf\+\_\+dyn\+\_\+end}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+dyn\+\_\+end()}{ice\_shelf\_dyn\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+dyn\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Deallocates all memory associated with the ice shelf dynamics module. 


\begin{DoxyParams}{Parameters}
{\em cs} & A pointer to the ice shelf dynamics control structure \\
\hline
\end{DoxyParams}


Definition at line 2955 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2955   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{pointer}   :: cs\textcolor{comment}{ !< A pointer to the ice shelf dynamics control structure}
2956 
2957   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
2958 
2959   \textcolor{keyword}{deallocate}(cs%u\_shelf, cs%v\_shelf)
2960   \textcolor{keyword}{deallocate}(cs%t\_shelf, cs%tmask)
2961   \textcolor{keyword}{deallocate}(cs%u\_bdry\_val, cs%v\_bdry\_val, cs%t\_bdry\_val)
2962   \textcolor{keyword}{deallocate}(cs%u\_face\_mask, cs%v\_face\_mask)
2963   \textcolor{keyword}{deallocate}(cs%umask, cs%vmask)
2964 
2965   \textcolor{keyword}{deallocate}(cs%ice\_visc, cs%basal\_traction)
2966   \textcolor{keyword}{deallocate}(cs%OD\_rt, cs%OD\_av)
2967   \textcolor{keyword}{deallocate}(cs%ground\_frac, cs%ground\_frac\_rt)
2968 
2969   \textcolor{keyword}{deallocate}(cs)
2970 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a48cfc9a51fb6a9e37cd004c818bea077}\label{namespacemom__ice__shelf__dynamics_a48cfc9a51fb6a9e37cd004c818bea077}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+min\+\_\+thickness\+\_\+calve@{ice\+\_\+shelf\+\_\+min\+\_\+thickness\+\_\+calve}}
\index{ice\+\_\+shelf\+\_\+min\+\_\+thickness\+\_\+calve@{ice\+\_\+shelf\+\_\+min\+\_\+thickness\+\_\+calve}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+min\+\_\+thickness\+\_\+calve()}{ice\_shelf\_min\_thickness\_calve()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+min\+\_\+thickness\+\_\+calve (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{h\+\_\+shelf,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{area\+\_\+shelf\+\_\+h,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{hmask,  }\item[{real, intent(in)}]{thickness\+\_\+calve,  }\item[{integer, intent(in), optional}]{halo }\end{DoxyParamCaption})}



Apply a very simple calving law using a minimum thickness rule. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+shelf} & The ice shelf thickness \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em area\+\_\+shelf\+\_\+h} & The area per cell covered by the ice shelf \mbox{[}L2 $\sim$$>$ m2\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em hmask} & A mask indicating which tracer points are partly or fully covered by an ice-\/shelf\\
\hline
\mbox{\tt in}  & {\em thickness\+\_\+calve} & The thickness at which to trigger calving \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em halo} & The number of halo points to use. If not present, work on the entire data domain. \\
\hline
\end{DoxyParams}


Definition at line 1655 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1655   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1656   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: h\_shelf\textcolor{comment}{ !< The ice shelf thickness [Z ~> m].}
1657   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: area\_shelf\_h\textcolor{comment}{ !< The area per cell covered by}
1658 \textcolor{comment}{                                             !! the ice shelf [L2 ~> m2].}
1659   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
1660 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
1661   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: thickness\_calve\textcolor{comment}{ !< The thickness at which to trigger calving [Z
       ~> m].}
1662   \textcolor{keywordtype}{integer},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: halo\textcolor{comment}{  !< The number of halo points to use.  If not present,}
1663 \textcolor{comment}{                                                !! work on the entire data domain.}
1664   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
1665 
1666   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(halo)) \textcolor{keywordflow}{then}
1667     is = g%isc - halo ; ie = g%iec + halo ; js = g%jsc - halo ; je = g%jec + halo
1668   \textcolor{keywordflow}{else}
1669     is = g%isd ; ie = g%ied ; js = g%jsd ; je = g%jed
1670 \textcolor{keywordflow}{  endif}
1671 
1672   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1673 \textcolor{comment}{!    if ((h\_shelf(i,j) < CS%thickness\_calve) .and. (hmask(i,j) == 1) .and. &}
1674 \textcolor{comment}{!        (CS%ground\_frac(i,j) == 0.0)) then}
1675     \textcolor{keywordflow}{if} ((h\_shelf(i,j) < thickness\_calve) .and. (area\_shelf\_h(i,j) > 0.)) \textcolor{keywordflow}{then}
1676       h\_shelf(i,j) = 0.0
1677       area\_shelf\_h(i,j) = 0.0
1678       hmask(i,j) = 0.0
1679 \textcolor{keywordflow}{    endif}
1680 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1681 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_af0560b5ebc88617568bd5d580dec7822}\label{namespacemom__ice__shelf__dynamics_af0560b5ebc88617568bd5d580dec7822}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+solve\+\_\+inner@{ice\+\_\+shelf\+\_\+solve\+\_\+inner}}
\index{ice\+\_\+shelf\+\_\+solve\+\_\+inner@{ice\+\_\+shelf\+\_\+solve\+\_\+inner}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+solve\+\_\+inner()}{ice\_shelf\_solve\_inner()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+solve\+\_\+inner (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{u\+\_\+shlf,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{v\+\_\+shlf,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{taudx,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{taudy,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{H\+\_\+node,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{float\+\_\+cond,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{integer, intent(out)}]{conv\+\_\+flag,  }\item[{integer, intent(out)}]{iters,  }\item[{type(time\+\_\+type), intent(in)}]{time,  }\item[{real, dimension(8,4,szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{Phi,  }\item[{real, dimension(\+:,\+:,\+:,\+:,\+:,\+:), intent(in)}]{Phisub }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in,out}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em v\+\_\+shlf} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em taudx} & The x-\/direction driving stress \mbox{[}R L3 Z T-\/2 $\sim$$>$ kg m s-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em taudy} & The y-\/direction driving stress \mbox{[}R L3 Z T-\/2 $\sim$$>$ kg m s-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em h\+\_\+node} & The ice shelf thickness at nodal (corner)\\
\hline
\mbox{\tt in}  & {\em float\+\_\+cond} & An array indicating where the ice\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt out}  & {\em conv\+\_\+flag} & A flag indicating whether (1) or not (0) the iterations have converged to the specified tolerance\\
\hline
\mbox{\tt out}  & {\em iters} & The number of iterations used in the solver.\\
\hline
\mbox{\tt in}  & {\em time} & The current model time\\
\hline
\mbox{\tt in}  & {\em phi} & The gradients of bilinear basis elements at Gaussian\\
\hline
\mbox{\tt in}  & {\em phisub} & Quadrature structure weights at subgridscale \\
\hline
\end{DoxyParams}


Definition at line 1003 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1003   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
1004   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{ !< A structure with elements that describe}
1005 \textcolor{comment}{                                           !! the ice-shelf state}
1006   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1007   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
1008   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1009                           \textcolor{keywordtype}{intent(inout)} :: u\_shlf\textcolor{comment}{  !< The zonal ice shelf velocity at vertices [L T-1 ~> m
       s-1]}
1010   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1011                           \textcolor{keywordtype}{intent(inout)} :: v\_shlf\textcolor{comment}{  !< The meridional ice shelf velocity at vertices [L T-1
       ~> m s-1]}
1012   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1013                           \textcolor{keywordtype}{intent(in)}    :: taudx\textcolor{comment}{ !< The x-direction driving stress [R L3 Z T-2 ~> kg m s-2]}
1014   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1015                           \textcolor{keywordtype}{intent(in)}    :: taudy\textcolor{comment}{  !< The y-direction driving stress [R L3 Z T-2 ~> kg m
       s-2]}
1016   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
1017                           \textcolor{keywordtype}{intent(in)}    :: h\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}
1018 \textcolor{comment}{                                             !! points [Z ~> m].}
1019   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1020                           \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}
1021 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}
1022   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1023                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
1024 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
1025   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(out)}   :: conv\_flag\textcolor{comment}{ !< A flag indicating whether (1) or not (0) the}
1026 \textcolor{comment}{                                           !! iterations have converged to the specified tolerance}
1027   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(out)}   :: iters\textcolor{comment}{ !< The number of iterations used in the solver.}
1028   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
1029   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(8,4,SZDI\_(G),SZDJ\_(G))}, &
1030                           \textcolor{keywordtype}{intent(in)}    :: phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}
1031 \textcolor{comment}{                                             !! quadrature points surrounding the cell vertices [L-1 ~>
       m-1].}
1032   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, &
1033                           \textcolor{keywordtype}{intent(in)}    :: phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}
1034 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}
1035 \textcolor{comment}{! one linear solve (nonlinear iteration) of the solution for velocity}
1036 
1037 \textcolor{comment}{! in this subroutine:}
1038 \textcolor{comment}{!    boundary contributions are added to taud to get the RHS}
1039 \textcolor{comment}{!    diagonal of matrix is found (for Jacobi precondition)}
1040 \textcolor{comment}{!    CG iteration is carried out for max. iterations or until convergence}
1041 
1042 \textcolor{comment}{! assumed - u, v, taud, visc, basal\_traction are valid on the halo}
1043 
1044   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} ::  &
1045                         ru, rv, &     \textcolor{comment}{! Residuals in the stress calculations [R L3 Z T-2 ~> m kg s-2]}
1046                         ru\_old, rv\_old, & \textcolor{comment}{! Previous values of Ru and Rv [R L3 Z T-2 ~> m kg s-2]}
1047                         zu, zv, & \textcolor{comment}{! Contributions to velocity changes [L T-1 ~> m s-1]}
1048                         zu\_old, zv\_old, & \textcolor{comment}{! Previous values of Zu and Zv [L T-1 ~> m s-1]}
1049                         diagu, diagv, & \textcolor{comment}{! Diagonals with units like Ru/Zu [R L2 Z T-1 ~> kg s-1]}
1050                         rhsu, rhsv, & \textcolor{comment}{! Right hand side of the stress balance [R L3 Z T-2 ~> m kg s-2]}
1051                         ubd, vbd, &   \textcolor{comment}{! Boundary stress contributions [R L3 Z T-2 ~> kg m s-2]}
1052                         au, av, & \textcolor{comment}{! The retarding lateral stress contributions [R L3 Z T-2 ~> kg m s-2]}
1053                         du, dv, & \textcolor{comment}{! Velocity changes [L T-1 ~> m s-1]}
1054                         sum\_vec, sum\_vec\_2
1055   \textcolor{keywordtype}{real}    :: tol, beta\_k, area, dot\_p1, resid0, cg\_halo
1056   \textcolor{keywordtype}{real}    :: num, denom
1057   \textcolor{keywordtype}{real}    :: alpha\_k     \textcolor{comment}{! A scaling factor for iterative corrections [nondim]}
1058   \textcolor{keywordtype}{real}    :: resid\_scale \textcolor{comment}{! A scaling factor for redimensionalizing the global residuals [m2 L-2 ~> 1]}
1059                          \textcolor{comment}{! [m2 L-2 ~> 1] [R L3 Z T-2 ~> m kg s-2]}
1060   \textcolor{keywordtype}{real}    :: resid2\_scale \textcolor{comment}{! A scaling factor for redimensionalizing the global squared residuals}
1061                          \textcolor{comment}{! [m2 L-2 ~> 1] [R L3 Z T-2 ~> m kg s-2]}
1062   \textcolor{keywordtype}{real}    :: rhoi\_rhow  \textcolor{comment}{! The density of ice divided by a typical water density [nondim]}
1063   \textcolor{keywordtype}{integer} :: iter, i, j, isd, ied, jsd, jed, isc, iec, jsc, jec, is, js, ie, je
1064   \textcolor{keywordtype}{integer} :: is\_sum, js\_sum, ie\_sum, je\_sum \textcolor{comment}{! Loop bounds for global sums or arrays starting at 1.}
1065   \textcolor{keywordtype}{integer} :: isdq, iedq, jsdq, jedq, iscq, iecq, jscq, jecq, nx\_halo, ny\_halo
1066 
1067   isdq = g%isdB ; iedq = g%iedB ; jsdq = g%jsdB ; jedq = g%jedB
1068   iscq = g%iscB ; iecq = g%iecB ; jscq = g%jscB ; jecq = g%jecB
1069   ny\_halo = g%domain%njhalo ; nx\_halo = g%domain%nihalo
1070   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
1071   isc = g%isc ; iec = g%iec ; jsc = g%jsc ; jec = g%jec
1072 
1073   rhoi\_rhow = cs%density\_ice / cs%density\_ocean\_avg
1074 
1075   zu(:,:) = 0 ; zv(:,:) = 0 ; diagu(:,:) = 0 ; diagv(:,:) = 0
1076   ru(:,:) = 0 ; rv(:,:) = 0 ; au(:,:) = 0 ; av(:,:) = 0
1077   du(:,:) = 0 ; dv(:,:) = 0 ; ubd(:,:) = 0 ; vbd(:,:) = 0
1078   dot\_p1 = 0
1079 
1080   \textcolor{comment}{! Determine the loop limits for sums, bearing in mind that the arrays will be starting at 1.}
1081   is\_sum = g%isc + (1-g%IsdB)
1082   ie\_sum = g%iecB + (1-g%IsdB)
1083   \textcolor{comment}{! Include the edge if tile is at the western bdry;  Should add a test to avoid this if reentrant.}
1084   \textcolor{keywordflow}{if} (g%isc+g%idg\_offset==g%isg) is\_sum = g%IscB + (1-g%IsdB)
1085 
1086   js\_sum = g%jsc + (1-g%JsdB)
1087   je\_sum = g%jecB + (1-g%JsdB)
1088   \textcolor{comment}{! Include the edge if tile is at the southern bdry;  Should add a test to avoid this if reentrant.}
1089   \textcolor{keywordflow}{if} (g%jsc+g%jdg\_offset==g%jsg) js\_sum = g%JscB + (1-g%JsdB)
1090 
1091   \textcolor{keyword}{call }apply\_boundary\_values(cs, iss, g, us, time, phisub, h\_node, cs%ice\_visc, &
1092                              cs%basal\_traction, float\_cond, rhoi\_rhow, ubd, vbd)
1093 
1094   rhsu(:,:) = taudx(:,:) - ubd(:,:)
1095   rhsv(:,:) = taudy(:,:) - vbd(:,:)
1096 
1097   \textcolor{keyword}{call }pass\_vector(rhsu, rhsv, g%domain, to\_all, bgrid\_ne)
1098 
1099   \textcolor{keyword}{call }matrix\_diagonal(cs, g, us, float\_cond, h\_node, cs%ice\_visc, cs%basal\_traction, &
1100                        hmask, rhoi\_rhow, phisub, diagu, diagv)
1101 
1102   \textcolor{keyword}{call }pass\_vector(diagu, diagv, g%domain, to\_all, bgrid\_ne)
1103 
1104   \textcolor{keyword}{call }cg\_action(au, av, u\_shlf, v\_shlf, phi, phisub, cs%umask, cs%vmask, hmask, &
1105                  h\_node, cs%ice\_visc, float\_cond, g%bathyT, cs%basal\_traction, &
1106                  g, us, isc-1, iec+1, jsc-1, jec+1, rhoi\_rhow)
1107 
1108   \textcolor{keyword}{call }pass\_vector(au, av, g%domain, to\_all, bgrid\_ne)
1109 
1110   ru(:,:) = (rhsu(:,:) - au(:,:))
1111   rv(:,:) = (rhsv(:,:) - av(:,:))
1112 
1113   resid\_scale = us%L\_to\_m**2*us%s\_to\_T*us%RZ\_to\_kg\_m2*us%L\_T\_to\_m\_s**2
1114   resid2\_scale = (us%RZ\_to\_kg\_m2*us%L\_to\_m*us%L\_T\_to\_m\_s**2)**2
1115 
1116   sum\_vec(:,:) = 0.0
1117   \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq
1118     \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) sum\_vec(i,j) = resid2\_scale*ru(i,j)**2
1119     \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) sum\_vec(i,j) = sum\_vec(i,j) + resid2\_scale*rv(i,j)**2
1120 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1121 
1122   dot\_p1 = \hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}( sum\_vec, js\_sum, ie\_sum, js\_sum, je\_sum )
1123 
1124   resid0 = sqrt(dot\_p1)
1125 
1126   \textcolor{keywordflow}{do} j=jsdq,jedq
1127     \textcolor{keywordflow}{do} i=isdq,iedq
1128       \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) zu(i,j) = ru(i,j) / diagu(i,j)
1129       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) zv(i,j) = rv(i,j) / diagv(i,j)
1130 \textcolor{keywordflow}{    enddo}
1131 \textcolor{keywordflow}{  enddo}
1132 
1133   du(:,:) = zu(:,:) ; dv(:,:) = zv(:,:)
1134 
1135   cg\_halo = 3
1136   conv\_flag = 0
1137 
1138   \textcolor{comment}{!!!!!!!!!!!!!!!!!!}
1139   \textcolor{comment}{!!              !!}
1140   \textcolor{comment}{!! MAIN CG LOOP !!}
1141   \textcolor{comment}{!!              !!}
1142   \textcolor{comment}{!!!!!!!!!!!!!!!!!!}
1143 
1144   \textcolor{comment}{! initially, c-grid data is valid up to 3 halo nodes out}
1145 
1146   \textcolor{keywordflow}{do} iter = 1,cs%cg\_max\_iterations
1147 
1148     \textcolor{comment}{! assume asymmetry}
1149     \textcolor{comment}{! thus we can never assume that any arrays are legit more than 3 vertices past}
1150     \textcolor{comment}{! the computational domain - this is their state in the initial iteration}
1151 
1152 
1153     is = isc - cg\_halo ; ie = iecq + cg\_halo
1154     js = jscq - cg\_halo ; je = jecq + cg\_halo
1155 
1156     au(:,:) = 0 ; av(:,:) = 0
1157 
1158     \textcolor{keyword}{call }cg\_action(au, av, du, dv, phi, phisub, cs%umask, cs%vmask, hmask, &
1159                    h\_node, cs%ice\_visc, float\_cond, g%bathyT, cs%basal\_traction, &
1160                    g, us, is, ie, js, je, rhoi\_rhow)
1161 
1162     \textcolor{comment}{! Au, Av valid region moves in by 1}
1163 
1164 
1165     sum\_vec(:,:) = 0.0 ; sum\_vec\_2(:,:) = 0.0
1166 
1167     \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq
1168       \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) \textcolor{keywordflow}{then}
1169         sum\_vec(i,j) = resid\_scale * zu(i,j) * ru(i,j)
1170         sum\_vec\_2(i,j) = resid\_scale * du(i,j) * au(i,j)
1171 \textcolor{keywordflow}{      endif}
1172       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) \textcolor{keywordflow}{then}
1173         sum\_vec(i,j) = sum\_vec(i,j) + resid\_scale * zv(i,j) * rv(i,j)
1174         sum\_vec\_2(i,j) = sum\_vec\_2(i,j) + resid\_scale * dv(i,j) * av(i,j)
1175 \textcolor{keywordflow}{      endif}
1176 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1177 
1178     alpha\_k = \hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}( sum\_vec, is\_sum, ie\_sum, js\_sum, je\_sum ) / &
1179               \hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}( sum\_vec\_2, is\_sum, ie\_sum, js\_sum, je\_sum )
1180 
1181 
1182     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
1183       \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) u\_shlf(i,j) = u\_shlf(i,j) + alpha\_k * du(i,j)
1184       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) v\_shlf(i,j) = v\_shlf(i,j) + alpha\_k * dv(i,j)
1185 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1186 
1187     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
1188       \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) \textcolor{keywordflow}{then}
1189         ru\_old(i,j) = ru(i,j) ; zu\_old(i,j) = zu(i,j)
1190 \textcolor{keywordflow}{      endif}
1191       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) \textcolor{keywordflow}{then}
1192         rv\_old(i,j) = rv(i,j) ; zv\_old(i,j) = zv(i,j)
1193 \textcolor{keywordflow}{      endif}
1194 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1195 
1196 \textcolor{comment}{!    Ru(:,:) = Ru(:,:) - alpha\_k * Au(:,:)}
1197 \textcolor{comment}{!    Rv(:,:) = Rv(:,:) - alpha\_k * Av(:,:)}
1198 
1199     \textcolor{keywordflow}{do} j=jsd,jed
1200       \textcolor{keywordflow}{do} i=isd,ied
1201         \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) ru(i,j) = ru(i,j) - alpha\_k * au(i,j)
1202         \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) rv(i,j) = rv(i,j) - alpha\_k * av(i,j)
1203 \textcolor{keywordflow}{      enddo}
1204 \textcolor{keywordflow}{    enddo}
1205 
1206     \textcolor{keywordflow}{do} j=jsdq,jedq
1207       \textcolor{keywordflow}{do} i=isdq,iedq
1208         \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) \textcolor{keywordflow}{then}
1209           zu(i,j) = ru(i,j) / diagu(i,j)
1210 \textcolor{keywordflow}{        endif}
1211         \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) \textcolor{keywordflow}{then}
1212           zv(i,j) = rv(i,j) / diagv(i,j)
1213 \textcolor{keywordflow}{        endif}
1214 \textcolor{keywordflow}{      enddo}
1215 \textcolor{keywordflow}{    enddo}
1216 
1217     \textcolor{comment}{! R,u,v,Z valid region moves in by 1}
1218 
1219     \textcolor{comment}{! beta\_k = (Z \(\backslash\)dot R) / (Zold \(\backslash\)dot Rold\}}
1220     sum\_vec(:,:) = 0.0 ; sum\_vec\_2(:,:) = 0.0
1221 
1222     \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq
1223       \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) \textcolor{keywordflow}{then}
1224         sum\_vec(i,j) = resid\_scale * zu(i,j) * ru(i,j)
1225         sum\_vec\_2(i,j) = resid\_scale * zu\_old(i,j) * ru\_old(i,j)
1226 \textcolor{keywordflow}{      endif}
1227       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) \textcolor{keywordflow}{then}
1228         sum\_vec(i,j) = sum\_vec(i,j) + resid\_scale * zv(i,j) * rv(i,j)
1229         sum\_vec\_2(i,j) = sum\_vec\_2(i,j) + resid\_scale * zv\_old(i,j) * rv\_old(i,j)
1230 \textcolor{keywordflow}{      endif}
1231 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1232 
1233     beta\_k = \hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}(sum\_vec, is\_sum, ie\_sum, js\_sum, je\_sum ) / &
1234              \hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}(sum\_vec\_2, is\_sum, ie\_sum, js\_sum, je\_sum )
1235 
1236 \textcolor{comment}{!    Du(:,:) = Zu(:,:) + beta\_k * Du(:,:)}
1237 \textcolor{comment}{!    Dv(:,:) = Zv(:,:) + beta\_k * Dv(:,:)}
1238 
1239     \textcolor{keywordflow}{do} j=jsd,jed
1240       \textcolor{keywordflow}{do} i=isd,ied
1241         \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) du(i,j) = zu(i,j) + beta\_k * du(i,j)
1242         \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) dv(i,j) = zv(i,j) + beta\_k * dv(i,j)
1243 \textcolor{keywordflow}{      enddo}
1244 \textcolor{keywordflow}{    enddo}
1245 
1246    \textcolor{comment}{! D valid region moves in by 1}
1247 
1248     sum\_vec(:,:) = 0.0
1249     \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq
1250       \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) sum\_vec(i,j) = resid2\_scale*ru(i,j)**2
1251       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) sum\_vec(i,j) = sum\_vec(i,j) + resid2\_scale*rv(i,j)**2
1252 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1253 
1254     dot\_p1 = \hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}( sum\_vec, is\_sum, ie\_sum, js\_sum, je\_sum )
1255     dot\_p1 = sqrt(dot\_p1)
1256 
1257     \textcolor{keywordflow}{if} (dot\_p1 <= cs%cg\_tolerance * resid0) \textcolor{keywordflow}{then}
1258       iters = iter
1259       conv\_flag = 1
1260       \textcolor{keywordflow}{exit}
1261 \textcolor{keywordflow}{    endif}
1262 
1263     cg\_halo = cg\_halo - 1
1264 
1265     \textcolor{keywordflow}{if} (cg\_halo == 0) \textcolor{keywordflow}{then}
1266       \textcolor{comment}{! pass vectors}
1267       \textcolor{keyword}{call }pass\_vector(du, dv, g%domain, to\_all, bgrid\_ne)
1268       \textcolor{keyword}{call }pass\_vector(u\_shlf, v\_shlf, g%domain, to\_all, bgrid\_ne)
1269       \textcolor{keyword}{call }pass\_vector(ru, rv, g%domain, to\_all, bgrid\_ne)
1270       cg\_halo = 3
1271 \textcolor{keywordflow}{    endif}
1272 
1273 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end of CG loop}
1274 
1275   \textcolor{keywordflow}{do} j=jsdq,jedq
1276     \textcolor{keywordflow}{do} i=isdq,iedq
1277       \textcolor{keywordflow}{if} (cs%umask(i,j) == 3) \textcolor{keywordflow}{then}
1278         u\_shlf(i,j) = cs%u\_bdry\_val(i,j)
1279       \textcolor{keywordflow}{elseif} (cs%umask(i,j) == 0) \textcolor{keywordflow}{then}
1280         u\_shlf(i,j) = 0
1281 \textcolor{keywordflow}{      endif}
1282 
1283       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 3) \textcolor{keywordflow}{then}
1284         v\_shlf(i,j) = cs%v\_bdry\_val(i,j)
1285       \textcolor{keywordflow}{elseif} (cs%vmask(i,j) == 0) \textcolor{keywordflow}{then}
1286         v\_shlf(i,j) = 0
1287 \textcolor{keywordflow}{      endif}
1288 \textcolor{keywordflow}{    enddo}
1289 \textcolor{keywordflow}{  enddo}
1290 
1291   \textcolor{keyword}{call }pass\_vector(u\_shlf, v\_shlf, g%domain, to\_all, bgrid\_ne)
1292 
1293   \textcolor{keywordflow}{if} (conv\_flag == 0) \textcolor{keywordflow}{then}
1294     iters = cs%cg\_max\_iterations
1295 \textcolor{keywordflow}{  endif}
1296 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_adb9d6c268c8acbd29ffab94087100099}\label{namespacemom__ice__shelf__dynamics_adb9d6c268c8acbd29ffab94087100099}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+solve\+\_\+outer@{ice\+\_\+shelf\+\_\+solve\+\_\+outer}}
\index{ice\+\_\+shelf\+\_\+solve\+\_\+outer@{ice\+\_\+shelf\+\_\+solve\+\_\+outer}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+solve\+\_\+outer()}{ice\_shelf\_solve\_outer()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+solve\+\_\+outer (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{u\+\_\+shlf,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{v\+\_\+shlf,  }\item[{integer, intent(out)}]{iters,  }\item[{type(time\+\_\+type), intent(in)}]{time }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & The ice shelf dynamics control structure\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in,out}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em v\+\_\+shlf} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em iters} & The number of iterations used in the solver.\\
\hline
\mbox{\tt in}  & {\em time} & The current model time \\
\hline
\end{DoxyParams}


Definition at line 780 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
780   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< The ice shelf dynamics control structure}
781   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{ !< A structure with elements that describe}
782 \textcolor{comment}{                                               !! the ice-shelf state}
783   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
784   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
785   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
786                           \textcolor{keywordtype}{intent(inout)} :: u\_shlf\textcolor{comment}{  !< The zonal ice shelf velocity at vertices [L T-1 ~> m
       s-1]}
787   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
788                           \textcolor{keywordtype}{intent(inout)} :: v\_shlf\textcolor{comment}{  !< The meridional ice shelf velocity at vertices [L T-1
       ~> m s-1]}
789   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(out)}   :: iters\textcolor{comment}{ !< The number of iterations used in the solver.}
790   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
791 
792   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: taudx, taudy \textcolor{comment}{! Driving stresses at q-points [R L3 Z T-2 ~> kg m
       s-2]}
793   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: u\_bdry\_cont \textcolor{comment}{! Boundary u-stress contribution [R L3 Z T-2 ~> kg m
       s-2]}
794   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: v\_bdry\_cont \textcolor{comment}{! Boundary v-stress contribution [R L3 Z T-2 ~> kg m
       s-2]}
795   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: au, av \textcolor{comment}{! The retarding lateral stress contributions [R L3 Z T-2
       ~> kg m s-2]}
796   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: err\_u, err\_v
797   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: u\_last, v\_last \textcolor{comment}{! Previous velocities [L T-1 ~> m s-1]}
798   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: h\_node \textcolor{comment}{! Ice shelf thickness at corners [Z ~> m].}
799   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: float\_cond \textcolor{comment}{! An array indicating where the ice}
800                                                 \textcolor{comment}{! shelf is floating: 0 if floating, 1 if not.}
801   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}
802   \textcolor{keywordtype}{integer} :: conv\_flag, i, j, k,l, iter
803   \textcolor{keywordtype}{integer} :: isdq, iedq, jsdq, jedq, isd, ied, jsd, jed, nodefloat, nsub
804   \textcolor{keywordtype}{real}    :: err\_max, err\_tempu, err\_tempv, err\_init, area, max\_vel, tempu, tempv
805   \textcolor{keywordtype}{real}    :: rhoi\_rhow \textcolor{comment}{! The density of ice divided by a typical water density [nondim]}
806   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:,:)} :: phi => null() \textcolor{comment}{! The gradients of bilinear basis elements at Gaussian}
807                                                 \textcolor{comment}{! quadrature points surrounding the cell vertices [m-1].}
808   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)} :: phisub => null() \textcolor{comment}{! Quadrature structure weights at subgridscale}
809                                                 \textcolor{comment}{!  locations for finite element calculations [nondim]}
810   \textcolor{keywordtype}{character(2)}                :: iternum
811   \textcolor{keywordtype}{character(2)}                :: numproc
812 
813   \textcolor{comment}{! for GL interpolation}
814   nsub = cs%n\_sub\_regularize
815 
816   isdq = g%isdB ; iedq = g%iedB ; jsdq = g%jsdB ; jedq = g%jedB
817   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
818   rhoi\_rhow = cs%density\_ice / cs%density\_ocean\_avg
819 
820   taudx(:,:) = 0.0 ; taudy(:,:) = 0.0
821   u\_bdry\_cont(:,:) = 0.0 ; v\_bdry\_cont(:,:) = 0.0
822   au(:,:) = 0.0 ; av(:,:) = 0.0
823 
824   \textcolor{comment}{! need to make these conditional on GL interpolation}
825   float\_cond(:,:) = 0.0 ; h\_node(:,:) = 0.0
826   \textcolor{keyword}{allocate}(phisub(nsub,nsub,2,2,2,2)) ; phisub(:,:,:,:,:,:) = 0.0
827 
828   \textcolor{keyword}{call }calc\_shelf\_driving\_stress(cs, iss, g, us, taudx, taudy, cs%OD\_av)
829 
830   \textcolor{comment}{! This is to determine which cells contain the grounding line, the criterion being that the cell}
831   \textcolor{comment}{! is ice-covered, with some nodes floating and some grounded flotation condition is estimated by}
832   \textcolor{comment}{! assuming topography is cellwise constant and H is bilinear in a cell; floating where}
833   \textcolor{comment}{! rho\_i/rho\_w * H\_node - D is negative}
834 
835   \textcolor{comment}{! need to make this conditional on GL interp}
836 
837   \textcolor{keywordflow}{if} (cs%GL\_regularize) \textcolor{keywordflow}{then}
838 
839     \textcolor{keyword}{call }interpolate\_h\_to\_b(g, iss%h\_shelf, iss%hmask, h\_node)
840 
841     \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
842       nodefloat = 0
843 
844       \textcolor{keywordflow}{do} l=0,1 ; \textcolor{keywordflow}{do} k=0,1
845         \textcolor{keywordflow}{if} ((iss%hmask(i,j) == 1) .and. &
846             (rhoi\_rhow * h\_node(i-1+k,j-1+l) - g%bathyT(i,j) <= 0)) \textcolor{keywordflow}{then}
847           nodefloat = nodefloat + 1
848 \textcolor{keywordflow}{        endif}
849 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
850       \textcolor{keywordflow}{if} ((nodefloat > 0) .and. (nodefloat < 4)) \textcolor{keywordflow}{then}
851         float\_cond(i,j) = 1.0
852         cs%ground\_frac(i,j) = 1.0
853 \textcolor{keywordflow}{      endif}
854 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
855 
856     \textcolor{keyword}{call }pass\_var(float\_cond, g%Domain)
857 
858     \textcolor{keyword}{call }bilinear\_shape\_functions\_subgrid(phisub, nsub)
859 
860 \textcolor{keywordflow}{  endif}
861 
862   \textcolor{comment}{! must prepare Phi}
863   \textcolor{keyword}{allocate}(phi(1:8,1:4,isd:ied,jsd:jed)) ; phi(:,:,:,:) = 0.0
864 
865   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
866     \textcolor{keyword}{call }bilinear\_shape\_fn\_grid(g, i, j, phi(:,:,i,j))
867 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
868 
869   \textcolor{keyword}{call }calc\_shelf\_visc(cs, iss, g, us, u\_shlf, v\_shlf)
870 
871   \textcolor{keyword}{call }pass\_var(cs%ice\_visc, g%domain)
872   \textcolor{keyword}{call }pass\_var(cs%basal\_traction, g%domain)
873 
874   \textcolor{comment}{! This makes sure basal stress is only applied when it is supposed to be}
875   \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%isd,g%ied
876     cs%basal\_traction(i,j) = cs%basal\_traction(i,j) * cs%ground\_frac(i,j)
877 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
878 
879   \textcolor{keyword}{call }apply\_boundary\_values(cs, iss, g, us, time, phisub, h\_node, cs%ice\_visc, &
880                              cs%basal\_traction, float\_cond, rhoi\_rhow, u\_bdry\_cont, v\_bdry\_cont)
881 
882   au(:,:) = 0.0 ; av(:,:) = 0.0
883 
884   \textcolor{keyword}{call }cg\_action(au, av, u\_shlf, v\_shlf, phi, phisub, cs%umask, cs%vmask, iss%hmask, h\_node, &
885                  cs%ice\_visc, float\_cond, g%bathyT, cs%basal\_traction, &
886                  g, us, g%isc-1, g%iec+1, g%jsc-1, g%jec+1, rhoi\_rhow)
887 
888   \textcolor{keywordflow}{if} (cs%nonlin\_solve\_err\_mode == 1) \textcolor{keywordflow}{then}
889     err\_init = 0 ; err\_tempu = 0 ; err\_tempv = 0
890     \textcolor{keywordflow}{do} j=g%IscB,g%JecB ; \textcolor{keywordflow}{do} i=g%IscB,g%IecB
891       \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) \textcolor{keywordflow}{then}
892         err\_tempu = abs(au(i,j) + u\_bdry\_cont(i,j) - taudx(i,j))
893         \textcolor{keywordflow}{if} (err\_tempu >= err\_init) err\_init = err\_tempu
894 \textcolor{keywordflow}{      endif}
895       \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) \textcolor{keywordflow}{then}
896         err\_tempv = abs(av(i,j) + v\_bdry\_cont(i,j) - taudy(i,j))
897         \textcolor{keywordflow}{if} (err\_tempv >= err\_init) err\_init = err\_tempv
898 \textcolor{keywordflow}{      endif}
899 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
900 
901     \textcolor{keyword}{call }max\_across\_pes(err\_init)
902 \textcolor{keywordflow}{  endif}
903 
904   u\_last(:,:) = u\_shlf(:,:) ; v\_last(:,:) = v\_shlf(:,:)
905 
906   \textcolor{comment}{!! begin loop}
907 
908   \textcolor{keywordflow}{do} iter=1,100
909 
910     \textcolor{keyword}{call }ice\_shelf\_solve\_inner(cs, iss, g, us, u\_shlf, v\_shlf, taudx, taudy, h\_node, float\_cond, &
911                                iss%hmask, conv\_flag, iters, time, phi, phisub)
912 
913     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
914       \textcolor{keyword}{call }qchksum(u\_shlf, \textcolor{stringliteral}{"u shelf"}, g%HI, haloshift=2, scale=us%L\_T\_to\_m\_s)
915       \textcolor{keyword}{call }qchksum(v\_shlf, \textcolor{stringliteral}{"v shelf"}, g%HI, haloshift=2, scale=us%L\_T\_to\_m\_s)
916 \textcolor{keywordflow}{    endif}
917 
918     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"ice\_shelf\_solve\_outer: linear solve done in "},iters,\textcolor{stringliteral}{" iterations"}
919     \textcolor{keyword}{call }mom\_mesg(mesg, 5)
920 
921     \textcolor{keyword}{call }calc\_shelf\_visc(cs, iss, g, us, u\_shlf, v\_shlf)
922     \textcolor{keyword}{call }pass\_var(cs%ice\_visc, g%domain)
923     \textcolor{keyword}{call }pass\_var(cs%basal\_traction, g%domain)
924 
925     \textcolor{comment}{! makes sure basal stress is only applied when it is supposed to be}
926     \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%isd,g%ied
927       cs%basal\_traction(i,j) = cs%basal\_traction(i,j) * cs%ground\_frac(i,j)
928 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
929 
930     u\_bdry\_cont(:,:) = 0 ; v\_bdry\_cont(:,:) = 0
931 
932     \textcolor{keyword}{call }apply\_boundary\_values(cs, iss, g, us, time, phisub, h\_node, cs%ice\_visc, &
933                                cs%basal\_traction, float\_cond, rhoi\_rhow, u\_bdry\_cont, v\_bdry\_cont)
934 
935     au(:,:) = 0 ; av(:,:) = 0
936 
937     \textcolor{keyword}{call }cg\_action(au, av, u\_shlf, v\_shlf, phi, phisub, cs%umask, cs%vmask, iss%hmask, h\_node, &
938                    cs%ice\_visc, float\_cond, g%bathyT, cs%basal\_traction, &
939                    g, us, g%isc-1, g%iec+1, g%jsc-1, g%jec+1, rhoi\_rhow)
940 
941     err\_max = 0
942 
943     \textcolor{keywordflow}{if} (cs%nonlin\_solve\_err\_mode == 1) \textcolor{keywordflow}{then}
944 
945       \textcolor{keywordflow}{do} j=g%jscB,g%jecB ; \textcolor{keywordflow}{do} i=g%jscB,g%iecB
946         \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) \textcolor{keywordflow}{then}
947           err\_tempu = abs(au(i,j) + u\_bdry\_cont(i,j) - taudx(i,j))
948           \textcolor{keywordflow}{if} (err\_tempu >= err\_max) err\_max = err\_tempu
949 \textcolor{keywordflow}{        endif}
950         \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) \textcolor{keywordflow}{then}
951           err\_tempv = abs(av(i,j) + v\_bdry\_cont(i,j) - taudy(i,j))
952           \textcolor{keywordflow}{if} (err\_tempv >= err\_max) err\_max = err\_tempv
953 \textcolor{keywordflow}{        endif}
954 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
955 
956       \textcolor{keyword}{call }max\_across\_pes(err\_max)
957 
958     \textcolor{keywordflow}{elseif} (cs%nonlin\_solve\_err\_mode == 2) \textcolor{keywordflow}{then}
959 
960       max\_vel = 0 ; tempu = 0 ; tempv = 0
961       \textcolor{keywordflow}{do} j=g%jscB,g%jecB ; \textcolor{keywordflow}{do} i=g%iscB,g%iecB
962         \textcolor{keywordflow}{if} (cs%umask(i,j) == 1) \textcolor{keywordflow}{then}
963           err\_tempu = abs(u\_last(i,j)-u\_shlf(i,j))
964           \textcolor{keywordflow}{if} (err\_tempu >= err\_max) err\_max = err\_tempu
965           tempu = u\_shlf(i,j)
966         \textcolor{keywordflow}{else}
967           tempu = 0.0
968 \textcolor{keywordflow}{        endif}
969         \textcolor{keywordflow}{if} (cs%vmask(i,j) == 1) \textcolor{keywordflow}{then}
970           err\_tempv = max(abs(v\_last(i,j)-v\_shlf(i,j)), err\_tempu)
971           \textcolor{keywordflow}{if} (err\_tempv >= err\_max) err\_max = err\_tempv
972           tempv = sqrt(v\_shlf(i,j)**2 + tempu**2)
973 \textcolor{keywordflow}{        endif}
974         \textcolor{keywordflow}{if} (tempv >= max\_vel) max\_vel = tempv
975 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
976 
977       u\_last(:,:) = u\_shlf(:,:)
978       v\_last(:,:) = v\_shlf(:,:)
979 
980       \textcolor{keyword}{call }max\_across\_pes(max\_vel)
981       \textcolor{keyword}{call }max\_across\_pes(err\_max)
982       err\_init = max\_vel
983 \textcolor{keywordflow}{    endif}
984 
985     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"ice\_shelf\_solve\_outer: nonlinear fractional residual = "}, err\_max/err\_init
986     \textcolor{keyword}{call }mom\_mesg(mesg, 5)
987 
988     \textcolor{keywordflow}{if} (err\_max <= cs%nonlinear\_tolerance * err\_init) \textcolor{keywordflow}{then}
989       \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"ice\_shelf\_solve\_outer: exiting nonlinear solve after "},iter,\textcolor{stringliteral}{" iterations"}
990       \textcolor{keyword}{call }mom\_mesg(mesg, 5)
991       \textcolor{keywordflow}{exit}
992 \textcolor{keywordflow}{    endif}
993 
994 \textcolor{keywordflow}{  enddo}
995 
996   \textcolor{keyword}{deallocate}(phi)
997   \textcolor{keyword}{deallocate}(phisub)
998 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_aed75a750ef5f5f2ca0d53b3a1d804073}\label{namespacemom__ice__shelf__dynamics_aed75a750ef5f5f2ca0d53b3a1d804073}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+shelf\+\_\+temp@{ice\+\_\+shelf\+\_\+temp}}
\index{ice\+\_\+shelf\+\_\+temp@{ice\+\_\+shelf\+\_\+temp}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+temp()}{ice\_shelf\_temp()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+temp (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{melt\+\_\+rate,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine updates the vertically averaged ice shelf temperature. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em melt\+\_\+rate} & basal melt rate \mbox{[}R Z T-\/1 $\sim$$>$ kg m-\/2 s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em time} & The current model time \\
\hline
\end{DoxyParams}


Definition at line 2976 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2976   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
2977   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{ !< A structure with elements that describe}
2978 \textcolor{comment}{                                               !! the ice-shelf state}
2979   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2980   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
2981   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}
2982   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2983                           \textcolor{keywordtype}{intent(in)}    :: melt\_rate\textcolor{comment}{ !< basal melt rate [R Z T-1 ~> kg m-2 s-1]}
2984   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
2985 
2986 \textcolor{comment}{! 5/23/12 OVS}
2987 \textcolor{comment}{!    This subroutine takes the velocity (on the Bgrid) and timesteps}
2988 \textcolor{comment}{!      (HT)\_t = - div (uHT) + (adot Tsurf -bdot Tbot) once and then calculates T=HT/H}
2989 \textcolor{comment}{!}
2990 \textcolor{comment}{!    The flux overflows are included here. That is because they will be used to advect 3D scalars}
2991 \textcolor{comment}{!    into partial cells}
2992 
2993   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}   :: th\_after\_uflux, th\_after\_vflux, th
2994   \textcolor{keywordtype}{integer}                           :: isd, ied, jsd, jed, i, j, isc, iec, jsc, jec
2995   \textcolor{keywordtype}{real} :: tsurf \textcolor{comment}{! Surface air temperature.  This is hard coded but should be an input argument.}
2996   \textcolor{keywordtype}{real} :: adot  \textcolor{comment}{! A surface heat exchange coefficient divided by the heat capacity of}
2997                 \textcolor{comment}{! ice [R Z T-1 degC-1 ~> kg m-2 s-1 degC-1].}
2998 
2999 
3000   \textcolor{comment}{! For now adot and Tsurf are defined here adot=surf acc 0.1m/yr, Tsurf=-20oC, vary them later}
3001   adot = (0.1/(365.0*86400.0))*us%m\_to\_Z*us%T\_to\_s * cs%density\_ice
3002   tsurf = -20.0
3003 
3004   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
3005   isc = g%isc ; iec = g%iec ; jsc = g%jsc ; jec = g%jec
3006 
3007   th\_after\_uflux(:,:) = 0.0
3008   th\_after\_vflux(:,:) = 0.0
3009 
3010   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
3011 \textcolor{comment}{!    if (ISS%hmask(i,j) > 1) then}
3012     \textcolor{keywordflow}{if} ((iss%hmask(i,j) == 3) .or. (iss%hmask(i,j) == -2)) \textcolor{keywordflow}{then}
3013       cs%t\_shelf(i,j) = cs%t\_bdry\_val(i,j)
3014 \textcolor{keywordflow}{    endif}
3015 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
3016 
3017   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
3018     \textcolor{comment}{! Convert the averge temperature to a depth integrated temperature.}
3019     th(i,j) = cs%t\_shelf(i,j)*iss%h\_shelf(i,j)
3020 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
3021 
3022 \textcolor{comment}{!  call enable\_averages(time\_step, Time, CS%diag)}
3023 \textcolor{comment}{!  call pass\_var(h\_after\_uflux, G%domain)}
3024 \textcolor{comment}{!  call pass\_var(h\_after\_vflux, G%domain)}
3025 \textcolor{comment}{!  if (CS%id\_h\_after\_uflux > 0) call post\_data(CS%id\_h\_after\_uflux, h\_after\_uflux, CS%diag)}
3026 \textcolor{comment}{!  if (CS%id\_h\_after\_vflux > 0) call post\_data(CS%id\_h\_after\_vflux, h\_after\_vflux, CS%diag)}
3027 \textcolor{comment}{!  call disable\_averaging(CS%diag)}
3028 
3029   \textcolor{keyword}{call }ice\_shelf\_advect\_temp\_x(cs, g, time\_step, iss%hmask, th, th\_after\_uflux)
3030   \textcolor{keyword}{call }ice\_shelf\_advect\_temp\_y(cs, g, time\_step, iss%hmask, th\_after\_uflux, th\_after\_vflux)
3031 
3032   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
3033     \textcolor{comment}{! Convert the integrated temperature back to the average temperature.}
3034 \textcolor{comment}{!   if ((ISS%hmask(i,j) == 1) .or. (ISS%hmask(i,j) == 2)) then}
3035     \textcolor{keywordflow}{if} (iss%h\_shelf(i,j) > 0.0) \textcolor{keywordflow}{then}
3036       cs%t\_shelf(i,j) = th\_after\_vflux(i,j) / iss%h\_shelf(i,j)
3037     \textcolor{keywordflow}{else}
3038       cs%t\_shelf(i,j) = -10.0
3039 \textcolor{keywordflow}{    endif}
3040 \textcolor{comment}{!   endif}
3041 
3042     \textcolor{keywordflow}{if} ((iss%hmask(i,j) == 1) .or. (iss%hmask(i,j) == 2)) \textcolor{keywordflow}{then}
3043       \textcolor{keywordflow}{if} (iss%h\_shelf(i,j) > 0.0) \textcolor{keywordflow}{then}
3044         cs%t\_shelf(i,j) = cs%t\_shelf(i,j) + &
3045             time\_step*(adot*tsurf - melt\_rate(i,j)*iss%tfreeze(i,j))/(cs%density\_ice*iss%h\_shelf(i,j))
3046       \textcolor{keywordflow}{else}
3047         \textcolor{comment}{! the ice is about to melt away in this case set thickness, area, and mask to zero}
3048         \textcolor{comment}{! NOTE: not mass conservative, should maybe scale salt & heat flux for this cell}
3049         cs%t\_shelf(i,j) = -10.0
3050         cs%tmask(i,j) = 0.0
3051 \textcolor{keywordflow}{      endif}
3052     \textcolor{keywordflow}{elseif} (iss%hmask(i,j) == 0) \textcolor{keywordflow}{then}
3053       cs%t\_shelf(i,j) = -10.0
3054     \textcolor{keywordflow}{elseif} ((iss%hmask(i,j) == 3) .or. (iss%hmask(i,j) == -2)) \textcolor{keywordflow}{then}
3055       cs%t\_shelf(i,j) = cs%t\_bdry\_val(i,j)
3056 \textcolor{keywordflow}{    endif}
3057 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
3058 
3059   \textcolor{keyword}{call }pass\_var(cs%t\_shelf, g%domain)
3060   \textcolor{keyword}{call }pass\_var(cs%tmask, g%domain)
3061 
3062   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
3063     \textcolor{keyword}{call }hchksum(cs%t\_shelf, \textcolor{stringliteral}{"temp after front"}, g%HI, haloshift=3)
3064 \textcolor{keywordflow}{  endif}
3065 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_af151ce3690653c467dd78e4ca552cac9}\label{namespacemom__ice__shelf__dynamics_af151ce3690653c467dd78e4ca552cac9}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!ice\+\_\+time\+\_\+step\+\_\+cfl@{ice\+\_\+time\+\_\+step\+\_\+cfl}}
\index{ice\+\_\+time\+\_\+step\+\_\+cfl@{ice\+\_\+time\+\_\+step\+\_\+cfl}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{ice\+\_\+time\+\_\+step\+\_\+cfl()}{ice\_time\_step\_cfl()}}
{\footnotesize\ttfamily real function, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+time\+\_\+step\+\_\+cfl (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(inout)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G }\end{DoxyParamCaption})}



This function returns the global maximum advective timestep that can be taken based on the current ice velocities. Because it involves finding a global minimum, it can be surprisingly expensive. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & The ice shelf dynamics control structure\\
\hline
\mbox{\tt in,out}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The maximum permitted timestep based on the ice velocities \mbox{[}T $\sim$$>$ s\mbox{]}. 
\end{DoxyReturn}


Definition at line 601 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
601   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{  !< The ice shelf dynamics control structure}
602   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< A structure with elements that describe}
603 \textcolor{comment}{                                               !! the ice-shelf state}
604   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{   !< The grid structure used by the ice shelf.}
605   \textcolor{keywordtype}{real} :: ice\_time\_step\_cfl\textcolor{comment}{ !< The maximum permitted timestep based on the ice velocities [T ~> s].}
606 
607   \textcolor{keywordtype}{real} :: dt\_local, min\_dt \textcolor{comment}{! These should be the minimum stable timesteps at a CFL of 1 [T ~> s]}
608   \textcolor{keywordtype}{real} :: min\_vel          \textcolor{comment}{! A minimal velocity for estimating a timestep [L T-1 ~> m s-1]}
609   \textcolor{keywordtype}{integer} :: i, j
610 
611   min\_dt = 5.0e17*g%US%s\_to\_T \textcolor{comment}{! The starting maximum is roughly the lifetime of the universe.}
612   min\_vel = (1.0e-12/(365.0*86400.0)) * g%US%m\_s\_to\_L\_T
613   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec ; \textcolor{keywordflow}{if} (iss%hmask(i,j) == 1.0) \textcolor{keywordflow}{then}
614     dt\_local = 2.0*g%areaT(i,j) / &
615        ((g%dyCu(i,j)  * max(abs(cs%u\_shelf(i,j)  + cs%u\_shelf(i,j-1)), min\_vel) + &
616          g%dyCu(i-1,j)* max(abs(cs%u\_shelf(i-1,j)+ cs%u\_shelf(i-1,j-1)), min\_vel)) + &
617         (g%dxCv(i,j)  * max(abs(cs%v\_shelf(i,j)  + cs%v\_shelf(i-1,j)), min\_vel) + &
618          g%dxCv(i,j-1)* max(abs(cs%v\_shelf(i,j-1)+ cs%v\_shelf(i-1,j-1)), min\_vel)))
619 
620     min\_dt = min(min\_dt, dt\_local)
621 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{! i- and j- loops}
622 
623   \textcolor{keyword}{call }min\_across\_pes(min\_dt)
624 
625   ice\_time\_step\_cfl = cs%CFL\_factor * min\_dt
626 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_aca798d728879d0f253dab89e4cd20b1e}\label{namespacemom__ice__shelf__dynamics_aca798d728879d0f253dab89e4cd20b1e}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!init\+\_\+boundary\+\_\+values@{init\+\_\+boundary\+\_\+values}}
\index{init\+\_\+boundary\+\_\+values@{init\+\_\+boundary\+\_\+values}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{init\+\_\+boundary\+\_\+values()}{init\_boundary\_values()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::init\+\_\+boundary\+\_\+values (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(time\+\_\+type), intent(in)}]{time,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{real, intent(in)}]{input\+\_\+flux,  }\item[{real, intent(in)}]{input\+\_\+thick,  }\item[{logical, intent(in), optional}]{new\+\_\+sim }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em time} & The current model time\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in}  & {\em input\+\_\+flux} & The integrated inward ice thickness flux per unit face length \mbox{[}Z L T-\/1 $\sim$$>$ m2 s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em input\+\_\+thick} & The ice thickness at boundaries \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em new\+\_\+sim} & If present and false, this run is being restarted \\
\hline
\end{DoxyParams}


Definition at line 1903 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1903   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs),\textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
1904   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1905   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
1906   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1907                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
1908 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
1909   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: input\_flux\textcolor{comment}{ !< The integrated inward ice thickness flux per}
1910 \textcolor{comment}{                                             !! unit face length [Z L T-1 ~> m2 s-1]}
1911   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: input\_thick\textcolor{comment}{ !< The ice thickness at boundaries [Z ~> m].}
1912   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: new\_sim\textcolor{comment}{ !< If present and false, this run is being restarted}
1913 
1914 \textcolor{comment}{! this will be a per-setup function. the boundary values of thickness and velocity}
1915 \textcolor{comment}{! (and possibly other variables) will be updated in this function}
1916 
1917 \textcolor{comment}{! FOR RESTARTING PURPOSES: if grid is not symmetric and the model is restarted, we will}
1918 \textcolor{comment}{!               need to update those velocity points not *technically* in any}
1919 \textcolor{comment}{!               computational domain -- if this function gets moves to another module,}
1920 \textcolor{comment}{!               DO NOT TAKE THE RESTARTING BIT WITH IT}
1921   \textcolor{keywordtype}{integer} :: i, j , isd, jsd, ied, jed
1922   \textcolor{keywordtype}{integer} :: gjec, gisc, gjsc, cnt, isc, jsc, iec, jec
1923   \textcolor{keywordtype}{integer} :: i\_off, j\_off
1924 
1925   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
1926   isd = g%isd ; jsd = g%jsd ; ied = g%ied ; jed = g%jed
1927   i\_off = g%idg\_offset ; j\_off = g%jdg\_offset
1928 
1929   \textcolor{comment}{! this loop results in some values being set twice but... eh.}
1930 
1931   \textcolor{keywordflow}{do} j=jsd,jed
1932     \textcolor{keywordflow}{do} i=isd,ied
1933 
1934       \textcolor{keywordflow}{if} (hmask(i,j) == 3) \textcolor{keywordflow}{then}
1935         cs%thickness\_bdry\_val(i,j) = input\_thick
1936 \textcolor{keywordflow}{      endif}
1937 
1938       \textcolor{keywordflow}{if} ((hmask(i,j) == 0) .or. (hmask(i,j) == 1) .or. (hmask(i,j) == 2)) \textcolor{keywordflow}{then}
1939         \textcolor{keywordflow}{if} ((i <= iec).and.(i >= isc)) \textcolor{keywordflow}{then}
1940           \textcolor{keywordflow}{if} (cs%u\_face\_mask(i-1,j) == 3) \textcolor{keywordflow}{then}
1941             cs%u\_bdry\_val(i-1,j-1) = (1 - ((g%geoLatBu(i-1,j-1) - 0.5*g%len\_lat)*2./g%len\_lat)**2) * &
1942                   1.5 * input\_flux / input\_thick
1943             cs%u\_bdry\_val(i-1,j) = (1 - ((g%geoLatBu(i-1,j) - 0.5*g%len\_lat)*2./g%len\_lat)**2) * &
1944                   1.5 * input\_flux / input\_thick
1945 \textcolor{keywordflow}{          endif}
1946 \textcolor{keywordflow}{        endif}
1947 \textcolor{keywordflow}{      endif}
1948 
1949       \textcolor{keywordflow}{if} (.not.(new\_sim)) \textcolor{keywordflow}{then}
1950         \textcolor{keywordflow}{if} (.not. g%symmetric) \textcolor{keywordflow}{then}
1951           \textcolor{keywordflow}{if} (((i+i\_off) == (g%domain%nihalo+1)).and.(cs%u\_face\_mask(i-1,j) == 3)) \textcolor{keywordflow}{then}
1952             cs%u\_shelf(i-1,j-1) = cs%u\_bdry\_val(i-1,j-1)
1953             cs%u\_shelf(i-1,j) = cs%u\_bdry\_val(i-1,j)
1954             cs%v\_shelf(i-1,j-1) = cs%v\_bdry\_val(i-1,j-1)
1955             cs%v\_shelf(i-1,j) = cs%v\_bdry\_val(i-1,j)
1956 \textcolor{keywordflow}{          endif}
1957           \textcolor{keywordflow}{if} (((j+j\_off) == (g%domain%njhalo+1)).and.(cs%v\_face\_mask(i,j-1) == 3)) \textcolor{keywordflow}{then}
1958             cs%u\_shelf(i-1,j-1) = cs%u\_bdry\_val(i-1,j-1)
1959             cs%u\_shelf(i,j-1) = cs%u\_bdry\_val(i,j-1)
1960             cs%v\_shelf(i-1,j-1) = cs%v\_bdry\_val(i-1,j-1)
1961             cs%v\_shelf(i,j-1) = cs%v\_bdry\_val(i,j-1)
1962 \textcolor{keywordflow}{          endif}
1963 \textcolor{keywordflow}{        endif}
1964 \textcolor{keywordflow}{      endif}
1965 \textcolor{keywordflow}{    enddo}
1966 \textcolor{keywordflow}{  enddo}
1967 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a65c987944c65ba5ab4c88ce809698a88}\label{namespacemom__ice__shelf__dynamics_a65c987944c65ba5ab4c88ce809698a88}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!initialize\+\_\+diagnostic\+\_\+fields@{initialize\+\_\+diagnostic\+\_\+fields}}
\index{initialize\+\_\+diagnostic\+\_\+fields@{initialize\+\_\+diagnostic\+\_\+fields}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{initialize\+\_\+diagnostic\+\_\+fields()}{initialize\_diagnostic\_fields()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::initialize\+\_\+diagnostic\+\_\+fields (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em time} & The current model time \\
\hline
\end{DoxyParams}


Definition at line 564 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
564   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{  !< A pointer to the ice shelf control structure}
565   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{ !< A structure with elements that describe}
566 \textcolor{comment}{                                               !! the ice-shelf state}
567   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{   !< The grid structure used by the ice shelf.}
568   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A structure containing unit conversion factors}
569   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
570 
571   \textcolor{keywordtype}{integer}         :: i, j, iters, isd, ied, jsd, jed
572   \textcolor{keywordtype}{real}            :: rhoi\_rhow
573   \textcolor{keywordtype}{real}            :: od  \textcolor{comment}{! Depth of open water below the ice shelf [Z ~> m]}
574   \textcolor{keywordtype}{type}(time\_type) :: dummy\_time
575 
576   rhoi\_rhow = cs%density\_ice / cs%density\_ocean\_avg
577   dummy\_time = set\_time(0,0)
578   isd=g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
579 
580   \textcolor{keywordflow}{do} j=jsd,jed
581     \textcolor{keywordflow}{do} i=isd,ied
582       od = g%bathyT(i,j) - rhoi\_rhow * iss%h\_shelf(i,j)
583       \textcolor{keywordflow}{if} (od >= 0) \textcolor{keywordflow}{then}
584     \textcolor{comment}{! ice thickness does not take up whole ocean column -> floating}
585         cs%OD\_av(i,j) = od
586         cs%ground\_frac(i,j) = 0.
587       \textcolor{keywordflow}{else}
588         cs%OD\_av(i,j) = 0.
589         cs%ground\_frac(i,j) = 1.
590 \textcolor{keywordflow}{      endif}
591 \textcolor{keywordflow}{    enddo}
592 \textcolor{keywordflow}{  enddo}
593 
594   \textcolor{keyword}{call }ice\_shelf\_solve\_outer(cs, iss, g, us, cs%u\_shelf, cs%v\_shelf, iters, dummy\_time)
595 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a214304391d90b046fd3756249be46afb}\label{namespacemom__ice__shelf__dynamics_a214304391d90b046fd3756249be46afb}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!initialize\+\_\+ice\+\_\+shelf\+\_\+dyn@{initialize\+\_\+ice\+\_\+shelf\+\_\+dyn}}
\index{initialize\+\_\+ice\+\_\+shelf\+\_\+dyn@{initialize\+\_\+ice\+\_\+shelf\+\_\+dyn}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{initialize\+\_\+ice\+\_\+shelf\+\_\+dyn()}{initialize\_ice\_shelf\_dyn()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::initialize\+\_\+ice\+\_\+shelf\+\_\+dyn (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(time\+\_\+type), intent(inout)}]{Time,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(in)}]{I\+SS,  }\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{logical, intent(in)}]{new\+\_\+sim,  }\item[{logical, intent(in), optional}]{solo\+\_\+ice\+\_\+sheet\+\_\+in }\end{DoxyParamCaption})}



Initializes shelf model data, parameters and diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt in,out}  & {\em time} & The clock that that will indicate the model time\\
\hline
\mbox{\tt in}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
 & {\em cs} & A pointer to the ice shelf dynamics control structure\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid type describing the ice shelf grid.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em diag} & A structure that is used to regulate the diagnostic output.\\
\hline
\mbox{\tt in}  & {\em new\+\_\+sim} & If true this is a new simulation, otherwise has been started from a restart file.\\
\hline
\mbox{\tt in}  & {\em solo\+\_\+ice\+\_\+sheet\+\_\+in} & If present, this indicates whether a solo ice-\/sheet driver. \\
\hline
\end{DoxyParams}


Definition at line 274 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
274   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
275   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer}       :: ocn\_grid\textcolor{comment}{   !< The calling ocean model's horizontal grid
       structure}
276   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(inout)} :: time\textcolor{comment}{ !< The clock that that will indicate the model time}
277   \textcolor{keywordtype}{type}(ice\_shelf\_state),   \textcolor{keywordtype}{intent(in)}    :: iss\textcolor{comment}{  !< A structure with elements that describe}
278 \textcolor{comment}{                                                 !! the ice-shelf state}
279   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs),  \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< A pointer to the ice shelf dynamics control structure}
280   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The grid type describing the ice shelf grid.}
281   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A structure containing unit conversion factors}
282   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: diag\textcolor{comment}{ !< A structure that is used to regulate the diagnostic
       output.}
283   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: new\_sim\textcolor{comment}{ !< If true this is a new simulation, otherwise}
284 \textcolor{comment}{                                                 !! has been started from a restart file.}
285   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: solo\_ice\_sheet\_in\textcolor{comment}{ !< If present, this indicates whether}
286 \textcolor{comment}{                                                 !! a solo ice-sheet driver.}
287 
288   \textcolor{comment}{! Local variables}
289   \textcolor{keywordtype}{real}    :: z\_rescale  \textcolor{comment}{! A rescaling factor for heights from the representation in}
290                         \textcolor{comment}{! a restart file to the internal representation in this run.}
291   \textcolor{keywordtype}{real}    :: vel\_rescale \textcolor{comment}{! A rescaling factor for horizontal velocities from the representation}
292                         \textcolor{comment}{! in a restart file to the internal representation in this run.}
293   \textcolor{comment}{!This include declares and sets the variable "version".}
294 \textcolor{preprocessor}{# include "version\_variable.h"}
295 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=200)} :: config
296   \textcolor{keywordtype}{character(len=200)} :: ic\_file,filename,inputdir
297   \textcolor{keywordtype}{character(len=40)}  :: var\_name
298   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn"}  \textcolor{comment}{! This module's name.}
299   \textcolor{keywordtype}{logical} :: shelf\_mass\_is\_dynamic, override\_shelf\_movement, active\_shelf\_dynamics
300   \textcolor{keywordtype}{logical} :: debug
301   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, isdq, iedq, jsdq, jedq, iters
302 
303   isdq = g%isdB ; iedq = g%iedB ; jsdq = g%jsdB ; jedq = g%jedB
304   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
305 
306   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
307     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn.F90, initialize\_ice\_shelf\_dyn: "}// &
308                           \textcolor{stringliteral}{"called with an associated control structure."})
309     \textcolor{keywordflow}{return}
310 \textcolor{keywordflow}{  endif}
311   \textcolor{keywordflow}{if} (cs%module\_is\_initialized) \textcolor{keywordflow}{then}
312     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn.F90, initialize\_ice\_shelf\_dyn was "}//&
313              \textcolor{stringliteral}{"called with a control structure that has already been initialized."})
314 \textcolor{keywordflow}{  endif}
315   cs%module\_is\_initialized = .true.
316 
317   cs%diag => diag \textcolor{comment}{! ; CS%Time => Time}
318 
319   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
320   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
321   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, debug, default=.false.)
322   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG\_IS"}, cs%debug, &
323                  \textcolor{stringliteral}{"If true, write verbose debugging messages for the ice shelf."}, &
324                  default=debug)
325   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DYNAMIC\_SHELF\_MASS"}, shelf\_mass\_is\_dynamic, &
326                  \textcolor{stringliteral}{"If true, the ice sheet mass can evolve with time."}, &
327                  default=.false.)
328   override\_shelf\_movement = .false. ; active\_shelf\_dynamics = .false.
329   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) \textcolor{keywordflow}{then}
330     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OVERRIDE\_SHELF\_MOVEMENT"}, override\_shelf\_movement, &
331                  \textcolor{stringliteral}{"If true, user provided code specifies the ice-shelf "}//&
332                  \textcolor{stringliteral}{"movement instead of the dynamic ice model."}, default=.false., do\_not\_log=.true.)
333     active\_shelf\_dynamics = .not.override\_shelf\_movement
334 
335     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERPOLATE"}, cs%GL\_regularize, &
336                  \textcolor{stringliteral}{"If true, regularize the floatation condition at the "}//&
337                  \textcolor{stringliteral}{"grounding line as in Goldberg Holland Schoof 2009."}, default=.false.)
338     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERP\_SUBGRID\_N"}, cs%n\_sub\_regularize, &
339                  \textcolor{stringliteral}{"The number of sub-partitions of each cell over which to "}//&
340                  \textcolor{stringliteral}{"integrate for the interpolated grounding line. Each cell "}//&
341                  \textcolor{stringliteral}{"is divided into NxN equally-sized rectangles, over which the "}//&
342                  \textcolor{stringliteral}{"basal contribution is integrated by iterative quadrature."}, &
343                  default=0)
344     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_COUPLE"}, cs%GL\_couple, &
345                  \textcolor{stringliteral}{"If true, let the floatation condition be determined by "}//&
346                  \textcolor{stringliteral}{"ocean column thickness. This means that update\_OD\_ffrac "}//&
347                  \textcolor{stringliteral}{"will be called.  GL\_REGULARIZE and GL\_COUPLE are exclusive."}, &
348                  default=.false., do\_not\_log=cs%GL\_regularize)
349     \textcolor{keywordflow}{if} (cs%GL\_regularize) cs%GL\_couple = .false.
350     \textcolor{keywordflow}{if} (cs%GL\_regularize .and. (cs%n\_sub\_regularize == 0)) \textcolor{keyword}{call }mom\_error (fatal, &
351       \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERP\_SUBGRID\_N must be a positive integer if GL regularization is used"})
352     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_CFL\_FACTOR"}, cs%CFL\_factor, &
353                  \textcolor{stringliteral}{"A factor used to limit timestep as CFL\_FACTOR * min (\(\backslash\)Delta x / u). "}//&
354                  \textcolor{stringliteral}{"This is only used with an ice-only model."}, default=0.25)
355 \textcolor{keywordflow}{  endif}
356   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs%density\_ocean\_avg, &
357                  \textcolor{stringliteral}{"avg ocean density used in floatation cond"}, &
358                  units=\textcolor{stringliteral}{"kg m-3"}, default=1035., scale=us%kg\_m3\_to\_R)
359   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}
360     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_VELOCITY\_TIMESTEP"}, cs%velocity\_update\_time\_step, &
361                  \textcolor{stringliteral}{"seconds between ice velocity calcs"}, units=\textcolor{stringliteral}{"s"}, scale=us%s\_to\_T, &
362                  fail\_if\_missing=.true.)
363     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs%g\_Earth, &
364                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, &
365                  units=\textcolor{stringliteral}{"m s-2"}, default = 9.80, scale=us%m\_s\_to\_L\_T**2*us%Z\_to\_m)
366 
367     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"A\_GLEN\_ISOTHERM"}, cs%A\_glen\_isothermal, &
368                  \textcolor{stringliteral}{"Ice viscosity parameter in Glen's Law"}, &
369                  units=\textcolor{stringliteral}{"Pa-3 yr-1"}, default=9.461e-18, scale=1.0/(365.0*86400.0))
370                  \textcolor{comment}{! This default is equivalent to 3.0001e-25 Pa-3 s-1, appropriate at about -10 C.}
371     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GLEN\_EXPONENT"}, cs%n\_glen, &
372                  \textcolor{stringliteral}{"nonlinearity exponent in Glen's Law"}, &
373                   units=\textcolor{stringliteral}{"none"}, default=3.)
374     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_STRAIN\_RATE\_GLEN"}, cs%eps\_glen\_min, &
375                  \textcolor{stringliteral}{"min. strain rate to avoid infinite Glen's law viscosity"}, &
376                  units=\textcolor{stringliteral}{"a-1"}, default=1.e-12, scale=us%T\_to\_s/(365.0*86400.0))
377     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BASAL\_FRICTION\_EXP"}, cs%n\_basal\_fric, &
378                  \textcolor{stringliteral}{"Exponent in sliding law \(\backslash\)tau\_b = C u^(n\_basal\_fric)"}, &
379                  units=\textcolor{stringliteral}{"none"}, fail\_if\_missing=.true.)
380     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BASAL\_FRICTION\_COEFF"}, cs%C\_basal\_friction, &
381                  \textcolor{stringliteral}{"Coefficient in sliding law \(\backslash\)tau\_b = C u^(n\_basal\_fric)"}, &
382                  units=\textcolor{stringliteral}{"Pa (m yr-1)-(n\_basal\_fric)"}, scale=us%kg\_m2s\_to\_RZ\_T*((365.0*86400.0)**cs
      %n\_basal\_fric), &
383                  fail\_if\_missing=.true.)
384     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSITY\_ICE"}, cs%density\_ice, &
385                  \textcolor{stringliteral}{"A typical density of ice."}, units=\textcolor{stringliteral}{"kg m-3"}, default=917.0, scale=us%kg\_m3\_to\_R)
386     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONJUGATE\_GRADIENT\_TOLERANCE"}, cs%cg\_tolerance, &
387                 \textcolor{stringliteral}{"tolerance in CG solver, relative to initial residual"}, default=1.e-6)
388     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_NONLINEAR\_TOLERANCE"}, cs%nonlinear\_tolerance, &
389                 \textcolor{stringliteral}{"nonlin tolerance in iterative velocity solve"},default=1.e-6)
390     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONJUGATE\_GRADIENT\_MAXIT"}, cs%cg\_max\_iterations, &
391                 \textcolor{stringliteral}{"max iteratiions in CG solver"}, default=2000)
392     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"THRESH\_FLOAT\_COL\_DEPTH"}, cs%thresh\_float\_col\_depth, &
393                 \textcolor{stringliteral}{"min ocean thickness to consider ice *floating*; "}//&
394                 \textcolor{stringliteral}{"will only be important with use of tides"}, &
395                 units=\textcolor{stringliteral}{"m"}, default=1.e-3, scale=us%m\_to\_Z)
396     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"NONLIN\_SOLVE\_ERR\_MODE"}, cs%nonlin\_solve\_err\_mode, &
397                 \textcolor{stringliteral}{"Choose whether nonlin error in vel solve is based on nonlinear "}//&
398                 \textcolor{stringliteral}{"residual (1) or relative change since last iteration (2)"}, default=1)
399 
400     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_MOVING\_FRONT"}, cs%moving\_shelf\_front, &
401                  \textcolor{stringliteral}{"Specify whether to advance shelf front (and calve)."}, &
402                  default=.true.)
403     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CALVE\_TO\_MASK"}, cs%calve\_to\_mask, &
404                  \textcolor{stringliteral}{"If true, do not allow an ice shelf where prohibited by a mask."}, &
405                  default=.false.)
406 \textcolor{keywordflow}{  endif}
407   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_THICKNESS\_SIMPLE\_CALVE"}, cs%min\_thickness\_simple\_calve, &
408                  \textcolor{stringliteral}{"Min thickness rule for the VERY simple calving law"},&
409                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us%m\_to\_Z)
410 
411   \textcolor{comment}{! Allocate memory in the ice shelf dynamics control structure that was not}
412   \textcolor{comment}{! previously allocated for registration for restarts.}
413   \textcolor{comment}{! OVS vertically integrated Temperature}
414 
415   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}
416     \textcolor{comment}{! DNG}
417     \textcolor{keyword}{allocate}( cs%u\_bdry\_val(isdq:iedq,jsdq:jedq) ) ; cs%u\_bdry\_val(:,:) = 0.0
418     \textcolor{keyword}{allocate}( cs%v\_bdry\_val(isdq:iedq,jsdq:jedq) ) ; cs%v\_bdry\_val(:,:) = 0.0
419     \textcolor{keyword}{allocate}( cs%t\_bdry\_val(isd:ied,jsd:jed) )   ; cs%t\_bdry\_val(:,:) = -15.0
420     \textcolor{keyword}{allocate}( cs%h\_bdry\_val(isd:ied,jsd:jed) ) ; cs%h\_bdry\_val(:,:) = 0.0
421     \textcolor{keyword}{allocate}( cs%thickness\_bdry\_val(isd:ied,jsd:jed) ) ; cs%thickness\_bdry\_val(:,:) = 0.0
422     \textcolor{keyword}{allocate}( cs%u\_face\_mask(isdq:iedq,jsd:jed) ) ; cs%u\_face\_mask(:,:) = 0.0
423     \textcolor{keyword}{allocate}( cs%v\_face\_mask(isd:ied,jsdq:jedq) ) ; cs%v\_face\_mask(:,:) = 0.0
424     \textcolor{keyword}{allocate}( cs%u\_face\_mask\_bdry(isdq:iedq,jsd:jed) ) ; cs%u\_face\_mask\_bdry(:,:) = -2.0
425     \textcolor{keyword}{allocate}( cs%v\_face\_mask\_bdry(isd:ied,jsdq:jedq) ) ; cs%v\_face\_mask\_bdry(:,:) = -2.0
426     \textcolor{keyword}{allocate}( cs%u\_flux\_bdry\_val(isdq:iedq,jsd:jed) ) ; cs%u\_flux\_bdry\_val(:,:) = 0.0
427     \textcolor{keyword}{allocate}( cs%v\_flux\_bdry\_val(isd:ied,jsdq:jedq) ) ; cs%v\_flux\_bdry\_val(:,:) = 0.0
428     \textcolor{keyword}{allocate}( cs%umask(isdq:iedq,jsdq:jedq) ) ; cs%umask(:,:) = -1.0
429     \textcolor{keyword}{allocate}( cs%vmask(isdq:iedq,jsdq:jedq) ) ; cs%vmask(:,:) = -1.0
430     \textcolor{keyword}{allocate}( cs%tmask(isdq:iedq,jsdq:jedq) ) ; cs%tmask(:,:) = -1.0
431 
432     cs%OD\_rt\_counter = 0
433     \textcolor{keyword}{allocate}( cs%OD\_rt(isd:ied,jsd:jed) ) ; cs%OD\_rt(:,:) = 0.0
434     \textcolor{keyword}{allocate}( cs%ground\_frac\_rt(isd:ied,jsd:jed) ) ; cs%ground\_frac\_rt(:,:) = 0.0
435 
436     \textcolor{keywordflow}{if} (cs%calve\_to\_mask) \textcolor{keywordflow}{then}
437       \textcolor{keyword}{allocate}( cs%calve\_mask(isd:ied,jsd:jed) ) ; cs%calve\_mask(:,:) = 0.0
438 \textcolor{keywordflow}{    endif}
439 
440     cs%elapsed\_velocity\_time = 0.0
441 
442     \textcolor{keyword}{call }update\_velocity\_masks(cs, g, iss%hmask, cs%umask, cs%vmask, cs%u\_face\_mask, cs%v\_face\_mask)
443 \textcolor{keywordflow}{  endif}
444 
445   \textcolor{comment}{! Take additional initialization steps, for example of dependent variables.}
446   \textcolor{keywordflow}{if} (active\_shelf\_dynamics .and. .not.new\_sim) \textcolor{keywordflow}{then}
447     \textcolor{keywordflow}{if} ((us%m\_to\_Z\_restart /= 0.0) .and. (us%m\_to\_Z\_restart /= us%m\_to\_Z)) \textcolor{keywordflow}{then}
448       z\_rescale = us%m\_to\_Z / us%m\_to\_Z\_restart
449       \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
450         cs%OD\_av(i,j) = z\_rescale * cs%OD\_av(i,j)
451 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
452 \textcolor{keywordflow}{    endif}
453 
454     \textcolor{keywordflow}{if} ((us%m\_to\_L\_restart*us%s\_to\_T\_restart /= 0.0) .and. &
455         (us%m\_to\_L\_restart /= us%m\_s\_to\_L\_T*us%s\_to\_T\_restart)) \textcolor{keywordflow}{then}
456       vel\_rescale = us%m\_s\_to\_L\_T*us%s\_to\_T\_restart / us%m\_to\_L\_restart
457       \textcolor{keywordflow}{do} j=g%jsc-1,g%jec ; \textcolor{keywordflow}{do} i=g%isc-1,g%iec
458         cs%u\_shelf(i,j) = vel\_rescale * cs%u\_shelf(i,j)
459         cs%v\_shelf(i,j) = vel\_rescale * cs%v\_shelf(i,j)
460 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
461 \textcolor{keywordflow}{    endif}
462 
463     \textcolor{comment}{! this is unfortunately necessary; if grid is not symmetric the boundary values}
464     \textcolor{comment}{!  of u and v are otherwise not set till the end of the first linear solve, and so}
465     \textcolor{comment}{!  viscosity is not calculated correctly.}
466     \textcolor{comment}{! This has to occur after init\_boundary\_values or some of the arrays on the}
467     \textcolor{comment}{! right hand side have not been set up yet.}
468     \textcolor{keywordflow}{if} (.not. g%symmetric) \textcolor{keywordflow}{then}
469       \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%isd,g%ied
470         \textcolor{keywordflow}{if} (((i+g%idg\_offset) == (g%domain%nihalo+1)).and.(cs%u\_face\_mask(i-1,j) == 3)) \textcolor{keywordflow}{then}
471           cs%u\_shelf(i-1,j-1) = cs%u\_bdry\_val(i-1,j-1)
472           cs%u\_shelf(i-1,j) = cs%u\_bdry\_val(i-1,j)
473           cs%v\_shelf(i-1,j-1) = cs%v\_bdry\_val(i-1,j-1)
474           cs%v\_shelf(i-1,j) = cs%v\_bdry\_val(i-1,j)
475 \textcolor{keywordflow}{        endif}
476         \textcolor{keywordflow}{if} (((j+g%jdg\_offset) == (g%domain%njhalo+1)).and.(cs%v\_face\_mask(i,j-1) == 3)) \textcolor{keywordflow}{then}
477           cs%u\_shelf(i-1,j-1) = cs%u\_bdry\_val(i-1,j-1)
478           cs%u\_shelf(i,j-1) = cs%u\_bdry\_val(i,j-1)
479           cs%v\_shelf(i-1,j-1) = cs%v\_bdry\_val(i-1,j-1)
480           cs%v\_shelf(i,j-1) = cs%v\_bdry\_val(i,j-1)
481 \textcolor{keywordflow}{        endif}
482 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
483 \textcolor{keywordflow}{    endif}
484 
485     \textcolor{keyword}{call }pass\_var(cs%OD\_av,g%domain)
486     \textcolor{keyword}{call }pass\_var(cs%ground\_frac,g%domain)
487     \textcolor{keyword}{call }pass\_var(cs%ice\_visc,g%domain)
488     \textcolor{keyword}{call }pass\_var(cs%basal\_traction, g%domain)
489     \textcolor{keyword}{call }pass\_vector(cs%u\_shelf, cs%v\_shelf, g%domain, to\_all, bgrid\_ne)
490 \textcolor{keywordflow}{  endif}
491 
492   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}
493     \textcolor{comment}{! If we are calving to a mask, i.e. if a mask exists where a shelf cannot, read the mask from a file.}
494     \textcolor{keywordflow}{if} (cs%calve\_to\_mask) \textcolor{keywordflow}{then}
495       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  MOM\_ice\_shelf.F90, initialize\_ice\_shelf: reading calving\_mask"})
496 
497       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
498       inputdir = slasher(inputdir)
499       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CALVING\_MASK\_FILE"}, ic\_file, &
500                    \textcolor{stringliteral}{"The file with a mask for where calving might occur."}, &
501                    default=\textcolor{stringliteral}{"ice\_shelf\_h.nc"})
502       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CALVING\_MASK\_VARNAME"}, var\_name, &
503                    \textcolor{stringliteral}{"The variable to use in masking calving."}, &
504                    default=\textcolor{stringliteral}{"area\_shelf\_h"})
505 
506       filename = trim(inputdir)//trim(ic\_file)
507       \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/CALVING\_MASK\_FILE"}, filename)
508       \textcolor{keywordflow}{if} (.not.file\_exists(filename, g%Domain)) \textcolor{keyword}{call }mom\_error(fatal, &
509          \textcolor{stringliteral}{" calving mask file: Unable to open "}//trim(filename))
510 
511       \textcolor{keyword}{call }mom\_read\_data(filename,trim(var\_name),cs%calve\_mask,g%Domain)
512       \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
513         \textcolor{keywordflow}{if} (cs%calve\_mask(i,j) > 0.0) cs%calve\_mask(i,j) = 1.0
514 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
515       \textcolor{keyword}{call }pass\_var(cs%calve\_mask,g%domain)
516 \textcolor{keywordflow}{    endif}
517 
518 \textcolor{comment}{!    call init\_boundary\_values(CS, G, time, ISS%hmask, CS%input\_flux, CS%input\_thickness, new\_sim)}
519 
520     \textcolor{keywordflow}{if} (new\_sim) \textcolor{keywordflow}{then}
521       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: initialize ice velocity."})
522       \textcolor{keyword}{call }update\_od\_ffrac\_uncoupled(cs, g, iss%h\_shelf(:,:))
523       \textcolor{keyword}{call }ice\_shelf\_solve\_outer(cs, iss, g, us, cs%u\_shelf, cs%v\_shelf, iters, time)
524 
525       \textcolor{keywordflow}{if} (cs%id\_u\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_shelf, cs%u\_shelf, cs%diag)
526       \textcolor{keywordflow}{if} (cs%id\_v\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_shelf, cs%v\_shelf,cs%diag)
527 \textcolor{keywordflow}{    endif}
528 
529   \textcolor{comment}{! Register diagnostics.}
530     cs%id\_u\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'u\_shelf'},cs%diag%axesCu1, time, &
531        \textcolor{stringliteral}{'x-velocity of ice'}, \textcolor{stringliteral}{'m yr-1'}, conversion=365.0*86400.0*us%L\_T\_to\_m\_s)
532     cs%id\_v\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'v\_shelf'},cs%diag%axesCv1, time, &
533        \textcolor{stringliteral}{'y-velocity of ice'}, \textcolor{stringliteral}{'m yr-1'}, conversion=365.0*86400.0*us%L\_T\_to\_m\_s)
534     cs%id\_u\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'u\_mask'},cs%diag%axesCu1, time, &
535        \textcolor{stringliteral}{'mask for u-nodes'}, \textcolor{stringliteral}{'none'})
536     cs%id\_v\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'v\_mask'},cs%diag%axesCv1, time, &
537        \textcolor{stringliteral}{'mask for v-nodes'}, \textcolor{stringliteral}{'none'})
538 \textcolor{comment}{!    CS%id\_surf\_elev = register\_diag\_field('ocean\_model','ice\_surf',CS%diag%axesT1, Time, &}
539 \textcolor{comment}{!       'ice surf elev', 'm')}
540     cs%id\_ground\_frac = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'ice\_ground\_frac'},cs%diag%axesT1, time, &
541        \textcolor{stringliteral}{'fraction of cell that is grounded'}, \textcolor{stringliteral}{'none'})
542     cs%id\_col\_thick = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'col\_thick'},cs%diag%axesT1, time, &
543        \textcolor{stringliteral}{'ocean column thickness passed to ice model'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
544     cs%id\_OD\_av = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'OD\_av'},cs%diag%axesT1, time, &
545        \textcolor{stringliteral}{'intermediate ocean column thickness passed to ice model'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
546     \textcolor{comment}{!CS%id\_h\_after\_uflux = register\_diag\_field('ocean\_model','h\_after\_uflux',CS%diag%axesh1, Time, &}
547     \textcolor{comment}{!   'thickness after u flux ', 'none')}
548     \textcolor{comment}{!CS%id\_h\_after\_vflux = register\_diag\_field('ocean\_model','h\_after\_vflux',CS%diag%axesh1, Time, &}
549     \textcolor{comment}{!   'thickness after v flux ', 'none')}
550     \textcolor{comment}{!CS%id\_h\_after\_adv = register\_diag\_field('ocean\_model','h\_after\_adv',CS%diag%axesh1, Time, &}
551     \textcolor{comment}{!   'thickness after front adv ', 'none')}
552 
553 \textcolor{comment}{!!! OVS vertically integrated temperature}
554     cs%id\_t\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'t\_shelf'},cs%diag%axesT1, time, &
555        \textcolor{stringliteral}{'T of ice'}, \textcolor{stringliteral}{'oC'})
556     cs%id\_t\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'tmask'},cs%diag%axesT1, time, &
557        \textcolor{stringliteral}{'mask for T-nodes'}, \textcolor{stringliteral}{'none'})
558 \textcolor{keywordflow}{  endif}
559 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a92ddf971169ef3b1e28c6dde0f3a66f2}\label{namespacemom__ice__shelf__dynamics_a92ddf971169ef3b1e28c6dde0f3a66f2}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!interpolate\+\_\+h\+\_\+to\+\_\+b@{interpolate\+\_\+h\+\_\+to\+\_\+b}}
\index{interpolate\+\_\+h\+\_\+to\+\_\+b@{interpolate\+\_\+h\+\_\+to\+\_\+b}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{interpolate\+\_\+h\+\_\+to\+\_\+b()}{interpolate\_h\_to\_b()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::interpolate\+\_\+h\+\_\+to\+\_\+b (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{h\+\_\+shelf,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{H\+\_\+node }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Interpolate the ice shelf thickness from tracer point to nodal points, subject to a mask. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em h\+\_\+shelf} & The ice shelf thickness at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+node} & The ice shelf thickness at nodal (corner) \\
\hline
\end{DoxyParams}


Definition at line 2911 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2911   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2912   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2913                          \textcolor{keywordtype}{intent(in)}    :: h\_shelf\textcolor{comment}{ !< The ice shelf thickness at tracer points [Z ~> m].}
2914   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2915                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
2916 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
2917   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2918                          \textcolor{keywordtype}{intent(inout)} :: h\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}
2919 \textcolor{comment}{                                             !! points [Z ~> m].}
2920 
2921   \textcolor{keywordtype}{integer} :: i, j, isc, iec, jsc, jec, num\_h, k, l
2922   \textcolor{keywordtype}{real}    :: summ
2923 
2924   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
2925 
2926   h\_node(:,:) = 0.0
2927 
2928   \textcolor{comment}{! H\_node is node-centered; average over all cells that share that node}
2929   \textcolor{comment}{! if no (active) cells share the node then its value there is irrelevant}
2930 
2931   \textcolor{keywordflow}{do} j=jsc-1,jec
2932     \textcolor{keywordflow}{do} i=isc-1,iec
2933       summ = 0.0
2934       num\_h = 0
2935       \textcolor{keywordflow}{do} k=0,1
2936         \textcolor{keywordflow}{do} l=0,1
2937           \textcolor{keywordflow}{if} (hmask(i+k,j+l) == 1.0) \textcolor{keywordflow}{then}
2938             summ = summ + h\_shelf(i+k,j+l)
2939             num\_h = num\_h + 1
2940 \textcolor{keywordflow}{          endif}
2941 \textcolor{keywordflow}{        enddo}
2942 \textcolor{keywordflow}{      enddo}
2943       \textcolor{keywordflow}{if} (num\_h > 0) \textcolor{keywordflow}{then}
2944         h\_node(i,j) = summ / num\_h
2945 \textcolor{keywordflow}{      endif}
2946 \textcolor{keywordflow}{    enddo}
2947 \textcolor{keywordflow}{  enddo}
2948 
2949   \textcolor{keyword}{call }pass\_var(h\_node, g%domain, position=corner)
2950 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a24ddff05700505a0ee7e011271b7ef8f}\label{namespacemom__ice__shelf__dynamics_a24ddff05700505a0ee7e011271b7ef8f}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!matrix\+\_\+diagonal@{matrix\+\_\+diagonal}}
\index{matrix\+\_\+diagonal@{matrix\+\_\+diagonal}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{matrix\+\_\+diagonal()}{matrix\_diagonal()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::matrix\+\_\+diagonal (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{float\+\_\+cond,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{H\+\_\+node,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{ice\+\_\+visc,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(in)}]{basal\+\_\+trac,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{real, intent(in)}]{dens\+\_\+ratio,  }\item[{real, dimension(\+:,\+:,\+:,\+:,\+:,\+:), intent(in)}]{Phisub,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{u\+\_\+diagonal,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{v\+\_\+diagonal }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



returns the diagonal entries of the matrix for a Jacobi preconditioning 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em float\+\_\+cond} & An array indicating where the ice\\
\hline
\mbox{\tt in}  & {\em h\+\_\+node} & The ice shelf thickness at nodal\\
\hline
\mbox{\tt in}  & {\em ice\+\_\+visc} & A field related to the ice viscosity from Glen\textquotesingle{}s\\
\hline
\mbox{\tt in}  & {\em basal\+\_\+trac} & A field related to the nonlinear part of the\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt in}  & {\em phisub} & Quadrature structure weights at subgridscale locations for finite element calculations \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em u\+\_\+diagonal} & The diagonal elements of the u-\/velocity\\
\hline
\mbox{\tt in,out}  & {\em v\+\_\+diagonal} & The diagonal elements of the v-\/velocity \\
\hline
\end{DoxyParams}


Definition at line 2165 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2165 
2166   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
2167   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2168   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
2169   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2170                           \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}
2171 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}
2172   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2173                           \textcolor{keywordtype}{intent(in)}    :: h\_node\textcolor{comment}{ !< The ice shelf thickness at nodal}
2174 \textcolor{comment}{                                                 !! (corner) points [Z ~> m].}
2175   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2176                           \textcolor{keywordtype}{intent(in)}    :: ice\_visc\textcolor{comment}{ !< A field related to the ice viscosity from Glen's}
2177 \textcolor{comment}{                                                !! flow law [R L4 Z T-1 ~> kg m2 s-1]. The exact form}
2178 \textcolor{comment}{                                                !!  and units depend on the basal law exponent.}
2179   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2180                           \textcolor{keywordtype}{intent(in)}    :: basal\_trac\textcolor{comment}{ !< A field related to the nonlinear part of the}
2181 \textcolor{comment}{                                                !! "linearized" basal stress [R Z T-1 ~> kg m-2 s-1].}
2182   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2183                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
2184 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
2185   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}
2186 \textcolor{comment}{                                                     !! of seawater [nondim]}
2187   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, \textcolor{keywordtype}{intent(in)} :: phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}
2188 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}
2189   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2190                           \textcolor{keywordtype}{intent(inout)} :: u\_diagonal\textcolor{comment}{ !< The diagonal elements of the u-velocity}
2191 \textcolor{comment}{                                            !! matrix from the left-hand side of the solver [R L2 Z T-1 ~>
       kg s-1]}
2192   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2193                           \textcolor{keywordtype}{intent(inout)} :: v\_diagonal\textcolor{comment}{  !< The diagonal elements of the v-velocity}
2194 \textcolor{comment}{                                            !! matrix from the left-hand side of the solver [R L2 Z T-1 ~>
       kg s-1]}
2195 
2196 
2197 \textcolor{comment}{! returns the diagonal entries of the matrix for a Jacobi preconditioning}
2198 
2199   \textcolor{keywordtype}{real} :: ux, uy, vx, vy \textcolor{comment}{! Interpolated weight gradients [L-1 ~> m-1]}
2200   \textcolor{keywordtype}{real} :: uq, vq
2201   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(8,4)} :: phi \textcolor{comment}{! Weight gradients [L-1 ~> m-1]}
2202   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2)}   :: xquad
2203   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(2,2)} :: hcell, sub\_ground
2204   \textcolor{keywordtype}{integer} :: i, j, is, js, cnt, isc, jsc, iec, jec, iphi, jphi, iq, jq, ilq, jlq, itgt, jtgt
2205 
2206   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
2207 
2208   xquad(1) = .5 * (1-sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))
2209 
2210   \textcolor{keywordflow}{do} j=jsc-1,jec+1 ; \textcolor{keywordflow}{do} i=isc-1,iec+1 ; \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}
2211 
2212     \textcolor{keyword}{call }bilinear\_shape\_fn\_grid(g, i, j, phi)
2213 
2214     \textcolor{comment}{! Phi(2*i-1,j) gives d(Phi\_i)/dx at quadrature point j}
2215     \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}
2216 
2217     \textcolor{keywordflow}{do} iq=1,2 ; \textcolor{keywordflow}{do} jq=1,2 ; \textcolor{keywordflow}{do} iphi=1,2 ; \textcolor{keywordflow}{do} jphi=1,2 ; itgt = i-2+iphi ; jtgt = j-2-jphi
2218       ilq = 1 ; \textcolor{keywordflow}{if} (iq == iphi) ilq = 2
2219       jlq = 1 ; \textcolor{keywordflow}{if} (jq == jphi) jlq = 2
2220 
2221       \textcolor{keywordflow}{if} (cs%umask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}
2222 
2223         ux = phi(2*(2*(jphi-1)+iphi)-1, 2*(jq-1)+iq)
2224         uy = phi(2*(2*(jphi-1)+iphi), 2*(jq-1)+iq)
2225         vx = 0.
2226         vy = 0.
2227 
2228         u\_diagonal(itgt,jtgt) = u\_diagonal(itgt,jtgt) + &
2229               0.25 * ice\_visc(i,j) * ((4*ux+2*vy) * phi(2*(2*(jphi-1)+iphi)-1,2*(jq-1)+iq) + &
2230                                       (uy+vy) * phi(2*(2*(jphi-1)+iphi),2*(jq-1)+iq))
2231 
2232         \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}
2233           uq = xquad(ilq) * xquad(jlq)
2234           u\_diagonal(itgt,jtgt) = u\_diagonal(itgt,jtgt) + &
2235               0.25 * basal\_trac(i,j) * uq * xquad(ilq) * xquad(jlq)
2236 \textcolor{keywordflow}{        endif}
2237 \textcolor{keywordflow}{      endif}
2238 
2239       \textcolor{keywordflow}{if} (cs%vmask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}
2240 
2241         vx = phi(2*(2*(jphi-1)+iphi)-1, 2*(jq-1)+iq)
2242         vy = phi(2*(2*(jphi-1)+iphi), 2*(jq-1)+iq)
2243         ux = 0.
2244         uy = 0.
2245 
2246         v\_diagonal(itgt,jtgt) = v\_diagonal(itgt,jtgt) + &
2247               0.25 * ice\_visc(i,j) * ((uy+vx) * phi(2*(2*(jphi-1)+iphi)-1,2*(jq-1)+iq) + &
2248                                   (4*vy+2*ux) * phi(2*(2*(jphi-1)+iphi),2*(jq-1)+iq))
2249 
2250         \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}
2251           vq = xquad(ilq) * xquad(jlq)
2252           v\_diagonal(itgt,jtgt) = v\_diagonal(itgt,jtgt) + &
2253                 0.25 * basal\_trac(i,j) * vq * xquad(ilq) * xquad(jlq)
2254 \textcolor{keywordflow}{        endif}
2255 \textcolor{keywordflow}{      endif}
2256 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
2257 
2258     \textcolor{keywordflow}{if} (float\_cond(i,j) == 1) \textcolor{keywordflow}{then}
2259       hcell(:,:) = h\_node(i-1:i,j-1:j)
2260       \textcolor{keyword}{call }cg\_diagonal\_subgrid\_basal(phisub, hcell, g%bathyT(i,j), dens\_ratio, sub\_ground)
2261       \textcolor{keywordflow}{do} iphi=1,2 ; \textcolor{keywordflow}{do} jphi=1,2 ; itgt = i-2+iphi ; jtgt = j-2-jphi
2262         \textcolor{keywordflow}{if} (cs%umask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}
2263           u\_diagonal(itgt,jtgt) = u\_diagonal(itgt,jtgt) + sub\_ground(iphi,jphi) * basal\_trac(i,j)
2264           v\_diagonal(itgt,jtgt) = v\_diagonal(itgt,jtgt) + sub\_ground(iphi,jphi) * basal\_trac(i,j)
2265 \textcolor{keywordflow}{        endif}
2266 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2267 \textcolor{keywordflow}{    endif}
2268 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
2269 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a44ac16282b7667409d32e7eb3e667822}\label{namespacemom__ice__shelf__dynamics_a44ac16282b7667409d32e7eb3e667822}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!quad\+\_\+area@{quad\+\_\+area}}
\index{quad\+\_\+area@{quad\+\_\+area}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{quad\+\_\+area()}{quad\_area()}}
{\footnotesize\ttfamily real function mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::quad\+\_\+area (\begin{DoxyParamCaption}\item[{real, dimension(4), intent(in)}]{X,  }\item[{real, dimension(4), intent(in)}]{Y }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calculate area of quadrilateral. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & The x-\/positions of the vertices of the quadrilateral \mbox{[}L $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em y} & The y-\/positions of the vertices of the quadrilateral \mbox{[}L $\sim$$>$ m\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 194 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
194   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(4)}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The x-positions of the vertices of the quadrilateral [L ~> m].}
195   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(4)}, \textcolor{keywordtype}{intent(in)} :: y\textcolor{comment}{ !< The y-positions of the vertices of the quadrilateral [L ~> m].}
196   \textcolor{keywordtype}{real} :: quad\_area \textcolor{comment}{! Computed area [L2 ~> m2]}
197   \textcolor{keywordtype}{real} :: p2, q2, a2, c2, b2, d2
198 
199 \textcolor{comment}{! X and Y must be passed in the form}
200     \textcolor{comment}{!  3 - 4}
201     \textcolor{comment}{!  |   |}
202     \textcolor{comment}{!  1 - 2}
203 
204   p2 = (x(4)-x(1))**2 + (y(4)-y(1))**2 ; q2 = (x(3)-x(2))**2 + (y(3)-y(2))**2
205   a2 = (x(3)-x(4))**2 + (y(3)-y(4))**2 ; c2 = (x(1)-x(2))**2 + (y(1)-y(2))**2
206   b2 = (x(2)-x(4))**2 + (y(2)-y(4))**2 ; d2 = (x(3)-x(1))**2 + (y(3)-y(1))**2
207   quad\_area = .25 * sqrt(4*p2*q2-(b2+d2-a2-c2)**2)
208 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a12331ec885577ea541129393928b838e}\label{namespacemom__ice__shelf__dynamics_a12331ec885577ea541129393928b838e}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!register\+\_\+ice\+\_\+shelf\+\_\+dyn\+\_\+restarts@{register\+\_\+ice\+\_\+shelf\+\_\+dyn\+\_\+restarts}}
\index{register\+\_\+ice\+\_\+shelf\+\_\+dyn\+\_\+restarts@{register\+\_\+ice\+\_\+shelf\+\_\+dyn\+\_\+restarts}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{register\+\_\+ice\+\_\+shelf\+\_\+dyn\+\_\+restarts()}{register\_ice\_shelf\_dyn\_restarts()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::register\+\_\+ice\+\_\+shelf\+\_\+dyn\+\_\+restarts (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), pointer}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



This subroutine is used to register any fields related to the ice shelf dynamics that should be written to or read from the restart file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The grid type describing the ice shelf grid.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
 & {\em cs} & A pointer to the ice shelf dynamics control structure\\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure. \\
\hline
\end{DoxyParams}


Definition at line 214 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
214   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The grid type describing the ice shelf grid.}
215   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
216   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{ !< A pointer to the ice shelf dynamics control structure}
217   \textcolor{keywordtype}{type}(mom\_restart\_cs),   \textcolor{keywordtype}{pointer}       :: restart\_cs\textcolor{comment}{ !< A pointer to the restart control structure.}
218 
219   \textcolor{keywordtype}{logical} :: shelf\_mass\_is\_dynamic, override\_shelf\_movement, active\_shelf\_dynamics
220   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn"}  \textcolor{comment}{! This module's name.}
221   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
222 
223   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
224   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
225 
226   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
227     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn.F90, register\_ice\_shelf\_dyn\_restarts: "}// &
228                           \textcolor{stringliteral}{"called with an associated control structure."})
229     \textcolor{keywordflow}{return}
230 \textcolor{keywordflow}{  endif}
231   \textcolor{keyword}{allocate}(cs)
232 
233   override\_shelf\_movement = .false. ; active\_shelf\_dynamics = .false.
234   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DYNAMIC\_SHELF\_MASS"}, shelf\_mass\_is\_dynamic, &
235                  \textcolor{stringliteral}{"If true, the ice sheet mass can evolve with time."}, &
236                  default=.false., do\_not\_log=.true.)
237   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) \textcolor{keywordflow}{then}
238     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OVERRIDE\_SHELF\_MOVEMENT"}, override\_shelf\_movement, &
239                  \textcolor{stringliteral}{"If true, user provided code specifies the ice-shelf "}//&
240                  \textcolor{stringliteral}{"movement instead of the dynamic ice model."}, default=.false., do\_not\_log=.true.)
241     active\_shelf\_dynamics = .not.override\_shelf\_movement
242 \textcolor{keywordflow}{  endif}
243 
244   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}
245     \textcolor{keyword}{allocate}( cs%u\_shelf(isdb:iedb,jsdb:jedb) ) ; cs%u\_shelf(:,:) = 0.0
246     \textcolor{keyword}{allocate}( cs%v\_shelf(isdb:iedb,jsdb:jedb) ) ; cs%v\_shelf(:,:) = 0.0
247     \textcolor{keyword}{allocate}( cs%t\_shelf(isd:ied,jsd:jed) )   ; cs%t\_shelf(:,:) = -10.0
248     \textcolor{keyword}{allocate}( cs%ice\_visc(isd:ied,jsd:jed) )    ; cs%ice\_visc(:,:) = 0.0
249     \textcolor{keyword}{allocate}( cs%basal\_traction(isd:ied,jsd:jed) ) ; cs%basal\_traction(:,:) = 0.0
250     \textcolor{keyword}{allocate}( cs%OD\_av(isd:ied,jsd:jed) )       ; cs%OD\_av(:,:) = 0.0
251     \textcolor{keyword}{allocate}( cs%ground\_frac(isd:ied,jsd:jed) )  ; cs%ground\_frac(:,:) = 0.0
252 
253     \textcolor{comment}{! additional restarts for ice shelf state}
254     \textcolor{keyword}{call }register\_restart\_field(cs%u\_shelf, \textcolor{stringliteral}{"u\_shelf"}, .false., restart\_cs, &
255                                 \textcolor{stringliteral}{"ice sheet/shelf u-velocity"}, \textcolor{stringliteral}{"m s-1"}, hor\_grid=\textcolor{stringliteral}{'Bu'})
256     \textcolor{keyword}{call }register\_restart\_field(cs%v\_shelf, \textcolor{stringliteral}{"v\_shelf"}, .false., restart\_cs, &
257                                 \textcolor{stringliteral}{"ice sheet/shelf v-velocity"}, \textcolor{stringliteral}{"m s-1"}, hor\_grid=\textcolor{stringliteral}{'Bu'})
258     \textcolor{keyword}{call }register\_restart\_field(cs%t\_shelf, \textcolor{stringliteral}{"t\_shelf"}, .true., restart\_cs, &
259                                 \textcolor{stringliteral}{"ice sheet/shelf vertically averaged temperature"}, \textcolor{stringliteral}{"deg C"})
260     \textcolor{keyword}{call }register\_restart\_field(cs%OD\_av, \textcolor{stringliteral}{"OD\_av"}, .true., restart\_cs, &
261                                 \textcolor{stringliteral}{"Average open ocean depth in a cell"},\textcolor{stringliteral}{"m"})
262     \textcolor{keyword}{call }register\_restart\_field(cs%ground\_frac, \textcolor{stringliteral}{"ground\_frac"}, .true., restart\_cs, &
263                                 \textcolor{stringliteral}{"fractional degree of grounding"}, \textcolor{stringliteral}{"nondim"})
264     \textcolor{keyword}{call }register\_restart\_field(cs%ice\_visc, \textcolor{stringliteral}{"viscosity"}, .true., restart\_cs, &
265                                 \textcolor{stringliteral}{"Volume integrated Glens law ice viscosity"}, \textcolor{stringliteral}{"kg m2 s-1"})
266     \textcolor{keyword}{call }register\_restart\_field(cs%basal\_traction, \textcolor{stringliteral}{"tau\_b\_beta"}, .true., restart\_cs, &
267                                 \textcolor{stringliteral}{"The area integrated basal traction coefficient"}, \textcolor{stringliteral}{"kg s-1"})
268 \textcolor{keywordflow}{  endif}
269 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a780c301ee73b99c7258b784efb8af172}\label{namespacemom__ice__shelf__dynamics_a780c301ee73b99c7258b784efb8af172}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!shelf\+\_\+advance\+\_\+front@{shelf\+\_\+advance\+\_\+front}}
\index{shelf\+\_\+advance\+\_\+front@{shelf\+\_\+advance\+\_\+front}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{shelf\+\_\+advance\+\_\+front()}{shelf\_advance\_front()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::shelf\+\_\+advance\+\_\+front (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(inout)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{hmask,  }\item[{real, dimension(szdib\+\_\+(g),szdj\+\_\+(g)), intent(inout)}]{uh\+\_\+ice,  }\item[{real, dimension(szdi\+\_\+(g),szdjb\+\_\+(g)), intent(inout)}]{vh\+\_\+ice }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in,out}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in,out}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt in,out}  & {\em uh\+\_\+ice} & The accumulated zonal ice volume flux \mbox{[}Z L2 $\sim$$>$ m3\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em vh\+\_\+ice} & The accumulated meridional ice volume flux \mbox{[}Z L2 $\sim$$>$ m3\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1463 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
1463   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
1464   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< A structure with elements that describe}
1465 \textcolor{comment}{                                           !! the ice-shelf state}
1466   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
1467   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
1468                           \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
1469 \textcolor{comment}{                                              !! partly or fully covered by an ice-shelf}
1470   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}, &
1471                           \textcolor{keywordtype}{intent(inout)} :: uh\_ice\textcolor{comment}{ !< The accumulated zonal ice volume flux [Z L2 ~> m3]}
1472   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}, &
1473                           \textcolor{keywordtype}{intent(inout)} :: vh\_ice\textcolor{comment}{ !< The accumulated meridional ice volume flux [Z L2 ~>
       m3]}
1474 
1475   \textcolor{comment}{! in this subroutine we go through the computational cells only and, if they are empty or partial cells,}
1476   \textcolor{comment}{! we find the reference thickness and update the shelf mass and partial area fraction and the hmask if
       necessary}
1477 
1478   \textcolor{comment}{! if any cells go from partial to complete, we then must set the thickness, update hmask accordingly,}
1479   \textcolor{comment}{! and divide the overflow across the adjacent EMPTY (not partly-covered) cells.}
1480   \textcolor{comment}{! (it is highly unlikely there will not be any; in which case this will need to be rethought.)}
1481 
1482   \textcolor{comment}{! most likely there will only be one "overflow". If not, though, a pass\_var of all relevant variables}
1483   \textcolor{comment}{! is done; there will therefore be a loop which, in practice, will hopefully not have to go through}
1484   \textcolor{comment}{! many iterations}
1485 
1486   \textcolor{comment}{! when 3d advected scalars are introduced, they will be impacted by what is done here}
1487 
1488   \textcolor{comment}{! flux\_enter(isd:ied,jsd:jed,1:4): if cell is not ice-covered, gives flux of ice into cell from kth
       boundary}
1489   \textcolor{comment}{!}
1490   \textcolor{comment}{!   from eastern neighbor:  flux\_enter(:,:,1)}
1491   \textcolor{comment}{!   from western neighbor:  flux\_enter(:,:,2)}
1492   \textcolor{comment}{!   from southern neighbor: flux\_enter(:,:,3)}
1493   \textcolor{comment}{!   from northern neighbor: flux\_enter(:,:,4)}
1494   \textcolor{comment}{!}
1495   \textcolor{comment}{!        o--- (4) ---o}
1496   \textcolor{comment}{!        |           |}
1497   \textcolor{comment}{!       (1)         (2)}
1498   \textcolor{comment}{!        |           |}
1499   \textcolor{comment}{!        o--- (3) ---o}
1500   \textcolor{comment}{!}
1501 
1502   \textcolor{keywordtype}{integer} :: i, j, isc, iec, jsc, jec, n\_flux, k, l, iter\_count
1503   \textcolor{keywordtype}{integer} :: i\_off, j\_off
1504   \textcolor{keywordtype}{integer} :: iter\_flag
1505 
1506   \textcolor{keywordtype}{real} :: h\_reference \textcolor{comment}{! A reference thicknesss based on neighboring cells [Z ~> m]}
1507   \textcolor{keywordtype}{real} :: tot\_flux    \textcolor{comment}{! The total ice mass flux [Z L2 ~> m3]}
1508   \textcolor{keywordtype}{real} :: partial\_vol \textcolor{comment}{! The volume covered by ice shelf [Z L2 ~> m3]}
1509   \textcolor{keywordtype}{real} :: dxdyh       \textcolor{comment}{! Cell area [L2 ~> m2]}
1510   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}
1511   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(4)} :: mapi, mapj, new\_partial
1512   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G),4)} :: flux\_enter  \textcolor{comment}{! The ice volume flux into the}
1513                                               \textcolor{comment}{! cell through the 4 cell boundaries [Z L2 ~> m3].}
1514   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G),4)} :: flux\_enter\_replace \textcolor{comment}{! An updated ice volume flux into the}
1515                                               \textcolor{comment}{! cell through the 4 cell boundaries [Z L2 ~> m3].}
1516 
1517   isc = g%isc ; iec = g%iec ; jsc = g%jsc ; jec = g%jec
1518   i\_off = g%idg\_offset ; j\_off = g%jdg\_offset
1519   iter\_count = 0 ; iter\_flag = 1
1520 
1521   flux\_enter(:,:,:) = 0.0
1522   \textcolor{keywordflow}{do} j=jsc-1,jec+1 ; \textcolor{keywordflow}{do} i=isc-1,iec+1
1523     \textcolor{keywordflow}{if} ((hmask(i,j) == 0) .or. (hmask(i,j) == 2)) \textcolor{keywordflow}{then}
1524       flux\_enter(i,j,1) = max(uh\_ice(i-1,j), 0.0)
1525       flux\_enter(i,j,2) = max(-uh\_ice(i,j), 0.0)
1526       flux\_enter(i,j,3) = max(vh\_ice(i,j-1), 0.0)
1527       flux\_enter(i,j,4) = max(-vh\_ice(i,j), 0.0)
1528 \textcolor{keywordflow}{    endif}
1529 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1530 
1531   mapi(1) = -1 ; mapi(2) = 1 ; mapi(3:4) = 0
1532   mapj(3) = -1 ; mapj(4) = 1 ; mapj(1:2) = 0
1533 
1534   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (iter\_flag == 1)
1535 
1536     iter\_flag = 0
1537 
1538     \textcolor{keywordflow}{if} (iter\_count > 0) \textcolor{keywordflow}{then}
1539       flux\_enter(:,:,:) = flux\_enter\_replace(:,:,:)
1540 \textcolor{keywordflow}{    endif}
1541     flux\_enter\_replace(:,:,:) = 0.0
1542 
1543     iter\_count = iter\_count + 1
1544 
1545     \textcolor{comment}{! if iter\_count >= 3 then some halo updates need to be done...}
1546 
1547     \textcolor{keywordflow}{do} j=jsc-1,jec+1
1548 
1549       \textcolor{keywordflow}{if} (((j+j\_off) <= g%domain%njglobal+g%domain%njhalo) .AND. &
1550          ((j+j\_off) >= g%domain%njhalo+1)) \textcolor{keywordflow}{then}
1551 
1552         \textcolor{keywordflow}{do} i=isc-1,iec+1
1553 
1554           \textcolor{keywordflow}{if} (((i+i\_off) <= g%domain%niglobal+g%domain%nihalo) .AND. &
1555               ((i+i\_off) >= g%domain%nihalo+1)) \textcolor{keywordflow}{then}
1556         \textcolor{comment}{! first get reference thickness by averaging over cells that are fluxing into this cell}
1557             n\_flux = 0
1558             h\_reference = 0.0
1559             tot\_flux = 0.0
1560 
1561             \textcolor{keywordflow}{do} k=1,2
1562               \textcolor{keywordflow}{if} (flux\_enter(i,j,k) > 0) \textcolor{keywordflow}{then}
1563                 n\_flux = n\_flux + 1
1564                 h\_reference = h\_reference + iss%h\_shelf(i+2*k-3,j)
1565                 tot\_flux = tot\_flux + flux\_enter(i,j,k)
1566                 flux\_enter(i,j,k) = 0.0
1567 \textcolor{keywordflow}{              endif}
1568 \textcolor{keywordflow}{            enddo}
1569 
1570             \textcolor{keywordflow}{do} k=1,2
1571               \textcolor{keywordflow}{if} (flux\_enter(i,j,k+2) > 0) \textcolor{keywordflow}{then}
1572                 n\_flux = n\_flux + 1
1573                 h\_reference = h\_reference + iss%h\_shelf(i,j+2*k-3)
1574                 tot\_flux = tot\_flux + flux\_enter(i,j,k+2)
1575                 flux\_enter(i,j,k+2) = 0.0
1576 \textcolor{keywordflow}{              endif}
1577 \textcolor{keywordflow}{            enddo}
1578 
1579             \textcolor{keywordflow}{if} (n\_flux > 0) \textcolor{keywordflow}{then}
1580               dxdyh = g%areaT(i,j)
1581               h\_reference = h\_reference / \textcolor{keywordtype}{real}(n\_flux)
1582               partial\_vol = iss%h\_shelf(i,j) * iss%area\_shelf\_h(i,j) + tot\_flux
1583 
1584               \textcolor{keywordflow}{if} ((partial\_vol / g%areaT(i,j)) == h\_reference) \textcolor{keywordflow}{then} \textcolor{comment}{! cell is exactly covered, no overflow}
1585                 iss%hmask(i,j) = 1
1586                 iss%h\_shelf(i,j) = h\_reference
1587                 iss%area\_shelf\_h(i,j) = g%areaT(i,j)
1588               \textcolor{keywordflow}{elseif} ((partial\_vol / g%areaT(i,j)) < h\_reference) \textcolor{keywordflow}{then}
1589                 iss%hmask(i,j) = 2
1590                \textcolor{comment}{!  ISS%mass\_shelf(i,j) = partial\_vol * CS%density\_ice}
1591                 iss%area\_shelf\_h(i,j) = partial\_vol / h\_reference
1592                 iss%h\_shelf(i,j) = h\_reference
1593               \textcolor{keywordflow}{else}
1594 
1595                 iss%hmask(i,j) = 1
1596                 iss%area\_shelf\_h(i,j) = g%areaT(i,j)
1597                 \textcolor{comment}{!h\_temp(i,j) = h\_reference}
1598                 partial\_vol = partial\_vol - h\_reference * g%areaT(i,j)
1599 
1600                 iter\_flag  = 1
1601 
1602                 n\_flux = 0 ; new\_partial(:) = 0
1603 
1604                 \textcolor{keywordflow}{do} k=1,2
1605                   \textcolor{keywordflow}{if} (cs%u\_face\_mask(i-2+k,j) == 2) \textcolor{keywordflow}{then}
1606                     n\_flux = n\_flux + 1
1607                   \textcolor{keywordflow}{elseif} (iss%hmask(i+2*k-3,j) == 0) \textcolor{keywordflow}{then}
1608                     n\_flux = n\_flux + 1
1609                     new\_partial(k) = 1
1610 \textcolor{keywordflow}{                  endif}
1611                   \textcolor{keywordflow}{if} (cs%v\_face\_mask(i,j-2+k) == 2) \textcolor{keywordflow}{then}
1612                     n\_flux = n\_flux + 1
1613                   \textcolor{keywordflow}{elseif} (iss%hmask(i,j+2*k-3) == 0) \textcolor{keywordflow}{then}
1614                     n\_flux = n\_flux + 1
1615                     new\_partial(k+2) = 1
1616 \textcolor{keywordflow}{                  endif}
1617 \textcolor{keywordflow}{                enddo}
1618 
1619                 \textcolor{keywordflow}{if} (n\_flux == 0) \textcolor{keywordflow}{then} \textcolor{comment}{! there is nowhere to put the extra ice!}
1620                   iss%h\_shelf(i,j) = h\_reference + partial\_vol / g%areaT(i,j)
1621                 \textcolor{keywordflow}{else}
1622                   iss%h\_shelf(i,j) = h\_reference
1623 
1624                   \textcolor{keywordflow}{do} k=1,2
1625                     \textcolor{keywordflow}{if} (new\_partial(k) == 1) &
1626                       flux\_enter\_replace(i+2*k-3,j,3-k) = partial\_vol / \textcolor{keywordtype}{real}(n\_flux)
1627                     \textcolor{keywordflow}{if} (new\_partial(k+2) == 1) &
1628                       flux\_enter\_replace(i,j+2*k-3,5-k) = partial\_vol / \textcolor{keywordtype}{real}(n\_flux)
1629 \textcolor{keywordflow}{                  enddo}
1630 \textcolor{keywordflow}{                endif}
1631 
1632 \textcolor{keywordflow}{              endif} \textcolor{comment}{! Parital\_vol test.}
1633 \textcolor{keywordflow}{            endif} \textcolor{comment}{! n\_flux gt 0 test.}
1634 
1635 \textcolor{keywordflow}{          endif}
1636 \textcolor{keywordflow}{        enddo} \textcolor{comment}{! j-loop}
1637 \textcolor{keywordflow}{      endif}
1638 \textcolor{keywordflow}{    enddo}
1639 
1640   \textcolor{comment}{!  call max\_across\_PEs(iter\_flag)}
1641 
1642 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! End of do while(iter\_flag) loop}
1643 
1644   \textcolor{keyword}{call }max\_across\_pes(iter\_count)
1645 
1646   \textcolor{keywordflow}{if} (is\_root\_pe() .and. (iter\_count > 1)) \textcolor{keywordflow}{then}
1647     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"shelf\_advance\_front: "}, iter\_count, \textcolor{stringliteral}{" max iterations"}
1648     \textcolor{keyword}{call }mom\_mesg(mesg, 5)
1649 \textcolor{keywordflow}{  endif}
1650 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a0e3d8eb91b7cbea4bb6b5063f5b1aada}\label{namespacemom__ice__shelf__dynamics_a0e3d8eb91b7cbea4bb6b5063f5b1aada}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!slope\+\_\+limiter@{slope\+\_\+limiter}}
\index{slope\+\_\+limiter@{slope\+\_\+limiter}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{slope\+\_\+limiter()}{slope\_limiter()}}
{\footnotesize\ttfamily real function mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::slope\+\_\+limiter (\begin{DoxyParamCaption}\item[{real, intent(in)}]{num,  }\item[{real, intent(in)}]{denom }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



used for flux limiting in advective subroutines Van Leer limiter (source\+: Wikipedia) The return value is between 0 and 2 \mbox{[}nondim\mbox{]}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em num} & The numerator of the ratio used in the Van Leer slope limiter\\
\hline
\mbox{\tt in}  & {\em denom} & The denominator of the ratio used in the Van Leer slope limiter \\
\hline
\end{DoxyParams}


Definition at line 176 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
176   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: num\textcolor{comment}{   !< The numerator of the ratio used in the Van Leer slope limiter}
177   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: denom\textcolor{comment}{ !< The denominator of the ratio used in the Van Leer slope limiter}
178   \textcolor{keywordtype}{real} :: slope\_limiter \textcolor{comment}{! The slope limiter value, between 0 and 2 [nondim].}
179   \textcolor{keywordtype}{real} :: r  \textcolor{comment}{! The ratio of num/denom [nondim]}
180 
181   \textcolor{keywordflow}{if} (denom == 0) \textcolor{keywordflow}{then}
182     slope\_limiter = 0
183   \textcolor{keywordflow}{elseif} (num*denom <= 0) \textcolor{keywordflow}{then}
184     slope\_limiter = 0
185   \textcolor{keywordflow}{else}
186     r = num/denom
187     slope\_limiter = (r+abs(r))/(1+abs(r))
188 \textcolor{keywordflow}{  endif}
189 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_adb908b77efa101749be0be069916139c}\label{namespacemom__ice__shelf__dynamics_adb908b77efa101749be0be069916139c}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!update\+\_\+ice\+\_\+shelf@{update\+\_\+ice\+\_\+shelf}}
\index{update\+\_\+ice\+\_\+shelf@{update\+\_\+ice\+\_\+shelf}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{update\+\_\+ice\+\_\+shelf()}{update\_ice\_shelf()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+ice\+\_\+shelf (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(inout)}]{I\+SS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in), optional}]{ocean\+\_\+mass,  }\item[{logical, intent(in), optional}]{coupled\+\_\+grounding,  }\item[{logical, intent(in), optional}]{must\+\_\+update\+\_\+vel }\end{DoxyParamCaption})}



This subroutine updates the ice shelf velocities, mass, stresses and properties due to the ice shelf dynamics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & The ice shelf dynamics control structure\\
\hline
\mbox{\tt in,out}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & time step \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em time} & The current model time\\
\hline
\mbox{\tt in}  & {\em ocean\+\_\+mass} & If present this is the mass per unit area\\
\hline
\mbox{\tt in}  & {\em coupled\+\_\+grounding} & If true, the grounding line is determined by coupled ice-\/ocean dynamics\\
\hline
\mbox{\tt in}  & {\em must\+\_\+update\+\_\+vel} & Always update the ice velocities if true. \\
\hline
\end{DoxyParams}


Definition at line 632 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
632   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< The ice shelf dynamics control structure}
633   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< A structure with elements that describe}
634 \textcolor{comment}{                                              !! the ice-shelf state}
635   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
636   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
637   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< time step [T ~> s]}
638   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
639   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
640                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: ocean\_mass\textcolor{comment}{ !< If present this is the mass per unit area}
641 \textcolor{comment}{                                              !! of the ocean [R Z ~> kg m-2].}
642   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: coupled\_grounding\textcolor{comment}{ !< If true, the grounding line is}
643 \textcolor{comment}{                                              !! determined by coupled ice-ocean dynamics}
644   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: must\_update\_vel\textcolor{comment}{ !< Always update the ice velocities if true.}
645 
646   \textcolor{keywordtype}{integer} :: iters
647   \textcolor{keywordtype}{logical} :: update\_ice\_vel, coupled\_gl
648 
649   update\_ice\_vel = .false.
650   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(must\_update\_vel)) update\_ice\_vel = must\_update\_vel
651 
652   coupled\_gl = .false.
653   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ocean\_mass) .and. \textcolor{keyword}{present}(coupled\_grounding)) coupled\_gl = coupled\_grounding
654 
655   \textcolor{keyword}{call }ice\_shelf\_advect(cs, iss, g, time\_step, time)
656   cs%elapsed\_velocity\_time = cs%elapsed\_velocity\_time + time\_step
657   \textcolor{keywordflow}{if} (cs%elapsed\_velocity\_time >= cs%velocity\_update\_time\_step) update\_ice\_vel = .true.
658 
659   \textcolor{keywordflow}{if} (coupled\_gl) \textcolor{keywordflow}{then}
660     \textcolor{keyword}{call }update\_od\_ffrac(cs, g, us, ocean\_mass, update\_ice\_vel)
661   \textcolor{keywordflow}{elseif} (update\_ice\_vel) \textcolor{keywordflow}{then}
662     \textcolor{keyword}{call }update\_od\_ffrac\_uncoupled(cs, g, iss%h\_shelf(:,:))
663 \textcolor{keywordflow}{  endif}
664 
665   \textcolor{keywordflow}{if} (update\_ice\_vel) \textcolor{keywordflow}{then}
666     \textcolor{keyword}{call }ice\_shelf\_solve\_outer(cs, iss, g, us, cs%u\_shelf, cs%v\_shelf, iters, time)
667 \textcolor{keywordflow}{  endif}
668 
669   \textcolor{keyword}{call }ice\_shelf\_temp(cs, iss, g, us, time\_step, iss%water\_flux, time)
670 
671   \textcolor{keywordflow}{if} (update\_ice\_vel) \textcolor{keywordflow}{then}
672     \textcolor{keyword}{call }enable\_averages(cs%elapsed\_velocity\_time, time, cs%diag)
673     \textcolor{keywordflow}{if} (cs%id\_col\_thick > 0) \textcolor{keyword}{call }post\_data(cs%id\_col\_thick, cs%OD\_av, cs%diag)
674     \textcolor{keywordflow}{if} (cs%id\_u\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_shelf, cs%u\_shelf, cs%diag)
675     \textcolor{keywordflow}{if} (cs%id\_v\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_shelf, cs%v\_shelf, cs%diag)
676     \textcolor{keywordflow}{if} (cs%id\_t\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_t\_shelf,cs%t\_shelf,cs%diag)
677     \textcolor{keywordflow}{if} (cs%id\_ground\_frac > 0) \textcolor{keyword}{call }post\_data(cs%id\_ground\_frac, cs%ground\_frac,cs%diag)
678     \textcolor{keywordflow}{if} (cs%id\_OD\_av >0) \textcolor{keyword}{call }post\_data(cs%id\_OD\_av, cs%OD\_av,cs%diag)
679 
680     \textcolor{keywordflow}{if} (cs%id\_u\_mask > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_mask,cs%umask,cs%diag)
681     \textcolor{keywordflow}{if} (cs%id\_v\_mask > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_mask,cs%vmask,cs%diag)
682     \textcolor{keywordflow}{if} (cs%id\_t\_mask > 0) \textcolor{keyword}{call }post\_data(cs%id\_t\_mask,cs%tmask,cs%diag)
683 
684     \textcolor{keyword}{call }disable\_averaging(cs%diag)
685 
686     cs%elapsed\_velocity\_time = 0.0
687 \textcolor{keywordflow}{  endif}
688 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_af4d6d4d402d1660aa068ab12d3a7d745}\label{namespacemom__ice__shelf__dynamics_af4d6d4d402d1660aa068ab12d3a7d745}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!update\+\_\+od\+\_\+ffrac@{update\+\_\+od\+\_\+ffrac}}
\index{update\+\_\+od\+\_\+ffrac@{update\+\_\+od\+\_\+ffrac}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{update\+\_\+od\+\_\+ffrac()}{update\_od\_ffrac()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+od\+\_\+ffrac (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{ocean\+\_\+mass,  }\item[{logical, intent(in)}]{find\+\_\+avg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\tt in}  & {\em ocean\+\_\+mass} & The mass per unit area of the ocean \mbox{[}kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em find\+\_\+avg} & If true, find the average of OD and ffrac, and reset the underlying running sums to 0. \\
\hline
\end{DoxyParams}


Definition at line 2511 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2511   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
2512   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2513   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}     :: us\textcolor{comment}{ !< A structure containing unit conversion factors}
2514   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2515                           \textcolor{keywordtype}{intent(in)}    :: ocean\_mass\textcolor{comment}{ !< The mass per unit area of the ocean [kg m-2].}
2516   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)}    :: find\_avg\textcolor{comment}{ !< If true, find the average of OD and ffrac, and}
2517 \textcolor{comment}{                                              !! reset the underlying running sums to 0.}
2518 
2519   \textcolor{keywordtype}{integer} :: isc, iec, jsc, jec, i, j
2520   \textcolor{keywordtype}{real}    :: i\_rho\_ocean \textcolor{comment}{! A typical specific volume of the ocean [R-1 ~> m3 kg-1]}
2521   \textcolor{keywordtype}{real}    :: i\_counter
2522 
2523   i\_rho\_ocean = 1.0 / cs%density\_ocean\_avg
2524 
2525   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
2526 
2527   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
2528     cs%OD\_rt(i,j) = cs%OD\_rt(i,j) + ocean\_mass(i,j)*i\_rho\_ocean
2529     \textcolor{keywordflow}{if} (ocean\_mass(i,j)*i\_rho\_ocean > cs%thresh\_float\_col\_depth) \textcolor{keywordflow}{then}
2530       cs%ground\_frac\_rt(i,j) = cs%ground\_frac\_rt(i,j) + 1.0
2531 \textcolor{keywordflow}{    endif}
2532 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
2533   cs%OD\_rt\_counter = cs%OD\_rt\_counter + 1
2534 
2535   \textcolor{keywordflow}{if} (find\_avg) \textcolor{keywordflow}{then}
2536     i\_counter = 1.0 / \textcolor{keywordtype}{real}(cs%od\_rt\_counter)
2537     \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
2538       cs%ground\_frac(i,j) = 1.0 - (cs%ground\_frac\_rt(i,j) * i\_counter)
2539       cs%OD\_av(i,j) = cs%OD\_rt(i,j) * i\_counter
2540 
2541       cs%OD\_rt(i,j) = 0.0 ; cs%ground\_frac\_rt(i,j) = 0.0
2542 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2543 
2544     \textcolor{keyword}{call }pass\_var(cs%ground\_frac, g%domain)
2545     \textcolor{keyword}{call }pass\_var(cs%OD\_av, g%domain)
2546 \textcolor{keywordflow}{  endif}
2547 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a4f860e8b97ca0400263678b1470c3e20}\label{namespacemom__ice__shelf__dynamics_a4f860e8b97ca0400263678b1470c3e20}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!update\+\_\+od\+\_\+ffrac\+\_\+uncoupled@{update\+\_\+od\+\_\+ffrac\+\_\+uncoupled}}
\index{update\+\_\+od\+\_\+ffrac\+\_\+uncoupled@{update\+\_\+od\+\_\+ffrac\+\_\+uncoupled}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{update\+\_\+od\+\_\+ffrac\+\_\+uncoupled()}{update\_od\_ffrac\_uncoupled()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+od\+\_\+ffrac\+\_\+uncoupled (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(inout)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{h\+\_\+shelf }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\tt in}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em h\+\_\+shelf} & the thickness of the ice shelf \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 2551 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2551   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
2552   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2553   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2554                           \textcolor{keywordtype}{intent(in)}    :: h\_shelf\textcolor{comment}{ !< the thickness of the ice shelf [Z ~> m].}
2555 
2556   \textcolor{keywordtype}{integer} :: i, j, iters, isd, ied, jsd, jed
2557   \textcolor{keywordtype}{real}    :: rhoi\_rhow, od
2558 
2559   rhoi\_rhow = cs%density\_ice / cs%density\_ocean\_avg
2560   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
2561 
2562   \textcolor{keywordflow}{do} j=jsd,jed
2563     \textcolor{keywordflow}{do} i=isd,ied
2564       od = g%bathyT(i,j) - rhoi\_rhow * h\_shelf(i,j)
2565       \textcolor{keywordflow}{if} (od >= 0) \textcolor{keywordflow}{then}
2566     \textcolor{comment}{! ice thickness does not take up whole ocean column -> floating}
2567         cs%OD\_av(i,j) = od
2568         cs%ground\_frac(i,j) = 0.
2569       \textcolor{keywordflow}{else}
2570         cs%OD\_av(i,j) = 0.
2571         cs%ground\_frac(i,j) = 1.
2572 \textcolor{keywordflow}{      endif}
2573 \textcolor{keywordflow}{    enddo}
2574 \textcolor{keywordflow}{  enddo}
2575 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf__dynamics_a4f87da4ad4dafef238d6f55a4c0d9d8d}\label{namespacemom__ice__shelf__dynamics_a4f87da4ad4dafef238d6f55a4c0d9d8d}} 
\index{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}!update\+\_\+velocity\+\_\+masks@{update\+\_\+velocity\+\_\+masks}}
\index{update\+\_\+velocity\+\_\+masks@{update\+\_\+velocity\+\_\+masks}!mom\+\_\+ice\+\_\+shelf\+\_\+dynamics@{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics}}
\subsubsection{\texorpdfstring{update\+\_\+velocity\+\_\+masks()}{update\_velocity\_masks()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+velocity\+\_\+masks (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__ice__shelf__dynamics_1_1ice__shelf__dyn__cs}{ice\+\_\+shelf\+\_\+dyn\+\_\+cs}), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{real, dimension(szdi\+\_\+(g),szdj\+\_\+(g)), intent(in)}]{hmask,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(out)}]{umask,  }\item[{real, dimension(szdib\+\_\+(g),szdjb\+\_\+(g)), intent(out)}]{vmask,  }\item[{real, dimension(szdib\+\_\+(g),szdj\+\_\+(g)), intent(out)}]{u\+\_\+face\+\_\+mask,  }\item[{real, dimension(szdi\+\_\+(g),szdjb\+\_\+(g)), intent(out)}]{v\+\_\+face\+\_\+mask }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & A pointer to the ice shelf dynamics control structure\\
\hline
\mbox{\tt in,out}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\tt in}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\tt out}  & {\em umask} & A coded mask indicating the nature of the\\
\hline
\mbox{\tt out}  & {\em vmask} & A coded mask indicating the nature of the\\
\hline
\mbox{\tt out}  & {\em u\+\_\+face\+\_\+mask} & A coded mask for velocities at the C-\/grid u-\/face\\
\hline
\mbox{\tt out}  & {\em v\+\_\+face\+\_\+mask} & A coded mask for velocities at the C-\/grid v-\/face \\
\hline
\end{DoxyParams}


Definition at line 2755 of file M\+O\+M\+\_\+ice\+\_\+shelf\+\_\+dynamics.\+F90.


\begin{DoxyCode}
2755   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_cs),\textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf dynamics control structure}
2756   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The grid structure used by the ice shelf.}
2757   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, &
2758                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}
2759 \textcolor{comment}{                                             !! partly or fully covered by an ice-shelf}
2760   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2761                          \textcolor{keywordtype}{intent(out)}   :: umask\textcolor{comment}{ !< A coded mask indicating the nature of the}
2762 \textcolor{comment}{                                             !! zonal flow at the corner point}
2763   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, &
2764                          \textcolor{keywordtype}{intent(out)}   :: vmask\textcolor{comment}{ !< A coded mask indicating the nature of the}
2765 \textcolor{comment}{                                             !! meridional flow at the corner point}
2766   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}, &
2767                          \textcolor{keywordtype}{intent(out)}   :: u\_face\_mask\textcolor{comment}{ !< A coded mask for velocities at the C-grid u-face}
2768   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}, &
2769                          \textcolor{keywordtype}{intent(out)}   :: v\_face\_mask\textcolor{comment}{ !< A coded mask for velocities at the C-grid v-face}
2770   \textcolor{comment}{! sets masks for velocity solve}
2771   \textcolor{comment}{! ignores the fact that their might be ice-free cells - this only considers the computational boundary}
2772 
2773   \textcolor{comment}{! !!!IMPORTANT!!! relies on thickness mask - assumed that this is called after hmask has been updated &
       halo-updated}
2774 
2775   \textcolor{keywordtype}{integer} :: i, j, k, iscq, iecq, jscq, jecq, isd, jsd, is, js, iegq, jegq
2776   \textcolor{keywordtype}{integer} :: giec, gjec, gisc, gjsc, isc, jsc, iec, jec
2777   \textcolor{keywordtype}{integer} :: i\_off, j\_off
2778 
2779   isc = g%isc ; jsc = g%jsc ; iec = g%iec ; jec = g%jec
2780   iscq = g%iscB ; iecq = g%iecB ; jscq = g%jscB ; jecq = g%jecB
2781   i\_off = g%idg\_offset ; j\_off = g%jdg\_offset
2782   isd = g%isd ; jsd = g%jsd
2783   iegq = g%iegB ; jegq = g%jegB
2784   gisc = g%Domain%nihalo ; gjsc = g%Domain%njhalo
2785   giec = g%Domain%niglobal+gisc ; gjec = g%Domain%njglobal+gjsc
2786 
2787   umask(:,:) = 0 ; vmask(:,:) = 0
2788   u\_face\_mask(:,:) = 0 ; v\_face\_mask(:,:) = 0
2789 
2790   \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
2791    is = isd ; js = jsd
2792   \textcolor{keywordflow}{else}
2793    is = isd+1 ; js = jsd+1
2794 \textcolor{keywordflow}{  endif}
2795 
2796   \textcolor{keywordflow}{do} j=js,g%jed
2797     \textcolor{keywordflow}{do} i=is,g%ied
2798 
2799       \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}
2800 
2801         umask(i-1:i,j-1:j) = 1.
2802         vmask(i-1:i,j-1:j) = 1.
2803 
2804         \textcolor{keywordflow}{do} k=0,1
2805 
2806           \textcolor{keywordflow}{select case} (int(cs%u\_face\_mask\_bdry(i-1+k,j)))
2807             \textcolor{keywordflow}{case} (3)
2808               umask(i-1+k,j-1:j)=3.
2809               vmask(i-1+k,j-1:j)=0.
2810               u\_face\_mask(i-1+k,j)=3.
2811             \textcolor{keywordflow}{case} (2)
2812               u\_face\_mask(i-1+k,j)=2.
2813             \textcolor{keywordflow}{case} (4)
2814               umask(i-1+k,j-1:j)=0.
2815               vmask(i-1+k,j-1:j)=0.
2816               u\_face\_mask(i-1+k,j)=4.
2817             \textcolor{keywordflow}{case} (0)
2818               umask(i-1+k,j-1:j)=0.
2819               vmask(i-1+k,j-1:j)=0.
2820               u\_face\_mask(i-1+k,j)=0.
2821             \textcolor{keywordflow}{case} (1)  \textcolor{comment}{! stress free x-boundary}
2822               umask(i-1+k,j-1:j)=0.
2823 \textcolor{keywordflow}{            case default}
2824 \textcolor{keywordflow}{          end select}
2825 \textcolor{keywordflow}{        enddo}
2826 
2827         \textcolor{keywordflow}{do} k=0,1
2828 
2829           \textcolor{keywordflow}{select case} (int(cs%v\_face\_mask\_bdry(i,j-1+k)))
2830             \textcolor{keywordflow}{case} (3)
2831               vmask(i-1:i,j-1+k)=3.
2832               umask(i-1:i,j-1+k)=0.
2833               v\_face\_mask(i,j-1+k)=3.
2834             \textcolor{keywordflow}{case} (2)
2835               v\_face\_mask(i,j-1+k)=2.
2836             \textcolor{keywordflow}{case} (4)
2837               umask(i-1:i,j-1+k)=0.
2838               vmask(i-1:i,j-1+k)=0.
2839               v\_face\_mask(i,j-1+k)=4.
2840             \textcolor{keywordflow}{case} (0)
2841               umask(i-1:i,j-1+k)=0.
2842               vmask(i-1:i,j-1+k)=0.
2843               v\_face\_mask(i,j-1+k)=0.
2844             \textcolor{keywordflow}{case} (1) \textcolor{comment}{! stress free y-boundary}
2845               vmask(i-1:i,j-1+k)=0.
2846 \textcolor{keywordflow}{            case default}
2847 \textcolor{keywordflow}{          end select}
2848 \textcolor{keywordflow}{        enddo}
2849 
2850         \textcolor{comment}{!if (CS%u\_face\_mask\_bdry(I-1,j) >= 0) then ! Western boundary}
2851         \textcolor{comment}{!  u\_face\_mask(I-1,j) = CS%u\_face\_mask\_bdry(I-1,j)}
2852         \textcolor{comment}{!  umask(I-1,J-1:J) = 3.}
2853         \textcolor{comment}{!  vmask(I-1,J-1:J) = 0.}
2854         \textcolor{comment}{!endif}
2855 
2856         \textcolor{comment}{!if (j\_off+j == gjsc+1) then ! SoutherN boundary}
2857         \textcolor{comment}{!  v\_face\_mask(i,J-1) = 0.}
2858         \textcolor{comment}{!  umask(I-1:I,J-1) = 0.}
2859         \textcolor{comment}{!  vmask(I-1:I,J-1) = 0.}
2860         \textcolor{comment}{!elseif (j\_off+j == gjec) then ! Northern boundary}
2861         \textcolor{comment}{!  v\_face\_mask(i,J) = 0.}
2862         \textcolor{comment}{!  umask(I-1:I,J) = 0.}
2863         \textcolor{comment}{!  vmask(I-1:I,J) = 0.}
2864         \textcolor{comment}{!endif}
2865 
2866         \textcolor{keywordflow}{if} (i < g%ied) \textcolor{keywordflow}{then}
2867           \textcolor{keywordflow}{if} ((hmask(i+1,j) == 0) .OR. (hmask(i+1,j) == 2)) \textcolor{keywordflow}{then}
2868             \textcolor{comment}{! east boundary or adjacent to unfilled cell}
2869             u\_face\_mask(i,j) = 2.
2870 \textcolor{keywordflow}{          endif}
2871 \textcolor{keywordflow}{        endif}
2872 
2873         \textcolor{keywordflow}{if} (i > g%isd) \textcolor{keywordflow}{then}
2874           \textcolor{keywordflow}{if} ((hmask(i-1,j) == 0) .OR. (hmask(i-1,j) == 2)) \textcolor{keywordflow}{then}
2875             \textcolor{comment}{!adjacent to unfilled cell}
2876             u\_face\_mask(i-1,j) = 2.
2877 \textcolor{keywordflow}{          endif}
2878 \textcolor{keywordflow}{        endif}
2879 
2880         \textcolor{keywordflow}{if} (j > g%jsd) \textcolor{keywordflow}{then}
2881           \textcolor{keywordflow}{if} ((hmask(i,j-1) == 0) .OR. (hmask(i,j-1) == 2)) \textcolor{keywordflow}{then}
2882             \textcolor{comment}{!adjacent to unfilled cell}
2883             v\_face\_mask(i,j-1) = 2.
2884 \textcolor{keywordflow}{          endif}
2885 \textcolor{keywordflow}{        endif}
2886 
2887         \textcolor{keywordflow}{if} (j < g%jed) \textcolor{keywordflow}{then}
2888           \textcolor{keywordflow}{if} ((hmask(i,j+1) == 0) .OR. (hmask(i,j+1) == 2)) \textcolor{keywordflow}{then}
2889             \textcolor{comment}{!adjacent to unfilled cell}
2890             v\_face\_mask(i,j) = 2.
2891 \textcolor{keywordflow}{          endif}
2892 \textcolor{keywordflow}{        endif}
2893 
2894 
2895 \textcolor{keywordflow}{      endif}
2896 
2897 \textcolor{keywordflow}{    enddo}
2898 \textcolor{keywordflow}{  enddo}
2899 
2900   \textcolor{comment}{! note: if the grid is nonsymmetric, there is a part that will not be transferred with a halo update}
2901   \textcolor{comment}{! so this subroutine must update its own symmetric part of the halo}
2902 
2903   \textcolor{keyword}{call }pass\_vector(u\_face\_mask, v\_face\_mask, g%domain, to\_all, cgrid\_ne)
2904   \textcolor{keyword}{call }pass\_vector(umask, vmask, g%domain, to\_all, bgrid\_ne)
2905 
\end{DoxyCode}
