\hypertarget{namespacemom__dynamics__unsplit__rk2}{}\doxysection{mom\+\_\+dynamics\+\_\+unsplit\+\_\+rk2 Module Reference}
\label{namespacemom__dynamics__unsplit__rk2}\index{mom\_dynamics\_unsplit\_rk2@{mom\_dynamics\_unsplit\_rk2}}


\doxysubsection{Detailed Description}
Time steps the ocean dynamics with an unsplit quasi 2nd order Runge-\/\+Kutta scheme. \doxysubsection*{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}
\doxysubsection*{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}
\doxysubsection*{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}



\doxysubsection{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}}
\doxysubsubsection{\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 665 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit\+\_\+\+R\+K2.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{666   \textcolor{keywordtype}{type}(MOM\_dyn\_unsplit\_RK2\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< dyn\_unsplit\_RK2 control structure that}}
\DoxyCodeLine{667 \textcolor{comment}{                                              !! will be deallocated in this subroutine.}}
\DoxyCodeLine{668 }
\DoxyCodeLine{669   dealloc\_(cs\%diffu) ; dealloc\_(cs\%diffv)}
\DoxyCodeLine{670   dealloc\_(cs\%CAu)   ; dealloc\_(cs\%CAv)}
\DoxyCodeLine{671   dealloc\_(cs\%PFu)   ; dealloc\_(cs\%PFv)}
\DoxyCodeLine{672 }
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__dynamics__unsplit__rk2_1_1mom__dyn__unsplit__rk2__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__restart_1_1mom__restart__cs}{mom\+\_\+restart\+\_\+cs}}), pointer}]{restart\+\_\+\+CS,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1accel__diag__ptrs}{accel\+\_\+diag\+\_\+ptrs}}), intent(inout), target}]{Accel\+\_\+diag,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1cont__diag__ptrs}{cont\+\_\+diag\+\_\+ptrs}}), intent(inout), target}]{Cont\+\_\+diag,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1ocean__internal__state}{ocean\+\_\+internal\+\_\+state}}), intent(inout)}]{M\+IS,  }\item[{type(\mbox{\hyperlink{structmom__meke__types_1_1meke__type}{meke\+\_\+type}}), pointer}]{M\+E\+KE,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__boundary__update_1_1update__obc__cs}{update\+\_\+obc\+\_\+cs}}), pointer}]{update\+\_\+\+O\+B\+C\+\_\+\+C\+Sp,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{A\+L\+E\+\_\+\+C\+Sp,  }\item[{type(\mbox{\hyperlink{structmom__set__visc_1_1set__visc__cs}{set\+\_\+visc\+\_\+cs}}), pointer}]{set\+Visc\+\_\+\+C\+Sp,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1vertvisc__type}{vertvisc\+\_\+type}}), intent(inout)}]{visc,  }\item[{type(\mbox{\hyperlink{structmom__get__input_1_1directories}{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{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em u} & The zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em v} & The meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em time} & The current model time. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters. \\
\hline
\mbox{\texttt{ 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{\texttt{ 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{\texttt{ in,out}}  & {\em cont\+\_\+diag} & A structure with pointers to various terms in the continuity equations. \\
\hline
\mbox{\texttt{ 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{\texttt{ in,out}}  & {\em visc} & A structure containing vertical viscosities, bottom drag viscosities, and related fields. \\
\hline
\mbox{\texttt{ in}}  & {\em dirs} & A structure containing several relevant directory paths. \\
\hline
\mbox{\texttt{ 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{\texttt{ out}}  & {\em cont\+\_\+stencil} & The stencil for thickness from the continuity solver. \\
\hline
\end{DoxyParams}


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


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


\begin{DoxyCode}{0}
\DoxyCodeLine{463   \textcolor{keywordtype}{type}(hor\_index\_type),         \textcolor{keywordtype}{intent(in)}    :: HI\textcolor{comment}{         !< A horizontal index type structure.}}
\DoxyCodeLine{464   \textcolor{keywordtype}{type}(verticalGrid\_type),      \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{         !< The ocean's vertical grid structure.}}
\DoxyCodeLine{465   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time}}
\DoxyCodeLine{466 \textcolor{comment}{                                                            !! parameters.}}
\DoxyCodeLine{467   \textcolor{keywordtype}{type}(MOM\_dyn\_unsplit\_RK2\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{         !< The control structure set up by}}
\DoxyCodeLine{468 \textcolor{comment}{                                                            !! initialize\_dyn\_unsplit\_RK2.}}
\DoxyCodeLine{469   \textcolor{keywordtype}{type}(MOM\_restart\_CS),         \textcolor{keywordtype}{pointer}       :: restart\_CS\textcolor{comment}{ !< A pointer to the restart control}}
\DoxyCodeLine{470 \textcolor{comment}{                                                            !! structure.}}
\DoxyCodeLine{471 \textcolor{comment}{!   This subroutine sets up any auxiliary restart variables that are specific}}
\DoxyCodeLine{472 \textcolor{comment}{! to the unsplit time stepping scheme.  All variables registered here should}}
\DoxyCodeLine{473 \textcolor{comment}{! have the ability to be recreated if they are not present in a restart file.}}
\DoxyCodeLine{474 }
\DoxyCodeLine{475   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{476   \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units}
\DoxyCodeLine{477   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{478   isd = hi\%isd ; ied = hi\%ied ; jsd = hi\%jsd ; jed = hi\%jed ; nz = gv\%ke}
\DoxyCodeLine{479   isdb = hi\%IsdB ; iedb = hi\%IedB ; jsdb = hi\%JsdB ; jedb = hi\%JedB}
\DoxyCodeLine{480 }
\DoxyCodeLine{481 \textcolor{comment}{! This is where a control structure that is specific to this module would be allocated.}}
\DoxyCodeLine{482   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{483     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"{}register\_restarts\_dyn\_unsplit\_RK2 called with an associated "{}}// \&}
\DoxyCodeLine{484                              \textcolor{stringliteral}{"{}control structure."{}})}
\DoxyCodeLine{485     \textcolor{keywordflow}{return}}
\DoxyCodeLine{486 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{487   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{488 }
\DoxyCodeLine{489   alloc\_(cs\%diffu(isdb:iedb,jsd:jed,nz)) ; cs\%diffu(:,:,:) = 0.0}
\DoxyCodeLine{490   alloc\_(cs\%diffv(isd:ied,jsdb:jedb,nz)) ; cs\%diffv(:,:,:) = 0.0}
\DoxyCodeLine{491   alloc\_(cs\%CAu(isdb:iedb,jsd:jed,nz)) ; cs\%CAu(:,:,:) = 0.0}
\DoxyCodeLine{492   alloc\_(cs\%CAv(isd:ied,jsdb:jedb,nz)) ; cs\%CAv(:,:,:) = 0.0}
\DoxyCodeLine{493   alloc\_(cs\%PFu(isdb:iedb,jsd:jed,nz)) ; cs\%PFu(:,:,:) = 0.0}
\DoxyCodeLine{494   alloc\_(cs\%PFv(isd:ied,jsdb:jedb,nz)) ; cs\%PFv(:,:,:) = 0.0}
\DoxyCodeLine{495 }
\DoxyCodeLine{496   thickness\_units = get\_thickness\_units(gv)}
\DoxyCodeLine{497   flux\_units = get\_flux\_units(gv)}
\DoxyCodeLine{498 }
\DoxyCodeLine{499 \textcolor{comment}{!  No extra restart fields are needed with this time stepping scheme.}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1vertvisc__type}{vertvisc\+\_\+type}}), intent(inout)}]{visc,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+local,  }\item[{real, intent(in)}]{dt,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{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(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__dynamics__unsplit__rk2_1_1mom__dyn__unsplit__rk2__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+rk2\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__lateral__mixing__coeffs_1_1varmix__cs}{varmix\+\_\+cs}}), pointer}]{Var\+Mix,  }\item[{type(\mbox{\hyperlink{structmom__meke__types_1_1meke__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{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+in} & The input and output zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em v\+\_\+in} & The input and output meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ 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{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables. \\
\hline
\mbox{\texttt{ in,out}}  & {\em visc} & A structure containing vertical viscosities, bottom drag viscosities, and related fields. \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+local} & The model time at the end of the time step. \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The baroclinic dynamics time step \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ 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{\texttt{ 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{\texttt{ 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{\texttt{ 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{\texttt{ 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{\texttt{ 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 191 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit\+\_\+\+R\+K2.\+F90.


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

\end{DoxyCode}
