\hypertarget{namespacemom__pressureforce__mont}{}\doxysection{mom\+\_\+pressureforce\+\_\+mont Module Reference}
\label{namespacemom__pressureforce__mont}\index{mom\_pressureforce\_mont@{mom\_pressureforce\_mont}}


\doxysubsection{Detailed Description}
Provides the Montgomery potential form of pressure gradient. 

Provides the Boussunesq and non-\/\+Boussinesq forms of the horizontal accelerations due to pressure gradients using the Montgomery potential. A second-\/order accurate, centered scheme is used. If a split time stepping scheme is used, the vertical decomposition into barotropic and baroclinic contributions described by Hallberg (J Comp Phys 1997) is used. With a nonlinear equation of state, compressibility is added along the lines proposed by Sun et al. (J\+PO 1999), but with compressibility coefficients based on a fit to a user-\/provided reference profile. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__pressureforce__mont_1_1pressureforce__mont__cs}{pressureforce\+\_\+mont\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure for the Montgomery potential form of pressure gradient. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__pressureforce__mont_a6880a913a82b65eb65a728abb487ef91}{pressureforce\+\_\+mont\+\_\+nonbouss}} (h, tv, P\+Fu, P\+Fv, G, GV, US, CS, p\+\_\+atm, pbce, eta)
\begin{DoxyCompactList}\small\item\em Non-\/\+Boussinesq Montgomery-\/potential form of pressure gradient. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__pressureforce__mont_a5f96546655ff2d3fc9090ba2467ef521}{pressureforce\+\_\+mont\+\_\+bouss}} (h, tv, P\+Fu, P\+Fv, G, GV, US, CS, p\+\_\+atm, pbce, eta)
\begin{DoxyCompactList}\small\item\em Boussinesq Montgomery-\/potential form of pressure gradient. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__pressureforce__mont_a0779efd30a447c2bc20294c46aeea180}{set\+\_\+pbce\+\_\+bouss}} (e, tv, G, GV, US, Rho0, G\+F\+S\+\_\+scale, pbce, rho\+\_\+star)
\begin{DoxyCompactList}\small\item\em Determines the partial derivative of the acceleration due to pressure forces with the free surface height. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__pressureforce__mont_a297cdf6e4eb83d250444c5f527a8a232}{set\+\_\+pbce\+\_\+nonbouss}} (p, tv, G, GV, US, G\+F\+S\+\_\+scale, pbce, alpha\+\_\+star)
\begin{DoxyCompactList}\small\item\em Determines the partial derivative of the acceleration due to pressure forces with the column mass. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__pressureforce__mont_a55f5cfcd322f96938285ff4eb7646d14}{pressureforce\+\_\+mont\+\_\+init}} (Time, G, GV, US, param\+\_\+file, diag, CS, tides\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initialize the Montgomery-\/potential form of P\+GF control structure. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__pressureforce__mont_a1aee187502d5f5b78db6c1bfb4fe72a6}{pressureforce\+\_\+mont\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Deallocates the Montgomery-\/potential form of P\+GF control structure. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__pressureforce__mont_a5f96546655ff2d3fc9090ba2467ef521}\label{namespacemom__pressureforce__mont_a5f96546655ff2d3fc9090ba2467ef521}} 
\index{mom\_pressureforce\_mont@{mom\_pressureforce\_mont}!pressureforce\_mont\_bouss@{pressureforce\_mont\_bouss}}
\index{pressureforce\_mont\_bouss@{pressureforce\_mont\_bouss}!mom\_pressureforce\_mont@{mom\_pressureforce\_mont}}
\doxysubsubsection{\texorpdfstring{pressureforce\_mont\_bouss()}{pressureforce\_mont\_bouss()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+pressureforce\+\_\+mont\+::pressureforce\+\_\+mont\+\_\+bouss (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{P\+Fu,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(out)}]{P\+Fv,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__pressureforce__mont_1_1pressureforce__mont__cs}{pressureforce\+\_\+mont\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{p\+\_\+atm,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out), optional}]{pbce,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(out), optional}]{eta }\end{DoxyParamCaption})}



Boussinesq Montgomery-\/potential form of pressure gradient. 

Determines the acceleration due to pressure forces.

To work, the following fields must be set outside of the usual (is\+:ie,js\+:je) range before this subroutine is called\+: h(isB\+:ie+1,jsB\+:je+1), T(isB\+:ie+1,jsB\+:je+1), and S(isB\+:ie+1,jsB\+:je+1). 
\begin{DoxyParams}[1]{Parameters}
\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
\mbox{\texttt{ in}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamic variables. \\
\hline
\mbox{\texttt{ out}}  & {\em pfu} & Zonal acceleration due to pressure gradients (equal to -\/d\+M/dx) \mbox{[}L T-\/2 $\sim$$>$ m s-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em pfv} & Meridional acceleration due to pressure gradients (equal to -\/d\+M/dy) \mbox{[}L T-\/2 $\sim$$>$ m s2\mbox{]}. \\
\hline
 & {\em cs} & Control structure for Montgomery potential P\+GF \\
\hline
 & {\em p\+\_\+atm} & The pressure at the ice-\/ocean or atmosphere-\/ocean \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em pbce} & The baroclinic pressure anomaly in each layer due to free surface height anomalies \mbox{[}L2 T-\/2 H-\/1 $\sim$$>$ m s-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em eta} & Free surface height \mbox{[}H $\sim$$>$ m\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 360 of file M\+O\+M\+\_\+\+Pressure\+Force\+\_\+\+Montgomery.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{361   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{   !< Ocean grid structure.}}
\DoxyCodeLine{362   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{  !< Vertical grid structure.}}
\DoxyCodeLine{363   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{364 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{   !< Layer thickness [H \string~> m].}}
\DoxyCodeLine{365   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                     \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{  !< Thermodynamic variables.}}
\DoxyCodeLine{366 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: PFu\textcolor{comment}{ !< Zonal acceleration due to pressure gradients}}
\DoxyCodeLine{367 \textcolor{comment}{                                                                !! (equal to -\/dM/dx) [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{368 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: PFv\textcolor{comment}{ !< Meridional acceleration due to pressure gradients}}
\DoxyCodeLine{369 \textcolor{comment}{                                                                !! (equal to -\/dM/dy) [L T-\/2 \string~> m s2].}}
\DoxyCodeLine{370   \textcolor{keywordtype}{type}(PressureForce\_Mont\_CS),               \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{  !< Control structure for Montgomery potential PGF}}
\DoxyCodeLine{371 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},                     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: p\_atm\textcolor{comment}{ !< The pressure at the ice-\/ocean or}}
\DoxyCodeLine{372 \textcolor{comment}{                                                                !! atmosphere-\/ocean [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{373 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: pbce\textcolor{comment}{ !< The baroclinic pressure anomaly in}}
\DoxyCodeLine{374 \textcolor{comment}{                                                                !! each layer due to free surface height anomalies}}
\DoxyCodeLine{375 \textcolor{comment}{                                                                !! [L2 T-\/2 H-\/1 \string~> m s-\/2].}}
\DoxyCodeLine{376 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: eta\textcolor{comment}{ !< Free surface height [H \string~> m].}}
\DoxyCodeLine{377   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{378 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: \&}
\DoxyCodeLine{379     M, \&        \textcolor{comment}{! The Montgomery potential, M = (p/rho + gz) [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{380     rho\_star    \textcolor{comment}{! In-\/situ density divided by the derivative with depth of the}}
\DoxyCodeLine{381                 \textcolor{comment}{! corrected e times (G\_Earth/Rho0) [m2 Z-\/1 s-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{382 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)} :: e \textcolor{comment}{! Interface height in m.}}
\DoxyCodeLine{383                 \textcolor{comment}{! e may be adjusted (with a nonlinear equation of state) so that}}
\DoxyCodeLine{384                 \textcolor{comment}{! its derivative compensates for the adiabatic compressibility}}
\DoxyCodeLine{385                 \textcolor{comment}{! in seawater, but e will still be close to the interface depth.}}
\DoxyCodeLine{386 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{target} :: \&}
\DoxyCodeLine{387     T\_tmp, \&    \textcolor{comment}{! Temporary array of temperatures where layers that are lighter}}
\DoxyCodeLine{388                 \textcolor{comment}{! than the mixed layer have the mixed layer's properties [degC].}}
\DoxyCodeLine{389     s\_tmp       \textcolor{comment}{! Temporary array of salinities where layers that are lighter}}
\DoxyCodeLine{390                 \textcolor{comment}{! than the mixed layer have the mixed layer's properties [ppt].}}
\DoxyCodeLine{391 }
\DoxyCodeLine{392 \textcolor{keywordtype}{  real} :: Rho\_cv\_BL(SZI\_(G)) \textcolor{comment}{!   The coordinate potential density in}}
\DoxyCodeLine{393                 \textcolor{comment}{! the deepest variable density near-\/surface layer [R \string~> kg m-\/3].}}
\DoxyCodeLine{394 \textcolor{keywordtype}{  real} :: h\_star(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! Layer thickness after compensation}}
\DoxyCodeLine{395                              \textcolor{comment}{! for compressibility [Z \string~> m].}}
\DoxyCodeLine{396 \textcolor{keywordtype}{  real} :: e\_tidal(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! Bottom geopotential anomaly due to tidal}}
\DoxyCodeLine{397                              \textcolor{comment}{! forces from astronomical sources and self-\/}}
\DoxyCodeLine{398                              \textcolor{comment}{! attraction and loading, in depth units [Z \string~> m].}}
\DoxyCodeLine{399 \textcolor{keywordtype}{  real} :: p\_ref(SZI\_(G))     \textcolor{comment}{!   The pressure used to calculate the coordinate}}
\DoxyCodeLine{400                              \textcolor{comment}{! density [R L2 T-\/2 \string~> Pa] (usually 2e7 Pa = 2000 dbar).}}
\DoxyCodeLine{401 \textcolor{keywordtype}{  real} :: I\_Rho0             \textcolor{comment}{! 1/Rho0 [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{402 \textcolor{keywordtype}{  real} :: G\_Rho0             \textcolor{comment}{! G\_Earth / Rho0 [L2 Z-\/1 T-\/2 R-\/1 \string~> m4 s-\/2 kg-\/1].}}
\DoxyCodeLine{403 \textcolor{keywordtype}{  real} :: PFu\_bc, PFv\_bc     \textcolor{comment}{! The pressure gradient force due to along-\/layer}}
\DoxyCodeLine{404                              \textcolor{comment}{! compensated density gradients [L T-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{405 \textcolor{keywordtype}{  real} :: h\_neglect          \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{406                              \textcolor{comment}{! in roundoff and can be neglected [Z \string~> m].}}
\DoxyCodeLine{407   \textcolor{keywordtype}{logical} :: use\_p\_atm       \textcolor{comment}{! If true, use the atmospheric pressure.}}
\DoxyCodeLine{408   \textcolor{keywordtype}{logical} :: use\_EOS         \textcolor{comment}{! If true, density is calculated from T \& S using}}
\DoxyCodeLine{409                              \textcolor{comment}{! an equation of state.}}
\DoxyCodeLine{410   \textcolor{keywordtype}{logical} :: is\_split        \textcolor{comment}{! A flag indicating whether the pressure}}
\DoxyCodeLine{411                              \textcolor{comment}{! gradient terms are to be split into}}
\DoxyCodeLine{412                              \textcolor{comment}{! barotropic and baroclinic pieces.}}
\DoxyCodeLine{413   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_tmp\textcolor{comment}{! A structure of temporary T \& S.}}
\DoxyCodeLine{414   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The computational domain for the equation of state}}
\DoxyCodeLine{415   \textcolor{keywordtype}{integer} :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz, nkmb}
\DoxyCodeLine{416   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{417 }
\DoxyCodeLine{418   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{419   nkmb=gv\%nk\_rho\_varies}
\DoxyCodeLine{420   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{421   eosdom(1) = isq -\/ (g\%isd-\/1) ;  eosdom(2) = g\%iec+1 -\/ (g\%isd-\/1)}
\DoxyCodeLine{422 }
\DoxyCodeLine{423   use\_p\_atm = .false.}
\DoxyCodeLine{424   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(p\_atm)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(p\_atm)) use\_p\_atm = .true. ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{425   is\_split = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pbce)) is\_split = .true.}
\DoxyCodeLine{426   use\_eos = \textcolor{keyword}{associated}(tv\%eqn\_of\_state)}
\DoxyCodeLine{427 }
\DoxyCodeLine{428   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{429        \textcolor{stringliteral}{"{}MOM\_PressureForce\_Mont: Module must be initialized before it is used."{}})}
\DoxyCodeLine{430   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{431     \textcolor{keywordflow}{if} (query\_compressible(tv\%eqn\_of\_state)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{432       \textcolor{stringliteral}{"{}PressureForce\_Mont\_Bouss: The Montgomery form of the pressure force "{}}//\&}
\DoxyCodeLine{433       \textcolor{stringliteral}{"{}can no longer be used with a compressible EOS. Use \#define ANALYTIC\_FV\_PGF."{}})}
\DoxyCodeLine{434 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{435 }
\DoxyCodeLine{436   h\_neglect = gv\%H\_subroundoff * gv\%H\_to\_Z}
\DoxyCodeLine{437   i\_rho0 = 1.0/cs\%Rho0}
\DoxyCodeLine{438   g\_rho0 = gv\%g\_Earth / gv\%Rho0}
\DoxyCodeLine{439 }
\DoxyCodeLine{440   \textcolor{keywordflow}{if} (cs\%tides) \textcolor{keywordflow}{then}}
\DoxyCodeLine{441     \textcolor{comment}{!   Determine the surface height anomaly for calculating self attraction}}
\DoxyCodeLine{442     \textcolor{comment}{! and loading.  This should really be based on bottom pressure anomalies,}}
\DoxyCodeLine{443     \textcolor{comment}{! but that is not yet implemented, and the current form is correct for}}
\DoxyCodeLine{444     \textcolor{comment}{! barotropic tides.}}
\DoxyCodeLine{445     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{446     \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{447       \textcolor{keywordflow}{do} i=isq,ieq+1 ; e(i,j,1) = -\/g\%bathyT(i,j) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{448       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{449         e(i,j,1) = e(i,j,1) + h(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{450 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{451 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{452     \textcolor{keyword}{call }calc\_tidal\_forcing(cs\%Time, e(:,:,1), e\_tidal, g, cs\%tides\_CSp, m\_to\_z=us\%m\_to\_Z)}
\DoxyCodeLine{453 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{454 }
\DoxyCodeLine{455 \textcolor{comment}{!    Here layer interface heights, e, are calculated.}}
\DoxyCodeLine{456   \textcolor{keywordflow}{if} (cs\%tides) \textcolor{keywordflow}{then}}
\DoxyCodeLine{457     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{458     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{459       e(i,j,nz+1) = -\/(g\%bathyT(i,j) + e\_tidal(i,j))}
\DoxyCodeLine{460 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{461   \textcolor{keywordflow}{else}}
\DoxyCodeLine{462     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{463     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{464       e(i,j,nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{465 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{466 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{467   \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{468   \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} k=nz,1,-\/1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{469     e(i,j,k) = e(i,j,k+1) + h(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{470 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{471 }
\DoxyCodeLine{472   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{473 \textcolor{comment}{!   Calculate in-\/situ densities (rho\_star).}}
\DoxyCodeLine{474 }
\DoxyCodeLine{475 \textcolor{comment}{! With a bulk mixed layer, replace the T \& S of any layers that are}}
\DoxyCodeLine{476 \textcolor{comment}{! lighter than the the buffer layer with the properties of the buffer}}
\DoxyCodeLine{477 \textcolor{comment}{! layer.  These layers will be massless anyway, and it avoids any}}
\DoxyCodeLine{478 \textcolor{comment}{! formal calculations with hydrostatically unstable profiles.}}
\DoxyCodeLine{479 }
\DoxyCodeLine{480     \textcolor{keywordflow}{if} (nkmb>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{481       tv\_tmp\%T => t\_tmp ; tv\_tmp\%S => s\_tmp}
\DoxyCodeLine{482       tv\_tmp\%eqn\_of\_state => tv\%eqn\_of\_state}
\DoxyCodeLine{483 }
\DoxyCodeLine{484       \textcolor{keywordflow}{do} i=isq,ieq+1 ; p\_ref(i) = tv\%P\_Ref ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{485       \textcolor{comment}{!\$OMP parallel do default(shared) private(Rho\_cv\_BL)}}
\DoxyCodeLine{486       \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{487         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{488           tv\_tmp\%T(i,j,k) = tv\%T(i,j,k) ; tv\_tmp\%S(i,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{489 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{490         \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,nkmb), tv\%S(:,j,nkmb), p\_ref, rho\_cv\_bl(:), \&}
\DoxyCodeLine{491                                tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{492 }
\DoxyCodeLine{493         \textcolor{keywordflow}{do} k=nkmb+1,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{494           \textcolor{keywordflow}{if} (gv\%Rlay(k) < rho\_cv\_bl(i)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{495             tv\_tmp\%T(i,j,k) = tv\%T(i,j,nkmb) ; tv\_tmp\%S(i,j,k) = tv\%S(i,j,nkmb)}
\DoxyCodeLine{496           \textcolor{keywordflow}{else}}
\DoxyCodeLine{497             tv\_tmp\%T(i,j,k) = tv\%T(i,j,k) ; tv\_tmp\%S(i,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{498 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{499 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{500 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{501     \textcolor{keywordflow}{else}}
\DoxyCodeLine{502       tv\_tmp\%T => tv\%T ; tv\_tmp\%S => tv\%S}
\DoxyCodeLine{503       tv\_tmp\%eqn\_of\_state => tv\%eqn\_of\_state}
\DoxyCodeLine{504       \textcolor{keywordflow}{do} i=isq,ieq+1 ; p\_ref(i) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{505 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{506 }
\DoxyCodeLine{507     \textcolor{comment}{! This no longer includes any pressure dependency, since this routine}}
\DoxyCodeLine{508     \textcolor{comment}{! will come down with a fatal error if there is any compressibility.}}
\DoxyCodeLine{509     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{510     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{511       \textcolor{keyword}{call }calculate\_density(tv\_tmp\%T(:,j,k), tv\_tmp\%S(:,j,k), p\_ref, rho\_star(:,j,k), \&}
\DoxyCodeLine{512                              tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{513       \textcolor{keywordflow}{do} i=isq,ieq+1 ; rho\_star(i,j,k) = g\_rho0*rho\_star(i,j,k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{514 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{515 \textcolor{keywordflow}{  endif}                                               \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{516 }
\DoxyCodeLine{517 \textcolor{comment}{!    Here the layer Montgomery potentials, M, are calculated.}}
\DoxyCodeLine{518   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{519     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{520     \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{521       \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{522         m(i,j,1) = cs\%GFS\_scale * (rho\_star(i,j,1) * e(i,j,1))}
\DoxyCodeLine{523         \textcolor{keywordflow}{if} (use\_p\_atm) m(i,j,1) = m(i,j,1) + p\_atm(i,j) * i\_rho0}
\DoxyCodeLine{524 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{525       \textcolor{keywordflow}{do} k=2,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{526         m(i,j,k) = m(i,j,k-\/1) + (rho\_star(i,j,k) -\/ rho\_star(i,j,k-\/1)) * e(i,j,k)}
\DoxyCodeLine{527 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{528 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{529   \textcolor{keywordflow}{else} \textcolor{comment}{! not use\_EOS}}
\DoxyCodeLine{530     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{531     \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{532       \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{533         m(i,j,1) = gv\%g\_prime(1) * e(i,j,1)}
\DoxyCodeLine{534         \textcolor{keywordflow}{if} (use\_p\_atm) m(i,j,1) = m(i,j,1) + p\_atm(i,j) * i\_rho0}
\DoxyCodeLine{535 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{536       \textcolor{keywordflow}{do} k=2,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{537         m(i,j,k) = m(i,j,k-\/1) + gv\%g\_prime(k) * e(i,j,k)}
\DoxyCodeLine{538 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{539 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{540 \textcolor{keywordflow}{  endif} \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{541 }
\DoxyCodeLine{542   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pbce)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{543     \textcolor{keyword}{call }set\_pbce\_bouss(e, tv\_tmp, g, gv, us, cs\%Rho0, cs\%GFS\_scale, pbce, rho\_star)}
\DoxyCodeLine{544 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{545 }
\DoxyCodeLine{546 \textcolor{comment}{!    Calculate the pressure force. On a Cartesian grid,}}
\DoxyCodeLine{547 \textcolor{comment}{!      PFu = -\/ dM/dx   and  PFv = -\/ dM/dy.}}
\DoxyCodeLine{548   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{549     \textcolor{comment}{!\$OMP parallel do default(shared) private(h\_star,PFu\_bc,PFv\_bc)}}
\DoxyCodeLine{550     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{551       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{552         h\_star(i,j) = (e(i,j,k) -\/ e(i,j,k+1)) + h\_neglect}
\DoxyCodeLine{553 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{554       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{555         pfu\_bc = -\/1.0*(rho\_star(i+1,j,k) -\/ rho\_star(i,j,k)) * (g\%IdxCu(i,j) * \&}
\DoxyCodeLine{556           ((h\_star(i,j) * h\_star(i+1,j) -\/ (e(i,j,k) * h\_star(i+1,j) + \&}
\DoxyCodeLine{557           e(i+1,j,k) * h\_star(i,j))) / (h\_star(i,j) + h\_star(i+1,j))))}
\DoxyCodeLine{558         pfu(i,j,k) = -\/(m(i+1,j,k) -\/ m(i,j,k)) * g\%IdxCu(i,j) + pfu\_bc}
\DoxyCodeLine{559         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%PFu\_bc)) cs\%PFu\_bc(i,j,k) = pfu\_bc}
\DoxyCodeLine{560 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{561       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{562         pfv\_bc = -\/1.0*(rho\_star(i,j+1,k) -\/ rho\_star(i,j,k)) * (g\%IdyCv(i,j) * \&}
\DoxyCodeLine{563           ((h\_star(i,j) * h\_star(i,j+1) -\/ (e(i,j,k) * h\_star(i,j+1) + \&}
\DoxyCodeLine{564           e(i,j+1,k) * h\_star(i,j))) / (h\_star(i,j) + h\_star(i,j+1))))}
\DoxyCodeLine{565         pfv(i,j,k) = -\/(m(i,j+1,k) -\/ m(i,j,k)) * g\%IdyCv(i,j) + pfv\_bc}
\DoxyCodeLine{566         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%PFv\_bc)) cs\%PFv\_bc(i,j,k) = pfv\_bc}
\DoxyCodeLine{567 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{568 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! k-\/loop}}
\DoxyCodeLine{569   \textcolor{keywordflow}{else} \textcolor{comment}{! .not. use\_EOS}}
\DoxyCodeLine{570     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{571     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{572       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{573         pfu(i,j,k) = -\/(m(i+1,j,k) -\/ m(i,j,k)) * g\%IdxCu(i,j)}
\DoxyCodeLine{574 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{575       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{576         pfv(i,j,k) = -\/(m(i,j+1,k) -\/ m(i,j,k)) * g\%IdyCv(i,j)}
\DoxyCodeLine{577 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{578 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{579 \textcolor{keywordflow}{  endif} \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{580 }
\DoxyCodeLine{581   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{582     \textcolor{keywordflow}{if} (cs\%tides) \textcolor{keywordflow}{then}}
\DoxyCodeLine{583     \textcolor{comment}{! eta is the sea surface height relative to a time-\/invariant geoid, for}}
\DoxyCodeLine{584     \textcolor{comment}{! comparison with what is used for eta in btstep.  See how e was calculated}}
\DoxyCodeLine{585     \textcolor{comment}{! about 200 lines above.}}
\DoxyCodeLine{586       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{587       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{588         eta(i,j) = e(i,j,1)*gv\%Z\_to\_H + e\_tidal(i,j)*gv\%Z\_to\_H}
\DoxyCodeLine{589 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{590     \textcolor{keywordflow}{else}}
\DoxyCodeLine{591       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{592       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{593         eta(i,j) = e(i,j,1)*gv\%Z\_to\_H}
\DoxyCodeLine{594 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{595 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{596 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{597 }
\DoxyCodeLine{598   \textcolor{keywordflow}{if} (cs\%id\_PFu\_bc>0) \textcolor{keyword}{call }post\_data(cs\%id\_PFu\_bc, cs\%PFu\_bc, cs\%diag)}
\DoxyCodeLine{599   \textcolor{keywordflow}{if} (cs\%id\_PFv\_bc>0) \textcolor{keyword}{call }post\_data(cs\%id\_PFv\_bc, cs\%PFv\_bc, cs\%diag)}
\DoxyCodeLine{600   \textcolor{keywordflow}{if} (cs\%id\_e\_tidal>0) \textcolor{keyword}{call }post\_data(cs\%id\_e\_tidal, e\_tidal, cs\%diag)}
\DoxyCodeLine{601 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__pressureforce__mont_a1aee187502d5f5b78db6c1bfb4fe72a6}\label{namespacemom__pressureforce__mont_a1aee187502d5f5b78db6c1bfb4fe72a6}} 
\index{mom\_pressureforce\_mont@{mom\_pressureforce\_mont}!pressureforce\_mont\_end@{pressureforce\_mont\_end}}
\index{pressureforce\_mont\_end@{pressureforce\_mont\_end}!mom\_pressureforce\_mont@{mom\_pressureforce\_mont}}
\doxysubsubsection{\texorpdfstring{pressureforce\_mont\_end()}{pressureforce\_mont\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+pressureforce\+\_\+mont\+::pressureforce\+\_\+mont\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__pressureforce__mont_1_1pressureforce__mont__cs}{pressureforce\+\_\+mont\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Deallocates the Montgomery-\/potential form of P\+GF control structure. 


\begin{DoxyParams}{Parameters}
{\em cs} & Control structure for Montgomery potential P\+GF \\
\hline
\end{DoxyParams}


Definition at line 889 of file M\+O\+M\+\_\+\+Pressure\+Force\+\_\+\+Montgomery.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{890   \textcolor{keywordtype}{type}(PressureForce\_Mont\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{  !< Control structure for Montgomery potential PGF}}
\DoxyCodeLine{891   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{deallocate}(cs)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__pressureforce__mont_a55f5cfcd322f96938285ff4eb7646d14}\label{namespacemom__pressureforce__mont_a55f5cfcd322f96938285ff4eb7646d14}} 
\index{mom\_pressureforce\_mont@{mom\_pressureforce\_mont}!pressureforce\_mont\_init@{pressureforce\_mont\_init}}
\index{pressureforce\_mont\_init@{pressureforce\_mont\_init}!mom\_pressureforce\_mont@{mom\_pressureforce\_mont}}
\doxysubsubsection{\texorpdfstring{pressureforce\_mont\_init()}{pressureforce\_mont\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+pressureforce\+\_\+mont\+::pressureforce\+\_\+mont\+\_\+init (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__pressureforce__mont_1_1pressureforce__mont__cs}{pressureforce\+\_\+mont\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__tidal__forcing_1_1tidal__forcing__cs}{tidal\+\_\+forcing\+\_\+cs}}), optional, pointer}]{tides\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Initialize the Montgomery-\/potential form of P\+GF control structure. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & Current model time \\
\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
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handles \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & Diagnostics control structure \\
\hline
 & {\em cs} & Montgomery P\+GF control structure \\
\hline
 & {\em tides\+\_\+csp} & Tides control structure \\
\hline
\end{DoxyParams}


Definition at line 821 of file M\+O\+M\+\_\+\+Pressure\+Force\+\_\+\+Montgomery.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{822   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< Current model time}}
\DoxyCodeLine{823   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< ocean grid structure}}
\DoxyCodeLine{824   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< Vertical grid structure}}
\DoxyCodeLine{825   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{826   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file handles}}
\DoxyCodeLine{827   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< Diagnostics control structure}}
\DoxyCodeLine{828   \textcolor{keywordtype}{type}(PressureForce\_Mont\_CS),  \textcolor{keywordtype}{pointer}  :: CS\textcolor{comment}{ !< Montgomery PGF control structure}}
\DoxyCodeLine{829   \textcolor{keywordtype}{type}(tidal\_forcing\_CS), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer} :: tides\_CSp\textcolor{comment}{ !< Tides control structure}}
\DoxyCodeLine{830 }
\DoxyCodeLine{831   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{832   \textcolor{keywordtype}{logical} :: use\_temperature, use\_EOS}
\DoxyCodeLine{833   \textcolor{comment}{! This include declares and sets the variable "{}version"{}.}}
\DoxyCodeLine{834 \textcolor{preprocessor}{\# include "{}version\_variable.h"{}}}
\DoxyCodeLine{835 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl   \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{836 }
\DoxyCodeLine{837   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{838     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"{}PressureForce\_init called with an associated "{}}// \&}
\DoxyCodeLine{839                             \textcolor{stringliteral}{"{}control structure."{}})}
\DoxyCodeLine{840     \textcolor{keywordflow}{return}}
\DoxyCodeLine{841   \textcolor{keywordflow}{else} ; \textcolor{keyword}{allocate}(cs) ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{842 }
\DoxyCodeLine{843   cs\%diag => diag ; cs\%Time => time}
\DoxyCodeLine{844   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(tides\_csp)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{845     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tides\_csp)) cs\%tides\_CSp => tides\_csp}
\DoxyCodeLine{846 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{847 }
\DoxyCodeLine{848   mdl = \textcolor{stringliteral}{"{}MOM\_PressureForce\_Mont"{}}}
\DoxyCodeLine{849   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{850   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}RHO\_0"{}}, cs\%Rho0, \&}
\DoxyCodeLine{851                  \textcolor{stringliteral}{"{}The mean ocean density used with BOUSSINESQ true to "{}}//\&}
\DoxyCodeLine{852                  \textcolor{stringliteral}{"{}calculate accelerations and the mass for conservation "{}}//\&}
\DoxyCodeLine{853                  \textcolor{stringliteral}{"{}properties, or with BOUSSINSEQ false to convert some "{}}//\&}
\DoxyCodeLine{854                  \textcolor{stringliteral}{"{}parameters from vertical units of m to kg m-\/2."{}}, \&}
\DoxyCodeLine{855                  units=\textcolor{stringliteral}{"{}kg m-\/3"{}}, default=1035.0, scale=us\%R\_to\_kg\_m3)}
\DoxyCodeLine{856   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}TIDES"{}}, cs\%tides, \&}
\DoxyCodeLine{857                  \textcolor{stringliteral}{"{}If true, apply tidal momentum forcing."{}}, default=.false.)}
\DoxyCodeLine{858   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}USE\_EOS"{}}, use\_eos, default=.true., \&}
\DoxyCodeLine{859                  do\_not\_log=.true.) \textcolor{comment}{! Input for diagnostic use only.}}
\DoxyCodeLine{860 }
\DoxyCodeLine{861   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{862     cs\%id\_PFu\_bc = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFu\_bc'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{863          \textcolor{stringliteral}{'Density Gradient Zonal Pressure Force Accel.'}, \textcolor{stringliteral}{"{}meter second-\/2"{}}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{864     cs\%id\_PFv\_bc = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFv\_bc'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{865          \textcolor{stringliteral}{'Density Gradient Meridional Pressure Force Accel.'}, \textcolor{stringliteral}{"{}meter second-\/2"{}}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{866     \textcolor{keywordflow}{if} (cs\%id\_PFu\_bc > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{867       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%PFu\_bc,g\%IsdB,g\%IedB,g\%jsd,g\%jed,g\%ke)}
\DoxyCodeLine{868       cs\%PFu\_bc(:,:,:) = 0.0}
\DoxyCodeLine{869 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{870     \textcolor{keywordflow}{if} (cs\%id\_PFv\_bc > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{871       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%PFv\_bc,g\%isd,g\%ied,g\%JsdB,g\%JedB,g\%ke)}
\DoxyCodeLine{872       cs\%PFv\_bc(:,:,:) = 0.0}
\DoxyCodeLine{873 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{874 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{875 }
\DoxyCodeLine{876   \textcolor{keywordflow}{if} (cs\%tides) \textcolor{keywordflow}{then}}
\DoxyCodeLine{877     cs\%id\_e\_tidal = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'e\_tidal'}, diag\%axesT1, \&}
\DoxyCodeLine{878         time, \textcolor{stringliteral}{'Tidal Forcing Astronomical and SAL Height Anomaly'}, \textcolor{stringliteral}{'meter'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{879 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{880 }
\DoxyCodeLine{881   cs\%GFS\_scale = 1.0}
\DoxyCodeLine{882   \textcolor{keywordflow}{if} (gv\%g\_prime(1) /= gv\%g\_Earth) cs\%GFS\_scale = gv\%g\_prime(1) / gv\%g\_Earth}
\DoxyCodeLine{883 }
\DoxyCodeLine{884   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"{}GFS / G\_EARTH"{}}, cs\%GFS\_scale)}
\DoxyCodeLine{885 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__pressureforce__mont_a6880a913a82b65eb65a728abb487ef91}\label{namespacemom__pressureforce__mont_a6880a913a82b65eb65a728abb487ef91}} 
\index{mom\_pressureforce\_mont@{mom\_pressureforce\_mont}!pressureforce\_mont\_nonbouss@{pressureforce\_mont\_nonbouss}}
\index{pressureforce\_mont\_nonbouss@{pressureforce\_mont\_nonbouss}!mom\_pressureforce\_mont@{mom\_pressureforce\_mont}}
\doxysubsubsection{\texorpdfstring{pressureforce\_mont\_nonbouss()}{pressureforce\_mont\_nonbouss()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+pressureforce\+\_\+mont\+::pressureforce\+\_\+mont\+\_\+nonbouss (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{P\+Fu,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(out)}]{P\+Fv,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__pressureforce__mont_1_1pressureforce__mont__cs}{pressureforce\+\_\+mont\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{p\+\_\+atm,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out), optional}]{pbce,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(out), optional}]{eta }\end{DoxyParamCaption})}



Non-\/\+Boussinesq Montgomery-\/potential form of pressure gradient. 

Determines the acceleration due to pressure forces in a non-\/\+Boussinesq fluid using the compressibility compensated (if appropriate) Montgomery-\/potential form described in Hallberg (Ocean Mod., 2005).

To work, the following fields must be set outside of the usual (is\+:ie,js\+:je) range before this subroutine is called\+: h(isB\+:ie+1,jsB\+:je+1), T(isB\+:ie+1,jsB\+:je+1), and S(isB\+:ie+1,jsB\+:je+1). 
\begin{DoxyParams}[1]{Parameters}
\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
\mbox{\texttt{ in}}  & {\em h} & Layer thickness, \mbox{[}H $\sim$$>$ kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamic variables. \\
\hline
\mbox{\texttt{ out}}  & {\em pfu} & Zonal acceleration due to pressure gradients (equal to -\/d\+M/dx) \mbox{[}L T-\/2 $\sim$$>$ m s-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em pfv} & Meridional acceleration due to pressure gradients (equal to -\/d\+M/dy) \mbox{[}L T-\/2 $\sim$$>$ m s-\/2\mbox{]}. \\
\hline
 & {\em cs} & Control structure for Montgomery potential P\+GF \\
\hline
 & {\em p\+\_\+atm} & The pressure at the ice-\/ocean or atmosphere-\/ocean \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em pbce} & The baroclinic pressure anomaly in \\
\hline
\mbox{\texttt{ out}}  & {\em eta} & Free surface height \mbox{[}H $\sim$$>$ kg m-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 63 of file M\+O\+M\+\_\+\+Pressure\+Force\+\_\+\+Montgomery.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{64   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{   !< Ocean grid structure.}}
\DoxyCodeLine{65   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{  !< Vertical grid structure.}}
\DoxyCodeLine{66   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{67 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{   !< Layer thickness, [H \string~> kg m-\/2].}}
\DoxyCodeLine{68   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                     \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{  !< Thermodynamic variables.}}
\DoxyCodeLine{69 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: PFu\textcolor{comment}{ !< Zonal acceleration due to pressure gradients}}
\DoxyCodeLine{70 \textcolor{comment}{                                                                !! (equal to -\/dM/dx) [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{71 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: PFv\textcolor{comment}{ !< Meridional acceleration due to pressure gradients}}
\DoxyCodeLine{72 \textcolor{comment}{                                                                !! (equal to -\/dM/dy) [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{73   \textcolor{keywordtype}{type}(PressureForce\_Mont\_CS),               \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{  !< Control structure for Montgomery potential PGF}}
\DoxyCodeLine{74 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: p\_atm\textcolor{comment}{ !< The pressure at the ice-\/ocean or}}
\DoxyCodeLine{75 \textcolor{comment}{                                                                !! atmosphere-\/ocean [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{76 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{77                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: pbce\textcolor{comment}{ !< The baroclinic pressure anomaly in}}
\DoxyCodeLine{78 \textcolor{comment}{                                                                !! each layer due to free surface height anomalies,}}
\DoxyCodeLine{79 \textcolor{comment}{                                                                !! [L2 T-\/2 H-\/1 \string~> m s-\/2 or m4 kg-\/1 s-\/2].}}
\DoxyCodeLine{80 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: eta\textcolor{comment}{ !< Free surface height [H \string~> kg m-\/1].}}
\DoxyCodeLine{81 }
\DoxyCodeLine{82   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{83 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: \&}
\DoxyCodeLine{84     M, \&          \textcolor{comment}{! The Montgomery potential, M = (p/rho + gz)  [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{85     alpha\_star, \& \textcolor{comment}{! Compression adjusted specific volume [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{86     dz\_geo        \textcolor{comment}{!   The change in geopotential across a layer [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{87 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)} :: p \textcolor{comment}{! Interface pressure [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{88                 \textcolor{comment}{! p may be adjusted (with a nonlinear equation of state) so that}}
\DoxyCodeLine{89                 \textcolor{comment}{! its derivative compensates for the adiabatic compressibility}}
\DoxyCodeLine{90                 \textcolor{comment}{! in seawater, but p will still be close to the pressure.}}
\DoxyCodeLine{91 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{target} :: \&}
\DoxyCodeLine{92     T\_tmp, \&    \textcolor{comment}{! Temporary array of temperatures where layers that are lighter}}
\DoxyCodeLine{93                 \textcolor{comment}{! than the mixed layer have the mixed layer's properties [degC].}}
\DoxyCodeLine{94     s\_tmp       \textcolor{comment}{! Temporary array of salinities where layers that are lighter}}
\DoxyCodeLine{95                 \textcolor{comment}{! than the mixed layer have the mixed layer's properties [ppt].}}
\DoxyCodeLine{96 }
\DoxyCodeLine{97 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G))} :: Rho\_cv\_BL  \textcolor{comment}{! The coordinate potential density in the}}
\DoxyCodeLine{98                   \textcolor{comment}{! deepest variable density near-\/surface layer [R \string~> kg m-\/3].}}
\DoxyCodeLine{99 }
\DoxyCodeLine{100 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{101     dM, \&         \textcolor{comment}{!   A barotropic correction to the Montgomery potentials to enable the use}}
\DoxyCodeLine{102                   \textcolor{comment}{! of a reduced gravity form of the equations [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{103     dp\_star, \&    \textcolor{comment}{! Layer thickness after compensation for compressibility [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{104     ssh, \&        \textcolor{comment}{! The sea surface height anomaly, in depth units [Z \string~> m].}}
\DoxyCodeLine{105     e\_tidal, \&    \textcolor{comment}{!   Bottom geopotential anomaly due to tidal forces from}}
\DoxyCodeLine{106                   \textcolor{comment}{! astronomical sources and self-\/attraction and loading [Z \string~> m].}}
\DoxyCodeLine{107     geopot\_bot    \textcolor{comment}{!   Bottom geopotential relative to time-\/mean sea level,}}
\DoxyCodeLine{108                   \textcolor{comment}{! including any tidal contributions [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{109 \textcolor{keywordtype}{  real} :: p\_ref(SZI\_(G))     \textcolor{comment}{!   The pressure used to calculate the coordinate}}
\DoxyCodeLine{110                              \textcolor{comment}{! density [R L2 T-\/2 \string~> Pa] (usually 2e7 Pa = 2000 dbar).}}
\DoxyCodeLine{111 \textcolor{keywordtype}{  real} :: rho\_in\_situ(SZI\_(G)) \textcolor{comment}{!In-\/situ density of a layer [R \string~> kg m-\/3].}}
\DoxyCodeLine{112 \textcolor{keywordtype}{  real} :: PFu\_bc, PFv\_bc     \textcolor{comment}{! The pressure gradient force due to along-\/layer}}
\DoxyCodeLine{113                              \textcolor{comment}{! compensated density gradients [L T-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{114 \textcolor{keywordtype}{  real} :: dp\_neglect         \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{115                              \textcolor{comment}{! in roundoff and can be neglected [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{116   \textcolor{keywordtype}{logical} :: use\_p\_atm       \textcolor{comment}{! If true, use the atmospheric pressure.}}
\DoxyCodeLine{117   \textcolor{keywordtype}{logical} :: use\_EOS         \textcolor{comment}{! If true, density is calculated from T \& S using an equation of state.}}
\DoxyCodeLine{118   \textcolor{keywordtype}{logical} :: is\_split        \textcolor{comment}{! A flag indicating whether the pressure gradient terms are to be}}
\DoxyCodeLine{119                              \textcolor{comment}{! split into barotropic and baroclinic pieces.}}
\DoxyCodeLine{120   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_tmp\textcolor{comment}{! A structure of temporary T \& S.}}
\DoxyCodeLine{121 }
\DoxyCodeLine{122 \textcolor{keywordtype}{  real} :: I\_gEarth           \textcolor{comment}{! The inverse of g\_Earth [T2 Z L-\/2 \string~> s2 m-\/1]}}
\DoxyCodeLine{123 \textcolor{comment}{!  real :: dalpha}}
\DoxyCodeLine{124 \textcolor{keywordtype}{  real} :: Pa\_to\_H     \textcolor{comment}{! A factor to convert from R L2 T-\/2 to the thickness units (H).}}
\DoxyCodeLine{125 \textcolor{keywordtype}{  real} :: alpha\_Lay(SZK\_(G)) \textcolor{comment}{! The specific volume of each layer [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{126 \textcolor{keywordtype}{  real} :: dalpha\_int(SZK\_(G)+1) \textcolor{comment}{! The change in specific volume across each}}
\DoxyCodeLine{127                              \textcolor{comment}{! interface [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{128   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The computational domain for the equation of state}}
\DoxyCodeLine{129   \textcolor{keywordtype}{integer} :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz, nkmb}
\DoxyCodeLine{130   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{131   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{132   nkmb=gv\%nk\_rho\_varies}
\DoxyCodeLine{133   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{134   eosdom(1) = isq -\/ (g\%isd-\/1) ;  eosdom(2) = g\%iec+1 -\/ (g\%isd-\/1)}
\DoxyCodeLine{135 }
\DoxyCodeLine{136   use\_p\_atm = .false.}
\DoxyCodeLine{137   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(p\_atm)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(p\_atm)) use\_p\_atm = .true. ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{138   is\_split = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pbce)) is\_split = .true.}
\DoxyCodeLine{139   use\_eos = \textcolor{keyword}{associated}(tv\%eqn\_of\_state)}
\DoxyCodeLine{140 }
\DoxyCodeLine{141   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{142       \textcolor{stringliteral}{"{}MOM\_PressureForce\_Mont: Module must be initialized before it is used."{}})}
\DoxyCodeLine{143   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{144     \textcolor{keywordflow}{if} (query\_compressible(tv\%eqn\_of\_state)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{145       \textcolor{stringliteral}{"{}PressureForce\_Mont\_nonBouss: The Montgomery form of the pressure force "{}}//\&}
\DoxyCodeLine{146       \textcolor{stringliteral}{"{}can no longer be used with a compressible EOS. Use \#define ANALYTIC\_FV\_PGF."{}})}
\DoxyCodeLine{147 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{148 }
\DoxyCodeLine{149   i\_gearth = 1.0 / gv\%g\_Earth}
\DoxyCodeLine{150   dp\_neglect = gv\%g\_Earth * gv\%H\_to\_RZ * gv\%H\_subroundoff}
\DoxyCodeLine{151   \textcolor{keywordflow}{do} k=1,nz ; alpha\_lay(k) = 1.0 / (gv\%Rlay(k)) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{152   \textcolor{keywordflow}{do} k=2,nz ; dalpha\_int(k) = alpha\_lay(k-\/1) -\/ alpha\_lay(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{153 }
\DoxyCodeLine{154   \textcolor{keywordflow}{if} (use\_p\_atm) \textcolor{keywordflow}{then}}
\DoxyCodeLine{155     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{156     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1 ; p(i,j,1) = p\_atm(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{157   \textcolor{keywordflow}{else}}
\DoxyCodeLine{158     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{159     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1 ; p(i,j,1) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{160 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{161   \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{162   \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{163     p(i,j,k+1) = p(i,j,k) + gv\%g\_Earth * gv\%H\_to\_RZ * h(i,j,k)}
\DoxyCodeLine{164 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{165 }
\DoxyCodeLine{166   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{167     pa\_to\_h = 1.0 / (gv\%g\_Earth * gv\%H\_to\_RZ)}
\DoxyCodeLine{168     \textcolor{keywordflow}{if} (use\_p\_atm) \textcolor{keywordflow}{then}}
\DoxyCodeLine{169       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{170       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{171         eta(i,j) = (p(i,j,nz+1) -\/ p\_atm(i,j)) * pa\_to\_h \textcolor{comment}{! eta has the same units as h.}}
\DoxyCodeLine{172 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{173     \textcolor{keywordflow}{else}}
\DoxyCodeLine{174       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{175       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{176         eta(i,j) = p(i,j,nz+1) * pa\_to\_h \textcolor{comment}{! eta has the same units as h.}}
\DoxyCodeLine{177 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{178 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{179 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{180 }
\DoxyCodeLine{181   \textcolor{keywordflow}{if} (cs\%tides) \textcolor{keywordflow}{then}}
\DoxyCodeLine{182     \textcolor{comment}{!   Determine the sea surface height anomalies, to enable the calculation}}
\DoxyCodeLine{183     \textcolor{comment}{! of self-\/attraction and loading.}}
\DoxyCodeLine{184     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{185     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{186       ssh(i,j) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{187 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{188     \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{189       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{190       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{191         \textcolor{keyword}{call }int\_specific\_vol\_dp(tv\%T(:,:,k), tv\%S(:,:,k), p(:,:,k), p(:,:,k+1), \&}
\DoxyCodeLine{192                                  0.0, g\%HI, tv\%eqn\_of\_state, us, dz\_geo(:,:,k), halo\_size=1)}
\DoxyCodeLine{193 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{194       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{195       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{196         ssh(i,j) = ssh(i,j) + i\_gearth * dz\_geo(i,j,k)}
\DoxyCodeLine{197 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{198     \textcolor{keywordflow}{else}}
\DoxyCodeLine{199       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{200       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{201         ssh(i,j) = ssh(i,j) + gv\%H\_to\_RZ * h(i,j,k) * alpha\_lay(k)}
\DoxyCodeLine{202 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{203 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{204 }
\DoxyCodeLine{205     \textcolor{keyword}{call }calc\_tidal\_forcing(cs\%Time, ssh, e\_tidal, g, cs\%tides\_CSp, m\_to\_z=us\%m\_to\_Z)}
\DoxyCodeLine{206     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{207     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{208       geopot\_bot(i,j) = -\/gv\%g\_Earth*(e\_tidal(i,j) + g\%bathyT(i,j))}
\DoxyCodeLine{209 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{210   \textcolor{keywordflow}{else}}
\DoxyCodeLine{211     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{212     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{213       geopot\_bot(i,j) = -\/gv\%g\_Earth*g\%bathyT(i,j)}
\DoxyCodeLine{214 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{215 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{216 }
\DoxyCodeLine{217   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{218     \textcolor{comment}{!   Calculate in-\/situ specific volumes (alpha\_star).}}
\DoxyCodeLine{219 }
\DoxyCodeLine{220     \textcolor{comment}{!   With a bulk mixed layer, replace the T \& S of any layers that are}}
\DoxyCodeLine{221     \textcolor{comment}{! lighter than the the buffer layer with the properties of the buffer}}
\DoxyCodeLine{222     \textcolor{comment}{! layer.  These layers will be massless anyway, and it avoids any}}
\DoxyCodeLine{223     \textcolor{comment}{! formal calculations with hydrostatically unstable profiles.}}
\DoxyCodeLine{224     \textcolor{keywordflow}{if} (nkmb>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{225       tv\_tmp\%T => t\_tmp ; tv\_tmp\%S => s\_tmp}
\DoxyCodeLine{226       tv\_tmp\%eqn\_of\_state => tv\%eqn\_of\_state}
\DoxyCodeLine{227       \textcolor{keywordflow}{do} i=isq,ieq+1 ; p\_ref(i) = tv\%P\_Ref ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{228       \textcolor{comment}{!\$OMP parallel do default(shared) private(Rho\_cv\_BL)}}
\DoxyCodeLine{229       \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{230         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{231           tv\_tmp\%T(i,j,k) = tv\%T(i,j,k) ; tv\_tmp\%S(i,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{232 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{233         \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,nkmb), tv\%S(:,j,nkmb), p\_ref, rho\_cv\_bl(:), \&}
\DoxyCodeLine{234                                tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{235         \textcolor{keywordflow}{do} k=nkmb+1,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{236           \textcolor{keywordflow}{if} (gv\%Rlay(k) < rho\_cv\_bl(i)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{237             tv\_tmp\%T(i,j,k) = tv\%T(i,j,nkmb) ; tv\_tmp\%S(i,j,k) = tv\%S(i,j,nkmb)}
\DoxyCodeLine{238           \textcolor{keywordflow}{else}}
\DoxyCodeLine{239             tv\_tmp\%T(i,j,k) = tv\%T(i,j,k) ; tv\_tmp\%S(i,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{240 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{241 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{242 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{243     \textcolor{keywordflow}{else}}
\DoxyCodeLine{244       tv\_tmp\%T => tv\%T ; tv\_tmp\%S => tv\%S}
\DoxyCodeLine{245       tv\_tmp\%eqn\_of\_state => tv\%eqn\_of\_state}
\DoxyCodeLine{246       \textcolor{keywordflow}{do} i=isq,ieq+1 ; p\_ref(i) = 0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{247 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{248     \textcolor{comment}{!\$OMP parallel do default(shared) private(rho\_in\_situ)}}
\DoxyCodeLine{249     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{250       \textcolor{keyword}{call }calculate\_density(tv\_tmp\%T(:,j,k), tv\_tmp\%S(:,j,k), p\_ref, rho\_in\_situ, \&}
\DoxyCodeLine{251                              tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{252       \textcolor{keywordflow}{do} i=isq,ieq+1 ; alpha\_star(i,j,k) = 1.0 / rho\_in\_situ(i) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{253 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{254 \textcolor{keywordflow}{  endif}                                               \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{255 }
\DoxyCodeLine{256   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{257     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{258     \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{259       \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{260         m(i,j,nz) = geopot\_bot(i,j) + p(i,j,nz+1) * alpha\_star(i,j,nz)}
\DoxyCodeLine{261 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{262       \textcolor{keywordflow}{do} k=nz-\/1,1,-\/1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{263         m(i,j,k) = m(i,j,k+1) + p(i,j,k+1) * (alpha\_star(i,j,k) -\/ alpha\_star(i,j,k+1))}
\DoxyCodeLine{264 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{265 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{266   \textcolor{keywordflow}{else} \textcolor{comment}{! not use\_EOS}}
\DoxyCodeLine{267     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{268     \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{269       \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{270         m(i,j,nz) = geopot\_bot(i,j) + p(i,j,nz+1) * alpha\_lay(nz)}
\DoxyCodeLine{271 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{272       \textcolor{keywordflow}{do} k=nz-\/1,1,-\/1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{273         m(i,j,k) = m(i,j,k+1) + p(i,j,k+1) * dalpha\_int(k+1)}
\DoxyCodeLine{274 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{275 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{276 \textcolor{keywordflow}{  endif} \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{277 }
\DoxyCodeLine{278   \textcolor{keywordflow}{if} (cs\%GFS\_scale < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{279     \textcolor{comment}{! Adjust the Montgomery potential to make this a reduced gravity model.}}
\DoxyCodeLine{280     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{281     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{282       dm(i,j) = (cs\%GFS\_scale -\/ 1.0) * m(i,j,1)}
\DoxyCodeLine{283 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{284     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{285     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{286       m(i,j,k) = m(i,j,k) + dm(i,j)}
\DoxyCodeLine{287 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{288 }
\DoxyCodeLine{289     \textcolor{comment}{!   Could instead do the following, to avoid taking small differences}}
\DoxyCodeLine{290     \textcolor{comment}{! of large numbers...}}
\DoxyCodeLine{291 \textcolor{comment}{!   do j=Jsq,Jeq+1 ; do i=Isq,Ieq+1}}
\DoxyCodeLine{292 \textcolor{comment}{!     M(i,j,1) = CS\%GFS\_scale * M(i,j,1)}}
\DoxyCodeLine{293 \textcolor{comment}{!   enddo ; enddo}}
\DoxyCodeLine{294 \textcolor{comment}{!   if (use\_EOS) then}}
\DoxyCodeLine{295 \textcolor{comment}{!     do k=2,nz ; do j=Jsq,Jeq+1 ; do i=Isq,Ieq+1}}
\DoxyCodeLine{296 \textcolor{comment}{!       M(i,j,k) = M(i,j,k-\/1) -\/ p(i,j,K) * (alpha\_star(i,j,k-\/1) -\/ alpha\_star(i,j,k))}}
\DoxyCodeLine{297 \textcolor{comment}{!     enddo ; enddo ; enddo}}
\DoxyCodeLine{298 \textcolor{comment}{!   else ! not use\_EOS}}
\DoxyCodeLine{299 \textcolor{comment}{!     do k=2,nz ; do j=Jsq,Jeq+1 ; do i=Isq,Ieq+1}}
\DoxyCodeLine{300 \textcolor{comment}{!        M(i,j,k) = M(i,j,k-\/1) -\/ p(i,j,K) * dalpha\_int(K)}}
\DoxyCodeLine{301 \textcolor{comment}{!     enddo ; enddo ; enddo}}
\DoxyCodeLine{302 \textcolor{comment}{!   endif ! use\_EOS}}
\DoxyCodeLine{303 }
\DoxyCodeLine{304 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{305 }
\DoxyCodeLine{306   \textcolor{comment}{! Note that ddM/dPb = alpha\_star(i,j,1)}}
\DoxyCodeLine{307   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pbce)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{308     \textcolor{keyword}{call }set\_pbce\_nonbouss(p, tv\_tmp, g, gv, us, cs\%GFS\_scale, pbce, alpha\_star)}
\DoxyCodeLine{309 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{310 }
\DoxyCodeLine{311 \textcolor{comment}{!    Calculate the pressure force. On a Cartesian grid,}}
\DoxyCodeLine{312 \textcolor{comment}{!      PFu = -\/ dM/dx   and  PFv = -\/ dM/dy.}}
\DoxyCodeLine{313   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{314     \textcolor{comment}{!\$OMP parallel do default(shared) private(dp\_star,PFu\_bc,PFv\_bc)}}
\DoxyCodeLine{315     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{316       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{317         dp\_star(i,j) = (p(i,j,k+1) -\/ p(i,j,k)) + dp\_neglect}
\DoxyCodeLine{318 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{319       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{320         \textcolor{comment}{! PFu\_bc = p* grad alpha*}}
\DoxyCodeLine{321         pfu\_bc = (alpha\_star(i+1,j,k) -\/ alpha\_star(i,j,k)) * (g\%IdxCu(i,j) * \&}
\DoxyCodeLine{322             ((dp\_star(i,j)*dp\_star(i+1,j) + (p(i,j,k)*dp\_star(i+1,j) + p(i+1,j,k)*dp\_star(i,j))) / \&}
\DoxyCodeLine{323              (dp\_star(i,j) + dp\_star(i+1,j))))}
\DoxyCodeLine{324         pfu(i,j,k) = -\/(m(i+1,j,k) -\/ m(i,j,k)) * g\%IdxCu(i,j) + pfu\_bc}
\DoxyCodeLine{325         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%PFu\_bc)) cs\%PFu\_bc(i,j,k) = pfu\_bc}
\DoxyCodeLine{326 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{327       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{328         pfv\_bc = (alpha\_star(i,j+1,k) -\/ alpha\_star(i,j,k)) * (g\%IdyCv(i,j) * \&}
\DoxyCodeLine{329             ((dp\_star(i,j)*dp\_star(i,j+1) + (p(i,j,k)*dp\_star(i,j+1) + p(i,j+1,k)*dp\_star(i,j))) / \&}
\DoxyCodeLine{330              (dp\_star(i,j) + dp\_star(i,j+1))))}
\DoxyCodeLine{331         pfv(i,j,k) = -\/(m(i,j+1,k) -\/ m(i,j,k)) * g\%IdyCv(i,j) + pfv\_bc}
\DoxyCodeLine{332         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%PFv\_bc)) cs\%PFv\_bc(i,j,k) = pfv\_bc}
\DoxyCodeLine{333 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{334 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! k-\/loop}}
\DoxyCodeLine{335   \textcolor{keywordflow}{else} \textcolor{comment}{! .not. use\_EOS}}
\DoxyCodeLine{336     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{337     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{338       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{339         pfu(i,j,k) = -\/(m(i+1,j,k) -\/ m(i,j,k)) * g\%IdxCu(i,j)}
\DoxyCodeLine{340 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{341       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{342         pfv(i,j,k) = -\/(m(i,j+1,k) -\/ m(i,j,k)) * g\%IdyCv(i,j)}
\DoxyCodeLine{343 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{344 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{345 \textcolor{keywordflow}{  endif} \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{346 }
\DoxyCodeLine{347   \textcolor{keywordflow}{if} (cs\%id\_PFu\_bc>0) \textcolor{keyword}{call }post\_data(cs\%id\_PFu\_bc, cs\%PFu\_bc, cs\%diag)}
\DoxyCodeLine{348   \textcolor{keywordflow}{if} (cs\%id\_PFv\_bc>0) \textcolor{keyword}{call }post\_data(cs\%id\_PFv\_bc, cs\%PFv\_bc, cs\%diag)}
\DoxyCodeLine{349   \textcolor{keywordflow}{if} (cs\%id\_e\_tidal>0) \textcolor{keyword}{call }post\_data(cs\%id\_e\_tidal, e\_tidal, cs\%diag)}
\DoxyCodeLine{350 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__pressureforce__mont_a0779efd30a447c2bc20294c46aeea180}\label{namespacemom__pressureforce__mont_a0779efd30a447c2bc20294c46aeea180}} 
\index{mom\_pressureforce\_mont@{mom\_pressureforce\_mont}!set\_pbce\_bouss@{set\_pbce\_bouss}}
\index{set\_pbce\_bouss@{set\_pbce\_bouss}!mom\_pressureforce\_mont@{mom\_pressureforce\_mont}}
\doxysubsubsection{\texorpdfstring{set\_pbce\_bouss()}{set\_pbce\_bouss()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+pressureforce\+\_\+mont\+::set\+\_\+pbce\+\_\+bouss (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)+1), intent(in)}]{e,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{real, intent(in)}]{Rho0,  }\item[{real, intent(in)}]{G\+F\+S\+\_\+scale,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{pbce,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in), optional}]{rho\+\_\+star }\end{DoxyParamCaption})}



Determines the partial derivative of the acceleration due to pressure forces with the free surface height. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em e} & Interface height \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em rho0} & The \char`\"{}\+Boussinesq\char`\"{} ocean density \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em gfs\+\_\+scale} & Ratio between gravity applied to top interface and the gravitational acceleration of the planet \mbox{[}nondim\mbox{]}. Usually this ratio is 1. \\
\hline
\mbox{\texttt{ out}}  & {\em pbce} & The baroclinic pressure anomaly in each layer due \\
\hline
\mbox{\texttt{ in}}  & {\em rho\+\_\+star} & The layer densities (maybe compressibility \\
\hline
\end{DoxyParams}


Definition at line 606 of file M\+O\+M\+\_\+\+Pressure\+Force\+\_\+\+Montgomery.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{607   \textcolor{keywordtype}{type}(ocean\_grid\_type),                \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{    !< Ocean grid structure}}
\DoxyCodeLine{608   \textcolor{keywordtype}{type}(verticalGrid\_type),              \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{   !< Vertical grid structure}}
\DoxyCodeLine{609 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \textcolor{keywordtype}{intent(in)} :: e\textcolor{comment}{ !< Interface height [Z \string~> m].}}
\DoxyCodeLine{610   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{   !< Thermodynamic variables}}
\DoxyCodeLine{611   \textcolor{keywordtype}{type}(unit\_scale\_type),                \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{612 \textcolor{keywordtype}{  real},                                 \textcolor{keywordtype}{intent(in)}  :: Rho0\textcolor{comment}{ !< The "{}Boussinesq"{} ocean density [R \string~> kg m-\/3].}}
\DoxyCodeLine{613 \textcolor{keywordtype}{  real},                                 \textcolor{keywordtype}{intent(in)}  :: GFS\_scale\textcolor{comment}{ !< Ratio between gravity applied to top}}
\DoxyCodeLine{614 \textcolor{comment}{                                                            !! interface and the gravitational acceleration of}}
\DoxyCodeLine{615 \textcolor{comment}{                                                            !! the planet [nondim]. Usually this ratio is 1.}}
\DoxyCodeLine{616 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{617                                         \textcolor{keywordtype}{intent(out)} :: pbce\textcolor{comment}{ !< The baroclinic pressure anomaly in each layer due}}
\DoxyCodeLine{618 \textcolor{comment}{                                                            !! to free surface height anomalies}}
\DoxyCodeLine{619 \textcolor{comment}{                                                            !! [L2 T-\/2 H-\/1 \string~> m s-\/2].}}
\DoxyCodeLine{620 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{621                               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_star\textcolor{comment}{ !< The layer densities (maybe compressibility}}
\DoxyCodeLine{622 \textcolor{comment}{                                                            !! compensated), times g/rho\_0 [L2 Z-\/1 T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{623 }
\DoxyCodeLine{624   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{625 \textcolor{keywordtype}{  real} :: Ihtot(SZI\_(G))     \textcolor{comment}{! The inverse of the sum of the layer thicknesses [H-\/1 \string~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{626 \textcolor{keywordtype}{  real} :: press(SZI\_(G))     \textcolor{comment}{! Interface pressure [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{627 \textcolor{keywordtype}{  real} :: T\_int(SZI\_(G))     \textcolor{comment}{! Interface temperature [degC].}}
\DoxyCodeLine{628 \textcolor{keywordtype}{  real} :: S\_int(SZI\_(G))     \textcolor{comment}{! Interface salinity [ppt].}}
\DoxyCodeLine{629 \textcolor{keywordtype}{  real} :: dR\_dT(SZI\_(G))     \textcolor{comment}{! Partial derivative of density with temperature [R degC-\/1 \string~> kg m-\/3 degC-\/1].}}
\DoxyCodeLine{630 \textcolor{keywordtype}{  real} :: dR\_dS(SZI\_(G))     \textcolor{comment}{! Partial derivative of density with salinity [R ppt-\/1 \string~> kg m-\/3 ppt-\/1].}}
\DoxyCodeLine{631 \textcolor{keywordtype}{  real} :: rho\_in\_situ(SZI\_(G)) \textcolor{comment}{! In-\/situ density at the top of a layer [R \string~> kg m-\/3].}}
\DoxyCodeLine{632 \textcolor{keywordtype}{  real} :: G\_Rho0             \textcolor{comment}{! A scaled version of g\_Earth / Rho0 [L2 Z-\/1 T-\/2 R-\/1 \string~> m4 s-\/2 kg-\/1]}}
\DoxyCodeLine{633 \textcolor{keywordtype}{  real} :: Rho0xG             \textcolor{comment}{! g\_Earth * Rho0 [kg s-\/2 m-\/1 Z-\/1 \string~> kg s-\/2 m-\/2]}}
\DoxyCodeLine{634   \textcolor{keywordtype}{logical} :: use\_EOS         \textcolor{comment}{! If true, density is calculated from T \& S using}}
\DoxyCodeLine{635                              \textcolor{comment}{! an equation of state.}}
\DoxyCodeLine{636 \textcolor{keywordtype}{  real} :: z\_neglect          \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{637                              \textcolor{comment}{! in roundoff and can be neglected [Z \string~> m].}}
\DoxyCodeLine{638   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The computational domain for the equation of state}}
\DoxyCodeLine{639   \textcolor{keywordtype}{integer} :: Isq, Ieq, Jsq, Jeq, nz, i, j, k}
\DoxyCodeLine{640 }
\DoxyCodeLine{641   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB ; nz = g\%ke}
\DoxyCodeLine{642   eosdom(1) = isq -\/ (g\%isd-\/1) ;  eosdom(2) = g\%iec+1 -\/ (g\%isd-\/1)}
\DoxyCodeLine{643 }
\DoxyCodeLine{644   rho0xg = rho0 * gv\%g\_Earth}
\DoxyCodeLine{645   g\_rho0 = gv\%g\_Earth / gv\%Rho0}
\DoxyCodeLine{646   use\_eos = \textcolor{keyword}{associated}(tv\%eqn\_of\_state)}
\DoxyCodeLine{647   z\_neglect = gv\%H\_subroundoff*gv\%H\_to\_Z}
\DoxyCodeLine{648 }
\DoxyCodeLine{649   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{650     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(rho\_star)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{651      \textcolor{comment}{!\$OMP parallel do default(shared) private(Ihtot)}}
\DoxyCodeLine{652       \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{653         \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{654           ihtot(i) = gv\%H\_to\_Z / ((e(i,j,1)-\/e(i,j,nz+1)) + z\_neglect)}
\DoxyCodeLine{655           pbce(i,j,1) = gfs\_scale * rho\_star(i,j,1) * gv\%H\_to\_Z}
\DoxyCodeLine{656 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{657         \textcolor{keywordflow}{do} k=2,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{658           pbce(i,j,k) = pbce(i,j,k-\/1) + (rho\_star(i,j,k)-\/rho\_star(i,j,k-\/1)) * \&}
\DoxyCodeLine{659                         ((e(i,j,k) -\/ e(i,j,nz+1)) * ihtot(i))}
\DoxyCodeLine{660 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{661 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! end of j loop}}
\DoxyCodeLine{662     \textcolor{keywordflow}{else}}
\DoxyCodeLine{663       \textcolor{comment}{!\$OMP parallel do default(shared) private(Ihtot,press,rho\_in\_situ,T\_int,S\_int,dR\_dT,dR\_dS)}}
\DoxyCodeLine{664       \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{665         \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{666           ihtot(i) = gv\%H\_to\_Z / ((e(i,j,1)-\/e(i,j,nz+1)) + z\_neglect)}
\DoxyCodeLine{667           press(i) = -\/rho0xg*e(i,j,1)}
\DoxyCodeLine{668 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{669         \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,1), tv\%S(:,j,1), press, rho\_in\_situ, \&}
\DoxyCodeLine{670                                tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{671         \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{672           pbce(i,j,1) = g\_rho0*(gfs\_scale * rho\_in\_situ(i)) * gv\%H\_to\_Z}
\DoxyCodeLine{673 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{674         \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{675           \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{676             press(i) = -\/rho0xg*e(i,j,k)}
\DoxyCodeLine{677             t\_int(i) = 0.5*(tv\%T(i,j,k-\/1)+tv\%T(i,j,k))}
\DoxyCodeLine{678             s\_int(i) = 0.5*(tv\%S(i,j,k-\/1)+tv\%S(i,j,k))}
\DoxyCodeLine{679 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{680           \textcolor{keyword}{call }calculate\_density\_derivs(t\_int, s\_int, press, dr\_dt, dr\_ds, \&}
\DoxyCodeLine{681                                         tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{682           \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{683             pbce(i,j,k) = pbce(i,j,k-\/1) + g\_rho0 * \&}
\DoxyCodeLine{684                ((e(i,j,k) -\/ e(i,j,nz+1)) * ihtot(i)) * \&}
\DoxyCodeLine{685                (dr\_dt(i)*(tv\%T(i,j,k)-\/tv\%T(i,j,k-\/1)) + \&}
\DoxyCodeLine{686                 dr\_ds(i)*(tv\%S(i,j,k)-\/tv\%S(i,j,k-\/1)))}
\DoxyCodeLine{687 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{688 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{689 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! end of j loop}}
\DoxyCodeLine{690 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{691   \textcolor{keywordflow}{else} \textcolor{comment}{! not use\_EOS}}
\DoxyCodeLine{692     \textcolor{comment}{!\$OMP parallel do default(shared) private(Ihtot)}}
\DoxyCodeLine{693     \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{694       \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{695         ihtot(i) = 1.0 / ((e(i,j,1)-\/e(i,j,nz+1)) + z\_neglect)}
\DoxyCodeLine{696         pbce(i,j,1) = gv\%g\_prime(1) * gv\%H\_to\_Z}
\DoxyCodeLine{697 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{698       \textcolor{keywordflow}{do} k=2,nz ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{699         pbce(i,j,k) = pbce(i,j,k-\/1) + \&}
\DoxyCodeLine{700                       (gv\%g\_prime(k)*gv\%H\_to\_Z) * ((e(i,j,k) -\/ e(i,j,nz+1)) * ihtot(i))}
\DoxyCodeLine{701 \textcolor{keywordflow}{     enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{702 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! end of j loop}}
\DoxyCodeLine{703 \textcolor{keywordflow}{  endif} \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{704 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__pressureforce__mont_a297cdf6e4eb83d250444c5f527a8a232}\label{namespacemom__pressureforce__mont_a297cdf6e4eb83d250444c5f527a8a232}} 
\index{mom\_pressureforce\_mont@{mom\_pressureforce\_mont}!set\_pbce\_nonbouss@{set\_pbce\_nonbouss}}
\index{set\_pbce\_nonbouss@{set\_pbce\_nonbouss}!mom\_pressureforce\_mont@{mom\_pressureforce\_mont}}
\doxysubsubsection{\texorpdfstring{set\_pbce\_nonbouss()}{set\_pbce\_nonbouss()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+pressureforce\+\_\+mont\+::set\+\_\+pbce\+\_\+nonbouss (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)+1), intent(in)}]{p,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{real, intent(in)}]{G\+F\+S\+\_\+scale,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{pbce,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in), optional}]{alpha\+\_\+star }\end{DoxyParamCaption})}



Determines the partial derivative of the acceleration due to pressure forces with the column mass. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em p} & Interface pressures \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em gfs\+\_\+scale} & Ratio between gravity applied to top interface and the gravitational acceleration of the planet \mbox{[}nondim\mbox{]}. Usually this ratio is 1. \\
\hline
\mbox{\texttt{ out}}  & {\em pbce} & The baroclinic pressure anomaly in each layer due to free surface height anomalies \mbox{[}L2 H-\/1 T-\/2 $\sim$$>$ m4 kg-\/1 s-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em alpha\+\_\+star} & The layer specific volumes (maybe compressibility compensated) \mbox{[}R-\/1 $\sim$$>$ m3 kg-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 709 of file M\+O\+M\+\_\+\+Pressure\+Force\+\_\+\+Montgomery.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{710   \textcolor{keywordtype}{type}(ocean\_grid\_type),                \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< Ocean grid structure}}
\DoxyCodeLine{711   \textcolor{keywordtype}{type}(verticalGrid\_type),              \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{ !< Vertical grid structure}}
\DoxyCodeLine{712 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \textcolor{keywordtype}{intent(in)} :: p\textcolor{comment}{ !< Interface pressures [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{713   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{ !< Thermodynamic variables}}
\DoxyCodeLine{714   \textcolor{keywordtype}{type}(unit\_scale\_type),                \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{715 \textcolor{keywordtype}{  real},                                 \textcolor{keywordtype}{intent(in)}  :: GFS\_scale\textcolor{comment}{ !< Ratio between gravity applied to top}}
\DoxyCodeLine{716 \textcolor{comment}{                                                          !! interface and the gravitational acceleration of}}
\DoxyCodeLine{717 \textcolor{comment}{                                                          !! the planet [nondim]. Usually this ratio is 1.}}
\DoxyCodeLine{718 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: pbce\textcolor{comment}{ !< The baroclinic pressure anomaly in each}}
\DoxyCodeLine{719 \textcolor{comment}{                                                          !! layer due to free surface height anomalies}}
\DoxyCodeLine{720 \textcolor{comment}{                                                          !! [L2 H-\/1 T-\/2 \string~> m4 kg-\/1 s-\/2].}}
\DoxyCodeLine{721 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: alpha\_star\textcolor{comment}{ !< The layer specific volumes}}
\DoxyCodeLine{722 \textcolor{comment}{                                                          !! (maybe compressibility compensated) [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{723   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{724 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{725     dpbce, \&      \textcolor{comment}{!   A barotropic correction to the pbce to enable the use of}}
\DoxyCodeLine{726                   \textcolor{comment}{! a reduced gravity form of the equations [L2 H-\/1 T-\/2 \string~> m4 kg-\/1 s-\/2].}}
\DoxyCodeLine{727     c\_htot        \textcolor{comment}{! dP\_dH divided by the total ocean pressure [H-\/1 \string~> m2 kg-\/1].}}
\DoxyCodeLine{728 \textcolor{keywordtype}{  real} :: T\_int(SZI\_(G))     \textcolor{comment}{! Interface temperature [degC].}}
\DoxyCodeLine{729 \textcolor{keywordtype}{  real} :: S\_int(SZI\_(G))     \textcolor{comment}{! Interface salinity [ppt].}}
\DoxyCodeLine{730 \textcolor{keywordtype}{  real} :: dR\_dT(SZI\_(G))     \textcolor{comment}{! Partial derivative of density with temperature [R degC-\/1 \string~> kg m-\/3 degC-\/1].}}
\DoxyCodeLine{731 \textcolor{keywordtype}{  real} :: dR\_dS(SZI\_(G))     \textcolor{comment}{! Partial derivative of density with salinity [R ppt-\/1 \string~> kg m-\/3 ppt-\/1].}}
\DoxyCodeLine{732 \textcolor{keywordtype}{  real} :: rho\_in\_situ(SZI\_(G)) \textcolor{comment}{! In-\/situ density at an interface [R \string~> kg m-\/3].}}
\DoxyCodeLine{733 \textcolor{keywordtype}{  real} :: alpha\_Lay(SZK\_(G)) \textcolor{comment}{! The specific volume of each layer [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{734 \textcolor{keywordtype}{  real} :: dalpha\_int(SZK\_(G)+1) \textcolor{comment}{! The change in specific volume across each interface [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{735 \textcolor{keywordtype}{  real} :: dP\_dH              \textcolor{comment}{! A factor that converts from thickness to pressure times other dimensional}}
\DoxyCodeLine{736                              \textcolor{comment}{! conversion factors [R L2 T-\/2 H-\/1 \string~> Pa m2 kg-\/1].}}
\DoxyCodeLine{737 \textcolor{keywordtype}{  real} :: dp\_neglect         \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{738                              \textcolor{comment}{! in roundoff and can be neglected [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{739   \textcolor{keywordtype}{logical} :: use\_EOS         \textcolor{comment}{! If true, density is calculated from T \& S using an equation of state.}}
\DoxyCodeLine{740   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The computational domain for the equation of state}}
\DoxyCodeLine{741   \textcolor{keywordtype}{integer} :: Isq, Ieq, Jsq, Jeq, nz, i, j, k}
\DoxyCodeLine{742 }
\DoxyCodeLine{743   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB ; nz = g\%ke}
\DoxyCodeLine{744   eosdom(1) = isq -\/ (g\%isd-\/1) ;  eosdom(2) = g\%iec+1 -\/ (g\%isd-\/1)}
\DoxyCodeLine{745 }
\DoxyCodeLine{746   use\_eos = \textcolor{keyword}{associated}(tv\%eqn\_of\_state)}
\DoxyCodeLine{747 }
\DoxyCodeLine{748   dp\_dh = gv\%g\_Earth * gv\%H\_to\_RZ}
\DoxyCodeLine{749   dp\_neglect = gv\%g\_Earth * gv\%H\_to\_RZ * gv\%H\_subroundoff}
\DoxyCodeLine{750 }
\DoxyCodeLine{751   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keywordflow}{then}}
\DoxyCodeLine{752     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(alpha\_star)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{753       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{754       \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{755         \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{756           c\_htot(i,j) = dp\_dh / ((p(i,j,nz+1)-\/p(i,j,1)) + dp\_neglect)}
\DoxyCodeLine{757           pbce(i,j,nz) = dp\_dh * alpha\_star(i,j,nz)}
\DoxyCodeLine{758 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{759         \textcolor{keywordflow}{do} k=nz-\/1,1,-\/1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{760           pbce(i,j,k) = pbce(i,j,k+1) + ((p(i,j,k+1)-\/p(i,j,1)) * c\_htot(i,j)) * \&}
\DoxyCodeLine{761               (alpha\_star(i,j,k) -\/ alpha\_star(i,j,k+1))}
\DoxyCodeLine{762 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{763 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{764     \textcolor{keywordflow}{else}}
\DoxyCodeLine{765       \textcolor{comment}{!\$OMP parallel do default(shared) private(T\_int,S\_int,dR\_dT,dR\_dS,rho\_in\_situ)}}
\DoxyCodeLine{766       \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{767         \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,nz), tv\%S(:,j,nz), p(:,j,nz+1), rho\_in\_situ, \&}
\DoxyCodeLine{768                                tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{769         \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{770           c\_htot(i,j) = dp\_dh / ((p(i,j,nz+1)-\/p(i,j,1)) + dp\_neglect)}
\DoxyCodeLine{771           pbce(i,j,nz) = dp\_dh / (rho\_in\_situ(i))}
\DoxyCodeLine{772 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{773         \textcolor{keywordflow}{do} k=nz-\/1,1,-\/1}
\DoxyCodeLine{774           \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{775             t\_int(i) = 0.5*(tv\%T(i,j,k)+tv\%T(i,j,k+1))}
\DoxyCodeLine{776             s\_int(i) = 0.5*(tv\%S(i,j,k)+tv\%S(i,j,k+1))}
\DoxyCodeLine{777 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{778           \textcolor{keyword}{call }calculate\_density(t\_int, s\_int, p(:,j,k+1), rho\_in\_situ, tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{779           \textcolor{keyword}{call }calculate\_density\_derivs(t\_int, s\_int, p(:,j,k+1), dr\_dt, dr\_ds, \&}
\DoxyCodeLine{780                                         tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{781           \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{782             pbce(i,j,k) = pbce(i,j,k+1) + ((p(i,j,k+1)-\/p(i,j,1))*c\_htot(i,j)) *  \&}
\DoxyCodeLine{783                 ((dr\_dt(i)*(tv\%T(i,j,k+1)-\/tv\%T(i,j,k)) + \&}
\DoxyCodeLine{784                   dr\_ds(i)*(tv\%S(i,j,k+1)-\/tv\%S(i,j,k))) / (rho\_in\_situ(i)**2))}
\DoxyCodeLine{785 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{786 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{787 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{788 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{789   \textcolor{keywordflow}{else} \textcolor{comment}{! not use\_EOS}}
\DoxyCodeLine{790 }
\DoxyCodeLine{791     \textcolor{keywordflow}{do} k=1,nz ; alpha\_lay(k) = 1.0 / (gv\%Rlay(k)) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{792     \textcolor{keywordflow}{do} k=2,nz ; dalpha\_int(k) = alpha\_lay(k-\/1) -\/ alpha\_lay(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{793 }
\DoxyCodeLine{794     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{795     \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{796       \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{797         c\_htot(i,j) = dp\_dh / ((p(i,j,nz+1)-\/p(i,j,1)) + dp\_neglect)}
\DoxyCodeLine{798         pbce(i,j,nz) = dp\_dh * alpha\_lay(nz)}
\DoxyCodeLine{799 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{800       \textcolor{keywordflow}{do} k=nz-\/1,1,-\/1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{801         pbce(i,j,k) = pbce(i,j,k+1) + ((p(i,j,k+1)-\/p(i,j,1))*c\_htot(i,j)) * dalpha\_int(k+1)}
\DoxyCodeLine{802 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{803 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{804 \textcolor{keywordflow}{  endif} \textcolor{comment}{! use\_EOS}}
\DoxyCodeLine{805 }
\DoxyCodeLine{806   \textcolor{keywordflow}{if} (gfs\_scale < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{807     \textcolor{comment}{! Adjust the Montgomery potential to make this a reduced gravity model.}}
\DoxyCodeLine{808     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{809     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{810       dpbce(i,j) = (gfs\_scale -\/ 1.0) * pbce(i,j,1)}
\DoxyCodeLine{811 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{812     \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{813     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{814       pbce(i,j,k) = pbce(i,j,k) + dpbce(i,j)}
\DoxyCodeLine{815 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{816 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{817 }

\end{DoxyCode}
