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


\subsection{Detailed Description}
Time steps the ocean dynamics with an unsplit quasi 3rd order scheme. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__dynamics__unsplit_1_1mom__dyn__unsplit__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+cs}
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+dynamics\+\_\+unsplit module control structure. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \hyperlink{namespacemom__dynamics__unsplit_ab72d911d187f9247b6cc72d87e815370}{step\+\_\+mom\+\_\+dyn\+\_\+unsplit} (u, v, h, tv, visc, Time\+\_\+local, dt, forces, p\+\_\+surf\+\_\+begin, p\+\_\+surf\+\_\+end, uh, vh, uhtr, vhtr, eta\+\_\+av, G, GV, US, CS, Var\+Mix, M\+E\+KE, Waves)
\begin{DoxyCompactList}\small\item\em Step the M\+O\+M6 dynamics using an unsplit mixed 2nd order (for continuity) and 3rd order (for the inviscid momentum equations) order scheme. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__dynamics__unsplit_a5a650785f745fd9cf42e1e014dd2d89a}{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit} (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 time stepping scheme. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__dynamics__unsplit_aa428b0ad5ed3e6cbbb1fd83484eba2f8}{initialize\+\_\+dyn\+\_\+unsplit} (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 dynamics module. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__dynamics__unsplit_a8f8e05fcc926eb5c1d41517f6b8cf1cb}{end\+\_\+dyn\+\_\+unsplit} (CS)
\begin{DoxyCompactList}\small\item\em Clean up and deallocate memory associated with the unsplit dynamics module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\textbf{ }\par
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_a9ebe0aaf06b20d3401139aaee12fef4a}\label{namespacemom__dynamics__unsplit_a9ebe0aaf06b20d3401139aaee12fef4a}} 
integer \hyperlink{namespacemom__dynamics__unsplit_a9ebe0aaf06b20d3401139aaee12fef4a}{id\+\_\+clock\+\_\+cor}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_adc6cdd4ab179eb08a54b9af6a0afcb9d}\label{namespacemom__dynamics__unsplit_adc6cdd4ab179eb08a54b9af6a0afcb9d}} 
integer \hyperlink{namespacemom__dynamics__unsplit_adc6cdd4ab179eb08a54b9af6a0afcb9d}{id\+\_\+clock\+\_\+pres}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_af864cc832cfa9afe699729b7a1ffe771}\label{namespacemom__dynamics__unsplit_af864cc832cfa9afe699729b7a1ffe771}} 
integer \hyperlink{namespacemom__dynamics__unsplit_af864cc832cfa9afe699729b7a1ffe771}{id\+\_\+clock\+\_\+vertvisc}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_acef00db07a4b4452681805a38d32cd42}\label{namespacemom__dynamics__unsplit_acef00db07a4b4452681805a38d32cd42}} 
integer \hyperlink{namespacemom__dynamics__unsplit_acef00db07a4b4452681805a38d32cd42}{id\+\_\+clock\+\_\+continuity}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_abd538ee02d6d7eed31ecabd28112878f}\label{namespacemom__dynamics__unsplit_abd538ee02d6d7eed31ecabd28112878f}} 
integer \hyperlink{namespacemom__dynamics__unsplit_abd538ee02d6d7eed31ecabd28112878f}{id\+\_\+clock\+\_\+horvisc}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_abdefb2afd3276cea01a19bb1abf8b000}\label{namespacemom__dynamics__unsplit_abdefb2afd3276cea01a19bb1abf8b000}} 
integer \hyperlink{namespacemom__dynamics__unsplit_abdefb2afd3276cea01a19bb1abf8b000}{id\+\_\+clock\+\_\+mom\+\_\+update}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_aa92d65d25a49356373b1371643e71e28}\label{namespacemom__dynamics__unsplit_aa92d65d25a49356373b1371643e71e28}} 
integer \hyperlink{namespacemom__dynamics__unsplit_aa92d65d25a49356373b1371643e71e28}{id\+\_\+clock\+\_\+pass}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_a785a58754b93e29c25bec43e6130a3cb}\label{namespacemom__dynamics__unsplit_a785a58754b93e29c25bec43e6130a3cb}} 
integer \hyperlink{namespacemom__dynamics__unsplit_a785a58754b93e29c25bec43e6130a3cb}{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_a8f8e05fcc926eb5c1d41517f6b8cf1cb}\label{namespacemom__dynamics__unsplit_a8f8e05fcc926eb5c1d41517f6b8cf1cb}} 
\index{mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}!end\+\_\+dyn\+\_\+unsplit@{end\+\_\+dyn\+\_\+unsplit}}
\index{end\+\_\+dyn\+\_\+unsplit@{end\+\_\+dyn\+\_\+unsplit}!mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}}
\subsubsection{\texorpdfstring{end\+\_\+dyn\+\_\+unsplit()}{end\_dyn\_unsplit()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+::end\+\_\+dyn\+\_\+unsplit (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__dynamics__unsplit_1_1mom__dyn__unsplit__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up and deallocate memory associated with the unsplit dynamics module. 


\begin{DoxyParams}{Parameters}
{\em cs} & unsplit dynamics control structure that will be deallocated in this subroutine. \\
\hline
\end{DoxyParams}


Definition at line 709 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit.\+F90.


\begin{DoxyCode}
709   \textcolor{keywordtype}{type}(mom\_dyn\_unsplit\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< unsplit dynamics control structure that}
710 \textcolor{comment}{                                          !! will be deallocated in this subroutine.}
711 
712   dealloc\_(cs%diffu) ; dealloc\_(cs%diffv)
713   dealloc\_(cs%CAu)   ; dealloc\_(cs%CAv)
714   dealloc\_(cs%PFu)   ; dealloc\_(cs%PFv)
715 
716   \textcolor{keyword}{deallocate}(cs)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_aa428b0ad5ed3e6cbbb1fd83484eba2f8}\label{namespacemom__dynamics__unsplit_aa428b0ad5ed3e6cbbb1fd83484eba2f8}} 
\index{mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}!initialize\+\_\+dyn\+\_\+unsplit@{initialize\+\_\+dyn\+\_\+unsplit}}
\index{initialize\+\_\+dyn\+\_\+unsplit@{initialize\+\_\+dyn\+\_\+unsplit}!mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}}
\subsubsection{\texorpdfstring{initialize\+\_\+dyn\+\_\+unsplit()}{initialize\_dyn\_unsplit()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+::initialize\+\_\+dyn\+\_\+unsplit (\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(\hyperlink{structmom__dynamics__unsplit_1_1mom__dyn__unsplit__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+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 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.\\
\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 560 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit.\+F90.


\begin{DoxyCode}
560   \textcolor{keywordtype}{type}(ocean\_grid\_type),          \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{          !< The ocean's grid structure.}
561   \textcolor{keywordtype}{type}(verticalgrid\_type),        \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{         !< The ocean's vertical grid structure.}
562   \textcolor{keywordtype}{type}(unit\_scale\_type),          \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{         !< A dimensional unit scaling type}
563   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, &
564                                   \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{          !< The zonal velocity [L T-1 ~> m s-1].}
565   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, &
566                                   \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{          !< The meridional velocity [L T-1 ~> m s-1].}
567   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} , &
568                                   \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{          !< Layer thicknesses [H ~> m or kg m-2]}
569   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{       !< The current model time.}
570   \textcolor{keywordtype}{type}(param\_file\_type),          \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse}
571 \textcolor{comment}{                                                              !! for run-time parameters.}
572   \textcolor{keywordtype}{type}(diag\_ctrl),        \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{       !< A structure that is used to}
573 \textcolor{comment}{                                                              !! regulate diagnostic output.}
574   \textcolor{keywordtype}{type}(mom\_dyn\_unsplit\_cs),       \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{         !< The control structure set up}
575 \textcolor{comment}{                                                              !! by initialize\_dyn\_unsplit.}
576   \textcolor{keywordtype}{type}(mom\_restart\_cs),           \textcolor{keywordtype}{pointer}       :: restart\_cs\textcolor{comment}{ !< A pointer to the restart control}
577 \textcolor{comment}{                                                              !!structure.}
578   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),  \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: accel\_diag\textcolor{comment}{ !< A set of pointers to the various}
579 \textcolor{comment}{                                     !! accelerations in the momentum equations, which can be used}
580 \textcolor{comment}{                                     !! for later derived diagnostics, like energy budgets.}
581   \textcolor{keywordtype}{type}(cont\_diag\_ptrs),   \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: cont\_diag\textcolor{comment}{  !< A structure with pointers to}
582 \textcolor{comment}{                                                              !! various terms in the continuity}
583 \textcolor{comment}{                                                              !! equations.}
584   \textcolor{keywordtype}{type}(ocean\_internal\_state),     \textcolor{keywordtype}{intent(inout)} :: mis\textcolor{comment}{        !< The "MOM6 Internal State"}
585 \textcolor{comment}{                                                   !! structure, used to pass around pointers}
586 \textcolor{comment}{                                                   !! to various arrays for diagnostic purposes.}
587   \textcolor{keywordtype}{type}(meke\_type),                \textcolor{keywordtype}{pointer}       :: meke\textcolor{comment}{ !< MEKE data}
588   \textcolor{keywordtype}{type}(ocean\_obc\_type),           \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{        !< If open boundary conditions are}
589 \textcolor{comment}{                                                       !! used, this points to the ocean\_OBC\_type}
590 \textcolor{comment}{                                                       !! that was set up in MOM\_initialization.}
591   \textcolor{keywordtype}{type}(update\_obc\_cs),            \textcolor{keywordtype}{pointer}       :: update\_obc\_csp\textcolor{comment}{ !< If open boundary condition}
592 \textcolor{comment}{                                                            !! updates are used, this points to}
593 \textcolor{comment}{                                                            !! the appropriate control structure.}
594   \textcolor{keywordtype}{type}(ale\_cs),                   \textcolor{keywordtype}{pointer}       :: ale\_csp\textcolor{comment}{    !< This points to the ALE control}
595 \textcolor{comment}{                                                              !! structure.}
596   \textcolor{keywordtype}{type}(set\_visc\_cs),              \textcolor{keywordtype}{pointer}       :: setvisc\_csp\textcolor{comment}{ !< This points to the set\_visc}
597 \textcolor{comment}{                                                               !! control structure.}
598   \textcolor{keywordtype}{type}(vertvisc\_type),            \textcolor{keywordtype}{intent(inout)} :: visc\textcolor{comment}{       !< A structure containing vertical}
599 \textcolor{comment}{                                                              !! viscosities, bottom drag}
600 \textcolor{comment}{                                                              !! viscosities, and related fields.}
601   \textcolor{keywordtype}{type}(directories),              \textcolor{keywordtype}{intent(in)}    :: dirs\textcolor{comment}{       !< A structure containing several}
602 \textcolor{comment}{                                                              !! relevant directory paths.}
603   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{target},                \textcolor{keywordtype}{intent(inout)} :: ntrunc\textcolor{comment}{     !< A target for the variable that}
604 \textcolor{comment}{                                                        !! records the number of times the velocity}
605 \textcolor{comment}{                                                        !! is truncated (this should be 0).}
606   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: cont\_stencil\textcolor{comment}{ !< The stencil for thickness}
607 \textcolor{comment}{                                                                !! from the continuity solver.}
608 
609   \textcolor{comment}{!   This subroutine initializes all of the variables that are used by this}
610   \textcolor{comment}{! dynamic core, including diagnostics and the cpu clocks.}
611 
612   \textcolor{comment}{! Local variables}
613   \textcolor{keywordtype}{character(len=40)} :: mdl = \textcolor{stringliteral}{"MOM\_dynamics\_unsplit"} \textcolor{comment}{! This module's name.}
614   \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units
615   \textcolor{comment}{! This include declares and sets the variable "version".}
616 \textcolor{preprocessor}{# include "version\_variable.h"}
617 \textcolor{preprocessor}{}  \textcolor{keywordtype}{real} :: h\_convert
618   \textcolor{keywordtype}{logical} :: use\_tides
619   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, isdb, iedb, jsdb, jedb
620   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed ; nz = g%ke
621   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
622 
623   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, &
624       \textcolor{stringliteral}{"initialize\_dyn\_unsplit called with an unassociated control structure."})
625   \textcolor{keywordflow}{if} (cs%module\_is\_initialized) \textcolor{keywordflow}{then}
626     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_dyn\_unsplit called with a control "}// &
627                             \textcolor{stringliteral}{"structure that has already been initialized."})
628     \textcolor{keywordflow}{return}
629 \textcolor{keywordflow}{  endif}
630   cs%module\_is\_initialized = .true.
631 
632   cs%diag => diag
633 
634   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
635   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FIX\_UNSPLIT\_DT\_VISC\_BUG"}, cs%use\_correct\_dt\_visc, &
636                  \textcolor{stringliteral}{"If true, use the correct timestep in the viscous terms applied in the first "}//&
637                  \textcolor{stringliteral}{"predictor step with the unsplit time stepping scheme, and in the calculation "}//&
638                  \textcolor{stringliteral}{"of the turbulent mixed layer properties for viscosity with unsplit or "}//&
639                  \textcolor{stringliteral}{"unsplit\_RK2."}, default=.true.)
640   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEBUG"}, cs%debug, &
641                  \textcolor{stringliteral}{"If true, write out verbose debugging data."}, &
642                  default=.false., debuggingparam=.true.)
643   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TIDES"}, use\_tides, &
644                  \textcolor{stringliteral}{"If true, apply tidal momentum forcing."}, default=.false.)
645 
646   \textcolor{keyword}{allocate}(cs%taux\_bot(isdb:iedb,jsd:jed)) ; cs%taux\_bot(:,:) = 0.0
647   \textcolor{keyword}{allocate}(cs%tauy\_bot(isd:ied,jsdb:jedb)) ; cs%tauy\_bot(:,:) = 0.0
648 
649   mis%diffu => cs%diffu ; mis%diffv => cs%diffv
650   mis%PFu => cs%PFu ; mis%PFv => cs%PFv
651   mis%CAu => cs%CAu ; mis%CAv => cs%CAv
652 
653   cs%ADp => accel\_diag ; cs%CDp => cont\_diag
654   accel\_diag%diffu => cs%diffu ; accel\_diag%diffv => cs%diffv
655   accel\_diag%PFu => cs%PFu ; accel\_diag%PFv => cs%PFv
656   accel\_diag%CAu => cs%CAu ; accel\_diag%CAv => cs%CAv
657 
658   \textcolor{keyword}{call }continuity\_init(time, g, gv, us, param\_file, diag, cs%continuity\_CSp)
659   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cont\_stencil)) cont\_stencil = continuity\_stencil(cs%continuity\_CSp)
660   \textcolor{keyword}{call }coriolisadv\_init(time, g, gv, us, param\_file, diag, cs%ADp, cs%CoriolisAdv\_CSp)
661   \textcolor{keywordflow}{if} (use\_tides) \textcolor{keyword}{call }tidal\_forcing\_init(time, g, param\_file, cs%tides\_CSp)
662   \textcolor{keyword}{call }pressureforce\_init(time, g, gv, us, param\_file, diag, cs%PressureForce\_CSp, &
663                           cs%tides\_CSp)
664   \textcolor{keyword}{call }hor\_visc\_init(time, g, us, param\_file, diag, cs%hor\_visc\_CSp, meke)
665   \textcolor{keyword}{call }vertvisc\_init(mis, time, g, gv, us, param\_file, diag, cs%ADp, dirs, &
666                      ntrunc, cs%vertvisc\_CSp)
667   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(setvisc\_csp)) \textcolor{keyword}{call }mom\_error(fatal, &
668     \textcolor{stringliteral}{"initialize\_dyn\_unsplit called with setVisc\_CSp unassociated."})
669   cs%set\_visc\_CSp => setvisc\_csp
670 
671   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ale\_csp)) cs%ALE\_CSp => ale\_csp
672   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) cs%OBC => obc
673   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(update\_obc\_csp)) cs%update\_OBC\_CSp => update\_obc\_csp
674 
675   flux\_units = get\_flux\_units(gv)
676   h\_convert = gv%H\_to\_m ; \textcolor{keywordflow}{if} (.not.gv%Boussinesq) h\_convert = gv%H\_to\_kg\_m2
677   cs%id\_uh = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'uh'}, diag%axesCuL, time, &
678       \textcolor{stringliteral}{'Zonal Thickness Flux'}, flux\_units, y\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., &
679       conversion=h\_convert*us%L\_to\_m**2*us%s\_to\_T)
680   cs%id\_vh = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vh'}, diag%axesCvL, time, &
681       \textcolor{stringliteral}{'Meridional Thickness Flux'}, flux\_units, x\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., &
682       conversion=h\_convert*us%L\_to\_m**2*us%s\_to\_T)
683   cs%id\_CAu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CAu'}, diag%axesCuL, time, &
684       \textcolor{stringliteral}{'Zonal Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
685       conversion=us%L\_T2\_to\_m\_s2)
686   cs%id\_CAv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CAv'}, diag%axesCvL, time, &
687       \textcolor{stringliteral}{'Meridional Coriolis and Advective Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
688       conversion=us%L\_T2\_to\_m\_s2)
689   cs%id\_PFu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFu'}, diag%axesCuL, time, &
690       \textcolor{stringliteral}{'Zonal Pressure Force Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
691       conversion=us%L\_T2\_to\_m\_s2)
692   cs%id\_PFv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PFv'}, diag%axesCvL, time, &
693       \textcolor{stringliteral}{'Meridional Pressure Force Acceleration'}, \textcolor{stringliteral}{'m s-2'}, &
694       conversion=us%L\_T2\_to\_m\_s2)
695 
696   id\_clock\_cor = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean Coriolis & mom advection)'}, grain=clock\_module)
697   id\_clock\_continuity = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean continuity equation)'}, grain=clock\_module)
698   id\_clock\_pres = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean pressure force)'}, grain=clock\_module)
699   id\_clock\_vertvisc = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean vertical viscosity)'}, grain=clock\_module)
700   id\_clock\_horvisc = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean horizontal viscosity)'}, grain=clock\_module)
701   id\_clock\_mom\_update = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean momentum increments)'}, grain=clock\_module)
702   id\_clock\_pass = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean message passing)'}, grain=clock\_module)
703   id\_clock\_pass\_init = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean init message passing)'}, grain=clock\_routine)
704 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_a5a650785f745fd9cf42e1e014dd2d89a}\label{namespacemom__dynamics__unsplit_a5a650785f745fd9cf42e1e014dd2d89a}} 
\index{mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}!register\+\_\+restarts\+\_\+dyn\+\_\+unsplit@{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit}}
\index{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit@{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit}!mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}}
\subsubsection{\texorpdfstring{register\+\_\+restarts\+\_\+dyn\+\_\+unsplit()}{register\_restarts\_dyn\_unsplit()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+::register\+\_\+restarts\+\_\+dyn\+\_\+unsplit (\begin{DoxyParamCaption}\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structmom__dynamics__unsplit_1_1mom__dyn__unsplit__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+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 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.\\
\hline
 & {\em restart\+\_\+cs} & A pointer to the restart control structure. \\
\hline
\end{DoxyParams}


Definition at line 518 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit.\+F90.


\begin{DoxyCode}
518   \textcolor{keywordtype}{type}(hor\_index\_type),      \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{         !< A horizontal index type structure.}
519   \textcolor{keywordtype}{type}(verticalgrid\_type),   \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{         !< The ocean's vertical grid structure.}
520   \textcolor{keywordtype}{type}(param\_file\_type),     \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for}
521 \textcolor{comment}{                                                      !! run-time parameters.}
522   \textcolor{keywordtype}{type}(mom\_dyn\_unsplit\_cs),  \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{         !< The control structure set up by}
523 \textcolor{comment}{                                                      !! initialize\_dyn\_unsplit.}
524   \textcolor{keywordtype}{type}(mom\_restart\_cs),      \textcolor{keywordtype}{pointer}    :: restart\_cs\textcolor{comment}{ !< A pointer to the restart control structure.}
525 
526   \textcolor{comment}{! Local arguments}
527   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_dynamics\_unsplit"} \textcolor{comment}{! This module's name.}
528   \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units
529   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nz, isdb, iedb, jsdb, jedb
530   isd = hi%isd ; ied = hi%ied ; jsd = hi%jsd ; jed = hi%jed ; nz = gv%ke
531   isdb = hi%IsdB ; iedb = hi%IedB ; jsdb = hi%JsdB ; jedb = hi%JedB
532 
533   \textcolor{comment}{! This is where a control structure that is specific to this module is allocated.}
534   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
535     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"register\_restarts\_dyn\_unsplit called with an associated "}// &
536                              \textcolor{stringliteral}{"control structure."})
537     \textcolor{keywordflow}{return}
538 \textcolor{keywordflow}{  endif}
539   \textcolor{keyword}{allocate}(cs)
540 
541   alloc\_(cs%diffu(isdb:iedb,jsd:jed,nz)) ; cs%diffu(:,:,:) = 0.0
542   alloc\_(cs%diffv(isd:ied,jsdb:jedb,nz)) ; cs%diffv(:,:,:) = 0.0
543   alloc\_(cs%CAu(isdb:iedb,jsd:jed,nz)) ; cs%CAu(:,:,:) = 0.0
544   alloc\_(cs%CAv(isd:ied,jsdb:jedb,nz)) ; cs%CAv(:,:,:) = 0.0
545   alloc\_(cs%PFu(isdb:iedb,jsd:jed,nz)) ; cs%PFu(:,:,:) = 0.0
546   alloc\_(cs%PFv(isd:ied,jsdb:jedb,nz)) ; cs%PFv(:,:,:) = 0.0
547 
548   thickness\_units = get\_thickness\_units(gv)
549   flux\_units = get\_flux\_units(gv)
550 
551 \textcolor{comment}{!  No extra restart fields are needed with this time stepping scheme.}
552 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dynamics__unsplit_ab72d911d187f9247b6cc72d87e815370}\label{namespacemom__dynamics__unsplit_ab72d911d187f9247b6cc72d87e815370}} 
\index{mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}!step\+\_\+mom\+\_\+dyn\+\_\+unsplit@{step\+\_\+mom\+\_\+dyn\+\_\+unsplit}}
\index{step\+\_\+mom\+\_\+dyn\+\_\+unsplit@{step\+\_\+mom\+\_\+dyn\+\_\+unsplit}!mom\+\_\+dynamics\+\_\+unsplit@{mom\+\_\+dynamics\+\_\+unsplit}}
\subsubsection{\texorpdfstring{step\+\_\+mom\+\_\+dyn\+\_\+unsplit()}{step\_mom\_dyn\_unsplit()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dynamics\+\_\+unsplit\+::step\+\_\+mom\+\_\+dyn\+\_\+unsplit (\begin{DoxyParamCaption}\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{v,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(vertvisc\+\_\+type), intent(inout)}]{visc,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+local,  }\item[{real, intent(in)}]{dt,  }\item[{type(mech\+\_\+forcing), intent(in)}]{forces,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf\+\_\+begin,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf\+\_\+end,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{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(\hyperlink{structmom__dynamics__unsplit_1_1mom__dyn__unsplit__cs}{mom\+\_\+dyn\+\_\+unsplit\+\_\+cs}), pointer}]{CS,  }\item[{type(varmix\+\_\+cs), pointer}]{Var\+Mix,  }\item[{type(meke\+\_\+type), pointer}]{M\+E\+KE,  }\item[{type(wave\+\_\+parameters\+\_\+cs), optional, pointer}]{Waves }\end{DoxyParamCaption})}



Step the M\+O\+M6 dynamics using an unsplit mixed 2nd order (for continuity) and 3rd order (for the inviscid momentum equations) order 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} & 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 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 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 start 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.\\
\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
 & {\em waves} & A pointer to a structure containing fields related to the surface wave conditions \\
\hline
\end{DoxyParams}


Definition at line 192 of file M\+O\+M\+\_\+dynamics\+\_\+unsplit.\+F90.


\begin{DoxyCode}
192   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< The ocean's grid structure.}
193   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{     !< The ocean's vertical grid structure.}
194   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
195   \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].}
196   \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].}
197   \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].}
198   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{     !< A structure pointing to various}
199 \textcolor{comment}{                                                   !! thermodynamic variables.}
200   \textcolor{keywordtype}{type}(vertvisc\_type),     \textcolor{keywordtype}{intent(inout)} :: visc\textcolor{comment}{   !< A structure containing vertical}
201 \textcolor{comment}{                                 !! viscosities, bottom drag viscosities, and related fields.}
202   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: time\_local\textcolor{comment}{   !< The model time at the end}
203 \textcolor{comment}{                                                         !! of the time step.}
204   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< The dynamics time step [T ~> s].}
205   \textcolor{keywordtype}{type}(mech\_forcing),      \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
206   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},    \textcolor{keywordtype}{pointer}       :: p\_surf\_begin\textcolor{comment}{ !< A pointer (perhaps NULL) to the surface}
207 \textcolor{comment}{                                                   !! pressure at the start of this dynamic step [R L2 T-2
       ~> Pa].}
208   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},    \textcolor{keywordtype}{pointer}       :: p\_surf\_end\textcolor{comment}{   !< A pointer (perhaps NULL) to the surface}
209 \textcolor{comment}{                                                   !! pressure at the end of this dynamic step [R L2 T-2 ~>
       Pa].}
210   \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}
211 \textcolor{comment}{                                                   !! [H L2 T-1 ~> m3 s-1 or kg s-1].}
212   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: vh\textcolor{comment}{ !< The meridional volume or mass}
213 \textcolor{comment}{                                                   !! transport [H L2 T-1 ~> m3 s-1 or kg s-1].}
214   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: uhtr\textcolor{comment}{ !< The accumulated zonal volume or mass}
215 \textcolor{comment}{                                                   !! transport since the last tracer advection [H L2 ~> m3
       or kg].}
216   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: vhtr\textcolor{comment}{ !< The accumulated meridional volume or
       mass}
217 \textcolor{comment}{                                                   !! transport since the last tracer advection [H L2 ~> m3
       or kg].}
218   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)} :: eta\_av\textcolor{comment}{ !< The time-mean free surface height or}
219 \textcolor{comment}{                                                   !! column mass [H ~> m or kg m-2].}
220   \textcolor{keywordtype}{type}(mom\_dyn\_unsplit\_cs), \textcolor{keywordtype}{pointer}      :: cs\textcolor{comment}{     !< The control structure set up by}
221 \textcolor{comment}{                                                   !! initialize\_dyn\_unsplit.}
222   \textcolor{keywordtype}{type}(varmix\_cs),         \textcolor{keywordtype}{pointer}       :: varmix\textcolor{comment}{ !< A pointer to a structure with fields}
223 \textcolor{comment}{                                 !! that specify the spatially variable viscosities.}
224   \textcolor{keywordtype}{type}(meke\_type),         \textcolor{keywordtype}{pointer}       :: meke\textcolor{comment}{   !< A pointer to a structure containing}
225 \textcolor{comment}{                                 !! fields related to the Mesoscale Eddy Kinetic Energy.}
226   \textcolor{keywordtype}{type}(wave\_parameters\_cs), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer} :: waves\textcolor{comment}{ !< A pointer to a structure containing}
227 \textcolor{comment}{                                 !! fields related to the surface wave conditions}
228 
229   \textcolor{comment}{! Local variables}
230   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))} :: h\_av, hp \textcolor{comment}{! Prediced or averaged layer thicknesses [H ~> m or
       kg m-2]}
231   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))} :: up, upp \textcolor{comment}{! Predicted zonal velocities [L T-1 ~> m s-1]}
232   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))} :: vp, vpp \textcolor{comment}{! Predicted meridional velocities [L T-1 ~> m s-1]}
233   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: p\_surf => null()
234   \textcolor{keywordtype}{real} :: dt\_pred   \textcolor{comment}{! The time step for the predictor part of the baroclinic time stepping [T ~> s].}
235   \textcolor{keywordtype}{real} :: dt\_visc   \textcolor{comment}{! The time step for a part of the update due to viscosity [T ~> s].}
236   \textcolor{keywordtype}{logical} :: dyn\_p\_surf
237   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isq, ieq, jsq, jeq, nz
238   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
239   isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
240   dt\_pred = dt / 3.0
241 
242   h\_av(:,:,:) = 0; hp(:,:,:) = 0
243   up(:,:,:) = 0; upp(:,:,:) = 0
244   vp(:,:,:) = 0; vpp(:,:,:) = 0
245 
246   dyn\_p\_surf = \textcolor{keyword}{associated}(p\_surf\_begin) .and. \textcolor{keyword}{associated}(p\_surf\_end)
247   \textcolor{keywordflow}{if} (dyn\_p\_surf) \textcolor{keywordflow}{then}
248     \textcolor{keyword}{call }safe\_alloc\_ptr(p\_surf,g%isd,g%ied,g%jsd,g%jed) ; p\_surf(:,:) = 0.0
249   \textcolor{keywordflow}{else}
250     p\_surf => forces%p\_surf
251 \textcolor{keywordflow}{  endif}
252 
253 \textcolor{comment}{! Matsuno's third order accurate three step scheme is used to step}
254 \textcolor{comment}{! all of the fields except h.  h is stepped separately.}
255 
256   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
257     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Start First Predictor "}, u, v, h, uh, vh, g, gv, us)
258 \textcolor{keywordflow}{  endif}
259 
260 \textcolor{comment}{! diffu = horizontal viscosity terms (u,h)}
261   \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
262   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_horvisc)
263   \textcolor{keyword}{call }horizontal\_viscosity(u, v, h, cs%diffu, cs%diffv, meke, varmix, g, gv, us, cs%hor\_visc\_CSp)
264   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_horvisc)
265   \textcolor{keyword}{call }disable\_averaging(cs%diag)
266 
267 \textcolor{comment}{! uh = u*h}
268 \textcolor{comment}{! hp = h + dt/2 div . uh}
269   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
270   \textcolor{keyword}{call }continuity(u, v, h, hp, uh, vh, dt*0.5, g, gv, us, cs%continuity\_CSp, obc=cs%OBC)
271   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
272   \textcolor{keyword}{call }pass\_var(hp, g%Domain, clock=id\_clock\_pass)
273   \textcolor{keyword}{call }pass\_vector(uh, vh, g%Domain, clock=id\_clock\_pass)
274 
275   \textcolor{keyword}{call }enable\_averages(0.5*dt, time\_local-real\_to\_time(0.5*us%T\_to\_s*dt), cs%diag)
276 \textcolor{comment}{!   Here the first half of the thickness fluxes are offered for averaging.}
277   \textcolor{keywordflow}{if} (cs%id\_uh > 0) \textcolor{keyword}{call }post\_data(cs%id\_uh, uh, cs%diag)
278   \textcolor{keywordflow}{if} (cs%id\_vh > 0) \textcolor{keyword}{call }post\_data(cs%id\_vh, vh, cs%diag)
279   \textcolor{keyword}{call }disable\_averaging(cs%diag)
280 
281 \textcolor{comment}{! h\_av = (h + hp)/2}
282 \textcolor{comment}{! u = u + dt diffu}
283   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_update)
284   \textcolor{keywordflow}{do} k=1,nz
285     \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
286       h\_av(i,j,k) = (h(i,j,k) + hp(i,j,k)) * 0.5
287 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
288     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
289       u(i,j,k) = u(i,j,k) + dt * cs%diffu(i,j,k) * g%mask2dCu(i,j)
290 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
291     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
292       v(i,j,k) = v(i,j,k) + dt * cs%diffv(i,j,k) * g%mask2dCv(i,j)
293 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
294     \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=isq-2,ieq+2
295       uhtr(i,j,k) = uhtr(i,j,k) + 0.5*dt*uh(i,j,k)
296 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
297     \textcolor{keywordflow}{do} j=jsq-2,jeq+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
298       vhtr(i,j,k) = vhtr(i,j,k) + 0.5*dt*vh(i,j,k)
299 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
300 \textcolor{keywordflow}{  enddo}
301   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_update)
302   \textcolor{keyword}{call }pass\_vector(u, v, g%Domain, clock=id\_clock\_pass)
303 
304 \textcolor{comment}{! CAu = -(f+zeta)/h\_av vh + d/dx KE}
305   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_cor)
306   \textcolor{keyword}{call }coradcalc(u, v, h\_av, uh, vh, cs%CAu, cs%CAv, cs%OBC, cs%ADp, &
307                  g, gv, us, cs%CoriolisAdv\_CSp)
308   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_cor)
309 
310 \textcolor{comment}{! PFu = d/dx M(h\_av,T,S)}
311   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pres)
312   \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
313     p\_surf(i,j) = 0.75*p\_surf\_begin(i,j) + 0.25*p\_surf\_end(i,j)
314 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
315   \textcolor{keyword}{call }pressureforce(h\_av, tv, cs%PFu, cs%PFv, g, gv, us, &
316                      cs%PressureForce\_CSp, cs%ALE\_CSp, p\_surf)
317   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pres)
318 
319   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) then; \textcolor{keywordflow}{if} (cs%OBC%update\_OBC) \textcolor{keywordflow}{then}
320     \textcolor{keyword}{call }update\_obc\_data(cs%OBC, g, gv, us, tv, h, cs%update\_OBC\_CSp, time\_local)
321 \textcolor{keyword}{  end}if; endif
322   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
323     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%PFu, cs%PFv)
324     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%CAu, cs%CAv)
325 \textcolor{keywordflow}{  endif}
326 
327 \textcolor{comment}{! up = u + dt\_pred * (PFu + CAu)}
328   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_update)
329   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
330     up(i,j,k) = g%mask2dCu(i,j) * (u(i,j,k) + dt\_pred * (cs%PFu(i,j,k) + cs%CAu(i,j,k)))
331 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
332   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
333     vp(i,j,k) = g%mask2dCv(i,j) * (v(i,j,k) + dt\_pred * (cs%PFv(i,j,k) + cs%CAv(i,j,k)))
334 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
335   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_update)
336 
337   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
338     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Predictor 1"}, up, vp, h\_av, uh, vh, g, gv, us)
339     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"Predictor 1 accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
340                           cs%diffu, cs%diffv, g, gv, us)
341 \textcolor{keywordflow}{  endif}
342 
343  \textcolor{comment}{! up <- up + dt/2 d/dz visc d/dz up}
344   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
345   \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
346   dt\_visc = 0.5*dt ; \textcolor{keywordflow}{if} (cs%use\_correct\_dt\_visc) dt\_visc = dt
347   \textcolor{keyword}{call }set\_viscous\_ml(u, v, h\_av, tv, forces, visc, dt\_visc, g, gv, us, cs%set\_visc\_CSp)
348   \textcolor{keyword}{call }disable\_averaging(cs%diag)
349 
350   dt\_visc = 0.5*dt ; \textcolor{keywordflow}{if} (cs%use\_correct\_dt\_visc) dt\_visc = dt\_pred
351   \textcolor{keyword}{call }vertvisc\_coef(up, vp, h\_av, forces, visc, dt\_visc, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
352   \textcolor{keyword}{call }vertvisc(up, vp, h\_av, forces, visc, dt\_visc, cs%OBC, cs%ADp, cs%CDp, &
353                 g, gv, us, cs%vertvisc\_CSp, waves=waves)
354   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
355   \textcolor{keyword}{call }pass\_vector(up, vp, g%Domain, clock=id\_clock\_pass)
356 
357 \textcolor{comment}{! uh = up * hp}
358 \textcolor{comment}{! h\_av = hp + dt/2 div . uh}
359   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
360   \textcolor{keyword}{call }continuity(up, vp, hp, h\_av, uh, vh, (0.5*dt), g, gv, us, cs%continuity\_CSp, obc=cs%OBC)
361   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
362   \textcolor{keyword}{call }pass\_var(h\_av, g%Domain, clock=id\_clock\_pass)
363   \textcolor{keyword}{call }pass\_vector(uh, vh, g%Domain, clock=id\_clock\_pass)
364 
365 \textcolor{comment}{! h\_av <- (hp + h\_av)/2}
366   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
367     h\_av(i,j,k) = (hp(i,j,k) + h\_av(i,j,k)) * 0.5
368 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
369 
370 \textcolor{comment}{! CAu = -(f+zeta(up))/h\_av vh + d/dx KE(up)}
371   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_cor)
372   \textcolor{keyword}{call }coradcalc(up, vp, h\_av, uh, vh, cs%CAu, cs%CAv, cs%OBC, cs%ADp, &
373                  g, gv, us, cs%CoriolisAdv\_CSp)
374   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_cor)
375 
376 \textcolor{comment}{! PFu = d/dx M(h\_av,T,S)}
377   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pres)
378   \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
379     p\_surf(i,j) = 0.25*p\_surf\_begin(i,j) + 0.75*p\_surf\_end(i,j)
380 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
381   \textcolor{keyword}{call }pressureforce(h\_av, tv, cs%PFu, cs%PFv, g, gv, us, &
382                      cs%PressureForce\_CSp, cs%ALE\_CSp, p\_surf)
383   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pres)
384 
385   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) then; \textcolor{keywordflow}{if} (cs%OBC%update\_OBC) \textcolor{keywordflow}{then}
386     \textcolor{keyword}{call }update\_obc\_data(cs%OBC, g, gv, us, tv, h, cs%update\_OBC\_CSp, time\_local)
387 \textcolor{keyword}{  end}if; endif
388   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
389     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%PFu, cs%PFv)
390     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%CAu, cs%CAv)
391 \textcolor{keywordflow}{  endif}
392 
393 \textcolor{comment}{! upp = u + dt/2 * ( PFu + CAu )}
394   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_update)
395   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
396     upp(i,j,k) = g%mask2dCu(i,j) * (u(i,j,k) + dt * 0.5 * (cs%PFu(i,j,k) + cs%CAu(i,j,k)))
397 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
398   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
399     vpp(i,j,k) = g%mask2dCv(i,j) * (v(i,j,k) + dt * 0.5 * (cs%PFv(i,j,k) + cs%CAv(i,j,k)))
400 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
401   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_update)
402 
403   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
404     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Predictor 2"}, upp, vpp, h\_av, uh, vh, g, gv, us)
405     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"Predictor 2 accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
406                           cs%diffu, cs%diffv, g, gv, us)
407 \textcolor{keywordflow}{  endif}
408 
409 \textcolor{comment}{! upp <- upp + dt/2 d/dz visc d/dz upp}
410   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
411   \textcolor{keyword}{call }vertvisc\_coef(upp, vpp, hp, forces, visc, dt*0.5, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
412   \textcolor{keyword}{call }vertvisc(upp, vpp, hp, forces, visc, dt*0.5, cs%OBC, cs%ADp, cs%CDp, &
413                 g, gv, us, cs%vertvisc\_CSp, waves=waves)
414   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
415   \textcolor{keyword}{call }pass\_vector(upp, vpp, g%Domain, clock=id\_clock\_pass)
416 
417 \textcolor{comment}{! uh = upp * hp}
418 \textcolor{comment}{! h = hp + dt/2 div . uh}
419   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_continuity)
420   \textcolor{keyword}{call }continuity(upp, vpp, hp, h, uh, vh, (dt*0.5), g, gv, us, cs%continuity\_CSp, obc=cs%OBC)
421   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_continuity)
422   \textcolor{keyword}{call }pass\_var(h, g%Domain, clock=id\_clock\_pass)
423   \textcolor{keyword}{call }pass\_vector(uh, vh, g%Domain, clock=id\_clock\_pass)
424   \textcolor{comment}{! Whenever thickness changes let the diag manager know, target grids}
425   \textcolor{comment}{! for vertical remapping may need to be regenerated.}
426   \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
427 
428   \textcolor{keyword}{call }enable\_averages(0.5*dt, time\_local, cs%diag)
429 \textcolor{comment}{!   Here the second half of the thickness fluxes are offered for averaging.}
430   \textcolor{keywordflow}{if} (cs%id\_uh > 0) \textcolor{keyword}{call }post\_data(cs%id\_uh, uh, cs%diag)
431   \textcolor{keywordflow}{if} (cs%id\_vh > 0) \textcolor{keyword}{call }post\_data(cs%id\_vh, vh, cs%diag)
432   \textcolor{keyword}{call }disable\_averaging(cs%diag)
433   \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
434 
435 \textcolor{comment}{! h\_av = (h + hp)/2}
436   \textcolor{keywordflow}{do} k=1,nz
437     \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
438       h\_av(i,j,k) = 0.5*(h(i,j,k) + hp(i,j,k))
439 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
440     \textcolor{keywordflow}{do} j=js-2,je+2 ; \textcolor{keywordflow}{do} i=isq-2,ieq+2
441       uhtr(i,j,k) = uhtr(i,j,k) + 0.5*dt*uh(i,j,k)
442 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
443     \textcolor{keywordflow}{do} j=jsq-2,jeq+2 ; \textcolor{keywordflow}{do} i=is-2,ie+2
444       vhtr(i,j,k) = vhtr(i,j,k) + 0.5*dt*vh(i,j,k)
445 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
446 \textcolor{keywordflow}{  enddo}
447 
448 \textcolor{comment}{! CAu = -(f+zeta(upp))/h\_av vh + d/dx KE(upp)}
449   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_cor)
450   \textcolor{keyword}{call }coradcalc(upp, vpp, h\_av, uh, vh, cs%CAu, cs%CAv, cs%OBC, cs%ADp, &
451                  g, gv, us, cs%CoriolisAdv\_CSp)
452   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_cor)
453 
454 \textcolor{comment}{! PFu = d/dx M(h\_av,T,S)}
455   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pres)
456   \textcolor{keyword}{call }pressureforce(h\_av, tv, cs%PFu, cs%PFv, g, gv, us, &
457                      cs%PressureForce\_CSp, cs%ALE\_CSp, p\_surf)
458   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pres)
459 
460   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) then; \textcolor{keywordflow}{if} (cs%OBC%update\_OBC) \textcolor{keywordflow}{then}
461     \textcolor{keyword}{call }update\_obc\_data(cs%OBC, g, gv, us, tv, h, cs%update\_OBC\_CSp, time\_local)
462 \textcolor{keyword}{  end}if; endif
463 
464 \textcolor{comment}{! u = u + dt * ( PFu + CAu )}
465   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keywordflow}{then}
466     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%PFu, cs%PFv)
467     \textcolor{keyword}{call }open\_boundary\_zero\_normal\_flow(cs%OBC, g, cs%CAu, cs%CAv)
468 \textcolor{keywordflow}{  endif}
469   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
470     u(i,j,k) = g%mask2dCu(i,j) * (u(i,j,k) + dt * (cs%PFu(i,j,k) + cs%CAu(i,j,k)))
471 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
472   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
473     v(i,j,k) = g%mask2dCv(i,j) * (v(i,j,k) + dt * (cs%PFv(i,j,k) + cs%CAv(i,j,k)))
474 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
475 
476 \textcolor{comment}{! u <- u + dt d/dz visc d/dz u}
477   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_vertvisc)
478   \textcolor{keyword}{call }vertvisc\_coef(u, v, h\_av, forces, visc, dt, g, gv, us, cs%vertvisc\_CSp, cs%OBC)
479   \textcolor{keyword}{call }vertvisc(u, v, h\_av, forces, visc, dt, cs%OBC, cs%ADp, cs%CDp, &
480                 g, gv, us, cs%vertvisc\_CSp, cs%taux\_bot, cs%tauy\_bot, waves=waves)
481   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_vertvisc)
482   \textcolor{keyword}{call }pass\_vector(u, v, g%Domain, clock=id\_clock\_pass)
483 
484   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
485     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Corrector"}, u, v, h, uh, vh, g, gv, us)
486     \textcolor{keyword}{call }mom\_accel\_chksum(\textcolor{stringliteral}{"Corrector accel"}, cs%CAu, cs%CAv, cs%PFu, cs%PFv, &
487                           cs%diffu, cs%diffv, g, gv, us)
488 \textcolor{keywordflow}{  endif}
489 
490   \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then}
491     \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}
492   \textcolor{keywordflow}{else}
493     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; eta\_av(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
494 \textcolor{keywordflow}{  endif}
495   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
496     eta\_av(i,j) = eta\_av(i,j) + h\_av(i,j,k)
497 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
498 
499   \textcolor{keywordflow}{if} (dyn\_p\_surf) \textcolor{keyword}{deallocate}(p\_surf)
500 
501 \textcolor{comment}{!   Here various terms used in to update the momentum equations are}
502 \textcolor{comment}{! offered for averaging.}
503   \textcolor{keywordflow}{if} (cs%id\_PFu > 0) \textcolor{keyword}{call }post\_data(cs%id\_PFu, cs%PFu, cs%diag)
504   \textcolor{keywordflow}{if} (cs%id\_PFv > 0) \textcolor{keyword}{call }post\_data(cs%id\_PFv, cs%PFv, cs%diag)
505   \textcolor{keywordflow}{if} (cs%id\_CAu > 0) \textcolor{keyword}{call }post\_data(cs%id\_CAu, cs%CAu, cs%diag)
506   \textcolor{keywordflow}{if} (cs%id\_CAv > 0) \textcolor{keyword}{call }post\_data(cs%id\_CAv, cs%CAv, cs%diag)
507 
\end{DoxyCode}
