\hypertarget{namespacemom__coriolisadv}{}\doxysection{mom\+\_\+coriolisadv Module Reference}
\label{namespacemom__coriolisadv}\index{mom\_coriolisadv@{mom\_coriolisadv}}


\doxysubsection{Detailed Description}
Accelerations due to the Coriolis force and momentum advection. 

This file contains the subroutine that calculates the time derivatives of the velocities due to Coriolis acceleration and momentum advection. This subroutine uses either a vorticity advection scheme from Arakawa and Hsu, Mon. Wea. Rev. 1990, or Sadourny\textquotesingle{}s (J\+AS 1975) energy conserving scheme. Both have been modified to use general orthogonal coordinates as described in Arakawa and Lamb, Mon. Wea. Rev. 1981. Both schemes are second order accurate, and allow for vanishingly small layer thicknesses. The Arakawa and Hsu scheme globally conserves both total energy and potential enstrophy in the limit of nondivergent flow. Sadourny\textquotesingle{}s energy conserving scheme conserves energy if the flow is nondivergent or centered difference thickness fluxes are used.

A small fragment of the grid is shown below\+: \begin{DoxyVerb}    j+1  x ^ x ^ x   At x:  q, CoriolisBu
    j+1  > o > o >   At ^:  v, CAv, vh
    j    x ^ x ^ x   At >:  u, CAu, uh, a, b, c, d
    j    > o > o >   At o:  h, KE
    j-1  x ^ x ^ x
        i-1  i  i+1  At x & ^:
           i  i+1    At > & o:\end{DoxyVerb}


The boundaries always run through q grid points (x). \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure for \mbox{\hyperlink{namespacemom__coriolisadv}{mom\+\_\+coriolisadv}}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__coriolisadv_ac677e9d644c881b7e8ce6413aa5450cd}{coradcalc}} (u, v, h, uh, vh, C\+Au, C\+Av, O\+BC, AD, G, GV, US, CS)
\begin{DoxyCompactList}\small\item\em Calculates the Coriolis and momentum advection contributions to the acceleration. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__coriolisadv_a87e4a437552052fa238260442af19868}{gradke}} (u, v, h, KE, K\+Ex, K\+Ey, k, O\+BC, G, US, CS)
\begin{DoxyCompactList}\small\item\em Calculates the acceleration due to the gradient of kinetic energy. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__coriolisadv_ae021ac8de3b3510ca4552314ec9e1a9a}{coriolisadv\+\_\+init}} (Time, G, GV, US, param\+\_\+file, diag, AD, CS)
\begin{DoxyCompactList}\small\item\em Initializes the control structure for \mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__coriolisadv_a6252eaea90947c83b5a1900d31191b96}{coriolisadv\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Destructor for \mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__coriolisadv_ac677e9d644c881b7e8ce6413aa5450cd}\label{namespacemom__coriolisadv_ac677e9d644c881b7e8ce6413aa5450cd}} 
\index{mom\_coriolisadv@{mom\_coriolisadv}!coradcalc@{coradcalc}}
\index{coradcalc@{coradcalc}!mom\_coriolisadv@{mom\_coriolisadv}}
\doxysubsubsection{\texorpdfstring{coradcalc()}{coradcalc()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+coriolisadv\+::coradcalc (\begin{DoxyParamCaption}\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(in)}]{v,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{uh,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(in)}]{vh,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(out)}]{C\+Au,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(out)}]{C\+Av,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(inout)}]{AD,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Calculates the Coriolis and momentum advection contributions to the acceleration. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocen grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em u} & Zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em v} & Meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em uh} & Zonal transport u$\ast$h$\ast$dy \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em vh} & Meridional transport v$\ast$h$\ast$dx \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em cau} & Zonal acceleration due to Coriolis and momentum advection \mbox{[}L T-\/2 $\sim$$>$ m s-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em cav} & Meridional acceleration due to Coriolis and momentum advection \mbox{[}L T-\/2 $\sim$$>$ m s-\/2\mbox{]}. \\
\hline
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em ad} & Storage for acceleration diagnostics \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & Control structure for M\+O\+M\+\_\+\+Coriolis\+Adv \\
\hline
\end{DoxyParams}


Definition at line 116 of file M\+O\+M\+\_\+\+Coriolis\+Adv.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{117   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< Ocen grid structure}}
\DoxyCodeLine{118   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< Vertical grid structure}}
\DoxyCodeLine{119 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{  !< Zonal velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{120 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: v\textcolor{comment}{  !< Meridional velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{121 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< Layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{122 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: uh\textcolor{comment}{ !< Zonal transport u*h*dy}}
\DoxyCodeLine{123 \textcolor{comment}{                                                                 !! [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1]}}
\DoxyCodeLine{124 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: vh\textcolor{comment}{ !< Meridional transport v*h*dx}}
\DoxyCodeLine{125 \textcolor{comment}{                                                                 !! [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1]}}
\DoxyCodeLine{126 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)}   :: CAu\textcolor{comment}{ !< Zonal acceleration due to Coriolis}}
\DoxyCodeLine{127 \textcolor{comment}{                                                                  !! and momentum advection [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{128 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)}   :: CAv\textcolor{comment}{ !< Meridional acceleration due to Coriolis}}
\DoxyCodeLine{129 \textcolor{comment}{                                                                  !! and momentum advection [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{130   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{131   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),                     \textcolor{keywordtype}{intent(inout)} :: AD\textcolor{comment}{  !< Storage for acceleration diagnostics}}
\DoxyCodeLine{132   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{133   \textcolor{keywordtype}{type}(CoriolisAdv\_CS),                      \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Control structure for MOM\_CoriolisAdv}}
\DoxyCodeLine{134 }
\DoxyCodeLine{135   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{136 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJB\_(G))} :: \&}
\DoxyCodeLine{137     q, \&        \textcolor{comment}{! Layer potential vorticity [H-\/1 T-\/1 \string~> m-\/1 s-\/1 or m2 kg-\/1 s-\/1].}}
\DoxyCodeLine{138     Ih\_q, \&     \textcolor{comment}{! The inverse of thickness interpolated to q points [H-\/1 \string~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{139     Area\_q      \textcolor{comment}{! The sum of the ocean areas at the 4 adjacent thickness points [L2 \string~> m2].}}
\DoxyCodeLine{140 }
\DoxyCodeLine{141 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{142     a, b, c, d  \textcolor{comment}{! a, b, c, \& d are combinations of the potential vorticities}}
\DoxyCodeLine{143                 \textcolor{comment}{! surrounding an h grid point.  At small scales, a = q/4,}}
\DoxyCodeLine{144                 \textcolor{comment}{! b = q/4, etc.  All are in [H-\/1 T-\/1 \string~> m-\/1 s-\/1 or m2 kg-\/1 s-\/1],}}
\DoxyCodeLine{145                 \textcolor{comment}{! and use the indexing of the corresponding u point.}}
\DoxyCodeLine{146 }
\DoxyCodeLine{147 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{148     Area\_h, \&   \textcolor{comment}{! The ocean area at h points [L2 \string~> m2].  Area\_h is used to find the}}
\DoxyCodeLine{149                 \textcolor{comment}{! average thickness in the denominator of q.  0 for land points.}}
\DoxyCodeLine{150     ke          \textcolor{comment}{! Kinetic energy per unit mass [L2 T-\/2 \string~> m2 s-\/2], KE = (u\string^2 + v\string^2)/2.}}
\DoxyCodeLine{151 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{152     hArea\_u, \&  \textcolor{comment}{! The cell area weighted thickness interpolated to u points}}
\DoxyCodeLine{153                 \textcolor{comment}{! times the effective areas [H L2 \string~> m3 or kg].}}
\DoxyCodeLine{154     kex, \&      \textcolor{comment}{! The zonal gradient of Kinetic energy per unit mass [L T-\/2 \string~> m s-\/2],}}
\DoxyCodeLine{155                 \textcolor{comment}{! KEx = d/dx KE.}}
\DoxyCodeLine{156     uh\_center   \textcolor{comment}{! Transport based on arithmetic mean h at u-\/points [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1]}}
\DoxyCodeLine{157 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G))} :: \&}
\DoxyCodeLine{158     hArea\_v, \&  \textcolor{comment}{! The cell area weighted thickness interpolated to v points}}
\DoxyCodeLine{159                 \textcolor{comment}{! times the effective areas [H L2 \string~> m3 or kg].}}
\DoxyCodeLine{160     key, \&      \textcolor{comment}{! The meridonal gradient of Kinetic energy per unit mass [L T-\/2 \string~> m s-\/2],}}
\DoxyCodeLine{161                 \textcolor{comment}{! KEy = d/dy KE.}}
\DoxyCodeLine{162     vh\_center   \textcolor{comment}{! Transport based on arithmetic mean h at v-\/points [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1]}}
\DoxyCodeLine{163 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{164     uh\_min, uh\_max, \&   \textcolor{comment}{! The smallest and largest estimates of the volume}}
\DoxyCodeLine{165     vh\_min, vh\_max, \&   \textcolor{comment}{! fluxes through the faces (i.e. u*h*dy \& v*h*dx)}}
\DoxyCodeLine{166                         \textcolor{comment}{! [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{167     ep\_u, ep\_v  \textcolor{comment}{! Additional pseudo-\/Coriolis terms in the Arakawa and Lamb}}
\DoxyCodeLine{168                 \textcolor{comment}{! discretization [H-\/1 s-\/1 \string~> m-\/1 s-\/1 or m2 kg-\/1 s-\/1].}}
\DoxyCodeLine{169 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJB\_(G))} :: \&}
\DoxyCodeLine{170     dvdx, dudy, \& \textcolor{comment}{! Contributions to the circulation around q-\/points [L2 T-\/1 \string~> m2 s-\/1]}}
\DoxyCodeLine{171     abs\_vort, \& \textcolor{comment}{! Absolute vorticity at q-\/points [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{172     q2, \&       \textcolor{comment}{! Relative vorticity over thickness [H-\/1 T-\/1 \string~> m-\/1 s-\/1 or m2 kg-\/1 s-\/1].}}
\DoxyCodeLine{173     max\_fvq, \&  \textcolor{comment}{! The maximum of the adjacent values of (-\/u) times absolute vorticity [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{174     min\_fvq, \&  \textcolor{comment}{! The minimum of the adjacent values of (-\/u) times absolute vorticity [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{175     max\_fuq, \&  \textcolor{comment}{! The maximum of the adjacent values of u times absolute vorticity [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{176     min\_fuq     \textcolor{comment}{! The minimum of the adjacent values of u times absolute vorticity [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{177 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJB\_(G),SZK\_(G))} :: \&}
\DoxyCodeLine{178     PV, \&       \textcolor{comment}{! A diagnostic array of the potential vorticities [H-\/1 T-\/1 \string~> m-\/1 s-\/1 or m2 kg-\/1 s-\/1].}}
\DoxyCodeLine{179     RV          \textcolor{comment}{! A diagnostic array of the relative vorticities [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{180 \textcolor{keywordtype}{  real} :: fv1, fv2, fu1, fu2   \textcolor{comment}{! (f+rv)*v or (f+rv)*u [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{181 \textcolor{keywordtype}{  real} :: max\_fv, max\_fu       \textcolor{comment}{! The maximum or minimum of the neighboring Coriolis}}
\DoxyCodeLine{182 \textcolor{keywordtype}{  real} :: min\_fv, min\_fu       \textcolor{comment}{! accelerations [L T-\/2 \string~> m s-\/2], i.e. max(min)\_fu(v)q.}}
\DoxyCodeLine{183 }
\DoxyCodeLine{184 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: C1\_12=1.0/12.0 \textcolor{comment}{! C1\_12 = 1/12}}
\DoxyCodeLine{185 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: C1\_24=1.0/24.0 \textcolor{comment}{! C1\_24 = 1/24}}
\DoxyCodeLine{186 \textcolor{keywordtype}{  real} :: absolute\_vorticity     \textcolor{comment}{! Absolute vorticity [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{187 \textcolor{keywordtype}{  real} :: relative\_vorticity     \textcolor{comment}{! Relative vorticity [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{188 \textcolor{keywordtype}{  real} :: Ih                     \textcolor{comment}{! Inverse of thickness [H-\/1 \string~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{189 \textcolor{keywordtype}{  real} :: max\_Ihq, min\_Ihq       \textcolor{comment}{! The maximum and minimum of the nearby Ihq [H-\/1 \string~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{190 \textcolor{keywordtype}{  real} :: hArea\_q                \textcolor{comment}{! The sum of area times thickness of the cells}}
\DoxyCodeLine{191                                  \textcolor{comment}{! surrounding a q point [H L2 \string~> m3 or kg].}}
\DoxyCodeLine{192 \textcolor{keywordtype}{  real} :: h\_neglect              \textcolor{comment}{! A thickness that is so small it is usually}}
\DoxyCodeLine{193                                  \textcolor{comment}{! lost in roundoff and can be neglected [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{194 \textcolor{keywordtype}{  real} :: temp1, temp2           \textcolor{comment}{! Temporary variables [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{195 \textcolor{keywordtype}{  real} :: eps\_vel                \textcolor{comment}{! A tiny, positive velocity [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{196 }
\DoxyCodeLine{197 \textcolor{keywordtype}{  real} :: uhc, vhc               \textcolor{comment}{! Centered estimates of uh and vh [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{198 \textcolor{keywordtype}{  real} :: uhm, vhm               \textcolor{comment}{! The input estimates of uh and vh [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{199 \textcolor{keywordtype}{  real} :: c1, c2, c3, slope      \textcolor{comment}{! Nondimensional parameters for the Coriolis limiter scheme.}}
\DoxyCodeLine{200 }
\DoxyCodeLine{201 \textcolor{keywordtype}{  real} :: Fe\_m2         \textcolor{comment}{! Nondimensional temporary variables asssociated with}}
\DoxyCodeLine{202 \textcolor{keywordtype}{  real} :: rat\_lin       \textcolor{comment}{! the ARAKAWA\_LAMB\_BLEND scheme.}}
\DoxyCodeLine{203 \textcolor{keywordtype}{  real} :: rat\_m1        \textcolor{comment}{! The ratio of the maximum neighboring inverse thickness}}
\DoxyCodeLine{204                         \textcolor{comment}{! to the minimum inverse thickness minus 1. rat\_m1 >= 0.}}
\DoxyCodeLine{205 \textcolor{keywordtype}{  real} :: AL\_wt         \textcolor{comment}{! The relative weight of the Arakawa \& Lamb scheme to the}}
\DoxyCodeLine{206                         \textcolor{comment}{! Arakawa \& Hsu scheme, nondimensional between 0 and 1.}}
\DoxyCodeLine{207 \textcolor{keywordtype}{  real} :: Sad\_wt        \textcolor{comment}{! The relative weight of the Sadourny energy scheme to}}
\DoxyCodeLine{208                         \textcolor{comment}{! the other two with the ARAKAWA\_LAMB\_BLEND scheme,}}
\DoxyCodeLine{209                         \textcolor{comment}{! nondimensional between 0 and 1.}}
\DoxyCodeLine{210 }
\DoxyCodeLine{211 \textcolor{keywordtype}{  real} :: Heff1, Heff2  \textcolor{comment}{! Temporary effective H at U or V points [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{212 \textcolor{keywordtype}{  real} :: Heff3, Heff4  \textcolor{comment}{! Temporary effective H at U or V points [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{213 \textcolor{keywordtype}{  real} :: h\_tiny        \textcolor{comment}{! A very small thickness [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{214 \textcolor{keywordtype}{  real} :: UHeff, VHeff  \textcolor{comment}{! More temporary variables [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{215 \textcolor{keywordtype}{  real} :: QUHeff,QVHeff \textcolor{comment}{! More temporary variables [H L2 T-\/1 s-\/1 \string~> m3 s-\/2 or kg s-\/2].}}
\DoxyCodeLine{216   \textcolor{keywordtype}{integer} :: i, j, k, n, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz}
\DoxyCodeLine{217 }
\DoxyCodeLine{218 \textcolor{comment}{! Diagnostics for fractional thickness-\/weighted terms}}
\DoxyCodeLine{219 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: \&}
\DoxyCodeLine{220     hf\_gKEu\_2d, hf\_gKEv\_2d, \& \textcolor{comment}{! Depth sum of hf\_gKEu, hf\_gKEv [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{221     hf\_rvxu\_2d, hf\_rvxv\_2d    \textcolor{comment}{! Depth sum of hf\_rvxu, hf\_rvxv [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{222   \textcolor{comment}{!real, allocatable, dimension(:,:,:) :: \&}}
\DoxyCodeLine{223   \textcolor{comment}{!  hf\_gKEu, hf\_gKEv, \& ! accel. due to KE gradient x fract. thickness  [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{224   \textcolor{comment}{!  hf\_rvxu, hf\_rvxv    ! accel. due to RV x fract. thickness [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{225   \textcolor{comment}{! 3D diagnostics hf\_gKEu etc. are commented because there is no clarity on proper remapping grid option.}}
\DoxyCodeLine{226   \textcolor{comment}{! The code is retained for degugging purposes in the future.}}
\DoxyCodeLine{227 }
\DoxyCodeLine{228 \textcolor{comment}{! To work, the following fields must be set outside of the usual}}
\DoxyCodeLine{229 \textcolor{comment}{! is to ie range before this subroutine is called:}}
\DoxyCodeLine{230 \textcolor{comment}{!   v(is-\/1:ie+2,js-\/1:je+1), u(is-\/1:ie+1,js-\/1:je+2), h(is-\/1:ie+2,js-\/1:je+2),}}
\DoxyCodeLine{231 \textcolor{comment}{!   uh(is-\/1,ie,js:je+1) and vh(is:ie+1,js-\/1:je).}}
\DoxyCodeLine{232 }
\DoxyCodeLine{233   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{234          \textcolor{stringliteral}{"MOM\_CoriolisAdv: Module must be initialized before it is used."})}
\DoxyCodeLine{235   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{236   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB ; nz = g\%ke}
\DoxyCodeLine{237   h\_neglect = gv\%H\_subroundoff}
\DoxyCodeLine{238   eps\_vel = 1.0e-\/10*us\%m\_s\_to\_L\_T}
\DoxyCodeLine{239   h\_tiny = gv\%Angstrom\_H  \textcolor{comment}{! Perhaps this should be set to h\_neglect instead.}}
\DoxyCodeLine{240 }
\DoxyCodeLine{241   \textcolor{comment}{!\$OMP parallel do default(private) shared(Isq,Ieq,Jsq,Jeq,G,Area\_h)}}
\DoxyCodeLine{242   \textcolor{keywordflow}{do} j=jsq-\/1,jeq+2 ; \textcolor{keywordflow}{do} i=isq-\/1,ieq+2}
\DoxyCodeLine{243     area\_h(i,j) = g\%mask2dT(i,j) * g\%areaT(i,j)}
\DoxyCodeLine{244 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{245   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{246     \textcolor{keywordflow}{if} (.not. obc\%segment(n)\%on\_pe) cycle}
\DoxyCodeLine{247     i = obc\%segment(n)\%HI\%IsdB ; j = obc\%segment(n)\%HI\%JsdB}
\DoxyCodeLine{248     \textcolor{keywordflow}{if} (obc\%segment(n)\%is\_N\_or\_S .and. (j >= jsq-\/1) .and. (j <= jeq+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{249       \textcolor{keywordflow}{do} i = max(isq-\/1,obc\%segment(n)\%HI\%isd), min(ieq+2,obc\%segment(n)\%HI\%ied)}
\DoxyCodeLine{250         \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{251           area\_h(i,j+1) = area\_h(i,j)}
\DoxyCodeLine{252         \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{253           area\_h(i,j) = area\_h(i,j+1)}
\DoxyCodeLine{254 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{255 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{256     \textcolor{keywordflow}{elseif} (obc\%segment(n)\%is\_E\_or\_W .and. (i >= isq-\/1) .and. (i <= ieq+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{257       \textcolor{keywordflow}{do} j = max(jsq-\/1,obc\%segment(n)\%HI\%jsd), min(jeq+2,obc\%segment(n)\%HI\%jed)}
\DoxyCodeLine{258         \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{259           area\_h(i+1,j) = area\_h(i,j)}
\DoxyCodeLine{260         \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_W)}}
\DoxyCodeLine{261           area\_h(i,j) = area\_h(i+1,j)}
\DoxyCodeLine{262 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{263 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{264 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{265 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{266   \textcolor{comment}{!\$OMP parallel do default(private) shared(Isq,Ieq,Jsq,Jeq,G,Area\_h,Area\_q)}}
\DoxyCodeLine{267   \textcolor{keywordflow}{do} j=jsq-\/1,jeq+1 ; \textcolor{keywordflow}{do} i=isq-\/1,ieq+1}
\DoxyCodeLine{268     area\_q(i,j) = (area\_h(i,j) + area\_h(i+1,j+1)) + \&}
\DoxyCodeLine{269                   (area\_h(i+1,j) + area\_h(i,j+1))}
\DoxyCodeLine{270 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{271 }
\DoxyCodeLine{272   \textcolor{comment}{!\$OMP parallel do default(private) shared(u,v,h,uh,vh,CAu,CAv,G,CS,AD,Area\_h,Area\_q,\&}}
\DoxyCodeLine{273   \textcolor{comment}{!\$OMP                        RV,PV,is,ie,js,je,Isq,Ieq,Jsq,Jeq,nz,h\_neglect,h\_tiny,OBC,eps\_vel)}}
\DoxyCodeLine{274   \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{275 }
\DoxyCodeLine{276     \textcolor{comment}{! Here the second order accurate layer potential vorticities, q,}}
\DoxyCodeLine{277     \textcolor{comment}{! are calculated.  hq is  second order accurate in space.  Relative}}
\DoxyCodeLine{278     \textcolor{comment}{! vorticity is second order accurate everywhere with free slip b.c.s,}}
\DoxyCodeLine{279     \textcolor{comment}{! but only first order accurate at boundaries with no slip b.c.s.}}
\DoxyCodeLine{280     \textcolor{comment}{! First calculate the contributions to the circulation around the q-\/point.}}
\DoxyCodeLine{281     \textcolor{keywordflow}{do} j=jsq-\/1,jeq+1 ; \textcolor{keywordflow}{do} i=isq-\/1,ieq+1}
\DoxyCodeLine{282       dvdx(i,j) = (v(i+1,j,k)*g\%dyCv(i+1,j) -\/ v(i,j,k)*g\%dyCv(i,j))}
\DoxyCodeLine{283       dudy(i,j) = (u(i,j+1,k)*g\%dxCu(i,j+1) -\/ u(i,j,k)*g\%dxCu(i,j))}
\DoxyCodeLine{284 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{285     \textcolor{keywordflow}{do} j=jsq-\/1,jeq+1 ; \textcolor{keywordflow}{do} i=isq-\/1,ieq+2}
\DoxyCodeLine{286       harea\_v(i,j) = 0.5*(area\_h(i,j) * h(i,j,k) + area\_h(i,j+1) * h(i,j+1,k))}
\DoxyCodeLine{287 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{288     \textcolor{keywordflow}{do} j=jsq-\/1,jeq+2 ; \textcolor{keywordflow}{do} i=isq-\/1,ieq+1}
\DoxyCodeLine{289       harea\_u(i,j) = 0.5*(area\_h(i,j) * h(i,j,k) + area\_h(i+1,j) * h(i+1,j,k))}
\DoxyCodeLine{290 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{291     \textcolor{keywordflow}{if} (cs\%Coriolis\_En\_Dis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{292       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=is-\/1,ie}
\DoxyCodeLine{293         uh\_center(i,j) = 0.5 * (g\%dy\_Cu(i,j) * u(i,j,k)) * (h(i,j,k) + h(i+1,j,k))}
\DoxyCodeLine{294 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{295       \textcolor{keywordflow}{do} j=js-\/1,je ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{296         vh\_center(i,j) = 0.5 * (g\%dx\_Cv(i,j) * v(i,j,k)) * (h(i,j,k) + h(i,j+1,k))}
\DoxyCodeLine{297 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{298 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{299 }
\DoxyCodeLine{300     \textcolor{comment}{! Adjust circulation components to relative vorticity and thickness projected onto}}
\DoxyCodeLine{301     \textcolor{comment}{! velocity points on open boundaries.}}
\DoxyCodeLine{302     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{303       \textcolor{keywordflow}{if} (.not. obc\%segment(n)\%on\_pe) cycle}
\DoxyCodeLine{304       i = obc\%segment(n)\%HI\%IsdB ; j = obc\%segment(n)\%HI\%JsdB}
\DoxyCodeLine{305       \textcolor{keywordflow}{if} (obc\%segment(n)\%is\_N\_or\_S .and. (j >= jsq-\/1) .and. (j <= jeq+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{306         \textcolor{keywordflow}{if} (obc\%zero\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=obc\%segment(n)\%HI\%IsdB,obc\%segment(n)\%HI\%IedB}
\DoxyCodeLine{307           dvdx(i,j) = 0. ; dudy(i,j) = 0.}
\DoxyCodeLine{308 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{309         \textcolor{keywordflow}{if} (obc\%freeslip\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=obc\%segment(n)\%HI\%IsdB,obc\%segment(n)\%HI\%IedB}
\DoxyCodeLine{310           dudy(i,j) = 0.}
\DoxyCodeLine{311 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{312         \textcolor{keywordflow}{if} (obc\%computed\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=obc\%segment(n)\%HI\%IsdB,obc\%segment(n)\%HI\%IedB}
\DoxyCodeLine{313           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{314             dudy(i,j) = 2.0*(obc\%segment(n)\%tangential\_vel(i,j,k) -\/ u(i,j,k))*g\%dxCu(i,j)}
\DoxyCodeLine{315           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{316             dudy(i,j) = 2.0*(u(i,j+1,k) -\/ obc\%segment(n)\%tangential\_vel(i,j,k))*g\%dxCu(i,j+1)}
\DoxyCodeLine{317 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{318 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{319         \textcolor{keywordflow}{if} (obc\%specified\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=obc\%segment(n)\%HI\%IsdB,obc\%segment(n)\%HI\%IedB}
\DoxyCodeLine{320           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{321             dudy(i,j) = obc\%segment(n)\%tangential\_grad(i,j,k)*g\%dxCu(i,j)*g\%dyBu(i,j)}
\DoxyCodeLine{322           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{323             dudy(i,j) = obc\%segment(n)\%tangential\_grad(i,j,k)*g\%dxCu(i,j+1)*g\%dyBu(i,j)}
\DoxyCodeLine{324 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{325 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{326 }
\DoxyCodeLine{327         \textcolor{comment}{! Project thicknesses across OBC points with a no-\/gradient condition.}}
\DoxyCodeLine{328         \textcolor{keywordflow}{do} i = max(isq-\/1,obc\%segment(n)\%HI\%isd), min(ieq+2,obc\%segment(n)\%HI\%ied)}
\DoxyCodeLine{329           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{330             harea\_v(i,j) = 0.5 * (area\_h(i,j) + area\_h(i,j+1)) * h(i,j,k)}
\DoxyCodeLine{331           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{332             harea\_v(i,j) = 0.5 * (area\_h(i,j) + area\_h(i,j+1)) * h(i,j+1,k)}
\DoxyCodeLine{333 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{334 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{335 }
\DoxyCodeLine{336         \textcolor{keywordflow}{if} (cs\%Coriolis\_En\_Dis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{337           \textcolor{keywordflow}{do} i = max(isq-\/1,obc\%segment(n)\%HI\%isd), min(ieq+2,obc\%segment(n)\%HI\%ied)}
\DoxyCodeLine{338             \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{339               vh\_center(i,j) = g\%dx\_Cv(i,j) * v(i,j,k) * h(i,j,k)}
\DoxyCodeLine{340             \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{341               vh\_center(i,j) = g\%dx\_Cv(i,j) * v(i,j,k) * h(i,j+1,k)}
\DoxyCodeLine{342 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{343 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{344 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{345       \textcolor{keywordflow}{elseif} (obc\%segment(n)\%is\_E\_or\_W .and. (i >= isq-\/1) .and. (i <= ieq+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{346         \textcolor{keywordflow}{if} (obc\%zero\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=obc\%segment(n)\%HI\%JsdB,obc\%segment(n)\%HI\%JedB}
\DoxyCodeLine{347           dvdx(i,j) = 0. ; dudy(i,j) = 0.}
\DoxyCodeLine{348 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{349         \textcolor{keywordflow}{if} (obc\%freeslip\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=obc\%segment(n)\%HI\%JsdB,obc\%segment(n)\%HI\%JedB}
\DoxyCodeLine{350           dvdx(i,j) = 0.}
\DoxyCodeLine{351 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{352         \textcolor{keywordflow}{if} (obc\%computed\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=obc\%segment(n)\%HI\%JsdB,obc\%segment(n)\%HI\%JedB}
\DoxyCodeLine{353           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{354             dvdx(i,j) = 2.0*(obc\%segment(n)\%tangential\_vel(i,j,k) -\/ v(i,j,k))*g\%dyCv(i,j)}
\DoxyCodeLine{355           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_W)}}
\DoxyCodeLine{356             dvdx(i,j) = 2.0*(v(i+1,j,k) -\/ obc\%segment(n)\%tangential\_vel(i,j,k))*g\%dyCv(i+1,j)}
\DoxyCodeLine{357 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{358 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{359         \textcolor{keywordflow}{if} (obc\%specified\_vorticity) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=obc\%segment(n)\%HI\%JsdB,obc\%segment(n)\%HI\%JedB}
\DoxyCodeLine{360           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{361             dvdx(i,j) = obc\%segment(n)\%tangential\_grad(i,j,k)*g\%dyCv(i,j)*g\%dxBu(i,j)}
\DoxyCodeLine{362           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_W)}}
\DoxyCodeLine{363             dvdx(i,j) = obc\%segment(n)\%tangential\_grad(i,j,k)*g\%dyCv(i+1,j)*g\%dxBu(i,j)}
\DoxyCodeLine{364 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{365 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{366 }
\DoxyCodeLine{367         \textcolor{comment}{! Project thicknesses across OBC points with a no-\/gradient condition.}}
\DoxyCodeLine{368         \textcolor{keywordflow}{do} j = max(jsq-\/1,obc\%segment(n)\%HI\%jsd), min(jeq+2,obc\%segment(n)\%HI\%jed)}
\DoxyCodeLine{369           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{370             harea\_u(i,j) = 0.5*(area\_h(i,j) + area\_h(i+1,j)) * h(i,j,k)}
\DoxyCodeLine{371           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_W)}}
\DoxyCodeLine{372             harea\_u(i,j) = 0.5*(area\_h(i,j) + area\_h(i+1,j)) * h(i+1,j,k)}
\DoxyCodeLine{373 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{374 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{375         \textcolor{keywordflow}{if} (cs\%Coriolis\_En\_Dis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{376           \textcolor{keywordflow}{do} j = max(jsq-\/1,obc\%segment(n)\%HI\%jsd), min(jeq+2,obc\%segment(n)\%HI\%jed)}
\DoxyCodeLine{377             \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{378               uh\_center(i,j) = g\%dy\_Cu(i,j) * u(i,j,k) * h(i,j,k)}
\DoxyCodeLine{379             \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_W)}}
\DoxyCodeLine{380               uh\_center(i,j) = g\%dy\_Cu(i,j) * u(i,j,k) * h(i+1,j,k)}
\DoxyCodeLine{381 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{382 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{383 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{384 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{385 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{386 }
\DoxyCodeLine{387     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{388       \textcolor{keywordflow}{if} (.not. obc\%segment(n)\%on\_pe) cycle}
\DoxyCodeLine{389       \textcolor{comment}{! Now project thicknesses across cell-\/corner points in the OBCs.  The two}}
\DoxyCodeLine{390       \textcolor{comment}{! projections have to occur in sequence and can not be combined easily.}}
\DoxyCodeLine{391       i = obc\%segment(n)\%HI\%IsdB ; j = obc\%segment(n)\%HI\%JsdB}
\DoxyCodeLine{392       \textcolor{keywordflow}{if} (obc\%segment(n)\%is\_N\_or\_S .and. (j >= jsq-\/1) .and. (j <= jeq+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{393         \textcolor{keywordflow}{do} i = max(isq-\/1,obc\%segment(n)\%HI\%IsdB), min(ieq+1,obc\%segment(n)\%HI\%IedB)}
\DoxyCodeLine{394           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{395             \textcolor{keywordflow}{if} (area\_h(i,j) + area\_h(i+1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{396               harea\_u(i,j+1) = harea\_u(i,j) * ((area\_h(i,j+1) + area\_h(i+1,j+1)) / \&}
\DoxyCodeLine{397                                                (area\_h(i,j) + area\_h(i+1,j)))}
\DoxyCodeLine{398             \textcolor{keywordflow}{else} ; harea\_u(i,j+1) = 0.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{399           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{400             \textcolor{keywordflow}{if} (area\_h(i,j+1) + area\_h(i+1,j+1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{401               harea\_u(i,j) = harea\_u(i,j+1) * ((area\_h(i,j) + area\_h(i+1,j)) / \&}
\DoxyCodeLine{402                                                (area\_h(i,j+1) + area\_h(i+1,j+1)))}
\DoxyCodeLine{403             \textcolor{keywordflow}{else} ; harea\_u(i,j) = 0.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{404 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{405 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{406       \textcolor{keywordflow}{elseif} (obc\%segment(n)\%is\_E\_or\_W .and. (i >= isq-\/1) .and. (i <= ieq+1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{407         \textcolor{keywordflow}{do} j = max(jsq-\/1,obc\%segment(n)\%HI\%JsdB), min(jeq+1,obc\%segment(n)\%HI\%JedB)}
\DoxyCodeLine{408           \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{409             \textcolor{keywordflow}{if} (area\_h(i,j) + area\_h(i,j+1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{410               harea\_v(i+1,j) = harea\_v(i,j) * ((area\_h(i+1,j) + area\_h(i+1,j+1)) / \&}
\DoxyCodeLine{411                                                (area\_h(i,j) + area\_h(i,j+1)))}
\DoxyCodeLine{412             \textcolor{keywordflow}{else} ; harea\_v(i+1,j) = 0.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{413           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_W)}}
\DoxyCodeLine{414             harea\_v(i,j) = 0.5 * (area\_h(i,j) + area\_h(i,j+1)) * h(i,j+1,k)}
\DoxyCodeLine{415             \textcolor{keywordflow}{if} (area\_h(i+1,j) + area\_h(i+1,j+1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{416               harea\_v(i,j) = harea\_v(i+1,j) * ((area\_h(i,j) + area\_h(i,j+1)) / \&}
\DoxyCodeLine{417                                                (area\_h(i+1,j) + area\_h(i+1,j+1)))}
\DoxyCodeLine{418             \textcolor{keywordflow}{else} ; harea\_v(i,j) = 0.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{419 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{420 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{421 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{422 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{423 }
\DoxyCodeLine{424     \textcolor{keywordflow}{do} j=jsq-\/1,jeq+1 ; \textcolor{keywordflow}{do} i=isq-\/1,ieq+1}
\DoxyCodeLine{425       \textcolor{keywordflow}{if} (cs\%no\_slip ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{426         relative\_vorticity = (2.0-\/g\%mask2dBu(i,j)) * (dvdx(i,j) -\/ dudy(i,j)) * g\%IareaBu(i,j)}
\DoxyCodeLine{427       \textcolor{keywordflow}{else}}
\DoxyCodeLine{428         relative\_vorticity = g\%mask2dBu(i,j) * (dvdx(i,j) -\/ dudy(i,j)) * g\%IareaBu(i,j)}
\DoxyCodeLine{429 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{430       absolute\_vorticity = g\%CoriolisBu(i,j) + relative\_vorticity}
\DoxyCodeLine{431       ih = 0.0}
\DoxyCodeLine{432       \textcolor{keywordflow}{if} (area\_q(i,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{433         harea\_q = (harea\_u(i,j) + harea\_u(i,j+1)) + (harea\_v(i,j) + harea\_v(i+1,j))}
\DoxyCodeLine{434         ih = area\_q(i,j) / (harea\_q + h\_neglect*area\_q(i,j))}
\DoxyCodeLine{435 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{436       q(i,j) = absolute\_vorticity * ih}
\DoxyCodeLine{437       abs\_vort(i,j) = absolute\_vorticity}
\DoxyCodeLine{438       ih\_q(i,j) = ih}
\DoxyCodeLine{439 }
\DoxyCodeLine{440       \textcolor{keywordflow}{if} (cs\%bound\_Coriolis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{441         fv1 = absolute\_vorticity * v(i+1,j,k)}
\DoxyCodeLine{442         fv2 = absolute\_vorticity * v(i,j,k)}
\DoxyCodeLine{443         fu1 = -\/absolute\_vorticity * u(i,j+1,k)}
\DoxyCodeLine{444         fu2 = -\/absolute\_vorticity * u(i,j,k)}
\DoxyCodeLine{445         \textcolor{keywordflow}{if} (fv1 > fv2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{446           max\_fvq(i,j) = fv1 ; min\_fvq(i,j) = fv2}
\DoxyCodeLine{447         \textcolor{keywordflow}{else}}
\DoxyCodeLine{448           max\_fvq(i,j) = fv2 ; min\_fvq(i,j) = fv1}
\DoxyCodeLine{449 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{450         \textcolor{keywordflow}{if} (fu1 > fu2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{451           max\_fuq(i,j) = fu1 ; min\_fuq(i,j) = fu2}
\DoxyCodeLine{452         \textcolor{keywordflow}{else}}
\DoxyCodeLine{453           max\_fuq(i,j) = fu2 ; min\_fuq(i,j) = fu1}
\DoxyCodeLine{454 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{455 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{456 }
\DoxyCodeLine{457       \textcolor{keywordflow}{if} (cs\%id\_rv > 0) rv(i,j,k) = relative\_vorticity}
\DoxyCodeLine{458       \textcolor{keywordflow}{if} (cs\%id\_PV > 0) pv(i,j,k) = q(i,j)}
\DoxyCodeLine{459       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%rv\_x\_v) .or. \textcolor{keyword}{associated}(ad\%rv\_x\_u)) \&}
\DoxyCodeLine{460         q2(i,j) = relative\_vorticity * ih}
\DoxyCodeLine{461 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{462 }
\DoxyCodeLine{463     \textcolor{comment}{!   a, b, c, and d are combinations of neighboring potential}}
\DoxyCodeLine{464     \textcolor{comment}{! vorticities which form the Arakawa and Hsu vorticity advection}}
\DoxyCodeLine{465     \textcolor{comment}{! scheme.  All are defined at u grid points.}}
\DoxyCodeLine{466 }
\DoxyCodeLine{467     \textcolor{keywordflow}{if} (cs\%Coriolis\_Scheme == arakawa\_hsu90) \textcolor{keywordflow}{then}}
\DoxyCodeLine{468       \textcolor{keywordflow}{do} j=jsq,jeq+1}
\DoxyCodeLine{469         \textcolor{keywordflow}{do} i=is-\/1,ieq}
\DoxyCodeLine{470           a(i,j) = (q(i,j) + (q(i+1,j) + q(i,j-\/1))) * c1\_12}
\DoxyCodeLine{471           d(i,j) = ((q(i,j) + q(i+1,j-\/1)) + q(i,j-\/1)) * c1\_12}
\DoxyCodeLine{472 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{473         \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{474           b(i,j) = (q(i,j) + (q(i-\/1,j) + q(i,j-\/1))) * c1\_12}
\DoxyCodeLine{475           c(i,j) = ((q(i,j) + q(i-\/1,j-\/1)) + q(i,j-\/1)) * c1\_12}
\DoxyCodeLine{476 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{477 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{478     \textcolor{keywordflow}{elseif} (cs\%Coriolis\_Scheme == arakawa\_lamb81) \textcolor{keywordflow}{then}}
\DoxyCodeLine{479       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{480         a(i-\/1,j) = (2.0*(q(i,j) + q(i-\/1,j-\/1)) + (q(i-\/1,j) + q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{481         d(i-\/1,j) = ((q(i,j) + q(i-\/1,j-\/1)) + 2.0*(q(i-\/1,j) + q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{482         b(i,j) =   ((q(i,j) + q(i-\/1,j-\/1)) + 2.0*(q(i-\/1,j) + q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{483         c(i,j) =   (2.0*(q(i,j) + q(i-\/1,j-\/1)) + (q(i-\/1,j) + q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{484         ep\_u(i,j) = ((q(i,j) -\/ q(i-\/1,j-\/1)) + (q(i-\/1,j) -\/ q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{485         ep\_v(i,j) = (-\/(q(i,j) -\/ q(i-\/1,j-\/1)) + (q(i-\/1,j) -\/ q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{486 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{487     \textcolor{keywordflow}{elseif} (cs\%Coriolis\_Scheme == al\_blend) \textcolor{keywordflow}{then}}
\DoxyCodeLine{488       fe\_m2 = cs\%F\_eff\_max\_blend -\/ 2.0}
\DoxyCodeLine{489       rat\_lin = 1.5 * fe\_m2 / max(cs\%wt\_lin\_blend, 1.0e-\/16)}
\DoxyCodeLine{490 }
\DoxyCodeLine{491       \textcolor{comment}{! This allows the code to always give Sadourny Energy}}
\DoxyCodeLine{492       \textcolor{keywordflow}{if} (cs\%F\_eff\_max\_blend <= 2.0) \textcolor{keywordflow}{then} ; fe\_m2 = -\/1. ; rat\_lin = -\/1.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{493 }
\DoxyCodeLine{494       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{495         min\_ihq = min(ih\_q(i-\/1,j-\/1), ih\_q(i,j-\/1), ih\_q(i-\/1,j), ih\_q(i,j))}
\DoxyCodeLine{496         max\_ihq = max(ih\_q(i-\/1,j-\/1), ih\_q(i,j-\/1), ih\_q(i-\/1,j), ih\_q(i,j))}
\DoxyCodeLine{497         rat\_m1 = 1.0e15}
\DoxyCodeLine{498         \textcolor{keywordflow}{if} (max\_ihq < 1.0e15*min\_ihq) rat\_m1 = max\_ihq / min\_ihq -\/ 1.0}
\DoxyCodeLine{499         \textcolor{comment}{! The weights used here are designed to keep the effective Coriolis}}
\DoxyCodeLine{500         \textcolor{comment}{! acceleration from any one point on its neighbors within a factor}}
\DoxyCodeLine{501         \textcolor{comment}{! of F\_eff\_max.  The minimum permitted value is 2 (the factor for}}
\DoxyCodeLine{502         \textcolor{comment}{! Sadourny's energy conserving scheme).}}
\DoxyCodeLine{503 }
\DoxyCodeLine{504         \textcolor{comment}{! Determine the relative weights of Arakawa \& Lamb vs. Arakawa and Hsu.}}
\DoxyCodeLine{505         \textcolor{keywordflow}{if} (rat\_m1 <= fe\_m2) \textcolor{keywordflow}{then} ; al\_wt = 1.0}
\DoxyCodeLine{506         \textcolor{keywordflow}{elseif} (rat\_m1 < 1.5*fe\_m2) \textcolor{keywordflow}{then} ; al\_wt = 3.0*fe\_m2 / rat\_m1 -\/ 2.0}
\DoxyCodeLine{507         \textcolor{keywordflow}{else} ; al\_wt = 0.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{508 }
\DoxyCodeLine{509         \textcolor{comment}{! Determine the relative weights of Sadourny Energy vs. the other two.}}
\DoxyCodeLine{510         \textcolor{keywordflow}{if} (rat\_m1 <= 1.5*fe\_m2) \textcolor{keywordflow}{then} ; sad\_wt = 0.0}
\DoxyCodeLine{511         \textcolor{keywordflow}{elseif} (rat\_m1 <= rat\_lin) \textcolor{keywordflow}{then}}
\DoxyCodeLine{512           sad\_wt = 1.0 -\/ (1.5*fe\_m2) / rat\_m1}
\DoxyCodeLine{513         \textcolor{keywordflow}{elseif} (rat\_m1 < 2.0*rat\_lin) \textcolor{keywordflow}{then}}
\DoxyCodeLine{514           sad\_wt = 1.0 -\/ (cs\%wt\_lin\_blend / rat\_lin) * (rat\_m1 -\/ 2.0*rat\_lin)}
\DoxyCodeLine{515         \textcolor{keywordflow}{else} ; sad\_wt = 1.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{516 }
\DoxyCodeLine{517         a(i-\/1,j) = sad\_wt * 0.25 * q(i-\/1,j) + (1.0 -\/ sad\_wt) * \&}
\DoxyCodeLine{518                    ( ((2.0-\/al\_wt)* q(i-\/1,j) + al\_wt*q(i,j-\/1)) + \&}
\DoxyCodeLine{519                       2.0 * (q(i,j) + q(i-\/1,j-\/1)) ) * c1\_24}
\DoxyCodeLine{520         d(i-\/1,j) = sad\_wt * 0.25 * q(i-\/1,j-\/1) + (1.0 -\/ sad\_wt) * \&}
\DoxyCodeLine{521                    ( ((2.0-\/al\_wt)* q(i-\/1,j-\/1) + al\_wt*q(i,j)) + \&}
\DoxyCodeLine{522                       2.0 * (q(i-\/1,j) + q(i,j-\/1)) ) * c1\_24}
\DoxyCodeLine{523         b(i,j) =   sad\_wt * 0.25 * q(i,j) + (1.0 -\/ sad\_wt) * \&}
\DoxyCodeLine{524                    ( ((2.0-\/al\_wt)* q(i,j) + al\_wt*q(i-\/1,j-\/1)) + \&}
\DoxyCodeLine{525                       2.0 * (q(i-\/1,j) + q(i,j-\/1)) ) * c1\_24}
\DoxyCodeLine{526         c(i,j) =   sad\_wt * 0.25 * q(i,j-\/1) + (1.0 -\/ sad\_wt) * \&}
\DoxyCodeLine{527                    ( ((2.0-\/al\_wt)* q(i,j-\/1) + al\_wt*q(i-\/1,j)) + \&}
\DoxyCodeLine{528                       2.0 * (q(i,j) + q(i-\/1,j-\/1)) ) * c1\_24}
\DoxyCodeLine{529         ep\_u(i,j) = al\_wt  * ((q(i,j) -\/ q(i-\/1,j-\/1)) + (q(i-\/1,j) -\/ q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{530         ep\_v(i,j) = al\_wt * (-\/(q(i,j) -\/ q(i-\/1,j-\/1)) + (q(i-\/1,j) -\/ q(i,j-\/1))) * c1\_24}
\DoxyCodeLine{531 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{532 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{533 }
\DoxyCodeLine{534     \textcolor{keywordflow}{if} (cs\%Coriolis\_En\_Dis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{535     \textcolor{comment}{!  c1 = 1.0-\/1.5*RANGE ; c2 = 1.0-\/RANGE ; c3 = 2.0 ; slope = 0.5}}
\DoxyCodeLine{536       c1 = 1.0-\/1.5*0.5 ; c2 = 1.0-\/0.5 ; c3 = 2.0 ; slope = 0.5}
\DoxyCodeLine{537 }
\DoxyCodeLine{538       \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=is-\/1,ie}
\DoxyCodeLine{539         uhc = uh\_center(i,j)}
\DoxyCodeLine{540         uhm = uh(i,j,k)}
\DoxyCodeLine{541         \textcolor{comment}{! This sometimes matters with some types of open boundary conditions.}}
\DoxyCodeLine{542         \textcolor{keywordflow}{if} (g\%dy\_Cu(i,j) == 0.0) uhc = uhm}
\DoxyCodeLine{543 }
\DoxyCodeLine{544         \textcolor{keywordflow}{if} (abs(uhc) < 0.1*abs(uhm)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{545           uhm = 10.0*uhc}
\DoxyCodeLine{546         \textcolor{keywordflow}{elseif} (abs(uhc) > c1*abs(uhm)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{547           \textcolor{keywordflow}{if} (abs(uhc) < c2*abs(uhm)) \textcolor{keywordflow}{then} ; uhc = (3.0*uhc+(1.0-\/c2*3.0)*uhm)}
\DoxyCodeLine{548           \textcolor{keywordflow}{elseif} (abs(uhc) <= c3*abs(uhm)) \textcolor{keywordflow}{then} ; uhc = uhm}
\DoxyCodeLine{549           \textcolor{keywordflow}{else} ; uhc = slope*uhc+(1.0-\/c3*slope)*uhm}
\DoxyCodeLine{550 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{551 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{552 }
\DoxyCodeLine{553         \textcolor{keywordflow}{if} (uhc > uhm) \textcolor{keywordflow}{then}}
\DoxyCodeLine{554           uh\_min(i,j) = uhm ; uh\_max(i,j) = uhc}
\DoxyCodeLine{555         \textcolor{keywordflow}{else}}
\DoxyCodeLine{556           uh\_max(i,j) = uhm ; uh\_min(i,j) = uhc}
\DoxyCodeLine{557 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{558 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{559       \textcolor{keywordflow}{do} j=js-\/1,je ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{560         vhc = vh\_center(i,j)}
\DoxyCodeLine{561         vhm = vh(i,j,k)}
\DoxyCodeLine{562         \textcolor{comment}{! This sometimes matters with some types of open boundary conditions.}}
\DoxyCodeLine{563         \textcolor{keywordflow}{if} (g\%dx\_Cv(i,j) == 0.0) vhc = vhm}
\DoxyCodeLine{564 }
\DoxyCodeLine{565         \textcolor{keywordflow}{if} (abs(vhc) < 0.1*abs(vhm)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{566           vhm = 10.0*vhc}
\DoxyCodeLine{567         \textcolor{keywordflow}{elseif} (abs(vhc) > c1*abs(vhm)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{568           \textcolor{keywordflow}{if} (abs(vhc) < c2*abs(vhm)) \textcolor{keywordflow}{then} ; vhc = (3.0*vhc+(1.0-\/c2*3.0)*vhm)}
\DoxyCodeLine{569           \textcolor{keywordflow}{elseif} (abs(vhc) <= c3*abs(vhm)) \textcolor{keywordflow}{then} ; vhc = vhm}
\DoxyCodeLine{570           \textcolor{keywordflow}{else} ; vhc = slope*vhc+(1.0-\/c3*slope)*vhm}
\DoxyCodeLine{571 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{572 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{573 }
\DoxyCodeLine{574         \textcolor{keywordflow}{if} (vhc > vhm) \textcolor{keywordflow}{then}}
\DoxyCodeLine{575           vh\_min(i,j) = vhm ; vh\_max(i,j) = vhc}
\DoxyCodeLine{576         \textcolor{keywordflow}{else}}
\DoxyCodeLine{577           vh\_max(i,j) = vhm ; vh\_min(i,j) = vhc}
\DoxyCodeLine{578 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{579 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{580 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{581 }
\DoxyCodeLine{582     \textcolor{comment}{! Calculate KE and the gradient of KE}}
\DoxyCodeLine{583     \textcolor{keyword}{call }gradke(u, v, h, ke, kex, key, k, obc, g, us, cs)}
\DoxyCodeLine{584 }
\DoxyCodeLine{585     \textcolor{comment}{! Calculate the tendencies of zonal velocity due to the Coriolis}}
\DoxyCodeLine{586     \textcolor{comment}{! force and momentum advection.  On a Cartesian grid, this is}}
\DoxyCodeLine{587     \textcolor{comment}{!     CAu =  q * vh -\/ d(KE)/dx.}}
\DoxyCodeLine{588     \textcolor{keywordflow}{if} (cs\%Coriolis\_Scheme == sadourny75\_energy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{589       \textcolor{keywordflow}{if} (cs\%Coriolis\_En\_Dis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{590         \textcolor{comment}{! Energy dissipating biased scheme, Hallberg 200x}}
\DoxyCodeLine{591         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{592           \textcolor{keywordflow}{if} (q(i,j)*u(i,j,k) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{593             temp1 = q(i,j) * ( (vh\_max(i,j)+vh\_max(i+1,j)) \&}
\DoxyCodeLine{594                              + (vh\_min(i,j)+vh\_min(i+1,j)) )*0.5}
\DoxyCodeLine{595           \textcolor{keywordflow}{elseif} (q(i,j)*u(i,j,k) < 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{596             temp1 = q(i,j) * (vh\_max(i,j)+vh\_max(i+1,j))}
\DoxyCodeLine{597           \textcolor{keywordflow}{else}}
\DoxyCodeLine{598             temp1 = q(i,j) * (vh\_min(i,j)+vh\_min(i+1,j))}
\DoxyCodeLine{599 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{600           \textcolor{keywordflow}{if} (q(i,j-\/1)*u(i,j,k) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{601             temp2 = q(i,j-\/1) * ( (vh\_max(i,j-\/1)+vh\_max(i+1,j-\/1)) \&}
\DoxyCodeLine{602                                + (vh\_min(i,j-\/1)+vh\_min(i+1,j-\/1)) )*0.5}
\DoxyCodeLine{603           \textcolor{keywordflow}{elseif} (q(i,j-\/1)*u(i,j,k) < 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{604             temp2 = q(i,j-\/1) * (vh\_max(i,j-\/1)+vh\_max(i+1,j-\/1))}
\DoxyCodeLine{605           \textcolor{keywordflow}{else}}
\DoxyCodeLine{606             temp2 = q(i,j-\/1) * (vh\_min(i,j-\/1)+vh\_min(i+1,j-\/1))}
\DoxyCodeLine{607 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{608           cau(i,j,k) = 0.25 * g\%IdxCu(i,j) * (temp1 + temp2)}
\DoxyCodeLine{609 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{610       \textcolor{keywordflow}{else}}
\DoxyCodeLine{611         \textcolor{comment}{! Energy conserving scheme, Sadourny 1975}}
\DoxyCodeLine{612         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{613           cau(i,j,k) = 0.25 * \&}
\DoxyCodeLine{614             (q(i,j) * (vh(i+1,j,k) + vh(i,j,k)) + \&}
\DoxyCodeLine{615              q(i,j-\/1) * (vh(i,j-\/1,k) + vh(i+1,j-\/1,k))) * g\%IdxCu(i,j)}
\DoxyCodeLine{616 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{617 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{618     \textcolor{keywordflow}{elseif} (cs\%Coriolis\_Scheme == sadourny75\_enstro) \textcolor{keywordflow}{then}}
\DoxyCodeLine{619       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{620         cau(i,j,k) = 0.125 * (g\%IdxCu(i,j) * (q(i,j) + q(i,j-\/1))) * \&}
\DoxyCodeLine{621                      ((vh(i+1,j,k) + vh(i,j,k)) + (vh(i,j-\/1,k) + vh(i+1,j-\/1,k)))}
\DoxyCodeLine{622 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{623     \textcolor{keywordflow}{elseif} ((cs\%Coriolis\_Scheme == arakawa\_hsu90) .or. \&}
\DoxyCodeLine{624             (cs\%Coriolis\_Scheme == arakawa\_lamb81) .or. \&}
\DoxyCodeLine{625             (cs\%Coriolis\_Scheme == al\_blend)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{626       \textcolor{comment}{! (Global) Energy and (Local) Enstrophy conserving, Arakawa \& Hsu 1990}}
\DoxyCodeLine{627       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{628         cau(i,j,k) = ((a(i,j) * vh(i+1,j,k) +  c(i,j) * vh(i,j-\/1,k))  + \&}
\DoxyCodeLine{629                       (b(i,j) * vh(i,j,k) +  d(i,j) * vh(i+1,j-\/1,k))) * g\%IdxCu(i,j)}
\DoxyCodeLine{630 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{631     \textcolor{keywordflow}{elseif} (cs\%Coriolis\_Scheme == robust\_enstro) \textcolor{keywordflow}{then}}
\DoxyCodeLine{632       \textcolor{comment}{! An enstrophy conserving scheme robust to vanishing layers}}
\DoxyCodeLine{633       \textcolor{comment}{! Note: Heffs are in lieu of h\_at\_v that should be returned by the}}
\DoxyCodeLine{634       \textcolor{comment}{!       continuity solver. AJA}}
\DoxyCodeLine{635       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{636         heff1 = abs(vh(i,j,k) * g\%IdxCv(i,j)) / (eps\_vel+abs(v(i,j,k)))}
\DoxyCodeLine{637         heff1 = max(heff1, min(h(i,j,k),h(i,j+1,k)))}
\DoxyCodeLine{638         heff1 = min(heff1, max(h(i,j,k),h(i,j+1,k)))}
\DoxyCodeLine{639         heff2 = abs(vh(i,j-\/1,k) * g\%IdxCv(i,j-\/1)) / (eps\_vel+abs(v(i,j-\/1,k)))}
\DoxyCodeLine{640         heff2 = max(heff2, min(h(i,j-\/1,k),h(i,j,k)))}
\DoxyCodeLine{641         heff2 = min(heff2, max(h(i,j-\/1,k),h(i,j,k)))}
\DoxyCodeLine{642         heff3 = abs(vh(i+1,j,k) * g\%IdxCv(i+1,j)) / (eps\_vel+abs(v(i+1,j,k)))}
\DoxyCodeLine{643         heff3 = max(heff3, min(h(i+1,j,k),h(i+1,j+1,k)))}
\DoxyCodeLine{644         heff3 = min(heff3, max(h(i+1,j,k),h(i+1,j+1,k)))}
\DoxyCodeLine{645         heff4 = abs(vh(i+1,j-\/1,k) * g\%IdxCv(i+1,j-\/1)) / (eps\_vel+abs(v(i+1,j-\/1,k)))}
\DoxyCodeLine{646         heff4 = max(heff4, min(h(i+1,j-\/1,k),h(i+1,j,k)))}
\DoxyCodeLine{647         heff4 = min(heff4, max(h(i+1,j-\/1,k),h(i+1,j,k)))}
\DoxyCodeLine{648         \textcolor{keywordflow}{if} (cs\%PV\_Adv\_Scheme == pv\_adv\_centered) \textcolor{keywordflow}{then}}
\DoxyCodeLine{649           cau(i,j,k) = 0.5*(abs\_vort(i,j)+abs\_vort(i,j-\/1)) * \&}
\DoxyCodeLine{650                        ((vh(i,j,k) + vh(i+1,j-\/1,k)) + (vh(i,j-\/1,k) + vh(i+1,j,k)) ) /  \&}
\DoxyCodeLine{651                        (h\_tiny + ((heff1+heff4) + (heff2+heff3)) ) * g\%IdxCu(i,j)}
\DoxyCodeLine{652         \textcolor{keywordflow}{elseif} (cs\%PV\_Adv\_Scheme == pv\_adv\_upwind1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{653           vheff = ((vh(i,j,k) + vh(i+1,j-\/1,k)) + (vh(i,j-\/1,k) + vh(i+1,j,k)) )}
\DoxyCodeLine{654           qvheff = 0.5*( (abs\_vort(i,j)+abs\_vort(i,j-\/1))*vheff \&}
\DoxyCodeLine{655                         -\/(abs\_vort(i,j)-\/abs\_vort(i,j-\/1))*abs(vheff) )}
\DoxyCodeLine{656           cau(i,j,k) = (qvheff / ( h\_tiny + ((heff1+heff4) + (heff2+heff3)) ) ) * g\%IdxCu(i,j)}
\DoxyCodeLine{657 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{658 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{659 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{660     \textcolor{comment}{! Add in the additonal terms with Arakawa \& Lamb.}}
\DoxyCodeLine{661     \textcolor{keywordflow}{if} ((cs\%Coriolis\_Scheme == arakawa\_lamb81) .or. \&}
\DoxyCodeLine{662         (cs\%Coriolis\_Scheme == al\_blend)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{663       cau(i,j,k) = cau(i,j,k) + \&}
\DoxyCodeLine{664             (ep\_u(i,j)*uh(i-\/1,j,k) -\/ ep\_u(i+1,j)*uh(i+1,j,k)) * g\%IdxCu(i,j)}
\DoxyCodeLine{665 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{666 }
\DoxyCodeLine{667 }
\DoxyCodeLine{668     \textcolor{keywordflow}{if} (cs\%bound\_Coriolis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{669       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{670         max\_fv = max(max\_fvq(i,j), max\_fvq(i,j-\/1))}
\DoxyCodeLine{671         min\_fv = min(min\_fvq(i,j), min\_fvq(i,j-\/1))}
\DoxyCodeLine{672        \textcolor{comment}{! CAu(I,j,k) = min( CAu(I,j,k), max\_fv )}}
\DoxyCodeLine{673        \textcolor{comment}{! CAu(I,j,k) = max( CAu(I,j,k), min\_fv )}}
\DoxyCodeLine{674         \textcolor{keywordflow}{if} (cau(i,j,k) > max\_fv) \textcolor{keywordflow}{then}}
\DoxyCodeLine{675             cau(i,j,k) = max\_fv}
\DoxyCodeLine{676         \textcolor{keywordflow}{else}}
\DoxyCodeLine{677           \textcolor{keywordflow}{if} (cau(i,j,k) < min\_fv) cau(i,j,k) = min\_fv}
\DoxyCodeLine{678 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{679 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{680 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{681 }
\DoxyCodeLine{682     \textcolor{comment}{! Term -\/ d(KE)/dx.}}
\DoxyCodeLine{683     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{684       cau(i,j,k) = cau(i,j,k) -\/ kex(i,j)}
\DoxyCodeLine{685       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%gradKEu)) ad\%gradKEu(i,j,k) = -\/kex(i,j)}
\DoxyCodeLine{686 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{687 }
\DoxyCodeLine{688 }
\DoxyCodeLine{689     \textcolor{comment}{! Calculate the tendencies of meridional velocity due to the Coriolis}}
\DoxyCodeLine{690     \textcolor{comment}{! force and momentum advection.  On a Cartesian grid, this is}}
\DoxyCodeLine{691     \textcolor{comment}{!     CAv = -\/ q * uh -\/ d(KE)/dy.}}
\DoxyCodeLine{692     \textcolor{keywordflow}{if} (cs\%Coriolis\_Scheme == sadourny75\_energy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{693       \textcolor{keywordflow}{if} (cs\%Coriolis\_En\_Dis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{694         \textcolor{comment}{! Energy dissipating biased scheme, Hallberg 200x}}
\DoxyCodeLine{695         \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{696           \textcolor{keywordflow}{if} (q(i-\/1,j)*v(i,j,k) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{697             temp1 = q(i-\/1,j) * ( (uh\_max(i-\/1,j)+uh\_max(i-\/1,j+1)) \&}
\DoxyCodeLine{698                                + (uh\_min(i-\/1,j)+uh\_min(i-\/1,j+1)) )*0.5}
\DoxyCodeLine{699           \textcolor{keywordflow}{elseif} (q(i-\/1,j)*v(i,j,k) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{700             temp1 = q(i-\/1,j) * (uh\_max(i-\/1,j)+uh\_max(i-\/1,j+1))}
\DoxyCodeLine{701           \textcolor{keywordflow}{else}}
\DoxyCodeLine{702             temp1 = q(i-\/1,j) * (uh\_min(i-\/1,j)+uh\_min(i-\/1,j+1))}
\DoxyCodeLine{703 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{704           \textcolor{keywordflow}{if} (q(i,j)*v(i,j,k) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{705             temp2 = q(i,j) * ( (uh\_max(i,j)+uh\_max(i,j+1)) \&}
\DoxyCodeLine{706                              + (uh\_min(i,j)+uh\_min(i,j+1)) )*0.5}
\DoxyCodeLine{707           \textcolor{keywordflow}{elseif} (q(i,j)*v(i,j,k) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{708             temp2 = q(i,j) * (uh\_max(i,j)+uh\_max(i,j+1))}
\DoxyCodeLine{709           \textcolor{keywordflow}{else}}
\DoxyCodeLine{710             temp2 = q(i,j) * (uh\_min(i,j)+uh\_min(i,j+1))}
\DoxyCodeLine{711 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{712           cav(i,j,k) = -\/0.25 * g\%IdyCv(i,j) * (temp1 + temp2)}
\DoxyCodeLine{713 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{714       \textcolor{keywordflow}{else}}
\DoxyCodeLine{715         \textcolor{comment}{! Energy conserving scheme, Sadourny 1975}}
\DoxyCodeLine{716         \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{717           cav(i,j,k) = -\/ 0.25* \&}
\DoxyCodeLine{718               (q(i-\/1,j)*(uh(i-\/1,j,k) + uh(i-\/1,j+1,k)) + \&}
\DoxyCodeLine{719                q(i,j)*(uh(i,j,k) + uh(i,j+1,k))) * g\%IdyCv(i,j)}
\DoxyCodeLine{720 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{721 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{722     \textcolor{keywordflow}{elseif} (cs\%Coriolis\_Scheme == sadourny75\_enstro) \textcolor{keywordflow}{then}}
\DoxyCodeLine{723       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{724         cav(i,j,k) = -\/0.125 * (g\%IdyCv(i,j) * (q(i-\/1,j) + q(i,j))) * \&}
\DoxyCodeLine{725                      ((uh(i-\/1,j,k) + uh(i-\/1,j+1,k)) + (uh(i,j,k) + uh(i,j+1,k)))}
\DoxyCodeLine{726 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{727     \textcolor{keywordflow}{elseif} ((cs\%Coriolis\_Scheme == arakawa\_hsu90) .or. \&}
\DoxyCodeLine{728             (cs\%Coriolis\_Scheme == arakawa\_lamb81) .or. \&}
\DoxyCodeLine{729             (cs\%Coriolis\_Scheme == al\_blend)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{730       \textcolor{comment}{! (Global) Energy and (Local) Enstrophy conserving, Arakawa \& Hsu 1990}}
\DoxyCodeLine{731       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{732         cav(i,j,k) = -\/ ((a(i-\/1,j)   * uh(i-\/1,j,k) + \&}
\DoxyCodeLine{733                          c(i,j+1)   * uh(i,j+1,k))  \&}
\DoxyCodeLine{734                       + (b(i,j)     * uh(i,j,k) +   \&}
\DoxyCodeLine{735                          d(i-\/1,j+1) * uh(i-\/1,j+1,k))) * g\%IdyCv(i,j)}
\DoxyCodeLine{736 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{737     \textcolor{keywordflow}{elseif} (cs\%Coriolis\_Scheme == robust\_enstro) \textcolor{keywordflow}{then}}
\DoxyCodeLine{738       \textcolor{comment}{! An enstrophy conserving scheme robust to vanishing layers}}
\DoxyCodeLine{739       \textcolor{comment}{! Note: Heffs are in lieu of h\_at\_u that should be returned by the}}
\DoxyCodeLine{740       \textcolor{comment}{!       continuity solver. AJA}}
\DoxyCodeLine{741       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{742         heff1 = abs(uh(i,j,k) * g\%IdyCu(i,j)) / (eps\_vel+abs(u(i,j,k)))}
\DoxyCodeLine{743         heff1 = max(heff1, min(h(i,j,k),h(i+1,j,k)))}
\DoxyCodeLine{744         heff1 = min(heff1, max(h(i,j,k),h(i+1,j,k)))}
\DoxyCodeLine{745         heff2 = abs(uh(i-\/1,j,k) * g\%IdyCu(i-\/1,j)) / (eps\_vel+abs(u(i-\/1,j,k)))}
\DoxyCodeLine{746         heff2 = max(heff2, min(h(i-\/1,j,k),h(i,j,k)))}
\DoxyCodeLine{747         heff2 = min(heff2, max(h(i-\/1,j,k),h(i,j,k)))}
\DoxyCodeLine{748         heff3 = abs(uh(i,j+1,k) * g\%IdyCu(i,j+1)) / (eps\_vel+abs(u(i,j+1,k)))}
\DoxyCodeLine{749         heff3 = max(heff3, min(h(i,j+1,k),h(i+1,j+1,k)))}
\DoxyCodeLine{750         heff3 = min(heff3, max(h(i,j+1,k),h(i+1,j+1,k)))}
\DoxyCodeLine{751         heff4 = abs(uh(i-\/1,j+1,k) * g\%IdyCu(i-\/1,j+1)) / (eps\_vel+abs(u(i-\/1,j+1,k)))}
\DoxyCodeLine{752         heff4 = max(heff4, min(h(i-\/1,j+1,k),h(i,j+1,k)))}
\DoxyCodeLine{753         heff4 = min(heff4, max(h(i-\/1,j+1,k),h(i,j+1,k)))}
\DoxyCodeLine{754         \textcolor{keywordflow}{if} (cs\%PV\_Adv\_Scheme == pv\_adv\_centered) \textcolor{keywordflow}{then}}
\DoxyCodeLine{755           cav(i,j,k) = -\/ 0.5*(abs\_vort(i,j)+abs\_vort(i-\/1,j)) * \&}
\DoxyCodeLine{756                          ((uh(i  ,j  ,k)+uh(i-\/1,j+1,k)) +      \&}
\DoxyCodeLine{757                           (uh(i-\/1,j  ,k)+uh(i  ,j+1,k)) ) /    \&}
\DoxyCodeLine{758                       (h\_tiny + ((heff1+heff4) +(heff2+heff3)) ) * g\%IdyCv(i,j)}
\DoxyCodeLine{759         \textcolor{keywordflow}{elseif} (cs\%PV\_Adv\_Scheme == pv\_adv\_upwind1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{760           uheff = ((uh(i  ,j  ,k)+uh(i-\/1,j+1,k)) +      \&}
\DoxyCodeLine{761                    (uh(i-\/1,j  ,k)+uh(i  ,j+1,k)) )}
\DoxyCodeLine{762           quheff = 0.5*( (abs\_vort(i,j)+abs\_vort(i-\/1,j))*uheff \&}
\DoxyCodeLine{763                         -\/(abs\_vort(i,j)-\/abs\_vort(i-\/1,j))*abs(uheff) )}
\DoxyCodeLine{764           cav(i,j,k) = -\/ quheff / \&}
\DoxyCodeLine{765                        (h\_tiny + ((heff1+heff4) +(heff2+heff3)) ) * g\%IdyCv(i,j)}
\DoxyCodeLine{766 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{767 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{768 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{769     \textcolor{comment}{! Add in the additonal terms with Arakawa \& Lamb.}}
\DoxyCodeLine{770     \textcolor{keywordflow}{if} ((cs\%Coriolis\_Scheme == arakawa\_lamb81) .or. \&}
\DoxyCodeLine{771         (cs\%Coriolis\_Scheme == al\_blend)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{772       cav(i,j,k) = cav(i,j,k) + \&}
\DoxyCodeLine{773             (ep\_v(i,j)*vh(i,j-\/1,k) -\/ ep\_v(i,j+1)*vh(i,j+1,k)) * g\%IdyCv(i,j)}
\DoxyCodeLine{774 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{775 }
\DoxyCodeLine{776     \textcolor{keywordflow}{if} (cs\%bound\_Coriolis) \textcolor{keywordflow}{then}}
\DoxyCodeLine{777       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{778         max\_fu = max(max\_fuq(i,j),max\_fuq(i-\/1,j))}
\DoxyCodeLine{779         min\_fu = min(min\_fuq(i,j),min\_fuq(i-\/1,j))}
\DoxyCodeLine{780         \textcolor{keywordflow}{if} (cav(i,j,k) > max\_fu) \textcolor{keywordflow}{then}}
\DoxyCodeLine{781             cav(i,j,k) = max\_fu}
\DoxyCodeLine{782         \textcolor{keywordflow}{else}}
\DoxyCodeLine{783           \textcolor{keywordflow}{if} (cav(i,j,k) < min\_fu) cav(i,j,k) = min\_fu}
\DoxyCodeLine{784 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{785 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{786 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{787 }
\DoxyCodeLine{788     \textcolor{comment}{! Term -\/ d(KE)/dy.}}
\DoxyCodeLine{789     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{790       cav(i,j,k) = cav(i,j,k) -\/ key(i,j)}
\DoxyCodeLine{791       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%gradKEv)) ad\%gradKEv(i,j,k) = -\/key(i,j)}
\DoxyCodeLine{792 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{793 }
\DoxyCodeLine{794     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%rv\_x\_u) .or. \textcolor{keyword}{associated}(ad\%rv\_x\_v)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{795       \textcolor{comment}{! Calculate the Coriolis-\/like acceleration due to relative vorticity.}}
\DoxyCodeLine{796       \textcolor{keywordflow}{if} (cs\%Coriolis\_Scheme == sadourny75\_energy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{797         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%rv\_x\_u)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{798           \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{799             ad\%rv\_x\_u(i,j,k) = -\/ 0.25* \&}
\DoxyCodeLine{800               (q2(i-\/1,j)*(uh(i-\/1,j,k) + uh(i-\/1,j+1,k)) + \&}
\DoxyCodeLine{801                q2(i,j)*(uh(i,j,k) + uh(i,j+1,k))) * g\%IdyCv(i,j)}
\DoxyCodeLine{802 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{803 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{804 }
\DoxyCodeLine{805         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%rv\_x\_v)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{806           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{807             ad\%rv\_x\_v(i,j,k) = 0.25 * \&}
\DoxyCodeLine{808               (q2(i,j) * (vh(i+1,j,k) + vh(i,j,k)) + \&}
\DoxyCodeLine{809                q2(i,j-\/1) * (vh(i,j-\/1,k) + vh(i+1,j-\/1,k))) * g\%IdxCu(i,j)}
\DoxyCodeLine{810 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{811 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{812       \textcolor{keywordflow}{else}}
\DoxyCodeLine{813         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%rv\_x\_u)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{814           \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{815             ad\%rv\_x\_u(i,j,k) = -\/g\%IdyCv(i,j) * c1\_12 * \&}
\DoxyCodeLine{816               ((q2(i,j) + q2(i-\/1,j) + q2(i-\/1,j-\/1)) * uh(i-\/1,j,k) + \&}
\DoxyCodeLine{817                (q2(i-\/1,j) + q2(i,j) + q2(i,j-\/1)) * uh(i,j,k) + \&}
\DoxyCodeLine{818                (q2(i-\/1,j) + q2(i,j+1) + q2(i,j)) * uh(i,j+1,k) + \&}
\DoxyCodeLine{819                (q2(i,j) + q2(i-\/1,j+1) + q2(i-\/1,j)) * uh(i-\/1,j+1,k))}
\DoxyCodeLine{820 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{821 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{822 }
\DoxyCodeLine{823         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ad\%rv\_x\_v)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{824           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{825             ad\%rv\_x\_v(i,j,k) = g\%IdxCu(i,j) * c1\_12 * \&}
\DoxyCodeLine{826               ((q2(i+1,j) + q2(i,j) + q2(i,j-\/1)) * vh(i+1,j,k) + \&}
\DoxyCodeLine{827                (q2(i-\/1,j) + q2(i,j) + q2(i,j-\/1)) * vh(i,j,k) + \&}
\DoxyCodeLine{828                (q2(i-\/1,j-\/1) + q2(i,j) + q2(i,j-\/1)) * vh(i,j-\/1,k) + \&}
\DoxyCodeLine{829                (q2(i+1,j-\/1) + q2(i,j) + q2(i,j-\/1)) * vh(i+1,j-\/1,k))}
\DoxyCodeLine{830 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{831 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{832 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{833 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{834 }
\DoxyCodeLine{835 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! k-\/loop.}}
\DoxyCodeLine{836 }
\DoxyCodeLine{837   \textcolor{comment}{! Here the various Coriolis-\/related derived quantities are offered for averaging.}}
\DoxyCodeLine{838   \textcolor{keywordflow}{if} (query\_averaging\_enabled(cs\%diag)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{839     \textcolor{keywordflow}{if} (cs\%id\_rv > 0) \textcolor{keyword}{call }post\_data(cs\%id\_rv, rv, cs\%diag)}
\DoxyCodeLine{840     \textcolor{keywordflow}{if} (cs\%id\_PV > 0) \textcolor{keyword}{call }post\_data(cs\%id\_PV, pv, cs\%diag)}
\DoxyCodeLine{841     \textcolor{keywordflow}{if} (cs\%id\_gKEu>0) \textcolor{keyword}{call }post\_data(cs\%id\_gKEu, ad\%gradKEu, cs\%diag)}
\DoxyCodeLine{842     \textcolor{keywordflow}{if} (cs\%id\_gKEv>0) \textcolor{keyword}{call }post\_data(cs\%id\_gKEv, ad\%gradKEv, cs\%diag)}
\DoxyCodeLine{843     \textcolor{keywordflow}{if} (cs\%id\_rvxu > 0) \textcolor{keyword}{call }post\_data(cs\%id\_rvxu, ad\%rv\_x\_u, cs\%diag)}
\DoxyCodeLine{844     \textcolor{keywordflow}{if} (cs\%id\_rvxv > 0) \textcolor{keyword}{call }post\_data(cs\%id\_rvxv, ad\%rv\_x\_v, cs\%diag)}
\DoxyCodeLine{845 }
\DoxyCodeLine{846     \textcolor{comment}{! Diagnostics for terms multiplied by fractional thicknesses}}
\DoxyCodeLine{847 }
\DoxyCodeLine{848     \textcolor{comment}{! 3D diagnostics hf\_gKEu etc. are commented because there is no clarity on proper remapping grid option.}}
\DoxyCodeLine{849     \textcolor{comment}{! The code is retained for degugging purposes in the future.}}
\DoxyCodeLine{850     \textcolor{comment}{!if (CS\%id\_hf\_gKEu > 0) then}}
\DoxyCodeLine{851     \textcolor{comment}{!  allocate(hf\_gKEu(G\%IsdB:G\%IedB,G\%jsd:G\%jed,G\%ke))}}
\DoxyCodeLine{852     \textcolor{comment}{!  do k=1,nz ; do j=js,je ; do I=Isq,Ieq}}
\DoxyCodeLine{853     \textcolor{comment}{!    hf\_gKEu(I,j,k) = AD\%gradKEu(I,j,k) * AD\%diag\_hfrac\_u(I,j,k)}}
\DoxyCodeLine{854     \textcolor{comment}{!  enddo ; enddo ; enddo}}
\DoxyCodeLine{855     \textcolor{comment}{!  call post\_data(CS\%id\_hf\_gKEu, hf\_gKEu, CS\%diag)}}
\DoxyCodeLine{856     \textcolor{comment}{!endif}}
\DoxyCodeLine{857 }
\DoxyCodeLine{858     \textcolor{comment}{!if (CS\%id\_hf\_gKEv > 0) then}}
\DoxyCodeLine{859     \textcolor{comment}{!  allocate(hf\_gKEv(G\%isd:G\%ied,G\%JsdB:G\%JedB,G\%ke))}}
\DoxyCodeLine{860     \textcolor{comment}{!  do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie}}
\DoxyCodeLine{861     \textcolor{comment}{!    hf\_gKEv(i,J,k) = AD\%gradKEv(i,J,k) * AD\%diag\_hfrac\_v(i,J,k)}}
\DoxyCodeLine{862     \textcolor{comment}{!  enddo ; enddo ; enddo}}
\DoxyCodeLine{863     \textcolor{comment}{!  call post\_data(CS\%id\_hf\_gKEv, hf\_gKEv, CS\%diag)}}
\DoxyCodeLine{864     \textcolor{comment}{!endif}}
\DoxyCodeLine{865 }
\DoxyCodeLine{866     \textcolor{keywordflow}{if} (cs\%id\_hf\_gKEu\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{867       \textcolor{keyword}{allocate}(hf\_gkeu\_2d(g\%IsdB:g\%IedB,g\%jsd:g\%jed))}
\DoxyCodeLine{868       hf\_gkeu\_2d(:,:) = 0.0}
\DoxyCodeLine{869       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{870         hf\_gkeu\_2d(i,j) = hf\_gkeu\_2d(i,j) + ad\%gradKEu(i,j,k) * ad\%diag\_hfrac\_u(i,j,k)}
\DoxyCodeLine{871 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{872       \textcolor{keyword}{call }post\_data(cs\%id\_hf\_gKEu\_2d, hf\_gkeu\_2d, cs\%diag)}
\DoxyCodeLine{873       \textcolor{keyword}{deallocate}(hf\_gkeu\_2d)}
\DoxyCodeLine{874 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{875 }
\DoxyCodeLine{876     \textcolor{keywordflow}{if} (cs\%id\_hf\_gKEv\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{877       \textcolor{keyword}{allocate}(hf\_gkev\_2d(g\%isd:g\%ied,g\%JsdB:g\%JedB))}
\DoxyCodeLine{878       hf\_gkev\_2d(:,:) = 0.0}
\DoxyCodeLine{879       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{880         hf\_gkev\_2d(i,j) = hf\_gkev\_2d(i,j) + ad\%gradKEv(i,j,k) * ad\%diag\_hfrac\_v(i,j,k)}
\DoxyCodeLine{881 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{882       \textcolor{keyword}{call }post\_data(cs\%id\_hf\_gKEv\_2d, hf\_gkev\_2d, cs\%diag)}
\DoxyCodeLine{883       \textcolor{keyword}{deallocate}(hf\_gkev\_2d)}
\DoxyCodeLine{884 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{885 }
\DoxyCodeLine{886     \textcolor{comment}{!if (CS\%id\_hf\_rvxv > 0) then}}
\DoxyCodeLine{887     \textcolor{comment}{!  allocate(hf\_rvxv(G\%IsdB:G\%IedB,G\%jsd:G\%jed,G\%ke))}}
\DoxyCodeLine{888     \textcolor{comment}{!  do k=1,nz ; do j=js,je ; do I=Isq,Ieq}}
\DoxyCodeLine{889     \textcolor{comment}{!    hf\_rvxv(I,j,k) = AD\%rv\_x\_v(I,j,k) * AD\%diag\_hfrac\_u(I,j,k)}}
\DoxyCodeLine{890     \textcolor{comment}{!  enddo ; enddo ; enddo}}
\DoxyCodeLine{891     \textcolor{comment}{!  call post\_data(CS\%id\_hf\_rvxv, hf\_rvxv, CS\%diag)}}
\DoxyCodeLine{892     \textcolor{comment}{!endif}}
\DoxyCodeLine{893 }
\DoxyCodeLine{894     \textcolor{comment}{!if (CS\%id\_hf\_rvxu > 0) then}}
\DoxyCodeLine{895     \textcolor{comment}{!  allocate(hf\_rvxu(G\%isd:G\%ied,G\%JsdB:G\%JedB,G\%ke))}}
\DoxyCodeLine{896     \textcolor{comment}{!  do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie}}
\DoxyCodeLine{897     \textcolor{comment}{!    hf\_rvxu(i,J,k) = AD\%rv\_x\_u(i,J,k) * AD\%diag\_hfrac\_v(i,J,k)}}
\DoxyCodeLine{898     \textcolor{comment}{!  enddo ; enddo ; enddo}}
\DoxyCodeLine{899     \textcolor{comment}{!  call post\_data(CS\%id\_hf\_rvxu, hf\_rvxu, CS\%diag)}}
\DoxyCodeLine{900     \textcolor{comment}{!endif}}
\DoxyCodeLine{901 }
\DoxyCodeLine{902     \textcolor{keywordflow}{if} (cs\%id\_hf\_rvxv\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{903       \textcolor{keyword}{allocate}(hf\_rvxv\_2d(g\%IsdB:g\%IedB,g\%jsd:g\%jed))}
\DoxyCodeLine{904       hf\_rvxv\_2d(:,:) = 0.0}
\DoxyCodeLine{905       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{906         hf\_rvxv\_2d(i,j) = hf\_rvxv\_2d(i,j) + ad\%rv\_x\_v(i,j,k) * ad\%diag\_hfrac\_u(i,j,k)}
\DoxyCodeLine{907 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{908       \textcolor{keyword}{call }post\_data(cs\%id\_hf\_rvxv\_2d, hf\_rvxv\_2d, cs\%diag)}
\DoxyCodeLine{909       \textcolor{keyword}{deallocate}(hf\_rvxv\_2d)}
\DoxyCodeLine{910 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{911 }
\DoxyCodeLine{912     \textcolor{keywordflow}{if} (cs\%id\_hf\_rvxu\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{913       \textcolor{keyword}{allocate}(hf\_rvxu\_2d(g\%isd:g\%ied,g\%JsdB:g\%JedB))}
\DoxyCodeLine{914       hf\_rvxu\_2d(:,:) = 0.0}
\DoxyCodeLine{915       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{916         hf\_rvxu\_2d(i,j) = hf\_rvxu\_2d(i,j) + ad\%rv\_x\_u(i,j,k) * ad\%diag\_hfrac\_v(i,j,k)}
\DoxyCodeLine{917 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{918       \textcolor{keyword}{call }post\_data(cs\%id\_hf\_rvxu\_2d, hf\_rvxu\_2d, cs\%diag)}
\DoxyCodeLine{919       \textcolor{keyword}{deallocate}(hf\_rvxu\_2d)}
\DoxyCodeLine{920 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{921 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{922 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__coriolisadv_a6252eaea90947c83b5a1900d31191b96}\label{namespacemom__coriolisadv_a6252eaea90947c83b5a1900d31191b96}} 
\index{mom\_coriolisadv@{mom\_coriolisadv}!coriolisadv\_end@{coriolisadv\_end}}
\index{coriolisadv\_end@{coriolisadv\_end}!mom\_coriolisadv@{mom\_coriolisadv}}
\doxysubsubsection{\texorpdfstring{coriolisadv\_end()}{coriolisadv\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+coriolisadv\+::coriolisadv\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Destructor for \mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}. 


\begin{DoxyParams}{Parameters}
{\em cs} & Control structure fro M\+O\+M\+\_\+\+Coriolis\+Adv \\
\hline
\end{DoxyParams}


Definition at line 1247 of file M\+O\+M\+\_\+\+Coriolis\+Adv.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1248   \textcolor{keywordtype}{type}(CoriolisAdv\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< Control structure fro MOM\_CoriolisAdv}}
\DoxyCodeLine{1249   \textcolor{keyword}{deallocate}(cs)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__coriolisadv_ae021ac8de3b3510ca4552314ec9e1a9a}\label{namespacemom__coriolisadv_ae021ac8de3b3510ca4552314ec9e1a9a}} 
\index{mom\_coriolisadv@{mom\_coriolisadv}!coriolisadv\_init@{coriolisadv\_init}}
\index{coriolisadv\_init@{coriolisadv\_init}!mom\_coriolisadv@{mom\_coriolisadv}}
\doxysubsubsection{\texorpdfstring{coriolisadv\_init()}{coriolisadv\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+coriolisadv\+::coriolisadv\+\_\+init (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(inout), target}]{AD,  }\item[{type(\mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Initializes the control structure for \mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}. 


\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} & Runtime parameter handles \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & Diagnostics control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em ad} & Strorage for acceleration diagnostics \\
\hline
 & {\em cs} & Control structure fro M\+O\+M\+\_\+\+Coriolis\+Adv \\
\hline
\end{DoxyParams}


Definition at line 1011 of file M\+O\+M\+\_\+\+Coriolis\+Adv.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1012   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< Current model time}}
\DoxyCodeLine{1013   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< Ocean grid structure}}
\DoxyCodeLine{1014   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< Vertical grid structure}}
\DoxyCodeLine{1015   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1016   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Runtime parameter handles}}
\DoxyCodeLine{1017   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< Diagnostics control structure}}
\DoxyCodeLine{1018   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),   \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: AD\textcolor{comment}{ !< Strorage for acceleration diagnostics}}
\DoxyCodeLine{1019   \textcolor{keywordtype}{type}(CoriolisAdv\_CS),    \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{ !< Control structure fro MOM\_CoriolisAdv}}
\DoxyCodeLine{1020   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1021 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{1022 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{1023 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_CoriolisAdv"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{1024   \textcolor{keywordtype}{character(len=20)}  :: tmpstr}
\DoxyCodeLine{1025   \textcolor{keywordtype}{character(len=400)} :: mesg}
\DoxyCodeLine{1026   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, nz}
\DoxyCodeLine{1027 }
\DoxyCodeLine{1028   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed ; nz = gv\%ke}
\DoxyCodeLine{1029   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{1030 }
\DoxyCodeLine{1031   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1032     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"CoriolisAdv\_init called with associated control structure."})}
\DoxyCodeLine{1033     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1034 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1035   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{1036 }
\DoxyCodeLine{1037   cs\%diag => diag ; cs\%Time => time}
\DoxyCodeLine{1038 }
\DoxyCodeLine{1039   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{1040   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{1041   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"NOSLIP"}, cs\%no\_slip, \&}
\DoxyCodeLine{1042                  \textcolor{stringliteral}{"If true, no slip boundary conditions are used; otherwise "}//\&}
\DoxyCodeLine{1043                  \textcolor{stringliteral}{"free slip boundary conditions are assumed. The "}//\&}
\DoxyCodeLine{1044                  \textcolor{stringliteral}{"implementation of the free slip BCs on a C-\/grid is much "}//\&}
\DoxyCodeLine{1045                  \textcolor{stringliteral}{"cleaner than the no slip BCs. The use of free slip BCs "}//\&}
\DoxyCodeLine{1046                  \textcolor{stringliteral}{"is strongly encouraged, and no slip BCs are not used with "}//\&}
\DoxyCodeLine{1047                  \textcolor{stringliteral}{"the biharmonic viscosity."}, default=.false.)}
\DoxyCodeLine{1048 }
\DoxyCodeLine{1049   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CORIOLIS\_EN\_DIS"}, cs\%Coriolis\_En\_Dis, \&}
\DoxyCodeLine{1050                  \textcolor{stringliteral}{"If true, two estimates of the thickness fluxes are used "}//\&}
\DoxyCodeLine{1051                  \textcolor{stringliteral}{"to estimate the Coriolis term, and the one that "}//\&}
\DoxyCodeLine{1052                  \textcolor{stringliteral}{"dissipates energy relative to the other one is used."}, \&}
\DoxyCodeLine{1053                  default=.false.)}
\DoxyCodeLine{1054 }
\DoxyCodeLine{1055   \textcolor{comment}{! Set \%Coriolis\_Scheme}}
\DoxyCodeLine{1056   \textcolor{comment}{! (Select the baseline discretization for the Coriolis term)}}
\DoxyCodeLine{1057   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CORIOLIS\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{1058                  \textcolor{stringliteral}{"CORIOLIS\_SCHEME selects the discretization for the "}//\&}
\DoxyCodeLine{1059                  \textcolor{stringliteral}{"Coriolis terms. Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{1060                  \textcolor{stringliteral}{"\(\backslash\)t SADOURNY75\_ENERGY -\/ Sadourny, 1975; energy cons. \(\backslash\)n"}//\&}
\DoxyCodeLine{1061                  \textcolor{stringliteral}{"\(\backslash\)t ARAKAWA\_HSU90     -\/ Arakawa \& Hsu, 1990 \(\backslash\)n"}//\&}
\DoxyCodeLine{1062                  \textcolor{stringliteral}{"\(\backslash\)t SADOURNY75\_ENSTRO -\/ Sadourny, 1975; enstrophy cons. \(\backslash\)n"}//\&}
\DoxyCodeLine{1063                  \textcolor{stringliteral}{"\(\backslash\)t ARAKAWA\_LAMB81    -\/ Arakawa \& Lamb, 1981; En. + Enst.\(\backslash\)n"}//\&}
\DoxyCodeLine{1064                  \textcolor{stringliteral}{"\(\backslash\)t ARAKAWA\_LAMB\_BLEND -\/ A blend of Arakawa \& Lamb with \(\backslash\)n"}//\&}
\DoxyCodeLine{1065                  \textcolor{stringliteral}{"\(\backslash\)t                      Arakawa \& Hsu and Sadourny energy"}, \&}
\DoxyCodeLine{1066                  default=sadourny75\_energy\_string)}
\DoxyCodeLine{1067   tmpstr = uppercase(tmpstr)}
\DoxyCodeLine{1068   \textcolor{keywordflow}{select case} (tmpstr)}
\DoxyCodeLine{1069     \textcolor{keywordflow}{case} (sadourny75\_energy\_string)}
\DoxyCodeLine{1070       cs\%Coriolis\_Scheme = sadourny75\_energy}
\DoxyCodeLine{1071     \textcolor{keywordflow}{case} (arakawa\_hsu\_string)}
\DoxyCodeLine{1072       cs\%Coriolis\_Scheme = arakawa\_hsu90}
\DoxyCodeLine{1073     \textcolor{keywordflow}{case} (sadourny75\_enstro\_string)}
\DoxyCodeLine{1074       cs\%Coriolis\_Scheme = sadourny75\_enstro}
\DoxyCodeLine{1075     \textcolor{keywordflow}{case} (arakawa\_lamb\_string)}
\DoxyCodeLine{1076       cs\%Coriolis\_Scheme = arakawa\_lamb81}
\DoxyCodeLine{1077     \textcolor{keywordflow}{case} (al\_blend\_string)}
\DoxyCodeLine{1078       cs\%Coriolis\_Scheme = al\_blend}
\DoxyCodeLine{1079     \textcolor{keywordflow}{case} (robust\_enstro\_string)}
\DoxyCodeLine{1080       cs\%Coriolis\_Scheme = robust\_enstro}
\DoxyCodeLine{1081       cs\%Coriolis\_En\_Dis = .false.}
\DoxyCodeLine{1082 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{1083       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'CoriolisAdv\_init: Coriolis\_Scheme ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)}
\DoxyCodeLine{1084       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"CoriolisAdv\_init: Unrecognized setting "}// \&}
\DoxyCodeLine{1085             \textcolor{stringliteral}{"\#define CORIOLIS\_SCHEME "}//trim(tmpstr)//\textcolor{stringliteral}{" found in input file."})}
\DoxyCodeLine{1086 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1087   \textcolor{keywordflow}{if} (cs\%Coriolis\_Scheme == al\_blend) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1088     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CORIOLIS\_BLEND\_WT\_LIN"}, cs\%wt\_lin\_blend, \&}
\DoxyCodeLine{1089                  \textcolor{stringliteral}{"A weighting value for the ratio of inverse thicknesses, "}//\&}
\DoxyCodeLine{1090                  \textcolor{stringliteral}{"beyond which the blending between Sadourny Energy and "}//\&}
\DoxyCodeLine{1091                  \textcolor{stringliteral}{"Arakawa \& Hsu goes linearly to 0 when CORIOLIS\_SCHEME "}//\&}
\DoxyCodeLine{1092                  \textcolor{stringliteral}{"is ARAWAKA\_LAMB\_BLEND. This must be between 1 and 1e-\/16."}, \&}
\DoxyCodeLine{1093                  units=\textcolor{stringliteral}{"nondim"}, default=0.125)}
\DoxyCodeLine{1094     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CORIOLIS\_BLEND\_F\_EFF\_MAX"}, cs\%F\_eff\_max\_blend, \&}
\DoxyCodeLine{1095                  \textcolor{stringliteral}{"The factor by which the maximum effective Coriolis "}//\&}
\DoxyCodeLine{1096                  \textcolor{stringliteral}{"acceleration from any point can be increased when "}//\&}
\DoxyCodeLine{1097                  \textcolor{stringliteral}{"blending different discretizations with the "}//\&}
\DoxyCodeLine{1098                  \textcolor{stringliteral}{"ARAKAWA\_LAMB\_BLEND Coriolis scheme.  This must be "}//\&}
\DoxyCodeLine{1099                  \textcolor{stringliteral}{"greater than 2.0 (the max value for Sadourny energy)."}, \&}
\DoxyCodeLine{1100                  units=\textcolor{stringliteral}{"nondim"}, default=4.0)}
\DoxyCodeLine{1101     cs\%wt\_lin\_blend = min(1.0, max(cs\%wt\_lin\_blend,1e-\/16))}
\DoxyCodeLine{1102     \textcolor{keywordflow}{if} (cs\%F\_eff\_max\_blend < 2.0) \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"CoriolisAdv\_init: "}//\&}
\DoxyCodeLine{1103            \textcolor{stringliteral}{"CORIOLIS\_BLEND\_F\_EFF\_MAX should be at least 2."})}
\DoxyCodeLine{1104 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1105 }
\DoxyCodeLine{1106   mesg = \textcolor{stringliteral}{"If true, the Coriolis terms at u-\/points are bounded by "}//\&}
\DoxyCodeLine{1107          \textcolor{stringliteral}{"the four estimates of (f+rv)v from the four neighboring "}//\&}
\DoxyCodeLine{1108          \textcolor{stringliteral}{"v-\/points, and similarly at v-\/points."}}
\DoxyCodeLine{1109   \textcolor{keywordflow}{if} (cs\%Coriolis\_En\_Dis .and. (cs\%Coriolis\_Scheme == sadourny75\_energy)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1110     mesg = trim(mesg)//\textcolor{stringliteral}{"  This option is "}//\&}
\DoxyCodeLine{1111                  \textcolor{stringliteral}{"always effectively false with CORIOLIS\_EN\_DIS defined and "}//\&}
\DoxyCodeLine{1112                  \textcolor{stringliteral}{"CORIOLIS\_SCHEME set to "}//trim(sadourny75\_energy\_string)//\textcolor{stringliteral}{"."}}
\DoxyCodeLine{1113   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1114     mesg = trim(mesg)//\textcolor{stringliteral}{"  This option would "}//\&}
\DoxyCodeLine{1115                  \textcolor{stringliteral}{"have no effect on the SADOURNY Coriolis scheme if it "}//\&}
\DoxyCodeLine{1116                  \textcolor{stringliteral}{"were possible to use centered difference thickness fluxes."}}
\DoxyCodeLine{1117 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1118   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BOUND\_CORIOLIS"}, cs\%bound\_Coriolis, mesg, \&}
\DoxyCodeLine{1119                  default=.false.)}
\DoxyCodeLine{1120   \textcolor{keywordflow}{if} ((cs\%Coriolis\_En\_Dis .and. (cs\%Coriolis\_Scheme == sadourny75\_energy)) .or. \&}
\DoxyCodeLine{1121       (cs\%Coriolis\_Scheme == robust\_enstro)) cs\%bound\_Coriolis = .false.}
\DoxyCodeLine{1122 }
\DoxyCodeLine{1123   \textcolor{comment}{! Set KE\_Scheme (selects discretization of KE)}}
\DoxyCodeLine{1124   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"KE\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{1125                  \textcolor{stringliteral}{"KE\_SCHEME selects the discretization for acceleration "}//\&}
\DoxyCodeLine{1126                  \textcolor{stringliteral}{"due to the kinetic energy gradient. Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{1127                  \textcolor{stringliteral}{"\(\backslash\)t KE\_ARAKAWA, KE\_SIMPLE\_GUDONOV, KE\_GUDONOV"}, \&}
\DoxyCodeLine{1128                  default=ke\_arakawa\_string)}
\DoxyCodeLine{1129   tmpstr = uppercase(tmpstr)}
\DoxyCodeLine{1130   \textcolor{keywordflow}{select case} (tmpstr)}
\DoxyCodeLine{1131     \textcolor{keywordflow}{case} (ke\_arakawa\_string); cs\%KE\_Scheme = ke\_arakawa}
\DoxyCodeLine{1132     \textcolor{keywordflow}{case} (ke\_simple\_gudonov\_string); cs\%KE\_Scheme = ke\_simple\_gudonov}
\DoxyCodeLine{1133     \textcolor{keywordflow}{case} (ke\_gudonov\_string); cs\%KE\_Scheme = ke\_gudonov}
\DoxyCodeLine{1134 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{1135       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'CoriolisAdv\_init: KE\_Scheme ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)}
\DoxyCodeLine{1136       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"CoriolisAdv\_init: "}// \&}
\DoxyCodeLine{1137                \textcolor{stringliteral}{"\#define KE\_SCHEME "}//trim(tmpstr)//\textcolor{stringliteral}{" in input file is invalid."})}
\DoxyCodeLine{1138 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1139 }
\DoxyCodeLine{1140   \textcolor{comment}{! Set PV\_Adv\_Scheme (selects discretization of PV advection)}}
\DoxyCodeLine{1141   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"PV\_ADV\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{1142                  \textcolor{stringliteral}{"PV\_ADV\_SCHEME selects the discretization for PV "}//\&}
\DoxyCodeLine{1143                  \textcolor{stringliteral}{"advection. Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{1144                  \textcolor{stringliteral}{"\(\backslash\)t PV\_ADV\_CENTERED -\/ centered (aka Sadourny, 75) \(\backslash\)n"}//\&}
\DoxyCodeLine{1145                  \textcolor{stringliteral}{"\(\backslash\)t PV\_ADV\_UPWIND1  -\/ upwind, first order"}, \&}
\DoxyCodeLine{1146                  default=pv\_adv\_centered\_string)}
\DoxyCodeLine{1147   \textcolor{keywordflow}{select case} (uppercase(tmpstr))}
\DoxyCodeLine{1148     \textcolor{keywordflow}{case} (pv\_adv\_centered\_string)}
\DoxyCodeLine{1149       cs\%PV\_Adv\_Scheme = pv\_adv\_centered}
\DoxyCodeLine{1150     \textcolor{keywordflow}{case} (pv\_adv\_upwind1\_string)}
\DoxyCodeLine{1151       cs\%PV\_Adv\_Scheme = pv\_adv\_upwind1}
\DoxyCodeLine{1152 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{1153       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'CoriolisAdv\_init: PV\_Adv\_Scheme ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)}
\DoxyCodeLine{1154       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"CoriolisAdv\_init: "}// \&}
\DoxyCodeLine{1155                      \textcolor{stringliteral}{"\#DEFINE PV\_ADV\_SCHEME in input file is invalid."})}
\DoxyCodeLine{1156 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1157 }
\DoxyCodeLine{1158   cs\%id\_rv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'RV'}, diag\%axesBL, time, \&}
\DoxyCodeLine{1159      \textcolor{stringliteral}{'Relative Vorticity'}, \textcolor{stringliteral}{'s-\/1'}, conversion=us\%s\_to\_T)}
\DoxyCodeLine{1160 }
\DoxyCodeLine{1161   cs\%id\_PV = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PV'}, diag\%axesBL, time, \&}
\DoxyCodeLine{1162      \textcolor{stringliteral}{'Potential Vorticity'}, \textcolor{stringliteral}{'m-\/1 s-\/1'}, conversion=gv\%m\_to\_H*us\%s\_to\_T)}
\DoxyCodeLine{1163 }
\DoxyCodeLine{1164   cs\%id\_gKEu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'gKEu'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{1165      \textcolor{stringliteral}{'Zonal Acceleration from Grad. Kinetic Energy'}, \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1166   \textcolor{keywordflow}{if} (cs\%id\_gKEu > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%gradKEu,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1167 }
\DoxyCodeLine{1168   cs\%id\_gKEv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'gKEv'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{1169      \textcolor{stringliteral}{'Meridional Acceleration from Grad. Kinetic Energy'}, \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1170   \textcolor{keywordflow}{if} (cs\%id\_gKEv > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%gradKEv,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1171 }
\DoxyCodeLine{1172   cs\%id\_rvxu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'rvxu'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{1173      \textcolor{stringliteral}{'Meridional Acceleration from Relative Vorticity'}, \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1174   \textcolor{keywordflow}{if} (cs\%id\_rvxu > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%rv\_x\_u,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1175 }
\DoxyCodeLine{1176   cs\%id\_rvxv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'rvxv'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{1177      \textcolor{stringliteral}{'Zonal Acceleration from Relative Vorticity'}, \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1178   \textcolor{keywordflow}{if} (cs\%id\_rvxv > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%rv\_x\_v,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1179 }
\DoxyCodeLine{1180   \textcolor{comment}{!CS\%id\_hf\_gKEu = register\_diag\_field('ocean\_model', 'hf\_gKEu', diag\%axesCuL, Time, \&}}
\DoxyCodeLine{1181   \textcolor{comment}{!   'Fractional Thickness-\/weighted Zonal Acceleration from Grad. Kinetic Energy', \&}}
\DoxyCodeLine{1182   \textcolor{comment}{!   'm-\/1 s-\/2', v\_extensive=.true., conversion=US\%L\_T2\_to\_m\_s2)}}
\DoxyCodeLine{1183   \textcolor{comment}{!if (CS\%id\_hf\_gKEu > 0) then}}
\DoxyCodeLine{1184   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%gradKEu,IsdB,IedB,jsd,jed,nz)}}
\DoxyCodeLine{1185   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%diag\_hfrac\_u,IsdB,IedB,jsd,jed,nz)}}
\DoxyCodeLine{1186   \textcolor{comment}{!endif}}
\DoxyCodeLine{1187 }
\DoxyCodeLine{1188   \textcolor{comment}{!CS\%id\_hf\_gKEv = register\_diag\_field('ocean\_model', 'hf\_gKEv', diag\%axesCvL, Time, \&}}
\DoxyCodeLine{1189   \textcolor{comment}{!   'Fractional Thickness-\/weighted Meridional Acceleration from Grad. Kinetic Energy', \&}}
\DoxyCodeLine{1190   \textcolor{comment}{!   'm-\/1 s-\/2', v\_extensive=.true., conversion=US\%L\_T2\_to\_m\_s2)}}
\DoxyCodeLine{1191   \textcolor{comment}{!if (CS\%id\_hf\_gKEv > 0) then}}
\DoxyCodeLine{1192   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%gradKEv,isd,ied,JsdB,JedB,nz)}}
\DoxyCodeLine{1193   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%diag\_hfrac\_v,isd,ied,Jsd,JedB,nz)}}
\DoxyCodeLine{1194   \textcolor{comment}{!endif}}
\DoxyCodeLine{1195 }
\DoxyCodeLine{1196   cs\%id\_hf\_gKEu\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_gKEu\_2d'}, diag\%axesCu1, time, \&}
\DoxyCodeLine{1197      \textcolor{stringliteral}{'Depth-\/sum Fractional Thickness-\/weighted Zonal Acceleration from Grad. Kinetic Energy'}, \&}
\DoxyCodeLine{1198      \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1199   \textcolor{keywordflow}{if} (cs\%id\_hf\_gKEu\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1200     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%gradKEu,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1201     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%diag\_hfrac\_u,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1202 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1203 }
\DoxyCodeLine{1204   cs\%id\_hf\_gKEv\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_gKEv\_2d'}, diag\%axesCv1, time, \&}
\DoxyCodeLine{1205      \textcolor{stringliteral}{'Depth-\/sum Fractional Thickness-\/weighted Meridional Acceleration from Grad. Kinetic Energy'}, \&}
\DoxyCodeLine{1206      \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1207   \textcolor{keywordflow}{if} (cs\%id\_hf\_gKEv\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1208     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%gradKEv,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1209     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%diag\_hfrac\_v,isd,ied,jsd,jedb,nz)}
\DoxyCodeLine{1210 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1211 }
\DoxyCodeLine{1212   \textcolor{comment}{!CS\%id\_hf\_rvxu = register\_diag\_field('ocean\_model', 'hf\_rvxu', diag\%axesCvL, Time, \&}}
\DoxyCodeLine{1213   \textcolor{comment}{!   'Fractional Thickness-\/weighted Meridional Acceleration from Relative Vorticity', \&}}
\DoxyCodeLine{1214   \textcolor{comment}{!   'm-\/1 s-\/2', v\_extensive=.true., conversion=US\%L\_T2\_to\_m\_s2)}}
\DoxyCodeLine{1215   \textcolor{comment}{!if (CS\%id\_hf\_rvxu > 0) then}}
\DoxyCodeLine{1216   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%rv\_x\_u,isd,ied,JsdB,JedB,nz)}}
\DoxyCodeLine{1217   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%diag\_hfrac\_v,isd,ied,Jsd,JedB,nz)}}
\DoxyCodeLine{1218   \textcolor{comment}{!endif}}
\DoxyCodeLine{1219 }
\DoxyCodeLine{1220   \textcolor{comment}{!CS\%id\_hf\_rvxv = register\_diag\_field('ocean\_model', 'hf\_rvxv', diag\%axesCuL, Time, \&}}
\DoxyCodeLine{1221   \textcolor{comment}{!   'Fractional Thickness-\/weighted Zonal Acceleration from Relative Vorticity', \&}}
\DoxyCodeLine{1222   \textcolor{comment}{!   'm-\/1 s-\/2', v\_extensive=.true., conversion=US\%L\_T2\_to\_m\_s2)}}
\DoxyCodeLine{1223   \textcolor{comment}{!if (CS\%id\_hf\_rvxv > 0) then}}
\DoxyCodeLine{1224   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%rv\_x\_v,IsdB,IedB,jsd,jed,nz)}}
\DoxyCodeLine{1225   \textcolor{comment}{!  call safe\_alloc\_ptr(AD\%diag\_hfrac\_u,IsdB,IedB,jsd,jed,nz)}}
\DoxyCodeLine{1226   \textcolor{comment}{!endif}}
\DoxyCodeLine{1227 }
\DoxyCodeLine{1228   cs\%id\_hf\_rvxu\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_rvxu\_2d'}, diag\%axesCv1, time, \&}
\DoxyCodeLine{1229      \textcolor{stringliteral}{'Fractional Thickness-\/weighted Meridional Acceleration from Relative Vorticity'}, \&}
\DoxyCodeLine{1230      \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1231   \textcolor{keywordflow}{if} (cs\%id\_hf\_rvxu\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1232     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%rv\_x\_u,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1233     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%diag\_hfrac\_v,isd,ied,jsd,jedb,nz)}
\DoxyCodeLine{1234 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1235 }
\DoxyCodeLine{1236   cs\%id\_hf\_rvxv\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_rvxv\_2d'}, diag\%axesCu1, time, \&}
\DoxyCodeLine{1237      \textcolor{stringliteral}{'Depth-\/sum Fractional Thickness-\/weighted Zonal Acceleration from Relative Vorticity'}, \&}
\DoxyCodeLine{1238      \textcolor{stringliteral}{'m-\/1 s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1239   \textcolor{keywordflow}{if} (cs\%id\_hf\_rvxv\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1240     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%rv\_x\_v,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1241     \textcolor{keyword}{call }safe\_alloc\_ptr(ad\%diag\_hfrac\_u,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1242 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1243 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__coriolisadv_a87e4a437552052fa238260442af19868}\label{namespacemom__coriolisadv_a87e4a437552052fa238260442af19868}} 
\index{mom\_coriolisadv@{mom\_coriolisadv}!gradke@{gradke}}
\index{gradke@{gradke}!mom\_coriolisadv@{mom\_coriolisadv}}
\doxysubsubsection{\texorpdfstring{gradke()}{gradke()}}
{\footnotesize\ttfamily subroutine mom\+\_\+coriolisadv\+::gradke (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in)}]{v,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{real, dimension( g \%isd\+: g \%ied , g \%jsd\+: g \%jed ), intent(out)}]{KE,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed ), intent(out)}]{K\+Ex,  }\item[{real, dimension( g \%isd\+: g \%ied , g \%jsdb\+: g \%jedb), intent(out)}]{K\+Ey,  }\item[{integer, intent(in)}]{k,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__coriolisadv_1_1coriolisadv__cs}{coriolisadv\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calculates the acceleration due to the gradient of kinetic energy. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocen grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em u} & Zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em v} & Meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em ke} & Kinetic energy per unit mass \mbox{[}L2 T-\/2 $\sim$$>$ m2 s-\/2\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em kex} & Zonal acceleration due to kinetic energy gradient \mbox{[}L T-\/2 $\sim$$>$ m s-\/2\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em key} & Meridional acceleration due to kinetic energy gradient \mbox{[}L T-\/2 $\sim$$>$ m s-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em k} & Layer number to calculate for \\
\hline
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & Control structure for M\+O\+M\+\_\+\+Coriolis\+Adv \\
\hline
\end{DoxyParams}


Definition at line 927 of file M\+O\+M\+\_\+\+Coriolis\+Adv.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{928   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< Ocen grid structure}}
\DoxyCodeLine{929 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)}  :: u\textcolor{comment}{ !< Zonal velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{930 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)}  :: v\textcolor{comment}{ !< Meridional velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{931 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{ !< Layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{932 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G) ,SZJ\_(G) )},         \textcolor{keywordtype}{intent(out)} :: KE\textcolor{comment}{ !< Kinetic energy per unit mass [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{933 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G) )},         \textcolor{keywordtype}{intent(out)} :: KEx\textcolor{comment}{ !< Zonal acceleration due to kinetic}}
\DoxyCodeLine{934 \textcolor{comment}{                                                                 !! energy gradient [L T-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{935 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G) ,SZJB\_(G))},         \textcolor{keywordtype}{intent(out)} :: KEy\textcolor{comment}{ !< Meridional acceleration due to kinetic}}
\DoxyCodeLine{936 \textcolor{comment}{                                                                 !! energy gradient [L T-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{937   \textcolor{keywordtype}{integer},                                    \textcolor{keywordtype}{intent(in)}  :: k\textcolor{comment}{ !< Layer number to calculate for}}
\DoxyCodeLine{938   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                       \textcolor{keywordtype}{pointer}     :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{939   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{940   \textcolor{keywordtype}{type}(CoriolisAdv\_CS),                       \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{ !< Control structure for MOM\_CoriolisAdv}}
\DoxyCodeLine{941   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{942 \textcolor{keywordtype}{  real} :: um, up, vm, vp         \textcolor{comment}{! Temporary variables [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{943 \textcolor{keywordtype}{  real} :: um2, up2, vm2, vp2     \textcolor{comment}{! Temporary variables [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{944 \textcolor{keywordtype}{  real} :: um2a, up2a, vm2a, vp2a \textcolor{comment}{! Temporary variables [L4 T-\/2 \string~> m4 s-\/2].}}
\DoxyCodeLine{945   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz, n}
\DoxyCodeLine{946 }
\DoxyCodeLine{947   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{948   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{949 }
\DoxyCodeLine{950 }
\DoxyCodeLine{951   \textcolor{comment}{! Calculate KE (Kinetic energy for use in the -\/grad(KE) acceleration term).}}
\DoxyCodeLine{952   \textcolor{keywordflow}{if} (cs\%KE\_Scheme == ke\_arakawa) \textcolor{keywordflow}{then}}
\DoxyCodeLine{953     \textcolor{comment}{! The following calculation of Kinetic energy includes the metric terms}}
\DoxyCodeLine{954     \textcolor{comment}{! identified in Arakawa \& Lamb 1982 as important for KE conservation.  It}}
\DoxyCodeLine{955     \textcolor{comment}{! also includes the possibility of partially-\/blocked tracer cell faces.}}
\DoxyCodeLine{956     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{957       ke(i,j) = ( ( g\%areaCu( i ,j)*(u( i ,j,k)*u( i ,j,k)) + \&}
\DoxyCodeLine{958                     g\%areaCu(i-\/1,j)*(u(i-\/1,j,k)*u(i-\/1,j,k)) ) + \&}
\DoxyCodeLine{959                   ( g\%areaCv(i, j )*(v(i, j ,k)*v(i, j ,k)) + \&}
\DoxyCodeLine{960                     g\%areaCv(i,j-\/1)*(v(i,j-\/1,k)*v(i,j-\/1,k)) ) )*0.25*g\%IareaT(i,j)}
\DoxyCodeLine{961 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{962   \textcolor{keywordflow}{elseif} (cs\%KE\_Scheme == ke\_simple\_gudonov) \textcolor{keywordflow}{then}}
\DoxyCodeLine{963     \textcolor{comment}{! The following discretization of KE is based on the one-\/dimensinal Gudonov}}
\DoxyCodeLine{964     \textcolor{comment}{! scheme which does not take into account any geometric factors}}
\DoxyCodeLine{965     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{966       up = 0.5*( u(i-\/1,j,k) + abs( u(i-\/1,j,k) ) ) ; up2 = up*up}
\DoxyCodeLine{967       um = 0.5*( u( i ,j,k) -\/ abs( u( i ,j,k) ) ) ; um2 = um*um}
\DoxyCodeLine{968       vp = 0.5*( v(i,j-\/1,k) + abs( v(i,j-\/1,k) ) ) ; vp2 = vp*vp}
\DoxyCodeLine{969       vm = 0.5*( v(i, j ,k) -\/ abs( v(i, j ,k) ) ) ; vm2 = vm*vm}
\DoxyCodeLine{970       ke(i,j) = ( max(up2,um2) + max(vp2,vm2) ) *0.5}
\DoxyCodeLine{971 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{972   \textcolor{keywordflow}{elseif} (cs\%KE\_Scheme == ke\_gudonov) \textcolor{keywordflow}{then}}
\DoxyCodeLine{973     \textcolor{comment}{! The following discretization of KE is based on the one-\/dimensinal Gudonov}}
\DoxyCodeLine{974     \textcolor{comment}{! scheme but has been adapted to take horizontal grid factors into account}}
\DoxyCodeLine{975     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{976       up = 0.5*( u(i-\/1,j,k) + abs( u(i-\/1,j,k) ) ) ; up2a = up*up*g\%areaCu(i-\/1,j)}
\DoxyCodeLine{977       um = 0.5*( u( i ,j,k) -\/ abs( u( i ,j,k) ) ) ; um2a = um*um*g\%areaCu( i ,j)}
\DoxyCodeLine{978       vp = 0.5*( v(i,j-\/1,k) + abs( v(i,j-\/1,k) ) ) ; vp2a = vp*vp*g\%areaCv(i,j-\/1)}
\DoxyCodeLine{979       vm = 0.5*( v(i, j ,k) -\/ abs( v(i, j ,k) ) ) ; vm2a = vm*vm*g\%areaCv(i, j )}
\DoxyCodeLine{980       ke(i,j) = ( max(um2a,up2a) + max(vm2a,vp2a) )*0.5*g\%IareaT(i,j)}
\DoxyCodeLine{981 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{982 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{983 }
\DoxyCodeLine{984   \textcolor{comment}{! Term -\/ d(KE)/dx.}}
\DoxyCodeLine{985   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{986     kex(i,j) = (ke(i+1,j) -\/ ke(i,j)) * g\%IdxCu(i,j)}
\DoxyCodeLine{987 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{988 }
\DoxyCodeLine{989   \textcolor{comment}{! Term -\/ d(KE)/dy.}}
\DoxyCodeLine{990   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{991     key(i,j) = (ke(i,j+1) -\/ ke(i,j)) * g\%IdyCv(i,j)}
\DoxyCodeLine{992 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{993 }
\DoxyCodeLine{994   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{995     \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{996       \textcolor{keywordflow}{if} (obc\%segment(n)\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{997         \textcolor{keywordflow}{do} i=obc\%segment(n)\%HI\%isd,obc\%segment(n)\%HI\%ied}
\DoxyCodeLine{998           key(i,obc\%segment(n)\%HI\%JsdB) = 0.}
\DoxyCodeLine{999 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{1000       \textcolor{keywordflow}{elseif} (obc\%segment(n)\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1001         \textcolor{keywordflow}{do} j=obc\%segment(n)\%HI\%jsd,obc\%segment(n)\%HI\%jed}
\DoxyCodeLine{1002           kex(obc\%segment(n)\%HI\%IsdB,j) = 0.}
\DoxyCodeLine{1003 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{1004 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1005 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1006 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1007 }

\end{DoxyCode}
