\hypertarget{namespacemom__ice__shelf__dynamics}{}\doxysection{mom\+\_\+ice\+\_\+shelf\+\_\+dynamics Module Reference}
\label{namespacemom__ice__shelf__dynamics}\index{mom\_ice\_shelf\_dynamics@{mom\_ice\_shelf\_dynamics}}


\doxysubsection{Detailed Description}
Implements a crude placeholder for a later implementation of full ice shelf dynamics. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\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 \mbox{\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}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
real function \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a44ac16282b7667409d32e7eb3e667822}{quad\+\_\+area}} (X, Y)
\begin{DoxyCompactList}\small\item\em Calculate area of quadrilateral. \end{DoxyCompactList}\item 
subroutine, public \mbox{\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 \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a65c987944c65ba5ab4c88ce809698a88}{initialize\+\_\+diagnostic\+\_\+fields}} (CS, I\+SS, G, US, Time)
\item 
real function, public \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_adb9d6c268c8acbd29ffab94087100099}{ice\+\_\+shelf\+\_\+solve\+\_\+outer}} (CS, I\+SS, G, US, u\+\_\+shlf, v\+\_\+shlf, iters, time)
\item 
subroutine \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a780c301ee73b99c7258b784efb8af172}{shelf\+\_\+advance\+\_\+front}} (CS, I\+SS, G, hmask, uh\+\_\+ice, vh\+\_\+ice)
\item 
subroutine, public \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a5c1d3896958689e3bd2086b539d2b3bc}{calve\+\_\+to\+\_\+mask}} (G, h\+\_\+shelf, area\+\_\+shelf\+\_\+h, hmask, calve\+\_\+mask)
\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a5b068cac79ab7726c0d7198ca153e890}{calc\+\_\+shelf\+\_\+driving\+\_\+stress}} (CS, I\+SS, G, US, taudx, taudy, OD)
\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_aca798d728879d0f253dab89e4cd20b1e}{init\+\_\+boundary\+\_\+values}} (CS, G, time, hmask, input\+\_\+flux, input\+\_\+thick, new\+\_\+sim)
\item 
subroutine \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_aad8e6045696a2ff49453364b2e888bca}{cg\+\_\+action\+\_\+subgrid\+\_\+basal}} (Phisub, H, U, V, bathyT, dens\+\_\+ratio, Ucontr, Vcontr)
\item 
subroutine \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a12746eb7c6f5e5644b844d3aaacafc1f}{cg\+\_\+diagonal\+\_\+subgrid\+\_\+basal}} (Phisub, H\+\_\+node, bathyT, dens\+\_\+ratio, sub\+\_\+grnd)
\item 
subroutine \mbox{\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 \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_af4d6d4d402d1660aa068ab12d3a7d745}{update\+\_\+od\+\_\+ffrac}} (CS, G, US, ocean\+\_\+mass, find\+\_\+avg)
\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a4f860e8b97ca0400263678b1470c3e20}{update\+\_\+od\+\_\+ffrac\+\_\+uncoupled}} (CS, G, h\+\_\+shelf)
\item 
subroutine \mbox{\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 \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_ad57b8fb98fdef287509cea5d1ef25c2e}{bilinear\+\_\+shape\+\_\+functions\+\_\+subgrid}} (Phisub, nsub)
\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a4f87da4ad4dafef238d6f55a4c0d9d8d}{update\+\_\+velocity\+\_\+masks}} (CS, G, hmask, umask, vmask, u\+\_\+face\+\_\+mask, v\+\_\+face\+\_\+mask)
\item 
subroutine \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a972c5ef280e662f96c8fbe696442a15a}{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+x}} (CS, G, time\+\_\+step, hmask, h0, h\+\_\+after\+\_\+uflux)
\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf__dynamics_a063954c33ef89113686bd79b94a742e9}{ice\+\_\+shelf\+\_\+advect\+\_\+temp\+\_\+y}} (CS, G, time\+\_\+step, hmask, h\+\_\+after\+\_\+uflux, h\+\_\+after\+\_\+vflux)
\end{DoxyCompactItemize}


\doxysubsection{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}}
\doxysubsubsection{\texorpdfstring{apply\_boundary\_values()}{apply\_boundary\_values()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::apply\+\_\+boundary\+\_\+values (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model time\\
\hline
\mbox{\texttt{ in}}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+node} & The ice shelf thickness at nodal\\
\hline
\mbox{\texttt{ in}}  & {\em ice\+\_\+visc} & A field related to the ice viscosity from Glen\textquotesingle{}s\\
\hline
\mbox{\texttt{ in}}  & {\em basal\+\_\+trac} & A field related to the nonlinear part of the\\
\hline
\mbox{\texttt{ in}}  & {\em float\+\_\+cond} & An array indicating where the ice\\
\hline
\mbox{\texttt{ in}}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater, nondimensional\\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+bdry\+\_\+contr} & Zonal force contributions due to the\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2310 }
\DoxyCodeLine{2311   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{2312   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{2313 \textcolor{comment}{                                               !! the ice-\/shelf state}}
\DoxyCodeLine{2314   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2315   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{2316   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{2317 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, \&}
\DoxyCodeLine{2318                           \textcolor{keywordtype}{intent(in)}    :: Phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}}
\DoxyCodeLine{2319 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}}
\DoxyCodeLine{2320 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2321                           \textcolor{keywordtype}{intent(in)}    :: H\_node\textcolor{comment}{ !< The ice shelf thickness at nodal}}
\DoxyCodeLine{2322 \textcolor{comment}{                                                 !! (corner) points [Z \string~> m].}}
\DoxyCodeLine{2323 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2324                           \textcolor{keywordtype}{intent(in)}    :: ice\_visc\textcolor{comment}{ !< A field related to the ice viscosity from Glen's}}
\DoxyCodeLine{2325 \textcolor{comment}{                                                !! flow law. The exact form and units depend on the}}
\DoxyCodeLine{2326 \textcolor{comment}{                                                !! basal law exponent.  [R L4 Z T-\/1 \string~> kg m2 s-\/1].}}
\DoxyCodeLine{2327 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2328                           \textcolor{keywordtype}{intent(in)}    :: basal\_trac\textcolor{comment}{ !< A field related to the nonlinear part of the}}
\DoxyCodeLine{2329 \textcolor{comment}{                                                !! "linearized" basal stress [R Z T-\/1 \string~> kg m-\/2 s-\/1].}}
\DoxyCodeLine{2330 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2331                           \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}}
\DoxyCodeLine{2332 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}}
\DoxyCodeLine{2333 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}}
\DoxyCodeLine{2334 \textcolor{comment}{                                                     !! of seawater, nondimensional}}
\DoxyCodeLine{2335 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2336                           \textcolor{keywordtype}{intent(inout)} :: u\_bdry\_contr\textcolor{comment}{ !< Zonal force contributions due to the}}
\DoxyCodeLine{2337 \textcolor{comment}{                                                        !! open boundaries [R L3 Z T-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{2338 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2339                           \textcolor{keywordtype}{intent(inout)} :: v\_bdry\_contr\textcolor{comment}{ !< Meridional force contributions due to the}}
\DoxyCodeLine{2340 \textcolor{comment}{                                                        !! open boundaries [R L3 Z T-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{2341 }
\DoxyCodeLine{2342 \textcolor{comment}{! this will be a per-\/setup function. the boundary values of thickness and velocity}}
\DoxyCodeLine{2343 \textcolor{comment}{! (and possibly other variables) will be updated in this function}}
\DoxyCodeLine{2344 }
\DoxyCodeLine{2345 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(8,4)}  :: Phi}
\DoxyCodeLine{2346 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2)} :: xquad}
\DoxyCodeLine{2347 \textcolor{keywordtype}{  real} :: ux, uy, vx, vy \textcolor{comment}{! Components of velocity shears or divergence [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{2348 \textcolor{keywordtype}{  real} :: uq, vq  \textcolor{comment}{! Interpolated velocities [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{2349 \textcolor{keywordtype}{  real} :: area}
\DoxyCodeLine{2350 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2,2)} :: Ucell,Vcell,Hcell,Usubcontr,Vsubcontr}
\DoxyCodeLine{2351   \textcolor{keywordtype}{integer} :: i, j, isc, jsc, iec, jec, iq, jq, iphi, jphi, ilq, jlq, Itgt, Jtgt}
\DoxyCodeLine{2352 }
\DoxyCodeLine{2353   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{2354 }
\DoxyCodeLine{2355   xquad(1) = .5 * (1-\/sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))}
\DoxyCodeLine{2356 }
\DoxyCodeLine{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}}
\DoxyCodeLine{2358 }
\DoxyCodeLine{2359     \textcolor{comment}{! process this cell if any corners have umask set to non-\/dirichlet bdry.}}
\DoxyCodeLine{2360     \textcolor{comment}{! NOTE: vmask not considered, probably should be}}
\DoxyCodeLine{2361 }
\DoxyCodeLine{2362     \textcolor{keywordflow}{if} ((cs\%umask(i-\/1,j-\/1) == 3) .OR. (cs\%umask(i,j-\/1) == 3) .OR. \&}
\DoxyCodeLine{2363         (cs\%umask(i-\/1,j) == 3) .OR. (cs\%umask(i,j) == 3)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2364 }
\DoxyCodeLine{2365       \textcolor{keyword}{call }bilinear\_shape\_fn\_grid(g, i, j, phi)}
\DoxyCodeLine{2366 }
\DoxyCodeLine{2367       \textcolor{comment}{! Phi(2*i-\/1,j) gives d(Phi\_i)/dx at quadrature point j}}
\DoxyCodeLine{2368       \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}}
\DoxyCodeLine{2369 }
\DoxyCodeLine{2370       \textcolor{keywordflow}{do} iq=1,2 ; \textcolor{keywordflow}{do} jq=1,2}
\DoxyCodeLine{2371 }
\DoxyCodeLine{2372         uq = cs\%u\_bdry\_val(i-\/1,j-\/1) * xquad(3-\/iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2373              cs\%u\_bdry\_val(i,j-\/1) * xquad(iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2374              cs\%u\_bdry\_val(i-\/1,j) * xquad(3-\/iq) * xquad(jq) + \&}
\DoxyCodeLine{2375              cs\%u\_bdry\_val(i,j) * xquad(iq) * xquad(jq)}
\DoxyCodeLine{2376 }
\DoxyCodeLine{2377         vq = cs\%v\_bdry\_val(i-\/1,j-\/1) * xquad(3-\/iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2378              cs\%v\_bdry\_val(i,j-\/1) * xquad(iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2379              cs\%v\_bdry\_val(i-\/1,j) * xquad(3-\/iq) * xquad(jq) + \&}
\DoxyCodeLine{2380              cs\%v\_bdry\_val(i,j) * xquad(iq) * xquad(jq)}
\DoxyCodeLine{2381 }
\DoxyCodeLine{2382         ux = cs\%u\_bdry\_val(i-\/1,j-\/1) * phi(1,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2383              cs\%u\_bdry\_val(i,j-\/1) * phi(3,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2384              cs\%u\_bdry\_val(i-\/1,j) * phi(5,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2385              cs\%u\_bdry\_val(i,j) * phi(7,2*(jq-\/1)+iq)}
\DoxyCodeLine{2386 }
\DoxyCodeLine{2387         vx = cs\%v\_bdry\_val(i-\/1,j-\/1) * phi(1,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2388              cs\%v\_bdry\_val(i,j-\/1) * phi(3,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2389              cs\%v\_bdry\_val(i-\/1,j) * phi(5,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2390              cs\%v\_bdry\_val(i,j) * phi(7,2*(jq-\/1)+iq)}
\DoxyCodeLine{2391 }
\DoxyCodeLine{2392         uy = cs\%u\_bdry\_val(i-\/1,j-\/1) * phi(2,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2393              cs\%u\_bdry\_val(i,j-\/1) * phi(4,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2394              cs\%u\_bdry\_val(i-\/1,j) * phi(6,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2395              cs\%u\_bdry\_val(i,j) * phi(8,2*(jq-\/1)+iq)}
\DoxyCodeLine{2396 }
\DoxyCodeLine{2397         vy = cs\%v\_bdry\_val(i-\/1,j-\/1) * phi(2,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2398              cs\%v\_bdry\_val(i,j-\/1) * phi(4,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2399              cs\%v\_bdry\_val(i-\/1,j) * phi(6,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2400              cs\%v\_bdry\_val(i,j) * phi(8,2*(jq-\/1)+iq)}
\DoxyCodeLine{2401 }
\DoxyCodeLine{2402         \textcolor{keywordflow}{do} iphi=1,2 ; \textcolor{keywordflow}{do} jphi=1,2 ; itgt = i-\/2+iphi ; jtgt = j-\/2-\/jphi}
\DoxyCodeLine{2403           ilq = 1 ; \textcolor{keywordflow}{if} (iq == iphi) ilq = 2}
\DoxyCodeLine{2404           jlq = 1 ; \textcolor{keywordflow}{if} (jq == jphi) jlq = 2}
\DoxyCodeLine{2405 }
\DoxyCodeLine{2406           \textcolor{keywordflow}{if} (cs\%umask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2407             u\_bdry\_contr(itgt,jtgt) = u\_bdry\_contr(itgt,jtgt) + \&}
\DoxyCodeLine{2408                0.25 * ice\_visc(i,j) * ( (4*ux+2*vy) * phi(2*(2*(jphi-\/1)+iphi)-\/1,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2409                                             (uy+vx) * phi(2*(2*(jphi-\/1)+iphi),2*(jq-\/1)+iq) )}
\DoxyCodeLine{2410 }
\DoxyCodeLine{2411             \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2412               u\_bdry\_contr(itgt,jtgt) = u\_bdry\_contr(itgt,jtgt) + \&}
\DoxyCodeLine{2413                 0.25 * basal\_trac(i,j) * uq * xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2414 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{2415 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2416 }
\DoxyCodeLine{2417           \textcolor{keywordflow}{if} (cs\%vmask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2418             v\_bdry\_contr(itgt,jtgt) = v\_bdry\_contr(itgt,jtgt) + \&}
\DoxyCodeLine{2419                 0.25 *  ice\_visc(i,j) * ( (uy+vx) * phi(2*(2*(jphi-\/1)+iphi)-\/1,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2420                                       (4*vy+2*ux) * phi(2*(2*(jphi-\/1)+iphi),2*(jq-\/1)+iq) )}
\DoxyCodeLine{2421 }
\DoxyCodeLine{2422             \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2423               v\_bdry\_contr(itgt,jtgt) = v\_bdry\_contr(itgt,jtgt) + \&}
\DoxyCodeLine{2424                   0.25 * basal\_trac(i,j) * vq * xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2425 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{2426 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2427 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2428 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2429 }
\DoxyCodeLine{2430       \textcolor{keywordflow}{if} (float\_cond(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2431         ucell(:,:) = cs\%u\_bdry\_val(i-\/1:i,j-\/1:j) ; vcell(:,:) = cs\%v\_bdry\_val(i-\/1:i,j-\/1:j)}
\DoxyCodeLine{2432         hcell(:,:) = h\_node(i-\/1:i,j-\/1:j)}
\DoxyCodeLine{2433         \textcolor{keyword}{call }cg\_action\_subgrid\_basal(phisub, hcell, ucell, vcell, g\%bathyT(i,j), \&}
\DoxyCodeLine{2434                                      dens\_ratio, usubcontr, vsubcontr)}
\DoxyCodeLine{2435 }
\DoxyCodeLine{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)}
\DoxyCodeLine{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)}
\DoxyCodeLine{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)}
\DoxyCodeLine{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)}
\DoxyCodeLine{2440 }
\DoxyCodeLine{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)}
\DoxyCodeLine{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)}
\DoxyCodeLine{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)}
\DoxyCodeLine{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)}
\DoxyCodeLine{2445 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2446 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2447 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in}}  & {\em i} & The i-\/index in the grid to work on. \\
\hline
\mbox{\texttt{ in}}  & {\em j} & The j-\/index in the grid to work on. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2650   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2651   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: i\textcolor{comment}{   !< The i-\/index in the grid to work on.}}
\DoxyCodeLine{2652   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{   !< The j-\/index in the grid to work on.}}
\DoxyCodeLine{2653 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(8,4)},  \textcolor{keywordtype}{intent(inout)} :: Phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}}
\DoxyCodeLine{2654 \textcolor{comment}{                                              !! quadrature points surrounding the cell vertices [L-\/1 \string~> m-\/1].}}
\DoxyCodeLine{2655 }
\DoxyCodeLine{2656 \textcolor{comment}{! This subroutine calculates the gradients of bilinear basis elements that}}
\DoxyCodeLine{2657 \textcolor{comment}{! that are centered at the vertices of the cell.  The values are calculated at}}
\DoxyCodeLine{2658 \textcolor{comment}{! points of gaussian quadrature. (in 1D: .5 * (1 +/-\/ sqrt(1/3)) for [0,1])}}
\DoxyCodeLine{2659 \textcolor{comment}{!     (ordered in same way as vertices)}}
\DoxyCodeLine{2660 \textcolor{comment}{!}}
\DoxyCodeLine{2661 \textcolor{comment}{! Phi(2*i-\/1,j) gives d(Phi\_i)/dx at quadrature point j}}
\DoxyCodeLine{2662 \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}}
\DoxyCodeLine{2663 \textcolor{comment}{! Phi\_i is equal to 1 at vertex i, and 0 at vertex k /= i, and bilinear}}
\DoxyCodeLine{2664 \textcolor{comment}{!}}
\DoxyCodeLine{2665 \textcolor{comment}{! This should be a one-\/off; once per nonlinear solve? once per lifetime?}}
\DoxyCodeLine{2666 }
\DoxyCodeLine{2667 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(4)} :: xquad, yquad \textcolor{comment}{! [nondim]}}
\DoxyCodeLine{2668 \textcolor{keywordtype}{  real} :: a, d       \textcolor{comment}{! Interpolated grid spacings [L \string~> m]}}
\DoxyCodeLine{2669 \textcolor{keywordtype}{  real} :: xexp, yexp \textcolor{comment}{! [nondim]}}
\DoxyCodeLine{2670   \textcolor{keywordtype}{integer} :: node, qpoint, xnode, xq, ynode, yq}
\DoxyCodeLine{2671 }
\DoxyCodeLine{2672   xquad(1:3:2) = .5 * (1-\/sqrt(1./3)) ; yquad(1:2) = .5 * (1-\/sqrt(1./3))}
\DoxyCodeLine{2673   xquad(2:4:2) = .5 * (1+sqrt(1./3)) ; yquad(3:4) = .5 * (1+sqrt(1./3))}
\DoxyCodeLine{2674 }
\DoxyCodeLine{2675   \textcolor{keywordflow}{do} qpoint=1,4}
\DoxyCodeLine{2676     a = g\%dxCv(i,j-\/1) * (1-\/yquad(qpoint)) + g\%dxCv(i,j) * yquad(qpoint) \textcolor{comment}{! d(x)/d(x*)}}
\DoxyCodeLine{2677     d = g\%dyCu(i-\/1,j) * (1-\/xquad(qpoint)) + g\%dyCu(i,j) * xquad(qpoint) \textcolor{comment}{! d(y)/d(y*)}}
\DoxyCodeLine{2678 }
\DoxyCodeLine{2679     \textcolor{keywordflow}{do} node=1,4}
\DoxyCodeLine{2680       xnode = 2-\/mod(node,2) ; ynode = ceiling(real(node)/2)}
\DoxyCodeLine{2681 }
\DoxyCodeLine{2682       \textcolor{keywordflow}{if} (ynode == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2683         yexp = 1-\/yquad(qpoint)}
\DoxyCodeLine{2684       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2685         yexp = yquad(qpoint)}
\DoxyCodeLine{2686 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2687 }
\DoxyCodeLine{2688       \textcolor{keywordflow}{if} (1 == xnode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2689         xexp = 1-\/xquad(qpoint)}
\DoxyCodeLine{2690       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2691         xexp = xquad(qpoint)}
\DoxyCodeLine{2692 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2693 }
\DoxyCodeLine{2694       phi(2*node-\/1,qpoint) = ( d * (2 * xnode -\/ 3) * yexp ) / (a*d)}
\DoxyCodeLine{2695       phi(2*node,qpoint)   = ( a * (2 * ynode -\/ 3) * xexp ) / (a*d)}
\DoxyCodeLine{2696 }
\DoxyCodeLine{2697 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2698 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em x} & The x-\/positions of the vertices of the quadrilateral \mbox{[}L $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em y} & The y-\/positions of the vertices of the quadrilateral \mbox{[}L $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ 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{\texttt{ 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}{0}
\DoxyCodeLine{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 \string~> m].}}
\DoxyCodeLine{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 \string~> m].}}
\DoxyCodeLine{2584 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(8,4)}, \textcolor{keywordtype}{intent(inout)} :: Phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}}
\DoxyCodeLine{2585 \textcolor{comment}{                                             !! quadrature points surrounding the cell vertices [L-\/1 \string~> m-\/1].}}
\DoxyCodeLine{2586 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(out)}   :: area\textcolor{comment}{ !< The quadrilateral cell area [L2 \string~> m2].}}
\DoxyCodeLine{2587 }
\DoxyCodeLine{2588 \textcolor{comment}{! X and Y must be passed in the form}}
\DoxyCodeLine{2589     \textcolor{comment}{!  3 -\/ 4}}
\DoxyCodeLine{2590     \textcolor{comment}{!  |   |}}
\DoxyCodeLine{2591     \textcolor{comment}{!  1 -\/ 2}}
\DoxyCodeLine{2592 }
\DoxyCodeLine{2593 \textcolor{comment}{! this subroutine calculates the gradients of bilinear basis elements that}}
\DoxyCodeLine{2594 \textcolor{comment}{! that are centered at the vertices of the cell. values are calculated at}}
\DoxyCodeLine{2595 \textcolor{comment}{! points of gaussian quadrature. (in 1D: .5 * (1 +/-\/ sqrt(1/3)) for [0,1])}}
\DoxyCodeLine{2596 \textcolor{comment}{!     (ordered in same way as vertices)}}
\DoxyCodeLine{2597 \textcolor{comment}{!}}
\DoxyCodeLine{2598 \textcolor{comment}{! Phi(2*i-\/1,j) gives d(Phi\_i)/dx at quadrature point j}}
\DoxyCodeLine{2599 \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}}
\DoxyCodeLine{2600 \textcolor{comment}{! Phi\_i is equal to 1 at vertex i, and 0 at vertex k /= i, and bilinear}}
\DoxyCodeLine{2601 \textcolor{comment}{!}}
\DoxyCodeLine{2602 \textcolor{comment}{! This should be a one-\/off; once per nonlinear solve? once per lifetime?}}
\DoxyCodeLine{2603 \textcolor{comment}{! ... will all cells have the same shape and dimension?}}
\DoxyCodeLine{2604 }
\DoxyCodeLine{2605 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(4)} :: xquad, yquad \textcolor{comment}{! [nondim]}}
\DoxyCodeLine{2606 \textcolor{keywordtype}{  real} :: a,b,c,d  \textcolor{comment}{! Various lengths [L \string~> m]}}
\DoxyCodeLine{2607 \textcolor{keywordtype}{  real} :: xexp, yexp \textcolor{comment}{! [nondim]}}
\DoxyCodeLine{2608   \textcolor{keywordtype}{integer} :: node, qpoint, xnode, xq, ynode, yq}
\DoxyCodeLine{2609 }
\DoxyCodeLine{2610   xquad(1:3:2) = .5 * (1-\/sqrt(1./3)) ; yquad(1:2) = .5 * (1-\/sqrt(1./3))}
\DoxyCodeLine{2611   xquad(2:4:2) = .5 * (1+sqrt(1./3)) ; yquad(3:4) = .5 * (1+sqrt(1./3))}
\DoxyCodeLine{2612 }
\DoxyCodeLine{2613   \textcolor{keywordflow}{do} qpoint=1,4}
\DoxyCodeLine{2614 }
\DoxyCodeLine{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*)}}
\DoxyCodeLine{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*)}}
\DoxyCodeLine{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*)}}
\DoxyCodeLine{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*)}}
\DoxyCodeLine{2619 }
\DoxyCodeLine{2620     \textcolor{keywordflow}{do} node=1,4}
\DoxyCodeLine{2621 }
\DoxyCodeLine{2622       xnode = 2-\/mod(node,2) ; ynode = ceiling(real(node)/2)}
\DoxyCodeLine{2623 }
\DoxyCodeLine{2624       \textcolor{keywordflow}{if} (ynode == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2625         yexp = 1-\/yquad(qpoint)}
\DoxyCodeLine{2626       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2627         yexp = yquad(qpoint)}
\DoxyCodeLine{2628 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2629 }
\DoxyCodeLine{2630       \textcolor{keywordflow}{if} (1 == xnode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2631         xexp = 1-\/xquad(qpoint)}
\DoxyCodeLine{2632       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2633         xexp = xquad(qpoint)}
\DoxyCodeLine{2634 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2635 }
\DoxyCodeLine{2636       phi(2*node-\/1,qpoint) = ( d * (2 * xnode -\/ 3) * yexp -\/ b * (2 * ynode -\/ 3) * xexp) / (a*d-\/b*c)}
\DoxyCodeLine{2637       phi(2*node,qpoint)   = (-\/c * (2 * xnode -\/ 3) * yexp + a * (2 * ynode -\/ 3) * xexp) / (a*d-\/b*c)}
\DoxyCodeLine{2638 }
\DoxyCodeLine{2639 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2640 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2641 }
\DoxyCodeLine{2642   area = quad\_area(x, y)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in,out}}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2704 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsub,nsub,2,2,2,2)}, \&}
\DoxyCodeLine{2705            \textcolor{keywordtype}{intent(inout)} :: Phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}}
\DoxyCodeLine{2706 \textcolor{comment}{                                   !! locations for finite element calculations [nondim]}}
\DoxyCodeLine{2707   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}    :: nsub\textcolor{comment}{   !< The number of subgridscale quadrature locations in each direction}}
\DoxyCodeLine{2708 }
\DoxyCodeLine{2709   \textcolor{comment}{! this subroutine is a helper for interpolation of floatation condition}}
\DoxyCodeLine{2710   \textcolor{comment}{! for the purposes of evaluating the terms \(\backslash\)int (u,v) \(\backslash\)phi\_i dx dy in a cell that is}}
\DoxyCodeLine{2711   \textcolor{comment}{!     in partial floatation}}
\DoxyCodeLine{2712   \textcolor{comment}{! the array Phisub contains the values of \(\backslash\)phi\_i (where i is a node of the cell)}}
\DoxyCodeLine{2713   \textcolor{comment}{!     at quad point j}}
\DoxyCodeLine{2714   \textcolor{comment}{! i think this general approach may not work for nonrectangular elements...}}
\DoxyCodeLine{2715   \textcolor{comment}{!}}
\DoxyCodeLine{2716 }
\DoxyCodeLine{2717   \textcolor{comment}{! Phisub(i,j,k,l,q1,q2)}}
\DoxyCodeLine{2718   \textcolor{comment}{!  i: subgrid index in x-\/direction}}
\DoxyCodeLine{2719   \textcolor{comment}{!  j: subgrid index in y-\/direction}}
\DoxyCodeLine{2720   \textcolor{comment}{!  k: basis function x-\/index}}
\DoxyCodeLine{2721   \textcolor{comment}{!  l: basis function y-\/index}}
\DoxyCodeLine{2722   \textcolor{comment}{!  q1: quad point x-\/index}}
\DoxyCodeLine{2723   \textcolor{comment}{!  q2: quad point y-\/index}}
\DoxyCodeLine{2724 }
\DoxyCodeLine{2725   \textcolor{comment}{! e.g. k=1,l=1 => node 1}}
\DoxyCodeLine{2726   \textcolor{comment}{!      q1=2,q2=1 => quad point 2}}
\DoxyCodeLine{2727 }
\DoxyCodeLine{2728     \textcolor{comment}{!  3 -\/ 4}}
\DoxyCodeLine{2729     \textcolor{comment}{!  |   |}}
\DoxyCodeLine{2730     \textcolor{comment}{!  1 -\/ 2}}
\DoxyCodeLine{2731 }
\DoxyCodeLine{2732   \textcolor{keywordtype}{integer} :: i, j, k, l, qx, qy, indx, indy}
\DoxyCodeLine{2733 \textcolor{keywordtype}{  real},\textcolor{keywordtype}{dimension(2)}    :: xquad}
\DoxyCodeLine{2734 \textcolor{keywordtype}{  real}                 :: x0, y0, x, y, val, fracx}
\DoxyCodeLine{2735 }
\DoxyCodeLine{2736   xquad(1) = .5 * (1-\/sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))}
\DoxyCodeLine{2737   fracx = 1.0/real(nsub)}
\DoxyCodeLine{2738 }
\DoxyCodeLine{2739   \textcolor{keywordflow}{do} j=1,nsub ; \textcolor{keywordflow}{do} i=1,nsub}
\DoxyCodeLine{2740     x0 = (i-\/1) * fracx ; y0 = (j-\/1) * fracx}
\DoxyCodeLine{2741     \textcolor{keywordflow}{do} qy=1,2 ; \textcolor{keywordflow}{do} qx=1,2}
\DoxyCodeLine{2742       x = x0 + fracx*xquad(qx)}
\DoxyCodeLine{2743       y = y0 + fracx*xquad(qy)}
\DoxyCodeLine{2744       phisub(i,j,1,1,qx,qy) = (1.0-\/x) * (1.0-\/y)}
\DoxyCodeLine{2745       phisub(i,j,1,2,qx,qy) = (1.0-\/x) * y}
\DoxyCodeLine{2746       phisub(i,j,2,1,qx,qy) = x * (1.0-\/y)}
\DoxyCodeLine{2747       phisub(i,j,2,2,qx,qy) = x * y}
\DoxyCodeLine{2748 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2749 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{calc\_shelf\_driving\_stress()}{calc\_shelf\_driving\_stress()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::calc\+\_\+shelf\+\_\+driving\+\_\+stress (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\texttt{ in}}  & {\em od} & ocean floor depth at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in,out}}  & {\em taudx} & X-\/direction driving stress at q-\/points \mbox{[}kg L s-\/2 $\sim$$>$ kg m s-\/2\mbox{]}\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1707   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}   :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1708   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{1709 \textcolor{comment}{                                             !! the ice-\/shelf state}}
\DoxyCodeLine{1710   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1711   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{1712 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1713                          \textcolor{keywordtype}{intent(in)}    :: OD\textcolor{comment}{  !< ocean floor depth at tracer points [Z \string~> m].}}
\DoxyCodeLine{1714 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1715                          \textcolor{keywordtype}{intent(inout)} :: taudx\textcolor{comment}{  !< X-\/direction driving stress at q-\/points [kg L s-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{1716 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1717                          \textcolor{keywordtype}{intent(inout)} :: taudy\textcolor{comment}{  !< Y-\/direction driving stress at q-\/points [kg L s-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{1718                                                   \textcolor{comment}{! This will become [R L3 Z T-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{1719 }
\DoxyCodeLine{1720 \textcolor{comment}{! driving stress!}}
\DoxyCodeLine{1721 }
\DoxyCodeLine{1722 \textcolor{comment}{! ! taudx and taudy will hold driving stress in the x-\/ and y-\/ directions when done.}}
\DoxyCodeLine{1723 \textcolor{comment}{!    they will sit on the BGrid, and so their size depends on whether the grid is symmetric}}
\DoxyCodeLine{1724 \textcolor{comment}{!}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1726 \textcolor{comment}{!}}
\DoxyCodeLine{1727 \textcolor{comment}{! OD -\/this is important and we do not yet know where (in MOM) it will come from. It represents}}
\DoxyCodeLine{1728 \textcolor{comment}{!     "average" ocean depth -\/-\/ and is needed to find surface elevation}}
\DoxyCodeLine{1729 \textcolor{comment}{!    (it is assumed that base\_ice = bed + OD)}}
\DoxyCodeLine{1730 }
\DoxyCodeLine{1731 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SIZE(OD,1),SIZE(OD,2))}  :: S, \&     \textcolor{comment}{! surface elevation [Z \string~> m].}}
\DoxyCodeLine{1732                             BASE     \textcolor{comment}{! basal elevation of shelf/stream [Z \string~> m].}}
\DoxyCodeLine{1733 }
\DoxyCodeLine{1734 }
\DoxyCodeLine{1735 \textcolor{keywordtype}{  real}    :: rho, rhow \textcolor{comment}{! Ice and ocean densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{1736 \textcolor{keywordtype}{  real}    :: sx, sy    \textcolor{comment}{! Ice shelf top slopes [Z L-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1737 \textcolor{keywordtype}{  real}    :: neumann\_val \textcolor{comment}{! [R Z L2 T-\/2 \string~> kg s-\/2]}}
\DoxyCodeLine{1738 \textcolor{keywordtype}{  real}    :: dxh, dyh  \textcolor{comment}{! Local grid spacing [L \string~> m]}}
\DoxyCodeLine{1739 \textcolor{keywordtype}{  real}    :: grav      \textcolor{comment}{! The gravitational acceleration [L2 Z-\/1 T-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{1740 }
\DoxyCodeLine{1741   \textcolor{keywordtype}{integer} :: i, j, iscq, iecq, jscq, jecq, isd, jsd, is, js, iegq, jegq}
\DoxyCodeLine{1742   \textcolor{keywordtype}{integer} :: giec, gjec, gisc, gjsc, cnt, isc, jsc, iec, jec}
\DoxyCodeLine{1743   \textcolor{keywordtype}{integer} :: i\_off, j\_off}
\DoxyCodeLine{1744 }
\DoxyCodeLine{1745   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{1746   iscq = g\%iscB ; iecq = g\%iecB ; jscq = g\%jscB ; jecq = g\%jecB}
\DoxyCodeLine{1747   isd = g\%isd ; jsd = g\%jsd}
\DoxyCodeLine{1748   iegq = g\%iegB ; jegq = g\%jegB}
\DoxyCodeLine{1749   gisc = g\%domain\%nihalo+1 ; gjsc = g\%domain\%njhalo+1}
\DoxyCodeLine{1750   giec = g\%domain\%niglobal+g\%domain\%nihalo ; gjec = g\%domain\%njglobal+g\%domain\%njhalo}
\DoxyCodeLine{1751   is = iscq -\/ 1; js = jscq -\/ 1}
\DoxyCodeLine{1752   i\_off = g\%idg\_offset ; j\_off = g\%jdg\_offset}
\DoxyCodeLine{1753 }
\DoxyCodeLine{1754   rho =  cs\%density\_ice}
\DoxyCodeLine{1755   rhow = cs\%density\_ocean\_avg}
\DoxyCodeLine{1756   grav = cs\%g\_Earth}
\DoxyCodeLine{1757 }
\DoxyCodeLine{1758   \textcolor{comment}{! prelim -\/ go through and calculate S}}
\DoxyCodeLine{1759 }
\DoxyCodeLine{1760   \textcolor{comment}{! or is this faster?}}
\DoxyCodeLine{1761   base(:,:) = -\/g\%bathyT(:,:) + od(:,:)}
\DoxyCodeLine{1762   s(:,:) = base(:,:) + iss\%h\_shelf(:,:)}
\DoxyCodeLine{1763 }
\DoxyCodeLine{1764   \textcolor{keywordflow}{do} j=jsc-\/1,jec+1}
\DoxyCodeLine{1765     \textcolor{keywordflow}{do} i=isc-\/1,iec+1}
\DoxyCodeLine{1766       cnt = 0}
\DoxyCodeLine{1767       sx = 0}
\DoxyCodeLine{1768       sy = 0}
\DoxyCodeLine{1769       dxh = g\%dxT(i,j)}
\DoxyCodeLine{1770       dyh = g\%dyT(i,j)}
\DoxyCodeLine{1771 }
\DoxyCodeLine{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}}
\DoxyCodeLine{1773 }
\DoxyCodeLine{1774         \textcolor{comment}{! calculate sx}}
\DoxyCodeLine{1775         \textcolor{keywordflow}{if} ((i+i\_off) == gisc) \textcolor{keywordflow}{then} \textcolor{comment}{! at left computational bdry}}
\DoxyCodeLine{1776           \textcolor{keywordflow}{if} (iss\%hmask(i+1,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1777             sx = (s(i+1,j)-\/s(i,j))/dxh}
\DoxyCodeLine{1778           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1779             sx = 0}
\DoxyCodeLine{1780 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1781         \textcolor{keywordflow}{elseif} ((i+i\_off) == giec) \textcolor{keywordflow}{then} \textcolor{comment}{! at east computational bdry}}
\DoxyCodeLine{1782           \textcolor{keywordflow}{if} (iss\%hmask(i-\/1,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1783             sx = (s(i,j)-\/s(i-\/1,j))/dxh}
\DoxyCodeLine{1784           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1785             sx = 0}
\DoxyCodeLine{1786 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1787         \textcolor{keywordflow}{else} \textcolor{comment}{! interior}}
\DoxyCodeLine{1788           \textcolor{keywordflow}{if} (iss\%hmask(i+1,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1789             cnt = cnt+1}
\DoxyCodeLine{1790             sx = s(i+1,j)}
\DoxyCodeLine{1791           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1792             sx = s(i,j)}
\DoxyCodeLine{1793 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1794           \textcolor{keywordflow}{if} (iss\%hmask(i-\/1,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1795             cnt = cnt+1}
\DoxyCodeLine{1796             sx = sx -\/ s(i-\/1,j)}
\DoxyCodeLine{1797           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1798             sx = sx -\/ s(i,j)}
\DoxyCodeLine{1799 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1800           \textcolor{keywordflow}{if} (cnt == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1801             sx = 0}
\DoxyCodeLine{1802           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1803             sx = sx / (cnt * dxh)}
\DoxyCodeLine{1804 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1805 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1806 }
\DoxyCodeLine{1807         cnt = 0}
\DoxyCodeLine{1808 }
\DoxyCodeLine{1809         \textcolor{comment}{! calculate sy, similarly}}
\DoxyCodeLine{1810         \textcolor{keywordflow}{if} ((j+j\_off) == gjsc) \textcolor{keywordflow}{then} \textcolor{comment}{! at south computational bdry}}
\DoxyCodeLine{1811           \textcolor{keywordflow}{if} (iss\%hmask(i,j+1) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1812             sy = (s(i,j+1)-\/s(i,j))/dyh}
\DoxyCodeLine{1813           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1814             sy = 0}
\DoxyCodeLine{1815 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1816         \textcolor{keywordflow}{elseif} ((j+j\_off) == gjec) \textcolor{keywordflow}{then} \textcolor{comment}{! at nprth computational bdry}}
\DoxyCodeLine{1817           \textcolor{keywordflow}{if} (iss\%hmask(i,j-\/1) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1818             sy = (s(i,j)-\/s(i,j-\/1))/dyh}
\DoxyCodeLine{1819           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1820             sy = 0}
\DoxyCodeLine{1821 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1822         \textcolor{keywordflow}{else} \textcolor{comment}{! interior}}
\DoxyCodeLine{1823           \textcolor{keywordflow}{if} (iss\%hmask(i,j+1) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1824             cnt = cnt+1}
\DoxyCodeLine{1825             sy = s(i,j+1)}
\DoxyCodeLine{1826           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1827             sy = s(i,j)}
\DoxyCodeLine{1828 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1829           \textcolor{keywordflow}{if} (iss\%hmask(i,j-\/1) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1830             cnt = cnt+1}
\DoxyCodeLine{1831             sy = sy -\/ s(i,j-\/1)}
\DoxyCodeLine{1832           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1833             sy = sy -\/ s(i,j)}
\DoxyCodeLine{1834 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1835           \textcolor{keywordflow}{if} (cnt == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1836             sy = 0}
\DoxyCodeLine{1837           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1838             sy = sy / (cnt * dyh)}
\DoxyCodeLine{1839 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1840 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1841 }
\DoxyCodeLine{1842         \textcolor{comment}{! SW vertex}}
\DoxyCodeLine{1843         taudx(i-\/1,j-\/1) = taudx(i-\/1,j-\/1) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sx * g\%areaT(i,j)}
\DoxyCodeLine{1844         taudy(i-\/1,j-\/1) = taudy(i-\/1,j-\/1) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sy * g\%areaT(i,j)}
\DoxyCodeLine{1845 }
\DoxyCodeLine{1846         \textcolor{comment}{! SE vertex}}
\DoxyCodeLine{1847         taudx(i,j-\/1) = taudx(i,j-\/1) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sx * g\%areaT(i,j)}
\DoxyCodeLine{1848         taudy(i,j-\/1) = taudy(i,j-\/1) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sy * g\%areaT(i,j)}
\DoxyCodeLine{1849 }
\DoxyCodeLine{1850         \textcolor{comment}{! NW vertex}}
\DoxyCodeLine{1851         taudx(i-\/1,j) = taudx(i-\/1,j) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sx * g\%areaT(i,j)}
\DoxyCodeLine{1852         taudy(i-\/1,j) = taudy(i-\/1,j) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sy * g\%areaT(i,j)}
\DoxyCodeLine{1853 }
\DoxyCodeLine{1854         \textcolor{comment}{! NE vertex}}
\DoxyCodeLine{1855         taudx(i,j) = taudx(i,j) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sx * g\%areaT(i,j)}
\DoxyCodeLine{1856         taudy(i,j) = taudy(i,j) -\/ .25 * rho * grav * iss\%h\_shelf(i,j) * sy * g\%areaT(i,j)}
\DoxyCodeLine{1857 }
\DoxyCodeLine{1858         \textcolor{keywordflow}{if} (cs\%ground\_frac(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1859           neumann\_val = .5 * grav * (rho * iss\%h\_shelf(i,j)**2 -\/ rhow * g\%bathyT(i,j)**2)}
\DoxyCodeLine{1860         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1861           neumann\_val = .5 * grav * (1-\/rho/rhow) * rho * iss\%h\_shelf(i,j)**2}
\DoxyCodeLine{1862 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1863 }
\DoxyCodeLine{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}}
\DoxyCodeLine{1865           \textcolor{comment}{! left face of the cell is at a stress boundary}}
\DoxyCodeLine{1866           \textcolor{comment}{! the depth-\/integrated longitudinal stress is equal to the difference of depth-\/integrated}}
\DoxyCodeLine{1867           \textcolor{comment}{! pressure on either side of the face}}
\DoxyCodeLine{1868           \textcolor{comment}{! on the ice side, it is rho g h\string^2 / 2}}
\DoxyCodeLine{1869           \textcolor{comment}{! on the ocean side, it is rhow g (delta OD)\string^2 / 2}}
\DoxyCodeLine{1870           \textcolor{comment}{! OD can be zero under the ice; but it is ASSUMED on the ice-\/free side of the face, topography elevation}}
\DoxyCodeLine{1871           \textcolor{comment}{!     is not above the base of the ice in the current cell}}
\DoxyCodeLine{1872 }
\DoxyCodeLine{1873           \textcolor{comment}{! Note the negative sign due to the direction of the normal vector}}
\DoxyCodeLine{1874           taudx(i-\/1,j-\/1) = taudx(i-\/1,j-\/1) -\/ .5 * dyh * neumann\_val}
\DoxyCodeLine{1875           taudx(i-\/1,j) = taudx(i-\/1,j) -\/ .5 * dyh * neumann\_val}
\DoxyCodeLine{1876 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1877 }
\DoxyCodeLine{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}}
\DoxyCodeLine{1879           \textcolor{comment}{! east face of the cell is at a stress boundary}}
\DoxyCodeLine{1880           taudx(i,j-\/1) = taudx(i,j-\/1) + .5 * dyh * neumann\_val}
\DoxyCodeLine{1881           taudx(i,j) = taudx(i,j) + .5 * dyh * neumann\_val}
\DoxyCodeLine{1882 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1883 }
\DoxyCodeLine{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}}
\DoxyCodeLine{1885           \textcolor{comment}{! south face of the cell is at a stress boundary}}
\DoxyCodeLine{1886           taudy(i-\/1,j-\/1) = taudy(i-\/1,j-\/1) -\/ .5 * dxh * neumann\_val}
\DoxyCodeLine{1887           taudy(i,j-\/1) = taudy(i,j-\/1) -\/ .5 * dxh * neumann\_val}
\DoxyCodeLine{1888 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1889 }
\DoxyCodeLine{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}}
\DoxyCodeLine{1891           \textcolor{comment}{! north face of the cell is at a stress boundary}}
\DoxyCodeLine{1892           taudy(i-\/1,j) = taudy(i-\/1,j) + .5 * dxh * neumann\_val}
\DoxyCodeLine{1893           taudy(i,j) = taudy(i,j) + .5 * dxh * neumann\_val}
\DoxyCodeLine{1894 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1895 }
\DoxyCodeLine{1896 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1897 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1898 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{calc\_shelf\_visc()}{calc\_shelf\_visc()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::calc\+\_\+shelf\+\_\+visc (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & A pointer to the ice shelf control structure \\
\hline
\mbox{\texttt{ in}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors \\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2454   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{2455   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{2456 \textcolor{comment}{                                               !! the ice-\/shelf state}}
\DoxyCodeLine{2457   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2458   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{2459 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%IsdB:G\%IedB,G\%JsdB:G\%JedB)}, \&}
\DoxyCodeLine{2460                           \textcolor{keywordtype}{intent(inout)} :: u\_shlf\textcolor{comment}{ !< The zonal ice shelf velocity [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{2461 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%IsdB:G\%IedB,G\%JsdB:G\%JedB)}, \&}
\DoxyCodeLine{2462                           \textcolor{keywordtype}{intent(inout)} :: v\_shlf\textcolor{comment}{ !< The meridional ice shelf velocity [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{2463 }
\DoxyCodeLine{2464 \textcolor{comment}{! update DEPTH\_INTEGRATED viscosity, based on horizontal strain rates -\/ this is for bilinear FEM solve}}
\DoxyCodeLine{2465 \textcolor{comment}{! so there is an "upper" and "lower" bilinear viscosity}}
\DoxyCodeLine{2466 }
\DoxyCodeLine{2467 \textcolor{comment}{! also this subroutine updates the nonlinear part of the basal traction}}
\DoxyCodeLine{2468 }
\DoxyCodeLine{2469 \textcolor{comment}{! this may be subject to change later... to make it "hybrid"}}
\DoxyCodeLine{2470 }
\DoxyCodeLine{2471   \textcolor{keywordtype}{integer} :: i, j, iscq, iecq, jscq, jecq, isd, jsd, ied, jed, iegq, jegq}
\DoxyCodeLine{2472   \textcolor{keywordtype}{integer} :: giec, gjec, gisc, gjsc, cnt, isc, jsc, iec, jec, is, js}
\DoxyCodeLine{2473 \textcolor{keywordtype}{  real} :: Visc\_coef, n\_g}
\DoxyCodeLine{2474 \textcolor{keywordtype}{  real} :: ux, uy, vx, vy, eps\_min \textcolor{comment}{! Velocity shears [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{2475 \textcolor{keywordtype}{  real} :: umid, vmid, unorm \textcolor{comment}{! Velocities [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{2476 }
\DoxyCodeLine{2477   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{2478   iscq = g\%iscB ; iecq = g\%iecB ; jscq = g\%jscB ; jecq = g\%jecB}
\DoxyCodeLine{2479   isd = g\%isd ; jsd = g\%jsd ; ied = g\%ied ; jed = g\%jed}
\DoxyCodeLine{2480   iegq = g\%iegB ; jegq = g\%jegB}
\DoxyCodeLine{2481   gisc = g\%domain\%nihalo+1 ; gjsc = g\%domain\%njhalo+1}
\DoxyCodeLine{2482   giec = g\%domain\%niglobal+gisc ; gjec = g\%domain\%njglobal+gjsc}
\DoxyCodeLine{2483   is = iscq -\/ 1; js = jscq -\/ 1}
\DoxyCodeLine{2484 }
\DoxyCodeLine{2485   n\_g = cs\%n\_glen; eps\_min = cs\%eps\_glen\_min}
\DoxyCodeLine{2486 }
\DoxyCodeLine{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)}
\DoxyCodeLine{2488 }
\DoxyCodeLine{2489   \textcolor{keywordflow}{do} j=jsd+1,jed-\/1}
\DoxyCodeLine{2490     \textcolor{keywordflow}{do} i=isd+1,ied-\/1}
\DoxyCodeLine{2491 }
\DoxyCodeLine{2492       \textcolor{keywordflow}{if} (iss\%hmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{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))}
\DoxyCodeLine{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))}
\DoxyCodeLine{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))}
\DoxyCodeLine{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))}
\DoxyCodeLine{2497         cs\%ice\_visc(i,j) = 0.5 * visc\_coef * (g\%areaT(i,j) * iss\%h\_shelf(i,j)) * \&}
\DoxyCodeLine{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))}
\DoxyCodeLine{2499 }
\DoxyCodeLine{2500         umid = ((u\_shlf(i,j) + u\_shlf(i-\/1,j-\/1)) + (u\_shlf(i,j-\/1) + u\_shlf(i-\/1,j))) * 0.25}
\DoxyCodeLine{2501         vmid = ((v\_shlf(i,j) + v\_shlf(i-\/1,j-\/1)) + (v\_shlf(i,j-\/1) + v\_shlf(i-\/1,j))) * 0.25}
\DoxyCodeLine{2502         unorm = sqrt(umid**2 + vmid**2 + eps\_min**2*(g\%dxT(i,j)**2 + g\%dyT(i,j)**2))}
\DoxyCodeLine{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)}
\DoxyCodeLine{2504 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2505 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2506 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in,out}}  & {\em h\+\_\+shelf} & The ice shelf thickness \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in,out}}  & {\em area\+\_\+shelf\+\_\+h} & The area per cell covered by the ice shelf \mbox{[}L2 $\sim$$>$ m2\mbox{]}.\\
\hline
\mbox{\texttt{ in,out}}  & {\em hmask} & A mask indicating which tracer points are partly or fully covered by an ice-\/shelf\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1685   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1686 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: h\_shelf\textcolor{comment}{ !< The ice shelf thickness [Z \string~> m].}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1688 \textcolor{comment}{                                                             !! the ice shelf [L2 \string~> m2].}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1690 \textcolor{comment}{                                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1692 \textcolor{comment}{                                                             !! shelf can exist, and where it will calve.}}
\DoxyCodeLine{1693 }
\DoxyCodeLine{1694   \textcolor{keywordtype}{integer}                        :: i,j}
\DoxyCodeLine{1695 }
\DoxyCodeLine{1696   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1697     \textcolor{keywordflow}{if} ((calve\_mask(i,j) == 0.0) .and. (hmask(i,j) /= 0.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1698       h\_shelf(i,j) = 0.0}
\DoxyCodeLine{1699       area\_shelf\_h(i,j) = 0.0}
\DoxyCodeLine{1700       hmask(i,j) = 0.0}
\DoxyCodeLine{1701 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1702 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ 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{\texttt{ 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{\texttt{ in}}  & {\em phi} & The gradients of bilinear basis elements at Gaussian\\
\hline
\mbox{\texttt{ in}}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+shlf} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ in}}  & {\em umask} & A coded mask indicating the nature of the\\
\hline
\mbox{\texttt{ in}}  & {\em vmask} & A coded mask indicating the nature of the\\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+node} & The ice shelf thickness at nodal (corner)\\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ in}}  & {\em ice\+\_\+visc} & A field related to the ice viscosity from Glen\textquotesingle{}s\\
\hline
\mbox{\texttt{ in}}  & {\em float\+\_\+cond} & An array indicating where the ice\\
\hline
\mbox{\texttt{ in}}  & {\em bathyt} & The depth of ocean bathymetry at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in}}  & {\em basal\+\_\+trac} & A field related to the nonlinear part of the\\
\hline
\mbox{\texttt{ in}}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater, nondimensional\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\texttt{ in}}  & {\em is} & The starting i-\/index to work on\\
\hline
\mbox{\texttt{ in}}  & {\em ie} & The ending i-\/index to work on\\
\hline
\mbox{\texttt{ in}}  & {\em js} & The starting j-\/index to work on\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1973 }
\DoxyCodeLine{1974   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1975 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%IsdB:G\%IedB,G\%JsdB:G\%JedB)}, \&}
\DoxyCodeLine{1976                          \textcolor{keywordtype}{intent(inout)} :: uret\textcolor{comment}{ !< The retarding stresses working at u-\/points [R L3 Z T-\/2 \string~> kg m s-\/2].}}
\DoxyCodeLine{1977 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%IsdB:G\%IedB,G\%JsdB:G\%JedB)}, \&}
\DoxyCodeLine{1978                          \textcolor{keywordtype}{intent(inout)} :: vret\textcolor{comment}{ !< The retarding stresses working at v-\/points [R L3 Z T-\/2 \string~> kg m s-\/2].}}
\DoxyCodeLine{1979 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G),8,4)}, \&}
\DoxyCodeLine{1980                          \textcolor{keywordtype}{intent(in)}   :: Phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}}
\DoxyCodeLine{1981 \textcolor{comment}{                                             !! quadrature points surrounding the cell vertices [L-\/1 \string~> m-\/1].}}
\DoxyCodeLine{1982 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, \&}
\DoxyCodeLine{1983                          \textcolor{keywordtype}{intent(in)}    :: Phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}}
\DoxyCodeLine{1984 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}}
\DoxyCodeLine{1985 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1986                          \textcolor{keywordtype}{intent(in)}    :: u\_shlf\textcolor{comment}{  !< The zonal ice shelf velocity at vertices [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1987 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1988                          \textcolor{keywordtype}{intent(in)}    :: v\_shlf\textcolor{comment}{  !< The meridional ice shelf velocity at vertices [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1989 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1990                          \textcolor{keywordtype}{intent(in)}    :: umask\textcolor{comment}{ !< A coded mask indicating the nature of the}}
\DoxyCodeLine{1991 \textcolor{comment}{                                             !! zonal flow at the corner point}}
\DoxyCodeLine{1992 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1993                          \textcolor{keywordtype}{intent(in)}    :: vmask\textcolor{comment}{ !< A coded mask indicating the nature of the}}
\DoxyCodeLine{1994 \textcolor{comment}{                                             !! meridional flow at the corner point}}
\DoxyCodeLine{1995 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1996                          \textcolor{keywordtype}{intent(in)}    :: H\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}}
\DoxyCodeLine{1997 \textcolor{comment}{                                             !! points [Z \string~> m].}}
\DoxyCodeLine{1998 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1999                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{2000 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{2001 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2002                          \textcolor{keywordtype}{intent(in)}    :: ice\_visc\textcolor{comment}{ !< A field related to the ice viscosity from Glen's}}
\DoxyCodeLine{2003 \textcolor{comment}{                                               !! flow law [R L4 Z T-\/1 \string~> kg m2 s-\/1]. The exact form}}
\DoxyCodeLine{2004 \textcolor{comment}{                                               !!  and units depend on the basal law exponent.}}
\DoxyCodeLine{2005 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2006                          \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}}
\DoxyCodeLine{2007 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}}
\DoxyCodeLine{2008 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2009                          \textcolor{keywordtype}{intent(in)}    :: bathyT\textcolor{comment}{ !< The depth of ocean bathymetry at tracer points [Z \string~> m].}}
\DoxyCodeLine{2010 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2011                          \textcolor{keywordtype}{intent(in)}    :: basal\_trac\textcolor{comment}{  !< A field related to the nonlinear part of the}}
\DoxyCodeLine{2012 \textcolor{comment}{                                                !! "linearized" basal stress [R Z T-\/1 \string~> kg m-\/2 s-\/1].}}
\DoxyCodeLine{2013                 \textcolor{comment}{! and/or whether flow is "hybridized"}}
\DoxyCodeLine{2014 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}}
\DoxyCodeLine{2015 \textcolor{comment}{                                                     !! of seawater, nondimensional}}
\DoxyCodeLine{2016   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A structure containing unit conversion factors}}
\DoxyCodeLine{2017   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: is\textcolor{comment}{  !< The starting i-\/index to work on}}
\DoxyCodeLine{2018   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: ie\textcolor{comment}{  !< The ending i-\/index to work on}}
\DoxyCodeLine{2019   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: js\textcolor{comment}{  !< The starting j-\/index to work on}}
\DoxyCodeLine{2020   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: je\textcolor{comment}{  !< The ending j-\/index to work on}}
\DoxyCodeLine{2021 }
\DoxyCodeLine{2022 \textcolor{comment}{! the linear action of the matrix on (u,v) with bilinear finite elements}}
\DoxyCodeLine{2023 \textcolor{comment}{! as of now everything is passed in so no grid pointers or anything of the sort have to be dereferenced,}}
\DoxyCodeLine{2024 \textcolor{comment}{! but this may change pursuant to conversations with others}}
\DoxyCodeLine{2025 \textcolor{comment}{!}}
\DoxyCodeLine{2026 \textcolor{comment}{! is \& ie are the cells over which the iteration is done; this may change between calls to this subroutine}}
\DoxyCodeLine{2027 \textcolor{comment}{!     in order to make less frequent halo updates}}
\DoxyCodeLine{2028 }
\DoxyCodeLine{2029 \textcolor{comment}{! the linear action of the matrix on (u,v) with bilinear finite elements}}
\DoxyCodeLine{2030 \textcolor{comment}{! Phi has the form}}
\DoxyCodeLine{2031 \textcolor{comment}{! Phi(k,q,i,j) -\/ applies to cell i,j}}
\DoxyCodeLine{2032 }
\DoxyCodeLine{2033     \textcolor{comment}{!  3 -\/ 4}}
\DoxyCodeLine{2034     \textcolor{comment}{!  |   |}}
\DoxyCodeLine{2035     \textcolor{comment}{!  1 -\/ 2}}
\DoxyCodeLine{2036 }
\DoxyCodeLine{2037 \textcolor{comment}{! Phi(2*k-\/1,q,i,j) gives d(Phi\_k)/dx at quadrature point q}}
\DoxyCodeLine{2038 \textcolor{comment}{! Phi(2*k,q,i,j) gives d(Phi\_k)/dy at quadrature point q}}
\DoxyCodeLine{2039 \textcolor{comment}{! Phi\_k is equal to 1 at vertex k, and 0 at vertex l /= k, and bilinear}}
\DoxyCodeLine{2040 }
\DoxyCodeLine{2041 \textcolor{keywordtype}{  real} :: ux, uy, vx, vy \textcolor{comment}{! Components of velocity shears or divergence [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{2042 \textcolor{keywordtype}{  real} :: uq, vq  \textcolor{comment}{! Interpolated velocities [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{2043   \textcolor{keywordtype}{integer} :: iq, jq, iphi, jphi, i, j, ilq, jlq, Itgt, Jtgt}
\DoxyCodeLine{2044 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2)} :: xquad}
\DoxyCodeLine{2045 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2,2)} :: Ucell, Vcell, Hcell, Usub, Vsub}
\DoxyCodeLine{2046 }
\DoxyCodeLine{2047   xquad(1) = .5 * (1-\/sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))}
\DoxyCodeLine{2048 }
\DoxyCodeLine{2049   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2050 }
\DoxyCodeLine{2051       \textcolor{keywordflow}{do} iq=1,2 ; \textcolor{keywordflow}{do} jq=1,2}
\DoxyCodeLine{2052 }
\DoxyCodeLine{2053         uq = u\_shlf(i-\/1,j-\/1) * xquad(3-\/iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2054              u\_shlf(i,j-\/1) * xquad(iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2055              u\_shlf(i-\/1,j) * xquad(3-\/iq) * xquad(jq) + \&}
\DoxyCodeLine{2056              u\_shlf(i,j) * xquad(iq) * xquad(jq)}
\DoxyCodeLine{2057 }
\DoxyCodeLine{2058         vq = v\_shlf(i-\/1,j-\/1) * xquad(3-\/iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2059              v\_shlf(i,j-\/1) * xquad(iq) * xquad(3-\/jq) + \&}
\DoxyCodeLine{2060              v\_shlf(i-\/1,j) * xquad(3-\/iq) * xquad(jq) + \&}
\DoxyCodeLine{2061              v\_shlf(i,j) * xquad(iq) * xquad(jq)}
\DoxyCodeLine{2062 }
\DoxyCodeLine{2063         ux = u\_shlf(i-\/1,j-\/1) * phi(1,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2064              u\_shlf(i,j-\/1) * phi(3,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2065              u\_shlf(i-\/1,j) * phi(5,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2066              u\_shlf(i,j) * phi(7,2*(jq-\/1)+iq,i,j)}
\DoxyCodeLine{2067 }
\DoxyCodeLine{2068         vx = v\_shlf(i-\/1,j-\/1) * phi(1,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2069              v\_shlf(i,j-\/1) * phi(3,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2070              v\_shlf(i-\/1,j) * phi(5,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2071              v\_shlf(i,j) * phi(7,2*(jq-\/1)+iq,i,j)}
\DoxyCodeLine{2072 }
\DoxyCodeLine{2073         uy = u\_shlf(i-\/1,j-\/1) * phi(2,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2074              u\_shlf(i,j-\/1) * phi(4,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2075              u\_shlf(i-\/1,j) * phi(6,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2076              u\_shlf(i,j) * phi(8,2*(jq-\/1)+iq,i,j)}
\DoxyCodeLine{2077 }
\DoxyCodeLine{2078         vy = v\_shlf(i-\/1,j-\/1) * phi(2,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2079              v\_shlf(i,j-\/1) * phi(4,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2080              v\_shlf(i-\/1,j) * phi(6,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2081              v\_shlf(i,j) * phi(8,2*(jq-\/1)+iq,i,j)}
\DoxyCodeLine{2082 }
\DoxyCodeLine{2083         \textcolor{keywordflow}{do} iphi=1,2 ; \textcolor{keywordflow}{do} jphi=1,2 ; itgt = i-\/2+iphi ; jtgt = j-\/2-\/jphi}
\DoxyCodeLine{2084           \textcolor{keywordflow}{if} (umask(itgt,jtgt) == 1) uret(itgt,jtgt) = uret(itgt,jtgt) + 0.25 * ice\_visc(i,j) * \&}
\DoxyCodeLine{2085                                ((4*ux+2*vy) * phi(2*(2*(jphi-\/1)+iphi)-\/1,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2086                                     (uy+vx) * phi(2*(2*(jphi-\/1)+iphi),2*(jq-\/1)+iq,i,j))}
\DoxyCodeLine{2087           \textcolor{keywordflow}{if} (vmask(itgt,jtgt) == 1) vret(itgt,jtgt) = vret(itgt,jtgt) + 0.25 * ice\_visc(i,j) * \&}
\DoxyCodeLine{2088                                    ((uy+vx) * phi(2*(2*(jphi-\/1)+iphi)-\/1,2*(jq-\/1)+iq,i,j) + \&}
\DoxyCodeLine{2089                                 (4*vy+2*ux) * phi(2*(2*(jphi-\/1)+iphi),2*(jq-\/1)+iq,i,j))}
\DoxyCodeLine{2090 }
\DoxyCodeLine{2091           \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2092             ilq = 1 ; \textcolor{keywordflow}{if} (iq == iphi) ilq = 2}
\DoxyCodeLine{2093             jlq = 1 ; \textcolor{keywordflow}{if} (jq == jphi) jlq = 2}
\DoxyCodeLine{2094             \textcolor{keywordflow}{if} (umask(itgt,jtgt) == 1) uret(itgt,jtgt) = uret(itgt,jtgt) +  \&}
\DoxyCodeLine{2095                   0.25 * basal\_trac(i,j) * uq * xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2096             \textcolor{keywordflow}{if} (vmask(itgt,jtgt) == 1) vret(itgt,jtgt) = vret(itgt,jtgt) +  \&}
\DoxyCodeLine{2097                   0.25 * basal\_trac(i,j) * vq * xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2098 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2099 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2100 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2101 }
\DoxyCodeLine{2102       \textcolor{keywordflow}{if} (float\_cond(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2103         ucell(:,:) = u\_shlf(i-\/1:i,j-\/1:j) ; vcell(:,:) = v\_shlf(i-\/1:i,j-\/1:j)}
\DoxyCodeLine{2104         hcell(:,:) = h\_node(i-\/1:i,j-\/1:j)}
\DoxyCodeLine{2105         \textcolor{keyword}{call }cg\_action\_subgrid\_basal(phisub, hcell, ucell, vcell, bathyt(i,j), dens\_ratio, usub, vsub)}
\DoxyCodeLine{2106 }
\DoxyCodeLine{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)}
\DoxyCodeLine{2108         \textcolor{keywordflow}{if} (umask(i-\/1,j) == 1) uret(i-\/1,j) = uret(i-\/1,j) + usub(1,2) * basal\_trac(i,j)}
\DoxyCodeLine{2109         \textcolor{keywordflow}{if} (umask(i,j-\/1) == 1) uret(i,j-\/1) = uret(i,j-\/1) + usub(2,1) * basal\_trac(i,j)}
\DoxyCodeLine{2110         \textcolor{keywordflow}{if} (umask(i,j) == 1)   uret(i,j)   = uret(i,j) + usub(2,2) * basal\_trac(i,j)}
\DoxyCodeLine{2111 }
\DoxyCodeLine{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)}
\DoxyCodeLine{2113         \textcolor{keywordflow}{if} (vmask(i-\/1,j) == 1) vret(i-\/1,j) = vret(i-\/1,j) + vsub(1,2) * basal\_trac(i,j)}
\DoxyCodeLine{2114         \textcolor{keywordflow}{if} (vmask(i,j-\/1) == 1) vret(i,j-\/1) = vret(i,j-\/1) + vsub(2,1) * basal\_trac(i,j)}
\DoxyCodeLine{2115         \textcolor{keywordflow}{if} (vmask(i,j) == 1)   vret(i,j)   = vret(i,j) + vsub(2,2) * basal\_trac(i,j)}
\DoxyCodeLine{2116 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2117 }
\DoxyCodeLine{2118 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\texttt{ in}}  & {\em h} & The ice shelf thickness at nodal (corner) points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in}}  & {\em u} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ in}}  & {\em v} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ in}}  & {\em bathyt} & The depth of ocean bathymetry at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in}}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\texttt{ 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{\texttt{ 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}{0}
\DoxyCodeLine{2123 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, \&}
\DoxyCodeLine{2124                         \textcolor{keywordtype}{intent(in)}    :: Phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}}
\DoxyCodeLine{2125 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}}
\DoxyCodeLine{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 \string~> m].}}
\DoxyCodeLine{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 \string~> m s-\/1]}}
\DoxyCodeLine{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 \string~> m s-\/1]}}
\DoxyCodeLine{2129 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(in)}    :: bathyT\textcolor{comment}{ !< The depth of ocean bathymetry at tracer points [Z \string~> m].}}
\DoxyCodeLine{2130 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}}
\DoxyCodeLine{2131 \textcolor{comment}{                                            !! of seawater [nondim]}}
\DoxyCodeLine{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}}
\DoxyCodeLine{2133 \textcolor{comment}{                                            !! is grounded, or 0 where it is floating [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{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}}
\DoxyCodeLine{2135 \textcolor{comment}{                                            !! is grounded, or 0 where it is floating [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{2136 }
\DoxyCodeLine{2137 \textcolor{keywordtype}{  real}    :: subarea \textcolor{comment}{! The fractional sub-\/cell area [nondim]}}
\DoxyCodeLine{2138 \textcolor{keywordtype}{  real}    :: hloc    \textcolor{comment}{! The local sub-\/cell ice thickness [Z \string~> m]}}
\DoxyCodeLine{2139   \textcolor{keywordtype}{integer} :: nsub, i, j, qx, qy, m, n}
\DoxyCodeLine{2140 }
\DoxyCodeLine{2141   nsub = \textcolor{keyword}{size}(phisub,1)}
\DoxyCodeLine{2142   subarea = 1.0 / (nsub**2)}
\DoxyCodeLine{2143 }
\DoxyCodeLine{2144   \textcolor{keywordflow}{do} n=1,2 ; \textcolor{keywordflow}{do} m=1,2}
\DoxyCodeLine{2145     ucontr(m,n) = 0.0 ; vcontr(m,n) = 0.0}
\DoxyCodeLine{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}
\DoxyCodeLine{2147       hloc = (phisub(i,j,1,1,qx,qy)*h(1,1) + phisub(i,j,2,2,qx,qy)*h(2,2)) + \&}
\DoxyCodeLine{2148              (phisub(i,j,1,2,qx,qy)*h(1,2) + phisub(i,j,2,1,qx,qy)*h(2,1))}
\DoxyCodeLine{2149       \textcolor{keywordflow}{if} (dens\_ratio * hloc -\/ bathyt > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2150         ucontr(m,n) = ucontr(m,n) + subarea * 0.25 * phisub(i,j,m,n,qx,qy) * \&}
\DoxyCodeLine{2151              ((phisub(i,j,1,1,qx,qy) * u(1,1) + phisub(i,j,2,2,qx,qy) * u(2,2)) + \&}
\DoxyCodeLine{2152               (phisub(i,j,1,2,qx,qy) * u(1,2) + phisub(i,j,2,1,qx,qy) * u(2,1)))}
\DoxyCodeLine{2153         vcontr(m,n) = vcontr(m,n) + subarea * 0.25 * phisub(i,j,m,n,qx,qy) * \&}
\DoxyCodeLine{2154              ((phisub(i,j,1,1,qx,qy) * v(1,1) + phisub(i,j,2,2,qx,qy) * v(2,2)) + \&}
\DoxyCodeLine{2155               (phisub(i,j,1,2,qx,qy) * v(1,2) + phisub(i,j,2,1,qx,qy) * v(2,1)))}
\DoxyCodeLine{2156 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2157 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2158 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em phisub} & Quadrature structure weights at subgridscale\\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+node} & The ice shelf thickness at nodal (corner) points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in}}  & {\em bathyt} & The depth of ocean bathymetry at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in}}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2273 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, \&}
\DoxyCodeLine{2274                         \textcolor{keywordtype}{intent(in)} :: Phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}}
\DoxyCodeLine{2275 \textcolor{comment}{                                             !! locations for finite element calculations [nondim]}}
\DoxyCodeLine{2276 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2,2)}, \textcolor{keywordtype}{intent(in)} :: H\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}}
\DoxyCodeLine{2277 \textcolor{comment}{                                             !! points [Z \string~> m].}}
\DoxyCodeLine{2278 \textcolor{keywordtype}{  real},              \textcolor{keywordtype}{intent(in)}    :: bathyT\textcolor{comment}{ !< The depth of ocean bathymetry at tracer points [Z \string~> m].}}
\DoxyCodeLine{2279 \textcolor{keywordtype}{  real},              \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}}
\DoxyCodeLine{2280 \textcolor{comment}{                                                 !! of seawater [nondim]}}
\DoxyCodeLine{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}}
\DoxyCodeLine{2282 \textcolor{comment}{                                                !! is grounded [nondim]}}
\DoxyCodeLine{2283 }
\DoxyCodeLine{2284   \textcolor{comment}{! bathyT = cellwise-\/constant bed elevation}}
\DoxyCodeLine{2285 }
\DoxyCodeLine{2286 \textcolor{keywordtype}{  real}    :: subarea \textcolor{comment}{! The fractional sub-\/cell area [nondim]}}
\DoxyCodeLine{2287 \textcolor{keywordtype}{  real}    :: hloc    \textcolor{comment}{! The local sub-\/region thickness [Z \string~> m]}}
\DoxyCodeLine{2288   \textcolor{keywordtype}{integer} :: nsub, i, j, k, l, qx, qy, m, n}
\DoxyCodeLine{2289 }
\DoxyCodeLine{2290   nsub = \textcolor{keyword}{size}(phisub,1)}
\DoxyCodeLine{2291   subarea = 1.0 / (nsub**2)}
\DoxyCodeLine{2292 }
\DoxyCodeLine{2293   sub\_grnd(:,:) = 0.0}
\DoxyCodeLine{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}
\DoxyCodeLine{2295 }
\DoxyCodeLine{2296     hloc = (phisub(i,j,1,1,qx,qy)*h\_node(1,1) + phisub(i,j,2,2,qx,qy)*h\_node(2,2)) + \&}
\DoxyCodeLine{2297            (phisub(i,j,1,2,qx,qy)*h\_node(1,2) + phisub(i,j,2,1,qx,qy)*h\_node(2,1))}
\DoxyCodeLine{2298 }
\DoxyCodeLine{2299     \textcolor{keywordflow}{if} (dens\_ratio * hloc -\/ bathyt > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2300       sub\_grnd(m,n) = sub\_grnd(m,n) + subarea * 0.25 * phisub(i,j,m,n,qx,qy)**2}
\DoxyCodeLine{2301 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2302 }
\DoxyCodeLine{2303 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{ice\_shelf\_advect()}{ice\_shelf\_advect()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+advect (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & The ice shelf dynamics control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & time step \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{695   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< The ice shelf dynamics control structure}}
\DoxyCodeLine{696   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{697 \textcolor{comment}{                                               !! the ice-\/shelf state}}
\DoxyCodeLine{698   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{699 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< time step [T \string~> s]}}
\DoxyCodeLine{700   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{701 }
\DoxyCodeLine{702 }
\DoxyCodeLine{703 \textcolor{comment}{! 3/8/11 DNG}}
\DoxyCodeLine{704 \textcolor{comment}{!}}
\DoxyCodeLine{705 \textcolor{comment}{!    This subroutine takes the velocity (on the Bgrid) and timesteps h\_t = -\/ div (uh) once.}}
\DoxyCodeLine{706 \textcolor{comment}{!    ADDITIONALLY, it will update the volume of ice in partially-\/filled cells, and update}}
\DoxyCodeLine{707 \textcolor{comment}{!        hmask accordingly}}
\DoxyCodeLine{708 \textcolor{comment}{!}}
\DoxyCodeLine{709 \textcolor{comment}{!    The flux overflows are included here. That is because they will be used to advect 3D scalars}}
\DoxyCodeLine{710 \textcolor{comment}{!    into partial cells}}
\DoxyCodeLine{711 }
\DoxyCodeLine{712 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}   :: h\_after\_uflux, h\_after\_vflux \textcolor{comment}{! Ice thicknesses [Z \string~> m].}}
\DoxyCodeLine{713 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}  :: uh\_ice  \textcolor{comment}{! The accumulated zonal ice volume flux [Z L2 \string~> m3]}}
\DoxyCodeLine{714 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}  :: vh\_ice  \textcolor{comment}{! The accumulated meridional ice volume flux [Z L2 \string~> m3]}}
\DoxyCodeLine{715   \textcolor{keywordtype}{type}(loop\_bounds\_type) :: LB}
\DoxyCodeLine{716   \textcolor{keywordtype}{integer}                           :: isd, ied, jsd, jed, i, j, isc, iec, jsc, jec, stencil}
\DoxyCodeLine{717 }
\DoxyCodeLine{718   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{719   isc = g\%isc ; iec = g\%iec ; jsc = g\%jsc ; jec = g\%jec}
\DoxyCodeLine{720 }
\DoxyCodeLine{721   uh\_ice(:,:) = 0.0}
\DoxyCodeLine{722   vh\_ice(:,:) = 0.0}
\DoxyCodeLine{723 }
\DoxyCodeLine{724   h\_after\_uflux(:,:) = 0.0}
\DoxyCodeLine{725   h\_after\_vflux(:,:) = 0.0}
\DoxyCodeLine{726   \textcolor{comment}{! call MOM\_mesg("MOM\_ice\_shelf.F90: ice\_shelf\_advect called")}}
\DoxyCodeLine{727 }
\DoxyCodeLine{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}}
\DoxyCodeLine{729     iss\%h\_shelf(i,j) = cs\%thickness\_bdry\_val(i,j)}
\DoxyCodeLine{730 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{731 }
\DoxyCodeLine{732   stencil = 2}
\DoxyCodeLine{733   lb\%ish = g\%isc ; lb\%ieh = g\%iec ; lb\%jsh = g\%jsc-\/stencil ; lb\%jeh = g\%jec+stencil}
\DoxyCodeLine{734   \textcolor{keywordflow}{if} (lb\%jsh < jsd) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{735     \textcolor{stringliteral}{"ice\_shelf\_advect:  Halo is too small for the ice thickness advection stencil."})}
\DoxyCodeLine{736 }
\DoxyCodeLine{737   \textcolor{keyword}{call }ice\_shelf\_advect\_thickness\_x(cs, g, lb, time\_step, iss\%hmask, iss\%h\_shelf, h\_after\_uflux, uh\_ice)}
\DoxyCodeLine{738 }
\DoxyCodeLine{739 \textcolor{comment}{!  call enable\_averages(time\_step, Time, CS\%diag)}}
\DoxyCodeLine{740 \textcolor{comment}{!  call pass\_var(h\_after\_uflux, G\%domain)}}
\DoxyCodeLine{741 \textcolor{comment}{!  if (CS\%id\_h\_after\_uflux > 0) call post\_data(CS\%id\_h\_after\_uflux, h\_after\_uflux, CS\%diag)}}
\DoxyCodeLine{742 \textcolor{comment}{!  call disable\_averaging(CS\%diag)}}
\DoxyCodeLine{743 }
\DoxyCodeLine{744   lb\%ish = g\%isc ; lb\%ieh = g\%iec ; lb\%jsh = g\%jsc ; lb\%jeh = g\%jec}
\DoxyCodeLine{745   \textcolor{keyword}{call }ice\_shelf\_advect\_thickness\_y(cs, g, lb, time\_step, iss\%hmask, h\_after\_uflux, h\_after\_vflux, vh\_ice)}
\DoxyCodeLine{746 }
\DoxyCodeLine{747 \textcolor{comment}{!  call enable\_averages(time\_step, Time, CS\%diag)}}
\DoxyCodeLine{748 \textcolor{comment}{!  call pass\_var(h\_after\_vflux, G\%domain)}}
\DoxyCodeLine{749 \textcolor{comment}{!  if (CS\%id\_h\_after\_vflux > 0) call post\_data(CS\%id\_h\_after\_vflux, h\_after\_vflux, CS\%diag)}}
\DoxyCodeLine{750 \textcolor{comment}{!  call disable\_averaging(CS\%diag)}}
\DoxyCodeLine{751 }
\DoxyCodeLine{752   \textcolor{keywordflow}{do} j=jsd,jed}
\DoxyCodeLine{753     \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{754       \textcolor{keywordflow}{if} (iss\%hmask(i,j) == 1) iss\%h\_shelf(i,j) = h\_after\_vflux(i,j)}
\DoxyCodeLine{755 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{756 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{757 }
\DoxyCodeLine{758   \textcolor{keywordflow}{if} (cs\%moving\_shelf\_front) \textcolor{keywordflow}{then}}
\DoxyCodeLine{759     \textcolor{keyword}{call }shelf\_advance\_front(cs, iss, g, iss\%hmask, uh\_ice, vh\_ice)}
\DoxyCodeLine{760     \textcolor{keywordflow}{if} (cs\%min\_thickness\_simple\_calve > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{761       \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, iss\%h\_shelf, iss\%area\_shelf\_h, iss\%hmask, \&}
\DoxyCodeLine{762                                          cs\%min\_thickness\_simple\_calve)}
\DoxyCodeLine{763 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{764     \textcolor{keywordflow}{if} (cs\%calve\_to\_mask) \textcolor{keywordflow}{then}}
\DoxyCodeLine{765       \textcolor{keyword}{call }calve\_to\_mask(g, iss\%h\_shelf, iss\%area\_shelf\_h, iss\%hmask, cs\%calve\_mask)}
\DoxyCodeLine{766 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{767 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{768 }
\DoxyCodeLine{769   \textcolor{comment}{!call enable\_averages(time\_step, Time, CS\%diag)}}
\DoxyCodeLine{770   \textcolor{comment}{!if (CS\%id\_h\_after\_adv > 0) call post\_data(CS\%id\_h\_after\_adv, ISS\%h\_shelf, CS\%diag)}}
\DoxyCodeLine{771   \textcolor{comment}{!call disable\_averaging(CS\%diag)}}
\DoxyCodeLine{772 }
\DoxyCodeLine{773   \textcolor{comment}{!call change\_thickness\_using\_melt(ISS, G, time\_step, fluxes, CS\%density\_ice)}}
\DoxyCodeLine{774 }
\DoxyCodeLine{775   \textcolor{keyword}{call }update\_velocity\_masks(cs, g, iss\%hmask, cs\%umask, cs\%vmask, cs\%u\_face\_mask, cs\%v\_face\_mask)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ in}}  & {\em h0} & The initial ice shelf thicknesses \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{3070   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{3071   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{3072 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T \string~> s].}}
\DoxyCodeLine{3073 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{3074                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{3075 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{3076 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{3077                           \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{ !< The initial ice shelf thicknesses [Z \string~> m].}}
\DoxyCodeLine{3078 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{3079                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_uflux\textcolor{comment}{ !< The ice shelf thicknesses after}}
\DoxyCodeLine{3080 \textcolor{comment}{                                              !! the zonal mass fluxes [Z \string~> m].}}
\DoxyCodeLine{3081 }
\DoxyCodeLine{3082   \textcolor{comment}{! use will be made of ISS\%hmask here -\/ its value at the boundary will be zero, just like uncovered cells}}
\DoxyCodeLine{3083   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}}
\DoxyCodeLine{3084 }
\DoxyCodeLine{3085   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, gjed, gied}
\DoxyCodeLine{3086   \textcolor{keywordtype}{integer} :: i\_off, j\_off}
\DoxyCodeLine{3087   \textcolor{keywordtype}{logical} :: at\_east\_bdry, at\_west\_bdry, one\_off\_west\_bdry, one\_off\_east\_bdry}
\DoxyCodeLine{3088 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(-\/2:2)} :: stencil}
\DoxyCodeLine{3089 \textcolor{keywordtype}{  real} :: u\_face     \textcolor{comment}{! Zonal velocity at a face, positive if out \{L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3090 \textcolor{keywordtype}{  real} :: flux\_diff, phi}
\DoxyCodeLine{3091 }
\DoxyCodeLine{3092   \textcolor{keywordtype}{character (len=1)}        :: debug\_str}
\DoxyCodeLine{3093 }
\DoxyCodeLine{3094 }
\DoxyCodeLine{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}
\DoxyCodeLine{3096   i\_off = g\%idg\_offset ; j\_off = g\%jdg\_offset}
\DoxyCodeLine{3097 }
\DoxyCodeLine{3098   \textcolor{keywordflow}{do} j=jsd+1,jed-\/1}
\DoxyCodeLine{3099     \textcolor{keywordflow}{if} (((j+j\_off) <= g\%domain\%njglobal+g\%domain\%njhalo) .AND. \&}
\DoxyCodeLine{3100         ((j+j\_off) >= g\%domain\%njhalo+1)) \textcolor{keywordflow}{then} \textcolor{comment}{! based on mehmet's code -\/ only if btw north \& south boundaries}}
\DoxyCodeLine{3101 }
\DoxyCodeLine{3102       stencil(:) = -\/1}
\DoxyCodeLine{3103 \textcolor{comment}{!     if (i+i\_off == G\%domain\%nihalo+G\%domain\%nihalo)}}
\DoxyCodeLine{3104       \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{3105 }
\DoxyCodeLine{3106         \textcolor{keywordflow}{if} (((i+i\_off) <= g\%domain\%niglobal+g\%domain\%nihalo) .AND. \&}
\DoxyCodeLine{3107              ((i+i\_off) >= g\%domain\%nihalo+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3108 }
\DoxyCodeLine{3109           \textcolor{keywordflow}{if} (i+i\_off == g\%domain\%nihalo+1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3110             at\_west\_bdry=.true.}
\DoxyCodeLine{3111           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3112             at\_west\_bdry=.false.}
\DoxyCodeLine{3113 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3114 }
\DoxyCodeLine{3115           \textcolor{keywordflow}{if} (i+i\_off == g\%domain\%niglobal+g\%domain\%nihalo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3116             at\_east\_bdry=.true.}
\DoxyCodeLine{3117           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3118             at\_east\_bdry=.false.}
\DoxyCodeLine{3119 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3120 }
\DoxyCodeLine{3121           \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3122 }
\DoxyCodeLine{3123             h\_after\_uflux(i,j) = h0(i,j)}
\DoxyCodeLine{3124 }
\DoxyCodeLine{3125             stencil(:) = h0(i-\/2:i+2,j)  \textcolor{comment}{! fine as long has nx\_halo >= 2}}
\DoxyCodeLine{3126 }
\DoxyCodeLine{3127             flux\_diff = 0}
\DoxyCodeLine{3128 }
\DoxyCodeLine{3129             \textcolor{comment}{! 1ST DO LEFT FACE}}
\DoxyCodeLine{3130 }
\DoxyCodeLine{3131             \textcolor{keywordflow}{if} (cs\%u\_face\_mask(i-\/1,j) == 4.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3132 }
\DoxyCodeLine{3133               flux\_diff = flux\_diff + g\%dyCu(i-\/1,j) * time\_step * cs\%u\_flux\_bdry\_val(i-\/1,j) * \&}
\DoxyCodeLine{3134                                cs\%t\_bdry\_val(i-\/1,j) / g\%areaT(i,j)}
\DoxyCodeLine{3135             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3136 }
\DoxyCodeLine{3137               \textcolor{comment}{! get u-\/velocity at center of left face}}
\DoxyCodeLine{3138               u\_face = 0.5 * (cs\%u\_shelf(i-\/1,j-\/1) + cs\%u\_shelf(i-\/1,j))}
\DoxyCodeLine{3139 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3141 }
\DoxyCodeLine{3142               \textcolor{comment}{! i may not cover all the cases.. but i cover the realistic ones}}
\DoxyCodeLine{3143 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3145                               \textcolor{comment}{! thickness bdry condition, and the stencil contains it}}
\DoxyCodeLine{3146                   flux\_diff = flux\_diff + abs(u\_face) * g\%dyCu(i-\/1,j) * time\_step * stencil(-\/1) / g\%areaT(i,j)}
\DoxyCodeLine{3147 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3149                   phi = slope\_limiter(stencil(-\/1)-\/stencil(-\/2), stencil(0)-\/stencil(-\/1))}
\DoxyCodeLine{3150                   flux\_diff = flux\_diff + abs(u\_face) * g\%dyCu(i-\/1,j)* time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3151                            (stencil(-\/1) -\/ phi * (stencil(-\/1)-\/stencil(0))/2)}
\DoxyCodeLine{3152 }
\DoxyCodeLine{3153                 \textcolor{keywordflow}{else}                            \textcolor{comment}{! h(i-\/1) is valid}}
\DoxyCodeLine{3154                                     \textcolor{comment}{! (o.w. flux would most likely be out of cell)}}
\DoxyCodeLine{3155                                     \textcolor{comment}{!  but h(i-\/2) is not}}
\DoxyCodeLine{3156 }
\DoxyCodeLine{3157                   flux\_diff = flux\_diff + abs(u\_face) * g\%dyCu(i-\/1,j) * time\_step / g\%areaT(i,j) * stencil(-\/1)}
\DoxyCodeLine{3158 }
\DoxyCodeLine{3159 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3160 }
\DoxyCodeLine{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}}
\DoxyCodeLine{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}}
\DoxyCodeLine{3163                   phi = slope\_limiter(stencil(0)-\/stencil(1), stencil(-\/1)-\/stencil(0))}
\DoxyCodeLine{3164                   flux\_diff = flux\_diff -\/ abs(u\_face) * g\%dyCu(i-\/1,j) * time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3165                              (stencil(0) -\/ phi * (stencil(0)-\/stencil(-\/1))/2)}
\DoxyCodeLine{3166 }
\DoxyCodeLine{3167                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{3168                   flux\_diff = flux\_diff -\/ abs(u\_face) * g\%dyCu(i-\/1,j) * time\_step / g\%areaT(i,j) * stencil(0)}
\DoxyCodeLine{3169 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3170 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3171 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3172 }
\DoxyCodeLine{3173             \textcolor{comment}{! NEXT DO RIGHT FACE}}
\DoxyCodeLine{3174 }
\DoxyCodeLine{3175             \textcolor{comment}{! get u-\/velocity at center of eastern face}}
\DoxyCodeLine{3176 }
\DoxyCodeLine{3177             \textcolor{keywordflow}{if} (cs\%u\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3178 }
\DoxyCodeLine{3179               flux\_diff = flux\_diff + g\%dyCu(i,j) * time\_step * cs\%u\_flux\_bdry\_val(i,j) *\&}
\DoxyCodeLine{3180                                cs\%t\_bdry\_val(i+1,j) / g\%areaT(i,j)}
\DoxyCodeLine{3181             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3182 }
\DoxyCodeLine{3183               u\_face = 0.5 * (cs\%u\_shelf(i,j-\/1) + cs\%u\_shelf(i,j))}
\DoxyCodeLine{3184 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3186 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3188                                             \textcolor{comment}{! thickness bdry condition, and the stencil contains it}}
\DoxyCodeLine{3189 }
\DoxyCodeLine{3190                   flux\_diff = flux\_diff + abs(u\_face) * g\%dyCu(i,j) * time\_step * stencil(1) / g\%areaT(i,j)}
\DoxyCodeLine{3191 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3193 }
\DoxyCodeLine{3194                   phi = slope\_limiter(stencil(1)-\/stencil(2), stencil(0)-\/stencil(1))}
\DoxyCodeLine{3195                   flux\_diff = flux\_diff + abs(u\_face) * g\%dyCu(i,j) * time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3196                       (stencil(1) -\/ phi * (stencil(1)-\/stencil(0))/2)}
\DoxyCodeLine{3197 }
\DoxyCodeLine{3198                 \textcolor{keywordflow}{else}                            \textcolor{comment}{! h(i+1) is valid}}
\DoxyCodeLine{3199                                             \textcolor{comment}{! (o.w. flux would most likely be out of cell)}}
\DoxyCodeLine{3200                                             \textcolor{comment}{!  but h(i+2) is not}}
\DoxyCodeLine{3201 }
\DoxyCodeLine{3202                   flux\_diff = flux\_diff + abs(u\_face) * g\%dyCu(i,j) * time\_step / g\%areaT(i,j) * stencil(1)}
\DoxyCodeLine{3203 }
\DoxyCodeLine{3204 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3205 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3207 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3209 }
\DoxyCodeLine{3210                   phi = slope\_limiter(stencil(0)-\/stencil(-\/1), stencil(1)-\/stencil(0))}
\DoxyCodeLine{3211                   flux\_diff = flux\_diff -\/ abs(u\_face) * g\%dyCu(i,j) * time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3212                       (stencil(0) -\/ phi * (stencil(0)-\/stencil(1))/2)}
\DoxyCodeLine{3213 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3215 }
\DoxyCodeLine{3216                   flux\_diff = flux\_diff -\/ abs(u\_face) * g\%dyCu(i,j) * time\_step / g\%areaT(i,j) * stencil(0)}
\DoxyCodeLine{3217 }
\DoxyCodeLine{3218 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3219 }
\DoxyCodeLine{3220 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3221 }
\DoxyCodeLine{3222               h\_after\_uflux(i,j) = h\_after\_uflux(i,j) + flux\_diff}
\DoxyCodeLine{3223 }
\DoxyCodeLine{3224 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3225 }
\DoxyCodeLine{3226 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3227 }
\DoxyCodeLine{3228 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3229 }
\DoxyCodeLine{3230 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! i loop}}
\DoxyCodeLine{3231 }
\DoxyCodeLine{3232 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3233 }
\DoxyCodeLine{3234 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! j loop}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+after\+\_\+uflux} & The ice shelf thicknesses after\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{3239   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{3240   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{3241 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T \string~> s].}}
\DoxyCodeLine{3242 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{3243                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{3244 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{3245 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{3246                           \textcolor{keywordtype}{intent(in)}    :: h\_after\_uflux\textcolor{comment}{ !< The ice shelf thicknesses after}}
\DoxyCodeLine{3247 \textcolor{comment}{                                              !! the zonal mass fluxes [Z \string~> m].}}
\DoxyCodeLine{3248 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{3249                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_vflux\textcolor{comment}{ !< The ice shelf thicknesses after}}
\DoxyCodeLine{3250 \textcolor{comment}{                                              !! the meridional mass fluxes [Z \string~> m].}}
\DoxyCodeLine{3251 }
\DoxyCodeLine{3252   \textcolor{comment}{! use will be made of ISS\%hmask here -\/ its value at the boundary will be zero, just like uncovered cells}}
\DoxyCodeLine{3253   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}}
\DoxyCodeLine{3254 }
\DoxyCodeLine{3255   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, gjed, gied}
\DoxyCodeLine{3256   \textcolor{keywordtype}{integer} :: i\_off, j\_off}
\DoxyCodeLine{3257   \textcolor{keywordtype}{logical} :: at\_north\_bdry, at\_south\_bdry, one\_off\_west\_bdry, one\_off\_east\_bdry}
\DoxyCodeLine{3258 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(-\/2:2)} :: stencil}
\DoxyCodeLine{3259 \textcolor{keywordtype}{  real} :: v\_face     \textcolor{comment}{! Pseudo-\/meridional velocity at a cell face, positive if out \{L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3260 \textcolor{keywordtype}{  real} :: flux\_diff, phi}
\DoxyCodeLine{3261   \textcolor{keywordtype}{character(len=1)}        :: debug\_str}
\DoxyCodeLine{3262 }
\DoxyCodeLine{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}
\DoxyCodeLine{3264   i\_off = g\%idg\_offset ; j\_off = g\%jdg\_offset}
\DoxyCodeLine{3265 }
\DoxyCodeLine{3266   \textcolor{keywordflow}{do} i=isd+2,ied-\/2}
\DoxyCodeLine{3267     \textcolor{keywordflow}{if} (((i+i\_off) <= g\%domain\%niglobal+g\%domain\%nihalo) .AND. \&}
\DoxyCodeLine{3268        ((i+i\_off) >= g\%domain\%nihalo+1)) \textcolor{keywordflow}{then}  \textcolor{comment}{! based on mehmet's code -\/ only if btw east \& west boundaries}}
\DoxyCodeLine{3269 }
\DoxyCodeLine{3270       stencil(:) = -\/1}
\DoxyCodeLine{3271 }
\DoxyCodeLine{3272       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{3273 }
\DoxyCodeLine{3274         \textcolor{keywordflow}{if} (((j+j\_off) <= g\%domain\%njglobal+g\%domain\%njhalo) .AND. \&}
\DoxyCodeLine{3275              ((j+j\_off) >= g\%domain\%njhalo+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3276 }
\DoxyCodeLine{3277           \textcolor{keywordflow}{if} (j+j\_off == g\%domain\%njhalo+1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3278             at\_south\_bdry=.true.}
\DoxyCodeLine{3279           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3280             at\_south\_bdry=.false.}
\DoxyCodeLine{3281 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3282           \textcolor{keywordflow}{if} (j+j\_off == g\%domain\%njglobal+g\%domain\%njhalo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3283             at\_north\_bdry=.true.}
\DoxyCodeLine{3284           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3285             at\_north\_bdry=.false.}
\DoxyCodeLine{3286 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3287 }
\DoxyCodeLine{3288           \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3289             h\_after\_vflux(i,j) = h\_after\_uflux(i,j)}
\DoxyCodeLine{3290 }
\DoxyCodeLine{3291             stencil(:) = h\_after\_uflux(i,j-\/2:j+2)  \textcolor{comment}{! fine as long has ny\_halo >= 2}}
\DoxyCodeLine{3292             flux\_diff = 0}
\DoxyCodeLine{3293 }
\DoxyCodeLine{3294             \textcolor{comment}{! 1ST DO south FACE}}
\DoxyCodeLine{3295 }
\DoxyCodeLine{3296             \textcolor{keywordflow}{if} (cs\%v\_face\_mask(i,j-\/1) == 4.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3297 }
\DoxyCodeLine{3298               flux\_diff = flux\_diff + g\%dxCv(i,j-\/1) * time\_step * cs\%v\_flux\_bdry\_val(i,j-\/1) * \&}
\DoxyCodeLine{3299                                  cs\%t\_bdry\_val(i,j-\/1)/ g\%areaT(i,j)}
\DoxyCodeLine{3300             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3301 }
\DoxyCodeLine{3302               \textcolor{comment}{! get u-\/velocity at center of west face}}
\DoxyCodeLine{3303               v\_face = 0.5 * (cs\%v\_shelf(i-\/1,j-\/1) + cs\%v\_shelf(i,j-\/1))}
\DoxyCodeLine{3304 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3306 }
\DoxyCodeLine{3307                 \textcolor{comment}{! i may not cover all the cases.. but i cover the realistic ones}}
\DoxyCodeLine{3308 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3310                                             \textcolor{comment}{! thickness bdry condition, and the stencil contains it}}
\DoxyCodeLine{3311                   flux\_diff = flux\_diff + abs(v\_face) * g\%dxCv(i,j-\/1) * time\_step * stencil(-\/1) / g\%areaT(i,j)}
\DoxyCodeLine{3312 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3314 }
\DoxyCodeLine{3315                   phi = slope\_limiter(stencil(-\/1)-\/stencil(-\/2), stencil(0)-\/stencil(-\/1))}
\DoxyCodeLine{3316                   flux\_diff = flux\_diff + abs(v\_face) * g\%dxCv(i,j-\/1) * time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3317                       (stencil(-\/1) -\/ phi * (stencil(-\/1)-\/stencil(0))/2)}
\DoxyCodeLine{3318 }
\DoxyCodeLine{3319                 \textcolor{keywordflow}{else}     \textcolor{comment}{! h(j-\/1) is valid}}
\DoxyCodeLine{3320                          \textcolor{comment}{! (o.w. flux would most likely be out of cell)}}
\DoxyCodeLine{3321                          \textcolor{comment}{!  but h(j-\/2) is not}}
\DoxyCodeLine{3322                   flux\_diff = flux\_diff + abs(v\_face) * g\%dxCv(i,j-\/1) * time\_step / g\%areaT(i,j) * stencil(-\/1)}
\DoxyCodeLine{3323 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3324 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3326 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3328                   phi = slope\_limiter(stencil(0)-\/stencil(1), stencil(-\/1)-\/stencil(0))}
\DoxyCodeLine{3329                   flux\_diff = flux\_diff -\/ abs(v\_face) * g\%dxCv(i,j-\/1) * time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3330                       (stencil(0) -\/ phi * (stencil(0)-\/stencil(-\/1))/2)}
\DoxyCodeLine{3331                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{3332                   flux\_diff = flux\_diff -\/ abs(v\_face) * g\%dxCv(i,j-\/1) * time\_step / g\%areaT(i,j) * stencil(0)}
\DoxyCodeLine{3333 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3334 }
\DoxyCodeLine{3335 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3336 }
\DoxyCodeLine{3337 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3338 }
\DoxyCodeLine{3339             \textcolor{comment}{! NEXT DO north FACE}}
\DoxyCodeLine{3340 }
\DoxyCodeLine{3341             \textcolor{keywordflow}{if} (cs\%v\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3342               flux\_diff = flux\_diff + g\%dxCv(i,j) * time\_step * cs\%v\_flux\_bdry\_val(i,j) *\&}
\DoxyCodeLine{3343                                cs\%t\_bdry\_val(i,j+1)/ g\%areaT(i,j)}
\DoxyCodeLine{3344             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3345 }
\DoxyCodeLine{3346             \textcolor{comment}{! get u-\/velocity at center of east face}}
\DoxyCodeLine{3347               v\_face = 0.5 * (cs\%v\_shelf(i-\/1,j) + cs\%v\_shelf(i,j))}
\DoxyCodeLine{3348 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3350 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3352                                             \textcolor{comment}{! thickness bdry condition, and the stencil contains it}}
\DoxyCodeLine{3353                   flux\_diff = flux\_diff + abs(v\_face) * g\%dxCv(i,j) * time\_step * stencil(1) / g\%areaT(i,j)}
\DoxyCodeLine{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}}
\DoxyCodeLine{3355                   phi = slope\_limiter(stencil(1)-\/stencil(2), stencil(0)-\/stencil(1))}
\DoxyCodeLine{3356                   flux\_diff = flux\_diff + abs(v\_face) * g\%dxCv(i,j) * time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3357                       (stencil(1) -\/ phi * (stencil(1)-\/stencil(0))/2)}
\DoxyCodeLine{3358                 \textcolor{keywordflow}{else}     \textcolor{comment}{! h(j+1) is valid}}
\DoxyCodeLine{3359                          \textcolor{comment}{! (o.w. flux would most likely be out of cell)}}
\DoxyCodeLine{3360                          \textcolor{comment}{!  but h(j+2) is not}}
\DoxyCodeLine{3361                   flux\_diff = flux\_diff + abs(v\_face) * g\%dxCv(i,j) * time\_step / g\%areaT(i,j) * stencil(1)}
\DoxyCodeLine{3362 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3363 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3365 }
\DoxyCodeLine{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}}
\DoxyCodeLine{3367                   phi = slope\_limiter(stencil(0)-\/stencil(-\/1), stencil(1)-\/stencil(0))}
\DoxyCodeLine{3368                   flux\_diff = flux\_diff -\/ abs(v\_face) * g\%dxCv(i,j) * time\_step / g\%areaT(i,j) * \&}
\DoxyCodeLine{3369                       (stencil(0) -\/ phi * (stencil(0)-\/stencil(1))/2)}
\DoxyCodeLine{3370                 \textcolor{keywordflow}{else}   \textcolor{comment}{! h(j+1) is valid}}
\DoxyCodeLine{3371                        \textcolor{comment}{! (o.w. flux would most likely be out of cell)}}
\DoxyCodeLine{3372                        \textcolor{comment}{!  but h(j+2) is not}}
\DoxyCodeLine{3373                   flux\_diff = flux\_diff -\/ abs(v\_face) * g\%dxCv(i,j) * time\_step / g\%areaT(i,j) * stencil(0)}
\DoxyCodeLine{3374 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{3375 }
\DoxyCodeLine{3376 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3377 }
\DoxyCodeLine{3378 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3379 }
\DoxyCodeLine{3380             h\_after\_vflux(i,j) = h\_after\_vflux(i,j) + flux\_diff}
\DoxyCodeLine{3381 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3382 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3383 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! j loop}}
\DoxyCodeLine{3384 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3385 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! i loop}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em lb} & Loop bounds structure.\\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\texttt{ in,out}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ in}}  & {\em h0} & The initial ice shelf thicknesses \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in,out}}  & {\em h\+\_\+after\+\_\+uflux} & The ice shelf thicknesses after\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1300   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1301   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1302   \textcolor{keywordtype}{type}(loop\_bounds\_type), \textcolor{keywordtype}{intent(in)}    :: LB\textcolor{comment}{   !< Loop bounds structure.}}
\DoxyCodeLine{1303 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T \string~> s].}}
\DoxyCodeLine{1304 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1305                           \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{1306 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{1307 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1308                           \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{ !< The initial ice shelf thicknesses [Z \string~> m].}}
\DoxyCodeLine{1309 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1310                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_uflux\textcolor{comment}{ !< The ice shelf thicknesses after}}
\DoxyCodeLine{1311 \textcolor{comment}{                                              !! the zonal mass fluxes [Z \string~> m].}}
\DoxyCodeLine{1312 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1313                           \textcolor{keywordtype}{intent(inout)} :: uh\_ice\textcolor{comment}{ !< The accumulated zonal ice volume flux [Z L2 \string~> m3]}}
\DoxyCodeLine{1314 }
\DoxyCodeLine{1315   \textcolor{comment}{! use will be made of ISS\%hmask here -\/ its value at the boundary will be zero, just like uncovered cells}}
\DoxyCodeLine{1316   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}}
\DoxyCodeLine{1317 }
\DoxyCodeLine{1318 }
\DoxyCodeLine{1319   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{1320   \textcolor{keywordtype}{integer} :: ish, ieh, jsh, jeh}
\DoxyCodeLine{1321 \textcolor{keywordtype}{  real} :: u\_face     \textcolor{comment}{! Zonal velocity at a face [L Z-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1322 \textcolor{keywordtype}{  real} :: h\_face     \textcolor{comment}{! Thickness at a face for transport [Z \string~> m]}}
\DoxyCodeLine{1323 \textcolor{keywordtype}{  real} :: slope\_lim  \textcolor{comment}{! The value of the slope limiter, in the range of 0 to 2 [nondim]}}
\DoxyCodeLine{1324 }
\DoxyCodeLine{1325 \textcolor{comment}{!  is = G\%isc-\/2 ; ie = G\%iec+2 ; js = G\%jsc ; je = G\%jec}}
\DoxyCodeLine{1326 \textcolor{comment}{!  isd = G\%isd ; ied = G\%ied ; jsd = G\%jsd ; jed = G\%jed}}
\DoxyCodeLine{1327 \textcolor{comment}{!  i\_off = G\%idg\_offset ; j\_off = G\%jdg\_offset}}
\DoxyCodeLine{1328 }
\DoxyCodeLine{1329   ish = lb\%ish ; ieh = lb\%ieh ; jsh = lb\%jsh ; jeh = lb\%jeh}
\DoxyCodeLine{1330 }
\DoxyCodeLine{1331   \textcolor{comment}{! hmask coded values: 1) fully covered; 2) partly covered -\/ no export; 3) Specified boundary condition}}
\DoxyCodeLine{1332   \textcolor{comment}{! relevant u\_face\_mask coded values: 1) Normal interior point; 4) Specified flux BC}}
\DoxyCodeLine{1333 }
\DoxyCodeLine{1334   \textcolor{keywordflow}{do} j=jsh,jeh ; \textcolor{keywordflow}{do} i=ish-\/1,ieh}
\DoxyCodeLine{1335     \textcolor{keywordflow}{if} (cs\%u\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then} \textcolor{comment}{! The flux itself is a specified boundary condition.}}
\DoxyCodeLine{1336       uh\_ice(i,j) = time\_step * g\%dyCu(i,j) * cs\%u\_flux\_bdry\_val(i,j)}
\DoxyCodeLine{1337     \textcolor{keywordflow}{elseif} ((hmask(i,j)==1) .or. (hmask(i+1,j) == 1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1338       u\_face = 0.5 * (cs\%u\_shelf(i,j-\/1) + cs\%u\_shelf(i,j))}
\DoxyCodeLine{1339       h\_face = 0.0 \textcolor{comment}{! This will apply when the source cell is iceless or not fully ice covered.}}
\DoxyCodeLine{1340 }
\DoxyCodeLine{1341       \textcolor{keywordflow}{if} (u\_face > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1342         \textcolor{keywordflow}{if} (hmask(i,j) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the west}}
\DoxyCodeLine{1343           h\_face = cs\%thickness\_bdry\_val(i,j)}
\DoxyCodeLine{1344         \textcolor{keywordflow}{elseif} (hmask(i,j) == 1) \textcolor{keywordflow}{then} \textcolor{comment}{! There can be eastward flow through this face.}}
\DoxyCodeLine{1345           \textcolor{keywordflow}{if} ((hmask(i-\/1,j) == 1) .and. (hmask(i+1,j) == 1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1346             slope\_lim = slope\_limiter(h0(i,j)-\/h0(i-\/1,j), h0(i+1,j)-\/h0(i,j))}
\DoxyCodeLine{1347             \textcolor{comment}{! This is a 2nd-\/order centered scheme with a slope limiter.  We could try PPM here.}}
\DoxyCodeLine{1348             h\_face = h0(i,j) -\/ slope\_lim * 0.5 * (h0(i,j)-\/h0(i+1,j))}
\DoxyCodeLine{1349           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1350             h\_face = h0(i,j)}
\DoxyCodeLine{1351 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1352 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1353       \textcolor{keywordflow}{else}}
\DoxyCodeLine{1354         \textcolor{keywordflow}{if} (hmask(i+1,j) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the east}}
\DoxyCodeLine{1355           h\_face = cs\%thickness\_bdry\_val(i+1,j)}
\DoxyCodeLine{1356         \textcolor{keywordflow}{elseif} (hmask(i+1,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1357           \textcolor{keywordflow}{if} ((hmask(i,j) == 1) .and. (hmask(i+2,j) == 1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1358             slope\_lim = slope\_limiter(h0(i+1,j)-\/h0(i,j), h0(i+2,j)-\/h0(i+1,j))}
\DoxyCodeLine{1359             h\_face = h0(i+1,j) -\/ slope\_lim * 0.5 * (h0(i+1,j)-\/h0(i,j))}
\DoxyCodeLine{1360           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1361             h\_face = h0(i+1,j)}
\DoxyCodeLine{1362 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1363 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1364 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1365 }
\DoxyCodeLine{1366       uh\_ice(i,j) = time\_step * g\%dyCu(i,j) * u\_face * h\_face}
\DoxyCodeLine{1367     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1368       uh\_ice(i,j) = 0.0}
\DoxyCodeLine{1369 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1370 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1371 }
\DoxyCodeLine{1372   \textcolor{keywordflow}{do} j=jsh,jeh ; \textcolor{keywordflow}{do} i=ish,ieh}
\DoxyCodeLine{1373     \textcolor{keywordflow}{if} (hmask(i,j) /= 3) \&}
\DoxyCodeLine{1374       h\_after\_uflux(i,j) = h0(i,j) + (uh\_ice(i-\/1,j) -\/ uh\_ice(i,j)) * g\%IareaT(i,j)}
\DoxyCodeLine{1375 }
\DoxyCodeLine{1376      \textcolor{comment}{! Update the masks of cells that have gone from no ice to partial ice.}}
\DoxyCodeLine{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}
\DoxyCodeLine{1378 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em lb} & Loop bounds structure.\\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\texttt{ in,out}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ in}}  & {\em h0} & The initial ice shelf thicknesses \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ in,out}}  & {\em h\+\_\+after\+\_\+vflux} & The ice shelf thicknesses after\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1383   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1384   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1385   \textcolor{keywordtype}{type}(loop\_bounds\_type), \textcolor{keywordtype}{intent(in)}    :: LB\textcolor{comment}{ !< Loop bounds structure.}}
\DoxyCodeLine{1386 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T \string~> s].}}
\DoxyCodeLine{1387 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1388                           \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{1389 \textcolor{comment}{                                              !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{1390 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1391                           \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{ !< The initial ice shelf thicknesses [Z \string~> m].}}
\DoxyCodeLine{1392 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1393                           \textcolor{keywordtype}{intent(inout)} :: h\_after\_vflux\textcolor{comment}{ !< The ice shelf thicknesses after}}
\DoxyCodeLine{1394 \textcolor{comment}{                                              !! the meridional mass fluxes [Z \string~> m].}}
\DoxyCodeLine{1395 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1396                           \textcolor{keywordtype}{intent(inout)} :: vh\_ice\textcolor{comment}{ !< The accumulated meridional ice volume flux [Z L2 \string~> m3]}}
\DoxyCodeLine{1397 }
\DoxyCodeLine{1398   \textcolor{comment}{! use will be made of ISS\%hmask here -\/ its value at the boundary will be zero, just like uncovered cells}}
\DoxyCodeLine{1399   \textcolor{comment}{! if there is an input bdry condition, the thickness there will be set in initialization}}
\DoxyCodeLine{1400 }
\DoxyCodeLine{1401 }
\DoxyCodeLine{1402   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{1403   \textcolor{keywordtype}{integer} :: ish, ieh, jsh, jeh}
\DoxyCodeLine{1404 \textcolor{keywordtype}{  real} :: v\_face     \textcolor{comment}{! Pseudo-\/meridional velocity at a face [L Z-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1405 \textcolor{keywordtype}{  real} :: h\_face     \textcolor{comment}{! Thickness at a face for transport [Z \string~> m]}}
\DoxyCodeLine{1406 \textcolor{keywordtype}{  real} :: slope\_lim  \textcolor{comment}{! The value of the slope limiter, in the range of 0 to 2 [nondim]}}
\DoxyCodeLine{1407 }
\DoxyCodeLine{1408   ish = lb\%ish ; ieh = lb\%ieh ; jsh = lb\%jsh ; jeh = lb\%jeh}
\DoxyCodeLine{1409 }
\DoxyCodeLine{1410   \textcolor{comment}{! hmask coded values: 1) fully covered; 2) partly covered -\/ no export; 3) Specified boundary condition}}
\DoxyCodeLine{1411   \textcolor{comment}{! relevant u\_face\_mask coded values: 1) Normal interior point; 4) Specified flux BC}}
\DoxyCodeLine{1412 }
\DoxyCodeLine{1413   \textcolor{keywordflow}{do} j=jsh-\/1,jeh ; \textcolor{keywordflow}{do} i=ish,ieh}
\DoxyCodeLine{1414     \textcolor{keywordflow}{if} (cs\%v\_face\_mask(i,j) == 4.) \textcolor{keywordflow}{then} \textcolor{comment}{! The flux itself is a specified boundary condition.}}
\DoxyCodeLine{1415       vh\_ice(i,j) = time\_step * g\%dxCv(i,j) * cs\%v\_flux\_bdry\_val(i,j)}
\DoxyCodeLine{1416     \textcolor{keywordflow}{elseif} ((hmask(i,j)==1) .or. (hmask(i,j+1) == 1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1417 }
\DoxyCodeLine{1418       v\_face = 0.5 * (cs\%v\_shelf(i-\/1,j) + cs\%v\_shelf(i,j))}
\DoxyCodeLine{1419       h\_face = 0.0 \textcolor{comment}{! This will apply when the source cell is iceless or not fully ice covered.}}
\DoxyCodeLine{1420 }
\DoxyCodeLine{1421       \textcolor{keywordflow}{if} (v\_face > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1422         \textcolor{keywordflow}{if} (hmask(i,j) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the south}}
\DoxyCodeLine{1423           h\_face = cs\%thickness\_bdry\_val(i,j)}
\DoxyCodeLine{1424         \textcolor{keywordflow}{elseif} (hmask(i,j) == 1) \textcolor{keywordflow}{then} \textcolor{comment}{! There can be northtward flow through this face.}}
\DoxyCodeLine{1425           \textcolor{keywordflow}{if} ((hmask(i,j-\/1) == 1) .and. (hmask(i,j+1) == 1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1426             slope\_lim = slope\_limiter(h0(i,j)-\/h0(i,j-\/1), h0(i,j+1)-\/h0(i,j))}
\DoxyCodeLine{1427             \textcolor{comment}{! This is a 2nd-\/order centered scheme with a slope limiter.  We could try PPM here.}}
\DoxyCodeLine{1428             h\_face = h0(i,j) -\/ slope\_lim * 0.5 * (h0(i,j)-\/h0(i,j+1))}
\DoxyCodeLine{1429           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1430             h\_face = h0(i,j)}
\DoxyCodeLine{1431 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1432 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1433       \textcolor{keywordflow}{else}}
\DoxyCodeLine{1434         \textcolor{keywordflow}{if} (hmask(i,j+1) == 3) \textcolor{keywordflow}{then} \textcolor{comment}{! This is a open boundary inflow from the north}}
\DoxyCodeLine{1435           h\_face = cs\%thickness\_bdry\_val(i,j+1)}
\DoxyCodeLine{1436         \textcolor{keywordflow}{elseif} (hmask(i,j+1) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1437           \textcolor{keywordflow}{if} ((hmask(i,j) == 1) .and. (hmask(i,j+2) == 1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1438             slope\_lim = slope\_limiter(h0(i,j+1)-\/h0(i,j), h0(i,j+2)-\/h0(i,j+1))}
\DoxyCodeLine{1439             h\_face = h0(i,j+1) -\/ slope\_lim * 0.5 * (h0(i,j+1)-\/h0(i,j))}
\DoxyCodeLine{1440           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1441             h\_face = h0(i,j+1)}
\DoxyCodeLine{1442 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1443 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1444 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1445 }
\DoxyCodeLine{1446       vh\_ice(i,j) = time\_step * g\%dxCv(i,j) * v\_face * h\_face}
\DoxyCodeLine{1447     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1448       vh\_ice(i,j) = 0.0}
\DoxyCodeLine{1449 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1450 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1451 }
\DoxyCodeLine{1452   \textcolor{keywordflow}{do} j=jsh,jeh ; \textcolor{keywordflow}{do} i=ish,ieh}
\DoxyCodeLine{1453     \textcolor{keywordflow}{if} (hmask(i,j) /= 3) \&}
\DoxyCodeLine{1454       h\_after\_vflux(i,j) = h0(i,j) + (vh\_ice(i,j-\/1) -\/ vh\_ice(i,j)) * g\%IareaT(i,j)}
\DoxyCodeLine{1455 }
\DoxyCodeLine{1456     \textcolor{comment}{! Update the masks of cells that have gone from no ice to partial ice.}}
\DoxyCodeLine{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}
\DoxyCodeLine{1458 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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}{0}
\DoxyCodeLine{2955   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{pointer}   :: CS\textcolor{comment}{ !< A pointer to the ice shelf dynamics control structure}}
\DoxyCodeLine{2956 }
\DoxyCodeLine{2957   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{2958 }
\DoxyCodeLine{2959   \textcolor{keyword}{deallocate}(cs\%u\_shelf, cs\%v\_shelf)}
\DoxyCodeLine{2960   \textcolor{keyword}{deallocate}(cs\%t\_shelf, cs\%tmask)}
\DoxyCodeLine{2961   \textcolor{keyword}{deallocate}(cs\%u\_bdry\_val, cs\%v\_bdry\_val, cs\%t\_bdry\_val)}
\DoxyCodeLine{2962   \textcolor{keyword}{deallocate}(cs\%u\_face\_mask, cs\%v\_face\_mask)}
\DoxyCodeLine{2963   \textcolor{keyword}{deallocate}(cs\%umask, cs\%vmask)}
\DoxyCodeLine{2964 }
\DoxyCodeLine{2965   \textcolor{keyword}{deallocate}(cs\%ice\_visc, cs\%basal\_traction)}
\DoxyCodeLine{2966   \textcolor{keyword}{deallocate}(cs\%OD\_rt, cs\%OD\_av)}
\DoxyCodeLine{2967   \textcolor{keyword}{deallocate}(cs\%ground\_frac, cs\%ground\_frac\_rt)}
\DoxyCodeLine{2968 }
\DoxyCodeLine{2969   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in,out}}  & {\em h\+\_\+shelf} & The ice shelf thickness \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em area\+\_\+shelf\+\_\+h} & The area per cell covered by the ice shelf \mbox{[}L2 $\sim$$>$ m2\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em hmask} & A mask indicating which tracer points are partly or fully covered by an ice-\/shelf \\
\hline
\mbox{\texttt{ in}}  & {\em thickness\+\_\+calve} & The thickness at which to trigger calving \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1655   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1656 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: h\_shelf\textcolor{comment}{ !< The ice shelf thickness [Z \string~> m].}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1658 \textcolor{comment}{                                             !! the ice shelf [L2 \string~> m2].}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1660 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{1661 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: thickness\_calve\textcolor{comment}{ !< The thickness at which to trigger calving [Z \string~> m].}}
\DoxyCodeLine{1662   \textcolor{keywordtype}{integer},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: halo\textcolor{comment}{  !< The number of halo points to use.  If not present,}}
\DoxyCodeLine{1663 \textcolor{comment}{                                                !! work on the entire data domain.}}
\DoxyCodeLine{1664   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1665 }
\DoxyCodeLine{1666   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(halo)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1667     is = g\%isc -\/ halo ; ie = g\%iec + halo ; js = g\%jsc -\/ halo ; je = g\%jec + halo}
\DoxyCodeLine{1668   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1669     is = g\%isd ; ie = g\%ied ; js = g\%jsd ; je = g\%jed}
\DoxyCodeLine{1670 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1671 }
\DoxyCodeLine{1672   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1673 \textcolor{comment}{!    if ((h\_shelf(i,j) < CS\%thickness\_calve) .and. (hmask(i,j) == 1) .and. \&}}
\DoxyCodeLine{1674 \textcolor{comment}{!        (CS\%ground\_frac(i,j) == 0.0)) then}}
\DoxyCodeLine{1675     \textcolor{keywordflow}{if} ((h\_shelf(i,j) < thickness\_calve) .and. (area\_shelf\_h(i,j) > 0.)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1676       h\_shelf(i,j) = 0.0}
\DoxyCodeLine{1677       area\_shelf\_h(i,j) = 0.0}
\DoxyCodeLine{1678       hmask(i,j) = 0.0}
\DoxyCodeLine{1679 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1680 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{ice\_shelf\_solve\_inner()}{ice\_shelf\_solve\_inner()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+solve\+\_\+inner (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ in,out}}  & {\em v\+\_\+shlf} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ in}}  & {\em taudx} & The x-\/direction driving stress \mbox{[}R L3 Z T-\/2 $\sim$$>$ kg m s-\/2\mbox{]}\\
\hline
\mbox{\texttt{ in}}  & {\em taudy} & The y-\/direction driving stress \mbox{[}R L3 Z T-\/2 $\sim$$>$ kg m s-\/2\mbox{]}\\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+node} & The ice shelf thickness at nodal (corner)\\
\hline
\mbox{\texttt{ in}}  & {\em float\+\_\+cond} & An array indicating where the ice\\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ out}}  & {\em conv\+\_\+flag} & A flag indicating whether (1) or not (0) the iterations have converged to the specified tolerance\\
\hline
\mbox{\texttt{ out}}  & {\em iters} & The number of iterations used in the solver.\\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model time\\
\hline
\mbox{\texttt{ in}}  & {\em phi} & The gradients of bilinear basis elements at Gaussian\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1003   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1004   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{1005 \textcolor{comment}{                                           !! the ice-\/shelf state}}
\DoxyCodeLine{1006   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1007   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{1008 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1009                           \textcolor{keywordtype}{intent(inout)} :: u\_shlf\textcolor{comment}{  !< The zonal ice shelf velocity at vertices [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1010 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1011                           \textcolor{keywordtype}{intent(inout)} :: v\_shlf\textcolor{comment}{  !< The meridional ice shelf velocity at vertices [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1012 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1013                           \textcolor{keywordtype}{intent(in)}    :: taudx\textcolor{comment}{ !< The x-\/direction driving stress [R L3 Z T-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{1014 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1015                           \textcolor{keywordtype}{intent(in)}    :: taudy\textcolor{comment}{  !< The y-\/direction driving stress [R L3 Z T-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{1016 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1017                           \textcolor{keywordtype}{intent(in)}    :: H\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}}
\DoxyCodeLine{1018 \textcolor{comment}{                                             !! points [Z \string~> m].}}
\DoxyCodeLine{1019 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1020                           \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}}
\DoxyCodeLine{1021 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}}
\DoxyCodeLine{1022 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1023                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{1024 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{1025   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(out)}   :: conv\_flag\textcolor{comment}{ !< A flag indicating whether (1) or not (0) the}}
\DoxyCodeLine{1026 \textcolor{comment}{                                           !! iterations have converged to the specified tolerance}}
\DoxyCodeLine{1027   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(out)}   :: iters\textcolor{comment}{ !< The number of iterations used in the solver.}}
\DoxyCodeLine{1028   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{1029 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(8,4,SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1030                           \textcolor{keywordtype}{intent(in)}    :: Phi\textcolor{comment}{ !< The gradients of bilinear basis elements at Gaussian}}
\DoxyCodeLine{1031 \textcolor{comment}{                                             !! quadrature points surrounding the cell vertices [L-\/1 \string~> m-\/1].}}
\DoxyCodeLine{1032 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, \&}
\DoxyCodeLine{1033                           \textcolor{keywordtype}{intent(in)}    :: Phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}}
\DoxyCodeLine{1034 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}}
\DoxyCodeLine{1035 \textcolor{comment}{! one linear solve (nonlinear iteration) of the solution for velocity}}
\DoxyCodeLine{1036 }
\DoxyCodeLine{1037 \textcolor{comment}{! in this subroutine:}}
\DoxyCodeLine{1038 \textcolor{comment}{!    boundary contributions are added to taud to get the RHS}}
\DoxyCodeLine{1039 \textcolor{comment}{!    diagonal of matrix is found (for Jacobi precondition)}}
\DoxyCodeLine{1040 \textcolor{comment}{!    CG iteration is carried out for max. iterations or until convergence}}
\DoxyCodeLine{1041 }
\DoxyCodeLine{1042 \textcolor{comment}{! assumed -\/ u, v, taud, visc, basal\_traction are valid on the halo}}
\DoxyCodeLine{1043 }
\DoxyCodeLine{1044 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} ::  \&}
\DoxyCodeLine{1045                         Ru, Rv, \&     \textcolor{comment}{! Residuals in the stress calculations [R L3 Z T-\/2 \string~> m kg s-\/2]}}
\DoxyCodeLine{1046                         Ru\_old, Rv\_old, \& \textcolor{comment}{! Previous values of Ru and Rv [R L3 Z T-\/2 \string~> m kg s-\/2]}}
\DoxyCodeLine{1047                         Zu, Zv, \& \textcolor{comment}{! Contributions to velocity changes [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1048                         Zu\_old, Zv\_old, \& \textcolor{comment}{! Previous values of Zu and Zv [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1049                         DIAGu, DIAGv, \& \textcolor{comment}{! Diagonals with units like Ru/Zu [R L2 Z T-\/1 \string~> kg s-\/1]}}
\DoxyCodeLine{1050                         RHSu, RHSv, \& \textcolor{comment}{! Right hand side of the stress balance [R L3 Z T-\/2 \string~> m kg s-\/2]}}
\DoxyCodeLine{1051                         ubd, vbd, \&   \textcolor{comment}{! Boundary stress contributions [R L3 Z T-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{1052                         Au, Av, \& \textcolor{comment}{! The retarding lateral stress contributions [R L3 Z T-\/2 \string~> kg m s-\/2]}}
\DoxyCodeLine{1053                         Du, Dv, \& \textcolor{comment}{! Velocity changes [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1054                         sum\_vec, sum\_vec\_2}
\DoxyCodeLine{1055 \textcolor{keywordtype}{  real}    :: tol, beta\_k, area, dot\_p1, resid0, cg\_halo}
\DoxyCodeLine{1056 \textcolor{keywordtype}{  real}    :: num, denom}
\DoxyCodeLine{1057 \textcolor{keywordtype}{  real}    :: alpha\_k     \textcolor{comment}{! A scaling factor for iterative corrections [nondim]}}
\DoxyCodeLine{1058 \textcolor{keywordtype}{  real}    :: resid\_scale \textcolor{comment}{! A scaling factor for redimensionalizing the global residuals [m2 L-\/2 \string~> 1]}}
\DoxyCodeLine{1059                          \textcolor{comment}{! [m2 L-\/2 \string~> 1] [R L3 Z T-\/2 \string~> m kg s-\/2]}}
\DoxyCodeLine{1060 \textcolor{keywordtype}{  real}    :: resid2\_scale \textcolor{comment}{! A scaling factor for redimensionalizing the global squared residuals}}
\DoxyCodeLine{1061                          \textcolor{comment}{! [m2 L-\/2 \string~> 1] [R L3 Z T-\/2 \string~> m kg s-\/2]}}
\DoxyCodeLine{1062 \textcolor{keywordtype}{  real}    :: rhoi\_rhow  \textcolor{comment}{! The density of ice divided by a typical water density [nondim]}}
\DoxyCodeLine{1063   \textcolor{keywordtype}{integer} :: iter, i, j, isd, ied, jsd, jed, isc, iec, jsc, jec, is, js, ie, je}
\DoxyCodeLine{1064   \textcolor{keywordtype}{integer} :: Is\_sum, Js\_sum, Ie\_sum, Je\_sum \textcolor{comment}{! Loop bounds for global sums or arrays starting at 1.}}
\DoxyCodeLine{1065   \textcolor{keywordtype}{integer} :: isdq, iedq, jsdq, jedq, iscq, iecq, jscq, jecq, nx\_halo, ny\_halo}
\DoxyCodeLine{1066 }
\DoxyCodeLine{1067   isdq = g\%isdB ; iedq = g\%iedB ; jsdq = g\%jsdB ; jedq = g\%jedB}
\DoxyCodeLine{1068   iscq = g\%iscB ; iecq = g\%iecB ; jscq = g\%jscB ; jecq = g\%jecB}
\DoxyCodeLine{1069   ny\_halo = g\%domain\%njhalo ; nx\_halo = g\%domain\%nihalo}
\DoxyCodeLine{1070   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{1071   isc = g\%isc ; iec = g\%iec ; jsc = g\%jsc ; jec = g\%jec}
\DoxyCodeLine{1072 }
\DoxyCodeLine{1073   rhoi\_rhow = cs\%density\_ice / cs\%density\_ocean\_avg}
\DoxyCodeLine{1074 }
\DoxyCodeLine{1075   zu(:,:) = 0 ; zv(:,:) = 0 ; diagu(:,:) = 0 ; diagv(:,:) = 0}
\DoxyCodeLine{1076   ru(:,:) = 0 ; rv(:,:) = 0 ; au(:,:) = 0 ; av(:,:) = 0}
\DoxyCodeLine{1077   du(:,:) = 0 ; dv(:,:) = 0 ; ubd(:,:) = 0 ; vbd(:,:) = 0}
\DoxyCodeLine{1078   dot\_p1 = 0}
\DoxyCodeLine{1079 }
\DoxyCodeLine{1080   \textcolor{comment}{! Determine the loop limits for sums, bearing in mind that the arrays will be starting at 1.}}
\DoxyCodeLine{1081   is\_sum = g\%isc + (1-\/g\%IsdB)}
\DoxyCodeLine{1082   ie\_sum = g\%iecB + (1-\/g\%IsdB)}
\DoxyCodeLine{1083   \textcolor{comment}{! Include the edge if tile is at the western bdry;  Should add a test to avoid this if reentrant.}}
\DoxyCodeLine{1084   \textcolor{keywordflow}{if} (g\%isc+g\%idg\_offset==g\%isg) is\_sum = g\%IscB + (1-\/g\%IsdB)}
\DoxyCodeLine{1085 }
\DoxyCodeLine{1086   js\_sum = g\%jsc + (1-\/g\%JsdB)}
\DoxyCodeLine{1087   je\_sum = g\%jecB + (1-\/g\%JsdB)}
\DoxyCodeLine{1088   \textcolor{comment}{! Include the edge if tile is at the southern bdry;  Should add a test to avoid this if reentrant.}}
\DoxyCodeLine{1089   \textcolor{keywordflow}{if} (g\%jsc+g\%jdg\_offset==g\%jsg) js\_sum = g\%JscB + (1-\/g\%JsdB)}
\DoxyCodeLine{1090 }
\DoxyCodeLine{1091   \textcolor{keyword}{call }apply\_boundary\_values(cs, iss, g, us, time, phisub, h\_node, cs\%ice\_visc, \&}
\DoxyCodeLine{1092                              cs\%basal\_traction, float\_cond, rhoi\_rhow, ubd, vbd)}
\DoxyCodeLine{1093 }
\DoxyCodeLine{1094   rhsu(:,:) = taudx(:,:) -\/ ubd(:,:)}
\DoxyCodeLine{1095   rhsv(:,:) = taudy(:,:) -\/ vbd(:,:)}
\DoxyCodeLine{1096 }
\DoxyCodeLine{1097   \textcolor{keyword}{call }pass\_vector(rhsu, rhsv, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{1098 }
\DoxyCodeLine{1099   \textcolor{keyword}{call }matrix\_diagonal(cs, g, us, float\_cond, h\_node, cs\%ice\_visc, cs\%basal\_traction, \&}
\DoxyCodeLine{1100                        hmask, rhoi\_rhow, phisub, diagu, diagv)}
\DoxyCodeLine{1101 }
\DoxyCodeLine{1102   \textcolor{keyword}{call }pass\_vector(diagu, diagv, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{1103 }
\DoxyCodeLine{1104   \textcolor{keyword}{call }cg\_action(au, av, u\_shlf, v\_shlf, phi, phisub, cs\%umask, cs\%vmask, hmask, \&}
\DoxyCodeLine{1105                  h\_node, cs\%ice\_visc, float\_cond, g\%bathyT, cs\%basal\_traction, \&}
\DoxyCodeLine{1106                  g, us, isc-\/1, iec+1, jsc-\/1, jec+1, rhoi\_rhow)}
\DoxyCodeLine{1107 }
\DoxyCodeLine{1108   \textcolor{keyword}{call }pass\_vector(au, av, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{1109 }
\DoxyCodeLine{1110   ru(:,:) = (rhsu(:,:) -\/ au(:,:))}
\DoxyCodeLine{1111   rv(:,:) = (rhsv(:,:) -\/ av(:,:))}
\DoxyCodeLine{1112 }
\DoxyCodeLine{1113   resid\_scale = us\%L\_to\_m**2*us\%s\_to\_T*us\%RZ\_to\_kg\_m2*us\%L\_T\_to\_m\_s**2}
\DoxyCodeLine{1114   resid2\_scale = (us\%RZ\_to\_kg\_m2*us\%L\_to\_m*us\%L\_T\_to\_m\_s**2)**2}
\DoxyCodeLine{1115 }
\DoxyCodeLine{1116   sum\_vec(:,:) = 0.0}
\DoxyCodeLine{1117   \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq}
\DoxyCodeLine{1118     \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) sum\_vec(i,j) = resid2\_scale*ru(i,j)**2}
\DoxyCodeLine{1119     \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) sum\_vec(i,j) = sum\_vec(i,j) + resid2\_scale*rv(i,j)**2}
\DoxyCodeLine{1120 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1121 }
\DoxyCodeLine{1122   dot\_p1 = \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}( sum\_vec, js\_sum, ie\_sum, js\_sum, je\_sum )}
\DoxyCodeLine{1123 }
\DoxyCodeLine{1124   resid0 = sqrt(dot\_p1)}
\DoxyCodeLine{1125 }
\DoxyCodeLine{1126   \textcolor{keywordflow}{do} j=jsdq,jedq}
\DoxyCodeLine{1127     \textcolor{keywordflow}{do} i=isdq,iedq}
\DoxyCodeLine{1128       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) zu(i,j) = ru(i,j) / diagu(i,j)}
\DoxyCodeLine{1129       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) zv(i,j) = rv(i,j) / diagv(i,j)}
\DoxyCodeLine{1130 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1131 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1132 }
\DoxyCodeLine{1133   du(:,:) = zu(:,:) ; dv(:,:) = zv(:,:)}
\DoxyCodeLine{1134 }
\DoxyCodeLine{1135   cg\_halo = 3}
\DoxyCodeLine{1136   conv\_flag = 0}
\DoxyCodeLine{1137 }
\DoxyCodeLine{1138   \textcolor{comment}{!!!!!!!!!!!!!!!!!!}}
\DoxyCodeLine{1139   \textcolor{comment}{!!              !!}}
\DoxyCodeLine{1140   \textcolor{comment}{!! MAIN CG LOOP !!}}
\DoxyCodeLine{1141   \textcolor{comment}{!!              !!}}
\DoxyCodeLine{1142   \textcolor{comment}{!!!!!!!!!!!!!!!!!!}}
\DoxyCodeLine{1143 }
\DoxyCodeLine{1144   \textcolor{comment}{! initially, c-\/grid data is valid up to 3 halo nodes out}}
\DoxyCodeLine{1145 }
\DoxyCodeLine{1146   \textcolor{keywordflow}{do} iter = 1,cs\%cg\_max\_iterations}
\DoxyCodeLine{1147 }
\DoxyCodeLine{1148     \textcolor{comment}{! assume asymmetry}}
\DoxyCodeLine{1149     \textcolor{comment}{! thus we can never assume that any arrays are legit more than 3 vertices past}}
\DoxyCodeLine{1150     \textcolor{comment}{! the computational domain -\/ this is their state in the initial iteration}}
\DoxyCodeLine{1151 }
\DoxyCodeLine{1152 }
\DoxyCodeLine{1153     is = isc -\/ cg\_halo ; ie = iecq + cg\_halo}
\DoxyCodeLine{1154     js = jscq -\/ cg\_halo ; je = jecq + cg\_halo}
\DoxyCodeLine{1155 }
\DoxyCodeLine{1156     au(:,:) = 0 ; av(:,:) = 0}
\DoxyCodeLine{1157 }
\DoxyCodeLine{1158     \textcolor{keyword}{call }cg\_action(au, av, du, dv, phi, phisub, cs\%umask, cs\%vmask, hmask, \&}
\DoxyCodeLine{1159                    h\_node, cs\%ice\_visc, float\_cond, g\%bathyT, cs\%basal\_traction, \&}
\DoxyCodeLine{1160                    g, us, is, ie, js, je, rhoi\_rhow)}
\DoxyCodeLine{1161 }
\DoxyCodeLine{1162     \textcolor{comment}{! Au, Av valid region moves in by 1}}
\DoxyCodeLine{1163 }
\DoxyCodeLine{1164 }
\DoxyCodeLine{1165     sum\_vec(:,:) = 0.0 ; sum\_vec\_2(:,:) = 0.0}
\DoxyCodeLine{1166 }
\DoxyCodeLine{1167     \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq}
\DoxyCodeLine{1168       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1169         sum\_vec(i,j) = resid\_scale * zu(i,j) * ru(i,j)}
\DoxyCodeLine{1170         sum\_vec\_2(i,j) = resid\_scale * du(i,j) * au(i,j)}
\DoxyCodeLine{1171 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1172       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1173         sum\_vec(i,j) = sum\_vec(i,j) + resid\_scale * zv(i,j) * rv(i,j)}
\DoxyCodeLine{1174         sum\_vec\_2(i,j) = sum\_vec\_2(i,j) + resid\_scale * dv(i,j) * av(i,j)}
\DoxyCodeLine{1175 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1176 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1177 }
\DoxyCodeLine{1178     alpha\_k = \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}( sum\_vec, is\_sum, ie\_sum, js\_sum, je\_sum ) / \&}
\DoxyCodeLine{1179               \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}( sum\_vec\_2, is\_sum, ie\_sum, js\_sum, je\_sum )}
\DoxyCodeLine{1180 }
\DoxyCodeLine{1181 }
\DoxyCodeLine{1182     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1183       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) u\_shlf(i,j) = u\_shlf(i,j) + alpha\_k * du(i,j)}
\DoxyCodeLine{1184       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) v\_shlf(i,j) = v\_shlf(i,j) + alpha\_k * dv(i,j)}
\DoxyCodeLine{1185 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1186 }
\DoxyCodeLine{1187     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1188       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1189         ru\_old(i,j) = ru(i,j) ; zu\_old(i,j) = zu(i,j)}
\DoxyCodeLine{1190 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1191       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1192         rv\_old(i,j) = rv(i,j) ; zv\_old(i,j) = zv(i,j)}
\DoxyCodeLine{1193 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1194 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1195 }
\DoxyCodeLine{1196 \textcolor{comment}{!    Ru(:,:) = Ru(:,:) -\/ alpha\_k * Au(:,:)}}
\DoxyCodeLine{1197 \textcolor{comment}{!    Rv(:,:) = Rv(:,:) -\/ alpha\_k * Av(:,:)}}
\DoxyCodeLine{1198 }
\DoxyCodeLine{1199     \textcolor{keywordflow}{do} j=jsd,jed}
\DoxyCodeLine{1200       \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1201         \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) ru(i,j) = ru(i,j) -\/ alpha\_k * au(i,j)}
\DoxyCodeLine{1202         \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) rv(i,j) = rv(i,j) -\/ alpha\_k * av(i,j)}
\DoxyCodeLine{1203 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1204 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1205 }
\DoxyCodeLine{1206     \textcolor{keywordflow}{do} j=jsdq,jedq}
\DoxyCodeLine{1207       \textcolor{keywordflow}{do} i=isdq,iedq}
\DoxyCodeLine{1208         \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1209           zu(i,j) = ru(i,j) / diagu(i,j)}
\DoxyCodeLine{1210 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1211         \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1212           zv(i,j) = rv(i,j) / diagv(i,j)}
\DoxyCodeLine{1213 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1214 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1215 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1216 }
\DoxyCodeLine{1217     \textcolor{comment}{! R,u,v,Z valid region moves in by 1}}
\DoxyCodeLine{1218 }
\DoxyCodeLine{1219     \textcolor{comment}{! beta\_k = (Z \(\backslash\)dot R) / (Zold \(\backslash\)dot Rold\}}}
\DoxyCodeLine{1220     sum\_vec(:,:) = 0.0 ; sum\_vec\_2(:,:) = 0.0}
\DoxyCodeLine{1221 }
\DoxyCodeLine{1222     \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq}
\DoxyCodeLine{1223       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1224         sum\_vec(i,j) = resid\_scale * zu(i,j) * ru(i,j)}
\DoxyCodeLine{1225         sum\_vec\_2(i,j) = resid\_scale * zu\_old(i,j) * ru\_old(i,j)}
\DoxyCodeLine{1226 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1227       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1228         sum\_vec(i,j) = sum\_vec(i,j) + resid\_scale * zv(i,j) * rv(i,j)}
\DoxyCodeLine{1229         sum\_vec\_2(i,j) = sum\_vec\_2(i,j) + resid\_scale * zv\_old(i,j) * rv\_old(i,j)}
\DoxyCodeLine{1230 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1231 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1232 }
\DoxyCodeLine{1233     beta\_k = \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}(sum\_vec, is\_sum, ie\_sum, js\_sum, je\_sum ) / \&}
\DoxyCodeLine{1234              \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}(sum\_vec\_2, is\_sum, ie\_sum, js\_sum, je\_sum )}
\DoxyCodeLine{1235 }
\DoxyCodeLine{1236 \textcolor{comment}{!    Du(:,:) = Zu(:,:) + beta\_k * Du(:,:)}}
\DoxyCodeLine{1237 \textcolor{comment}{!    Dv(:,:) = Zv(:,:) + beta\_k * Dv(:,:)}}
\DoxyCodeLine{1238 }
\DoxyCodeLine{1239     \textcolor{keywordflow}{do} j=jsd,jed}
\DoxyCodeLine{1240       \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1241         \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) du(i,j) = zu(i,j) + beta\_k * du(i,j)}
\DoxyCodeLine{1242         \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) dv(i,j) = zv(i,j) + beta\_k * dv(i,j)}
\DoxyCodeLine{1243 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1244 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1245 }
\DoxyCodeLine{1246    \textcolor{comment}{! D valid region moves in by 1}}
\DoxyCodeLine{1247 }
\DoxyCodeLine{1248     sum\_vec(:,:) = 0.0}
\DoxyCodeLine{1249     \textcolor{keywordflow}{do} j=jscq,jecq ; \textcolor{keywordflow}{do} i=iscq,iecq}
\DoxyCodeLine{1250       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) sum\_vec(i,j) = resid2\_scale*ru(i,j)**2}
\DoxyCodeLine{1251       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) sum\_vec(i,j) = sum\_vec(i,j) + resid2\_scale*rv(i,j)**2}
\DoxyCodeLine{1252 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1253 }
\DoxyCodeLine{1254     dot\_p1 = \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}( sum\_vec, is\_sum, ie\_sum, js\_sum, je\_sum )}
\DoxyCodeLine{1255     dot\_p1 = sqrt(dot\_p1)}
\DoxyCodeLine{1256 }
\DoxyCodeLine{1257     \textcolor{keywordflow}{if} (dot\_p1 <= cs\%cg\_tolerance * resid0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1258       iters = iter}
\DoxyCodeLine{1259       conv\_flag = 1}
\DoxyCodeLine{1260       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1261 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1262 }
\DoxyCodeLine{1263     cg\_halo = cg\_halo -\/ 1}
\DoxyCodeLine{1264 }
\DoxyCodeLine{1265     \textcolor{keywordflow}{if} (cg\_halo == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1266       \textcolor{comment}{! pass vectors}}
\DoxyCodeLine{1267       \textcolor{keyword}{call }pass\_vector(du, dv, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{1268       \textcolor{keyword}{call }pass\_vector(u\_shlf, v\_shlf, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{1269       \textcolor{keyword}{call }pass\_vector(ru, rv, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{1270       cg\_halo = 3}
\DoxyCodeLine{1271 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1272 }
\DoxyCodeLine{1273 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end of CG loop}}
\DoxyCodeLine{1274 }
\DoxyCodeLine{1275   \textcolor{keywordflow}{do} j=jsdq,jedq}
\DoxyCodeLine{1276     \textcolor{keywordflow}{do} i=isdq,iedq}
\DoxyCodeLine{1277       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1278         u\_shlf(i,j) = cs\%u\_bdry\_val(i,j)}
\DoxyCodeLine{1279       \textcolor{keywordflow}{elseif} (cs\%umask(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1280         u\_shlf(i,j) = 0}
\DoxyCodeLine{1281 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1282 }
\DoxyCodeLine{1283       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1284         v\_shlf(i,j) = cs\%v\_bdry\_val(i,j)}
\DoxyCodeLine{1285       \textcolor{keywordflow}{elseif} (cs\%vmask(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1286         v\_shlf(i,j) = 0}
\DoxyCodeLine{1287 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1288 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1289 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1290 }
\DoxyCodeLine{1291   \textcolor{keyword}{call }pass\_vector(u\_shlf, v\_shlf, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{1292 }
\DoxyCodeLine{1293   \textcolor{keywordflow}{if} (conv\_flag == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1294     iters = cs\%cg\_max\_iterations}
\DoxyCodeLine{1295 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{ice\_shelf\_solve\_outer()}{ice\_shelf\_solve\_outer()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+solve\+\_\+outer (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & The ice shelf dynamics control structure\\
\hline
\mbox{\texttt{ in}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+shlf} & The zonal ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ in,out}}  & {\em v\+\_\+shlf} & The meridional ice shelf velocity at vertices \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\texttt{ out}}  & {\em iters} & The number of iterations used in the solver.\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{780   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< The ice shelf dynamics control structure}}
\DoxyCodeLine{781   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{782 \textcolor{comment}{                                               !! the ice-\/shelf state}}
\DoxyCodeLine{783   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{784   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{785 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{786                           \textcolor{keywordtype}{intent(inout)} :: u\_shlf\textcolor{comment}{  !< The zonal ice shelf velocity at vertices [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{787 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{788                           \textcolor{keywordtype}{intent(inout)} :: v\_shlf\textcolor{comment}{  !< The meridional ice shelf velocity at vertices [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{789   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(out)}   :: iters\textcolor{comment}{ !< The number of iterations used in the solver.}}
\DoxyCodeLine{790   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{791 }
\DoxyCodeLine{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 \string~> kg m s-\/2]}}
\DoxyCodeLine{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 \string~> kg m s-\/2]}}
\DoxyCodeLine{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 \string~> kg m s-\/2]}}
\DoxyCodeLine{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 \string~> kg m s-\/2]}}
\DoxyCodeLine{796 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: err\_u, err\_v}
\DoxyCodeLine{797 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: u\_last, v\_last \textcolor{comment}{! Previous velocities [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{798 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))} :: H\_node \textcolor{comment}{! Ice shelf thickness at corners [Z \string~> m].}}
\DoxyCodeLine{799 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: float\_cond \textcolor{comment}{! An array indicating where the ice}}
\DoxyCodeLine{800                                                 \textcolor{comment}{! shelf is floating: 0 if floating, 1 if not.}}
\DoxyCodeLine{801   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{802   \textcolor{keywordtype}{integer} :: conv\_flag, i, j, k,l, iter}
\DoxyCodeLine{803   \textcolor{keywordtype}{integer} :: isdq, iedq, jsdq, jedq, isd, ied, jsd, jed, nodefloat, nsub}
\DoxyCodeLine{804 \textcolor{keywordtype}{  real}    :: err\_max, err\_tempu, err\_tempv, err\_init, area, max\_vel, tempu, tempv}
\DoxyCodeLine{805 \textcolor{keywordtype}{  real}    :: rhoi\_rhow \textcolor{comment}{! The density of ice divided by a typical water density [nondim]}}
\DoxyCodeLine{806 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:,:)} :: Phi => null() \textcolor{comment}{! The gradients of bilinear basis elements at Gaussian}}
\DoxyCodeLine{807                                                 \textcolor{comment}{! quadrature points surrounding the cell vertices [m-\/1].}}
\DoxyCodeLine{808 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)} :: Phisub => null() \textcolor{comment}{! Quadrature structure weights at subgridscale}}
\DoxyCodeLine{809                                                 \textcolor{comment}{!  locations for finite element calculations [nondim]}}
\DoxyCodeLine{810   \textcolor{keywordtype}{character(2)}                :: iternum}
\DoxyCodeLine{811   \textcolor{keywordtype}{character(2)}                :: numproc}
\DoxyCodeLine{812 }
\DoxyCodeLine{813   \textcolor{comment}{! for GL interpolation}}
\DoxyCodeLine{814   nsub = cs\%n\_sub\_regularize}
\DoxyCodeLine{815 }
\DoxyCodeLine{816   isdq = g\%isdB ; iedq = g\%iedB ; jsdq = g\%jsdB ; jedq = g\%jedB}
\DoxyCodeLine{817   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{818   rhoi\_rhow = cs\%density\_ice / cs\%density\_ocean\_avg}
\DoxyCodeLine{819 }
\DoxyCodeLine{820   taudx(:,:) = 0.0 ; taudy(:,:) = 0.0}
\DoxyCodeLine{821   u\_bdry\_cont(:,:) = 0.0 ; v\_bdry\_cont(:,:) = 0.0}
\DoxyCodeLine{822   au(:,:) = 0.0 ; av(:,:) = 0.0}
\DoxyCodeLine{823 }
\DoxyCodeLine{824   \textcolor{comment}{! need to make these conditional on GL interpolation}}
\DoxyCodeLine{825   float\_cond(:,:) = 0.0 ; h\_node(:,:) = 0.0}
\DoxyCodeLine{826   \textcolor{keyword}{allocate}(phisub(nsub,nsub,2,2,2,2)) ; phisub(:,:,:,:,:,:) = 0.0}
\DoxyCodeLine{827 }
\DoxyCodeLine{828   \textcolor{keyword}{call }calc\_shelf\_driving\_stress(cs, iss, g, us, taudx, taudy, cs\%OD\_av)}
\DoxyCodeLine{829 }
\DoxyCodeLine{830   \textcolor{comment}{! This is to determine which cells contain the grounding line, the criterion being that the cell}}
\DoxyCodeLine{831   \textcolor{comment}{! is ice-\/covered, with some nodes floating and some grounded flotation condition is estimated by}}
\DoxyCodeLine{832   \textcolor{comment}{! assuming topography is cellwise constant and H is bilinear in a cell; floating where}}
\DoxyCodeLine{833   \textcolor{comment}{! rho\_i/rho\_w * H\_node -\/ D is negative}}
\DoxyCodeLine{834 }
\DoxyCodeLine{835   \textcolor{comment}{! need to make this conditional on GL interp}}
\DoxyCodeLine{836 }
\DoxyCodeLine{837   \textcolor{keywordflow}{if} (cs\%GL\_regularize) \textcolor{keywordflow}{then}}
\DoxyCodeLine{838 }
\DoxyCodeLine{839     \textcolor{keyword}{call }interpolate\_h\_to\_b(g, iss\%h\_shelf, iss\%hmask, h\_node)}
\DoxyCodeLine{840 }
\DoxyCodeLine{841     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{842       nodefloat = 0}
\DoxyCodeLine{843 }
\DoxyCodeLine{844       \textcolor{keywordflow}{do} l=0,1 ; \textcolor{keywordflow}{do} k=0,1}
\DoxyCodeLine{845         \textcolor{keywordflow}{if} ((iss\%hmask(i,j) == 1) .and. \&}
\DoxyCodeLine{846             (rhoi\_rhow * h\_node(i-\/1+k,j-\/1+l) -\/ g\%bathyT(i,j) <= 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{847           nodefloat = nodefloat + 1}
\DoxyCodeLine{848 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{849 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{850       \textcolor{keywordflow}{if} ((nodefloat > 0) .and. (nodefloat < 4)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{851         float\_cond(i,j) = 1.0}
\DoxyCodeLine{852         cs\%ground\_frac(i,j) = 1.0}
\DoxyCodeLine{853 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{854 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{855 }
\DoxyCodeLine{856     \textcolor{keyword}{call }pass\_var(float\_cond, g\%Domain)}
\DoxyCodeLine{857 }
\DoxyCodeLine{858     \textcolor{keyword}{call }bilinear\_shape\_functions\_subgrid(phisub, nsub)}
\DoxyCodeLine{859 }
\DoxyCodeLine{860 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{861 }
\DoxyCodeLine{862   \textcolor{comment}{! must prepare Phi}}
\DoxyCodeLine{863   \textcolor{keyword}{allocate}(phi(1:8,1:4,isd:ied,jsd:jed)) ; phi(:,:,:,:) = 0.0}
\DoxyCodeLine{864 }
\DoxyCodeLine{865   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{866     \textcolor{keyword}{call }bilinear\_shape\_fn\_grid(g, i, j, phi(:,:,i,j))}
\DoxyCodeLine{867 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{868 }
\DoxyCodeLine{869   \textcolor{keyword}{call }calc\_shelf\_visc(cs, iss, g, us, u\_shlf, v\_shlf)}
\DoxyCodeLine{870 }
\DoxyCodeLine{871   \textcolor{keyword}{call }pass\_var(cs\%ice\_visc, g\%domain)}
\DoxyCodeLine{872   \textcolor{keyword}{call }pass\_var(cs\%basal\_traction, g\%domain)}
\DoxyCodeLine{873 }
\DoxyCodeLine{874   \textcolor{comment}{! This makes sure basal stress is only applied when it is supposed to be}}
\DoxyCodeLine{875   \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{876     cs\%basal\_traction(i,j) = cs\%basal\_traction(i,j) * cs\%ground\_frac(i,j)}
\DoxyCodeLine{877 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{878 }
\DoxyCodeLine{879   \textcolor{keyword}{call }apply\_boundary\_values(cs, iss, g, us, time, phisub, h\_node, cs\%ice\_visc, \&}
\DoxyCodeLine{880                              cs\%basal\_traction, float\_cond, rhoi\_rhow, u\_bdry\_cont, v\_bdry\_cont)}
\DoxyCodeLine{881 }
\DoxyCodeLine{882   au(:,:) = 0.0 ; av(:,:) = 0.0}
\DoxyCodeLine{883 }
\DoxyCodeLine{884   \textcolor{keyword}{call }cg\_action(au, av, u\_shlf, v\_shlf, phi, phisub, cs\%umask, cs\%vmask, iss\%hmask, h\_node, \&}
\DoxyCodeLine{885                  cs\%ice\_visc, float\_cond, g\%bathyT, cs\%basal\_traction, \&}
\DoxyCodeLine{886                  g, us, g\%isc-\/1, g\%iec+1, g\%jsc-\/1, g\%jec+1, rhoi\_rhow)}
\DoxyCodeLine{887 }
\DoxyCodeLine{888   \textcolor{keywordflow}{if} (cs\%nonlin\_solve\_err\_mode == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{889     err\_init = 0 ; err\_tempu = 0 ; err\_tempv = 0}
\DoxyCodeLine{890     \textcolor{keywordflow}{do} j=g\%IscB,g\%JecB ; \textcolor{keywordflow}{do} i=g\%IscB,g\%IecB}
\DoxyCodeLine{891       \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{892         err\_tempu = abs(au(i,j) + u\_bdry\_cont(i,j) -\/ taudx(i,j))}
\DoxyCodeLine{893         \textcolor{keywordflow}{if} (err\_tempu >= err\_init) err\_init = err\_tempu}
\DoxyCodeLine{894 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{895       \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{896         err\_tempv = abs(av(i,j) + v\_bdry\_cont(i,j) -\/ taudy(i,j))}
\DoxyCodeLine{897         \textcolor{keywordflow}{if} (err\_tempv >= err\_init) err\_init = err\_tempv}
\DoxyCodeLine{898 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{899 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{900 }
\DoxyCodeLine{901     \textcolor{keyword}{call }max\_across\_pes(err\_init)}
\DoxyCodeLine{902 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{903 }
\DoxyCodeLine{904   u\_last(:,:) = u\_shlf(:,:) ; v\_last(:,:) = v\_shlf(:,:)}
\DoxyCodeLine{905 }
\DoxyCodeLine{906   \textcolor{comment}{!! begin loop}}
\DoxyCodeLine{907 }
\DoxyCodeLine{908   \textcolor{keywordflow}{do} iter=1,100}
\DoxyCodeLine{909 }
\DoxyCodeLine{910     \textcolor{keyword}{call }ice\_shelf\_solve\_inner(cs, iss, g, us, u\_shlf, v\_shlf, taudx, taudy, h\_node, float\_cond, \&}
\DoxyCodeLine{911                                iss\%hmask, conv\_flag, iters, time, phi, phisub)}
\DoxyCodeLine{912 }
\DoxyCodeLine{913     \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{914       \textcolor{keyword}{call }qchksum(u\_shlf, \textcolor{stringliteral}{"u shelf"}, g\%HI, haloshift=2, scale=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{915       \textcolor{keyword}{call }qchksum(v\_shlf, \textcolor{stringliteral}{"v shelf"}, g\%HI, haloshift=2, scale=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{916 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{917 }
\DoxyCodeLine{918     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"ice\_shelf\_solve\_outer: linear solve done in "},iters,\textcolor{stringliteral}{" iterations"}}
\DoxyCodeLine{919     \textcolor{keyword}{call }mom\_mesg(mesg, 5)}
\DoxyCodeLine{920 }
\DoxyCodeLine{921     \textcolor{keyword}{call }calc\_shelf\_visc(cs, iss, g, us, u\_shlf, v\_shlf)}
\DoxyCodeLine{922     \textcolor{keyword}{call }pass\_var(cs\%ice\_visc, g\%domain)}
\DoxyCodeLine{923     \textcolor{keyword}{call }pass\_var(cs\%basal\_traction, g\%domain)}
\DoxyCodeLine{924 }
\DoxyCodeLine{925     \textcolor{comment}{! makes sure basal stress is only applied when it is supposed to be}}
\DoxyCodeLine{926     \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{927       cs\%basal\_traction(i,j) = cs\%basal\_traction(i,j) * cs\%ground\_frac(i,j)}
\DoxyCodeLine{928 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{929 }
\DoxyCodeLine{930     u\_bdry\_cont(:,:) = 0 ; v\_bdry\_cont(:,:) = 0}
\DoxyCodeLine{931 }
\DoxyCodeLine{932     \textcolor{keyword}{call }apply\_boundary\_values(cs, iss, g, us, time, phisub, h\_node, cs\%ice\_visc, \&}
\DoxyCodeLine{933                                cs\%basal\_traction, float\_cond, rhoi\_rhow, u\_bdry\_cont, v\_bdry\_cont)}
\DoxyCodeLine{934 }
\DoxyCodeLine{935     au(:,:) = 0 ; av(:,:) = 0}
\DoxyCodeLine{936 }
\DoxyCodeLine{937     \textcolor{keyword}{call }cg\_action(au, av, u\_shlf, v\_shlf, phi, phisub, cs\%umask, cs\%vmask, iss\%hmask, h\_node, \&}
\DoxyCodeLine{938                    cs\%ice\_visc, float\_cond, g\%bathyT, cs\%basal\_traction, \&}
\DoxyCodeLine{939                    g, us, g\%isc-\/1, g\%iec+1, g\%jsc-\/1, g\%jec+1, rhoi\_rhow)}
\DoxyCodeLine{940 }
\DoxyCodeLine{941     err\_max = 0}
\DoxyCodeLine{942 }
\DoxyCodeLine{943     \textcolor{keywordflow}{if} (cs\%nonlin\_solve\_err\_mode == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{944 }
\DoxyCodeLine{945       \textcolor{keywordflow}{do} j=g\%jscB,g\%jecB ; \textcolor{keywordflow}{do} i=g\%jscB,g\%iecB}
\DoxyCodeLine{946         \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{947           err\_tempu = abs(au(i,j) + u\_bdry\_cont(i,j) -\/ taudx(i,j))}
\DoxyCodeLine{948           \textcolor{keywordflow}{if} (err\_tempu >= err\_max) err\_max = err\_tempu}
\DoxyCodeLine{949 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{950         \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{951           err\_tempv = abs(av(i,j) + v\_bdry\_cont(i,j) -\/ taudy(i,j))}
\DoxyCodeLine{952           \textcolor{keywordflow}{if} (err\_tempv >= err\_max) err\_max = err\_tempv}
\DoxyCodeLine{953 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{954 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{955 }
\DoxyCodeLine{956       \textcolor{keyword}{call }max\_across\_pes(err\_max)}
\DoxyCodeLine{957 }
\DoxyCodeLine{958     \textcolor{keywordflow}{elseif} (cs\%nonlin\_solve\_err\_mode == 2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{959 }
\DoxyCodeLine{960       max\_vel = 0 ; tempu = 0 ; tempv = 0}
\DoxyCodeLine{961       \textcolor{keywordflow}{do} j=g\%jscB,g\%jecB ; \textcolor{keywordflow}{do} i=g\%iscB,g\%iecB}
\DoxyCodeLine{962         \textcolor{keywordflow}{if} (cs\%umask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{963           err\_tempu = abs(u\_last(i,j)-\/u\_shlf(i,j))}
\DoxyCodeLine{964           \textcolor{keywordflow}{if} (err\_tempu >= err\_max) err\_max = err\_tempu}
\DoxyCodeLine{965           tempu = u\_shlf(i,j)}
\DoxyCodeLine{966         \textcolor{keywordflow}{else}}
\DoxyCodeLine{967           tempu = 0.0}
\DoxyCodeLine{968 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{969         \textcolor{keywordflow}{if} (cs\%vmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{970           err\_tempv = max(abs(v\_last(i,j)-\/v\_shlf(i,j)), err\_tempu)}
\DoxyCodeLine{971           \textcolor{keywordflow}{if} (err\_tempv >= err\_max) err\_max = err\_tempv}
\DoxyCodeLine{972           tempv = sqrt(v\_shlf(i,j)**2 + tempu**2)}
\DoxyCodeLine{973 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{974         \textcolor{keywordflow}{if} (tempv >= max\_vel) max\_vel = tempv}
\DoxyCodeLine{975 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{976 }
\DoxyCodeLine{977       u\_last(:,:) = u\_shlf(:,:)}
\DoxyCodeLine{978       v\_last(:,:) = v\_shlf(:,:)}
\DoxyCodeLine{979 }
\DoxyCodeLine{980       \textcolor{keyword}{call }max\_across\_pes(max\_vel)}
\DoxyCodeLine{981       \textcolor{keyword}{call }max\_across\_pes(err\_max)}
\DoxyCodeLine{982       err\_init = max\_vel}
\DoxyCodeLine{983 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{984 }
\DoxyCodeLine{985     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"ice\_shelf\_solve\_outer: nonlinear fractional residual = "}, err\_max/err\_init}
\DoxyCodeLine{986     \textcolor{keyword}{call }mom\_mesg(mesg, 5)}
\DoxyCodeLine{987 }
\DoxyCodeLine{988     \textcolor{keywordflow}{if} (err\_max <= cs\%nonlinear\_tolerance * err\_init) \textcolor{keywordflow}{then}}
\DoxyCodeLine{989       \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"ice\_shelf\_solve\_outer: exiting nonlinear solve after "},iter,\textcolor{stringliteral}{" iterations"}}
\DoxyCodeLine{990       \textcolor{keyword}{call }mom\_mesg(mesg, 5)}
\DoxyCodeLine{991       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{992 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{993 }
\DoxyCodeLine{994 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{995 }
\DoxyCodeLine{996   \textcolor{keyword}{deallocate}(phi)}
\DoxyCodeLine{997   \textcolor{keyword}{deallocate}(phisub)}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{ice\_shelf\_temp()}{ice\_shelf\_temp()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::ice\+\_\+shelf\+\_\+temp (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & A pointer to the ice shelf control structure \\
\hline
\mbox{\texttt{ in}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em melt\+\_\+rate} & basal melt rate \mbox{[}R Z T-\/1 $\sim$$>$ kg m-\/2 s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2976   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{2977   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{2978 \textcolor{comment}{                                               !! the ice-\/shelf state}}
\DoxyCodeLine{2979   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2980   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{2981 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T \string~> s].}}
\DoxyCodeLine{2982 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2983                           \textcolor{keywordtype}{intent(in)}    :: melt\_rate\textcolor{comment}{ !< basal melt rate [R Z T-\/1 \string~> kg m-\/2 s-\/1]}}
\DoxyCodeLine{2984   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{2985 }
\DoxyCodeLine{2986 \textcolor{comment}{! 5/23/12 OVS}}
\DoxyCodeLine{2987 \textcolor{comment}{!    This subroutine takes the velocity (on the Bgrid) and timesteps}}
\DoxyCodeLine{2988 \textcolor{comment}{!      (HT)\_t = -\/ div (uHT) + (adot Tsurf -\/bdot Tbot) once and then calculates T=HT/H}}
\DoxyCodeLine{2989 \textcolor{comment}{!}}
\DoxyCodeLine{2990 \textcolor{comment}{!    The flux overflows are included here. That is because they will be used to advect 3D scalars}}
\DoxyCodeLine{2991 \textcolor{comment}{!    into partial cells}}
\DoxyCodeLine{2992 }
\DoxyCodeLine{2993 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}   :: th\_after\_uflux, th\_after\_vflux, TH}
\DoxyCodeLine{2994   \textcolor{keywordtype}{integer}                           :: isd, ied, jsd, jed, i, j, isc, iec, jsc, jec}
\DoxyCodeLine{2995 \textcolor{keywordtype}{  real} :: Tsurf \textcolor{comment}{! Surface air temperature.  This is hard coded but should be an input argument.}}
\DoxyCodeLine{2996 \textcolor{keywordtype}{  real} :: adot  \textcolor{comment}{! A surface heat exchange coefficient divided by the heat capacity of}}
\DoxyCodeLine{2997                 \textcolor{comment}{! ice [R Z T-\/1 degC-\/1 \string~> kg m-\/2 s-\/1 degC-\/1].}}
\DoxyCodeLine{2998 }
\DoxyCodeLine{2999 }
\DoxyCodeLine{3000   \textcolor{comment}{! For now adot and Tsurf are defined here adot=surf acc 0.1m/yr, Tsurf=-\/20oC, vary them later}}
\DoxyCodeLine{3001   adot = (0.1/(365.0*86400.0))*us\%m\_to\_Z*us\%T\_to\_s * cs\%density\_ice}
\DoxyCodeLine{3002   tsurf = -\/20.0}
\DoxyCodeLine{3003 }
\DoxyCodeLine{3004   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{3005   isc = g\%isc ; iec = g\%iec ; jsc = g\%jsc ; jec = g\%jec}
\DoxyCodeLine{3006 }
\DoxyCodeLine{3007   th\_after\_uflux(:,:) = 0.0}
\DoxyCodeLine{3008   th\_after\_vflux(:,:) = 0.0}
\DoxyCodeLine{3009 }
\DoxyCodeLine{3010   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{3011 \textcolor{comment}{!    if (ISS\%hmask(i,j) > 1) then}}
\DoxyCodeLine{3012     \textcolor{keywordflow}{if} ((iss\%hmask(i,j) == 3) .or. (iss\%hmask(i,j) == -\/2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3013       cs\%t\_shelf(i,j) = cs\%t\_bdry\_val(i,j)}
\DoxyCodeLine{3014 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3015 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3016 }
\DoxyCodeLine{3017   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{3018     \textcolor{comment}{! Convert the averge temperature to a depth integrated temperature.}}
\DoxyCodeLine{3019     th(i,j) = cs\%t\_shelf(i,j)*iss\%h\_shelf(i,j)}
\DoxyCodeLine{3020 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3021 }
\DoxyCodeLine{3022 \textcolor{comment}{!  call enable\_averages(time\_step, Time, CS\%diag)}}
\DoxyCodeLine{3023 \textcolor{comment}{!  call pass\_var(h\_after\_uflux, G\%domain)}}
\DoxyCodeLine{3024 \textcolor{comment}{!  call pass\_var(h\_after\_vflux, G\%domain)}}
\DoxyCodeLine{3025 \textcolor{comment}{!  if (CS\%id\_h\_after\_uflux > 0) call post\_data(CS\%id\_h\_after\_uflux, h\_after\_uflux, CS\%diag)}}
\DoxyCodeLine{3026 \textcolor{comment}{!  if (CS\%id\_h\_after\_vflux > 0) call post\_data(CS\%id\_h\_after\_vflux, h\_after\_vflux, CS\%diag)}}
\DoxyCodeLine{3027 \textcolor{comment}{!  call disable\_averaging(CS\%diag)}}
\DoxyCodeLine{3028 }
\DoxyCodeLine{3029   \textcolor{keyword}{call }ice\_shelf\_advect\_temp\_x(cs, g, time\_step, iss\%hmask, th, th\_after\_uflux)}
\DoxyCodeLine{3030   \textcolor{keyword}{call }ice\_shelf\_advect\_temp\_y(cs, g, time\_step, iss\%hmask, th\_after\_uflux, th\_after\_vflux)}
\DoxyCodeLine{3031 }
\DoxyCodeLine{3032   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{3033     \textcolor{comment}{! Convert the integrated temperature back to the average temperature.}}
\DoxyCodeLine{3034 \textcolor{comment}{!   if ((ISS\%hmask(i,j) == 1) .or. (ISS\%hmask(i,j) == 2)) then}}
\DoxyCodeLine{3035     \textcolor{keywordflow}{if} (iss\%h\_shelf(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3036       cs\%t\_shelf(i,j) = th\_after\_vflux(i,j) / iss\%h\_shelf(i,j)}
\DoxyCodeLine{3037     \textcolor{keywordflow}{else}}
\DoxyCodeLine{3038       cs\%t\_shelf(i,j) = -\/10.0}
\DoxyCodeLine{3039 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3040 \textcolor{comment}{!   endif}}
\DoxyCodeLine{3041 }
\DoxyCodeLine{3042     \textcolor{keywordflow}{if} ((iss\%hmask(i,j) == 1) .or. (iss\%hmask(i,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3043       \textcolor{keywordflow}{if} (iss\%h\_shelf(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3044         cs\%t\_shelf(i,j) = cs\%t\_shelf(i,j) + \&}
\DoxyCodeLine{3045             time\_step*(adot*tsurf -\/ melt\_rate(i,j)*iss\%tfreeze(i,j))/(cs\%density\_ice*iss\%h\_shelf(i,j))}
\DoxyCodeLine{3046       \textcolor{keywordflow}{else}}
\DoxyCodeLine{3047         \textcolor{comment}{! the ice is about to melt away in this case set thickness, area, and mask to zero}}
\DoxyCodeLine{3048         \textcolor{comment}{! NOTE: not mass conservative, should maybe scale salt \& heat flux for this cell}}
\DoxyCodeLine{3049         cs\%t\_shelf(i,j) = -\/10.0}
\DoxyCodeLine{3050         cs\%tmask(i,j) = 0.0}
\DoxyCodeLine{3051 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3052     \textcolor{keywordflow}{elseif} (iss\%hmask(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3053       cs\%t\_shelf(i,j) = -\/10.0}
\DoxyCodeLine{3054     \textcolor{keywordflow}{elseif} ((iss\%hmask(i,j) == 3) .or. (iss\%hmask(i,j) == -\/2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3055       cs\%t\_shelf(i,j) = cs\%t\_bdry\_val(i,j)}
\DoxyCodeLine{3056 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3057 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3058 }
\DoxyCodeLine{3059   \textcolor{keyword}{call }pass\_var(cs\%t\_shelf, g\%domain)}
\DoxyCodeLine{3060   \textcolor{keyword}{call }pass\_var(cs\%tmask, g\%domain)}
\DoxyCodeLine{3061 }
\DoxyCodeLine{3062   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3063     \textcolor{keyword}{call }hchksum(cs\%t\_shelf, \textcolor{stringliteral}{"temp after front"}, g\%HI, haloshift=3)}
\DoxyCodeLine{3064 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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{\texttt{ in,out}}  & {\em cs} & The ice shelf dynamics control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{601   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{  !< The ice shelf dynamics control structure}}
\DoxyCodeLine{602   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{603 \textcolor{comment}{                                               !! the ice-\/shelf state}}
\DoxyCodeLine{604   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{605 \textcolor{keywordtype}{  real} :: ice\_time\_step\_CFL\textcolor{comment}{ !< The maximum permitted timestep based on the ice velocities [T \string~> s].}}
\DoxyCodeLine{606 }
\DoxyCodeLine{607 \textcolor{keywordtype}{  real} :: dt\_local, min\_dt \textcolor{comment}{! These should be the minimum stable timesteps at a CFL of 1 [T \string~> s]}}
\DoxyCodeLine{608 \textcolor{keywordtype}{  real} :: min\_vel          \textcolor{comment}{! A minimal velocity for estimating a timestep [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{609   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{610 }
\DoxyCodeLine{611   min\_dt = 5.0e17*g\%US\%s\_to\_T \textcolor{comment}{! The starting maximum is roughly the lifetime of the universe.}}
\DoxyCodeLine{612   min\_vel = (1.0e-\/12/(365.0*86400.0)) * g\%US\%m\_s\_to\_L\_T}
\DoxyCodeLine{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}}
\DoxyCodeLine{614     dt\_local = 2.0*g\%areaT(i,j) / \&}
\DoxyCodeLine{615        ((g\%dyCu(i,j)  * max(abs(cs\%u\_shelf(i,j)  + cs\%u\_shelf(i,j-\/1)), min\_vel) + \&}
\DoxyCodeLine{616          g\%dyCu(i-\/1,j)* max(abs(cs\%u\_shelf(i-\/1,j)+ cs\%u\_shelf(i-\/1,j-\/1)), min\_vel)) + \&}
\DoxyCodeLine{617         (g\%dxCv(i,j)  * max(abs(cs\%v\_shelf(i,j)  + cs\%v\_shelf(i-\/1,j)), min\_vel) + \&}
\DoxyCodeLine{618          g\%dxCv(i,j-\/1)* max(abs(cs\%v\_shelf(i,j-\/1)+ cs\%v\_shelf(i-\/1,j-\/1)), min\_vel)))}
\DoxyCodeLine{619 }
\DoxyCodeLine{620     min\_dt = min(min\_dt, dt\_local)}
\DoxyCodeLine{621 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{! i-\/ and j-\/ loops}}
\DoxyCodeLine{622 }
\DoxyCodeLine{623   \textcolor{keyword}{call }min\_across\_pes(min\_dt)}
\DoxyCodeLine{624 }
\DoxyCodeLine{625   ice\_time\_step\_cfl = cs\%CFL\_factor * min\_dt}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{init\_boundary\_values()}{init\_boundary\_values()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::init\+\_\+boundary\+\_\+values (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model time\\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ 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{\texttt{ in}}  & {\em input\+\_\+thick} & The ice thickness at boundaries \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1903   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS),\textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1904   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1905   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{1906 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1907                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{1908 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{1909 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: input\_flux\textcolor{comment}{ !< The integrated inward ice thickness flux per}}
\DoxyCodeLine{1910 \textcolor{comment}{                                             !! unit face length [Z L T-\/1 \string~> m2 s-\/1]}}
\DoxyCodeLine{1911 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: input\_thick\textcolor{comment}{ !< The ice thickness at boundaries [Z \string~> m].}}
\DoxyCodeLine{1912   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: new\_sim\textcolor{comment}{ !< If present and false, this run is being restarted}}
\DoxyCodeLine{1913 }
\DoxyCodeLine{1914 \textcolor{comment}{! this will be a per-\/setup function. the boundary values of thickness and velocity}}
\DoxyCodeLine{1915 \textcolor{comment}{! (and possibly other variables) will be updated in this function}}
\DoxyCodeLine{1916 }
\DoxyCodeLine{1917 \textcolor{comment}{! FOR RESTARTING PURPOSES: if grid is not symmetric and the model is restarted, we will}}
\DoxyCodeLine{1918 \textcolor{comment}{!               need to update those velocity points not *technically* in any}}
\DoxyCodeLine{1919 \textcolor{comment}{!               computational domain -\/-\/ if this function gets moves to another module,}}
\DoxyCodeLine{1920 \textcolor{comment}{!               DO NOT TAKE THE RESTARTING BIT WITH IT}}
\DoxyCodeLine{1921   \textcolor{keywordtype}{integer} :: i, j , isd, jsd, ied, jed}
\DoxyCodeLine{1922   \textcolor{keywordtype}{integer} :: gjec, gisc, gjsc, cnt, isc, jsc, iec, jec}
\DoxyCodeLine{1923   \textcolor{keywordtype}{integer} :: i\_off, j\_off}
\DoxyCodeLine{1924 }
\DoxyCodeLine{1925   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{1926   isd = g\%isd ; jsd = g\%jsd ; ied = g\%ied ; jed = g\%jed}
\DoxyCodeLine{1927   i\_off = g\%idg\_offset ; j\_off = g\%jdg\_offset}
\DoxyCodeLine{1928 }
\DoxyCodeLine{1929   \textcolor{comment}{! this loop results in some values being set twice but... eh.}}
\DoxyCodeLine{1930 }
\DoxyCodeLine{1931   \textcolor{keywordflow}{do} j=jsd,jed}
\DoxyCodeLine{1932     \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1933 }
\DoxyCodeLine{1934       \textcolor{keywordflow}{if} (hmask(i,j) == 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1935         cs\%thickness\_bdry\_val(i,j) = input\_thick}
\DoxyCodeLine{1936 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1937 }
\DoxyCodeLine{1938       \textcolor{keywordflow}{if} ((hmask(i,j) == 0) .or. (hmask(i,j) == 1) .or. (hmask(i,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1939         \textcolor{keywordflow}{if} ((i <= iec).and.(i >= isc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1940           \textcolor{keywordflow}{if} (cs\%u\_face\_mask(i-\/1,j) == 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{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) * \&}
\DoxyCodeLine{1942                   1.5 * input\_flux / input\_thick}
\DoxyCodeLine{1943             cs\%u\_bdry\_val(i-\/1,j) = (1 -\/ ((g\%geoLatBu(i-\/1,j) -\/ 0.5*g\%len\_lat)*2./g\%len\_lat)**2) * \&}
\DoxyCodeLine{1944                   1.5 * input\_flux / input\_thick}
\DoxyCodeLine{1945 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1946 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1947 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1948 }
\DoxyCodeLine{1949       \textcolor{keywordflow}{if} (.not.(new\_sim)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1950         \textcolor{keywordflow}{if} (.not. g\%symmetric) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1951           \textcolor{keywordflow}{if} (((i+i\_off) == (g\%domain\%nihalo+1)).and.(cs\%u\_face\_mask(i-\/1,j) == 3)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1952             cs\%u\_shelf(i-\/1,j-\/1) = cs\%u\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{1953             cs\%u\_shelf(i-\/1,j) = cs\%u\_bdry\_val(i-\/1,j)}
\DoxyCodeLine{1954             cs\%v\_shelf(i-\/1,j-\/1) = cs\%v\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{1955             cs\%v\_shelf(i-\/1,j) = cs\%v\_bdry\_val(i-\/1,j)}
\DoxyCodeLine{1956 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1957           \textcolor{keywordflow}{if} (((j+j\_off) == (g\%domain\%njhalo+1)).and.(cs\%v\_face\_mask(i,j-\/1) == 3)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1958             cs\%u\_shelf(i-\/1,j-\/1) = cs\%u\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{1959             cs\%u\_shelf(i,j-\/1) = cs\%u\_bdry\_val(i,j-\/1)}
\DoxyCodeLine{1960             cs\%v\_shelf(i-\/1,j-\/1) = cs\%v\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{1961             cs\%v\_shelf(i,j-\/1) = cs\%v\_bdry\_val(i,j-\/1)}
\DoxyCodeLine{1962 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1963 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1964 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1965 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1966 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{initialize\_diagnostic\_fields()}{initialize\_diagnostic\_fields()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::initialize\+\_\+diagnostic\+\_\+fields (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{564   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{  !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{565   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{566 \textcolor{comment}{                                               !! the ice-\/shelf state}}
\DoxyCodeLine{567   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{568   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A structure containing unit conversion factors}}
\DoxyCodeLine{569   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{570 }
\DoxyCodeLine{571   \textcolor{keywordtype}{integer}         :: i, j, iters, isd, ied, jsd, jed}
\DoxyCodeLine{572 \textcolor{keywordtype}{  real}            :: rhoi\_rhow}
\DoxyCodeLine{573 \textcolor{keywordtype}{  real}            :: OD  \textcolor{comment}{! Depth of open water below the ice shelf [Z \string~> m]}}
\DoxyCodeLine{574   \textcolor{keywordtype}{type}(time\_type) :: dummy\_time}
\DoxyCodeLine{575 }
\DoxyCodeLine{576   rhoi\_rhow = cs\%density\_ice / cs\%density\_ocean\_avg}
\DoxyCodeLine{577   dummy\_time = set\_time(0,0)}
\DoxyCodeLine{578   isd=g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{579 }
\DoxyCodeLine{580   \textcolor{keywordflow}{do} j=jsd,jed}
\DoxyCodeLine{581     \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{582       od = g\%bathyT(i,j) -\/ rhoi\_rhow * iss\%h\_shelf(i,j)}
\DoxyCodeLine{583       \textcolor{keywordflow}{if} (od >= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{584     \textcolor{comment}{! ice thickness does not take up whole ocean column -\/> floating}}
\DoxyCodeLine{585         cs\%OD\_av(i,j) = od}
\DoxyCodeLine{586         cs\%ground\_frac(i,j) = 0.}
\DoxyCodeLine{587       \textcolor{keywordflow}{else}}
\DoxyCodeLine{588         cs\%OD\_av(i,j) = 0.}
\DoxyCodeLine{589         cs\%ground\_frac(i,j) = 1.}
\DoxyCodeLine{590 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{591 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{592 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{593 }
\DoxyCodeLine{594   \textcolor{keyword}{call }ice\_shelf\_solve\_outer(cs, iss, g, us, cs\%u\_shelf, cs\%v\_shelf, iters, dummy\_time)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in,out}}  & {\em time} & The clock that that will indicate the model time \\
\hline
\mbox{\texttt{ 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{\texttt{ in,out}}  & {\em g} & The grid type describing the ice shelf grid. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & A structure that is used to regulate the diagnostic output. \\
\hline
\mbox{\texttt{ in}}  & {\em new\+\_\+sim} & If true this is a new simulation, otherwise has been started from a restart file. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{274   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{275   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer}       :: ocn\_grid\textcolor{comment}{   !< The calling ocean model's horizontal grid structure}}
\DoxyCodeLine{276   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(inout)} :: Time\textcolor{comment}{ !< The clock that that will indicate the model time}}
\DoxyCodeLine{277   \textcolor{keywordtype}{type}(ice\_shelf\_state),   \textcolor{keywordtype}{intent(in)}    :: ISS\textcolor{comment}{  !< A structure with elements that describe}}
\DoxyCodeLine{278 \textcolor{comment}{                                                 !! the ice-\/shelf state}}
\DoxyCodeLine{279   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS),  \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< A pointer to the ice shelf dynamics control structure}}
\DoxyCodeLine{280   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The grid type describing the ice shelf grid.}}
\DoxyCodeLine{281   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A structure containing unit conversion factors}}
\DoxyCodeLine{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.}}
\DoxyCodeLine{283   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: new\_sim\textcolor{comment}{ !< If true this is a new simulation, otherwise}}
\DoxyCodeLine{284 \textcolor{comment}{                                                 !! has been started from a restart file.}}
\DoxyCodeLine{285   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: solo\_ice\_sheet\_in\textcolor{comment}{ !< If present, this indicates whether}}
\DoxyCodeLine{286 \textcolor{comment}{                                                 !! a solo ice-\/sheet driver.}}
\DoxyCodeLine{287 }
\DoxyCodeLine{288   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{289 \textcolor{keywordtype}{  real}    :: Z\_rescale  \textcolor{comment}{! A rescaling factor for heights from the representation in}}
\DoxyCodeLine{290                         \textcolor{comment}{! a restart file to the internal representation in this run.}}
\DoxyCodeLine{291 \textcolor{keywordtype}{  real}    :: vel\_rescale \textcolor{comment}{! A rescaling factor for horizontal velocities from the representation}}
\DoxyCodeLine{292                         \textcolor{comment}{! in a restart file to the internal representation in this run.}}
\DoxyCodeLine{293   \textcolor{comment}{!This include declares and sets the variable "version".}}
\DoxyCodeLine{294 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{295 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=200)} :: config}
\DoxyCodeLine{296   \textcolor{keywordtype}{character(len=200)} :: IC\_file,filename,inputdir}
\DoxyCodeLine{297   \textcolor{keywordtype}{character(len=40)}  :: var\_name}
\DoxyCodeLine{298   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{299   \textcolor{keywordtype}{logical} :: shelf\_mass\_is\_dynamic, override\_shelf\_movement, active\_shelf\_dynamics}
\DoxyCodeLine{300   \textcolor{keywordtype}{logical} :: debug}
\DoxyCodeLine{301   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, Isdq, Iedq, Jsdq, Jedq, iters}
\DoxyCodeLine{302 }
\DoxyCodeLine{303   isdq = g\%isdB ; iedq = g\%iedB ; jsdq = g\%jsdB ; jedq = g\%jedB}
\DoxyCodeLine{304   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{305 }
\DoxyCodeLine{306   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{307     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn.F90, initialize\_ice\_shelf\_dyn: "}// \&}
\DoxyCodeLine{308                           \textcolor{stringliteral}{"called with an associated control structure."})}
\DoxyCodeLine{309     \textcolor{keywordflow}{return}}
\DoxyCodeLine{310 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{311   \textcolor{keywordflow}{if} (cs\%module\_is\_initialized) \textcolor{keywordflow}{then}}
\DoxyCodeLine{312     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn.F90, initialize\_ice\_shelf\_dyn was "}//\&}
\DoxyCodeLine{313              \textcolor{stringliteral}{"called with a control structure that has already been initialized."})}
\DoxyCodeLine{314 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{315   cs\%module\_is\_initialized = .true.}
\DoxyCodeLine{316 }
\DoxyCodeLine{317   cs\%diag => diag \textcolor{comment}{! ; CS\%Time => Time}}
\DoxyCodeLine{318 }
\DoxyCodeLine{319   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{320   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{321   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, debug, default=.false.)}
\DoxyCodeLine{322   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG\_IS"}, cs\%debug, \&}
\DoxyCodeLine{323                  \textcolor{stringliteral}{"If true, write verbose debugging messages for the ice shelf."}, \&}
\DoxyCodeLine{324                  default=debug)}
\DoxyCodeLine{325   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DYNAMIC\_SHELF\_MASS"}, shelf\_mass\_is\_dynamic, \&}
\DoxyCodeLine{326                  \textcolor{stringliteral}{"If true, the ice sheet mass can evolve with time."}, \&}
\DoxyCodeLine{327                  default=.false.)}
\DoxyCodeLine{328   override\_shelf\_movement = .false. ; active\_shelf\_dynamics = .false.}
\DoxyCodeLine{329   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) \textcolor{keywordflow}{then}}
\DoxyCodeLine{330     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OVERRIDE\_SHELF\_MOVEMENT"}, override\_shelf\_movement, \&}
\DoxyCodeLine{331                  \textcolor{stringliteral}{"If true, user provided code specifies the ice-\/shelf "}//\&}
\DoxyCodeLine{332                  \textcolor{stringliteral}{"movement instead of the dynamic ice model."}, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{333     active\_shelf\_dynamics = .not.override\_shelf\_movement}
\DoxyCodeLine{334 }
\DoxyCodeLine{335     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERPOLATE"}, cs\%GL\_regularize, \&}
\DoxyCodeLine{336                  \textcolor{stringliteral}{"If true, regularize the floatation condition at the "}//\&}
\DoxyCodeLine{337                  \textcolor{stringliteral}{"grounding line as in Goldberg Holland Schoof 2009."}, default=.false.)}
\DoxyCodeLine{338     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERP\_SUBGRID\_N"}, cs\%n\_sub\_regularize, \&}
\DoxyCodeLine{339                  \textcolor{stringliteral}{"The number of sub-\/partitions of each cell over which to "}//\&}
\DoxyCodeLine{340                  \textcolor{stringliteral}{"integrate for the interpolated grounding line. Each cell "}//\&}
\DoxyCodeLine{341                  \textcolor{stringliteral}{"is divided into NxN equally-\/sized rectangles, over which the "}//\&}
\DoxyCodeLine{342                  \textcolor{stringliteral}{"basal contribution is integrated by iterative quadrature."}, \&}
\DoxyCodeLine{343                  default=0)}
\DoxyCodeLine{344     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_COUPLE"}, cs\%GL\_couple, \&}
\DoxyCodeLine{345                  \textcolor{stringliteral}{"If true, let the floatation condition be determined by "}//\&}
\DoxyCodeLine{346                  \textcolor{stringliteral}{"ocean column thickness. This means that update\_OD\_ffrac "}//\&}
\DoxyCodeLine{347                  \textcolor{stringliteral}{"will be called.  GL\_REGULARIZE and GL\_COUPLE are exclusive."}, \&}
\DoxyCodeLine{348                  default=.false., do\_not\_log=cs\%GL\_regularize)}
\DoxyCodeLine{349     \textcolor{keywordflow}{if} (cs\%GL\_regularize) cs\%GL\_couple = .false.}
\DoxyCodeLine{350     \textcolor{keywordflow}{if} (cs\%GL\_regularize .and. (cs\%n\_sub\_regularize == 0)) \textcolor{keyword}{call }mom\_error (fatal, \&}
\DoxyCodeLine{351       \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERP\_SUBGRID\_N must be a positive integer if GL regularization is used"})}
\DoxyCodeLine{352     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_CFL\_FACTOR"}, cs\%CFL\_factor, \&}
\DoxyCodeLine{353                  \textcolor{stringliteral}{"A factor used to limit timestep as CFL\_FACTOR * min (\(\backslash\)Delta x / u). "}//\&}
\DoxyCodeLine{354                  \textcolor{stringliteral}{"This is only used with an ice-\/only model."}, default=0.25)}
\DoxyCodeLine{355 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{356   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs\%density\_ocean\_avg, \&}
\DoxyCodeLine{357                  \textcolor{stringliteral}{"avg ocean density used in floatation cond"}, \&}
\DoxyCodeLine{358                  units=\textcolor{stringliteral}{"kg m-\/3"}, default=1035., scale=us\%kg\_m3\_to\_R)}
\DoxyCodeLine{359   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{360     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_VELOCITY\_TIMESTEP"}, cs\%velocity\_update\_time\_step, \&}
\DoxyCodeLine{361                  \textcolor{stringliteral}{"seconds between ice velocity calcs"}, units=\textcolor{stringliteral}{"s"}, scale=us\%s\_to\_T, \&}
\DoxyCodeLine{362                  fail\_if\_missing=.true.)}
\DoxyCodeLine{363     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs\%g\_Earth, \&}
\DoxyCodeLine{364                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, \&}
\DoxyCodeLine{365                  units=\textcolor{stringliteral}{"m s-\/2"}, default = 9.80, scale=us\%m\_s\_to\_L\_T**2*us\%Z\_to\_m)}
\DoxyCodeLine{366 }
\DoxyCodeLine{367     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"A\_GLEN\_ISOTHERM"}, cs\%A\_glen\_isothermal, \&}
\DoxyCodeLine{368                  \textcolor{stringliteral}{"Ice viscosity parameter in Glen's Law"}, \&}
\DoxyCodeLine{369                  units=\textcolor{stringliteral}{"Pa-\/3 yr-\/1"}, default=9.461e-\/18, scale=1.0/(365.0*86400.0))}
\DoxyCodeLine{370                  \textcolor{comment}{! This default is equivalent to 3.0001e-\/25 Pa-\/3 s-\/1, appropriate at about -\/10 C.}}
\DoxyCodeLine{371     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GLEN\_EXPONENT"}, cs\%n\_glen, \&}
\DoxyCodeLine{372                  \textcolor{stringliteral}{"nonlinearity exponent in Glen's Law"}, \&}
\DoxyCodeLine{373                   units=\textcolor{stringliteral}{"none"}, default=3.)}
\DoxyCodeLine{374     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_STRAIN\_RATE\_GLEN"}, cs\%eps\_glen\_min, \&}
\DoxyCodeLine{375                  \textcolor{stringliteral}{"min. strain rate to avoid infinite Glen's law viscosity"}, \&}
\DoxyCodeLine{376                  units=\textcolor{stringliteral}{"a-\/1"}, default=1.e-\/12, scale=us\%T\_to\_s/(365.0*86400.0))}
\DoxyCodeLine{377     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BASAL\_FRICTION\_EXP"}, cs\%n\_basal\_fric, \&}
\DoxyCodeLine{378                  \textcolor{stringliteral}{"Exponent in sliding law \(\backslash\)tau\_b = C u\string^(n\_basal\_fric)"}, \&}
\DoxyCodeLine{379                  units=\textcolor{stringliteral}{"none"}, fail\_if\_missing=.true.)}
\DoxyCodeLine{380     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BASAL\_FRICTION\_COEFF"}, cs\%C\_basal\_friction, \&}
\DoxyCodeLine{381                  \textcolor{stringliteral}{"Coefficient in sliding law \(\backslash\)tau\_b = C u\string^(n\_basal\_fric)"}, \&}
\DoxyCodeLine{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), \&}
\DoxyCodeLine{383                  fail\_if\_missing=.true.)}
\DoxyCodeLine{384     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSITY\_ICE"}, cs\%density\_ice, \&}
\DoxyCodeLine{385                  \textcolor{stringliteral}{"A typical density of ice."}, units=\textcolor{stringliteral}{"kg m-\/3"}, default=917.0, scale=us\%kg\_m3\_to\_R)}
\DoxyCodeLine{386     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONJUGATE\_GRADIENT\_TOLERANCE"}, cs\%cg\_tolerance, \&}
\DoxyCodeLine{387                 \textcolor{stringliteral}{"tolerance in CG solver, relative to initial residual"}, default=1.e-\/6)}
\DoxyCodeLine{388     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_NONLINEAR\_TOLERANCE"}, cs\%nonlinear\_tolerance, \&}
\DoxyCodeLine{389                 \textcolor{stringliteral}{"nonlin tolerance in iterative velocity solve"},default=1.e-\/6)}
\DoxyCodeLine{390     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONJUGATE\_GRADIENT\_MAXIT"}, cs\%cg\_max\_iterations, \&}
\DoxyCodeLine{391                 \textcolor{stringliteral}{"max iteratiions in CG solver"}, default=2000)}
\DoxyCodeLine{392     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"THRESH\_FLOAT\_COL\_DEPTH"}, cs\%thresh\_float\_col\_depth, \&}
\DoxyCodeLine{393                 \textcolor{stringliteral}{"min ocean thickness to consider ice *floating*; "}//\&}
\DoxyCodeLine{394                 \textcolor{stringliteral}{"will only be important with use of tides"}, \&}
\DoxyCodeLine{395                 units=\textcolor{stringliteral}{"m"}, default=1.e-\/3, scale=us\%m\_to\_Z)}
\DoxyCodeLine{396     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"NONLIN\_SOLVE\_ERR\_MODE"}, cs\%nonlin\_solve\_err\_mode, \&}
\DoxyCodeLine{397                 \textcolor{stringliteral}{"Choose whether nonlin error in vel solve is based on nonlinear "}//\&}
\DoxyCodeLine{398                 \textcolor{stringliteral}{"residual (1) or relative change since last iteration (2)"}, default=1)}
\DoxyCodeLine{399 }
\DoxyCodeLine{400     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_MOVING\_FRONT"}, cs\%moving\_shelf\_front, \&}
\DoxyCodeLine{401                  \textcolor{stringliteral}{"Specify whether to advance shelf front (and calve)."}, \&}
\DoxyCodeLine{402                  default=.true.)}
\DoxyCodeLine{403     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CALVE\_TO\_MASK"}, cs\%calve\_to\_mask, \&}
\DoxyCodeLine{404                  \textcolor{stringliteral}{"If true, do not allow an ice shelf where prohibited by a mask."}, \&}
\DoxyCodeLine{405                  default=.false.)}
\DoxyCodeLine{406 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{407   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_THICKNESS\_SIMPLE\_CALVE"}, cs\%min\_thickness\_simple\_calve, \&}
\DoxyCodeLine{408                  \textcolor{stringliteral}{"Min thickness rule for the VERY simple calving law"},\&}
\DoxyCodeLine{409                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us\%m\_to\_Z)}
\DoxyCodeLine{410 }
\DoxyCodeLine{411   \textcolor{comment}{! Allocate memory in the ice shelf dynamics control structure that was not}}
\DoxyCodeLine{412   \textcolor{comment}{! previously allocated for registration for restarts.}}
\DoxyCodeLine{413   \textcolor{comment}{! OVS vertically integrated Temperature}}
\DoxyCodeLine{414 }
\DoxyCodeLine{415   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{416     \textcolor{comment}{! DNG}}
\DoxyCodeLine{417     \textcolor{keyword}{allocate}( cs\%u\_bdry\_val(isdq:iedq,jsdq:jedq) ) ; cs\%u\_bdry\_val(:,:) = 0.0}
\DoxyCodeLine{418     \textcolor{keyword}{allocate}( cs\%v\_bdry\_val(isdq:iedq,jsdq:jedq) ) ; cs\%v\_bdry\_val(:,:) = 0.0}
\DoxyCodeLine{419     \textcolor{keyword}{allocate}( cs\%t\_bdry\_val(isd:ied,jsd:jed) )   ; cs\%t\_bdry\_val(:,:) = -\/15.0}
\DoxyCodeLine{420     \textcolor{keyword}{allocate}( cs\%h\_bdry\_val(isd:ied,jsd:jed) ) ; cs\%h\_bdry\_val(:,:) = 0.0}
\DoxyCodeLine{421     \textcolor{keyword}{allocate}( cs\%thickness\_bdry\_val(isd:ied,jsd:jed) ) ; cs\%thickness\_bdry\_val(:,:) = 0.0}
\DoxyCodeLine{422     \textcolor{keyword}{allocate}( cs\%u\_face\_mask(isdq:iedq,jsd:jed) ) ; cs\%u\_face\_mask(:,:) = 0.0}
\DoxyCodeLine{423     \textcolor{keyword}{allocate}( cs\%v\_face\_mask(isd:ied,jsdq:jedq) ) ; cs\%v\_face\_mask(:,:) = 0.0}
\DoxyCodeLine{424     \textcolor{keyword}{allocate}( cs\%u\_face\_mask\_bdry(isdq:iedq,jsd:jed) ) ; cs\%u\_face\_mask\_bdry(:,:) = -\/2.0}
\DoxyCodeLine{425     \textcolor{keyword}{allocate}( cs\%v\_face\_mask\_bdry(isd:ied,jsdq:jedq) ) ; cs\%v\_face\_mask\_bdry(:,:) = -\/2.0}
\DoxyCodeLine{426     \textcolor{keyword}{allocate}( cs\%u\_flux\_bdry\_val(isdq:iedq,jsd:jed) ) ; cs\%u\_flux\_bdry\_val(:,:) = 0.0}
\DoxyCodeLine{427     \textcolor{keyword}{allocate}( cs\%v\_flux\_bdry\_val(isd:ied,jsdq:jedq) ) ; cs\%v\_flux\_bdry\_val(:,:) = 0.0}
\DoxyCodeLine{428     \textcolor{keyword}{allocate}( cs\%umask(isdq:iedq,jsdq:jedq) ) ; cs\%umask(:,:) = -\/1.0}
\DoxyCodeLine{429     \textcolor{keyword}{allocate}( cs\%vmask(isdq:iedq,jsdq:jedq) ) ; cs\%vmask(:,:) = -\/1.0}
\DoxyCodeLine{430     \textcolor{keyword}{allocate}( cs\%tmask(isdq:iedq,jsdq:jedq) ) ; cs\%tmask(:,:) = -\/1.0}
\DoxyCodeLine{431 }
\DoxyCodeLine{432     cs\%OD\_rt\_counter = 0}
\DoxyCodeLine{433     \textcolor{keyword}{allocate}( cs\%OD\_rt(isd:ied,jsd:jed) ) ; cs\%OD\_rt(:,:) = 0.0}
\DoxyCodeLine{434     \textcolor{keyword}{allocate}( cs\%ground\_frac\_rt(isd:ied,jsd:jed) ) ; cs\%ground\_frac\_rt(:,:) = 0.0}
\DoxyCodeLine{435 }
\DoxyCodeLine{436     \textcolor{keywordflow}{if} (cs\%calve\_to\_mask) \textcolor{keywordflow}{then}}
\DoxyCodeLine{437       \textcolor{keyword}{allocate}( cs\%calve\_mask(isd:ied,jsd:jed) ) ; cs\%calve\_mask(:,:) = 0.0}
\DoxyCodeLine{438 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{439 }
\DoxyCodeLine{440     cs\%elapsed\_velocity\_time = 0.0}
\DoxyCodeLine{441 }
\DoxyCodeLine{442     \textcolor{keyword}{call }update\_velocity\_masks(cs, g, iss\%hmask, cs\%umask, cs\%vmask, cs\%u\_face\_mask, cs\%v\_face\_mask)}
\DoxyCodeLine{443 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{444 }
\DoxyCodeLine{445   \textcolor{comment}{! Take additional initialization steps, for example of dependent variables.}}
\DoxyCodeLine{446   \textcolor{keywordflow}{if} (active\_shelf\_dynamics .and. .not.new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{447     \textcolor{keywordflow}{if} ((us\%m\_to\_Z\_restart /= 0.0) .and. (us\%m\_to\_Z\_restart /= us\%m\_to\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{448       z\_rescale = us\%m\_to\_Z / us\%m\_to\_Z\_restart}
\DoxyCodeLine{449       \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{450         cs\%OD\_av(i,j) = z\_rescale * cs\%OD\_av(i,j)}
\DoxyCodeLine{451 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{452 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{453 }
\DoxyCodeLine{454     \textcolor{keywordflow}{if} ((us\%m\_to\_L\_restart*us\%s\_to\_T\_restart /= 0.0) .and. \&}
\DoxyCodeLine{455         (us\%m\_to\_L\_restart /= us\%m\_s\_to\_L\_T*us\%s\_to\_T\_restart)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{456       vel\_rescale = us\%m\_s\_to\_L\_T*us\%s\_to\_T\_restart / us\%m\_to\_L\_restart}
\DoxyCodeLine{457       \textcolor{keywordflow}{do} j=g\%jsc-\/1,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc-\/1,g\%iec}
\DoxyCodeLine{458         cs\%u\_shelf(i,j) = vel\_rescale * cs\%u\_shelf(i,j)}
\DoxyCodeLine{459         cs\%v\_shelf(i,j) = vel\_rescale * cs\%v\_shelf(i,j)}
\DoxyCodeLine{460 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{461 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{462 }
\DoxyCodeLine{463     \textcolor{comment}{! this is unfortunately necessary; if grid is not symmetric the boundary values}}
\DoxyCodeLine{464     \textcolor{comment}{!  of u and v are otherwise not set till the end of the first linear solve, and so}}
\DoxyCodeLine{465     \textcolor{comment}{!  viscosity is not calculated correctly.}}
\DoxyCodeLine{466     \textcolor{comment}{! This has to occur after init\_boundary\_values or some of the arrays on the}}
\DoxyCodeLine{467     \textcolor{comment}{! right hand side have not been set up yet.}}
\DoxyCodeLine{468     \textcolor{keywordflow}{if} (.not. g\%symmetric) \textcolor{keywordflow}{then}}
\DoxyCodeLine{469       \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{470         \textcolor{keywordflow}{if} (((i+g\%idg\_offset) == (g\%domain\%nihalo+1)).and.(cs\%u\_face\_mask(i-\/1,j) == 3)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{471           cs\%u\_shelf(i-\/1,j-\/1) = cs\%u\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{472           cs\%u\_shelf(i-\/1,j) = cs\%u\_bdry\_val(i-\/1,j)}
\DoxyCodeLine{473           cs\%v\_shelf(i-\/1,j-\/1) = cs\%v\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{474           cs\%v\_shelf(i-\/1,j) = cs\%v\_bdry\_val(i-\/1,j)}
\DoxyCodeLine{475 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{476         \textcolor{keywordflow}{if} (((j+g\%jdg\_offset) == (g\%domain\%njhalo+1)).and.(cs\%v\_face\_mask(i,j-\/1) == 3)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{477           cs\%u\_shelf(i-\/1,j-\/1) = cs\%u\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{478           cs\%u\_shelf(i,j-\/1) = cs\%u\_bdry\_val(i,j-\/1)}
\DoxyCodeLine{479           cs\%v\_shelf(i-\/1,j-\/1) = cs\%v\_bdry\_val(i-\/1,j-\/1)}
\DoxyCodeLine{480           cs\%v\_shelf(i,j-\/1) = cs\%v\_bdry\_val(i,j-\/1)}
\DoxyCodeLine{481 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{482 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{483 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{484 }
\DoxyCodeLine{485     \textcolor{keyword}{call }pass\_var(cs\%OD\_av,g\%domain)}
\DoxyCodeLine{486     \textcolor{keyword}{call }pass\_var(cs\%ground\_frac,g\%domain)}
\DoxyCodeLine{487     \textcolor{keyword}{call }pass\_var(cs\%ice\_visc,g\%domain)}
\DoxyCodeLine{488     \textcolor{keyword}{call }pass\_var(cs\%basal\_traction, g\%domain)}
\DoxyCodeLine{489     \textcolor{keyword}{call }pass\_vector(cs\%u\_shelf, cs\%v\_shelf, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{490 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{491 }
\DoxyCodeLine{492   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{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.}}
\DoxyCodeLine{494     \textcolor{keywordflow}{if} (cs\%calve\_to\_mask) \textcolor{keywordflow}{then}}
\DoxyCodeLine{495       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  MOM\_ice\_shelf.F90, initialize\_ice\_shelf: reading calving\_mask"})}
\DoxyCodeLine{496 }
\DoxyCodeLine{497       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{498       inputdir = slasher(inputdir)}
\DoxyCodeLine{499       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CALVING\_MASK\_FILE"}, ic\_file, \&}
\DoxyCodeLine{500                    \textcolor{stringliteral}{"The file with a mask for where calving might occur."}, \&}
\DoxyCodeLine{501                    default=\textcolor{stringliteral}{"ice\_shelf\_h.nc"})}
\DoxyCodeLine{502       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CALVING\_MASK\_VARNAME"}, var\_name, \&}
\DoxyCodeLine{503                    \textcolor{stringliteral}{"The variable to use in masking calving."}, \&}
\DoxyCodeLine{504                    default=\textcolor{stringliteral}{"area\_shelf\_h"})}
\DoxyCodeLine{505 }
\DoxyCodeLine{506       filename = trim(inputdir)//trim(ic\_file)}
\DoxyCodeLine{507       \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/CALVING\_MASK\_FILE"}, filename)}
\DoxyCodeLine{508       \textcolor{keywordflow}{if} (.not.file\_exists(filename, g\%Domain)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{509          \textcolor{stringliteral}{" calving mask file: Unable to open "}//trim(filename))}
\DoxyCodeLine{510 }
\DoxyCodeLine{511       \textcolor{keyword}{call }mom\_read\_data(filename,trim(var\_name),cs\%calve\_mask,g\%Domain)}
\DoxyCodeLine{512       \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{513         \textcolor{keywordflow}{if} (cs\%calve\_mask(i,j) > 0.0) cs\%calve\_mask(i,j) = 1.0}
\DoxyCodeLine{514 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{515       \textcolor{keyword}{call }pass\_var(cs\%calve\_mask,g\%domain)}
\DoxyCodeLine{516 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{517 }
\DoxyCodeLine{518 \textcolor{comment}{!    call init\_boundary\_values(CS, G, time, ISS\%hmask, CS\%input\_flux, CS\%input\_thickness, new\_sim)}}
\DoxyCodeLine{519 }
\DoxyCodeLine{520     \textcolor{keywordflow}{if} (new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{521       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: initialize ice velocity."})}
\DoxyCodeLine{522       \textcolor{keyword}{call }update\_od\_ffrac\_uncoupled(cs, g, iss\%h\_shelf(:,:))}
\DoxyCodeLine{523       \textcolor{keyword}{call }ice\_shelf\_solve\_outer(cs, iss, g, us, cs\%u\_shelf, cs\%v\_shelf, iters, time)}
\DoxyCodeLine{524 }
\DoxyCodeLine{525       \textcolor{keywordflow}{if} (cs\%id\_u\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_u\_shelf, cs\%u\_shelf, cs\%diag)}
\DoxyCodeLine{526       \textcolor{keywordflow}{if} (cs\%id\_v\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_v\_shelf, cs\%v\_shelf,cs\%diag)}
\DoxyCodeLine{527 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{528 }
\DoxyCodeLine{529   \textcolor{comment}{! Register diagnostics.}}
\DoxyCodeLine{530     cs\%id\_u\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'u\_shelf'},cs\%diag\%axesCu1, time, \&}
\DoxyCodeLine{531        \textcolor{stringliteral}{'x-\/velocity of ice'}, \textcolor{stringliteral}{'m yr-\/1'}, conversion=365.0*86400.0*us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{532     cs\%id\_v\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'v\_shelf'},cs\%diag\%axesCv1, time, \&}
\DoxyCodeLine{533        \textcolor{stringliteral}{'y-\/velocity of ice'}, \textcolor{stringliteral}{'m yr-\/1'}, conversion=365.0*86400.0*us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{534     cs\%id\_u\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'u\_mask'},cs\%diag\%axesCu1, time, \&}
\DoxyCodeLine{535        \textcolor{stringliteral}{'mask for u-\/nodes'}, \textcolor{stringliteral}{'none'})}
\DoxyCodeLine{536     cs\%id\_v\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'v\_mask'},cs\%diag\%axesCv1, time, \&}
\DoxyCodeLine{537        \textcolor{stringliteral}{'mask for v-\/nodes'}, \textcolor{stringliteral}{'none'})}
\DoxyCodeLine{538 \textcolor{comment}{!    CS\%id\_surf\_elev = register\_diag\_field('ocean\_model','ice\_surf',CS\%diag\%axesT1, Time, \&}}
\DoxyCodeLine{539 \textcolor{comment}{!       'ice surf elev', 'm')}}
\DoxyCodeLine{540     cs\%id\_ground\_frac = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'ice\_ground\_frac'},cs\%diag\%axesT1, time, \&}
\DoxyCodeLine{541        \textcolor{stringliteral}{'fraction of cell that is grounded'}, \textcolor{stringliteral}{'none'})}
\DoxyCodeLine{542     cs\%id\_col\_thick = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'col\_thick'},cs\%diag\%axesT1, time, \&}
\DoxyCodeLine{543        \textcolor{stringliteral}{'ocean column thickness passed to ice model'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{544     cs\%id\_OD\_av = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'OD\_av'},cs\%diag\%axesT1, time, \&}
\DoxyCodeLine{545        \textcolor{stringliteral}{'intermediate ocean column thickness passed to ice model'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{546     \textcolor{comment}{!CS\%id\_h\_after\_uflux = register\_diag\_field('ocean\_model','h\_after\_uflux',CS\%diag\%axesh1, Time, \&}}
\DoxyCodeLine{547     \textcolor{comment}{!   'thickness after u flux ', 'none')}}
\DoxyCodeLine{548     \textcolor{comment}{!CS\%id\_h\_after\_vflux = register\_diag\_field('ocean\_model','h\_after\_vflux',CS\%diag\%axesh1, Time, \&}}
\DoxyCodeLine{549     \textcolor{comment}{!   'thickness after v flux ', 'none')}}
\DoxyCodeLine{550     \textcolor{comment}{!CS\%id\_h\_after\_adv = register\_diag\_field('ocean\_model','h\_after\_adv',CS\%diag\%axesh1, Time, \&}}
\DoxyCodeLine{551     \textcolor{comment}{!   'thickness after front adv ', 'none')}}
\DoxyCodeLine{552 }
\DoxyCodeLine{553 \textcolor{comment}{!!! OVS vertically integrated temperature}}
\DoxyCodeLine{554     cs\%id\_t\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'t\_shelf'},cs\%diag\%axesT1, time, \&}
\DoxyCodeLine{555        \textcolor{stringliteral}{'T of ice'}, \textcolor{stringliteral}{'oC'})}
\DoxyCodeLine{556     cs\%id\_t\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'tmask'},cs\%diag\%axesT1, time, \&}
\DoxyCodeLine{557        \textcolor{stringliteral}{'mask for T-\/nodes'}, \textcolor{stringliteral}{'none'})}
\DoxyCodeLine{558 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+shelf} & The ice shelf thickness at tracer points \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2911   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2912 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2913                          \textcolor{keywordtype}{intent(in)}    :: h\_shelf\textcolor{comment}{ !< The ice shelf thickness at tracer points [Z \string~> m].}}
\DoxyCodeLine{2914 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2915                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{2916 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{2917 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2918                          \textcolor{keywordtype}{intent(inout)} :: H\_node\textcolor{comment}{ !< The ice shelf thickness at nodal (corner)}}
\DoxyCodeLine{2919 \textcolor{comment}{                                             !! points [Z \string~> m].}}
\DoxyCodeLine{2920 }
\DoxyCodeLine{2921   \textcolor{keywordtype}{integer} :: i, j, isc, iec, jsc, jec, num\_h, k, l}
\DoxyCodeLine{2922 \textcolor{keywordtype}{  real}    :: summ}
\DoxyCodeLine{2923 }
\DoxyCodeLine{2924   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{2925 }
\DoxyCodeLine{2926   h\_node(:,:) = 0.0}
\DoxyCodeLine{2927 }
\DoxyCodeLine{2928   \textcolor{comment}{! H\_node is node-\/centered; average over all cells that share that node}}
\DoxyCodeLine{2929   \textcolor{comment}{! if no (active) cells share the node then its value there is irrelevant}}
\DoxyCodeLine{2930 }
\DoxyCodeLine{2931   \textcolor{keywordflow}{do} j=jsc-\/1,jec}
\DoxyCodeLine{2932     \textcolor{keywordflow}{do} i=isc-\/1,iec}
\DoxyCodeLine{2933       summ = 0.0}
\DoxyCodeLine{2934       num\_h = 0}
\DoxyCodeLine{2935       \textcolor{keywordflow}{do} k=0,1}
\DoxyCodeLine{2936         \textcolor{keywordflow}{do} l=0,1}
\DoxyCodeLine{2937           \textcolor{keywordflow}{if} (hmask(i+k,j+l) == 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2938             summ = summ + h\_shelf(i+k,j+l)}
\DoxyCodeLine{2939             num\_h = num\_h + 1}
\DoxyCodeLine{2940 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2941 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2942 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2943       \textcolor{keywordflow}{if} (num\_h > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2944         h\_node(i,j) = summ / num\_h}
\DoxyCodeLine{2945 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2946 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2947 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2948 }
\DoxyCodeLine{2949   \textcolor{keyword}{call }pass\_var(h\_node, g\%domain, position=corner)}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{matrix\_diagonal()}{matrix\_diagonal()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::matrix\+\_\+diagonal (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors \\
\hline
\mbox{\texttt{ in}}  & {\em float\+\_\+cond} & An array indicating where the ice \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+node} & The ice shelf thickness at nodal \\
\hline
\mbox{\texttt{ in}}  & {\em ice\+\_\+visc} & A field related to the ice viscosity from Glen\textquotesingle{}s \\
\hline
\mbox{\texttt{ in}}  & {\em basal\+\_\+trac} & A field related to the nonlinear part of the \\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are \\
\hline
\mbox{\texttt{ in}}  & {\em dens\+\_\+ratio} & The density of ice divided by the density of seawater \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em phisub} & Quadrature structure weights at subgridscale locations for finite element calculations \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+diagonal} & The diagonal elements of the u-\/velocity \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2165 }
\DoxyCodeLine{2166   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{2167   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2168   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{2169 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2170                           \textcolor{keywordtype}{intent(in)}    :: float\_cond\textcolor{comment}{ !< An array indicating where the ice}}
\DoxyCodeLine{2171 \textcolor{comment}{                                                !! shelf is floating: 0 if floating, 1 if not.}}
\DoxyCodeLine{2172 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2173                           \textcolor{keywordtype}{intent(in)}    :: H\_node\textcolor{comment}{ !< The ice shelf thickness at nodal}}
\DoxyCodeLine{2174 \textcolor{comment}{                                                 !! (corner) points [Z \string~> m].}}
\DoxyCodeLine{2175 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2176                           \textcolor{keywordtype}{intent(in)}    :: ice\_visc\textcolor{comment}{ !< A field related to the ice viscosity from Glen's}}
\DoxyCodeLine{2177 \textcolor{comment}{                                                !! flow law [R L4 Z T-\/1 \string~> kg m2 s-\/1]. The exact form}}
\DoxyCodeLine{2178 \textcolor{comment}{                                                !!  and units depend on the basal law exponent.}}
\DoxyCodeLine{2179 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2180                           \textcolor{keywordtype}{intent(in)}    :: basal\_trac\textcolor{comment}{ !< A field related to the nonlinear part of the}}
\DoxyCodeLine{2181 \textcolor{comment}{                                                !! "linearized" basal stress [R Z T-\/1 \string~> kg m-\/2 s-\/1].}}
\DoxyCodeLine{2182 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2183                           \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{2184 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{2185 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: dens\_ratio\textcolor{comment}{ !< The density of ice divided by the density}}
\DoxyCodeLine{2186 \textcolor{comment}{                                                     !! of seawater [nondim]}}
\DoxyCodeLine{2187 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:,:,:,:)}, \textcolor{keywordtype}{intent(in)} :: Phisub\textcolor{comment}{ !< Quadrature structure weights at subgridscale}}
\DoxyCodeLine{2188 \textcolor{comment}{                                            !! locations for finite element calculations [nondim]}}
\DoxyCodeLine{2189 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2190                           \textcolor{keywordtype}{intent(inout)} :: u\_diagonal\textcolor{comment}{ !< The diagonal elements of the u-\/velocity}}
\DoxyCodeLine{2191 \textcolor{comment}{                                            !! matrix from the left-\/hand side of the solver [R L2 Z T-\/1 \string~> kg s-\/1]}}
\DoxyCodeLine{2192 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2193                           \textcolor{keywordtype}{intent(inout)} :: v\_diagonal\textcolor{comment}{  !< The diagonal elements of the v-\/velocity}}
\DoxyCodeLine{2194 \textcolor{comment}{                                            !! matrix from the left-\/hand side of the solver [R L2 Z T-\/1 \string~> kg s-\/1]}}
\DoxyCodeLine{2195 }
\DoxyCodeLine{2196 }
\DoxyCodeLine{2197 \textcolor{comment}{! returns the diagonal entries of the matrix for a Jacobi preconditioning}}
\DoxyCodeLine{2198 }
\DoxyCodeLine{2199 \textcolor{keywordtype}{  real} :: ux, uy, vx, vy \textcolor{comment}{! Interpolated weight gradients [L-\/1 \string~> m-\/1]}}
\DoxyCodeLine{2200 \textcolor{keywordtype}{  real} :: uq, vq}
\DoxyCodeLine{2201 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(8,4)} :: Phi \textcolor{comment}{! Weight gradients [L-\/1 \string~> m-\/1]}}
\DoxyCodeLine{2202 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2)}   :: xquad}
\DoxyCodeLine{2203 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(2,2)} :: Hcell, sub\_ground}
\DoxyCodeLine{2204   \textcolor{keywordtype}{integer} :: i, j, is, js, cnt, isc, jsc, iec, jec, iphi, jphi, iq, jq, ilq, jlq, Itgt, Jtgt}
\DoxyCodeLine{2205 }
\DoxyCodeLine{2206   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{2207 }
\DoxyCodeLine{2208   xquad(1) = .5 * (1-\/sqrt(1./3)) ; xquad(2) = .5 * (1+sqrt(1./3))}
\DoxyCodeLine{2209 }
\DoxyCodeLine{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}}
\DoxyCodeLine{2211 }
\DoxyCodeLine{2212     \textcolor{keyword}{call }bilinear\_shape\_fn\_grid(g, i, j, phi)}
\DoxyCodeLine{2213 }
\DoxyCodeLine{2214     \textcolor{comment}{! Phi(2*i-\/1,j) gives d(Phi\_i)/dx at quadrature point j}}
\DoxyCodeLine{2215     \textcolor{comment}{! Phi(2*i,j) gives d(Phi\_i)/dy at quadrature point j}}
\DoxyCodeLine{2216 }
\DoxyCodeLine{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}
\DoxyCodeLine{2218       ilq = 1 ; \textcolor{keywordflow}{if} (iq == iphi) ilq = 2}
\DoxyCodeLine{2219       jlq = 1 ; \textcolor{keywordflow}{if} (jq == jphi) jlq = 2}
\DoxyCodeLine{2220 }
\DoxyCodeLine{2221       \textcolor{keywordflow}{if} (cs\%umask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2222 }
\DoxyCodeLine{2223         ux = phi(2*(2*(jphi-\/1)+iphi)-\/1, 2*(jq-\/1)+iq)}
\DoxyCodeLine{2224         uy = phi(2*(2*(jphi-\/1)+iphi), 2*(jq-\/1)+iq)}
\DoxyCodeLine{2225         vx = 0.}
\DoxyCodeLine{2226         vy = 0.}
\DoxyCodeLine{2227 }
\DoxyCodeLine{2228         u\_diagonal(itgt,jtgt) = u\_diagonal(itgt,jtgt) + \&}
\DoxyCodeLine{2229               0.25 * ice\_visc(i,j) * ((4*ux+2*vy) * phi(2*(2*(jphi-\/1)+iphi)-\/1,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2230                                       (uy+vy) * phi(2*(2*(jphi-\/1)+iphi),2*(jq-\/1)+iq))}
\DoxyCodeLine{2231 }
\DoxyCodeLine{2232         \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2233           uq = xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2234           u\_diagonal(itgt,jtgt) = u\_diagonal(itgt,jtgt) + \&}
\DoxyCodeLine{2235               0.25 * basal\_trac(i,j) * uq * xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2236 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2237 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2238 }
\DoxyCodeLine{2239       \textcolor{keywordflow}{if} (cs\%vmask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2240 }
\DoxyCodeLine{2241         vx = phi(2*(2*(jphi-\/1)+iphi)-\/1, 2*(jq-\/1)+iq)}
\DoxyCodeLine{2242         vy = phi(2*(2*(jphi-\/1)+iphi), 2*(jq-\/1)+iq)}
\DoxyCodeLine{2243         ux = 0.}
\DoxyCodeLine{2244         uy = 0.}
\DoxyCodeLine{2245 }
\DoxyCodeLine{2246         v\_diagonal(itgt,jtgt) = v\_diagonal(itgt,jtgt) + \&}
\DoxyCodeLine{2247               0.25 * ice\_visc(i,j) * ((uy+vx) * phi(2*(2*(jphi-\/1)+iphi)-\/1,2*(jq-\/1)+iq) + \&}
\DoxyCodeLine{2248                                   (4*vy+2*ux) * phi(2*(2*(jphi-\/1)+iphi),2*(jq-\/1)+iq))}
\DoxyCodeLine{2249 }
\DoxyCodeLine{2250         \textcolor{keywordflow}{if} (float\_cond(i,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2251           vq = xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2252           v\_diagonal(itgt,jtgt) = v\_diagonal(itgt,jtgt) + \&}
\DoxyCodeLine{2253                 0.25 * basal\_trac(i,j) * vq * xquad(ilq) * xquad(jlq)}
\DoxyCodeLine{2254 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2255 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2256 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2257 }
\DoxyCodeLine{2258     \textcolor{keywordflow}{if} (float\_cond(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2259       hcell(:,:) = h\_node(i-\/1:i,j-\/1:j)}
\DoxyCodeLine{2260       \textcolor{keyword}{call }cg\_diagonal\_subgrid\_basal(phisub, hcell, g\%bathyT(i,j), dens\_ratio, sub\_ground)}
\DoxyCodeLine{2261       \textcolor{keywordflow}{do} iphi=1,2 ; \textcolor{keywordflow}{do} jphi=1,2 ; itgt = i-\/2+iphi ; jtgt = j-\/2-\/jphi}
\DoxyCodeLine{2262         \textcolor{keywordflow}{if} (cs\%umask(itgt,jtgt) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2263           u\_diagonal(itgt,jtgt) = u\_diagonal(itgt,jtgt) + sub\_ground(iphi,jphi) * basal\_trac(i,j)}
\DoxyCodeLine{2264           v\_diagonal(itgt,jtgt) = v\_diagonal(itgt,jtgt) + sub\_ground(iphi,jphi) * basal\_trac(i,j)}
\DoxyCodeLine{2265 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2266 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2267 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2268 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em x} & The x-\/positions of the vertices of the quadrilateral \mbox{[}L $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{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 \string~> m].}}
\DoxyCodeLine{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 \string~> m].}}
\DoxyCodeLine{196 \textcolor{keywordtype}{  real} :: quad\_area \textcolor{comment}{! Computed area [L2 \string~> m2]}}
\DoxyCodeLine{197 \textcolor{keywordtype}{  real} :: p2, q2, a2, c2, b2, d2}
\DoxyCodeLine{198 }
\DoxyCodeLine{199 \textcolor{comment}{! X and Y must be passed in the form}}
\DoxyCodeLine{200     \textcolor{comment}{!  3 -\/ 4}}
\DoxyCodeLine{201     \textcolor{comment}{!  |   |}}
\DoxyCodeLine{202     \textcolor{comment}{!  1 -\/ 2}}
\DoxyCodeLine{203 }
\DoxyCodeLine{204   p2 = (x(4)-\/x(1))**2 + (y(4)-\/y(1))**2 ; q2 = (x(3)-\/x(2))**2 + (y(3)-\/y(2))**2}
\DoxyCodeLine{205   a2 = (x(3)-\/x(4))**2 + (y(3)-\/y(4))**2 ; c2 = (x(1)-\/x(2))**2 + (y(1)-\/y(2))**2}
\DoxyCodeLine{206   b2 = (x(2)-\/x(4))**2 + (y(2)-\/y(4))**2 ; d2 = (x(3)-\/x(1))**2 + (y(3)-\/y(1))**2}
\DoxyCodeLine{207   quad\_area = .25 * sqrt(4*p2*q2-\/(b2+d2-\/a2-\/c2)**2)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\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{\texttt{ in,out}}  & {\em g} & The grid type describing the ice shelf grid. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{214   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The grid type describing the ice shelf grid.}}
\DoxyCodeLine{215   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{216   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< A pointer to the ice shelf dynamics control structure}}
\DoxyCodeLine{217   \textcolor{keywordtype}{type}(MOM\_restart\_CS),   \textcolor{keywordtype}{pointer}       :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control structure.}}
\DoxyCodeLine{218 }
\DoxyCodeLine{219   \textcolor{keywordtype}{logical} :: shelf\_mass\_is\_dynamic, override\_shelf\_movement, active\_shelf\_dynamics}
\DoxyCodeLine{220   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{221   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{224   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{225 }
\DoxyCodeLine{226   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{227     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf\_dyn.F90, register\_ice\_shelf\_dyn\_restarts: "}// \&}
\DoxyCodeLine{228                           \textcolor{stringliteral}{"called with an associated control structure."})}
\DoxyCodeLine{229     \textcolor{keywordflow}{return}}
\DoxyCodeLine{230 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{231   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{232 }
\DoxyCodeLine{233   override\_shelf\_movement = .false. ; active\_shelf\_dynamics = .false.}
\DoxyCodeLine{234   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DYNAMIC\_SHELF\_MASS"}, shelf\_mass\_is\_dynamic, \&}
\DoxyCodeLine{235                  \textcolor{stringliteral}{"If true, the ice sheet mass can evolve with time."}, \&}
\DoxyCodeLine{236                  default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{237   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) \textcolor{keywordflow}{then}}
\DoxyCodeLine{238     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OVERRIDE\_SHELF\_MOVEMENT"}, override\_shelf\_movement, \&}
\DoxyCodeLine{239                  \textcolor{stringliteral}{"If true, user provided code specifies the ice-\/shelf "}//\&}
\DoxyCodeLine{240                  \textcolor{stringliteral}{"movement instead of the dynamic ice model."}, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{241     active\_shelf\_dynamics = .not.override\_shelf\_movement}
\DoxyCodeLine{242 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{243 }
\DoxyCodeLine{244   \textcolor{keywordflow}{if} (active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{245     \textcolor{keyword}{allocate}( cs\%u\_shelf(isdb:iedb,jsdb:jedb) ) ; cs\%u\_shelf(:,:) = 0.0}
\DoxyCodeLine{246     \textcolor{keyword}{allocate}( cs\%v\_shelf(isdb:iedb,jsdb:jedb) ) ; cs\%v\_shelf(:,:) = 0.0}
\DoxyCodeLine{247     \textcolor{keyword}{allocate}( cs\%t\_shelf(isd:ied,jsd:jed) )   ; cs\%t\_shelf(:,:) = -\/10.0}
\DoxyCodeLine{248     \textcolor{keyword}{allocate}( cs\%ice\_visc(isd:ied,jsd:jed) )    ; cs\%ice\_visc(:,:) = 0.0}
\DoxyCodeLine{249     \textcolor{keyword}{allocate}( cs\%basal\_traction(isd:ied,jsd:jed) ) ; cs\%basal\_traction(:,:) = 0.0}
\DoxyCodeLine{250     \textcolor{keyword}{allocate}( cs\%OD\_av(isd:ied,jsd:jed) )       ; cs\%OD\_av(:,:) = 0.0}
\DoxyCodeLine{251     \textcolor{keyword}{allocate}( cs\%ground\_frac(isd:ied,jsd:jed) )  ; cs\%ground\_frac(:,:) = 0.0}
\DoxyCodeLine{252 }
\DoxyCodeLine{253     \textcolor{comment}{! additional restarts for ice shelf state}}
\DoxyCodeLine{254     \textcolor{keyword}{call }register\_restart\_field(cs\%u\_shelf, \textcolor{stringliteral}{"u\_shelf"}, .false., restart\_cs, \&}
\DoxyCodeLine{255                                 \textcolor{stringliteral}{"ice sheet/shelf u-\/velocity"}, \textcolor{stringliteral}{"m s-\/1"}, hor\_grid=\textcolor{stringliteral}{'Bu'})}
\DoxyCodeLine{256     \textcolor{keyword}{call }register\_restart\_field(cs\%v\_shelf, \textcolor{stringliteral}{"v\_shelf"}, .false., restart\_cs, \&}
\DoxyCodeLine{257                                 \textcolor{stringliteral}{"ice sheet/shelf v-\/velocity"}, \textcolor{stringliteral}{"m s-\/1"}, hor\_grid=\textcolor{stringliteral}{'Bu'})}
\DoxyCodeLine{258     \textcolor{keyword}{call }register\_restart\_field(cs\%t\_shelf, \textcolor{stringliteral}{"t\_shelf"}, .true., restart\_cs, \&}
\DoxyCodeLine{259                                 \textcolor{stringliteral}{"ice sheet/shelf vertically averaged temperature"}, \textcolor{stringliteral}{"deg C"})}
\DoxyCodeLine{260     \textcolor{keyword}{call }register\_restart\_field(cs\%OD\_av, \textcolor{stringliteral}{"OD\_av"}, .true., restart\_cs, \&}
\DoxyCodeLine{261                                 \textcolor{stringliteral}{"Average open ocean depth in a cell"},\textcolor{stringliteral}{"m"})}
\DoxyCodeLine{262     \textcolor{keyword}{call }register\_restart\_field(cs\%ground\_frac, \textcolor{stringliteral}{"ground\_frac"}, .true., restart\_cs, \&}
\DoxyCodeLine{263                                 \textcolor{stringliteral}{"fractional degree of grounding"}, \textcolor{stringliteral}{"nondim"})}
\DoxyCodeLine{264     \textcolor{keyword}{call }register\_restart\_field(cs\%ice\_visc, \textcolor{stringliteral}{"viscosity"}, .true., restart\_cs, \&}
\DoxyCodeLine{265                                 \textcolor{stringliteral}{"Volume integrated Glens law ice viscosity"}, \textcolor{stringliteral}{"kg m2 s-\/1"})}
\DoxyCodeLine{266     \textcolor{keyword}{call }register\_restart\_field(cs\%basal\_traction, \textcolor{stringliteral}{"tau\_b\_beta"}, .true., restart\_cs, \&}
\DoxyCodeLine{267                                 \textcolor{stringliteral}{"The area integrated basal traction coefficient"}, \textcolor{stringliteral}{"kg s-\/1"})}
\DoxyCodeLine{268 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{shelf\_advance\_front()}{shelf\_advance\_front()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::shelf\+\_\+advance\+\_\+front (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in,out}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in,out}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ in,out}}  & {\em uh\+\_\+ice} & The accumulated zonal ice volume flux \mbox{[}Z L2 $\sim$$>$ m3\mbox{]}\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1463   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1464   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{1465 \textcolor{comment}{                                           !! the ice-\/shelf state}}
\DoxyCodeLine{1466   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{1467 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1468                           \textcolor{keywordtype}{intent(inout)} :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{1469 \textcolor{comment}{                                              !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{1470 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{1471                           \textcolor{keywordtype}{intent(inout)} :: uh\_ice\textcolor{comment}{ !< The accumulated zonal ice volume flux [Z L2 \string~> m3]}}
\DoxyCodeLine{1472 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{1473                           \textcolor{keywordtype}{intent(inout)} :: vh\_ice\textcolor{comment}{ !< The accumulated meridional ice volume flux [Z L2 \string~> m3]}}
\DoxyCodeLine{1474 }
\DoxyCodeLine{1475   \textcolor{comment}{! in this subroutine we go through the computational cells only and, if they are empty or partial cells,}}
\DoxyCodeLine{1476   \textcolor{comment}{! we find the reference thickness and update the shelf mass and partial area fraction and the hmask if necessary}}
\DoxyCodeLine{1477 }
\DoxyCodeLine{1478   \textcolor{comment}{! if any cells go from partial to complete, we then must set the thickness, update hmask accordingly,}}
\DoxyCodeLine{1479   \textcolor{comment}{! and divide the overflow across the adjacent EMPTY (not partly-\/covered) cells.}}
\DoxyCodeLine{1480   \textcolor{comment}{! (it is highly unlikely there will not be any; in which case this will need to be rethought.)}}
\DoxyCodeLine{1481 }
\DoxyCodeLine{1482   \textcolor{comment}{! most likely there will only be one "overflow". If not, though, a pass\_var of all relevant variables}}
\DoxyCodeLine{1483   \textcolor{comment}{! is done; there will therefore be a loop which, in practice, will hopefully not have to go through}}
\DoxyCodeLine{1484   \textcolor{comment}{! many iterations}}
\DoxyCodeLine{1485 }
\DoxyCodeLine{1486   \textcolor{comment}{! when 3d advected scalars are introduced, they will be impacted by what is done here}}
\DoxyCodeLine{1487 }
\DoxyCodeLine{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}}
\DoxyCodeLine{1489   \textcolor{comment}{!}}
\DoxyCodeLine{1490   \textcolor{comment}{!   from eastern neighbor:  flux\_enter(:,:,1)}}
\DoxyCodeLine{1491   \textcolor{comment}{!   from western neighbor:  flux\_enter(:,:,2)}}
\DoxyCodeLine{1492   \textcolor{comment}{!   from southern neighbor: flux\_enter(:,:,3)}}
\DoxyCodeLine{1493   \textcolor{comment}{!   from northern neighbor: flux\_enter(:,:,4)}}
\DoxyCodeLine{1494   \textcolor{comment}{!}}
\DoxyCodeLine{1495   \textcolor{comment}{!        o-\/-\/-\/ (4) -\/-\/-\/o}}
\DoxyCodeLine{1496   \textcolor{comment}{!        |           |}}
\DoxyCodeLine{1497   \textcolor{comment}{!       (1)         (2)}}
\DoxyCodeLine{1498   \textcolor{comment}{!        |           |}}
\DoxyCodeLine{1499   \textcolor{comment}{!        o-\/-\/-\/ (3) -\/-\/-\/o}}
\DoxyCodeLine{1500   \textcolor{comment}{!}}
\DoxyCodeLine{1501 }
\DoxyCodeLine{1502   \textcolor{keywordtype}{integer} :: i, j, isc, iec, jsc, jec, n\_flux, k, l, iter\_count}
\DoxyCodeLine{1503   \textcolor{keywordtype}{integer} :: i\_off, j\_off}
\DoxyCodeLine{1504   \textcolor{keywordtype}{integer} :: iter\_flag}
\DoxyCodeLine{1505 }
\DoxyCodeLine{1506 \textcolor{keywordtype}{  real} :: h\_reference \textcolor{comment}{! A reference thicknesss based on neighboring cells [Z \string~> m]}}
\DoxyCodeLine{1507 \textcolor{keywordtype}{  real} :: tot\_flux    \textcolor{comment}{! The total ice mass flux [Z L2 \string~> m3]}}
\DoxyCodeLine{1508 \textcolor{keywordtype}{  real} :: partial\_vol \textcolor{comment}{! The volume covered by ice shelf [Z L2 \string~> m3]}}
\DoxyCodeLine{1509 \textcolor{keywordtype}{  real} :: dxdyh       \textcolor{comment}{! Cell area [L2 \string~> m2]}}
\DoxyCodeLine{1510   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{1511   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(4)} :: mapi, mapj, new\_partial}
\DoxyCodeLine{1512 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G),4)} :: flux\_enter  \textcolor{comment}{! The ice volume flux into the}}
\DoxyCodeLine{1513                                               \textcolor{comment}{! cell through the 4 cell boundaries [Z L2 \string~> m3].}}
\DoxyCodeLine{1514 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G),4)} :: flux\_enter\_replace \textcolor{comment}{! An updated ice volume flux into the}}
\DoxyCodeLine{1515                                               \textcolor{comment}{! cell through the 4 cell boundaries [Z L2 \string~> m3].}}
\DoxyCodeLine{1516 }
\DoxyCodeLine{1517   isc = g\%isc ; iec = g\%iec ; jsc = g\%jsc ; jec = g\%jec}
\DoxyCodeLine{1518   i\_off = g\%idg\_offset ; j\_off = g\%jdg\_offset}
\DoxyCodeLine{1519   iter\_count = 0 ; iter\_flag = 1}
\DoxyCodeLine{1520 }
\DoxyCodeLine{1521   flux\_enter(:,:,:) = 0.0}
\DoxyCodeLine{1522   \textcolor{keywordflow}{do} j=jsc-\/1,jec+1 ; \textcolor{keywordflow}{do} i=isc-\/1,iec+1}
\DoxyCodeLine{1523     \textcolor{keywordflow}{if} ((hmask(i,j) == 0) .or. (hmask(i,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1524       flux\_enter(i,j,1) = max(uh\_ice(i-\/1,j), 0.0)}
\DoxyCodeLine{1525       flux\_enter(i,j,2) = max(-\/uh\_ice(i,j), 0.0)}
\DoxyCodeLine{1526       flux\_enter(i,j,3) = max(vh\_ice(i,j-\/1), 0.0)}
\DoxyCodeLine{1527       flux\_enter(i,j,4) = max(-\/vh\_ice(i,j), 0.0)}
\DoxyCodeLine{1528 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1529 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1530 }
\DoxyCodeLine{1531   mapi(1) = -\/1 ; mapi(2) = 1 ; mapi(3:4) = 0}
\DoxyCodeLine{1532   mapj(3) = -\/1 ; mapj(4) = 1 ; mapj(1:2) = 0}
\DoxyCodeLine{1533 }
\DoxyCodeLine{1534   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (iter\_flag == 1)}
\DoxyCodeLine{1535 }
\DoxyCodeLine{1536     iter\_flag = 0}
\DoxyCodeLine{1537 }
\DoxyCodeLine{1538     \textcolor{keywordflow}{if} (iter\_count > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1539       flux\_enter(:,:,:) = flux\_enter\_replace(:,:,:)}
\DoxyCodeLine{1540 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1541     flux\_enter\_replace(:,:,:) = 0.0}
\DoxyCodeLine{1542 }
\DoxyCodeLine{1543     iter\_count = iter\_count + 1}
\DoxyCodeLine{1544 }
\DoxyCodeLine{1545     \textcolor{comment}{! if iter\_count >= 3 then some halo updates need to be done...}}
\DoxyCodeLine{1546 }
\DoxyCodeLine{1547     \textcolor{keywordflow}{do} j=jsc-\/1,jec+1}
\DoxyCodeLine{1548 }
\DoxyCodeLine{1549       \textcolor{keywordflow}{if} (((j+j\_off) <= g\%domain\%njglobal+g\%domain\%njhalo) .AND. \&}
\DoxyCodeLine{1550          ((j+j\_off) >= g\%domain\%njhalo+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1551 }
\DoxyCodeLine{1552         \textcolor{keywordflow}{do} i=isc-\/1,iec+1}
\DoxyCodeLine{1553 }
\DoxyCodeLine{1554           \textcolor{keywordflow}{if} (((i+i\_off) <= g\%domain\%niglobal+g\%domain\%nihalo) .AND. \&}
\DoxyCodeLine{1555               ((i+i\_off) >= g\%domain\%nihalo+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1556         \textcolor{comment}{! first get reference thickness by averaging over cells that are fluxing into this cell}}
\DoxyCodeLine{1557             n\_flux = 0}
\DoxyCodeLine{1558             h\_reference = 0.0}
\DoxyCodeLine{1559             tot\_flux = 0.0}
\DoxyCodeLine{1560 }
\DoxyCodeLine{1561             \textcolor{keywordflow}{do} k=1,2}
\DoxyCodeLine{1562               \textcolor{keywordflow}{if} (flux\_enter(i,j,k) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1563                 n\_flux = n\_flux + 1}
\DoxyCodeLine{1564                 h\_reference = h\_reference + iss\%h\_shelf(i+2*k-\/3,j)}
\DoxyCodeLine{1565                 tot\_flux = tot\_flux + flux\_enter(i,j,k)}
\DoxyCodeLine{1566                 flux\_enter(i,j,k) = 0.0}
\DoxyCodeLine{1567 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1568 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{1569 }
\DoxyCodeLine{1570             \textcolor{keywordflow}{do} k=1,2}
\DoxyCodeLine{1571               \textcolor{keywordflow}{if} (flux\_enter(i,j,k+2) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1572                 n\_flux = n\_flux + 1}
\DoxyCodeLine{1573                 h\_reference = h\_reference + iss\%h\_shelf(i,j+2*k-\/3)}
\DoxyCodeLine{1574                 tot\_flux = tot\_flux + flux\_enter(i,j,k+2)}
\DoxyCodeLine{1575                 flux\_enter(i,j,k+2) = 0.0}
\DoxyCodeLine{1576 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1577 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{1578 }
\DoxyCodeLine{1579             \textcolor{keywordflow}{if} (n\_flux > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1580               dxdyh = g\%areaT(i,j)}
\DoxyCodeLine{1581               h\_reference = h\_reference / real(n\_flux)}
\DoxyCodeLine{1582               partial\_vol = iss\%h\_shelf(i,j) * iss\%area\_shelf\_h(i,j) + tot\_flux}
\DoxyCodeLine{1583 }
\DoxyCodeLine{1584               \textcolor{keywordflow}{if} ((partial\_vol / g\%areaT(i,j)) == h\_reference) \textcolor{keywordflow}{then} \textcolor{comment}{! cell is exactly covered, no overflow}}
\DoxyCodeLine{1585                 iss\%hmask(i,j) = 1}
\DoxyCodeLine{1586                 iss\%h\_shelf(i,j) = h\_reference}
\DoxyCodeLine{1587                 iss\%area\_shelf\_h(i,j) = g\%areaT(i,j)}
\DoxyCodeLine{1588               \textcolor{keywordflow}{elseif} ((partial\_vol / g\%areaT(i,j)) < h\_reference) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1589                 iss\%hmask(i,j) = 2}
\DoxyCodeLine{1590                \textcolor{comment}{!  ISS\%mass\_shelf(i,j) = partial\_vol * CS\%density\_ice}}
\DoxyCodeLine{1591                 iss\%area\_shelf\_h(i,j) = partial\_vol / h\_reference}
\DoxyCodeLine{1592                 iss\%h\_shelf(i,j) = h\_reference}
\DoxyCodeLine{1593               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1594 }
\DoxyCodeLine{1595                 iss\%hmask(i,j) = 1}
\DoxyCodeLine{1596                 iss\%area\_shelf\_h(i,j) = g\%areaT(i,j)}
\DoxyCodeLine{1597                 \textcolor{comment}{!h\_temp(i,j) = h\_reference}}
\DoxyCodeLine{1598                 partial\_vol = partial\_vol -\/ h\_reference * g\%areaT(i,j)}
\DoxyCodeLine{1599 }
\DoxyCodeLine{1600                 iter\_flag  = 1}
\DoxyCodeLine{1601 }
\DoxyCodeLine{1602                 n\_flux = 0 ; new\_partial(:) = 0}
\DoxyCodeLine{1603 }
\DoxyCodeLine{1604                 \textcolor{keywordflow}{do} k=1,2}
\DoxyCodeLine{1605                   \textcolor{keywordflow}{if} (cs\%u\_face\_mask(i-\/2+k,j) == 2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1606                     n\_flux = n\_flux + 1}
\DoxyCodeLine{1607                   \textcolor{keywordflow}{elseif} (iss\%hmask(i+2*k-\/3,j) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1608                     n\_flux = n\_flux + 1}
\DoxyCodeLine{1609                     new\_partial(k) = 1}
\DoxyCodeLine{1610 \textcolor{keywordflow}{                  endif}}
\DoxyCodeLine{1611                   \textcolor{keywordflow}{if} (cs\%v\_face\_mask(i,j-\/2+k) == 2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1612                     n\_flux = n\_flux + 1}
\DoxyCodeLine{1613                   \textcolor{keywordflow}{elseif} (iss\%hmask(i,j+2*k-\/3) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1614                     n\_flux = n\_flux + 1}
\DoxyCodeLine{1615                     new\_partial(k+2) = 1}
\DoxyCodeLine{1616 \textcolor{keywordflow}{                  endif}}
\DoxyCodeLine{1617 \textcolor{keywordflow}{                enddo}}
\DoxyCodeLine{1618 }
\DoxyCodeLine{1619                 \textcolor{keywordflow}{if} (n\_flux == 0) \textcolor{keywordflow}{then} \textcolor{comment}{! there is nowhere to put the extra ice!}}
\DoxyCodeLine{1620                   iss\%h\_shelf(i,j) = h\_reference + partial\_vol / g\%areaT(i,j)}
\DoxyCodeLine{1621                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{1622                   iss\%h\_shelf(i,j) = h\_reference}
\DoxyCodeLine{1623 }
\DoxyCodeLine{1624                   \textcolor{keywordflow}{do} k=1,2}
\DoxyCodeLine{1625                     \textcolor{keywordflow}{if} (new\_partial(k) == 1) \&}
\DoxyCodeLine{1626                       flux\_enter\_replace(i+2*k-\/3,j,3-\/k) = partial\_vol / real(n\_flux)}
\DoxyCodeLine{1627                     \textcolor{keywordflow}{if} (new\_partial(k+2) == 1) \&}
\DoxyCodeLine{1628                       flux\_enter\_replace(i,j+2*k-\/3,5-\/k) = partial\_vol / real(n\_flux)}
\DoxyCodeLine{1629 \textcolor{keywordflow}{                  enddo}}
\DoxyCodeLine{1630 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{1631 }
\DoxyCodeLine{1632 \textcolor{keywordflow}{              endif} \textcolor{comment}{! Parital\_vol test.}}
\DoxyCodeLine{1633 \textcolor{keywordflow}{            endif} \textcolor{comment}{! n\_flux gt 0 test.}}
\DoxyCodeLine{1634 }
\DoxyCodeLine{1635 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1636 \textcolor{keywordflow}{        enddo} \textcolor{comment}{! j-\/loop}}
\DoxyCodeLine{1637 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1638 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1639 }
\DoxyCodeLine{1640   \textcolor{comment}{!  call max\_across\_PEs(iter\_flag)}}
\DoxyCodeLine{1641 }
\DoxyCodeLine{1642 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! End of do while(iter\_flag) loop}}
\DoxyCodeLine{1643 }
\DoxyCodeLine{1644   \textcolor{keyword}{call }max\_across\_pes(iter\_count)}
\DoxyCodeLine{1645 }
\DoxyCodeLine{1646   \textcolor{keywordflow}{if} (is\_root\_pe() .and. (iter\_count > 1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1647     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"shelf\_advance\_front: "}, iter\_count, \textcolor{stringliteral}{" max iterations"}}
\DoxyCodeLine{1648     \textcolor{keyword}{call }mom\_mesg(mesg, 5)}
\DoxyCodeLine{1649 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em num} & The numerator of the ratio used in the Van Leer slope limiter \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{176 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}    :: num\textcolor{comment}{   !< The numerator of the ratio used in the Van Leer slope limiter}}
\DoxyCodeLine{177 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}    :: denom\textcolor{comment}{ !< The denominator of the ratio used in the Van Leer slope limiter}}
\DoxyCodeLine{178 \textcolor{keywordtype}{  real} :: slope\_limiter \textcolor{comment}{! The slope limiter value, between 0 and 2 [nondim].}}
\DoxyCodeLine{179 \textcolor{keywordtype}{  real} :: r  \textcolor{comment}{! The ratio of num/denom [nondim]}}
\DoxyCodeLine{180 }
\DoxyCodeLine{181   \textcolor{keywordflow}{if} (denom == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{182     slope\_limiter = 0}
\DoxyCodeLine{183   \textcolor{keywordflow}{elseif} (num*denom <= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{184     slope\_limiter = 0}
\DoxyCodeLine{185   \textcolor{keywordflow}{else}}
\DoxyCodeLine{186     r = num/denom}
\DoxyCodeLine{187     slope\_limiter = (r+abs(r))/(1+abs(r))}
\DoxyCodeLine{188 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{update\_ice\_shelf()}{update\_ice\_shelf()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+ice\+\_\+shelf (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & The ice shelf dynamics control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & time step \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
\mbox{\texttt{ in}}  & {\em ocean\+\_\+mass} & If present this is the mass per unit area \\
\hline
\mbox{\texttt{ in}}  & {\em coupled\+\_\+grounding} & If true, the grounding line is determined by coupled ice-\/ocean dynamics \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{632   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< The ice shelf dynamics control structure}}
\DoxyCodeLine{633   \textcolor{keywordtype}{type}(ice\_shelf\_state),  \textcolor{keywordtype}{intent(inout)} :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{634 \textcolor{comment}{                                              !! the ice-\/shelf state}}
\DoxyCodeLine{635   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{636   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{637 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< time step [T \string~> s]}}
\DoxyCodeLine{638   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{639 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{640                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: ocean\_mass\textcolor{comment}{ !< If present this is the mass per unit area}}
\DoxyCodeLine{641 \textcolor{comment}{                                              !! of the ocean [R Z \string~> kg m-\/2].}}
\DoxyCodeLine{642   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: coupled\_grounding\textcolor{comment}{ !< If true, the grounding line is}}
\DoxyCodeLine{643 \textcolor{comment}{                                              !! determined by coupled ice-\/ocean dynamics}}
\DoxyCodeLine{644   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: must\_update\_vel\textcolor{comment}{ !< Always update the ice velocities if true.}}
\DoxyCodeLine{645 }
\DoxyCodeLine{646   \textcolor{keywordtype}{integer} :: iters}
\DoxyCodeLine{647   \textcolor{keywordtype}{logical} :: update\_ice\_vel, coupled\_GL}
\DoxyCodeLine{648 }
\DoxyCodeLine{649   update\_ice\_vel = .false.}
\DoxyCodeLine{650   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(must\_update\_vel)) update\_ice\_vel = must\_update\_vel}
\DoxyCodeLine{651 }
\DoxyCodeLine{652   coupled\_gl = .false.}
\DoxyCodeLine{653   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ocean\_mass) .and. \textcolor{keyword}{present}(coupled\_grounding)) coupled\_gl = coupled\_grounding}
\DoxyCodeLine{654 }
\DoxyCodeLine{655   \textcolor{keyword}{call }ice\_shelf\_advect(cs, iss, g, time\_step, time)}
\DoxyCodeLine{656   cs\%elapsed\_velocity\_time = cs\%elapsed\_velocity\_time + time\_step}
\DoxyCodeLine{657   \textcolor{keywordflow}{if} (cs\%elapsed\_velocity\_time >= cs\%velocity\_update\_time\_step) update\_ice\_vel = .true.}
\DoxyCodeLine{658 }
\DoxyCodeLine{659   \textcolor{keywordflow}{if} (coupled\_gl) \textcolor{keywordflow}{then}}
\DoxyCodeLine{660     \textcolor{keyword}{call }update\_od\_ffrac(cs, g, us, ocean\_mass, update\_ice\_vel)}
\DoxyCodeLine{661   \textcolor{keywordflow}{elseif} (update\_ice\_vel) \textcolor{keywordflow}{then}}
\DoxyCodeLine{662     \textcolor{keyword}{call }update\_od\_ffrac\_uncoupled(cs, g, iss\%h\_shelf(:,:))}
\DoxyCodeLine{663 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{664 }
\DoxyCodeLine{665   \textcolor{keywordflow}{if} (update\_ice\_vel) \textcolor{keywordflow}{then}}
\DoxyCodeLine{666     \textcolor{keyword}{call }ice\_shelf\_solve\_outer(cs, iss, g, us, cs\%u\_shelf, cs\%v\_shelf, iters, time)}
\DoxyCodeLine{667 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{668 }
\DoxyCodeLine{669   \textcolor{keyword}{call }ice\_shelf\_temp(cs, iss, g, us, time\_step, iss\%water\_flux, time)}
\DoxyCodeLine{670 }
\DoxyCodeLine{671   \textcolor{keywordflow}{if} (update\_ice\_vel) \textcolor{keywordflow}{then}}
\DoxyCodeLine{672     \textcolor{keyword}{call }enable\_averages(cs\%elapsed\_velocity\_time, time, cs\%diag)}
\DoxyCodeLine{673     \textcolor{keywordflow}{if} (cs\%id\_col\_thick > 0) \textcolor{keyword}{call }post\_data(cs\%id\_col\_thick, cs\%OD\_av, cs\%diag)}
\DoxyCodeLine{674     \textcolor{keywordflow}{if} (cs\%id\_u\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_u\_shelf, cs\%u\_shelf, cs\%diag)}
\DoxyCodeLine{675     \textcolor{keywordflow}{if} (cs\%id\_v\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_v\_shelf, cs\%v\_shelf, cs\%diag)}
\DoxyCodeLine{676     \textcolor{keywordflow}{if} (cs\%id\_t\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_t\_shelf,cs\%t\_shelf,cs\%diag)}
\DoxyCodeLine{677     \textcolor{keywordflow}{if} (cs\%id\_ground\_frac > 0) \textcolor{keyword}{call }post\_data(cs\%id\_ground\_frac, cs\%ground\_frac,cs\%diag)}
\DoxyCodeLine{678     \textcolor{keywordflow}{if} (cs\%id\_OD\_av >0) \textcolor{keyword}{call }post\_data(cs\%id\_OD\_av, cs\%OD\_av,cs\%diag)}
\DoxyCodeLine{679 }
\DoxyCodeLine{680     \textcolor{keywordflow}{if} (cs\%id\_u\_mask > 0) \textcolor{keyword}{call }post\_data(cs\%id\_u\_mask,cs\%umask,cs\%diag)}
\DoxyCodeLine{681     \textcolor{keywordflow}{if} (cs\%id\_v\_mask > 0) \textcolor{keyword}{call }post\_data(cs\%id\_v\_mask,cs\%vmask,cs\%diag)}
\DoxyCodeLine{682     \textcolor{keywordflow}{if} (cs\%id\_t\_mask > 0) \textcolor{keyword}{call }post\_data(cs\%id\_t\_mask,cs\%tmask,cs\%diag)}
\DoxyCodeLine{683 }
\DoxyCodeLine{684     \textcolor{keyword}{call }disable\_averaging(cs\%diag)}
\DoxyCodeLine{685 }
\DoxyCodeLine{686     cs\%elapsed\_velocity\_time = 0.0}
\DoxyCodeLine{687 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{update\_od\_ffrac()}{update\_od\_ffrac()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+od\+\_\+ffrac (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A structure containing unit conversion factors\\
\hline
\mbox{\texttt{ in}}  & {\em ocean\+\_\+mass} & The mass per unit area of the ocean \mbox{[}kg m-\/2\mbox{]}.\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2511   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{2512   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2513   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}     :: US\textcolor{comment}{ !< A structure containing unit conversion factors}}
\DoxyCodeLine{2514 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2515                           \textcolor{keywordtype}{intent(in)}    :: ocean\_mass\textcolor{comment}{ !< The mass per unit area of the ocean [kg m-\/2].}}
\DoxyCodeLine{2516   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)}    :: find\_avg\textcolor{comment}{ !< If true, find the average of OD and ffrac, and}}
\DoxyCodeLine{2517 \textcolor{comment}{                                              !! reset the underlying running sums to 0.}}
\DoxyCodeLine{2518 }
\DoxyCodeLine{2519   \textcolor{keywordtype}{integer} :: isc, iec, jsc, jec, i, j}
\DoxyCodeLine{2520 \textcolor{keywordtype}{  real}    :: I\_rho\_ocean \textcolor{comment}{! A typical specific volume of the ocean [R-\/1 \string~> m3 kg-\/1]}}
\DoxyCodeLine{2521 \textcolor{keywordtype}{  real}    :: I\_counter}
\DoxyCodeLine{2522 }
\DoxyCodeLine{2523   i\_rho\_ocean = 1.0 / cs\%density\_ocean\_avg}
\DoxyCodeLine{2524 }
\DoxyCodeLine{2525   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{2526 }
\DoxyCodeLine{2527   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{2528     cs\%OD\_rt(i,j) = cs\%OD\_rt(i,j) + ocean\_mass(i,j)*i\_rho\_ocean}
\DoxyCodeLine{2529     \textcolor{keywordflow}{if} (ocean\_mass(i,j)*i\_rho\_ocean > cs\%thresh\_float\_col\_depth) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2530       cs\%ground\_frac\_rt(i,j) = cs\%ground\_frac\_rt(i,j) + 1.0}
\DoxyCodeLine{2531 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2532 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2533   cs\%OD\_rt\_counter = cs\%OD\_rt\_counter + 1}
\DoxyCodeLine{2534 }
\DoxyCodeLine{2535   \textcolor{keywordflow}{if} (find\_avg) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2536     i\_counter = 1.0 / real(cs\%OD\_rt\_counter)}
\DoxyCodeLine{2537     \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{2538       cs\%ground\_frac(i,j) = 1.0 -\/ (cs\%ground\_frac\_rt(i,j) * i\_counter)}
\DoxyCodeLine{2539       cs\%OD\_av(i,j) = cs\%OD\_rt(i,j) * i\_counter}
\DoxyCodeLine{2540 }
\DoxyCodeLine{2541       cs\%OD\_rt(i,j) = 0.0 ; cs\%ground\_frac\_rt(i,j) = 0.0}
\DoxyCodeLine{2542 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2543 }
\DoxyCodeLine{2544     \textcolor{keyword}{call }pass\_var(cs\%ground\_frac, g\%domain)}
\DoxyCodeLine{2545     \textcolor{keyword}{call }pass\_var(cs\%OD\_av, g\%domain)}
\DoxyCodeLine{2546 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{update\_od\_ffrac\_uncoupled()}{update\_od\_ffrac\_uncoupled()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+od\+\_\+ffrac\+\_\+uncoupled (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in,out}}  & {\em cs} & A pointer to the ice shelf control structure\\
\hline
\mbox{\texttt{ in}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2551   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{2552   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2553 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2554                           \textcolor{keywordtype}{intent(in)}    :: h\_shelf\textcolor{comment}{ !< the thickness of the ice shelf [Z \string~> m].}}
\DoxyCodeLine{2555 }
\DoxyCodeLine{2556   \textcolor{keywordtype}{integer} :: i, j, iters, isd, ied, jsd, jed}
\DoxyCodeLine{2557 \textcolor{keywordtype}{  real}    :: rhoi\_rhow, OD}
\DoxyCodeLine{2558 }
\DoxyCodeLine{2559   rhoi\_rhow = cs\%density\_ice / cs\%density\_ocean\_avg}
\DoxyCodeLine{2560   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{2561 }
\DoxyCodeLine{2562   \textcolor{keywordflow}{do} j=jsd,jed}
\DoxyCodeLine{2563     \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{2564       od = g\%bathyT(i,j) -\/ rhoi\_rhow * h\_shelf(i,j)}
\DoxyCodeLine{2565       \textcolor{keywordflow}{if} (od >= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2566     \textcolor{comment}{! ice thickness does not take up whole ocean column -\/> floating}}
\DoxyCodeLine{2567         cs\%OD\_av(i,j) = od}
\DoxyCodeLine{2568         cs\%ground\_frac(i,j) = 0.}
\DoxyCodeLine{2569       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2570         cs\%OD\_av(i,j) = 0.}
\DoxyCodeLine{2571         cs\%ground\_frac(i,j) = 1.}
\DoxyCodeLine{2572 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2573 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2574 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{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}}
\doxysubsubsection{\texorpdfstring{update\_velocity\_masks()}{update\_velocity\_masks()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+\_\+dynamics\+::update\+\_\+velocity\+\_\+masks (\begin{DoxyParamCaption}\item[{type(\mbox{\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{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf dynamics control structure\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The grid structure used by the ice shelf.\\
\hline
\mbox{\texttt{ in}}  & {\em hmask} & A mask indicating which tracer points are\\
\hline
\mbox{\texttt{ out}}  & {\em umask} & A coded mask indicating the nature of the\\
\hline
\mbox{\texttt{ out}}  & {\em vmask} & A coded mask indicating the nature of the\\
\hline
\mbox{\texttt{ out}}  & {\em u\+\_\+face\+\_\+mask} & A coded mask for velocities at the C-\/grid u-\/face\\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2755   \textcolor{keywordtype}{type}(ice\_shelf\_dyn\_CS),\textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf dynamics control structure}}
\DoxyCodeLine{2756   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The grid structure used by the ice shelf.}}
\DoxyCodeLine{2757 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2758                          \textcolor{keywordtype}{intent(in)}    :: hmask\textcolor{comment}{ !< A mask indicating which tracer points are}}
\DoxyCodeLine{2759 \textcolor{comment}{                                             !! partly or fully covered by an ice-\/shelf}}
\DoxyCodeLine{2760 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2761                          \textcolor{keywordtype}{intent(out)}   :: umask\textcolor{comment}{ !< A coded mask indicating the nature of the}}
\DoxyCodeLine{2762 \textcolor{comment}{                                             !! zonal flow at the corner point}}
\DoxyCodeLine{2763 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2764                          \textcolor{keywordtype}{intent(out)}   :: vmask\textcolor{comment}{ !< A coded mask indicating the nature of the}}
\DoxyCodeLine{2765 \textcolor{comment}{                                             !! meridional flow at the corner point}}
\DoxyCodeLine{2766 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDIB\_(G),SZDJ\_(G))}, \&}
\DoxyCodeLine{2767                          \textcolor{keywordtype}{intent(out)}   :: u\_face\_mask\textcolor{comment}{ !< A coded mask for velocities at the C-\/grid u-\/face}}
\DoxyCodeLine{2768 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJB\_(G))}, \&}
\DoxyCodeLine{2769                          \textcolor{keywordtype}{intent(out)}   :: v\_face\_mask\textcolor{comment}{ !< A coded mask for velocities at the C-\/grid v-\/face}}
\DoxyCodeLine{2770   \textcolor{comment}{! sets masks for velocity solve}}
\DoxyCodeLine{2771   \textcolor{comment}{! ignores the fact that their might be ice-\/free cells -\/ this only considers the computational boundary}}
\DoxyCodeLine{2772 }
\DoxyCodeLine{2773   \textcolor{comment}{! !!!IMPORTANT!!! relies on thickness mask -\/ assumed that this is called after hmask has been updated \& halo-\/updated}}
\DoxyCodeLine{2774 }
\DoxyCodeLine{2775   \textcolor{keywordtype}{integer} :: i, j, k, iscq, iecq, jscq, jecq, isd, jsd, is, js, iegq, jegq}
\DoxyCodeLine{2776   \textcolor{keywordtype}{integer} :: giec, gjec, gisc, gjsc, isc, jsc, iec, jec}
\DoxyCodeLine{2777   \textcolor{keywordtype}{integer} :: i\_off, j\_off}
\DoxyCodeLine{2778 }
\DoxyCodeLine{2779   isc = g\%isc ; jsc = g\%jsc ; iec = g\%iec ; jec = g\%jec}
\DoxyCodeLine{2780   iscq = g\%iscB ; iecq = g\%iecB ; jscq = g\%jscB ; jecq = g\%jecB}
\DoxyCodeLine{2781   i\_off = g\%idg\_offset ; j\_off = g\%jdg\_offset}
\DoxyCodeLine{2782   isd = g\%isd ; jsd = g\%jsd}
\DoxyCodeLine{2783   iegq = g\%iegB ; jegq = g\%jegB}
\DoxyCodeLine{2784   gisc = g\%Domain\%nihalo ; gjsc = g\%Domain\%njhalo}
\DoxyCodeLine{2785   giec = g\%Domain\%niglobal+gisc ; gjec = g\%Domain\%njglobal+gjsc}
\DoxyCodeLine{2786 }
\DoxyCodeLine{2787   umask(:,:) = 0 ; vmask(:,:) = 0}
\DoxyCodeLine{2788   u\_face\_mask(:,:) = 0 ; v\_face\_mask(:,:) = 0}
\DoxyCodeLine{2789 }
\DoxyCodeLine{2790   \textcolor{keywordflow}{if} (g\%symmetric) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2791    is = isd ; js = jsd}
\DoxyCodeLine{2792   \textcolor{keywordflow}{else}}
\DoxyCodeLine{2793    is = isd+1 ; js = jsd+1}
\DoxyCodeLine{2794 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2795 }
\DoxyCodeLine{2796   \textcolor{keywordflow}{do} j=js,g\%jed}
\DoxyCodeLine{2797     \textcolor{keywordflow}{do} i=is,g\%ied}
\DoxyCodeLine{2798 }
\DoxyCodeLine{2799       \textcolor{keywordflow}{if} (hmask(i,j) == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2800 }
\DoxyCodeLine{2801         umask(i-\/1:i,j-\/1:j) = 1.}
\DoxyCodeLine{2802         vmask(i-\/1:i,j-\/1:j) = 1.}
\DoxyCodeLine{2803 }
\DoxyCodeLine{2804         \textcolor{keywordflow}{do} k=0,1}
\DoxyCodeLine{2805 }
\DoxyCodeLine{2806           \textcolor{keywordflow}{select case} (int(cs\%u\_face\_mask\_bdry(i-\/1+k,j)))}
\DoxyCodeLine{2807             \textcolor{keywordflow}{case} (3)}
\DoxyCodeLine{2808               umask(i-\/1+k,j-\/1:j)=3.}
\DoxyCodeLine{2809               vmask(i-\/1+k,j-\/1:j)=0.}
\DoxyCodeLine{2810               u\_face\_mask(i-\/1+k,j)=3.}
\DoxyCodeLine{2811             \textcolor{keywordflow}{case} (2)}
\DoxyCodeLine{2812               u\_face\_mask(i-\/1+k,j)=2.}
\DoxyCodeLine{2813             \textcolor{keywordflow}{case} (4)}
\DoxyCodeLine{2814               umask(i-\/1+k,j-\/1:j)=0.}
\DoxyCodeLine{2815               vmask(i-\/1+k,j-\/1:j)=0.}
\DoxyCodeLine{2816               u\_face\_mask(i-\/1+k,j)=4.}
\DoxyCodeLine{2817             \textcolor{keywordflow}{case} (0)}
\DoxyCodeLine{2818               umask(i-\/1+k,j-\/1:j)=0.}
\DoxyCodeLine{2819               vmask(i-\/1+k,j-\/1:j)=0.}
\DoxyCodeLine{2820               u\_face\_mask(i-\/1+k,j)=0.}
\DoxyCodeLine{2821             \textcolor{keywordflow}{case} (1)  \textcolor{comment}{! stress free x-\/boundary}}
\DoxyCodeLine{2822               umask(i-\/1+k,j-\/1:j)=0.}
\DoxyCodeLine{2823 \textcolor{keywordflow}{            case default}}
\DoxyCodeLine{2824 \textcolor{keywordflow}{          end select}}
\DoxyCodeLine{2825 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2826 }
\DoxyCodeLine{2827         \textcolor{keywordflow}{do} k=0,1}
\DoxyCodeLine{2828 }
\DoxyCodeLine{2829           \textcolor{keywordflow}{select case} (int(cs\%v\_face\_mask\_bdry(i,j-\/1+k)))}
\DoxyCodeLine{2830             \textcolor{keywordflow}{case} (3)}
\DoxyCodeLine{2831               vmask(i-\/1:i,j-\/1+k)=3.}
\DoxyCodeLine{2832               umask(i-\/1:i,j-\/1+k)=0.}
\DoxyCodeLine{2833               v\_face\_mask(i,j-\/1+k)=3.}
\DoxyCodeLine{2834             \textcolor{keywordflow}{case} (2)}
\DoxyCodeLine{2835               v\_face\_mask(i,j-\/1+k)=2.}
\DoxyCodeLine{2836             \textcolor{keywordflow}{case} (4)}
\DoxyCodeLine{2837               umask(i-\/1:i,j-\/1+k)=0.}
\DoxyCodeLine{2838               vmask(i-\/1:i,j-\/1+k)=0.}
\DoxyCodeLine{2839               v\_face\_mask(i,j-\/1+k)=4.}
\DoxyCodeLine{2840             \textcolor{keywordflow}{case} (0)}
\DoxyCodeLine{2841               umask(i-\/1:i,j-\/1+k)=0.}
\DoxyCodeLine{2842               vmask(i-\/1:i,j-\/1+k)=0.}
\DoxyCodeLine{2843               v\_face\_mask(i,j-\/1+k)=0.}
\DoxyCodeLine{2844             \textcolor{keywordflow}{case} (1) \textcolor{comment}{! stress free y-\/boundary}}
\DoxyCodeLine{2845               vmask(i-\/1:i,j-\/1+k)=0.}
\DoxyCodeLine{2846 \textcolor{keywordflow}{            case default}}
\DoxyCodeLine{2847 \textcolor{keywordflow}{          end select}}
\DoxyCodeLine{2848 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2849 }
\DoxyCodeLine{2850         \textcolor{comment}{!if (CS\%u\_face\_mask\_bdry(I-\/1,j) >= 0) then ! Western boundary}}
\DoxyCodeLine{2851         \textcolor{comment}{!  u\_face\_mask(I-\/1,j) = CS\%u\_face\_mask\_bdry(I-\/1,j)}}
\DoxyCodeLine{2852         \textcolor{comment}{!  umask(I-\/1,J-\/1:J) = 3.}}
\DoxyCodeLine{2853         \textcolor{comment}{!  vmask(I-\/1,J-\/1:J) = 0.}}
\DoxyCodeLine{2854         \textcolor{comment}{!endif}}
\DoxyCodeLine{2855 }
\DoxyCodeLine{2856         \textcolor{comment}{!if (j\_off+j == gjsc+1) then ! SoutherN boundary}}
\DoxyCodeLine{2857         \textcolor{comment}{!  v\_face\_mask(i,J-\/1) = 0.}}
\DoxyCodeLine{2858         \textcolor{comment}{!  umask(I-\/1:I,J-\/1) = 0.}}
\DoxyCodeLine{2859         \textcolor{comment}{!  vmask(I-\/1:I,J-\/1) = 0.}}
\DoxyCodeLine{2860         \textcolor{comment}{!elseif (j\_off+j == gjec) then ! Northern boundary}}
\DoxyCodeLine{2861         \textcolor{comment}{!  v\_face\_mask(i,J) = 0.}}
\DoxyCodeLine{2862         \textcolor{comment}{!  umask(I-\/1:I,J) = 0.}}
\DoxyCodeLine{2863         \textcolor{comment}{!  vmask(I-\/1:I,J) = 0.}}
\DoxyCodeLine{2864         \textcolor{comment}{!endif}}
\DoxyCodeLine{2865 }
\DoxyCodeLine{2866         \textcolor{keywordflow}{if} (i < g\%ied) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2867           \textcolor{keywordflow}{if} ((hmask(i+1,j) == 0) .OR. (hmask(i+1,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2868             \textcolor{comment}{! east boundary or adjacent to unfilled cell}}
\DoxyCodeLine{2869             u\_face\_mask(i,j) = 2.}
\DoxyCodeLine{2870 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2871 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2872 }
\DoxyCodeLine{2873         \textcolor{keywordflow}{if} (i > g\%isd) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2874           \textcolor{keywordflow}{if} ((hmask(i-\/1,j) == 0) .OR. (hmask(i-\/1,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2875             \textcolor{comment}{!adjacent to unfilled cell}}
\DoxyCodeLine{2876             u\_face\_mask(i-\/1,j) = 2.}
\DoxyCodeLine{2877 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2878 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2879 }
\DoxyCodeLine{2880         \textcolor{keywordflow}{if} (j > g\%jsd) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2881           \textcolor{keywordflow}{if} ((hmask(i,j-\/1) == 0) .OR. (hmask(i,j-\/1) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2882             \textcolor{comment}{!adjacent to unfilled cell}}
\DoxyCodeLine{2883             v\_face\_mask(i,j-\/1) = 2.}
\DoxyCodeLine{2884 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2885 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2886 }
\DoxyCodeLine{2887         \textcolor{keywordflow}{if} (j < g\%jed) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2888           \textcolor{keywordflow}{if} ((hmask(i,j+1) == 0) .OR. (hmask(i,j+1) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2889             \textcolor{comment}{!adjacent to unfilled cell}}
\DoxyCodeLine{2890             v\_face\_mask(i,j) = 2.}
\DoxyCodeLine{2891 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2892 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2893 }
\DoxyCodeLine{2894 }
\DoxyCodeLine{2895 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2896 }
\DoxyCodeLine{2897 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2898 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2899 }
\DoxyCodeLine{2900   \textcolor{comment}{! note: if the grid is nonsymmetric, there is a part that will not be transferred with a halo update}}
\DoxyCodeLine{2901   \textcolor{comment}{! so this subroutine must update its own symmetric part of the halo}}
\DoxyCodeLine{2902 }
\DoxyCodeLine{2903   \textcolor{keyword}{call }pass\_vector(u\_face\_mask, v\_face\_mask, g\%domain, to\_all, cgrid\_ne)}
\DoxyCodeLine{2904   \textcolor{keyword}{call }pass\_vector(umask, vmask, g\%domain, to\_all, bgrid\_ne)}
\DoxyCodeLine{2905 }

\end{DoxyCode}
