\hypertarget{interfacemom__interface__heights_1_1find__eta}{}\doxysection{mom\+\_\+interface\+\_\+heights\+::find\+\_\+eta Interface Reference}
\label{interfacemom__interface__heights_1_1find__eta}\index{mom\_interface\_heights::find\_eta@{mom\_interface\_heights::find\_eta}}


\doxysubsection{Detailed Description}
Calculates the heights of sruface or all interfaces from layer thicknesses. 

Definition at line 21 of file M\+O\+M\+\_\+interface\+\_\+heights.\+F90.

\doxysubsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{interfacemom__interface__heights_1_1find__eta_ae26c15f886fb9bcad8586126f15f8bc9}{find\+\_\+eta\+\_\+2d}} (h, tv, G, GV, US, eta, eta\+\_\+bt, halo\+\_\+size, eta\+\_\+to\+\_\+m)
\begin{DoxyCompactList}\small\item\em Calculates the free surface height, using the appropriate form for consistency with the calculation of the pressure gradient forces. Additionally, the sea surface height may be adjusted for consistency with the corresponding time-\/average quantity from the barotropic calculation. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{interfacemom__interface__heights_1_1find__eta_a41b663c6f254432fda1d6a54e710a71d}{find\+\_\+eta\+\_\+3d}} (h, tv, G, GV, US, eta, eta\+\_\+bt, halo\+\_\+size, eta\+\_\+to\+\_\+m)
\begin{DoxyCompactList}\small\item\em Calculates the heights of all interfaces between layers, using the appropriate form for consistency with the calculation of the pressure gradient forces. Additionally, these height may be dilated for consistency with the corresponding time-\/average quantity from the barotropic calculation. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Calculates the heights of sruface or all interfaces from layer thicknesses. 

Definition at line 21 of file M\+O\+M\+\_\+interface\+\_\+heights.\+F90.



\doxysubsection{Functions and subroutines}
\mbox{\Hypertarget{interfacemom__interface__heights_1_1find__eta_ae26c15f886fb9bcad8586126f15f8bc9}\label{interfacemom__interface__heights_1_1find__eta_ae26c15f886fb9bcad8586126f15f8bc9}} 
\index{mom\_interface\_heights::find\_eta@{mom\_interface\_heights::find\_eta}!find\_eta\_2d@{find\_eta\_2d}}
\index{find\_eta\_2d@{find\_eta\_2d}!mom\_interface\_heights::find\_eta@{mom\_interface\_heights::find\_eta}}
\doxysubsubsection{\texorpdfstring{find\_eta\_2d()}{find\_eta\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+interface\+\_\+heights\+::find\+\_\+eta\+::find\+\_\+eta\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\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), intent(out)}]{eta,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in), optional}]{eta\+\_\+bt,  }\item[{integer, intent(in), optional}]{halo\+\_\+size,  }\item[{real, intent(in), optional}]{eta\+\_\+to\+\_\+m }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calculates the free surface height, using the appropriate form for consistency with the calculation of the pressure gradient forces. Additionally, the sea surface height may be adjusted for consistency with the corresponding time-\/average quantity from the barotropic calculation. 


\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 h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables. \\
\hline
\mbox{\texttt{ out}}  & {\em eta} & free surface height relative to mean sea level (z=0) often \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em eta\+\_\+bt} & optional barotropic variable that gives the \char`\"{}correct\char`\"{} free surface height (Boussinesq) or total water column mass per unit area (non-\/\+Boussinesq) \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em halo\+\_\+size} & width of halo points on which to calculate eta. \\
\hline
\mbox{\texttt{ in}}  & {\em eta\+\_\+to\+\_\+m} & The conversion factor from the units of eta to m; by default this is USZ\+\_\+to\+\_\+m. \\
\hline
\end{DoxyParams}


Definition at line 148 of file M\+O\+M\+\_\+interface\+\_\+heights.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{149   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{   !< The ocean's grid structure.}}
\DoxyCodeLine{150   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{  !< The ocean's vertical grid structure.}}
\DoxyCodeLine{151   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{152 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{   !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{153   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{  !< A structure pointing to various}}
\DoxyCodeLine{154 \textcolor{comment}{                                                                 !! thermodynamic variables.}}
\DoxyCodeLine{155 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},           \textcolor{keywordtype}{intent(out)} :: eta\textcolor{comment}{ !< free surface height relative to}}
\DoxyCodeLine{156 \textcolor{comment}{                                                                 !! mean sea level (z=0) often [Z \string~> m].}}
\DoxyCodeLine{157 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: eta\_bt\textcolor{comment}{ !< optional barotropic}}
\DoxyCodeLine{158 \textcolor{comment}{                   !! variable that gives the "correct" free surface height (Boussinesq) or total}}
\DoxyCodeLine{159 \textcolor{comment}{                   !! water column mass per unit area (non-\/Boussinesq) [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{160   \textcolor{keywordtype}{integer},                          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: halo\_size\textcolor{comment}{ !< width of halo points on}}
\DoxyCodeLine{161 \textcolor{comment}{                                                                 !! which to calculate eta.}}
\DoxyCodeLine{162 \textcolor{keywordtype}{  real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: eta\_to\_m\textcolor{comment}{  !< The conversion factor from}}
\DoxyCodeLine{163 \textcolor{comment}{             !! the units of eta to m; by default this is US\%Z\_to\_m.}}
\DoxyCodeLine{164   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{165 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)} :: \&}
\DoxyCodeLine{166     p          \textcolor{comment}{! Hydrostatic pressure at each interface [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{167 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: \&}
\DoxyCodeLine{168     dz\_geo     \textcolor{comment}{! The change in geopotential height across a layer [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{169 \textcolor{keywordtype}{  real} :: htot(SZI\_(G))  \textcolor{comment}{! The sum of all layers' thicknesses [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{170 \textcolor{keywordtype}{  real} :: I\_gEarth          \textcolor{comment}{! The inverse of the gravitational acceleration times the}}
\DoxyCodeLine{171                             \textcolor{comment}{! rescaling factor derived from eta\_to\_m [T2 Z L-\/2 \string~> s2 m-\/1]}}
\DoxyCodeLine{172 \textcolor{keywordtype}{  real} :: Z\_to\_eta, H\_to\_eta, H\_to\_rho\_eta \textcolor{comment}{! Unit conversion factors with obvious names.}}
\DoxyCodeLine{173   \textcolor{keywordtype}{integer} i, j, k, is, ie, js, je, nz, halo}
\DoxyCodeLine{174 }
\DoxyCodeLine{175   halo = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(halo\_size)) halo = max(0,halo\_size)}
\DoxyCodeLine{176   is = g\%isc-\/halo ; ie = g\%iec+halo ; js = g\%jsc-\/halo ; je = g\%jec+halo}
\DoxyCodeLine{177   nz = g\%ke}
\DoxyCodeLine{178 }
\DoxyCodeLine{179   z\_to\_eta = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta\_to\_m)) z\_to\_eta = us\%Z\_to\_m / eta\_to\_m}
\DoxyCodeLine{180   h\_to\_eta = gv\%H\_to\_Z * z\_to\_eta}
\DoxyCodeLine{181   h\_to\_rho\_eta =  gv\%H\_to\_RZ * z\_to\_eta}
\DoxyCodeLine{182   i\_gearth = z\_to\_eta / gv\%g\_Earth}
\DoxyCodeLine{183 }
\DoxyCodeLine{184 \textcolor{comment}{!\$OMP parallel default(shared) private(htot)}}
\DoxyCodeLine{185 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{186   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; eta(i,j) = -\/z\_to\_eta*g\%bathyT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{187 }
\DoxyCodeLine{188   \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{189     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta\_bt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{190 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{191       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{192         eta(i,j) = h\_to\_eta*eta\_bt(i,j)}
\DoxyCodeLine{193 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{194     \textcolor{keywordflow}{else}}
\DoxyCodeLine{195 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{196       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{197         eta(i,j) = eta(i,j) + h(i,j,k)*h\_to\_eta}
\DoxyCodeLine{198 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{199 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{200   \textcolor{keywordflow}{else}}
\DoxyCodeLine{201     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{202 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{203       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{204         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%p\_surf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{205           \textcolor{keywordflow}{do} i=is,ie ; p(i,j,1) = tv\%p\_surf(i,j) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{206         \textcolor{keywordflow}{else}}
\DoxyCodeLine{207           \textcolor{keywordflow}{do} i=is,ie ; p(i,j,1) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{208 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{209 }
\DoxyCodeLine{210         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{211           p(i,j,k+1) = p(i,j,k) + gv\%g\_Earth*gv\%H\_to\_RZ*h(i,j,k)}
\DoxyCodeLine{212 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{213 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{214 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{215       \textcolor{keywordflow}{do} k = 1, nz}
\DoxyCodeLine{216         \textcolor{keyword}{call }int\_specific\_vol\_dp(tv\%T(:,:,k), tv\%S(:,:,k), p(:,:,k), p(:,:,k+1), 0.0, \&}
\DoxyCodeLine{217                                  g\%HI, tv\%eqn\_of\_state, us, dz\_geo(:,:,k), halo\_size=halo)}
\DoxyCodeLine{218 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{219 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{220       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{221           eta(i,j) = eta(i,j) + i\_gearth * dz\_geo(i,j,k)}
\DoxyCodeLine{222 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{223     \textcolor{keywordflow}{else}}
\DoxyCodeLine{224 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{225       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{226         eta(i,j) = eta(i,j) + h\_to\_rho\_eta*h(i,j,k) / gv\%Rlay(k)}
\DoxyCodeLine{227 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{228 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{229     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta\_bt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{230       \textcolor{comment}{!   Dilate the water column to agree with the time-\/averaged column}}
\DoxyCodeLine{231       \textcolor{comment}{! mass from the barotropic solution.}}
\DoxyCodeLine{232 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{233       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{234         \textcolor{keywordflow}{do} i=is,ie ; htot(i) = gv\%H\_subroundoff ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{235         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie ; htot(i) = htot(i) + h(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{236         \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{237           eta(i,j) = (eta\_bt(i,j) / htot(i)) * (eta(i,j) + z\_to\_eta*g\%bathyT(i,j)) -\/ \&}
\DoxyCodeLine{238                      z\_to\_eta*g\%bathyT(i,j)}
\DoxyCodeLine{239 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{240 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{241 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{242 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{243 \textcolor{comment}{!\$OMP end parallel}}
\DoxyCodeLine{244 }

\end{DoxyCode}
\mbox{\Hypertarget{interfacemom__interface__heights_1_1find__eta_a41b663c6f254432fda1d6a54e710a71d}\label{interfacemom__interface__heights_1_1find__eta_a41b663c6f254432fda1d6a54e710a71d}} 
\index{mom\_interface\_heights::find\_eta@{mom\_interface\_heights::find\_eta}!find\_eta\_3d@{find\_eta\_3d}}
\index{find\_eta\_3d@{find\_eta\_3d}!mom\_interface\_heights::find\_eta@{mom\_interface\_heights::find\_eta}}
\doxysubsubsection{\texorpdfstring{find\_eta\_3d()}{find\_eta\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+interface\+\_\+heights\+::find\+\_\+eta\+::find\+\_\+eta\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\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(out)}]{eta,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in), optional}]{eta\+\_\+bt,  }\item[{integer, intent(in), optional}]{halo\+\_\+size,  }\item[{real, intent(in), optional}]{eta\+\_\+to\+\_\+m }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calculates the heights of all interfaces between layers, using the appropriate form for consistency with the calculation of the pressure gradient forces. Additionally, these height may be dilated for consistency with the corresponding time-\/average quantity from the barotropic calculation. 


\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 h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables. \\
\hline
\mbox{\texttt{ out}}  & {\em eta} & layer interface heights \mbox{[}Z $\sim$$>$ m\mbox{]} or 1/eta\+\_\+to\+\_\+m m). \\
\hline
\mbox{\texttt{ in}}  & {\em eta\+\_\+bt} & optional barotropic variable that gives the \char`\"{}correct\char`\"{} free surface height (Boussinesq) or total water column mass per unit area (non-\/\+Boussinesq). This is used to dilate the layer. thicknesses when calculating interfaceheights \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em halo\+\_\+size} & width of halo points on which to calculate eta. \\
\hline
\mbox{\texttt{ in}}  & {\em eta\+\_\+to\+\_\+m} & The conversion factor from the units of eta to m; by default this is USZ\+\_\+to\+\_\+m. \\
\hline
\end{DoxyParams}


Definition at line 31 of file M\+O\+M\+\_\+interface\+\_\+heights.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{32   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{   !< The ocean's grid structure.}}
\DoxyCodeLine{33   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{  !< The ocean's vertical grid structure.}}
\DoxyCodeLine{34   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{35 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{   !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{36   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{  !< A structure pointing to various}}
\DoxyCodeLine{37 \textcolor{comment}{                                                                 !! thermodynamic variables.}}
\DoxyCodeLine{38 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \textcolor{keywordtype}{intent(out)} :: eta\textcolor{comment}{ !< layer interface heights}}
\DoxyCodeLine{39 \textcolor{comment}{                                                                 !! [Z \string~> m] or 1/eta\_to\_m m).}}
\DoxyCodeLine{40 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: eta\_bt\textcolor{comment}{ !< optional barotropic}}
\DoxyCodeLine{41 \textcolor{comment}{             !! variable that gives the "correct" free surface height (Boussinesq) or total water}}
\DoxyCodeLine{42 \textcolor{comment}{             !! column mass per unit area (non-\/Boussinesq).  This is used to dilate the layer.}}
\DoxyCodeLine{43 \textcolor{comment}{             !! thicknesses when calculating interfaceheights [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{44   \textcolor{keywordtype}{integer},                          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: halo\_size\textcolor{comment}{ !< width of halo points on}}
\DoxyCodeLine{45 \textcolor{comment}{                                                                 !! which to calculate eta.}}
\DoxyCodeLine{46 \textcolor{keywordtype}{  real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: eta\_to\_m\textcolor{comment}{  !< The conversion factor from}}
\DoxyCodeLine{47 \textcolor{comment}{             !! the units of eta to m; by default this is US\%Z\_to\_m.}}
\DoxyCodeLine{48 }
\DoxyCodeLine{49   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{50 \textcolor{keywordtype}{  real} :: p(SZI\_(G),SZJ\_(G),SZK\_(G)+1)    \textcolor{comment}{! Hydrostatic pressure at each interface [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{51 \textcolor{keywordtype}{  real} :: dz\_geo(SZI\_(G),SZJ\_(G),SZK\_(G)) \textcolor{comment}{! The change in geopotential height}}
\DoxyCodeLine{52                                           \textcolor{comment}{! across a layer [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{53 \textcolor{keywordtype}{  real} :: dilate(SZI\_(G))                 \textcolor{comment}{! non-\/dimensional dilation factor}}
\DoxyCodeLine{54 \textcolor{keywordtype}{  real} :: htot(SZI\_(G))                   \textcolor{comment}{! total thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{55 \textcolor{keywordtype}{  real} :: I\_gEarth          \textcolor{comment}{! The inverse of the gravitational acceleration times the}}
\DoxyCodeLine{56                             \textcolor{comment}{! rescaling factor derived from eta\_to\_m [T2 Z L-\/2 \string~> s2 m-\/1]}}
\DoxyCodeLine{57 \textcolor{keywordtype}{  real} :: Z\_to\_eta, H\_to\_eta, H\_to\_rho\_eta \textcolor{comment}{! Unit conversion factors with obvious names.}}
\DoxyCodeLine{58   \textcolor{keywordtype}{integer} i, j, k, isv, iev, jsv, jev, nz, halo}
\DoxyCodeLine{59 }
\DoxyCodeLine{60   halo = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(halo\_size)) halo = max(0,halo\_size)}
\DoxyCodeLine{61 }
\DoxyCodeLine{62   isv = g\%isc-\/halo ; iev = g\%iec+halo ; jsv = g\%jsc-\/halo ; jev = g\%jec+halo}
\DoxyCodeLine{63   nz = g\%ke}
\DoxyCodeLine{64 }
\DoxyCodeLine{65   \textcolor{keywordflow}{if} ((isv<g\%isd) .or. (iev>g\%ied) .or. (jsv<g\%jsd) .or. (jev>g\%jed)) \&}
\DoxyCodeLine{66     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"find\_eta called with an overly large halo\_size."})}
\DoxyCodeLine{67 }
\DoxyCodeLine{68   z\_to\_eta = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta\_to\_m)) z\_to\_eta = us\%Z\_to\_m / eta\_to\_m}
\DoxyCodeLine{69   h\_to\_eta = gv\%H\_to\_Z * z\_to\_eta}
\DoxyCodeLine{70   h\_to\_rho\_eta =  gv\%H\_to\_RZ * z\_to\_eta}
\DoxyCodeLine{71   i\_gearth = z\_to\_eta / gv\%g\_Earth}
\DoxyCodeLine{72 }
\DoxyCodeLine{73 \textcolor{comment}{!\$OMP parallel default(shared) private(dilate,htot)}}
\DoxyCodeLine{74 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{75   \textcolor{keywordflow}{do} j=jsv,jev ; \textcolor{keywordflow}{do} i=isv,iev ; eta(i,j,nz+1) = -\/z\_to\_eta*g\%bathyT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{76 }
\DoxyCodeLine{77   \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{78 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{79     \textcolor{keywordflow}{do} j=jsv,jev ; \textcolor{keywordflow}{do} k=nz,1,-\/1; \textcolor{keywordflow}{do} i=isv,iev}
\DoxyCodeLine{80       eta(i,j,k) = eta(i,j,k+1) + h(i,j,k)*h\_to\_eta}
\DoxyCodeLine{81 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{82     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta\_bt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{83       \textcolor{comment}{! Dilate the water column to agree with the free surface height}}
\DoxyCodeLine{84       \textcolor{comment}{! that is used for the dynamics.}}
\DoxyCodeLine{85 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{86       \textcolor{keywordflow}{do} j=jsv,jev}
\DoxyCodeLine{87         \textcolor{keywordflow}{do} i=isv,iev}
\DoxyCodeLine{88           dilate(i) = (eta\_bt(i,j)*h\_to\_eta + z\_to\_eta*g\%bathyT(i,j)) / \&}
\DoxyCodeLine{89                       (eta(i,j,1) + z\_to\_eta*g\%bathyT(i,j))}
\DoxyCodeLine{90 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{91         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isv,iev}
\DoxyCodeLine{92           eta(i,j,k) = dilate(i) * (eta(i,j,k) + z\_to\_eta*g\%bathyT(i,j)) -\/ z\_to\_eta*g\%bathyT(i,j)}
\DoxyCodeLine{93 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{94 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{95 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{96   \textcolor{keywordflow}{else}}
\DoxyCodeLine{97     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{98 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{99       \textcolor{keywordflow}{do} j=jsv,jev}
\DoxyCodeLine{100         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%p\_surf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{101           \textcolor{keywordflow}{do} i=isv,iev ; p(i,j,1) = tv\%p\_surf(i,j) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{102         \textcolor{keywordflow}{else}}
\DoxyCodeLine{103           \textcolor{keywordflow}{do} i=isv,iev ; p(i,j,1) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{104 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{105         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isv,iev}
\DoxyCodeLine{106           p(i,j,k+1) = p(i,j,k) + gv\%g\_Earth*gv\%H\_to\_RZ*h(i,j,k)}
\DoxyCodeLine{107 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{108 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{109 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{110       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{111         \textcolor{keyword}{call }int\_specific\_vol\_dp(tv\%T(:,:,k), tv\%S(:,:,k), p(:,:,k), p(:,:,k+1), \&}
\DoxyCodeLine{112                                  0.0, g\%HI, tv\%eqn\_of\_state, us, dz\_geo(:,:,k), halo\_size=halo)}
\DoxyCodeLine{113 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{114 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{115       \textcolor{keywordflow}{do} j=jsv,jev}
\DoxyCodeLine{116         \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} i=isv,iev}
\DoxyCodeLine{117           eta(i,j,k) = eta(i,j,k+1) + i\_gearth * dz\_geo(i,j,k)}
\DoxyCodeLine{118 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{119 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{120     \textcolor{keywordflow}{else}}
\DoxyCodeLine{121 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{122       \textcolor{keywordflow}{do} j=jsv,jev ;  \textcolor{keywordflow}{do} k=nz,1,-\/1; \textcolor{keywordflow}{do} i=isv,iev}
\DoxyCodeLine{123         eta(i,j,k) = eta(i,j,k+1) + h\_to\_rho\_eta*h(i,j,k) / gv\%Rlay(k)}
\DoxyCodeLine{124 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{125 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{126     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta\_bt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{127       \textcolor{comment}{! Dilate the water column to agree with the free surface height}}
\DoxyCodeLine{128       \textcolor{comment}{! from the time-\/averaged barotropic solution.}}
\DoxyCodeLine{129 \textcolor{comment}{!\$OMP do}}
\DoxyCodeLine{130       \textcolor{keywordflow}{do} j=jsv,jev}
\DoxyCodeLine{131         \textcolor{keywordflow}{do} i=isv,iev ; htot(i) = gv\%H\_subroundoff ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{132         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isv,iev ; htot(i) = htot(i) + h(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{133         \textcolor{keywordflow}{do} i=isv,iev ; dilate(i) = eta\_bt(i,j) / htot(i) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{134         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isv,iev}
\DoxyCodeLine{135           eta(i,j,k) = dilate(i) * (eta(i,j,k) + z\_to\_eta*g\%bathyT(i,j)) -\/ z\_to\_eta*g\%bathyT(i,j)}
\DoxyCodeLine{136 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{137 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{138 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{139 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{140 \textcolor{comment}{!\$OMP end parallel}}
\DoxyCodeLine{141 }

\end{DoxyCode}


The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/home/cermak/src/\+M\+O\+M6.\+devrob/src/core/M\+O\+M\+\_\+interface\+\_\+heights.\+F90\end{DoxyCompactItemize}
