\hypertarget{namespacemom__state__initialization}{}\doxysection{mom\+\_\+state\+\_\+initialization Module Reference}
\label{namespacemom__state__initialization}\index{mom\_state\_initialization@{mom\_state\_initialization}}


\doxysubsection{Detailed Description}
Initialization functions for state variables, u, v, h, T and S. \doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__state__initialization_a81503d4f1855cb185f122d6314e4f06c}{mom\+\_\+initialize\+\_\+state}} (u, v, h, tv, Time, G, GV, US, PF, dirs, restart\+\_\+\+CS, A\+L\+E\+\_\+\+C\+Sp, tracer\+\_\+\+Reg, sponge\+\_\+\+C\+Sp, A\+L\+E\+\_\+sponge\+\_\+\+C\+Sp, O\+BC, Time\+\_\+in)
\begin{DoxyCompactList}\small\item\em Initialize temporally evolving fields, either as initial conditions or by reading them from a restart (or saves) file. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a847ac374f69c4777e3e49a5ebdcebf43}{initialize\+\_\+thickness\+\_\+from\+\_\+file}} (h, G, GV, US, param\+\_\+file, file\+\_\+has\+\_\+thickness, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Reads the layer thicknesses or interface heights from a file. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a59cb36440a4ef993c4c98170e52a775f}{adjustetatofitbathymetry}} (G, GV, US, eta, h)
\begin{DoxyCompactList}\small\item\em Adjust interface heights to fit the bathymetry and diagnose layer thickness. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a06f7a21e110b80140439dedccaf4fa1c}{initialize\+\_\+thickness\+\_\+uniform}} (h, G, GV, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes thickness to be uniform. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_ade07252728855ac18a50b547f0cb16f7}{initialize\+\_\+thickness\+\_\+list}} (h, G, GV, US, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initialize thickness from a 1D list. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__state__initialization_a1752fe7b4c2a9878165f5ae77201cd30}\label{namespacemom__state__initialization_a1752fe7b4c2a9878165f5ae77201cd30}} 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a1752fe7b4c2a9878165f5ae77201cd30}{initialize\+\_\+thickness\+\_\+search}}
\begin{DoxyCompactList}\small\item\em Search density space for location of layers (not implemented!) \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a9b4e1b8c587fb11f1ec78e7e30215913}{convert\+\_\+thickness}} (h, G, GV, US, tv)
\begin{DoxyCompactList}\small\item\em Converts thickness from geometric to pressure units. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_aad295781ac5adccf3a80e2323ce77905}{depress\+\_\+surface}} (h, G, GV, US, param\+\_\+file, tv, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Depress the sea-\/surface based on an initial condition file. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_abbe8ee99793eae86251739a8a1bf572f}{trim\+\_\+for\+\_\+ice}} (PF, G, GV, US, A\+L\+E\+\_\+\+C\+Sp, tv, h, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Adjust the layer thicknesses by cutting away the top of each model column at the depth where the hydrostatic pressure matches an imposed surface pressure read from file. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a214d4aa46f0374e29369282389f40de7}{cut\+\_\+off\+\_\+column\+\_\+top}} (nk, tv, GV, US, G\+\_\+earth, depth, min\+\_\+thickness, T, T\+\_\+t, T\+\_\+b, S, S\+\_\+t, S\+\_\+b, p\+\_\+surf, h, remap\+\_\+\+CS, z\+\_\+tol, remap\+\_\+answers\+\_\+2018)
\begin{DoxyCompactList}\small\item\em Adjust the layer thicknesses by removing the top of the water column above the depth where the hydrostatic pressure matches p\+\_\+surf. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_adcedb30eb6f940cef3fbdd4328aedef8}{initialize\+\_\+velocity\+\_\+from\+\_\+file}} (u, v, G, US, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initialize horizontal velocity components from file. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a1de6eb1d89deb76196b2876c8982a956}{initialize\+\_\+velocity\+\_\+zero}} (u, v, G, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initialize horizontal velocity components to zero. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_ac10655a7937f2239ff8ae9b899f4bc4b}{initialize\+\_\+velocity\+\_\+uniform}} (u, v, G, US, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Sets the initial velocity components to uniform. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_af4ebdba67fde58a9aa7633bca4c117ba}{initialize\+\_\+velocity\+\_\+circular}} (u, v, G, US, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Sets the initial velocity components to be circular with no flow at edges of domain and center. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a706c24ba7b8a344152ea0d3da051ceb5}{initialize\+\_\+temp\+\_\+salt\+\_\+from\+\_\+file}} (T, S, G, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes temperature and salinity from file. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a7d627f0ef1dc66acc764a40fd662a758}{initialize\+\_\+temp\+\_\+salt\+\_\+from\+\_\+profile}} (T, S, G, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes temperature and salinity from a 1D profile. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a964fba68510337bdde7636a18f783fc9}{initialize\+\_\+temp\+\_\+salt\+\_\+fit}} (T, S, G, GV, US, param\+\_\+file, eqn\+\_\+of\+\_\+state, P\+\_\+\+Ref, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes temperature and salinity by fitting to density. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a0793ab167463a3bb45114f57cf018a40}{initialize\+\_\+temp\+\_\+salt\+\_\+linear}} (T, S, G, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes T and S with linear profiles according to reference surface layer salinity and temperature and a specified range. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_ac672706eef5c8d6c07333f5e46e4cdff}{initialize\+\_\+sponges\+\_\+file}} (G, GV, US, use\+\_\+temperature, tv, param\+\_\+file, Layer\+\_\+\+C\+Sp, A\+L\+E\+\_\+\+C\+Sp, Time)
\begin{DoxyCompactList}\small\item\em This subroutine sets the inverse restoration time (Idamp), and the values towards which the interface heights and an arbitrary number of tracers should be restored within each sponge. The interface height is always subject to damping, and must always be the first registered field. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_ace20e4d29e01307fc37911d9ce4df2e3}{set\+\_\+velocity\+\_\+depth\+\_\+max}} (G)
\begin{DoxyCompactList}\small\item\em This subroutine sets the 4 bottom depths at velocity points to be the maximum of the adjacent depths. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_aebc1c5c12c684e398074f2f56bc61d97}{compute\+\_\+global\+\_\+grid\+\_\+integrals}} (G, US)
\begin{DoxyCompactList}\small\item\em Subroutine to pre-\/compute global integrals of grid quantities for later use in reporting diagnostics. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a9eda11f130fa39ea833f7b1e4d099c58}{set\+\_\+velocity\+\_\+depth\+\_\+min}} (G)
\begin{DoxyCompactList}\small\item\em This subroutine sets the 4 bottom depths at velocity points to be the minimum of the adjacent depths. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a4b1a2ab2ba01da2b898f5e65ebc30c9d}{mom\+\_\+temp\+\_\+salt\+\_\+initialize\+\_\+from\+\_\+z}} (h, tv, G, GV, US, PF, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em This subroutine determines the isopycnal or other coordinate interfaces and layer potential temperatures and salinities directly from a z-\/space file on a latitude-\/longitude grid. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a526e4ed5e2543f0d7bec8bc0dde37ae2}{find\+\_\+interfaces}} (rho, zin, nk\+\_\+data, Rb, depth, zi, G, US, nlevs, nkml, hml, eps\+\_\+z, eps\+\_\+rho)
\begin{DoxyCompactList}\small\item\em Find interface positions corresponding to interpolated depths in a density profile. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__state__initialization_a807c1c2bb13f172945c7c25f3af7abd1}{mom\+\_\+state\+\_\+init\+\_\+tests}} (G, GV, US, tv)
\begin{DoxyCompactList}\small\item\em Run simple unit tests. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__state__initialization_a0d04f34a0f7ba9ce38686ca2ce005508}\label{namespacemom__state__initialization_a0d04f34a0f7ba9ce38686ca2ce005508}} 
character(len=40) \mbox{\hyperlink{namespacemom__state__initialization_a0d04f34a0f7ba9ce38686ca2ce005508}{mdl}} = \char`\"{}M\+O\+M\+\_\+state\+\_\+initialization\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__state__initialization_a59cb36440a4ef993c4c98170e52a775f}\label{namespacemom__state__initialization_a59cb36440a4ef993c4c98170e52a775f}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!adjustetatofitbathymetry@{adjustetatofitbathymetry}}
\index{adjustetatofitbathymetry@{adjustetatofitbathymetry}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{adjustetatofitbathymetry()}{adjustetatofitbathymetry()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::adjustetatofitbathymetry (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke+1), intent(inout)}]{eta,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(inout)}]{h }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Adjust interface heights to fit the bathymetry and diagnose layer thickness. 

If the bottom most interface is below the topography then the bottom-\/most layers are contracted to GVAngstrom\+\_\+m. If the bottom most interface is above the topography then the entire column is dilated (expanded) to fill the void. \begin{DoxyRemark}{Remarks}
\{There is a (hard-\/wired) \char`\"{}tolerance\char`\"{} parameter such that the criteria for adjustment must equal or exceed 10cm.\} 
\end{DoxyRemark}

\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em eta} & Interface heights \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 712 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{713   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< The ocean's grid structure}}
\DoxyCodeLine{714   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< The ocean's vertical grid structure}}
\DoxyCodeLine{715   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{716 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \textcolor{keywordtype}{intent(inout)} :: eta\textcolor{comment}{ !< Interface heights [Z \string~> m].}}
\DoxyCodeLine{717 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{718   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{719   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, contractions, dilations}
\DoxyCodeLine{720 \textcolor{keywordtype}{  real} :: hTolerance = 0.1\textcolor{comment}{ !<  Tolerance to exceed adjustment criteria [Z \string~> m]}}
\DoxyCodeLine{721 \textcolor{keywordtype}{  real} :: hTmp, eTmp, dilate}
\DoxyCodeLine{722   \textcolor{keywordtype}{character(len=100)} :: mesg}
\DoxyCodeLine{723 }
\DoxyCodeLine{724   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{725   htolerance = 0.1*us\%m\_to\_Z}
\DoxyCodeLine{726 }
\DoxyCodeLine{727   contractions = 0}
\DoxyCodeLine{728   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{729     \textcolor{keywordflow}{if} (-\/eta(i,j,nz+1) > g\%bathyT(i,j) + htolerance) \textcolor{keywordflow}{then}}
\DoxyCodeLine{730       eta(i,j,nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{731       contractions = contractions + 1}
\DoxyCodeLine{732 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{733 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{734   \textcolor{keyword}{call }sum\_across\_pes(contractions)}
\DoxyCodeLine{735   \textcolor{keywordflow}{if} ((contractions > 0) .and. (is\_root\_pe())) \textcolor{keywordflow}{then}}
\DoxyCodeLine{736     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Thickness initial conditions were contracted ",'}// \&}
\DoxyCodeLine{737                \textcolor{stringliteral}{'"to fit topography in ",I8," places.")'}) contractions}
\DoxyCodeLine{738     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{'adjustEtaToFitBathymetry: '}//mesg)}
\DoxyCodeLine{739 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{740 }
\DoxyCodeLine{741   \textcolor{comment}{!   To preserve previous answers in non-\/Boussinesq cases, delay converting}}
\DoxyCodeLine{742   \textcolor{comment}{! thicknesses to units of H until the end of this routine.}}
\DoxyCodeLine{743   \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{744     \textcolor{comment}{! Collapse layers to thinnest possible if the thickness less than}}
\DoxyCodeLine{745     \textcolor{comment}{! the thinnest possible (or negative).}}
\DoxyCodeLine{746     \textcolor{keywordflow}{if} (eta(i,j,k) < (eta(i,j,k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{747       eta(i,j,k) = eta(i,j,k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{748       h(i,j,k) = gv\%Angstrom\_Z}
\DoxyCodeLine{749     \textcolor{keywordflow}{else}}
\DoxyCodeLine{750       h(i,j,k) = (eta(i,j,k) -\/ eta(i,j,k+1))}
\DoxyCodeLine{751 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{752 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{753 }
\DoxyCodeLine{754   dilations = 0}
\DoxyCodeLine{755   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{756     \textcolor{comment}{!   The whole column is dilated to accommodate deeper topography than}}
\DoxyCodeLine{757     \textcolor{comment}{! the bathymetry would indicate.}}
\DoxyCodeLine{758     \textcolor{comment}{! This should be...  if ((G\%mask2dt(i,j)*(eta(i,j,1)-\/eta(i,j,nz+1)) > 0.0) .and. \&}}
\DoxyCodeLine{759     \textcolor{keywordflow}{if} (-\/eta(i,j,nz+1) < g\%bathyT(i,j) -\/ htolerance) \textcolor{keywordflow}{then}}
\DoxyCodeLine{760       dilations = dilations + 1}
\DoxyCodeLine{761       \textcolor{keywordflow}{if} (eta(i,j,1) <= eta(i,j,nz+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{762         \textcolor{keywordflow}{do} k=1,nz ; h(i,j,k) = (eta(i,j,1) + g\%bathyT(i,j)) / real(nz) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{763       \textcolor{keywordflow}{else}}
\DoxyCodeLine{764         dilate = (eta(i,j,1) + g\%bathyT(i,j)) / (eta(i,j,1) -\/ eta(i,j,nz+1))}
\DoxyCodeLine{765         \textcolor{keywordflow}{do} k=1,nz ; h(i,j,k) = h(i,j,k) * dilate ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{766 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{767       \textcolor{keywordflow}{do} k=nz,2,-\/1 ; eta(i,j,k) = eta(i,j,k+1) + h(i,j,k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{768 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{769 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{770 }
\DoxyCodeLine{771   \textcolor{comment}{! Now convert thicknesses to units of H.}}
\DoxyCodeLine{772   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{773     h(i,j,k) = h(i,j,k)*gv\%Z\_to\_H}
\DoxyCodeLine{774 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{775 }
\DoxyCodeLine{776   \textcolor{keyword}{call }sum\_across\_pes(dilations)}
\DoxyCodeLine{777   \textcolor{keywordflow}{if} ((dilations > 0) .and. (is\_root\_pe())) \textcolor{keywordflow}{then}}
\DoxyCodeLine{778     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Thickness initial conditions were dilated ",'}// \&}
\DoxyCodeLine{779                \textcolor{stringliteral}{'"to fit topography in ",I8," places.")'}) dilations}
\DoxyCodeLine{780     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{'adjustEtaToFitBathymetry: '}//mesg)}
\DoxyCodeLine{781 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{782 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_aebc1c5c12c684e398074f2f56bc61d97}\label{namespacemom__state__initialization_aebc1c5c12c684e398074f2f56bc61d97}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!compute\_global\_grid\_integrals@{compute\_global\_grid\_integrals}}
\index{compute\_global\_grid\_integrals@{compute\_global\_grid\_integrals}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{compute\_global\_grid\_integrals()}{compute\_global\_grid\_integrals()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::compute\+\_\+global\+\_\+grid\+\_\+integrals (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Subroutine to pre-\/compute global integrals of grid quantities for later use in reporting diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 1932 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1933   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The ocean's grid structure}}
\DoxyCodeLine{1934   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{1935   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1936 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%isc:G\%iec, G\%jsc:G\%jec)} :: tmpForSumming}
\DoxyCodeLine{1937 \textcolor{keywordtype}{  real} :: area\_scale}
\DoxyCodeLine{1938   \textcolor{keywordtype}{integer} :: i,j}
\DoxyCodeLine{1939 }
\DoxyCodeLine{1940   area\_scale = us\%L\_to\_m**2}
\DoxyCodeLine{1941   tmpforsumming(:,:) = 0.}
\DoxyCodeLine{1942   g\%areaT\_global = 0.0 ; g\%IareaT\_global = 0.0}
\DoxyCodeLine{1943   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1944     tmpforsumming(i,j) = area\_scale*g\%areaT(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{1945 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1946   g\%areaT\_global = \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}(tmpforsumming)}
\DoxyCodeLine{1947   g\%IareaT\_global = 1. / (g\%areaT\_global)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a9b4e1b8c587fb11f1ec78e7e30215913}\label{namespacemom__state__initialization_a9b4e1b8c587fb11f1ec78e7e30215913}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!convert\_thickness@{convert\_thickness}}
\index{convert\_thickness@{convert\_thickness}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{convert\_thickness()}{convert\_thickness()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::convert\+\_\+thickness (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(inout)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Converts thickness from geometric to pressure units. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Input geometric layer thicknesses being converted \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\end{DoxyParams}


Definition at line 922 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{923   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< The ocean's grid structure}}
\DoxyCodeLine{924   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< The ocean's vertical grid structure}}
\DoxyCodeLine{925   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{926 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{927                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{  !< Input geometric layer thicknesses being converted}}
\DoxyCodeLine{928 \textcolor{comment}{                                               !! to layer pressure [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{929   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{ !< A structure pointing to various}}
\DoxyCodeLine{930 \textcolor{comment}{                                               !! thermodynamic variables}}
\DoxyCodeLine{931   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{932 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{933     p\_top, p\_bot                  \textcolor{comment}{! Pressure at the interfaces above and below a layer [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{934 \textcolor{keywordtype}{  real} :: dz\_geo(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! The change in geopotential height across a layer [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{935 \textcolor{keywordtype}{  real} :: rho(SZI\_(G))            \textcolor{comment}{! The in situ density [R \string~> kg m-\/3]}}
\DoxyCodeLine{936 \textcolor{keywordtype}{  real} :: I\_gEarth      \textcolor{comment}{! Unit conversion factors divided by the gravitational acceleration}}
\DoxyCodeLine{937                         \textcolor{comment}{! [H T2 R-\/1 L-\/2 \string~> s2 m2 kg-\/1 or s2 m-\/1]}}
\DoxyCodeLine{938 \textcolor{keywordtype}{  real} :: HR\_to\_pres    \textcolor{comment}{! A conversion factor from the input geometric thicknesses times the layer}}
\DoxyCodeLine{939                         \textcolor{comment}{! densities into pressure units [L2 T-\/2 H-\/1 \string~> m s-\/2 or m4 kg-\/1 s-\/2].}}
\DoxyCodeLine{940   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The i-\/computational domain for the equation of state}}
\DoxyCodeLine{941   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz}
\DoxyCodeLine{942   \textcolor{keywordtype}{integer} :: itt, max\_itt}
\DoxyCodeLine{943 }
\DoxyCodeLine{944   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{945   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{946   max\_itt = 10}
\DoxyCodeLine{947 }
\DoxyCodeLine{948   \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{949     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"Not yet converting thickness with Boussinesq approx."})}
\DoxyCodeLine{950   \textcolor{keywordflow}{else}}
\DoxyCodeLine{951     i\_gearth = gv\%RZ\_to\_H / gv\%g\_Earth}
\DoxyCodeLine{952     hr\_to\_pres = gv\%g\_Earth * gv\%H\_to\_Z}
\DoxyCodeLine{953 }
\DoxyCodeLine{954     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{955       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{956         p\_bot(i,j) = 0.0 ; p\_top(i,j) = 0.0}
\DoxyCodeLine{957 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{958       eosdom(:) = eos\_domain(g\%HI)}
\DoxyCodeLine{959       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{960         \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{961           \textcolor{keywordflow}{do} i=is,ie ; p\_top(i,j) = p\_bot(i,j) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{962           \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,k), tv\%S(:,j,k), p\_top(:,j), rho, \&}
\DoxyCodeLine{963                                  tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{964           \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{965             p\_bot(i,j) = p\_top(i,j) + hr\_to\_pres * (h(i,j,k) * rho(i))}
\DoxyCodeLine{966 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{967 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{968 }
\DoxyCodeLine{969         \textcolor{keywordflow}{do} itt=1,max\_itt}
\DoxyCodeLine{970           \textcolor{keyword}{call }int\_specific\_vol\_dp(tv\%T(:,:,k), tv\%S(:,:,k), p\_top, p\_bot, 0.0, g\%HI, \&}
\DoxyCodeLine{971                                    tv\%eqn\_of\_state, us, dz\_geo)}
\DoxyCodeLine{972           \textcolor{keywordflow}{if} (itt < max\_itt) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{973             \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,k), tv\%S(:,j,k), p\_bot(:,j), rho, \&}
\DoxyCodeLine{974                                    tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{975             \textcolor{comment}{! Use Newton's method to correct the bottom value.}}
\DoxyCodeLine{976             \textcolor{comment}{! The hydrostatic equation is sufficiently linear that no bounds-\/checking is needed.}}
\DoxyCodeLine{977             \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{978               p\_bot(i,j) = p\_bot(i,j) + rho(i) * (hr\_to\_pres*h(i,j,k) -\/ dz\_geo(i,j))}
\DoxyCodeLine{979 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{980 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{981 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{982 }
\DoxyCodeLine{983         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{984           h(i,j,k) = (p\_bot(i,j) -\/ p\_top(i,j)) * i\_gearth}
\DoxyCodeLine{985 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{986 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{987     \textcolor{keywordflow}{else}}
\DoxyCodeLine{988       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{989         h(i,j,k) = h(i,j,k) * (gv\%Rlay(k) / gv\%Rho0)}
\DoxyCodeLine{990 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{991 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{992 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{993 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a214d4aa46f0374e29369282389f40de7}\label{namespacemom__state__initialization_a214d4aa46f0374e29369282389f40de7}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!cut\_off\_column\_top@{cut\_off\_column\_top}}
\index{cut\_off\_column\_top@{cut\_off\_column\_top}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{cut\_off\_column\_top()}{cut\_off\_column\_top()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::cut\+\_\+off\+\_\+column\+\_\+top (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{nk,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{G\+\_\+earth,  }\item[{real, intent(in)}]{depth,  }\item[{real, intent(in)}]{min\+\_\+thickness,  }\item[{real, dimension(nk), intent(inout)}]{T,  }\item[{real, dimension(nk), intent(in)}]{T\+\_\+t,  }\item[{real, dimension(nk), intent(in)}]{T\+\_\+b,  }\item[{real, dimension(nk), intent(inout)}]{S,  }\item[{real, dimension(nk), intent(in)}]{S\+\_\+t,  }\item[{real, dimension(nk), intent(in)}]{S\+\_\+b,  }\item[{real, intent(in)}]{p\+\_\+surf,  }\item[{real, dimension(nk), intent(inout)}]{h,  }\item[{type(remapping\+\_\+cs), pointer}]{remap\+\_\+\+CS,  }\item[{real, intent(in), optional}]{z\+\_\+tol,  }\item[{logical, intent(in), optional}]{remap\+\_\+answers\+\_\+2018 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Adjust the layer thicknesses by removing the top of the water column above the depth where the hydrostatic pressure matches p\+\_\+surf. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em nk} & Number of layers \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamics structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em g\+\_\+earth} & Gravitational acceleration \mbox{[}L2 Z-\/1 T-\/2 $\sim$$>$ m s-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em depth} & Depth of ocean column \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em min\+\_\+thickness} & Smallest thickness allowed \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em t} & Layer mean temperature \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em t\+\_\+t} & Temperature at top of layer \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em t\+\_\+b} & Temperature at bottom of layer \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em s} & Layer mean salinity \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s\+\_\+t} & Salinity at top of layer \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s\+\_\+b} & Salinity at bottom of layer \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em p\+\_\+surf} & Imposed pressure on ocean at surface \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
 & {\em remap\+\_\+cs} & Remapping structure for remapping T and S, if associated \\
\hline
\mbox{\texttt{ in}}  & {\em z\+\_\+tol} & The tolerance with which to find the depth matching the specified pressure \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em remap\+\_\+answers\+\_\+2018} & If true, use the order of arithmetic and expressions that recover the answers for remapping from the end of 2018. Otherwise, use more robust forms of the same expressions. \\
\hline
\end{DoxyParams}


Definition at line 1171 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1173   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: nk\textcolor{comment}{  !< Number of layers}}
\DoxyCodeLine{1174   \textcolor{keywordtype}{type}(thermo\_var\_ptrs), \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{  !< Thermodynamics structure}}
\DoxyCodeLine{1175   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{  !< The ocean's vertical grid structure.}}
\DoxyCodeLine{1176   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1177 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: G\_earth\textcolor{comment}{ !< Gravitational acceleration [L2 Z-\/1 T-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{1178 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: depth\textcolor{comment}{ !< Depth of ocean column [Z \string~> m].}}
\DoxyCodeLine{1179 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: min\_thickness\textcolor{comment}{ !< Smallest thickness allowed [Z \string~> m].}}
\DoxyCodeLine{1180 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)},   \textcolor{keywordtype}{intent(inout)} :: T\textcolor{comment}{   !< Layer mean temperature [degC]}}
\DoxyCodeLine{1181 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)},   \textcolor{keywordtype}{intent(in)}    :: T\_t\textcolor{comment}{ !< Temperature at top of layer [degC]}}
\DoxyCodeLine{1182 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)},   \textcolor{keywordtype}{intent(in)}    :: T\_b\textcolor{comment}{ !< Temperature at bottom of layer [degC]}}
\DoxyCodeLine{1183 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)},   \textcolor{keywordtype}{intent(inout)} :: S\textcolor{comment}{   !< Layer mean salinity [ppt]}}
\DoxyCodeLine{1184 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)},   \textcolor{keywordtype}{intent(in)}    :: S\_t\textcolor{comment}{ !< Salinity at top of layer [ppt]}}
\DoxyCodeLine{1185 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)},   \textcolor{keywordtype}{intent(in)}    :: S\_b\textcolor{comment}{ !< Salinity at bottom of layer [ppt]}}
\DoxyCodeLine{1186 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: p\_surf\textcolor{comment}{ !< Imposed pressure on ocean at surface [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{1187 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)},   \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1188   \textcolor{keywordtype}{type}(remapping\_CS),    \textcolor{keywordtype}{pointer}       :: remap\_CS\textcolor{comment}{ !< Remapping structure for remapping T and S,}}
\DoxyCodeLine{1189 \textcolor{comment}{                                                   !! if associated}}
\DoxyCodeLine{1190 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: z\_tol\textcolor{comment}{ !< The tolerance with which to find the depth}}
\DoxyCodeLine{1191 \textcolor{comment}{                                                !! matching the specified pressure [Z \string~> m].}}
\DoxyCodeLine{1192   \textcolor{keywordtype}{logical},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: remap\_answers\_2018\textcolor{comment}{ !< If true, use the order of arithmetic}}
\DoxyCodeLine{1193 \textcolor{comment}{                                                !! and expressions that recover the answers for remapping}}
\DoxyCodeLine{1194 \textcolor{comment}{                                                !! from the end of 2018. Otherwise, use more robust}}
\DoxyCodeLine{1195 \textcolor{comment}{                                                !! forms of the same expressions.}}
\DoxyCodeLine{1196 }
\DoxyCodeLine{1197   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1198 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk+1)} :: e \textcolor{comment}{! Top and bottom edge values for reconstructions [Z \string~> m]}}
\DoxyCodeLine{1199 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)} :: h0, S0, T0, h1, S1, T1}
\DoxyCodeLine{1200 \textcolor{keywordtype}{  real} :: P\_t, P\_b  \textcolor{comment}{! Top and bottom pressures [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{1201 \textcolor{keywordtype}{  real} :: z\_out, e\_top}
\DoxyCodeLine{1202   \textcolor{keywordtype}{logical} :: answers\_2018}
\DoxyCodeLine{1203   \textcolor{keywordtype}{integer} :: k}
\DoxyCodeLine{1204 }
\DoxyCodeLine{1205   answers\_2018 = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(remap\_answers\_2018)) answers\_2018 = remap\_answers\_2018}
\DoxyCodeLine{1206 }
\DoxyCodeLine{1207   \textcolor{comment}{! Calculate original interface positions}}
\DoxyCodeLine{1208   e(nk+1) = -\/depth}
\DoxyCodeLine{1209   \textcolor{keywordflow}{do} k=nk,1,-\/1}
\DoxyCodeLine{1210     e(k) = e(k+1) + gv\%H\_to\_Z*h(k)}
\DoxyCodeLine{1211     h0(k) = h(nk+1-\/k) \textcolor{comment}{! Keep a copy to use in remapping}}
\DoxyCodeLine{1212 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1213 }
\DoxyCodeLine{1214   p\_t = 0.}
\DoxyCodeLine{1215   e\_top = e(1)}
\DoxyCodeLine{1216   \textcolor{keywordflow}{do} k=1,nk}
\DoxyCodeLine{1217     \textcolor{keyword}{call }find\_depth\_of\_pressure\_in\_cell(t\_t(k), t\_b(k), s\_t(k), s\_b(k), e(k), e(k+1), \&}
\DoxyCodeLine{1218                                         p\_t, p\_surf, gv\%Rho0, g\_earth, tv\%eqn\_of\_state, \&}
\DoxyCodeLine{1219                                         us, p\_b, z\_out, z\_tol=z\_tol)}
\DoxyCodeLine{1220     \textcolor{keywordflow}{if} (z\_out>=e(k)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1221       \textcolor{comment}{! Imposed pressure was less that pressure at top of cell}}
\DoxyCodeLine{1222       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1223     \textcolor{keywordflow}{elseif} (z\_out<=e(k+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1224       \textcolor{comment}{! Imposed pressure was greater than pressure at bottom of cell}}
\DoxyCodeLine{1225       e\_top = e(k+1)}
\DoxyCodeLine{1226     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1227       \textcolor{comment}{! Imposed pressure was fell between pressures at top and bottom of cell}}
\DoxyCodeLine{1228       e\_top = z\_out}
\DoxyCodeLine{1229       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1230 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1231     p\_t = p\_b}
\DoxyCodeLine{1232 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1233   \textcolor{keywordflow}{if} (e\_top<e(1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1234     \textcolor{comment}{! Clip layers from the top down, if at all}}
\DoxyCodeLine{1235     \textcolor{keywordflow}{do} k=1,nk}
\DoxyCodeLine{1236       \textcolor{keywordflow}{if} (e(k) > e\_top) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1237         \textcolor{comment}{! Original e(K) is too high}}
\DoxyCodeLine{1238         e(k) = e\_top}
\DoxyCodeLine{1239         e\_top = e\_top -\/ min\_thickness \textcolor{comment}{! Next interface must be at least this deep}}
\DoxyCodeLine{1240 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1241       \textcolor{comment}{! This layer needs trimming}}
\DoxyCodeLine{1242       h(k) = gv\%Z\_to\_H * max( min\_thickness, e(k) -\/ e(k+1) )}
\DoxyCodeLine{1243       \textcolor{keywordflow}{if} (e(k) < e\_top) \textcolor{keywordflow}{exit} \textcolor{comment}{! No need to go further}}
\DoxyCodeLine{1244 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1245 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1246 }
\DoxyCodeLine{1247   \textcolor{comment}{! Now we need to remap but remapping assumes the surface is at the}}
\DoxyCodeLine{1248   \textcolor{comment}{! same place in the two columns so we turn the column upside down.}}
\DoxyCodeLine{1249   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(remap\_cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1250     \textcolor{keywordflow}{do} k=1,nk}
\DoxyCodeLine{1251       s0(k) = s(nk+1-\/k)}
\DoxyCodeLine{1252       t0(k) = t(nk+1-\/k)}
\DoxyCodeLine{1253       h1(k) = h(nk+1-\/k)}
\DoxyCodeLine{1254 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1255     \textcolor{keywordflow}{if} (answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1256       \textcolor{keyword}{call }remapping\_core\_h(remap\_cs, nk, h0, t0, nk, h1, t1, 1.0e-\/30*gv\%m\_to\_H, 1.0e-\/10*gv\%m\_to\_H)}
\DoxyCodeLine{1257       \textcolor{keyword}{call }remapping\_core\_h(remap\_cs, nk, h0, s0, nk, h1, s1, 1.0e-\/30*gv\%m\_to\_H, 1.0e-\/10*gv\%m\_to\_H)}
\DoxyCodeLine{1258     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1259       \textcolor{keyword}{call }remapping\_core\_h(remap\_cs, nk, h0, t0, nk, h1, t1, gv\%H\_subroundoff, gv\%H\_subroundoff)}
\DoxyCodeLine{1260       \textcolor{keyword}{call }remapping\_core\_h(remap\_cs, nk, h0, s0, nk, h1, s1, gv\%H\_subroundoff, gv\%H\_subroundoff)}
\DoxyCodeLine{1261 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1262     \textcolor{keywordflow}{do} k=1,nk}
\DoxyCodeLine{1263       s(k) = s1(nk+1-\/k)}
\DoxyCodeLine{1264       t(k) = t1(nk+1-\/k)}
\DoxyCodeLine{1265 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1266 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1267 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_aad295781ac5adccf3a80e2323ce77905}\label{namespacemom__state__initialization_aad295781ac5adccf3a80e2323ce77905}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!depress\_surface@{depress\_surface}}
\index{depress\_surface@{depress\_surface}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{depress\_surface()}{depress\_surface()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::depress\+\_\+surface (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Depress the sea-\/surface based on an initial condition file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 997 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{998   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{999   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{1000   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1001 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1002                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1003   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{1004   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{1005   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1006 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{1007   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1008 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{1009     eta\_sfc  \textcolor{comment}{! The free surface height that the model should use [Z \string~> m].}}
\DoxyCodeLine{1010 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)} :: \&}
\DoxyCodeLine{1011     eta  \textcolor{comment}{! The free surface height that the model should use [Z \string~> m].}}
\DoxyCodeLine{1012 \textcolor{keywordtype}{  real} :: dilate  \textcolor{comment}{! A ratio by which layers are dilated [nondim].}}
\DoxyCodeLine{1013 \textcolor{keywordtype}{  real} :: scale\_factor \textcolor{comment}{! A scaling factor for the eta\_sfc values that are read}}
\DoxyCodeLine{1014                        \textcolor{comment}{! in, which can be used to change units, for example.}}
\DoxyCodeLine{1015   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"depress\_surface"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{1016   \textcolor{keywordtype}{character(len=200)} :: inputdir, eta\_srf\_file \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{1017   \textcolor{keywordtype}{character(len=200)} :: filename, eta\_srf\_var  \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{1018   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1019   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{1020   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{1021 }
\DoxyCodeLine{1022   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1023 }
\DoxyCodeLine{1024   \textcolor{comment}{! Read the surface height (or pressure) from a file.}}
\DoxyCodeLine{1025 }
\DoxyCodeLine{1026   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1027   inputdir = slasher(inputdir)}
\DoxyCodeLine{1028   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SURFACE\_HEIGHT\_IC\_FILE"}, eta\_srf\_file,\&}
\DoxyCodeLine{1029                  \textcolor{stringliteral}{"The initial condition file for the surface height."}, \&}
\DoxyCodeLine{1030                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1031   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SURFACE\_HEIGHT\_IC\_VAR"}, eta\_srf\_var, \&}
\DoxyCodeLine{1032                  \textcolor{stringliteral}{"The initial condition variable for the surface height."},\&}
\DoxyCodeLine{1033                  default=\textcolor{stringliteral}{"SSH"}, do\_not\_log=just\_read)}
\DoxyCodeLine{1034   filename = trim(inputdir)//trim(eta\_srf\_file)}
\DoxyCodeLine{1035   \textcolor{keywordflow}{if} (.not.just\_read) \&}
\DoxyCodeLine{1036     \textcolor{keyword}{call }log\_param(param\_file,  mdl, \textcolor{stringliteral}{"INPUTDIR/SURFACE\_HEIGHT\_IC\_FILE"}, filename)}
\DoxyCodeLine{1037 }
\DoxyCodeLine{1038   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SURFACE\_HEIGHT\_IC\_SCALE"}, scale\_factor, \&}
\DoxyCodeLine{1039                  \textcolor{stringliteral}{"A scaling factor to convert SURFACE\_HEIGHT\_IC\_VAR into units of m"}, \&}
\DoxyCodeLine{1040                  units=\textcolor{stringliteral}{"variable"}, default=1.0, scale=us\%m\_to\_Z, do\_not\_log=just\_read)}
\DoxyCodeLine{1041 }
\DoxyCodeLine{1042   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1043 }
\DoxyCodeLine{1044   \textcolor{keyword}{call }mom\_read\_data(filename, eta\_srf\_var, eta\_sfc, g\%Domain, scale=scale\_factor)}
\DoxyCodeLine{1045 }
\DoxyCodeLine{1046   \textcolor{comment}{! Convert thicknesses to interface heights.}}
\DoxyCodeLine{1047   \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, eta)}
\DoxyCodeLine{1048 }
\DoxyCodeLine{1049   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1050 \textcolor{comment}{!    if (eta\_sfc(i,j) < eta(i,j,nz+1)) then}}
\DoxyCodeLine{1051       \textcolor{comment}{! Issue a warning?}}
\DoxyCodeLine{1052 \textcolor{comment}{!    endif}}
\DoxyCodeLine{1053     \textcolor{keywordflow}{if} (eta\_sfc(i,j) > eta(i,j,1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1054       \textcolor{comment}{! Dilate the water column to agree, but only up to 10-\/fold.}}
\DoxyCodeLine{1055       \textcolor{keywordflow}{if} (eta\_sfc(i,j) -\/ eta(i,j,nz+1) > 10.0*(eta(i,j,1) -\/ eta(i,j,nz+1))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1056         dilate = 10.0}
\DoxyCodeLine{1057         \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Free surface height dilation attempted "}//\&}
\DoxyCodeLine{1058                \textcolor{stringliteral}{"to exceed 10-\/fold."}, all\_print=.true.)}
\DoxyCodeLine{1059       \textcolor{keywordflow}{else}}
\DoxyCodeLine{1060         dilate = (eta\_sfc(i,j) -\/ eta(i,j,nz+1)) / (eta(i,j,1) -\/ eta(i,j,nz+1))}
\DoxyCodeLine{1061 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1062       \textcolor{keywordflow}{do} k=1,nz ; h(i,j,k) = h(i,j,k) * dilate ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1063     \textcolor{keywordflow}{elseif} (eta(i,j,1) > eta\_sfc(i,j)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1064       \textcolor{comment}{! Remove any mass that is above the target free surface.}}
\DoxyCodeLine{1065       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1066         \textcolor{keywordflow}{if} (eta(i,j,k) <= eta\_sfc(i,j)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1067         \textcolor{keywordflow}{if} (eta(i,j,k+1) >= eta\_sfc(i,j)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1068           h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{1069         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1070           h(i,j,k) = max(gv\%Angstrom\_H, h(i,j,k) * \&}
\DoxyCodeLine{1071               (eta\_sfc(i,j) -\/ eta(i,j,k+1)) / (eta(i,j,k) -\/ eta(i,j,k+1)) )}
\DoxyCodeLine{1072 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1073 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1074 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1075 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1076 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a526e4ed5e2543f0d7bec8bc0dde37ae2}\label{namespacemom__state__initialization_a526e4ed5e2543f0d7bec8bc0dde37ae2}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!find\_interfaces@{find\_interfaces}}
\index{find\_interfaces@{find\_interfaces}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{find\_interfaces()}{find\_interfaces()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::find\+\_\+interfaces (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,nk\+\_\+data), intent(in)}]{rho,  }\item[{real, dimension(nk\+\_\+data), intent(in)}]{zin,  }\item[{integer, intent(in)}]{nk\+\_\+data,  }\item[{real, dimension( g \%ke+1), intent(in)}]{Rb,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in)}]{depth,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke+1), intent(out)}]{zi,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{integer, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in)}]{nlevs,  }\item[{integer, intent(in)}]{nkml,  }\item[{real, intent(in)}]{hml,  }\item[{real, intent(in)}]{eps\+\_\+z,  }\item[{real, intent(in)}]{eps\+\_\+rho }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Find interface positions corresponding to interpolated depths in a density profile. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em nk\+\_\+data} & The number of levels in the input data \\
\hline
\mbox{\texttt{ in}}  & {\em rho} & Potential density in z-\/space \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em zin} & Input data levels \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em rb} & target interface densities \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em depth} & ocean depth \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em zi} & The returned interface heights \mbox{[}Z $\sim$$>$ m\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em nlevs} & number of valid points in each column \\
\hline
\mbox{\texttt{ in}}  & {\em nkml} & number of mixed layer pieces to distribute over a depth of hml. \\
\hline
\mbox{\texttt{ in}}  & {\em hml} & mixed layer depth \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em eps\+\_\+z} & A negligibly small layer thickness \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em eps\+\_\+rho} & A negligibly small density difference \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 2452 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2454   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{     !< The ocean's grid structure}}
\DoxyCodeLine{2455   \textcolor{keywordtype}{integer},                    \textcolor{keywordtype}{intent(in)}  :: nk\_data\textcolor{comment}{ !< The number of levels in the input data}}
\DoxyCodeLine{2456 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),nk\_data)}, \&}
\DoxyCodeLine{2457                               \textcolor{keywordtype}{intent(in)}  :: rho\textcolor{comment}{   !< Potential density in z-\/space [R \string~> kg m-\/3]}}
\DoxyCodeLine{2458 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk\_data)},   \textcolor{keywordtype}{intent(in)}  :: zin\textcolor{comment}{   !< Input data levels [Z \string~> m].}}
\DoxyCodeLine{2459 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(G)+1)}, \textcolor{keywordtype}{intent(in)}  :: Rb\textcolor{comment}{    !< target interface densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{2460 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{2461                               \textcolor{keywordtype}{intent(in)}  :: depth\textcolor{comment}{ !< ocean depth [Z \string~> m].}}
\DoxyCodeLine{2462 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \&}
\DoxyCodeLine{2463                               \textcolor{keywordtype}{intent(out)} :: zi\textcolor{comment}{    !< The returned interface heights [Z \string~> m]}}
\DoxyCodeLine{2464   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{    !< A dimensional unit scaling type}}
\DoxyCodeLine{2465   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{2466                               \textcolor{keywordtype}{intent(in)}  :: nlevs\textcolor{comment}{ !< number of valid points in each column}}
\DoxyCodeLine{2467   \textcolor{keywordtype}{integer},                    \textcolor{keywordtype}{intent(in)}  :: nkml\textcolor{comment}{  !< number of mixed layer pieces to distribute over}}
\DoxyCodeLine{2468 \textcolor{comment}{                                                   !! a depth of hml.}}
\DoxyCodeLine{2469 \textcolor{keywordtype}{  real},                       \textcolor{keywordtype}{intent(in)}  :: hml\textcolor{comment}{   !< mixed layer depth [Z \string~> m].}}
\DoxyCodeLine{2470 \textcolor{keywordtype}{  real},                       \textcolor{keywordtype}{intent(in)}  :: eps\_z\textcolor{comment}{ !< A negligibly small layer thickness [Z \string~> m].}}
\DoxyCodeLine{2471 \textcolor{keywordtype}{  real},                       \textcolor{keywordtype}{intent(in)}  :: eps\_rho\textcolor{comment}{ !< A negligibly small density difference [R \string~> kg m-\/3].}}
\DoxyCodeLine{2472 }
\DoxyCodeLine{2473   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{2474 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk\_data)} :: rho\_ \textcolor{comment}{! A column of densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{2475 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(G)+1)} :: zi\_ \textcolor{comment}{! A column interface heights (negative downward) [Z \string~> m].}}
\DoxyCodeLine{2476 \textcolor{keywordtype}{  real}    :: slope      \textcolor{comment}{! The rate of change of height with density [Z R-\/1 \string~> m4 kg-\/1]}}
\DoxyCodeLine{2477 \textcolor{keywordtype}{  real}    :: drhodz     \textcolor{comment}{! A local vertical density gradient [R Z-\/1 \string~> kg m-\/4]}}
\DoxyCodeLine{2478 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: zoff=0.999}
\DoxyCodeLine{2479   \textcolor{keywordtype}{logical} :: unstable   \textcolor{comment}{! True if the column is statically unstable anywhere.}}
\DoxyCodeLine{2480   \textcolor{keywordtype}{integer} :: nlevs\_data \textcolor{comment}{! The number of data values in a column.}}
\DoxyCodeLine{2481   \textcolor{keywordtype}{logical} :: work\_down  \textcolor{comment}{! This indicates whether this pass goes up or down the water column.}}
\DoxyCodeLine{2482   \textcolor{keywordtype}{integer} :: k\_int, lo\_int, hi\_int, mid}
\DoxyCodeLine{2483   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{2484 }
\DoxyCodeLine{2485   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{2486 }
\DoxyCodeLine{2487   zi(:,:,:) = 0.0}
\DoxyCodeLine{2488 }
\DoxyCodeLine{2489   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{2490     nlevs\_data = nlevs(i,j)}
\DoxyCodeLine{2491     \textcolor{keywordflow}{do} k=1,nlevs\_data ; rho\_(k) = rho(i,j,k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2492 }
\DoxyCodeLine{2493     unstable=.true.}
\DoxyCodeLine{2494     work\_down = .true.}
\DoxyCodeLine{2495     \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (unstable)}
\DoxyCodeLine{2496       \textcolor{comment}{! Modifiy the input profile until it no longer has densities that decrease with depth.}}
\DoxyCodeLine{2497       unstable=.false.}
\DoxyCodeLine{2498       \textcolor{keywordflow}{if} (work\_down) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2499         \textcolor{keywordflow}{do} k=2,nlevs\_data-\/1 ; \textcolor{keywordflow}{if} (rho\_(k) -\/ rho\_(k-\/1) < 0.0 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2500           \textcolor{keywordflow}{if} (k == 2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2501             rho\_(k-\/1) = rho\_(k) -\/ eps\_rho}
\DoxyCodeLine{2502           \textcolor{keywordflow}{else}}
\DoxyCodeLine{2503             drhodz = (rho\_(k+1)-\/rho\_(k-\/1)) / (zin(k+1)-\/zin(k-\/1))}
\DoxyCodeLine{2504             \textcolor{keywordflow}{if} (drhodz < 0.0) unstable=.true.}
\DoxyCodeLine{2505             rho\_(k) = rho\_(k-\/1) + drhodz*zoff*(zin(k)-\/zin(k-\/1))}
\DoxyCodeLine{2506 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2507 \textcolor{keywordflow}{        endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2508         work\_down = .false.}
\DoxyCodeLine{2509       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2510         \textcolor{keywordflow}{do} k=nlevs\_data-\/1,2,-\/1 ;  \textcolor{keywordflow}{if} (rho\_(k+1) -\/ rho\_(k) < 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2511           \textcolor{keywordflow}{if} (k == nlevs\_data-\/1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2512             rho\_(k+1) = rho\_(k-\/1) + eps\_rho \textcolor{comment}{!\#\#\# This should be rho\_(k) + eps\_rho}}
\DoxyCodeLine{2513           \textcolor{keywordflow}{else}}
\DoxyCodeLine{2514             drhodz = (rho\_(k+1)-\/rho\_(k-\/1)) / (zin(k+1)-\/zin(k-\/1))}
\DoxyCodeLine{2515             \textcolor{keywordflow}{if} (drhodz  < 0.0) unstable=.true.}
\DoxyCodeLine{2516             rho\_(k) = rho\_(k+1) -\/ drhodz*(zin(k+1)-\/zin(k))}
\DoxyCodeLine{2517 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2518 \textcolor{keywordflow}{        endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2519         work\_down = .true.}
\DoxyCodeLine{2520 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2521 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2522 }
\DoxyCodeLine{2523     \textcolor{comment}{! Find and store the interface depths.}}
\DoxyCodeLine{2524     zi\_(1) = 0.0}
\DoxyCodeLine{2525     \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{2526       \textcolor{comment}{! Find the value of k\_int in the list of rho\_ where rho\_(k\_int) <= Rb(K) < rho\_(k\_int+1).}}
\DoxyCodeLine{2527       \textcolor{comment}{! This might be made a little faster by exploiting the fact that Rb is}}
\DoxyCodeLine{2528       \textcolor{comment}{! monotonically increasing and not resetting lo\_int back to 1 inside the K loop.}}
\DoxyCodeLine{2529       lo\_int = 1 ; hi\_int = nlevs\_data}
\DoxyCodeLine{2530       \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (lo\_int < hi\_int)}
\DoxyCodeLine{2531         mid = (lo\_int+hi\_int) / 2}
\DoxyCodeLine{2532         \textcolor{keywordflow}{if} (rb(k) < rho\_(mid)) \textcolor{keywordflow}{then} ; hi\_int = mid}
\DoxyCodeLine{2533         \textcolor{keywordflow}{else} ; lo\_int = mid+1 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{2534 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2535       k\_int = max(1, lo\_int-\/1)}
\DoxyCodeLine{2536 }
\DoxyCodeLine{2537       \textcolor{comment}{! Linearly interpolate to find the depth, zi\_, where Rb would be found.}}
\DoxyCodeLine{2538       slope = (zin(k\_int+1) -\/ zin(k\_int)) / max(rho\_(k\_int+1) -\/ rho\_(k\_int), eps\_rho)}
\DoxyCodeLine{2539       zi\_(k) = -\/1.0*(zin(k\_int) + slope*(rb(k)-\/rho\_(k\_int)))}
\DoxyCodeLine{2540       zi\_(k) = min(max(zi\_(k), -\/depth(i,j)), -\/1.0*hml)}
\DoxyCodeLine{2541 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2542     zi\_(nz+1) = -\/depth(i,j)}
\DoxyCodeLine{2543     \textcolor{keywordflow}{if} (nkml > 0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=2,nkml+1}
\DoxyCodeLine{2544       zi\_(k) = max(hml*((1.0-\/real(k))/real(nkml)), -\/depth(i,j))}
\DoxyCodeLine{2545 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{2546     \textcolor{keywordflow}{do} k=nz,max(nkml+2,2),-\/1}
\DoxyCodeLine{2547       \textcolor{keywordflow}{if} (zi\_(k) < zi\_(k+1) + eps\_z) zi\_(k) = zi\_(k+1) + eps\_z}
\DoxyCodeLine{2548       \textcolor{keywordflow}{if} (zi\_(k) > -\/1.0*hml)  zi\_(k) = max(-\/1.0*hml, -\/depth(i,j))}
\DoxyCodeLine{2549 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2550 }
\DoxyCodeLine{2551     \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{2552       zi(i,j,k) = zi\_(k)}
\DoxyCodeLine{2553 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2554 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{! i-\/ and j-\/ loops}}
\DoxyCodeLine{2555 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_ac672706eef5c8d6c07333f5e46e4cdff}\label{namespacemom__state__initialization_ac672706eef5c8d6c07333f5e46e4cdff}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_sponges\_file@{initialize\_sponges\_file}}
\index{initialize\_sponges\_file@{initialize\_sponges\_file}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_sponges\_file()}{initialize\_sponges\_file()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+sponges\+\_\+file (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{logical, intent(in)}]{use\+\_\+temperature,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(sponge\+\_\+cs), pointer}]{Layer\+\_\+\+C\+Sp,  }\item[{type(ale\+\_\+sponge\+\_\+cs), pointer}]{A\+L\+E\+\_\+\+C\+Sp,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine sets the inverse restoration time (Idamp), and the values towards which the interface heights and an arbitrary number of tracers should be restored within each sponge. The interface height is always subject to damping, and must always be the first registered field. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em use\+\_\+temperature} & If true, T \& S are state variables. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters. \\
\hline
 & {\em layer\+\_\+csp} & A pointer that is set to point to the control structure for this module (in layered mode). \\
\hline
 & {\em ale\+\_\+csp} & A pointer that is set to point to the control structure for this module (in A\+LE mode). \\
\hline
\mbox{\texttt{ in}}  & {\em time} & Time at the start of the run segment. Time\+\_\+in overrides any value set for Time. \\
\hline
\end{DoxyParams}


Definition at line 1712 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1713   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{1714   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{1715   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1716   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: use\_temperature\textcolor{comment}{ !< If true, T \& S are state variables.}}
\DoxyCodeLine{1717   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic}}
\DoxyCodeLine{1718 \textcolor{comment}{                                              !! variables.}}
\DoxyCodeLine{1719   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters.}}
\DoxyCodeLine{1720   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}    :: Layer\_CSp\textcolor{comment}{  !< A pointer that is set to point to the control}}
\DoxyCodeLine{1721 \textcolor{comment}{                                              !! structure for this module (in layered mode).}}
\DoxyCodeLine{1722   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),     \textcolor{keywordtype}{pointer}    :: ALE\_CSp\textcolor{comment}{  !< A pointer that is set to point to the control}}
\DoxyCodeLine{1723 \textcolor{comment}{                                                  !! structure for this module (in ALE mode).}}
\DoxyCodeLine{1724   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< Time at the start of the run segment. Time\_in}}
\DoxyCodeLine{1725 \textcolor{comment}{                                              !! overrides any value set for Time.}}
\DoxyCodeLine{1726   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1727 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: eta \textcolor{comment}{! The target interface heights [Z \string~> m].}}
\DoxyCodeLine{1728 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: h   \textcolor{comment}{! The target interface thicknesses [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{1729 }
\DoxyCodeLine{1730 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension (SZI\_(G),SZJ\_(G),SZK\_(G))} :: \&}
\DoxyCodeLine{1731     tmp, tmp2 \textcolor{comment}{! A temporary array for tracers.}}
\DoxyCodeLine{1732 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension (SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{1733     tmp\_2d \textcolor{comment}{! A temporary array for tracers.}}
\DoxyCodeLine{1734 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: tmp\_tr \textcolor{comment}{! A temporary array for reading sponge fields}}
\DoxyCodeLine{1735 }
\DoxyCodeLine{1736 \textcolor{keywordtype}{  real} :: Idamp(SZI\_(G),SZJ\_(G))    \textcolor{comment}{! The inverse damping rate [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{1737 \textcolor{keywordtype}{  real} :: pres(SZI\_(G))     \textcolor{comment}{! An array of the reference pressure [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{1738 }
\DoxyCodeLine{1739   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The i-\/computational domain for the equation of state}}
\DoxyCodeLine{1740   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{1741   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{1742   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(4)} :: siz}
\DoxyCodeLine{1743   \textcolor{keywordtype}{integer} :: nz\_data  \textcolor{comment}{! The size of the sponge source grid}}
\DoxyCodeLine{1744   \textcolor{keywordtype}{character(len=40)} :: potemp\_var, salin\_var, Idamp\_var, eta\_var}
\DoxyCodeLine{1745   \textcolor{keywordtype}{character(len=40)} :: mdl = \textcolor{stringliteral}{"initialize\_sponges\_file"}}
\DoxyCodeLine{1746   \textcolor{keywordtype}{character(len=200)} :: damping\_file, state\_file  \textcolor{comment}{! Strings for filenames}}
\DoxyCodeLine{1747   \textcolor{keywordtype}{character(len=200)} :: filename, inputdir \textcolor{comment}{! Strings for file/path and path.}}
\DoxyCodeLine{1748 }
\DoxyCodeLine{1749   \textcolor{keywordtype}{logical} :: use\_ALE \textcolor{comment}{! True if ALE is being used, False if in layered mode}}
\DoxyCodeLine{1750   \textcolor{keywordtype}{logical} :: time\_space\_interp\_sponge \textcolor{comment}{! True if using sponge data which}}
\DoxyCodeLine{1751   \textcolor{comment}{! need to be interpolated from in both the horizontal dimension and in}}
\DoxyCodeLine{1752   \textcolor{comment}{! time prior to vertical remapping.}}
\DoxyCodeLine{1753 }
\DoxyCodeLine{1754 }
\DoxyCodeLine{1755   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{1756   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{1757 }
\DoxyCodeLine{1758   pres(:) = 0.0 ; tmp(:,:,:) = 0.0 ; idamp(:,:) = 0.0}
\DoxyCodeLine{1759 }
\DoxyCodeLine{1760   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1761   inputdir = slasher(inputdir)}
\DoxyCodeLine{1762   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_DAMPING\_FILE"}, damping\_file, \&}
\DoxyCodeLine{1763                  \textcolor{stringliteral}{"The name of the file with the sponge damping rates."}, \&}
\DoxyCodeLine{1764                  fail\_if\_missing=.true.)}
\DoxyCodeLine{1765   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_STATE\_FILE"}, state\_file, \&}
\DoxyCodeLine{1766                  \textcolor{stringliteral}{"The name of the file with the state to damp toward."}, \&}
\DoxyCodeLine{1767                  default=damping\_file)}
\DoxyCodeLine{1768   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_PTEMP\_VAR"}, potemp\_var, \&}
\DoxyCodeLine{1769                  \textcolor{stringliteral}{"The name of the potential temperature variable in "}//\&}
\DoxyCodeLine{1770                  \textcolor{stringliteral}{"SPONGE\_STATE\_FILE."}, default=\textcolor{stringliteral}{"PTEMP"})}
\DoxyCodeLine{1771   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_SALT\_VAR"}, salin\_var, \&}
\DoxyCodeLine{1772                  \textcolor{stringliteral}{"The name of the salinity variable in "}//\&}
\DoxyCodeLine{1773                  \textcolor{stringliteral}{"SPONGE\_STATE\_FILE."}, default=\textcolor{stringliteral}{"SALT"})}
\DoxyCodeLine{1774   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_ETA\_VAR"}, eta\_var, \&}
\DoxyCodeLine{1775                  \textcolor{stringliteral}{"The name of the interface height variable in "}//\&}
\DoxyCodeLine{1776                  \textcolor{stringliteral}{"SPONGE\_STATE\_FILE."}, default=\textcolor{stringliteral}{"ETA"})}
\DoxyCodeLine{1777   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPONGE\_IDAMP\_VAR"}, idamp\_var, \&}
\DoxyCodeLine{1778                  \textcolor{stringliteral}{"The name of the inverse damping rate variable in "}//\&}
\DoxyCodeLine{1779                  \textcolor{stringliteral}{"SPONGE\_DAMPING\_FILE."}, default=\textcolor{stringliteral}{"Idamp"})}
\DoxyCodeLine{1780   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_REGRIDDING"}, use\_ale, do\_not\_log = .true.)}
\DoxyCodeLine{1781   time\_space\_interp\_sponge = .false.}
\DoxyCodeLine{1782   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"NEW\_SPONGES"}, time\_space\_interp\_sponge, \&}
\DoxyCodeLine{1783                  \textcolor{stringliteral}{"Set True if using the newer sponging code which "}//\&}
\DoxyCodeLine{1784                  \textcolor{stringliteral}{"performs on-\/the-\/fly regridding in lat-\/lon-\/time."},\&}
\DoxyCodeLine{1785                  \textcolor{stringliteral}{"of sponge restoring data."}, default=.false.)}
\DoxyCodeLine{1786   \textcolor{keywordflow}{if} (time\_space\_interp\_sponge) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1787      \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{" initialize\_sponges:  NEW\_SPONGES has been deprecated. "}//\&}
\DoxyCodeLine{1788           \textcolor{stringliteral}{"Please use INTERPOLATE\_SPONGE\_TIME\_SPACE instead. Setting "}//\&}
\DoxyCodeLine{1789           \textcolor{stringliteral}{"INTERPOLATE\_SPONGE\_TIME\_SPACE = True."})}
\DoxyCodeLine{1790 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1791   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERPOLATE\_SPONGE\_TIME\_SPACE"}, time\_space\_interp\_sponge, \&}
\DoxyCodeLine{1792                  \textcolor{stringliteral}{"Set True if using the newer sponging code which "}//\&}
\DoxyCodeLine{1793                  \textcolor{stringliteral}{"performs on-\/the-\/fly regridding in lat-\/lon-\/time."},\&}
\DoxyCodeLine{1794                  \textcolor{stringliteral}{"of sponge restoring data."}, default=time\_space\_interp\_sponge)}
\DoxyCodeLine{1795 }
\DoxyCodeLine{1796   filename = trim(inputdir)//trim(damping\_file)}
\DoxyCodeLine{1797   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/SPONGE\_DAMPING\_FILE"}, filename)}
\DoxyCodeLine{1798   \textcolor{keywordflow}{if} (.not.file\_exists(filename, g\%Domain)) \&}
\DoxyCodeLine{1799     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{" initialize\_sponges: Unable to open "}//trim(filename))}
\DoxyCodeLine{1800 }
\DoxyCodeLine{1801   \textcolor{keywordflow}{if} (time\_space\_interp\_sponge .and. .not. use\_ale) \&}
\DoxyCodeLine{1802     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{" initialize\_sponges: Time-\/varying sponges are currently unavailable in layered mode "})}
\DoxyCodeLine{1803 }
\DoxyCodeLine{1804   \textcolor{keyword}{call }mom\_read\_data(filename, idamp\_var, idamp(:,:), g\%Domain, scale=us\%T\_to\_s)}
\DoxyCodeLine{1805 }
\DoxyCodeLine{1806   \textcolor{comment}{! Now register all of the fields which are damped in the sponge.}}
\DoxyCodeLine{1807   \textcolor{comment}{! By default, momentum is advected vertically within the sponge, but}}
\DoxyCodeLine{1808   \textcolor{comment}{! momentum is typically not damped within the sponge.}}
\DoxyCodeLine{1809 }
\DoxyCodeLine{1810   filename = trim(inputdir)//trim(state\_file)}
\DoxyCodeLine{1811   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/SPONGE\_STATE\_FILE"}, filename)}
\DoxyCodeLine{1812   \textcolor{keywordflow}{if} (.not.file\_exists(filename, g\%Domain)) \&}
\DoxyCodeLine{1813     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{" initialize\_sponges: Unable to open "}//trim(filename))}
\DoxyCodeLine{1814 }
\DoxyCodeLine{1815 }
\DoxyCodeLine{1816   \textcolor{keywordflow}{if} (.not. use\_ale) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1817     \textcolor{comment}{! The first call to set\_up\_sponge\_field is for the interface heights if in layered mode.}}
\DoxyCodeLine{1818     \textcolor{keyword}{allocate}(eta(isd:ied,jsd:jed,nz+1)); eta(:,:,:) = 0.0}
\DoxyCodeLine{1819     \textcolor{keyword}{call }mom\_read\_data(filename, eta\_var, eta(:,:,:), g\%Domain, scale=us\%m\_to\_Z)}
\DoxyCodeLine{1820 }
\DoxyCodeLine{1821     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1822       eta(i,j,nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{1823 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1824     \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1825       \textcolor{keywordflow}{if} (eta(i,j,k) < (eta(i,j,k+1) + gv\%Angstrom\_Z)) \&}
\DoxyCodeLine{1826         eta(i,j,k) = eta(i,j,k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{1827 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1828     \textcolor{comment}{! Set the inverse damping rates so that the model will know where to}}
\DoxyCodeLine{1829     \textcolor{comment}{! apply the sponges, along with the interface heights.}}
\DoxyCodeLine{1830     \textcolor{keyword}{call }initialize\_sponge(idamp, eta, g, param\_file, layer\_csp, gv)}
\DoxyCodeLine{1831     \textcolor{keyword}{deallocate}(eta)}
\DoxyCodeLine{1832 }
\DoxyCodeLine{1833     \textcolor{keywordflow}{if} ( gv\%nkml>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1834       \textcolor{comment}{! This call to set\_up\_sponge\_ML\_density registers the target values of the}}
\DoxyCodeLine{1835       \textcolor{comment}{! mixed layer density, which is used in determining which layers can be}}
\DoxyCodeLine{1836       \textcolor{comment}{! inflated without causing static instabilities.}}
\DoxyCodeLine{1837       \textcolor{keywordflow}{do} i=is-\/1,ie ; pres(i) = tv\%P\_Ref ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1838       eosdom(:) = eos\_domain(g\%HI)}
\DoxyCodeLine{1839 }
\DoxyCodeLine{1840       \textcolor{keyword}{call }mom\_read\_data(filename, potemp\_var, tmp(:,:,:), g\%Domain)}
\DoxyCodeLine{1841       \textcolor{keyword}{call }mom\_read\_data(filename, salin\_var, tmp2(:,:,:), g\%Domain)}
\DoxyCodeLine{1842 }
\DoxyCodeLine{1843       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{1844         \textcolor{keyword}{call }calculate\_density(tmp(:,j,1), tmp2(:,j,1), pres, tmp\_2d(:,j), tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{1845 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1846 }
\DoxyCodeLine{1847       \textcolor{keyword}{call }set\_up\_sponge\_ml\_density(tmp\_2d, g, layer\_csp)}
\DoxyCodeLine{1848 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1849 }
\DoxyCodeLine{1850    \textcolor{comment}{! Now register all of the tracer fields which are damped in the}}
\DoxyCodeLine{1851    \textcolor{comment}{! sponge. By default, momentum is advected vertically within the}}
\DoxyCodeLine{1852    \textcolor{comment}{! sponge, but momentum is typically not damped within the sponge.}}
\DoxyCodeLine{1853 }
\DoxyCodeLine{1854 }
\DoxyCodeLine{1855     \textcolor{comment}{! The remaining calls to set\_up\_sponge\_field can be in any order.}}
\DoxyCodeLine{1856     \textcolor{keywordflow}{if} ( use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1857       \textcolor{keyword}{call }mom\_read\_data(filename, potemp\_var, tmp(:,:,:), g\%Domain)}
\DoxyCodeLine{1858       \textcolor{keyword}{call }set\_up\_sponge\_field(tmp, tv\%T, g, nz, layer\_csp)}
\DoxyCodeLine{1859       \textcolor{keyword}{call }mom\_read\_data(filename, salin\_var, tmp(:,:,:), g\%Domain)}
\DoxyCodeLine{1860       \textcolor{keyword}{call }set\_up\_sponge\_field(tmp, tv\%S, g, nz, layer\_csp)}
\DoxyCodeLine{1861 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1862 }
\DoxyCodeLine{1863 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1864 }
\DoxyCodeLine{1865 }
\DoxyCodeLine{1866   \textcolor{keywordflow}{if}  (use\_ale) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1867     \textcolor{keywordflow}{if} (.not. time\_space\_interp\_sponge) \textcolor{keywordflow}{then} \textcolor{comment}{! ALE mode}}
\DoxyCodeLine{1868       \textcolor{keyword}{call }field\_size(filename,eta\_var,siz,no\_domain=.true.)}
\DoxyCodeLine{1869       \textcolor{keywordflow}{if} (siz(1) /= g\%ieg-\/g\%isg+1 .or. siz(2) /= g\%jeg-\/g\%jsg+1) \&}
\DoxyCodeLine{1870         \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_sponge\_file: Array size mismatch for sponge data."})}
\DoxyCodeLine{1871       nz\_data = siz(3)-\/1}
\DoxyCodeLine{1872       \textcolor{keyword}{allocate}(eta(isd:ied,jsd:jed,nz\_data+1))}
\DoxyCodeLine{1873       \textcolor{keyword}{allocate}(h(isd:ied,jsd:jed,nz\_data))}
\DoxyCodeLine{1874       \textcolor{keyword}{call }mom\_read\_data(filename, eta\_var, eta(:,:,:), g\%Domain, scale=us\%m\_to\_Z)}
\DoxyCodeLine{1875       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1876         eta(i,j,nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{1877 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1878       \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1879         \textcolor{keywordflow}{if} (eta(i,j,k) < (eta(i,j,k+1) + gv\%Angstrom\_Z)) \&}
\DoxyCodeLine{1880           eta(i,j,k) = eta(i,j,k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{1881 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1882       \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1883         h(i,j,k) = gv\%Z\_to\_H*(eta(i,j,k)-\/eta(i,j,k+1))}
\DoxyCodeLine{1884 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1885       \textcolor{keyword}{call }initialize\_ale\_sponge(idamp, g, param\_file, ale\_csp, h, nz\_data)}
\DoxyCodeLine{1886       \textcolor{keyword}{deallocate}(eta)}
\DoxyCodeLine{1887       \textcolor{keyword}{deallocate}(h)}
\DoxyCodeLine{1888       \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1889         \textcolor{keyword}{allocate}(tmp\_tr(isd:ied,jsd:jed,nz\_data))}
\DoxyCodeLine{1890         \textcolor{keyword}{call }mom\_read\_data(filename, potemp\_var, tmp\_tr(:,:,:), g\%Domain)}
\DoxyCodeLine{1891         \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(tmp\_tr, g, tv\%T, ale\_csp)}
\DoxyCodeLine{1892         \textcolor{keyword}{call }mom\_read\_data(filename, salin\_var, tmp\_tr(:,:,:), g\%Domain)}
\DoxyCodeLine{1893         \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(tmp\_tr, g, tv\%S, ale\_csp)}
\DoxyCodeLine{1894         \textcolor{keyword}{deallocate}(tmp\_tr)}
\DoxyCodeLine{1895 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1896     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1897       \textcolor{comment}{! Initialize sponges without supplying sponge grid}}
\DoxyCodeLine{1898       \textcolor{keyword}{call }initialize\_ale\_sponge(idamp, g, param\_file, ale\_csp)}
\DoxyCodeLine{1899       \textcolor{comment}{! The remaining calls to set\_up\_sponge\_field can be in any order.}}
\DoxyCodeLine{1900       \textcolor{keywordflow}{if} ( use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1901         \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(filename, potemp\_var, time, g, gv, us, tv\%T, ale\_csp)}
\DoxyCodeLine{1902         \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(filename, salin\_var, time, g, gv, us, tv\%S, ale\_csp)}
\DoxyCodeLine{1903 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1904 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1905 }
\DoxyCodeLine{1906 }
\DoxyCodeLine{1907 }
\DoxyCodeLine{1908 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1909 }
\DoxyCodeLine{1910 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a964fba68510337bdde7636a18f783fc9}\label{namespacemom__state__initialization_a964fba68510337bdde7636a18f783fc9}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_temp\_salt\_fit@{initialize\_temp\_salt\_fit}}
\index{initialize\_temp\_salt\_fit@{initialize\_temp\_salt\_fit}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_temp\_salt\_fit()}{initialize\_temp\_salt\_fit()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+temp\+\_\+salt\+\_\+fit (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{T,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{S,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(eos\+\_\+type), pointer}]{eqn\+\_\+of\+\_\+state,  }\item[{real, intent(in)}]{P\+\_\+\+Ref,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initializes temperature and salinity by fitting to density. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ out}}  & {\em t} & The potential temperature that is being initialized \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em s} & The salinity that is being initialized \mbox{[}ppt\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters. \\
\hline
 & {\em eqn\+\_\+of\+\_\+state} & Equation of state structure \\
\hline
\mbox{\texttt{ in}}  & {\em p\+\_\+ref} & The coordinate-\/density reference pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1551 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1552   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{            !< The ocean's grid structure.}}
\DoxyCodeLine{1553   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{           !< The ocean's vertical grid structure.}}
\DoxyCodeLine{1554 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: T\textcolor{comment}{ !< The potential temperature that is}}
\DoxyCodeLine{1555 \textcolor{comment}{                                                       !! being initialized [degC].}}
\DoxyCodeLine{1556 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: S\textcolor{comment}{ !< The salinity that is being}}
\DoxyCodeLine{1557 \textcolor{comment}{                                                       !! initialized [ppt].}}
\DoxyCodeLine{1558   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{           !< A dimensional unit scaling type}}
\DoxyCodeLine{1559   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{   !< A structure to parse for run-\/time}}
\DoxyCodeLine{1560 \textcolor{comment}{                                                       !! parameters.}}
\DoxyCodeLine{1561   \textcolor{keywordtype}{type}(EOS\_type),          \textcolor{keywordtype}{pointer}     :: eqn\_of\_state\textcolor{comment}{ !< Equation of state structure}}
\DoxyCodeLine{1562 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}  :: P\_Ref\textcolor{comment}{        !< The coordinate-\/density reference pressure}}
\DoxyCodeLine{1563 \textcolor{comment}{                                                       !! [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{1564   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1565 \textcolor{comment}{                                                       !! only read parameters without changing h.}}
\DoxyCodeLine{1566   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1567 \textcolor{keywordtype}{  real} :: T0(SZK\_(G))   \textcolor{comment}{! Layer potential temperatures [degC]}}
\DoxyCodeLine{1568 \textcolor{keywordtype}{  real} :: S0(SZK\_(G))   \textcolor{comment}{! Layer salinities [degC]}}
\DoxyCodeLine{1569 \textcolor{keywordtype}{  real} :: T\_Ref         \textcolor{comment}{! Reference Temperature [degC]}}
\DoxyCodeLine{1570 \textcolor{keywordtype}{  real} :: S\_Ref         \textcolor{comment}{! Reference Salinity [ppt]}}
\DoxyCodeLine{1571 \textcolor{keywordtype}{  real} :: pres(SZK\_(G))      \textcolor{comment}{! An array of the reference pressure [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{1572 \textcolor{keywordtype}{  real} :: drho\_dT(SZK\_(G))   \textcolor{comment}{! Derivative of density with temperature [R degC-\/1 \string~> kg m-\/3 degC-\/1].}}
\DoxyCodeLine{1573 \textcolor{keywordtype}{  real} :: drho\_dS(SZK\_(G))   \textcolor{comment}{! Derivative of density with salinity [R ppt-\/1 \string~> kg m-\/3 ppt-\/1].}}
\DoxyCodeLine{1574 \textcolor{keywordtype}{  real} :: rho\_guess(SZK\_(G)) \textcolor{comment}{! Potential density at T0 \& S0 [R \string~> kg m-\/3].}}
\DoxyCodeLine{1575   \textcolor{keywordtype}{logical} :: fit\_salin       \textcolor{comment}{! If true, accept the prescribed temperature and fit the salinity.}}
\DoxyCodeLine{1576   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1577   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_temp\_salt\_fit"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{1578   \textcolor{keywordtype}{integer} :: i, j, k, itt, nz}
\DoxyCodeLine{1579   nz = g\%ke}
\DoxyCodeLine{1580 }
\DoxyCodeLine{1581   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1582 }
\DoxyCodeLine{1583   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{1584 }
\DoxyCodeLine{1585   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"T\_REF"}, t\_ref, \&}
\DoxyCodeLine{1586                  \textcolor{stringliteral}{"A reference temperature used in initialization."}, \&}
\DoxyCodeLine{1587                  units=\textcolor{stringliteral}{"degC"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1588   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_REF"}, s\_ref, \&}
\DoxyCodeLine{1589                  \textcolor{stringliteral}{"A reference salinity used in initialization."}, units=\textcolor{stringliteral}{"PSU"}, \&}
\DoxyCodeLine{1590                  default=35.0, do\_not\_log=just\_read)}
\DoxyCodeLine{1591   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FIT\_SALINITY"}, fit\_salin, \&}
\DoxyCodeLine{1592                  \textcolor{stringliteral}{"If true, accept the prescribed temperature and fit the "}//\&}
\DoxyCodeLine{1593                  \textcolor{stringliteral}{"salinity; otherwise take salinity and fit temperature."}, \&}
\DoxyCodeLine{1594                  default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{1595 }
\DoxyCodeLine{1596   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1597 }
\DoxyCodeLine{1598   \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1599     pres(k) = p\_ref ; s0(k) = s\_ref}
\DoxyCodeLine{1600     t0(k) = t\_ref}
\DoxyCodeLine{1601 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1602 }
\DoxyCodeLine{1603   \textcolor{keyword}{call }calculate\_density(t0(1), s0(1), pres(1), rho\_guess(1), eqn\_of\_state)}
\DoxyCodeLine{1604   \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state, (/1,1/) )}
\DoxyCodeLine{1605 }
\DoxyCodeLine{1606   \textcolor{keywordflow}{if} (fit\_salin) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1607     \textcolor{comment}{! A first guess of the layers' temperatures.}}
\DoxyCodeLine{1608     \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{1609       s0(k) = max(0.0, s0(1) + (gv\%Rlay(k) -\/ rho\_guess(1)) / drho\_ds(1))}
\DoxyCodeLine{1610 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1611     \textcolor{comment}{! Refine the guesses for each layer.}}
\DoxyCodeLine{1612     \textcolor{keywordflow}{do} itt=1,6}
\DoxyCodeLine{1613       \textcolor{keyword}{call }calculate\_density(t0, s0, pres, rho\_guess, eqn\_of\_state)}
\DoxyCodeLine{1614       \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state)}
\DoxyCodeLine{1615       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1616         s0(k) = max(0.0, s0(k) + (gv\%Rlay(k) -\/ rho\_guess(k)) / drho\_ds(k))}
\DoxyCodeLine{1617 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1618 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1619   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1620     \textcolor{comment}{! A first guess of the layers' temperatures.}}
\DoxyCodeLine{1621     \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{1622       t0(k) = t0(1) + (gv\%Rlay(k) -\/ rho\_guess(1)) / drho\_dt(1)}
\DoxyCodeLine{1623 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1624     \textcolor{keywordflow}{do} itt=1,6}
\DoxyCodeLine{1625       \textcolor{keyword}{call }calculate\_density(t0, s0, pres, rho\_guess, eqn\_of\_state)}
\DoxyCodeLine{1626       \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state)}
\DoxyCodeLine{1627       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1628         t0(k) = t0(k) + (gv\%Rlay(k) -\/ rho\_guess(k)) / drho\_dt(k)}
\DoxyCodeLine{1629 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1630 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1631 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1632 }
\DoxyCodeLine{1633   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{1634     t(i,j,k) = t0(k) ; s(i,j,k) = s0(k)}
\DoxyCodeLine{1635 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1636 }
\DoxyCodeLine{1637   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a706c24ba7b8a344152ea0d3da051ceb5}\label{namespacemom__state__initialization_a706c24ba7b8a344152ea0d3da051ceb5}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_temp\_salt\_from\_file@{initialize\_temp\_salt\_from\_file}}
\index{initialize\_temp\_salt\_from\_file@{initialize\_temp\_salt\_from\_file}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_temp\_salt\_from\_file()}{initialize\_temp\_salt\_from\_file()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+temp\+\_\+salt\+\_\+from\+\_\+file (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{T,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{S,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initializes temperature and salinity from file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em t} & The potential temperature that is being initialized \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em s} & The salinity that is being initialized \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1450 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1451   \textcolor{keywordtype}{type}(ocean\_grid\_type),                  \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1452 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: T\textcolor{comment}{ !< The potential temperature that is}}
\DoxyCodeLine{1453 \textcolor{comment}{                                                             !! being initialized [degC]}}
\DoxyCodeLine{1454 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: S\textcolor{comment}{ !< The salinity that is}}
\DoxyCodeLine{1455 \textcolor{comment}{                                                             !! being initialized [ppt]}}
\DoxyCodeLine{1456   \textcolor{keywordtype}{type}(param\_file\_type),                  \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{1457   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1458 \textcolor{comment}{                                                           !! only read parameters without changing h.}}
\DoxyCodeLine{1459   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1460   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1461   \textcolor{keywordtype}{character(len=200)} :: filename, salt\_filename \textcolor{comment}{! Full paths to input files}}
\DoxyCodeLine{1462   \textcolor{keywordtype}{character(len=200)} :: ts\_file, salt\_file, inputdir \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{1463   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_temp\_salt\_from\_file"}}
\DoxyCodeLine{1464   \textcolor{keywordtype}{character(len=64)}  :: temp\_var, salt\_var \textcolor{comment}{! Temperature and salinity names in files}}
\DoxyCodeLine{1465 }
\DoxyCodeLine{1466   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1467 }
\DoxyCodeLine{1468   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{1469 }
\DoxyCodeLine{1470   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TS\_FILE"}, ts\_file, \&}
\DoxyCodeLine{1471                  \textcolor{stringliteral}{"The initial condition file for temperature."}, \&}
\DoxyCodeLine{1472                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1473   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1474   inputdir = slasher(inputdir)}
\DoxyCodeLine{1475 }
\DoxyCodeLine{1476   filename = trim(inputdir)//trim(ts\_file)}
\DoxyCodeLine{1477   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/TS\_FILE"}, filename)}
\DoxyCodeLine{1478   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TEMP\_IC\_VAR"}, temp\_var, \&}
\DoxyCodeLine{1479                  \textcolor{stringliteral}{"The initial condition variable for potential temperature."}, \&}
\DoxyCodeLine{1480                  default=\textcolor{stringliteral}{"PTEMP"}, do\_not\_log=just\_read)}
\DoxyCodeLine{1481   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SALT\_IC\_VAR"}, salt\_var, \&}
\DoxyCodeLine{1482                  \textcolor{stringliteral}{"The initial condition variable for salinity."}, \&}
\DoxyCodeLine{1483                  default=\textcolor{stringliteral}{"SALT"}, do\_not\_log=just\_read)}
\DoxyCodeLine{1484   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SALT\_FILE"}, salt\_file, \&}
\DoxyCodeLine{1485                  \textcolor{stringliteral}{"The initial condition file for salinity."}, \&}
\DoxyCodeLine{1486                  default=trim(ts\_file), do\_not\_log=just\_read)}
\DoxyCodeLine{1487 }
\DoxyCodeLine{1488   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1489 }
\DoxyCodeLine{1490   \textcolor{keywordflow}{if} (.not.file\_exists(filename, g\%Domain)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{1491      \textcolor{stringliteral}{" initialize\_temp\_salt\_from\_file: Unable to open "}//trim(filename))}
\DoxyCodeLine{1492 }
\DoxyCodeLine{1493   \textcolor{comment}{! Read the temperatures and salinities from netcdf files.}}
\DoxyCodeLine{1494   \textcolor{keyword}{call }mom\_read\_data(filename, temp\_var, t(:,:,:), g\%Domain)}
\DoxyCodeLine{1495 }
\DoxyCodeLine{1496   salt\_filename = trim(inputdir)//trim(salt\_file)}
\DoxyCodeLine{1497   \textcolor{keywordflow}{if} (.not.file\_exists(salt\_filename, g\%Domain)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{1498      \textcolor{stringliteral}{" initialize\_temp\_salt\_from\_file: Unable to open "}//trim(salt\_filename))}
\DoxyCodeLine{1499 }
\DoxyCodeLine{1500   \textcolor{keyword}{call }mom\_read\_data(salt\_filename, salt\_var, s(:,:,:), g\%Domain)}
\DoxyCodeLine{1501 }
\DoxyCodeLine{1502   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a7d627f0ef1dc66acc764a40fd662a758}\label{namespacemom__state__initialization_a7d627f0ef1dc66acc764a40fd662a758}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_temp\_salt\_from\_profile@{initialize\_temp\_salt\_from\_profile}}
\index{initialize\_temp\_salt\_from\_profile@{initialize\_temp\_salt\_from\_profile}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_temp\_salt\_from\_profile()}{initialize\_temp\_salt\_from\_profile()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+temp\+\_\+salt\+\_\+from\+\_\+profile (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{T,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{S,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initializes temperature and salinity from a 1D profile. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em t} & The potential temperature that is being initialized \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em s} & The salinity that is being initialized \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1506 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1507   \textcolor{keywordtype}{type}(ocean\_grid\_type),                    \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< The ocean's grid structure}}
\DoxyCodeLine{1508 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: T\textcolor{comment}{ !< The potential temperature that is}}
\DoxyCodeLine{1509 \textcolor{comment}{                                                             !! being initialized [degC]}}
\DoxyCodeLine{1510 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: S\textcolor{comment}{ !< The salinity that is}}
\DoxyCodeLine{1511 \textcolor{comment}{                                                             !! being initialized [ppt]}}
\DoxyCodeLine{1512   \textcolor{keywordtype}{type}(param\_file\_type),                    \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{1513   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1514 \textcolor{comment}{                                                           !! only read parameters without changing h.}}
\DoxyCodeLine{1515   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1516 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(G))} :: T0, S0}
\DoxyCodeLine{1517   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{1518   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1519   \textcolor{keywordtype}{character(len=200)} :: filename, ts\_file, inputdir \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{1520   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_temp\_salt\_from\_profile"}}
\DoxyCodeLine{1521 }
\DoxyCodeLine{1522   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1523 }
\DoxyCodeLine{1524   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{1525 }
\DoxyCodeLine{1526   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TS\_FILE"}, ts\_file, \&}
\DoxyCodeLine{1527                  \textcolor{stringliteral}{"The file with the reference profiles for temperature "}//\&}
\DoxyCodeLine{1528                  \textcolor{stringliteral}{"and salinity."}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1529 }
\DoxyCodeLine{1530   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1531 }
\DoxyCodeLine{1532   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1533   inputdir = slasher(inputdir)}
\DoxyCodeLine{1534   filename = trim(inputdir)//trim(ts\_file)}
\DoxyCodeLine{1535   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/TS\_FILE"}, filename)}
\DoxyCodeLine{1536   \textcolor{keywordflow}{if} (.not.file\_exists(filename)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{1537      \textcolor{stringliteral}{" initialize\_temp\_salt\_from\_profile: Unable to open "}//trim(filename))}
\DoxyCodeLine{1538 }
\DoxyCodeLine{1539   \textcolor{comment}{! Read the temperatures and salinities from a netcdf file.}}
\DoxyCodeLine{1540   \textcolor{keyword}{call }mom\_read\_data(filename, \textcolor{stringliteral}{"PTEMP"}, t0(:))}
\DoxyCodeLine{1541   \textcolor{keyword}{call }mom\_read\_data(filename, \textcolor{stringliteral}{"SALT"},  s0(:))}
\DoxyCodeLine{1542 }
\DoxyCodeLine{1543   \textcolor{keywordflow}{do} k=1,g\%ke ; \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1544     t(i,j,k) = t0(k) ; s(i,j,k) = s0(k)}
\DoxyCodeLine{1545 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1546 }
\DoxyCodeLine{1547   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a0793ab167463a3bb45114f57cf018a40}\label{namespacemom__state__initialization_a0793ab167463a3bb45114f57cf018a40}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_temp\_salt\_linear@{initialize\_temp\_salt\_linear}}
\index{initialize\_temp\_salt\_linear@{initialize\_temp\_salt\_linear}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_temp\_salt\_linear()}{initialize\_temp\_salt\_linear()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+temp\+\_\+salt\+\_\+linear (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{T,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{S,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initializes T and S with linear profiles according to reference surface layer salinity and temperature and a specified range. 

\begin{DoxyRemark}{Remarks}
Note that the linear distribution is set up with respect to the layer number, not the physical position). 
\end{DoxyRemark}

\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em t} & The potential temperature that is being initialized \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em s} & The salinity that is being initialized \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1645 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1646   \textcolor{keywordtype}{type}(ocean\_grid\_type),                    \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{          !< The ocean's grid structure}}
\DoxyCodeLine{1647 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: T\textcolor{comment}{ !< The potential temperature that is}}
\DoxyCodeLine{1648 \textcolor{comment}{                                                             !! being initialized [degC]}}
\DoxyCodeLine{1649 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: S\textcolor{comment}{ !< The salinity that is}}
\DoxyCodeLine{1650 \textcolor{comment}{                                                             !! being initialized [ppt]}}
\DoxyCodeLine{1651   \textcolor{keywordtype}{type}(param\_file\_type),                    \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< A structure to parse for}}
\DoxyCodeLine{1652 \textcolor{comment}{                                                                     !! run-\/time parameters}}
\DoxyCodeLine{1653   \textcolor{keywordtype}{logical},                        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true,}}
\DoxyCodeLine{1654 \textcolor{comment}{                                                                      !! this call will only read}}
\DoxyCodeLine{1655 \textcolor{comment}{                                                                      !! parameters without}}
\DoxyCodeLine{1656 \textcolor{comment}{                                                                      !! changing h.}}
\DoxyCodeLine{1657 }
\DoxyCodeLine{1658   \textcolor{keywordtype}{integer} :: k}
\DoxyCodeLine{1659 \textcolor{keywordtype}{  real}  :: delta\_S, delta\_T}
\DoxyCodeLine{1660 \textcolor{keywordtype}{  real}  :: S\_top, T\_top \textcolor{comment}{! Reference salinity and temerature within surface layer}}
\DoxyCodeLine{1661 \textcolor{keywordtype}{  real}  :: S\_range, T\_range \textcolor{comment}{! Range of salinities and temperatures over the vertical}}
\DoxyCodeLine{1662 \textcolor{keywordtype}{  real}  :: delta}
\DoxyCodeLine{1663   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1664   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_temp\_salt\_linear"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{1665 }
\DoxyCodeLine{1666   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1667 }
\DoxyCodeLine{1668   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{1669   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"T\_TOP"}, t\_top, \&}
\DoxyCodeLine{1670                  \textcolor{stringliteral}{"Initial temperature of the top surface."}, \&}
\DoxyCodeLine{1671                  units=\textcolor{stringliteral}{"degC"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1672   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"T\_RANGE"}, t\_range, \&}
\DoxyCodeLine{1673                  \textcolor{stringliteral}{"Initial temperature difference (top-\/bottom)."}, \&}
\DoxyCodeLine{1674                  units=\textcolor{stringliteral}{"degC"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1675   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_TOP"}, s\_top, \&}
\DoxyCodeLine{1676                  \textcolor{stringliteral}{"Initial salinity of the top surface."}, \&}
\DoxyCodeLine{1677                  units=\textcolor{stringliteral}{"PSU"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1678   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_RANGE"}, s\_range, \&}
\DoxyCodeLine{1679                  \textcolor{stringliteral}{"Initial salinity difference (top-\/bottom)."}, \&}
\DoxyCodeLine{1680                  units=\textcolor{stringliteral}{"PSU"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1681 }
\DoxyCodeLine{1682   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1683 }
\DoxyCodeLine{1684   \textcolor{comment}{! Prescribe salinity}}
\DoxyCodeLine{1685 \textcolor{comment}{! delta\_S = S\_range / ( G\%ke -\/ 1.0 )}}
\DoxyCodeLine{1686 \textcolor{comment}{! S(:,:,1) = S\_top}}
\DoxyCodeLine{1687 \textcolor{comment}{! do k = 2,G\%ke}}
\DoxyCodeLine{1688 \textcolor{comment}{!   S(:,:,k) = S(:,:,k-\/1) + delta\_S}}
\DoxyCodeLine{1689 \textcolor{comment}{! enddo}}
\DoxyCodeLine{1690   \textcolor{keywordflow}{do} k = 1,g\%ke}
\DoxyCodeLine{1691     s(:,:,k) = s\_top -\/ s\_range*((real(k)-\/0.5)/real(g\%ke))}
\DoxyCodeLine{1692     t(:,:,k) = t\_top -\/ t\_range*((real(k)-\/0.5)/real(g\%ke))}
\DoxyCodeLine{1693 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1694 }
\DoxyCodeLine{1695   \textcolor{comment}{! Prescribe temperature}}
\DoxyCodeLine{1696 \textcolor{comment}{! delta\_T = T\_range / ( G\%ke -\/ 1.0 )}}
\DoxyCodeLine{1697 \textcolor{comment}{! T(:,:,1) = T\_top}}
\DoxyCodeLine{1698 \textcolor{comment}{! do k = 2,G\%ke}}
\DoxyCodeLine{1699 \textcolor{comment}{!   T(:,:,k) = T(:,:,k-\/1) + delta\_T}}
\DoxyCodeLine{1700 \textcolor{comment}{! enddo}}
\DoxyCodeLine{1701 \textcolor{comment}{! delta = 1}}
\DoxyCodeLine{1702 \textcolor{comment}{! T(:,:,G\%ke/2 -\/ (delta-\/1):G\%ke/2 + delta) = 1.0}}
\DoxyCodeLine{1703 }
\DoxyCodeLine{1704   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a847ac374f69c4777e3e49a5ebdcebf43}\label{namespacemom__state__initialization_a847ac374f69c4777e3e49a5ebdcebf43}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_thickness\_from\_file@{initialize\_thickness\_from\_file}}
\index{initialize\_thickness\_from\_file@{initialize\_thickness\_from\_file}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_thickness\_from\_file()}{initialize\_thickness\_from\_file()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+thickness\+\_\+from\+\_\+file (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(out)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in)}]{file\+\_\+has\+\_\+thickness,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Reads the layer thicknesses or interface heights from a file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ out}}  & {\em h} & The thickness that is being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em file\+\_\+has\+\_\+thickness} & If true, this file contains layer thicknesses; otherwise it contains interface heights. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 619 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{621   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{622   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{623   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{624 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{625                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{    !< The thickness that is being initialized [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{626   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}}
\DoxyCodeLine{627 \textcolor{comment}{                                               !! to parse for model parameter values.}}
\DoxyCodeLine{628   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}  :: file\_has\_thickness\textcolor{comment}{ !< If true, this file contains layer}}
\DoxyCodeLine{629 \textcolor{comment}{                                               !! thicknesses; otherwise it contains}}
\DoxyCodeLine{630 \textcolor{comment}{                                               !! interface heights.}}
\DoxyCodeLine{631   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{632 \textcolor{comment}{                                               !! only read parameters without changing h.}}
\DoxyCodeLine{633 }
\DoxyCodeLine{634   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{635 \textcolor{keywordtype}{  real} :: eta(SZI\_(G),SZJ\_(G),SZK\_(G)+1)  \textcolor{comment}{! Interface heights, in depth units.}}
\DoxyCodeLine{636   \textcolor{keywordtype}{integer} :: inconsistent = 0}
\DoxyCodeLine{637   \textcolor{keywordtype}{logical} :: correct\_thickness}
\DoxyCodeLine{638   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{639   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_thickness\_from\_file"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{640   \textcolor{keywordtype}{character(len=200)} :: filename, thickness\_file, inputdir, mesg \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{641   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{642 }
\DoxyCodeLine{643   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{644 }
\DoxyCodeLine{645   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{646 }
\DoxyCodeLine{647   \textcolor{keywordflow}{if} (.not.just\_read) \&}
\DoxyCodeLine{648     \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{649 }
\DoxyCodeLine{650   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."}, do\_not\_log=just\_read)}
\DoxyCodeLine{651   inputdir = slasher(inputdir)}
\DoxyCodeLine{652   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"THICKNESS\_FILE"}, thickness\_file, \&}
\DoxyCodeLine{653                  \textcolor{stringliteral}{"The name of the thickness file."}, \&}
\DoxyCodeLine{654                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{655 }
\DoxyCodeLine{656   filename = trim(inputdir)//trim(thickness\_file)}
\DoxyCodeLine{657   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/THICKNESS\_FILE"}, filename)}
\DoxyCodeLine{658 }
\DoxyCodeLine{659   \textcolor{keywordflow}{if} ((.not.just\_read) .and. (.not.file\_exists(filename, g\%Domain))) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{660          \textcolor{stringliteral}{" initialize\_thickness\_from\_file: Unable to open "}//trim(filename))}
\DoxyCodeLine{661 }
\DoxyCodeLine{662   \textcolor{keywordflow}{if} (file\_has\_thickness) \textcolor{keywordflow}{then}}
\DoxyCodeLine{663     \textcolor{comment}{!\#\#\# Consider adding a parameter to use to rescale h.}}
\DoxyCodeLine{664     \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{665     \textcolor{keyword}{call }mom\_read\_data(filename, \textcolor{stringliteral}{"h"}, h(:,:,:), g\%Domain, scale=gv\%m\_to\_H)}
\DoxyCodeLine{666   \textcolor{keywordflow}{else}}
\DoxyCodeLine{667     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADJUST\_THICKNESS"}, correct\_thickness, \&}
\DoxyCodeLine{668                  \textcolor{stringliteral}{"If true, all mass below the bottom removed if the "}//\&}
\DoxyCodeLine{669                  \textcolor{stringliteral}{"topography is shallower than the thickness input file "}//\&}
\DoxyCodeLine{670                  \textcolor{stringliteral}{"would indicate."}, default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{671     \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{672 }
\DoxyCodeLine{673     \textcolor{keyword}{call }mom\_read\_data(filename, \textcolor{stringliteral}{"eta"}, eta(:,:,:), g\%Domain, scale=us\%m\_to\_Z)}
\DoxyCodeLine{674 }
\DoxyCodeLine{675     \textcolor{keywordflow}{if} (correct\_thickness) \textcolor{keywordflow}{then}}
\DoxyCodeLine{676       \textcolor{keyword}{call }adjustetatofitbathymetry(g, gv, us, eta, h)}
\DoxyCodeLine{677     \textcolor{keywordflow}{else}}
\DoxyCodeLine{678       \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{679         \textcolor{keywordflow}{if} (eta(i,j,k) < (eta(i,j,k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{680           eta(i,j,k) = eta(i,j,k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{681           h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{682         \textcolor{keywordflow}{else}}
\DoxyCodeLine{683           h(i,j,k) = gv\%Z\_to\_H * (eta(i,j,k) -\/ eta(i,j,k+1))}
\DoxyCodeLine{684 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{685 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{686 }
\DoxyCodeLine{687       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{688         \textcolor{keywordflow}{if} (abs(eta(i,j,nz+1) + g\%bathyT(i,j)) > 1.0*us\%m\_to\_Z) \&}
\DoxyCodeLine{689           inconsistent = inconsistent + 1}
\DoxyCodeLine{690 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{691       \textcolor{keyword}{call }sum\_across\_pes(inconsistent)}
\DoxyCodeLine{692 }
\DoxyCodeLine{693       \textcolor{keywordflow}{if} ((inconsistent > 0) .and. (is\_root\_pe())) \textcolor{keywordflow}{then}}
\DoxyCodeLine{694         \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Thickness initial conditions are inconsistent ",'}// \&}
\DoxyCodeLine{695                  \textcolor{stringliteral}{'"with topography in ",I8," places.")'}) inconsistent}
\DoxyCodeLine{696         \textcolor{keyword}{call }mom\_error(warning, mesg)}
\DoxyCodeLine{697 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{698 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{699 }
\DoxyCodeLine{700 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{701   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_ade07252728855ac18a50b547f0cb16f7}\label{namespacemom__state__initialization_ade07252728855ac18a50b547f0cb16f7}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_thickness\_list@{initialize\_thickness\_list}}
\index{initialize\_thickness\_list@{initialize\_thickness\_list}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_thickness\_list()}{initialize\_thickness\_list()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+thickness\+\_\+list (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initialize thickness from a 1D list. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ out}}  & {\em h} & The thickness that is being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 841 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{842   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{           !< The ocean's grid structure.}}
\DoxyCodeLine{843   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{          !< The ocean's vertical grid structure.}}
\DoxyCodeLine{844   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{845 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{846                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{           !< The thickness that is being initialized [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{847   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}}
\DoxyCodeLine{848 \textcolor{comment}{                                                      !! to parse for model parameter values.}}
\DoxyCodeLine{849   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{850 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{851   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{852   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_thickness\_list"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{853 \textcolor{keywordtype}{  real} :: e0(SZK\_(G)+1)   \textcolor{comment}{! The resting interface heights, in depth units [Z \string~> m],}}
\DoxyCodeLine{854                           \textcolor{comment}{! usually negative because it is positive upward.}}
\DoxyCodeLine{855 \textcolor{keywordtype}{  real} :: eta1D(SZK\_(G)+1)\textcolor{comment}{! Interface height relative to the sea surface}}
\DoxyCodeLine{856                           \textcolor{comment}{! positive upward, in depth units [Z \string~> m].}}
\DoxyCodeLine{857   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{858   \textcolor{keywordtype}{character(len=200)} :: filename, eta\_file, inputdir \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{859   \textcolor{keywordtype}{character(len=72)}  :: eta\_var}
\DoxyCodeLine{860   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{861 }
\DoxyCodeLine{862   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{863 }
\DoxyCodeLine{864   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{865 }
\DoxyCodeLine{866   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERFACE\_IC\_FILE"}, eta\_file, \&}
\DoxyCodeLine{867                  \textcolor{stringliteral}{"The file from which horizontal mean initial conditions "}//\&}
\DoxyCodeLine{868                  \textcolor{stringliteral}{"for interface depths can be read."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{869   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERFACE\_IC\_VAR"}, eta\_var, \&}
\DoxyCodeLine{870                  \textcolor{stringliteral}{"The variable name for horizontal mean initial conditions "}//\&}
\DoxyCodeLine{871                  \textcolor{stringliteral}{"for interface depths relative to mean sea level."}, \&}
\DoxyCodeLine{872                  default=\textcolor{stringliteral}{"eta"})}
\DoxyCodeLine{873 }
\DoxyCodeLine{874   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return}}
\DoxyCodeLine{875 }
\DoxyCodeLine{876   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{877 }
\DoxyCodeLine{878   \textcolor{keyword}{call }get\_param(param\_file,  mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{879   filename = trim(slasher(inputdir))//trim(eta\_file)}
\DoxyCodeLine{880   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/INTERFACE\_IC\_FILE"}, filename)}
\DoxyCodeLine{881 }
\DoxyCodeLine{882   e0(:) = 0.0}
\DoxyCodeLine{883   \textcolor{keyword}{call }mom\_read\_data(filename, eta\_var, e0(:), scale=us\%m\_to\_Z)}
\DoxyCodeLine{884 }
\DoxyCodeLine{885   \textcolor{keywordflow}{if} ((abs(e0(1)) -\/ 0.0) > 0.001) \textcolor{keywordflow}{then}}
\DoxyCodeLine{886     \textcolor{comment}{! This list probably starts with the interior interface, so shift it up.}}
\DoxyCodeLine{887     \textcolor{keywordflow}{do} k=nz+1,2,-\/1 ; e0(k) = e0(k-\/1) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{888     e0(1) = 0.0}
\DoxyCodeLine{889 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{890 }
\DoxyCodeLine{891   \textcolor{keywordflow}{if} (e0(2) > e0(1)) \textcolor{keywordflow}{then} \textcolor{comment}{! Switch to the convention for interface heights increasing upward.}}
\DoxyCodeLine{892     \textcolor{keywordflow}{do} k=1,nz ; e0(k) = -\/e0(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{893 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{894 }
\DoxyCodeLine{895   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{896     \textcolor{comment}{! This sets the initial thickness (in m) of the layers.  The}}
\DoxyCodeLine{897     \textcolor{comment}{! thicknesses are set to insure that: 1.  each layer is at least an}}
\DoxyCodeLine{898     \textcolor{comment}{! Angstrom thick, and 2.  the interfaces are where they should be}}
\DoxyCodeLine{899     \textcolor{comment}{! based on the resting depths and interface height perturbations,}}
\DoxyCodeLine{900     \textcolor{comment}{! as long at this doesn't interfere with 1.}}
\DoxyCodeLine{901     eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{902     \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{903       eta1d(k) = e0(k)}
\DoxyCodeLine{904       \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{905         eta1d(k) = eta1d(k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{906         h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{907       \textcolor{keywordflow}{else}}
\DoxyCodeLine{908         h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{909 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{910 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{911 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{912 }
\DoxyCodeLine{913   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a06f7a21e110b80140439dedccaf4fa1c}\label{namespacemom__state__initialization_a06f7a21e110b80140439dedccaf4fa1c}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_thickness\_uniform@{initialize\_thickness\_uniform}}
\index{initialize\_thickness\_uniform@{initialize\_thickness\_uniform}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_thickness\_uniform()}{initialize\_thickness\_uniform()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+thickness\+\_\+uniform (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out)}]{h,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initializes thickness to be uniform. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ out}}  & {\em h} & The thickness that is being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 786 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{787   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{           !< The ocean's grid structure.}}
\DoxyCodeLine{788   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{          !< The ocean's vertical grid structure.}}
\DoxyCodeLine{789 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{790                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{           !< The thickness that is being initialized [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{791   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}}
\DoxyCodeLine{792 \textcolor{comment}{                                                      !! to parse for model parameter values.}}
\DoxyCodeLine{793   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{794 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{795   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{796   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_thickness\_uniform"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{797 \textcolor{keywordtype}{  real} :: e0(SZK\_(G)+1)   \textcolor{comment}{! The resting interface heights, in depth units, usually}}
\DoxyCodeLine{798                           \textcolor{comment}{! negative because it is positive upward.}}
\DoxyCodeLine{799 \textcolor{keywordtype}{  real} :: eta1D(SZK\_(G)+1)\textcolor{comment}{! Interface height relative to the sea surface}}
\DoxyCodeLine{800                           \textcolor{comment}{! positive upward, in depth units.}}
\DoxyCodeLine{801   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{802   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{803 }
\DoxyCodeLine{804   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{805 }
\DoxyCodeLine{806   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{807 }
\DoxyCodeLine{808   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! This subroutine has no run-\/time parameters.}}
\DoxyCodeLine{809 }
\DoxyCodeLine{810   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{811 }
\DoxyCodeLine{812   \textcolor{keywordflow}{if} (g\%max\_depth<=0.) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_thickness\_uniform: "}// \&}
\DoxyCodeLine{813       \textcolor{stringliteral}{"MAXIMUM\_DEPTH has a non-\/sensical value! Was it set?"})}
\DoxyCodeLine{814 }
\DoxyCodeLine{815   \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{816     e0(k) = -\/g\%max\_depth * real(k-\/1) / real(nz)}
\DoxyCodeLine{817 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{818 }
\DoxyCodeLine{819   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{820     \textcolor{comment}{! This sets the initial thickness (in m) of the layers.  The}}
\DoxyCodeLine{821     \textcolor{comment}{! thicknesses are set to insure that: 1.  each layer is at least an}}
\DoxyCodeLine{822     \textcolor{comment}{! Angstrom thick, and 2.  the interfaces are where they should be}}
\DoxyCodeLine{823     \textcolor{comment}{! based on the resting depths and interface height perturbations,}}
\DoxyCodeLine{824     \textcolor{comment}{! as long at this doesn't interfere with 1.}}
\DoxyCodeLine{825     eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{826     \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{827       eta1d(k) = e0(k)}
\DoxyCodeLine{828       \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{829         eta1d(k) = eta1d(k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{830         h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{831       \textcolor{keywordflow}{else}}
\DoxyCodeLine{832         h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{833 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{834 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{835 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{836 }
\DoxyCodeLine{837   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_af4ebdba67fde58a9aa7633bca4c117ba}\label{namespacemom__state__initialization_af4ebdba67fde58a9aa7633bca4c117ba}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_velocity\_circular@{initialize\_velocity\_circular}}
\index{initialize\_velocity\_circular@{initialize\_velocity\_circular}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_velocity\_circular()}{initialize\_velocity\_circular()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+velocity\+\_\+circular (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(out)}]{v,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the initial velocity components to be circular with no flow at edges of domain and center. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em u} & The zonal velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em v} & The meridional velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1387 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1388   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< The ocean's grid structure}}
\DoxyCodeLine{1389 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1390                            \textcolor{keywordtype}{intent(out)} :: u\textcolor{comment}{  !< The zonal velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1391 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1392                            \textcolor{keywordtype}{intent(out)} :: v\textcolor{comment}{  !< The meridional velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1393   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{1394   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file to}}
\DoxyCodeLine{1395 \textcolor{comment}{                                                      !! parse for model parameter values.}}
\DoxyCodeLine{1396   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1397 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{1398   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1399   \textcolor{keywordtype}{character(len=200)} :: mdl = \textcolor{stringliteral}{"initialize\_velocity\_circular"}}
\DoxyCodeLine{1400 \textcolor{keywordtype}{  real} :: circular\_max\_u \textcolor{comment}{! The amplitude of the zonal flow [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1401 \textcolor{keywordtype}{  real} :: dpi        \textcolor{comment}{! A local variable storing pi = 3.14159265358979...}}
\DoxyCodeLine{1402 \textcolor{keywordtype}{  real} :: psi1, psi2 \textcolor{comment}{! Values of the streamfunction at two points [L2 T-\/1 \string~> m2 s-\/1]}}
\DoxyCodeLine{1403   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1404   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz}
\DoxyCodeLine{1405   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{1406   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{1407 }
\DoxyCodeLine{1408   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1409 }
\DoxyCodeLine{1410   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CIRCULAR\_MAX\_U"}, circular\_max\_u, \&}
\DoxyCodeLine{1411                  \textcolor{stringliteral}{"The amplitude of zonal flow from which to scale the "}// \&}
\DoxyCodeLine{1412                  \textcolor{stringliteral}{"circular stream function [m s-\/1]."}, \&}
\DoxyCodeLine{1413                  units=\textcolor{stringliteral}{"m s-\/1"}, default=0., scale=us\%m\_s\_to\_L\_T, do\_not\_log=just\_read)}
\DoxyCodeLine{1414 }
\DoxyCodeLine{1415   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1416 }
\DoxyCodeLine{1417   dpi=acos(0.0)*2.0 \textcolor{comment}{! pi}}
\DoxyCodeLine{1418 }
\DoxyCodeLine{1419   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1420     psi1 = my\_psi(i,j)}
\DoxyCodeLine{1421     psi2 = my\_psi(i,j-\/1)}
\DoxyCodeLine{1422     u(i,j,k) = (psi1 -\/ psi2) / g\%dy\_Cu(i,j) \textcolor{comment}{! *(circular\_max\_u*G\%len\_lon/(2.0*dpi))}}
\DoxyCodeLine{1423 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1424   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1425     psi1 = my\_psi(i,j)}
\DoxyCodeLine{1426     psi2 = my\_psi(i-\/1,j)}
\DoxyCodeLine{1427     v(i,j,k) = (psi2 -\/ psi1) / g\%dx\_Cv(i,j) \textcolor{comment}{! *(circular\_max\_u*G\%len\_lon/(2.0*dpi))}}
\DoxyCodeLine{1428 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1429 }
\DoxyCodeLine{1430   \textcolor{keyword}{contains}}
\DoxyCodeLine{1431 \textcolor{comment}{}}
\DoxyCodeLine{1432 \textcolor{comment}{  !> Returns the value of a circular stream function at (ig,jg) in [L2 T-\/1 \string~> m2 s-\/1]}}
\DoxyCodeLine{1433 \textcolor{keywordtype}{  real} function my\_psi(ig,jg)}
\DoxyCodeLine{1434     \textcolor{keywordtype}{integer} :: ig\textcolor{comment}{ !< Global i-\/index}}
\DoxyCodeLine{1435     \textcolor{keywordtype}{integer} :: jg\textcolor{comment}{ !< Global j-\/index}}
\DoxyCodeLine{1436     \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1437 \textcolor{keywordtype}{    real} :: x, y, r \textcolor{comment}{! [nondim]}}
\DoxyCodeLine{1438 }
\DoxyCodeLine{1439     x = 2.0*(g\%geoLonBu(ig,jg)-\/g\%west\_lon) / g\%len\_lon -\/ 1.0  \textcolor{comment}{! -\/1<x<1}}
\DoxyCodeLine{1440     y = 2.0*(g\%geoLatBu(ig,jg)-\/g\%south\_lat) / g\%len\_lat -\/ 1.0 \textcolor{comment}{! -\/1<y<1}}
\DoxyCodeLine{1441     r = sqrt( x**2 + y**2 ) \textcolor{comment}{! Circular stream function is a function of radius only}}
\DoxyCodeLine{1442     r = min(1.0, r) \textcolor{comment}{! Flatten stream function in corners of box}}
\DoxyCodeLine{1443     my\_psi = 0.5*(1.0 -\/ cos(dpi*r))}
\DoxyCodeLine{1444     my\_psi = my\_psi * (circular\_max\_u * g\%US\%m\_to\_L*g\%len\_lon*1e3 / dpi) \textcolor{comment}{! len\_lon is in km}}
\DoxyCodeLine{1445   \textcolor{keyword}{end function }my\_psi}
\DoxyCodeLine{1446 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_adcedb30eb6f940cef3fbdd4328aedef8}\label{namespacemom__state__initialization_adcedb30eb6f940cef3fbdd4328aedef8}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_velocity\_from\_file@{initialize\_velocity\_from\_file}}
\index{initialize\_velocity\_from\_file@{initialize\_velocity\_from\_file}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_velocity\_from\_file()}{initialize\_velocity\_from\_file()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+velocity\+\_\+from\+\_\+file (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(out)}]{v,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initialize horizontal velocity components from file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em u} & The zonal velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em v} & The meridional velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for modelparameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1271 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1272   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< The ocean's grid structure}}
\DoxyCodeLine{1273 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1274                            \textcolor{keywordtype}{intent(out)} :: u\textcolor{comment}{  !< The zonal velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1275 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1276                            \textcolor{keywordtype}{intent(out)} :: v\textcolor{comment}{  !< The meridional velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1277   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{1278   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file to}}
\DoxyCodeLine{1279 \textcolor{comment}{                                                      !! parse for modelparameter values.}}
\DoxyCodeLine{1280   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1281 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{1282   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1283   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_velocity\_from\_file"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{1284   \textcolor{keywordtype}{character(len=200)} :: filename,velocity\_file,inputdir \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{1285   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1286 }
\DoxyCodeLine{1287   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1288 }
\DoxyCodeLine{1289   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{1290 }
\DoxyCodeLine{1291   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"VELOCITY\_FILE"}, velocity\_file, \&}
\DoxyCodeLine{1292                  \textcolor{stringliteral}{"The name of the velocity initial condition file."}, \&}
\DoxyCodeLine{1293                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1294   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1295   inputdir = slasher(inputdir)}
\DoxyCodeLine{1296 }
\DoxyCodeLine{1297   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1298 }
\DoxyCodeLine{1299   filename = trim(inputdir)//trim(velocity\_file)}
\DoxyCodeLine{1300   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/VELOCITY\_FILE"}, filename)}
\DoxyCodeLine{1301 }
\DoxyCodeLine{1302   \textcolor{keywordflow}{if} (.not.file\_exists(filename, g\%Domain)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{1303          \textcolor{stringliteral}{" initialize\_velocity\_from\_file: Unable to open "}//trim(filename))}
\DoxyCodeLine{1304 }
\DoxyCodeLine{1305   \textcolor{comment}{!  Read the velocities from a netcdf file.}}
\DoxyCodeLine{1306   \textcolor{keyword}{call }mom\_read\_vector(filename, \textcolor{stringliteral}{"u"}, \textcolor{stringliteral}{"v"}, u(:,:,:), v(:,:,:), g\%Domain, scale=us\%m\_s\_to\_L\_T)}
\DoxyCodeLine{1307 }
\DoxyCodeLine{1308   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_ac10655a7937f2239ff8ae9b899f4bc4b}\label{namespacemom__state__initialization_ac10655a7937f2239ff8ae9b899f4bc4b}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_velocity\_uniform@{initialize\_velocity\_uniform}}
\index{initialize\_velocity\_uniform@{initialize\_velocity\_uniform}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_velocity\_uniform()}{initialize\_velocity\_uniform()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+velocity\+\_\+uniform (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(out)}]{v,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the initial velocity components to uniform. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em u} & The zonal velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em v} & The meridional velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for modelparameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1346 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1347   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< The ocean's grid structure}}
\DoxyCodeLine{1348 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1349                            \textcolor{keywordtype}{intent(out)} :: u\textcolor{comment}{  !< The zonal velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1350 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1351                            \textcolor{keywordtype}{intent(out)} :: v\textcolor{comment}{  !< The meridional velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1352   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{1353   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file to}}
\DoxyCodeLine{1354 \textcolor{comment}{                                                      !! parse for modelparameter values.}}
\DoxyCodeLine{1355   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1356 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{1357   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1358   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz}
\DoxyCodeLine{1359 \textcolor{keywordtype}{  real}    :: initial\_u\_const, initial\_v\_const}
\DoxyCodeLine{1360   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1361   \textcolor{keywordtype}{character(len=200)} :: mdl = \textcolor{stringliteral}{"initialize\_velocity\_uniform"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{1362   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{1363   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{1364 }
\DoxyCodeLine{1365   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1366 }
\DoxyCodeLine{1367   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INITIAL\_U\_CONST"}, initial\_u\_const, \&}
\DoxyCodeLine{1368                  \textcolor{stringliteral}{"A initial uniform value for the zonal flow."}, \&}
\DoxyCodeLine{1369                  default=0.0, units=\textcolor{stringliteral}{"m s-\/1"}, scale=us\%m\_s\_to\_L\_T, do\_not\_log=just\_read)}
\DoxyCodeLine{1370   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INITIAL\_V\_CONST"}, initial\_v\_const, \&}
\DoxyCodeLine{1371                  \textcolor{stringliteral}{"A initial uniform value for the meridional flow."}, \&}
\DoxyCodeLine{1372                  default=0.0, units=\textcolor{stringliteral}{"m s-\/1"}, scale=us\%m\_s\_to\_L\_T, do\_not\_log=just\_read)}
\DoxyCodeLine{1373 }
\DoxyCodeLine{1374   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1375 }
\DoxyCodeLine{1376   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1377     u(i,j,k) = initial\_u\_const}
\DoxyCodeLine{1378 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1379   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1380     v(i,j,k) = initial\_v\_const}
\DoxyCodeLine{1381 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1382 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a1de6eb1d89deb76196b2876c8982a956}\label{namespacemom__state__initialization_a1de6eb1d89deb76196b2876c8982a956}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!initialize\_velocity\_zero@{initialize\_velocity\_zero}}
\index{initialize\_velocity\_zero@{initialize\_velocity\_zero}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{initialize\_velocity\_zero()}{initialize\_velocity\_zero()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::initialize\+\_\+velocity\+\_\+zero (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(out)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(out)}]{v,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initialize horizontal velocity components to zero. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em u} & The zonal velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em v} & The meridional velocity that is being initialized \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for modelparameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1312 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1313   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< The ocean's grid structure}}
\DoxyCodeLine{1314 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1315                            \textcolor{keywordtype}{intent(out)} :: u\textcolor{comment}{  !< The zonal velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1316 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1317                            \textcolor{keywordtype}{intent(out)} :: v\textcolor{comment}{  !< The meridional velocity that is being initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1318   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file to}}
\DoxyCodeLine{1319 \textcolor{comment}{                                                      !! parse for modelparameter values.}}
\DoxyCodeLine{1320   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1321 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{1322   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1323   \textcolor{keywordtype}{character(len=200)} :: mdl = \textcolor{stringliteral}{"initialize\_velocity\_zero"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{1324   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1325   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz}
\DoxyCodeLine{1326   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{1327   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{1328 }
\DoxyCodeLine{1329   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1330 }
\DoxyCodeLine{1331   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{1332 }
\DoxyCodeLine{1333   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1334 }
\DoxyCodeLine{1335   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1336     u(i,j,k) = 0.0}
\DoxyCodeLine{1337 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1338   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1339     v(i,j,k) = 0.0}
\DoxyCodeLine{1340 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1341 }
\DoxyCodeLine{1342   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a81503d4f1855cb185f122d6314e4f06c}\label{namespacemom__state__initialization_a81503d4f1855cb185f122d6314e4f06c}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!mom\_initialize\_state@{mom\_initialize\_state}}
\index{mom\_initialize\_state@{mom\_initialize\_state}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{mom\_initialize\_state()}{mom\_initialize\_state()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+state\+\_\+initialization\+::mom\+\_\+initialize\+\_\+state (\begin{DoxyParamCaption}\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(out)}]{v,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{type(time\+\_\+type), intent(inout)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF,  }\item[{type(directories), intent(in)}]{dirs,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS,  }\item[{type(ale\+\_\+cs), pointer}]{A\+L\+E\+\_\+\+C\+Sp,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{tracer\+\_\+\+Reg,  }\item[{type(sponge\+\_\+cs), pointer}]{sponge\+\_\+\+C\+Sp,  }\item[{type(ale\+\_\+sponge\+\_\+cs), pointer}]{A\+L\+E\+\_\+sponge\+\_\+\+C\+Sp,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(time\+\_\+type), intent(in), optional}]{Time\+\_\+in }\end{DoxyParamCaption})}



Initialize temporally evolving fields, either as initial conditions or by reading them from a restart (or saves) file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ out}}  & {\em u} & The zonal velocity that is being \\
\hline
\mbox{\texttt{ out}}  & {\em v} & The meridional velocity that is being \\
\hline
\mbox{\texttt{ out}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\mbox{\texttt{ in,out}}  & {\em time} & Time at the start of the run segment. \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em dirs} & A structure containing several relevant directory paths. \\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure. \\
\hline
 & {\em ale\+\_\+csp} & The A\+LE control structure for remapping \\
\hline
 & {\em tracer\+\_\+reg} & A pointer to the tracer registry \\
\hline
 & {\em sponge\+\_\+csp} & The layerwise sponge control structure. \\
\hline
 & {\em ale\+\_\+sponge\+\_\+csp} & The A\+LE sponge control structure. \\
\hline
 & {\em obc} & The open boundary condition control structure. \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+in} & Time at the start of the run segment. Time\+\_\+in overrides any value set for Time. \\
\hline
\end{DoxyParams}


Definition at line 114 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{117   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{118   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{119   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{120 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{121                               \textcolor{keywordtype}{intent(out)}   :: u\textcolor{comment}{    !< The zonal velocity that is being}}
\DoxyCodeLine{122 \textcolor{comment}{                                                    !! initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{123 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{124                               \textcolor{keywordtype}{intent(out)}   :: v\textcolor{comment}{    !< The meridional velocity that is being}}
\DoxyCodeLine{125 \textcolor{comment}{                                                    !! initialized [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{126 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \&}
\DoxyCodeLine{127                               \textcolor{keywordtype}{intent(out)}   :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{128   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic}}
\DoxyCodeLine{129 \textcolor{comment}{                                                    !! variables}}
\DoxyCodeLine{130   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(inout)} :: Time\textcolor{comment}{ !< Time at the start of the run segment.}}
\DoxyCodeLine{131   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{   !< A structure indicating the open file to parse}}
\DoxyCodeLine{132 \textcolor{comment}{                                                    !! for model parameter values.}}
\DoxyCodeLine{133   \textcolor{keywordtype}{type}(directories),          \textcolor{keywordtype}{intent(in)}    :: dirs\textcolor{comment}{ !< A structure containing several relevant}}
\DoxyCodeLine{134 \textcolor{comment}{                                                    !! directory paths.}}
\DoxyCodeLine{135   \textcolor{keywordtype}{type}(MOM\_restart\_CS),       \textcolor{keywordtype}{pointer}       :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control}}
\DoxyCodeLine{136 \textcolor{comment}{                                                    !! structure.}}
\DoxyCodeLine{137   \textcolor{keywordtype}{type}(ALE\_CS),               \textcolor{keywordtype}{pointer}       :: ALE\_CSp\textcolor{comment}{ !< The ALE control structure for remapping}}
\DoxyCodeLine{138   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}       :: tracer\_Reg\textcolor{comment}{ !< A pointer to the tracer registry}}
\DoxyCodeLine{139   \textcolor{keywordtype}{type}(sponge\_CS),            \textcolor{keywordtype}{pointer}       :: sponge\_CSp\textcolor{comment}{ !< The layerwise sponge control structure.}}
\DoxyCodeLine{140   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),        \textcolor{keywordtype}{pointer}       :: ALE\_sponge\_CSp\textcolor{comment}{ !< The ALE sponge control structure.}}
\DoxyCodeLine{141   \textcolor{keywordtype}{type}(ocean\_OBC\_type),       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{   !< The open boundary condition control structure.}}
\DoxyCodeLine{142   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)}    :: Time\_in\textcolor{comment}{ !< Time at the start of the run segment.}}
\DoxyCodeLine{143 \textcolor{comment}{                                                     !! Time\_in overrides any value set for Time.}}
\DoxyCodeLine{144   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{145   \textcolor{keywordtype}{character(len=200)} :: filename   \textcolor{comment}{! The name of an input file.}}
\DoxyCodeLine{146   \textcolor{keywordtype}{character(len=200)} :: filename2  \textcolor{comment}{! The name of an input files.}}
\DoxyCodeLine{147   \textcolor{keywordtype}{character(len=200)} :: inputdir   \textcolor{comment}{! The directory where NetCDF input files are.}}
\DoxyCodeLine{148   \textcolor{keywordtype}{character(len=200)} :: config}
\DoxyCodeLine{149 \textcolor{keywordtype}{  real} :: H\_rescale   \textcolor{comment}{! A rescaling factor for thicknesses from the representation in}}
\DoxyCodeLine{150                       \textcolor{comment}{! a restart file to the internal representation in this run.}}
\DoxyCodeLine{151 \textcolor{keywordtype}{  real} :: vel\_rescale \textcolor{comment}{! A rescaling factor for velocities from the representation in}}
\DoxyCodeLine{152                       \textcolor{comment}{! a restart file to the internal representation in this run.}}
\DoxyCodeLine{153 \textcolor{keywordtype}{  real} :: dt          \textcolor{comment}{! The baroclinic dynamics timestep for this run [T \string~> s].}}
\DoxyCodeLine{154   \textcolor{keywordtype}{logical} :: from\_Z\_file, useALE}
\DoxyCodeLine{155   \textcolor{keywordtype}{logical} :: new\_sim}
\DoxyCodeLine{156   \textcolor{keywordtype}{integer} :: write\_geom}
\DoxyCodeLine{157   \textcolor{keywordtype}{logical} :: use\_temperature, use\_sponge, use\_OBC}
\DoxyCodeLine{158   \textcolor{keywordtype}{logical} :: use\_EOS     \textcolor{comment}{! If true, density is calculated from T \& S using an equation of state.}}
\DoxyCodeLine{159   \textcolor{keywordtype}{logical} :: depress\_sfc \textcolor{comment}{! If true, remove the mass that would be displaced}}
\DoxyCodeLine{160                          \textcolor{comment}{! by a large surface pressure by squeezing the column.}}
\DoxyCodeLine{161   \textcolor{keywordtype}{logical} :: trim\_ic\_for\_p\_surf \textcolor{comment}{! If true, remove the mass that would be displaced}}
\DoxyCodeLine{162                          \textcolor{comment}{! by a large surface pressure, such as with an ice sheet.}}
\DoxyCodeLine{163   \textcolor{keywordtype}{logical} :: regrid\_accelerate}
\DoxyCodeLine{164   \textcolor{keywordtype}{integer} :: regrid\_iterations}
\DoxyCodeLine{165 \textcolor{comment}{!  logical :: Analytic\_FV\_PGF, obsol\_test}}
\DoxyCodeLine{166   \textcolor{keywordtype}{logical} :: convert}
\DoxyCodeLine{167   \textcolor{keywordtype}{logical} :: just\_read  \textcolor{comment}{! If true, only read the parameters because this}}
\DoxyCodeLine{168                         \textcolor{comment}{! is a run from a restart file; this option}}
\DoxyCodeLine{169                         \textcolor{comment}{! allows the use of Fatal unused parameters.}}
\DoxyCodeLine{170   \textcolor{keywordtype}{type}(EOS\_type), \textcolor{keywordtype}{pointer} :: eos => null()}
\DoxyCodeLine{171   \textcolor{keywordtype}{logical} :: debug      \textcolor{comment}{! If true, write debugging output.}}
\DoxyCodeLine{172   \textcolor{keywordtype}{logical} :: debug\_obc  \textcolor{comment}{! If true, do debugging calls related to OBCs.}}
\DoxyCodeLine{173   \textcolor{keywordtype}{logical} :: debug\_layers = .false.}
\DoxyCodeLine{174   \textcolor{keywordtype}{character(len=80)} :: mesg}
\DoxyCodeLine{175 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{176 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{177 \textcolor{preprocessor}{}  \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz}
\DoxyCodeLine{178   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{179 }
\DoxyCodeLine{180   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{181   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{182   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{183   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{184 }
\DoxyCodeLine{185   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"MOM\_initialize\_state(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{186   \textcolor{keyword}{call }log\_version(pf, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{187   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"DEBUG"}, debug, default=.false.)}
\DoxyCodeLine{188   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"DEBUG\_OBC"}, debug\_obc, default=.false.)}
\DoxyCodeLine{189 }
\DoxyCodeLine{190   new\_sim = determine\_is\_new\_run(dirs\%input\_filename, dirs\%restart\_input\_dir, \&}
\DoxyCodeLine{191                                  g, restart\_cs)}
\DoxyCodeLine{192   just\_read = .not.new\_sim}
\DoxyCodeLine{193 }
\DoxyCodeLine{194   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, \&}
\DoxyCodeLine{195          \textcolor{stringliteral}{"The directory in which input files are found."}, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{196   inputdir = slasher(inputdir)}
\DoxyCodeLine{197 }
\DoxyCodeLine{198   use\_temperature = \textcolor{keyword}{associated}(tv\%T)}
\DoxyCodeLine{199   useale = \textcolor{keyword}{associated}(ale\_csp)}
\DoxyCodeLine{200   use\_eos = \textcolor{keyword}{associated}(tv\%eqn\_of\_state)}
\DoxyCodeLine{201   use\_obc = \textcolor{keyword}{associated}(obc)}
\DoxyCodeLine{202   \textcolor{keywordflow}{if} (use\_eos) eos => tv\%eqn\_of\_state}
\DoxyCodeLine{203 }
\DoxyCodeLine{204   \textcolor{comment}{!====================================================================}}
\DoxyCodeLine{205   \textcolor{comment}{!    Initialize temporally evolving fields, either as initial}}
\DoxyCodeLine{206   \textcolor{comment}{!  conditions or by reading them from a restart (or saves) file.}}
\DoxyCodeLine{207   \textcolor{comment}{!====================================================================}}
\DoxyCodeLine{208 }
\DoxyCodeLine{209   \textcolor{keywordflow}{if} (new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{210     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"Run initialized internally."}, 3)}
\DoxyCodeLine{211 }
\DoxyCodeLine{212     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(time\_in)) time = time\_in}
\DoxyCodeLine{213     \textcolor{comment}{! Otherwise leave Time at its input value.}}
\DoxyCodeLine{214 }
\DoxyCodeLine{215     \textcolor{comment}{! This initialization should not be needed. Certainly restricting it}}
\DoxyCodeLine{216     \textcolor{comment}{! to the computational domain helps detect possible uninitialized}}
\DoxyCodeLine{217     \textcolor{comment}{! data in halos which should be covered by the pass\_var(h) later.}}
\DoxyCodeLine{218     \textcolor{comment}{!do k = 1, nz; do j = js, je; do i = is, ie}}
\DoxyCodeLine{219     \textcolor{comment}{!  h(i,j,k) = 0.}}
\DoxyCodeLine{220     \textcolor{comment}{!enddo}}
\DoxyCodeLine{221 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   \textcolor{comment}{! The remaining initialization calls are done, regardless of whether the}}
\DoxyCodeLine{224   \textcolor{comment}{! fields are actually initialized here (if just\_read=.false.) or whether it}}
\DoxyCodeLine{225   \textcolor{comment}{! is just to make sure that all valid parameters are read to enable the}}
\DoxyCodeLine{226   \textcolor{comment}{! detection of unused parameters.}}
\DoxyCodeLine{227   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"INIT\_LAYERS\_FROM\_Z\_FILE"}, from\_z\_file, \&}
\DoxyCodeLine{228              \textcolor{stringliteral}{"If true, initialize the layer thicknesses, temperatures, "}//\&}
\DoxyCodeLine{229              \textcolor{stringliteral}{"and salinities from a Z-\/space file on a latitude-\/longitude "}//\&}
\DoxyCodeLine{230              \textcolor{stringliteral}{"grid."}, default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{231 }
\DoxyCodeLine{232   \textcolor{keywordflow}{if} (from\_z\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{233     \textcolor{comment}{! Initialize thickness and T/S from z-\/coordinate data in a file.}}
\DoxyCodeLine{234     \textcolor{keywordflow}{if} (.NOT.use\_temperature) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_initialize\_state : "}//\&}
\DoxyCodeLine{235        \textcolor{stringliteral}{"use\_temperature must be true if INIT\_LAYERS\_FROM\_Z\_FILE is true"})}
\DoxyCodeLine{236 }
\DoxyCodeLine{237     \textcolor{keyword}{call }mom\_temp\_salt\_initialize\_from\_z(h, tv, g, gv, us, pf, just\_read\_params=just\_read)}
\DoxyCodeLine{238 }
\DoxyCodeLine{239   \textcolor{keywordflow}{else}}
\DoxyCodeLine{240     \textcolor{comment}{! Initialize thickness, h.}}
\DoxyCodeLine{241     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"THICKNESS\_CONFIG"}, config, \&}
\DoxyCodeLine{242              \textcolor{stringliteral}{"A string that determines how the initial layer "}//\&}
\DoxyCodeLine{243              \textcolor{stringliteral}{"thicknesses are specified for a new run: \(\backslash\)n"}//\&}
\DoxyCodeLine{244              \textcolor{stringliteral}{" \(\backslash\)t file -\/ read interface heights from the file specified \(\backslash\)n"}//\&}
\DoxyCodeLine{245              \textcolor{stringliteral}{" \(\backslash\)t thickness\_file -\/ read thicknesses from the file specified \(\backslash\)n"}//\&}
\DoxyCodeLine{246              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t by (THICKNESS\_FILE).\(\backslash\)n"}//\&}
\DoxyCodeLine{247              \textcolor{stringliteral}{" \(\backslash\)t coord -\/ determined by ALE coordinate.\(\backslash\)n"}//\&}
\DoxyCodeLine{248              \textcolor{stringliteral}{" \(\backslash\)t uniform -\/ uniform thickness layers evenly distributed \(\backslash\)n"}//\&}
\DoxyCodeLine{249              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t between the surface and MAXIMUM\_DEPTH. \(\backslash\)n"}//\&}
\DoxyCodeLine{250              \textcolor{stringliteral}{" \(\backslash\)t list -\/ read a list of positive interface depths. \(\backslash\)n"}//\&}
\DoxyCodeLine{251              \textcolor{stringliteral}{" \(\backslash\)t DOME -\/ use a slope and channel configuration for the \(\backslash\)n"}//\&}
\DoxyCodeLine{252              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t DOME sill-\/overflow test case. \(\backslash\)n"}//\&}
\DoxyCodeLine{253              \textcolor{stringliteral}{" \(\backslash\)t ISOMIP -\/ use a configuration for the \(\backslash\)n"}//\&}
\DoxyCodeLine{254              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t ISOMIP test case. \(\backslash\)n"}//\&}
\DoxyCodeLine{255              \textcolor{stringliteral}{" \(\backslash\)t benchmark -\/ use the benchmark test case thicknesses. \(\backslash\)n"}//\&}
\DoxyCodeLine{256              \textcolor{stringliteral}{" \(\backslash\)t Neverworld -\/ use the Neverworld test case thicknesses. \(\backslash\)n"}//\&}
\DoxyCodeLine{257              \textcolor{stringliteral}{" \(\backslash\)t search -\/ search a density profile for the interface \(\backslash\)n"}//\&}
\DoxyCodeLine{258              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t densities. This is not yet implemented. \(\backslash\)n"}//\&}
\DoxyCodeLine{259              \textcolor{stringliteral}{" \(\backslash\)t circle\_obcs -\/ the circle\_obcs test case is used. \(\backslash\)n"}//\&}
\DoxyCodeLine{260              \textcolor{stringliteral}{" \(\backslash\)t DOME2D -\/ 2D version of DOME initialization. \(\backslash\)n"}//\&}
\DoxyCodeLine{261              \textcolor{stringliteral}{" \(\backslash\)t adjustment2d -\/ 2D lock exchange thickness ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{262              \textcolor{stringliteral}{" \(\backslash\)t sloshing -\/ sloshing gravity thickness ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{263              \textcolor{stringliteral}{" \(\backslash\)t seamount -\/ no motion test with seamount ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{264              \textcolor{stringliteral}{" \(\backslash\)t dumbbell -\/ sloshing channel ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{265              \textcolor{stringliteral}{" \(\backslash\)t soliton -\/ Equatorial Rossby soliton. \(\backslash\)n"}//\&}
\DoxyCodeLine{266              \textcolor{stringliteral}{" \(\backslash\)t rossby\_front -\/ a mixed layer front in thermal wind balance.\(\backslash\)n"}//\&}
\DoxyCodeLine{267              \textcolor{stringliteral}{" \(\backslash\)t USER -\/ call a user modified routine."}, \&}
\DoxyCodeLine{268              default=\textcolor{stringliteral}{"uniform"}, do\_not\_log=just\_read)}
\DoxyCodeLine{269     \textcolor{keywordflow}{select case} (trim(config))}
\DoxyCodeLine{270        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"file"})}
\DoxyCodeLine{271          \textcolor{keyword}{call }initialize\_thickness\_from\_file(h, g, gv, us, pf, .false., just\_read\_params=just\_read)}
\DoxyCodeLine{272        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"thickness\_file"})}
\DoxyCodeLine{273          \textcolor{keyword}{call }initialize\_thickness\_from\_file(h, g, gv, us, pf, .true., just\_read\_params=just\_read)}
\DoxyCodeLine{274        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"coord"})}
\DoxyCodeLine{275          \textcolor{keywordflow}{if} (new\_sim .and. useale) \textcolor{keywordflow}{then}}
\DoxyCodeLine{276            \textcolor{keyword}{call }ale\_initthicknesstocoord( ale\_csp, g, gv, h )}
\DoxyCodeLine{277          \textcolor{keywordflow}{elseif} (new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{278            \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_initialize\_state: USE\_REGRIDDING must be True "}//\&}
\DoxyCodeLine{279                                  \textcolor{stringliteral}{"for THICKNESS\_CONFIG of 'coord'"})}
\DoxyCodeLine{280 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{281        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"uniform"}); \textcolor{keyword}{call }initialize\_thickness\_uniform(h, g, gv, pf, \&}
\DoxyCodeLine{282                                   just\_read\_params=just\_read)}
\DoxyCodeLine{283        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"list"}); \textcolor{keyword}{call }initialize\_thickness\_list(h, g, gv, us, pf, \&}
\DoxyCodeLine{284                                   just\_read\_params=just\_read)}
\DoxyCodeLine{285        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"DOME"}); \textcolor{keyword}{call }dome\_initialize\_thickness(h, g, gv, pf, \&}
\DoxyCodeLine{286                                just\_read\_params=just\_read)}
\DoxyCodeLine{287        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"ISOMIP"}); \textcolor{keyword}{call }isomip\_initialize\_thickness(h, g, gv, us, pf, tv, \&}
\DoxyCodeLine{288                                  just\_read\_params=just\_read)}
\DoxyCodeLine{289        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"benchmark"}); \textcolor{keyword}{call }benchmark\_initialize\_thickness(h, g, gv, us, pf, \&}
\DoxyCodeLine{290                                     tv\%eqn\_of\_state, tv\%P\_Ref, just\_read\_params=just\_read)}
\DoxyCodeLine{291        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Neverwoorld"},\textcolor{stringliteral}{"Neverland"}); \textcolor{keyword}{call }neverworld\_initialize\_thickness(h, g, gv, us, pf, \&}
\DoxyCodeLine{292                                  tv\%eqn\_of\_state, tv\%P\_Ref)}
\DoxyCodeLine{293        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"search"}); \textcolor{keyword}{call }initialize\_thickness\_search}
\DoxyCodeLine{294        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"circle\_obcs"}); \textcolor{keyword}{call }circle\_obcs\_initialize\_thickness(h, g, gv, pf, \&}
\DoxyCodeLine{295                                       just\_read\_params=just\_read)}
\DoxyCodeLine{296        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"lock\_exchange"}); \textcolor{keyword}{call }lock\_exchange\_initialize\_thickness(h, g, gv, us, \&}
\DoxyCodeLine{297                                         pf, just\_read\_params=just\_read)}
\DoxyCodeLine{298        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"external\_gwave"}); \textcolor{keyword}{call }external\_gwave\_initialize\_thickness(h, g, gv, us, \&}
\DoxyCodeLine{299                                          pf, just\_read\_params=just\_read)}
\DoxyCodeLine{300        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"DOME2D"}); \textcolor{keyword}{call }dome2d\_initialize\_thickness(h, g, gv, us, pf, \&}
\DoxyCodeLine{301                                  just\_read\_params=just\_read)}
\DoxyCodeLine{302        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"adjustment2d"}); \textcolor{keyword}{call }adjustment\_initialize\_thickness(h, g, gv, us, \&}
\DoxyCodeLine{303                                        pf, just\_read\_params=just\_read)}
\DoxyCodeLine{304        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"sloshing"}); \textcolor{keyword}{call }sloshing\_initialize\_thickness(h, g, gv, us, pf, \&}
\DoxyCodeLine{305                                    just\_read\_params=just\_read)}
\DoxyCodeLine{306        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"seamount"}); \textcolor{keyword}{call }seamount\_initialize\_thickness(h, g, gv, us, pf, \&}
\DoxyCodeLine{307                                    just\_read\_params=just\_read)}
\DoxyCodeLine{308        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"dumbbell"}); \textcolor{keyword}{call }dumbbell\_initialize\_thickness(h, g, gv, us, pf, \&}
\DoxyCodeLine{309                                    just\_read\_params=just\_read)}
\DoxyCodeLine{310        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"soliton"}); \textcolor{keyword}{call }soliton\_initialize\_thickness(h, g, gv, us)}
\DoxyCodeLine{311        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"phillips"}); \textcolor{keyword}{call }phillips\_initialize\_thickness(h, g, gv, us, pf, \&}
\DoxyCodeLine{312                                    just\_read\_params=just\_read)}
\DoxyCodeLine{313        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"rossby\_front"}); \textcolor{keyword}{call }rossby\_front\_initialize\_thickness(h, g, gv, us, \&}
\DoxyCodeLine{314                                        pf, just\_read\_params=just\_read)}
\DoxyCodeLine{315        \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"USER"}); \textcolor{keyword}{call }user\_initialize\_thickness(h, g, gv, pf, \&}
\DoxyCodeLine{316                                just\_read\_params=just\_read)}
\DoxyCodeLine{317 \textcolor{keywordflow}{       case default} ; \textcolor{keyword}{call }mom\_error(fatal,  \textcolor{stringliteral}{"MOM\_initialize\_state: "}//\&}
\DoxyCodeLine{318             \textcolor{stringliteral}{"Unrecognized layer thickness configuration "}//trim(config))}
\DoxyCodeLine{319 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{320 }
\DoxyCodeLine{321     \textcolor{comment}{! Initialize temperature and salinity (T and S).}}
\DoxyCodeLine{322     \textcolor{keywordflow}{if} ( use\_temperature ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{323       \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"TS\_CONFIG"}, config, \&}
\DoxyCodeLine{324              \textcolor{stringliteral}{"A string that determines how the initial tempertures "}//\&}
\DoxyCodeLine{325              \textcolor{stringliteral}{"and salinities are specified for a new run: \(\backslash\)n"}//\&}
\DoxyCodeLine{326              \textcolor{stringliteral}{" \(\backslash\)t file -\/ read velocities from the file specified \(\backslash\)n"}//\&}
\DoxyCodeLine{327              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t by (TS\_FILE). \(\backslash\)n"}//\&}
\DoxyCodeLine{328              \textcolor{stringliteral}{" \(\backslash\)t fit -\/ find the temperatures that are consistent with \(\backslash\)n"}//\&}
\DoxyCodeLine{329              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t the layer densities and salinity S\_REF. \(\backslash\)n"}//\&}
\DoxyCodeLine{330              \textcolor{stringliteral}{" \(\backslash\)t TS\_profile -\/ use temperature and salinity profiles \(\backslash\)n"}//\&}
\DoxyCodeLine{331              \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t (read from TS\_FILE) to set layer densities. \(\backslash\)n"}//\&}
\DoxyCodeLine{332              \textcolor{stringliteral}{" \(\backslash\)t benchmark -\/ use the benchmark test case T \& S. \(\backslash\)n"}//\&}
\DoxyCodeLine{333              \textcolor{stringliteral}{" \(\backslash\)t linear -\/ linear in logical layer space. \(\backslash\)n"}//\&}
\DoxyCodeLine{334              \textcolor{stringliteral}{" \(\backslash\)t DOME2D -\/ 2D DOME initialization. \(\backslash\)n"}//\&}
\DoxyCodeLine{335              \textcolor{stringliteral}{" \(\backslash\)t ISOMIP -\/ ISOMIP initialization. \(\backslash\)n"}//\&}
\DoxyCodeLine{336              \textcolor{stringliteral}{" \(\backslash\)t adjustment2d -\/ 2d lock exchange T/S ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{337              \textcolor{stringliteral}{" \(\backslash\)t sloshing -\/ sloshing mode T/S ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{338              \textcolor{stringliteral}{" \(\backslash\)t seamount -\/ no motion test with seamount ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{339              \textcolor{stringliteral}{" \(\backslash\)t dumbbell -\/ sloshing channel ICs. \(\backslash\)n"}//\&}
\DoxyCodeLine{340              \textcolor{stringliteral}{" \(\backslash\)t rossby\_front -\/ a mixed layer front in thermal wind balance.\(\backslash\)n"}//\&}
\DoxyCodeLine{341              \textcolor{stringliteral}{" \(\backslash\)t SCM\_CVMix\_tests -\/ used in the SCM CVMix tests.\(\backslash\)n"}//\&}
\DoxyCodeLine{342              \textcolor{stringliteral}{" \(\backslash\)t USER -\/ call a user modified routine."}, \&}
\DoxyCodeLine{343              fail\_if\_missing=new\_sim, do\_not\_log=just\_read)}
\DoxyCodeLine{344 \textcolor{comment}{!            " \(\backslash\)t baroclinic\_zone -\/ an analytic baroclinic zone. \(\backslash\)n"//\&}}
\DoxyCodeLine{345       \textcolor{keywordflow}{select case} (trim(config))}
\DoxyCodeLine{346         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"fit"}); \textcolor{keyword}{call }initialize\_temp\_salt\_fit(tv\%T, tv\%S, g, gv, us, pf, \&}
\DoxyCodeLine{347                                eos, tv\%P\_Ref, just\_read\_params=just\_read)}
\DoxyCodeLine{348         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"file"}); \textcolor{keyword}{call }initialize\_temp\_salt\_from\_file(tv\%T, tv\%S, g, \&}
\DoxyCodeLine{349                                 pf, just\_read\_params=just\_read)}
\DoxyCodeLine{350         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"benchmark"}); \textcolor{keyword}{call }benchmark\_init\_temperature\_salinity(tv\%T, tv\%S, \&}
\DoxyCodeLine{351                                      g, gv, us, pf, eos, tv\%P\_Ref, just\_read\_params=just\_read)}
\DoxyCodeLine{352         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"TS\_profile"}) ; \textcolor{keyword}{call }initialize\_temp\_salt\_from\_profile(tv\%T, tv\%S, \&}
\DoxyCodeLine{353                                        g, pf, just\_read\_params=just\_read)}
\DoxyCodeLine{354         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"linear"}); \textcolor{keyword}{call }initialize\_temp\_salt\_linear(tv\%T, tv\%S, g, pf, \&}
\DoxyCodeLine{355                                   just\_read\_params=just\_read)}
\DoxyCodeLine{356         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"DOME2D"}); \textcolor{keyword}{call }dome2d\_initialize\_temperature\_salinity ( tv\%T, \&}
\DoxyCodeLine{357                                   tv\%S, h, g, gv, pf, eos, just\_read\_params=just\_read)}
\DoxyCodeLine{358         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"ISOMIP"}); \textcolor{keyword}{call }isomip\_initialize\_temperature\_salinity ( tv\%T, \&}
\DoxyCodeLine{359                                   tv\%S, h, g, gv, us, pf, eos, just\_read\_params=just\_read)}
\DoxyCodeLine{360         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"adjustment2d"}); \textcolor{keyword}{call }adjustment\_initialize\_temperature\_salinity ( tv\%T, \&}
\DoxyCodeLine{361                                         tv\%S, h, g, gv, pf, eos, just\_read\_params=just\_read)}
\DoxyCodeLine{362         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"baroclinic\_zone"}); \textcolor{keyword}{call }baroclinic\_zone\_init\_temperature\_salinity( tv\%T, \&}
\DoxyCodeLine{363                                            tv\%S, h, g, gv, us, pf, just\_read\_params=just\_read)}
\DoxyCodeLine{364         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"sloshing"}); \textcolor{keyword}{call }sloshing\_initialize\_temperature\_salinity(tv\%T, \&}
\DoxyCodeLine{365                                     tv\%S, h, g, gv, pf, eos, just\_read\_params=just\_read)}
\DoxyCodeLine{366         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"seamount"}); \textcolor{keyword}{call }seamount\_initialize\_temperature\_salinity(tv\%T, \&}
\DoxyCodeLine{367                                     tv\%S, h, g, gv, pf, eos, just\_read\_params=just\_read)}
\DoxyCodeLine{368         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"dumbbell"}); \textcolor{keyword}{call }dumbbell\_initialize\_temperature\_salinity(tv\%T, \&}
\DoxyCodeLine{369                                     tv\%S, h, g, gv, pf, eos, just\_read\_params=just\_read)}
\DoxyCodeLine{370         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"rossby\_front"}); \textcolor{keyword}{call }rossby\_front\_initialize\_temperature\_salinity ( tv\%T, \&}
\DoxyCodeLine{371                                         tv\%S, h, g, gv, pf, eos, just\_read\_params=just\_read)}
\DoxyCodeLine{372         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"SCM\_CVMix\_tests"}); \textcolor{keyword}{call }scm\_cvmix\_tests\_ts\_init(tv\%T, tv\%S, h, \&}
\DoxyCodeLine{373                                            g, gv, us, pf, just\_read\_params=just\_read)}
\DoxyCodeLine{374         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"dense"}); \textcolor{keyword}{call }dense\_water\_initialize\_ts(g, gv, pf, eos, tv\%T, tv\%S, \&}
\DoxyCodeLine{375                                  h, just\_read\_params=just\_read)}
\DoxyCodeLine{376         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"USER"}); \textcolor{keyword}{call }user\_init\_temperature\_salinity(tv\%T, tv\%S, g, pf, eos, \&}
\DoxyCodeLine{377                                 just\_read\_params=just\_read)}
\DoxyCodeLine{378 \textcolor{keywordflow}{        case default} ; \textcolor{keyword}{call }mom\_error(fatal,  \textcolor{stringliteral}{"MOM\_initialize\_state: "}//\&}
\DoxyCodeLine{379                \textcolor{stringliteral}{"Unrecognized Temp \& salt configuration "}//trim(config))}
\DoxyCodeLine{380 \textcolor{keywordflow}{      end select}}
\DoxyCodeLine{381 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{382 \textcolor{keywordflow}{  endif}  \textcolor{comment}{! not from\_Z\_file.}}
\DoxyCodeLine{383   \textcolor{keywordflow}{if} (use\_temperature .and. use\_obc) \&}
\DoxyCodeLine{384     \textcolor{keyword}{call }fill\_temp\_salt\_segments(g, obc, tv)}
\DoxyCodeLine{385 }
\DoxyCodeLine{386   \textcolor{comment}{! The thicknesses in halo points might be needed to initialize the velocities.}}
\DoxyCodeLine{387   \textcolor{keywordflow}{if} (new\_sim) \textcolor{keyword}{call }pass\_var(h, g\%Domain)}
\DoxyCodeLine{388 }
\DoxyCodeLine{389   \textcolor{comment}{! Initialize velocity components, u and v}}
\DoxyCodeLine{390   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"VELOCITY\_CONFIG"}, config, \&}
\DoxyCodeLine{391        \textcolor{stringliteral}{"A string that determines how the initial velocities "}//\&}
\DoxyCodeLine{392        \textcolor{stringliteral}{"are specified for a new run: \(\backslash\)n"}//\&}
\DoxyCodeLine{393        \textcolor{stringliteral}{" \(\backslash\)t file -\/ read velocities from the file specified \(\backslash\)n"}//\&}
\DoxyCodeLine{394        \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t by (VELOCITY\_FILE). \(\backslash\)n"}//\&}
\DoxyCodeLine{395        \textcolor{stringliteral}{" \(\backslash\)t zero -\/ the fluid is initially at rest. \(\backslash\)n"}//\&}
\DoxyCodeLine{396        \textcolor{stringliteral}{" \(\backslash\)t uniform -\/ the flow is uniform (determined by\(\backslash\)n"}//\&}
\DoxyCodeLine{397        \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t parameters INITIAL\_U\_CONST and INITIAL\_V\_CONST).\(\backslash\)n"}//\&}
\DoxyCodeLine{398        \textcolor{stringliteral}{" \(\backslash\)t rossby\_front -\/ a mixed layer front in thermal wind balance.\(\backslash\)n"}//\&}
\DoxyCodeLine{399        \textcolor{stringliteral}{" \(\backslash\)t soliton -\/ Equatorial Rossby soliton.\(\backslash\)n"}//\&}
\DoxyCodeLine{400        \textcolor{stringliteral}{" \(\backslash\)t USER -\/ call a user modified routine."}, default=\textcolor{stringliteral}{"zero"}, \&}
\DoxyCodeLine{401        do\_not\_log=just\_read)}
\DoxyCodeLine{402   \textcolor{keywordflow}{select case} (trim(config))}
\DoxyCodeLine{403      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"file"}); \textcolor{keyword}{call }initialize\_velocity\_from\_file(u, v, g, us, pf, \&}
\DoxyCodeLine{404                              just\_read\_params=just\_read)}
\DoxyCodeLine{405      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"zero"}); \textcolor{keyword}{call }initialize\_velocity\_zero(u, v, g, pf, \&}
\DoxyCodeLine{406                              just\_read\_params=just\_read)}
\DoxyCodeLine{407      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"uniform"}); \textcolor{keyword}{call }initialize\_velocity\_uniform(u, v, g, us, pf, \&}
\DoxyCodeLine{408                                 just\_read\_params=just\_read)}
\DoxyCodeLine{409      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"circular"}); \textcolor{keyword}{call }initialize\_velocity\_circular(u, v, g, us, pf, \&}
\DoxyCodeLine{410                                  just\_read\_params=just\_read)}
\DoxyCodeLine{411      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"phillips"}); \textcolor{keyword}{call }phillips\_initialize\_velocity(u, v, g, gv, us, pf, \&}
\DoxyCodeLine{412                                  just\_read\_params=just\_read)}
\DoxyCodeLine{413      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"rossby\_front"}); \textcolor{keyword}{call }rossby\_front\_initialize\_velocity(u, v, h, \&}
\DoxyCodeLine{414                                      g, gv, us, pf, just\_read\_params=just\_read)}
\DoxyCodeLine{415      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"soliton"}); \textcolor{keyword}{call }soliton\_initialize\_velocity(u, v, h, g, us)}
\DoxyCodeLine{416      \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"USER"}); \textcolor{keyword}{call }user\_initialize\_velocity(u, v, g, us, pf, \&}
\DoxyCodeLine{417                              just\_read\_params=just\_read)}
\DoxyCodeLine{418 \textcolor{keywordflow}{     case default} ; \textcolor{keyword}{call }mom\_error(fatal,  \textcolor{stringliteral}{"MOM\_initialize\_state: "}//\&}
\DoxyCodeLine{419           \textcolor{stringliteral}{"Unrecognized velocity configuration "}//trim(config))}
\DoxyCodeLine{420 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{421 }
\DoxyCodeLine{422   \textcolor{keywordflow}{if} (new\_sim) \textcolor{keyword}{call }pass\_vector(u, v, g\%Domain)}
\DoxyCodeLine{423   \textcolor{keywordflow}{if} (debug .and. new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{424     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"MOM\_initialize\_state [uv]"}, u, v, g\%HI, haloshift=1, scale=us\%m\_s\_to\_L\_T)}
\DoxyCodeLine{425 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{426 }
\DoxyCodeLine{427   \textcolor{comment}{! Optionally convert the thicknesses from m to kg m-\/2.  This is particularly}}
\DoxyCodeLine{428   \textcolor{comment}{! useful in a non-\/Boussinesq model.}}
\DoxyCodeLine{429   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"CONVERT\_THICKNESS\_UNITS"}, convert, \&}
\DoxyCodeLine{430                \textcolor{stringliteral}{"If true,  convert the thickness initial conditions from "}//\&}
\DoxyCodeLine{431                \textcolor{stringliteral}{"units of m to kg m-\/2 or vice versa, depending on whether "}//\&}
\DoxyCodeLine{432                \textcolor{stringliteral}{"BOUSSINESQ is defined. This does not apply if a restart "}//\&}
\DoxyCodeLine{433                \textcolor{stringliteral}{"file is read."}, default=.not.gv\%Boussinesq, do\_not\_log=just\_read)}
\DoxyCodeLine{434 }
\DoxyCodeLine{435   \textcolor{keywordflow}{if} (new\_sim .and. convert .and. .not.gv\%Boussinesq) \&}
\DoxyCodeLine{436     \textcolor{comment}{! Convert thicknesses from geomtric distances to mass-\/per-\/unit-\/area.}}
\DoxyCodeLine{437     \textcolor{keyword}{call }convert\_thickness(h, g, gv, us, tv)}
\DoxyCodeLine{438 }
\DoxyCodeLine{439   \textcolor{comment}{! Remove the mass that would be displaced by an ice shelf or inverse barometer.}}
\DoxyCodeLine{440   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"DEPRESS\_INITIAL\_SURFACE"}, depress\_sfc, \&}
\DoxyCodeLine{441                \textcolor{stringliteral}{"If true,  depress the initial surface to avoid huge "}//\&}
\DoxyCodeLine{442                \textcolor{stringliteral}{"tsunamis when a large surface pressure is applied."}, \&}
\DoxyCodeLine{443                default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{444   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"TRIM\_IC\_FOR\_P\_SURF"}, trim\_ic\_for\_p\_surf, \&}
\DoxyCodeLine{445                \textcolor{stringliteral}{"If true, cuts way the top of the column for initial conditions "}//\&}
\DoxyCodeLine{446                \textcolor{stringliteral}{"at the depth where the hydrostatic pressure matches the imposed "}//\&}
\DoxyCodeLine{447                \textcolor{stringliteral}{"surface pressure which is read from file."}, default=.false., \&}
\DoxyCodeLine{448                do\_not\_log=just\_read)}
\DoxyCodeLine{449   \textcolor{keywordflow}{if} (depress\_sfc .and. trim\_ic\_for\_p\_surf) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_initialize\_state: "}//\&}
\DoxyCodeLine{450            \textcolor{stringliteral}{"DEPRESS\_INITIAL\_SURFACE and TRIM\_IC\_FOR\_P\_SURF are exclusive and cannot both be True"})}
\DoxyCodeLine{451   \textcolor{keywordflow}{if} (new\_sim .and. debug .and. (depress\_sfc .or. trim\_ic\_for\_p\_surf)) \&}
\DoxyCodeLine{452     \textcolor{keyword}{call }hchksum(h, \textcolor{stringliteral}{"Pre-\/depress: h "}, g\%HI, haloshift=1, scale=gv\%H\_to\_m)}
\DoxyCodeLine{453   \textcolor{keywordflow}{if} (depress\_sfc) \textcolor{keyword}{call }depress\_surface(h, g, gv, us, pf, tv, just\_read\_params=just\_read)}
\DoxyCodeLine{454   \textcolor{keywordflow}{if} (trim\_ic\_for\_p\_surf) \textcolor{keyword}{call }trim\_for\_ice(pf, g, gv, us, ale\_csp, tv, h, just\_read\_params=just\_read)}
\DoxyCodeLine{455 }
\DoxyCodeLine{456   \textcolor{comment}{! Perhaps we want to run the regridding coordinate generator for multiple}}
\DoxyCodeLine{457   \textcolor{comment}{! iterations here so the initial grid is consistent with the coordinate}}
\DoxyCodeLine{458   \textcolor{keywordflow}{if} (useale) \textcolor{keywordflow}{then}}
\DoxyCodeLine{459     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"REGRID\_ACCELERATE\_INIT"}, regrid\_accelerate, \&}
\DoxyCodeLine{460          \textcolor{stringliteral}{"If true, runs REGRID\_ACCELERATE\_ITERATIONS iterations of the regridding "}//\&}
\DoxyCodeLine{461          \textcolor{stringliteral}{"algorithm to push the initial grid to be consistent with the initial "}//\&}
\DoxyCodeLine{462          \textcolor{stringliteral}{"condition. Useful only for state-\/based and iterative coordinates."}, \&}
\DoxyCodeLine{463          default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{464     \textcolor{keywordflow}{if} (regrid\_accelerate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{465       \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"REGRID\_ACCELERATE\_ITERATIONS"}, regrid\_iterations, \&}
\DoxyCodeLine{466            \textcolor{stringliteral}{"The number of regridding iterations to perform to generate "}//\&}
\DoxyCodeLine{467            \textcolor{stringliteral}{"an initial grid that is consistent with the initial conditions."}, \&}
\DoxyCodeLine{468            default=1, do\_not\_log=just\_read)}
\DoxyCodeLine{469 }
\DoxyCodeLine{470       \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"DT"}, dt, \textcolor{stringliteral}{"Timestep"}, fail\_if\_missing=.true., scale=us\%s\_to\_T)}
\DoxyCodeLine{471 }
\DoxyCodeLine{472       \textcolor{keywordflow}{if} (new\_sim .and. debug) \&}
\DoxyCodeLine{473         \textcolor{keyword}{call }hchksum(h, \textcolor{stringliteral}{"Pre-\/ALE\_regrid: h "}, g\%HI, haloshift=1, scale=gv\%H\_to\_m)}
\DoxyCodeLine{474       \textcolor{keyword}{call }ale\_regrid\_accelerated(ale\_csp, g, gv, h, tv, regrid\_iterations, u, v, obc, tracer\_reg, \&}
\DoxyCodeLine{475                                   dt=dt, initial=.true.)}
\DoxyCodeLine{476 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{477 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{478   \textcolor{comment}{! This is the end of the block of code that might have initialized fields}}
\DoxyCodeLine{479   \textcolor{comment}{! internally at the start of a new run.}}
\DoxyCodeLine{480 }
\DoxyCodeLine{481   \textcolor{keywordflow}{if} (.not.new\_sim) \textcolor{keywordflow}{then} \textcolor{comment}{! This block restores the state from a restart file.}}
\DoxyCodeLine{482     \textcolor{comment}{!    This line calls a subroutine that reads the initial conditions}}
\DoxyCodeLine{483     \textcolor{comment}{!  from a previously generated file.}}
\DoxyCodeLine{484     \textcolor{keyword}{call }restore\_state(dirs\%input\_filename, dirs\%restart\_input\_dir, time, \&}
\DoxyCodeLine{485                        g, restart\_cs)}
\DoxyCodeLine{486     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(time\_in)) time = time\_in}
\DoxyCodeLine{487     \textcolor{keywordflow}{if} ((gv\%m\_to\_H\_restart /= 0.0) .and. (gv\%m\_to\_H\_restart /= gv\%m\_to\_H)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{488       h\_rescale = gv\%m\_to\_H / gv\%m\_to\_H\_restart}
\DoxyCodeLine{489       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; h(i,j,k) = h\_rescale * h(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{490 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{491     \textcolor{keywordflow}{if} ( (us\%s\_to\_T\_restart * us\%m\_to\_L\_restart /= 0.0) .and. \&}
\DoxyCodeLine{492          ((us\%m\_to\_L * us\%s\_to\_T\_restart) /= (us\%m\_to\_L\_restart * us\%s\_to\_T)) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{493       vel\_rescale = (us\%m\_to\_L * us\%s\_to\_T\_restart) /  (us\%m\_to\_L\_restart * us\%s\_to\_T)}
\DoxyCodeLine{494       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb ; u(i,j,k) = vel\_rescale * u(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{495       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied ; v(i,j,k) = vel\_rescale * v(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{496 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{497 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{498 }
\DoxyCodeLine{499   \textcolor{keywordflow}{if} ( use\_temperature ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{500     \textcolor{keyword}{call }pass\_var(tv\%T, g\%Domain, complete=.false.)}
\DoxyCodeLine{501     \textcolor{keyword}{call }pass\_var(tv\%S, g\%Domain, complete=.false.)}
\DoxyCodeLine{502 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{503   \textcolor{keyword}{call }pass\_var(h, g\%Domain)}
\DoxyCodeLine{504 }
\DoxyCodeLine{505   \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{506     \textcolor{keyword}{call }hchksum(h, \textcolor{stringliteral}{"MOM\_initialize\_state: h "}, g\%HI, haloshift=1, scale=gv\%H\_to\_m)}
\DoxyCodeLine{507     \textcolor{keywordflow}{if} ( use\_temperature ) \textcolor{keyword}{call }hchksum(tv\%T, \textcolor{stringliteral}{"MOM\_initialize\_state: T "}, g\%HI, haloshift=1)}
\DoxyCodeLine{508     \textcolor{keywordflow}{if} ( use\_temperature ) \textcolor{keyword}{call }hchksum(tv\%S, \textcolor{stringliteral}{"MOM\_initialize\_state: S "}, g\%HI, haloshift=1)}
\DoxyCodeLine{509     \textcolor{keywordflow}{if} ( use\_temperature .and. debug\_layers) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{510       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("MOM\_IS: T[",I2,"]")'}) k}
\DoxyCodeLine{511       \textcolor{keyword}{call }hchksum(tv\%T(:,:,k), mesg, g\%HI, haloshift=1)}
\DoxyCodeLine{512       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("MOM\_IS: S[",I2,"]")'}) k}
\DoxyCodeLine{513       \textcolor{keyword}{call }hchksum(tv\%S(:,:,k), mesg, g\%HI, haloshift=1)}
\DoxyCodeLine{514 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{515 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{516 }
\DoxyCodeLine{517   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"SPONGE"}, use\_sponge, \&}
\DoxyCodeLine{518                  \textcolor{stringliteral}{"If true, sponges may be applied anywhere in the domain. "}//\&}
\DoxyCodeLine{519                  \textcolor{stringliteral}{"The exact location and properties of those sponges are "}//\&}
\DoxyCodeLine{520                  \textcolor{stringliteral}{"specified via SPONGE\_CONFIG."}, default=.false.)}
\DoxyCodeLine{521   \textcolor{keywordflow}{if} ( use\_sponge ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{522     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"SPONGE\_CONFIG"}, config, \&}
\DoxyCodeLine{523                  \textcolor{stringliteral}{"A string that sets how the sponges are configured: \(\backslash\)n"}//\&}
\DoxyCodeLine{524                  \textcolor{stringliteral}{" \(\backslash\)t file -\/ read sponge properties from the file \(\backslash\)n"}//\&}
\DoxyCodeLine{525                  \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t specified by (SPONGE\_FILE).\(\backslash\)n"}//\&}
\DoxyCodeLine{526                  \textcolor{stringliteral}{" \(\backslash\)t ISOMIP -\/ apply ale sponge in the ISOMIP case \(\backslash\)n"}//\&}
\DoxyCodeLine{527                  \textcolor{stringliteral}{" \(\backslash\)t RGC -\/ apply sponge in the rotating\_gravity\_current case \(\backslash\)n"}//\&}
\DoxyCodeLine{528                  \textcolor{stringliteral}{" \(\backslash\)t DOME -\/ use a slope and channel configuration for the \(\backslash\)n"}//\&}
\DoxyCodeLine{529                  \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t DOME sill-\/overflow test case. \(\backslash\)n"}//\&}
\DoxyCodeLine{530                  \textcolor{stringliteral}{" \(\backslash\)t BFB -\/ Sponge at the southern boundary of the domain\(\backslash\)n"}//\&}
\DoxyCodeLine{531                  \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t for buoyancy-\/forced basin case.\(\backslash\)n"}//\&}
\DoxyCodeLine{532                  \textcolor{stringliteral}{" \(\backslash\)t USER -\/ call a user modified routine."}, default=\textcolor{stringliteral}{"file"})}
\DoxyCodeLine{533     \textcolor{keywordflow}{select case} (trim(config))}
\DoxyCodeLine{534       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"DOME"}); \textcolor{keyword}{call }dome\_initialize\_sponges(g, gv, us, tv, pf, sponge\_csp)}
\DoxyCodeLine{535       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"DOME2D"}); \textcolor{keyword}{call }dome2d\_initialize\_sponges(g, gv, us, tv, pf, useale, \&}
\DoxyCodeLine{536                                                       sponge\_csp, ale\_sponge\_csp)}
\DoxyCodeLine{537       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"ISOMIP"}); \textcolor{keyword}{call }isomip\_initialize\_sponges(g, gv, us, tv, pf, useale, \&}
\DoxyCodeLine{538                                                       sponge\_csp, ale\_sponge\_csp)}
\DoxyCodeLine{539       \textcolor{keywordflow}{case}(\textcolor{stringliteral}{"RGC"}); \textcolor{keyword}{call }rgc\_initialize\_sponges(g, gv, us, tv, u, v, pf, useale, \&}
\DoxyCodeLine{540                                                      sponge\_csp, ale\_sponge\_csp)}
\DoxyCodeLine{541       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"USER"}); \textcolor{keyword}{call }user\_initialize\_sponges(g, gv, use\_temperature, tv, pf, sponge\_csp, h)}
\DoxyCodeLine{542       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"BFB"}); \textcolor{keyword}{call }bfb\_initialize\_sponges\_southonly(g, gv, us, use\_temperature, tv, pf, \&}
\DoxyCodeLine{543                                                           sponge\_csp, h)}
\DoxyCodeLine{544       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"DUMBBELL"}); \textcolor{keyword}{call }dumbbell\_initialize\_sponges(g, gv, us, tv, pf, useale, \&}
\DoxyCodeLine{545                                                           sponge\_csp, ale\_sponge\_csp)}
\DoxyCodeLine{546       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"phillips"}); \textcolor{keyword}{call }phillips\_initialize\_sponges(g, gv, us, tv, pf, sponge\_csp, h)}
\DoxyCodeLine{547       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"dense"}); \textcolor{keyword}{call }dense\_water\_initialize\_sponges(g, gv, us, tv, pf, useale, \&}
\DoxyCodeLine{548                                                           sponge\_csp, ale\_sponge\_csp)}
\DoxyCodeLine{549       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"file"}); \textcolor{keyword}{call }initialize\_sponges\_file(g, gv, us, use\_temperature, tv, pf, \&}
\DoxyCodeLine{550                                                   sponge\_csp, ale\_sponge\_csp, time)}
\DoxyCodeLine{551 \textcolor{keywordflow}{      case default} ; \textcolor{keyword}{call }mom\_error(fatal,  \textcolor{stringliteral}{"MOM\_initialize\_state: "}//\&}
\DoxyCodeLine{552              \textcolor{stringliteral}{"Unrecognized sponge configuration "}//trim(config))}
\DoxyCodeLine{553 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{554 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{555 }
\DoxyCodeLine{556   \textcolor{comment}{! Reads OBC parameters not pertaining to the location of the boundaries}}
\DoxyCodeLine{557   \textcolor{keyword}{call }open\_boundary\_init(g, gv, us, pf, obc, restart\_cs)}
\DoxyCodeLine{558 }
\DoxyCodeLine{559   \textcolor{comment}{! This controls user code for setting open boundary data}}
\DoxyCodeLine{560   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{561      \textcolor{keyword}{call }initialize\_segment\_data(g, obc, pf) \textcolor{comment}{!   call initialize\_segment\_data(G, OBC, param\_file)}}
\DoxyCodeLine{562 \textcolor{comment}{!     call open\_boundary\_config(G, US, PF, OBC)}}
\DoxyCodeLine{563     \textcolor{comment}{! Call this once to fill boundary arrays from fixed values}}
\DoxyCodeLine{564     \textcolor{keywordflow}{if} (.not. obc\%needs\_IO\_for\_data)  \&}
\DoxyCodeLine{565       \textcolor{keyword}{call }update\_obc\_segment\_data(g, gv, us, obc, tv, h, time)}
\DoxyCodeLine{566 }
\DoxyCodeLine{567     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"OBC\_USER\_CONFIG"}, config, \&}
\DoxyCodeLine{568                  \textcolor{stringliteral}{"A string that sets how the user code is invoked to set open boundary data: \(\backslash\)n"}//\&}
\DoxyCodeLine{569                  \textcolor{stringliteral}{"   DOME -\/ specified inflow on northern boundary\(\backslash\)n"}//\&}
\DoxyCodeLine{570                  \textcolor{stringliteral}{"   dyed\_channel -\/ supercritical with dye on the inflow boundary\(\backslash\)n"}//\&}
\DoxyCodeLine{571                  \textcolor{stringliteral}{"   dyed\_obcs -\/ circle\_obcs with dyes on the open boundaries\(\backslash\)n"}//\&}
\DoxyCodeLine{572                  \textcolor{stringliteral}{"   Kelvin -\/ barotropic Kelvin wave forcing on the western boundary\(\backslash\)n"}//\&}
\DoxyCodeLine{573                  \textcolor{stringliteral}{"   shelfwave -\/ Flather with shelf wave forcing on western boundary\(\backslash\)n"}//\&}
\DoxyCodeLine{574                  \textcolor{stringliteral}{"   supercritical -\/ now only needed here for the allocations\(\backslash\)n"}//\&}
\DoxyCodeLine{575                  \textcolor{stringliteral}{"   tidal\_bay -\/ Flather with tidal forcing on eastern boundary\(\backslash\)n"}//\&}
\DoxyCodeLine{576                  \textcolor{stringliteral}{"   USER -\/ user specified"}, default=\textcolor{stringliteral}{"none"})}
\DoxyCodeLine{577     \textcolor{keywordflow}{if} (trim(config) == \textcolor{stringliteral}{"DOME"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{578       \textcolor{keyword}{call }dome\_set\_obc\_data(obc, tv, g, gv, us, pf, tracer\_reg)}
\DoxyCodeLine{579     \textcolor{keywordflow}{elseif} (trim(config) == \textcolor{stringliteral}{"dyed\_channel"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{580       \textcolor{keyword}{call }dyed\_channel\_set\_obc\_tracer\_data(obc, g, gv, pf, tracer\_reg)}
\DoxyCodeLine{581       obc\%update\_OBC = .true.}
\DoxyCodeLine{582     \textcolor{keywordflow}{elseif} (trim(config) == \textcolor{stringliteral}{"dyed\_obcs"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{583       \textcolor{keyword}{call }dyed\_obcs\_set\_obc\_data(obc, g, gv, pf, tracer\_reg)}
\DoxyCodeLine{584     \textcolor{keywordflow}{elseif} (trim(config) == \textcolor{stringliteral}{"Kelvin"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{585       obc\%update\_OBC = .true.}
\DoxyCodeLine{586     \textcolor{keywordflow}{elseif} (trim(config) == \textcolor{stringliteral}{"shelfwave"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{587       obc\%update\_OBC = .true.}
\DoxyCodeLine{588     \textcolor{keywordflow}{elseif} (lowercase(trim(config)) == \textcolor{stringliteral}{"supercritical"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{589       \textcolor{keyword}{call }supercritical\_set\_obc\_data(obc, g, pf)}
\DoxyCodeLine{590     \textcolor{keywordflow}{elseif} (trim(config) == \textcolor{stringliteral}{"tidal\_bay"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{591       obc\%update\_OBC = .true.}
\DoxyCodeLine{592     \textcolor{keywordflow}{elseif} (trim(config) == \textcolor{stringliteral}{"USER"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{593       \textcolor{keyword}{call }user\_set\_obc\_data(obc, tv, g, pf, tracer\_reg)}
\DoxyCodeLine{594     \textcolor{keywordflow}{elseif} (.not. trim(config) == \textcolor{stringliteral}{"none"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{595       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"The open boundary conditions specified by "}//\&}
\DoxyCodeLine{596               \textcolor{stringliteral}{"OBC\_USER\_CONFIG = "}//trim(config)//\textcolor{stringliteral}{" have not been fully implemented."})}
\DoxyCodeLine{597 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{598     \textcolor{keywordflow}{if} (open\_boundary\_query(obc, apply\_open\_obc=.true.)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{599       \textcolor{keyword}{call }set\_tracer\_data(obc, tv, h, g, pf, tracer\_reg)}
\DoxyCodeLine{600 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{601 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{602 \textcolor{comment}{! if (open\_boundary\_query(OBC, apply\_nudged\_OBC=.true.)) then}}
\DoxyCodeLine{603 \textcolor{comment}{!   call set\_3D\_OBC\_data(OBC, tv, h, G, PF, tracer\_Reg)}}
\DoxyCodeLine{604 \textcolor{comment}{! endif}}
\DoxyCodeLine{605   \textcolor{comment}{! Still need a way to specify the boundary values}}
\DoxyCodeLine{606   \textcolor{keywordflow}{if} (debug.and.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{607     \textcolor{keyword}{call }hchksum(g\%mask2dT, \textcolor{stringliteral}{'MOM\_initialize\_state: mask2dT '}, g\%HI)}
\DoxyCodeLine{608     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{'MOM\_initialize\_state: mask2dC[uv]'}, g\%mask2dCu,  \&}
\DoxyCodeLine{609                   g\%mask2dCv, g\%HI)}
\DoxyCodeLine{610     \textcolor{keyword}{call }qchksum(g\%mask2dBu, \textcolor{stringliteral}{'MOM\_initialize\_state: mask2dBu '}, g\%HI)}
\DoxyCodeLine{611 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{612 }
\DoxyCodeLine{613   \textcolor{keywordflow}{if} (debug\_obc) \textcolor{keyword}{call }open\_boundary\_test\_extern\_h(g, gv, obc, h)}
\DoxyCodeLine{614   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{'MOM\_initialize\_state()'})}
\DoxyCodeLine{615 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a807c1c2bb13f172945c7c25f3af7abd1}\label{namespacemom__state__initialization_a807c1c2bb13f172945c7c25f3af7abd1}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!mom\_state\_init\_tests@{mom\_state\_init\_tests}}
\index{mom\_state\_init\_tests@{mom\_state\_init\_tests}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{mom\_state\_init\_tests()}{mom\_state\_init\_tests()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::mom\+\_\+state\+\_\+init\+\_\+tests (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Run simple unit tests. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamics structure. \\
\hline
\end{DoxyParams}


Definition at line 2559 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2560   \textcolor{keywordtype}{type}(ocean\_grid\_type),     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{2561   \textcolor{keywordtype}{type}(verticalGrid\_type),   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{2562   \textcolor{keywordtype}{type}(unit\_scale\_type),     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{2563   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),     \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< Thermodynamics structure.}}
\DoxyCodeLine{2564 }
\DoxyCodeLine{2565   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{2566   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: nk=5}
\DoxyCodeLine{2567 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)} :: T, T\_t, T\_b \textcolor{comment}{! Temperatures [degC]}}
\DoxyCodeLine{2568 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)} :: S, S\_t, S\_b \textcolor{comment}{! Salinities [ppt]}}
\DoxyCodeLine{2569 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)} :: rho \textcolor{comment}{! Layer density [R \string~> kg m-\/3]}}
\DoxyCodeLine{2570 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)} :: h   \textcolor{comment}{! Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{2571 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk)} :: z   \textcolor{comment}{! Height of layer center [Z \string~> m]}}
\DoxyCodeLine{2572 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nk+1)} :: e \textcolor{comment}{! Interface heights [Z \string~> m]}}
\DoxyCodeLine{2573   \textcolor{keywordtype}{integer} :: k}
\DoxyCodeLine{2574 \textcolor{keywordtype}{  real} :: P\_tot, P\_t, P\_b    \textcolor{comment}{! Pressures [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{2575 \textcolor{keywordtype}{  real} :: z\_out              \textcolor{comment}{! Output height [Z \string~> m]}}
\DoxyCodeLine{2576 \textcolor{keywordtype}{  real} :: I\_z\_scale          \textcolor{comment}{! The inverse of the height scale for prescribed gradients [Z-\/1 \string~> m-\/1]}}
\DoxyCodeLine{2577   \textcolor{keywordtype}{type}(remapping\_CS), \textcolor{keywordtype}{pointer} :: remap\_CS => null()}
\DoxyCodeLine{2578 }
\DoxyCodeLine{2579   i\_z\_scale = 1.0 / (500.0*us\%m\_to\_Z)}
\DoxyCodeLine{2580   \textcolor{keywordflow}{do} k = 1, nk}
\DoxyCodeLine{2581     h(k) = 100.0*gv\%m\_to\_H}
\DoxyCodeLine{2582 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2583   e(1) = 0.}
\DoxyCodeLine{2584   \textcolor{keywordflow}{do} k = 1, nk}
\DoxyCodeLine{2585     e(k+1) = e(k) -\/ gv\%H\_to\_Z * h(k)}
\DoxyCodeLine{2586 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2587   p\_tot = 0.}
\DoxyCodeLine{2588   \textcolor{keywordflow}{do} k = 1, nk}
\DoxyCodeLine{2589     z(k) = 0.5 * ( e(k) + e(k+1) )}
\DoxyCodeLine{2590     t\_t(k) = 20. + (0. * i\_z\_scale) * e(k)}
\DoxyCodeLine{2591     t(k)   = 20. + (0. * i\_z\_scale)*z(k)}
\DoxyCodeLine{2592     t\_b(k) = 20. + (0. * i\_z\_scale)*e(k+1)}
\DoxyCodeLine{2593     s\_t(k) = 35. -\/ (0. * i\_z\_scale)*e(k)}
\DoxyCodeLine{2594     s(k)   = 35. + (0. * i\_z\_scale)*z(k)}
\DoxyCodeLine{2595     s\_b(k) = 35. -\/ (0. * i\_z\_scale)*e(k+1)}
\DoxyCodeLine{2596     \textcolor{keyword}{call }calculate\_density(0.5*(t\_t(k)+t\_b(k)), 0.5*(s\_t(k)+s\_b(k)), -\/gv\%Rho0*gv\%g\_Earth*us\%m\_to\_Z*z(k), \&}
\DoxyCodeLine{2597                            rho(k), tv\%eqn\_of\_state)}
\DoxyCodeLine{2598     p\_tot = p\_tot + gv\%g\_Earth * rho(k) * gv\%H\_to\_Z*h(k)}
\DoxyCodeLine{2599 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2600 }
\DoxyCodeLine{2601   p\_t = 0.}
\DoxyCodeLine{2602   \textcolor{keywordflow}{do} k = 1, nk}
\DoxyCodeLine{2603     \textcolor{keyword}{call }find\_depth\_of\_pressure\_in\_cell(t\_t(k), t\_b(k), s\_t(k), s\_b(k), e(k), e(k+1), p\_t, 0.5*p\_tot, \&}
\DoxyCodeLine{2604                                         gv\%Rho0, gv\%g\_Earth, tv\%eqn\_of\_state, us, p\_b, z\_out)}
\DoxyCodeLine{2605     \textcolor{keyword}{write}(0,*) k, us\%RL2\_T2\_to\_Pa*p\_t, us\%RL2\_T2\_to\_Pa*p\_b, 0.5*us\%RL2\_T2\_to\_Pa*p\_tot, \&}
\DoxyCodeLine{2606                us\%Z\_to\_m*e(k), us\%Z\_to\_m*e(k+1), us\%Z\_to\_m*z\_out}
\DoxyCodeLine{2607     p\_t = p\_b}
\DoxyCodeLine{2608 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2609   \textcolor{keyword}{write}(0,*) us\%RL2\_T2\_to\_Pa*p\_b, us\%RL2\_T2\_to\_Pa*p\_tot}
\DoxyCodeLine{2610 }
\DoxyCodeLine{2611   \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{''}}
\DoxyCodeLine{2612   \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{' ==================================================================== '}}
\DoxyCodeLine{2613   \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{''}}
\DoxyCodeLine{2614   \textcolor{keyword}{write}(0,*) gv\%H\_to\_m*h}
\DoxyCodeLine{2615   \textcolor{keyword}{call }cut\_off\_column\_top(nk, tv, gv, us, gv\%g\_Earth, -\/e(nk+1), gv\%Angstrom\_Z, \&}
\DoxyCodeLine{2616                           t, t\_t, t\_b, s, s\_t, s\_b, 0.5*p\_tot, h, remap\_cs)}
\DoxyCodeLine{2617   \textcolor{keyword}{write}(0,*) gv\%H\_to\_m*h}
\DoxyCodeLine{2618 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a4b1a2ab2ba01da2b898f5e65ebc30c9d}\label{namespacemom__state__initialization_a4b1a2ab2ba01da2b898f5e65ebc30c9d}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!mom\_temp\_salt\_initialize\_from\_z@{mom\_temp\_salt\_initialize\_from\_z}}
\index{mom\_temp\_salt\_initialize\_from\_z@{mom\_temp\_salt\_initialize\_from\_z}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{mom\_temp\_salt\_initialize\_from\_z()}{mom\_temp\_salt\_initialize\_from\_z()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::mom\+\_\+temp\+\_\+salt\+\_\+initialize\+\_\+from\+\_\+z (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine determines the isopycnal or other coordinate interfaces and layer potential temperatures and salinities directly from a z-\/space file on a latitude-\/longitude grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em h} & Layer thicknesses being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & A structure pointing to various thermodynamic variables including temperature and salinity \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1970 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1971   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1972 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1973                            \textcolor{keywordtype}{intent(out)}   :: h\textcolor{comment}{    !< Layer thicknesses being initialized [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1974   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic}}
\DoxyCodeLine{1975 \textcolor{comment}{                                                 !! variables including temperature and salinity}}
\DoxyCodeLine{1976   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{1977   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1978   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{   !< A structure indicating the open file}}
\DoxyCodeLine{1979 \textcolor{comment}{                                                 !! to parse for model parameter values.}}
\DoxyCodeLine{1980   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1981 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{1982 }
\DoxyCodeLine{1983   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1984   \textcolor{keywordtype}{character(len=200)} :: filename\textcolor{comment}{   !< The name of an input file containing temperature}}
\DoxyCodeLine{1985 \textcolor{comment}{                                   !! and salinity in z-\/space; also used for  ice shelf area.}}
\DoxyCodeLine{1986   \textcolor{keywordtype}{character(len=200)} :: tfilename\textcolor{comment}{  !< The name of an input file containing only temperature}}
\DoxyCodeLine{1987 \textcolor{comment}{                                   !! in z-\/space.}}
\DoxyCodeLine{1988   \textcolor{keywordtype}{character(len=200)} :: sfilename\textcolor{comment}{  !< The name of an input file containing only salinity}}
\DoxyCodeLine{1989 \textcolor{comment}{                                   !! in z-\/space.}}
\DoxyCodeLine{1990   \textcolor{keywordtype}{character(len=200)} :: shelf\_file\textcolor{comment}{ !< The name of an input file used for  ice shelf area.}}
\DoxyCodeLine{1991   \textcolor{keywordtype}{character(len=200)} :: inputdir   \textcolor{comment}{!! The directory where NetCDF input filesare.}}
\DoxyCodeLine{1992   \textcolor{keywordtype}{character(len=200)} :: mesg, area\_varname, ice\_shelf\_file}
\DoxyCodeLine{1993 }
\DoxyCodeLine{1994   \textcolor{keywordtype}{type}(EOS\_type), \textcolor{keywordtype}{pointer} :: eos => null()}
\DoxyCodeLine{1995   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_loc   \textcolor{comment}{! A temporary thermo\_var container}}
\DoxyCodeLine{1996   \textcolor{keywordtype}{type}(verticalGrid\_type) :: GV\_loc \textcolor{comment}{! A temporary vertical grid structure}}
\DoxyCodeLine{1997   \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{1998 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{1999 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_initialize\_layers\_from\_Z"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{2000 }
\DoxyCodeLine{2001   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The i-\/computational domain for the equation of state}}
\DoxyCodeLine{2002   \textcolor{keywordtype}{integer} :: is, ie, js, je, nz \textcolor{comment}{! compute domain indices}}
\DoxyCodeLine{2003   \textcolor{keywordtype}{integer} :: isc,iec,jsc,jec    \textcolor{comment}{! global compute domain indices}}
\DoxyCodeLine{2004   \textcolor{keywordtype}{integer} :: isg, ieg, jsg, jeg \textcolor{comment}{! global extent}}
\DoxyCodeLine{2005   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed \textcolor{comment}{! data domain indices}}
\DoxyCodeLine{2006 }
\DoxyCodeLine{2007   \textcolor{keywordtype}{integer} :: i, j, k, ks, np, ni, nj}
\DoxyCodeLine{2008   \textcolor{keywordtype}{integer} :: nkml     \textcolor{comment}{! The number of layers in the mixed layer.}}
\DoxyCodeLine{2009 }
\DoxyCodeLine{2010   \textcolor{keywordtype}{integer} :: kd, inconsistent}
\DoxyCodeLine{2011   \textcolor{keywordtype}{integer} :: nkd      \textcolor{comment}{! number of levels to use for regridding input arrays}}
\DoxyCodeLine{2012 \textcolor{keywordtype}{  real}    :: eps\_Z    \textcolor{comment}{! A negligibly thin layer thickness [Z \string~> m].}}
\DoxyCodeLine{2013 \textcolor{keywordtype}{  real}    :: eps\_rho  \textcolor{comment}{! A negligibly small density difference [R \string~> kg m-\/3].}}
\DoxyCodeLine{2014 \textcolor{keywordtype}{  real}    :: PI\_180   \textcolor{comment}{! for conversion from degrees to radians}}
\DoxyCodeLine{2015 }
\DoxyCodeLine{2016 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: shelf\_area => null()}
\DoxyCodeLine{2017 \textcolor{keywordtype}{  real}    :: Hmix\_default \textcolor{comment}{! The default initial mixed layer depth [m].}}
\DoxyCodeLine{2018 \textcolor{keywordtype}{  real}    :: Hmix\_depth   \textcolor{comment}{! The mixed layer depth in the initial condition [Z \string~> m].}}
\DoxyCodeLine{2019 \textcolor{keywordtype}{  real}    :: dilate       \textcolor{comment}{! A dilation factor to match topography [nondim]}}
\DoxyCodeLine{2020 \textcolor{keywordtype}{  real}    :: missing\_value\_temp, missing\_value\_salt}
\DoxyCodeLine{2021   \textcolor{keywordtype}{logical} :: correct\_thickness}
\DoxyCodeLine{2022   \textcolor{keywordtype}{character(len=40)} :: potemp\_var, salin\_var}
\DoxyCodeLine{2023   \textcolor{keywordtype}{character(len=8)}  :: laynum}
\DoxyCodeLine{2024 }
\DoxyCodeLine{2025   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: niter=10   \textcolor{comment}{! number of iterations for t/s adjustment to layer density}}
\DoxyCodeLine{2026   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{2027   \textcolor{keywordtype}{logical}            :: adjust\_temperature = .true.  \textcolor{comment}{! fit t/s to target densities}}
\DoxyCodeLine{2028 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter}    :: missing\_value = -\/1.e20}
\DoxyCodeLine{2029 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter}    :: temp\_land\_fill = 0.0, salt\_land\_fill = 35.0}
\DoxyCodeLine{2030   \textcolor{keywordtype}{logical} :: reentrant\_x, tripolar\_n,dbg}
\DoxyCodeLine{2031   \textcolor{keywordtype}{logical} :: debug = .false.  \textcolor{comment}{! manually set this to true for verbose output}}
\DoxyCodeLine{2032 }
\DoxyCodeLine{2033   \textcolor{comment}{! data arrays}}
\DoxyCodeLine{2034 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: z\_edges\_in, z\_in \textcolor{comment}{! Interface heights [Z \string~> m]}}
\DoxyCodeLine{2035 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: Rb  \textcolor{comment}{! Interface densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{2036 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: temp\_z, salt\_z, mask\_z}
\DoxyCodeLine{2037 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: rho\_z \textcolor{comment}{! Densities in Z-\/space [R \string~> kg m-\/3]}}
\DoxyCodeLine{2038 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)} :: zi   \textcolor{comment}{! Interface heights [Z \string~> m].}}
\DoxyCodeLine{2039   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}  :: nlevs}
\DoxyCodeLine{2040 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G))}   :: press  \textcolor{comment}{! Pressures [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{2041 }
\DoxyCodeLine{2042   \textcolor{comment}{! Local variables for ALE remapping}}
\DoxyCodeLine{2043 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: hTarget \textcolor{comment}{! Target thicknesses [Z \string~> m].}}
\DoxyCodeLine{2044 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable} :: area\_shelf\_h \textcolor{comment}{! Shelf-\/covered area per grid cell [L2 \string~> m2]}}
\DoxyCodeLine{2045 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: frac\_shelf\_h \textcolor{comment}{! Fractional shelf area per grid cell [nondim]}}
\DoxyCodeLine{2046 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: tmpT1dIn, tmpS1dIn}
\DoxyCodeLine{2047 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: tmp\_mask\_in}
\DoxyCodeLine{2048 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: h1 \textcolor{comment}{! Thicknesses [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{2049 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: dz\_interface \textcolor{comment}{! Change in position of interface due to regridding}}
\DoxyCodeLine{2050 \textcolor{keywordtype}{  real} :: zTopOfCell, zBottomOfCell \textcolor{comment}{! Heights in Z units [Z \string~> m].}}
\DoxyCodeLine{2051   \textcolor{keywordtype}{type}(regridding\_CS) :: regridCS \textcolor{comment}{! Regridding parameters and work arrays}}
\DoxyCodeLine{2052   \textcolor{keywordtype}{type}(remapping\_CS) :: remapCS \textcolor{comment}{! Remapping parameters and work arrays}}
\DoxyCodeLine{2053 }
\DoxyCodeLine{2054   \textcolor{keywordtype}{logical} :: homogenize, useALEremapping, remap\_full\_column, remap\_general, remap\_old\_alg}
\DoxyCodeLine{2055   \textcolor{keywordtype}{logical} :: answers\_2018, default\_2018\_answers, hor\_regrid\_answers\_2018}
\DoxyCodeLine{2056   \textcolor{keywordtype}{logical} :: use\_ice\_shelf}
\DoxyCodeLine{2057   \textcolor{keywordtype}{logical} :: pre\_gridded}
\DoxyCodeLine{2058   \textcolor{keywordtype}{logical} :: separate\_mixed\_layer  \textcolor{comment}{! If true, handle the mixed layers differently.}}
\DoxyCodeLine{2059   \textcolor{keywordtype}{character(len=10)} :: remappingScheme}
\DoxyCodeLine{2060 \textcolor{keywordtype}{  real} :: tempAvg, saltAvg}
\DoxyCodeLine{2061   \textcolor{keywordtype}{integer} :: nPoints, ans}
\DoxyCodeLine{2062   \textcolor{keywordtype}{integer} :: id\_clock\_routine, id\_clock\_read, id\_clock\_interp, id\_clock\_fill, id\_clock\_ALE}
\DoxyCodeLine{2063 }
\DoxyCodeLine{2064   id\_clock\_routine = cpu\_clock\_id(\textcolor{stringliteral}{'(Initialize from Z)'}, grain=clock\_routine)}
\DoxyCodeLine{2065   id\_clock\_ale = cpu\_clock\_id(\textcolor{stringliteral}{'(Initialize from Z) ALE'}, grain=clock\_loop)}
\DoxyCodeLine{2066 }
\DoxyCodeLine{2067   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_routine)}
\DoxyCodeLine{2068 }
\DoxyCodeLine{2069   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{2070   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{2071   isg = g\%isg ; ieg = g\%ieg ; jsg = g\%jsg ; jeg = g\%jeg}
\DoxyCodeLine{2072 }
\DoxyCodeLine{2073   pi\_180=atan(1.0)/45.}
\DoxyCodeLine{2074 }
\DoxyCodeLine{2075   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{2076 }
\DoxyCodeLine{2077   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_state\_initialization.F90"})}
\DoxyCodeLine{2078   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_version(pf, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{2079 }
\DoxyCodeLine{2080   inputdir = \textcolor{stringliteral}{"."} ;  \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir)}
\DoxyCodeLine{2081   inputdir = slasher(inputdir)}
\DoxyCodeLine{2082 }
\DoxyCodeLine{2083   eos => tv\%eqn\_of\_state}
\DoxyCodeLine{2084 }
\DoxyCodeLine{2085   reentrant\_x = .false. ; \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"REENTRANT\_X"}, reentrant\_x, default=.true.)}
\DoxyCodeLine{2086   tripolar\_n = .false. ;  \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"TRIPOLAR\_N"}, tripolar\_n, default=.false.)}
\DoxyCodeLine{2087 }
\DoxyCodeLine{2088   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"TEMP\_SALT\_Z\_INIT\_FILE"},filename, \&}
\DoxyCodeLine{2089                  \textcolor{stringliteral}{"The name of the z-\/space input file used to initialize "}//\&}
\DoxyCodeLine{2090                  \textcolor{stringliteral}{"temperatures (T) and salinities (S). If T and S are not "}//\&}
\DoxyCodeLine{2091                  \textcolor{stringliteral}{"in the same file, TEMP\_Z\_INIT\_FILE and SALT\_Z\_INIT\_FILE "}//\&}
\DoxyCodeLine{2092                  \textcolor{stringliteral}{"must be set."},default=\textcolor{stringliteral}{"temp\_salt\_z.nc"},do\_not\_log=just\_read)}
\DoxyCodeLine{2093   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"TEMP\_Z\_INIT\_FILE"},tfilename, \&}
\DoxyCodeLine{2094                  \textcolor{stringliteral}{"The name of the z-\/space input file used to initialize "}//\&}
\DoxyCodeLine{2095                  \textcolor{stringliteral}{"temperatures, only."}, default=trim(filename),do\_not\_log=just\_read)}
\DoxyCodeLine{2096   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"SALT\_Z\_INIT\_FILE"},sfilename, \&}
\DoxyCodeLine{2097                  \textcolor{stringliteral}{"The name of the z-\/space input file used to initialize "}//\&}
\DoxyCodeLine{2098                  \textcolor{stringliteral}{"temperatures, only."}, default=trim(filename),do\_not\_log=just\_read)}
\DoxyCodeLine{2099   filename = trim(inputdir)//trim(filename)}
\DoxyCodeLine{2100   tfilename = trim(inputdir)//trim(tfilename)}
\DoxyCodeLine{2101   sfilename = trim(inputdir)//trim(sfilename)}
\DoxyCodeLine{2102   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_FILE\_PTEMP\_VAR"}, potemp\_var, \&}
\DoxyCodeLine{2103                  \textcolor{stringliteral}{"The name of the potential temperature variable in "}//\&}
\DoxyCodeLine{2104                  \textcolor{stringliteral}{"TEMP\_Z\_INIT\_FILE."}, default=\textcolor{stringliteral}{"ptemp"},do\_not\_log=just\_read)}
\DoxyCodeLine{2105   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_FILE\_SALT\_VAR"}, salin\_var, \&}
\DoxyCodeLine{2106                  \textcolor{stringliteral}{"The name of the salinity variable in "}//\&}
\DoxyCodeLine{2107                  \textcolor{stringliteral}{"SALT\_Z\_INIT\_FILE."}, default=\textcolor{stringliteral}{"salt"},do\_not\_log=just\_read)}
\DoxyCodeLine{2108   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_HOMOGENIZE"}, homogenize, \&}
\DoxyCodeLine{2109                  \textcolor{stringliteral}{"If True, then horizontally homogenize the interpolated "}//\&}
\DoxyCodeLine{2110                  \textcolor{stringliteral}{"initial conditions."}, default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{2111   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_ALE\_REMAPPING"}, usealeremapping, \&}
\DoxyCodeLine{2112                  \textcolor{stringliteral}{"If True, then remap straight to model coordinate from file."}, \&}
\DoxyCodeLine{2113                  default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{2114   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_REMAPPING\_SCHEME"}, remappingscheme, \&}
\DoxyCodeLine{2115                  \textcolor{stringliteral}{"The remapping scheme to use if using Z\_INIT\_ALE\_REMAPPING "}//\&}
\DoxyCodeLine{2116                  \textcolor{stringliteral}{"is True."}, default=\textcolor{stringliteral}{"PPM\_IH4"}, do\_not\_log=just\_read)}
\DoxyCodeLine{2117   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_REMAP\_GENERAL"}, remap\_general, \&}
\DoxyCodeLine{2118                  \textcolor{stringliteral}{"If false, only initializes to z* coordinates. "}//\&}
\DoxyCodeLine{2119                  \textcolor{stringliteral}{"If true, allows initialization directly to general coordinates."},\&}
\DoxyCodeLine{2120                  default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{2121   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_REMAP\_FULL\_COLUMN"}, remap\_full\_column, \&}
\DoxyCodeLine{2122                  \textcolor{stringliteral}{"If false, only reconstructs profiles for valid data points. "}//\&}
\DoxyCodeLine{2123                  \textcolor{stringliteral}{"If true, inserts vanished layers below the valid data."}, \&}
\DoxyCodeLine{2124                  default=remap\_general, do\_not\_log=just\_read)}
\DoxyCodeLine{2125   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_REMAP\_OLD\_ALG"}, remap\_old\_alg, \&}
\DoxyCodeLine{2126                  \textcolor{stringliteral}{"If false, uses the preferred remapping algorithm for initialization. "}//\&}
\DoxyCodeLine{2127                  \textcolor{stringliteral}{"If true, use an older, less robust algorithm for remapping."}, \&}
\DoxyCodeLine{2128                  default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{2129   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{2130                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{2131                  default=.false.)}
\DoxyCodeLine{2132   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"TEMP\_SALT\_INIT\_VERTICAL\_REMAP\_ONLY"}, pre\_gridded, \&}
\DoxyCodeLine{2133                  \textcolor{stringliteral}{"If true, initial conditions are on the model horizontal grid. "} //\&}
\DoxyCodeLine{2134                  \textcolor{stringliteral}{"Extrapolation over missing ocean values is done using an ICE-\/9 "}//\&}
\DoxyCodeLine{2135                  \textcolor{stringliteral}{"procedure with vertical ALE remapping ."}, \&}
\DoxyCodeLine{2136                  default=.false.)}
\DoxyCodeLine{2137   \textcolor{keywordflow}{if} (usealeremapping) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2138     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, answers\_2018, \&}
\DoxyCodeLine{2139                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//\&}
\DoxyCodeLine{2140                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//\&}
\DoxyCodeLine{2141                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{2142 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2143   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"HOR\_REGRID\_2018\_ANSWERS"}, hor\_regrid\_answers\_2018, \&}
\DoxyCodeLine{2144                  \textcolor{stringliteral}{"If true, use the order of arithmetic for horizonal regridding that recovers "}//\&}
\DoxyCodeLine{2145                  \textcolor{stringliteral}{"the answers from the end of 2018.  Otherwise, use rotationally symmetric "}//\&}
\DoxyCodeLine{2146                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{2147   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"ICE\_SHELF"}, use\_ice\_shelf, default=.false.)}
\DoxyCodeLine{2148   \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2149     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"ICE\_THICKNESS\_FILE"}, ice\_shelf\_file, \&}
\DoxyCodeLine{2150                  \textcolor{stringliteral}{"The file from which the ice bathymetry and area are read."}, \&}
\DoxyCodeLine{2151                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{2152     shelf\_file = trim(inputdir)//trim(ice\_shelf\_file)}
\DoxyCodeLine{2153     \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_param(pf, mdl, \textcolor{stringliteral}{"INPUTDIR/THICKNESS\_FILE"}, shelf\_file)}
\DoxyCodeLine{2154     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"ICE\_AREA\_VARNAME"}, area\_varname, \&}
\DoxyCodeLine{2155                  \textcolor{stringliteral}{"The name of the area variable in ICE\_THICKNESS\_FILE."}, \&}
\DoxyCodeLine{2156                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{2157 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2158   \textcolor{keywordflow}{if} (.not.usealeremapping) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2159     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"ADJUST\_THICKNESS"}, correct\_thickness, \&}
\DoxyCodeLine{2160                  \textcolor{stringliteral}{"If true, all mass below the bottom removed if the "}//\&}
\DoxyCodeLine{2161                  \textcolor{stringliteral}{"topography is shallower than the thickness input file "}//\&}
\DoxyCodeLine{2162                  \textcolor{stringliteral}{"would indicate."}, default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{2163 }
\DoxyCodeLine{2164     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"FIT\_TO\_TARGET\_DENSITY\_IC"}, adjust\_temperature, \&}
\DoxyCodeLine{2165                  \textcolor{stringliteral}{"If true, all the interior layers are adjusted to "}//\&}
\DoxyCodeLine{2166                  \textcolor{stringliteral}{"their target densities using mostly temperature "}//\&}
\DoxyCodeLine{2167                  \textcolor{stringliteral}{"This approach can be problematic, particularly in the "}//\&}
\DoxyCodeLine{2168                  \textcolor{stringliteral}{"high latitudes."}, default=.true., do\_not\_log=just\_read)}
\DoxyCodeLine{2169     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_SEPARATE\_MIXED\_LAYER"}, separate\_mixed\_layer, \&}
\DoxyCodeLine{2170                  \textcolor{stringliteral}{"If true, distribute the topmost Z\_INIT\_HMIX\_DEPTH of water over NKML layers, "}//\&}
\DoxyCodeLine{2171                  \textcolor{stringliteral}{"and do not correct the density of the topmost NKML+NKBL layers.  Otherwise "}//\&}
\DoxyCodeLine{2172                  \textcolor{stringliteral}{"all layers are initialized based on the depths of their target densities."}, \&}
\DoxyCodeLine{2173                  default=.false., do\_not\_log=just\_read.or.(gv\%nkml==0))}
\DoxyCodeLine{2174     \textcolor{keywordflow}{if} (gv\%nkml == 0) separate\_mixed\_layer = .false.}
\DoxyCodeLine{2175     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, hmix\_default, default=0.0)}
\DoxyCodeLine{2176     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"Z\_INIT\_HMIX\_DEPTH"}, hmix\_depth, \&}
\DoxyCodeLine{2177                  \textcolor{stringliteral}{"The mixed layer depth in the initial conditions when Z\_INIT\_SEPARATE\_MIXED\_LAYER "}//\&}
\DoxyCodeLine{2178                  \textcolor{stringliteral}{"is set to true."}, default=hmix\_default, units=\textcolor{stringliteral}{"m"}, scale=us\%m\_to\_Z, \&}
\DoxyCodeLine{2179                  do\_not\_log=(just\_read .or. .not.separate\_mixed\_layer))}
\DoxyCodeLine{2180     \textcolor{comment}{! Reusing MINIMUM\_DEPTH for the default mixed layer depth may be a strange choice, but}}
\DoxyCodeLine{2181     \textcolor{comment}{! it reproduces previous answers.}}
\DoxyCodeLine{2182 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2183   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2184     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_routine)}
\DoxyCodeLine{2185     \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{2186 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2187 }
\DoxyCodeLine{2188   eps\_z = gv\%Angstrom\_Z}
\DoxyCodeLine{2189   eps\_rho = 1.0e-\/10*us\%kg\_m3\_to\_R}
\DoxyCodeLine{2190 }
\DoxyCodeLine{2191   \textcolor{comment}{! Read input grid coordinates for temperature and salinity field}}
\DoxyCodeLine{2192   \textcolor{comment}{! in z-\/coordinate dataset. The file is REQUIRED to contain the}}
\DoxyCodeLine{2193   \textcolor{comment}{! following:}}
\DoxyCodeLine{2194   \textcolor{comment}{!}}
\DoxyCodeLine{2195   \textcolor{comment}{! dimension variables:}}
\DoxyCodeLine{2196   \textcolor{comment}{!          lon (degrees\_E), lat (degrees\_N), depth(meters)}}
\DoxyCodeLine{2197   \textcolor{comment}{! variables:}}
\DoxyCodeLine{2198   \textcolor{comment}{!          ptemp(lon,lat,depth) : degC, potential temperature}}
\DoxyCodeLine{2199   \textcolor{comment}{!          salt (lon,lat,depth) : ppt, salinity}}
\DoxyCodeLine{2200   \textcolor{comment}{!}}
\DoxyCodeLine{2201   \textcolor{comment}{! The first record will be read if there are multiple time levels.}}
\DoxyCodeLine{2202   \textcolor{comment}{! The observation grid MUST tile the model grid. If the model grid extends}}
\DoxyCodeLine{2203   \textcolor{comment}{! to the North/South Pole past the limits of the input data, they are extrapolated using the average}}
\DoxyCodeLine{2204   \textcolor{comment}{! value at the northernmost/southernmost latitude.}}
\DoxyCodeLine{2205 }
\DoxyCodeLine{2206   \textcolor{keyword}{call }horiz\_interp\_and\_extrap\_tracer(tfilename, potemp\_var, 1.0, 1, \&}
\DoxyCodeLine{2207        g, temp\_z, mask\_z, z\_in, z\_edges\_in, missing\_value\_temp, reentrant\_x, \&}
\DoxyCodeLine{2208        tripolar\_n, homogenize, m\_to\_z=us\%m\_to\_Z, answers\_2018=hor\_regrid\_answers\_2018, ongrid=pre\_gridded)}
\DoxyCodeLine{2209 }
\DoxyCodeLine{2210   \textcolor{keyword}{call }horiz\_interp\_and\_extrap\_tracer(sfilename, salin\_var, 1.0, 1, \&}
\DoxyCodeLine{2211        g, salt\_z, mask\_z, z\_in, z\_edges\_in, missing\_value\_salt, reentrant\_x, \&}
\DoxyCodeLine{2212        tripolar\_n, homogenize, m\_to\_z=us\%m\_to\_Z, answers\_2018=hor\_regrid\_answers\_2018, ongrid=pre\_gridded)}
\DoxyCodeLine{2213 }
\DoxyCodeLine{2214   kd = \textcolor{keyword}{size}(z\_in,1)}
\DoxyCodeLine{2215 }
\DoxyCodeLine{2216   \textcolor{comment}{! Convert the sign convention of Z\_edges\_in.}}
\DoxyCodeLine{2217   \textcolor{keywordflow}{do} k=1,\textcolor{keyword}{size}(z\_edges\_in,1) ; z\_edges\_in(k) = -\/z\_edges\_in(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2218 }
\DoxyCodeLine{2219   \textcolor{keyword}{allocate}(rho\_z(isd:ied,jsd:jed,kd))}
\DoxyCodeLine{2220   \textcolor{keyword}{allocate}(area\_shelf\_h(isd:ied,jsd:jed))}
\DoxyCodeLine{2221   \textcolor{keyword}{allocate}(frac\_shelf\_h(isd:ied,jsd:jed))}
\DoxyCodeLine{2222 }
\DoxyCodeLine{2223   \textcolor{comment}{! Convert T\&S to Absolute Salinity and Conservative Temperature if using TEOS10 or NEMO}}
\DoxyCodeLine{2224   \textcolor{keyword}{call }convert\_temp\_salt\_for\_teos10(temp\_z, salt\_z, g\%HI, kd, mask\_z, eos)}
\DoxyCodeLine{2225 }
\DoxyCodeLine{2226   press(:) = tv\%P\_Ref}
\DoxyCodeLine{2227   eosdom(:) = eos\_domain(g\%HI)}
\DoxyCodeLine{2228   \textcolor{keywordflow}{do} k=1,kd ; \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{2229     \textcolor{keyword}{call }calculate\_density(temp\_z(:,j,k), salt\_z(:,j,k), press, rho\_z(:,j,k), eos, eosdom)}
\DoxyCodeLine{2230 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2231 }
\DoxyCodeLine{2232   \textcolor{keyword}{call }pass\_var(temp\_z,g\%Domain)}
\DoxyCodeLine{2233   \textcolor{keyword}{call }pass\_var(salt\_z,g\%Domain)}
\DoxyCodeLine{2234   \textcolor{keyword}{call }pass\_var(mask\_z,g\%Domain)}
\DoxyCodeLine{2235   \textcolor{keyword}{call }pass\_var(rho\_z,g\%Domain)}
\DoxyCodeLine{2236 }
\DoxyCodeLine{2237   \textcolor{comment}{! This is needed for building an ALE grid under ice shelves}}
\DoxyCodeLine{2238   \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2239     \textcolor{keywordflow}{if} (.not.file\_exists(shelf\_file, g\%Domain)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{2240       \textcolor{stringliteral}{"MOM\_temp\_salt\_initialize\_from\_Z: Unable to open shelf file "}//trim(shelf\_file))}
\DoxyCodeLine{2241 }
\DoxyCodeLine{2242     \textcolor{keyword}{call }mom\_read\_data(shelf\_file, trim(area\_varname), area\_shelf\_h, g\%Domain, scale=us\%m\_to\_L**2)}
\DoxyCodeLine{2243 }
\DoxyCodeLine{2244     \textcolor{comment}{! Initialize frac\_shelf\_h with zeros (open water everywhere)}}
\DoxyCodeLine{2245     frac\_shelf\_h(:,:) = 0.0}
\DoxyCodeLine{2246     \textcolor{comment}{! Compute fractional ice shelf coverage of h}}
\DoxyCodeLine{2247     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{2248       \textcolor{keywordflow}{if} (g\%areaT(i,j) > 0.0) \&}
\DoxyCodeLine{2249         frac\_shelf\_h(i,j) = area\_shelf\_h(i,j) / g\%areaT(i,j)}
\DoxyCodeLine{2250 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2251     \textcolor{comment}{! Pass to the pointer for use as an argument to regridding\_main}}
\DoxyCodeLine{2252     shelf\_area => frac\_shelf\_h}
\DoxyCodeLine{2253 }
\DoxyCodeLine{2254 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2255 }
\DoxyCodeLine{2256   \textcolor{comment}{! Done with horizontal interpolation.}}
\DoxyCodeLine{2257   \textcolor{comment}{! Now remap to model coordinates}}
\DoxyCodeLine{2258   \textcolor{keywordflow}{if} (usealeremapping) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2259     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_ale)}
\DoxyCodeLine{2260     nkd = max(gv\%ke, kd)}
\DoxyCodeLine{2261 }
\DoxyCodeLine{2262     \textcolor{comment}{! Build the source grid and copy data onto model-\/shaped arrays with vanished layers}}
\DoxyCodeLine{2263     \textcolor{keyword}{allocate}( tmp\_mask\_in(isd:ied,jsd:jed,nkd) ) ; tmp\_mask\_in(:,:,:) = 0.}
\DoxyCodeLine{2264     \textcolor{keyword}{allocate}( h1(isd:ied,jsd:jed,nkd) ) ; h1(:,:,:) = 0.}
\DoxyCodeLine{2265     \textcolor{keyword}{allocate}( tmpt1din(isd:ied,jsd:jed,nkd) ) ; tmpt1din(:,:,:) = 0.}
\DoxyCodeLine{2266     \textcolor{keyword}{allocate}( tmps1din(isd:ied,jsd:jed,nkd) ) ; tmps1din(:,:,:) = 0.}
\DoxyCodeLine{2267     \textcolor{keywordflow}{do} j = js, je ; \textcolor{keywordflow}{do} i = is, ie}
\DoxyCodeLine{2268       \textcolor{keywordflow}{if} (g\%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2269         ztopofcell = 0. ; zbottomofcell = 0.}
\DoxyCodeLine{2270         tmp\_mask\_in(i,j,1:kd) = mask\_z(i,j,:)}
\DoxyCodeLine{2271         \textcolor{keywordflow}{do} k = 1, nkd}
\DoxyCodeLine{2272           \textcolor{keywordflow}{if} (tmp\_mask\_in(i,j,k)>0. .and. k<=kd) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2273             zbottomofcell = max( z\_edges\_in(k+1), -\/g\%bathyT(i,j) )}
\DoxyCodeLine{2274             tmpt1din(i,j,k) = temp\_z(i,j,k)}
\DoxyCodeLine{2275             tmps1din(i,j,k) = salt\_z(i,j,k)}
\DoxyCodeLine{2276           \textcolor{keywordflow}{elseif} (k>1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2277             zbottomofcell = -\/g\%bathyT(i,j)}
\DoxyCodeLine{2278             tmpt1din(i,j,k) = tmpt1din(i,j,k-\/1)}
\DoxyCodeLine{2279             tmps1din(i,j,k) = tmps1din(i,j,k-\/1)}
\DoxyCodeLine{2280           \textcolor{keywordflow}{else} \textcolor{comment}{! This next block should only ever be reached over land}}
\DoxyCodeLine{2281             tmpt1din(i,j,k) = -\/99.9}
\DoxyCodeLine{2282             tmps1din(i,j,k) = -\/99.9}
\DoxyCodeLine{2283 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2284           h1(i,j,k) = gv\%Z\_to\_H * (ztopofcell -\/ zbottomofcell)}
\DoxyCodeLine{2285           ztopofcell = zbottomofcell \textcolor{comment}{! Bottom becomes top for next value of k}}
\DoxyCodeLine{2286 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2287         h1(i,j,kd) = h1(i,j,kd) + gv\%Z\_to\_H * max(0., ztopofcell + g\%bathyT(i,j) )}
\DoxyCodeLine{2288         \textcolor{comment}{! The max here is in case the data data is shallower than model}}
\DoxyCodeLine{2289 \textcolor{keywordflow}{      endif} \textcolor{comment}{! mask2dT}}
\DoxyCodeLine{2290 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2291     \textcolor{keyword}{deallocate}( tmp\_mask\_in )}
\DoxyCodeLine{2292     \textcolor{keyword}{call }pass\_var(h1, g\%Domain)}
\DoxyCodeLine{2293     \textcolor{keyword}{call }pass\_var(tmpt1din, g\%Domain)}
\DoxyCodeLine{2294     \textcolor{keyword}{call }pass\_var(tmps1din, g\%Domain)}
\DoxyCodeLine{2295 }
\DoxyCodeLine{2296     \textcolor{comment}{! Build the target grid (and set the model thickness to it)}}
\DoxyCodeLine{2297     \textcolor{comment}{! This call can be more general but is hard-\/coded for z* coordinates...  ????}}
\DoxyCodeLine{2298     \textcolor{keyword}{call }ale\_initregridding( gv, us, g\%max\_depth, pf, mdl, regridcs ) \textcolor{comment}{! sets regridCS}}
\DoxyCodeLine{2299 }
\DoxyCodeLine{2300     \textcolor{keywordflow}{if} (.not. remap\_general) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2301       \textcolor{comment}{! This is the old way of initializing to z* coordinates only}}
\DoxyCodeLine{2302       \textcolor{keyword}{allocate}( htarget(nz) )}
\DoxyCodeLine{2303       htarget = getcoordinateresolution( regridcs )}
\DoxyCodeLine{2304       \textcolor{keywordflow}{do} j = js, je ; \textcolor{keywordflow}{do} i = is, ie}
\DoxyCodeLine{2305         h(i,j,:) = 0.}
\DoxyCodeLine{2306         \textcolor{keywordflow}{if} (g\%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2307           \textcolor{comment}{! Build the target grid combining hTarget and topography}}
\DoxyCodeLine{2308           ztopofcell = 0. ; zbottomofcell = 0.}
\DoxyCodeLine{2309           \textcolor{keywordflow}{do} k = 1, nz}
\DoxyCodeLine{2310             zbottomofcell = max( ztopofcell -\/ htarget(k), -\/g\%bathyT(i,j) )}
\DoxyCodeLine{2311             h(i,j,k) = gv\%Z\_to\_H * (ztopofcell -\/ zbottomofcell)}
\DoxyCodeLine{2312             ztopofcell = zbottomofcell \textcolor{comment}{! Bottom becomes top for next value of k}}
\DoxyCodeLine{2313 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{2314         \textcolor{keywordflow}{else}}
\DoxyCodeLine{2315           h(i,j,:) = 0.}
\DoxyCodeLine{2316 \textcolor{keywordflow}{        endif} \textcolor{comment}{! mask2dT}}
\DoxyCodeLine{2317 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2318       \textcolor{keyword}{call }pass\_var(h, g\%Domain)}
\DoxyCodeLine{2319       \textcolor{keyword}{deallocate}( htarget )}
\DoxyCodeLine{2320 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2321 }
\DoxyCodeLine{2322     \textcolor{comment}{! Now remap from source grid to target grid, first setting reconstruction parameters}}
\DoxyCodeLine{2323     \textcolor{keyword}{call }initialize\_remapping( remapcs, remappingscheme, boundary\_extrapolation=.false., answers\_2018=answers\_2018 )}
\DoxyCodeLine{2324     \textcolor{keywordflow}{if} (remap\_general) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2325       \textcolor{keyword}{call }set\_regrid\_params( regridcs, min\_thickness=0. )}
\DoxyCodeLine{2326       tv\_loc = tv}
\DoxyCodeLine{2327       tv\_loc\%T => tmpt1din}
\DoxyCodeLine{2328       tv\_loc\%S => tmps1din}
\DoxyCodeLine{2329       gv\_loc = gv}
\DoxyCodeLine{2330       gv\_loc\%ke = nkd}
\DoxyCodeLine{2331       \textcolor{keyword}{allocate}( dz\_interface(isd:ied,jsd:jed,nkd+1) ) \textcolor{comment}{! Need for argument to regridding\_main() but is not used}}
\DoxyCodeLine{2332       \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2333         \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv\_loc, h1, tv\_loc, h, dz\_interface, shelf\_area )}
\DoxyCodeLine{2334       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2335         \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv\_loc, h1, tv\_loc, h, dz\_interface )}
\DoxyCodeLine{2336 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2337       \textcolor{keyword}{deallocate}( dz\_interface )}
\DoxyCodeLine{2338 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2339     \textcolor{keyword}{call }ale\_remap\_scalar(remapcs, g, gv, nkd, h1, tmpt1din, h, tv\%T, all\_cells=remap\_full\_column, \&}
\DoxyCodeLine{2340                           old\_remap=remap\_old\_alg, answers\_2018=answers\_2018 )}
\DoxyCodeLine{2341     \textcolor{keyword}{call }ale\_remap\_scalar(remapcs, g, gv, nkd, h1, tmps1din, h, tv\%S, all\_cells=remap\_full\_column, \&}
\DoxyCodeLine{2342                           old\_remap=remap\_old\_alg, answers\_2018=answers\_2018 )}
\DoxyCodeLine{2343     \textcolor{keyword}{deallocate}( h1 )}
\DoxyCodeLine{2344     \textcolor{keyword}{deallocate}( tmpt1din )}
\DoxyCodeLine{2345     \textcolor{keyword}{deallocate}( tmps1din )}
\DoxyCodeLine{2346 }
\DoxyCodeLine{2347     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_ale)}
\DoxyCodeLine{2348 }
\DoxyCodeLine{2349   \textcolor{keywordflow}{else} \textcolor{comment}{! remap to isopycnal layer space}}
\DoxyCodeLine{2350 }
\DoxyCodeLine{2351     \textcolor{comment}{! Next find interface positions using local arrays}}
\DoxyCodeLine{2352     \textcolor{comment}{! nlevs contains the number of valid data points in each column}}
\DoxyCodeLine{2353     nlevs = int(sum(mask\_z,dim=3))}
\DoxyCodeLine{2354 }
\DoxyCodeLine{2355     \textcolor{comment}{! Rb contains the layer interface densities}}
\DoxyCodeLine{2356     \textcolor{keyword}{allocate}(rb(nz+1))}
\DoxyCodeLine{2357     \textcolor{keywordflow}{do} k=2,nz ; rb(k) = 0.5*(gv\%Rlay(k-\/1)+gv\%Rlay(k)) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2358     rb(1) = 0.0}
\DoxyCodeLine{2359     \textcolor{keywordflow}{if} (nz>1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2360       rb(nz+1) = 2.0*gv\%Rlay(nz) -\/ gv\%Rlay(nz-\/1)}
\DoxyCodeLine{2361     \textcolor{keywordflow}{else}}
\DoxyCodeLine{2362       rb(nz+1) = 2.0 * gv\%Rlay(1)}
\DoxyCodeLine{2363 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2364 }
\DoxyCodeLine{2365     nkml = 0 ; \textcolor{keywordflow}{if} (separate\_mixed\_layer) nkml = gv\%nkml}
\DoxyCodeLine{2366 }
\DoxyCodeLine{2367     \textcolor{keyword}{call }find\_interfaces(rho\_z, z\_in, kd, rb, g\%bathyT, zi, g, us, \&}
\DoxyCodeLine{2368                          nlevs, nkml, hml=hmix\_depth, eps\_z=eps\_z, eps\_rho=eps\_rho)}
\DoxyCodeLine{2369 }
\DoxyCodeLine{2370     \textcolor{keywordflow}{if} (correct\_thickness) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2371       \textcolor{keyword}{call }adjustetatofitbathymetry(g, gv, us, zi, h)}
\DoxyCodeLine{2372     \textcolor{keywordflow}{else}}
\DoxyCodeLine{2373       \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{2374         \textcolor{keywordflow}{if} (zi(i,j,k) < (zi(i,j,k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2375           zi(i,j,k) = zi(i,j,k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{2376           h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{2377         \textcolor{keywordflow}{else}}
\DoxyCodeLine{2378           h(i,j,k) = gv\%Z\_to\_H * (zi(i,j,k) -\/ zi(i,j,k+1))}
\DoxyCodeLine{2379 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2380 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2381       inconsistent=0}
\DoxyCodeLine{2382       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{2383         \textcolor{keywordflow}{if} (abs(zi(i,j,nz+1) + g\%bathyT(i,j)) > 1.0*us\%m\_to\_Z) \&}
\DoxyCodeLine{2384           inconsistent = inconsistent + 1}
\DoxyCodeLine{2385 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2386       \textcolor{keyword}{call }sum\_across\_pes(inconsistent)}
\DoxyCodeLine{2387 }
\DoxyCodeLine{2388       \textcolor{keywordflow}{if} ((inconsistent > 0) .and. (is\_root\_pe())) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2389         \textcolor{keyword}{write}(mesg, \textcolor{stringliteral}{'("Thickness initial conditions are inconsistent ",'}// \&}
\DoxyCodeLine{2390                     \textcolor{stringliteral}{'"with topography in ",I5," places.")'}) inconsistent}
\DoxyCodeLine{2391         \textcolor{keyword}{call }mom\_error(warning, mesg)}
\DoxyCodeLine{2392 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2393 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2394 }
\DoxyCodeLine{2395     \textcolor{keyword}{call }tracer\_z\_init\_array(temp\_z, z\_edges\_in, kd, zi, missing\_value, g, nz, nlevs, eps\_z, tv\%T)}
\DoxyCodeLine{2396     \textcolor{keyword}{call }tracer\_z\_init\_array(salt\_z, z\_edges\_in, kd, zi, missing\_value, g, nz, nlevs, eps\_z, tv\%S)}
\DoxyCodeLine{2397 }
\DoxyCodeLine{2398     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{2399       npoints = 0 ; tempavg = 0. ; saltavg = 0.}
\DoxyCodeLine{2400       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (g\%mask2dT(i,j) >= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2401         npoints = npoints + 1}
\DoxyCodeLine{2402         tempavg = tempavg + tv\%T(i,j,k)}
\DoxyCodeLine{2403         saltavg = saltavg + tv\%S(i,j,k)}
\DoxyCodeLine{2404 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2405 }
\DoxyCodeLine{2406       \textcolor{comment}{! Horizontally homogenize data to produce perfectly "flat" initial conditions}}
\DoxyCodeLine{2407       \textcolor{keywordflow}{if} (homogenize) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2408         \textcolor{keyword}{call }sum\_across\_pes(npoints)}
\DoxyCodeLine{2409         \textcolor{keyword}{call }sum\_across\_pes(tempavg)}
\DoxyCodeLine{2410         \textcolor{keyword}{call }sum\_across\_pes(saltavg)}
\DoxyCodeLine{2411         \textcolor{keywordflow}{if} (npoints>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2412           tempavg = tempavg / real(npoints)}
\DoxyCodeLine{2413           saltavg = saltavg / real(npoints)}
\DoxyCodeLine{2414 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2415         tv\%T(:,:,k) = tempavg}
\DoxyCodeLine{2416         tv\%S(:,:,k) = saltavg}
\DoxyCodeLine{2417 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2418 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2419 }
\DoxyCodeLine{2420 \textcolor{keywordflow}{  endif} \textcolor{comment}{! useALEremapping}}
\DoxyCodeLine{2421 }
\DoxyCodeLine{2422   \textcolor{comment}{! Fill land values}}
\DoxyCodeLine{2423   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{2424     \textcolor{keywordflow}{if} (tv\%T(i,j,k) == missing\_value) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2425       tv\%T(i,j,k) = temp\_land\_fill}
\DoxyCodeLine{2426       tv\%S(i,j,k) = salt\_land\_fill}
\DoxyCodeLine{2427 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2428 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2429 }
\DoxyCodeLine{2430 }
\DoxyCodeLine{2431   \textcolor{keywordflow}{if} (adjust\_temperature .and. .not. usealeremapping) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2432     \textcolor{comment}{! Finally adjust to target density}}
\DoxyCodeLine{2433     ks = 1 ; \textcolor{keywordflow}{if} (separate\_mixed\_layer) ks = gv\%nk\_rho\_varies + 1}
\DoxyCodeLine{2434     \textcolor{keyword}{call }determine\_temperature(tv\%T, tv\%S, gv\%Rlay(1:nz), tv\%P\_Ref, niter, \&}
\DoxyCodeLine{2435                                missing\_value, h, ks, g, us, eos)}
\DoxyCodeLine{2436 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2437 }
\DoxyCodeLine{2438   \textcolor{keyword}{deallocate}(z\_in, z\_edges\_in, temp\_z, salt\_z, mask\_z)}
\DoxyCodeLine{2439   \textcolor{keyword}{deallocate}(rho\_z, area\_shelf\_h, frac\_shelf\_h)}
\DoxyCodeLine{2440 }
\DoxyCodeLine{2441   \textcolor{keyword}{call }pass\_var(h, g\%Domain)}
\DoxyCodeLine{2442   \textcolor{keyword}{call }pass\_var(tv\%T, g\%Domain)}
\DoxyCodeLine{2443   \textcolor{keyword}{call }pass\_var(tv\%S, g\%Domain)}
\DoxyCodeLine{2444 }
\DoxyCodeLine{2445   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})}
\DoxyCodeLine{2446   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_routine)}
\DoxyCodeLine{2447 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_ace20e4d29e01307fc37911d9ce4df2e3}\label{namespacemom__state__initialization_ace20e4d29e01307fc37911d9ce4df2e3}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!set\_velocity\_depth\_max@{set\_velocity\_depth\_max}}
\index{set\_velocity\_depth\_max@{set\_velocity\_depth\_max}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{set\_velocity\_depth\_max()}{set\_velocity\_depth\_max()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::set\+\_\+velocity\+\_\+depth\+\_\+max (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine sets the 4 bottom depths at velocity points to be the maximum of the adjacent depths. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\end{DoxyParams}


Definition at line 1915 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1916   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The ocean's grid structure}}
\DoxyCodeLine{1917   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1918   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{1919 }
\DoxyCodeLine{1920   \textcolor{keywordflow}{do} i=g\%isd,g\%ied-\/1 ; \textcolor{keywordflow}{do} j=g\%jsd,g\%jed}
\DoxyCodeLine{1921     g\%Dblock\_u(i,j) = g\%mask2dCu(i,j) * max(g\%bathyT(i,j), g\%bathyT(i+1,j))}
\DoxyCodeLine{1922     g\%Dopen\_u(i,j) = g\%Dblock\_u(i,j)}
\DoxyCodeLine{1923 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1924   \textcolor{keywordflow}{do} i=g\%isd,g\%ied ; \textcolor{keywordflow}{do} j=g\%jsd,g\%jed-\/1}
\DoxyCodeLine{1925     g\%Dblock\_v(i,j) = g\%mask2dCv(i,j) * max(g\%bathyT(i,j), g\%bathyT(i,j+1))}
\DoxyCodeLine{1926     g\%Dopen\_v(i,j) = g\%Dblock\_v(i,j)}
\DoxyCodeLine{1927 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_a9eda11f130fa39ea833f7b1e4d099c58}\label{namespacemom__state__initialization_a9eda11f130fa39ea833f7b1e4d099c58}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!set\_velocity\_depth\_min@{set\_velocity\_depth\_min}}
\index{set\_velocity\_depth\_min@{set\_velocity\_depth\_min}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{set\_velocity\_depth\_min()}{set\_velocity\_depth\_min()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::set\+\_\+velocity\+\_\+depth\+\_\+min (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine sets the 4 bottom depths at velocity points to be the minimum of the adjacent depths. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\end{DoxyParams}


Definition at line 1952 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1953   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1954   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1955   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{1956 }
\DoxyCodeLine{1957   \textcolor{keywordflow}{do} i=g\%isd,g\%ied-\/1 ; \textcolor{keywordflow}{do} j=g\%jsd,g\%jed}
\DoxyCodeLine{1958     g\%Dblock\_u(i,j) = g\%mask2dCu(i,j) * min(g\%bathyT(i,j), g\%bathyT(i+1,j))}
\DoxyCodeLine{1959     g\%Dopen\_u(i,j) = g\%Dblock\_u(i,j)}
\DoxyCodeLine{1960 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1961   \textcolor{keywordflow}{do} i=g\%isd,g\%ied ; \textcolor{keywordflow}{do} j=g\%jsd,g\%jed-\/1}
\DoxyCodeLine{1962     g\%Dblock\_v(i,j) = g\%mask2dCv(i,j) * min(g\%bathyT(i,j), g\%bathyT(i,j+1))}
\DoxyCodeLine{1963     g\%Dopen\_v(i,j) = g\%Dblock\_v(i,j)}
\DoxyCodeLine{1964 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__state__initialization_abbe8ee99793eae86251739a8a1bf572f}\label{namespacemom__state__initialization_abbe8ee99793eae86251739a8a1bf572f}} 
\index{mom\_state\_initialization@{mom\_state\_initialization}!trim\_for\_ice@{trim\_for\_ice}}
\index{trim\_for\_ice@{trim\_for\_ice}!mom\_state\_initialization@{mom\_state\_initialization}}
\doxysubsubsection{\texorpdfstring{trim\_for\_ice()}{trim\_for\_ice()}}
{\footnotesize\ttfamily subroutine mom\+\_\+state\+\_\+initialization\+::trim\+\_\+for\+\_\+ice (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(ale\+\_\+cs), pointer}]{A\+L\+E\+\_\+\+C\+Sp,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(inout)}]{h,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Adjust the layer thicknesses by cutting away the top of each model column at the depth where the hydrostatic pressure matches an imposed surface pressure read from file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em pf} & Parameter file structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em ale\+\_\+csp} & A\+LE control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamics structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 1081 of file M\+O\+M\+\_\+state\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1082   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{1083   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< Ocean grid structure}}
\DoxyCodeLine{1084   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< Vertical grid structure}}
\DoxyCodeLine{1085   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{1086   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{pointer}       :: ALE\_CSp\textcolor{comment}{ !< ALE control structure}}
\DoxyCodeLine{1087   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{ !< Thermodynamics structure}}
\DoxyCodeLine{1088 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1089                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{  !< Layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1090   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{1091 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{1092   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1093   \textcolor{keywordtype}{character(len=200)} :: mdl = \textcolor{stringliteral}{"trim\_for\_ice"}}
\DoxyCodeLine{1094 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: p\_surf \textcolor{comment}{! Imposed pressure on ocean at surface [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{1095 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: S\_t, S\_b \textcolor{comment}{! Top and bottom edge values for reconstructions}}
\DoxyCodeLine{1096 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: T\_t, T\_b \textcolor{comment}{! of salinity [ppt] and temperature [degC] within each layer.}}
\DoxyCodeLine{1097   \textcolor{keywordtype}{character(len=200)} :: inputdir, filename, p\_surf\_file, p\_surf\_var \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{1098 \textcolor{keywordtype}{  real} :: scale\_factor   \textcolor{comment}{! A file-\/dependent scaling factor for the input pressure.}}
\DoxyCodeLine{1099 \textcolor{keywordtype}{  real} :: min\_thickness  \textcolor{comment}{! The minimum layer thickness, recast into Z units [Z \string~> m].}}
\DoxyCodeLine{1100   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{1101   \textcolor{keywordtype}{logical} :: default\_2018\_answers, remap\_answers\_2018}
\DoxyCodeLine{1102   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{1103   \textcolor{keywordtype}{logical} :: use\_remapping \textcolor{comment}{! If true, remap the initial conditions.}}
\DoxyCodeLine{1104   \textcolor{keywordtype}{type}(remapping\_CS), \textcolor{keywordtype}{pointer} :: remap\_CS => null()}
\DoxyCodeLine{1105 }
\DoxyCodeLine{1106   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{1107 }
\DoxyCodeLine{1108   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"SURFACE\_PRESSURE\_FILE"}, p\_surf\_file, \&}
\DoxyCodeLine{1109                  \textcolor{stringliteral}{"The initial condition file for the surface pressure exerted by ice."}, \&}
\DoxyCodeLine{1110                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{1111   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"SURFACE\_PRESSURE\_VAR"}, p\_surf\_var, \&}
\DoxyCodeLine{1112                  \textcolor{stringliteral}{"The initial condition variable for the surface pressure exerted by ice."}, \&}
\DoxyCodeLine{1113                  units=\textcolor{stringliteral}{"Pa"}, default=\textcolor{stringliteral}{""}, do\_not\_log=just\_read)}
\DoxyCodeLine{1114   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."}, do\_not\_log=.true.)}
\DoxyCodeLine{1115   filename = trim(slasher(inputdir))//trim(p\_surf\_file)}
\DoxyCodeLine{1116   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_param(pf,  mdl, \textcolor{stringliteral}{"!INPUTDIR/SURFACE\_HEIGHT\_IC\_FILE"}, filename)}
\DoxyCodeLine{1117 }
\DoxyCodeLine{1118   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"SURFACE\_PRESSURE\_SCALE"}, scale\_factor, \&}
\DoxyCodeLine{1119                  \textcolor{stringliteral}{"A scaling factor to convert SURFACE\_PRESSURE\_VAR from "}//\&}
\DoxyCodeLine{1120                  \textcolor{stringliteral}{"file SURFACE\_PRESSURE\_FILE into a surface pressure."}, \&}
\DoxyCodeLine{1121                  units=\textcolor{stringliteral}{"file dependent"}, default=1., do\_not\_log=just\_read)}
\DoxyCodeLine{1122   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"MIN\_THICKNESS"}, min\_thickness, \textcolor{stringliteral}{'Minimum layer thickness'}, \&}
\DoxyCodeLine{1123                  units=\textcolor{stringliteral}{'m'}, default=1.e-\/3, do\_not\_log=just\_read, scale=us\%m\_to\_Z)}
\DoxyCodeLine{1124   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"TRIMMING\_USES\_REMAPPING"}, use\_remapping, \&}
\DoxyCodeLine{1125                  \textcolor{stringliteral}{'When trimming the column, also remap T and S.'}, \&}
\DoxyCodeLine{1126                  default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{1127   remap\_answers\_2018 = .true.}
\DoxyCodeLine{1128   \textcolor{keywordflow}{if} (use\_remapping) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1129     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{1130                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{1131                  default=.false.)}
\DoxyCodeLine{1132     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, remap\_answers\_2018, \&}
\DoxyCodeLine{1133                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//\&}
\DoxyCodeLine{1134                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//\&}
\DoxyCodeLine{1135                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{1136 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1137 }
\DoxyCodeLine{1138   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{1139 }
\DoxyCodeLine{1140   \textcolor{keyword}{call }mom\_read\_data(filename, p\_surf\_var, p\_surf, g\%Domain, \&}
\DoxyCodeLine{1141                      scale=scale\_factor*us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2)}
\DoxyCodeLine{1142 }
\DoxyCodeLine{1143   \textcolor{keywordflow}{if} (use\_remapping) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1144     \textcolor{keyword}{allocate}(remap\_cs)}
\DoxyCodeLine{1145     \textcolor{keyword}{call }initialize\_remapping(remap\_cs, \textcolor{stringliteral}{'PLM'}, boundary\_extrapolation=.true.)}
\DoxyCodeLine{1146 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1147 }
\DoxyCodeLine{1148   \textcolor{comment}{! Find edge values of T and S used in reconstructions}}
\DoxyCodeLine{1149   \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(ale\_csp) ) \textcolor{keywordflow}{then} \textcolor{comment}{! This should only be associated if we are in ALE mode}}
\DoxyCodeLine{1150     \textcolor{keyword}{call }ts\_plm\_edge\_values(ale\_csp, s\_t, s\_b, t\_t, t\_b, g, gv, tv, h, .true.)}
\DoxyCodeLine{1151   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1152 \textcolor{comment}{!    call MOM\_error(FATAL, "trim\_for\_ice: Does not work without ALE mode")}}
\DoxyCodeLine{1153     \textcolor{keywordflow}{do} k=1,g\%ke ; \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1154       t\_t(i,j,k) = tv\%T(i,j,k) ; t\_b(i,j,k) = tv\%T(i,j,k)}
\DoxyCodeLine{1155       s\_t(i,j,k) = tv\%S(i,j,k) ; s\_b(i,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{1156 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1157 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1158 }
\DoxyCodeLine{1159   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1160     \textcolor{keyword}{call }cut\_off\_column\_top(gv\%ke, tv, gv, us, gv\%g\_Earth, g\%bathyT(i,j), \&}
\DoxyCodeLine{1161                min\_thickness, tv\%T(i,j,:), t\_t(i,j,:), t\_b(i,j,:), \&}
\DoxyCodeLine{1162                tv\%S(i,j,:), s\_t(i,j,:), s\_b(i,j,:), p\_surf(i,j), h(i,j,:), remap\_cs, \&}
\DoxyCodeLine{1163                z\_tol=1.0e-\/5*us\%m\_to\_Z, remap\_answers\_2018=remap\_answers\_2018)}
\DoxyCodeLine{1164 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1165 }

\end{DoxyCode}
