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


\doxysubsection{Detailed Description}
Implements the thermodynamic aspects of ocean / ice-\/shelf interactions, along with a crude placeholder for a later implementation of full ice shelf dynamics, all using the M\+OM framework and coding style. 

\hypertarget{namespacemom__ice__shelf_section_ICE_SHELF}{}\doxysubsection{section\+\_\+\+I\+C\+E\+\_\+\+S\+H\+E\+LF}\label{namespacemom__ice__shelf_section_ICE_SHELF}
This module implements the thermodynamic aspects of ocean/ice-\/shelf inter-\/actions using the M\+OM framework and coding style.

Derived from code by Chris Little, early 2010.

The ice-\/sheet dynamics subroutines do the following\+: initialize\+\_\+shelf\+\_\+mass -\/ Initializes the ice shelf mass distribution.
\begin{DoxyItemize}
\item Initializes h\+\_\+shelf, h\+\_\+mask, area\+\_\+shelf\+\_\+h
\item C\+U\+R\+R\+E\+N\+T\+LY\+: initializes mass\+\_\+shelf as well, but this is unnecessary, as mass\+\_\+shelf is initialized based on h\+\_\+shelf and density\+\_\+ice immediately afterwards. Possibly subroutine should be renamed update\+\_\+shelf\+\_\+mass -\/ updates ice shelf mass via net\+C\+DF file U\+S\+E\+R\+\_\+update\+\_\+shelf\+\_\+mass (T\+O\+DO). solo\+\_\+step\+\_\+ice\+\_\+shelf -\/ called only in ice-\/only mode. shelf\+\_\+calc\+\_\+flux -\/ after melt rate \& fluxes are calculated, ice dynamics are done. currently mass\+\_\+shelf is updated immediately after ice\+\_\+shelf\+\_\+advect in fully dynamic mode.
\end{DoxyItemize}

N\+O\+T\+ES\+: be aware that hmask(\+:,\+:) has a number of functions; it is used for front advancement, for subroutines in the velocity solve, and for thickness boundary conditions (this last one may be removed). in other words, interfering with its updates will have implications you might not expect.

Overall issues\+: Many variables need better documentation and units and the subgrid on which they are discretized.\hypertarget{namespacemom__ice__shelf_section_ICE_SHELF_equations}{}\doxysubsubsection{I\+C\+E\+\_\+\+S\+H\+E\+L\+F equations}\label{namespacemom__ice__shelf_section_ICE_SHELF_equations}
The three fundamental equations are\+: Heat flux \[ \qquad \rho_w C_{pw} \gamma_T (T_w - T_b) = \rho_i \dot{m} L_f \] Salt flux \[ \qquad \rho_w \gamma_s (S_w - S_b) = \rho_i \dot{m} S_b \] Freezing temperature \[ \qquad T_b = a S_b + b + c P \]

where ....\hypertarget{namespacemom__ice__shelf_section_ICE_SHELF_references}{}\doxysubsubsection{References}\label{namespacemom__ice__shelf_section_ICE_SHELF_references}
Asay-\/\+Davis, Xylar S., Stephen L. Cornford, Benjamin K. Galton-\/\+Fenzi, Rupert M. Gladstone, G. Hilmar Gudmundsson, David M. Holland, Paul R. Holland, and Daniel F. Martin. Experimental design for three interrelated marine ice sheet and ocean model intercomparison projects\+: M\+I\+S\+M\+IP v. 3 (M\+I\+S\+M\+I\+P+), I\+S\+O\+M\+IP v. 2 (I\+S\+O\+M\+I\+P+) and M\+I\+S\+O\+M\+IP v. 1 (M\+I\+S\+O\+M\+I\+P1). Geoscientific Model Development 9, no. 7 (2016)\+: 2471.

Goldberg, D. N., et al. Investigation of land ice-\/ocean interaction with a fully coupled ice-\/ocean model\+: 1. Model description and behavior. Journal of Geophysical Research\+: Earth Surface 117.\+F2 (2012).

Goldberg, D. N., et al. Investigation of land ice-\/ocean interaction with a fully coupled ice-\/ocean model\+: 2. Sensitivity to external forcings. Journal of Geophysical Research\+: Earth Surface 117.\+F2 (2012).

Holland, David M., and Adrian Jenkins. Modeling thermodynamic ice-\/ocean interactions at the base of an ice shelf. Journal of Physical Oceanography 29.\+8 (1999)\+: 1787-\/1800. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure that contains ice shelf parameters and diagnostics handles. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}{shelf\+\_\+calc\+\_\+flux}} (sfc\+\_\+state, fluxes, Time, time\+\_\+step, CS, forces)
\begin{DoxyCompactList}\small\item\em Calculates fluxes between the ocean and ice-\/shelf using the three-\/equations formulation (optional to use just two equations). See \mbox{\hyperlink{namespacemom__ice__shelf_section_ICE_SHELF_equations}{I\+C\+E\+\_\+\+S\+H\+E\+LF equations}}. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf_a787fc1ef4951b3bb4a7d654efb147fc4}{change\+\_\+thickness\+\_\+using\+\_\+melt}} (I\+SS, G, US, time\+\_\+step, fluxes, density\+\_\+ice, debug)
\begin{DoxyCompactList}\small\item\em Changes the thickness (mass) of the ice shelf based on sub-\/ice-\/shelf melting. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ice__shelf_a0274b25df07d5fa712d038c31f921cbc}{add\+\_\+shelf\+\_\+forces}} (G, US, CS, forces, do\+\_\+shelf\+\_\+area)
\begin{DoxyCompactList}\small\item\em This subroutine adds the mechanical forcing fields and perhaps shelf areas, based on the ice state in ice\+\_\+shelf\+\_\+\+CS. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf_aca1d1c1db015f270ce1b1f93d16dea91}{add\+\_\+shelf\+\_\+pressure}} (G, US, CS, fluxes)
\begin{DoxyCompactList}\small\item\em This subroutine adds the ice shelf pressure to the fluxes type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ice__shelf_a8f7eae8642835e30aff99f77f3836945}{add\+\_\+shelf\+\_\+flux}} (G, US, CS, sfc\+\_\+state, fluxes)
\begin{DoxyCompactList}\small\item\em Updates surface fluxes that are influenced by sub-\/ice-\/shelf melting. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}{initialize\+\_\+ice\+\_\+shelf}} (param\+\_\+file, ocn\+\_\+grid, Time, CS, diag, forces, fluxes, Time\+\_\+in, 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_ac478a1dd52137f8e851916bee2243fa3}{initialize\+\_\+shelf\+\_\+mass}} (G, param\+\_\+file, CS, I\+SS, new\+\_\+sim)
\begin{DoxyCompactList}\small\item\em Initializes shelf mass based on three options (file, zero and user) \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ice__shelf_a6f0fa9f98ac01752ca2983c7e9816097}{update\+\_\+shelf\+\_\+mass}} (G, US, CS, I\+SS, Time)
\begin{DoxyCompactList}\small\item\em Updates the ice shelf mass using data from a file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ice__shelf_a40ae01bbe3155191647f2150903dda69}{ice\+\_\+shelf\+\_\+save\+\_\+restart}} (CS, Time, directory, time\+\_\+stamped, filename\+\_\+suffix)
\begin{DoxyCompactList}\small\item\em Save the ice shelf restart file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ice__shelf_a6d0412c7264e0480d5144d26995dd8d3}{ice\+\_\+shelf\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Deallocates all memory associated with this module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ice__shelf_a0678e919d45fc9e9e9b00dce3564a2fc}{solo\+\_\+step\+\_\+ice\+\_\+shelf}} (CS, time\+\_\+interval, nsteps, Time, min\+\_\+time\+\_\+step\+\_\+in)
\begin{DoxyCompactList}\small\item\em This routine is for stepping a stand-\/alone ice shelf model without an ocean. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}\label{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}} 
integer \mbox{\hyperlink{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}{id\+\_\+clock\+\_\+shelf}}
\begin{DoxyCompactList}\small\item\em C\+PU Clock for the ice shelf code. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}\label{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}} 
integer \mbox{\hyperlink{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}{id\+\_\+clock\+\_\+pass}}
\begin{DoxyCompactList}\small\item\em C\+PU Clock for group pass calls. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__ice__shelf_a8f7eae8642835e30aff99f77f3836945}\label{namespacemom__ice__shelf_a8f7eae8642835e30aff99f77f3836945}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!add\_shelf\_flux@{add\_shelf\_flux}}
\index{add\_shelf\_flux@{add\_shelf\_flux}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{add\_shelf\_flux()}{add\_shelf\_flux()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::add\+\_\+shelf\+\_\+flux (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS,  }\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(forcing), intent(inout)}]{fluxes }\end{DoxyParamCaption})}



Updates surface fluxes that are influenced by sub-\/ice-\/shelf melting. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & This module\textquotesingle{}s control structure. \\
\hline
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & Surface ocean state \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure of surface fluxes that may be used/updated. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{885   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{886   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{887   \textcolor{keywordtype}{type}(ice\_shelf\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< This module's control structure.}}
\DoxyCodeLine{888   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< Surface ocean state}}
\DoxyCodeLine{889   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{  !< A structure of surface fluxes that may be used/updated.}}
\DoxyCodeLine{890 }
\DoxyCodeLine{891   \textcolor{comment}{! local variables}}
\DoxyCodeLine{892 \textcolor{keywordtype}{  real} :: frac\_shelf\textcolor{comment}{       !< The fractional area covered by the ice shelf [nondim].}}
\DoxyCodeLine{893 \textcolor{keywordtype}{  real} :: frac\_open\textcolor{comment}{        !< The fractional area of the ocean that is not covered by the ice shelf [nondim].}}
\DoxyCodeLine{894 \textcolor{keywordtype}{  real} :: delta\_mass\_shelf\textcolor{comment}{ !< Change in ice shelf mass over one time step [R Z m2 T-\/1 ~> kg s-\/1]}}
\DoxyCodeLine{895 \textcolor{keywordtype}{  real} :: balancing\_flux\textcolor{comment}{   !< The fresh water flux that balances the integrated melt flux [R Z T-\/1 ~> kg m-\/2 s-\/1]}}
\DoxyCodeLine{896 \textcolor{keywordtype}{  real} :: balancing\_area\textcolor{comment}{   !< total area where the balancing flux is applied [m2]}}
\DoxyCodeLine{897   \textcolor{keywordtype}{type}(time\_type) :: dTime\textcolor{comment}{ !< The time step as a time\_type}}
\DoxyCodeLine{898   \textcolor{keywordtype}{type}(time\_type) :: Time0\textcolor{comment}{ !< The previous time (Time-\/dt)}}
\DoxyCodeLine{899 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: bal\_frac\textcolor{comment}{  !< Fraction of the cel1 where the mass flux}}
\DoxyCodeLine{900 \textcolor{comment}{                          !! balancing the net melt flux occurs, 0 to 1 [nondim]}}
\DoxyCodeLine{901 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: last\_mass\_shelf\textcolor{comment}{ !< Ice shelf mass}}
\DoxyCodeLine{902 \textcolor{comment}{                          !! at at previous time (Time-\/dt) [R Z ~> kg m-\/2]}}
\DoxyCodeLine{903 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: delta\_float\_mass\textcolor{comment}{   !< The change in the floating mass between}}
\DoxyCodeLine{904 \textcolor{comment}{                          !! the two timesteps at (Time) and (Time-\/dt) [R Z ~> kg m-\/2].}}
\DoxyCodeLine{905 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_h\_shelf\textcolor{comment}{ !< Ice shelf thickness [Z ~> m]}}
\DoxyCodeLine{906 \textcolor{comment}{                          !! at at previous time (Time-\/dt)}}
\DoxyCodeLine{907 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_hmask\textcolor{comment}{ !< Ice shelf mask [nondim]}}
\DoxyCodeLine{908 \textcolor{comment}{                          !! at at previous time (Time-\/dt)}}
\DoxyCodeLine{909 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_area\_shelf\_h\textcolor{comment}{ !< Ice shelf area [L2 ~> m2]}}
\DoxyCodeLine{910 \textcolor{comment}{                          !! at at previous time (Time-\/dt)}}
\DoxyCodeLine{911   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: ISS => null() \textcolor{comment}{!< A structure with elements that describe}}
\DoxyCodeLine{912 \textcolor{comment}{                                          !! the ice-\/shelf state}}
\DoxyCodeLine{913 }
\DoxyCodeLine{914   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{915   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{916   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{917   isd = g\%isd ; jsd = g\%jsd ; ied = g\%ied ; jed = g\%jed}
\DoxyCodeLine{918 }
\DoxyCodeLine{919   \textcolor{keywordflow}{if} ((cs\%grid\%isc /= g\%isc) .or. (cs\%grid\%iec /= g\%iec) .or. \&}
\DoxyCodeLine{920       (cs\%grid\%jsc /= g\%jsc) .or. (cs\%grid\%jec /= g\%jec)) \&}
\DoxyCodeLine{921     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_flux: Incompatible ocean and ice shelf grids."})}
\DoxyCodeLine{922 }
\DoxyCodeLine{923   iss => cs\%ISS}
\DoxyCodeLine{924 }
\DoxyCodeLine{925 }
\DoxyCodeLine{926   \textcolor{keyword}{call }add\_shelf\_pressure(g, us, cs, fluxes)}
\DoxyCodeLine{927 }
\DoxyCodeLine{928   \textcolor{comment}{! Determine ustar and the square magnitude of the velocity in the}}
\DoxyCodeLine{929   \textcolor{comment}{! bottom boundary layer. Together these give the TKE source and}}
\DoxyCodeLine{930   \textcolor{comment}{! vertical decay scale.}}
\DoxyCodeLine{931 }
\DoxyCodeLine{932   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{933     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state\%taux\_shelf) .and. \textcolor{keyword}{allocated}(sfc\_state\%tauy\_shelf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{934       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"tau[xy]\_shelf"}, sfc\_state\%taux\_shelf, sfc\_state\%tauy\_shelf, \&}
\DoxyCodeLine{935                     g\%HI, haloshift=0, scale=us\%RZ\_T\_to\_kg\_m2s*us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{936 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{937 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{938 }
\DoxyCodeLine{939   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics .or. cs\%override\_shelf\_movement) \textcolor{keywordflow}{then}}
\DoxyCodeLine{940     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{941       \textcolor{keywordflow}{if} (g\%areaT(i,j) > 0.0) \&}
\DoxyCodeLine{942         fluxes\%frac\_shelf\_h(i,j) = min(1.0, iss\%area\_shelf\_h(i,j) * g\%IareaT(i,j))}
\DoxyCodeLine{943 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{944 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{945 }
\DoxyCodeLine{946   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{947     \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"Before adding shelf fluxes"}, fluxes, g, cs\%US, haloshift=0)}
\DoxyCodeLine{948 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{949 }
\DoxyCodeLine{950   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (iss\%area\_shelf\_h(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{951     \textcolor{comment}{! Replace fluxes intercepted by the ice shelf with fluxes from the ice shelf}}
\DoxyCodeLine{952     frac\_shelf = min(1.0, iss\%area\_shelf\_h(i,j) * g\%IareaT(i,j))}
\DoxyCodeLine{953     frac\_open = max(0.0, 1.0 -\/ frac\_shelf)}
\DoxyCodeLine{954 }
\DoxyCodeLine{955     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%sw)) fluxes\%sw(i,j) = frac\_open * fluxes\%sw(i,j)}
\DoxyCodeLine{956     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%sw\_vis\_dir)) fluxes\%sw\_vis\_dir(i,j) = frac\_open * fluxes\%sw\_vis\_dir(i,j)}
\DoxyCodeLine{957     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%sw\_vis\_dif)) fluxes\%sw\_vis\_dif(i,j) = frac\_open * fluxes\%sw\_vis\_dif(i,j)}
\DoxyCodeLine{958     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%sw\_nir\_dir)) fluxes\%sw\_nir\_dir(i,j) = frac\_open * fluxes\%sw\_nir\_dir(i,j)}
\DoxyCodeLine{959     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%sw\_nir\_dif)) fluxes\%sw\_nir\_dif(i,j) = frac\_open * fluxes\%sw\_nir\_dif(i,j)}
\DoxyCodeLine{960     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%lw)) fluxes\%lw(i,j) = frac\_open * fluxes\%lw(i,j)}
\DoxyCodeLine{961     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%latent)) fluxes\%latent(i,j) = frac\_open * fluxes\%latent(i,j)}
\DoxyCodeLine{962     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%evap)) fluxes\%evap(i,j) = frac\_open * fluxes\%evap(i,j)}
\DoxyCodeLine{963     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%lprec)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{964       \textcolor{keywordflow}{if} (iss\%water\_flux(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{965         fluxes\%lprec(i,j) =  frac\_shelf*iss\%water\_flux(i,j)*cs\%flux\_factor + frac\_open * fluxes\%lprec(i,j)}
\DoxyCodeLine{966       \textcolor{keywordflow}{else}}
\DoxyCodeLine{967         fluxes\%lprec(i,j) = frac\_open * fluxes\%lprec(i,j)}
\DoxyCodeLine{968         fluxes\%evap(i,j) = fluxes\%evap(i,j) + frac\_shelf*iss\%water\_flux(i,j)*cs\%flux\_factor}
\DoxyCodeLine{969 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{970 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{971 }
\DoxyCodeLine{972     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%sens)) \&}
\DoxyCodeLine{973       fluxes\%sens(i,j) = frac\_shelf*iss\%tflux\_ocn(i,j)*cs\%flux\_factor + frac\_open * fluxes\%sens(i,j)}
\DoxyCodeLine{974     \textcolor{comment}{! The salt flux should be mostly from sea ice, so perhaps none should be intercepted and this should be changed.}}
\DoxyCodeLine{975     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%salt\_flux)) \&}
\DoxyCodeLine{976       fluxes\%salt\_flux(i,j) = frac\_shelf * iss\%salt\_flux(i,j)*cs\%flux\_factor + frac\_open * fluxes\%salt\_flux(i,j)}
\DoxyCodeLine{977 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{978 }
\DoxyCodeLine{979   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{980     \textcolor{keyword}{call }hchksum(iss\%water\_flux, \textcolor{stringliteral}{"water\_flux add shelf fluxes"}, g\%HI, haloshift=0, scale=us\%RZ\_T\_to\_kg\_m2s)}
\DoxyCodeLine{981     \textcolor{keyword}{call }hchksum(iss\%tflux\_ocn, \textcolor{stringliteral}{"tflux\_ocn add shelf fluxes"}, g\%HI, haloshift=0, scale=us\%QRZ\_T\_to\_W\_m2)}
\DoxyCodeLine{982     \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"After adding shelf fluxes"}, fluxes, g, cs\%US, haloshift=0)}
\DoxyCodeLine{983 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{984 }
\DoxyCodeLine{985   \textcolor{comment}{! Keep sea level constant by removing mass via a balancing flux that might be applied}}
\DoxyCodeLine{986   \textcolor{comment}{! in the open ocean or the sponge region (via virtual precip, vprec). Apply additional}}
\DoxyCodeLine{987   \textcolor{comment}{! salt/heat fluxes so that the resultant surface buoyancy forcing is ~ 0.}}
\DoxyCodeLine{988   \textcolor{comment}{! This is needed for some of the ISOMIP+ experiments.}}
\DoxyCodeLine{989 }
\DoxyCodeLine{990   \textcolor{keywordflow}{if} (cs\%constant\_sea\_level) \textcolor{keywordflow}{then}}
\DoxyCodeLine{991     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(fluxes\%salt\_flux)) \textcolor{keyword}{allocate}(fluxes\%salt\_flux(ie,je))}
\DoxyCodeLine{992     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(fluxes\%vprec)) \textcolor{keyword}{allocate}(fluxes\%vprec(ie,je))}
\DoxyCodeLine{993     fluxes\%salt\_flux(:,:) = 0.0 ; fluxes\%vprec(:,:) = 0.0}
\DoxyCodeLine{994 }
\DoxyCodeLine{995     \textcolor{comment}{! take into account changes in mass (or thickness) when imposing ice shelf mass}}
\DoxyCodeLine{996     \textcolor{keywordflow}{if} (cs\%override\_shelf\_movement .and. cs\%mass\_from\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{997       dtime = real\_to\_time(cs\%time\_step)}
\DoxyCodeLine{998 }
\DoxyCodeLine{999       \textcolor{comment}{! Compute changes in mass after at least one full time step}}
\DoxyCodeLine{1000       \textcolor{keywordflow}{if} (cs\%Time > dtime) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1001         time0 = cs\%Time -\/ dtime}
\DoxyCodeLine{1002         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1003           last\_hmask(i,j) = iss\%hmask(i,j) ; last\_area\_shelf\_h(i,j) = iss\%area\_shelf\_h(i,j)}
\DoxyCodeLine{1004 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1005         \textcolor{keyword}{call }time\_interp\_external(cs\%id\_read\_mass, time0, last\_mass\_shelf)}
\DoxyCodeLine{1006         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1007         \textcolor{comment}{! This should only be done if time\_interp\_external did an update.}}
\DoxyCodeLine{1008           last\_mass\_shelf(i,j) = us\%kg\_m3\_to\_R*us\%m\_to\_Z * last\_mass\_shelf(i,j) \textcolor{comment}{! Rescale after time\_interp}}
\DoxyCodeLine{1009           last\_h\_shelf(i,j) = last\_mass\_shelf(i,j) / cs\%density\_ice}
\DoxyCodeLine{1010 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1011 }
\DoxyCodeLine{1012         \textcolor{comment}{! apply calving}}
\DoxyCodeLine{1013         \textcolor{keywordflow}{if} (cs\%min\_thickness\_simple\_calve > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1014           \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, last\_h\_shelf, last\_area\_shelf\_h, last\_hmask, \&}
\DoxyCodeLine{1015                                        cs\%min\_thickness\_simple\_calve, halo=0)}
\DoxyCodeLine{1016           \textcolor{comment}{! convert to mass again}}
\DoxyCodeLine{1017           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1018             last\_mass\_shelf(i,j) = last\_h\_shelf(i,j) * cs\%density\_ice}
\DoxyCodeLine{1019 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1020 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1021 }
\DoxyCodeLine{1022         \textcolor{comment}{! get total ice shelf mass at (Time-\/dt) and (Time), in kg}}
\DoxyCodeLine{1023         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1024           \textcolor{comment}{! Just consider the change in the mass of the floating shelf.}}
\DoxyCodeLine{1025           \textcolor{keywordflow}{if} ((sfc\_state\%ocean\_mass(i,j) > cs\%min\_ocean\_mass\_float) .and. \&}
\DoxyCodeLine{1026               (iss\%area\_shelf\_h(i,j) > 0.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1027             delta\_float\_mass(i,j) = iss\%mass\_shelf(i,j) -\/ last\_mass\_shelf(i,j)}
\DoxyCodeLine{1028           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1029             delta\_float\_mass(i,j) = 0.0}
\DoxyCodeLine{1030 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1031 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1032         delta\_mass\_shelf = us\%kg\_m2s\_to\_RZ\_T*(global\_area\_integral(delta\_float\_mass, g, scale=us\%RZ\_to\_kg\_m2, \&}
\DoxyCodeLine{1033                                                                    area=iss\%area\_shelf\_h) / cs\%time\_step)}
\DoxyCodeLine{1034       else\textcolor{comment}{! first time step}}
\DoxyCodeLine{1035         delta\_mass\_shelf = 0.0}
\DoxyCodeLine{1036 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1037     \textcolor{keywordflow}{else} \textcolor{comment}{! ice shelf mass does not change}}
\DoxyCodeLine{1038       delta\_mass\_shelf = 0.0}
\DoxyCodeLine{1039 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1040 }
\DoxyCodeLine{1041     \textcolor{comment}{! average total melt flux over sponge area}}
\DoxyCodeLine{1042     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1043       \textcolor{keywordflow}{if} ((g\%mask2dT(i,j) > 0.0) .AND. (iss\%area\_shelf\_h(i,j) * g\%IareaT(i,j) < 1.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1044          \textcolor{comment}{! Uncomment this for some ISOMIP cases:}}
\DoxyCodeLine{1045          \textcolor{comment}{!  .AND. (G\%geoLonT(i,j) >= 790.0) .AND. (G\%geoLonT(i,j) <= 800.0)) then}}
\DoxyCodeLine{1046         bal\_frac(i,j) = max(1.0 -\/ iss\%area\_shelf\_h(i,j) * g\%IareaT(i,j), 0.0)}
\DoxyCodeLine{1047       \textcolor{keywordflow}{else}}
\DoxyCodeLine{1048         bal\_frac(i,j) = 0.0}
\DoxyCodeLine{1049 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1050 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1051 }
\DoxyCodeLine{1052     balancing\_area = global\_area\_integral(bal\_frac, g)}
\DoxyCodeLine{1053     \textcolor{keywordflow}{if} (balancing\_area > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1054       balancing\_flux = ( us\%kg\_m2s\_to\_RZ\_T*global\_area\_integral(iss\%water\_flux, g, scale=us\%RZ\_T\_to\_kg\_m2s, \&}
\DoxyCodeLine{1055                                                                 area=iss\%area\_shelf\_h) + \&}
\DoxyCodeLine{1056                          delta\_mass\_shelf ) / balancing\_area}
\DoxyCodeLine{1057     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1058       balancing\_flux = 0.0}
\DoxyCodeLine{1059 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1060 }
\DoxyCodeLine{1061     \textcolor{comment}{! apply fluxes}}
\DoxyCodeLine{1062     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1063       \textcolor{keywordflow}{if} (bal\_frac(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1064         \textcolor{comment}{! evap is negative, and vprec has units of [R Z T-\/1 ~> kg m-\/2 s-\/1]}}
\DoxyCodeLine{1065         fluxes\%vprec(i,j) = -\/balancing\_flux}
\DoxyCodeLine{1066         fluxes\%sens(i,j) = fluxes\%vprec(i,j) * cs\%Cp * cs\%T0 \textcolor{comment}{! [ Q R Z T-\/1 ~> W /m\string^2 ]}}
\DoxyCodeLine{1067         fluxes\%salt\_flux(i,j) = fluxes\%vprec(i,j) * cs\%S0*1.0e-\/3 \textcolor{comment}{! [kgSalt/kg R Z T-\/1 ~> kgSalt m-\/2 s-\/1]}}
\DoxyCodeLine{1068 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1069 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1070 }
\DoxyCodeLine{1071     \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1072       \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'Balancing flux (kg/(m\string^2 s)), dt = '}, balancing\_flux*us\%RZ\_T\_to\_kg\_m2s, cs\%time\_step}
\DoxyCodeLine{1073       \textcolor{keyword}{call }mom\_mesg(mesg)}
\DoxyCodeLine{1074       \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"After constant sea level"}, fluxes, g, cs\%US, haloshift=0)}
\DoxyCodeLine{1075 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1076 }
\DoxyCodeLine{1077 \textcolor{keywordflow}{  endif} \textcolor{comment}{! constant\_sea\_level}}
\DoxyCodeLine{1078 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a0274b25df07d5fa712d038c31f921cbc}\label{namespacemom__ice__shelf_a0274b25df07d5fa712d038c31f921cbc}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!add\_shelf\_forces@{add\_shelf\_forces}}
\index{add\_shelf\_forces@{add\_shelf\_forces}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{add\_shelf\_forces()}{add\_shelf\_forces()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::add\+\_\+shelf\+\_\+forces (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{logical, intent(in), optional}]{do\+\_\+shelf\+\_\+area }\end{DoxyParamCaption})}



This subroutine adds the mechanical forcing fields and perhaps shelf areas, based on the ice state in ice\+\_\+shelf\+\_\+\+CS. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & This module\textquotesingle{}s control structure. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em do\+\_\+shelf\+\_\+area} & If true find the shelf-\/covered areas. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{776   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{777   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{778   \textcolor{keywordtype}{type}(ice\_shelf\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< This module's control structure.}}
\DoxyCodeLine{779   \textcolor{keywordtype}{type}(mech\_forcing),    \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{780   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)}    :: do\_shelf\_area\textcolor{comment}{ !< If true find the shelf-\/covered areas.}}
\DoxyCodeLine{781 }
\DoxyCodeLine{782 \textcolor{keywordtype}{  real} :: kv\_rho\_ice \textcolor{comment}{! The viscosity of ice divided by its density [L4 T-\/1 R-\/1 Z-\/2 ~> m5 kg-\/1 s-\/1].}}
\DoxyCodeLine{783 \textcolor{keywordtype}{  real} :: press\_ice  \textcolor{comment}{! The pressure of the ice shelf per unit area of ocean (not ice) [R L2 T-\/2 ~> Pa].}}
\DoxyCodeLine{784   \textcolor{keywordtype}{logical} :: find\_area \textcolor{comment}{! If true find the shelf areas at u \& v points.}}
\DoxyCodeLine{785   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: ISS => null() \textcolor{comment}{! A structure with elements that describe}}
\DoxyCodeLine{786                                           \textcolor{comment}{! the ice-\/shelf state}}
\DoxyCodeLine{787 }
\DoxyCodeLine{788   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{789   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{790   isd = g\%isd ; jsd = g\%jsd ; ied = g\%ied ; jed = g\%jed}
\DoxyCodeLine{791 }
\DoxyCodeLine{792   \textcolor{keywordflow}{if} ((cs\%grid\%isc /= g\%isc) .or. (cs\%grid\%iec /= g\%iec) .or. \&}
\DoxyCodeLine{793       (cs\%grid\%jsc /= g\%jsc) .or. (cs\%grid\%jec /= g\%jec)) \&}
\DoxyCodeLine{794     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_forces: Incompatible ocean and ice shelf grids."})}
\DoxyCodeLine{795 }
\DoxyCodeLine{796   iss => cs\%ISS}
\DoxyCodeLine{797 }
\DoxyCodeLine{798   find\_area = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(do\_shelf\_area)) find\_area = do\_shelf\_area}
\DoxyCodeLine{799 }
\DoxyCodeLine{800   \textcolor{keywordflow}{if} (find\_area) \textcolor{keywordflow}{then}}
\DoxyCodeLine{801     \textcolor{comment}{! The frac\_shelf is set over the widest possible area. Could it be smaller?}}
\DoxyCodeLine{802     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied-\/1}
\DoxyCodeLine{803       forces\%frac\_shelf\_u(i,j) = 0.0}
\DoxyCodeLine{804       \textcolor{keywordflow}{if} ((g\%areaT(i,j) + g\%areaT(i+1,j) > 0.0)) \& \textcolor{comment}{! .and. (G\%areaCu(I,j) > 0.0)) \&}}
\DoxyCodeLine{805         forces\%frac\_shelf\_u(i,j) = (iss\%area\_shelf\_h(i,j) + iss\%area\_shelf\_h(i+1,j)) / \&}
\DoxyCodeLine{806                                    (g\%areaT(i,j) + g\%areaT(i+1,j))}
\DoxyCodeLine{807 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{808     \textcolor{keywordflow}{do} j=jsd,jed-\/1 ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{809       forces\%frac\_shelf\_v(i,j) = 0.0}
\DoxyCodeLine{810       \textcolor{keywordflow}{if} ((g\%areaT(i,j) + g\%areaT(i,j+1) > 0.0)) \& \textcolor{comment}{! .and. (G\%areaCv(i,J) > 0.0)) \&}}
\DoxyCodeLine{811         forces\%frac\_shelf\_v(i,j) = (iss\%area\_shelf\_h(i,j) + iss\%area\_shelf\_h(i,j+1)) / \&}
\DoxyCodeLine{812                                    (g\%areaT(i,j) + g\%areaT(i,j+1))}
\DoxyCodeLine{813 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{814     \textcolor{keyword}{call }pass\_vector(forces\%frac\_shelf\_u, forces\%frac\_shelf\_v, g\%domain, to\_all, cgrid\_ne)}
\DoxyCodeLine{815 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{816 }
\DoxyCodeLine{817   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{818     press\_ice = (iss\%area\_shelf\_h(i,j) * g\%IareaT(i,j)) * (cs\%g\_Earth * iss\%mass\_shelf(i,j))}
\DoxyCodeLine{819     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces\%p\_surf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{820       \textcolor{keywordflow}{if} (.not.forces\%accumulate\_p\_surf) forces\%p\_surf(i,j) = 0.0}
\DoxyCodeLine{821       forces\%p\_surf(i,j) = forces\%p\_surf(i,j) + press\_ice}
\DoxyCodeLine{822 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{823     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces\%p\_surf\_full)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{824       \textcolor{keywordflow}{if} (.not.forces\%accumulate\_p\_surf) forces\%p\_surf\_full(i,j) = 0.0}
\DoxyCodeLine{825       forces\%p\_surf\_full(i,j) = forces\%p\_surf\_full(i,j) + press\_ice}
\DoxyCodeLine{826 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{827 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{828 }
\DoxyCodeLine{829   \textcolor{comment}{! For various reasons, forces\%rigidity\_ice\_[uv] is always updated here. Note}}
\DoxyCodeLine{830   \textcolor{comment}{! that it may have been zeroed out where IOB is translated to forces and}}
\DoxyCodeLine{831   \textcolor{comment}{! contributions from icebergs and the sea-\/ice pack added subsequently.}}
\DoxyCodeLine{832   \textcolor{comment}{!\#\#\# THE RIGIDITY SHOULD ALSO INCORPORATE AREAL-\/COVERAGE INFORMATION.}}
\DoxyCodeLine{833   kv\_rho\_ice = cs\%kv\_ice / cs\%density\_ice}
\DoxyCodeLine{834   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-\/1,ie}
\DoxyCodeLine{835     \textcolor{keywordflow}{if} (.not.forces\%accumulate\_rigidity) forces\%rigidity\_ice\_u(i,j) = 0.0}
\DoxyCodeLine{836     forces\%rigidity\_ice\_u(i,j) = forces\%rigidity\_ice\_u(i,j) + \&}
\DoxyCodeLine{837             kv\_rho\_ice * min(iss\%mass\_shelf(i,j), iss\%mass\_shelf(i+1,j))}
\DoxyCodeLine{838 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{839   \textcolor{keywordflow}{do} j=js-\/1,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{840     \textcolor{keywordflow}{if} (.not.forces\%accumulate\_rigidity) forces\%rigidity\_ice\_v(i,j) = 0.0}
\DoxyCodeLine{841     forces\%rigidity\_ice\_v(i,j) = forces\%rigidity\_ice\_v(i,j) + \&}
\DoxyCodeLine{842             kv\_rho\_ice * min(iss\%mass\_shelf(i,j), iss\%mass\_shelf(i,j+1))}
\DoxyCodeLine{843 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{844 }
\DoxyCodeLine{845   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{846     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"rigidity\_ice\_[uv]"}, forces\%rigidity\_ice\_u, forces\%rigidity\_ice\_v, \&}
\DoxyCodeLine{847                   g\%HI, symmetric=.true., scale=us\%L\_to\_m**3*us\%L\_to\_Z*us\%s\_to\_T)}
\DoxyCodeLine{848     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"frac\_shelf\_[uv]"}, forces\%frac\_shelf\_u, forces\%frac\_shelf\_v, \&}
\DoxyCodeLine{849                   g\%HI, symmetric=.true.)}
\DoxyCodeLine{850 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{851 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_aca1d1c1db015f270ce1b1f93d16dea91}\label{namespacemom__ice__shelf_aca1d1c1db015f270ce1b1f93d16dea91}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!add\_shelf\_pressure@{add\_shelf\_pressure}}
\index{add\_shelf\_pressure@{add\_shelf\_pressure}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{add\_shelf\_pressure()}{add\_shelf\_pressure()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+::add\+\_\+shelf\+\_\+pressure (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), intent(in)}]{CS,  }\item[{type(forcing), intent(inout)}]{fluxes }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine adds the ice shelf pressure to the fluxes type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em cs} & This module\textquotesingle{}s control structure. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure of surface fluxes that may be updated. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{856   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{857   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{858   \textcolor{keywordtype}{type}(ice\_shelf\_CS),    \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{   !< This module's control structure.}}
\DoxyCodeLine{859   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{  !< A structure of surface fluxes that may be updated.}}
\DoxyCodeLine{860 }
\DoxyCodeLine{861 \textcolor{keywordtype}{  real} :: press\_ice\textcolor{comment}{       !< The pressure of the ice shelf per unit area of ocean (not ice) [R L2 T-\/2 ~> Pa].}}
\DoxyCodeLine{862   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{863   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{864 }
\DoxyCodeLine{865   \textcolor{keywordflow}{if} ((cs\%grid\%isc /= g\%isc) .or. (cs\%grid\%iec /= g\%iec) .or. \&}
\DoxyCodeLine{866       (cs\%grid\%jsc /= g\%jsc) .or. (cs\%grid\%jec /= g\%jec)) \&}
\DoxyCodeLine{867     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_pressure: Incompatible ocean and ice shelf grids."})}
\DoxyCodeLine{868 }
\DoxyCodeLine{869   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{870     press\_ice = (cs\%ISS\%area\_shelf\_h(i,j) * g\%IareaT(i,j)) * (cs\%g\_Earth * cs\%ISS\%mass\_shelf(i,j))}
\DoxyCodeLine{871     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%p\_surf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{872       \textcolor{keywordflow}{if} (.not.fluxes\%accumulate\_p\_surf) fluxes\%p\_surf(i,j) = 0.0}
\DoxyCodeLine{873       fluxes\%p\_surf(i,j) = fluxes\%p\_surf(i,j) + press\_ice}
\DoxyCodeLine{874 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{875     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%p\_surf\_full)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{876       \textcolor{keywordflow}{if} (.not.fluxes\%accumulate\_p\_surf) fluxes\%p\_surf\_full(i,j) = 0.0}
\DoxyCodeLine{877       fluxes\%p\_surf\_full(i,j) = fluxes\%p\_surf\_full(i,j) + press\_ice}
\DoxyCodeLine{878 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{879 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{880 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a787fc1ef4951b3bb4a7d654efb147fc4}\label{namespacemom__ice__shelf_a787fc1ef4951b3bb4a7d654efb147fc4}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!change\_thickness\_using\_melt@{change\_thickness\_using\_melt}}
\index{change\_thickness\_using\_melt@{change\_thickness\_using\_melt}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{change\_thickness\_using\_melt()}{change\_thickness\_using\_melt()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+::change\+\_\+thickness\+\_\+using\+\_\+melt (\begin{DoxyParamCaption}\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(forcing), intent(inout)}]{fluxes,  }\item[{real, intent(in)}]{density\+\_\+ice,  }\item[{logical, intent(in), optional}]{debug }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Changes the thickness (mass) of the ice shelf based on sub-\/ice-\/shelf melting. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in,out}}  & {\em iss} & A structure with elements that describe the ice-\/shelf state \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & structure containing pointers to any possible thermodynamic or mass-\/flux forcing fields. \\
\hline
\mbox{\texttt{ in}}  & {\em density\+\_\+ice} & The density of ice-\/shelf ice \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em debug} & If present and true, write chksums \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{728   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The ocean's grid structure.}}
\DoxyCodeLine{729   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(inout)} :: ISS\textcolor{comment}{ !< A structure with elements that describe}}
\DoxyCodeLine{730 \textcolor{comment}{                                              !! the ice-\/shelf state}}
\DoxyCodeLine{731   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{732 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}}
\DoxyCodeLine{733   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< structure containing pointers to any possible}}
\DoxyCodeLine{734 \textcolor{comment}{                                                 !! thermodynamic or mass-\/flux forcing fields.}}
\DoxyCodeLine{735 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: density\_ice\textcolor{comment}{ !< The density of ice-\/shelf ice [R ~> kg m-\/3].}}
\DoxyCodeLine{736   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{ !< If present and true, write chksums}}
\DoxyCodeLine{737 }
\DoxyCodeLine{738   \textcolor{comment}{! locals}}
\DoxyCodeLine{739 \textcolor{keywordtype}{  real} :: I\_rho\_ice \textcolor{comment}{! Ice specific volume [R-\/1 ~> m3 kg-\/1]}}
\DoxyCodeLine{740   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{741 }
\DoxyCodeLine{742   i\_rho\_ice = 1.0 / density\_ice}
\DoxyCodeLine{743 }
\DoxyCodeLine{744 }
\DoxyCodeLine{745   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{746     \textcolor{keywordflow}{if} ((iss\%hmask(i,j) == 1) .or. (iss\%hmask(i,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{747       \textcolor{comment}{! first, zero out fluxes applied during previous time step}}
\DoxyCodeLine{748       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%lprec)) fluxes\%lprec(i,j) = 0.0}
\DoxyCodeLine{749       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%sens)) fluxes\%sens(i,j) = 0.0}
\DoxyCodeLine{750       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%frac\_shelf\_h)) fluxes\%frac\_shelf\_h(i,j) = 0.0}
\DoxyCodeLine{751       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%salt\_flux)) fluxes\%salt\_flux(i,j) = 0.0}
\DoxyCodeLine{752 }
\DoxyCodeLine{753       \textcolor{keywordflow}{if} (iss\%water\_flux(i,j) * time\_step / density\_ice < iss\%h\_shelf(i,j)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{754         iss\%h\_shelf(i,j) = iss\%h\_shelf(i,j) -\/ iss\%water\_flux(i,j) * time\_step / density\_ice}
\DoxyCodeLine{755       \textcolor{keywordflow}{else}}
\DoxyCodeLine{756         \textcolor{comment}{! the ice is about to melt away, so set thickness, area, and mask to zero}}
\DoxyCodeLine{757         \textcolor{comment}{! NOTE: this is not mass conservative should maybe scale salt \& heat flux for this cell}}
\DoxyCodeLine{758         iss\%h\_shelf(i,j) = 0.0}
\DoxyCodeLine{759         iss\%hmask(i,j) = 0.0}
\DoxyCodeLine{760         iss\%area\_shelf\_h(i,j) = 0.0}
\DoxyCodeLine{761 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{762       iss\%mass\_shelf(i,j) = iss\%h\_shelf(i,j) * density\_ice}
\DoxyCodeLine{763 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{764 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{765 }
\DoxyCodeLine{766   \textcolor{keyword}{call }pass\_var(iss\%area\_shelf\_h, g\%domain)}
\DoxyCodeLine{767   \textcolor{keyword}{call }pass\_var(iss\%h\_shelf, g\%domain)}
\DoxyCodeLine{768   \textcolor{keyword}{call }pass\_var(iss\%hmask, g\%domain)}
\DoxyCodeLine{769   \textcolor{keyword}{call }pass\_var(iss\%mass\_shelf, g\%domain)}
\DoxyCodeLine{770 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a6d0412c7264e0480d5144d26995dd8d3}\label{namespacemom__ice__shelf_a6d0412c7264e0480d5144d26995dd8d3}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!ice\_shelf\_end@{ice\_shelf\_end}}
\index{ice\_shelf\_end@{ice\_shelf\_end}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{ice\_shelf\_end()}{ice\_shelf\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::ice\+\_\+shelf\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Deallocates all memory associated with this module. 


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


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1790   \textcolor{keywordtype}{type}(ice\_shelf\_CS), \textcolor{keywordtype}{pointer}   :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1791 }
\DoxyCodeLine{1792   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1793 }
\DoxyCodeLine{1794   \textcolor{keyword}{call }ice\_shelf\_state\_end(cs\%ISS)}
\DoxyCodeLine{1795 }
\DoxyCodeLine{1796   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics) \textcolor{keyword}{call }ice\_shelf\_dyn\_end(cs\%dCS)}
\DoxyCodeLine{1797 }
\DoxyCodeLine{1798   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{1799 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a40ae01bbe3155191647f2150903dda69}\label{namespacemom__ice__shelf_a40ae01bbe3155191647f2150903dda69}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!ice\_shelf\_save\_restart@{ice\_shelf\_save\_restart}}
\index{ice\_shelf\_save\_restart@{ice\_shelf\_save\_restart}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{ice\_shelf\_save\_restart()}{ice\_shelf\_save\_restart()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::ice\+\_\+shelf\+\_\+save\+\_\+restart (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{character(len=$\ast$), intent(in), optional}]{directory,  }\item[{logical, intent(in), optional}]{time\+\_\+stamped,  }\item[{character(len=$\ast$), intent(in), optional}]{filename\+\_\+suffix }\end{DoxyParamCaption})}



Save the ice shelf restart file. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & ice shelf control structure \\
\hline
\mbox{\texttt{ in}}  & {\em time} & model time at this call \\
\hline
\mbox{\texttt{ in}}  & {\em directory} & An optional directory into which to write these restart files. \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+stamped} & f true, the restart file names include a unique time stamp. The default is false. \\
\hline
\mbox{\texttt{ in}}  & {\em filename\+\_\+suffix} & An optional suffix (e.\+g., a time-\/stamp) to append to the restart file names. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1767   \textcolor{keywordtype}{type}(ice\_shelf\_CS),         \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< ice shelf control structure}}
\DoxyCodeLine{1768   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< model time at this call}}
\DoxyCodeLine{1769   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: directory\textcolor{comment}{ !< An optional directory into which to write}}
\DoxyCodeLine{1770 \textcolor{comment}{                                               !! these restart files.}}
\DoxyCodeLine{1771   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: time\_stamped\textcolor{comment}{ !< f true, the restart file names include}}
\DoxyCodeLine{1772 \textcolor{comment}{                                               !! a unique time stamp.  The default is false.}}
\DoxyCodeLine{1773   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: filename\_suffix\textcolor{comment}{ !< An optional suffix (e.g., a}}
\DoxyCodeLine{1774 \textcolor{comment}{                                               !! time-\/stamp) to append to the restart file names.}}
\DoxyCodeLine{1775   \textcolor{comment}{! local variables}}
\DoxyCodeLine{1776   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: G => null()}
\DoxyCodeLine{1777   \textcolor{keywordtype}{character(len=200)} :: restart\_dir}
\DoxyCodeLine{1778 }
\DoxyCodeLine{1779   g => cs\%grid}
\DoxyCodeLine{1780 }
\DoxyCodeLine{1781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(directory)) \textcolor{keywordflow}{then} ; restart\_dir = directory}
\DoxyCodeLine{1782   \textcolor{keywordflow}{else} ; restart\_dir = cs\%restart\_output\_dir ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1783 }
\DoxyCodeLine{1784   \textcolor{keyword}{call }save\_restart(restart\_dir, time, cs\%grid, cs\%restart\_CSp, time\_stamped)}
\DoxyCodeLine{1785 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}\label{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!initialize\_ice\_shelf@{initialize\_ice\_shelf}}
\index{initialize\_ice\_shelf@{initialize\_ice\_shelf}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{initialize\_ice\_shelf()}{initialize\_ice\_shelf()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::initialize\+\_\+ice\+\_\+shelf (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(ocean\+\_\+grid\+\_\+type), pointer}]{ocn\+\_\+grid,  }\item[{type(time\+\_\+type), intent(inout)}]{Time,  }\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{type(mech\+\_\+forcing), intent(inout), optional}]{forces,  }\item[{type(forcing), intent(inout), optional}]{fluxes,  }\item[{type(time\+\_\+type), intent(in), optional}]{Time\+\_\+in,  }\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
 & {\em ocn\+\_\+grid} & The calling ocean model\textquotesingle{}s horizontal grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em time} & The clock that that will indicate the model time \\
\hline
 & {\em cs} & A pointer to the ice shelf control structure \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & A structure that is used to regulate the diagnostic output. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing pointers to any possible thermodynamic or mass-\/flux forcing fields. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+in} & The time at initialization. \\
\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 1084 of file M\+O\+M\+\_\+ice\+\_\+shelf.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1084   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{1085   \textcolor{keywordtype}{type}(ocean\_grid\_type),        \textcolor{keywordtype}{pointer}       :: ocn\_grid\textcolor{comment}{   !< The calling ocean model's horizontal grid structure}}
\DoxyCodeLine{1086   \textcolor{keywordtype}{type}(time\_type),              \textcolor{keywordtype}{intent(inout)} :: Time\textcolor{comment}{ !< The clock that that will indicate the model time}}
\DoxyCodeLine{1087   \textcolor{keywordtype}{type}(ice\_shelf\_CS),           \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1088   \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{1089   \textcolor{keywordtype}{type}(forcing),      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to any possible}}
\DoxyCodeLine{1090 \textcolor{comment}{                                                   !! thermodynamic or mass-\/flux forcing fields.}}
\DoxyCodeLine{1091   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{1092   \textcolor{keywordtype}{type}(time\_type),    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: Time\_in\textcolor{comment}{ !< The time at initialization.}}
\DoxyCodeLine{1093   \textcolor{keywordtype}{logical},            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: solo\_ice\_sheet\_in\textcolor{comment}{ !< If present, this indicates whether}}
\DoxyCodeLine{1094 \textcolor{comment}{                                                   !! a solo ice-\/sheet driver.}}
\DoxyCodeLine{1095 }
\DoxyCodeLine{1096   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: G  => null(), og  => null() \textcolor{comment}{! Pointers to grids for convenience.}}
\DoxyCodeLine{1097   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{pointer} :: US => null() \textcolor{comment}{! Pointer to a structure containing}}
\DoxyCodeLine{1098                                                  \textcolor{comment}{! various unit conversion factors}}
\DoxyCodeLine{1099   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: ISS => null() \textcolor{comment}{!< A structure with elements that describe}}
\DoxyCodeLine{1100 \textcolor{comment}{                                          !! the ice-\/shelf state}}
\DoxyCodeLine{1101   \textcolor{keywordtype}{type}(directories)  :: dirs}
\DoxyCodeLine{1102   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer} :: dG => null()}
\DoxyCodeLine{1103 \textcolor{keywordtype}{  real}    :: Z\_rescale  \textcolor{comment}{! A rescaling factor for heights from the representation in}}
\DoxyCodeLine{1104                         \textcolor{comment}{! a restart file to the internal representation in this run.}}
\DoxyCodeLine{1105 \textcolor{keywordtype}{  real}    :: RZ\_rescale \textcolor{comment}{! A rescaling factor for mass loads from the representation in}}
\DoxyCodeLine{1106                         \textcolor{comment}{! a restart file to the internal representation in this run.}}
\DoxyCodeLine{1107 \textcolor{keywordtype}{  real}    :: L\_rescale  \textcolor{comment}{! A rescaling factor for horizontal lengths from the representation in}}
\DoxyCodeLine{1108                         \textcolor{comment}{! a restart file to the internal representation in this run.}}
\DoxyCodeLine{1109 \textcolor{keywordtype}{  real} :: meltrate\_conversion \textcolor{comment}{! The conversion factor to use for in the melt rate diagnostic.}}
\DoxyCodeLine{1110 \textcolor{keywordtype}{  real} :: dz\_ocean\_min\_float \textcolor{comment}{! The minimum ocean thickness above which the ice shelf is considered}}
\DoxyCodeLine{1111                         \textcolor{comment}{! to be floating when CONST\_SEA\_LEVEL = True [Z ~> m].}}
\DoxyCodeLine{1112 \textcolor{keywordtype}{  real} :: cdrag, drag\_bg\_vel}
\DoxyCodeLine{1113   \textcolor{keywordtype}{logical} :: new\_sim, save\_IC, var\_force}
\DoxyCodeLine{1114   \textcolor{comment}{!This include declares and sets the variable "version".}}
\DoxyCodeLine{1115 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{1116 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=200)} :: config}
\DoxyCodeLine{1117   \textcolor{keywordtype}{character(len=200)} :: IC\_file,filename,inputdir}
\DoxyCodeLine{1118   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{1119   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, Isdq, Iedq, Jsdq, Jedq}
\DoxyCodeLine{1120   \textcolor{keywordtype}{integer} :: wd\_halos(2)}
\DoxyCodeLine{1121   \textcolor{keywordtype}{logical} :: read\_TideAmp, shelf\_mass\_is\_dynamic, debug}
\DoxyCodeLine{1122   \textcolor{keywordtype}{character(len=240)} :: Tideamp\_file}
\DoxyCodeLine{1123 \textcolor{keywordtype}{  real}    :: utide  \textcolor{comment}{! A tidal velocity [L T-\/1 ~> m s-\/1]}}
\DoxyCodeLine{1124 \textcolor{keywordtype}{  real}    :: col\_thick\_melt\_thresh \textcolor{comment}{! An ocean column thickness below which iceshelf melting}}
\DoxyCodeLine{1125                        \textcolor{comment}{! does not occur [Z ~> m]}}
\DoxyCodeLine{1126   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1127     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: "}// \&}
\DoxyCodeLine{1128                           \textcolor{stringliteral}{"called with an associated control structure."})}
\DoxyCodeLine{1129     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1130 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1131   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{1132 }
\DoxyCodeLine{1133   \textcolor{comment}{!   Go through all of the infrastructure initialization calls, since this is}}
\DoxyCodeLine{1134   \textcolor{comment}{! being treated as an independent component that just happens to use the}}
\DoxyCodeLine{1135   \textcolor{comment}{! MOM's grid and infrastructure.}}
\DoxyCodeLine{1136   \textcolor{keyword}{call }get\_mom\_input(dirs=dirs)}
\DoxyCodeLine{1137 }
\DoxyCodeLine{1138   \textcolor{comment}{! Determining the internal unit scaling factors for this run.}}
\DoxyCodeLine{1139   \textcolor{keyword}{call }unit\_scaling\_init(param\_file, cs\%US)}
\DoxyCodeLine{1140 }
\DoxyCodeLine{1141   \textcolor{comment}{! Set up the ice-\/shelf domain and grid}}
\DoxyCodeLine{1142   wd\_halos(:)=0}
\DoxyCodeLine{1143   \textcolor{keyword}{call }mom\_domains\_init(cs\%grid\%domain, param\_file, min\_halo=wd\_halos, symmetric=grid\_sym\_)}
\DoxyCodeLine{1144   \textcolor{comment}{! call diag\_mediator\_init(CS\%grid,param\_file,CS\%diag)}}
\DoxyCodeLine{1145   \textcolor{comment}{! this needs to be fixed -\/ will probably break when not using coupled driver 0}}
\DoxyCodeLine{1146   \textcolor{keyword}{call }mom\_grid\_init(cs\%grid, param\_file, cs\%US)}
\DoxyCodeLine{1147 }
\DoxyCodeLine{1148   \textcolor{keyword}{call }create\_dyn\_horgrid(dg, cs\%grid\%HI)}
\DoxyCodeLine{1149   \textcolor{keyword}{call }clone\_mom\_domain(cs\%grid\%Domain, dg\%Domain)}
\DoxyCodeLine{1150 }
\DoxyCodeLine{1151   \textcolor{keyword}{call }set\_grid\_metrics(dg, param\_file, cs\%US)}
\DoxyCodeLine{1152   \textcolor{comment}{! call set\_diag\_mediator\_grid(CS\%grid, CS\%diag)}}
\DoxyCodeLine{1153 }
\DoxyCodeLine{1154   \textcolor{comment}{! The ocean grid possibly uses different symmetry.}}
\DoxyCodeLine{1155   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ocn\_grid)) \textcolor{keywordflow}{then} ; cs\%ocn\_grid => ocn\_grid}
\DoxyCodeLine{1156   \textcolor{keywordflow}{else} ; cs\%ocn\_grid => cs\%grid ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1157 }
\DoxyCodeLine{1158   \textcolor{comment}{! Convenience pointers}}
\DoxyCodeLine{1159   g => cs\%grid}
\DoxyCodeLine{1160   og => cs\%ocn\_grid}
\DoxyCodeLine{1161   us => cs\%US}
\DoxyCodeLine{1162 }
\DoxyCodeLine{1163   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1164     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'OG: '}, og\%isd, og\%isc, og\%iec, og\%ied, og\%jsd, og\%jsc, og\%jsd, og\%jed}
\DoxyCodeLine{1165     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'IG: '}, g\%isd, g\%isc, g\%iec, g\%ied, g\%jsd, g\%jsc, g\%jsd, g\%jed}
\DoxyCodeLine{1166 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1167 }
\DoxyCodeLine{1168   cs\%diag => diag}
\DoxyCodeLine{1169 }
\DoxyCodeLine{1170   \textcolor{comment}{! Are we being called from the solo ice-\/sheet driver? When called by the ocean}}
\DoxyCodeLine{1171   \textcolor{comment}{! model solo\_ice\_sheet\_in is not preset.}}
\DoxyCodeLine{1172   cs\%solo\_ice\_sheet = .false.}
\DoxyCodeLine{1173   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(solo\_ice\_sheet\_in)) cs\%solo\_ice\_sheet = solo\_ice\_sheet\_in}
\DoxyCodeLine{1174 }
\DoxyCodeLine{1175   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(time\_in)) time = time\_in}
\DoxyCodeLine{1176 }
\DoxyCodeLine{1177   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1178   isd = g\%isd ; jsd = g\%jsd ; ied = g\%ied ; jed = g\%jed}
\DoxyCodeLine{1179   isdq = g\%IsdB ; iedq = g\%IedB ; jsdq = g\%JsdB ; jedq = g\%JedB}
\DoxyCodeLine{1180 }
\DoxyCodeLine{1181   cs\%override\_shelf\_movement = .false. ; cs\%active\_shelf\_dynamics = .false.}
\DoxyCodeLine{1182 }
\DoxyCodeLine{1183   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{1184   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, debug, default=.false.)}
\DoxyCodeLine{1185   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG\_IS"}, cs\%debug, \&}
\DoxyCodeLine{1186                  \textcolor{stringliteral}{"If true, write verbose debugging messages for the ice shelf."}, \&}
\DoxyCodeLine{1187                  default=debug)}
\DoxyCodeLine{1188   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DYNAMIC\_SHELF\_MASS"}, shelf\_mass\_is\_dynamic, \&}
\DoxyCodeLine{1189                  \textcolor{stringliteral}{"If true, the ice sheet mass can evolve with time."}, \&}
\DoxyCodeLine{1190                  default=.false.)}
\DoxyCodeLine{1191   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1192     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OVERRIDE\_SHELF\_MOVEMENT"}, cs\%override\_shelf\_movement, \&}
\DoxyCodeLine{1193                  \textcolor{stringliteral}{"If true, user provided code specifies the ice-\/shelf "}//\&}
\DoxyCodeLine{1194                  \textcolor{stringliteral}{"movement instead of the dynamic ice model."}, default=.false.)}
\DoxyCodeLine{1195     cs\%active\_shelf\_dynamics = .not.cs\%override\_shelf\_movement}
\DoxyCodeLine{1196     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERPOLATE"}, cs\%GL\_regularize, \&}
\DoxyCodeLine{1197                  \textcolor{stringliteral}{"If true, regularize the floatation condition at the "}//\&}
\DoxyCodeLine{1198                  \textcolor{stringliteral}{"grounding line as in Goldberg Holland Schoof 2009."}, default=.false.)}
\DoxyCodeLine{1199     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_COUPLE"}, cs\%GL\_couple, \&}
\DoxyCodeLine{1200                  \textcolor{stringliteral}{"If true, let the floatation condition be determined by "}//\&}
\DoxyCodeLine{1201                  \textcolor{stringliteral}{"ocean column thickness. This means that update\_OD\_ffrac "}//\&}
\DoxyCodeLine{1202                  \textcolor{stringliteral}{"will be called.  GL\_REGULARIZE and GL\_COUPLE are exclusive."}, \&}
\DoxyCodeLine{1203                  default=.false., do\_not\_log=cs\%GL\_regularize)}
\DoxyCodeLine{1204     \textcolor{keywordflow}{if} (cs\%GL\_regularize) cs\%GL\_couple = .false.}
\DoxyCodeLine{1205 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1206 }
\DoxyCodeLine{1207   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_THERMO"}, cs\%isthermo, \&}
\DoxyCodeLine{1208                  \textcolor{stringliteral}{"If true, use a thermodynamically interactive ice shelf."}, \&}
\DoxyCodeLine{1209                  default=.false.)}
\DoxyCodeLine{1210   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_HEAT\_FUSION"}, cs\%Lat\_fusion, \&}
\DoxyCodeLine{1211                  \textcolor{stringliteral}{"The latent heat of fusion."}, units=\textcolor{stringliteral}{"J/kg"}, default=hlf, scale=us\%J\_kg\_to\_Q)}
\DoxyCodeLine{1212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_THREE\_EQN"}, cs\%threeeq, \&}
\DoxyCodeLine{1213                  \textcolor{stringliteral}{"If true, use the three equation expression of "}//\&}
\DoxyCodeLine{1214                  \textcolor{stringliteral}{"consistency to calculate the fluxes at the ice-\/ocean "}//\&}
\DoxyCodeLine{1215                  \textcolor{stringliteral}{"interface."}, default=.true.)}
\DoxyCodeLine{1216   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_INSULATOR"}, cs\%insulator, \&}
\DoxyCodeLine{1217                  \textcolor{stringliteral}{"If true, the ice shelf is a perfect insulatior "}//\&}
\DoxyCodeLine{1218                  \textcolor{stringliteral}{"(no conduction)."}, default=.false.)}
\DoxyCodeLine{1219   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MELTING\_CUTOFF\_DEPTH"}, cs\%cutoff\_depth, \&}
\DoxyCodeLine{1220                  \textcolor{stringliteral}{"Depth above which the melt is set to zero (it must be >= 0) "}//\&}
\DoxyCodeLine{1221                  \textcolor{stringliteral}{"Default value won't affect the solution."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us\%m\_to\_Z)}
\DoxyCodeLine{1222   \textcolor{keywordflow}{if} (cs\%cutoff\_depth < 0.) \&}
\DoxyCodeLine{1223     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"Initialize\_ice\_shelf: MELTING\_CUTOFF\_DEPTH must be >= 0."})}
\DoxyCodeLine{1224 }
\DoxyCodeLine{1225   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONST\_SEA\_LEVEL"}, cs\%constant\_sea\_level, \&}
\DoxyCodeLine{1226                  \textcolor{stringliteral}{"If true, apply evaporative, heat and salt fluxes in "}//\&}
\DoxyCodeLine{1227                  \textcolor{stringliteral}{"the sponge region. This will avoid a large increase "}//\&}
\DoxyCodeLine{1228                  \textcolor{stringliteral}{"in sea level. This option is needed for some of the "}//\&}
\DoxyCodeLine{1229                  \textcolor{stringliteral}{"ISOMIP+ experiments (Ocean3 and Ocean4). "}//\&}
\DoxyCodeLine{1230                  \textcolor{stringliteral}{"IMPORTANT: it is not currently possible to do "}//\&}
\DoxyCodeLine{1231                  \textcolor{stringliteral}{"prefect restarts using this flag."}, default=.false.)}
\DoxyCodeLine{1232   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_OCEAN\_FLOAT\_THICK"}, dz\_ocean\_min\_float, \&}
\DoxyCodeLine{1233                  \textcolor{stringliteral}{"The minimum ocean thickness above which the ice shelf is considered to be "}//\&}
\DoxyCodeLine{1234                  \textcolor{stringliteral}{"floating when CONST\_SEA\_LEVEL = True."}, \&}
\DoxyCodeLine{1235                  default=0.1, units=\textcolor{stringliteral}{"m"}, scale=us\%m\_to\_Z, do\_not\_log=.not.cs\%constant\_sea\_level)}
\DoxyCodeLine{1236 }
\DoxyCodeLine{1237   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ISOMIP\_S\_SUR\_SPONGE"}, cs\%S0, \&}
\DoxyCodeLine{1238                  \textcolor{stringliteral}{"Surface salinity in the restoring region."}, \&}
\DoxyCodeLine{1239                 default=33.8, units=\textcolor{stringliteral}{'ppt'}, do\_not\_log=.true.)}
\DoxyCodeLine{1240 }
\DoxyCodeLine{1241   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ISOMIP\_T\_SUR\_SPONGE"}, cs\%T0, \&}
\DoxyCodeLine{1242                 \textcolor{stringliteral}{"Surface temperature in the restoring region."}, \&}
\DoxyCodeLine{1243                 default=-\/1.9, units=\textcolor{stringliteral}{'degC'}, do\_not\_log=.true.)}
\DoxyCodeLine{1244 }
\DoxyCodeLine{1245   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_3EQ\_GAMMA"}, cs\%const\_gamma, \&}
\DoxyCodeLine{1246                  \textcolor{stringliteral}{"If true, user specifies a constant nondimensional heat-\/transfer coefficient "}//\&}
\DoxyCodeLine{1247                  \textcolor{stringliteral}{"(GAMMA\_T\_3EQ), from which the default salt-\/transfer coefficient is set "}//\&}
\DoxyCodeLine{1248                  \textcolor{stringliteral}{"as GAMMA\_T\_3EQ/35. This is used with SHELF\_THREE\_EQN."}, default=.false.)}
\DoxyCodeLine{1249   \textcolor{keywordflow}{if} (cs\%threeeq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1250     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_S\_ROOT"}, cs\%find\_salt\_root, \&}
\DoxyCodeLine{1251                  \textcolor{stringliteral}{"If SHELF\_S\_ROOT = True, salinity at the ice/ocean interface (Sbdry) "}//\&}
\DoxyCodeLine{1252                  \textcolor{stringliteral}{"is computed from a quadratic equation. Otherwise, the previous "}//\&}
\DoxyCodeLine{1253                  \textcolor{stringliteral}{"interactive method to estimate Sbdry is used."}, default=.false.)}
\DoxyCodeLine{1254   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1255     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_2EQ\_GAMMA\_T"}, cs\%gamma\_t, \&}
\DoxyCodeLine{1256                  \textcolor{stringliteral}{"If SHELF\_THREE\_EQN is false, this the fixed turbulent "}//\&}
\DoxyCodeLine{1257                  \textcolor{stringliteral}{"exchange velocity at the ice-\/ocean interface."}, \&}
\DoxyCodeLine{1258                  units=\textcolor{stringliteral}{"m s-\/1"}, scale=us\%m\_to\_Z*us\%T\_to\_s, fail\_if\_missing=.true.)}
\DoxyCodeLine{1259 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1260   \textcolor{keywordflow}{if} (cs\%const\_gamma .or. cs\%find\_salt\_root) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1261     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_3EQ\_GAMMA\_T"}, cs\%Gamma\_T\_3EQ, \&}
\DoxyCodeLine{1262                  \textcolor{stringliteral}{"Nondimensional heat-\/transfer coefficient."}, \&}
\DoxyCodeLine{1263                   units=\textcolor{stringliteral}{"nondim"}, default=2.2e-\/2)}
\DoxyCodeLine{1264     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_3EQ\_GAMMA\_S"}, cs\%Gamma\_S\_3EQ, \&}
\DoxyCodeLine{1265                  \textcolor{stringliteral}{"Nondimensional salt-\/transfer coefficient."}, \&}
\DoxyCodeLine{1266                  default=cs\%Gamma\_T\_3EQ/35.0, units=\textcolor{stringliteral}{"nondim"})}
\DoxyCodeLine{1267 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1268 }
\DoxyCodeLine{1269   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_MASS\_FROM\_FILE"}, \&}
\DoxyCodeLine{1270                  cs\%mass\_from\_file, \textcolor{stringliteral}{"Read the mass of the "}//\&}
\DoxyCodeLine{1271                  \textcolor{stringliteral}{"ice shelf (every time step) from a file."}, default=.false.)}
\DoxyCodeLine{1272 }
\DoxyCodeLine{1273   \textcolor{keywordflow}{if} (cs\%find\_salt\_root) \textcolor{keywordflow}{then} \textcolor{comment}{! read liquidus coeffs.}}
\DoxyCodeLine{1274      \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TFREEZE\_S0\_P0"}, cs\%TFr\_0\_0, \&}
\DoxyCodeLine{1275                  \textcolor{stringliteral}{"this is the freezing potential temperature at "}//\&}
\DoxyCodeLine{1276                  \textcolor{stringliteral}{"S=0, P=0."}, units=\textcolor{stringliteral}{"degC"}, default=0.0, do\_not\_log=.true.)}
\DoxyCodeLine{1277     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DS"}, cs\%dTFr\_dS, \&}
\DoxyCodeLine{1278                  \textcolor{stringliteral}{"this is the derivative of the freezing potential temperature with salinity."}, \&}
\DoxyCodeLine{1279                  units=\textcolor{stringliteral}{"degC psu-\/1"}, default=-\/0.054, do\_not\_log=.true.)}
\DoxyCodeLine{1280     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DP"}, cs\%dTFr\_dp, \&}
\DoxyCodeLine{1281                  \textcolor{stringliteral}{"this is the derivative of the freezing potential temperature with pressure."}, \&}
\DoxyCodeLine{1282                  units=\textcolor{stringliteral}{"degC Pa-\/1"}, default=0.0, scale=us\%RL2\_T2\_to\_Pa, do\_not\_log=.true.)}
\DoxyCodeLine{1283 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1284 }
\DoxyCodeLine{1285   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs\%g\_Earth, \&}
\DoxyCodeLine{1286                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, \&}
\DoxyCodeLine{1287                  units=\textcolor{stringliteral}{"m s-\/2"}, default = 9.80, scale=us\%m\_s\_to\_L\_T**2*us\%Z\_to\_m)}
\DoxyCodeLine{1288   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"C\_P"}, cs\%Cp, \&}
\DoxyCodeLine{1289                  \textcolor{stringliteral}{"The heat capacity of sea water, approximated as a constant. "}//\&}
\DoxyCodeLine{1290                  \textcolor{stringliteral}{"The default value is from the TEOS-\/10 definition of conservative temperature."}, \&}
\DoxyCodeLine{1291                  units=\textcolor{stringliteral}{"J kg-\/1 K-\/1"}, default=3991.86795711963, scale=us\%J\_kg\_to\_Q)}
\DoxyCodeLine{1292   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs\%Rho\_ocn, \&}
\DoxyCodeLine{1293                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//\&}
\DoxyCodeLine{1294                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//\&}
\DoxyCodeLine{1295                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//\&}
\DoxyCodeLine{1296                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-\/2."}, \&}
\DoxyCodeLine{1297                  units=\textcolor{stringliteral}{"kg m-\/3"}, default=1035.0, scale=us\%kg\_m3\_to\_R)}
\DoxyCodeLine{1298   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"C\_P\_ICE"}, cs\%Cp\_ice, \&}
\DoxyCodeLine{1299                  \textcolor{stringliteral}{"The heat capacity of ice."}, units=\textcolor{stringliteral}{"J kg-\/1 K-\/1"}, scale=us\%J\_kg\_to\_Q, \&}
\DoxyCodeLine{1300                  default=2.10e3)}
\DoxyCodeLine{1301   \textcolor{keywordflow}{if} (cs\%constant\_sea\_level) cs\%min\_ocean\_mass\_float = dz\_ocean\_min\_float*cs\%Rho\_ocn}
\DoxyCodeLine{1302 }
\DoxyCodeLine{1303   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_FLUX\_FACTOR"}, cs\%flux\_factor, \&}
\DoxyCodeLine{1304                  \textcolor{stringliteral}{"Non-\/dimensional factor applied to shelf thermodynamic "}//\&}
\DoxyCodeLine{1305                  \textcolor{stringliteral}{"fluxes."}, units=\textcolor{stringliteral}{"none"}, default=1.0)}
\DoxyCodeLine{1306 }
\DoxyCodeLine{1307   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KV\_ICE"}, cs\%kv\_ice, \&}
\DoxyCodeLine{1308                  \textcolor{stringliteral}{"The viscosity of the ice."}, \&}
\DoxyCodeLine{1309                  units=\textcolor{stringliteral}{"m2 s-\/1"}, default=1.0e10, scale=us\%Z\_to\_L**2*us\%m\_to\_L**2*us\%T\_to\_s)}
\DoxyCodeLine{1310   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KV\_MOLECULAR"}, cs\%kv\_molec, \&}
\DoxyCodeLine{1311                  \textcolor{stringliteral}{"The molecular kinimatic viscosity of sea water at the "}//\&}
\DoxyCodeLine{1312                  \textcolor{stringliteral}{"freezing temperature."}, units=\textcolor{stringliteral}{"m2 s-\/1"}, default=1.95e-\/6, scale=us\%m2\_s\_to\_Z2\_T)}
\DoxyCodeLine{1313   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_SALINITY"}, cs\%Salin\_ice, \&}
\DoxyCodeLine{1314                  \textcolor{stringliteral}{"The salinity of the ice inside the ice shelf."}, units=\textcolor{stringliteral}{"psu"}, \&}
\DoxyCodeLine{1315                  default=0.0)}
\DoxyCodeLine{1316   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_TEMPERATURE"}, cs\%Temp\_ice, \&}
\DoxyCodeLine{1317                  \textcolor{stringliteral}{"The temperature at the center of the ice shelf."}, \&}
\DoxyCodeLine{1318                  units = \textcolor{stringliteral}{"degC"}, default=-\/15.0)}
\DoxyCodeLine{1319   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KD\_SALT\_MOLECULAR"}, cs\%kd\_molec\_salt, \&}
\DoxyCodeLine{1320                  \textcolor{stringliteral}{"The molecular diffusivity of salt in sea water at the "}//\&}
\DoxyCodeLine{1321                  \textcolor{stringliteral}{"freezing point."}, units=\textcolor{stringliteral}{"m2 s-\/1"}, default=8.02e-\/10, scale=us\%m2\_s\_to\_Z2\_T)}
\DoxyCodeLine{1322   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KD\_TEMP\_MOLECULAR"}, cs\%kd\_molec\_temp, \&}
\DoxyCodeLine{1323                  \textcolor{stringliteral}{"The molecular diffusivity of heat in sea water at the "}//\&}
\DoxyCodeLine{1324                  \textcolor{stringliteral}{"freezing point."}, units=\textcolor{stringliteral}{"m2 s-\/1"}, default=1.41e-\/7, scale=us\%m2\_s\_to\_Z2\_T)}
\DoxyCodeLine{1325   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DT\_FORCING"}, cs\%time\_step, \&}
\DoxyCodeLine{1326                  \textcolor{stringliteral}{"The time step for changing forcing, coupling with other "}//\&}
\DoxyCodeLine{1327                  \textcolor{stringliteral}{"components, or potentially writing certain diagnostics. "}//\&}
\DoxyCodeLine{1328                  \textcolor{stringliteral}{"The default value is given by DT."}, units=\textcolor{stringliteral}{"s"}, default=0.0)}
\DoxyCodeLine{1329 }
\DoxyCodeLine{1330   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"COL\_THICK\_MELT\_THRESHOLD"}, col\_thick\_melt\_thresh, \&}
\DoxyCodeLine{1331                  \textcolor{stringliteral}{"The minimum ocean column thickness where melting is allowed."}, \&}
\DoxyCodeLine{1332                  units=\textcolor{stringliteral}{"m"}, scale=us\%m\_to\_Z, default=0.0)}
\DoxyCodeLine{1333   cs\%col\_mass\_melt\_threshold =  cs\%Rho\_ocn * col\_thick\_melt\_thresh}
\DoxyCodeLine{1334 }
\DoxyCodeLine{1335   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"READ\_TIDEAMP"}, read\_tideamp, \&}
\DoxyCodeLine{1336                  \textcolor{stringliteral}{"If true, read a file (given by TIDEAMP\_FILE) containing "}//\&}
\DoxyCodeLine{1337                  \textcolor{stringliteral}{"the tidal amplitude with INT\_TIDE\_DISSIPATION."}, default=.false.)}
\DoxyCodeLine{1338 }
\DoxyCodeLine{1339   \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%utide,isd,ied,jsd,jed)   ; cs\%utide(:,:) = 0.0}
\DoxyCodeLine{1340 }
\DoxyCodeLine{1341   \textcolor{keywordflow}{if} (read\_tideamp) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1342     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDEAMP\_FILE"}, tideamp\_file, \&}
\DoxyCodeLine{1343                  \textcolor{stringliteral}{"The path to the file containing the spatially varying "}//\&}
\DoxyCodeLine{1344                  \textcolor{stringliteral}{"tidal amplitudes."}, \&}
\DoxyCodeLine{1345                  default=\textcolor{stringliteral}{"tideamp.nc"})}
\DoxyCodeLine{1346     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1347     inputdir = slasher(inputdir)}
\DoxyCodeLine{1348     tideamp\_file = trim(inputdir) // trim(tideamp\_file)}
\DoxyCodeLine{1349     \textcolor{keyword}{call }mom\_read\_data(tideamp\_file, \textcolor{stringliteral}{'tideamp'}, cs\%utide, g\%domain, timelevel=1, scale=us\%m\_s\_to\_L\_T)}
\DoxyCodeLine{1350   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1351     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"UTIDE"}, utide, \&}
\DoxyCodeLine{1352                  \textcolor{stringliteral}{"The constant tidal amplitude used with INT\_TIDE\_DISSIPATION."}, \&}
\DoxyCodeLine{1353                  units=\textcolor{stringliteral}{"m s-\/1"}, default=0.0 , scale=us\%m\_s\_to\_L\_T)}
\DoxyCodeLine{1354     cs\%utide(:,:) = utide}
\DoxyCodeLine{1355 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1356 }
\DoxyCodeLine{1357   \textcolor{keyword}{call }eos\_init(param\_file, cs\%eqn\_of\_state)}
\DoxyCodeLine{1358 }
\DoxyCodeLine{1359   \textcolor{comment}{!! new parameters that need to be in MOM\_input}}
\DoxyCodeLine{1360 }
\DoxyCodeLine{1361   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1362 }
\DoxyCodeLine{1363     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSITY\_ICE"}, cs\%density\_ice, \&}
\DoxyCodeLine{1364                  \textcolor{stringliteral}{"A typical density of ice."}, units=\textcolor{stringliteral}{"kg m-\/3"}, default=917.0, scale=us\%kg\_m3\_to\_R)}
\DoxyCodeLine{1365 }
\DoxyCodeLine{1366     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUT\_FLUX\_ICE\_SHELF"}, cs\%input\_flux, \&}
\DoxyCodeLine{1367                  \textcolor{stringliteral}{"volume flux at upstream boundary"}, units=\textcolor{stringliteral}{"m2 s-\/1"}, default=0.)}
\DoxyCodeLine{1368     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUT\_THICK\_ICE\_SHELF"}, cs\%input\_thickness, \&}
\DoxyCodeLine{1369                  \textcolor{stringliteral}{"flux thickness at upstream boundary"}, units=\textcolor{stringliteral}{"m"}, default=1000.)}
\DoxyCodeLine{1370   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1371     \textcolor{comment}{! This is here because of inconsistent defaults.  I don't know why.  RWH}}
\DoxyCodeLine{1372     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSITY\_ICE"}, cs\%density\_ice, \&}
\DoxyCodeLine{1373                  \textcolor{stringliteral}{"A typical density of ice."}, units=\textcolor{stringliteral}{"kg m-\/3"}, default=900.0, scale=us\%kg\_m3\_to\_R)}
\DoxyCodeLine{1374 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1375   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_THICKNESS\_SIMPLE\_CALVE"}, \&}
\DoxyCodeLine{1376                 cs\%min\_thickness\_simple\_calve, \&}
\DoxyCodeLine{1377                  \textcolor{stringliteral}{"Min thickness rule for the very simple calving law"},\&}
\DoxyCodeLine{1378                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us\%m\_to\_Z)}
\DoxyCodeLine{1379 }
\DoxyCodeLine{1380   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USTAR\_SHELF\_BG"}, cs\%ustar\_bg, \&}
\DoxyCodeLine{1381                  \textcolor{stringliteral}{"The minimum value of ustar under ice shelves."}, \&}
\DoxyCodeLine{1382                  units=\textcolor{stringliteral}{"m s-\/1"}, default=0.0, scale=us\%m\_to\_Z*us\%T\_to\_s)}
\DoxyCodeLine{1383   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CDRAG\_SHELF"}, cdrag, \&}
\DoxyCodeLine{1384        \textcolor{stringliteral}{"CDRAG is the drag coefficient relating the magnitude of "}//\&}
\DoxyCodeLine{1385        \textcolor{stringliteral}{"the velocity field to the surface stress."}, units=\textcolor{stringliteral}{"nondim"}, \&}
\DoxyCodeLine{1386        default=0.003)}
\DoxyCodeLine{1387   cs\%cdrag = cdrag}
\DoxyCodeLine{1388   \textcolor{keywordflow}{if} (cs\%ustar\_bg <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1389     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DRAG\_BG\_VEL\_SHELF"}, drag\_bg\_vel, \&}
\DoxyCodeLine{1390                  \textcolor{stringliteral}{"DRAG\_BG\_VEL is either the assumed bottom velocity (with "}//\&}
\DoxyCodeLine{1391                  \textcolor{stringliteral}{"LINEAR\_DRAG) or an unresolved  velocity that is "}//\&}
\DoxyCodeLine{1392                  \textcolor{stringliteral}{"combined with the resolved velocity to estimate the "}//\&}
\DoxyCodeLine{1393                  \textcolor{stringliteral}{"velocity magnitude."}, units=\textcolor{stringliteral}{"m s-\/1"}, default=0.0, scale=us\%m\_to\_Z*us\%T\_to\_s)}
\DoxyCodeLine{1394     \textcolor{keywordflow}{if} (cs\%cdrag*drag\_bg\_vel > 0.0) cs\%ustar\_bg = sqrt(cs\%cdrag)*drag\_bg\_vel}
\DoxyCodeLine{1395 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1396 }
\DoxyCodeLine{1397   \textcolor{comment}{! Allocate and initialize state variables to default values}}
\DoxyCodeLine{1398   \textcolor{keyword}{call }ice\_shelf\_state\_init(cs\%ISS, cs\%grid)}
\DoxyCodeLine{1399   iss => cs\%ISS}
\DoxyCodeLine{1400 }
\DoxyCodeLine{1401   \textcolor{comment}{! Allocate the arrays for passing ice-\/shelf data through the forcing type.}}
\DoxyCodeLine{1402   \textcolor{keywordflow}{if} (.not. cs\%solo\_ice\_sheet) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1403     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: allocating fluxes."})}
\DoxyCodeLine{1404      \textcolor{comment}{! GMM: the following assures that water/heat fluxes are just allocated}}
\DoxyCodeLine{1405      \textcolor{comment}{! when SHELF\_THERMO = True. These fluxes are necessary if one wants to}}
\DoxyCodeLine{1406      \textcolor{comment}{! use either ENERGETICS\_SFC\_PBL (ALE mode) or BULKMIXEDLAYER (layer mode).}}
\DoxyCodeLine{1407     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \&}
\DoxyCodeLine{1408       \textcolor{keyword}{call }allocate\_forcing\_type(cs\%ocn\_grid, fluxes, ustar=.true., shelf=.true., \&}
\DoxyCodeLine{1409                                  press=.true., water=cs\%isthermo, heat=cs\%isthermo)}
\DoxyCodeLine{1410     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) \&}
\DoxyCodeLine{1411       \textcolor{keyword}{call }allocate\_mech\_forcing(cs\%ocn\_grid, forces, ustar=.true., shelf=.true., press=.true.)}
\DoxyCodeLine{1412   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1413     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: allocating fluxes in solo mode."})}
\DoxyCodeLine{1414     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \&}
\DoxyCodeLine{1415       \textcolor{keyword}{call }allocate\_forcing\_type(g, fluxes, ustar=.true., shelf=.true., press=.true.)}
\DoxyCodeLine{1416     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) \&}
\DoxyCodeLine{1417       \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, ustar=.true., shelf=.true., press=.true.)}
\DoxyCodeLine{1418 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1419 }
\DoxyCodeLine{1420   \textcolor{comment}{! Set up the bottom depth, G\%D either analytically or from file}}
\DoxyCodeLine{1421   \textcolor{keyword}{call }mom\_initialize\_topography(dg\%bathyT, g\%max\_depth, dg, param\_file)}
\DoxyCodeLine{1422   \textcolor{keyword}{call }rescale\_dyn\_horgrid\_bathymetry(dg, us\%Z\_to\_m)}
\DoxyCodeLine{1423 }
\DoxyCodeLine{1424   \textcolor{comment}{! Set up the Coriolis parameter, G\%f, usually analytically.}}
\DoxyCodeLine{1425   \textcolor{keyword}{call }mom\_initialize\_rotation(dg\%CoriolisBu, dg, param\_file, us)}
\DoxyCodeLine{1426   \textcolor{comment}{! This copies grid elements, including bathyT and CoriolisBu from dG to CS\%grid.}}
\DoxyCodeLine{1427   \textcolor{keyword}{call }copy\_dyngrid\_to\_mom\_grid(dg, cs\%grid, us)}
\DoxyCodeLine{1428 }
\DoxyCodeLine{1429   \textcolor{keyword}{call }destroy\_dyn\_horgrid(dg)}
\DoxyCodeLine{1430 }
\DoxyCodeLine{1431   \textcolor{comment}{! Set up the restarts.}}
\DoxyCodeLine{1432   \textcolor{keyword}{call }restart\_init(param\_file, cs\%restart\_CSp, \textcolor{stringliteral}{"Shelf.res"})}
\DoxyCodeLine{1433   \textcolor{keyword}{call }register\_restart\_field(iss\%mass\_shelf, \textcolor{stringliteral}{"shelf\_mass"}, .true., cs\%restart\_CSp, \&}
\DoxyCodeLine{1434                               \textcolor{stringliteral}{"Ice shelf mass"}, \textcolor{stringliteral}{"kg m-\/2"})}
\DoxyCodeLine{1435   \textcolor{keyword}{call }register\_restart\_field(iss\%area\_shelf\_h, \textcolor{stringliteral}{"shelf\_area"}, .true., cs\%restart\_CSp, \&}
\DoxyCodeLine{1436                               \textcolor{stringliteral}{"Ice shelf area in cell"}, \textcolor{stringliteral}{"m2"})}
\DoxyCodeLine{1437   \textcolor{keyword}{call }register\_restart\_field(iss\%h\_shelf, \textcolor{stringliteral}{"h\_shelf"}, .true., cs\%restart\_CSp, \&}
\DoxyCodeLine{1438                               \textcolor{stringliteral}{"ice sheet/shelf thickness"}, \textcolor{stringliteral}{"m"})}
\DoxyCodeLine{1439   \textcolor{keyword}{call }register\_restart\_field(us\%m\_to\_Z\_restart, \textcolor{stringliteral}{"m\_to\_Z"}, .false., cs\%restart\_CSp, \&}
\DoxyCodeLine{1440                               \textcolor{stringliteral}{"Height unit conversion factor"}, \textcolor{stringliteral}{"Z meter-\/1"})}
\DoxyCodeLine{1441   \textcolor{keyword}{call }register\_restart\_field(us\%m\_to\_L\_restart, \textcolor{stringliteral}{"m\_to\_L"}, .false., cs\%restart\_CSp, \&}
\DoxyCodeLine{1442                               \textcolor{stringliteral}{"Length unit conversion factor"}, \textcolor{stringliteral}{"L meter-\/1"})}
\DoxyCodeLine{1443   \textcolor{keyword}{call }register\_restart\_field(us\%kg\_m3\_to\_R\_restart, \textcolor{stringliteral}{"kg\_m3\_to\_R"}, .false., cs\%restart\_CSp, \&}
\DoxyCodeLine{1444                               \textcolor{stringliteral}{"Density unit conversion factor"}, \textcolor{stringliteral}{"R m3 kg-\/1"})}
\DoxyCodeLine{1445   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1446     \textcolor{keyword}{call }register\_restart\_field(iss\%hmask, \textcolor{stringliteral}{"h\_mask"}, .true., cs\%restart\_CSp, \&}
\DoxyCodeLine{1447                                 \textcolor{stringliteral}{"ice sheet/shelf thickness mask"} ,\textcolor{stringliteral}{"none"})}
\DoxyCodeLine{1448 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1449 }
\DoxyCodeLine{1450   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1451     \textcolor{comment}{! Allocate CS\%dCS and specify additional restarts for ice shelf dynamics}}
\DoxyCodeLine{1452     \textcolor{keyword}{call }register\_ice\_shelf\_dyn\_restarts(g, param\_file, cs\%dCS, cs\%restart\_CSp)}
\DoxyCodeLine{1453 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1454 }
\DoxyCodeLine{1455   \textcolor{comment}{!GMM -\/ I think we do not need to save ustar\_shelf and iceshelf\_melt in the restart file}}
\DoxyCodeLine{1456   \textcolor{comment}{!if (.not. CS\%solo\_ice\_sheet) then}}
\DoxyCodeLine{1457   \textcolor{comment}{!  call register\_restart\_field(fluxes\%ustar\_shelf, "ustar\_shelf", .false., CS\%restart\_CSp, \&}}
\DoxyCodeLine{1458   \textcolor{comment}{!                              "Friction velocity under ice shelves", "m s-\/1")}}
\DoxyCodeLine{1459   \textcolor{comment}{!endif}}
\DoxyCodeLine{1460 }
\DoxyCodeLine{1461   cs\%restart\_output\_dir = dirs\%restart\_output\_dir}
\DoxyCodeLine{1462 }
\DoxyCodeLine{1463   new\_sim = .false.}
\DoxyCodeLine{1464   \textcolor{keywordflow}{if} ((dirs\%input\_filename(1:1) == \textcolor{stringliteral}{'n'}) .and. \&}
\DoxyCodeLine{1465       (len\_trim(dirs\%input\_filename) == 1)) new\_sim = .true.}
\DoxyCodeLine{1466 }
\DoxyCodeLine{1467   \textcolor{keywordflow}{if} (cs\%override\_shelf\_movement .and. cs\%mass\_from\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1468 }
\DoxyCodeLine{1469     \textcolor{comment}{! initialize the ids for reading shelf mass from a netCDF}}
\DoxyCodeLine{1470     \textcolor{keyword}{call }initialize\_shelf\_mass(g, param\_file, cs, iss)}
\DoxyCodeLine{1471 }
\DoxyCodeLine{1472     \textcolor{keywordflow}{if} (new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1473       \textcolor{comment}{! new simulation, initialize ice thickness as in the static case}}
\DoxyCodeLine{1474       \textcolor{keyword}{call }initialize\_ice\_thickness(iss\%h\_shelf, iss\%area\_shelf\_h, iss\%hmask, g, us, param\_file)}
\DoxyCodeLine{1475 }
\DoxyCodeLine{1476     \textcolor{comment}{! next make sure mass is consistent with thickness}}
\DoxyCodeLine{1477       \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{1478         \textcolor{keywordflow}{if} ((iss\%hmask(i,j) == 1) .or. (iss\%hmask(i,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1479           iss\%mass\_shelf(i,j) = iss\%h\_shelf(i,j)*cs\%density\_ice}
\DoxyCodeLine{1480 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1481 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1482 }
\DoxyCodeLine{1483       \textcolor{keywordflow}{if} (cs\%min\_thickness\_simple\_calve > 0.0) \&}
\DoxyCodeLine{1484         \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, iss\%h\_shelf, iss\%area\_shelf\_h, iss\%hmask, \&}
\DoxyCodeLine{1485                                            cs\%min\_thickness\_simple\_calve)}
\DoxyCodeLine{1486 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1487 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1488 }
\DoxyCodeLine{1489   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1490     \textcolor{comment}{! the only reason to initialize boundary conds is if the shelf is dynamic -\/ MJH}}
\DoxyCodeLine{1491 }
\DoxyCodeLine{1492     \textcolor{comment}{! call initialize\_ice\_shelf\_boundary ( CS\%u\_face\_mask\_bdry, CS\%v\_face\_mask\_bdry, \&}}
\DoxyCodeLine{1493     \textcolor{comment}{!                                      CS\%u\_flux\_bdry\_val, CS\%v\_flux\_bdry\_val, \&}}
\DoxyCodeLine{1494     \textcolor{comment}{!                                      CS\%u\_bdry\_val, CS\%v\_bdry\_val, CS\%h\_bdry\_val, \&}}
\DoxyCodeLine{1495     \textcolor{comment}{!                                      ISS\%hmask, G, param\_file)}}
\DoxyCodeLine{1496 }
\DoxyCodeLine{1497 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1498 }
\DoxyCodeLine{1499   \textcolor{keywordflow}{if} (new\_sim .and. (.not. (cs\%override\_shelf\_movement .and. cs\%mass\_from\_file))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1500 }
\DoxyCodeLine{1501     \textcolor{comment}{! This model is initialized internally or from a file.}}
\DoxyCodeLine{1502     \textcolor{keyword}{call }initialize\_ice\_thickness(iss\%h\_shelf, iss\%area\_shelf\_h, iss\%hmask, g, us, param\_file)}
\DoxyCodeLine{1503 }
\DoxyCodeLine{1504     \textcolor{comment}{! next make sure mass is consistent with thickness}}
\DoxyCodeLine{1505     \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{1506       \textcolor{keywordflow}{if} ((iss\%hmask(i,j) == 1) .or. (iss\%hmask(i,j) == 2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1507         iss\%mass\_shelf(i,j) = iss\%h\_shelf(i,j)*cs\%density\_ice}
\DoxyCodeLine{1508 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1509 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1510 }
\DoxyCodeLine{1511   \textcolor{comment}{! else ! Previous block for new\_sim=.T., this block restores the state.}}
\DoxyCodeLine{1512   \textcolor{keywordflow}{elseif} (.not.new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1513     \textcolor{comment}{! This line calls a subroutine that reads the initial conditions from a restart file.}}
\DoxyCodeLine{1514     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: Restoring ice shelf from file."})}
\DoxyCodeLine{1515     \textcolor{keyword}{call }restore\_state(dirs\%input\_filename, dirs\%restart\_input\_dir, time, \&}
\DoxyCodeLine{1516                        g, cs\%restart\_CSp)}
\DoxyCodeLine{1517 }
\DoxyCodeLine{1518     \textcolor{keywordflow}{if} ((us\%m\_to\_Z\_restart /= 0.0) .and. (us\%m\_to\_Z\_restart /= us\%m\_to\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1519       z\_rescale = us\%m\_to\_Z / us\%m\_to\_Z\_restart}
\DoxyCodeLine{1520       \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1521         iss\%h\_shelf(i,j) = z\_rescale * iss\%h\_shelf(i,j)}
\DoxyCodeLine{1522 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1523 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1524 }
\DoxyCodeLine{1525     \textcolor{keywordflow}{if} ((us\%m\_to\_Z\_restart*us\%kg\_m3\_to\_R\_restart /= 0.0) .and. \&}
\DoxyCodeLine{1526         (us\%m\_to\_Z*us\%kg\_m3\_to\_R /= us\%m\_to\_Z\_restart * us\%kg\_m3\_to\_R\_restart)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1527       rz\_rescale = us\%m\_to\_Z*us\%kg\_m3\_to\_R / (us\%m\_to\_Z\_restart * us\%kg\_m3\_to\_R\_restart)}
\DoxyCodeLine{1528       \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1529         iss\%mass\_shelf(i,j) = rz\_rescale * iss\%mass\_shelf(i,j)}
\DoxyCodeLine{1530 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1531 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1532 }
\DoxyCodeLine{1533     \textcolor{keywordflow}{if} ((us\%m\_to\_L\_restart /= 0.0) .and. (us\%m\_to\_L\_restart /= us\%m\_to\_L)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1534       l\_rescale = us\%m\_to\_L / us\%m\_to\_L\_restart}
\DoxyCodeLine{1535       \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1536         iss\%area\_shelf\_h(i,j) = l\_rescale**2 * iss\%area\_shelf\_h(i,j)}
\DoxyCodeLine{1537 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1538 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1539 }
\DoxyCodeLine{1540 \textcolor{keywordflow}{  endif} \textcolor{comment}{! .not. new\_sim}}
\DoxyCodeLine{1541 }
\DoxyCodeLine{1542   cs\%Time = time}
\DoxyCodeLine{1543 }
\DoxyCodeLine{1544   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)}
\DoxyCodeLine{1545   \textcolor{keyword}{call }pass\_var(iss\%area\_shelf\_h, g\%domain)}
\DoxyCodeLine{1546   \textcolor{keyword}{call }pass\_var(iss\%h\_shelf, g\%domain)}
\DoxyCodeLine{1547   \textcolor{keyword}{call }pass\_var(iss\%mass\_shelf, g\%domain)}
\DoxyCodeLine{1548   \textcolor{keyword}{call }pass\_var(iss\%hmask, g\%domain)}
\DoxyCodeLine{1549   \textcolor{keyword}{call }pass\_var(g\%bathyT, g\%domain)}
\DoxyCodeLine{1550   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)}
\DoxyCodeLine{1551 }
\DoxyCodeLine{1552   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1553     \textcolor{keywordflow}{if} (iss\%area\_shelf\_h(i,j) > g\%areaT(i,j)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1554       \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"Initialize\_ice\_shelf: area\_shelf\_h exceeds G\%areaT."})}
\DoxyCodeLine{1555       iss\%area\_shelf\_h(i,j) = g\%areaT(i,j)}
\DoxyCodeLine{1556 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1557 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1558   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1559     \textcolor{keywordflow}{if} (g\%areaT(i,j) > 0.0) fluxes\%frac\_shelf\_h(i,j) = iss\%area\_shelf\_h(i,j) / g\%areaT(i,j)}
\DoxyCodeLine{1560 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1561 }
\DoxyCodeLine{1562   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1563     \textcolor{keyword}{call }hchksum(fluxes\%frac\_shelf\_h, \textcolor{stringliteral}{"IS init: frac\_shelf\_h"}, g\%HI, haloshift=0)}
\DoxyCodeLine{1564 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1565 }
\DoxyCodeLine{1566   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) \&}
\DoxyCodeLine{1567     \textcolor{keyword}{call }add\_shelf\_forces(g, us, cs, forces, do\_shelf\_area=.not.cs\%solo\_ice\_sheet)}
\DoxyCodeLine{1568 }
\DoxyCodeLine{1569   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \textcolor{keyword}{call }add\_shelf\_pressure(g, us, cs, fluxes)}
\DoxyCodeLine{1570 }
\DoxyCodeLine{1571   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics .and. .not.cs\%isthermo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1572     iss\%water\_flux(:,:) = 0.0}
\DoxyCodeLine{1573 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1574 }
\DoxyCodeLine{1575   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) \&}
\DoxyCodeLine{1576     \textcolor{keyword}{call }initialize\_ice\_shelf\_dyn(param\_file, time, iss, cs\%dCS, g, us, diag, new\_sim, solo\_ice\_sheet\_in)}
\DoxyCodeLine{1577 }
\DoxyCodeLine{1578   \textcolor{keyword}{call }fix\_restart\_unit\_scaling(us)}
\DoxyCodeLine{1579 }
\DoxyCodeLine{1580   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SAVE\_INITIAL\_CONDS"}, save\_ic, \&}
\DoxyCodeLine{1581                  \textcolor{stringliteral}{"If true, save the ice shelf initial conditions."}, \&}
\DoxyCodeLine{1582                  default=.false.)}
\DoxyCodeLine{1583   \textcolor{keywordflow}{if} (save\_ic) \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_IC\_OUTPUT\_FILE"}, ic\_file,\&}
\DoxyCodeLine{1584                  \textcolor{stringliteral}{"The name-\/root of the output file for the ice shelf "}//\&}
\DoxyCodeLine{1585                  \textcolor{stringliteral}{"initial conditions."}, default=\textcolor{stringliteral}{"MOM\_Shelf\_IC"})}
\DoxyCodeLine{1586 }
\DoxyCodeLine{1587   \textcolor{keywordflow}{if} (save\_ic .and. .not.((dirs\%input\_filename(1:1) == \textcolor{stringliteral}{'r'}) .and. \&}
\DoxyCodeLine{1588                           (len\_trim(dirs\%input\_filename) == 1))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1589     \textcolor{keyword}{call }save\_restart(dirs\%output\_directory, cs\%Time, g, \&}
\DoxyCodeLine{1590                       cs\%restart\_CSp, filename=ic\_file)}
\DoxyCodeLine{1591 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1592 }
\DoxyCodeLine{1593 }
\DoxyCodeLine{1594   cs\%id\_area\_shelf\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_shelf\_h'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1595      \textcolor{stringliteral}{'Ice Shelf Area in cell'}, \textcolor{stringliteral}{'meter-\/2'}, conversion=us\%L\_to\_m**2)}
\DoxyCodeLine{1596   cs\%id\_shelf\_mass = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'shelf\_mass'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1597      \textcolor{stringliteral}{'mass of shelf'}, \textcolor{stringliteral}{'kg/m\string^2'}, conversion=us\%RZ\_to\_kg\_m2)}
\DoxyCodeLine{1598   cs\%id\_h\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_shelf'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1599        \textcolor{stringliteral}{'ice shelf thickness'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{1600   cs\%id\_mass\_flux = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'mass\_flux'}, cs\%diag\%axesT1,\&}
\DoxyCodeLine{1601      cs\%Time, \textcolor{stringliteral}{'Total mass flux of freshwater across the ice-\/ocean interface.'}, \&}
\DoxyCodeLine{1602      \textcolor{stringliteral}{'kg/s'}, conversion=us\%RZ\_T\_to\_kg\_m2s*us\%L\_to\_m**2)}
\DoxyCodeLine{1603 }
\DoxyCodeLine{1604   \textcolor{keywordflow}{if} (cs\%const\_gamma) \textcolor{keywordflow}{then} \textcolor{comment}{! use ISOMIP+ eq. with rho\_fw = 1000. kg m-\/3}}
\DoxyCodeLine{1605     meltrate\_conversion = 86400.0*365.0*us\%Z\_to\_m*us\%s\_to\_T / (1000.0*us\%kg\_m3\_to\_R)}
\DoxyCodeLine{1606   \textcolor{keywordflow}{else} \textcolor{comment}{! use original eq.}}
\DoxyCodeLine{1607     meltrate\_conversion = 86400.0*365.0*us\%Z\_to\_m*us\%s\_to\_T / cs\%density\_ice}
\DoxyCodeLine{1608 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1609   cs\%id\_melt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'melt'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1610      \textcolor{stringliteral}{'Ice Shelf Melt Rate'}, \textcolor{stringliteral}{'m yr-\/1'}, conversion= meltrate\_conversion)}
\DoxyCodeLine{1611   cs\%id\_thermal\_driving = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'thermal\_driving'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1612      \textcolor{stringliteral}{'pot. temp. in the boundary layer minus freezing pot. temp. at the ice-\/ocean interface.'}, \textcolor{stringliteral}{'Celsius'})}
\DoxyCodeLine{1613   cs\%id\_haline\_driving = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'haline\_driving'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1614      \textcolor{stringliteral}{'salinity in the boundary layer minus salinity at the ice-\/ocean interface.'}, \textcolor{stringliteral}{'psu'})}
\DoxyCodeLine{1615   cs\%id\_Sbdry = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sbdry'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1616      \textcolor{stringliteral}{'salinity at the ice-\/ocean interface.'}, \textcolor{stringliteral}{'psu'})}
\DoxyCodeLine{1617   cs\%id\_u\_ml = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_ml'}, cs\%diag\%axesCu1, cs\%Time, \&}
\DoxyCodeLine{1618      \textcolor{stringliteral}{'Eastward vel. in the boundary layer (used to compute ustar)'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{1619   cs\%id\_v\_ml = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_ml'}, cs\%diag\%axesCv1, cs\%Time, \&}
\DoxyCodeLine{1620      \textcolor{stringliteral}{'Northward vel. in the boundary layer (used to compute ustar)'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{1621   cs\%id\_exch\_vel\_s = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'exch\_vel\_s'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1622      \textcolor{stringliteral}{'Sub-\/shelf salinity exchange velocity'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%Z\_to\_m*us\%s\_to\_T)}
\DoxyCodeLine{1623   cs\%id\_exch\_vel\_t = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'exch\_vel\_t'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1624      \textcolor{stringliteral}{'Sub-\/shelf thermal exchange velocity'}, \textcolor{stringliteral}{'m s-\/1'} , conversion=us\%Z\_to\_m*us\%s\_to\_T)}
\DoxyCodeLine{1625   cs\%id\_tfreeze = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'tfreeze'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1626      \textcolor{stringliteral}{'In Situ Freezing point at ice shelf interface'}, \textcolor{stringliteral}{'degC'})}
\DoxyCodeLine{1627   cs\%id\_tfl\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'tflux\_shelf'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1628      \textcolor{stringliteral}{'Heat conduction into ice shelf'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=-\/us\%QRZ\_T\_to\_W\_m2)}
\DoxyCodeLine{1629   cs\%id\_ustar\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ustar\_shelf'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1630      \textcolor{stringliteral}{'Fric vel under shelf'}, \textcolor{stringliteral}{'m/s'}, conversion=us\%Z\_to\_m*us\%s\_to\_T)}
\DoxyCodeLine{1631   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1632     cs\%id\_h\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_mask'}, cs\%diag\%axesT1, cs\%Time, \&}
\DoxyCodeLine{1633        \textcolor{stringliteral}{'ice shelf thickness mask'}, \textcolor{stringliteral}{'none'})}
\DoxyCodeLine{1634 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1635 }
\DoxyCodeLine{1636   id\_clock\_shelf = cpu\_clock\_id(\textcolor{stringliteral}{'Ice shelf'}, grain=clock\_component)}
\DoxyCodeLine{1637   id\_clock\_pass = cpu\_clock\_id(\textcolor{stringliteral}{' Ice shelf halo updates'}, grain=clock\_routine)}
\DoxyCodeLine{1638 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_ac478a1dd52137f8e851916bee2243fa3}\label{namespacemom__ice__shelf_ac478a1dd52137f8e851916bee2243fa3}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!initialize\_shelf\_mass@{initialize\_shelf\_mass}}
\index{initialize\_shelf\_mass@{initialize\_shelf\_mass}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{initialize\_shelf\_mass()}{initialize\_shelf\_mass()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+::initialize\+\_\+shelf\+\_\+mass (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(inout)}]{I\+SS,  }\item[{logical, intent(in), optional}]{new\+\_\+sim }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initializes shelf mass based on three options (file, zero and user) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
 & {\em cs} & A pointer to the ice shelf control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em iss} & The ice shelf state type that is being updated \\
\hline
\mbox{\texttt{ in}}  & {\em new\+\_\+sim} & If present and false, this run is being restarted \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1643 }
\DoxyCodeLine{1644   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< The ocean's grid structure.}}
\DoxyCodeLine{1645   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{1646   \textcolor{keywordtype}{type}(ice\_shelf\_CS),    \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1647   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(inout)} :: ISS\textcolor{comment}{ !< The ice shelf state type that is being updated}}
\DoxyCodeLine{1648   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: new\_sim\textcolor{comment}{ !< If present and false, this run is being restarted}}
\DoxyCodeLine{1649 }
\DoxyCodeLine{1650   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1651   \textcolor{keywordtype}{logical} :: read\_shelf\_area, new\_sim\_2}
\DoxyCodeLine{1652   \textcolor{keywordtype}{character(len=240)} :: config, inputdir, shelf\_file, filename}
\DoxyCodeLine{1653   \textcolor{keywordtype}{character(len=120)} :: shelf\_mass\_var  \textcolor{comment}{! The name of shelf mass in the file.}}
\DoxyCodeLine{1654   \textcolor{keywordtype}{character(len=120)} :: shelf\_area\_var \textcolor{comment}{! The name of shelf area in the file.}}
\DoxyCodeLine{1655   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf"}}
\DoxyCodeLine{1656   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1657 }
\DoxyCodeLine{1658   new\_sim\_2 = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(new\_sim)) new\_sim\_2 = new\_sim}
\DoxyCodeLine{1659 }
\DoxyCodeLine{1660   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_CONFIG"}, config, \&}
\DoxyCodeLine{1661                  \textcolor{stringliteral}{"A string that specifies how the ice shelf is "}//\&}
\DoxyCodeLine{1662                  \textcolor{stringliteral}{"initialized. Valid options include:\(\backslash\)n"}//\&}
\DoxyCodeLine{1663                  \textcolor{stringliteral}{" \(\backslash\)tfile\(\backslash\)t Read from a file.\(\backslash\)n"}//\&}
\DoxyCodeLine{1664                  \textcolor{stringliteral}{" \(\backslash\)tzero\(\backslash\)t Set shelf mass to 0 everywhere.\(\backslash\)n"}//\&}
\DoxyCodeLine{1665                  \textcolor{stringliteral}{" \(\backslash\)tUSER\(\backslash\)t Call USER\_initialize\_shelf\_mass.\(\backslash\)n"}, \&}
\DoxyCodeLine{1666                  fail\_if\_missing=.true.)}
\DoxyCodeLine{1667 }
\DoxyCodeLine{1668   \textcolor{keywordflow}{select case} ( trim(config) )}
\DoxyCodeLine{1669     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"file"})}
\DoxyCodeLine{1670 }
\DoxyCodeLine{1671       \textcolor{keyword}{call }time\_interp\_external\_init()}
\DoxyCodeLine{1672 }
\DoxyCodeLine{1673       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1674       inputdir = slasher(inputdir)}
\DoxyCodeLine{1675 }
\DoxyCodeLine{1676       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_FILE"}, shelf\_file, \&}
\DoxyCodeLine{1677               \textcolor{stringliteral}{"If DYNAMIC\_SHELF\_MASS = True, OVERRIDE\_SHELF\_MOVEMENT = True "}//\&}
\DoxyCodeLine{1678               \textcolor{stringliteral}{"and ICE\_SHELF\_MASS\_FROM\_FILE = True, this is the file from "}//\&}
\DoxyCodeLine{1679               \textcolor{stringliteral}{"which to read the shelf mass and area."}, \&}
\DoxyCodeLine{1680                default=\textcolor{stringliteral}{"shelf\_mass.nc"})}
\DoxyCodeLine{1681       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_MASS\_VAR"}, shelf\_mass\_var, \&}
\DoxyCodeLine{1682                  \textcolor{stringliteral}{"The variable in SHELF\_FILE with the shelf mass."}, \&}
\DoxyCodeLine{1683                  default=\textcolor{stringliteral}{"shelf\_mass"})}
\DoxyCodeLine{1684       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"READ\_SHELF\_AREA"}, read\_shelf\_area, \&}
\DoxyCodeLine{1685                  \textcolor{stringliteral}{"If true, also read the area covered by ice-\/shelf from SHELF\_FILE."}, \&}
\DoxyCodeLine{1686                  default=.false.)}
\DoxyCodeLine{1687 }
\DoxyCodeLine{1688       filename = trim(slasher(inputdir))//trim(shelf\_file)}
\DoxyCodeLine{1689       \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/SHELF\_FILE"}, filename)}
\DoxyCodeLine{1690 }
\DoxyCodeLine{1691       cs\%id\_read\_mass = init\_external\_field(filename, shelf\_mass\_var, \&}
\DoxyCodeLine{1692                           domain=g\%Domain\%mpp\_domain, verbose=cs\%debug)}
\DoxyCodeLine{1693 }
\DoxyCodeLine{1694       \textcolor{keywordflow}{if} (read\_shelf\_area) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1695          \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_AREA\_VAR"}, shelf\_area\_var, \&}
\DoxyCodeLine{1696                   \textcolor{stringliteral}{"The variable in SHELF\_FILE with the shelf area."}, \&}
\DoxyCodeLine{1697                   default=\textcolor{stringliteral}{"shelf\_area"})}
\DoxyCodeLine{1698 }
\DoxyCodeLine{1699          cs\%id\_read\_area = init\_external\_field(filename,shelf\_area\_var, \&}
\DoxyCodeLine{1700                              domain=g\%Domain\%mpp\_domain)}
\DoxyCodeLine{1701 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1702 }
\DoxyCodeLine{1703       \textcolor{keywordflow}{if} (.not.file\_exists(filename, g\%Domain)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{1704            \textcolor{stringliteral}{" initialize\_shelf\_mass: Unable to open "}//trim(filename))}
\DoxyCodeLine{1705 }
\DoxyCodeLine{1706     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"zero"})}
\DoxyCodeLine{1707       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1708         iss\%mass\_shelf(i,j) = 0.0}
\DoxyCodeLine{1709         iss\%area\_shelf\_h(i,j) = 0.0}
\DoxyCodeLine{1710 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1711 }
\DoxyCodeLine{1712     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"USER"})}
\DoxyCodeLine{1713       \textcolor{keyword}{call }user\_initialize\_shelf\_mass(iss\%mass\_shelf, iss\%area\_shelf\_h, \&}
\DoxyCodeLine{1714                    iss\%h\_shelf, iss\%hmask, g, cs\%US, cs\%user\_CS, param\_file, new\_sim\_2)}
\DoxyCodeLine{1715 }
\DoxyCodeLine{1716 \textcolor{keywordflow}{    case default} ;  \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_ice\_shelf: "}// \&}
\DoxyCodeLine{1717       \textcolor{stringliteral}{"Unrecognized ice shelf setup "}//trim(config))}
\DoxyCodeLine{1718 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1719 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}\label{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!shelf\_calc\_flux@{shelf\_calc\_flux}}
\index{shelf\_calc\_flux@{shelf\_calc\_flux}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{shelf\_calc\_flux()}{shelf\_calc\_flux()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::shelf\+\_\+calc\+\_\+flux (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{real, intent(in)}]{time\+\_\+step,  }\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS,  }\item[{type(mech\+\_\+forcing), intent(inout), optional}]{forces }\end{DoxyParamCaption})}



Calculates fluxes between the ocean and ice-\/shelf using the three-\/equations formulation (optional to use just two equations). See \mbox{\hyperlink{namespacemom__ice__shelf_section_ICE_SHELF_equations}{I\+C\+E\+\_\+\+S\+H\+E\+LF equations}}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. The intent is only inout to allow for halo updates. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & structure containing pointers to any possible thermodynamic or mass-\/flux forcing fields. \\
\hline
\mbox{\texttt{ in}}  & {\em time} & Start time of the fluxes. \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+step} & Length of time over which these fluxes will be applied \mbox{[}s\mbox{]}. \\
\hline
 & {\em cs} & A pointer to the control structure returned by a previous call to initialize\+\_\+ice\+\_\+shelf. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{195   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{196 \textcolor{comment}{                                                !! describe the surface state of the ocean.  The}}
\DoxyCodeLine{197 \textcolor{comment}{                                                !! intent is only inout to allow for halo updates.}}
\DoxyCodeLine{198   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< structure containing pointers to any possible}}
\DoxyCodeLine{199 \textcolor{comment}{                                                !! thermodynamic or mass-\/flux forcing fields.}}
\DoxyCodeLine{200   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{  !< Start time of the fluxes.}}
\DoxyCodeLine{201 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< Length of time over which these fluxes}}
\DoxyCodeLine{202 \textcolor{comment}{                                                !! will be applied [s].}}
\DoxyCodeLine{203   \textcolor{keywordtype}{type}(ice\_shelf\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{    !< A pointer to the control structure returned}}
\DoxyCodeLine{204 \textcolor{comment}{                                                !! by a previous call to initialize\_ice\_shelf.}}
\DoxyCodeLine{205   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{206 }
\DoxyCodeLine{207   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{208   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: G => null()  \textcolor{comment}{!< The grid structure used by the ice shelf.}}
\DoxyCodeLine{209   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{pointer} :: US => null() \textcolor{comment}{!< Pointer to a structure containing}}
\DoxyCodeLine{210 \textcolor{comment}{                                                 !! various unit conversion factors}}
\DoxyCodeLine{211   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: ISS => null() \textcolor{comment}{!< A structure with elements that describe}}
\DoxyCodeLine{212 \textcolor{comment}{                                                 !! the ice-\/shelf state}}
\DoxyCodeLine{213 }
\DoxyCodeLine{214 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(CS\%grid))} :: \&}
\DoxyCodeLine{215     Rhoml, \&   !< Ocean mixed layer density [R ~> kg m-\/3].}
\DoxyCodeLine{216     dR0\_dT, \&  !< Partial derivative of the mixed layer density}
\DoxyCodeLine{217 \textcolor{comment}{               !< with temperature [R degC-\/1 ~> kg m-\/3 degC-\/1].}}
\DoxyCodeLine{218     dr0\_ds, \&  \textcolor{comment}{!< Partial derivative of the mixed layer density}}
\DoxyCodeLine{219 \textcolor{comment}{               !< with salinity [R ppt-\/1 ~> kg m-\/3 ppt-\/1].}}
\DoxyCodeLine{220     p\_int      \textcolor{comment}{!< The pressure at the ice-\/ocean interface [R L2 T-\/2 ~> Pa].}}
\DoxyCodeLine{221 }
\DoxyCodeLine{222 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(CS\%grid),SZJ\_(CS\%grid))} :: \&}
\DoxyCodeLine{223     exch\_vel\_t, \&  !< Sub-\/shelf thermal exchange velocity [Z T-\/1 ~> m s-\/1]}
\DoxyCodeLine{224     exch\_vel\_s\textcolor{comment}{     !< Sub-\/shelf salt exchange velocity [Z T-\/1 ~> m s-\/1]}}
\DoxyCodeLine{225 }
\DoxyCodeLine{226 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(CS\%grid),SZDJ\_(CS\%grid))} :: \&}
\DoxyCodeLine{227     mass\_flux\textcolor{comment}{  !< Total mass flux of freshwater across the ice-\/ocean interface. [R Z L2 T-\/1 ~> kg/s]}}
\DoxyCodeLine{228 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(CS\%grid),SZDJ\_(CS\%grid))} :: \&}
\DoxyCodeLine{229     haline\_driving\textcolor{comment}{ !< (SSS -\/ S\_boundary) ice-\/ocean}}
\DoxyCodeLine{230 \textcolor{comment}{               !! interface, positive for melting and negative for freezing.}}
\DoxyCodeLine{231 \textcolor{comment}{               !! This is computed as part of the ISOMIP diagnostics.}}
\DoxyCodeLine{232 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: VK    = 0.40\textcolor{comment}{ !< Von Karman's constant -\/ dimensionless}}
\DoxyCodeLine{233 \textcolor{keywordtype}{  real} :: ZETA\_N = 0.052\textcolor{comment}{ !> The fraction of the boundary layer over which the}}
\DoxyCodeLine{234 \textcolor{comment}{               !! viscosity is linearly increasing [nondim]. (Was 1/8. Why?)}}
\DoxyCodeLine{235 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: RC    = 0.20     \textcolor{comment}{! critical flux Richardson number.}}
\DoxyCodeLine{236 \textcolor{keywordtype}{  real} :: I\_ZETA\_N\textcolor{comment}{ !< The inverse of ZETA\_N [nondim].}}
\DoxyCodeLine{237 \textcolor{keywordtype}{  real} :: I\_LF\textcolor{comment}{     !< The inverse of the latent heat of fusion [Q-\/1 ~> kg J-\/1].}}
\DoxyCodeLine{238 \textcolor{keywordtype}{  real} :: I\_VK\textcolor{comment}{     !< The inverse of the Von Karman constant [nondim].}}
\DoxyCodeLine{239 \textcolor{keywordtype}{  real} :: PR, SC\textcolor{comment}{   !< The Prandtl number and Schmidt number [nondim].}}
\DoxyCodeLine{240 }
\DoxyCodeLine{241   \textcolor{comment}{! 3 equations formulation variables}}
\DoxyCodeLine{242 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZDI\_(CS\%grid),SZDJ\_(CS\%grid))} :: \&}
\DoxyCodeLine{243     Sbdry\textcolor{comment}{     !< Salinities in the ocean at the interface with the ice shelf [ppt].}}
\DoxyCodeLine{244 \textcolor{keywordtype}{  real} :: Sbdry\_it}
\DoxyCodeLine{245 \textcolor{keywordtype}{  real} :: Sbdry1, Sbdry2}
\DoxyCodeLine{246 \textcolor{keywordtype}{  real} :: S\_a, S\_b, S\_c  \textcolor{comment}{! Variables used to find salt roots}}
\DoxyCodeLine{247 \textcolor{keywordtype}{  real} :: dS\_it\textcolor{comment}{    !< The interface salinity change during an iteration [ppt].}}
\DoxyCodeLine{248 \textcolor{keywordtype}{  real} :: hBL\_neut\textcolor{comment}{ !< The neutral boundary layer thickness [Z ~> m].}}
\DoxyCodeLine{249 \textcolor{keywordtype}{  real} :: hBL\_neut\_h\_molec\textcolor{comment}{ !< The ratio of the neutral boundary layer thickness}}
\DoxyCodeLine{250 \textcolor{comment}{                   !! to the molecular boundary layer thickness [nondim].}}
\DoxyCodeLine{251 \textcolor{keywordtype}{  real} :: wT\_flux\textcolor{comment}{ !< The downward vertical flux of heat just inside the ocean [degC Z T-\/1 ~> degC m s-\/1].}}
\DoxyCodeLine{252 \textcolor{keywordtype}{  real} :: wB\_flux\textcolor{comment}{ !< The downward vertical flux of buoyancy just inside the ocean [Z2 T-\/3 ~> m2 s-\/3].}}
\DoxyCodeLine{253 \textcolor{keywordtype}{  real} :: dB\_dS\textcolor{comment}{   !< The derivative of buoyancy with salinity [Z T-\/2 ppt-\/1 ~> m s-\/2 ppt-\/1].}}
\DoxyCodeLine{254 \textcolor{keywordtype}{  real} :: dB\_dT\textcolor{comment}{   !< The derivative of buoyancy with temperature [Z T-\/2 degC-\/1 ~> m s-\/2 degC-\/1].}}
\DoxyCodeLine{255 \textcolor{keywordtype}{  real} :: I\_n\_star \textcolor{comment}{! [nondim]}}
\DoxyCodeLine{256 \textcolor{keywordtype}{  real} :: n\_star\_term \textcolor{comment}{! A term in the expression for nstar [T3 Z-\/2 ~> s3 m-\/2]}}
\DoxyCodeLine{257 \textcolor{keywordtype}{  real} :: absf     \textcolor{comment}{! The absolute value of the Coriolis parameter [T-\/1 ~> s-\/1]}}
\DoxyCodeLine{258 \textcolor{keywordtype}{  real} :: dIns\_dwB\textcolor{comment}{ !< The partial derivative of I\_n\_star with wB\_flux, in [T3 Z-\/2 ~> s3 m-\/2]}}
\DoxyCodeLine{259 \textcolor{keywordtype}{  real} :: dT\_ustar \textcolor{comment}{! The difference between the the freezing point and the ocean boundary layer}}
\DoxyCodeLine{260                    \textcolor{comment}{! temperature times the friction velocity [degC Z T-\/1 ~> degC m s-\/1]}}
\DoxyCodeLine{261 \textcolor{keywordtype}{  real} :: dS\_ustar \textcolor{comment}{! The difference between the salinity at the ice-\/ocean interface and the ocean}}
\DoxyCodeLine{262                    \textcolor{comment}{! boundary layer salinity times the friction velocity [ppt Z T-\/1 ~> ppt m s-\/1]}}
\DoxyCodeLine{263 \textcolor{keywordtype}{  real} :: ustar\_h  \textcolor{comment}{! The friction velocity in the water below the ice shelf [Z T-\/1 ~> m s-\/1]}}
\DoxyCodeLine{264 \textcolor{keywordtype}{  real} :: Gam\_turb \textcolor{comment}{! [nondim]}}
\DoxyCodeLine{265 \textcolor{keywordtype}{  real} :: Gam\_mol\_t, Gam\_mol\_s \textcolor{comment}{! Relative coefficients of molecular diffusivites [nondim]}}
\DoxyCodeLine{266 \textcolor{keywordtype}{  real} :: RhoCp     \textcolor{comment}{! A typical ocean density times the heat capacity of water [Q R ~> J m-\/3]}}
\DoxyCodeLine{267 \textcolor{keywordtype}{  real} :: ln\_neut}
\DoxyCodeLine{268 \textcolor{keywordtype}{  real} :: mass\_exch \textcolor{comment}{! A mass exchange rate [R Z T-\/1 ~> kg m-\/2 s-\/1]}}
\DoxyCodeLine{269 \textcolor{keywordtype}{  real} :: Sb\_min, Sb\_max}
\DoxyCodeLine{270 \textcolor{keywordtype}{  real} :: dS\_min, dS\_max}
\DoxyCodeLine{271   \textcolor{comment}{! Variables used in iterating for wB\_flux.}}
\DoxyCodeLine{272 \textcolor{keywordtype}{  real} :: wB\_flux\_new, dDwB\_dwB\_in}
\DoxyCodeLine{273 \textcolor{keywordtype}{  real} :: I\_Gam\_T, I\_Gam\_S}
\DoxyCodeLine{274 \textcolor{keywordtype}{  real} :: dG\_dwB   \textcolor{comment}{! The derivative of Gam\_turb with wB [T3 Z-\/2 ~> s3 m-\/2]}}
\DoxyCodeLine{275 \textcolor{keywordtype}{  real} :: taux2, tauy2 \textcolor{comment}{! The squared surface stresses [R2 L2 Z2 T-\/4 ~> Pa2].}}
\DoxyCodeLine{276 \textcolor{keywordtype}{  real} :: u2\_av, v2\_av \textcolor{comment}{! The ice-\/area weighted average squared ocean velocities [L2 T-\/2 ~> m2 s-\/2]}}
\DoxyCodeLine{277 \textcolor{keywordtype}{  real} :: asu1, asu2   \textcolor{comment}{! Ocean areas covered by ice shelves at neighboring u-\/}}
\DoxyCodeLine{278 \textcolor{keywordtype}{  real} :: asv1, asv2   \textcolor{comment}{! and v-\/points [L2 ~> m2].}}
\DoxyCodeLine{279 \textcolor{keywordtype}{  real} :: I\_au, I\_av   \textcolor{comment}{! The Adcroft reciprocals of the ice shelf areas at adjacent points [L-\/2 ~> m-\/2]}}
\DoxyCodeLine{280 \textcolor{keywordtype}{  real} :: Irho0        \textcolor{comment}{! The inverse of the mean density times a unit conversion factor [R-\/1 L Z-\/1 ~> m3 kg-\/1]}}
\DoxyCodeLine{281   \textcolor{keywordtype}{logical} :: Sb\_min\_set, Sb\_max\_set}
\DoxyCodeLine{282   \textcolor{keywordtype}{logical} :: update\_ice\_vel \textcolor{comment}{! If true, it is time to update the ice shelf velocities.}}
\DoxyCodeLine{283   \textcolor{keywordtype}{logical} :: coupled\_GL     \textcolor{comment}{! If true, the grouding line position is determined based on}}
\DoxyCodeLine{284                             \textcolor{comment}{! coupled ice-\/ocean dynamics.}}
\DoxyCodeLine{285 }
\DoxyCodeLine{286 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: c2\_3 = 2.0/3.0}
\DoxyCodeLine{287   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{288   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The i-\/computational domain for the equation of state}}
\DoxyCodeLine{289   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, ied, jed, it1, it3}
\DoxyCodeLine{290 }
\DoxyCodeLine{291   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: "}// \&}
\DoxyCodeLine{292        \textcolor{stringliteral}{"initialize\_ice\_shelf must be called before shelf\_calc\_flux."})}
\DoxyCodeLine{293   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_shelf)}
\DoxyCodeLine{294 }
\DoxyCodeLine{295   g => cs\%grid ; us => cs\%US}
\DoxyCodeLine{296   iss => cs\%ISS}
\DoxyCodeLine{297 }
\DoxyCodeLine{298   \textcolor{comment}{! useful parameters}}
\DoxyCodeLine{299   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; ied = g\%ied ; jed = g\%jed}
\DoxyCodeLine{300   i\_zeta\_n = 1.0 / zeta\_n}
\DoxyCodeLine{301   i\_lf = 1.0 / cs\%Lat\_fusion}
\DoxyCodeLine{302   sc = cs\%kv\_molec/cs\%kd\_molec\_salt}
\DoxyCodeLine{303   pr = cs\%kv\_molec/cs\%kd\_molec\_temp}
\DoxyCodeLine{304   i\_vk = 1.0/vk}
\DoxyCodeLine{305   rhocp = cs\%Rho\_ocn * cs\%Cp}
\DoxyCodeLine{306 }
\DoxyCodeLine{307   \textcolor{comment}{!first calculate molecular component}}
\DoxyCodeLine{308   gam\_mol\_t = 12.5 * (pr**c2\_3) -\/ 6.0}
\DoxyCodeLine{309   gam\_mol\_s = 12.5 * (sc**c2\_3) -\/ 6.0}
\DoxyCodeLine{310 }
\DoxyCodeLine{311   \textcolor{comment}{! GMM, zero some fields of the ice shelf structure (ice\_shelf\_CS)}}
\DoxyCodeLine{312   \textcolor{comment}{! these fields are already set to zero during initialization}}
\DoxyCodeLine{313   \textcolor{comment}{! However, they seem to be changed somewhere and, for diagnostic}}
\DoxyCodeLine{314   \textcolor{comment}{! reasons, it is better to set them to zero again.}}
\DoxyCodeLine{315   exch\_vel\_t(:,:) = 0.0 ; exch\_vel\_s(:,:) = 0.0}
\DoxyCodeLine{316   iss\%tflux\_shelf(:,:) = 0.0 ; iss\%water\_flux(:,:) = 0.0}
\DoxyCodeLine{317   iss\%salt\_flux(:,:) = 0.0 ; iss\%tflux\_ocn(:,:) = 0.0 ; iss\%tfreeze(:,:) = 0.0}
\DoxyCodeLine{318   \textcolor{comment}{! define Sbdry to avoid Run-\/Time Check Failure, when melt is not computed.}}
\DoxyCodeLine{319   haline\_driving(:,:) = 0.0}
\DoxyCodeLine{320   sbdry(:,:) = sfc\_state\%sss(:,:)}
\DoxyCodeLine{321 }
\DoxyCodeLine{322   \textcolor{comment}{!update time}}
\DoxyCodeLine{323   cs\%Time = time}
\DoxyCodeLine{324 }
\DoxyCodeLine{325   \textcolor{keywordflow}{if} (cs\%override\_shelf\_movement) \textcolor{keywordflow}{then}}
\DoxyCodeLine{326     cs\%time\_step = time\_step}
\DoxyCodeLine{327     \textcolor{comment}{! update shelf mass}}
\DoxyCodeLine{328     \textcolor{keywordflow}{if} (cs\%mass\_from\_file) \textcolor{keyword}{call }update\_shelf\_mass(g, us, cs, iss, time)}
\DoxyCodeLine{329 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{330 }
\DoxyCodeLine{331   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{332     \textcolor{keyword}{call }hchksum(fluxes\%frac\_shelf\_h, \textcolor{stringliteral}{"frac\_shelf\_h before apply melting"}, g\%HI, haloshift=0)}
\DoxyCodeLine{333     \textcolor{keyword}{call }hchksum(sfc\_state\%sst, \textcolor{stringliteral}{"sst before apply melting"}, g\%HI, haloshift=0)}
\DoxyCodeLine{334     \textcolor{keyword}{call }hchksum(sfc\_state\%sss, \textcolor{stringliteral}{"sss before apply melting"}, g\%HI, haloshift=0)}
\DoxyCodeLine{335     \textcolor{keyword}{call }hchksum(sfc\_state\%u, \textcolor{stringliteral}{"u\_ml before apply melting"}, g\%HI, haloshift=0, scale=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{336     \textcolor{keyword}{call }hchksum(sfc\_state\%v, \textcolor{stringliteral}{"v\_ml before apply melting"}, g\%HI, haloshift=0, scale=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{337     \textcolor{keyword}{call }hchksum(sfc\_state\%ocean\_mass, \textcolor{stringliteral}{"ocean\_mass before apply melting"}, g\%HI, haloshift=0, \&}
\DoxyCodeLine{338                  scale=us\%RZ\_to\_kg\_m2)}
\DoxyCodeLine{339 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{340 }
\DoxyCodeLine{341   \textcolor{comment}{! Calculate the friction velocity under ice shelves, using taux\_shelf and tauy\_shelf if possible.}}
\DoxyCodeLine{342   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state\%taux\_shelf) .and. \textcolor{keyword}{allocated}(sfc\_state\%tauy\_shelf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{343     \textcolor{keyword}{call }pass\_vector(sfc\_state\%taux\_shelf, sfc\_state\%tauy\_shelf, g\%domain, to\_all, cgrid\_ne)}
\DoxyCodeLine{344 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{345   irho0 = us\%Z\_to\_L / cs\%Rho\_ocn}
\DoxyCodeLine{346   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (fluxes\%frac\_shelf\_h(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{347     taux2 = 0.0 ; tauy2 = 0.0 ; u2\_av = 0.0 ; v2\_av = 0.0}
\DoxyCodeLine{348     asu1 = (iss\%area\_shelf\_h(i-\/1,j) + iss\%area\_shelf\_h(i,j))}
\DoxyCodeLine{349     asu2 = (iss\%area\_shelf\_h(i,j) + iss\%area\_shelf\_h(i+1,j))}
\DoxyCodeLine{350     asv1 = (iss\%area\_shelf\_h(i,j-\/1) + iss\%area\_shelf\_h(i,j))}
\DoxyCodeLine{351     asv2 = (iss\%area\_shelf\_h(i,j) + iss\%area\_shelf\_h(i,j+1))}
\DoxyCodeLine{352     i\_au = 0.0 ; \textcolor{keywordflow}{if} (asu1 + asu2 > 0.0) i\_au = 1.0 / (asu1 + asu2)}
\DoxyCodeLine{353     i\_av = 0.0 ; \textcolor{keywordflow}{if} (asv1 + asv2 > 0.0) i\_av = 1.0 / (asv1 + asv2)}
\DoxyCodeLine{354     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state\%taux\_shelf) .and. \textcolor{keyword}{allocated}(sfc\_state\%tauy\_shelf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{355       taux2 = (asu1 * sfc\_state\%taux\_shelf(i-\/1,j)**2 + asu2 * sfc\_state\%taux\_shelf(i,j)**2  ) * i\_au}
\DoxyCodeLine{356       tauy2 = (asv1 * sfc\_state\%tauy\_shelf(i,j-\/1)**2 + asv2 * sfc\_state\%tauy\_shelf(i,j)**2  ) * i\_av}
\DoxyCodeLine{357 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{358     u2\_av = (asu1 * sfc\_state\%u(i-\/1,j)**2 + asu2 * sfc\_state\%u(i,j)**2) * i\_au}
\DoxyCodeLine{359     v2\_av = (asv1 * sfc\_state\%v(i,j-\/1)**2 + asu2 * sfc\_state\%v(i,j)**2) * i\_av}
\DoxyCodeLine{360 }
\DoxyCodeLine{361     \textcolor{keywordflow}{if} (taux2 + tauy2 > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{362       fluxes\%ustar\_shelf(i,j) = max(cs\%ustar\_bg, us\%L\_to\_Z * \&}
\DoxyCodeLine{363           sqrt(irho0 * sqrt(taux2 + tauy2) + cs\%cdrag*cs\%utide(i,j)**2))}
\DoxyCodeLine{364     \textcolor{keywordflow}{else}   \textcolor{comment}{! Take care of the cases when taux\_shelf is not set or not allocated.}}
\DoxyCodeLine{365       fluxes\%ustar\_shelf(i,j) = max(cs\%ustar\_bg, us\%L\_TO\_Z * \&}
\DoxyCodeLine{366           sqrt(cs\%cdrag*((u2\_av + v2\_av) + cs\%utide(i,j)**2)))}
\DoxyCodeLine{367 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{368   \textcolor{keywordflow}{else} \textcolor{comment}{! There is no shelf here.}}
\DoxyCodeLine{369     fluxes\%ustar\_shelf(i,j) = 0.0}
\DoxyCodeLine{370 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{371 }
\DoxyCodeLine{372   eosdom(:) = eos\_domain(g\%HI)}
\DoxyCodeLine{373   \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{374     \textcolor{comment}{! Find the pressure at the ice-\/ocean interface, averaged only over the}}
\DoxyCodeLine{375     \textcolor{comment}{! part of the cell covered by ice shelf.}}
\DoxyCodeLine{376     \textcolor{keywordflow}{do} i=is,ie ; p\_int(i) = cs\%g\_Earth * iss\%mass\_shelf(i,j) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{377 }
\DoxyCodeLine{378     \textcolor{comment}{! Calculate insitu densities and expansion coefficients}}
\DoxyCodeLine{379     \textcolor{keyword}{call }calculate\_density(sfc\_state\%sst(:,j), sfc\_state\%sss(:,j), p\_int, rhoml(:), \&}
\DoxyCodeLine{380                                  cs\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{381     \textcolor{keyword}{call }calculate\_density\_derivs(sfc\_state\%sst(:,j), sfc\_state\%sss(:,j), p\_int, dr0\_dt, dr0\_ds, \&}
\DoxyCodeLine{382                                  cs\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{383 }
\DoxyCodeLine{384     \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{385       \textcolor{keywordflow}{if} ((sfc\_state\%ocean\_mass(i,j) > cs\%col\_mass\_melt\_threshold) .and. \&}
\DoxyCodeLine{386           (iss\%area\_shelf\_h(i,j) > 0.0) .and. cs\%isthermo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{387 }
\DoxyCodeLine{388         \textcolor{keywordflow}{if} (cs\%threeeq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{389           \textcolor{comment}{!   Iteratively determine a self-\/consistent set of fluxes, with the ocean}}
\DoxyCodeLine{390           \textcolor{comment}{! salinity just below the ice-\/shelf as the variable that is being}}
\DoxyCodeLine{391           \textcolor{comment}{! iterated for.}}
\DoxyCodeLine{392 }
\DoxyCodeLine{393           ustar\_h = fluxes\%ustar\_shelf(i,j)}
\DoxyCodeLine{394 }
\DoxyCodeLine{395           \textcolor{comment}{! Estimate the neutral ocean boundary layer thickness as the minimum of the}}
\DoxyCodeLine{396           \textcolor{comment}{! reported ocean mixed layer thickness and the neutral Ekman depth.}}
\DoxyCodeLine{397           absf = 0.25*((abs(g\%CoriolisBu(i,j)) + abs(g\%CoriolisBu(i-\/1,j-\/1))) + \&}
\DoxyCodeLine{398                                  (abs(g\%CoriolisBu(i,j-\/1)) + abs(g\%CoriolisBu(i-\/1,j))))}
\DoxyCodeLine{399           \textcolor{keywordflow}{if} (absf*sfc\_state\%Hml(i,j) <= vk*ustar\_h) \textcolor{keywordflow}{then} ; hbl\_neut = sfc\_state\%Hml(i,j)}
\DoxyCodeLine{400           \textcolor{keywordflow}{else} ; hbl\_neut = (vk*ustar\_h) / absf ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{401           hbl\_neut\_h\_molec = zeta\_n * ((hbl\_neut * ustar\_h) / (5.0 * cs\%kv\_molec))}
\DoxyCodeLine{402 }
\DoxyCodeLine{403           \textcolor{comment}{! Determine the mixed layer buoyancy flux, wB\_flux.}}
\DoxyCodeLine{404           db\_ds = (us\%L\_to\_Z**2*cs\%g\_Earth / rhoml(i)) * dr0\_ds(i)}
\DoxyCodeLine{405           db\_dt = (us\%L\_to\_Z**2*cs\%g\_Earth / rhoml(i)) * dr0\_dt(i)}
\DoxyCodeLine{406           ln\_neut = 0.0 ; \textcolor{keywordflow}{if} (hbl\_neut\_h\_molec > 1.0) ln\_neut = log(hbl\_neut\_h\_molec)}
\DoxyCodeLine{407 }
\DoxyCodeLine{408           \textcolor{keywordflow}{if} (cs\%find\_salt\_root) \textcolor{keywordflow}{then}}
\DoxyCodeLine{409             \textcolor{comment}{! Solve for the skin salinity using the linearized liquidus parameters and}}
\DoxyCodeLine{410             \textcolor{comment}{! balancing the turbulent fresh water flux in the near-\/boundary layer with}}
\DoxyCodeLine{411             \textcolor{comment}{! the net fresh water or salt added by melting:}}
\DoxyCodeLine{412             \textcolor{comment}{! (Cp/Lat\_fusion)*Gamma\_T\_3Eq*(TFr\_skin-\/T\_ocn) = Gamma\_S\_3Eq*(S\_skin-\/S\_ocn)/S\_skin}}
\DoxyCodeLine{413 }
\DoxyCodeLine{414             \textcolor{comment}{! S\_a is always < 0.0 with a realistic expression for the freezing point.}}
\DoxyCodeLine{415             s\_a = cs\%dTFr\_dS * cs\%Gamma\_T\_3EQ * cs\%Cp}
\DoxyCodeLine{416             s\_b = cs\%Gamma\_T\_3EQ*cs\%Cp*(cs\%TFr\_0\_0 + cs\%dTFr\_dp*p\_int(i) -\/ sfc\_state\%sst(i,j)) -\/ \&}
\DoxyCodeLine{417                   cs\%Lat\_fusion * cs\%Gamma\_S\_3EQ    \textcolor{comment}{! S\_b Can take either sign, but is usually negative.}}
\DoxyCodeLine{418             s\_c = cs\%Lat\_fusion * cs\%Gamma\_S\_3EQ * sfc\_state\%sss(i,j) \textcolor{comment}{! Always >= 0}}
\DoxyCodeLine{419 }
\DoxyCodeLine{420             \textcolor{keywordflow}{if} (s\_c == 0.0) \textcolor{keywordflow}{then}  \textcolor{comment}{! The solution for fresh water.}}
\DoxyCodeLine{421               sbdry(i,j) = 0.0}
\DoxyCodeLine{422             \textcolor{keywordflow}{elseif} (s\_a < 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! This is the usual ocean case}}
\DoxyCodeLine{423               \textcolor{keywordflow}{if} (s\_b < 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! This is almost always the case}}
\DoxyCodeLine{424                 sbdry(i,j) = 2.0*s\_c / (-\/s\_b + sqrt(s\_b*s\_b -\/ 4.*s\_a*s\_c))}
\DoxyCodeLine{425               \textcolor{keywordflow}{else}}
\DoxyCodeLine{426                 sbdry(i,j) = (s\_b + sqrt(s\_b*s\_b -\/ 4.*s\_a*s\_c)) / (-\/2.*s\_a)}
\DoxyCodeLine{427 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{428             \textcolor{keywordflow}{elseif} ((s\_a == 0.0) .and. (s\_b < 0.0)) \textcolor{keywordflow}{then} \textcolor{comment}{! It should be the case that S\_b < 0.}}
\DoxyCodeLine{429               sbdry(i,j) = -\/s\_c / s\_b}
\DoxyCodeLine{430             \textcolor{keywordflow}{else}}
\DoxyCodeLine{431               \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Impossible conditions found in 3-\/equation skin salinity calculation."})}
\DoxyCodeLine{432 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{433 }
\DoxyCodeLine{434             \textcolor{comment}{! Safety check}}
\DoxyCodeLine{435             \textcolor{keywordflow}{if} (sbdry(i,j) < 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{436               \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'sfc\_state\%sss(i,j) = '},sfc\_state\%sss(i,j), \textcolor{stringliteral}{'S\_a, S\_b, S\_c'}, s\_a, s\_b, s\_c}
\DoxyCodeLine{437               \textcolor{keyword}{call }mom\_error(warning, mesg, .true.)}
\DoxyCodeLine{438               \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'I,J,Sbdry1,Sbdry2'},i,j,sbdry1,sbdry2}
\DoxyCodeLine{439               \textcolor{keyword}{call }mom\_error(warning, mesg, .true.)}
\DoxyCodeLine{440               \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: Negative salinity (Sbdry)."})}
\DoxyCodeLine{441 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{442           \textcolor{keywordflow}{else}}
\DoxyCodeLine{443             \textcolor{comment}{! Guess sss as the iteration starting point for the boundary salinity.}}
\DoxyCodeLine{444             sbdry(i,j) = sfc\_state\%sss(i,j) ; sb\_max\_set = .false.}
\DoxyCodeLine{445             sb\_min\_set = .false.}
\DoxyCodeLine{446 \textcolor{keywordflow}{          endif} \textcolor{comment}{!find\_salt\_root}}
\DoxyCodeLine{447 }
\DoxyCodeLine{448           \textcolor{keywordflow}{do} it1 = 1,20}
\DoxyCodeLine{449             \textcolor{comment}{! Determine the potential temperature at the ice-\/ocean interface.}}
\DoxyCodeLine{450             \textcolor{keyword}{call }calculate\_tfreeze(sbdry(i,j), p\_int(i), iss\%tfreeze(i,j), cs\%eqn\_of\_state, \&}
\DoxyCodeLine{451                                    pres\_scale=us\%RL2\_T2\_to\_Pa)}
\DoxyCodeLine{452 }
\DoxyCodeLine{453             dt\_ustar = (iss\%tfreeze(i,j) -\/ sfc\_state\%sst(i,j)) * ustar\_h}
\DoxyCodeLine{454             ds\_ustar = (sbdry(i,j) -\/ sfc\_state\%sss(i,j)) * ustar\_h}
\DoxyCodeLine{455 }
\DoxyCodeLine{456             \textcolor{comment}{! First, determine the buoyancy flux assuming no effects of stability}}
\DoxyCodeLine{457             \textcolor{comment}{! on the turbulence.  Following H \& J '99, this limit also applies}}
\DoxyCodeLine{458             \textcolor{comment}{! when the buoyancy flux is destabilizing.}}
\DoxyCodeLine{459 }
\DoxyCodeLine{460             \textcolor{keywordflow}{if} (cs\%const\_gamma) \textcolor{keywordflow}{then} \textcolor{comment}{! if using a constant gamma\_T}}
\DoxyCodeLine{461               \textcolor{comment}{! note the different form, here I\_Gam\_T is NOT 1/Gam\_T!}}
\DoxyCodeLine{462               i\_gam\_t = cs\%Gamma\_T\_3EQ}
\DoxyCodeLine{463               i\_gam\_s = cs\%Gamma\_S\_3EQ}
\DoxyCodeLine{464             \textcolor{keywordflow}{else}}
\DoxyCodeLine{465               gam\_turb = i\_vk * (ln\_neut + (0.5 * i\_zeta\_n -\/ 1.0))}
\DoxyCodeLine{466               i\_gam\_t = 1.0 / (gam\_mol\_t + gam\_turb)}
\DoxyCodeLine{467               i\_gam\_s = 1.0 / (gam\_mol\_s + gam\_turb)}
\DoxyCodeLine{468 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{469 }
\DoxyCodeLine{470             wt\_flux = dt\_ustar * i\_gam\_t}
\DoxyCodeLine{471             wb\_flux = db\_ds * (ds\_ustar * i\_gam\_s) + db\_dt * wt\_flux}
\DoxyCodeLine{472 }
\DoxyCodeLine{473             \textcolor{keywordflow}{if} (wb\_flux < 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{474               \textcolor{comment}{! The buoyancy flux is stabilizing and will reduce the tubulent}}
\DoxyCodeLine{475               \textcolor{comment}{! fluxes, and iteration is required.}}
\DoxyCodeLine{476               n\_star\_term = (zeta\_n/rc) * (hbl\_neut * vk) / (ustar\_h)**3}
\DoxyCodeLine{477               \textcolor{keywordflow}{do} it3 = 1,30}
\DoxyCodeLine{478                \textcolor{comment}{! n\_star <= 1.0 is the ratio of working boundary layer thickness}}
\DoxyCodeLine{479                \textcolor{comment}{! to the neutral thickness.}}
\DoxyCodeLine{480                \textcolor{comment}{! hBL = n\_star*hBL\_neut ; hSub = 1/8*n\_star*hBL}}
\DoxyCodeLine{481 }
\DoxyCodeLine{482                 i\_n\_star = sqrt(1.0 -\/ n\_star\_term * wb\_flux)}
\DoxyCodeLine{483                 dins\_dwb = 0.5 * n\_star\_term / i\_n\_star}
\DoxyCodeLine{484                 \textcolor{keywordflow}{if} (hbl\_neut\_h\_molec > i\_n\_star**2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{485                   gam\_turb = i\_vk * ((ln\_neut -\/ 2.0*log(i\_n\_star)) + \&}
\DoxyCodeLine{486                                     (0.5*i\_zeta\_n*i\_n\_star -\/ 1.0))}
\DoxyCodeLine{487                   dg\_dwb =  i\_vk * ( -\/2.0 / i\_n\_star + (0.5 * i\_zeta\_n)) * dins\_dwb}
\DoxyCodeLine{488                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{489                   \textcolor{comment}{!   The layer dominated by molecular viscosity is smaller than}}
\DoxyCodeLine{490                   \textcolor{comment}{! the assumed boundary layer.  This should be rare!}}
\DoxyCodeLine{491                   gam\_turb = i\_vk * (0.5 * i\_zeta\_n*i\_n\_star -\/ 1.0)}
\DoxyCodeLine{492                   dg\_dwb = i\_vk * (0.5 * i\_zeta\_n) * dins\_dwb}
\DoxyCodeLine{493 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{494 }
\DoxyCodeLine{495                 \textcolor{keywordflow}{if} (cs\%const\_gamma) \textcolor{keywordflow}{then} \textcolor{comment}{! if using a constant gamma\_T}}
\DoxyCodeLine{496                   \textcolor{comment}{! note the different form, here I\_Gam\_T is NOT 1/Gam\_T!}}
\DoxyCodeLine{497                   i\_gam\_t = cs\%Gamma\_T\_3EQ}
\DoxyCodeLine{498                   i\_gam\_s = cs\%Gamma\_S\_3EQ}
\DoxyCodeLine{499                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{500                   i\_gam\_t = 1.0 / (gam\_mol\_t + gam\_turb)}
\DoxyCodeLine{501                   i\_gam\_s = 1.0 / (gam\_mol\_s + gam\_turb)}
\DoxyCodeLine{502 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{503 }
\DoxyCodeLine{504                 wt\_flux = dt\_ustar * i\_gam\_t}
\DoxyCodeLine{505                 wb\_flux\_new = db\_ds * (ds\_ustar * i\_gam\_s) + db\_dt * wt\_flux}
\DoxyCodeLine{506 }
\DoxyCodeLine{507                 \textcolor{comment}{! Find the root where wB\_flux\_new = wB\_flux.  Make the 1.0e-\/4 below into a parameter?}}
\DoxyCodeLine{508                 \textcolor{keywordflow}{if} (abs(wb\_flux\_new -\/ wb\_flux) < 1.0e-\/4*(abs(wb\_flux\_new) + abs(wb\_flux))) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{509 }
\DoxyCodeLine{510                 ddwb\_dwb\_in = dg\_dwb * (db\_ds * (ds\_ustar * i\_gam\_s**2) + \&}
\DoxyCodeLine{511                                         db\_dt * (dt\_ustar * i\_gam\_t**2)) -\/ 1.0}
\DoxyCodeLine{512                 \textcolor{comment}{! This is Newton's method without any bounds.  Should bounds be needed?}}
\DoxyCodeLine{513                 wb\_flux\_new = wb\_flux -\/ (wb\_flux\_new -\/ wb\_flux) / ddwb\_dwb\_in}
\DoxyCodeLine{514 \textcolor{keywordflow}{              enddo} \textcolor{comment}{!it3}}
\DoxyCodeLine{515 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{516 }
\DoxyCodeLine{517             iss\%tflux\_ocn(i,j)  = rhocp * wt\_flux}
\DoxyCodeLine{518             exch\_vel\_t(i,j) = ustar\_h * i\_gam\_t}
\DoxyCodeLine{519             exch\_vel\_s(i,j) = ustar\_h * i\_gam\_s}
\DoxyCodeLine{520 }
\DoxyCodeLine{521             \textcolor{comment}{! Calculate the heat flux inside the ice shelf.}}
\DoxyCodeLine{522             \textcolor{comment}{! Vertical adv/diff as in H+J 1999, eqns (26) \& approx from (31).}}
\DoxyCodeLine{523             \textcolor{comment}{!   Q\_ice = density\_ice * CS\%Cp\_ice * K\_ice * dT/dz (at interface)}}
\DoxyCodeLine{524             \textcolor{comment}{! vertical adv/diff as in H+J 1999, eqs (31) \& (26)...}}
\DoxyCodeLine{525             \textcolor{comment}{!   dT/dz ~= min( (lprec/(density\_ice*K\_ice))*(CS\%Temp\_Ice-\/T\_freeze) , 0.0 )}}
\DoxyCodeLine{526             \textcolor{comment}{! If this approximation is not made, iterations are required... See H+J Fig 3.}}
\DoxyCodeLine{527 }
\DoxyCodeLine{528             \textcolor{keywordflow}{if} (iss\%tflux\_ocn(i,j) >= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{529               \textcolor{comment}{! Freezing occurs due to downward ocean heat flux, so zero iout ce heat flux.}}
\DoxyCodeLine{530               iss\%water\_flux(i,j) = -\/i\_lf * iss\%tflux\_ocn(i,j)}
\DoxyCodeLine{531               iss\%tflux\_shelf(i,j) = 0.0}
\DoxyCodeLine{532             \textcolor{keywordflow}{else}}
\DoxyCodeLine{533               \textcolor{keywordflow}{if} (cs\%insulator) \textcolor{keywordflow}{then}}
\DoxyCodeLine{534                 \textcolor{comment}{!no conduction/perfect insulator}}
\DoxyCodeLine{535                 iss\%tflux\_shelf(i,j) = 0.0}
\DoxyCodeLine{536                 iss\%water\_flux(i,j) = i\_lf * (iss\%tflux\_shelf(i,j) -\/ iss\%tflux\_ocn(i,j))}
\DoxyCodeLine{537 }
\DoxyCodeLine{538               \textcolor{keywordflow}{else}}
\DoxyCodeLine{539                 \textcolor{comment}{! With melting, from H\&J 1999, eqs (31) \& (26)...}}
\DoxyCodeLine{540                 \textcolor{comment}{!   Q\_ice ~= Cp\_ice * (CS\%Temp\_Ice-\/T\_freeze) * lprec}}
\DoxyCodeLine{541                 \textcolor{comment}{!   RhoLF*lprec = Q\_ice -\/ ISS\%tflux\_ocn(i,j)}}
\DoxyCodeLine{542                 \textcolor{comment}{!   lprec = -\/(ISS\%tflux\_ocn(i,j)) / (CS\%Lat\_fusion + Cp\_ice * (T\_freeze-\/CS\%Temp\_Ice))}}
\DoxyCodeLine{543                 iss\%water\_flux(i,j) = -\/iss\%tflux\_ocn(i,j) / \&}
\DoxyCodeLine{544                      (cs\%Lat\_fusion + cs\%Cp\_ice * (iss\%tfreeze(i,j) -\/ cs\%Temp\_Ice))}
\DoxyCodeLine{545 }
\DoxyCodeLine{546                 iss\%tflux\_shelf(i,j) = iss\%tflux\_ocn(i,j) + cs\%Lat\_fusion*iss\%water\_flux(i,j)}
\DoxyCodeLine{547 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{548 }
\DoxyCodeLine{549 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{550             \textcolor{comment}{!other options: dTi/dz linear through shelf, with draft in [Z ~> m], KTI in [Z2 T-\/1 ~> m2 s-\/1]}}
\DoxyCodeLine{551             \textcolor{comment}{!    dTi\_dz = (CS\%Temp\_Ice -\/ ISS\%tfreeze(i,j)) / draft(i,j)}}
\DoxyCodeLine{552             \textcolor{comment}{!    ISS\%tflux\_shelf(i,j) = Rho\_Ice * CS\%Cp\_ice * KTI * dTi\_dz}}
\DoxyCodeLine{553 }
\DoxyCodeLine{554 }
\DoxyCodeLine{555             \textcolor{keywordflow}{if} (cs\%find\_salt\_root) \textcolor{keywordflow}{then}}
\DoxyCodeLine{556               \textcolor{keywordflow}{exit} \textcolor{comment}{! no need to do interaction, so exit loop}}
\DoxyCodeLine{557             \textcolor{keywordflow}{else}}
\DoxyCodeLine{558 }
\DoxyCodeLine{559               mass\_exch = exch\_vel\_s(i,j) * cs\%Rho\_ocn}
\DoxyCodeLine{560               sbdry\_it = (sfc\_state\%sss(i,j) * mass\_exch + cs\%Salin\_ice * iss\%water\_flux(i,j)) / \&}
\DoxyCodeLine{561                          (mass\_exch + iss\%water\_flux(i,j))}
\DoxyCodeLine{562               ds\_it = sbdry\_it -\/ sbdry(i,j)}
\DoxyCodeLine{563               \textcolor{keywordflow}{if} (abs(ds\_it) < 1.0e-\/4*(0.5*(sfc\_state\%sss(i,j) + sbdry(i,j) + 1.0e-\/10))) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{564 }
\DoxyCodeLine{565 }
\DoxyCodeLine{566               \textcolor{keywordflow}{if} (ds\_it < 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! Sbdry is now the upper bound.}}
\DoxyCodeLine{567                 \textcolor{keywordflow}{if} (sb\_max\_set .and. (sbdry(i,j) > sb\_max)) \&}
\DoxyCodeLine{568                   \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"shelf\_calc\_flux: Irregular iteration for Sbdry (max)."})}
\DoxyCodeLine{569                 sb\_max = sbdry(i,j) ; ds\_max = ds\_it ; sb\_max\_set = .true.}
\DoxyCodeLine{570               \textcolor{keywordflow}{else} \textcolor{comment}{! Sbdry is now the lower bound.}}
\DoxyCodeLine{571                 \textcolor{keywordflow}{if} (sb\_min\_set .and. (sbdry(i,j) < sb\_min)) \&}
\DoxyCodeLine{572                    \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: Irregular iteration for Sbdry (min)."})}
\DoxyCodeLine{573                  sb\_min = sbdry(i,j) ; ds\_min = ds\_it ; sb\_min\_set = .true.}
\DoxyCodeLine{574 \textcolor{keywordflow}{              endif} \textcolor{comment}{! dS\_it < 0.0}}
\DoxyCodeLine{575 }
\DoxyCodeLine{576               \textcolor{keywordflow}{if} (sb\_min\_set .and. sb\_max\_set) \textcolor{keywordflow}{then}}
\DoxyCodeLine{577                 \textcolor{comment}{! Use the false position method for the next iteration.}}
\DoxyCodeLine{578                 sbdry(i,j) = sb\_min + (sb\_max-\/sb\_min) * (ds\_min / (ds\_min -\/ ds\_max))}
\DoxyCodeLine{579               \textcolor{keywordflow}{else}}
\DoxyCodeLine{580                 sbdry(i,j) = sbdry\_it}
\DoxyCodeLine{581 \textcolor{keywordflow}{              endif} \textcolor{comment}{! Sb\_min\_set}}
\DoxyCodeLine{582 }
\DoxyCodeLine{583               sbdry(i,j) = sbdry\_it}
\DoxyCodeLine{584 \textcolor{keywordflow}{            endif} \textcolor{comment}{! CS\%find\_salt\_root}}
\DoxyCodeLine{585 }
\DoxyCodeLine{586 \textcolor{keywordflow}{          enddo} \textcolor{comment}{!it1}}
\DoxyCodeLine{587           \textcolor{comment}{! Check for non-\/convergence and/or non-\/boundedness?}}
\DoxyCodeLine{588 }
\DoxyCodeLine{589         \textcolor{keywordflow}{else}}
\DoxyCodeLine{590           \textcolor{comment}{!   In the 2-\/equation form, the mixed layer turbulent exchange velocity}}
\DoxyCodeLine{591           \textcolor{comment}{! is specified and large enough that the ocean salinity at the interface}}
\DoxyCodeLine{592           \textcolor{comment}{! is about the same as the boundary layer salinity.}}
\DoxyCodeLine{593 }
\DoxyCodeLine{594           \textcolor{keyword}{call }calculate\_tfreeze(sfc\_state\%sss(i,j), p\_int(i), iss\%tfreeze(i,j), cs\%eqn\_of\_state, \&}
\DoxyCodeLine{595                                  pres\_scale=us\%RL2\_T2\_to\_Pa)}
\DoxyCodeLine{596 }
\DoxyCodeLine{597           exch\_vel\_t(i,j) = cs\%gamma\_t}
\DoxyCodeLine{598           iss\%tflux\_ocn(i,j) = rhocp * exch\_vel\_t(i,j) * (iss\%tfreeze(i,j) -\/ sfc\_state\%sst(i,j))}
\DoxyCodeLine{599           iss\%tflux\_shelf(i,j) = 0.0}
\DoxyCodeLine{600           iss\%water\_flux(i,j) = -\/i\_lf * iss\%tflux\_ocn(i,j)}
\DoxyCodeLine{601           sbdry(i,j) = 0.0}
\DoxyCodeLine{602 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{603       \textcolor{keywordflow}{elseif} (iss\%area\_shelf\_h(i,j) > 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! This is an ice-\/sheet, not a floating shelf.}}
\DoxyCodeLine{604         iss\%tflux\_ocn(i,j) = 0.0}
\DoxyCodeLine{605       \textcolor{keywordflow}{else} \textcolor{comment}{! There is no ice shelf or sheet here.}}
\DoxyCodeLine{606         iss\%tflux\_ocn(i,j) = 0.0}
\DoxyCodeLine{607 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{608 }
\DoxyCodeLine{609 \textcolor{comment}{!      haline\_driving(i,j) = sfc\_state\%sss(i,j) -\/ Sbdry(i,j)}}
\DoxyCodeLine{610 }
\DoxyCodeLine{611 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! i-\/loop}}
\DoxyCodeLine{612 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! j-\/loop}}
\DoxyCodeLine{613 }
\DoxyCodeLine{614 }
\DoxyCodeLine{615   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{616     \textcolor{comment}{! ISS\%water\_flux = net liquid water into the ocean [R Z T-\/1 ~> kg m-\/2 s-\/1]}}
\DoxyCodeLine{617     fluxes\%iceshelf\_melt(i,j) = iss\%water\_flux(i,j) * cs\%flux\_factor}
\DoxyCodeLine{618 }
\DoxyCodeLine{619     \textcolor{keywordflow}{if} ((sfc\_state\%ocean\_mass(i,j) > cs\%col\_mass\_melt\_threshold) .and. \&}
\DoxyCodeLine{620         (iss\%area\_shelf\_h(i,j) > 0.0) .and.  (cs\%isthermo)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{621 }
\DoxyCodeLine{622       \textcolor{comment}{! Set melt to zero above a cutoff pressure (CS\%Rho\_ocn*CS\%cutoff\_depth*CS\%g\_Earth).}}
\DoxyCodeLine{623       \textcolor{comment}{! This is needed for the ISOMIP test case.}}
\DoxyCodeLine{624       \textcolor{keywordflow}{if} (iss\%mass\_shelf(i,j) < cs\%Rho\_ocn*cs\%cutoff\_depth) \textcolor{keywordflow}{then}}
\DoxyCodeLine{625         iss\%water\_flux(i,j) = 0.0}
\DoxyCodeLine{626         fluxes\%iceshelf\_melt(i,j) = 0.0}
\DoxyCodeLine{627 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{628       \textcolor{comment}{! Compute haline driving, which is one of the diags. used in ISOMIP}}
\DoxyCodeLine{629       haline\_driving(i,j) = (iss\%water\_flux(i,j) * sbdry(i,j)) / (cs\%Rho\_ocn * exch\_vel\_s(i,j))}
\DoxyCodeLine{630 }
\DoxyCodeLine{631       \textcolor{comment}{!!!!!!!!!!!!!!!!!!!!!!!!!!!!Safety checks !!!!!!!!!!!!!!!!!!!!!!!!!}}
\DoxyCodeLine{632       \textcolor{comment}{!1)Check if haline\_driving computed above is consistent with}}
\DoxyCodeLine{633       \textcolor{comment}{! haline\_driving = sfc\_state\%sss -\/ Sbdry}}
\DoxyCodeLine{634       \textcolor{comment}{!if (fluxes\%iceshelf\_melt(i,j) /= 0.0) then}}
\DoxyCodeLine{635       \textcolor{comment}{!   if (haline\_driving(i,j) /= (sfc\_state\%sss(i,j) -\/ Sbdry(i,j))) then}}
\DoxyCodeLine{636       \textcolor{comment}{!     write(mesg,*) 'at i,j=',i,j,' haline\_driving, sss-\/Sbdry',haline\_driving(i,j), \&}}
\DoxyCodeLine{637       \textcolor{comment}{!                   (sfc\_state\%sss(i,j) -\/ Sbdry(i,j))}}
\DoxyCodeLine{638       \textcolor{comment}{!     call MOM\_error(FATAL, \&}}
\DoxyCodeLine{639       \textcolor{comment}{!            "shelf\_calc\_flux: Inconsistency in melt and haline\_driving"//trim(mesg))}}
\DoxyCodeLine{640       \textcolor{comment}{!   endif}}
\DoxyCodeLine{641       \textcolor{comment}{!endif}}
\DoxyCodeLine{642 }
\DoxyCodeLine{643       \textcolor{comment}{! 2) check if |melt| > 0 when ustar\_shelf = 0.}}
\DoxyCodeLine{644       \textcolor{comment}{! this should never happen}}
\DoxyCodeLine{645       \textcolor{keywordflow}{if} ((abs(fluxes\%iceshelf\_melt(i,j))>0.0) .and. (fluxes\%ustar\_shelf(i,j) == 0.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{646         \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"|melt| = "},fluxes\%iceshelf\_melt(i,j),\textcolor{stringliteral}{" > 0 and ustar\_shelf = 0. at i,j"}, i, j}
\DoxyCodeLine{647         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: "}//trim(mesg))}
\DoxyCodeLine{648 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{649        \textcolor{comment}{!!!!!!!!!!!!!!!!!!!!!!!!!!!!End of safety checks !!!!!!!!!!!!!!!!!!!}}
\DoxyCodeLine{650     \textcolor{keywordflow}{elseif} (iss\%area\_shelf\_h(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{651       \textcolor{comment}{! This is grounded ice, that could be modified to melt if a geothermal heat flux were used.}}
\DoxyCodeLine{652       haline\_driving(i,j) = 0.0}
\DoxyCodeLine{653       iss\%water\_flux(i,j) = 0.0}
\DoxyCodeLine{654       fluxes\%iceshelf\_melt(i,j) = 0.0}
\DoxyCodeLine{655 \textcolor{keywordflow}{    endif} \textcolor{comment}{! area\_shelf\_h}}
\DoxyCodeLine{656 }
\DoxyCodeLine{657     \textcolor{comment}{! mass flux [R Z L2 T-\/1 ~> kg s-\/1], part of ISOMIP diags.}}
\DoxyCodeLine{658     mass\_flux(i,j) = iss\%water\_flux(i,j) * iss\%area\_shelf\_h(i,j)}
\DoxyCodeLine{659 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{! i-\/ and j-\/loops}}
\DoxyCodeLine{660 }
\DoxyCodeLine{661   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics .or. cs\%override\_shelf\_movement) \textcolor{keywordflow}{then}}
\DoxyCodeLine{662     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)}
\DoxyCodeLine{663     \textcolor{keyword}{call }pass\_var(iss\%area\_shelf\_h, g\%domain, complete=.false.)}
\DoxyCodeLine{664     \textcolor{keyword}{call }pass\_var(iss\%mass\_shelf, g\%domain)}
\DoxyCodeLine{665     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)}
\DoxyCodeLine{666 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{667 }
\DoxyCodeLine{668   \textcolor{comment}{! Melting has been computed, now is time to update thickness and mass}}
\DoxyCodeLine{669   \textcolor{keywordflow}{if} ( cs\%override\_shelf\_movement .and. (.not.cs\%mass\_from\_file)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{670     \textcolor{keyword}{call }change\_thickness\_using\_melt(iss, g, us, us\%s\_to\_T*time\_step, fluxes, cs\%density\_ice, cs\%debug)}
\DoxyCodeLine{671 }
\DoxyCodeLine{672     \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{673       \textcolor{keyword}{call }hchksum(iss\%h\_shelf, \textcolor{stringliteral}{"h\_shelf after change thickness using melt"}, g\%HI, haloshift=0, scale=us\%Z\_to\_m)}
\DoxyCodeLine{674       \textcolor{keyword}{call }hchksum(iss\%mass\_shelf, \textcolor{stringliteral}{"mass\_shelf after change thickness using melt"}, g\%HI, haloshift=0, \&}
\DoxyCodeLine{675                    scale=us\%RZ\_to\_kg\_m2)}
\DoxyCodeLine{676 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{677 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{678 }
\DoxyCodeLine{679   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"Before add shelf flux"}, fluxes, g, cs\%US, haloshift=0)}
\DoxyCodeLine{680 }
\DoxyCodeLine{681   \textcolor{keyword}{call }add\_shelf\_flux(g, us, cs, sfc\_state, fluxes)}
\DoxyCodeLine{682 }
\DoxyCodeLine{683   \textcolor{comment}{! now the thermodynamic data is passed on... time to update the ice dynamic quantities}}
\DoxyCodeLine{684 }
\DoxyCodeLine{685   \textcolor{keywordflow}{if} (cs\%active\_shelf\_dynamics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{686     update\_ice\_vel = .false.}
\DoxyCodeLine{687     coupled\_gl = (cs\%GL\_couple .and. .not.cs\%solo\_ice\_sheet)}
\DoxyCodeLine{688 }
\DoxyCodeLine{689     \textcolor{comment}{! advect the ice shelf, and advance the front. Calving will be in here somewhere as well..}}
\DoxyCodeLine{690     \textcolor{comment}{! when we decide on how to do it}}
\DoxyCodeLine{691     \textcolor{keyword}{call }update\_ice\_shelf(cs\%dCS, iss, g, us, us\%s\_to\_T*time\_step, time, \&}
\DoxyCodeLine{692                           sfc\_state\%ocean\_mass, coupled\_gl)}
\DoxyCodeLine{693 }
\DoxyCodeLine{694 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{695 }
\DoxyCodeLine{696   \textcolor{keyword}{call }enable\_averaging(time\_step,time,cs\%diag)}
\DoxyCodeLine{697   \textcolor{keywordflow}{if} (cs\%id\_shelf\_mass > 0) \textcolor{keyword}{call }post\_data(cs\%id\_shelf\_mass, iss\%mass\_shelf, cs\%diag)}
\DoxyCodeLine{698   \textcolor{keywordflow}{if} (cs\%id\_area\_shelf\_h > 0) \textcolor{keyword}{call }post\_data(cs\%id\_area\_shelf\_h, iss\%area\_shelf\_h, cs\%diag)}
\DoxyCodeLine{699   \textcolor{keywordflow}{if} (cs\%id\_ustar\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_ustar\_shelf, fluxes\%ustar\_shelf, cs\%diag)}
\DoxyCodeLine{700   \textcolor{keywordflow}{if} (cs\%id\_melt > 0) \textcolor{keyword}{call }post\_data(cs\%id\_melt, fluxes\%iceshelf\_melt, cs\%diag)}
\DoxyCodeLine{701   \textcolor{keywordflow}{if} (cs\%id\_thermal\_driving > 0) \textcolor{keyword}{call }post\_data(cs\%id\_thermal\_driving, (sfc\_state\%sst-\/iss\%tfreeze), cs\%diag)}
\DoxyCodeLine{702   \textcolor{keywordflow}{if} (cs\%id\_Sbdry > 0) \textcolor{keyword}{call }post\_data(cs\%id\_Sbdry, sbdry, cs\%diag)}
\DoxyCodeLine{703   \textcolor{keywordflow}{if} (cs\%id\_haline\_driving > 0) \textcolor{keyword}{call }post\_data(cs\%id\_haline\_driving, haline\_driving, cs\%diag)}
\DoxyCodeLine{704   \textcolor{keywordflow}{if} (cs\%id\_mass\_flux > 0) \textcolor{keyword}{call }post\_data(cs\%id\_mass\_flux, mass\_flux, cs\%diag)}
\DoxyCodeLine{705   \textcolor{keywordflow}{if} (cs\%id\_u\_ml > 0) \textcolor{keyword}{call }post\_data(cs\%id\_u\_ml, sfc\_state\%u, cs\%diag)}
\DoxyCodeLine{706   \textcolor{keywordflow}{if} (cs\%id\_v\_ml > 0) \textcolor{keyword}{call }post\_data(cs\%id\_v\_ml, sfc\_state\%v, cs\%diag)}
\DoxyCodeLine{707   \textcolor{keywordflow}{if} (cs\%id\_tfreeze > 0) \textcolor{keyword}{call }post\_data(cs\%id\_tfreeze, iss\%tfreeze, cs\%diag)}
\DoxyCodeLine{708   \textcolor{keywordflow}{if} (cs\%id\_tfl\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_tfl\_shelf, iss\%tflux\_shelf, cs\%diag)}
\DoxyCodeLine{709   \textcolor{keywordflow}{if} (cs\%id\_exch\_vel\_t > 0) \textcolor{keyword}{call }post\_data(cs\%id\_exch\_vel\_t, exch\_vel\_t, cs\%diag)}
\DoxyCodeLine{710   \textcolor{keywordflow}{if} (cs\%id\_exch\_vel\_s > 0) \textcolor{keyword}{call }post\_data(cs\%id\_exch\_vel\_s, exch\_vel\_s, cs\%diag)}
\DoxyCodeLine{711   \textcolor{keywordflow}{if} (cs\%id\_h\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_h\_shelf, iss\%h\_shelf, cs\%diag)}
\DoxyCodeLine{712   \textcolor{keywordflow}{if} (cs\%id\_h\_mask > 0) \textcolor{keyword}{call }post\_data(cs\%id\_h\_mask,iss\%hmask,cs\%diag)}
\DoxyCodeLine{713   \textcolor{keyword}{call }disable\_averaging(cs\%diag)}
\DoxyCodeLine{714 }
\DoxyCodeLine{715   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{716     \textcolor{keyword}{call }add\_shelf\_forces(g, us, cs, forces, do\_shelf\_area=(cs\%active\_shelf\_dynamics .or. \&}
\DoxyCodeLine{717                                                         cs\%override\_shelf\_movement))}
\DoxyCodeLine{718 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{719 }
\DoxyCodeLine{720   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_shelf)}
\DoxyCodeLine{721 }
\DoxyCodeLine{722   \textcolor{keywordflow}{if} (cs\%debug) \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"End of shelf calc flux"}, fluxes, g, cs\%US, haloshift=0)}
\DoxyCodeLine{723 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a0678e919d45fc9e9e9b00dce3564a2fc}\label{namespacemom__ice__shelf_a0678e919d45fc9e9e9b00dce3564a2fc}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!solo\_step\_ice\_shelf@{solo\_step\_ice\_shelf}}
\index{solo\_step\_ice\_shelf@{solo\_step\_ice\_shelf}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{solo\_step\_ice\_shelf()}{solo\_step\_ice\_shelf()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::solo\+\_\+step\+\_\+ice\+\_\+shelf (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), pointer}]{CS,  }\item[{type(time\+\_\+type), intent(in)}]{time\+\_\+interval,  }\item[{integer, intent(inout)}]{nsteps,  }\item[{type(time\+\_\+type), intent(inout)}]{Time,  }\item[{real, intent(in), optional}]{min\+\_\+time\+\_\+step\+\_\+in }\end{DoxyParamCaption})}



This routine is for stepping a stand-\/alone ice shelf model without an ocean. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & A pointer to the ice shelf control structure \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+interval} & The time interval for this update \mbox{[}s\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em nsteps} & The running number of ice shelf steps. \\
\hline
\mbox{\texttt{ in,out}}  & {\em time} & The current model time \\
\hline
\mbox{\texttt{ in}}  & {\em min\+\_\+time\+\_\+step\+\_\+in} & The minimum permitted time step \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1804   \textcolor{keywordtype}{type}(ice\_shelf\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{      !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1805   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)}    :: time\_interval\textcolor{comment}{ !< The time interval for this update [s].}}
\DoxyCodeLine{1806   \textcolor{keywordtype}{integer},         \textcolor{keywordtype}{intent(inout)} :: nsteps\textcolor{comment}{  !< The running number of ice shelf steps.}}
\DoxyCodeLine{1807   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(inout)} :: Time\textcolor{comment}{    !< The current model time}}
\DoxyCodeLine{1808 \textcolor{keywordtype}{  real},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: min\_time\_step\_in\textcolor{comment}{ !< The minimum permitted time step [T ~> s].}}
\DoxyCodeLine{1809 }
\DoxyCodeLine{1810   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: G => null()  \textcolor{comment}{! A pointer to the ocean's grid structure}}
\DoxyCodeLine{1811   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{pointer} :: US => null() \textcolor{comment}{! Pointer to a structure containing}}
\DoxyCodeLine{1812                                                  \textcolor{comment}{! various unit conversion factors}}
\DoxyCodeLine{1813   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: ISS => null() \textcolor{comment}{!< A structure with elements that describe}}
\DoxyCodeLine{1814 \textcolor{comment}{                                          !! the ice-\/shelf state}}
\DoxyCodeLine{1815 \textcolor{keywordtype}{  real} :: remaining\_time    \textcolor{comment}{! The remaining time in this call [T ~> s]}}
\DoxyCodeLine{1816 \textcolor{keywordtype}{  real} :: time\_step         \textcolor{comment}{! The internal time step during this call [T ~> s]}}
\DoxyCodeLine{1817 \textcolor{keywordtype}{  real} :: min\_time\_step     \textcolor{comment}{! The minimal required timestep that would indicate a fatal problem [T ~> s]}}
\DoxyCodeLine{1818   \textcolor{keywordtype}{character(len=240)} :: mesg}
\DoxyCodeLine{1819   \textcolor{keywordtype}{logical} :: update\_ice\_vel \textcolor{comment}{! If true, it is time to update the ice shelf velocities.}}
\DoxyCodeLine{1820   \textcolor{keywordtype}{logical} :: coupled\_GL     \textcolor{comment}{! If true the grouding line position is determined based on}}
\DoxyCodeLine{1821                             \textcolor{comment}{! coupled ice-\/ocean dynamics.}}
\DoxyCodeLine{1822   \textcolor{keywordtype}{integer} :: is, iec, js, jec, i, j}
\DoxyCodeLine{1823 }
\DoxyCodeLine{1824   g => cs\%grid}
\DoxyCodeLine{1825   us => cs\%US}
\DoxyCodeLine{1826   iss => cs\%ISS}
\DoxyCodeLine{1827   is = g\%isc ; iec = g\%iec ; js = g\%jsc ; jec = g\%jec}
\DoxyCodeLine{1828 }
\DoxyCodeLine{1829   remaining\_time = us\%s\_to\_T*time\_type\_to\_real(time\_interval)}
\DoxyCodeLine{1830 }
\DoxyCodeLine{1831   \textcolor{keywordflow}{if} (\textcolor{keyword}{present} (min\_time\_step\_in)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1832     min\_time\_step = min\_time\_step\_in}
\DoxyCodeLine{1833   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1834     min\_time\_step = 1000.0*us\%s\_to\_T \textcolor{comment}{! At 1 km resolution this would imply ice is moving at ~1 meter per second}}
\DoxyCodeLine{1835 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1836 }
\DoxyCodeLine{1837   \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"TIME in ice shelf call, yrs: "}, time\_type\_to\_real(time)/(365. * 86400.)}
\DoxyCodeLine{1838   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"solo\_step\_ice\_shelf: "}//mesg, 5)}
\DoxyCodeLine{1839 }
\DoxyCodeLine{1840   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (remaining\_time > 0.0)}
\DoxyCodeLine{1841     nsteps = nsteps+1}
\DoxyCodeLine{1842 }
\DoxyCodeLine{1843     \textcolor{comment}{! If time\_interval is not too long, this is unnecessary.}}
\DoxyCodeLine{1844     time\_step = min(ice\_time\_step\_cfl(cs\%dCS, iss, g), remaining\_time)}
\DoxyCodeLine{1845 }
\DoxyCodeLine{1846     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"Ice model timestep = "}, us\%T\_to\_s*time\_step, \textcolor{stringliteral}{" seconds"}}
\DoxyCodeLine{1847     \textcolor{keywordflow}{if} ((time\_step < min\_time\_step) .and. (time\_step < remaining\_time))  \textcolor{keywordflow}{then}}
\DoxyCodeLine{1848       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf:solo\_step\_ice\_shelf: abnormally small timestep "}//mesg)}
\DoxyCodeLine{1849     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1850       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"solo\_step\_ice\_shelf: "}//mesg, 5)}
\DoxyCodeLine{1851 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1852 }
\DoxyCodeLine{1853     remaining\_time = remaining\_time -\/ time\_step}
\DoxyCodeLine{1854 }
\DoxyCodeLine{1855     \textcolor{comment}{! If the last mini-\/timestep is a day or less, we cannot expect velocities to change by much.}}
\DoxyCodeLine{1856     \textcolor{comment}{! Do not update the velocities if the last step is very short.}}
\DoxyCodeLine{1857     update\_ice\_vel = ((time\_step > min\_time\_step) .or. (remaining\_time > 0.0))}
\DoxyCodeLine{1858     coupled\_gl = .false.}
\DoxyCodeLine{1859 }
\DoxyCodeLine{1860     \textcolor{keyword}{call }update\_ice\_shelf(cs\%dCS, iss, g, us, time\_step, time, must\_update\_vel=update\_ice\_vel)}
\DoxyCodeLine{1861 }
\DoxyCodeLine{1862     \textcolor{keyword}{call }enable\_averages(time\_step, time, cs\%diag)}
\DoxyCodeLine{1863     \textcolor{keywordflow}{if} (cs\%id\_area\_shelf\_h > 0) \textcolor{keyword}{call }post\_data(cs\%id\_area\_shelf\_h, iss\%area\_shelf\_h, cs\%diag)}
\DoxyCodeLine{1864     \textcolor{keywordflow}{if} (cs\%id\_h\_shelf > 0) \textcolor{keyword}{call }post\_data(cs\%id\_h\_shelf, iss\%h\_shelf, cs\%diag)}
\DoxyCodeLine{1865     \textcolor{keywordflow}{if} (cs\%id\_h\_mask > 0) \textcolor{keyword}{call }post\_data(cs\%id\_h\_mask, iss\%hmask, cs\%diag)}
\DoxyCodeLine{1866     \textcolor{keyword}{call }disable\_averaging(cs\%diag)}
\DoxyCodeLine{1867 }
\DoxyCodeLine{1868 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1869 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a6f0fa9f98ac01752ca2983c7e9816097}\label{namespacemom__ice__shelf_a6f0fa9f98ac01752ca2983c7e9816097}} 
\index{mom\_ice\_shelf@{mom\_ice\_shelf}!update\_shelf\_mass@{update\_shelf\_mass}}
\index{update\_shelf\_mass@{update\_shelf\_mass}!mom\_ice\_shelf@{mom\_ice\_shelf}}
\doxysubsubsection{\texorpdfstring{update\_shelf\_mass()}{update\_shelf\_mass()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ice\+\_\+shelf\+::update\+\_\+shelf\+\_\+mass (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__ice__shelf_1_1ice__shelf__cs}{ice\+\_\+shelf\+\_\+cs}}), intent(in)}]{CS,  }\item[{type(ice\+\_\+shelf\+\_\+state), intent(inout)}]{I\+SS,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Updates the ice shelf mass using data from a file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em cs} & A pointer to the ice shelf control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em iss} & The ice shelf state type that is being updated \\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1724   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< The ocean's grid structure.}}
\DoxyCodeLine{1725   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1726   \textcolor{keywordtype}{type}(ice\_shelf\_CS),    \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{  !< A pointer to the ice shelf control structure}}
\DoxyCodeLine{1727   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(inout)} :: ISS\textcolor{comment}{ !< The ice shelf state type that is being updated}}
\DoxyCodeLine{1728   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{1729 }
\DoxyCodeLine{1730   \textcolor{comment}{! local variables}}
\DoxyCodeLine{1731   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1732   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1733 }
\DoxyCodeLine{1734   \textcolor{keyword}{call }time\_interp\_external(cs\%id\_read\_mass, time, iss\%mass\_shelf)}
\DoxyCodeLine{1735   \textcolor{comment}{! This should only be done if time\_interp\_external did an update.}}
\DoxyCodeLine{1736   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1737     iss\%mass\_shelf(i,j) = us\%kg\_m3\_to\_R*us\%m\_to\_Z * iss\%mass\_shelf(i,j) \textcolor{comment}{! Rescale after time\_interp}}
\DoxyCodeLine{1738 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1739 }
\DoxyCodeLine{1740   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1741     iss\%area\_shelf\_h(i,j) = 0.0}
\DoxyCodeLine{1742     iss\%hmask(i,j) = 0.}
\DoxyCodeLine{1743     \textcolor{keywordflow}{if} (iss\%mass\_shelf(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1744       iss\%area\_shelf\_h(i,j) = g\%areaT(i,j)}
\DoxyCodeLine{1745       iss\%h\_shelf(i,j) = iss\%mass\_shelf(i,j) / cs\%density\_ice}
\DoxyCodeLine{1746       iss\%hmask(i,j) = 1.}
\DoxyCodeLine{1747 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1748 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1749 }
\DoxyCodeLine{1750   \textcolor{comment}{!call USER\_update\_shelf\_mass(ISS\%mass\_shelf, ISS\%area\_shelf\_h, ISS\%h\_shelf, \&}}
\DoxyCodeLine{1751   \textcolor{comment}{!                            ISS\%hmask, CS\%grid, CS\%user\_CS, Time, .true.)}}
\DoxyCodeLine{1752 }
\DoxyCodeLine{1753   \textcolor{keywordflow}{if} (cs\%min\_thickness\_simple\_calve > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1754     \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, iss\%h\_shelf, iss\%area\_shelf\_h, iss\%hmask, \&}
\DoxyCodeLine{1755                                        cs\%min\_thickness\_simple\_calve, halo=0)}
\DoxyCodeLine{1756 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1757 }
\DoxyCodeLine{1758   \textcolor{keyword}{call }pass\_var(iss\%area\_shelf\_h, g\%domain)}
\DoxyCodeLine{1759   \textcolor{keyword}{call }pass\_var(iss\%h\_shelf, g\%domain)}
\DoxyCodeLine{1760   \textcolor{keyword}{call }pass\_var(iss\%hmask, g\%domain)}
\DoxyCodeLine{1761   \textcolor{keyword}{call }pass\_var(iss\%mass\_shelf, g\%domain)}
\DoxyCodeLine{1762 }

\end{DoxyCode}
