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


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.  


\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 
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 
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{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{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 \hyperlink{MOM__ice__shelf_8F90_source_l00885}{885} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



References \hyperlink{namespacemom__ice__shelf_aca1d1c1db015f270ce1b1f93d16dea91}{add\+\_\+shelf\+\_\+pressure()}.



Referenced by \hyperlink{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}{shelf\+\_\+calc\+\_\+flux()}.


\begin{DoxyCode}
00885   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
00886   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
00887   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< This module's control structure.}
00888   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< Surface ocean state}
00889   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{  !< A structure of surface fluxes that may be
       used/updated.}
00890 
00891   \textcolor{comment}{! local variables}
00892   \textcolor{keywordtype}{real} :: frac\_shelf\textcolor{comment}{       !< The fractional area covered by the ice shelf [nondim].}
00893   \textcolor{keywordtype}{real} :: frac\_open\textcolor{comment}{        !< The fractional area of the ocean that is not covered by the ice shelf
       [nondim].}
00894   \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]}
00895   \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]}
00896   \textcolor{keywordtype}{real} :: balancing\_area\textcolor{comment}{   !< total area where the balancing flux is applied [m2]}
00897   \textcolor{keywordtype}{type}(time\_type) :: dtime\textcolor{comment}{ !< The time step as a time\_type}
00898   \textcolor{keywordtype}{type}(time\_type) :: time0\textcolor{comment}{ !< The previous time (Time-dt)}
00899   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: bal\_frac\textcolor{comment}{  !< Fraction of the cel1 where the mass flux}
00900 \textcolor{comment}{                          !! balancing the net melt flux occurs, 0 to 1 [nondim]}
00901   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: last\_mass\_shelf\textcolor{comment}{ !< Ice shelf mass}
00902 \textcolor{comment}{                          !! at at previous time (Time-dt) [R Z ~> kg m-2]}
00903   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))} :: delta\_float\_mass\textcolor{comment}{   !< The change in the floating mass between}
00904 \textcolor{comment}{                          !! the two timesteps at (Time) and (Time-dt) [R Z ~> kg m-2].}
00905   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_h\_shelf\textcolor{comment}{ !< Ice shelf thickness [Z ~> m]}
00906 \textcolor{comment}{                          !! at at previous time (Time-dt)}
00907   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_hmask\textcolor{comment}{ !< Ice shelf mask [nondim]}
00908 \textcolor{comment}{                          !! at at previous time (Time-dt)}
00909   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(G),SZDJ\_(G))}  :: last\_area\_shelf\_h\textcolor{comment}{ !< Ice shelf area [L2 ~> m2]}
00910 \textcolor{comment}{                          !! at at previous time (Time-dt)}
00911   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: iss => null() \textcolor{comment}{!< A structure with elements that describe}
00912 \textcolor{comment}{                                          !! the ice-shelf state}
00913 
00914   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}
00915   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
00916   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
00917   isd = g%isd ; jsd = g%jsd ; ied = g%ied ; jed = g%jed
00918 
00919   \textcolor{keywordflow}{if} ((cs%grid%isc /= g%isc) .or. (cs%grid%iec /= g%iec) .or. &
00920       (cs%grid%jsc /= g%jsc) .or. (cs%grid%jec /= g%jec)) &
00921     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_flux: Incompatible ocean and ice shelf grids."})
00922 
00923   iss => cs%ISS
00924 
00925 
00926   \textcolor{keyword}{call }add\_shelf\_pressure(g, us, cs, fluxes)
00927 
00928   \textcolor{comment}{! Determine ustar and the square magnitude of the velocity in the}
00929   \textcolor{comment}{! bottom boundary layer. Together these give the TKE source and}
00930   \textcolor{comment}{! vertical decay scale.}
00931 
00932   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00933     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%taux\_shelf) .and. \textcolor{keyword}{allocated}(sfc\_state%tauy\_shelf)) \textcolor{keywordflow}{then}
00934       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"tau[xy]\_shelf"}, sfc\_state%taux\_shelf, sfc\_state%tauy\_shelf, &
00935                     g%HI, haloshift=0, scale=us%RZ\_T\_to\_kg\_m2s*us%L\_T\_to\_m\_s)
00936 \textcolor{keywordflow}{    endif}
00937 \textcolor{keywordflow}{  endif}
00938 
00939   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics .or. cs%override\_shelf\_movement) \textcolor{keywordflow}{then}
00940     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
00941       \textcolor{keywordflow}{if} (g%areaT(i,j) > 0.0) &
00942         fluxes%frac\_shelf\_h(i,j) = min(1.0, iss%area\_shelf\_h(i,j) * g%IareaT(i,j))
00943 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00944 \textcolor{keywordflow}{  endif}
00945 
00946   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00947     \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"Before adding shelf fluxes"}, fluxes, g, cs%US, haloshift=0)
00948 \textcolor{keywordflow}{  endif}
00949 
00950   \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}
00951     \textcolor{comment}{! Replace fluxes intercepted by the ice shelf with fluxes from the ice shelf}
00952     frac\_shelf = min(1.0, iss%area\_shelf\_h(i,j) * g%IareaT(i,j))
00953     frac\_open = max(0.0, 1.0 - frac\_shelf)
00954 
00955     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw)) fluxes%sw(i,j) = frac\_open * fluxes%sw(i,j)
00956     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_vis\_dir)) fluxes%sw\_vis\_dir(i,j) = frac\_open * fluxes%sw\_vis\_dir(i,j)
00957     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_vis\_dif)) fluxes%sw\_vis\_dif(i,j) = frac\_open * fluxes%sw\_vis\_dif(i,j)
00958     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_nir\_dir)) fluxes%sw\_nir\_dir(i,j) = frac\_open * fluxes%sw\_nir\_dir(i,j)
00959     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_nir\_dif)) fluxes%sw\_nir\_dif(i,j) = frac\_open * fluxes%sw\_nir\_dif(i,j)
00960     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lw)) fluxes%lw(i,j) = frac\_open * fluxes%lw(i,j)
00961     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent)) fluxes%latent(i,j) = frac\_open * fluxes%latent(i,j)
00962     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap)) fluxes%evap(i,j) = frac\_open * fluxes%evap(i,j)
00963     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) \textcolor{keywordflow}{then}
00964       \textcolor{keywordflow}{if} (iss%water\_flux(i,j) > 0.0) \textcolor{keywordflow}{then}
00965         fluxes%lprec(i,j) =  frac\_shelf*iss%water\_flux(i,j)*cs%flux\_factor + frac\_open * fluxes%lprec(i,j)
00966       \textcolor{keywordflow}{else}
00967         fluxes%lprec(i,j) = frac\_open * fluxes%lprec(i,j)
00968         fluxes%evap(i,j) = fluxes%evap(i,j) + frac\_shelf*iss%water\_flux(i,j)*cs%flux\_factor
00969 \textcolor{keywordflow}{      endif}
00970 \textcolor{keywordflow}{    endif}
00971 
00972     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens)) &
00973       fluxes%sens(i,j) = frac\_shelf*iss%tflux\_ocn(i,j)*cs%flux\_factor + frac\_open * fluxes%sens(i,j)
00974     \textcolor{comment}{! The salt flux should be mostly from sea ice, so perhaps none should be intercepted and this should be
       changed.}
00975     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux)) &
00976       fluxes%salt\_flux(i,j) = frac\_shelf * iss%salt\_flux(i,j)*cs%flux\_factor + frac\_open * fluxes%salt\_flux
      (i,j)
00977 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00978 
00979   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00980     \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)
00981     \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)
00982     \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"After adding shelf fluxes"}, fluxes, g, cs%US, haloshift=0)
00983 \textcolor{keywordflow}{  endif}
00984 
00985   \textcolor{comment}{! Keep sea level constant by removing mass via a balancing flux that might be applied}
00986   \textcolor{comment}{! in the open ocean or the sponge region (via virtual precip, vprec). Apply additional}
00987   \textcolor{comment}{! salt/heat fluxes so that the resultant surface buoyancy forcing is ~ 0.}
00988   \textcolor{comment}{! This is needed for some of the ISOMIP+ experiments.}
00989 
00990   \textcolor{keywordflow}{if} (cs%constant\_sea\_level) \textcolor{keywordflow}{then}
00991     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(fluxes%salt\_flux)) \textcolor{keyword}{allocate}(fluxes%salt\_flux(ie,je))
00992     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(fluxes%vprec)) \textcolor{keyword}{allocate}(fluxes%vprec(ie,je))
00993     fluxes%salt\_flux(:,:) = 0.0 ; fluxes%vprec(:,:) = 0.0
00994 
00995     \textcolor{comment}{! take into account changes in mass (or thickness) when imposing ice shelf mass}
00996     \textcolor{keywordflow}{if} (cs%override\_shelf\_movement .and. cs%mass\_from\_file) \textcolor{keywordflow}{then}
00997       dtime = real\_to\_time(cs%time\_step)
00998 
00999       \textcolor{comment}{! Compute changes in mass after at least one full time step}
01000       \textcolor{keywordflow}{if} (cs%Time > dtime) \textcolor{keywordflow}{then}
01001         time0 = cs%Time - dtime
01002         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01003           last\_hmask(i,j) = iss%hmask(i,j) ; last\_area\_shelf\_h(i,j) = iss%area\_shelf\_h(i,j)
01004 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
01005         \textcolor{keyword}{call }time\_interp\_external(cs%id\_read\_mass, time0, last\_mass\_shelf)
01006         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01007         \textcolor{comment}{! This should only be done if time\_interp\_external did an update.}
01008           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}
01009           last\_h\_shelf(i,j) = last\_mass\_shelf(i,j) / cs%density\_ice
01010 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
01011 
01012         \textcolor{comment}{! apply calving}
01013         \textcolor{keywordflow}{if} (cs%min\_thickness\_simple\_calve > 0.0) \textcolor{keywordflow}{then}
01014           \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, last\_h\_shelf, last\_area\_shelf\_h, last\_hmask, &
01015                                        cs%min\_thickness\_simple\_calve, halo=0)
01016           \textcolor{comment}{! convert to mass again}
01017           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01018             last\_mass\_shelf(i,j) = last\_h\_shelf(i,j) * cs%density\_ice
01019 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
01020 \textcolor{keywordflow}{        endif}
01021 
01022         \textcolor{comment}{! get total ice shelf mass at (Time-dt) and (Time), in kg}
01023         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01024           \textcolor{comment}{! Just consider the change in the mass of the floating shelf.}
01025           \textcolor{keywordflow}{if} ((sfc\_state%ocean\_mass(i,j) > cs%min\_ocean\_mass\_float) .and. &
01026               (iss%area\_shelf\_h(i,j) > 0.0)) \textcolor{keywordflow}{then}
01027             delta\_float\_mass(i,j) = iss%mass\_shelf(i,j) - last\_mass\_shelf(i,j)
01028           \textcolor{keywordflow}{else}
01029             delta\_float\_mass(i,j) = 0.0
01030 \textcolor{keywordflow}{          endif}
01031 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
01032         delta\_mass\_shelf = us%kg\_m2s\_to\_RZ\_T*(global\_area\_integral(delta\_float\_mass, g, scale=us
      %RZ\_to\_kg\_m2, &
01033                                                                    area=iss%area\_shelf\_h) / cs%time\_step)
01034       else\textcolor{comment}{! first time step}
01035         delta\_mass\_shelf = 0.0
01036 \textcolor{keywordflow}{      endif}
01037     \textcolor{keywordflow}{else} \textcolor{comment}{! ice shelf mass does not change}
01038       delta\_mass\_shelf = 0.0
01039 \textcolor{keywordflow}{    endif}
01040 
01041     \textcolor{comment}{! average total melt flux over sponge area}
01042     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01043       \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}
01044          \textcolor{comment}{! Uncomment this for some ISOMIP cases:}
01045          \textcolor{comment}{!  .AND. (G%geoLonT(i,j) >= 790.0) .AND. (G%geoLonT(i,j) <= 800.0)) then}
01046         bal\_frac(i,j) = max(1.0 - iss%area\_shelf\_h(i,j) * g%IareaT(i,j), 0.0)
01047       \textcolor{keywordflow}{else}
01048         bal\_frac(i,j) = 0.0
01049 \textcolor{keywordflow}{      endif}
01050 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
01051 
01052     balancing\_area = global\_area\_integral(bal\_frac, g)
01053     \textcolor{keywordflow}{if} (balancing\_area > 0.0) \textcolor{keywordflow}{then}
01054       balancing\_flux = ( us%kg\_m2s\_to\_RZ\_T*global\_area\_integral(iss%water\_flux, g, scale=us%RZ\_T\_to\_kg\_m2s,
       &
01055                                                                 area=iss%area\_shelf\_h) + &
01056                          delta\_mass\_shelf ) / balancing\_area
01057     \textcolor{keywordflow}{else}
01058       balancing\_flux = 0.0
01059 \textcolor{keywordflow}{    endif}
01060 
01061     \textcolor{comment}{! apply fluxes}
01062     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01063       \textcolor{keywordflow}{if} (bal\_frac(i,j) > 0.0) \textcolor{keywordflow}{then}
01064         \textcolor{comment}{! evap is negative, and vprec has units of [R Z T-1 ~> kg m-2 s-1]}
01065         fluxes%vprec(i,j) = -balancing\_flux
01066         fluxes%sens(i,j) = fluxes%vprec(i,j) * cs%Cp * cs%T0 \textcolor{comment}{! [ Q R Z T-1 ~> W /m^2 ]}
01067         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]}
01068 \textcolor{keywordflow}{      endif}
01069 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
01070 
01071     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01072       \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'Balancing flux (kg/(m^2 s)), dt = '}, balancing\_flux*us%RZ\_T\_to\_kg\_m2s, cs%time\_step
01073       \textcolor{keyword}{call }mom\_mesg(mesg)
01074       \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"After constant sea level"}, fluxes, g, cs%US, haloshift=0)
01075 \textcolor{keywordflow}{    endif}
01076 
01077 \textcolor{keywordflow}{  endif} \textcolor{comment}{! constant\_sea\_level}
01078 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l00776}{776} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



Referenced by \hyperlink{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}{initialize\+\_\+ice\+\_\+shelf()}, and \hyperlink{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}{shelf\+\_\+calc\+\_\+flux()}.


\begin{DoxyCode}
00776   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
00777   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
00778   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< This module's control structure.}
00779   \textcolor{keywordtype}{type}(mech\_forcing),    \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
00780   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)}    :: do\_shelf\_area\textcolor{comment}{ !< If true find the shelf-covered areas.}
00781 
00782   \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].}
00783   \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].}
00784   \textcolor{keywordtype}{logical} :: find\_area \textcolor{comment}{! If true find the shelf areas at u & v points.}
00785   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: iss => null() \textcolor{comment}{! A structure with elements that describe}
00786                                           \textcolor{comment}{! the ice-shelf state}
00787 
00788   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
00789   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
00790   isd = g%isd ; jsd = g%jsd ; ied = g%ied ; jed = g%jed
00791 
00792   \textcolor{keywordflow}{if} ((cs%grid%isc /= g%isc) .or. (cs%grid%iec /= g%iec) .or. &
00793       (cs%grid%jsc /= g%jsc) .or. (cs%grid%jec /= g%jec)) &
00794     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_forces: Incompatible ocean and ice shelf grids."})
00795 
00796   iss => cs%ISS
00797 
00798   find\_area = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(do\_shelf\_area)) find\_area = do\_shelf\_area
00799 
00800   \textcolor{keywordflow}{if} (find\_area) \textcolor{keywordflow}{then}
00801     \textcolor{comment}{! The frac\_shelf is set over the widest possible area. Could it be smaller?}
00802     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied-1
00803       forces%frac\_shelf\_u(i,j) = 0.0
00804       \textcolor{keywordflow}{if} ((g%areaT(i,j) + g%areaT(i+1,j) > 0.0)) & \textcolor{comment}{! .and. (G%areaCu(I,j) > 0.0)) &}
00805         forces%frac\_shelf\_u(i,j) = (iss%area\_shelf\_h(i,j) + iss%area\_shelf\_h(i+1,j)) / &
00806                                    (g%areaT(i,j) + g%areaT(i+1,j))
00807 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00808     \textcolor{keywordflow}{do} j=jsd,jed-1 ; \textcolor{keywordflow}{do} i=isd,ied
00809       forces%frac\_shelf\_v(i,j) = 0.0
00810       \textcolor{keywordflow}{if} ((g%areaT(i,j) + g%areaT(i,j+1) > 0.0)) & \textcolor{comment}{! .and. (G%areaCv(i,J) > 0.0)) &}
00811         forces%frac\_shelf\_v(i,j) = (iss%area\_shelf\_h(i,j) + iss%area\_shelf\_h(i,j+1)) / &
00812                                    (g%areaT(i,j) + g%areaT(i,j+1))
00813 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00814     \textcolor{keyword}{call }pass\_vector(forces%frac\_shelf\_u, forces%frac\_shelf\_v, g%domain, to\_all, cgrid\_ne)
00815 \textcolor{keywordflow}{  endif}
00816 
00817   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
00818     press\_ice = (iss%area\_shelf\_h(i,j) * g%IareaT(i,j)) * (cs%g\_Earth * iss%mass\_shelf(i,j))
00819     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf)) \textcolor{keywordflow}{then}
00820       \textcolor{keywordflow}{if} (.not.forces%accumulate\_p\_surf) forces%p\_surf(i,j) = 0.0
00821       forces%p\_surf(i,j) = forces%p\_surf(i,j) + press\_ice
00822 \textcolor{keywordflow}{    endif}
00823     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf\_full)) \textcolor{keywordflow}{then}
00824       \textcolor{keywordflow}{if} (.not.forces%accumulate\_p\_surf) forces%p\_surf\_full(i,j) = 0.0
00825       forces%p\_surf\_full(i,j) = forces%p\_surf\_full(i,j) + press\_ice
00826 \textcolor{keywordflow}{    endif}
00827 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00828 
00829   \textcolor{comment}{! For various reasons, forces%rigidity\_ice\_[uv] is always updated here. Note}
00830   \textcolor{comment}{! that it may have been zeroed out where IOB is translated to forces and}
00831   \textcolor{comment}{! contributions from icebergs and the sea-ice pack added subsequently.}
00832   \textcolor{comment}{!### THE RIGIDITY SHOULD ALSO INCORPORATE AREAL-COVERAGE INFORMATION.}
00833   kv\_rho\_ice = cs%kv\_ice / cs%density\_ice
00834   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ie
00835     \textcolor{keywordflow}{if} (.not.forces%accumulate\_rigidity) forces%rigidity\_ice\_u(i,j) = 0.0
00836     forces%rigidity\_ice\_u(i,j) = forces%rigidity\_ice\_u(i,j) + &
00837             kv\_rho\_ice * min(iss%mass\_shelf(i,j), iss%mass\_shelf(i+1,j))
00838 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00839   \textcolor{keywordflow}{do} j=js-1,je ; \textcolor{keywordflow}{do} i=is,ie
00840     \textcolor{keywordflow}{if} (.not.forces%accumulate\_rigidity) forces%rigidity\_ice\_v(i,j) = 0.0
00841     forces%rigidity\_ice\_v(i,j) = forces%rigidity\_ice\_v(i,j) + &
00842             kv\_rho\_ice * min(iss%mass\_shelf(i,j), iss%mass\_shelf(i,j+1))
00843 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00844 
00845   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00846     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"rigidity\_ice\_[uv]"}, forces%rigidity\_ice\_u, forces%rigidity\_ice\_v, &
00847                   g%HI, symmetric=.true., scale=us%L\_to\_m**3*us%L\_to\_Z*us%s\_to\_T)
00848     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"frac\_shelf\_[uv]"}, forces%frac\_shelf\_u, forces%frac\_shelf\_v, &
00849                   g%HI, symmetric=.true.)
00850 \textcolor{keywordflow}{  endif}
00851 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l00856}{856} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



Referenced by \hyperlink{namespacemom__ice__shelf_a8f7eae8642835e30aff99f77f3836945}{add\+\_\+shelf\+\_\+flux()}, and \hyperlink{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}{initialize\+\_\+ice\+\_\+shelf()}.


\begin{DoxyCode}
00856   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure.}
00857   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
00858   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{   !< This module's control structure.}
00859   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{  !< A structure of surface fluxes that may be updated.}
00860 
00861   \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].}
00862   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
00863   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
00864 
00865   \textcolor{keywordflow}{if} ((cs%grid%isc /= g%isc) .or. (cs%grid%iec /= g%iec) .or. &
00866       (cs%grid%jsc /= g%jsc) .or. (cs%grid%jec /= g%jec)) &
00867     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"add\_shelf\_pressure: Incompatible ocean and ice shelf grids."})
00868 
00869   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
00870     press\_ice = (cs%ISS%area\_shelf\_h(i,j) * g%IareaT(i,j)) * (cs%g\_Earth * cs%ISS%mass\_shelf(i,j))
00871     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf)) \textcolor{keywordflow}{then}
00872       \textcolor{keywordflow}{if} (.not.fluxes%accumulate\_p\_surf) fluxes%p\_surf(i,j) = 0.0
00873       fluxes%p\_surf(i,j) = fluxes%p\_surf(i,j) + press\_ice
00874 \textcolor{keywordflow}{    endif}
00875     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf\_full)) \textcolor{keywordflow}{then}
00876       \textcolor{keywordflow}{if} (.not.fluxes%accumulate\_p\_surf) fluxes%p\_surf\_full(i,j) = 0.0
00877       fluxes%p\_surf\_full(i,j) = fluxes%p\_surf\_full(i,j) + press\_ice
00878 \textcolor{keywordflow}{    endif}
00879 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00880 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l00728}{728} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



Referenced by \hyperlink{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}{shelf\+\_\+calc\+\_\+flux()}.


\begin{DoxyCode}
00728   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{  !< The ocean's grid structure.}
00729   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< A structure with elements that describe}
00730 \textcolor{comment}{                                              !! the ice-shelf state}
00731   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
00732   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< The time step for this update [T ~> s].}
00733   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< structure containing pointers to any possible}
00734 \textcolor{comment}{                                                 !! thermodynamic or mass-flux forcing fields.}
00735   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: density\_ice\textcolor{comment}{ !< The density of ice-shelf ice [R ~> kg m-3].}
00736   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{ !< If present and true, write chksums}
00737 
00738   \textcolor{comment}{! locals}
00739   \textcolor{keywordtype}{real} :: i\_rho\_ice \textcolor{comment}{! Ice specific volume [R-1 ~> m3 kg-1]}
00740   \textcolor{keywordtype}{integer} :: i, j
00741 
00742   i\_rho\_ice = 1.0 / density\_ice
00743 
00744 
00745   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
00746     \textcolor{keywordflow}{if} ((iss%hmask(i,j) == 1) .or. (iss%hmask(i,j) == 2)) \textcolor{keywordflow}{then}
00747       \textcolor{comment}{! first, zero out fluxes applied during previous time step}
00748       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) fluxes%lprec(i,j) = 0.0
00749       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens)) fluxes%sens(i,j) = 0.0
00750       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frac\_shelf\_h)) fluxes%frac\_shelf\_h(i,j) = 0.0
00751       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux)) fluxes%salt\_flux(i,j) = 0.0
00752 
00753       \textcolor{keywordflow}{if} (iss%water\_flux(i,j) * time\_step / density\_ice < iss%h\_shelf(i,j)) \textcolor{keywordflow}{then}
00754         iss%h\_shelf(i,j) = iss%h\_shelf(i,j) - iss%water\_flux(i,j) * time\_step / density\_ice
00755       \textcolor{keywordflow}{else}
00756         \textcolor{comment}{! the ice is about to melt away, so set thickness, area, and mask to zero}
00757         \textcolor{comment}{! NOTE: this is not mass conservative should maybe scale salt & heat flux for this cell}
00758         iss%h\_shelf(i,j) = 0.0
00759         iss%hmask(i,j) = 0.0
00760         iss%area\_shelf\_h(i,j) = 0.0
00761 \textcolor{keywordflow}{      endif}
00762       iss%mass\_shelf(i,j) = iss%h\_shelf(i,j) * density\_ice
00763 \textcolor{keywordflow}{    endif}
00764 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00765 
00766   \textcolor{keyword}{call }pass\_var(iss%area\_shelf\_h, g%domain)
00767   \textcolor{keyword}{call }pass\_var(iss%h\_shelf, g%domain)
00768   \textcolor{keyword}{call }pass\_var(iss%hmask, g%domain)
00769   \textcolor{keyword}{call }pass\_var(iss%mass\_shelf, g%domain)
00770 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l01790}{1790} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.


\begin{DoxyCode}
01790   \textcolor{keywordtype}{type}(ice\_shelf\_cs), \textcolor{keywordtype}{pointer}   :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
01791 
01792   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
01793 
01794   \textcolor{keyword}{call }ice\_shelf\_state\_end(cs%ISS)
01795 
01796   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keyword}{call }ice\_shelf\_dyn\_end(cs%dCS)
01797 
01798   \textcolor{keyword}{deallocate}(cs)
01799 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l01767}{1767} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.


\begin{DoxyCode}
01767   \textcolor{keywordtype}{type}(ice\_shelf\_cs),         \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{ !< ice shelf control structure}
01768   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)} :: time\textcolor{comment}{ !< model time at this call}
01769   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: directory\textcolor{comment}{ !< An optional directory into which to write}
01770 \textcolor{comment}{                                               !! these restart files.}
01771   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: time\_stamped\textcolor{comment}{ !< f true, the restart file names include}
01772 \textcolor{comment}{                                               !! a unique time stamp.  The default is false.}
01773   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: filename\_suffix\textcolor{comment}{ !< An optional suffix (e.g., a}
01774 \textcolor{comment}{                                               !! time-stamp) to append to the restart file names.}
01775   \textcolor{comment}{! local variables}
01776   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: g => null()
01777   \textcolor{keywordtype}{character(len=200)} :: restart\_dir
01778 
01779   g => cs%grid
01780 
01781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(directory)) \textcolor{keywordflow}{then} ; restart\_dir = directory
01782   \textcolor{keywordflow}{else} ; restart\_dir = cs%restart\_output\_dir ;\textcolor{keywordflow}{ endif}
01783 
01784   \textcolor{keyword}{call }save\_restart(restart\_dir, time, cs%grid, cs%restart\_CSp, time\_stamped)
01785 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l01084}{1084} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



References \hyperlink{namespacemom__ice__shelf_a0274b25df07d5fa712d038c31f921cbc}{add\+\_\+shelf\+\_\+forces()}, \hyperlink{namespacemom__ice__shelf_aca1d1c1db015f270ce1b1f93d16dea91}{add\+\_\+shelf\+\_\+pressure()}, \hyperlink{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}{mom\+\_\+eos\+::eos\+\_\+init()}, \hyperlink{namespacemom__unit__scaling_a0d99ae286970838e8f4cd534e3a2744c}{mom\+\_\+unit\+\_\+scaling\+::fix\+\_\+restart\+\_\+unit\+\_\+scaling()}, \hyperlink{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}{id\+\_\+clock\+\_\+pass}, \hyperlink{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}{id\+\_\+clock\+\_\+shelf}, \hyperlink{namespacemom__ice__shelf_ac478a1dd52137f8e851916bee2243fa3}{initialize\+\_\+shelf\+\_\+mass()}, and \hyperlink{namespacemom__unit__scaling_a74867ddf628f93dcee854980e08bbe21}{mom\+\_\+unit\+\_\+scaling\+::unit\+\_\+scaling\+\_\+init()}.


\begin{DoxyCode}
01084   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
01085   \textcolor{keywordtype}{type}(ocean\_grid\_type),        \textcolor{keywordtype}{pointer}       :: ocn\_grid\textcolor{comment}{   !< The calling ocean model's horizontal grid
       structure}
01086   \textcolor{keywordtype}{type}(time\_type),              \textcolor{keywordtype}{intent(inout)} :: time\textcolor{comment}{ !< The clock that that will indicate the model time}
01087   \textcolor{keywordtype}{type}(ice\_shelf\_cs),           \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< A pointer to the ice shelf control structure}
01088   \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.}
01089   \textcolor{keywordtype}{type}(forcing),      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to any possible}
01090 \textcolor{comment}{                                                   !! thermodynamic or mass-flux forcing fields.}
01091   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
01092   \textcolor{keywordtype}{type}(time\_type),    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: time\_in\textcolor{comment}{ !< The time at initialization.}
01093   \textcolor{keywordtype}{logical},            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: solo\_ice\_sheet\_in\textcolor{comment}{ !< If present, this indicates whether}
01094 \textcolor{comment}{                                                   !! a solo ice-sheet driver.}
01095 
01096   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: g  => null(), og  => null() \textcolor{comment}{! Pointers to grids for convenience.}
01097   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{! Pointer to a structure containing}
01098                                                  \textcolor{comment}{! various unit conversion factors}
01099   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: iss => null() \textcolor{comment}{!< A structure with elements that describe}
01100 \textcolor{comment}{                                          !! the ice-shelf state}
01101   \textcolor{keywordtype}{type}(directories)  :: dirs
01102   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer} :: dg => null()
01103   \textcolor{keywordtype}{real}    :: z\_rescale  \textcolor{comment}{! A rescaling factor for heights from the representation in}
01104                         \textcolor{comment}{! a restart file to the internal representation in this run.}
01105   \textcolor{keywordtype}{real}    :: rz\_rescale \textcolor{comment}{! A rescaling factor for mass loads from the representation in}
01106                         \textcolor{comment}{! a restart file to the internal representation in this run.}
01107   \textcolor{keywordtype}{real}    :: l\_rescale  \textcolor{comment}{! A rescaling factor for horizontal lengths from the representation in}
01108                         \textcolor{comment}{! a restart file to the internal representation in this run.}
01109   \textcolor{keywordtype}{real} :: meltrate\_conversion \textcolor{comment}{! The conversion factor to use for in the melt rate diagnostic.}
01110   \textcolor{keywordtype}{real} :: dz\_ocean\_min\_float \textcolor{comment}{! The minimum ocean thickness above which the ice shelf is considered}
01111                         \textcolor{comment}{! to be floating when CONST\_SEA\_LEVEL = True [Z ~> m].}
01112   \textcolor{keywordtype}{real} :: cdrag, drag\_bg\_vel
01113   \textcolor{keywordtype}{logical} :: new\_sim, save\_ic, var\_force
01114   \textcolor{comment}{!This include declares and sets the variable "version".}
01115 \textcolor{preprocessor}{# include "version\_variable.h"}
01116 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=200)} :: config
01117   \textcolor{keywordtype}{character(len=200)} :: ic\_file,filename,inputdir
01118   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf"}  \textcolor{comment}{! This module's name.}
01119   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed, isdq, iedq, jsdq, jedq
01120   \textcolor{keywordtype}{integer} :: wd\_halos(2)
01121   \textcolor{keywordtype}{logical} :: read\_tideamp, shelf\_mass\_is\_dynamic, debug
01122   \textcolor{keywordtype}{character(len=240)} :: tideamp\_file
01123   \textcolor{keywordtype}{real}    :: utide  \textcolor{comment}{! A tidal velocity [L T-1 ~> m s-1]}
01124   \textcolor{keywordtype}{real}    :: col\_thick\_melt\_thresh \textcolor{comment}{! An ocean column thickness below which iceshelf melting}
01125                        \textcolor{comment}{! does not occur [Z ~> m]}
01126   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
01127     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: "}// &
01128                           \textcolor{stringliteral}{"called with an associated control structure."})
01129     \textcolor{keywordflow}{return}
01130 \textcolor{keywordflow}{  endif}
01131   \textcolor{keyword}{allocate}(cs)
01132 
01133   \textcolor{comment}{!   Go through all of the infrastructure initialization calls, since this is}
01134   \textcolor{comment}{! being treated as an independent component that just happens to use the}
01135   \textcolor{comment}{! MOM's grid and infrastructure.}
01136   \textcolor{keyword}{call }get\_mom\_input(dirs=dirs)
01137 
01138   \textcolor{comment}{! Determining the internal unit scaling factors for this run.}
01139   \textcolor{keyword}{call }unit\_scaling\_init(param\_file, cs%US)
01140 
01141   \textcolor{comment}{! Set up the ice-shelf domain and grid}
01142   wd\_halos(:)=0
01143   \textcolor{keyword}{call }mom\_domains\_init(cs%grid%domain, param\_file, min\_halo=wd\_halos, symmetric=grid\_sym\_)
01144   \textcolor{comment}{! call diag\_mediator\_init(CS%grid,param\_file,CS%diag)}
01145   \textcolor{comment}{! this needs to be fixed - will probably break when not using coupled driver 0}
01146   \textcolor{keyword}{call }mom\_grid\_init(cs%grid, param\_file, cs%US)
01147 
01148   \textcolor{keyword}{call }create\_dyn\_horgrid(dg, cs%grid%HI)
01149   \textcolor{keyword}{call }clone\_mom\_domain(cs%grid%Domain, dg%Domain)
01150 
01151   \textcolor{keyword}{call }set\_grid\_metrics(dg, param\_file, cs%US)
01152   \textcolor{comment}{! call set\_diag\_mediator\_grid(CS%grid, CS%diag)}
01153 
01154   \textcolor{comment}{! The ocean grid possibly uses different symmetry.}
01155   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ocn\_grid)) \textcolor{keywordflow}{then} ; cs%ocn\_grid => ocn\_grid
01156   \textcolor{keywordflow}{else} ; cs%ocn\_grid => cs%grid ;\textcolor{keywordflow}{ endif}
01157 
01158   \textcolor{comment}{! Convenience pointers}
01159   g => cs%grid
01160   og => cs%ocn\_grid
01161   us => cs%US
01162 
01163   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then}
01164     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'OG: '}, og%isd, og%isc, og%iec, og%ied, og%jsd, og%jsc, og%jsd, og%jed
01165     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'IG: '}, g%isd, g%isc, g%iec, g%ied, g%jsd, g%jsc, g%jsd, g%jed
01166 \textcolor{keywordflow}{  endif}
01167 
01168   cs%diag => diag
01169 
01170   \textcolor{comment}{! Are we being called from the solo ice-sheet driver? When called by the ocean}
01171   \textcolor{comment}{! model solo\_ice\_sheet\_in is not preset.}
01172   cs%solo\_ice\_sheet = .false.
01173   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(solo\_ice\_sheet\_in)) cs%solo\_ice\_sheet = solo\_ice\_sheet\_in
01174 
01175   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(time\_in)) time = time\_in
01176 
01177   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
01178   isd = g%isd ; jsd = g%jsd ; ied = g%ied ; jed = g%jed
01179   isdq = g%IsdB ; iedq = g%IedB ; jsdq = g%JsdB ; jedq = g%JedB
01180 
01181   cs%override\_shelf\_movement = .false. ; cs%active\_shelf\_dynamics = .false.
01182 
01183   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
01184   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, debug, default=.false.)
01185   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG\_IS"}, cs%debug, &
01186                  \textcolor{stringliteral}{"If true, write verbose debugging messages for the ice shelf."}, &
01187                  default=debug)
01188   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DYNAMIC\_SHELF\_MASS"}, shelf\_mass\_is\_dynamic, &
01189                  \textcolor{stringliteral}{"If true, the ice sheet mass can evolve with time."}, &
01190                  default=.false.)
01191   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) \textcolor{keywordflow}{then}
01192     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OVERRIDE\_SHELF\_MOVEMENT"}, cs%override\_shelf\_movement, &
01193                  \textcolor{stringliteral}{"If true, user provided code specifies the ice-shelf "}//&
01194                  \textcolor{stringliteral}{"movement instead of the dynamic ice model."}, default=.false.)
01195     cs%active\_shelf\_dynamics = .not.cs%override\_shelf\_movement
01196     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_INTERPOLATE"}, cs%GL\_regularize, &
01197                  \textcolor{stringliteral}{"If true, regularize the floatation condition at the "}//&
01198                  \textcolor{stringliteral}{"grounding line as in Goldberg Holland Schoof 2009."}, default=.false.)
01199     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GROUNDING\_LINE\_COUPLE"}, cs%GL\_couple, &
01200                  \textcolor{stringliteral}{"If true, let the floatation condition be determined by "}//&
01201                  \textcolor{stringliteral}{"ocean column thickness. This means that update\_OD\_ffrac "}//&
01202                  \textcolor{stringliteral}{"will be called.  GL\_REGULARIZE and GL\_COUPLE are exclusive."}, &
01203                  default=.false., do\_not\_log=cs%GL\_regularize)
01204     \textcolor{keywordflow}{if} (cs%GL\_regularize) cs%GL\_couple = .false.
01205 \textcolor{keywordflow}{  endif}
01206 
01207   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_THERMO"}, cs%isthermo, &
01208                  \textcolor{stringliteral}{"If true, use a thermodynamically interactive ice shelf."}, &
01209                  default=.false.)
01210   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_HEAT\_FUSION"}, cs%Lat\_fusion, &
01211                  \textcolor{stringliteral}{"The latent heat of fusion."}, units=\textcolor{stringliteral}{"J/kg"}, default=hlf, scale=us%J\_kg\_to\_Q)
01212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_THREE\_EQN"}, cs%threeeq, &
01213                  \textcolor{stringliteral}{"If true, use the three equation expression of "}//&
01214                  \textcolor{stringliteral}{"consistency to calculate the fluxes at the ice-ocean "}//&
01215                  \textcolor{stringliteral}{"interface."}, default=.true.)
01216   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_INSULATOR"}, cs%insulator, &
01217                  \textcolor{stringliteral}{"If true, the ice shelf is a perfect insulatior "}//&
01218                  \textcolor{stringliteral}{"(no conduction)."}, default=.false.)
01219   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MELTING\_CUTOFF\_DEPTH"}, cs%cutoff\_depth, &
01220                  \textcolor{stringliteral}{"Depth above which the melt is set to zero (it must be >= 0) "}//&
01221                  \textcolor{stringliteral}{"Default value won't affect the solution."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us%m\_to\_Z)
01222   \textcolor{keywordflow}{if} (cs%cutoff\_depth < 0.) &
01223     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"Initialize\_ice\_shelf: MELTING\_CUTOFF\_DEPTH must be >= 0."})
01224 
01225   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONST\_SEA\_LEVEL"}, cs%constant\_sea\_level, &
01226                  \textcolor{stringliteral}{"If true, apply evaporative, heat and salt fluxes in "}//&
01227                  \textcolor{stringliteral}{"the sponge region. This will avoid a large increase "}//&
01228                  \textcolor{stringliteral}{"in sea level. This option is needed for some of the "}//&
01229                  \textcolor{stringliteral}{"ISOMIP+ experiments (Ocean3 and Ocean4). "}//&
01230                  \textcolor{stringliteral}{"IMPORTANT: it is not currently possible to do "}//&
01231                  \textcolor{stringliteral}{"prefect restarts using this flag."}, default=.false.)
01232   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_OCEAN\_FLOAT\_THICK"}, dz\_ocean\_min\_float, &
01233                  \textcolor{stringliteral}{"The minimum ocean thickness above which the ice shelf is considered to be "}//&
01234                  \textcolor{stringliteral}{"floating when CONST\_SEA\_LEVEL = True."}, &
01235                  default=0.1, units=\textcolor{stringliteral}{"m"}, scale=us%m\_to\_Z, do\_not\_log=.not.cs%constant\_sea\_level)
01236 
01237   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ISOMIP\_S\_SUR\_SPONGE"}, cs%S0, &
01238                  \textcolor{stringliteral}{"Surface salinity in the restoring region."}, &
01239                 default=33.8, units=\textcolor{stringliteral}{'ppt'}, do\_not\_log=.true.)
01240 
01241   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ISOMIP\_T\_SUR\_SPONGE"}, cs%T0, &
01242                 \textcolor{stringliteral}{"Surface temperature in the restoring region."}, &
01243                 default=-1.9, units=\textcolor{stringliteral}{'degC'}, do\_not\_log=.true.)
01244 
01245   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_3EQ\_GAMMA"}, cs%const\_gamma, &
01246                  \textcolor{stringliteral}{"If true, user specifies a constant nondimensional heat-transfer coefficient "}//&
01247                  \textcolor{stringliteral}{"(GAMMA\_T\_3EQ), from which the default salt-transfer coefficient is set "}//&
01248                  \textcolor{stringliteral}{"as GAMMA\_T\_3EQ/35. This is used with SHELF\_THREE\_EQN."}, default=.false.)
01249   \textcolor{keywordflow}{if} (cs%threeeq) \textcolor{keywordflow}{then}
01250     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_S\_ROOT"}, cs%find\_salt\_root, &
01251                  \textcolor{stringliteral}{"If SHELF\_S\_ROOT = True, salinity at the ice/ocean interface (Sbdry) "}//&
01252                  \textcolor{stringliteral}{"is computed from a quadratic equation. Otherwise, the previous "}//&
01253                  \textcolor{stringliteral}{"interactive method to estimate Sbdry is used."}, default=.false.)
01254   \textcolor{keywordflow}{else}
01255     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_2EQ\_GAMMA\_T"}, cs%gamma\_t, &
01256                  \textcolor{stringliteral}{"If SHELF\_THREE\_EQN is false, this the fixed turbulent "}//&
01257                  \textcolor{stringliteral}{"exchange velocity at the ice-ocean interface."}, &
01258                  units=\textcolor{stringliteral}{"m s-1"}, scale=us%m\_to\_Z*us%T\_to\_s, fail\_if\_missing=.true.)
01259 \textcolor{keywordflow}{  endif}
01260   \textcolor{keywordflow}{if} (cs%const\_gamma .or. cs%find\_salt\_root) \textcolor{keywordflow}{then}
01261     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_3EQ\_GAMMA\_T"}, cs%Gamma\_T\_3EQ, &
01262                  \textcolor{stringliteral}{"Nondimensional heat-transfer coefficient."}, &
01263                   units=\textcolor{stringliteral}{"nondim"}, default=2.2e-2)
01264     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_3EQ\_GAMMA\_S"}, cs%Gamma\_S\_3EQ, &
01265                  \textcolor{stringliteral}{"Nondimensional salt-transfer coefficient."}, &
01266                  default=cs%Gamma\_T\_3EQ/35.0, units=\textcolor{stringliteral}{"nondim"})
01267 \textcolor{keywordflow}{  endif}
01268 
01269   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_MASS\_FROM\_FILE"}, &
01270                  cs%mass\_from\_file, \textcolor{stringliteral}{"Read the mass of the "}//&
01271                  \textcolor{stringliteral}{"ice shelf (every time step) from a file."}, default=.false.)
01272 
01273   \textcolor{keywordflow}{if} (cs%find\_salt\_root) \textcolor{keywordflow}{then} \textcolor{comment}{! read liquidus coeffs.}
01274      \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TFREEZE\_S0\_P0"}, cs%TFr\_0\_0, &
01275                  \textcolor{stringliteral}{"this is the freezing potential temperature at "}//&
01276                  \textcolor{stringliteral}{"S=0, P=0."}, units=\textcolor{stringliteral}{"degC"}, default=0.0, do\_not\_log=.true.)
01277     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DS"}, cs%dTFr\_dS, &
01278                  \textcolor{stringliteral}{"this is the derivative of the freezing potential temperature with salinity."}, &
01279                  units=\textcolor{stringliteral}{"degC psu-1"}, default=-0.054, do\_not\_log=.true.)
01280     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DP"}, cs%dTFr\_dp, &
01281                  \textcolor{stringliteral}{"this is the derivative of the freezing potential temperature with pressure."}, &
01282                  units=\textcolor{stringliteral}{"degC Pa-1"}, default=0.0, scale=us%RL2\_T2\_to\_Pa, do\_not\_log=.true.)
01283 \textcolor{keywordflow}{  endif}
01284 
01285   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs%g\_Earth, &
01286                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, &
01287                  units=\textcolor{stringliteral}{"m s-2"}, default = 9.80, scale=us%m\_s\_to\_L\_T**2*us%Z\_to\_m)
01288   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"C\_P"}, cs%Cp, &
01289                  \textcolor{stringliteral}{"The heat capacity of sea water, approximated as a constant. "}//&
01290                  \textcolor{stringliteral}{"The default value is from the TEOS-10 definition of conservative temperature."}, &
01291                  units=\textcolor{stringliteral}{"J kg-1 K-1"}, default=3991.86795711963, scale=us%J\_kg\_to\_Q)
01292   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs%Rho\_ocn, &
01293                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//&
01294                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//&
01295                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//&
01296                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-2."}, &
01297                  units=\textcolor{stringliteral}{"kg m-3"}, default=1035.0, scale=us%kg\_m3\_to\_R)
01298   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"C\_P\_ICE"}, cs%Cp\_ice, &
01299                  \textcolor{stringliteral}{"The heat capacity of ice."}, units=\textcolor{stringliteral}{"J kg-1 K-1"}, scale=us%J\_kg\_to\_Q, &
01300                  default=2.10e3)
01301   \textcolor{keywordflow}{if} (cs%constant\_sea\_level) cs%min\_ocean\_mass\_float = dz\_ocean\_min\_float*cs%Rho\_ocn
01302 
01303   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_FLUX\_FACTOR"}, cs%flux\_factor, &
01304                  \textcolor{stringliteral}{"Non-dimensional factor applied to shelf thermodynamic "}//&
01305                  \textcolor{stringliteral}{"fluxes."}, units=\textcolor{stringliteral}{"none"}, default=1.0)
01306 
01307   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KV\_ICE"}, cs%kv\_ice, &
01308                  \textcolor{stringliteral}{"The viscosity of the ice."}, &
01309                  units=\textcolor{stringliteral}{"m2 s-1"}, default=1.0e10, scale=us%Z\_to\_L**2*us%m\_to\_L**2*us%T\_to\_s)
01310   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KV\_MOLECULAR"}, cs%kv\_molec, &
01311                  \textcolor{stringliteral}{"The molecular kinimatic viscosity of sea water at the "}//&
01312                  \textcolor{stringliteral}{"freezing temperature."}, units=\textcolor{stringliteral}{"m2 s-1"}, default=1.95e-6, scale=us%m2\_s\_to\_Z2\_T)
01313   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_SALINITY"}, cs%Salin\_ice, &
01314                  \textcolor{stringliteral}{"The salinity of the ice inside the ice shelf."}, units=\textcolor{stringliteral}{"psu"}, &
01315                  default=0.0)
01316   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_TEMPERATURE"}, cs%Temp\_ice, &
01317                  \textcolor{stringliteral}{"The temperature at the center of the ice shelf."}, &
01318                  units = \textcolor{stringliteral}{"degC"}, default=-15.0)
01319   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KD\_SALT\_MOLECULAR"}, cs%kd\_molec\_salt, &
01320                  \textcolor{stringliteral}{"The molecular diffusivity of salt in sea water at the "}//&
01321                  \textcolor{stringliteral}{"freezing point."}, units=\textcolor{stringliteral}{"m2 s-1"}, default=8.02e-10, scale=us%m2\_s\_to\_Z2\_T)
01322   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KD\_TEMP\_MOLECULAR"}, cs%kd\_molec\_temp, &
01323                  \textcolor{stringliteral}{"The molecular diffusivity of heat in sea water at the "}//&
01324                  \textcolor{stringliteral}{"freezing point."}, units=\textcolor{stringliteral}{"m2 s-1"}, default=1.41e-7, scale=us%m2\_s\_to\_Z2\_T)
01325   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DT\_FORCING"}, cs%time\_step, &
01326                  \textcolor{stringliteral}{"The time step for changing forcing, coupling with other "}//&
01327                  \textcolor{stringliteral}{"components, or potentially writing certain diagnostics. "}//&
01328                  \textcolor{stringliteral}{"The default value is given by DT."}, units=\textcolor{stringliteral}{"s"}, default=0.0)
01329 
01330   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"COL\_THICK\_MELT\_THRESHOLD"}, col\_thick\_melt\_thresh, &
01331                  \textcolor{stringliteral}{"The minimum ocean column thickness where melting is allowed."}, &
01332                  units=\textcolor{stringliteral}{"m"}, scale=us%m\_to\_Z, default=0.0)
01333   cs%col\_mass\_melt\_threshold =  cs%Rho\_ocn * col\_thick\_melt\_thresh
01334 
01335   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"READ\_TIDEAMP"}, read\_tideamp, &
01336                  \textcolor{stringliteral}{"If true, read a file (given by TIDEAMP\_FILE) containing "}//&
01337                  \textcolor{stringliteral}{"the tidal amplitude with INT\_TIDE\_DISSIPATION."}, default=.false.)
01338 
01339   \textcolor{keyword}{call }safe\_alloc\_ptr(cs%utide,isd,ied,jsd,jed)   ; cs%utide(:,:) = 0.0
01340 
01341   \textcolor{keywordflow}{if} (read\_tideamp) \textcolor{keywordflow}{then}
01342     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDEAMP\_FILE"}, tideamp\_file, &
01343                  \textcolor{stringliteral}{"The path to the file containing the spatially varying "}//&
01344                  \textcolor{stringliteral}{"tidal amplitudes."}, &
01345                  default=\textcolor{stringliteral}{"tideamp.nc"})
01346     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
01347     inputdir = slasher(inputdir)
01348     tideamp\_file = trim(inputdir) // trim(tideamp\_file)
01349     \textcolor{keyword}{call }mom\_read\_data(tideamp\_file, \textcolor{stringliteral}{'tideamp'}, cs%utide, g%domain, timelevel=1, scale=us%m\_s\_to\_L\_T)
01350   \textcolor{keywordflow}{else}
01351     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"UTIDE"}, utide, &
01352                  \textcolor{stringliteral}{"The constant tidal amplitude used with INT\_TIDE\_DISSIPATION."}, &
01353                  units=\textcolor{stringliteral}{"m s-1"}, default=0.0 , scale=us%m\_s\_to\_L\_T)
01354     cs%utide(:,:) = utide
01355 \textcolor{keywordflow}{  endif}
01356 
01357   \textcolor{keyword}{call }eos\_init(param\_file, cs%eqn\_of\_state)
01358 
01359   \textcolor{comment}{!! new parameters that need to be in MOM\_input}
01360 
01361   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keywordflow}{then}
01362 
01363     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSITY\_ICE"}, cs%density\_ice, &
01364                  \textcolor{stringliteral}{"A typical density of ice."}, units=\textcolor{stringliteral}{"kg m-3"}, default=917.0, scale=us%kg\_m3\_to\_R)
01365 
01366     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUT\_FLUX\_ICE\_SHELF"}, cs%input\_flux, &
01367                  \textcolor{stringliteral}{"volume flux at upstream boundary"}, units=\textcolor{stringliteral}{"m2 s-1"}, default=0.)
01368     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUT\_THICK\_ICE\_SHELF"}, cs%input\_thickness, &
01369                  \textcolor{stringliteral}{"flux thickness at upstream boundary"}, units=\textcolor{stringliteral}{"m"}, default=1000.)
01370   \textcolor{keywordflow}{else}
01371     \textcolor{comment}{! This is here because of inconsistent defaults.  I don't know why.  RWH}
01372     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSITY\_ICE"}, cs%density\_ice, &
01373                  \textcolor{stringliteral}{"A typical density of ice."}, units=\textcolor{stringliteral}{"kg m-3"}, default=900.0, scale=us%kg\_m3\_to\_R)
01374 \textcolor{keywordflow}{  endif}
01375   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIN\_THICKNESS\_SIMPLE\_CALVE"}, &
01376                 cs%min\_thickness\_simple\_calve, &
01377                  \textcolor{stringliteral}{"Min thickness rule for the very simple calving law"},&
01378                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us%m\_to\_Z)
01379 
01380   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USTAR\_SHELF\_BG"}, cs%ustar\_bg, &
01381                  \textcolor{stringliteral}{"The minimum value of ustar under ice shelves."}, &
01382                  units=\textcolor{stringliteral}{"m s-1"}, default=0.0, scale=us%m\_to\_Z*us%T\_to\_s)
01383   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CDRAG\_SHELF"}, cdrag, &
01384        \textcolor{stringliteral}{"CDRAG is the drag coefficient relating the magnitude of "}//&
01385        \textcolor{stringliteral}{"the velocity field to the surface stress."}, units=\textcolor{stringliteral}{"nondim"}, &
01386        default=0.003)
01387   cs%cdrag = cdrag
01388   \textcolor{keywordflow}{if} (cs%ustar\_bg <= 0.0) \textcolor{keywordflow}{then}
01389     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DRAG\_BG\_VEL\_SHELF"}, drag\_bg\_vel, &
01390                  \textcolor{stringliteral}{"DRAG\_BG\_VEL is either the assumed bottom velocity (with "}//&
01391                  \textcolor{stringliteral}{"LINEAR\_DRAG) or an unresolved  velocity that is "}//&
01392                  \textcolor{stringliteral}{"combined with the resolved velocity to estimate the "}//&
01393                  \textcolor{stringliteral}{"velocity magnitude."}, units=\textcolor{stringliteral}{"m s-1"}, default=0.0, scale=us%m\_to\_Z*us%T\_to\_s)
01394     \textcolor{keywordflow}{if} (cs%cdrag*drag\_bg\_vel > 0.0) cs%ustar\_bg = sqrt(cs%cdrag)*drag\_bg\_vel
01395 \textcolor{keywordflow}{  endif}
01396 
01397   \textcolor{comment}{! Allocate and initialize state variables to default values}
01398   \textcolor{keyword}{call }ice\_shelf\_state\_init(cs%ISS, cs%grid)
01399   iss => cs%ISS
01400 
01401   \textcolor{comment}{! Allocate the arrays for passing ice-shelf data through the forcing type.}
01402   \textcolor{keywordflow}{if} (.not. cs%solo\_ice\_sheet) \textcolor{keywordflow}{then}
01403     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: allocating fluxes."})
01404      \textcolor{comment}{! GMM: the following assures that water/heat fluxes are just allocated}
01405      \textcolor{comment}{! when SHELF\_THERMO = True. These fluxes are necessary if one wants to}
01406      \textcolor{comment}{! use either ENERGETICS\_SFC\_PBL (ALE mode) or BULKMIXEDLAYER (layer mode).}
01407     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) &
01408       \textcolor{keyword}{call }allocate\_forcing\_type(cs%ocn\_grid, fluxes, ustar=.true., shelf=.true., &
01409                                  press=.true., water=cs%isthermo, heat=cs%isthermo)
01410     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) &
01411       \textcolor{keyword}{call }allocate\_mech\_forcing(cs%ocn\_grid, forces, ustar=.true., shelf=.true., press=.true.)
01412   \textcolor{keywordflow}{else}
01413     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: allocating fluxes in solo mode."})
01414     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) &
01415       \textcolor{keyword}{call }allocate\_forcing\_type(g, fluxes, ustar=.true., shelf=.true., press=.true.)
01416     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) &
01417       \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, ustar=.true., shelf=.true., press=.true.)
01418 \textcolor{keywordflow}{  endif}
01419 
01420   \textcolor{comment}{! Set up the bottom depth, G%D either analytically or from file}
01421   \textcolor{keyword}{call }mom\_initialize\_topography(dg%bathyT, g%max\_depth, dg, param\_file)
01422   \textcolor{keyword}{call }rescale\_dyn\_horgrid\_bathymetry(dg, us%Z\_to\_m)
01423 
01424   \textcolor{comment}{! Set up the Coriolis parameter, G%f, usually analytically.}
01425   \textcolor{keyword}{call }mom\_initialize\_rotation(dg%CoriolisBu, dg, param\_file, us)
01426   \textcolor{comment}{! This copies grid elements, including bathyT and CoriolisBu from dG to CS%grid.}
01427   \textcolor{keyword}{call }copy\_dyngrid\_to\_mom\_grid(dg, cs%grid, us)
01428 
01429   \textcolor{keyword}{call }destroy\_dyn\_horgrid(dg)
01430 
01431   \textcolor{comment}{! Set up the restarts.}
01432   \textcolor{keyword}{call }restart\_init(param\_file, cs%restart\_CSp, \textcolor{stringliteral}{"Shelf.res"})
01433   \textcolor{keyword}{call }register\_restart\_field(iss%mass\_shelf, \textcolor{stringliteral}{"shelf\_mass"}, .true., cs%restart\_CSp, &
01434                               \textcolor{stringliteral}{"Ice shelf mass"}, \textcolor{stringliteral}{"kg m-2"})
01435   \textcolor{keyword}{call }register\_restart\_field(iss%area\_shelf\_h, \textcolor{stringliteral}{"shelf\_area"}, .true., cs%restart\_CSp, &
01436                               \textcolor{stringliteral}{"Ice shelf area in cell"}, \textcolor{stringliteral}{"m2"})
01437   \textcolor{keyword}{call }register\_restart\_field(iss%h\_shelf, \textcolor{stringliteral}{"h\_shelf"}, .true., cs%restart\_CSp, &
01438                               \textcolor{stringliteral}{"ice sheet/shelf thickness"}, \textcolor{stringliteral}{"m"})
01439   \textcolor{keyword}{call }register\_restart\_field(us%m\_to\_Z\_restart, \textcolor{stringliteral}{"m\_to\_Z"}, .false., cs%restart\_CSp, &
01440                               \textcolor{stringliteral}{"Height unit conversion factor"}, \textcolor{stringliteral}{"Z meter-1"})
01441   \textcolor{keyword}{call }register\_restart\_field(us%m\_to\_L\_restart, \textcolor{stringliteral}{"m\_to\_L"}, .false., cs%restart\_CSp, &
01442                               \textcolor{stringliteral}{"Length unit conversion factor"}, \textcolor{stringliteral}{"L meter-1"})
01443   \textcolor{keyword}{call }register\_restart\_field(us%kg\_m3\_to\_R\_restart, \textcolor{stringliteral}{"kg\_m3\_to\_R"}, .false., cs%restart\_CSp, &
01444                               \textcolor{stringliteral}{"Density unit conversion factor"}, \textcolor{stringliteral}{"R m3 kg-1"})
01445   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keywordflow}{then}
01446     \textcolor{keyword}{call }register\_restart\_field(iss%hmask, \textcolor{stringliteral}{"h\_mask"}, .true., cs%restart\_CSp, &
01447                                 \textcolor{stringliteral}{"ice sheet/shelf thickness mask"} ,\textcolor{stringliteral}{"none"})
01448 \textcolor{keywordflow}{  endif}
01449 
01450   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keywordflow}{then}
01451     \textcolor{comment}{! Allocate CS%dCS and specify additional restarts for ice shelf dynamics}
01452     \textcolor{keyword}{call }register\_ice\_shelf\_dyn\_restarts(g, param\_file, cs%dCS, cs%restart\_CSp)
01453 \textcolor{keywordflow}{  endif}
01454 
01455   \textcolor{comment}{!GMM - I think we do not need to save ustar\_shelf and iceshelf\_melt in the restart file}
01456   \textcolor{comment}{!if (.not. CS%solo\_ice\_sheet) then}
01457   \textcolor{comment}{!  call register\_restart\_field(fluxes%ustar\_shelf, "ustar\_shelf", .false., CS%restart\_CSp, &}
01458   \textcolor{comment}{!                              "Friction velocity under ice shelves", "m s-1")}
01459   \textcolor{comment}{!endif}
01460 
01461   cs%restart\_output\_dir = dirs%restart\_output\_dir
01462 
01463   new\_sim = .false.
01464   \textcolor{keywordflow}{if} ((dirs%input\_filename(1:1) == \textcolor{stringliteral}{'n'}) .and. &
01465       (len\_trim(dirs%input\_filename) == 1)) new\_sim = .true.
01466 
01467   \textcolor{keywordflow}{if} (cs%override\_shelf\_movement .and. cs%mass\_from\_file) \textcolor{keywordflow}{then}
01468 
01469     \textcolor{comment}{! initialize the ids for reading shelf mass from a netCDF}
01470     \textcolor{keyword}{call }initialize\_shelf\_mass(g, param\_file, cs, iss)
01471 
01472     \textcolor{keywordflow}{if} (new\_sim) \textcolor{keywordflow}{then}
01473       \textcolor{comment}{! new simulation, initialize ice thickness as in the static case}
01474       \textcolor{keyword}{call }initialize\_ice\_thickness(iss%h\_shelf, iss%area\_shelf\_h, iss%hmask, g, us, param\_file)
01475 
01476     \textcolor{comment}{! next make sure mass is consistent with thickness}
01477       \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%isd,g%ied
01478         \textcolor{keywordflow}{if} ((iss%hmask(i,j) == 1) .or. (iss%hmask(i,j) == 2)) \textcolor{keywordflow}{then}
01479           iss%mass\_shelf(i,j) = iss%h\_shelf(i,j)*cs%density\_ice
01480 \textcolor{keywordflow}{        endif}
01481 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
01482 
01483       \textcolor{keywordflow}{if} (cs%min\_thickness\_simple\_calve > 0.0) &
01484         \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, iss%h\_shelf, iss%area\_shelf\_h, iss%hmask, &
01485                                            cs%min\_thickness\_simple\_calve)
01486 \textcolor{keywordflow}{    endif}
01487 \textcolor{keywordflow}{  endif}
01488 
01489   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keywordflow}{then}
01490     \textcolor{comment}{! the only reason to initialize boundary conds is if the shelf is dynamic - MJH}
01491 
01492     \textcolor{comment}{! call initialize\_ice\_shelf\_boundary ( CS%u\_face\_mask\_bdry, CS%v\_face\_mask\_bdry, &}
01493     \textcolor{comment}{!                                      CS%u\_flux\_bdry\_val, CS%v\_flux\_bdry\_val, &}
01494     \textcolor{comment}{!                                      CS%u\_bdry\_val, CS%v\_bdry\_val, CS%h\_bdry\_val, &}
01495     \textcolor{comment}{!                                      ISS%hmask, G, param\_file)}
01496 
01497 \textcolor{keywordflow}{  endif}
01498 
01499   \textcolor{keywordflow}{if} (new\_sim .and. (.not. (cs%override\_shelf\_movement .and. cs%mass\_from\_file))) \textcolor{keywordflow}{then}
01500 
01501     \textcolor{comment}{! This model is initialized internally or from a file.}
01502     \textcolor{keyword}{call }initialize\_ice\_thickness(iss%h\_shelf, iss%area\_shelf\_h, iss%hmask, g, us, param\_file)
01503 
01504     \textcolor{comment}{! next make sure mass is consistent with thickness}
01505     \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%isd,g%ied
01506       \textcolor{keywordflow}{if} ((iss%hmask(i,j) == 1) .or. (iss%hmask(i,j) == 2)) \textcolor{keywordflow}{then}
01507         iss%mass\_shelf(i,j) = iss%h\_shelf(i,j)*cs%density\_ice
01508 \textcolor{keywordflow}{      endif}
01509 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
01510 
01511   \textcolor{comment}{! else ! Previous block for new\_sim=.T., this block restores the state.}
01512   \textcolor{keywordflow}{elseif} (.not.new\_sim) \textcolor{keywordflow}{then}
01513     \textcolor{comment}{! This line calls a subroutine that reads the initial conditions from a restart file.}
01514     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_ice\_shelf.F90, initialize\_ice\_shelf: Restoring ice shelf from file."})
01515     \textcolor{keyword}{call }restore\_state(dirs%input\_filename, dirs%restart\_input\_dir, time, &
01516                        g, cs%restart\_CSp)
01517 
01518     \textcolor{keywordflow}{if} ((us%m\_to\_Z\_restart /= 0.0) .and. (us%m\_to\_Z\_restart /= us%m\_to\_Z)) \textcolor{keywordflow}{then}
01519       z\_rescale = us%m\_to\_Z / us%m\_to\_Z\_restart
01520       \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
01521         iss%h\_shelf(i,j) = z\_rescale * iss%h\_shelf(i,j)
01522 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
01523 \textcolor{keywordflow}{    endif}
01524 
01525     \textcolor{keywordflow}{if} ((us%m\_to\_Z\_restart*us%kg\_m3\_to\_R\_restart /= 0.0) .and. &
01526         (us%m\_to\_Z*us%kg\_m3\_to\_R /= us%m\_to\_Z\_restart * us%kg\_m3\_to\_R\_restart)) \textcolor{keywordflow}{then}
01527       rz\_rescale = us%m\_to\_Z*us%kg\_m3\_to\_R / (us%m\_to\_Z\_restart * us%kg\_m3\_to\_R\_restart)
01528       \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
01529         iss%mass\_shelf(i,j) = rz\_rescale * iss%mass\_shelf(i,j)
01530 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
01531 \textcolor{keywordflow}{    endif}
01532 
01533     \textcolor{keywordflow}{if} ((us%m\_to\_L\_restart /= 0.0) .and. (us%m\_to\_L\_restart /= us%m\_to\_L)) \textcolor{keywordflow}{then}
01534       l\_rescale = us%m\_to\_L / us%m\_to\_L\_restart
01535       \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
01536         iss%area\_shelf\_h(i,j) = l\_rescale**2 * iss%area\_shelf\_h(i,j)
01537 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
01538 \textcolor{keywordflow}{    endif}
01539 
01540 \textcolor{keywordflow}{  endif} \textcolor{comment}{! .not. new\_sim}
01541 
01542   cs%Time = time
01543 
01544   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)
01545   \textcolor{keyword}{call }pass\_var(iss%area\_shelf\_h, g%domain)
01546   \textcolor{keyword}{call }pass\_var(iss%h\_shelf, g%domain)
01547   \textcolor{keyword}{call }pass\_var(iss%mass\_shelf, g%domain)
01548   \textcolor{keyword}{call }pass\_var(iss%hmask, g%domain)
01549   \textcolor{keyword}{call }pass\_var(g%bathyT, g%domain)
01550   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)
01551 
01552   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
01553     \textcolor{keywordflow}{if} (iss%area\_shelf\_h(i,j) > g%areaT(i,j)) \textcolor{keywordflow}{then}
01554       \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"Initialize\_ice\_shelf: area\_shelf\_h exceeds G%areaT."})
01555       iss%area\_shelf\_h(i,j) = g%areaT(i,j)
01556 \textcolor{keywordflow}{    endif}
01557 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01558   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
01559     \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)
01560 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
01561 
01562   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01563     \textcolor{keyword}{call }hchksum(fluxes%frac\_shelf\_h, \textcolor{stringliteral}{"IS init: frac\_shelf\_h"}, g%HI, haloshift=0)
01564 \textcolor{keywordflow}{  endif}
01565 
01566   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) &
01567     \textcolor{keyword}{call }add\_shelf\_forces(g, us, cs, forces, do\_shelf\_area=.not.cs%solo\_ice\_sheet)
01568 
01569   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \textcolor{keyword}{call }add\_shelf\_pressure(g, us, cs, fluxes)
01570 
01571   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics .and. .not.cs%isthermo) \textcolor{keywordflow}{then}
01572     iss%water\_flux(:,:) = 0.0
01573 \textcolor{keywordflow}{  endif}
01574 
01575   \textcolor{keywordflow}{if} (shelf\_mass\_is\_dynamic) &
01576     \textcolor{keyword}{call }initialize\_ice\_shelf\_dyn(param\_file, time, iss, cs%dCS, g, us, diag, new\_sim, solo\_ice\_sheet\_in)
01577 
01578   \textcolor{keyword}{call }fix\_restart\_unit\_scaling(us)
01579 
01580   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SAVE\_INITIAL\_CONDS"}, save\_ic, &
01581                  \textcolor{stringliteral}{"If true, save the ice shelf initial conditions."}, &
01582                  default=.false.)
01583   \textcolor{keywordflow}{if} (save\_ic) \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_IC\_OUTPUT\_FILE"}, ic\_file,&
01584                  \textcolor{stringliteral}{"The name-root of the output file for the ice shelf "}//&
01585                  \textcolor{stringliteral}{"initial conditions."}, default=\textcolor{stringliteral}{"MOM\_Shelf\_IC"})
01586 
01587   \textcolor{keywordflow}{if} (save\_ic .and. .not.((dirs%input\_filename(1:1) == \textcolor{stringliteral}{'r'}) .and. &
01588                           (len\_trim(dirs%input\_filename) == 1))) \textcolor{keywordflow}{then}
01589     \textcolor{keyword}{call }save\_restart(dirs%output\_directory, cs%Time, g, &
01590                       cs%restart\_CSp, filename=ic\_file)
01591 \textcolor{keywordflow}{  endif}
01592 
01593 
01594   cs%id\_area\_shelf\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_shelf\_h'}, cs%diag%axesT1, cs%Time, &
01595      \textcolor{stringliteral}{'Ice Shelf Area in cell'}, \textcolor{stringliteral}{'meter-2'}, conversion=us%L\_to\_m**2)
01596   cs%id\_shelf\_mass = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'shelf\_mass'}, cs%diag%axesT1, cs%Time, &
01597      \textcolor{stringliteral}{'mass of shelf'}, \textcolor{stringliteral}{'kg/m^2'}, conversion=us%RZ\_to\_kg\_m2)
01598   cs%id\_h\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_shelf'}, cs%diag%axesT1, cs%Time, &
01599        \textcolor{stringliteral}{'ice shelf thickness'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
01600   cs%id\_mass\_flux = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'mass\_flux'}, cs%diag%axesT1,&
01601      cs%Time, \textcolor{stringliteral}{'Total mass flux of freshwater across the ice-ocean interface.'}, &
01602      \textcolor{stringliteral}{'kg/s'}, conversion=us%RZ\_T\_to\_kg\_m2s*us%L\_to\_m**2)
01603 
01604   \textcolor{keywordflow}{if} (cs%const\_gamma) \textcolor{keywordflow}{then} \textcolor{comment}{! use ISOMIP+ eq. with rho\_fw = 1000. kg m-3}
01605     meltrate\_conversion = 86400.0*365.0*us%Z\_to\_m*us%s\_to\_T / (1000.0*us%kg\_m3\_to\_R)
01606   \textcolor{keywordflow}{else} \textcolor{comment}{! use original eq.}
01607     meltrate\_conversion = 86400.0*365.0*us%Z\_to\_m*us%s\_to\_T / cs%density\_ice
01608 \textcolor{keywordflow}{  endif}
01609   cs%id\_melt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'melt'}, cs%diag%axesT1, cs%Time, &
01610      \textcolor{stringliteral}{'Ice Shelf Melt Rate'}, \textcolor{stringliteral}{'m yr-1'}, conversion= meltrate\_conversion)
01611   cs%id\_thermal\_driving = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'thermal\_driving'}, cs%diag%axesT1, cs%Time, &
01612      \textcolor{stringliteral}{'pot. temp. in the boundary layer minus freezing pot. temp. at the ice-ocean interface.'}, \textcolor{stringliteral}{'Celsius'})
01613   cs%id\_haline\_driving = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'haline\_driving'}, cs%diag%axesT1, cs%Time, &
01614      \textcolor{stringliteral}{'salinity in the boundary layer minus salinity at the ice-ocean interface.'}, \textcolor{stringliteral}{'psu'})
01615   cs%id\_Sbdry = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sbdry'}, cs%diag%axesT1, cs%Time, &
01616      \textcolor{stringliteral}{'salinity at the ice-ocean interface.'}, \textcolor{stringliteral}{'psu'})
01617   cs%id\_u\_ml = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_ml'}, cs%diag%axesCu1, cs%Time, &
01618      \textcolor{stringliteral}{'Eastward vel. in the boundary layer (used to compute ustar)'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
01619   cs%id\_v\_ml = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_ml'}, cs%diag%axesCv1, cs%Time, &
01620      \textcolor{stringliteral}{'Northward vel. in the boundary layer (used to compute ustar)'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
01621   cs%id\_exch\_vel\_s = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'exch\_vel\_s'}, cs%diag%axesT1, cs%Time, &
01622      \textcolor{stringliteral}{'Sub-shelf salinity exchange velocity'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%Z\_to\_m*us%s\_to\_T)
01623   cs%id\_exch\_vel\_t = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'exch\_vel\_t'}, cs%diag%axesT1, cs%Time, &
01624      \textcolor{stringliteral}{'Sub-shelf thermal exchange velocity'}, \textcolor{stringliteral}{'m s-1'} , conversion=us%Z\_to\_m*us%s\_to\_T)
01625   cs%id\_tfreeze = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'tfreeze'}, cs%diag%axesT1, cs%Time, &
01626      \textcolor{stringliteral}{'In Situ Freezing point at ice shelf interface'}, \textcolor{stringliteral}{'degC'})
01627   cs%id\_tfl\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'tflux\_shelf'}, cs%diag%axesT1, cs%Time, &
01628      \textcolor{stringliteral}{'Heat conduction into ice shelf'}, \textcolor{stringliteral}{'W m-2'}, conversion=-us%QRZ\_T\_to\_W\_m2)
01629   cs%id\_ustar\_shelf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ustar\_shelf'}, cs%diag%axesT1, cs%Time, &
01630      \textcolor{stringliteral}{'Fric vel under shelf'}, \textcolor{stringliteral}{'m/s'}, conversion=us%Z\_to\_m*us%s\_to\_T)
01631   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keywordflow}{then}
01632     cs%id\_h\_mask = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_mask'}, cs%diag%axesT1, cs%Time, &
01633        \textcolor{stringliteral}{'ice shelf thickness mask'}, \textcolor{stringliteral}{'none'})
01634 \textcolor{keywordflow}{  endif}
01635 
01636   id\_clock\_shelf = cpu\_clock\_id(\textcolor{stringliteral}{'Ice shelf'}, grain=clock\_component)
01637   id\_clock\_pass = cpu\_clock\_id(\textcolor{stringliteral}{' Ice shelf halo updates'}, grain=clock\_routine)
01638 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l01643}{1643} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



Referenced by \hyperlink{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}{initialize\+\_\+ice\+\_\+shelf()}.


\begin{DoxyCode}
01643 
01644   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{   !< The ocean's grid structure.}
01645   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
01646   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{ !< A pointer to the ice shelf control structure}
01647   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< The ice shelf state type that is being updated}
01648   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: new\_sim\textcolor{comment}{ !< If present and false, this run is being restarted}
01649 
01650   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
01651   \textcolor{keywordtype}{logical} :: read\_shelf\_area, new\_sim\_2
01652   \textcolor{keywordtype}{character(len=240)} :: config, inputdir, shelf\_file, filename
01653   \textcolor{keywordtype}{character(len=120)} :: shelf\_mass\_var  \textcolor{comment}{! The name of shelf mass in the file.}
01654   \textcolor{keywordtype}{character(len=120)} :: shelf\_area\_var \textcolor{comment}{! The name of shelf area in the file.}
01655   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_ice\_shelf"}
01656   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
01657 
01658   new\_sim\_2 = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(new\_sim)) new\_sim\_2 = new\_sim
01659 
01660   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF\_CONFIG"}, config, &
01661                  \textcolor{stringliteral}{"A string that specifies how the ice shelf is "}//&
01662                  \textcolor{stringliteral}{"initialized. Valid options include:\(\backslash\)n"}//&
01663                  \textcolor{stringliteral}{" \(\backslash\)tfile\(\backslash\)t Read from a file.\(\backslash\)n"}//&
01664                  \textcolor{stringliteral}{" \(\backslash\)tzero\(\backslash\)t Set shelf mass to 0 everywhere.\(\backslash\)n"}//&
01665                  \textcolor{stringliteral}{" \(\backslash\)tUSER\(\backslash\)t Call USER\_initialize\_shelf\_mass.\(\backslash\)n"}, &
01666                  fail\_if\_missing=.true.)
01667 
01668   \textcolor{keywordflow}{select case} ( trim(config) )
01669     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"file"})
01670 
01671       \textcolor{keyword}{call }time\_interp\_external\_init()
01672 
01673       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
01674       inputdir = slasher(inputdir)
01675 
01676       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_FILE"}, shelf\_file, &
01677               \textcolor{stringliteral}{"If DYNAMIC\_SHELF\_MASS = True, OVERRIDE\_SHELF\_MOVEMENT = True "}//&
01678               \textcolor{stringliteral}{"and ICE\_SHELF\_MASS\_FROM\_FILE = True, this is the file from "}//&
01679               \textcolor{stringliteral}{"which to read the shelf mass and area."}, &
01680                default=\textcolor{stringliteral}{"shelf\_mass.nc"})
01681       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_MASS\_VAR"}, shelf\_mass\_var, &
01682                  \textcolor{stringliteral}{"The variable in SHELF\_FILE with the shelf mass."}, &
01683                  default=\textcolor{stringliteral}{"shelf\_mass"})
01684       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"READ\_SHELF\_AREA"}, read\_shelf\_area, &
01685                  \textcolor{stringliteral}{"If true, also read the area covered by ice-shelf from SHELF\_FILE."}, &
01686                  default=.false.)
01687 
01688       filename = trim(slasher(inputdir))//trim(shelf\_file)
01689       \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/SHELF\_FILE"}, filename)
01690 
01691       cs%id\_read\_mass = init\_external\_field(filename, shelf\_mass\_var, &
01692                           domain=g%Domain%mpp\_domain, verbose=cs%debug)
01693 
01694       \textcolor{keywordflow}{if} (read\_shelf\_area) \textcolor{keywordflow}{then}
01695          \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHELF\_AREA\_VAR"}, shelf\_area\_var, &
01696                   \textcolor{stringliteral}{"The variable in SHELF\_FILE with the shelf area."}, &
01697                   default=\textcolor{stringliteral}{"shelf\_area"})
01698 
01699          cs%id\_read\_area = init\_external\_field(filename,shelf\_area\_var, &
01700                              domain=g%Domain%mpp\_domain)
01701 \textcolor{keywordflow}{      endif}
01702 
01703       \textcolor{keywordflow}{if} (.not.file\_exists(filename, g%Domain)) \textcolor{keyword}{call }mom\_error(fatal, &
01704            \textcolor{stringliteral}{" initialize\_shelf\_mass: Unable to open "}//trim(filename))
01705 
01706     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"zero"})
01707       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01708         iss%mass\_shelf(i,j) = 0.0
01709         iss%area\_shelf\_h(i,j) = 0.0
01710 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
01711 
01712     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"USER"})
01713       \textcolor{keyword}{call }user\_initialize\_shelf\_mass(iss%mass\_shelf, iss%area\_shelf\_h, &
01714                    iss%h\_shelf, iss%hmask, g, cs%US, cs%user\_CS, param\_file, new\_sim\_2)
01715 
01716 \textcolor{keywordflow}{    case default} ;  \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_ice\_shelf: "}// &
01717       \textcolor{stringliteral}{"Unrecognized ice shelf setup "}//trim(config))
01718 \textcolor{keywordflow}{  end select}
01719 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l00195}{195} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



References \hyperlink{namespacemom__ice__shelf_a8f7eae8642835e30aff99f77f3836945}{add\+\_\+shelf\+\_\+flux()}, \hyperlink{namespacemom__ice__shelf_a0274b25df07d5fa712d038c31f921cbc}{add\+\_\+shelf\+\_\+forces()}, \hyperlink{namespacemom__ice__shelf_a787fc1ef4951b3bb4a7d654efb147fc4}{change\+\_\+thickness\+\_\+using\+\_\+melt()}, \hyperlink{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}{id\+\_\+clock\+\_\+pass}, \hyperlink{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}{id\+\_\+clock\+\_\+shelf}, and \hyperlink{namespacemom__ice__shelf_a6f0fa9f98ac01752ca2983c7e9816097}{update\+\_\+shelf\+\_\+mass()}.


\begin{DoxyCode}
00195   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
00196 \textcolor{comment}{                                                !! describe the surface state of the ocean.  The}
00197 \textcolor{comment}{                                                !! intent is only inout to allow for halo updates.}
00198   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< structure containing pointers to any possible}
00199 \textcolor{comment}{                                                !! thermodynamic or mass-flux forcing fields.}
00200   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{  !< Start time of the fluxes.}
00201   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: time\_step\textcolor{comment}{ !< Length of time over which these fluxes}
00202 \textcolor{comment}{                                                !! will be applied [s].}
00203   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{    !< A pointer to the control structure returned}
00204 \textcolor{comment}{                                                !! by a previous call to initialize\_ice\_shelf.}
00205   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
00206 
00207   \textcolor{comment}{! Local variables}
00208   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: g => null()  \textcolor{comment}{!< The grid structure used by the ice shelf.}
00209   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{!< Pointer to a structure containing}
00210 \textcolor{comment}{                                                 !! various unit conversion factors}
00211   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: iss => null() \textcolor{comment}{!< A structure with elements that describe}
00212 \textcolor{comment}{                                                 !! the ice-shelf state}
00213 
00214   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(CS%grid))} :: &
00215     rhoml, &   !< Ocean mixed layer density [R ~> kg m-3].
00216     dr0\_dt, &  !< Partial derivative of the mixed layer density
00217 \textcolor{comment}{               !< with temperature [R degC-1 ~> kg m-3 degC-1].}
00218     dr0\_ds, &  \textcolor{comment}{!< Partial derivative of the mixed layer density}
00219 \textcolor{comment}{               !< with salinity [R ppt-1 ~> kg m-3 ppt-1].}
00220     p\_int      \textcolor{comment}{!< The pressure at the ice-ocean interface [R L2 T-2 ~> Pa].}
00221 
00222   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(CS%grid),SZJ\_(CS%grid))} :: &
00223     exch\_vel\_t, &  !< Sub-shelf thermal exchange velocity [Z T-1 ~> m s-1]
00224     exch\_vel\_s\textcolor{comment}{     !< Sub-shelf salt exchange velocity [Z T-1 ~> m s-1]}
00225 
00226   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(CS%grid),SZDJ\_(CS%grid))} :: &
00227     mass\_flux\textcolor{comment}{  !< Total mass flux of freshwater across the ice-ocean interface. [R Z L2 T-1 ~> kg/s]}
00228   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(CS%grid),SZDJ\_(CS%grid))} :: &
00229     haline\_driving\textcolor{comment}{ !< (SSS - S\_boundary) ice-ocean}
00230 \textcolor{comment}{               !! interface, positive for melting and negative for freezing.}
00231 \textcolor{comment}{               !! This is computed as part of the ISOMIP diagnostics.}
00232   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{parameter} :: vk    = 0.40\textcolor{comment}{ !< Von Karman's constant - dimensionless}
00233   \textcolor{keywordtype}{real} :: zeta\_n = 0.052\textcolor{comment}{ !> The fraction of the boundary layer over which the}
00234 \textcolor{comment}{               !! viscosity is linearly increasing [nondim]. (Was 1/8. Why?)}
00235   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{parameter} :: rc    = 0.20     \textcolor{comment}{! critical flux Richardson number.}
00236   \textcolor{keywordtype}{real} :: i\_zeta\_n\textcolor{comment}{ !< The inverse of ZETA\_N [nondim].}
00237   \textcolor{keywordtype}{real} :: i\_lf\textcolor{comment}{     !< The inverse of the latent heat of fusion [Q-1 ~> kg J-1].}
00238   \textcolor{keywordtype}{real} :: i\_vk\textcolor{comment}{     !< The inverse of the Von Karman constant [nondim].}
00239   \textcolor{keywordtype}{real} :: pr, sc\textcolor{comment}{   !< The Prandtl number and Schmidt number [nondim].}
00240 
00241   \textcolor{comment}{! 3 equations formulation variables}
00242   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZDI\_(CS%grid),SZDJ\_(CS%grid))} :: &
00243     sbdry\textcolor{comment}{     !< Salinities in the ocean at the interface with the ice shelf [ppt].}
00244   \textcolor{keywordtype}{real} :: sbdry\_it
00245   \textcolor{keywordtype}{real} :: sbdry1, sbdry2
00246   \textcolor{keywordtype}{real} :: s\_a, s\_b, s\_c  \textcolor{comment}{! Variables used to find salt roots}
00247   \textcolor{keywordtype}{real} :: ds\_it\textcolor{comment}{    !< The interface salinity change during an iteration [ppt].}
00248   \textcolor{keywordtype}{real} :: hbl\_neut\textcolor{comment}{ !< The neutral boundary layer thickness [Z ~> m].}
00249   \textcolor{keywordtype}{real} :: hbl\_neut\_h\_molec\textcolor{comment}{ !< The ratio of the neutral boundary layer thickness}
00250 \textcolor{comment}{                   !! to the molecular boundary layer thickness [nondim].}
00251   \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].}
00252   \textcolor{keywordtype}{real} :: wb\_flux\textcolor{comment}{ !< The downward vertical flux of buoyancy just inside the ocean [Z2 T-3 ~> m2 s-3].}
00253   \textcolor{keywordtype}{real} :: db\_ds\textcolor{comment}{   !< The derivative of buoyancy with salinity [Z T-2 ppt-1 ~> m s-2 ppt-1].}
00254   \textcolor{keywordtype}{real} :: db\_dt\textcolor{comment}{   !< The derivative of buoyancy with temperature [Z T-2 degC-1 ~> m s-2 degC-1].}
00255   \textcolor{keywordtype}{real} :: i\_n\_star \textcolor{comment}{! [nondim]}
00256   \textcolor{keywordtype}{real} :: n\_star\_term \textcolor{comment}{! A term in the expression for nstar [T3 Z-2 ~> s3 m-2]}
00257   \textcolor{keywordtype}{real} :: absf     \textcolor{comment}{! The absolute value of the Coriolis parameter [T-1 ~> s-1]}
00258   \textcolor{keywordtype}{real} :: dins\_dwb\textcolor{comment}{ !< The partial derivative of I\_n\_star with wB\_flux, in [T3 Z-2 ~> s3 m-2]}
00259   \textcolor{keywordtype}{real} :: dt\_ustar \textcolor{comment}{! The difference between the the freezing point and the ocean boundary layer}
00260                    \textcolor{comment}{! temperature times the friction velocity [degC Z T-1 ~> degC m s-1]}
00261   \textcolor{keywordtype}{real} :: ds\_ustar \textcolor{comment}{! The difference between the salinity at the ice-ocean interface and the ocean}
00262                    \textcolor{comment}{! boundary layer salinity times the friction velocity [ppt Z T-1 ~> ppt m s-1]}
00263   \textcolor{keywordtype}{real} :: ustar\_h  \textcolor{comment}{! The friction velocity in the water below the ice shelf [Z T-1 ~> m s-1]}
00264   \textcolor{keywordtype}{real} :: gam\_turb \textcolor{comment}{! [nondim]}
00265   \textcolor{keywordtype}{real} :: gam\_mol\_t, gam\_mol\_s \textcolor{comment}{! Relative coefficients of molecular diffusivites [nondim]}
00266   \textcolor{keywordtype}{real} :: rhocp     \textcolor{comment}{! A typical ocean density times the heat capacity of water [Q R ~> J m-3]}
00267   \textcolor{keywordtype}{real} :: ln\_neut
00268   \textcolor{keywordtype}{real} :: mass\_exch \textcolor{comment}{! A mass exchange rate [R Z T-1 ~> kg m-2 s-1]}
00269   \textcolor{keywordtype}{real} :: sb\_min, sb\_max
00270   \textcolor{keywordtype}{real} :: ds\_min, ds\_max
00271   \textcolor{comment}{! Variables used in iterating for wB\_flux.}
00272   \textcolor{keywordtype}{real} :: wb\_flux\_new, ddwb\_dwb\_in
00273   \textcolor{keywordtype}{real} :: i\_gam\_t, i\_gam\_s
00274   \textcolor{keywordtype}{real} :: dg\_dwb   \textcolor{comment}{! The derivative of Gam\_turb with wB [T3 Z-2 ~> s3 m-2]}
00275   \textcolor{keywordtype}{real} :: taux2, tauy2 \textcolor{comment}{! The squared surface stresses [R2 L2 Z2 T-4 ~> Pa2].}
00276   \textcolor{keywordtype}{real} :: u2\_av, v2\_av \textcolor{comment}{! The ice-area weighted average squared ocean velocities [L2 T-2 ~> m2 s-2]}
00277   \textcolor{keywordtype}{real} :: asu1, asu2   \textcolor{comment}{! Ocean areas covered by ice shelves at neighboring u-}
00278   \textcolor{keywordtype}{real} :: asv1, asv2   \textcolor{comment}{! and v-points [L2 ~> m2].}
00279   \textcolor{keywordtype}{real} :: i\_au, i\_av   \textcolor{comment}{! The Adcroft reciprocals of the ice shelf areas at adjacent points [L-2 ~> m-2]}
00280   \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]}
00281   \textcolor{keywordtype}{logical} :: sb\_min\_set, sb\_max\_set
00282   \textcolor{keywordtype}{logical} :: update\_ice\_vel \textcolor{comment}{! If true, it is time to update the ice shelf velocities.}
00283   \textcolor{keywordtype}{logical} :: coupled\_gl     \textcolor{comment}{! If true, the grouding line position is determined based on}
00284                             \textcolor{comment}{! coupled ice-ocean dynamics.}
00285 
00286   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{parameter} :: c2\_3 = 2.0/3.0
00287   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}
00288   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: eosdom \textcolor{comment}{! The i-computational domain for the equation of state}
00289   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, ied, jed, it1, it3
00290 
00291   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: "}// &
00292        \textcolor{stringliteral}{"initialize\_ice\_shelf must be called before shelf\_calc\_flux."})
00293   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_shelf)
00294 
00295   g => cs%grid ; us => cs%US
00296   iss => cs%ISS
00297 
00298   \textcolor{comment}{! useful parameters}
00299   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; ied = g%ied ; jed = g%jed
00300   i\_zeta\_n = 1.0 / zeta\_n
00301   i\_lf = 1.0 / cs%Lat\_fusion
00302   sc = cs%kv\_molec/cs%kd\_molec\_salt
00303   pr = cs%kv\_molec/cs%kd\_molec\_temp
00304   i\_vk = 1.0/vk
00305   rhocp = cs%Rho\_ocn * cs%Cp
00306 
00307   \textcolor{comment}{!first calculate molecular component}
00308   gam\_mol\_t = 12.5 * (pr**c2\_3) - 6.0
00309   gam\_mol\_s = 12.5 * (sc**c2\_3) - 6.0
00310 
00311   \textcolor{comment}{! GMM, zero some fields of the ice shelf structure (ice\_shelf\_CS)}
00312   \textcolor{comment}{! these fields are already set to zero during initialization}
00313   \textcolor{comment}{! However, they seem to be changed somewhere and, for diagnostic}
00314   \textcolor{comment}{! reasons, it is better to set them to zero again.}
00315   exch\_vel\_t(:,:) = 0.0 ; exch\_vel\_s(:,:) = 0.0
00316   iss%tflux\_shelf(:,:) = 0.0 ; iss%water\_flux(:,:) = 0.0
00317   iss%salt\_flux(:,:) = 0.0 ; iss%tflux\_ocn(:,:) = 0.0 ; iss%tfreeze(:,:) = 0.0
00318   \textcolor{comment}{! define Sbdry to avoid Run-Time Check Failure, when melt is not computed.}
00319   haline\_driving(:,:) = 0.0
00320   sbdry(:,:) = sfc\_state%sss(:,:)
00321 
00322   \textcolor{comment}{!update time}
00323   cs%Time = time
00324 
00325   \textcolor{keywordflow}{if} (cs%override\_shelf\_movement) \textcolor{keywordflow}{then}
00326     cs%time\_step = time\_step
00327     \textcolor{comment}{! update shelf mass}
00328     \textcolor{keywordflow}{if} (cs%mass\_from\_file) \textcolor{keyword}{call }update\_shelf\_mass(g, us, cs, iss, time)
00329 \textcolor{keywordflow}{  endif}
00330 
00331   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00332     \textcolor{keyword}{call }hchksum(fluxes%frac\_shelf\_h, \textcolor{stringliteral}{"frac\_shelf\_h before apply melting"}, g%HI, haloshift=0)
00333     \textcolor{keyword}{call }hchksum(sfc\_state%sst, \textcolor{stringliteral}{"sst before apply melting"}, g%HI, haloshift=0)
00334     \textcolor{keyword}{call }hchksum(sfc\_state%sss, \textcolor{stringliteral}{"sss before apply melting"}, g%HI, haloshift=0)
00335     \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)
00336     \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)
00337     \textcolor{keyword}{call }hchksum(sfc\_state%ocean\_mass, \textcolor{stringliteral}{"ocean\_mass before apply melting"}, g%HI, haloshift=0, &
00338                  scale=us%RZ\_to\_kg\_m2)
00339 \textcolor{keywordflow}{  endif}
00340 
00341   \textcolor{comment}{! Calculate the friction velocity under ice shelves, using taux\_shelf and tauy\_shelf if possible.}
00342   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%taux\_shelf) .and. \textcolor{keyword}{allocated}(sfc\_state%tauy\_shelf)) \textcolor{keywordflow}{then}
00343     \textcolor{keyword}{call }pass\_vector(sfc\_state%taux\_shelf, sfc\_state%tauy\_shelf, g%domain, to\_all, cgrid\_ne)
00344 \textcolor{keywordflow}{  endif}
00345   irho0 = us%Z\_to\_L / cs%Rho\_ocn
00346   \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}
00347     taux2 = 0.0 ; tauy2 = 0.0 ; u2\_av = 0.0 ; v2\_av = 0.0
00348     asu1 = (iss%area\_shelf\_h(i-1,j) + iss%area\_shelf\_h(i,j))
00349     asu2 = (iss%area\_shelf\_h(i,j) + iss%area\_shelf\_h(i+1,j))
00350     asv1 = (iss%area\_shelf\_h(i,j-1) + iss%area\_shelf\_h(i,j))
00351     asv2 = (iss%area\_shelf\_h(i,j) + iss%area\_shelf\_h(i,j+1))
00352     i\_au = 0.0 ; \textcolor{keywordflow}{if} (asu1 + asu2 > 0.0) i\_au = 1.0 / (asu1 + asu2)
00353     i\_av = 0.0 ; \textcolor{keywordflow}{if} (asv1 + asv2 > 0.0) i\_av = 1.0 / (asv1 + asv2)
00354     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%taux\_shelf) .and. \textcolor{keyword}{allocated}(sfc\_state%tauy\_shelf)) \textcolor{keywordflow}{then}
00355       taux2 = (asu1 * sfc\_state%taux\_shelf(i-1,j)**2 + asu2 * sfc\_state%taux\_shelf(i,j)**2  ) * i\_au
00356       tauy2 = (asv1 * sfc\_state%tauy\_shelf(i,j-1)**2 + asv2 * sfc\_state%tauy\_shelf(i,j)**2  ) * i\_av
00357 \textcolor{keywordflow}{    endif}
00358     u2\_av = (asu1 * sfc\_state%u(i-1,j)**2 + asu2 * sfc\_state%u(i,j)**2) * i\_au
00359     v2\_av = (asv1 * sfc\_state%v(i,j-1)**2 + asu2 * sfc\_state%v(i,j)**2) * i\_av
00360 
00361     \textcolor{keywordflow}{if} (taux2 + tauy2 > 0.0) \textcolor{keywordflow}{then}
00362       fluxes%ustar\_shelf(i,j) = max(cs%ustar\_bg, us%L\_to\_Z * &
00363           sqrt(irho0 * sqrt(taux2 + tauy2) + cs%cdrag*cs%utide(i,j)**2))
00364     \textcolor{keywordflow}{else}   \textcolor{comment}{! Take care of the cases when taux\_shelf is not set or not allocated.}
00365       fluxes%ustar\_shelf(i,j) = max(cs%ustar\_bg, us%L\_TO\_Z * &
00366           sqrt(cs%cdrag*((u2\_av + v2\_av) + cs%utide(i,j)**2)))
00367 \textcolor{keywordflow}{    endif}
00368   \textcolor{keywordflow}{else} \textcolor{comment}{! There is no shelf here.}
00369     fluxes%ustar\_shelf(i,j) = 0.0
00370 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00371 
00372   eosdom(:) = eos\_domain(g%HI)
00373   \textcolor{keywordflow}{do} j=js,je
00374     \textcolor{comment}{! Find the pressure at the ice-ocean interface, averaged only over the}
00375     \textcolor{comment}{! part of the cell covered by ice shelf.}
00376     \textcolor{keywordflow}{do} i=is,ie ; p\_int(i) = cs%g\_Earth * iss%mass\_shelf(i,j) ;\textcolor{keywordflow}{ enddo}
00377 
00378     \textcolor{comment}{! Calculate insitu densities and expansion coefficients}
00379     \textcolor{keyword}{call }calculate\_density(sfc\_state%sst(:,j), sfc\_state%sss(:,j), p\_int, rhoml(:), &
00380                                  cs%eqn\_of\_state, eosdom)
00381     \textcolor{keyword}{call }calculate\_density\_derivs(sfc\_state%sst(:,j), sfc\_state%sss(:,j), p\_int, dr0\_dt, dr0\_ds, &
00382                                  cs%eqn\_of\_state, eosdom)
00383 
00384     \textcolor{keywordflow}{do} i=is,ie
00385       \textcolor{keywordflow}{if} ((sfc\_state%ocean\_mass(i,j) > cs%col\_mass\_melt\_threshold) .and. &
00386           (iss%area\_shelf\_h(i,j) > 0.0) .and. cs%isthermo) \textcolor{keywordflow}{then}
00387 
00388         \textcolor{keywordflow}{if} (cs%threeeq) \textcolor{keywordflow}{then}
00389           \textcolor{comment}{!   Iteratively determine a self-consistent set of fluxes, with the ocean}
00390           \textcolor{comment}{! salinity just below the ice-shelf as the variable that is being}
00391           \textcolor{comment}{! iterated for.}
00392 
00393           ustar\_h = fluxes%ustar\_shelf(i,j)
00394 
00395           \textcolor{comment}{! Estimate the neutral ocean boundary layer thickness as the minimum of the}
00396           \textcolor{comment}{! reported ocean mixed layer thickness and the neutral Ekman depth.}
00397           absf = 0.25*((abs(g%CoriolisBu(i,j)) + abs(g%CoriolisBu(i-1,j-1))) + &
00398                                  (abs(g%CoriolisBu(i,j-1)) + abs(g%CoriolisBu(i-1,j))))
00399           \textcolor{keywordflow}{if} (absf*sfc\_state%Hml(i,j) <= vk*ustar\_h) \textcolor{keywordflow}{then} ; hbl\_neut = sfc\_state%Hml(i,j)
00400           \textcolor{keywordflow}{else} ; hbl\_neut = (vk*ustar\_h) / absf ;\textcolor{keywordflow}{ endif}
00401           hbl\_neut\_h\_molec = zeta\_n * ((hbl\_neut * ustar\_h) / (5.0 * cs%kv\_molec))
00402 
00403           \textcolor{comment}{! Determine the mixed layer buoyancy flux, wB\_flux.}
00404           db\_ds = (us%L\_to\_Z**2*cs%g\_Earth / rhoml(i)) * dr0\_ds(i)
00405           db\_dt = (us%L\_to\_Z**2*cs%g\_Earth / rhoml(i)) * dr0\_dt(i)
00406           ln\_neut = 0.0 ; \textcolor{keywordflow}{if} (hbl\_neut\_h\_molec > 1.0) ln\_neut = log(hbl\_neut\_h\_molec)
00407 
00408           \textcolor{keywordflow}{if} (cs%find\_salt\_root) \textcolor{keywordflow}{then}
00409             \textcolor{comment}{! Solve for the skin salinity using the linearized liquidus parameters and}
00410             \textcolor{comment}{! balancing the turbulent fresh water flux in the near-boundary layer with}
00411             \textcolor{comment}{! the net fresh water or salt added by melting:}
00412             \textcolor{comment}{! (Cp/Lat\_fusion)*Gamma\_T\_3Eq*(TFr\_skin-T\_ocn) = Gamma\_S\_3Eq*(S\_skin-S\_ocn)/S\_skin}
00413 
00414             \textcolor{comment}{! S\_a is always < 0.0 with a realistic expression for the freezing point.}
00415             s\_a = cs%dTFr\_dS * cs%Gamma\_T\_3EQ * cs%Cp
00416             s\_b = cs%Gamma\_T\_3EQ*cs%Cp*(cs%TFr\_0\_0 + cs%dTFr\_dp*p\_int(i) - sfc\_state%sst(i,j)) - &
00417                   cs%Lat\_fusion * cs%Gamma\_S\_3EQ    \textcolor{comment}{! S\_b Can take either sign, but is usually negative.}
00418             s\_c = cs%Lat\_fusion * cs%Gamma\_S\_3EQ * sfc\_state%sss(i,j) \textcolor{comment}{! Always >= 0}
00419 
00420             \textcolor{keywordflow}{if} (s\_c == 0.0) \textcolor{keywordflow}{then}  \textcolor{comment}{! The solution for fresh water.}
00421               sbdry(i,j) = 0.0
00422             \textcolor{keywordflow}{elseif} (s\_a < 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! This is the usual ocean case}
00423               \textcolor{keywordflow}{if} (s\_b < 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! This is almost always the case}
00424                 sbdry(i,j) = 2.0*s\_c / (-s\_b + sqrt(s\_b*s\_b - 4.*s\_a*s\_c))
00425               \textcolor{keywordflow}{else}
00426                 sbdry(i,j) = (s\_b + sqrt(s\_b*s\_b - 4.*s\_a*s\_c)) / (-2.*s\_a)
00427 \textcolor{keywordflow}{              endif}
00428             \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.}
00429               sbdry(i,j) = -s\_c / s\_b
00430             \textcolor{keywordflow}{else}
00431               \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Impossible conditions found in 3-equation skin salinity calculation."})
00432 \textcolor{keywordflow}{            endif}
00433 
00434             \textcolor{comment}{! Safety check}
00435             \textcolor{keywordflow}{if} (sbdry(i,j) < 0.) \textcolor{keywordflow}{then}
00436               \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
00437               \textcolor{keyword}{call }mom\_error(warning, mesg, .true.)
00438               \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'I,J,Sbdry1,Sbdry2'},i,j,sbdry1,sbdry2
00439               \textcolor{keyword}{call }mom\_error(warning, mesg, .true.)
00440               \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: Negative salinity (Sbdry)."})
00441 \textcolor{keywordflow}{            endif}
00442           \textcolor{keywordflow}{else}
00443             \textcolor{comment}{! Guess sss as the iteration starting point for the boundary salinity.}
00444             sbdry(i,j) = sfc\_state%sss(i,j) ; sb\_max\_set = .false.
00445             sb\_min\_set = .false.
00446 \textcolor{keywordflow}{          endif} \textcolor{comment}{!find\_salt\_root}
00447 
00448           \textcolor{keywordflow}{do} it1 = 1,20
00449             \textcolor{comment}{! Determine the potential temperature at the ice-ocean interface.}
00450             \textcolor{keyword}{call }calculate\_tfreeze(sbdry(i,j), p\_int(i), iss%tfreeze(i,j), cs%eqn\_of\_state, &
00451                                    pres\_scale=us%RL2\_T2\_to\_Pa)
00452 
00453             dt\_ustar = (iss%tfreeze(i,j) - sfc\_state%sst(i,j)) * ustar\_h
00454             ds\_ustar = (sbdry(i,j) - sfc\_state%sss(i,j)) * ustar\_h
00455 
00456             \textcolor{comment}{! First, determine the buoyancy flux assuming no effects of stability}
00457             \textcolor{comment}{! on the turbulence.  Following H & J '99, this limit also applies}
00458             \textcolor{comment}{! when the buoyancy flux is destabilizing.}
00459 
00460             \textcolor{keywordflow}{if} (cs%const\_gamma) \textcolor{keywordflow}{then} \textcolor{comment}{! if using a constant gamma\_T}
00461               \textcolor{comment}{! note the different form, here I\_Gam\_T is NOT 1/Gam\_T!}
00462               i\_gam\_t = cs%Gamma\_T\_3EQ
00463               i\_gam\_s = cs%Gamma\_S\_3EQ
00464             \textcolor{keywordflow}{else}
00465               gam\_turb = i\_vk * (ln\_neut + (0.5 * i\_zeta\_n - 1.0))
00466               i\_gam\_t = 1.0 / (gam\_mol\_t + gam\_turb)
00467               i\_gam\_s = 1.0 / (gam\_mol\_s + gam\_turb)
00468 \textcolor{keywordflow}{            endif}
00469 
00470             wt\_flux = dt\_ustar * i\_gam\_t
00471             wb\_flux = db\_ds * (ds\_ustar * i\_gam\_s) + db\_dt * wt\_flux
00472 
00473             \textcolor{keywordflow}{if} (wb\_flux < 0.0) \textcolor{keywordflow}{then}
00474               \textcolor{comment}{! The buoyancy flux is stabilizing and will reduce the tubulent}
00475               \textcolor{comment}{! fluxes, and iteration is required.}
00476               n\_star\_term = (zeta\_n/rc) * (hbl\_neut * vk) / (ustar\_h)**3
00477               \textcolor{keywordflow}{do} it3 = 1,30
00478                \textcolor{comment}{! n\_star <= 1.0 is the ratio of working boundary layer thickness}
00479                \textcolor{comment}{! to the neutral thickness.}
00480                \textcolor{comment}{! hBL = n\_star*hBL\_neut ; hSub = 1/8*n\_star*hBL}
00481 
00482                 i\_n\_star = sqrt(1.0 - n\_star\_term * wb\_flux)
00483                 dins\_dwb = 0.5 * n\_star\_term / i\_n\_star
00484                 \textcolor{keywordflow}{if} (hbl\_neut\_h\_molec > i\_n\_star**2) \textcolor{keywordflow}{then}
00485                   gam\_turb = i\_vk * ((ln\_neut - 2.0*log(i\_n\_star)) + &
00486                                     (0.5*i\_zeta\_n*i\_n\_star - 1.0))
00487                   dg\_dwb =  i\_vk * ( -2.0 / i\_n\_star + (0.5 * i\_zeta\_n)) * dins\_dwb
00488                 \textcolor{keywordflow}{else}
00489                   \textcolor{comment}{!   The layer dominated by molecular viscosity is smaller than}
00490                   \textcolor{comment}{! the assumed boundary layer.  This should be rare!}
00491                   gam\_turb = i\_vk * (0.5 * i\_zeta\_n*i\_n\_star - 1.0)
00492                   dg\_dwb = i\_vk * (0.5 * i\_zeta\_n) * dins\_dwb
00493 \textcolor{keywordflow}{                endif}
00494 
00495                 \textcolor{keywordflow}{if} (cs%const\_gamma) \textcolor{keywordflow}{then} \textcolor{comment}{! if using a constant gamma\_T}
00496                   \textcolor{comment}{! note the different form, here I\_Gam\_T is NOT 1/Gam\_T!}
00497                   i\_gam\_t = cs%Gamma\_T\_3EQ
00498                   i\_gam\_s = cs%Gamma\_S\_3EQ
00499                 \textcolor{keywordflow}{else}
00500                   i\_gam\_t = 1.0 / (gam\_mol\_t + gam\_turb)
00501                   i\_gam\_s = 1.0 / (gam\_mol\_s + gam\_turb)
00502 \textcolor{keywordflow}{                endif}
00503 
00504                 wt\_flux = dt\_ustar * i\_gam\_t
00505                 wb\_flux\_new = db\_ds * (ds\_ustar * i\_gam\_s) + db\_dt * wt\_flux
00506 
00507                 \textcolor{comment}{! Find the root where wB\_flux\_new = wB\_flux.  Make the 1.0e-4 below into a parameter?}
00508                 \textcolor{keywordflow}{if} (abs(wb\_flux\_new - wb\_flux) < 1.0e-4*(abs(wb\_flux\_new) + abs(wb\_flux))) \textcolor{keywordflow}{exit}
00509 
00510                 ddwb\_dwb\_in = dg\_dwb * (db\_ds * (ds\_ustar * i\_gam\_s**2) + &
00511                                         db\_dt * (dt\_ustar * i\_gam\_t**2)) - 1.0
00512                 \textcolor{comment}{! This is Newton's method without any bounds.  Should bounds be needed?}
00513                 wb\_flux\_new = wb\_flux - (wb\_flux\_new - wb\_flux) / ddwb\_dwb\_in
00514 \textcolor{keywordflow}{              enddo} \textcolor{comment}{!it3}
00515 \textcolor{keywordflow}{            endif}
00516 
00517             iss%tflux\_ocn(i,j)  = rhocp * wt\_flux
00518             exch\_vel\_t(i,j) = ustar\_h * i\_gam\_t
00519             exch\_vel\_s(i,j) = ustar\_h * i\_gam\_s
00520 
00521             \textcolor{comment}{! Calculate the heat flux inside the ice shelf.}
00522             \textcolor{comment}{! Vertical adv/diff as in H+J 1999, eqns (26) & approx from (31).}
00523             \textcolor{comment}{!   Q\_ice = density\_ice * CS%Cp\_ice * K\_ice * dT/dz (at interface)}
00524             \textcolor{comment}{! vertical adv/diff as in H+J 1999, eqs (31) & (26)...}
00525             \textcolor{comment}{!   dT/dz ~= min( (lprec/(density\_ice*K\_ice))*(CS%Temp\_Ice-T\_freeze) , 0.0 )}
00526             \textcolor{comment}{! If this approximation is not made, iterations are required... See H+J Fig 3.}
00527 
00528             \textcolor{keywordflow}{if} (iss%tflux\_ocn(i,j) >= 0.0) \textcolor{keywordflow}{then}
00529               \textcolor{comment}{! Freezing occurs due to downward ocean heat flux, so zero iout ce heat flux.}
00530               iss%water\_flux(i,j) = -i\_lf * iss%tflux\_ocn(i,j)
00531               iss%tflux\_shelf(i,j) = 0.0
00532             \textcolor{keywordflow}{else}
00533               \textcolor{keywordflow}{if} (cs%insulator) \textcolor{keywordflow}{then}
00534                 \textcolor{comment}{!no conduction/perfect insulator}
00535                 iss%tflux\_shelf(i,j) = 0.0
00536                 iss%water\_flux(i,j) = i\_lf * (iss%tflux\_shelf(i,j) - iss%tflux\_ocn(i,j))
00537 
00538               \textcolor{keywordflow}{else}
00539                 \textcolor{comment}{! With melting, from H&J 1999, eqs (31) & (26)...}
00540                 \textcolor{comment}{!   Q\_ice ~= Cp\_ice * (CS%Temp\_Ice-T\_freeze) * lprec}
00541                 \textcolor{comment}{!   RhoLF*lprec = Q\_ice - ISS%tflux\_ocn(i,j)}
00542                 \textcolor{comment}{!   lprec = -(ISS%tflux\_ocn(i,j)) / (CS%Lat\_fusion + Cp\_ice * (T\_freeze-CS%Temp\_Ice))}
00543                 iss%water\_flux(i,j) = -iss%tflux\_ocn(i,j) / &
00544                      (cs%Lat\_fusion + cs%Cp\_ice * (iss%tfreeze(i,j) - cs%Temp\_Ice))
00545 
00546                 iss%tflux\_shelf(i,j) = iss%tflux\_ocn(i,j) + cs%Lat\_fusion*iss%water\_flux(i,j)
00547 \textcolor{keywordflow}{              endif}
00548 
00549 \textcolor{keywordflow}{            endif}
00550             \textcolor{comment}{!other options: dTi/dz linear through shelf, with draft in [Z ~> m], KTI in [Z2 T-1 ~> m2 s-1]}
00551             \textcolor{comment}{!    dTi\_dz = (CS%Temp\_Ice - ISS%tfreeze(i,j)) / draft(i,j)}
00552             \textcolor{comment}{!    ISS%tflux\_shelf(i,j) = Rho\_Ice * CS%Cp\_ice * KTI * dTi\_dz}
00553 
00554 
00555             \textcolor{keywordflow}{if} (cs%find\_salt\_root) \textcolor{keywordflow}{then}
00556               \textcolor{keywordflow}{exit} \textcolor{comment}{! no need to do interaction, so exit loop}
00557             \textcolor{keywordflow}{else}
00558 
00559               mass\_exch = exch\_vel\_s(i,j) * cs%Rho\_ocn
00560               sbdry\_it = (sfc\_state%sss(i,j) * mass\_exch + cs%Salin\_ice * iss%water\_flux(i,j)) / &
00561                          (mass\_exch + iss%water\_flux(i,j))
00562               ds\_it = sbdry\_it - sbdry(i,j)
00563               \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}
00564 
00565 
00566               \textcolor{keywordflow}{if} (ds\_it < 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! Sbdry is now the upper bound.}
00567                 \textcolor{keywordflow}{if} (sb\_max\_set .and. (sbdry(i,j) > sb\_max)) &
00568                   \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"shelf\_calc\_flux: Irregular iteration for Sbdry (max)."})
00569                 sb\_max = sbdry(i,j) ; ds\_max = ds\_it ; sb\_max\_set = .true.
00570               \textcolor{keywordflow}{else} \textcolor{comment}{! Sbdry is now the lower bound.}
00571                 \textcolor{keywordflow}{if} (sb\_min\_set .and. (sbdry(i,j) < sb\_min)) &
00572                    \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: Irregular iteration for Sbdry (min)."})
00573                  sb\_min = sbdry(i,j) ; ds\_min = ds\_it ; sb\_min\_set = .true.
00574 \textcolor{keywordflow}{              endif} \textcolor{comment}{! dS\_it < 0.0}
00575 
00576               \textcolor{keywordflow}{if} (sb\_min\_set .and. sb\_max\_set) \textcolor{keywordflow}{then}
00577                 \textcolor{comment}{! Use the false position method for the next iteration.}
00578                 sbdry(i,j) = sb\_min + (sb\_max-sb\_min) * (ds\_min / (ds\_min - ds\_max))
00579               \textcolor{keywordflow}{else}
00580                 sbdry(i,j) = sbdry\_it
00581 \textcolor{keywordflow}{              endif} \textcolor{comment}{! Sb\_min\_set}
00582 
00583               sbdry(i,j) = sbdry\_it
00584 \textcolor{keywordflow}{            endif} \textcolor{comment}{! CS%find\_salt\_root}
00585 
00586 \textcolor{keywordflow}{          enddo} \textcolor{comment}{!it1}
00587           \textcolor{comment}{! Check for non-convergence and/or non-boundedness?}
00588 
00589         \textcolor{keywordflow}{else}
00590           \textcolor{comment}{!   In the 2-equation form, the mixed layer turbulent exchange velocity}
00591           \textcolor{comment}{! is specified and large enough that the ocean salinity at the interface}
00592           \textcolor{comment}{! is about the same as the boundary layer salinity.}
00593 
00594           \textcolor{keyword}{call }calculate\_tfreeze(sfc\_state%sss(i,j), p\_int(i), iss%tfreeze(i,j), cs%eqn\_of\_state, &
00595                                  pres\_scale=us%RL2\_T2\_to\_Pa)
00596 
00597           exch\_vel\_t(i,j) = cs%gamma\_t
00598           iss%tflux\_ocn(i,j) = rhocp * exch\_vel\_t(i,j) * (iss%tfreeze(i,j) - sfc\_state%sst(i,j))
00599           iss%tflux\_shelf(i,j) = 0.0
00600           iss%water\_flux(i,j) = -i\_lf * iss%tflux\_ocn(i,j)
00601           sbdry(i,j) = 0.0
00602 \textcolor{keywordflow}{        endif}
00603       \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.}
00604         iss%tflux\_ocn(i,j) = 0.0
00605       \textcolor{keywordflow}{else} \textcolor{comment}{! There is no ice shelf or sheet here.}
00606         iss%tflux\_ocn(i,j) = 0.0
00607 \textcolor{keywordflow}{      endif}
00608 
00609 \textcolor{comment}{!      haline\_driving(i,j) = sfc\_state%sss(i,j) - Sbdry(i,j)}
00610 
00611 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! i-loop}
00612 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! j-loop}
00613 
00614 
00615   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
00616     \textcolor{comment}{! ISS%water\_flux = net liquid water into the ocean [R Z T-1 ~> kg m-2 s-1]}
00617     fluxes%iceshelf\_melt(i,j) = iss%water\_flux(i,j) * cs%flux\_factor
00618 
00619     \textcolor{keywordflow}{if} ((sfc\_state%ocean\_mass(i,j) > cs%col\_mass\_melt\_threshold) .and. &
00620         (iss%area\_shelf\_h(i,j) > 0.0) .and.  (cs%isthermo)) \textcolor{keywordflow}{then}
00621 
00622       \textcolor{comment}{! Set melt to zero above a cutoff pressure (CS%Rho\_ocn*CS%cutoff\_depth*CS%g\_Earth).}
00623       \textcolor{comment}{! This is needed for the ISOMIP test case.}
00624       \textcolor{keywordflow}{if} (iss%mass\_shelf(i,j) < cs%Rho\_ocn*cs%cutoff\_depth) \textcolor{keywordflow}{then}
00625         iss%water\_flux(i,j) = 0.0
00626         fluxes%iceshelf\_melt(i,j) = 0.0
00627 \textcolor{keywordflow}{      endif}
00628       \textcolor{comment}{! Compute haline driving, which is one of the diags. used in ISOMIP}
00629       haline\_driving(i,j) = (iss%water\_flux(i,j) * sbdry(i,j)) / (cs%Rho\_ocn * exch\_vel\_s(i,j))
00630 
00631       \textcolor{comment}{!!!!!!!!!!!!!!!!!!!!!!!!!!!!Safety checks !!!!!!!!!!!!!!!!!!!!!!!!!}
00632       \textcolor{comment}{!1)Check if haline\_driving computed above is consistent with}
00633       \textcolor{comment}{! haline\_driving = sfc\_state%sss - Sbdry}
00634       \textcolor{comment}{!if (fluxes%iceshelf\_melt(i,j) /= 0.0) then}
00635       \textcolor{comment}{!   if (haline\_driving(i,j) /= (sfc\_state%sss(i,j) - Sbdry(i,j))) then}
00636       \textcolor{comment}{!     write(mesg,*) 'at i,j=',i,j,' haline\_driving, sss-Sbdry',haline\_driving(i,j), &}
00637       \textcolor{comment}{!                   (sfc\_state%sss(i,j) - Sbdry(i,j))}
00638       \textcolor{comment}{!     call MOM\_error(FATAL, &}
00639       \textcolor{comment}{!            "shelf\_calc\_flux: Inconsistency in melt and haline\_driving"//trim(mesg))}
00640       \textcolor{comment}{!   endif}
00641       \textcolor{comment}{!endif}
00642 
00643       \textcolor{comment}{! 2) check if |melt| > 0 when ustar\_shelf = 0.}
00644       \textcolor{comment}{! this should never happen}
00645       \textcolor{keywordflow}{if} ((abs(fluxes%iceshelf\_melt(i,j))>0.0) .and. (fluxes%ustar\_shelf(i,j) == 0.0)) \textcolor{keywordflow}{then}
00646         \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{"|melt| = "},fluxes%iceshelf\_melt(i,j),\textcolor{stringliteral}{" > 0 and ustar\_shelf = 0. at i,j"}, i, j
00647         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"shelf\_calc\_flux: "}//trim(mesg))
00648 \textcolor{keywordflow}{      endif}
00649        \textcolor{comment}{!!!!!!!!!!!!!!!!!!!!!!!!!!!!End of safety checks !!!!!!!!!!!!!!!!!!!}
00650     \textcolor{keywordflow}{elseif} (iss%area\_shelf\_h(i,j) > 0.0) \textcolor{keywordflow}{then}
00651       \textcolor{comment}{! This is grounded ice, that could be modified to melt if a geothermal heat flux were used.}
00652       haline\_driving(i,j) = 0.0
00653       iss%water\_flux(i,j) = 0.0
00654       fluxes%iceshelf\_melt(i,j) = 0.0
00655 \textcolor{keywordflow}{    endif} \textcolor{comment}{! area\_shelf\_h}
00656 
00657     \textcolor{comment}{! mass flux [R Z L2 T-1 ~> kg s-1], part of ISOMIP diags.}
00658     mass\_flux(i,j) = iss%water\_flux(i,j) * iss%area\_shelf\_h(i,j)
00659 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{! i- and j-loops}
00660 
00661   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics .or. cs%override\_shelf\_movement) \textcolor{keywordflow}{then}
00662     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)
00663     \textcolor{keyword}{call }pass\_var(iss%area\_shelf\_h, g%domain, complete=.false.)
00664     \textcolor{keyword}{call }pass\_var(iss%mass\_shelf, g%domain)
00665     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)
00666 \textcolor{keywordflow}{  endif}
00667 
00668   \textcolor{comment}{! Melting has been computed, now is time to update thickness and mass}
00669   \textcolor{keywordflow}{if} ( cs%override\_shelf\_movement .and. (.not.cs%mass\_from\_file)) \textcolor{keywordflow}{then}
00670     \textcolor{keyword}{call }change\_thickness\_using\_melt(iss, g, us, us%s\_to\_T*time\_step, fluxes, cs%density\_ice, cs%debug)
00671 
00672     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00673       \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)
00674       \textcolor{keyword}{call }hchksum(iss%mass\_shelf, \textcolor{stringliteral}{"mass\_shelf after change thickness using melt"}, g%HI, haloshift=0, &
00675                    scale=us%RZ\_to\_kg\_m2)
00676 \textcolor{keywordflow}{    endif}
00677 \textcolor{keywordflow}{  endif}
00678 
00679   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"Before add shelf flux"}, fluxes, g, cs%US, haloshift=0)
00680 
00681   \textcolor{keyword}{call }add\_shelf\_flux(g, us, cs, sfc\_state, fluxes)
00682 
00683   \textcolor{comment}{! now the thermodynamic data is passed on... time to update the ice dynamic quantities}
00684 
00685   \textcolor{keywordflow}{if} (cs%active\_shelf\_dynamics) \textcolor{keywordflow}{then}
00686     update\_ice\_vel = .false.
00687     coupled\_gl = (cs%GL\_couple .and. .not.cs%solo\_ice\_sheet)
00688 
00689     \textcolor{comment}{! advect the ice shelf, and advance the front. Calving will be in here somewhere as well..}
00690     \textcolor{comment}{! when we decide on how to do it}
00691     \textcolor{keyword}{call }update\_ice\_shelf(cs%dCS, iss, g, us, us%s\_to\_T*time\_step, time, &
00692                           sfc\_state%ocean\_mass, coupled\_gl)
00693 
00694 \textcolor{keywordflow}{  endif}
00695 
00696   \textcolor{keyword}{call }enable\_averaging(time\_step,time,cs%diag)
00697   \textcolor{keywordflow}{if} (cs%id\_shelf\_mass > 0) \textcolor{keyword}{call }post\_data(cs%id\_shelf\_mass, iss%mass\_shelf, cs%diag)
00698   \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)
00699   \textcolor{keywordflow}{if} (cs%id\_ustar\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_ustar\_shelf, fluxes%ustar\_shelf, cs%diag)
00700   \textcolor{keywordflow}{if} (cs%id\_melt > 0) \textcolor{keyword}{call }post\_data(cs%id\_melt, fluxes%iceshelf\_melt, cs%diag)
00701   \textcolor{keywordflow}{if} (cs%id\_thermal\_driving > 0) \textcolor{keyword}{call }post\_data(cs%id\_thermal\_driving, (sfc\_state%sst-iss%tfreeze), cs%diag
      )
00702   \textcolor{keywordflow}{if} (cs%id\_Sbdry > 0) \textcolor{keyword}{call }post\_data(cs%id\_Sbdry, sbdry, cs%diag)
00703   \textcolor{keywordflow}{if} (cs%id\_haline\_driving > 0) \textcolor{keyword}{call }post\_data(cs%id\_haline\_driving, haline\_driving, cs%diag)
00704   \textcolor{keywordflow}{if} (cs%id\_mass\_flux > 0) \textcolor{keyword}{call }post\_data(cs%id\_mass\_flux, mass\_flux, cs%diag)
00705   \textcolor{keywordflow}{if} (cs%id\_u\_ml > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_ml, sfc\_state%u, cs%diag)
00706   \textcolor{keywordflow}{if} (cs%id\_v\_ml > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_ml, sfc\_state%v, cs%diag)
00707   \textcolor{keywordflow}{if} (cs%id\_tfreeze > 0) \textcolor{keyword}{call }post\_data(cs%id\_tfreeze, iss%tfreeze, cs%diag)
00708   \textcolor{keywordflow}{if} (cs%id\_tfl\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_tfl\_shelf, iss%tflux\_shelf, cs%diag)
00709   \textcolor{keywordflow}{if} (cs%id\_exch\_vel\_t > 0) \textcolor{keyword}{call }post\_data(cs%id\_exch\_vel\_t, exch\_vel\_t, cs%diag)
00710   \textcolor{keywordflow}{if} (cs%id\_exch\_vel\_s > 0) \textcolor{keyword}{call }post\_data(cs%id\_exch\_vel\_s, exch\_vel\_s, cs%diag)
00711   \textcolor{keywordflow}{if} (cs%id\_h\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_h\_shelf, iss%h\_shelf, cs%diag)
00712   \textcolor{keywordflow}{if} (cs%id\_h\_mask > 0) \textcolor{keyword}{call }post\_data(cs%id\_h\_mask,iss%hmask,cs%diag)
00713   \textcolor{keyword}{call }disable\_averaging(cs%diag)
00714 
00715   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) \textcolor{keywordflow}{then}
00716     \textcolor{keyword}{call }add\_shelf\_forces(g, us, cs, forces, do\_shelf\_area=(cs%active\_shelf\_dynamics .or. &
00717                                                         cs%override\_shelf\_movement))
00718 \textcolor{keywordflow}{  endif}
00719 
00720   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_shelf)
00721 
00722   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"End of shelf calc flux"}, fluxes, g, cs%US, haloshift=0)
00723 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l01804}{1804} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.


\begin{DoxyCode}
01804   \textcolor{keywordtype}{type}(ice\_shelf\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{      !< A pointer to the ice shelf control structure}
01805   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)}    :: time\_interval\textcolor{comment}{ !< The time interval for this update [s].}
01806   \textcolor{keywordtype}{integer},         \textcolor{keywordtype}{intent(inout)} :: nsteps\textcolor{comment}{  !< The running number of ice shelf steps.}
01807   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(inout)} :: time\textcolor{comment}{    !< The current model time}
01808   \textcolor{keywordtype}{real},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: min\_time\_step\_in\textcolor{comment}{ !< The minimum permitted time step [T ~> s].}
01809 
01810   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: g => null()  \textcolor{comment}{! A pointer to the ocean's grid structure}
01811   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{! Pointer to a structure containing}
01812                                                  \textcolor{comment}{! various unit conversion factors}
01813   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{pointer} :: iss => null() \textcolor{comment}{!< A structure with elements that describe}
01814 \textcolor{comment}{                                          !! the ice-shelf state}
01815   \textcolor{keywordtype}{real} :: remaining\_time    \textcolor{comment}{! The remaining time in this call [T ~> s]}
01816   \textcolor{keywordtype}{real} :: time\_step         \textcolor{comment}{! The internal time step during this call [T ~> s]}
01817   \textcolor{keywordtype}{real} :: min\_time\_step     \textcolor{comment}{! The minimal required timestep that would indicate a fatal problem [T ~> s]}
01818   \textcolor{keywordtype}{character(len=240)} :: mesg
01819   \textcolor{keywordtype}{logical} :: update\_ice\_vel \textcolor{comment}{! If true, it is time to update the ice shelf velocities.}
01820   \textcolor{keywordtype}{logical} :: coupled\_gl     \textcolor{comment}{! If true the grouding line position is determined based on}
01821                             \textcolor{comment}{! coupled ice-ocean dynamics.}
01822   \textcolor{keywordtype}{integer} :: is, iec, js, jec, i, j
01823 
01824   g => cs%grid
01825   us => cs%US
01826   iss => cs%ISS
01827   is = g%isc ; iec = g%iec ; js = g%jsc ; jec = g%jec
01828 
01829   remaining\_time = us%s\_to\_T*time\_type\_to\_real(time\_interval)
01830 
01831   \textcolor{keywordflow}{if} (\textcolor{keyword}{present} (min\_time\_step\_in)) \textcolor{keywordflow}{then}
01832     min\_time\_step = min\_time\_step\_in
01833   \textcolor{keywordflow}{else}
01834     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}
01835 \textcolor{keywordflow}{  endif}
01836 
01837   \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"TIME in ice shelf call, yrs: "}, time\_type\_to\_real(time)/(365. * 86400.)
01838   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"solo\_step\_ice\_shelf: "}//mesg, 5)
01839 
01840   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (remaining\_time > 0.0)
01841     nsteps = nsteps+1
01842 
01843     \textcolor{comment}{! If time\_interval is not too long, this is unnecessary.}
01844     time\_step = min(ice\_time\_step\_cfl(cs%dCS, iss, g), remaining\_time)
01845 
01846     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"Ice model timestep = "}, us%T\_to\_s*time\_step, \textcolor{stringliteral}{" seconds"}
01847     \textcolor{keywordflow}{if} ((time\_step < min\_time\_step) .and. (time\_step < remaining\_time))  \textcolor{keywordflow}{then}
01848       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_ice\_shelf:solo\_step\_ice\_shelf: abnormally small timestep "}//mesg)
01849     \textcolor{keywordflow}{else}
01850       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"solo\_step\_ice\_shelf: "}//mesg, 5)
01851 \textcolor{keywordflow}{    endif}
01852 
01853     remaining\_time = remaining\_time - time\_step
01854 
01855     \textcolor{comment}{! If the last mini-timestep is a day or less, we cannot expect velocities to change by much.}
01856     \textcolor{comment}{! Do not update the velocities if the last step is very short.}
01857     update\_ice\_vel = ((time\_step > min\_time\_step) .or. (remaining\_time > 0.0))
01858     coupled\_gl = .false.
01859 
01860     \textcolor{keyword}{call }update\_ice\_shelf(cs%dCS, iss, g, us, time\_step, time, must\_update\_vel=update\_ice\_vel)
01861 
01862     \textcolor{keyword}{call }enable\_averages(time\_step, time, cs%diag)
01863     \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)
01864     \textcolor{keywordflow}{if} (cs%id\_h\_shelf > 0) \textcolor{keyword}{call }post\_data(cs%id\_h\_shelf, iss%h\_shelf, cs%diag)
01865     \textcolor{keywordflow}{if} (cs%id\_h\_mask > 0) \textcolor{keyword}{call }post\_data(cs%id\_h\_mask, iss%hmask, cs%diag)
01866     \textcolor{keyword}{call }disable\_averaging(cs%diag)
01867 
01868 \textcolor{keywordflow}{  enddo}
01869 
\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 \hyperlink{MOM__ice__shelf_8F90_source_l01724}{1724} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



Referenced by \hyperlink{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}{shelf\+\_\+calc\+\_\+flux()}.


\begin{DoxyCode}
01724   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{   !< The ocean's grid structure.}
01725   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
01726   \textcolor{keywordtype}{type}(ice\_shelf\_cs),    \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{  !< A pointer to the ice shelf control structure}
01727   \textcolor{keywordtype}{type}(ice\_shelf\_state), \textcolor{keywordtype}{intent(inout)} :: iss\textcolor{comment}{ !< The ice shelf state type that is being updated}
01728   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
01729 
01730   \textcolor{comment}{! local variables}
01731   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
01732   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
01733 
01734   \textcolor{keyword}{call }time\_interp\_external(cs%id\_read\_mass, time, iss%mass\_shelf)
01735   \textcolor{comment}{! This should only be done if time\_interp\_external did an update.}
01736   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01737     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}
01738 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01739 
01740   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
01741     iss%area\_shelf\_h(i,j) = 0.0
01742     iss%hmask(i,j) = 0.
01743     \textcolor{keywordflow}{if} (iss%mass\_shelf(i,j) > 0.0) \textcolor{keywordflow}{then}
01744       iss%area\_shelf\_h(i,j) = g%areaT(i,j)
01745       iss%h\_shelf(i,j) = iss%mass\_shelf(i,j) / cs%density\_ice
01746       iss%hmask(i,j) = 1.
01747 \textcolor{keywordflow}{    endif}
01748 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01749 
01750   \textcolor{comment}{!call USER\_update\_shelf\_mass(ISS%mass\_shelf, ISS%area\_shelf\_h, ISS%h\_shelf, &}
01751   \textcolor{comment}{!                            ISS%hmask, CS%grid, CS%user\_CS, Time, .true.)}
01752 
01753   \textcolor{keywordflow}{if} (cs%min\_thickness\_simple\_calve > 0.0) \textcolor{keywordflow}{then}
01754     \textcolor{keyword}{call }ice\_shelf\_min\_thickness\_calve(g, iss%h\_shelf, iss%area\_shelf\_h, iss%hmask, &
01755                                        cs%min\_thickness\_simple\_calve, halo=0)
01756 \textcolor{keywordflow}{  endif}
01757 
01758   \textcolor{keyword}{call }pass\_var(iss%area\_shelf\_h, g%domain)
01759   \textcolor{keyword}{call }pass\_var(iss%h\_shelf, g%domain)
01760   \textcolor{keyword}{call }pass\_var(iss%hmask, g%domain)
01761   \textcolor{keyword}{call }pass\_var(iss%mass\_shelf, g%domain)
01762 
\end{DoxyCode}


\subsection{Variable Documentation}
\mbox{\Hypertarget{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}\label{namespacemom__ice__shelf_a3db8709f10aa77ed302598f3a23a608d}} 
\index{mom\+\_\+ice\+\_\+shelf@{mom\+\_\+ice\+\_\+shelf}!id\+\_\+clock\+\_\+pass@{id\+\_\+clock\+\_\+pass}}
\index{id\+\_\+clock\+\_\+pass@{id\+\_\+clock\+\_\+pass}!mom\+\_\+ice\+\_\+shelf@{mom\+\_\+ice\+\_\+shelf}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+pass}{id\_clock\_pass}}
{\footnotesize\ttfamily integer mom\+\_\+ice\+\_\+shelf\+::id\+\_\+clock\+\_\+pass\hspace{0.3cm}{\ttfamily [private]}}



C\+PU Clock for group pass calls. 



Definition at line \hyperlink{MOM__ice__shelf_8F90_source_l00187}{187} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



Referenced by \hyperlink{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}{initialize\+\_\+ice\+\_\+shelf()}, and \hyperlink{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}{shelf\+\_\+calc\+\_\+flux()}.


\begin{DoxyCode}
00187 \textcolor{keywordtype}{integer} :: id\_clock\_pass\textcolor{comment}{ !< CPU Clock for group pass calls}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}\label{namespacemom__ice__shelf_a5aff3e9a37cb5bc2b5b998bf296437ff}} 
\index{mom\+\_\+ice\+\_\+shelf@{mom\+\_\+ice\+\_\+shelf}!id\+\_\+clock\+\_\+shelf@{id\+\_\+clock\+\_\+shelf}}
\index{id\+\_\+clock\+\_\+shelf@{id\+\_\+clock\+\_\+shelf}!mom\+\_\+ice\+\_\+shelf@{mom\+\_\+ice\+\_\+shelf}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+shelf}{id\_clock\_shelf}}
{\footnotesize\ttfamily integer mom\+\_\+ice\+\_\+shelf\+::id\+\_\+clock\+\_\+shelf}



C\+PU Clock for the ice shelf code. 



Definition at line \hyperlink{MOM__ice__shelf_8F90_source_l00186}{186} of file \hyperlink{MOM__ice__shelf_8F90_source}{M\+O\+M\+\_\+ice\+\_\+shelf.\+F90}.



Referenced by \hyperlink{namespacemom__ice__shelf_a5990f9918493ff4984245eac74e5f4d9}{initialize\+\_\+ice\+\_\+shelf()}, and \hyperlink{namespacemom__ice__shelf_a21a2a3ddec5ea25c7bca246419e4dcfe}{shelf\+\_\+calc\+\_\+flux()}.


\begin{DoxyCode}
00186 \textcolor{keywordtype}{integer} :: id\_clock\_shelf\textcolor{comment}{ !< CPU Clock for the ice shelf code}
\end{DoxyCode}
