\hypertarget{namespacemom__dynamics__split__rk2}{}\section{mom\+\_\+dynamics\+\_\+split\+\_\+rk2 Module Reference}
\label{namespacemom__dynamics__split__rk2}\index{mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}}


\subsection{Detailed Description}
Time step the adiabatic dynamic core of M\+OM using R\+K2 method. 

This file time steps the adiabatic dynamic core by splitting between baroclinic and barotropic modes. It uses a pseudo-\/second order Runge-\/\+Kutta time stepping scheme for the baroclinic momentum equation and a forward-\/backward coupling between the baroclinic momentum and continuity equations. This split time-\/stepping scheme is described in detail in Hallberg (J\+CP, 1997). Additional issues related to exact tracer conservation and how to ensure consistency between the barotropic and layered estimates of the free surface height are described in Hallberg and Adcroft (Ocean Modelling, 2009). This was the time stepping code that is used for most G\+O\+LD applications, including G\+F\+DL\textquotesingle{}s E\+S\+M2G Earth system model, and all of the examples provided with the M\+OM code (although several of these solutions are routinely verified by comparison with the slower unsplit schemes).

The subroutine step\+\_\+\+M\+O\+M\+\_\+dyn\+\_\+split\+\_\+\+R\+K2 actually does the time stepping, while register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+\+R\+K2 sets the fields that are found in a full restart file with this scheme, and initialize\+\_\+dyn\+\_\+split\+\_\+\+R\+K2 initializes the cpu clocks that are used in this module. For largely historical reasons, this module does not have its own control structure, but shares the same control structure with \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90} and the other M\+O\+M\+\_\+dynamics\+\_\+... modules. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__dynamics__split__rk2_1_1mom__dyn__split__rk2__cs}{mom\+\_\+dyn\+\_\+split\+\_\+rk2\+\_\+cs}
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+dynamics\+\_\+split\+\_\+\+R\+K2 module control structure. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \hyperlink{namespacemom__dynamics__split__rk2_a976e700971f232fc11bc69b31d611c32}{step\+\_\+mom\+\_\+dyn\+\_\+split\+\_\+rk2} (u, v, h, tv, visc, Time\+\_\+local, dt, forces, p\+\_\+surf\+\_\+begin, p\+\_\+surf\+\_\+end, uh, vh, uhtr, vhtr, eta\+\_\+av, G, GV, US, CS, calc\+\_\+dtbt, Var\+Mix, M\+E\+KE, thickness\+\_\+diffuse\+\_\+\+C\+Sp, Waves)
\begin{DoxyCompactList}\small\item\em R\+K2 splitting for time stepping M\+OM adiabatic dynamics. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__dynamics__split__rk2_a9f889b82fd5ed29a854da99d3c929366}{register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+rk2} (HI, GV, param\+\_\+file, CS, restart\+\_\+\+CS, uh, vh)
\begin{DoxyCompactList}\small\item\em This subroutine sets up any auxiliary restart variables that are specific to the unsplit time stepping scheme. All variables registered here should have the ability to be recreated if they are not present in a restart file. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__dynamics__split__rk2_a3995d7e0c8fb36abdc7166ea4fe586d1}{initialize\+\_\+dyn\+\_\+split\+\_\+rk2} (u, v, h, uh, vh, eta, Time, G, GV, US, param\+\_\+file, diag, CS, restart\+\_\+\+CS, dt, Accel\+\_\+diag, Cont\+\_\+diag, M\+IS, Var\+Mix, M\+E\+KE, thickness\+\_\+diffuse\+\_\+\+C\+Sp, O\+BC, update\+\_\+\+O\+B\+C\+\_\+\+C\+Sp, A\+L\+E\+\_\+\+C\+Sp, set\+Visc\+\_\+\+C\+Sp, visc, dirs, ntrunc, calc\+\_\+dtbt, cont\+\_\+stencil)
\begin{DoxyCompactList}\small\item\em This subroutine initializes all of the variables that are used by this dynamic core, including diagnostics and the cpu clocks. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__dynamics__split__rk2_a2dedc57e0443d33d9713aa987de22564}{end\+\_\+dyn\+\_\+split\+\_\+rk2} (CS)
\begin{DoxyCompactList}\small\item\em Close the dyn\+\_\+split\+\_\+\+R\+K2 module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\textbf{ }\par
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_ad3884ecee0a084445790d44528ac6dac}\label{namespacemom__dynamics__split__rk2_ad3884ecee0a084445790d44528ac6dac}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_ad3884ecee0a084445790d44528ac6dac}{id\+\_\+clock\+\_\+cor}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a9d8b6d38a0e7724afacfa6913ae739ae}\label{namespacemom__dynamics__split__rk2_a9d8b6d38a0e7724afacfa6913ae739ae}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a9d8b6d38a0e7724afacfa6913ae739ae}{id\+\_\+clock\+\_\+pres}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_acfd11d4aebbf6b14f39077090f56ef5b}\label{namespacemom__dynamics__split__rk2_acfd11d4aebbf6b14f39077090f56ef5b}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_acfd11d4aebbf6b14f39077090f56ef5b}{id\+\_\+clock\+\_\+vertvisc}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a1a01bde62f65f6600cce148448abdfbe}\label{namespacemom__dynamics__split__rk2_a1a01bde62f65f6600cce148448abdfbe}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a1a01bde62f65f6600cce148448abdfbe}{id\+\_\+clock\+\_\+horvisc}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a7ff3a37691e3acc35039962cf6b2fdaa}\label{namespacemom__dynamics__split__rk2_a7ff3a37691e3acc35039962cf6b2fdaa}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a7ff3a37691e3acc35039962cf6b2fdaa}{id\+\_\+clock\+\_\+mom\+\_\+update}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a86ec3d9ffc9d19a3fd8c552970a9e551}\label{namespacemom__dynamics__split__rk2_a86ec3d9ffc9d19a3fd8c552970a9e551}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a86ec3d9ffc9d19a3fd8c552970a9e551}{id\+\_\+clock\+\_\+continuity}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a15db1d2e90277d772fdb192e2137a668}\label{namespacemom__dynamics__split__rk2_a15db1d2e90277d772fdb192e2137a668}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a15db1d2e90277d772fdb192e2137a668}{id\+\_\+clock\+\_\+thick\+\_\+diff}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a2ce197eb3f285e6c96fcbcf109fa52b4}\label{namespacemom__dynamics__split__rk2_a2ce197eb3f285e6c96fcbcf109fa52b4}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a2ce197eb3f285e6c96fcbcf109fa52b4}{id\+\_\+clock\+\_\+btstep}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a1156e9ac0a7338e196c5eb018cb21262}\label{namespacemom__dynamics__split__rk2_a1156e9ac0a7338e196c5eb018cb21262}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a1156e9ac0a7338e196c5eb018cb21262}{id\+\_\+clock\+\_\+btcalc}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a82edb8c495c4b87e86a1536b5e64e0bd}\label{namespacemom__dynamics__split__rk2_a82edb8c495c4b87e86a1536b5e64e0bd}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a82edb8c495c4b87e86a1536b5e64e0bd}{id\+\_\+clock\+\_\+btforce}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_ae0a9bda16164c51889e836534aa290fa}\label{namespacemom__dynamics__split__rk2_ae0a9bda16164c51889e836534aa290fa}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_ae0a9bda16164c51889e836534aa290fa}{id\+\_\+clock\+\_\+pass}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a39c9d62531c00323c3b2ed559902a460}\label{namespacemom__dynamics__split__rk2_a39c9d62531c00323c3b2ed559902a460}} 
integer \hyperlink{namespacemom__dynamics__split__rk2_a39c9d62531c00323c3b2ed559902a460}{id\+\_\+clock\+\_\+pass\+\_\+init}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\end{DoxyCompactItemize}



\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a2dedc57e0443d33d9713aa987de22564}\label{namespacemom__dynamics__split__rk2_a2dedc57e0443d33d9713aa987de22564}} 
\index{mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}!end\+\_\+dyn\+\_\+split\+\_\+rk2@{end\+\_\+dyn\+\_\+split\+\_\+rk2}}
\index{end\+\_\+dyn\+\_\+split\+\_\+rk2@{end\+\_\+dyn\+\_\+split\+\_\+rk2}!mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}}
\subsubsection{\texorpdfstring{end\+\_\+dyn\+\_\+split\+\_\+rk2()}{end\_dyn\_split\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+split\+\_\+rk2\+::end\+\_\+dyn\+\_\+split\+\_\+rk2 (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__dynamics__split__rk2_1_1mom__dyn__split__rk2__cs}{mom\+\_\+dyn\+\_\+split\+\_\+rk2\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Close the dyn\+\_\+split\+\_\+\+R\+K2 module. 


\begin{DoxyParams}{Parameters}
{\em cs} & module control structure \\
\hline
\end{DoxyParams}


Definition at line 1444 of file M\+O\+M\+\_\+dynamics\+\_\+split\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
1444   \textcolor{keywordtype}{type}(mom\_dyn\_split\_rk2\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{  !< module control structure}
1445 
1446   dealloc\_(cs%diffu) ; dealloc\_(cs%diffv)
1447   dealloc\_(cs%CAu)   ; dealloc\_(cs%CAv)
1448   dealloc\_(cs%PFu)   ; dealloc\_(cs%PFv)
1449 
1450   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%taux\_bot)) \textcolor{keyword}{deallocate}(cs%taux\_bot)
1451   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tauy\_bot)) \textcolor{keyword}{deallocate}(cs%tauy\_bot)
1452   dealloc\_(cs%uhbt) ; dealloc\_(cs%vhbt)
1453   dealloc\_(cs%u\_accel\_bt) ; dealloc\_(cs%v\_accel\_bt)
1454   dealloc\_(cs%visc\_rem\_u) ; dealloc\_(cs%visc\_rem\_v)
1455 
1456   dealloc\_(cs%eta) ; dealloc\_(cs%eta\_PF) ; dealloc\_(cs%pbce)
1457   dealloc\_(cs%h\_av) ; dealloc\_(cs%u\_av) ; dealloc\_(cs%v\_av)
1458 
1459   \textcolor{keyword}{call }dealloc\_bt\_cont\_type(cs%BT\_cont)
1460 
1461   \textcolor{keyword}{deallocate}(cs)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a3995d7e0c8fb36abdc7166ea4fe586d1}\label{namespacemom__dynamics__split__rk2_a3995d7e0c8fb36abdc7166ea4fe586d1}} 
\index{mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}!initialize\+\_\+dyn\+\_\+split\+\_\+rk2@{initialize\+\_\+dyn\+\_\+split\+\_\+rk2}}
\index{initialize\+\_\+dyn\+\_\+split\+\_\+rk2@{initialize\+\_\+dyn\+\_\+split\+\_\+rk2}!mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}}
\subsubsection{\texorpdfstring{initialize\+\_\+dyn\+\_\+split\+\_\+rk2()}{initialize\_dyn\_split\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+split\+\_\+rk2\+::initialize\+\_\+dyn\+\_\+split\+\_\+rk2 (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(inout)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(inout)}]{v,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(inout)}]{h,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(inout), target}]{uh,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(inout), target}]{vh,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(inout)}]{eta,  }\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(\hyperlink{structmom__dynamics__split__rk2_1_1mom__dyn__split__rk2__cs}{mom\+\_\+dyn\+\_\+split\+\_\+rk2\+\_\+cs}), pointer}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS,  }\item[{real, intent(in)}]{dt,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(inout), target}]{Accel\+\_\+diag,  }\item[{type(cont\+\_\+diag\+\_\+ptrs), intent(inout), target}]{Cont\+\_\+diag,  }\item[{type(ocean\+\_\+internal\+\_\+state), intent(inout)}]{M\+IS,  }\item[{type(varmix\+\_\+cs), pointer}]{Var\+Mix,  }\item[{type(meke\+\_\+type), pointer}]{M\+E\+KE,  }\item[{type(thickness\+\_\+diffuse\+\_\+cs), pointer}]{thickness\+\_\+diffuse\+\_\+\+C\+Sp,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(update\+\_\+obc\+\_\+cs), pointer}]{update\+\_\+\+O\+B\+C\+\_\+\+C\+Sp,  }\item[{type(ale\+\_\+cs), pointer}]{A\+L\+E\+\_\+\+C\+Sp,  }\item[{type(set\+\_\+visc\+\_\+cs), pointer}]{set\+Visc\+\_\+\+C\+Sp,  }\item[{type(vertvisc\+\_\+type), intent(inout)}]{visc,  }\item[{type(directories), intent(in)}]{dirs,  }\item[{integer, intent(inout), target}]{ntrunc,  }\item[{logical, intent(out)}]{calc\+\_\+dtbt,  }\item[{integer, intent(out), optional}]{cont\+\_\+stencil }\end{DoxyParamCaption})}



This subroutine initializes all of the variables that are used by this dynamic core, including diagnostics and the cpu clocks. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em u} & zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em v} & merid velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em uh} & zonal volume/mass transport \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em vh} & merid volume/mass transport \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em eta} & free surface height or column mass \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em time} & current model time\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & parameter file for parsing\\
\hline
\mbox{\tt in,out}  & {\em diag} & to control diagnostics\\
\hline
 & {\em cs} & module control structure\\
\hline
 & {\em restart\+\_\+cs} & restart control structure\\
\hline
\mbox{\tt in}  & {\em dt} & time step \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em accel\+\_\+diag} & points to momentum equation terms for budget analysis\\
\hline
\mbox{\tt in,out}  & {\em cont\+\_\+diag} & points to terms in continuity equation\\
\hline
\mbox{\tt in,out}  & {\em mis} & \char`\"{}\+M\+O\+M6 internal state\char`\"{} used to pass diagnostic pointers\\
\hline
 & {\em varmix} & points to spatially variable viscosities\\
\hline
 & {\em meke} & points to mesoscale eddy kinetic energy fields\\
\hline
 & {\em thickness\+\_\+diffuse\+\_\+csp} & Pointer to the control structure used for the isopycnal height diffusive transport.\\
\hline
 & {\em obc} & points to O\+BC related fields\\
\hline
 & {\em update\+\_\+obc\+\_\+csp} & points to O\+BC update related fields\\
\hline
 & {\em ale\+\_\+csp} & points to A\+LE control structure\\
\hline
 & {\em setvisc\+\_\+csp} & points to the set\+\_\+visc control structure.\\
\hline
\mbox{\tt in,out}  & {\em visc} & vertical viscosities, bottom drag, and related\\
\hline
\mbox{\tt in}  & {\em dirs} & contains directory paths\\
\hline
\mbox{\tt in,out}  & {\em ntrunc} & A target for the variable that records the number of times the velocity is truncated (this should be 0).\\
\hline
\mbox{\tt out}  & {\em calc\+\_\+dtbt} & If true, recalculate the barotropic time step\\
\hline
\mbox{\tt out}  & {\em cont\+\_\+stencil} & The stencil for thickness from the continuity solver. \\
\hline
\end{DoxyParams}


Definition at line 1077 of file M\+O\+M\+\_\+dynamics\+\_\+split\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
1077   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{          !< ocean grid structure}
1078   \textcolor{keywordtype}{type}(verticalgrid\_type),          \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{         !< ocean vertical grid structure}
1079   \textcolor{keywordtype}{type}(unit\_scale\_type),            \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{         !< A dimensional unit scaling type}
1080   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, &
1081                                     \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{          !< zonal velocity [L T-1 ~> m s-1]}
1082   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, &
1083                                     \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{          !< merid velocity [L T-1 ~> m s-1]}
1084   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} , \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{ !< layer thickness [H ~> m or kg m-2]}
1085   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, &
1086                             \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: uh\textcolor{comment}{    !< zonal volume/mass transport [H L2 T-1 ~> m3
       s-1 or kg s-1]}
1087   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, &
1088                             \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: vh\textcolor{comment}{    !< merid volume/mass transport [H L2 T-1 ~> m3
       s-1 or kg s-1]}
1089   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: eta\textcolor{comment}{        !< free surface height or column mass [H ~>
       m or kg m-2]}
1090   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{       !< current model time}
1091   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< parameter file for parsing}
1092   \textcolor{keywordtype}{type}(diag\_ctrl),          \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{       !< to control diagnostics}
1093   \textcolor{keywordtype}{type}(mom\_dyn\_split\_rk2\_cs),       \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{         !< module control structure}
1094   \textcolor{keywordtype}{type}(mom\_restart\_cs),             \textcolor{keywordtype}{pointer}       :: restart\_cs\textcolor{comment}{ !< restart control structure}
1095   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{         !< time step [T ~> s]}
1096   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),    \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: accel\_diag\textcolor{comment}{ !< points to momentum equation terms for}
1097 \textcolor{comment}{                                                                !! budget analysis}
1098   \textcolor{keywordtype}{type}(cont\_diag\_ptrs),     \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: cont\_diag\textcolor{comment}{  !< points to terms in continuity equation}
1099   \textcolor{keywordtype}{type}(ocean\_internal\_state),       \textcolor{keywordtype}{intent(inout)} :: mis\textcolor{comment}{        !< "MOM6 internal state" used to pass}
1100 \textcolor{comment}{                                                                !! diagnostic pointers}
1101   \textcolor{keywordtype}{type}(varmix\_cs),                  \textcolor{keywordtype}{pointer}       :: varmix\textcolor{comment}{     !< points to spatially variable viscosities}
1102   \textcolor{keywordtype}{type}(meke\_type),                  \textcolor{keywordtype}{pointer}       :: meke\textcolor{comment}{       !< points to mesoscale eddy kinetic energy
       fields}
1103 \textcolor{comment}{!  type(Barotropic\_CS),              pointer       :: Barotropic\_CSp !< Pointer to the control structure
       for}
1104 \textcolor{comment}{!                                                                !! the barotropic module}
1105   \textcolor{keywordtype}{type}(thickness\_diffuse\_cs),       \textcolor{keywordtype}{pointer}       :: thickness\_diffuse\_csp\textcolor{comment}{ !< Pointer to the control
       structure}
1106 \textcolor{comment}{                                                  !! used for the isopycnal height diffusive transport.}
1107   \textcolor{keywordtype}{type}(ocean\_obc\_type),             \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{        !< points to OBC related fields}
1108   \textcolor{keywordtype}{type}(update\_obc\_cs),              \textcolor{keywordtype}{pointer}       :: update\_obc\_csp\textcolor{comment}{ !< points to OBC update related fields}
1109   \textcolor{keywordtype}{type}(ale\_cs),                     \textcolor{keywordtype}{pointer}       :: ale\_csp\textcolor{comment}{    !< points to ALE control structure}
1110   \textcolor{keywordtype}{type}(set\_visc\_cs),                \textcolor{keywordtype}{pointer}       :: setvisc\_csp\textcolor{comment}{ !< points to the set\_visc control
       structure.}
1111   \textcolor{keywordtype}{type}(vertvisc\_type),              \textcolor{keywordtype}{intent(inout)} :: visc\textcolor{comment}{       !< vertical viscosities, bottom drag, and
       related}
1112   \textcolor{keywordtype}{type}(directories),                \textcolor{keywordtype}{intent(in)}    :: dirs\textcolor{comment}{       !< contains directory paths}
1113   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{target},                  \textcolor{keywordtype}{intent(inout)} :: ntrunc\textcolor{comment}{     !< A target for the variable that records}
1114 \textcolor{comment}{                                                                !! the number of times the velocity is}
1115 \textcolor{comment}{                                                                !! truncated (this should be 0).}
1116   \textcolor{keywordtype}{logical},                          \textcolor{keywordtype}{intent(out)}   :: calc\_dtbt\textcolor{comment}{  !< If true, recalculate the barotropic time
       step}
1117   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: cont\_stencil\textcolor{comment}{ !< The stencil for thickness}
1118 \textcolor{comment}{                                                                !! from the continuity solver.}
1119 
1120   \textcolor{comment}{! local variables}
1121   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_tmp
1122   \textcolor{keywordtype}{character(len=40)} :: mdl = \textcolor{stringliteral}{"MOM\_dynamics\_split\_RK2"} \textcolor{comment}{! This module's name.}
1123   \textcolor{comment}{! This include declares and sets the variable "version".}
1124 \textcolor{preprocessor}{# include "version\_variable.h"}
1125 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units, eta\_rest\_name
1126   \textcolor{keywordtype}{real} :: h\_rescale  \textcolor{comment}{! A rescaling factor for thicknesses from the representation in}
1127                      \textcolor{comment}{! a restart file to the internal representation in this run.}
1128   \textcolor{keywordtype}{real} :: vel\_rescale  \textcolor{comment}{! A rescaling factor for velocities from the representation in}
1129                      \textcolor{comment}{! a restart file to the internal representation in this run.}
1130   \textcolor{keywordtype}{real} :: uh\_rescale \textcolor{comment}{! A rescaling factor for thickness transports from the representation in}
1131                      \textcolor{comment}{! a restart file to the internal representation in this run.}
1132   \textcolor{keywordtype}{real} :: accel\_rescale \textcolor{comment}{! A rescaling factor for accelerations from the representation in}
1133                      \textcolor{comment}{! a restart file to the internal representation in this run.}
1134   \textcolor{keywordtype}{real} :: h\_convert
1135   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_av\_h\_uvh
1136   \textcolor{keywordtype}{logical} :: use\_tides, debug\_truncations
1137 
1138   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz
1139   \textcolor{keywordtype}{integer} :: isdb, iedb, jsdb, jedb
1140   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec ; nz = g%ke
1141   isd  = g%isd  ; ied  = g%ied  ; jsd  = g%jsd  ; jed  = g%jed
1142   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
1143 
1144   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, &
1145       \textcolor{stringliteral}{"initialize\_dyn\_split\_RK2 called with an unassociated control structure."})
1146   \textcolor{keywordflow}{if} (cs%module\_is\_initialized) \textcolor{keywordflow}{then}
1147     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_dyn\_split\_RK2 called with a control "}// &
1148                             \textcolor{stringliteral}{"structure that has already been initialized."})
1149     \textcolor{keywordflow}{return}
1150 \textcolor{keywordflow}{  endif}
1151   cs%module\_is\_initialized = .true.
1152 
1153   cs%diag => diag
1154 
1155   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
1156   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDES"}, use\_tides, &
1157                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing."}, default=.false.)
1158   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BE"}, cs%be, &
1159                  \textcolor{stringliteral}{"If SPLIT is true, BE determines the relative weighting "}//&
1160                  \textcolor{stringliteral}{"of a  2nd-order Runga-Kutta baroclinic time stepping "}//&
1161                  \textcolor{stringliteral}{"scheme (0.5) and a backward Euler scheme (1) that is "}//&
1162                  \textcolor{stringliteral}{"used for the Coriolis and inertial terms.  BE may be "}//&
1163                  \textcolor{stringliteral}{"from 0.5 to 1, but instability may occur near 0.5. "}//&
1164                  \textcolor{stringliteral}{"BE is also applicable if SPLIT is false and USE\_RK2 "}//&
1165                  \textcolor{stringliteral}{"is true."}, units=\textcolor{stringliteral}{"nondim"}, default=0.6)
1166   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BEGW"}, cs%begw, &
1167                  \textcolor{stringliteral}{"If SPLIT is true, BEGW is a number from 0 to 1 that "}//&
1168                  \textcolor{stringliteral}{"controls the extent to which the treatment of gravity "}//&
1169                  \textcolor{stringliteral}{"waves is forward-backward (0) or simulated backward "}//&
1170                  \textcolor{stringliteral}{"Euler (1).  0 is almost always used. "}//&
1171                  \textcolor{stringliteral}{"If SPLIT is false and USE\_RK2 is true, BEGW can be "}//&
1172                  \textcolor{stringliteral}{"between 0 and 0.5 to damp gravity waves."}, &
1173                  units=\textcolor{stringliteral}{"nondim"}, default=0.0)
1174 
1175   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SPLIT\_BOTTOM\_STRESS"}, cs%split\_bottom\_stress, &
1176                  \textcolor{stringliteral}{"If true, provide the bottom stress calculated by the "}//&
1177                  \textcolor{stringliteral}{"vertical viscosity to the barotropic solver."}, default=.false.)
1178   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BT\_USE\_LAYER\_FLUXES"}, cs%BT\_use\_layer\_fluxes, &
1179                  \textcolor{stringliteral}{"If true, use the summed layered fluxes plus an "}//&
1180                  \textcolor{stringliteral}{"adjustment due to the change in the barotropic velocity "}//&
1181                  \textcolor{stringliteral}{"in the barotropic continuity equation."}, default=.true.)
1182   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, cs%debug, &
1183                  \textcolor{stringliteral}{"If true, write out verbose debugging data."}, &
1184                  default=.false., debuggingparam=.true.)
1185   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG\_OBC"}, cs%debug\_OBC, default=.false.)
1186   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG\_TRUNCATIONS"}, debug\_truncations, &
1187                  default=.false.)
1188 
1189   \textcolor{keyword}{allocate}(cs%taux\_bot(isdb:iedb,jsd:jed)) ; cs%taux\_bot(:,:) = 0.0
1190   \textcolor{keyword}{allocate}(cs%tauy\_bot(isd:ied,jsdb:jedb)) ; cs%tauy\_bot(:,:) = 0.0
1191 
1192   alloc\_(cs%uhbt(isdb:iedb,jsd:jed))          ; cs%uhbt(:,:)         = 0.0
1193   alloc\_(cs%vhbt(isd:ied,jsdb:jedb))          ; cs%vhbt(:,:)         = 0.0
1194   alloc\_(cs%visc\_rem\_u(isdb:iedb,jsd:jed,nz)) ; cs%visc\_rem\_u(:,:,:) = 0.0
1195   alloc\_(cs%visc\_rem\_v(isd:ied,jsdb:jedb,nz)) ; cs%visc\_rem\_v(:,:,:) = 0.0
1196   alloc\_(cs%eta\_PF(isd:ied,jsd:jed))          ; cs%eta\_PF(:,:)       = 0.0
1197   alloc\_(cs%pbce(isd:ied,jsd:jed,nz))         ; cs%pbce(:,:,:)       = 0.0
1198 
1199   alloc\_(cs%u\_accel\_bt(isdb:iedb,jsd:jed,nz)) ; cs%u\_accel\_bt(:,:,:) = 0.0
1200   alloc\_(cs%v\_accel\_bt(isd:ied,jsdb:jedb,nz)) ; cs%v\_accel\_bt(:,:,:) = 0.0
1201 
1202   mis%diffu      => cs%diffu
1203   mis%diffv      => cs%diffv
1204   mis%PFu        => cs%PFu
1205   mis%PFv        => cs%PFv
1206   mis%CAu        => cs%CAu
1207   mis%CAv        => cs%CAv
1208   mis%pbce       => cs%pbce
1209   mis%u\_accel\_bt => cs%u\_accel\_bt
1210   mis%v\_accel\_bt => cs%v\_accel\_bt
1211   mis%u\_av       => cs%u\_av
1212   mis%v\_av       => cs%v\_av
1213 
1214   cs%ADp           => accel\_diag
1215   cs%CDp           => cont\_diag
1216   accel\_diag%diffu => cs%diffu
1217   accel\_diag%diffv => cs%diffv
1218   accel\_diag%PFu   => cs%PFu
1219   accel\_diag%PFv   => cs%PFv
1220   accel\_diag%CAu   => cs%CAu
1221   accel\_diag%CAv   => cs%CAv
1222 
1223 \textcolor{comment}{!  Accel\_diag%pbce => CS%pbce}
1224 \textcolor{comment}{!  Accel\_diag%u\_accel\_bt => CS%u\_accel\_bt ; Accel\_diag%v\_accel\_bt => CS%v\_accel\_bt}
1225 \textcolor{comment}{!  Accel\_diag%u\_av => CS%u\_av ; Accel\_diag%v\_av => CS%v\_av}
1226 
1227   id\_clock\_pass\_init = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean init message passing)'}, &
1228                                      grain=clock\_routine)
1229 
1230   \textcolor{keyword}{call }continuity\_init(time, g, gv, us, param\_file, diag, cs%continuity\_CSp)
1231   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cont\_stencil)) cont\_stencil = continuity\_stencil(cs%continuity\_CSp)
1232   \textcolor{keyword}{call }coriolisadv\_init(time, g, gv, us, param\_file, diag, cs%ADp, cs%CoriolisAdv\_CSp)
1233   \textcolor{keywordflow}{if} (use\_tides) \textcolor{keyword}{call }tidal\_forcing\_init(time, g, param\_file, cs%tides\_CSp)
1234   \textcolor{keyword}{call }pressureforce\_init(time, g, gv, us, param\_file, diag, cs%PressureForce\_CSp, &
1235                           cs%tides\_CSp)
1236   \textcolor{keyword}{call }hor\_visc\_init(time, g, us, param\_file, diag, cs%hor\_visc\_CSp, meke, adp=cs%ADp)
1237   \textcolor{keyword}{call }vertvisc\_init(mis, time, g, gv, us, param\_file, diag, cs%ADp, dirs, &
1238                      ntrunc, cs%vertvisc\_CSp)
1239   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(setvisc\_csp)) \textcolor{keyword}{call }mom\_error(fatal, &
1240     \textcolor{stringliteral}{"initialize\_dyn\_split\_RK2 called with setVisc\_CSp unassociated."})
1241   cs%set\_visc\_CSp => setvisc\_csp
1242   \textcolor{keyword}{call }updatecfltruncationvalue(time, cs%vertvisc\_CSp, &
1243                                 activate=is\_new\_run(restart\_cs) )
1244 
1245   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ale\_csp)) cs%ALE\_CSp => ale\_csp
1246   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
1247     cs%OBC => obc
1248     \textcolor{keywordflow}{if} (obc%ramp) \textcolor{keyword}{call }update\_obc\_ramp(time, cs%OBC, &
1249                                 activate=is\_new\_run(restart\_cs) )
1250 \textcolor{keywordflow}{  endif}
1251   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(update\_obc\_csp)) cs%update\_OBC\_CSp => update\_obc\_csp
1252 
1253   eta\_rest\_name = \textcolor{stringliteral}{"sfc"} ; \textcolor{keywordflow}{if} (.not.gv%Boussinesq) eta\_rest\_name = \textcolor{stringliteral}{"p\_bot"}
1254   \textcolor{keywordflow}{if} (.not. query\_initialized(cs%eta, trim(eta\_rest\_name), restart\_cs)) \textcolor{keywordflow}{then}
1255     \textcolor{comment}{! Estimate eta based on the layer thicknesses - h.  With the Boussinesq}
1256     \textcolor{comment}{! approximation, eta is the free surface height anomaly, while without it}
1257     \textcolor{comment}{! eta is the mass of ocean per unit area.  eta always has the same}
1258     \textcolor{comment}{! dimensions as h, either m or kg m-3.}
1259     \textcolor{comment}{!   CS%eta(:,:) = 0.0 already from initialization.}
1260     \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then}
1261       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; cs%eta(i,j) = -gv%Z\_to\_H * g%bathyT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1262 \textcolor{keywordflow}{    endif}
1263     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1264        cs%eta(i,j) = cs%eta(i,j) + h(i,j,k)
1265 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1266   \textcolor{keywordflow}{elseif} ((gv%m\_to\_H\_restart /= 0.0) .and. (gv%m\_to\_H\_restart /= gv%m\_to\_H)) \textcolor{keywordflow}{then}
1267     h\_rescale = gv%m\_to\_H / gv%m\_to\_H\_restart
1268     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; cs%eta(i,j) = h\_rescale * cs%eta(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1269 \textcolor{keywordflow}{  endif}
1270   \textcolor{comment}{! Copy eta into an output array.}
1271   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; eta(i,j) = cs%eta(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1272 
1273   \textcolor{keyword}{call }barotropic\_init(u, v, h, cs%eta, time, g, gv, us, param\_file, diag, &
1274                        cs%barotropic\_CSp, restart\_cs, calc\_dtbt, cs%BT\_cont, &
1275                        cs%tides\_CSp)
1276 
1277   \textcolor{keywordflow}{if} (.not. query\_initialized(cs%diffu,\textcolor{stringliteral}{"diffu"},restart\_cs) .or. &
1278       .not. query\_initialized(cs%diffv,\textcolor{stringliteral}{"diffv"},restart\_cs)) \textcolor{keywordflow}{then}
1279     \textcolor{keyword}{call }horizontal\_viscosity(u, v, h, cs%diffu, cs%diffv, meke, varmix, &
1280                               g, gv, us, cs%hor\_visc\_CSp, &
1281                               obc=cs%OBC, bt=cs%barotropic\_CSp, &
1282                               td=thickness\_diffuse\_csp)
1283   \textcolor{keywordflow}{else}
1284     \textcolor{keywordflow}{if} ( (us%s\_to\_T\_restart * us%m\_to\_L\_restart /= 0.0) .and. &
1285          (us%m\_to\_L * us%s\_to\_T\_restart**2 /= us%m\_to\_L\_restart * us%s\_to\_T**2) ) \textcolor{keywordflow}{then}
1286       accel\_rescale = (us%m\_to\_L * us%s\_to\_T\_restart**2) / (us%m\_to\_L\_restart * us%s\_to\_T**2)
1287       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=g%IscB,g%IecB
1288         cs%diffu(i,j,k) = accel\_rescale * cs%diffu(i,j,k)
1289 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1290       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=g%JscB,g%JecB ; \textcolor{keywordflow}{do} i=is,ie
1291         cs%diffv(i,j,k) = accel\_rescale * cs%diffv(i,j,k)
1292 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1293 \textcolor{keywordflow}{    endif}
1294 \textcolor{keywordflow}{  endif}
1295 
1296   \textcolor{keywordflow}{if} (.not. query\_initialized(cs%u\_av,\textcolor{stringliteral}{"u2"}, restart\_cs) .or. &
1297       .not. query\_initialized(cs%u\_av,\textcolor{stringliteral}{"v2"}, restart\_cs)) \textcolor{keywordflow}{then}
1298     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb ; cs%u\_av(i,j,k) = u(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1299     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied ; cs%v\_av(i,j,k) = v(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1300   \textcolor{keywordflow}{elseif} ( (us%s\_to\_T\_restart * us%m\_to\_L\_restart /= 0.0) .and. &
1301          ((us%m\_to\_L * us%s\_to\_T\_restart) /= (us%m\_to\_L\_restart * us%s\_to\_T)) ) \textcolor{keywordflow}{then}
1302     vel\_rescale = (us%m\_to\_L * us%s\_to\_T\_restart) /  (us%m\_to\_L\_restart * us%s\_to\_T)
1303     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb ; cs%u\_av(i,j,k) = vel\_rescale * cs%u\_av(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{
       enddo} ;\textcolor{keywordflow}{ enddo}
1304     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied ; cs%v\_av(i,j,k) = vel\_rescale * cs%v\_av(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{
       enddo} ;\textcolor{keywordflow}{ enddo}
1305 \textcolor{keywordflow}{  endif}
1306 
1307   \textcolor{comment}{! This call is just here to initialize uh and vh.}
1308   \textcolor{keywordflow}{if} (.not. query\_initialized(uh,\textcolor{stringliteral}{"uh"},restart\_cs) .or. &
1309       .not. query\_initialized(vh,\textcolor{stringliteral}{"vh"},restart\_cs)) \textcolor{keywordflow}{then}
1310     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied ; h\_tmp(i,j,k) = h(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1311     \textcolor{keyword}{call }continuity(u, v, h, h\_tmp, uh, vh, dt, g, gv, us, cs%continuity\_CSp, obc=cs%OBC)
1312     \textcolor{keyword}{call }pass\_var(h\_tmp, g%Domain, clock=id\_clock\_pass\_init)
1313     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
1314       cs%h\_av(i,j,k) = 0.5*(h(i,j,k) + h\_tmp(i,j,k))
1315 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1316   \textcolor{keywordflow}{else}
1317     \textcolor{keywordflow}{if} (.not. query\_initialized(cs%h\_av,\textcolor{stringliteral}{"h2"},restart\_cs)) \textcolor{keywordflow}{then}
1318       cs%h\_av(:,:,:) = h(:,:,:)
1319     \textcolor{keywordflow}{elseif} ((gv%m\_to\_H\_restart /= 0.0) .and. (gv%m\_to\_H\_restart /= gv%m\_to\_H)) \textcolor{keywordflow}{then}
1320       h\_rescale = gv%m\_to\_H / gv%m\_to\_H\_restart
1321       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; cs%h\_av(i,j,k) = h\_rescale * cs%h\_av(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{
       enddo}
1322 \textcolor{keywordflow}{    endif}
1323     \textcolor{keywordflow}{if} ( (gv%m\_to\_H\_restart * us%s\_to\_T\_restart * us%m\_to\_L\_restart /= 0.0) .and. &
1324          ((gv%m\_to\_H * us%m\_to\_L**2 * us%s\_to\_T\_restart) /= &
1325           (gv%m\_to\_H\_restart * us%m\_to\_L\_restart**2 * us%s\_to\_T)) ) \textcolor{keywordflow}{then}
1326       uh\_rescale = (gv%m\_to\_H * us%m\_to\_L**2 * us%s\_to\_T\_restart) / &
1327                    (gv%m\_to\_H\_restart * us%m\_to\_L\_restart**2 * us%s\_to\_T)
1328       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=g%IscB,g%IecB ; uh(i,j,k) = uh\_rescale * uh(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{
       enddo}
1329       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=g%JscB,g%JecB ; \textcolor{keywordflow}{do} i=is,ie ; vh(i,j,k) = uh\_rescale * vh(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{
       enddo}
1330 \textcolor{keywordflow}{    endif}
1331 \textcolor{keywordflow}{  endif}
1332 
1333   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass\_init)
1334   \textcolor{keyword}{call }create\_group\_pass(pass\_av\_h\_uvh, cs%u\_av, cs%v\_av, g%Domain, halo=2)
1335   \textcolor{keyword}{call }create\_group\_pass(pass\_av\_h\_uvh, cs%h\_av, g%Domain, halo=2)
1336   \textcolor{keyword}{call }create\_group\_pass(pass\_av\_h\_uvh, uh, vh, g%Domain, halo=2)
1337   \textcolor{keyword}{call }do\_group\_pass(pass\_av\_h\_uvh, g%Domain)
1338   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass\_init)
1339 
1340   flux\_units = get\_flux\_units(gv)
1341   h\_convert = gv%H\_to\_m ; \textcolor{keywordflow}{if} (.not.gv%Boussinesq) h\_convert = gv%H\_to\_kg\_m2
1342   cs%id\_uh = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'uh'}, diag%axesCuL, time, &
1343       \textcolor{stringliteral}{'Zonal Thickness Flux'}, flux\_units, y\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., &
1344       conversion=h\_convert*us%L\_to\_m**2*us%s\_to\_T)
1345   cs%id\_vh = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vh'}, diag%axesCvL, time, &
1346       \textcolor{stringliteral}{'Meridional Thickness Flux'}, flux\_units, x\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., &
1347       conversion=h\_convert*us%L\_to\_m**2*us%s\_to\_T)
1348 
1349   cs%id\_CAu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CAu'}, diag%axesCuL, time, &
1350       \textcolor{stringliteral}{'Zonal Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'m s-2'}, conversion=us%L\_T2\_to\_m\_s2)
1351   cs%id\_CAv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CAv'}, diag%axesCvL, time, &
1352       \textcolor{stringliteral}{'Meridional Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'m s-2'}, conversion=us%L\_T2\_to\_m\_s2)
1353   cs%id\_PFu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFu'}, diag%axesCuL, time, &
1354       \textcolor{stringliteral}{'Zonal Pressure Force Acceleration'}, \textcolor{stringliteral}{'m s-2'}, conversion=us%L\_T2\_to\_m\_s2)
1355   cs%id\_PFv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFv'}, diag%axesCvL, time, &
1356       \textcolor{stringliteral}{'Meridional Pressure Force Acceleration'}, \textcolor{stringliteral}{'m s-2'}, conversion=us%L\_T2\_to\_m\_s2)
1357 
1358   \textcolor{comment}{!CS%id\_hf\_PFu = register\_diag\_field('ocean\_model', 'hf\_PFu', diag%axesCuL, Time, &}
1359   \textcolor{comment}{!    'Fractional Thickness-weighted Zonal Pressure Force Acceleration', 'm s-2', &}
1360   \textcolor{comment}{!    v\_extensive=.true., conversion=US%L\_T2\_to\_m\_s2)}
1361   \textcolor{comment}{!if(CS%id\_hf\_PFu > 0) call safe\_alloc\_ptr(CS%ADp%diag\_hfrac\_u,IsdB,IedB,jsd,jed,nz)}
1362 
1363   \textcolor{comment}{!CS%id\_hf\_PFv = register\_diag\_field('ocean\_model', 'hf\_PFv', diag%axesCvL, Time, &}
1364   \textcolor{comment}{!    'Fractional Thickness-weighted Meridional Pressure Force Acceleration', 'm s-2', &}
1365   \textcolor{comment}{!    v\_extensive=.true., conversion=US%L\_T2\_to\_m\_s2)}
1366   \textcolor{comment}{!if(CS%id\_hf\_PFv > 0) call safe\_alloc\_ptr(CS%ADp%diag\_hfrac\_v,isd,ied,Jsd,JedB,nz)}
1367 
1368   \textcolor{comment}{!CS%id\_hf\_CAu = register\_diag\_field('ocean\_model', 'hf\_CAu', diag%axesCuL, Time, &}
1369   \textcolor{comment}{!    'Fractional Thickness-weighted Zonal Coriolis and Advective Acceleration', 'm s-2', &}
1370   \textcolor{comment}{!    v\_extensive=.true., conversion=US%L\_T2\_to\_m\_s2)}
1371   \textcolor{comment}{!if(CS%id\_hf\_CAu > 0) call safe\_alloc\_ptr(CS%ADp%diag\_hfrac\_u,IsdB,IedB,jsd,jed,nz)}
1372 
1373   \textcolor{comment}{!CS%id\_hf\_CAv = register\_diag\_field('ocean\_model', 'hf\_CAv', diag%axesCvL, Time, &}
1374   \textcolor{comment}{!    'Fractional Thickness-weighted Meridional Coriolis and Advective Acceleration', 'm s-2', &}
1375   \textcolor{comment}{!    v\_extensive=.true., conversion=US%L\_T2\_to\_m\_s2)}
1376   \textcolor{comment}{!if(CS%id\_hf\_CAv > 0) call safe\_alloc\_ptr(CS%ADp%diag\_hfrac\_v,isd,ied,Jsd,JedB,nz)}
1377 
1378   cs%id\_hf\_PFu\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_PFu\_2d'}, diag%axesCu1, time, &
1379       \textcolor{stringliteral}{'Depth-sum Fractional Thickness-weighted Zonal Pressure Force Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
1380       conversion=us%L\_T2\_to\_m\_s2)
1381   \textcolor{keywordflow}{if}(cs%id\_hf\_PFu\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%diag\_hfrac\_u,isdb,iedb,jsd,jed,nz)
1382 
1383   cs%id\_hf\_PFv\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_PFv\_2d'}, diag%axesCv1, time, &
1384       \textcolor{stringliteral}{'Depth-sum Fractional Thickness-weighted Meridional Pressure Force Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
1385       conversion=us%L\_T2\_to\_m\_s2)
1386   \textcolor{keywordflow}{if}(cs%id\_hf\_PFv\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%diag\_hfrac\_v,isd,ied,jsd,jedb,nz)
1387 
1388   cs%id\_hf\_CAu\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_CAu\_2d'}, diag%axesCu1, time, &
1389       \textcolor{stringliteral}{'Depth-sum Fractional Thickness-weighted Zonal Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
1390       conversion=us%L\_T2\_to\_m\_s2)
1391   \textcolor{keywordflow}{if}(cs%id\_hf\_CAu\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%diag\_hfrac\_u,isdb,iedb,jsd,jed,nz)
1392 
1393   cs%id\_hf\_CAv\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_CAv\_2d'}, diag%axesCv1, time, &
1394       \textcolor{stringliteral}{'Depth-sum Fractional Thickness-weighted Meridional Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
1395       conversion=us%L\_T2\_to\_m\_s2)
1396   \textcolor{keywordflow}{if}(cs%id\_hf\_CAv\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%diag\_hfrac\_v,isd,ied,jsd,jedb,nz)
1397 
1398   cs%id\_uav = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'uav'}, diag%axesCuL, time, &
1399       \textcolor{stringliteral}{'Barotropic-step Averaged Zonal Velocity'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
1400   cs%id\_vav = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vav'}, diag%axesCvL, time, &
1401       \textcolor{stringliteral}{'Barotropic-step Averaged Meridional Velocity'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
1402 
1403   cs%id\_u\_BT\_accel = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_BT\_accel'}, diag%axesCuL, time, &
1404     \textcolor{stringliteral}{'Barotropic Anomaly Zonal Acceleration'}, \textcolor{stringliteral}{'m s-2'}, conversion=us%L\_T2\_to\_m\_s2)
1405   cs%id\_v\_BT\_accel = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_BT\_accel'}, diag%axesCvL, time, &
1406     \textcolor{stringliteral}{'Barotropic Anomaly Meridional Acceleration'}, \textcolor{stringliteral}{'m s-2'}, conversion=us%L\_T2\_to\_m\_s2)
1407 
1408   \textcolor{comment}{!CS%id\_hf\_u\_BT\_accel = register\_diag\_field('ocean\_model', 'hf\_u\_BT\_accel', diag%axesCuL, Time, &}
1409   \textcolor{comment}{!    'Fractional Thickness-weighted Barotropic Anomaly Zonal Acceleration', 'm s-2', &}
1410   \textcolor{comment}{!    v\_extensive=.true., conversion=US%L\_T2\_to\_m\_s2)}
1411   \textcolor{comment}{!if(CS%id\_hf\_u\_BT\_accel > 0) call safe\_alloc\_ptr(CS%ADp%diag\_hfrac\_u,IsdB,IedB,jsd,jed,nz)}
1412 
1413   \textcolor{comment}{!CS%id\_hf\_v\_BT\_accel = register\_diag\_field('ocean\_model', 'hf\_v\_BT\_accel', diag%axesCvL, Time, &}
1414   \textcolor{comment}{!    'Fractional Thickness-weighted Barotropic Anomaly Meridional Acceleration', 'm s-2', &}
1415   \textcolor{comment}{!    v\_extensive=.true., conversion=US%L\_T2\_to\_m\_s2)}
1416   \textcolor{comment}{!if(CS%id\_hf\_v\_BT\_accel > 0) call safe\_alloc\_ptr(CS%ADp%diag\_hfrac\_v,isd,ied,Jsd,JedB,nz)}
1417 
1418   cs%id\_hf\_u\_BT\_accel\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_u\_BT\_accel\_2d'}, diag%axesCu1, time, &
1419       \textcolor{stringliteral}{'Depth-sum Fractional Thickness-weighted Barotropic Anomaly Zonal Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
1420       conversion=us%L\_T2\_to\_m\_s2)
1421   \textcolor{keywordflow}{if}(cs%id\_hf\_u\_BT\_accel\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%diag\_hfrac\_u,isdb,iedb,jsd,jed,nz)
1422 
1423   cs%id\_hf\_v\_BT\_accel\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_v\_BT\_accel\_2d'}, diag%axesCv1, time, &
1424       \textcolor{stringliteral}{'Depth-sum Fractional Thickness-weighted Barotropic Anomaly Meridional Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
1425       conversion=us%L\_T2\_to\_m\_s2)
1426   \textcolor{keywordflow}{if}(cs%id\_hf\_v\_BT\_accel\_2d > 0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%diag\_hfrac\_v,isd,ied,jsd,jedb,nz)
1427 
1428   id\_clock\_cor        = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean Coriolis & mom advection)'}, grain=clock\_module)
1429   id\_clock\_continuity = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean continuity equation)'},      grain=clock\_module)
1430   id\_clock\_pres       = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean pressure force)'},           grain=clock\_module)
1431   id\_clock\_vertvisc   = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean vertical viscosity)'},       grain=clock\_module)
1432   id\_clock\_horvisc    = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean horizontal viscosity)'},     grain=clock\_module)
1433   id\_clock\_mom\_update = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean momentum increments)'},      grain=clock\_module)
1434   id\_clock\_pass       = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean message passing)'},          grain=clock\_module)
1435   id\_clock\_btcalc     = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean barotropic mode calc)'},     grain=clock\_module)
1436   id\_clock\_btstep     = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean barotropic mode stepping)'}, grain=clock\_module)
1437   id\_clock\_btforce    = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean barotropic forcing calc)'},  grain=clock\_module)
1438 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a9f889b82fd5ed29a854da99d3c929366}\label{namespacemom__dynamics__split__rk2_a9f889b82fd5ed29a854da99d3c929366}} 
\index{mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}!register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+rk2@{register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+rk2}}
\index{register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+rk2@{register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+rk2}!mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}}
\subsubsection{\texorpdfstring{register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+rk2()}{register\_restarts\_dyn\_split\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+split\+\_\+rk2\+::register\+\_\+restarts\+\_\+dyn\+\_\+split\+\_\+rk2 (\begin{DoxyParamCaption}\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structmom__dynamics__split__rk2_1_1mom__dyn__split__rk2__cs}{mom\+\_\+dyn\+\_\+split\+\_\+rk2\+\_\+cs}), pointer}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS,  }\item[{real, dimension(szib\+\_\+(hi),szj\+\_\+(hi),szk\+\_\+(gv)), intent(inout), target}]{uh,  }\item[{real, dimension(szi\+\_\+(hi),szjb\+\_\+(hi),szk\+\_\+(gv)), intent(inout), target}]{vh }\end{DoxyParamCaption})}



This subroutine sets up any auxiliary restart variables that are specific to the unsplit time stepping scheme. All variables registered here should have the ability to be recreated if they are not present in a restart file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi} & Horizontal index structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & parameter file\\
\hline
 & {\em cs} & module control structure\\
\hline
 & {\em restart\+\_\+cs} & restart control structure\\
\hline
\mbox{\tt in,out}  & {\em uh} & zonal volume/mass transport \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em vh} & merid volume/mass transport \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1001 of file M\+O\+M\+\_\+dynamics\+\_\+split\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
1001   \textcolor{keywordtype}{type}(hor\_index\_type),          \textcolor{keywordtype}{intent(in)}    :: hi\textcolor{comment}{         !< Horizontal index structure}
1002   \textcolor{keywordtype}{type}(verticalgrid\_type),       \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{         !< ocean vertical grid structure}
1003   \textcolor{keywordtype}{type}(param\_file\_type),         \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< parameter file}
1004   \textcolor{keywordtype}{type}(mom\_dyn\_split\_rk2\_cs),    \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{         !< module control structure}
1005   \textcolor{keywordtype}{type}(mom\_restart\_cs),          \textcolor{keywordtype}{pointer}       :: restart\_cs\textcolor{comment}{ !< restart control structure}
1006   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(HI),SZJ\_(HI),SZK\_(GV))}, &
1007                          \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: uh\textcolor{comment}{ !< zonal volume/mass transport [H L2 T-1 ~> m3 s-1 or
       kg s-1]}
1008   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(HI),SZJB\_(HI),SZK\_(GV))}, &
1009                          \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: vh\textcolor{comment}{ !< merid volume/mass transport [H L2 T-1 ~> m3 s-1 or
       kg s-1]}
1010 
1011   \textcolor{keywordtype}{type}(vardesc)      :: vd(2)
1012   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_dynamics\_split\_RK2"} \textcolor{comment}{! This module's name.}
1013   \textcolor{keywordtype}{character(len=48)}  :: thickness\_units, flux\_units
1014 
1015   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, isdb, iedb, jsdb, jedb
1016 
1017   isd  = hi%isd  ; ied  = hi%ied  ; jsd  = hi%jsd  ; jed  = hi%jed ; nz = gv%ke
1018   isdb = hi%IsdB ; iedb = hi%IedB ; jsdb = hi%JsdB ; jedb = hi%JedB
1019 
1020   \textcolor{comment}{! This is where a control structure specific to this module would be allocated.}
1021   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
1022     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_restarts\_dyn\_split\_RK2 called with an associated "}// &
1023                              \textcolor{stringliteral}{"control structure."})
1024     \textcolor{keywordflow}{return}
1025 \textcolor{keywordflow}{  endif}
1026   \textcolor{keyword}{allocate}(cs)
1027 
1028   alloc\_(cs%diffu(isdb:iedb,jsd:jed,nz)) ; cs%diffu(:,:,:) = 0.0
1029   alloc\_(cs%diffv(isd:ied,jsdb:jedb,nz)) ; cs%diffv(:,:,:) = 0.0
1030   alloc\_(cs%CAu(isdb:iedb,jsd:jed,nz))   ; cs%CAu(:,:,:)   = 0.0
1031   alloc\_(cs%CAv(isd:ied,jsdb:jedb,nz))   ; cs%CAv(:,:,:)   = 0.0
1032   alloc\_(cs%PFu(isdb:iedb,jsd:jed,nz))   ; cs%PFu(:,:,:)   = 0.0
1033   alloc\_(cs%PFv(isd:ied,jsdb:jedb,nz))   ; cs%PFv(:,:,:)   = 0.0
1034 
1035   alloc\_(cs%eta(isd:ied,jsd:jed))       ; cs%eta(:,:)    = 0.0
1036   alloc\_(cs%u\_av(isdb:iedb,jsd:jed,nz)) ; cs%u\_av(:,:,:) = 0.0
1037   alloc\_(cs%v\_av(isd:ied,jsdb:jedb,nz)) ; cs%v\_av(:,:,:) = 0.0
1038   alloc\_(cs%h\_av(isd:ied,jsd:jed,nz))   ; cs%h\_av(:,:,:) = gv%Angstrom\_H
1039 
1040   thickness\_units = get\_thickness\_units(gv)
1041   flux\_units = get\_flux\_units(gv)
1042 
1043   \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then}
1044     vd(1) = var\_desc(\textcolor{stringliteral}{"sfc"},thickness\_units,\textcolor{stringliteral}{"Free surface Height"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'})
1045   \textcolor{keywordflow}{else}
1046     vd(1) = var\_desc(\textcolor{stringliteral}{"p\_bot"},thickness\_units,\textcolor{stringliteral}{"Bottom Pressure"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'})
1047 \textcolor{keywordflow}{  endif}
1048   \textcolor{keyword}{call }register\_restart\_field(cs%eta, vd(1), .false., restart\_cs)
1049 
1050   vd(1) = var\_desc(\textcolor{stringliteral}{"u2"},\textcolor{stringliteral}{"m s-1"},\textcolor{stringliteral}{"Auxiliary Zonal velocity"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'L'})
1051   vd(2) = var\_desc(\textcolor{stringliteral}{"v2"},\textcolor{stringliteral}{"m s-1"},\textcolor{stringliteral}{"Auxiliary Meridional velocity"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'L'})
1052   \textcolor{keyword}{call }register\_restart\_pair(cs%u\_av, cs%v\_av, vd(1), vd(2), .false., restart\_cs)
1053 
1054   vd(1) = var\_desc(\textcolor{stringliteral}{"h2"},thickness\_units,\textcolor{stringliteral}{"Auxiliary Layer Thickness"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'L'})
1055   \textcolor{keyword}{call }register\_restart\_field(cs%h\_av, vd(1), .false., restart\_cs)
1056 
1057   vd(1) = var\_desc(\textcolor{stringliteral}{"uh"},flux\_units,\textcolor{stringliteral}{"Zonal thickness flux"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'L'})
1058   vd(2) = var\_desc(\textcolor{stringliteral}{"vh"},flux\_units,\textcolor{stringliteral}{"Meridional thickness flux"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'L'})
1059   \textcolor{keyword}{call }register\_restart\_pair(uh, vh, vd(1), vd(2), .false., restart\_cs)
1060 
1061   vd(1) = var\_desc(\textcolor{stringliteral}{"diffu"},\textcolor{stringliteral}{"m s-2"},\textcolor{stringliteral}{"Zonal horizontal viscous acceleration"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'L'})
1062   vd(2) = var\_desc(\textcolor{stringliteral}{"diffv"},\textcolor{stringliteral}{"m s-2"},\textcolor{stringliteral}{"Meridional horizontal viscous acceleration"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'L'})
1063   \textcolor{keyword}{call }register\_restart\_pair(cs%diffu, cs%diffv, vd(1), vd(2), .false., restart\_cs)
1064 
1065   \textcolor{keyword}{call }register\_barotropic\_restarts(hi, gv, param\_file, cs%barotropic\_CSp, &
1066                                     restart\_cs)
1067 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__split__rk2_a976e700971f232fc11bc69b31d611c32}\label{namespacemom__dynamics__split__rk2_a976e700971f232fc11bc69b31d611c32}} 
\index{mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}!step\+\_\+mom\+\_\+dyn\+\_\+split\+\_\+rk2@{step\+\_\+mom\+\_\+dyn\+\_\+split\+\_\+rk2}}
\index{step\+\_\+mom\+\_\+dyn\+\_\+split\+\_\+rk2@{step\+\_\+mom\+\_\+dyn\+\_\+split\+\_\+rk2}!mom\+\_\+dynamics\+\_\+split\+\_\+rk2@{mom\+\_\+dynamics\+\_\+split\+\_\+rk2}}
\subsubsection{\texorpdfstring{step\+\_\+mom\+\_\+dyn\+\_\+split\+\_\+rk2()}{step\_mom\_dyn\_split\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+split\+\_\+rk2\+::step\+\_\+mom\+\_\+dyn\+\_\+split\+\_\+rk2 (\begin{DoxyParamCaption}\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout), target}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout), target}]{v,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(vertvisc\+\_\+type), intent(inout)}]{visc,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+local,  }\item[{real, intent(in)}]{dt,  }\item[{type(mech\+\_\+forcing), intent(in)}]{forces,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf\+\_\+begin,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf\+\_\+end,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout), target}]{uh,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout), target}]{vh,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{uhtr,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{vhtr,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(out)}]{eta\+\_\+av,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\hyperlink{structmom__dynamics__split__rk2_1_1mom__dyn__split__rk2__cs}{mom\+\_\+dyn\+\_\+split\+\_\+rk2\+\_\+cs}), pointer}]{CS,  }\item[{logical, intent(in)}]{calc\+\_\+dtbt,  }\item[{type(varmix\+\_\+cs), pointer}]{Var\+Mix,  }\item[{type(meke\+\_\+type), pointer}]{M\+E\+KE,  }\item[{type(thickness\+\_\+diffuse\+\_\+cs), pointer}]{thickness\+\_\+diffuse\+\_\+\+C\+Sp,  }\item[{type(wave\+\_\+parameters\+\_\+cs), optional, pointer}]{Waves }\end{DoxyParamCaption})}



R\+K2 splitting for time stepping M\+OM adiabatic dynamics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em u} & zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em v} & merid velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tv} & thermodynamic type\\
\hline
\mbox{\tt in,out}  & {\em visc} & vertical visc, bottom drag, and related\\
\hline
\mbox{\tt in}  & {\em time\+\_\+local} & model time at end of time step\\
\hline
\mbox{\tt in}  & {\em dt} & time step \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
 & {\em p\+\_\+surf\+\_\+begin} & surf pressure at the start of this dynamic time step \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
 & {\em p\+\_\+surf\+\_\+end} & surf pressure at the end of this dynamic time step \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em uh} & zonal volume/mass transport\\
\hline
\mbox{\tt in,out}  & {\em vh} & merid volume/mass transport\\
\hline
\mbox{\tt in,out}  & {\em uhtr} & accumulatated zonal volume/mass transport\\
\hline
\mbox{\tt in,out}  & {\em vhtr} & accumulatated merid volume/mass transport\\
\hline
\mbox{\tt out}  & {\em eta\+\_\+av} & free surface height or column mass time averaged over time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
 & {\em cs} & module control structure\\
\hline
\mbox{\tt in}  & {\em calc\+\_\+dtbt} & if true, recalculate barotropic time step\\
\hline
 & {\em varmix} & specify the spatially varying viscosities\\
\hline
 & {\em meke} & related to mesoscale eddy kinetic energy param\\
\hline
 & {\em thickness\+\_\+diffuse\+\_\+csp} & Pointer to a structure containing interface height diffusivities\\
\hline
 & {\em waves} & A pointer to a structure containing fields related to the surface wave conditions \\
\hline
\end{DoxyParams}


Definition at line 245 of file M\+O\+M\+\_\+dynamics\+\_\+split\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
245   \textcolor{keywordtype}{type}(ocean\_grid\_type),             \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{            !< ocean grid structure}
246   \textcolor{keywordtype}{type}(verticalgrid\_type),           \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{           !< ocean vertical grid structure}
247   \textcolor{keywordtype}{type}(unit\_scale\_type),             \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{           !< A dimensional unit scaling type}
248   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, &
249                              \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{            !< zonal velocity [L T-1 ~> m s-1]}
250   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, &
251                              \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{            !< merid velocity [L T-1 ~> m s-1]}
252   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  &
253                                      \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{            !< layer thickness [H ~> m or kg m-2]}
254   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),             \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{           !< thermodynamic type}
255   \textcolor{keywordtype}{type}(vertvisc\_type),               \textcolor{keywordtype}{intent(inout)} :: visc\textcolor{comment}{         !< vertical visc, bottom drag, and
       related}
256   \textcolor{keywordtype}{type}(time\_type),                   \textcolor{keywordtype}{intent(in)}    :: time\_local\textcolor{comment}{   !< model time at end of time step}
257   \textcolor{keywordtype}{real},                              \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{           !< time step [T ~> s]}
258   \textcolor{keywordtype}{type}(mech\_forcing),                \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{       !< A structure with the driving
       mechanical forces}
259   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},              \textcolor{keywordtype}{pointer}       :: p\_surf\_begin\textcolor{comment}{ !< surf pressure at the start of this
       dynamic}
260 \textcolor{comment}{                                                                   !! time step [R L2 T-2 ~> Pa]}
261   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},              \textcolor{keywordtype}{pointer}       :: p\_surf\_end\textcolor{comment}{   !< surf pressure at the end of this
       dynamic}
262 \textcolor{comment}{                                                                   !! time step [R L2 T-2 ~> Pa]}
263   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, &
264                              \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: uh\textcolor{comment}{           !< zonal volume/mass transport}
265 \textcolor{comment}{                                                                   !! [H L2 T-1 ~> m3 s-1 or kg s-1]}
266   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, &
267                              \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: vh\textcolor{comment}{           !< merid volume/mass transport}
268 \textcolor{comment}{                                                                   !! [H L2 T-1 ~> m3 s-1 or kg s-1]}
269   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, &
270                                      \textcolor{keywordtype}{intent(inout)} :: uhtr\textcolor{comment}{         !< accumulatated zonal volume/mass
       transport}
271 \textcolor{comment}{                                                                   !! since last tracer advection [H L2 ~>
       m3 or kg]}
272   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, &
273                                      \textcolor{keywordtype}{intent(inout)} :: vhtr\textcolor{comment}{         !< accumulatated merid volume/mass
       transport}
274 \textcolor{comment}{                                                                   !! since last tracer advection [H L2 ~>
       m3 or kg]}
275   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},  \textcolor{keywordtype}{intent(out)}   :: eta\_av\textcolor{comment}{       !< free surface height or column mass
       time}
276 \textcolor{comment}{                                                                   !! averaged over time step [H ~> m or kg
       m-2]}
277   \textcolor{keywordtype}{type}(mom\_dyn\_split\_rk2\_cs),        \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{           !< module control structure}
278   \textcolor{keywordtype}{logical},                           \textcolor{keywordtype}{intent(in)}    :: calc\_dtbt\textcolor{comment}{    !< if true, recalculate barotropic time
       step}
279   \textcolor{keywordtype}{type}(varmix\_cs),                   \textcolor{keywordtype}{pointer}       :: varmix\textcolor{comment}{       !< specify the spatially varying
       viscosities}
280   \textcolor{keywordtype}{type}(meke\_type),                   \textcolor{keywordtype}{pointer}       :: meke\textcolor{comment}{         !< related to mesoscale eddy kinetic
       energy param}
281   \textcolor{keywordtype}{type}(thickness\_diffuse\_cs),        \textcolor{keywordtype}{pointer}       :: thickness\_diffuse\_csp\textcolor{comment}{ !< Pointer to a structure
       containing}
282 \textcolor{comment}{                                                                   !! interface height diffusivities}
283   \textcolor{keywordtype}{type}(wave\_parameters\_cs), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}      :: waves\textcolor{comment}{        !< A pointer to a structure containing}
284 \textcolor{comment}{                                                                   !! fields related to the surface wave
       conditions}
285 
286   \textcolor{comment}{! local variables}
287   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))} :: up   \textcolor{comment}{! Predicted zonal velocity [L T-1 ~> m s-1].}
288   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))} :: vp   \textcolor{comment}{! Predicted meridional velocity [L T-1 ~> m s-1].}
289   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}  :: hp   \textcolor{comment}{! Predicted thickness [H ~> m or kg m-2].}
290 
291   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))} :: u\_bc\_accel
292   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))} :: v\_bc\_accel
293     \textcolor{comment}{! u\_bc\_accel and v\_bc\_accel are the summed baroclinic accelerations of each}
294     \textcolor{comment}{! layer calculated by the non-barotropic part of the model [L T-2 ~> m s-2].}
295 
296   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{target} :: uh\_in
297   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{target} :: vh\_in
298     \textcolor{comment}{! uh\_in and vh\_in are the zonal or meridional mass transports that would be}
299     \textcolor{comment}{! obtained using the initial velocities [H L2 T-1 ~> m3 s-1 or kg s-1].}
300 
301   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G))} :: uhbt\_out
302   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G))} :: vhbt\_out
303     \textcolor{comment}{! uhbt\_out and vhbt\_out are the vertically summed transports from the}
304     \textcolor{comment}{! barotropic solver based on its final velocities [H m2 s-1 ~> m3 s-1 or kg s-1].}
305 
306   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: eta\_pred
307     \textcolor{comment}{! eta\_pred is the predictor value of the free surface height or column mass,}
308     \textcolor{comment}{! [H ~> m or kg m-2].}
309 
310   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))} :: u\_old\_rad\_obc
311   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))} :: v\_old\_rad\_obc
312     \textcolor{comment}{! u\_old\_rad\_OBC and v\_old\_rad\_OBC are the starting velocities, which are}
313     \textcolor{comment}{! saved for use in the Flather open boundary condition code [L T-1 ~> m s-1].}
314 
315   \textcolor{keywordtype}{real} :: pres\_to\_eta \textcolor{comment}{! A factor that converts pressures to the units of eta}
316                       \textcolor{comment}{! [H T2 R-1 L-2 ~> m Pa-1 or kg m-2 Pa-1]}
317   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:)} :: &
318     p\_surf => null(), eta\_pf\_start => null(), &
319     taux\_bot => null(), tauy\_bot => null(), &
320     eta => null()
321 
322   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:,:)} :: &
323     uh\_ptr => null(), u\_ptr => null(),  vh\_ptr => null(), v\_ptr => null(), &
324     u\_av, & \textcolor{comment}{! The zonal velocity time-averaged over a time step [L T-1 ~> m s-1].}
325     v\_av, & \textcolor{comment}{! The meridional velocity time-averaged over a time step [L T-1 ~> m s-1].}
326     h\_av    \textcolor{comment}{! The layer thickness time-averaged over a time step [H ~> m or kg m-2].}
327 
328   \textcolor{comment}{! real, allocatable, dimension(:,:,:) :: &}
329     \textcolor{comment}{! hf\_PFu, hf\_PFv, & ! Pressure force accel. x fract. thickness [L T-2 ~> m s-2].}
330     \textcolor{comment}{! hf\_CAu, hf\_CAv, & ! Coriolis force accel. x fract. thickness [L T-2 ~> m s-2].}
331     \textcolor{comment}{! hf\_u\_BT\_accel, hf\_v\_BT\_accel ! barotropic correction accel. x fract. thickness [L T-2 ~> m s-2].}
332     \textcolor{comment}{! 3D diagnostics hf\_PFu etc. are commented because there is no clarity on proper remapping grid option.}
333     \textcolor{comment}{! The code is retained for degugging purposes in the future.}
334 
335   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: &
336     hf\_pfu\_2d, hf\_pfv\_2d, & \textcolor{comment}{! Depth integeral of hf\_PFu, hf\_PFv [L T-2 ~> m s-2].}
337     hf\_cau\_2d, hf\_cav\_2d, & \textcolor{comment}{! Depth integeral of hf\_CAu, hf\_CAv [L T-2 ~> m s-2].}
338     hf\_u\_bt\_accel\_2d, hf\_v\_bt\_accel\_2d \textcolor{comment}{! Depth integeral of hf\_u\_BT\_accel, hf\_v\_BT\_accel}
339 
340   \textcolor{keywordtype}{real} :: dt\_pred   \textcolor{comment}{! The time step for the predictor part of the baroclinic time stepping [T ~> s].}
341 
342   \textcolor{keywordtype}{logical} :: dyn\_p\_surf
343   \textcolor{keywordtype}{logical} :: bt\_cont\_bt\_thick \textcolor{comment}{! If true, use the BT\_cont\_type to estimate the}
344                               \textcolor{comment}{! relative weightings of the layers in calculating}
345                               \textcolor{comment}{! the barotropic accelerations.}
346   \textcolor{comment}{!---For group halo pass}
347   \textcolor{keywordtype}{logical} :: showcalltree, sym
348 
349   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isq, ieq, jsq, jeq, nz
350   \textcolor{keywordtype}{integer} :: cont\_stencil
351   is  = g%isc  ; ie  = g%iec  ; js  = g%jsc  ; je  = g%jec ; nz = g%ke
352   isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
353   u\_av => cs%u\_av ; v\_av => cs%v\_av ; h\_av => cs%h\_av ; eta => cs%eta
354 
355   sym=.false.;\textcolor{keywordflow}{if} (g%Domain%symmetric) sym=.true.  \textcolor{comment}{! switch to include symmetric domain in checksums}
356 
357   showcalltree = calltree\_showquery()
358   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"step\_MOM\_dyn\_split\_RK2(), MOM\_dynamics\_split\_RK2.F90"})
359 
360   \textcolor{comment}{!$OMP parallel do default(shared)}
361   \textcolor{keywordflow}{do} k=1,nz
362     \textcolor{keywordflow}{do} j=g%jsd,g%jed   ; \textcolor{keywordflow}{do} i=g%isdB,g%iedB ;  up(i,j,k) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
363     \textcolor{keywordflow}{do} j=g%jsdB,g%jedB ; \textcolor{keywordflow}{do} i=g%isd,g%ied   ;  vp(i,j,k) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
364     \textcolor{keywordflow}{do} j=g%jsd,g%jed   ; \textcolor{keywordflow}{do} i=g%isd,g%ied   ;  hp(i,j,k) = h(i,j,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
365 \textcolor{keywordflow}{  enddo}
366 
367   \textcolor{comment}{! Update CFL truncation value as function of time}
368   \textcolor{keyword}{call }updatecfltruncationvalue(time\_local, cs%vertvisc\_CSp)
369 
370   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
371     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Start predictor "}, u, v, h, uh, vh, g, gv, us, symmetric=sym)
372     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Start predictor u "}, u, v, g)
373     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Start predictor uh "}, uh, vh, g)
374 \textcolor{keywordflow}{  endif}
375 
376   dyn\_p\_surf = \textcolor{keyword}{associated}(p\_surf\_begin) .and. \textcolor{keyword}{associated}(p\_surf\_end)
377   \textcolor{keywordflow}{if} (dyn\_p\_surf) \textcolor{keywordflow}{then}
378     p\_surf => p\_surf\_end
379     \textcolor{keyword}{call }safe\_alloc\_ptr(eta\_pf\_start,g%isd,g%ied,g%jsd,g%jed)
380     eta\_pf\_start(:,:) = 0.0
381   \textcolor{keywordflow}{else}
382     p\_surf => forces%p\_surf
383 \textcolor{keywordflow}{  endif}
384 
385   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
386     \textcolor{keywordflow}{if} (cs%debug\_OBC) \textcolor{keyword}{call }open\_boundary\_test\_extern\_h(g, gv, cs%OBC, h)
387 
388     \textcolor{comment}{! Update OBC ramp value as function of time}
389     \textcolor{keyword}{call }update\_obc\_ramp(time\_local, cs%OBC)
390 
391     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%IsdB,g%IedB
392       u\_old\_rad\_obc(i,j,k) = u\_av(i,j,k)
393 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
394     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=g%JsdB,g%JedB ; \textcolor{keywordflow}{do} i=g%isd,g%ied
395       v\_old\_rad\_obc(i,j,k) = v\_av(i,j,k)
396 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
397 \textcolor{keywordflow}{  endif}
398 
399   bt\_cont\_bt\_thick = .false.
400   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%BT\_cont)) bt\_cont\_bt\_thick = &
401     (\textcolor{keyword}{allocated}(cs%BT\_cont%h\_u) .and. \textcolor{keyword}{allocated}(cs%BT\_cont%h\_v))
402 
403   \textcolor{keywordflow}{if} (cs%split\_bottom\_stress) \textcolor{keywordflow}{then}
404     taux\_bot => cs%taux\_bot ; tauy\_bot => cs%tauy\_bot
405 \textcolor{keywordflow}{  endif}
406 
407   \textcolor{comment}{!--- begin set up for group halo pass}
408 
409   cont\_stencil = continuity\_stencil(cs%continuity\_CSp)
410   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)
411   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_eta, eta, g%Domain, halo=1)
412   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_visc\_rem, cs%visc\_rem\_u, cs%visc\_rem\_v, g%Domain, &
413                          to\_all+scalar\_pair, cgrid\_ne, halo=max(1,cont\_stencil))
414   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_uvp, up, vp, g%Domain, halo=max(1,cont\_stencil))
415   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_hp\_uv, hp, g%Domain, halo=2)
416   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_hp\_uv, u\_av, v\_av, g%Domain, halo=2)
417   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_hp\_uv, uh(:,:,:), vh(:,:,:), g%Domain, halo=2)
418 
419   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_uv, u, v, g%Domain, halo=max(2,cont\_stencil))
420   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_h, h, g%Domain, halo=max(2,cont\_stencil))
421   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_av\_uvh, u\_av, v\_av, g%Domain, halo=2)
422   \textcolor{keyword}{call }create\_group\_pass(cs%pass\_av\_uvh, uh(:,:,:), vh(:,:,:), g%Domain, halo=2)
423   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)
424   \textcolor{comment}{!--- end set up for group halo pass}
425 
426 
427 \textcolor{comment}{! PFu = d/dx M(h,T,S)}
428 \textcolor{comment}{! pbce = dM/deta}
429   \textcolor{keywordflow}{if} (cs%begw == 0.0) \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
430   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pres)
431   \textcolor{keyword}{call }pressureforce(h, tv, cs%PFu, cs%PFv, g, gv, us, cs%PressureForce\_CSp, &
432                      cs%ALE\_CSp, p\_surf, cs%pbce, cs%eta\_PF)
433   \textcolor{keywordflow}{if} (dyn\_p\_surf) \textcolor{keywordflow}{then}
434     pres\_to\_eta = 1.0 / (gv%g\_Earth * gv%H\_to\_RZ)
435     \textcolor{comment}{!$OMP parallel do default(shared)}
436     \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1
437       eta\_pf\_start(i,j) = cs%eta\_PF(i,j) - pres\_to\_eta * (p\_surf\_begin(i,j) - p\_surf\_end(i,j))
438 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
439 \textcolor{keywordflow}{  endif}
440   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pres)
441   \textcolor{keyword}{call }disable\_averaging(cs%diag)
442   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with PressureForce (step\_MOM\_dyn\_split\_RK2)"})
443 
444   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) then; \textcolor{keywordflow}{if} (cs%OBC%update\_OBC) \textcolor{keywordflow}{then}
445     \textcolor{keyword}{call }update\_obc\_data(cs%OBC, g, gv, us, tv, h, cs%update\_OBC\_CSp, time\_local)
446 \textcolor{keyword}{  end}if; endif
447   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC) .and. cs%debug\_OBC) &
448     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%PFu, cs%PFv)
449 
450   \textcolor{keywordflow}{if} (g%nonblocking\_updates) &
451     \textcolor{keyword}{call }start\_group\_pass(cs%pass\_eta, g%Domain, clock=id\_clock\_pass)
452 
453 \textcolor{comment}{! CAu = -(f+zeta\_av)/h\_av vh + d/dx KE\_av}
454   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_cor)
455   \textcolor{keyword}{call }coradcalc(u\_av, v\_av, h\_av, uh, vh, cs%CAu, cs%CAv, cs%OBC, cs%ADp, &
456                  g, gv, us, cs%CoriolisAdv\_CSp)
457   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_cor)
458   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with CorAdCalc (step\_MOM\_dyn\_split\_RK2)"})
459 
460 \textcolor{comment}{! u\_bc\_accel = CAu + PFu + diffu(u[n-1])}
461   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_btforce)
462   \textcolor{comment}{!$OMP parallel do default(shared)}
463   \textcolor{keywordflow}{do} k=1,nz
464     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
465       u\_bc\_accel(i,j,k) = (cs%CAu(i,j,k) + cs%PFu(i,j,k)) + cs%diffu(i,j,k)
466 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
467     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
468       v\_bc\_accel(i,j,k) = (cs%CAv(i,j,k) + cs%PFv(i,j,k)) + cs%diffv(i,j,k)
469 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
470 \textcolor{keywordflow}{  enddo}
471   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
472     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, u\_bc\_accel, v\_bc\_accel)
473 \textcolor{keywordflow}{  endif}
474   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_btforce)
475 
476   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
477     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"pre-btstep accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
478                           cs%diffu, cs%diffv, g, gv, us, cs%pbce, u\_bc\_accel, v\_bc\_accel, &
479                           symmetric=sym)
480     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"pre-btstep CS%Ca "}, cs%Cau, cs%Cav, g)
481     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"pre-btstep CS%PF "}, cs%PFu, cs%PFv, g)
482     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"pre-btstep CS%diff "}, cs%diffu, cs%diffv, g)
483     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"pre-btstep u\_bc\_accel "}, u\_bc\_accel, v\_bc\_accel, g)
484 \textcolor{keywordflow}{  endif}
485 
486   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
487   \textcolor{comment}{!$OMP parallel do default(shared)}
488   \textcolor{keywordflow}{do} k=1,nz
489     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
490       up(i,j,k) = g%mask2dCu(i,j) * (u(i,j,k) + dt * u\_bc\_accel(i,j,k))
491 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
492     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
493       vp(i,j,k) = g%mask2dCv(i,j) * (v(i,j,k) + dt * v\_bc\_accel(i,j,k))
494 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
495 \textcolor{keywordflow}{  enddo}
496 
497   \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
498   \textcolor{keyword}{call }set\_viscous\_ml(u, v, h, tv, forces, visc, dt, g, gv, us, &
499                       cs%set\_visc\_CSp)
500   \textcolor{keyword}{call }disable\_averaging(cs%diag)
501 
502   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
503     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"before vertvisc: up"}, up, vp, g%HI, haloshift=0, symmetric=sym, scale=us%L\_T\_to\_m\_s)
504 \textcolor{keywordflow}{  endif}
505   \textcolor{keyword}{call }vertvisc\_coef(up, vp, h, forces, visc, dt, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
506   \textcolor{keyword}{call }vertvisc\_remnant(visc, cs%visc\_rem\_u, cs%visc\_rem\_v, dt, g, gv, us, cs%vertvisc\_CSp)
507   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
508   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with vertvisc\_coef (step\_MOM\_dyn\_split\_RK2)"})
509 
510 
511   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)
512   \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
513     \textcolor{keyword}{call }complete\_group\_pass(cs%pass\_eta, g%Domain)
514     \textcolor{keyword}{call }start\_group\_pass(cs%pass\_visc\_rem, g%Domain)
515   \textcolor{keywordflow}{else}
516     \textcolor{keyword}{call }do\_group\_pass(cs%pass\_eta, g%Domain)
517     \textcolor{keyword}{call }do\_group\_pass(cs%pass\_visc\_rem, g%Domain)
518 \textcolor{keywordflow}{  endif}
519   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)
520 
521   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_btcalc)
522   \textcolor{comment}{! Calculate the relative layer weights for determining barotropic quantities.}
523   \textcolor{keywordflow}{if} (.not.bt\_cont\_bt\_thick) &
524     \textcolor{keyword}{call }btcalc(h, g, gv, cs%barotropic\_CSp, obc=cs%OBC)
525   \textcolor{keyword}{call }bt\_mass\_source(h, eta, .true., g, gv, cs%barotropic\_CSp)
526   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_btcalc)
527 
528   \textcolor{keywordflow}{if} (g%nonblocking\_updates) &
529     \textcolor{keyword}{call }complete\_group\_pass(cs%pass\_visc\_rem, g%Domain, clock=id\_clock\_pass)
530 
531 \textcolor{comment}{! u\_accel\_bt = layer accelerations due to barotropic solver}
532   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%BT\_cont) .or. cs%BT\_use\_layer\_fluxes) \textcolor{keywordflow}{then}
533     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
534     \textcolor{keyword}{call }continuity(u, v, h, hp, uh\_in, vh\_in, dt, g, gv, us, cs%continuity\_CSp, &
535                     obc=cs%OBC, visc\_rem\_u=cs%visc\_rem\_u, visc\_rem\_v=cs%visc\_rem\_v, bt\_cont=cs%BT\_cont)
536     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
537     \textcolor{keywordflow}{if} (bt\_cont\_bt\_thick) \textcolor{keywordflow}{then}
538       \textcolor{keyword}{call }btcalc(h, g, gv, cs%barotropic\_CSp, cs%BT\_cont%h\_u, cs%BT\_cont%h\_v, &
539                   obc=cs%OBC)
540 \textcolor{keywordflow}{    endif}
541     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with continuity[BT\_cont] (step\_MOM\_dyn\_split\_RK2)"})
542 \textcolor{keywordflow}{  endif}
543 
544   \textcolor{keywordflow}{if} (cs%BT\_use\_layer\_fluxes) \textcolor{keywordflow}{then}
545     uh\_ptr => uh\_in ; vh\_ptr => vh\_in; u\_ptr => u ; v\_ptr => v
546 \textcolor{keywordflow}{  endif}
547 
548   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_btstep)
549   \textcolor{keywordflow}{if} (calc\_dtbt) \textcolor{keyword}{call }set\_dtbt(g, gv, us, cs%barotropic\_CSp, eta, cs%pbce)
550   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"btstep(), MOM\_barotropic.F90"})
551   \textcolor{comment}{! This is the predictor step call to btstep.}
552   \textcolor{keyword}{call }btstep(u, v, eta, dt, u\_bc\_accel, v\_bc\_accel, forces, cs%pbce, cs%eta\_PF, &
553               u\_av, v\_av, cs%u\_accel\_bt, cs%v\_accel\_bt, eta\_pred, cs%uhbt, cs%vhbt, &
554               g, gv, us, cs%barotropic\_CSp, cs%visc\_rem\_u, cs%visc\_rem\_v, adp=cs%ADp, &
555               obc=cs%OBC, bt\_cont=cs%BT\_cont, eta\_pf\_start=eta\_pf\_start, &
556               taux\_bot=taux\_bot, tauy\_bot=tauy\_bot, &
557               uh0=uh\_ptr, vh0=vh\_ptr, u\_uh0=u\_ptr, v\_vh0=v\_ptr)
558   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"btstep()"})
559   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_btstep)
560 
561 \textcolor{comment}{! up = u + dt\_pred*( u\_bc\_accel + u\_accel\_bt )}
562   dt\_pred = dt * cs%be
563   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_update)
564 
565   \textcolor{comment}{!$OMP parallel do default(shared)}
566   \textcolor{keywordflow}{do} k=1,nz
567     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
568       vp(i,j,k) = g%mask2dCv(i,j) * (v(i,j,k) + dt\_pred * &
569                       (v\_bc\_accel(i,j,k) + cs%v\_accel\_bt(i,j,k)))
570 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
571     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
572       up(i,j,k) = g%mask2dCu(i,j) * (u(i,j,k) + dt\_pred * &
573                       (u\_bc\_accel(i,j,k) + cs%u\_accel\_bt(i,j,k)))
574 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
575 \textcolor{keywordflow}{  enddo}
576   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_update)
577 
578   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
579     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Predictor 1 [uv]"}, up, vp, g%HI, haloshift=0, symmetric=sym, scale=us%L\_T\_to\_m\_s)
580     \textcolor{keyword}{call }hchksum(h, \textcolor{stringliteral}{"Predictor 1 h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
581     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Predictor 1 [uv]h"}, uh, vh, g%HI,haloshift=2, &
582                   symmetric=sym, scale=gv%H\_to\_m*us%L\_to\_m**2*us%s\_to\_T)
583 \textcolor{comment}{!   call MOM\_state\_chksum("Predictor 1", up, vp, h, uh, vh, G, GV, US, haloshift=1)}
584     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"Predictor accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
585              cs%diffu, cs%diffv, g, gv, us, cs%pbce, cs%u\_accel\_bt, cs%v\_accel\_bt, symmetric=sym)
586     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Predictor 1 init"}, u, v, h, uh, vh, g, gv, us, haloshift=2, &
587                           symmetric=sym)
588     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Predictor 1 up"}, up, vp, g)
589     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Predictor 1 uh"}, uh, vh, g)
590 \textcolor{keywordflow}{  endif}
591 
592 \textcolor{comment}{! up <- up + dt\_pred d/dz visc d/dz up}
593 \textcolor{comment}{! u\_av  <- u\_av  + dt\_pred d/dz visc d/dz u\_av}
594   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
595   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
596     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"0 before vertvisc: [uv]p"}, up, vp, g%HI,haloshift=0, symmetric=sym, scale=us%L\_T\_to\_m\_s)
597 \textcolor{keywordflow}{  endif}
598   \textcolor{keyword}{call }vertvisc\_coef(up, vp, h, forces, visc, dt\_pred, g, gv, us, cs%vertvisc\_CSp, &
599                      cs%OBC)
600   \textcolor{keyword}{call }vertvisc(up, vp, h, forces, visc, dt\_pred, cs%OBC, cs%ADp, cs%CDp, g, &
601                 gv, us, cs%vertvisc\_CSp, cs%taux\_bot, cs%tauy\_bot, waves=waves)
602   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with vertvisc (step\_MOM\_dyn\_split\_RK2)"})
603   \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
604     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
605     \textcolor{keyword}{call }start\_group\_pass(cs%pass\_uvp, g%Domain, clock=id\_clock\_pass)
606     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
607 \textcolor{keywordflow}{  endif}
608   \textcolor{keyword}{call }vertvisc\_remnant(visc, cs%visc\_rem\_u, cs%visc\_rem\_v, dt\_pred, g, gv, us, cs%vertvisc\_CSp)
609   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
610 
611   \textcolor{keyword}{call }do\_group\_pass(cs%pass\_visc\_rem, g%Domain, clock=id\_clock\_pass)
612   \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
613     \textcolor{keyword}{call }complete\_group\_pass(cs%pass\_uvp, g%Domain, clock=id\_clock\_pass)
614   \textcolor{keywordflow}{else}
615     \textcolor{keyword}{call }do\_group\_pass(cs%pass\_uvp, g%Domain, clock=id\_clock\_pass)
616 \textcolor{keywordflow}{  endif}
617 
618   \textcolor{comment}{! uh = u\_av * h}
619   \textcolor{comment}{! hp = h + dt * div . uh}
620   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
621   \textcolor{keyword}{call }continuity(up, vp, h, hp, uh, vh, dt, g, gv, us, cs%continuity\_CSp, &
622                   cs%uhbt, cs%vhbt, cs%OBC, cs%visc\_rem\_u, cs%visc\_rem\_v, &
623                   u\_av, v\_av, bt\_cont=cs%BT\_cont)
624   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
625   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with continuity (step\_MOM\_dyn\_split\_RK2)"})
626 
627   \textcolor{keyword}{call }do\_group\_pass(cs%pass\_hp\_uv, g%Domain, clock=id\_clock\_pass)
628 
629   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
630 
631     \textcolor{keywordflow}{if} (cs%debug) &
632       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Pre OBC avg [uv]"}, u\_av, v\_av, g%HI, haloshift=1, symmetric=sym, scale=us%L\_T\_to\_m\_s)
633 
634     \textcolor{keyword}{call }radiation\_open\_bdry\_conds(cs%OBC, u\_av, u\_old\_rad\_obc, v\_av, v\_old\_rad\_obc, g, us, dt\_pred)
635 
636     \textcolor{keywordflow}{if} (cs%debug) &
637       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Post OBC avg [uv]"}, u\_av, v\_av, g%HI, haloshift=1, symmetric=sym, scale=us%L\_T\_to\_m\_s)
638 
639     \textcolor{comment}{! These should be done with a pass that excludes uh & vh.}
640 \textcolor{comment}{!   call do\_group\_pass(CS%pass\_hp\_uv, G%Domain, clock=id\_clock\_pass)}
641 \textcolor{keywordflow}{  endif}
642 
643   \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
644     \textcolor{keyword}{call }start\_group\_pass(cs%pass\_av\_uvh, g%Domain, clock=id\_clock\_pass)
645 \textcolor{keywordflow}{  endif}
646 
647   \textcolor{comment}{! h\_av = (h + hp)/2}
648   \textcolor{comment}{!$OMP parallel do default(shared)}
649   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
650     h\_av(i,j,k) = 0.5*(h(i,j,k) + hp(i,j,k))
651 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
652 
653   \textcolor{comment}{! The correction phase of the time step starts here.}
654   \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
655 
656   \textcolor{comment}{! Calculate a revised estimate of the free-surface height correction to be}
657   \textcolor{comment}{! used in the next call to btstep.  This call is at this point so that}
658   \textcolor{comment}{! hp can be changed if CS%begw /= 0.}
659   \textcolor{comment}{! eta\_cor = ...                 (hidden inside CS%barotropic\_CSp)}
660   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_btcalc)
661   \textcolor{keyword}{call }bt\_mass\_source(hp, eta\_pred, .false., g, gv, cs%barotropic\_CSp)
662   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_btcalc)
663 
664   \textcolor{keywordflow}{if} (cs%begw /= 0.0) \textcolor{keywordflow}{then}
665     \textcolor{comment}{! hp <- (1-begw)*h\_in + begw*hp}
666     \textcolor{comment}{! Back up hp to the value it would have had after a time-step of}
667     \textcolor{comment}{! begw*dt.  hp is not used again until recalculated by continuity.}
668     \textcolor{comment}{!$OMP parallel do default(shared)}
669     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-1,je+1 ; \textcolor{keywordflow}{do} i=is-1,ie+1
670       hp(i,j,k) = (1.0-cs%begw)*h(i,j,k) + cs%begw*hp(i,j,k)
671 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
672 
673     \textcolor{comment}{! PFu = d/dx M(hp,T,S)}
674     \textcolor{comment}{! pbce = dM/deta}
675     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pres)
676     \textcolor{keyword}{call }pressureforce(hp, tv, cs%PFu, cs%PFv, g, gv, us, cs%PressureForce\_CSp, &
677                        cs%ALE\_CSp, p\_surf, cs%pbce, cs%eta\_PF)
678     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pres)
679     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with PressureForce[hp=(1-b).h+b.h]
       (step\_MOM\_dyn\_split\_RK2)"})
680 \textcolor{keywordflow}{  endif}
681 
682   \textcolor{keywordflow}{if} (g%nonblocking\_updates) &
683     \textcolor{keyword}{call }complete\_group\_pass(cs%pass\_av\_uvh, g%Domain, clock=id\_clock\_pass)
684 
685   \textcolor{keywordflow}{if} (bt\_cont\_bt\_thick) \textcolor{keywordflow}{then}
686     \textcolor{keyword}{call }btcalc(h, g, gv, cs%barotropic\_CSp, cs%BT\_cont%h\_u, cs%BT\_cont%h\_v, &
687                 obc=cs%OBC)
688     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with btcalc[BT\_cont\_BT\_thick] (step\_MOM\_dyn\_split\_RK2)"})
689 \textcolor{keywordflow}{  endif}
690 
691   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
692     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Predictor "}, up, vp, hp, uh, vh, g, gv, us, symmetric=sym)
693     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Predictor avg [uv]"}, u\_av, v\_av, g%HI, haloshift=1, symmetric=sym, scale=us%L\_T\_to\_m\_s)
694     \textcolor{keyword}{call }hchksum(h\_av, \textcolor{stringliteral}{"Predictor avg h"}, g%HI, haloshift=0, scale=gv%H\_to\_m)
695   \textcolor{comment}{! call MOM\_state\_chksum("Predictor avg ", u\_av, v\_av, h\_av, uh, vh, G, GV, US)}
696     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Predictor up "}, up, vp, g)
697     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Predictor uh "}, uh, vh, g)
698 \textcolor{keywordflow}{  endif}
699 
700 \textcolor{comment}{! diffu = horizontal viscosity terms (u\_av)}
701   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_horvisc)
702   \textcolor{keyword}{call }horizontal\_viscosity(u\_av, v\_av, h\_av, cs%diffu, cs%diffv, &
703                             meke, varmix, g, gv, us, cs%hor\_visc\_CSp, &
704                             obc=cs%OBC, bt=cs%barotropic\_CSp, td=thickness\_diffuse\_csp, &
705                             adp=cs%ADp)
706   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_horvisc)
707   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with horizontal\_viscosity (step\_MOM\_dyn\_split\_RK2)"})
708 
709 \textcolor{comment}{! CAu = -(f+zeta\_av)/h\_av vh + d/dx KE\_av}
710   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_cor)
711   \textcolor{keyword}{call }coradcalc(u\_av, v\_av, h\_av, uh, vh, cs%CAu, cs%CAv, cs%OBC, cs%ADp, &
712                  g, gv, us, cs%CoriolisAdv\_CSp)
713   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_cor)
714   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with CorAdCalc (step\_MOM\_dyn\_split\_RK2)"})
715 
716 \textcolor{comment}{! Calculate the momentum forcing terms for the barotropic equations.}
717 
718 \textcolor{comment}{! u\_bc\_accel = CAu + PFu + diffu(u[n-1])}
719   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_btforce)
720   \textcolor{comment}{!$OMP parallel do default(shared)}
721   \textcolor{keywordflow}{do} k=1,nz
722     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
723       u\_bc\_accel(i,j,k) = (cs%Cau(i,j,k) + cs%PFu(i,j,k)) + cs%diffu(i,j,k)
724 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
725     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
726       v\_bc\_accel(i,j,k) = (cs%Cav(i,j,k) + cs%PFv(i,j,k)) + cs%diffv(i,j,k)
727 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
728 \textcolor{keywordflow}{  enddo}
729   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
730     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, u\_bc\_accel, v\_bc\_accel)
731 \textcolor{keywordflow}{  endif}
732   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_btforce)
733 
734   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
735     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"corr pre-btstep accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
736                           cs%diffu, cs%diffv, g, gv, us, cs%pbce, u\_bc\_accel, v\_bc\_accel, &
737                           symmetric=sym)
738     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"corr pre-btstep CS%Ca "}, cs%Cau, cs%Cav, g)
739     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"corr pre-btstep CS%PF "}, cs%PFu, cs%PFv, g)
740     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"corr pre-btstep CS%diff "}, cs%diffu, cs%diffv, g)
741     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"corr pre-btstep u\_bc\_accel "}, u\_bc\_accel, v\_bc\_accel, g)
742 \textcolor{keywordflow}{  endif}
743 
744   \textcolor{comment}{! u\_accel\_bt = layer accelerations due to barotropic solver}
745   \textcolor{comment}{! pbce = dM/deta}
746   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_btstep)
747   \textcolor{keywordflow}{if} (cs%BT\_use\_layer\_fluxes) \textcolor{keywordflow}{then}
748     uh\_ptr => uh ; vh\_ptr => vh ; u\_ptr => u\_av ; v\_ptr => v\_av
749 \textcolor{keywordflow}{  endif}
750 
751   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"btstep(), MOM\_barotropic.F90"})
752   \textcolor{comment}{! This is the corrector step call to btstep.}
753   \textcolor{keyword}{call }btstep(u, v, eta, dt, u\_bc\_accel, v\_bc\_accel, forces, cs%pbce, &
754               cs%eta\_PF, u\_av, v\_av, cs%u\_accel\_bt, cs%v\_accel\_bt, &
755               eta\_pred, cs%uhbt, cs%vhbt, g, gv, us, cs%barotropic\_CSp, &
756               cs%visc\_rem\_u, cs%visc\_rem\_v, etaav=eta\_av, adp=cs%ADp, &
757               obc=cs%OBC, bt\_cont = cs%BT\_cont, eta\_pf\_start=eta\_pf\_start, &
758               taux\_bot=taux\_bot, tauy\_bot=tauy\_bot, &
759               uh0=uh\_ptr, vh0=vh\_ptr, u\_uh0=u\_ptr, v\_vh0=v\_ptr)
760   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; eta(i,j) = eta\_pred(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
761 
762   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_btstep)
763   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"btstep()"})
764 
765   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
766     \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"u\_accel\_bt "}, cs%u\_accel\_bt, cs%v\_accel\_bt, g)
767 \textcolor{keywordflow}{  endif}
768 
769   \textcolor{comment}{! u = u + dt*( u\_bc\_accel + u\_accel\_bt )}
770   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_update)
771   \textcolor{comment}{!$OMP parallel do default(shared)}
772   \textcolor{keywordflow}{do} k=1,nz
773     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
774       u(i,j,k) = g%mask2dCu(i,j) * (u(i,j,k) + dt * &
775                       (u\_bc\_accel(i,j,k) + cs%u\_accel\_bt(i,j,k)))
776 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
777     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
778       v(i,j,k) = g%mask2dCv(i,j) * (v(i,j,k) + dt * &
779                       (v\_bc\_accel(i,j,k) + cs%v\_accel\_bt(i,j,k)))
780 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
781 \textcolor{keywordflow}{  enddo}
782   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_update)
783 
784   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
785     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Corrector 1 [uv]"}, u, v, g%HI,haloshift=0, symmetric=sym, scale=us%L\_T\_to\_m\_s)
786     \textcolor{keyword}{call }hchksum(h, \textcolor{stringliteral}{"Corrector 1 h"}, g%HI, haloshift=2, scale=gv%H\_to\_m)
787     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Corrector 1 [uv]h"}, uh, vh, g%HI, haloshift=2, &
788                   symmetric=sym, scale=gv%H\_to\_m*us%L\_to\_m**2*us%s\_to\_T)
789   \textcolor{comment}{! call MOM\_state\_chksum("Corrector 1", u, v, h, uh, vh, G, GV, US, haloshift=1)}
790     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"Corrector accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
791                           cs%diffu, cs%diffv, g, gv, us, cs%pbce, cs%u\_accel\_bt, cs%v\_accel\_bt, &
792                           symmetric=sym)
793 \textcolor{keywordflow}{  endif}
794 
795   \textcolor{comment}{! u <- u + dt d/dz visc d/dz u}
796   \textcolor{comment}{! u\_av <- u\_av + dt d/dz visc d/dz u\_av}
797   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
798   \textcolor{keyword}{call }vertvisc\_coef(u, v, h, forces, visc, dt, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
799   \textcolor{keyword}{call }vertvisc(u, v, h, forces, visc, dt, cs%OBC, cs%ADp, cs%CDp, g, gv, us, &
800                 cs%vertvisc\_CSp, cs%taux\_bot, cs%tauy\_bot,waves=waves)
801   \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
802     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
803     \textcolor{keyword}{call }start\_group\_pass(cs%pass\_uv, g%Domain, clock=id\_clock\_pass)
804     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
805 \textcolor{keywordflow}{  endif}
806   \textcolor{keyword}{call }vertvisc\_remnant(visc, cs%visc\_rem\_u, cs%visc\_rem\_v, dt, g, gv, us, cs%vertvisc\_CSp)
807   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
808   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with vertvisc (step\_MOM\_dyn\_split\_RK2)"})
809 
810 \textcolor{comment}{! Later, h\_av = (h\_in + h\_out)/2, but for now use h\_av to store h\_in.}
811   \textcolor{comment}{!$OMP parallel do default(shared)}
812   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
813     h\_av(i,j,k) = h(i,j,k)
814 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
815 
816   \textcolor{keyword}{call }do\_group\_pass(cs%pass\_visc\_rem, g%Domain, clock=id\_clock\_pass)
817   \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
818     \textcolor{keyword}{call }complete\_group\_pass(cs%pass\_uv, g%Domain, clock=id\_clock\_pass)
819   \textcolor{keywordflow}{else}
820     \textcolor{keyword}{call }do\_group\_pass(cs%pass\_uv, g%Domain, clock=id\_clock\_pass)
821 \textcolor{keywordflow}{  endif}
822 
823   \textcolor{comment}{! uh = u\_av * h}
824   \textcolor{comment}{! h  = h + dt * div . uh}
825   \textcolor{comment}{! u\_av and v\_av adjusted so their mass transports match uhbt and vhbt.}
826   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
827   \textcolor{keyword}{call }continuity(u, v, h, h, uh, vh, dt, g, gv, us, cs%continuity\_CSp, &
828                   cs%uhbt, cs%vhbt, cs%OBC, cs%visc\_rem\_u, cs%visc\_rem\_v, u\_av, v\_av)
829   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
830   \textcolor{keyword}{call }do\_group\_pass(cs%pass\_h, g%Domain, clock=id\_clock\_pass)
831   \textcolor{comment}{! Whenever thickness changes let the diag manager know, target grids}
832   \textcolor{comment}{! for vertical remapping may need to be regenerated.}
833   \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
834   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with continuity (step\_MOM\_dyn\_split\_RK2)"})
835 
836   \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
837     \textcolor{keyword}{call }start\_group\_pass(cs%pass\_av\_uvh, g%Domain, clock=id\_clock\_pass)
838   \textcolor{keywordflow}{else}
839     \textcolor{keyword}{call }do\_group\_pass(cs%pass\_av\_uvh, g%domain, clock=id\_clock\_pass)
840 \textcolor{keywordflow}{  endif}
841 
842   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
843     \textcolor{keyword}{call }radiation\_open\_bdry\_conds(cs%OBC, u, u\_old\_rad\_obc, v, v\_old\_rad\_obc, g, us, dt)
844 \textcolor{keywordflow}{  endif}
845 
846 \textcolor{comment}{! h\_av = (h\_in + h\_out)/2 . Going in to this line, h\_av = h\_in.}
847   \textcolor{comment}{!$OMP parallel do default(shared)}
848   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
849     h\_av(i,j,k) = 0.5*(h\_av(i,j,k) + h(i,j,k))
850 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
851 
852   \textcolor{keywordflow}{if} (g%nonblocking\_updates) &
853     \textcolor{keyword}{call }complete\_group\_pass(cs%pass\_av\_uvh, g%Domain, clock=id\_clock\_pass)
854 
855   \textcolor{comment}{!$OMP parallel do default(shared)}
856   \textcolor{keywordflow}{do} k=1,nz
857     \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=isq-2,ieq+2
858       uhtr(i,j,k) = uhtr(i,j,k) + uh(i,j,k)*dt
859 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
860     \textcolor{keywordflow}{do} j=jsq-2,jeq+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
861       vhtr(i,j,k) = vhtr(i,j,k) + vh(i,j,k)*dt
862 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
863 \textcolor{keywordflow}{  enddo}
864 
865   \textcolor{comment}{!   The time-averaged free surface height has already been set by the last}
866   \textcolor{comment}{!  call to btstep.}
867 
868   \textcolor{comment}{!  Here various terms used in to update the momentum equations are}
869   \textcolor{comment}{!  offered for time averaging.}
870   \textcolor{keywordflow}{if} (cs%id\_PFu > 0) \textcolor{keyword}{call }post\_data(cs%id\_PFu, cs%PFu, cs%diag)
871   \textcolor{keywordflow}{if} (cs%id\_PFv > 0) \textcolor{keyword}{call }post\_data(cs%id\_PFv, cs%PFv, cs%diag)
872   \textcolor{keywordflow}{if} (cs%id\_CAu > 0) \textcolor{keyword}{call }post\_data(cs%id\_CAu, cs%CAu, cs%diag)
873   \textcolor{keywordflow}{if} (cs%id\_CAv > 0) \textcolor{keyword}{call }post\_data(cs%id\_CAv, cs%CAv, cs%diag)
874 
875   \textcolor{comment}{! Here the thickness fluxes are offered for time averaging.}
876   \textcolor{keywordflow}{if} (cs%id\_uh         > 0) \textcolor{keyword}{call }post\_data(cs%id\_uh , uh,                   cs%diag)
877   \textcolor{keywordflow}{if} (cs%id\_vh         > 0) \textcolor{keyword}{call }post\_data(cs%id\_vh , vh,                   cs%diag)
878   \textcolor{keywordflow}{if} (cs%id\_uav        > 0) \textcolor{keyword}{call }post\_data(cs%id\_uav, u\_av,                 cs%diag)
879   \textcolor{keywordflow}{if} (cs%id\_vav        > 0) \textcolor{keyword}{call }post\_data(cs%id\_vav, v\_av,                 cs%diag)
880   \textcolor{keywordflow}{if} (cs%id\_u\_BT\_accel > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_BT\_accel, cs%u\_accel\_bt, cs%diag)
881   \textcolor{keywordflow}{if} (cs%id\_v\_BT\_accel > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_BT\_accel, cs%v\_accel\_bt, cs%diag)
882 
883   \textcolor{comment}{! Diagnostics for terms multiplied by fractional thicknesses}
884 
885   \textcolor{comment}{! 3D diagnostics hf\_PFu etc. are commented because there is no clarity on proper remapping grid option.}
886   \textcolor{comment}{! The code is retained for degugging purposes in the future.}
887   \textcolor{comment}{!if (CS%id\_hf\_PFu > 0) then}
888   \textcolor{comment}{!  allocate(hf\_PFu(G%IsdB:G%IedB,G%jsd:G%jed,G%ke))}
889   \textcolor{comment}{!  do k=1,nz ; do j=js,je ; do I=Isq,Ieq}
890   \textcolor{comment}{!    hf\_PFu(I,j,k) = CS%PFu(I,j,k) * CS%ADp%diag\_hfrac\_u(I,j,k)}
891   \textcolor{comment}{!  enddo ; enddo ; enddo}
892   \textcolor{comment}{!  call post\_data(CS%id\_hf\_PFu, hf\_PFu, CS%diag)}
893   \textcolor{comment}{!endif}
894   \textcolor{comment}{!if (CS%id\_hf\_PFv > 0) then}
895   \textcolor{comment}{!  allocate(hf\_PFv(G%isd:G%ied,G%JsdB:G%JedB,G%ke))}
896   \textcolor{comment}{!  do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie}
897   \textcolor{comment}{!    hf\_PFv(i,J,k) = CS%PFv(i,J,k) * CS%ADp%diag\_hfrac\_v(i,J,k)}
898   \textcolor{comment}{!  enddo ; enddo ; enddo}
899   \textcolor{comment}{!  call post\_data(CS%id\_hf\_PFv, hf\_PFv, CS%diag)}
900   \textcolor{comment}{!endif}
901   \textcolor{keywordflow}{if} (cs%id\_hf\_PFu\_2d > 0) \textcolor{keywordflow}{then}
902     \textcolor{keyword}{allocate}(hf\_pfu\_2d(g%IsdB:g%IedB,g%jsd:g%jed))
903     hf\_pfu\_2d(:,:) = 0.0
904     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
905       hf\_pfu\_2d(i,j) = hf\_pfu\_2d(i,j) + cs%PFu(i,j,k) * cs%ADp%diag\_hfrac\_u(i,j,k)
906 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
907     \textcolor{keyword}{call }post\_data(cs%id\_hf\_PFu\_2d, hf\_pfu\_2d, cs%diag)
908     \textcolor{keyword}{deallocate}(hf\_pfu\_2d)
909 \textcolor{keywordflow}{  endif}
910   \textcolor{keywordflow}{if} (cs%id\_hf\_PFv\_2d > 0) \textcolor{keywordflow}{then}
911     \textcolor{keyword}{allocate}(hf\_pfv\_2d(g%isd:g%ied,g%JsdB:g%JedB))
912     hf\_pfv\_2d(:,:) = 0.0
913     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
914       hf\_pfv\_2d(i,j) = hf\_pfv\_2d(i,j) + cs%PFv(i,j,k) * cs%ADp%diag\_hfrac\_v(i,j,k)
915 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
916     \textcolor{keyword}{call }post\_data(cs%id\_hf\_PFv\_2d, hf\_pfv\_2d, cs%diag)
917     \textcolor{keyword}{deallocate}(hf\_pfv\_2d)
918 \textcolor{keywordflow}{  endif}
919 
920   \textcolor{comment}{!if (CS%id\_hf\_CAu > 0) then}
921   \textcolor{comment}{!  allocate(hf\_CAu(G%IsdB:G%IedB,G%jsd:G%jed,G%ke))}
922   \textcolor{comment}{!  do k=1,nz ; do j=js,je ; do I=Isq,Ieq}
923   \textcolor{comment}{!    hf\_CAu(I,j,k) = CS%CAu(I,j,k) * CS%ADp%diag\_hfrac\_u(I,j,k)}
924   \textcolor{comment}{!  enddo ; enddo ; enddo}
925   \textcolor{comment}{!  call post\_data(CS%id\_hf\_CAu, hf\_CAu, CS%diag)}
926   \textcolor{comment}{!endif}
927   \textcolor{comment}{!if (CS%id\_hf\_CAv > 0) then}
928   \textcolor{comment}{!  allocate(hf\_CAv(G%isd:G%ied,G%JsdB:G%JedB,G%ke))}
929   \textcolor{comment}{!  do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie}
930   \textcolor{comment}{!    hf\_CAv(i,J,k) = CS%CAv(i,J,k) * CS%ADp%diag\_hfrac\_v(i,J,k)}
931   \textcolor{comment}{!  enddo ; enddo ; enddo}
932   \textcolor{comment}{!  call post\_data(CS%id\_hf\_CAv, hf\_CAv, CS%diag)}
933   \textcolor{comment}{!endif}
934   \textcolor{keywordflow}{if} (cs%id\_hf\_CAu\_2d > 0) \textcolor{keywordflow}{then}
935     \textcolor{keyword}{allocate}(hf\_cau\_2d(g%IsdB:g%IedB,g%jsd:g%jed))
936     hf\_cau\_2d(:,:) = 0.0
937     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
938       hf\_cau\_2d(i,j) = hf\_cau\_2d(i,j) + cs%CAu(i,j,k) * cs%ADp%diag\_hfrac\_u(i,j,k)
939 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
940     \textcolor{keyword}{call }post\_data(cs%id\_hf\_CAu\_2d, hf\_cau\_2d, cs%diag)
941     \textcolor{keyword}{deallocate}(hf\_cau\_2d)
942 \textcolor{keywordflow}{  endif}
943   \textcolor{keywordflow}{if} (cs%id\_hf\_CAv\_2d > 0) \textcolor{keywordflow}{then}
944     \textcolor{keyword}{allocate}(hf\_cav\_2d(g%isd:g%ied,g%JsdB:g%JedB))
945     hf\_cav\_2d(:,:) = 0.0
946     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
947       hf\_cav\_2d(i,j) = hf\_cav\_2d(i,j) + cs%CAv(i,j,k) * cs%ADp%diag\_hfrac\_v(i,j,k)
948 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
949     \textcolor{keyword}{call }post\_data(cs%id\_hf\_CAv\_2d, hf\_cav\_2d, cs%diag)
950     \textcolor{keyword}{deallocate}(hf\_cav\_2d)
951 \textcolor{keywordflow}{  endif}
952 
953   \textcolor{comment}{!if (CS%id\_hf\_u\_BT\_accel > 0) then}
954   \textcolor{comment}{!  allocate(hf\_u\_BT\_accel(G%IsdB:G%IedB,G%jsd:G%jed,G%ke))}
955   \textcolor{comment}{!  do k=1,nz ; do j=js,je ; do I=Isq,Ieq}
956   \textcolor{comment}{!    hf\_u\_BT\_accel(I,j,k) = CS%u\_accel\_bt(I,j,k) * CS%ADp%diag\_hfrac\_u(I,j,k)}
957   \textcolor{comment}{!  enddo ; enddo ; enddo}
958   \textcolor{comment}{!  call post\_data(CS%id\_hf\_u\_BT\_accel, hf\_u\_BT\_accel, CS%diag)}
959   \textcolor{comment}{!endif}
960   \textcolor{comment}{!if (CS%id\_hf\_v\_BT\_accel > 0) then}
961   \textcolor{comment}{!  allocate(hf\_v\_BT\_accel(G%isd:G%ied,G%JsdB:G%JedB,G%ke))}
962   \textcolor{comment}{!  do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie}
963   \textcolor{comment}{!    hf\_v\_BT\_accel(i,J,k) = CS%v\_accel\_bt(i,J,k) * CS%ADp%diag\_hfrac\_v(i,J,k)}
964   \textcolor{comment}{!  enddo ; enddo ; enddo}
965   \textcolor{comment}{!  call post\_data(CS%id\_hf\_v\_BT\_accel, hf\_v\_BT\_accel, CS%diag)}
966   \textcolor{comment}{!endif}
967   \textcolor{keywordflow}{if} (cs%id\_hf\_u\_BT\_accel\_2d > 0) \textcolor{keywordflow}{then}
968     \textcolor{keyword}{allocate}(hf\_u\_bt\_accel\_2d(g%IsdB:g%IedB,g%jsd:g%jed))
969     hf\_u\_bt\_accel\_2d(:,:) = 0.0
970     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
971       hf\_u\_bt\_accel\_2d(i,j) = hf\_u\_bt\_accel\_2d(i,j) + cs%u\_accel\_bt(i,j,k) * cs%ADp%diag\_hfrac\_u(i,j,k)
972 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
973     \textcolor{keyword}{call }post\_data(cs%id\_hf\_u\_BT\_accel\_2d, hf\_u\_bt\_accel\_2d, cs%diag)
974     \textcolor{keyword}{deallocate}(hf\_u\_bt\_accel\_2d)
975 \textcolor{keywordflow}{  endif}
976   \textcolor{keywordflow}{if} (cs%id\_hf\_v\_BT\_accel\_2d > 0) \textcolor{keywordflow}{then}
977     \textcolor{keyword}{allocate}(hf\_v\_bt\_accel\_2d(g%isd:g%ied,g%JsdB:g%JedB))
978     hf\_v\_bt\_accel\_2d(:,:) = 0.0
979     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
980       hf\_v\_bt\_accel\_2d(i,j) = hf\_v\_bt\_accel\_2d(i,j) + cs%v\_accel\_bt(i,j,k) * cs%ADp%diag\_hfrac\_v(i,j,k)
981 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
982     \textcolor{keyword}{call }post\_data(cs%id\_hf\_v\_BT\_accel\_2d, hf\_v\_bt\_accel\_2d, cs%diag)
983     \textcolor{keyword}{deallocate}(hf\_v\_bt\_accel\_2d)
984 \textcolor{keywordflow}{  endif}
985 
986   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
987     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Corrector "}, u, v, h, uh, vh, g, gv, us, symmetric=sym)
988     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Corrector avg [uv]"}, u\_av, v\_av, g%HI, haloshift=1, symmetric=sym, scale=us%L\_T\_to\_m\_s)
989     \textcolor{keyword}{call }hchksum(h\_av, \textcolor{stringliteral}{"Corrector avg h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
990  \textcolor{comment}{!  call MOM\_state\_chksum("Corrector avg ", u\_av, v\_av, h\_av, uh, vh, G, GV, US)}
991 \textcolor{keywordflow}{  endif}
992 
993   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"step\_MOM\_dyn\_split\_RK2()"})
994 
\end{DoxyCode}
