\hypertarget{namespacemom__dynamics__unsplit__rk2}{}\section{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2 Module Reference}
\label{namespacemom__dynamics__unsplit__rk2}\index{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}}


\subsection{Detailed Description}
Time steps the ocean dynamics with an unsplit quasi 2nd order Runge-\/\+Kutta scheme. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__dynamics__unsplit__rk2_1_1mom__dyn__unsplit__rk2__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+dynamics\+\_\+unsplit\+\_\+\+R\+K2 module control structure. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a25424d65cc3339442e528c0a92b173a3}{step\+\_\+mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2}} (u\+\_\+in, v\+\_\+in, h\+\_\+in, tv, visc, Time\+\_\+local, dt, forces, p\+\_\+surf\+\_\+begin, p\+\_\+surf\+\_\+end, uh, vh, uhtr, vhtr, eta\+\_\+av, G, GV, US, CS, Var\+Mix, M\+E\+KE)
\begin{DoxyCompactList}\small\item\em Step the M\+O\+M6 dynamics using an unsplit quasi-\/2nd order Runge-\/\+Kutta scheme. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a6e670b5eaefad5b2f16b3e00c2788dfb}{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit\+\_\+rk2}} (HI, GV, param\+\_\+file, CS, restart\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Allocate the control structure for this module, allocates memory in it, and registers any auxiliary restart variables that are specific to the unsplit R\+K2 time stepping scheme. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a900ac5cb7e63b6b9872123de94f147d7}{initialize\+\_\+dyn\+\_\+unsplit\+\_\+rk2}} (u, v, h, Time, G, GV, US, param\+\_\+file, diag, CS, restart\+\_\+\+CS, Accel\+\_\+diag, Cont\+\_\+diag, M\+IS, M\+E\+KE, O\+BC, update\+\_\+\+O\+B\+C\+\_\+\+C\+Sp, A\+L\+E\+\_\+\+C\+Sp, set\+Visc\+\_\+\+C\+Sp, visc, dirs, ntrunc, cont\+\_\+stencil)
\begin{DoxyCompactList}\small\item\em Initialize parameters and allocate memory associated with the unsplit R\+K2 dynamics module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_af9ef63649616487c19908fab5978a314}{end\+\_\+dyn\+\_\+unsplit\+\_\+rk2}} (CS)
\begin{DoxyCompactList}\small\item\em Clean up and deallocate memory associated with the dyn\+\_\+unsplit\+\_\+\+R\+K2 module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\textbf{ }\par
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a7e37729c2b8bd8fe064e04199812ebd0}\label{namespacemom__dynamics__unsplit__rk2_a7e37729c2b8bd8fe064e04199812ebd0}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a7e37729c2b8bd8fe064e04199812ebd0}{id\+\_\+clock\+\_\+cor}}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a314c5540fca3e752724507b32064fe10}\label{namespacemom__dynamics__unsplit__rk2_a314c5540fca3e752724507b32064fe10}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a314c5540fca3e752724507b32064fe10}{id\+\_\+clock\+\_\+pres}}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a9ac6a7bb5f61fda4e77ea9caa32922a9}\label{namespacemom__dynamics__unsplit__rk2_a9ac6a7bb5f61fda4e77ea9caa32922a9}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a9ac6a7bb5f61fda4e77ea9caa32922a9}{id\+\_\+clock\+\_\+vertvisc}}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a3eda0d9efa534956d888c15854311985}\label{namespacemom__dynamics__unsplit__rk2_a3eda0d9efa534956d888c15854311985}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a3eda0d9efa534956d888c15854311985}{id\+\_\+clock\+\_\+horvisc}}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a9d72cd363e8c5410c95a01e8e084edd0}\label{namespacemom__dynamics__unsplit__rk2_a9d72cd363e8c5410c95a01e8e084edd0}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a9d72cd363e8c5410c95a01e8e084edd0}{id\+\_\+clock\+\_\+continuity}}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a2f4e7535d331890d36cc15d0e3b838c2}\label{namespacemom__dynamics__unsplit__rk2_a2f4e7535d331890d36cc15d0e3b838c2}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a2f4e7535d331890d36cc15d0e3b838c2}{id\+\_\+clock\+\_\+mom\+\_\+update}}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a2f515a6af1b092c869a49813789196ed}\label{namespacemom__dynamics__unsplit__rk2_a2f515a6af1b092c869a49813789196ed}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_a2f515a6af1b092c869a49813789196ed}{id\+\_\+clock\+\_\+pass}}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_aeecbf1faadbab92d4585779d1301bf98}\label{namespacemom__dynamics__unsplit__rk2_aeecbf1faadbab92d4585779d1301bf98}} 
integer \mbox{\hyperlink{namespacemom__dynamics__unsplit__rk2_aeecbf1faadbab92d4585779d1301bf98}{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__unsplit__rk2_af9ef63649616487c19908fab5978a314}\label{namespacemom__dynamics__unsplit__rk2_af9ef63649616487c19908fab5978a314}} 
\index{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}!end\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{end\+\_\+dyn\+\_\+unsplit\+\_\+rk2}}
\index{end\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{end\+\_\+dyn\+\_\+unsplit\+\_\+rk2}!mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}}
\subsubsection{\texorpdfstring{end\+\_\+dyn\+\_\+unsplit\+\_\+rk2()}{end\_dyn\_unsplit\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2\+::end\+\_\+dyn\+\_\+unsplit\+\_\+rk2 (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dynamics__unsplit__rk2_1_1mom__dyn__unsplit__rk2__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up and deallocate memory associated with the dyn\+\_\+unsplit\+\_\+\+R\+K2 module. 


\begin{DoxyParams}{Parameters}
{\em cs} & dyn\+\_\+unsplit\+\_\+\+R\+K2 control structure that will be deallocated in this subroutine. \\
\hline
\end{DoxyParams}


Definition at line 666 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
666   \textcolor{keywordtype}{type}(MOM\_dyn\_unsplit\_RK2\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< dyn\_unsplit\_RK2 control structure that}
667 \textcolor{comment}{                                              !! will be deallocated in this subroutine.}
668 
669   dealloc\_(cs%diffu) ; dealloc\_(cs%diffv)
670   dealloc\_(cs%CAu)   ; dealloc\_(cs%CAv)
671   dealloc\_(cs%PFu)   ; dealloc\_(cs%PFv)
672 
673   \textcolor{keyword}{deallocate}(cs)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a900ac5cb7e63b6b9872123de94f147d7}\label{namespacemom__dynamics__unsplit__rk2_a900ac5cb7e63b6b9872123de94f147d7}} 
\index{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}!initialize\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{initialize\+\_\+dyn\+\_\+unsplit\+\_\+rk2}}
\index{initialize\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{initialize\+\_\+dyn\+\_\+unsplit\+\_\+rk2}!mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}}
\subsubsection{\texorpdfstring{initialize\+\_\+dyn\+\_\+unsplit\+\_\+rk2()}{initialize\_dyn\_unsplit\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2\+::initialize\+\_\+dyn\+\_\+unsplit\+\_\+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[{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(\mbox{\hyperlink{structmom__dynamics__unsplit__rk2_1_1mom__dyn__unsplit__rk2__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2\+\_\+cs}}), pointer}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS,  }\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(meke\+\_\+type), pointer}]{M\+E\+KE,  }\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[{integer, intent(out), optional}]{cont\+\_\+stencil }\end{DoxyParamCaption})}



Initialize parameters and allocate memory associated with the unsplit R\+K2 dynamics module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em u} & The zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em v} & The meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em time} & The current model time.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters.\\
\hline
\mbox{\tt in,out}  & {\em diag} & A structure that is used to regulate diagnostic output.\\
\hline
 & {\em cs} & The control structure set up by initialize\+\_\+dyn\+\_\+unsplit\+\_\+\+R\+K2.\\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure.\\
\hline
\mbox{\tt in,out}  & {\em accel\+\_\+diag} & A set of pointers to the various accelerations in the momentum equations, which can be used for later derived diagnostics, like energy budgets.\\
\hline
\mbox{\tt in,out}  & {\em cont\+\_\+diag} & A structure with pointers to various terms in the continuity equations.\\
\hline
\mbox{\tt in,out}  & {\em mis} & The \char`\"{}\+M\+O\+M6 Internal State\char`\"{} structure, used to pass around pointers to various arrays for diagnostic purposes.\\
\hline
 & {\em meke} & M\+E\+KE data\\
\hline
 & {\em obc} & If open boundary conditions are used, this points to the ocean\+\_\+\+O\+B\+C\+\_\+type that was set up in M\+O\+M\+\_\+initialization.\\
\hline
 & {\em update\+\_\+obc\+\_\+csp} & If open boundary condition updates are used, this points to the appropriate control structure.\\
\hline
 & {\em ale\+\_\+csp} & This points to the A\+LE control structure.\\
\hline
 & {\em setvisc\+\_\+csp} & This points to the set\+\_\+visc control structure.\\
\hline
\mbox{\tt in,out}  & {\em visc} & A structure containing vertical viscosities, bottom drag viscosities, and related fields.\\
\hline
\mbox{\tt in}  & {\em dirs} & A structure containing several relevant 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 cont\+\_\+stencil} & The stencil for thickness from the continuity solver. \\
\hline
\end{DoxyParams}


Definition at line 508 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
508   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}
509   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}
510   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}
511   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{    !< The zonal velocity [L T-1 ~> m s-1].}
512   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{    !< The meridional velocity [L T-1 ~> m
       s-1].}
513   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} , \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{    !< Layer thicknesses [H ~> m or kg m-2]}
514   \textcolor{keywordtype}{type}(time\_type),                   \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time.}
515   \textcolor{keywordtype}{type}(param\_file\_type),                     \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse}
516 \textcolor{comment}{                                                                         !! for run-time parameters.}
517   \textcolor{keywordtype}{type}(diag\_ctrl),                   \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< A structure that is used to}
518 \textcolor{comment}{                                                                   !! regulate diagnostic output.}
519   \textcolor{keywordtype}{type}(MOM\_dyn\_unsplit\_RK2\_CS),              \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< The control structure set up}
520 \textcolor{comment}{                                                                   !! by initialize\_dyn\_unsplit\_RK2.}
521   \textcolor{keywordtype}{type}(MOM\_restart\_CS),                      \textcolor{keywordtype}{pointer}       :: restart\_CS\textcolor{comment}{ !< A pointer to the restart}
522 \textcolor{comment}{                                                                         !! control structure.}
523   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),             \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: Accel\_diag\textcolor{comment}{ !< A set of pointers to the}
524 \textcolor{comment}{                                      !! various accelerations in the momentum equations, which can}
525 \textcolor{comment}{                                      !! be used for later derived diagnostics, like energy budgets.}
526   \textcolor{keywordtype}{type}(cont\_diag\_ptrs),              \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: Cont\_diag\textcolor{comment}{  !< A structure with pointers}
527 \textcolor{comment}{                                                                         !! to various terms in the}
528 \textcolor{comment}{                                                                         !! continuity equations.}
529   \textcolor{keywordtype}{type}(ocean\_internal\_state),                \textcolor{keywordtype}{intent(inout)} :: MIS\textcolor{comment}{  !< The "MOM6 Internal State"}
530 \textcolor{comment}{                                                     !! structure, used to pass around pointers}
531 \textcolor{comment}{                                                     !! to various arrays for diagnostic purposes.}
532   \textcolor{keywordtype}{type}(MEKE\_type),                           \textcolor{keywordtype}{pointer}       :: MEKE\textcolor{comment}{ !< MEKE data}
533   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{  !< If open boundary conditions}
534 \textcolor{comment}{                                                    !! are used, this points to the ocean\_OBC\_type}
535 \textcolor{comment}{                                                    !! that was set up in MOM\_initialization.}
536   \textcolor{keywordtype}{type}(update\_OBC\_CS),                       \textcolor{keywordtype}{pointer}       :: update\_OBC\_CSp\textcolor{comment}{ !< If open boundary}
537 \textcolor{comment}{                                                         !! condition updates are used, this points}
538 \textcolor{comment}{                                                         !! to the appropriate control structure.}
539   \textcolor{keywordtype}{type}(ALE\_CS),                              \textcolor{keywordtype}{pointer}       :: ALE\_CSp\textcolor{comment}{     !< This points to the ALE}
540 \textcolor{comment}{                                                                          !! control structure.}
541   \textcolor{keywordtype}{type}(set\_visc\_CS),                         \textcolor{keywordtype}{pointer}       :: setVisc\_CSp\textcolor{comment}{ !< This points to the}
542 \textcolor{comment}{                                                                          !! set\_visc control}
543 \textcolor{comment}{                                                                          !! structure.}
544   \textcolor{keywordtype}{type}(vertvisc\_type),                       \textcolor{keywordtype}{intent(inout)} :: visc\textcolor{comment}{ !< A structure containing}
545 \textcolor{comment}{                                                         !! vertical viscosities, bottom drag}
546 \textcolor{comment}{                                                         !! viscosities, and related fields.}
547   \textcolor{keywordtype}{type}(directories),                         \textcolor{keywordtype}{intent(in)}    :: dirs\textcolor{comment}{ !< A structure containing several}
548 \textcolor{comment}{                                                                   !! relevant directory paths.}
549   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{target},                           \textcolor{keywordtype}{intent(inout)} :: ntrunc\textcolor{comment}{ !< A target for the variable}
550 \textcolor{comment}{                                                       !! that records the number of times the}
551 \textcolor{comment}{                                                       !! velocity is truncated (this should be 0).}
552   \textcolor{keywordtype}{integer},                         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: cont\_stencil\textcolor{comment}{ !< The stencil for}
553 \textcolor{comment}{                                                       !! thickness from the continuity solver.}
554 
555   \textcolor{comment}{!   This subroutine initializes all of the variables that are used by this}
556   \textcolor{comment}{! dynamic core, including diagnostics and the cpu clocks.}
557 
558   \textcolor{comment}{! Local variables}
559   \textcolor{keywordtype}{character(len=40)} :: mdl = \textcolor{stringliteral}{"MOM\_dynamics\_unsplit\_RK2"} \textcolor{comment}{! This module's name.}
560   \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units
561   \textcolor{comment}{! This include declares and sets the variable "version".}
562 \textcolor{preprocessor}{# include "version\_variable.h"}
563 \textcolor{preprocessor}{}  \textcolor{keywordtype}{real} :: H\_convert
564   \textcolor{keywordtype}{logical} :: use\_tides
565   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, IsdB, IedB, JsdB, JedB
566   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed ; nz = g%ke
567   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
568 
569   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, &
570       \textcolor{stringliteral}{"initialize\_dyn\_unsplit\_RK2 called with an unassociated control structure."})
571   \textcolor{keywordflow}{if} (cs%module\_is\_initialized) \textcolor{keywordflow}{then}
572     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_dyn\_unsplit\_RK2 called with a control "}// &
573                             \textcolor{stringliteral}{"structure that has already been initialized."})
574     \textcolor{keywordflow}{return}
575 \textcolor{keywordflow}{  endif}
576   cs%module\_is\_initialized = .true.
577 
578   cs%diag => diag
579 
580   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
581   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BE"}, cs%be, &
582                  \textcolor{stringliteral}{"If SPLIT is true, BE determines the relative weighting "}//&
583                  \textcolor{stringliteral}{"of a  2nd-order Runga-Kutta baroclinic time stepping "}//&
584                  \textcolor{stringliteral}{"scheme (0.5) and a backward Euler scheme (1) that is "}//&
585                  \textcolor{stringliteral}{"used for the Coriolis and inertial terms.  BE may be "}//&
586                  \textcolor{stringliteral}{"from 0.5 to 1, but instability may occur near 0.5. "}//&
587                  \textcolor{stringliteral}{"BE is also applicable if SPLIT is false and USE\_RK2 "}//&
588                  \textcolor{stringliteral}{"is true."}, units=\textcolor{stringliteral}{"nondim"}, default=0.6)
589   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BEGW"}, cs%begw, &
590                  \textcolor{stringliteral}{"If SPLIT is true, BEGW is a number from 0 to 1 that "}//&
591                  \textcolor{stringliteral}{"controls the extent to which the treatment of gravity "}//&
592                  \textcolor{stringliteral}{"waves is forward-backward (0) or simulated backward "}//&
593                  \textcolor{stringliteral}{"Euler (1).  0 is almost always used. "}//&
594                  \textcolor{stringliteral}{"If SPLIT is false and USE\_RK2 is true, BEGW can be "}//&
595                  \textcolor{stringliteral}{"between 0 and 0.5 to damp gravity waves."}, &
596                  units=\textcolor{stringliteral}{"nondim"}, default=0.0)
597   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FIX\_UNSPLIT\_DT\_VISC\_BUG"}, cs%use\_correct\_dt\_visc, &
598                  \textcolor{stringliteral}{"If true, use the correct timestep in the viscous terms applied in the first "}//&
599                  \textcolor{stringliteral}{"predictor step with the unsplit time stepping scheme, and in the calculation "}//&
600                  \textcolor{stringliteral}{"of the turbulent mixed layer properties for viscosity with unsplit or "}//&
601                  \textcolor{stringliteral}{"unsplit\_RK2."}, default=.true.)
602   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, cs%debug, &
603                  \textcolor{stringliteral}{"If true, write out verbose debugging data."}, &
604                  default=.false., debuggingparam=.true.)
605   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDES"}, use\_tides, &
606                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing."}, default=.false.)
607 
608   \textcolor{keyword}{allocate}(cs%taux\_bot(isdb:iedb,jsd:jed)) ; cs%taux\_bot(:,:) = 0.0
609   \textcolor{keyword}{allocate}(cs%tauy\_bot(isd:ied,jsdb:jedb)) ; cs%tauy\_bot(:,:) = 0.0
610 
611   mis%diffu => cs%diffu ; mis%diffv => cs%diffv
612   mis%PFu => cs%PFu ; mis%PFv => cs%PFv
613   mis%CAu => cs%CAu ; mis%CAv => cs%CAv
614 
615   cs%ADp => accel\_diag ; cs%CDp => cont\_diag
616   accel\_diag%diffu => cs%diffu ; accel\_diag%diffv => cs%diffv
617   accel\_diag%PFu => cs%PFu ; accel\_diag%PFv => cs%PFv
618   accel\_diag%CAu => cs%CAu ; accel\_diag%CAv => cs%CAv
619 
620   \textcolor{keyword}{call }continuity\_init(time, g, gv, us, param\_file, diag, cs%continuity\_CSp)
621   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cont\_stencil)) cont\_stencil = continuity\_stencil(cs%continuity\_CSp)
622   \textcolor{keyword}{call }coriolisadv\_init(time, g, gv, us, param\_file, diag, cs%ADp, cs%CoriolisAdv\_CSp)
623   \textcolor{keywordflow}{if} (use\_tides) \textcolor{keyword}{call }tidal\_forcing\_init(time, g, param\_file, cs%tides\_CSp)
624   \textcolor{keyword}{call }pressureforce\_init(time, g, gv, us, param\_file, diag, cs%PressureForce\_CSp, &
625                           cs%tides\_CSp)
626   \textcolor{keyword}{call }hor\_visc\_init(time, g, us, param\_file, diag, cs%hor\_visc\_CSp, meke)
627   \textcolor{keyword}{call }vertvisc\_init(mis, time, g, gv, us, param\_file, diag, cs%ADp, dirs, &
628                      ntrunc, cs%vertvisc\_CSp)
629   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(setvisc\_csp)) \textcolor{keyword}{call }mom\_error(fatal, &
630     \textcolor{stringliteral}{"initialize\_dyn\_unsplit\_RK2 called with setVisc\_CSp unassociated."})
631   cs%set\_visc\_CSp => setvisc\_csp
632 
633   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ale\_csp)) cs%ALE\_CSp => ale\_csp
634   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) cs%OBC => obc
635 
636   flux\_units = get\_flux\_units(gv)
637   h\_convert = gv%H\_to\_m ; \textcolor{keywordflow}{if} (.not.gv%Boussinesq) h\_convert = gv%H\_to\_kg\_m2
638   cs%id\_uh = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'uh'}, diag%axesCuL, time, &
639       \textcolor{stringliteral}{'Zonal Thickness Flux'}, flux\_units, y\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., &
640       conversion=h\_convert*us%L\_to\_m**2*us%s\_to\_T)
641   cs%id\_vh = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vh'}, diag%axesCvL, time, &
642       \textcolor{stringliteral}{'Meridional Thickness Flux'}, flux\_units, x\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., &
643       conversion=h\_convert*us%L\_to\_m**2*us%s\_to\_T)
644   cs%id\_CAu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CAu'}, diag%axesCuL, time, &
645       \textcolor{stringliteral}{'Zonal Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'meter second-2'}, conversion=us%L\_T2\_to\_m\_s2)
646   cs%id\_CAv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CAv'}, diag%axesCvL, time, &
647       \textcolor{stringliteral}{'Meridional Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'meter second-2'}, conversion=us%L\_T2\_to\_m\_s2)
648   cs%id\_PFu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFu'}, diag%axesCuL, time, &
649       \textcolor{stringliteral}{'Zonal Pressure Force Acceleration'}, \textcolor{stringliteral}{'meter second-2'}, conversion=us%L\_T2\_to\_m\_s2)
650   cs%id\_PFv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFv'}, diag%axesCvL, time, &
651       \textcolor{stringliteral}{'Meridional Pressure Force Acceleration'}, \textcolor{stringliteral}{'meter second-2'}, conversion=us%L\_T2\_to\_m\_s2)
652 
653   id\_clock\_cor = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean Coriolis & mom advection)'}, grain=clock\_module)
654   id\_clock\_continuity = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean continuity equation)'}, grain=clock\_module)
655   id\_clock\_pres = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean pressure force)'}, grain=clock\_module)
656   id\_clock\_vertvisc = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean vertical viscosity)'}, grain=clock\_module)
657   id\_clock\_horvisc = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean horizontal viscosity)'}, grain=clock\_module)
658   id\_clock\_mom\_update = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean momentum increments)'}, grain=clock\_module)
659   id\_clock\_pass = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean message passing)'}, grain=clock\_module)
660   id\_clock\_pass\_init = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean init message passing)'}, grain=clock\_routine)
661 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a6e670b5eaefad5b2f16b3e00c2788dfb}\label{namespacemom__dynamics__unsplit__rk2_a6e670b5eaefad5b2f16b3e00c2788dfb}} 
\index{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}!register\+\_\+restarts\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit\+\_\+rk2}}
\index{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit\+\_\+rk2}!mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}}
\subsubsection{\texorpdfstring{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit\+\_\+rk2()}{register\_restarts\_dyn\_unsplit\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2\+::register\+\_\+restarts\+\_\+dyn\+\_\+unsplit\+\_\+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(\mbox{\hyperlink{structmom__dynamics__unsplit__rk2_1_1mom__dyn__unsplit__rk2__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2\+\_\+cs}}), pointer}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+CS }\end{DoxyParamCaption})}



Allocate the control structure for this module, allocates memory in it, and registers any auxiliary restart variables that are specific to the unsplit R\+K2 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} & A horizontal index type structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters.\\
\hline
 & {\em cs} & The control structure set up by initialize\+\_\+dyn\+\_\+unsplit\+\_\+\+R\+K2.\\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure. \\
\hline
\end{DoxyParams}


Definition at line 463 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
463   \textcolor{keywordtype}{type}(hor\_index\_type),         \textcolor{keywordtype}{intent(in)}    :: HI\textcolor{comment}{         !< A horizontal index type structure.}
464   \textcolor{keywordtype}{type}(verticalGrid\_type),      \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{         !< The ocean's vertical grid structure.}
465   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time}
466 \textcolor{comment}{                                                            !! parameters.}
467   \textcolor{keywordtype}{type}(MOM\_dyn\_unsplit\_RK2\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{         !< The control structure set up by}
468 \textcolor{comment}{                                                            !! initialize\_dyn\_unsplit\_RK2.}
469   \textcolor{keywordtype}{type}(MOM\_restart\_CS),         \textcolor{keywordtype}{pointer}       :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control}
470 \textcolor{comment}{                                                            !! structure.}
471 \textcolor{comment}{!   This subroutine sets up any auxiliary restart variables that are specific}
472 \textcolor{comment}{! to the unsplit time stepping scheme.  All variables registered here should}
473 \textcolor{comment}{! have the ability to be recreated if they are not present in a restart file.}
474 
475   \textcolor{comment}{! Local variables}
476   \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units
477   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, IsdB, IedB, JsdB, JedB
478   isd = hi%isd ; ied = hi%ied ; jsd = hi%jsd ; jed = hi%jed ; nz = gv%ke
479   isdb = hi%IsdB ; iedb = hi%IedB ; jsdb = hi%JsdB ; jedb = hi%JedB
480 
481 \textcolor{comment}{! This is where a control structure that is specific to this module would be allocated.}
482   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
483     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_restarts\_dyn\_unsplit\_RK2 called with an associated "}// &
484                              \textcolor{stringliteral}{"control structure."})
485     \textcolor{keywordflow}{return}
486 \textcolor{keywordflow}{  endif}
487   \textcolor{keyword}{allocate}(cs)
488 
489   alloc\_(cs%diffu(isdb:iedb,jsd:jed,nz)) ; cs%diffu(:,:,:) = 0.0
490   alloc\_(cs%diffv(isd:ied,jsdb:jedb,nz)) ; cs%diffv(:,:,:) = 0.0
491   alloc\_(cs%CAu(isdb:iedb,jsd:jed,nz)) ; cs%CAu(:,:,:) = 0.0
492   alloc\_(cs%CAv(isd:ied,jsdb:jedb,nz)) ; cs%CAv(:,:,:) = 0.0
493   alloc\_(cs%PFu(isdb:iedb,jsd:jed,nz)) ; cs%PFu(:,:,:) = 0.0
494   alloc\_(cs%PFv(isd:ied,jsdb:jedb,nz)) ; cs%PFv(:,:,:) = 0.0
495 
496   thickness\_units = get\_thickness\_units(gv)
497   flux\_units = get\_flux\_units(gv)
498 
499 \textcolor{comment}{!  No extra restart fields are needed with this time stepping scheme.}
500 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__unsplit__rk2_a25424d65cc3339442e528c0a92b173a3}\label{namespacemom__dynamics__unsplit__rk2_a25424d65cc3339442e528c0a92b173a3}} 
\index{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}!step\+\_\+mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{step\+\_\+mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2}}
\index{step\+\_\+mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2@{step\+\_\+mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2}!mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2@{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2}}
\subsubsection{\texorpdfstring{step\+\_\+mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2()}{step\_mom\_dyn\_unsplit\_rk2()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2\+::step\+\_\+mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2 (\begin{DoxyParamCaption}\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{u\+\_\+in,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{v\+\_\+in,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{h\+\_\+in,  }\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)}]{uh,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{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(\mbox{\hyperlink{structmom__dynamics__unsplit__rk2_1_1mom__dyn__unsplit__rk2__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2\+\_\+cs}}), pointer}]{CS,  }\item[{type(varmix\+\_\+cs), pointer}]{Var\+Mix,  }\item[{type(meke\+\_\+type), pointer}]{M\+E\+KE }\end{DoxyParamCaption})}



Step the M\+O\+M6 dynamics using an unsplit quasi-\/2nd order Runge-\/\+Kutta scheme. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em u\+\_\+in} & The input and output zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em v\+\_\+in} & The input and output meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+in} & The input and output layer thicknesses, \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}, depending on whether the Boussinesq approximation is made.\\
\hline
\mbox{\tt in}  & {\em tv} & A structure pointing to various thermodynamic variables.\\
\hline
\mbox{\tt in,out}  & {\em visc} & A structure containing vertical viscosities, bottom drag viscosities, and related fields.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+local} & The model time at the end of the time step.\\
\hline
\mbox{\tt in}  & {\em dt} & The baroclinic dynamics 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} & A pointer (perhaps N\+U\+LL) to the surface pressure at the beginning of this dynamic step \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}.\\
\hline
 & {\em p\+\_\+surf\+\_\+end} & A pointer (perhaps N\+U\+LL) to the surface pressure at the end of this dynamic step \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em uh} & The zonal volume or mass transport \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em vh} & The meridional volume or mass transport \mbox{[}H L2 T-\/1 $\sim$$>$ m3 s-\/1 or kg s-\/1\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em uhtr} & The accumulated zonal volume or mass transport since the last tracer advection \mbox{[}H L2 $\sim$$>$ m3 or kg\mbox{]}.\\
\hline
\mbox{\tt in,out}  & {\em vhtr} & The accumulated meridional volume or mass transport since the last tracer advection \mbox{[}H L2 $\sim$$>$ m3 or kg\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em eta\+\_\+av} & The time-\/mean free surface height or column mass \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
 & {\em cs} & The control structure set up by initialize\+\_\+dyn\+\_\+unsplit\+\_\+\+R\+K2.\\
\hline
 & {\em varmix} & A pointer to a structure with fields that specify the spatially variable viscosities.\\
\hline
 & {\em meke} & A pointer to a structure containing fields related to the Mesoscale Eddy Kinetic Energy. \\
\hline
\end{DoxyParams}


Definition at line 194 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}
194   \textcolor{keywordtype}{type}(ocean\_grid\_type),             \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{       !< The ocean's grid structure.}
195   \textcolor{keywordtype}{type}(verticalGrid\_type),           \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{      !< The ocean's vertical grid structure.}
196   \textcolor{keywordtype}{type}(unit\_scale\_type),             \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{      !< A dimensional unit scaling type}
197   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: u\_in\textcolor{comment}{ !< The input and output zonal}
198 \textcolor{comment}{                                                              !! velocity [L T-1 ~> m s-1].}
199   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: v\_in\textcolor{comment}{ !< The input and output meridional}
200 \textcolor{comment}{                                                              !! velocity [L T-1 ~> m s-1].}
201   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(inout)} :: h\_in\textcolor{comment}{ !< The input and output layer
       thicknesses,}
202 \textcolor{comment}{                                                              !! [H ~> m or kg m-2], depending on whether}
203 \textcolor{comment}{                                                              !! the Boussinesq approximation is made.}
204   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),             \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{      !< A structure pointing to various}
205 \textcolor{comment}{                                                              !! thermodynamic variables.}
206   \textcolor{keywordtype}{type}(vertvisc\_type),               \textcolor{keywordtype}{intent(inout)} :: visc\textcolor{comment}{    !< A structure containing vertical}
207 \textcolor{comment}{                                                              !! viscosities, bottom drag}
208 \textcolor{comment}{                                                              !! viscosities, and related fields.}
209   \textcolor{keywordtype}{type}(time\_type),                   \textcolor{keywordtype}{intent(in)}    :: Time\_local\textcolor{comment}{   !< The model time at the end of}
210 \textcolor{comment}{                                                              !! the time step.}
211   \textcolor{keywordtype}{real},                              \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{      !< The baroclinic dynamics time step [T ~>
       s].}
212   \textcolor{keywordtype}{type}(mech\_forcing),                \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{  !< A structure with the driving mechanical
       forces}
213   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},              \textcolor{keywordtype}{pointer}       :: p\_surf\_begin\textcolor{comment}{ !< A pointer (perhaps NULL) to}
214 \textcolor{comment}{                                                              !! the surface pressure at the beginning}
215 \textcolor{comment}{                                                              !! of this dynamic step [R L2 T-2 ~> Pa].}
216   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},              \textcolor{keywordtype}{pointer}       :: p\_surf\_end\textcolor{comment}{   !< A pointer (perhaps NULL) to}
217 \textcolor{comment}{                                                              !! the surface pressure at the end of}
218 \textcolor{comment}{                                                              !! this dynamic step [R L2 T-2 ~> Pa].}
219   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: uh\textcolor{comment}{ !< The zonal volume or mass transport}
220 \textcolor{comment}{                                                              !! [H L2 T-1 ~> m3 s-1 or kg s-1].}
221   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: vh\textcolor{comment}{  !< The meridional volume or mass}
222 \textcolor{comment}{                                                              !! transport [H L2 T-1 ~> m3 s-1 or kg s-1].}
223   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: uhtr\textcolor{comment}{ !< The accumulated zonal volume or}
224 \textcolor{comment}{                                                              !! mass transport since the last}
225 \textcolor{comment}{                                                              !! tracer advection [H L2 ~> m3 or kg].}
226   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: vhtr\textcolor{comment}{ !< The accumulated meridional volume}
227 \textcolor{comment}{                                                              !! or mass transport since the last}
228 \textcolor{comment}{                                                              !! tracer advection [H L2 ~> m3 or kg].}
229   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},  \textcolor{keywordtype}{intent(out)}   :: eta\_av\textcolor{comment}{  !< The time-mean free surface height}
230 \textcolor{comment}{                                                              !! or column mass [H ~> m or kg m-2].}
231   \textcolor{keywordtype}{type}(MOM\_dyn\_unsplit\_RK2\_CS),      \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{      !< The control structure set up by}
232 \textcolor{comment}{                                                              !! initialize\_dyn\_unsplit\_RK2.}
233   \textcolor{keywordtype}{type}(VarMix\_CS),                   \textcolor{keywordtype}{pointer}       :: VarMix\textcolor{comment}{  !< A pointer to a structure with}
234 \textcolor{comment}{                                                              !! fields that specify the spatially}
235 \textcolor{comment}{                                                              !! variable viscosities.}
236   \textcolor{keywordtype}{type}(MEKE\_type),                   \textcolor{keywordtype}{pointer}       :: MEKE\textcolor{comment}{    !< A pointer to a structure containing}
237 \textcolor{comment}{                                                              !! fields related to the Mesoscale}
238 \textcolor{comment}{                                                              !! Eddy Kinetic Energy.}
239   \textcolor{comment}{! Local variables}
240   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_av, hp
241   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))} :: up \textcolor{comment}{! Predicted zonal velocities [L T-1 ~> m s-1]}
242   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))} :: vp \textcolor{comment}{! Predicted meridional velocities [L T-1 ~> m s-1]}
243   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: p\_surf => null()
244   \textcolor{keywordtype}{real} :: dt\_pred   \textcolor{comment}{! The time step for the predictor part of the baroclinic time stepping [T ~> s]}
245   \textcolor{keywordtype}{real} :: dt\_visc   \textcolor{comment}{! The time step for a part of the update due to viscosity [T ~> s]}
246   \textcolor{keywordtype}{logical} :: dyn\_p\_surf
247   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz
248   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
249   isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
250   dt\_pred = dt * cs%BE
251 
252   h\_av(:,:,:) = 0; hp(:,:,:) = 0
253   up(:,:,:) = 0
254   vp(:,:,:) = 0
255 
256   dyn\_p\_surf = \textcolor{keyword}{associated}(p\_surf\_begin) .and. \textcolor{keyword}{associated}(p\_surf\_end)
257   \textcolor{keywordflow}{if} (dyn\_p\_surf) \textcolor{keywordflow}{then}
258     \textcolor{keyword}{call }safe\_alloc\_ptr(p\_surf,g%isd,g%ied,g%jsd,g%jed) ; p\_surf(:,:) = 0.0
259   \textcolor{keywordflow}{else}
260     p\_surf => forces%p\_surf
261 \textcolor{keywordflow}{  endif}
262 
263 \textcolor{comment}{! Runge-Kutta second order accurate two step scheme is used to step}
264 \textcolor{comment}{! all of the fields except h.  h is stepped separately.}
265 
266   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
267     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Start Predictor "}, u\_in, v\_in, h\_in, uh, vh, g, gv, us)
268 \textcolor{keywordflow}{  endif}
269 
270 \textcolor{comment}{! diffu = horizontal viscosity terms (u,h)}
271   \textcolor{keyword}{call }enable\_averages(dt,time\_local, cs%diag)
272   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_horvisc)
273   \textcolor{keyword}{call }horizontal\_viscosity(u\_in, v\_in, h\_in, cs%diffu, cs%diffv, meke, varmix, &
274                             g, gv, us, cs%hor\_visc\_CSp)
275   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_horvisc)
276   \textcolor{keyword}{call }disable\_averaging(cs%diag)
277   \textcolor{keyword}{call }pass\_vector(cs%diffu, cs%diffv, g%Domain, clock=id\_clock\_pass)
278 
279 \textcolor{comment}{! This continuity step is solely for the Coroilis terms, specifically in the}
280 \textcolor{comment}{! denominator of PV and in the mass transport or PV.}
281 \textcolor{comment}{! uh = u[n-1]*h[n-1/2]}
282 \textcolor{comment}{! hp = h[n-1/2] + dt/2 div . uh}
283   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
284   \textcolor{comment}{! This is a duplicate calculation of the last continuity from the previous step}
285   \textcolor{comment}{! and could/should be optimized out. -AJA}
286   \textcolor{keyword}{call }continuity(u\_in, v\_in, h\_in, hp, uh, vh, dt\_pred, g, gv, us, cs%continuity\_CSp, obc=cs%OBC)
287   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
288   \textcolor{keyword}{call }pass\_var(hp, g%Domain, clock=id\_clock\_pass)
289   \textcolor{keyword}{call }pass\_vector(uh, vh, g%Domain, clock=id\_clock\_pass)
290 
291 \textcolor{comment}{! h\_av = (h + hp)/2  (used in PV denominator)}
292   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_update)
293   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
294     h\_av(i,j,k) = (h\_in(i,j,k) + hp(i,j,k)) * 0.5
295 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
296   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_update)
297 
298 \textcolor{comment}{! CAu = -(f+zeta)/h\_av vh + d/dx KE  (function of u[n-1] and uh[n-1])}
299   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_cor)
300   \textcolor{keyword}{call }coradcalc(u\_in, v\_in, h\_av, uh, vh, cs%CAu, cs%CAv, cs%OBC, cs%ADp, &
301                  g, gv, us, cs%CoriolisAdv\_CSp)
302   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_cor)
303 
304 \textcolor{comment}{! PFu = d/dx M(h\_av,T,S)  (function of h[n-1/2])}
305   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pres)
306   \textcolor{keywordflow}{if} (dyn\_p\_surf) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
307     p\_surf(i,j) = 0.5*p\_surf\_begin(i,j) + 0.5*p\_surf\_end(i,j)
308 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
309   \textcolor{keyword}{call }pressureforce(h\_in, tv, cs%PFu, cs%PFv, g, gv, us, cs%PressureForce\_CSp, cs%ALE\_CSp, p\_surf)
310   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pres)
311   \textcolor{keyword}{call }pass\_vector(cs%PFu, cs%PFv, g%Domain, clock=id\_clock\_pass)
312   \textcolor{keyword}{call }pass\_vector(cs%CAu, cs%CAv, g%Domain, clock=id\_clock\_pass)
313 
314   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) then; \textcolor{keywordflow}{if} (cs%OBC%update\_OBC) \textcolor{keywordflow}{then}
315     \textcolor{keyword}{call }update\_obc\_data(cs%OBC, g, gv, us, tv, h\_in, cs%update\_OBC\_CSp, time\_local)
316 \textcolor{keyword}{  end}if; endif
317   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
318     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%PFu, cs%PFv)
319     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%CAu, cs%CAv)
320     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%diffu, cs%diffv)
321 \textcolor{keywordflow}{  endif}
322 
323 \textcolor{comment}{! up+[n-1/2] = u[n-1] + dt\_pred * (PFu + CAu)}
324   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_update)
325   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
326     up(i,j,k) = g%mask2dCu(i,j) * (u\_in(i,j,k) + dt\_pred * &
327                    ((cs%PFu(i,j,k) + cs%CAu(i,j,k)) + cs%diffu(i,j,k)))
328 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
329   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
330     vp(i,j,k) = g%mask2dCv(i,j) * (v\_in(i,j,k) + dt\_pred * &
331                    ((cs%PFv(i,j,k) + cs%CAv(i,j,k)) + cs%diffv(i,j,k)))
332 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
333   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_update)
334 
335   \textcolor{keywordflow}{if} (cs%debug) &
336     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"Predictor 1 accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv,&
337                           cs%diffu, cs%diffv, g, gv, us)
338 
339  \textcolor{comment}{! up[n-1/2] <- up*[n-1/2] + dt/2 d/dz visc d/dz up[n-1/2]}
340   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
341   \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
342   dt\_visc = dt\_pred ; \textcolor{keywordflow}{if} (cs%use\_correct\_dt\_visc) dt\_visc = dt
343   \textcolor{keyword}{call }set\_viscous\_ml(u\_in, v\_in, h\_av, tv, forces, visc, dt\_visc, g, gv, us, cs%set\_visc\_CSp)
344   \textcolor{keyword}{call }disable\_averaging(cs%diag)
345 
346   \textcolor{keyword}{call }vertvisc\_coef(up, vp, h\_av, forces, visc, dt\_pred, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
347   \textcolor{keyword}{call }vertvisc(up, vp, h\_av, forces, visc, dt\_pred, cs%OBC, cs%ADp, cs%CDp, &
348                 g, gv, us, cs%vertvisc\_CSp)
349   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
350   \textcolor{keyword}{call }pass\_vector(up, vp, g%Domain, clock=id\_clock\_pass)
351 
352 \textcolor{comment}{! uh = up[n-1/2] * h[n-1/2]}
353 \textcolor{comment}{! h\_av = h + dt div . uh}
354   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
355   \textcolor{keyword}{call }continuity(up, vp, h\_in, hp, uh, vh, dt, g, gv, us, cs%continuity\_CSp, obc=cs%OBC)
356   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
357   \textcolor{keyword}{call }pass\_var(hp, g%Domain, clock=id\_clock\_pass)
358   \textcolor{keyword}{call }pass\_vector(uh, vh, g%Domain, clock=id\_clock\_pass)
359 
360 \textcolor{comment}{! h\_av <- (h + hp)/2   (centered at n-1/2)}
361   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
362     h\_av(i,j,k) = (h\_in(i,j,k) + hp(i,j,k)) * 0.5
363 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
364 
365   \textcolor{keywordflow}{if} (cs%debug) &
366     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Predictor 1"}, up, vp, h\_av, uh, vh, g, gv, us)
367 
368 \textcolor{comment}{! CAu = -(f+zeta(up))/h\_av vh + d/dx KE(up)  (function of up[n-1/2], h[n-1/2])}
369   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_cor)
370   \textcolor{keyword}{call }coradcalc(up, vp, h\_av, uh, vh, cs%CAu, cs%CAv, cs%OBC, cs%ADp, &
371                  g, gv, us, cs%CoriolisAdv\_CSp)
372   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_cor)
373   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
374     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%CAu, cs%CAv)
375 \textcolor{keywordflow}{  endif}
376 
377 \textcolor{comment}{! call enable\_averages(dt, Time\_local, CS%diag)  ?????????????????????/}
378 
379 \textcolor{comment}{! up* = u[n] + (1+gamma) * dt * ( PFu + CAu )  Extrapolated for damping}
380 \textcolor{comment}{! u*[n+1] = u[n] + dt * ( PFu + CAu )}
381   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
382     up(i,j,k) = g%mask2dCu(i,j) * (u\_in(i,j,k) + dt * (1.+cs%begw) * &
383             ((cs%PFu(i,j,k) + cs%CAu(i,j,k)) + cs%diffu(i,j,k)))
384     u\_in(i,j,k) = g%mask2dCu(i,j) * (u\_in(i,j,k) +  dt * &
385             ((cs%PFu(i,j,k) + cs%CAu(i,j,k)) + cs%diffu(i,j,k)))
386 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
387   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
388     vp(i,j,k) = g%mask2dCv(i,j) * (v\_in(i,j,k) + dt * (1.+cs%begw) * &
389             ((cs%PFv(i,j,k) + cs%CAv(i,j,k)) + cs%diffv(i,j,k)))
390     v\_in(i,j,k) = g%mask2dCv(i,j) * (v\_in(i,j,k) + dt * &
391             ((cs%PFv(i,j,k) + cs%CAv(i,j,k)) + cs%diffv(i,j,k)))
392 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
393 
394 \textcolor{comment}{! up[n] <- up* + dt d/dz visc d/dz up}
395 \textcolor{comment}{! u[n] <- u*[n] + dt d/dz visc d/dz u[n]}
396   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
397   \textcolor{keyword}{call }vertvisc\_coef(up, vp, h\_av, forces, visc, dt, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
398   \textcolor{keyword}{call }vertvisc(up, vp, h\_av, forces, visc, dt, cs%OBC, cs%ADp, cs%CDp, &
399                 g, gv, us, cs%vertvisc\_CSp, cs%taux\_bot, cs%tauy\_bot)
400   \textcolor{keyword}{call }vertvisc\_coef(u\_in, v\_in, h\_av, forces, visc, dt, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
401   \textcolor{keyword}{call }vertvisc(u\_in, v\_in, h\_av, forces, visc, dt, cs%OBC, cs%ADp, cs%CDp,&
402                 g, gv, us, cs%vertvisc\_CSp, cs%taux\_bot, cs%tauy\_bot)
403   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
404   \textcolor{keyword}{call }pass\_vector(up, vp, g%Domain, clock=id\_clock\_pass)
405   \textcolor{keyword}{call }pass\_vector(u\_in, v\_in, g%Domain, clock=id\_clock\_pass)
406 
407 \textcolor{comment}{! uh = up[n] * h[n]  (up[n] might be extrapolated to damp GWs)}
408 \textcolor{comment}{! h[n+1] = h[n] + dt div . uh}
409   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
410   \textcolor{keyword}{call }continuity(up, vp, h\_in, h\_in, uh, vh, dt, g, gv, us, cs%continuity\_CSp, obc=cs%OBC)
411   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
412   \textcolor{keyword}{call }pass\_var(h\_in, g%Domain, clock=id\_clock\_pass)
413   \textcolor{keyword}{call }pass\_vector(uh, vh, g%Domain, clock=id\_clock\_pass)
414 
415 \textcolor{comment}{! Accumulate mass flux for tracer transport}
416   \textcolor{keywordflow}{do} k=1,nz
417     \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=isq-2,ieq+2
418       uhtr(i,j,k) = uhtr(i,j,k) + dt*uh(i,j,k)
419 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
420     \textcolor{keywordflow}{do} j=jsq-2,jeq+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
421       vhtr(i,j,k) = vhtr(i,j,k) + dt*vh(i,j,k)
422 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
423 \textcolor{keywordflow}{  enddo}
424 
425   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
426     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Corrector"}, u\_in, v\_in, h\_in, uh, vh, g, gv, us)
427     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"Corrector accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
428                           cs%diffu, cs%diffv, g, gv, us)
429 \textcolor{keywordflow}{  endif}
430 
431   \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then}
432     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; eta\_av(i,j) = -gv%Z\_to\_H*g%bathyT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
433   \textcolor{keywordflow}{else}
434     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; eta\_av(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
435 \textcolor{keywordflow}{  endif}
436   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
437     eta\_av(i,j) = eta\_av(i,j) + h\_av(i,j,k)
438 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
439 
440   \textcolor{keywordflow}{if} (dyn\_p\_surf) \textcolor{keyword}{deallocate}(p\_surf)
441 
442 \textcolor{comment}{!   Here various terms used in to update the momentum equations are}
443 \textcolor{comment}{! offered for averaging.}
444   \textcolor{keywordflow}{if} (cs%id\_PFu > 0) \textcolor{keyword}{call }post\_data(cs%id\_PFu, cs%PFu, cs%diag)
445   \textcolor{keywordflow}{if} (cs%id\_PFv > 0) \textcolor{keyword}{call }post\_data(cs%id\_PFv, cs%PFv, cs%diag)
446   \textcolor{keywordflow}{if} (cs%id\_CAu > 0) \textcolor{keyword}{call }post\_data(cs%id\_CAu, cs%CAu, cs%diag)
447   \textcolor{keywordflow}{if} (cs%id\_CAv > 0) \textcolor{keyword}{call }post\_data(cs%id\_CAv, cs%CAv, cs%diag)
448 
449 \textcolor{comment}{!   Here the thickness fluxes are offered for averaging.}
450   \textcolor{keywordflow}{if} (cs%id\_uh > 0) \textcolor{keyword}{call }post\_data(cs%id\_uh, uh, cs%diag)
451   \textcolor{keywordflow}{if} (cs%id\_vh > 0) \textcolor{keyword}{call }post\_data(cs%id\_vh, vh, cs%diag)
452 
\end{DoxyCode}
