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


\subsection{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}{}\subsection{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}{}\subsubsection{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}{}\subsubsection{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. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \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}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \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 \hyperlink{namespacemom__ice__shelf_section_ICE_SHELF_equations}{I\+C\+E\+\_\+\+S\+H\+E\+LF equations}. \end{DoxyCompactList}\item 
subroutine \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 \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 \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 \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 \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 \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 \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 \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 \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 \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}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}\label{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}} 
integer \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 \hyperlink{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}{id\+\_\+clock\+\_\+pass}
\begin{DoxyCompactList}\small\item\em C\+PU Clock for group pass calls. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{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}}
\subsubsection{\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(\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{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
 & {\em cs} & This module\textquotesingle{}s control structure.\\
\hline
\mbox{\tt in,out}  & {\em sfc\+\_\+state} & Surface ocean state\\
\hline
\mbox{\tt 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}
885   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
886   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
887   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< This module's control structure.}
888   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< Surface ocean state}
889   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{  !< A structure of surface fluxes that may be
       used/updated.}
890 
891   \textcolor{comment}{! local variables}
892   \textcolor{keywordtype}{real} :: frac\_shelf\textcolor{comment}{       !< The fractional area covered by the ice shelf [nondim].}
893   \textcolor{keywordtype}{real} :: frac\_open\textcolor{comment}{        !< The fractional area of the ocean that is not covered by the ice shelf
       [nondim].}
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]}
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]}
896   \textcolor{keywordtype}{real} :: balancing\_area\textcolor{comment}{   !< total area where the balancing flux is applied [m2]}
897   \textcolor{keywordtype}{type}(time\_type) :: dtime\textcolor{comment}{ !< The time step as a time\_type}
898   \textcolor{keywordtype}{type}(time\_type) :: time0\textcolor{comment}{ !< The previous time (Time-dt)}
899   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: bal\_frac\textcolor{comment}{  !< Fraction of the cel1 where the mass flux}
900 \textcolor{comment}{                          !! balancing the net melt flux occurs, 0 to 1 [nondim]}
901   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: last\_mass\_shelf\textcolor{comment}{ !< Ice shelf mass}
902 \textcolor{comment}{                          !! at at previous time (Time-dt) [R Z ~> kg m-2]}
903   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: delta\_float\_mass\textcolor{comment}{   !< The change in the floating mass between}
904 \textcolor{comment}{                          !! the two timesteps at (Time) and (Time-dt) [R Z ~> kg m-2].}
905   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_h\_shelf\textcolor{comment}{ !< Ice shelf thickness [Z ~> m]}
906 \textcolor{comment}{                          !! at at previous time (Time-dt)}
907   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_hmask\textcolor{comment}{ !< Ice shelf mask [nondim]}
908 \textcolor{comment}{                          !! at at previous time (Time-dt)}
909   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_area\_shelf\_h\textcolor{comment}{ !< Ice shelf area [L2 ~> m2]}
910 \textcolor{comment}{                          !! at at previous time (Time-dt)}
911   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: iss => null() \textcolor{comment}{!< A structure with elements that describe}
912 \textcolor{comment}{                                          !! the ice-shelf state}
913 
914   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}
915   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
916   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
917   isd = g%isd ; jsd = g%jsd ; ied = g%ied ; jed = g%jed
918 
919   \textcolor{keywordflow}{if} ((cs%grid%isc /= g%isc) .or. (cs%grid%iec /= g%iec) .or. &
920       (cs%grid%jsc /= g%jsc) .or. (cs%grid%jec /= g%jec)) &
921     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_flux: Incompatible ocean and ice shelf grids."})
922 
923   iss => cs%ISS
924 
925 
926   \textcolor{keyword}{call }add\_shelf\_pressure(g, us, cs, fluxes)
927 
928   \textcolor{comment}{! Determine ustar and the square magnitude of the velocity in the}
929   \textcolor{comment}{! bottom boundary layer. Together these give the TKE source and}
930   \textcolor{comment}{! vertical decay scale.}
931 
932   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
933     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%taux\_shelf) .and. \textcolor{keyword}{allocated}(sfc\_state%tauy\_shelf)) \textcolor{keywordflow}{then}
934       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"tau[xy]\_shelf"}, sfc\_state%taux\_shelf, sfc\_state%tauy\_shelf, &
935                     g%HI, haloshift=0, scale=us%RZ\_T\_to\_kg\_m2s*us%L\_T\_to\_m\_s)
936 \textcolor{keywordflow}{    endif}
937 \textcolor{keywordflow}{  endif}
938 
939   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics .or. cs%override\_shelf\_movement) \textcolor{keywordflow}{then}
940     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
941       \textcolor{keywordflow}{if} (g%areaT(i,j) > 0.0) &
942         fluxes%frac\_shelf\_h(i,j) = min(1.0, iss%area\_shelf\_h(i,j) * g%IareaT(i,j))
943 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
944 \textcolor{keywordflow}{  endif}
945 
946   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
947     \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"Before adding shelf fluxes"}, fluxes, g, cs%US, haloshift=0)
948 \textcolor{keywordflow}{  endif}
949 
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}
951     \textcolor{comment}{! Replace fluxes intercepted by the ice shelf with fluxes from the ice shelf}
952     frac\_shelf = min(1.0, iss%area\_shelf\_h(i,j) * g%IareaT(i,j))
953     frac\_open = max(0.0, 1.0 - frac\_shelf)
954 
955     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw)) fluxes%sw(i,j) = frac\_open * fluxes%sw(i,j)
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)
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)
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)
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)
960     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lw)) fluxes%lw(i,j) = frac\_open * fluxes%lw(i,j)
961     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent)) fluxes%latent(i,j) = frac\_open * fluxes%latent(i,j)
962     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap)) fluxes%evap(i,j) = frac\_open * fluxes%evap(i,j)
963     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) \textcolor{keywordflow}{then}
964       \textcolor{keywordflow}{if} (iss%water\_flux(i,j) > 0.0) \textcolor{keywordflow}{then}
965         fluxes%lprec(i,j) =  frac\_shelf*iss%water\_flux(i,j)*cs%flux\_factor + frac\_open * fluxes%lprec(i,j)
966       \textcolor{keywordflow}{else}
967         fluxes%lprec(i,j) = frac\_open * fluxes%lprec(i,j)
968         fluxes%evap(i,j) = fluxes%evap(i,j) + frac\_shelf*iss%water\_flux(i,j)*cs%flux\_factor
969 \textcolor{keywordflow}{      endif}
970 \textcolor{keywordflow}{    endif}
971 
972     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens)) &
973       fluxes%sens(i,j) = frac\_shelf*iss%tflux\_ocn(i,j)*cs%flux\_factor + frac\_open * fluxes%sens(i,j)
974     \textcolor{comment}{! The salt flux should be mostly from sea ice, so perhaps none should be intercepted and this should be
       changed.}
975     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux)) &
976       fluxes%salt\_flux(i,j) = frac\_shelf * iss%salt\_flux(i,j)*cs%flux\_factor + frac\_open * fluxes%salt\_flux
      (i,j)
977 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
978 
979   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
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)
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)
982     \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"After adding shelf fluxes"}, fluxes, g, cs%US, haloshift=0)
983 \textcolor{keywordflow}{  endif}
984 
985   \textcolor{comment}{! Keep sea level constant by removing mass via a balancing flux that might be applied}
986   \textcolor{comment}{! in the open ocean or the sponge region (via virtual precip, vprec). Apply additional}
987   \textcolor{comment}{! salt/heat fluxes so that the resultant surface buoyancy forcing is ~ 0.}
988   \textcolor{comment}{! This is needed for some of the ISOMIP+ experiments.}
989 
990   \textcolor{keywordflow}{if} (cs%constant\_sea\_level) \textcolor{keywordflow}{then}
991     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(fluxes%salt\_flux)) \textcolor{keyword}{allocate}(fluxes%salt\_flux(ie,je))
992     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(fluxes%vprec)) \textcolor{keyword}{allocate}(fluxes%vprec(ie,je))
993     fluxes%salt\_flux(:,:) = 0.0 ; fluxes%vprec(:,:) = 0.0
994 
995     \textcolor{comment}{! take into account changes in mass (or thickness) when imposing ice shelf mass}
996     \textcolor{keywordflow}{if} (cs%override\_shelf\_movement .and. cs%mass\_from\_file) \textcolor{keywordflow}{then}
997       dtime = real\_to\_time(cs%time\_step)
998 
999       \textcolor{comment}{! Compute changes in mass after at least one full time step}
1000       \textcolor{keywordflow}{if} (cs%Time > dtime) \textcolor{keywordflow}{then}
1001         time0 = cs%Time - dtime
1002         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1003           last\_hmask(i,j) = iss%hmask(i,j) ; last\_area\_shelf\_h(i,j) = iss%area\_shelf\_h(i,j)
1004 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
1005         \textcolor{keyword}{call }time\_interp\_external(cs%id\_read\_mass, time0, last\_mass\_shelf)
1006         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1007         \textcolor{comment}{! This should only be done if time\_interp\_external did an update.}
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}
1009           last\_h\_shelf(i,j) = last\_mass\_shelf(i,j) / cs%density\_ice
1010 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
1011 
1012         \textcolor{comment}{! apply calving}
1013         \textcolor{keywordflow}{if} (cs%min\_thickness\_simple\_calve > 0.0) \textcolor{keywordflow}{then}
1014           \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, last\_h\_shelf, last\_area\_shelf\_h, last\_hmask, &
1015                                        cs%min\_thickness\_simple\_calve, halo=0)
1016           \textcolor{comment}{! convert to mass again}
1017           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1018             last\_mass\_shelf(i,j) = last\_h\_shelf(i,j) * cs%density\_ice
1019 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
1020 \textcolor{keywordflow}{        endif}
1021 
1022         \textcolor{comment}{! get total ice shelf mass at (Time-dt) and (Time), in kg}
1023         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1024           \textcolor{comment}{! Just consider the change in the mass of the floating shelf.}
1025           \textcolor{keywordflow}{if} ((sfc\_state%ocean\_mass(i,j) > cs%min\_ocean\_mass\_float) .and. &
1026               (iss%area\_shelf\_h(i,j) > 0.0)) \textcolor{keywordflow}{then}
1027             delta\_float\_mass(i,j) = iss%mass\_shelf(i,j) - last\_mass\_shelf(i,j)
1028           \textcolor{keywordflow}{else}
1029             delta\_float\_mass(i,j) = 0.0
1030 \textcolor{keywordflow}{          endif}
1031 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
1032         delta\_mass\_shelf = us%kg\_m2s\_to\_RZ\_T*(global\_area\_integral(delta\_float\_mass, g, scale=us
      %RZ\_to\_kg\_m2, &
1033                                                                    area=iss%area\_shelf\_h) / cs%time\_step)
1034       else\textcolor{comment}{! first time step}
1035         delta\_mass\_shelf = 0.0
1036 \textcolor{keywordflow}{      endif}
1037     \textcolor{keywordflow}{else} \textcolor{comment}{! ice shelf mass does not change}
1038       delta\_mass\_shelf = 0.0
1039 \textcolor{keywordflow}{    endif}
1040 
1041     \textcolor{comment}{! average total melt flux over sponge area}
1042     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
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}
1044          \textcolor{comment}{! Uncomment this for some ISOMIP cases:}
1045          \textcolor{comment}{!  .AND. (G%geoLonT(i,j) >= 790.0) .AND. (G%geoLonT(i,j) <= 800.0)) then}
1046         bal\_frac(i,j) = max(1.0 - iss%area\_shelf\_h(i,j) * g%IareaT(i,j), 0.0)
1047       \textcolor{keywordflow}{else}
1048         bal\_frac(i,j) = 0.0
1049 \textcolor{keywordflow}{      endif}
1050 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1051 
1052     balancing\_area = global\_area\_integral(bal\_frac, g)
1053     \textcolor{keywordflow}{if} (balancing\_area > 0.0) \textcolor{keywordflow}{then}
1054       balancing\_flux = ( us%kg\_m2s\_to\_RZ\_T*global\_area\_integral(iss%water\_flux, g, scale=us%RZ\_T\_to\_kg\_m2s,
       &
1055                                                                 area=iss%area\_shelf\_h) + &
1056                          delta\_mass\_shelf ) / balancing\_area
1057     \textcolor{keywordflow}{else}
1058       balancing\_flux = 0.0
1059 \textcolor{keywordflow}{    endif}
1060 
1061     \textcolor{comment}{! apply fluxes}
1062     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1063       \textcolor{keywordflow}{if} (bal\_frac(i,j) > 0.0) \textcolor{keywordflow}{then}
1064         \textcolor{comment}{! evap is negative, and vprec has units of [R Z T-1 ~> kg m-2 s-1]}
1065         fluxes%vprec(i,j) = -balancing\_flux
1066         fluxes%sens(i,j) = fluxes%vprec(i,j) * cs%Cp * cs%T0 \textcolor{comment}{! [ Q R Z T-1 ~> W /m^2 ]}
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]}
1068 \textcolor{keywordflow}{      endif}
1069 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1070 
1071     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
1072       \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'Balancing flux (kg/(m^2 s)), dt = '}, balancing\_flux*us%RZ\_T\_to\_kg\_m2s, cs%time\_step
1073       \textcolor{keyword}{call }mom\_mesg(mesg)
1074       \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"After constant sea level"}, fluxes, g, cs%US, haloshift=0)
1075 \textcolor{keywordflow}{    endif}
1076 
1077 \textcolor{keywordflow}{  endif} \textcolor{comment}{! constant\_sea\_level}
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}}
\subsubsection{\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(\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{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
 & {\em cs} & This module\textquotesingle{}s control structure.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt 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}
776   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
777   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
778   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< This module's control structure.}
779   \textcolor{keywordtype}{type}(mech\_forcing),    \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
780   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)}    :: do\_shelf\_area\textcolor{comment}{ !< If true find the shelf-covered areas.}
781 
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].}
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].}
784   \textcolor{keywordtype}{logical} :: find\_area \textcolor{comment}{! If true find the shelf areas at u & v points.}
785   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: iss => null() \textcolor{comment}{! A structure with elements that describe}
786                                           \textcolor{comment}{! the ice-shelf state}
787 
788   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
789   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
790   isd = g%isd ; jsd = g%jsd ; ied = g%ied ; jed = g%jed
791 
792   \textcolor{keywordflow}{if} ((cs%grid%isc /= g%isc) .or. (cs%grid%iec /= g%iec) .or. &
793       (cs%grid%jsc /= g%jsc) .or. (cs%grid%jec /= g%jec)) &
794     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_forces: Incompatible ocean and ice shelf grids."})
795 
796   iss => cs%ISS
797 
798   find\_area = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(do\_shelf\_area)) find\_area = do\_shelf\_area
799 
800   \textcolor{keywordflow}{if} (find\_area) \textcolor{keywordflow}{then}
801     \textcolor{comment}{! The frac\_shelf is set over the widest possible area. Could it be smaller?}
802     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied-1
803       forces%frac\_shelf\_u(i,j) = 0.0
804       \textcolor{keywordflow}{if} ((g%areaT(i,j) + g%areaT(i+1,j) > 0.0)) & \textcolor{comment}{! .and. (G%areaCu(I,j) > 0.0)) &}
805         forces%frac\_shelf\_u(i,j) = (iss%area\_shelf\_h(i,j) + iss%area\_shelf\_h(i+1,j)) / &
806                                    (g%areaT(i,j) + g%areaT(i+1,j))
807 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
808     \textcolor{keywordflow}{do} j=jsd,jed-1 ; \textcolor{keywordflow}{do} i=isd,ied
809       forces%frac\_shelf\_v(i,j) = 0.0
810       \textcolor{keywordflow}{if} ((g%areaT(i,j) + g%areaT(i,j+1) > 0.0)) & \textcolor{comment}{! .and. (G%areaCv(i,J) > 0.0)) &}
811         forces%frac\_shelf\_v(i,j) = (iss%area\_shelf\_h(i,j) + iss%area\_shelf\_h(i,j+1)) / &
812                                    (g%areaT(i,j) + g%areaT(i,j+1))
813 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
814     \textcolor{keyword}{call }pass\_vector(forces%frac\_shelf\_u, forces%frac\_shelf\_v, g%domain, to\_all, cgrid\_ne)
815 \textcolor{keywordflow}{  endif}
816 
817   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
818     press\_ice = (iss%area\_shelf\_h(i,j) * g%IareaT(i,j)) * (cs%g\_Earth * iss%mass\_shelf(i,j))
819     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf)) \textcolor{keywordflow}{then}
820       \textcolor{keywordflow}{if} (.not.forces%accumulate\_p\_surf) forces%p\_surf(i,j) = 0.0
821       forces%p\_surf(i,j) = forces%p\_surf(i,j) + press\_ice
822 \textcolor{keywordflow}{    endif}
823     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf\_full)) \textcolor{keywordflow}{then}
824       \textcolor{keywordflow}{if} (.not.forces%accumulate\_p\_surf) forces%p\_surf\_full(i,j) = 0.0
825       forces%p\_surf\_full(i,j) = forces%p\_surf\_full(i,j) + press\_ice
826 \textcolor{keywordflow}{    endif}
827 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
828 
829   \textcolor{comment}{! For various reasons, forces%rigidity\_ice\_[uv] is always updated here. Note}
830   \textcolor{comment}{! that it may have been zeroed out where IOB is translated to forces and}
831   \textcolor{comment}{! contributions from icebergs and the sea-ice pack added subsequently.}
832   \textcolor{comment}{!### THE RIGIDITY SHOULD ALSO INCORPORATE AREAL-COVERAGE INFORMATION.}
833   kv\_rho\_ice = cs%kv\_ice / cs%density\_ice
834   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ie
835     \textcolor{keywordflow}{if} (.not.forces%accumulate\_rigidity) forces%rigidity\_ice\_u(i,j) = 0.0
836     forces%rigidity\_ice\_u(i,j) = forces%rigidity\_ice\_u(i,j) + &
837             kv\_rho\_ice * min(iss%mass\_shelf(i,j), iss%mass\_shelf(i+1,j))
838 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
839   \textcolor{keywordflow}{do} j=js-1,je ; \textcolor{keywordflow}{do} i=is,ie
840     \textcolor{keywordflow}{if} (.not.forces%accumulate\_rigidity) forces%rigidity\_ice\_v(i,j) = 0.0
841     forces%rigidity\_ice\_v(i,j) = forces%rigidity\_ice\_v(i,j) + &
842             kv\_rho\_ice * min(iss%mass\_shelf(i,j), iss%mass\_shelf(i,j+1))
843 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
844 
845   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
846     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"rigidity\_ice\_[uv]"}, forces%rigidity\_ice\_u, forces%rigidity\_ice\_v, &
847                   g%HI, symmetric=.true., scale=us%L\_to\_m**3*us%L\_to\_Z*us%s\_to\_T)
848     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"frac\_shelf\_[uv]"}, forces%frac\_shelf\_u, forces%frac\_shelf\_v, &
849                   g%HI, symmetric=.true.)
850 \textcolor{keywordflow}{  endif}
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}}
\subsubsection{\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(\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{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em cs} & This module\textquotesingle{}s control structure.\\
\hline
\mbox{\tt 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}
856   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
857   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
858   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{   !< This module's control structure.}
859   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{  !< A structure of surface fluxes that may be updated.}
860 
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].}
862   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
863   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
864 
865   \textcolor{keywordflow}{if} ((cs%grid%isc /= g%isc) .or. (cs%grid%iec /= g%iec) .or. &
866       (cs%grid%jsc /= g%jsc) .or. (cs%grid%jec /= g%jec)) &
867     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_pressure: Incompatible ocean and ice shelf grids."})
868 
869   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
870     press\_ice = (cs%ISS%area\_shelf\_h(i,j) * g%IareaT(i,j)) * (cs%g\_Earth * cs%ISS%mass\_shelf(i,j))
871     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf)) \textcolor{keywordflow}{then}
872       \textcolor{keywordflow}{if} (.not.fluxes%accumulate\_p\_surf) fluxes%p\_surf(i,j) = 0.0
873       fluxes%p\_surf(i,j) = fluxes%p\_surf(i,j) + press\_ice
874 \textcolor{keywordflow}{    endif}
875     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf\_full)) \textcolor{keywordflow}{then}
876       \textcolor{keywordflow}{if} (.not.fluxes%accumulate\_p\_surf) fluxes%p\_surf\_full(i,j) = 0.0
877       fluxes%p\_surf\_full(i,j) = fluxes%p\_surf\_full(i,j) + press\_ice
878 \textcolor{keywordflow}{    endif}
879 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
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}}
\subsubsection{\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{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in,out}  & {\em iss} & A structure with elements that describe the ice-\/shelf state\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em time\+\_\+step} & The time step for this update \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & structure containing pointers to any possible thermodynamic or mass-\/flux forcing fields.\\
\hline
\mbox{\tt in}  & {\em density\+\_\+ice} & The density of ice-\/shelf ice \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}.\\
\hline
\mbox{\tt 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}
728   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The ocean's grid structure.}
729   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< A structure with elements that describe}
730 \textcolor{comment}{                                              !! the ice-shelf state}
731   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
732   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}
733   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< structure containing pointers to any possible}
734 \textcolor{comment}{                                                 !! thermodynamic or mass-flux forcing fields.}
735   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: density\_ice\textcolor{comment}{ !< The density of ice-shelf ice [R ~> kg m-3].}
736   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{ !< If present and true, write chksums}
737 
738   \textcolor{comment}{! locals}
739   \textcolor{keywordtype}{real} :: i\_rho\_ice \textcolor{comment}{! Ice specific volume [R-1 ~> m3 kg-1]}
740   \textcolor{keywordtype}{integer} :: i, j
741 
742   i\_rho\_ice = 1.0 / density\_ice
743 
744 
745   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
746     \textcolor{keywordflow}{if} ((iss%hmask(i,j) == 1) .or. (iss%hmask(i,j) == 2)) \textcolor{keywordflow}{then}
747       \textcolor{comment}{! first, zero out fluxes applied during previous time step}
748       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) fluxes%lprec(i,j) = 0.0
749       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens)) fluxes%sens(i,j) = 0.0
750       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frac\_shelf\_h)) fluxes%frac\_shelf\_h(i,j) = 0.0
751       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux)) fluxes%salt\_flux(i,j) = 0.0
752 
753       \textcolor{keywordflow}{if} (iss%water\_flux(i,j) * time\_step / density\_ice < iss%h\_shelf(i,j)) \textcolor{keywordflow}{then}
754         iss%h\_shelf(i,j) = iss%h\_shelf(i,j) - iss%water\_flux(i,j) * time\_step / density\_ice
755       \textcolor{keywordflow}{else}
756         \textcolor{comment}{! the ice is about to melt away, so set thickness, area, and mask to zero}
757         \textcolor{comment}{! NOTE: this is not mass conservative should maybe scale salt & heat flux for this cell}
758         iss%h\_shelf(i,j) = 0.0
759         iss%hmask(i,j) = 0.0
760         iss%area\_shelf\_h(i,j) = 0.0
761 \textcolor{keywordflow}{      endif}
762       iss%mass\_shelf(i,j) = iss%h\_shelf(i,j) * density\_ice
763 \textcolor{keywordflow}{    endif}
764 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
765 
766   \textcolor{keyword}{call }pass\_var(iss%area\_shelf\_h, g%domain)
767   \textcolor{keyword}{call }pass\_var(iss%h\_shelf, g%domain)
768   \textcolor{keyword}{call }pass\_var(iss%hmask, g%domain)
769   \textcolor{keyword}{call }pass\_var(iss%mass\_shelf, g%domain)
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}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+end()}{ice\_shelf\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::ice\+\_\+shelf\+\_\+end (\begin{DoxyParamCaption}\item[{type(\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}
1790   \textcolor{keywordtype}{type}(ice\_shelf\_cs), \textcolor{keywordtype}{pointer}   :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
1791 
1792   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
1793 
1794   \textcolor{keyword}{call }ice\_shelf\_state\_end(cs%ISS)
1795 
1796   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keyword}{call }ice\_shelf\_dyn\_end(cs%dCS)
1797 
1798   \textcolor{keyword}{deallocate}(cs)
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}}
\subsubsection{\texorpdfstring{ice\+\_\+shelf\+\_\+save\+\_\+restart()}{ice\_shelf\_save\_restart()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ice\+\_\+shelf\+::ice\+\_\+shelf\+\_\+save\+\_\+restart (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em time} & model time at this call\\
\hline
\mbox{\tt in}  & {\em directory} & An optional directory into which to write these restart files.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+stamped} & f true, the restart file names include a unique time stamp. The default is false.\\
\hline
\mbox{\tt 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}
1767   \textcolor{keywordtype}{type}(ice\_shelf\_cs),         \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{ !< ice shelf control structure}
1768   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)} :: time\textcolor{comment}{ !< model time at this call}
1769   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: directory\textcolor{comment}{ !< An optional directory into which to write}
1770 \textcolor{comment}{                                               !! these restart files.}
1771   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: time\_stamped\textcolor{comment}{ !< f true, the restart file names include}
1772 \textcolor{comment}{                                               !! a unique time stamp.  The default is false.}
1773   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: filename\_suffix\textcolor{comment}{ !< An optional suffix (e.g., a}
1774 \textcolor{comment}{                                               !! time-stamp) to append to the restart file names.}
1775   \textcolor{comment}{! local variables}
1776   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: g => null()
1777   \textcolor{keywordtype}{character(len=200)} :: restart\_dir
1778 
1779   g => cs%grid
1780 
1781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(directory)) \textcolor{keywordflow}{then} ; restart\_dir = directory
1782   \textcolor{keywordflow}{else} ; restart\_dir = cs%restart\_output\_dir ;\textcolor{keywordflow}{ endif}
1783 
1784   \textcolor{keyword}{call }save\_restart(restart\_dir, time, cs%grid, cs%restart\_CSp, time\_stamped)
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}}
\subsubsection{\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(\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{\tt 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{\tt 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{\tt in}  & {\em diag} & A structure that is used to regulate the diagnostic output.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing pointers to any possible thermodynamic or mass-\/flux forcing fields.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em time\+\_\+in} & The time at initialization.\\
\hline
\mbox{\tt in}  & {\em solo\+\_\+ice\+\_\+sheet\+\_\+in} & If present, this indicates whether a solo ice-\/sheet driver. \\
\hline
\end{DoxyParams}


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


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


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


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


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