\hypertarget{namespacemom__diagnostics}{}\doxysection{mom\+\_\+diagnostics Module Reference}
\label{namespacemom__diagnostics}\index{mom\_diagnostics@{mom\_diagnostics}}


\doxysubsection{Detailed Description}
Calculates any requested diagnostic quantities that are not calculated in the various subroutines. Diagnostic quantities are requested by allocating them memory. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em The control structure for the M\+O\+M\+\_\+diagnostics module. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diagnostics_1_1surface__diag__ids}{surface\+\_\+diag\+\_\+ids}}
\begin{DoxyCompactList}\small\item\em A structure with diagnostic I\+Ds of the surface and integrated variables. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diagnostics_1_1transport__diag__ids}{transport\+\_\+diag\+\_\+ids}}
\begin{DoxyCompactList}\small\item\em A structure with diagnostic I\+Ds of mass transport related diagnostics. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_a6bd689b4d9f660020d8e3960879b4799}{calculate\+\_\+diagnostic\+\_\+fields}} (u, v, h, uh, vh, tv, A\+Dp, C\+Dp, p\+\_\+surf, dt, diag\+\_\+pre\+\_\+sync, G, GV, US, CS, eta\+\_\+bt)
\begin{DoxyCompactList}\small\item\em Diagnostics not more naturally calculated elsewhere are computed here. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diagnostics_ab43b50cd32dfe693c6ce575c279988fb}{find\+\_\+weights}} (Rlist, R\+\_\+in, k, nz, wt, wt\+\_\+p)
\begin{DoxyCompactList}\small\item\em This subroutine finds the location of R\+\_\+in in an increasing ordered list, Rlist, returning as k the element such that Rlist(k) $<$= R\+\_\+in $<$ Rlist(k+1), and where wt and wt\+\_\+p are the linear weights that should be assigned to elements k and k+1. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diagnostics_a3dc7691c006b2abc1c355adc8e4d1a34}{calculate\+\_\+vertical\+\_\+integrals}} (h, tv, p\+\_\+surf, G, GV, US, CS)
\begin{DoxyCompactList}\small\item\em This subroutine calculates vertical integrals of several tracers, along with the mass-\/weight of these tracers, the total column mass, and the carefully calculated column height. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diagnostics_ad8679de99516ebb0ec2a973c441f2fec}{calculate\+\_\+energy\+\_\+diagnostics}} (u, v, h, uh, vh, A\+Dp, C\+Dp, G, GV, US, CS)
\begin{DoxyCompactList}\small\item\em This subroutine calculates terms in the mechanical energy budget. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_addfe6cd212e836194ccaf737bcc5cce8}{register\+\_\+time\+\_\+deriv}} (lb, f\+\_\+ptr, deriv\+\_\+ptr, CS)
\begin{DoxyCompactList}\small\item\em This subroutine registers fields to calculate a diagnostic time derivative. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diagnostics_ad69737c75e3f4a36546c8437fb39b099}{calculate\+\_\+derivs}} (dt, G, CS)
\begin{DoxyCompactList}\small\item\em This subroutine calculates all registered time derivatives. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_ac756556059608d88e6a4ef34a07e60ee}{post\+\_\+surface\+\_\+dyn\+\_\+diags}} (I\+Ds, G, diag, sfc\+\_\+state, ssh)
\begin{DoxyCompactList}\small\item\em This routine posts diagnostics of various dynamic ocean surface quantities, including velocities, speed and sea surface height, at the time the ocean state is reported back to the caller. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_a6fc7dbf8144ba279cc9b7856780ba5d6}{post\+\_\+surface\+\_\+thermo\+\_\+diags}} (I\+Ds, G, GV, US, diag, dt\+\_\+int, sfc\+\_\+state, tv, ssh, ssh\+\_\+ibc)
\begin{DoxyCompactList}\small\item\em This routine posts diagnostics of various ocean surface and integrated quantities at the time the ocean state is reported back to the caller. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_acab7430159d4702301069d0d4f82f45c}{post\+\_\+transport\+\_\+diagnostics}} (G, GV, US, uhtr, vhtr, h, I\+Ds, diag\+\_\+pre\+\_\+dyn, diag, dt\+\_\+trans, Reg)
\begin{DoxyCompactList}\small\item\em This routine posts diagnostics of the transports, including the subgridscale contributions. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_ae8281123dfff124b0a362ea9fd1e0078}{mom\+\_\+diagnostics\+\_\+init}} (M\+IS, A\+Dp, C\+Dp, Time, G, GV, US, param\+\_\+file, diag, CS, tv)
\begin{DoxyCompactList}\small\item\em This subroutine registers various diagnostics and allocates space for fields that other diagnostis depend upon. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_ae9e2f6374b60bc78898a3c462174f90d}{register\+\_\+surface\+\_\+diags}} (Time, G, US, I\+Ds, diag, tv)
\begin{DoxyCompactList}\small\item\em Register diagnostics of the surface state and integrated quantities. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_ac16b7c49e4a4b5ea2beb426bc5270ee9}{register\+\_\+transport\+\_\+diags}} (Time, G, GV, US, I\+Ds, diag)
\begin{DoxyCompactList}\small\item\em Register certain diagnostics related to transports. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_af505e1356cf2f8172d27b60136b928e4}{write\+\_\+static\+\_\+fields}} (G, GV, US, tv, diag)
\begin{DoxyCompactList}\small\item\em Offers the static fields in the ocean grid type for output via the diag\+\_\+manager. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diagnostics_a90a92410576d955e89d2aa4e3f6d7402}{set\+\_\+dependent\+\_\+diagnostics}} (M\+IS, A\+Dp, C\+Dp, G, CS)
\begin{DoxyCompactList}\small\item\em This subroutine sets up diagnostics upon which other diagnostics depend. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diagnostics_ae7ada8fb77b23b1b4cfb10d8c8b0ba50}{mom\+\_\+diagnostics\+\_\+end}} (CS, A\+Dp)
\begin{DoxyCompactList}\small\item\em Deallocate memory associated with the diagnostics module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__diagnostics_ad69737c75e3f4a36546c8437fb39b099}\label{namespacemom__diagnostics_ad69737c75e3f4a36546c8437fb39b099}} 
\index{mom\_diagnostics@{mom\_diagnostics}!calculate\_derivs@{calculate\_derivs}}
\index{calculate\_derivs@{calculate\_derivs}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{calculate\_derivs()}{calculate\_derivs()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diagnostics\+::calculate\+\_\+derivs (\begin{DoxyParamCaption}\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), intent(inout)}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine calculates all registered time derivatives. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em dt} & The time interval over which differences occur \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & Control structure returned by previous call to diagnostics\+\_\+init. \\
\hline
\end{DoxyParams}


Definition at line 1193 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1194 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The time interval over which differences occur [T \string~> s].}}
\DoxyCodeLine{1195   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{1196   \textcolor{keywordtype}{type}(diagnostics\_CS),  \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< Control structure returned by previous call to}}
\DoxyCodeLine{1197 \textcolor{comment}{                                               !! diagnostics\_init.}}
\DoxyCodeLine{1198 }
\DoxyCodeLine{1199 \textcolor{comment}{! This subroutine calculates all registered time derivatives.}}
\DoxyCodeLine{1200 \textcolor{keywordtype}{  real} :: Idt  \textcolor{comment}{! The inverse timestep [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{1201   \textcolor{keywordtype}{integer} :: i, j, k, m}
\DoxyCodeLine{1202 }
\DoxyCodeLine{1203   \textcolor{keywordflow}{if} (dt > 0.0) \textcolor{keywordflow}{then} ; idt = 1.0/dt}
\DoxyCodeLine{1204   \textcolor{keywordflow}{else} ; \textcolor{keywordflow}{return} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1205 }
\DoxyCodeLine{1206   \textcolor{comment}{! Because the field is unknown, its grid index bounds are also unknown.}}
\DoxyCodeLine{1207   \textcolor{comment}{! Additionally, two of the fields (dudt, dvdt) require calculation of spatial}}
\DoxyCodeLine{1208   \textcolor{comment}{! derivatives when computing d(KE)/dt.  This raises issues in non-\/symmetric}}
\DoxyCodeLine{1209   \textcolor{comment}{! mode, where the symmetric boundaries (west, south) may not be updated.}}
\DoxyCodeLine{1210 }
\DoxyCodeLine{1211   \textcolor{comment}{! For this reason, we explicitly loop from isc-\/1:iec and jsc-\/1:jec, in order}}
\DoxyCodeLine{1212   \textcolor{comment}{! to force boundary value updates, even though it may not be strictly valid}}
\DoxyCodeLine{1213   \textcolor{comment}{! for all fields.  Note this assumes a halo, and that it has been updated.}}
\DoxyCodeLine{1214 }
\DoxyCodeLine{1215   \textcolor{keywordflow}{do} m=1,cs\%num\_time\_deriv}
\DoxyCodeLine{1216     \textcolor{keywordflow}{do} k=1,cs\%nlay(m) ; \textcolor{keywordflow}{do} j=g\%jsc-\/1,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc-\/1,g\%iec}
\DoxyCodeLine{1217       cs\%deriv(m)\%p(i,j,k) = (cs\%var\_ptr(m)\%p(i,j,k) -\/ cs\%prev\_val(m)\%p(i,j,k)) * idt}
\DoxyCodeLine{1218       cs\%prev\_val(m)\%p(i,j,k) = cs\%var\_ptr(m)\%p(i,j,k)}
\DoxyCodeLine{1219 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1220 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1221 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_a6bd689b4d9f660020d8e3960879b4799}\label{namespacemom__diagnostics_a6bd689b4d9f660020d8e3960879b4799}} 
\index{mom\_diagnostics@{mom\_diagnostics}!calculate\_diagnostic\_fields@{calculate\_diagnostic\_fields}}
\index{calculate\_diagnostic\_fields@{calculate\_diagnostic\_fields}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{calculate\_diagnostic\_fields()}{calculate\_diagnostic\_fields()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::calculate\+\_\+diagnostic\+\_\+fields (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in)}]{v,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{uh,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in)}]{vh,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(in)}]{A\+Dp,  }\item[{type(cont\+\_\+diag\+\_\+ptrs), intent(in)}]{C\+Dp,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf,  }\item[{real, intent(in)}]{dt,  }\item[{type(diag\+\_\+grid\+\_\+storage), intent(in)}]{diag\+\_\+pre\+\_\+sync,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), intent(inout)}]{CS,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in), optional}]{eta\+\_\+bt }\end{DoxyParamCaption})}



Diagnostics not more naturally calculated elsewhere are computed here. 


\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}}  & {\em u} & The zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em v} & The meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em uh} & Transport through zonal faces = u$\ast$h$\ast$dy, \\
\hline
\mbox{\texttt{ in}}  & {\em vh} & Transport through meridional faces = v$\ast$h$\ast$dx, \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables. \\
\hline
\mbox{\texttt{ in}}  & {\em adp} & structure with pointers to accelerations in momentum equation. \\
\hline
\mbox{\texttt{ in}}  & {\em cdp} & structure with pointers to terms in continuity equation. \\
\hline
 & {\em p\+\_\+surf} & A pointer to the surface pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}. If p\+\_\+surf is not associated, it is the same as setting the surface pressure to 0. \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The time difference since the last call to this subroutine \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em diag\+\_\+pre\+\_\+sync} & Target grids from previous timestep \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & Control structure returned by a previous call to diagnostics\+\_\+init. \\
\hline
\mbox{\texttt{ in}}  & {\em eta\+\_\+bt} & An optional barotropic \\
\hline
\end{DoxyParams}


Definition at line 195 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{197   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{198   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{199   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{200 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{201                            \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{    !< The zonal velocity [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{202 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{203                            \textcolor{keywordtype}{intent(in)}    :: v\textcolor{comment}{    !< The meridional velocity [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{204 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \&}
\DoxyCodeLine{205                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{206 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{207                            \textcolor{keywordtype}{intent(in)}    :: uh\textcolor{comment}{   !< Transport through zonal faces = u*h*dy,}}
\DoxyCodeLine{208 \textcolor{comment}{                                                 !! [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{209 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{210                            \textcolor{keywordtype}{intent(in)}    :: vh\textcolor{comment}{   !< Transport through meridional faces = v*h*dx,}}
\DoxyCodeLine{211 \textcolor{comment}{                                                 !! [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{212   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< A structure pointing to various}}
\DoxyCodeLine{213 \textcolor{comment}{                                                 !! thermodynamic variables.}}
\DoxyCodeLine{214   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: ADp\textcolor{comment}{  !< structure with pointers to}}
\DoxyCodeLine{215 \textcolor{comment}{                                                 !! accelerations in momentum equation.}}
\DoxyCodeLine{216   \textcolor{keywordtype}{type}(cont\_diag\_ptrs),    \textcolor{keywordtype}{intent(in)}    :: CDp\textcolor{comment}{  !< structure with pointers to}}
\DoxyCodeLine{217 \textcolor{comment}{                                                 !! terms in continuity equation.}}
\DoxyCodeLine{218 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},    \textcolor{keywordtype}{pointer}       :: p\_surf\textcolor{comment}{ !< A pointer to the surface pressure [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{219 \textcolor{comment}{                                                 !! If p\_surf is not associated, it is the same}}
\DoxyCodeLine{220 \textcolor{comment}{                                                 !! as setting the surface pressure to 0.}}
\DoxyCodeLine{221 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The time difference since the last}}
\DoxyCodeLine{222 \textcolor{comment}{                                                 !! call to this subroutine [T \string~> s].}}
\DoxyCodeLine{223   \textcolor{keywordtype}{type}(diag\_grid\_storage), \textcolor{keywordtype}{intent(in)}    :: diag\_pre\_sync\textcolor{comment}{ !< Target grids from previous timestep}}
\DoxyCodeLine{224   \textcolor{keywordtype}{type}(diagnostics\_CS),    \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< Control structure returned by a}}
\DoxyCodeLine{225 \textcolor{comment}{                                                 !! previous call to diagnostics\_init.}}
\DoxyCodeLine{226 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{227                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}   :: eta\_bt\textcolor{comment}{ !< An optional barotropic}}
\DoxyCodeLine{228 \textcolor{comment}{    !! variable that gives the "correct" free surface height (Boussinesq) or total water column}}
\DoxyCodeLine{229 \textcolor{comment}{    !! mass per unit area (non-\/Boussinesq).  This is used to dilate the layer thicknesses when}}
\DoxyCodeLine{230 \textcolor{comment}{    !! calculating interface heights [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{231 }
\DoxyCodeLine{232   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{233   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom \textcolor{comment}{! The i-\/computational domain for the equation of state}}
\DoxyCodeLine{234   \textcolor{keywordtype}{integer} i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz, nkmb}
\DoxyCodeLine{235 }
\DoxyCodeLine{236 \textcolor{keywordtype}{  real} :: Rcv(SZI\_(G),SZJ\_(G),SZK\_(G))  \textcolor{comment}{! Coordinate variable potential density [R \string~> kg m-\/3].}}
\DoxyCodeLine{237 \textcolor{keywordtype}{  real} :: work\_3d(SZI\_(G),SZJ\_(G),SZK\_(G)) \textcolor{comment}{! A 3-\/d temporary work array.}}
\DoxyCodeLine{238 \textcolor{keywordtype}{  real} :: work\_2d(SZI\_(G),SZJ\_(G))         \textcolor{comment}{! A 2-\/d temporary work array.}}
\DoxyCodeLine{239 \textcolor{keywordtype}{  real} :: rho\_in\_situ(SZI\_(G))             \textcolor{comment}{! In situ density [R \string~> kg m-\/3]}}
\DoxyCodeLine{240 }
\DoxyCodeLine{241 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: \&}
\DoxyCodeLine{242     hf\_du\_dt\_2d, hf\_dv\_dt\_2d \textcolor{comment}{! z integeral of hf\_du\_dt, hf\_dv\_dt [L T-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{243 }
\DoxyCodeLine{244   \textcolor{comment}{! tmp array for surface properties}}
\DoxyCodeLine{245 \textcolor{keywordtype}{  real} :: surface\_field(SZI\_(G),SZJ\_(G))}
\DoxyCodeLine{246 \textcolor{keywordtype}{  real} :: pressure\_1d(SZI\_(G)) \textcolor{comment}{! Temporary array for pressure when calling EOS [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{247 \textcolor{keywordtype}{  real} :: wt, wt\_p}
\DoxyCodeLine{248 }
\DoxyCodeLine{249 \textcolor{keywordtype}{  real} :: f2\_h     \textcolor{comment}{! Squared Coriolis parameter at to h-\/points [T-\/2 \string~> s-\/2]}}
\DoxyCodeLine{250 \textcolor{keywordtype}{  real} :: mag\_beta \textcolor{comment}{! Magnitude of the gradient of f [T-\/1 L-\/1 \string~> s-\/1 m-\/1]}}
\DoxyCodeLine{251 \textcolor{keywordtype}{  real} :: absurdly\_small\_freq2 \textcolor{comment}{! Frequency squared used to avoid division by 0 [T-\/2 \string~> s-\/2]}}
\DoxyCodeLine{252 }
\DoxyCodeLine{253   \textcolor{keywordtype}{integer} :: k\_list}
\DoxyCodeLine{254 }
\DoxyCodeLine{255 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(G))} :: temp\_layer\_ave, salt\_layer\_ave}
\DoxyCodeLine{256 \textcolor{keywordtype}{  real} :: thetaoga, soga, masso, tosga, sosga}
\DoxyCodeLine{257 }
\DoxyCodeLine{258   is  = g\%isc  ; ie   = g\%iec  ; js  = g\%jsc  ; je  = g\%jec}
\DoxyCodeLine{259   isq = g\%IscB ; ieq  = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{260   nz  = g\%ke   ; nkmb = gv\%nk\_rho\_varies}
\DoxyCodeLine{261 }
\DoxyCodeLine{262   \textcolor{comment}{! This value is roughly (pi / (the age of the universe) )\string^2.}}
\DoxyCodeLine{263   absurdly\_small\_freq2 = 1e-\/34*us\%T\_to\_s**2}
\DoxyCodeLine{264 }
\DoxyCodeLine{265   \textcolor{keywordflow}{if} (loc(cs)==0) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{266          \textcolor{stringliteral}{"calculate\_diagnostic\_fields: Module must be initialized before used."})}
\DoxyCodeLine{267 }
\DoxyCodeLine{268   \textcolor{keyword}{call }calculate\_derivs(dt, g, cs)}
\DoxyCodeLine{269 }
\DoxyCodeLine{270   \textcolor{keywordflow}{if} (dt > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{271     \textcolor{keyword}{call }diag\_save\_grids(cs\%diag)}
\DoxyCodeLine{272     \textcolor{keyword}{call }diag\_copy\_storage\_to\_diag(cs\%diag, diag\_pre\_sync)}
\DoxyCodeLine{273 }
\DoxyCodeLine{274     \textcolor{keywordflow}{if} (cs\%id\_h\_pre\_sync > 0) \&}
\DoxyCodeLine{275         \textcolor{keyword}{call }post\_data(cs\%id\_h\_pre\_sync, diag\_pre\_sync\%h\_state, cs\%diag, alt\_h = diag\_pre\_sync\%h\_state)}
\DoxyCodeLine{276 }
\DoxyCodeLine{277     \textcolor{keywordflow}{if} (cs\%id\_du\_dt>0) \textcolor{keyword}{call }post\_data(cs\%id\_du\_dt, cs\%du\_dt, cs\%diag, alt\_h = diag\_pre\_sync\%h\_state)}
\DoxyCodeLine{278 }
\DoxyCodeLine{279     \textcolor{keywordflow}{if} (cs\%id\_dv\_dt>0) \textcolor{keyword}{call }post\_data(cs\%id\_dv\_dt, cs\%dv\_dt, cs\%diag, alt\_h = diag\_pre\_sync\%h\_state)}
\DoxyCodeLine{280 }
\DoxyCodeLine{281     \textcolor{keywordflow}{if} (cs\%id\_dh\_dt>0) \textcolor{keyword}{call }post\_data(cs\%id\_dh\_dt, cs\%dh\_dt, cs\%diag, alt\_h = diag\_pre\_sync\%h\_state)}
\DoxyCodeLine{282 }
\DoxyCodeLine{283     \textcolor{comment}{!! Diagnostics for terms multiplied by fractional thicknesses}}
\DoxyCodeLine{284 }
\DoxyCodeLine{285     \textcolor{comment}{! 3D diagnostics hf\_du(dv)\_dt are commented because there is no clarity on proper remapping grid option.}}
\DoxyCodeLine{286     \textcolor{comment}{! The code is retained for degugging purposes in the future.}}
\DoxyCodeLine{287     \textcolor{comment}{!if (CS\%id\_hf\_du\_dt > 0) then}}
\DoxyCodeLine{288     \textcolor{comment}{!  do k=1,nz ; do j=js,je ; do I=Isq,Ieq}}
\DoxyCodeLine{289     \textcolor{comment}{!    CS\%hf\_du\_dt(I,j,k) = CS\%du\_dt(I,j,k) * ADp\%diag\_hfrac\_u(I,j,k)}}
\DoxyCodeLine{290     \textcolor{comment}{!  enddo ; enddo ; enddo}}
\DoxyCodeLine{291     \textcolor{comment}{!  call post\_data(CS\%id\_hf\_du\_dt, CS\%hf\_du\_dt, CS\%diag, alt\_h = diag\_pre\_sync\%h\_state)}}
\DoxyCodeLine{292     \textcolor{comment}{!endif}}
\DoxyCodeLine{293 }
\DoxyCodeLine{294     \textcolor{comment}{!if (CS\%id\_hf\_dv\_dt > 0) then}}
\DoxyCodeLine{295     \textcolor{comment}{!  do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie}}
\DoxyCodeLine{296     \textcolor{comment}{!    CS\%hf\_dv\_dt(i,J,k) = CS\%dv\_dt(i,J,k) * ADp\%diag\_hfrac\_v(i,J,k)}}
\DoxyCodeLine{297     \textcolor{comment}{!  enddo ; enddo ; enddo}}
\DoxyCodeLine{298     \textcolor{comment}{!  call post\_data(CS\%id\_hf\_dv\_dt, CS\%hf\_dv\_dt, CS\%diag, alt\_h = diag\_pre\_sync\%h\_state)}}
\DoxyCodeLine{299     \textcolor{comment}{!endif}}
\DoxyCodeLine{300 }
\DoxyCodeLine{301     \textcolor{keywordflow}{if} (cs\%id\_hf\_du\_dt\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{302       \textcolor{keyword}{allocate}(hf\_du\_dt\_2d(g\%IsdB:g\%IedB,g\%jsd:g\%jed))}
\DoxyCodeLine{303       hf\_du\_dt\_2d(:,:) = 0.0}
\DoxyCodeLine{304       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{305         hf\_du\_dt\_2d(i,j) = hf\_du\_dt\_2d(i,j) + cs\%du\_dt(i,j,k) * adp\%diag\_hfrac\_u(i,j,k)}
\DoxyCodeLine{306 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{307       \textcolor{keyword}{call }post\_data(cs\%id\_hf\_du\_dt\_2d, hf\_du\_dt\_2d, cs\%diag)}
\DoxyCodeLine{308       \textcolor{keyword}{deallocate}(hf\_du\_dt\_2d)}
\DoxyCodeLine{309 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{310 }
\DoxyCodeLine{311     \textcolor{keywordflow}{if} (cs\%id\_hf\_dv\_dt\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{312       \textcolor{keyword}{allocate}(hf\_dv\_dt\_2d(g\%isd:g\%ied,g\%JsdB:g\%JedB))}
\DoxyCodeLine{313       hf\_dv\_dt\_2d(:,:) = 0.0}
\DoxyCodeLine{314       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{315         hf\_dv\_dt\_2d(i,j) = hf\_dv\_dt\_2d(i,j) + cs\%dv\_dt(i,j,k) * adp\%diag\_hfrac\_v(i,j,k)}
\DoxyCodeLine{316 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{317       \textcolor{keyword}{call }post\_data(cs\%id\_hf\_dv\_dt\_2d, hf\_dv\_dt\_2d, cs\%diag)}
\DoxyCodeLine{318       \textcolor{keyword}{deallocate}(hf\_dv\_dt\_2d)}
\DoxyCodeLine{319 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{320 }
\DoxyCodeLine{321     \textcolor{keyword}{call }diag\_restore\_grids(cs\%diag)}
\DoxyCodeLine{322 }
\DoxyCodeLine{323     \textcolor{keyword}{call }calculate\_energy\_diagnostics(u, v, h, uh, vh, adp, cdp, g, gv, us, cs)}
\DoxyCodeLine{324 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{325 }
\DoxyCodeLine{326   \textcolor{comment}{! smg: is the following robust to ALE? It seems a bit opaque.}}
\DoxyCodeLine{327   \textcolor{comment}{! If the model is NOT in isopycnal mode then nkmb=0. But we need all the}}
\DoxyCodeLine{328   \textcolor{comment}{! following diagnostics to treat all layers as variable density, so we set}}
\DoxyCodeLine{329   \textcolor{comment}{! nkmb = nz, on the expectation that loops nkmb+1,nz will not iterate.}}
\DoxyCodeLine{330   \textcolor{comment}{! This behavior is ANSI F77 but some compiler options can force at least}}
\DoxyCodeLine{331   \textcolor{comment}{! one iteration that would break the following one-\/line workaround!}}
\DoxyCodeLine{332   \textcolor{keywordflow}{if} (nkmb==0 .and. nz > 1) nkmb = nz}
\DoxyCodeLine{333 }
\DoxyCodeLine{334   \textcolor{keywordflow}{if} (cs\%id\_u > 0) \textcolor{keyword}{call }post\_data(cs\%id\_u, u, cs\%diag)}
\DoxyCodeLine{335 }
\DoxyCodeLine{336   \textcolor{keywordflow}{if} (cs\%id\_v > 0) \textcolor{keyword}{call }post\_data(cs\%id\_v, v, cs\%diag)}
\DoxyCodeLine{337 }
\DoxyCodeLine{338   \textcolor{keywordflow}{if} (cs\%id\_h > 0) \textcolor{keyword}{call }post\_data(cs\%id\_h, h, cs\%diag)}
\DoxyCodeLine{339 }
\DoxyCodeLine{340   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%e)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{341     \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, cs\%e, eta\_bt)}
\DoxyCodeLine{342     \textcolor{keywordflow}{if} (cs\%id\_e > 0) \textcolor{keyword}{call }post\_data(cs\%id\_e, cs\%e, cs\%diag)}
\DoxyCodeLine{343 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{344 }
\DoxyCodeLine{345   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%e\_D)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{346     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%e)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{347       \textcolor{keywordflow}{do} k=1,nz+1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{348         cs\%e\_D(i,j,k) = cs\%e(i,j,k) + g\%bathyT(i,j)}
\DoxyCodeLine{349 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{350     \textcolor{keywordflow}{else}}
\DoxyCodeLine{351       \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, cs\%e\_D, eta\_bt)}
\DoxyCodeLine{352       \textcolor{keywordflow}{do} k=1,nz+1 ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{353         cs\%e\_D(i,j,k) = cs\%e\_D(i,j,k) + g\%bathyT(i,j)}
\DoxyCodeLine{354 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{355 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{356 }
\DoxyCodeLine{357     \textcolor{keywordflow}{if} (cs\%id\_e\_D > 0) \textcolor{keyword}{call }post\_data(cs\%id\_e\_D, cs\%e\_D, cs\%diag)}
\DoxyCodeLine{358 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{359 }
\DoxyCodeLine{360   \textcolor{comment}{! mass per area of grid cell (for Bouss, use Rho0)}}
\DoxyCodeLine{361   \textcolor{keywordflow}{if} (cs\%id\_masscello > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{362     \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{363       work\_3d(i,j,k) = gv\%H\_to\_kg\_m2*h(i,j,k)}
\DoxyCodeLine{364 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{365     \textcolor{keyword}{call }post\_data(cs\%id\_masscello, work\_3d, cs\%diag)}
\DoxyCodeLine{366 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{367 }
\DoxyCodeLine{368   \textcolor{comment}{! mass of liquid ocean (for Bouss, use Rho0). The reproducing sum requires the use of MKS units.}}
\DoxyCodeLine{369   \textcolor{keywordflow}{if} (cs\%id\_masso > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{370     work\_2d(:,:) = 0.0}
\DoxyCodeLine{371     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{372       work\_2d(i,j) = work\_2d(i,j) + (gv\%H\_to\_kg\_m2*h(i,j,k)) * us\%L\_to\_m**2*g\%areaT(i,j)}
\DoxyCodeLine{373 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{374     masso = reproducing\_sum(work\_2d)}
\DoxyCodeLine{375     \textcolor{keyword}{call }post\_data(cs\%id\_masso, masso, cs\%diag)}
\DoxyCodeLine{376 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{377 }
\DoxyCodeLine{378   \textcolor{comment}{! diagnose thickness/volumes of grid cells [m]}}
\DoxyCodeLine{379   \textcolor{keywordflow}{if} (cs\%id\_thkcello>0 .or. cs\%id\_volcello>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{380     \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then} \textcolor{comment}{! thkcello = h for Boussinesq}}
\DoxyCodeLine{381       \textcolor{keywordflow}{if} (cs\%id\_thkcello > 0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (gv\%H\_to\_Z == 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{382         \textcolor{keyword}{call }post\_data(cs\%id\_thkcello, h, cs\%diag)}
\DoxyCodeLine{383       \textcolor{keywordflow}{else}}
\DoxyCodeLine{384         \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{385           work\_3d(i,j,k) = gv\%H\_to\_Z*h(i,j,k)}
\DoxyCodeLine{386 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{387         \textcolor{keyword}{call }post\_data(cs\%id\_thkcello, work\_3d, cs\%diag)}
\DoxyCodeLine{388 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{389       \textcolor{keywordflow}{if} (cs\%id\_volcello > 0) \textcolor{keywordflow}{then} \textcolor{comment}{! volcello = h*area for Boussinesq}}
\DoxyCodeLine{390         \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{391           work\_3d(i,j,k) = ( gv\%H\_to\_Z*h(i,j,k) ) * us\%Z\_to\_m*us\%L\_to\_m**2*g\%areaT(i,j)}
\DoxyCodeLine{392 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{393         \textcolor{keyword}{call }post\_data(cs\%id\_volcello, work\_3d, cs\%diag)}
\DoxyCodeLine{394 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{395     \textcolor{keywordflow}{else} \textcolor{comment}{! thkcello = dp/(rho*g) for non-\/Boussinesq}}
\DoxyCodeLine{396       eosdom(:) = eos\_domain(g\%HI)}
\DoxyCodeLine{397       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{398         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(p\_surf)) \textcolor{keywordflow}{then} \textcolor{comment}{! Pressure loading at top of surface layer [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{399           \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{400             pressure\_1d(i) = p\_surf(i,j)}
\DoxyCodeLine{401 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{402         \textcolor{keywordflow}{else}}
\DoxyCodeLine{403           \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{404             pressure\_1d(i) = 0.0}
\DoxyCodeLine{405 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{406 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{407         \textcolor{keywordflow}{do} k=1,nz \textcolor{comment}{! Integrate vertically downward for pressure}}
\DoxyCodeLine{408           \textcolor{keywordflow}{do} i=is,ie \textcolor{comment}{! Pressure for EOS at the layer center [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{409             pressure\_1d(i) = pressure\_1d(i) + 0.5*(gv\%H\_to\_RZ*gv\%g\_Earth)*h(i,j,k)}
\DoxyCodeLine{410 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{411           \textcolor{comment}{! Store in-\/situ density [R \string~> kg m-\/3] in work\_3d}}
\DoxyCodeLine{412           \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,k), tv\%S(:,j,k), pressure\_1d, rho\_in\_situ, \&}
\DoxyCodeLine{413                                  tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{414           \textcolor{keywordflow}{do} i=is,ie \textcolor{comment}{! Cell thickness = dz = dp/(g*rho) (meter); store in work\_3d}}
\DoxyCodeLine{415             work\_3d(i,j,k) = (gv\%H\_to\_RZ*h(i,j,k)) / rho\_in\_situ(i)}
\DoxyCodeLine{416 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{417           \textcolor{keywordflow}{do} i=is,ie \textcolor{comment}{! Pressure for EOS at the bottom interface [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{418             pressure\_1d(i) = pressure\_1d(i) + 0.5*(gv\%H\_to\_RZ*gv\%g\_Earth)*h(i,j,k)}
\DoxyCodeLine{419 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{420 \textcolor{keywordflow}{        enddo} \textcolor{comment}{! k}}
\DoxyCodeLine{421 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! j}}
\DoxyCodeLine{422       \textcolor{keywordflow}{if} (cs\%id\_thkcello > 0) \textcolor{keyword}{call }post\_data(cs\%id\_thkcello, work\_3d, cs\%diag)}
\DoxyCodeLine{423       \textcolor{keywordflow}{if} (cs\%id\_volcello > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{424         \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie \textcolor{comment}{! volcello = dp/(rho*g)*area for non-\/Boussinesq}}
\DoxyCodeLine{425           work\_3d(i,j,k) = us\%Z\_to\_m*us\%L\_to\_m**2*g\%areaT(i,j) * work\_3d(i,j,k)}
\DoxyCodeLine{426 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{427         \textcolor{keyword}{call }post\_data(cs\%id\_volcello, work\_3d, cs\%diag)}
\DoxyCodeLine{428 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{429 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{430 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{431 }
\DoxyCodeLine{432   \textcolor{comment}{! Calculate additional, potentially derived temperature diagnostics}}
\DoxyCodeLine{433   \textcolor{keywordflow}{if} (tv\%T\_is\_conT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{434     \textcolor{comment}{! Internal T\&S variables are conservative temperature \& absolute salinity,}}
\DoxyCodeLine{435     \textcolor{comment}{! so they need to converted to potential temperature and practical salinity}}
\DoxyCodeLine{436     \textcolor{comment}{! for some diagnostics using TEOS-\/10 function calls.}}
\DoxyCodeLine{437     \textcolor{keywordflow}{if} ((cs\%id\_Tpot > 0) .or. (cs\%id\_tob > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{438       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{439         work\_3d(i,j,k) = gsw\_pt\_from\_ct(tv\%S(i,j,k),tv\%T(i,j,k))}
\DoxyCodeLine{440 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{441       \textcolor{keywordflow}{if} (cs\%id\_Tpot > 0) \textcolor{keyword}{call }post\_data(cs\%id\_Tpot, work\_3d, cs\%diag)}
\DoxyCodeLine{442       \textcolor{keywordflow}{if} (cs\%id\_tob > 0) \textcolor{keyword}{call }post\_data(cs\%id\_tob, work\_3d(:,:,nz), cs\%diag, mask=g\%mask2dT)}
\DoxyCodeLine{443 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{444   \textcolor{keywordflow}{else}}
\DoxyCodeLine{445     \textcolor{comment}{! Internal T\&S variables are potential temperature \& practical salinity}}
\DoxyCodeLine{446     \textcolor{keywordflow}{if} (cs\%id\_tob > 0) \textcolor{keyword}{call }post\_data(cs\%id\_tob, tv\%T(:,:,nz), cs\%diag, mask=g\%mask2dT)}
\DoxyCodeLine{447 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{448 }
\DoxyCodeLine{449   \textcolor{comment}{! Calculate additional, potentially derived salinity diagnostics}}
\DoxyCodeLine{450   \textcolor{keywordflow}{if} (tv\%S\_is\_absS) \textcolor{keywordflow}{then}}
\DoxyCodeLine{451     \textcolor{comment}{! Internal T\&S variables are conservative temperature \& absolute salinity,}}
\DoxyCodeLine{452     \textcolor{comment}{! so they need to converted to potential temperature and practical salinity}}
\DoxyCodeLine{453     \textcolor{comment}{! for some diagnostics using TEOS-\/10 function calls.}}
\DoxyCodeLine{454     \textcolor{keywordflow}{if} ((cs\%id\_Sprac > 0) .or. (cs\%id\_sob > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{455       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{456         work\_3d(i,j,k) = gsw\_sp\_from\_sr(tv\%S(i,j,k))}
\DoxyCodeLine{457 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{458       \textcolor{keywordflow}{if} (cs\%id\_Sprac > 0) \textcolor{keyword}{call }post\_data(cs\%id\_Sprac, work\_3d, cs\%diag)}
\DoxyCodeLine{459       \textcolor{keywordflow}{if} (cs\%id\_sob > 0) \textcolor{keyword}{call }post\_data(cs\%id\_sob, work\_3d(:,:,nz), cs\%diag, mask=g\%mask2dT)}
\DoxyCodeLine{460 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{461   \textcolor{keywordflow}{else}}
\DoxyCodeLine{462     \textcolor{comment}{! Internal T\&S variables are potential temperature \& practical salinity}}
\DoxyCodeLine{463     \textcolor{keywordflow}{if} (cs\%id\_sob > 0) \textcolor{keyword}{call }post\_data(cs\%id\_sob, tv\%S(:,:,nz), cs\%diag, mask=g\%mask2dT)}
\DoxyCodeLine{464 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{465 }
\DoxyCodeLine{466   \textcolor{comment}{! volume mean potential temperature}}
\DoxyCodeLine{467   \textcolor{keywordflow}{if} (cs\%id\_thetaoga>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{468     thetaoga = global\_volume\_mean(tv\%T, h, g, gv)}
\DoxyCodeLine{469     \textcolor{keyword}{call }post\_data(cs\%id\_thetaoga, thetaoga, cs\%diag)}
\DoxyCodeLine{470 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{471 }
\DoxyCodeLine{472   \textcolor{comment}{! area mean SST}}
\DoxyCodeLine{473   \textcolor{keywordflow}{if} (cs\%id\_tosga > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{474     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{475        surface\_field(i,j) = tv\%T(i,j,1)}
\DoxyCodeLine{476 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{477     tosga = global\_area\_mean(surface\_field, g)}
\DoxyCodeLine{478     \textcolor{keyword}{call }post\_data(cs\%id\_tosga, tosga, cs\%diag)}
\DoxyCodeLine{479 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{480 }
\DoxyCodeLine{481   \textcolor{comment}{! volume mean salinity}}
\DoxyCodeLine{482   \textcolor{keywordflow}{if} (cs\%id\_soga>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{483     soga = global\_volume\_mean(tv\%S, h, g, gv)}
\DoxyCodeLine{484     \textcolor{keyword}{call }post\_data(cs\%id\_soga, soga, cs\%diag)}
\DoxyCodeLine{485 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{486 }
\DoxyCodeLine{487   \textcolor{comment}{! area mean SSS}}
\DoxyCodeLine{488   \textcolor{keywordflow}{if} (cs\%id\_sosga > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{489     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{490        surface\_field(i,j) = tv\%S(i,j,1)}
\DoxyCodeLine{491 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{492     sosga = global\_area\_mean(surface\_field, g)}
\DoxyCodeLine{493     \textcolor{keyword}{call }post\_data(cs\%id\_sosga, sosga, cs\%diag)}
\DoxyCodeLine{494 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{495 }
\DoxyCodeLine{496   \textcolor{comment}{! layer mean potential temperature}}
\DoxyCodeLine{497   \textcolor{keywordflow}{if} (cs\%id\_temp\_layer\_ave>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{498     temp\_layer\_ave = global\_layer\_mean(tv\%T, h, g, gv)}
\DoxyCodeLine{499     \textcolor{keyword}{call }post\_data(cs\%id\_temp\_layer\_ave, temp\_layer\_ave, cs\%diag)}
\DoxyCodeLine{500 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{501 }
\DoxyCodeLine{502   \textcolor{comment}{! layer mean salinity}}
\DoxyCodeLine{503   \textcolor{keywordflow}{if} (cs\%id\_salt\_layer\_ave>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{504     salt\_layer\_ave = global\_layer\_mean(tv\%S, h, g, gv)}
\DoxyCodeLine{505     \textcolor{keyword}{call }post\_data(cs\%id\_salt\_layer\_ave, salt\_layer\_ave, cs\%diag)}
\DoxyCodeLine{506 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{507 }
\DoxyCodeLine{508   \textcolor{keyword}{call }calculate\_vertical\_integrals(h, tv, p\_surf, g, gv, us, cs)}
\DoxyCodeLine{509 }
\DoxyCodeLine{510   \textcolor{keywordflow}{if} ((cs\%id\_Rml > 0) .or. (cs\%id\_Rcv > 0) .or. \textcolor{keyword}{associated}(cs\%h\_Rlay) .or. \&}
\DoxyCodeLine{511       \textcolor{keyword}{associated}(cs\%uh\_Rlay) .or. \textcolor{keyword}{associated}(cs\%vh\_Rlay) .or. \&}
\DoxyCodeLine{512       \textcolor{keyword}{associated}(cs\%uhGM\_Rlay) .or. \textcolor{keyword}{associated}(cs\%vhGM\_Rlay)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{513 }
\DoxyCodeLine{514     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{515       eosdom(:) = eos\_domain(g\%HI, halo=1)}
\DoxyCodeLine{516       pressure\_1d(:) = tv\%P\_Ref}
\DoxyCodeLine{517       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{518       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-\/1,je+1}
\DoxyCodeLine{519         \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,k), tv\%S(:,j,k), pressure\_1d, rcv(:,j,k), tv\%eqn\_of\_state, \&}
\DoxyCodeLine{520                                eosdom)}
\DoxyCodeLine{521 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{522     \textcolor{keywordflow}{else} \textcolor{comment}{! Rcv should not be used much in this case, so fill in sensible values.}}
\DoxyCodeLine{523       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-\/1,je+1 ; \textcolor{keywordflow}{do} i=is-\/1,ie+1}
\DoxyCodeLine{524         rcv(i,j,k) = gv\%Rlay(k)}
\DoxyCodeLine{525 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{526 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{527     \textcolor{keywordflow}{if} (cs\%id\_Rml > 0) \textcolor{keyword}{call }post\_data(cs\%id\_Rml, rcv, cs\%diag)}
\DoxyCodeLine{528     \textcolor{keywordflow}{if} (cs\%id\_Rcv > 0) \textcolor{keyword}{call }post\_data(cs\%id\_Rcv, rcv, cs\%diag)}
\DoxyCodeLine{529 }
\DoxyCodeLine{530     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%h\_Rlay)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{531       k\_list = nz/2}
\DoxyCodeLine{532 \textcolor{comment}{!\$OMP parallel do default(none) shared(is,ie,js,je,nz,nkmb,CS,Rcv,h,GV) \&}}
\DoxyCodeLine{533 \textcolor{comment}{!\$OMP                          private(wt,wt\_p) firstprivate(k\_list)}}
\DoxyCodeLine{534       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{535         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{536           cs\%h\_Rlay(i,j,k) = 0.0}
\DoxyCodeLine{537 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{538         \textcolor{keywordflow}{do} k=nkmb+1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{539           cs\%h\_Rlay(i,j,k) = h(i,j,k)}
\DoxyCodeLine{540 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{541         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{542           \textcolor{keyword}{call }find\_weights(gv\%Rlay, rcv(i,j,k), k\_list, nz, wt, wt\_p)}
\DoxyCodeLine{543           cs\%h\_Rlay(i,j,k\_list)   = cs\%h\_Rlay(i,j,k\_list)   + h(i,j,k)*wt}
\DoxyCodeLine{544           cs\%h\_Rlay(i,j,k\_list+1) = cs\%h\_Rlay(i,j,k\_list+1) + h(i,j,k)*wt\_p}
\DoxyCodeLine{545 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{546 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{547 }
\DoxyCodeLine{548       \textcolor{keywordflow}{if} (cs\%id\_h\_Rlay > 0) \textcolor{keyword}{call }post\_data(cs\%id\_h\_Rlay, cs\%h\_Rlay, cs\%diag)}
\DoxyCodeLine{549 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{550 }
\DoxyCodeLine{551     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%uh\_Rlay)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{552       k\_list = nz/2}
\DoxyCodeLine{553 \textcolor{comment}{!\$OMP parallel do default(none) shared(Isq,Ieq,js,je,nz,nkmb,Rcv,CS,GV,uh) \&}}
\DoxyCodeLine{554 \textcolor{comment}{!\$OMP                          private(wt,wt\_p) firstprivate(k\_list)}}
\DoxyCodeLine{555       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{556         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{557           cs\%uh\_Rlay(i,j,k) = 0.0}
\DoxyCodeLine{558 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{559         \textcolor{keywordflow}{do} k=nkmb+1,nz ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{560           cs\%uh\_Rlay(i,j,k) = uh(i,j,k)}
\DoxyCodeLine{561 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{562         k\_list = nz/2}
\DoxyCodeLine{563         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{564           \textcolor{keyword}{call }find\_weights(gv\%Rlay, 0.5*(rcv(i,j,k)+rcv(i+1,j,k)), k\_list, nz, wt, wt\_p)}
\DoxyCodeLine{565           cs\%uh\_Rlay(i,j,k\_list)   = cs\%uh\_Rlay(i,j,k\_list)   + uh(i,j,k)*wt}
\DoxyCodeLine{566           cs\%uh\_Rlay(i,j,k\_list+1) = cs\%uh\_Rlay(i,j,k\_list+1) + uh(i,j,k)*wt\_p}
\DoxyCodeLine{567 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{568 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{569 }
\DoxyCodeLine{570       \textcolor{keywordflow}{if} (cs\%id\_uh\_Rlay > 0) \textcolor{keyword}{call }post\_data(cs\%id\_uh\_Rlay, cs\%uh\_Rlay, cs\%diag)}
\DoxyCodeLine{571 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{572 }
\DoxyCodeLine{573     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%vh\_Rlay)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{574       k\_list = nz/2}
\DoxyCodeLine{575 \textcolor{comment}{!\$OMP parallel do default(none)  shared(Jsq,Jeq,is,ie,nz,nkmb,Rcv,CS,GV,vh) \&}}
\DoxyCodeLine{576 \textcolor{comment}{!\$OMP                          private(wt,wt\_p) firstprivate(k\_list)}}
\DoxyCodeLine{577       \textcolor{keywordflow}{do} j=jsq,jeq}
\DoxyCodeLine{578         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{579           cs\%vh\_Rlay(i,j,k) = 0.0}
\DoxyCodeLine{580 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{581         \textcolor{keywordflow}{do} k=nkmb+1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{582           cs\%vh\_Rlay(i,j,k) = vh(i,j,k)}
\DoxyCodeLine{583 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{584         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{585           \textcolor{keyword}{call }find\_weights(gv\%Rlay, 0.5*(rcv(i,j,k)+rcv(i,j+1,k)), k\_list, nz, wt, wt\_p)}
\DoxyCodeLine{586           cs\%vh\_Rlay(i,j,k\_list)   = cs\%vh\_Rlay(i,j,k\_list)   + vh(i,j,k)*wt}
\DoxyCodeLine{587           cs\%vh\_Rlay(i,j,k\_list+1) = cs\%vh\_Rlay(i,j,k\_list+1) + vh(i,j,k)*wt\_p}
\DoxyCodeLine{588 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{589 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{590 }
\DoxyCodeLine{591       \textcolor{keywordflow}{if} (cs\%id\_vh\_Rlay > 0) \textcolor{keyword}{call }post\_data(cs\%id\_vh\_Rlay, cs\%vh\_Rlay, cs\%diag)}
\DoxyCodeLine{592 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{593 }
\DoxyCodeLine{594     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%uhGM\_Rlay) .and. \textcolor{keyword}{associated}(cdp\%uhGM)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{595       k\_list = nz/2}
\DoxyCodeLine{596 \textcolor{comment}{!\$OMP parallel do default(none) shared(Isq,Ieq,js,je,nz,nkmb,Rcv,CDP,CS,GV) \&}}
\DoxyCodeLine{597 \textcolor{comment}{!\$OMP                          private(wt,wt\_p) firstprivate(k\_list)}}
\DoxyCodeLine{598       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{599         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{600           cs\%uhGM\_Rlay(i,j,k) = 0.0}
\DoxyCodeLine{601 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{602         \textcolor{keywordflow}{do} k=nkmb+1,nz ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{603           cs\%uhGM\_Rlay(i,j,k) = cdp\%uhGM(i,j,k)}
\DoxyCodeLine{604 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{605         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{606           \textcolor{keyword}{call }find\_weights(gv\%Rlay, 0.5*(rcv(i,j,k)+rcv(i+1,j,k)), k\_list, nz, wt, wt\_p)}
\DoxyCodeLine{607           cs\%uhGM\_Rlay(i,j,k\_list)   = cs\%uhGM\_Rlay(i,j,k\_list)   + cdp\%uhGM(i,j,k)*wt}
\DoxyCodeLine{608           cs\%uhGM\_Rlay(i,j,k\_list+1) = cs\%uhGM\_Rlay(i,j,k\_list+1) + cdp\%uhGM(i,j,k)*wt\_p}
\DoxyCodeLine{609 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{610 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{611 }
\DoxyCodeLine{612       \textcolor{keywordflow}{if} (cs\%id\_uhGM\_Rlay > 0) \textcolor{keyword}{call }post\_data(cs\%id\_uhGM\_Rlay, cs\%uhGM\_Rlay, cs\%diag)}
\DoxyCodeLine{613 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{614 }
\DoxyCodeLine{615     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%vhGM\_Rlay) .and. \textcolor{keyword}{associated}(cdp\%vhGM)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{616       k\_list = nz/2}
\DoxyCodeLine{617 \textcolor{comment}{!\$OMP parallel do default(none) shared(is,ie,Jsq,Jeq,nz,nkmb,CS,CDp,Rcv,GV) \&}}
\DoxyCodeLine{618 \textcolor{comment}{!\$OMP                          private(wt,wt\_p) firstprivate(k\_list)}}
\DoxyCodeLine{619       \textcolor{keywordflow}{do} j=jsq,jeq}
\DoxyCodeLine{620         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{621           cs\%vhGM\_Rlay(i,j,k) = 0.0}
\DoxyCodeLine{622 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{623         \textcolor{keywordflow}{do} k=nkmb+1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{624           cs\%vhGM\_Rlay(i,j,k) = cdp\%vhGM(i,j,k)}
\DoxyCodeLine{625 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{626         \textcolor{keywordflow}{do} k=1,nkmb ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{627           \textcolor{keyword}{call }find\_weights(gv\%Rlay, 0.5*(rcv(i,j,k)+rcv(i,j+1,k)), k\_list, nz, wt, wt\_p)}
\DoxyCodeLine{628           cs\%vhGM\_Rlay(i,j,k\_list)   = cs\%vhGM\_Rlay(i,j,k\_list)   + cdp\%vhGM(i,j,k)*wt}
\DoxyCodeLine{629           cs\%vhGM\_Rlay(i,j,k\_list+1) = cs\%vhGM\_Rlay(i,j,k\_list+1) + cdp\%vhGM(i,j,k)*wt\_p}
\DoxyCodeLine{630 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{631 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{632 }
\DoxyCodeLine{633       \textcolor{keywordflow}{if} (cs\%id\_vhGM\_Rlay > 0) \textcolor{keyword}{call }post\_data(cs\%id\_vhGM\_Rlay, cs\%vhGM\_Rlay, cs\%diag)}
\DoxyCodeLine{634 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{635 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{636 }
\DoxyCodeLine{637   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{638     eosdom(:) = eos\_domain(g\%HI)}
\DoxyCodeLine{639     \textcolor{keywordflow}{if} (cs\%id\_rhopot0 > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{640       pressure\_1d(:) = 0.}
\DoxyCodeLine{641       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{642       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{643         \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,k), tv\%S(:,j,k), pressure\_1d, rcv(:,j,k), \&}
\DoxyCodeLine{644                                 tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{645 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{646       \textcolor{keywordflow}{if} (cs\%id\_rhopot0 > 0) \textcolor{keyword}{call }post\_data(cs\%id\_rhopot0, rcv, cs\%diag)}
\DoxyCodeLine{647 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{648     \textcolor{keywordflow}{if} (cs\%id\_rhopot2 > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{649       pressure\_1d(:) = 2.0e7*us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2 \textcolor{comment}{! 2000 dbars}}
\DoxyCodeLine{650       \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{651       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{652         \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,k), tv\%S(:,j,k), pressure\_1d, rcv(:,j,k), \&}
\DoxyCodeLine{653                                 tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{654 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{655       \textcolor{keywordflow}{if} (cs\%id\_rhopot2 > 0) \textcolor{keyword}{call }post\_data(cs\%id\_rhopot2, rcv, cs\%diag)}
\DoxyCodeLine{656 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{657     \textcolor{keywordflow}{if} (cs\%id\_rhoinsitu > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{658       \textcolor{comment}{!\$OMP parallel do default(shared) private(pressure\_1d)}}
\DoxyCodeLine{659       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{660         pressure\_1d(:) = 0. \textcolor{comment}{! Start at p=0 Pa at surface}}
\DoxyCodeLine{661         \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{662           pressure\_1d(:) =  pressure\_1d(:) + 0.5 * h(:,j,k) * (gv\%H\_to\_RZ*gv\%g\_Earth) \textcolor{comment}{! Pressure in middle of layer k}}
\DoxyCodeLine{663           \textcolor{keyword}{call }calculate\_density(tv\%T(:,j,k), tv\%S(:,j,k), pressure\_1d, rcv(:,j,k), \&}
\DoxyCodeLine{664                                 tv\%eqn\_of\_state, eosdom)}
\DoxyCodeLine{665           pressure\_1d(:) =  pressure\_1d(:) + 0.5 * h(:,j,k) * (gv\%H\_to\_RZ*gv\%g\_Earth) \textcolor{comment}{! Pressure at bottom of layer k}}
\DoxyCodeLine{666 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{667 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{668       \textcolor{keywordflow}{if} (cs\%id\_rhoinsitu > 0) \textcolor{keyword}{call }post\_data(cs\%id\_rhoinsitu, rcv, cs\%diag)}
\DoxyCodeLine{669 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{670 }
\DoxyCodeLine{671     \textcolor{keywordflow}{if} (cs\%id\_drho\_dT > 0 .or. cs\%id\_drho\_dS > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{672       \textcolor{comment}{!\$OMP parallel do default(shared) private(pressure\_1d)}}
\DoxyCodeLine{673       \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{674         pressure\_1d(:) = 0. \textcolor{comment}{! Start at p=0 Pa at surface}}
\DoxyCodeLine{675         \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{676           pressure\_1d(:) =  pressure\_1d(:) + 0.5 * h(:,j,k) * gv\%H\_to\_Pa \textcolor{comment}{! Pressure in middle of layer k}}
\DoxyCodeLine{677           \textcolor{comment}{! To avoid storing more arrays, put drho\_dT into Rcv, and drho\_dS into work3d}}
\DoxyCodeLine{678           \textcolor{keyword}{call }calculate\_density\_derivs(tv\%T(:,j,k),tv\%S(:,j,k),pressure\_1d, \&}
\DoxyCodeLine{679                                  rcv(:,j,k),work\_3d(:,j,k),is,ie-\/is+1, tv\%eqn\_of\_state)}
\DoxyCodeLine{680           pressure\_1d(:) =  pressure\_1d(:) + 0.5 * h(:,j,k) * gv\%H\_to\_Pa \textcolor{comment}{! Pressure at bottom of layer k}}
\DoxyCodeLine{681 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{682 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{683       \textcolor{keywordflow}{if} (cs\%id\_drho\_dT > 0) \textcolor{keyword}{call }post\_data(cs\%id\_drho\_dT, rcv, cs\%diag)}
\DoxyCodeLine{684       \textcolor{keywordflow}{if} (cs\%id\_drho\_dS > 0) \textcolor{keyword}{call }post\_data(cs\%id\_drho\_dS, work\_3d, cs\%diag)}
\DoxyCodeLine{685 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{686 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{687 }
\DoxyCodeLine{688   \textcolor{keywordflow}{if} ((cs\%id\_cg1>0) .or. (cs\%id\_Rd1>0) .or. (cs\%id\_cfl\_cg1>0) .or. \&}
\DoxyCodeLine{689       (cs\%id\_cfl\_cg1\_x>0) .or. (cs\%id\_cfl\_cg1\_y>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{690     \textcolor{keyword}{call }wave\_speed(h, tv, g, gv, us, cs\%cg1, cs\%wave\_speed\_CSp)}
\DoxyCodeLine{691     \textcolor{keywordflow}{if} (cs\%id\_cg1>0) \textcolor{keyword}{call }post\_data(cs\%id\_cg1, cs\%cg1, cs\%diag)}
\DoxyCodeLine{692     \textcolor{keywordflow}{if} (cs\%id\_Rd1>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{693       \textcolor{comment}{!\$OMP parallel do default(shared) private(f2\_h,mag\_beta)}}
\DoxyCodeLine{694       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{695         \textcolor{comment}{! Blend the equatorial deformation radius with the standard one.}}
\DoxyCodeLine{696         f2\_h = absurdly\_small\_freq2 + 0.25 * \&}
\DoxyCodeLine{697             ((g\%CoriolisBu(i,j)**2 + g\%CoriolisBu(i-\/1,j-\/1)**2) + \&}
\DoxyCodeLine{698              (g\%CoriolisBu(i-\/1,j)**2 + g\%CoriolisBu(i,j-\/1)**2))}
\DoxyCodeLine{699         mag\_beta = sqrt(0.5 * ( \&}
\DoxyCodeLine{700             (((g\%CoriolisBu(i,j)-\/g\%CoriolisBu(i-\/1,j)) * g\%IdxCv(i,j))**2 + \&}
\DoxyCodeLine{701              ((g\%CoriolisBu(i,j-\/1)-\/g\%CoriolisBu(i-\/1,j-\/1)) * g\%IdxCv(i,j-\/1))**2) + \&}
\DoxyCodeLine{702             (((g\%CoriolisBu(i,j)-\/g\%CoriolisBu(i,j-\/1)) * g\%IdyCu(i,j))**2 + \&}
\DoxyCodeLine{703              ((g\%CoriolisBu(i-\/1,j)-\/g\%CoriolisBu(i-\/1,j-\/1)) * g\%IdyCu(i-\/1,j))**2) ))}
\DoxyCodeLine{704         cs\%Rd1(i,j) = cs\%cg1(i,j) / sqrt(f2\_h + cs\%cg1(i,j) * mag\_beta)}
\DoxyCodeLine{705 }
\DoxyCodeLine{706 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{707       \textcolor{keyword}{call }post\_data(cs\%id\_Rd1, cs\%Rd1, cs\%diag)}
\DoxyCodeLine{708 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{709     \textcolor{keywordflow}{if} (cs\%id\_cfl\_cg1>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{710       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{711         cs\%cfl\_cg1(i,j) = (dt*cs\%cg1(i,j)) * (g\%IdxT(i,j) + g\%IdyT(i,j))}
\DoxyCodeLine{712 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{713       \textcolor{keyword}{call }post\_data(cs\%id\_cfl\_cg1, cs\%cfl\_cg1, cs\%diag)}
\DoxyCodeLine{714 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{715     \textcolor{keywordflow}{if} (cs\%id\_cfl\_cg1\_x>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{716       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{717         cs\%cfl\_cg1\_x(i,j) = (dt*cs\%cg1(i,j)) * g\%IdxT(i,j)}
\DoxyCodeLine{718 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{719       \textcolor{keyword}{call }post\_data(cs\%id\_cfl\_cg1\_x, cs\%cfl\_cg1\_x, cs\%diag)}
\DoxyCodeLine{720 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{721     \textcolor{keywordflow}{if} (cs\%id\_cfl\_cg1\_y>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{722       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{723         cs\%cfl\_cg1\_y(i,j) = (dt*cs\%cg1(i,j)) * g\%IdyT(i,j)}
\DoxyCodeLine{724 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{725       \textcolor{keyword}{call }post\_data(cs\%id\_cfl\_cg1\_y, cs\%cfl\_cg1\_y, cs\%diag)}
\DoxyCodeLine{726 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{727 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{728   \textcolor{keywordflow}{if} ((cs\%id\_cg\_ebt>0) .or. (cs\%id\_Rd\_ebt>0) .or. (cs\%id\_p\_ebt>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{729     \textcolor{keywordflow}{if} (cs\%id\_p\_ebt>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{730       \textcolor{keyword}{call }wave\_speed(h, tv, g, gv, us, cs\%cg1, cs\%wave\_speed\_CSp, use\_ebt\_mode=.true., \&}
\DoxyCodeLine{731                       mono\_n2\_column\_fraction=cs\%mono\_N2\_column\_fraction, \&}
\DoxyCodeLine{732                       mono\_n2\_depth=cs\%mono\_N2\_depth, modal\_structure=cs\%p\_ebt)}
\DoxyCodeLine{733       \textcolor{keyword}{call }post\_data(cs\%id\_p\_ebt, cs\%p\_ebt, cs\%diag)}
\DoxyCodeLine{734     \textcolor{keywordflow}{else}}
\DoxyCodeLine{735       \textcolor{keyword}{call }wave\_speed(h, tv, g, gv, us, cs\%cg1, cs\%wave\_speed\_CSp, use\_ebt\_mode=.true., \&}
\DoxyCodeLine{736                       mono\_n2\_column\_fraction=cs\%mono\_N2\_column\_fraction, \&}
\DoxyCodeLine{737                       mono\_n2\_depth=cs\%mono\_N2\_depth)}
\DoxyCodeLine{738 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{739     \textcolor{keywordflow}{if} (cs\%id\_cg\_ebt>0) \textcolor{keyword}{call }post\_data(cs\%id\_cg\_ebt, cs\%cg1, cs\%diag)}
\DoxyCodeLine{740     \textcolor{keywordflow}{if} (cs\%id\_Rd\_ebt>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{741       \textcolor{comment}{!\$OMP parallel do default(shared) private(f2\_h,mag\_beta)}}
\DoxyCodeLine{742       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{743         \textcolor{comment}{! Blend the equatorial deformation radius with the standard one.}}
\DoxyCodeLine{744         f2\_h = absurdly\_small\_freq2 + 0.25 * \&}
\DoxyCodeLine{745             ((g\%CoriolisBu(i,j)**2 + g\%CoriolisBu(i-\/1,j-\/1)**2) + \&}
\DoxyCodeLine{746              (g\%CoriolisBu(i-\/1,j)**2 + g\%CoriolisBu(i,j-\/1)**2))}
\DoxyCodeLine{747         mag\_beta = sqrt(0.5 * ( \&}
\DoxyCodeLine{748             (((g\%CoriolisBu(i,j)-\/g\%CoriolisBu(i-\/1,j)) * g\%IdxCv(i,j))**2 + \&}
\DoxyCodeLine{749              ((g\%CoriolisBu(i,j-\/1)-\/g\%CoriolisBu(i-\/1,j-\/1)) * g\%IdxCv(i,j-\/1))**2) + \&}
\DoxyCodeLine{750             (((g\%CoriolisBu(i,j)-\/g\%CoriolisBu(i,j-\/1)) * g\%IdyCu(i,j))**2 + \&}
\DoxyCodeLine{751              ((g\%CoriolisBu(i-\/1,j)-\/g\%CoriolisBu(i-\/1,j-\/1)) * g\%IdyCu(i-\/1,j))**2) ))}
\DoxyCodeLine{752         cs\%Rd1(i,j) = cs\%cg1(i,j) / sqrt(f2\_h + cs\%cg1(i,j) * mag\_beta)}
\DoxyCodeLine{753 }
\DoxyCodeLine{754 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{755       \textcolor{keyword}{call }post\_data(cs\%id\_Rd\_ebt, cs\%Rd1, cs\%diag)}
\DoxyCodeLine{756 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{757 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{758 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_ad8679de99516ebb0ec2a973c441f2fec}\label{namespacemom__diagnostics_ad8679de99516ebb0ec2a973c441f2fec}} 
\index{mom\_diagnostics@{mom\_diagnostics}!calculate\_energy\_diagnostics@{calculate\_energy\_diagnostics}}
\index{calculate\_energy\_diagnostics@{calculate\_energy\_diagnostics}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{calculate\_energy\_diagnostics()}{calculate\_energy\_diagnostics()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diagnostics\+::calculate\+\_\+energy\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in)}]{v,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{uh,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in)}]{vh,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(in)}]{A\+Dp,  }\item[{type(cont\+\_\+diag\+\_\+ptrs), intent(in)}]{C\+Dp,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), intent(inout)}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine calculates terms in the mechanical energy budget. 


\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 u} & The zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em v} & The meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em uh} & Transport through zonal faces=u$\ast$h$\ast$dy, \\
\hline
\mbox{\texttt{ in}}  & {\em vh} & Transport through merid faces=v$\ast$h$\ast$dx, \\
\hline
\mbox{\texttt{ in}}  & {\em adp} & Structure pointing to accelerations in momentum equation. \\
\hline
\mbox{\texttt{ in}}  & {\em cdp} & Structure pointing to terms in continuity equations. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & Control structure returned by a previous call to diagnostics\+\_\+init. \\
\hline
\end{DoxyParams}


Definition at line 949 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{950   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{951   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{952 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{953                            \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{    !< The zonal velocity [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{954 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{955                            \textcolor{keywordtype}{intent(in)}    :: v\textcolor{comment}{    !< The meridional velocity [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{956 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{957                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{958 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{959                            \textcolor{keywordtype}{intent(in)}    :: uh\textcolor{comment}{   !< Transport through zonal faces=u*h*dy,}}
\DoxyCodeLine{960 \textcolor{comment}{                                                 !! [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{961 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{962                            \textcolor{keywordtype}{intent(in)}    :: vh\textcolor{comment}{   !< Transport through merid faces=v*h*dx,}}
\DoxyCodeLine{963 \textcolor{comment}{                                                 !! [H L2 T-\/1 \string~> m3 s-\/1 or kg s-\/1].}}
\DoxyCodeLine{964   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: ADp\textcolor{comment}{  !< Structure pointing to accelerations in momentum equation.}}
\DoxyCodeLine{965   \textcolor{keywordtype}{type}(cont\_diag\_ptrs),    \textcolor{keywordtype}{intent(in)}    :: CDp\textcolor{comment}{  !< Structure pointing to terms in continuity equations.}}
\DoxyCodeLine{966   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{967   \textcolor{keywordtype}{type}(diagnostics\_CS),    \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< Control structure returned by a previous call to}}
\DoxyCodeLine{968 \textcolor{comment}{                                                 !! diagnostics\_init.}}
\DoxyCodeLine{969 }
\DoxyCodeLine{970 \textcolor{comment}{! This subroutine calculates terms in the mechanical energy budget.}}
\DoxyCodeLine{971 }
\DoxyCodeLine{972   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{973 \textcolor{keywordtype}{  real} :: KE\_u(SZIB\_(G),SZJ\_(G))}
\DoxyCodeLine{974 \textcolor{keywordtype}{  real} :: KE\_v(SZI\_(G),SZJB\_(G))}
\DoxyCodeLine{975 \textcolor{keywordtype}{  real} :: KE\_h(SZI\_(G),SZJ\_(G))}
\DoxyCodeLine{976 }
\DoxyCodeLine{977   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz}
\DoxyCodeLine{978   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{979   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{980 }
\DoxyCodeLine{981   \textcolor{keywordflow}{do} j=js-\/1,je ; \textcolor{keywordflow}{do} i=is-\/1,ie}
\DoxyCodeLine{982     ke\_u(i,j) = 0.0 ; ke\_v(i,j) = 0.0}
\DoxyCodeLine{983 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{984 }
\DoxyCodeLine{985   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{986     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{987       cs\%KE(i,j,k) = ((u(i,j,k) * u(i,j,k) + u(i-\/1,j,k) * u(i-\/1,j,k)) \&}
\DoxyCodeLine{988           + (v(i,j,k) * v(i,j,k) + v(i,j-\/1,k) * v(i,j-\/1,k))) * 0.25}
\DoxyCodeLine{989       \textcolor{comment}{! DELETE THE FOLLOWING...  Make this 0 to test the momentum balance,}}
\DoxyCodeLine{990       \textcolor{comment}{! or a huge number to test the continuity balance.}}
\DoxyCodeLine{991       \textcolor{comment}{! CS\%KE(i,j,k) *= 1e20}}
\DoxyCodeLine{992 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{993     \textcolor{keywordflow}{if} (cs\%id\_KE > 0) \textcolor{keyword}{call }post\_data(cs\%id\_KE, cs\%KE, cs\%diag)}
\DoxyCodeLine{994 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{995 }
\DoxyCodeLine{996   \textcolor{keywordflow}{if} (.not.g\%symmetric) \textcolor{keywordflow}{then}}
\DoxyCodeLine{997     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%dKE\_dt) .OR. \textcolor{keyword}{associated}(cs\%PE\_to\_KE) .OR. \textcolor{keyword}{associated}(cs\%KE\_CorAdv) .OR. \&}
\DoxyCodeLine{998        \textcolor{keyword}{associated}(cs\%KE\_adv) .OR. \textcolor{keyword}{associated}(cs\%KE\_visc)  .OR. \textcolor{keyword}{associated}(cs\%KE\_horvisc).OR. \&}
\DoxyCodeLine{999        \textcolor{keyword}{associated}(cs\%KE\_dia) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1000         \textcolor{keyword}{call }create\_group\_pass(cs\%pass\_KE\_uv, ke\_u, ke\_v, g\%Domain, to\_north+to\_east)}
\DoxyCodeLine{1001 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1002 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1003 }
\DoxyCodeLine{1004   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%dKE\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1005     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1006       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1007         ke\_u(i,j) = uh(i,j,k) * g\%dxCu(i,j) * cs\%du\_dt(i,j,k)}
\DoxyCodeLine{1008 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1009       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1010         ke\_v(i,j) = vh(i,j,k) * g\%dyCv(i,j) * cs\%dv\_dt(i,j,k)}
\DoxyCodeLine{1011 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1012       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1013         ke\_h(i,j) = cs\%KE(i,j,k) * cs\%dh\_dt(i,j,k)}
\DoxyCodeLine{1014 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1015       \textcolor{keywordflow}{if} (.not.g\%symmetric) \&}
\DoxyCodeLine{1016          \textcolor{keyword}{call }do\_group\_pass(cs\%pass\_KE\_uv, g\%domain)}
\DoxyCodeLine{1017       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1018         cs\%dKE\_dt(i,j,k) = ke\_h(i,j) + 0.5 * g\%IareaT(i,j) \&}
\DoxyCodeLine{1019             * (ke\_u(i,j) + ke\_u(i-\/1,j) + ke\_v(i,j) + ke\_v(i,j-\/1))}
\DoxyCodeLine{1020 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1021 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1022     \textcolor{keywordflow}{if} (cs\%id\_dKEdt > 0) \textcolor{keyword}{call }post\_data(cs\%id\_dKEdt, cs\%dKE\_dt, cs\%diag)}
\DoxyCodeLine{1023 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1024 }
\DoxyCodeLine{1025   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%PE\_to\_KE)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1026     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1027       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1028         ke\_u(i,j) = uh(i,j,k) * g\%dxCu(i,j) * adp\%PFu(i,j,k)}
\DoxyCodeLine{1029 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1030       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1031         ke\_v(i,j) = vh(i,j,k) * g\%dyCv(i,j) * adp\%PFv(i,j,k)}
\DoxyCodeLine{1032 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1033       \textcolor{keywordflow}{if} (.not.g\%symmetric) \&}
\DoxyCodeLine{1034          \textcolor{keyword}{call }do\_group\_pass(cs\%pass\_KE\_uv, g\%domain)}
\DoxyCodeLine{1035       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1036         cs\%PE\_to\_KE(i,j,k) = 0.5 * g\%IareaT(i,j) \&}
\DoxyCodeLine{1037             * (ke\_u(i,j) + ke\_u(i-\/1,j) + ke\_v(i,j) + ke\_v(i,j-\/1))}
\DoxyCodeLine{1038 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1039 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1040     \textcolor{keywordflow}{if} (cs\%id\_PE\_to\_KE > 0) \textcolor{keyword}{call }post\_data(cs\%id\_PE\_to\_KE, cs\%PE\_to\_KE, cs\%diag)}
\DoxyCodeLine{1041 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1042 }
\DoxyCodeLine{1043   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_CorAdv)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1044     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1045       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1046         ke\_u(i,j) = uh(i,j,k) * g\%dxCu(i,j) * adp\%CAu(i,j,k)}
\DoxyCodeLine{1047 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1048       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1049         ke\_v(i,j) = vh(i,j,k) * g\%dyCv(i,j) * adp\%CAv(i,j,k)}
\DoxyCodeLine{1050 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1051       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1052         ke\_h(i,j) = -\/cs\%KE(i,j,k) * g\%IareaT(i,j) \&}
\DoxyCodeLine{1053             * (uh(i,j,k) -\/ uh(i-\/1,j,k) + vh(i,j,k) -\/ vh(i,j-\/1,k))}
\DoxyCodeLine{1054 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1055       \textcolor{keywordflow}{if} (.not.g\%symmetric) \&}
\DoxyCodeLine{1056          \textcolor{keyword}{call }do\_group\_pass(cs\%pass\_KE\_uv, g\%domain)}
\DoxyCodeLine{1057       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1058         cs\%KE\_CorAdv(i,j,k) = ke\_h(i,j) + 0.5 * g\%IareaT(i,j) \&}
\DoxyCodeLine{1059             * (ke\_u(i,j) + ke\_u(i-\/1,j) + ke\_v(i,j) + ke\_v(i,j-\/1))}
\DoxyCodeLine{1060 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1061 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1062     \textcolor{keywordflow}{if} (cs\%id\_KE\_Coradv > 0) \textcolor{keyword}{call }post\_data(cs\%id\_KE\_Coradv, cs\%KE\_Coradv, cs\%diag)}
\DoxyCodeLine{1063 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1064 }
\DoxyCodeLine{1065   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_adv)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1066     \textcolor{comment}{! NOTE: All terms in KE\_adv are multipled by -\/1, which can easily produce}}
\DoxyCodeLine{1067     \textcolor{comment}{! negative zeros and may signal a reproducibility issue over land.}}
\DoxyCodeLine{1068     \textcolor{comment}{! We resolve this by re-\/initializing and only evaluating over water points.}}
\DoxyCodeLine{1069     ke\_u(:,:) = 0. ; ke\_v(:,:) = 0.}
\DoxyCodeLine{1070     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1071       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1072         \textcolor{keywordflow}{if} (g\%mask2dCu(i,j) /= 0.) \&}
\DoxyCodeLine{1073           ke\_u(i,j) = uh(i,j,k) * g\%dxCu(i,j) * adp\%gradKEu(i,j,k)}
\DoxyCodeLine{1074 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1075       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1076         \textcolor{keywordflow}{if} (g\%mask2dCv(i,j) /= 0.) \&}
\DoxyCodeLine{1077           ke\_v(i,j) = vh(i,j,k) * g\%dyCv(i,j) * adp\%gradKEv(i,j,k)}
\DoxyCodeLine{1078 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1079       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1080         ke\_h(i,j) = -\/cs\%KE(i,j,k) * g\%IareaT(i,j) \&}
\DoxyCodeLine{1081             * (uh(i,j,k) -\/ uh(i-\/1,j,k) + vh(i,j,k) -\/ vh(i,j-\/1,k))}
\DoxyCodeLine{1082 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1083       \textcolor{keywordflow}{if} (.not.g\%symmetric) \&}
\DoxyCodeLine{1084          \textcolor{keyword}{call }do\_group\_pass(cs\%pass\_KE\_uv, g\%domain)}
\DoxyCodeLine{1085       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1086         cs\%KE\_adv(i,j,k) = ke\_h(i,j) + 0.5 * g\%IareaT(i,j) \&}
\DoxyCodeLine{1087             * (ke\_u(i,j) + ke\_u(i-\/1,j) + ke\_v(i,j) + ke\_v(i,j-\/1))}
\DoxyCodeLine{1088 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1089 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1090     \textcolor{keywordflow}{if} (cs\%id\_KE\_adv > 0) \textcolor{keyword}{call }post\_data(cs\%id\_KE\_adv, cs\%KE\_adv, cs\%diag)}
\DoxyCodeLine{1091 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1092 }
\DoxyCodeLine{1093   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_visc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1094     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1095       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1096         ke\_u(i,j) = uh(i,j,k) * g\%dxCu(i,j) * adp\%du\_dt\_visc(i,j,k)}
\DoxyCodeLine{1097 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1098       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1099         ke\_v(i,j) = vh(i,j,k) * g\%dyCv(i,j) * adp\%dv\_dt\_visc(i,j,k)}
\DoxyCodeLine{1100 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1101       \textcolor{keywordflow}{if} (.not.g\%symmetric) \&}
\DoxyCodeLine{1102          \textcolor{keyword}{call }do\_group\_pass(cs\%pass\_KE\_uv, g\%domain)}
\DoxyCodeLine{1103       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1104         cs\%KE\_visc(i,j,k) = 0.5 * g\%IareaT(i,j) \&}
\DoxyCodeLine{1105             * (ke\_u(i,j) + ke\_u(i-\/1,j) + ke\_v(i,j) + ke\_v(i,j-\/1))}
\DoxyCodeLine{1106 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1107 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1108     \textcolor{keywordflow}{if} (cs\%id\_KE\_visc > 0) \textcolor{keyword}{call }post\_data(cs\%id\_KE\_visc, cs\%KE\_visc, cs\%diag)}
\DoxyCodeLine{1109 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1110 }
\DoxyCodeLine{1111   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_horvisc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1112     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1113       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1114         ke\_u(i,j) = uh(i,j,k) * g\%dxCu(i,j) * adp\%diffu(i,j,k)}
\DoxyCodeLine{1115 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1116       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1117         ke\_v(i,j) = vh(i,j,k) * g\%dyCv(i,j) * adp\%diffv(i,j,k)}
\DoxyCodeLine{1118 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1119       \textcolor{keywordflow}{if} (.not.g\%symmetric) \&}
\DoxyCodeLine{1120          \textcolor{keyword}{call }do\_group\_pass(cs\%pass\_KE\_uv, g\%domain)}
\DoxyCodeLine{1121       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1122         cs\%KE\_horvisc(i,j,k) = 0.5 * g\%IareaT(i,j) \&}
\DoxyCodeLine{1123             * (ke\_u(i,j) + ke\_u(i-\/1,j) + ke\_v(i,j) + ke\_v(i,j-\/1))}
\DoxyCodeLine{1124 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1125 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1126     \textcolor{keywordflow}{if} (cs\%id\_KE\_horvisc > 0) \textcolor{keyword}{call }post\_data(cs\%id\_KE\_horvisc, cs\%KE\_horvisc, cs\%diag)}
\DoxyCodeLine{1127 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1128 }
\DoxyCodeLine{1129   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_dia)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1130     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1131       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{1132         ke\_u(i,j) = uh(i,j,k) * g\%dxCu(i,j) * adp\%du\_dt\_dia(i,j,k)}
\DoxyCodeLine{1133 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1134       \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1135         ke\_v(i,j) = vh(i,j,k) * g\%dyCv(i,j) * adp\%dv\_dt\_dia(i,j,k)}
\DoxyCodeLine{1136 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1137       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1138         ke\_h(i,j) = cs\%KE(i,j,k) \&}
\DoxyCodeLine{1139             * (us\%T\_to\_s * (cdp\%diapyc\_vel(i,j,k) -\/ cdp\%diapyc\_vel(i,j,k+1)))}
\DoxyCodeLine{1140 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1141       \textcolor{keywordflow}{if} (.not.g\%symmetric) \&}
\DoxyCodeLine{1142          \textcolor{keyword}{call }do\_group\_pass(cs\%pass\_KE\_uv, g\%domain)}
\DoxyCodeLine{1143       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1144         cs\%KE\_dia(i,j,k) = ke\_h(i,j) + 0.5 * g\%IareaT(i,j) \&}
\DoxyCodeLine{1145             * (ke\_u(i,j) + ke\_u(i-\/1,j) + ke\_v(i,j) + ke\_v(i,j-\/1))}
\DoxyCodeLine{1146 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1147 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1148     \textcolor{keywordflow}{if} (cs\%id\_KE\_dia > 0) \textcolor{keyword}{call }post\_data(cs\%id\_KE\_dia, cs\%KE\_dia, cs\%diag)}
\DoxyCodeLine{1149 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1150 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_a3dc7691c006b2abc1c355adc8e4d1a34}\label{namespacemom__diagnostics_a3dc7691c006b2abc1c355adc8e4d1a34}} 
\index{mom\_diagnostics@{mom\_diagnostics}!calculate\_vertical\_integrals@{calculate\_vertical\_integrals}}
\index{calculate\_vertical\_integrals@{calculate\_vertical\_integrals}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{calculate\_vertical\_integrals()}{calculate\_vertical\_integrals()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diagnostics\+::calculate\+\_\+vertical\+\_\+integrals (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), intent(inout)}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine calculates vertical integrals of several tracers, along with the mass-\/weight of these tracers, the total column mass, and the carefully calculated column height. 


\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}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables. \\
\hline
 & {\em p\+\_\+surf} & A pointer to the surface pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}. If p\+\_\+surf is not associated, it is the same as setting the surface pressure to 0. \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & Control structure returned by a previous call to diagnostics\+\_\+init. \\
\hline
\end{DoxyParams}


Definition at line 832 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{833   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{834   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{835   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{836 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{837                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{838   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< A structure pointing to various}}
\DoxyCodeLine{839 \textcolor{comment}{                                                 !! thermodynamic variables.}}
\DoxyCodeLine{840 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},    \textcolor{keywordtype}{pointer}       :: p\_surf\textcolor{comment}{ !< A pointer to the surface pressure [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{841 \textcolor{comment}{                                                 !! If p\_surf is not associated, it is the same}}
\DoxyCodeLine{842 \textcolor{comment}{                                                 !! as setting the surface pressure to 0.}}
\DoxyCodeLine{843   \textcolor{keywordtype}{type}(diagnostics\_CS),    \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< Control structure returned by a}}
\DoxyCodeLine{844 \textcolor{comment}{                                                 !! previous call to diagnostics\_init.}}
\DoxyCodeLine{845 }
\DoxyCodeLine{846 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G))} :: \&}
\DoxyCodeLine{847     z\_top, \&  \textcolor{comment}{! Height of the top of a layer or the ocean [Z \string~> m].}}
\DoxyCodeLine{848     z\_bot, \&  \textcolor{comment}{! Height of the bottom of a layer (for id\_mass) or the}}
\DoxyCodeLine{849               \textcolor{comment}{! (positive) depth of the ocean (for id\_col\_ht) [Z \string~> m].}}
\DoxyCodeLine{850     mass, \&   \textcolor{comment}{! integrated mass of the water column [R Z \string~> kg m-\/2].  For}}
\DoxyCodeLine{851               \textcolor{comment}{! non-\/Boussinesq models this is rho*dz. For Boussinesq}}
\DoxyCodeLine{852               \textcolor{comment}{! models, this is either the integral of in-\/situ density}}
\DoxyCodeLine{853               \textcolor{comment}{! (rho*dz for col\_mass) or reference density (Rho\_0*dz for mass\_wt).}}
\DoxyCodeLine{854     btm\_pres,\&\textcolor{comment}{! The pressure at the ocean bottom, or CMIP variable 'pbo'.}}
\DoxyCodeLine{855               \textcolor{comment}{! This is the column mass multiplied by gravity plus the pressure}}
\DoxyCodeLine{856               \textcolor{comment}{! at the ocean surface [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{857     dpress, \& \textcolor{comment}{! Change in hydrostatic pressure across a layer [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{858     tr\_int    \textcolor{comment}{! vertical integral of a tracer times density,}}
\DoxyCodeLine{859               \textcolor{comment}{! (Rho\_0 in a Boussinesq model) [TR kg m-\/2].}}
\DoxyCodeLine{860 \textcolor{keywordtype}{  real}    :: IG\_Earth  \textcolor{comment}{! Inverse of gravitational acceleration [T2 Z L-\/2 \string~> s2 m-\/1].}}
\DoxyCodeLine{861 }
\DoxyCodeLine{862   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{863   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{864 }
\DoxyCodeLine{865   \textcolor{keywordflow}{if} (cs\%id\_mass\_wt > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{866     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; mass(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{867     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{868       mass(i,j) = mass(i,j) + gv\%H\_to\_RZ*h(i,j,k)}
\DoxyCodeLine{869 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{870     \textcolor{keyword}{call }post\_data(cs\%id\_mass\_wt, mass, cs\%diag)}
\DoxyCodeLine{871 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{872 }
\DoxyCodeLine{873   \textcolor{keywordflow}{if} (cs\%id\_temp\_int > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{874     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; tr\_int(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{875     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{876       tr\_int(i,j) = tr\_int(i,j) + (gv\%H\_to\_RZ*h(i,j,k))*tv\%T(i,j,k)}
\DoxyCodeLine{877 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{878     \textcolor{keyword}{call }post\_data(cs\%id\_temp\_int, tr\_int, cs\%diag)}
\DoxyCodeLine{879 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{880 }
\DoxyCodeLine{881   \textcolor{keywordflow}{if} (cs\%id\_salt\_int > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{882     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; tr\_int(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{883     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{884       tr\_int(i,j) = tr\_int(i,j) + (gv\%H\_to\_RZ*h(i,j,k))*tv\%S(i,j,k)}
\DoxyCodeLine{885 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{886     \textcolor{keyword}{call }post\_data(cs\%id\_salt\_int, tr\_int, cs\%diag)}
\DoxyCodeLine{887 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{888 }
\DoxyCodeLine{889   \textcolor{keywordflow}{if} (cs\%id\_col\_ht > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{890     \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, z\_top)}
\DoxyCodeLine{891     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{892       z\_bot(i,j) = z\_top(i,j) + g\%bathyT(i,j)}
\DoxyCodeLine{893 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{894     \textcolor{keyword}{call }post\_data(cs\%id\_col\_ht, z\_bot, cs\%diag)}
\DoxyCodeLine{895 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{896 }
\DoxyCodeLine{897   \textcolor{comment}{! NOTE: int\_density\_z expects z\_top and z\_btm values from [ij]sq to [ij]eq+1}}
\DoxyCodeLine{898   \textcolor{keywordflow}{if} (cs\%id\_col\_mass > 0 .or. cs\%id\_pbo > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{899     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; mass(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{900     \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{901       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{902         ig\_earth = 1.0 / gv\%g\_Earth}
\DoxyCodeLine{903 \textcolor{comment}{!       do j=js,je ; do i=is,ie ; z\_bot(i,j) = -\/P\_SURF(i,j)/GV\%H\_to\_Pa ; enddo ; enddo}}
\DoxyCodeLine{904         \textcolor{keywordflow}{do} j=g\%jscB,g\%jecB+1 ; \textcolor{keywordflow}{do} i=g\%iscB,g\%iecB+1}
\DoxyCodeLine{905           z\_bot(i,j) = 0.0}
\DoxyCodeLine{906 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{907         \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{908           \textcolor{keywordflow}{do} j=g\%jscB,g\%jecB+1 ; \textcolor{keywordflow}{do} i=g\%iscB,g\%iecB+1}
\DoxyCodeLine{909             z\_top(i,j) = z\_bot(i,j)}
\DoxyCodeLine{910             z\_bot(i,j) = z\_top(i,j) -\/ gv\%H\_to\_Z*h(i,j,k)}
\DoxyCodeLine{911 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{912           \textcolor{keyword}{call }int\_density\_dz(tv\%T(:,:,k), tv\%S(:,:,k), z\_top, z\_bot, 0.0, gv\%Rho0, gv\%g\_Earth, \&}
\DoxyCodeLine{913                               g\%HI, tv\%eqn\_of\_state, us, dpress)}
\DoxyCodeLine{914           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{915             mass(i,j) = mass(i,j) + dpress(i,j) * ig\_earth}
\DoxyCodeLine{916 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{917 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{918       \textcolor{keywordflow}{else}}
\DoxyCodeLine{919         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{920           mass(i,j) = mass(i,j) + (gv\%H\_to\_Z*gv\%Rlay(k))*h(i,j,k)}
\DoxyCodeLine{921 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{922 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{923     \textcolor{keywordflow}{else}}
\DoxyCodeLine{924       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{925         mass(i,j) = mass(i,j) + gv\%H\_to\_RZ*h(i,j,k)}
\DoxyCodeLine{926 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{927 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{928     \textcolor{keywordflow}{if} (cs\%id\_col\_mass > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{929       \textcolor{keyword}{call }post\_data(cs\%id\_col\_mass, mass, cs\%diag)}
\DoxyCodeLine{930 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{931     \textcolor{keywordflow}{if} (cs\%id\_pbo > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{932       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; btm\_pres(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{933       \textcolor{comment}{! 'pbo' is defined as the sea water pressure at the sea floor}}
\DoxyCodeLine{934       \textcolor{comment}{!     pbo = (mass * g) + p\_surf}}
\DoxyCodeLine{935       \textcolor{comment}{! where p\_surf is the sea water pressure at sea water surface.}}
\DoxyCodeLine{936       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{937         btm\_pres(i,j) = gv\%g\_Earth * mass(i,j)}
\DoxyCodeLine{938         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(p\_surf)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{939           btm\_pres(i,j) = btm\_pres(i,j) + p\_surf(i,j)}
\DoxyCodeLine{940 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{941 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{942       \textcolor{keyword}{call }post\_data(cs\%id\_pbo, btm\_pres, cs\%diag)}
\DoxyCodeLine{943 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{944 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{945 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_ab43b50cd32dfe693c6ce575c279988fb}\label{namespacemom__diagnostics_ab43b50cd32dfe693c6ce575c279988fb}} 
\index{mom\_diagnostics@{mom\_diagnostics}!find\_weights@{find\_weights}}
\index{find\_weights@{find\_weights}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{find\_weights()}{find\_weights()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diagnostics\+::find\+\_\+weights (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{Rlist,  }\item[{real, intent(in)}]{R\+\_\+in,  }\item[{integer, intent(inout)}]{k,  }\item[{integer, intent(in)}]{nz,  }\item[{real, intent(out)}]{wt,  }\item[{real, intent(out)}]{wt\+\_\+p }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine finds the location of R\+\_\+in in an increasing ordered list, Rlist, returning as k the element such that Rlist(k) $<$= R\+\_\+in $<$ Rlist(k+1), and where wt and wt\+\_\+p are the linear weights that should be assigned to elements k and k+1. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em rlist} & The list of target densities \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em r\+\_\+in} & The density being inserted into Rlist \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em k} & The value of k such that Rlist(k) $<$= R\+\_\+in $<$ Rlist(k+1) The input value is a first guess \\
\hline
\mbox{\texttt{ in}}  & {\em nz} & The number of layers in Rlist \\
\hline
\mbox{\texttt{ out}}  & {\em wt} & The weight of layer k for interpolation, nondim \\
\hline
\mbox{\texttt{ out}}  & {\em wt\+\_\+p} & The weight of layer k+1 for interpolation, nondim \\
\hline
\end{DoxyParams}


Definition at line 765 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{766 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \&}
\DoxyCodeLine{767             \textcolor{keywordtype}{intent(in)}    :: Rlist\textcolor{comment}{ !< The list of target densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{768 \textcolor{keywordtype}{  real},     \textcolor{keywordtype}{intent(in)}    :: R\_in\textcolor{comment}{ !< The density being inserted into Rlist [R \string~> kg m-\/3]}}
\DoxyCodeLine{769   \textcolor{keywordtype}{integer},  \textcolor{keywordtype}{intent(inout)} :: k\textcolor{comment}{    !< The value of k such that Rlist(k) <= R\_in < Rlist(k+1)}}
\DoxyCodeLine{770 \textcolor{comment}{                                  !! The input value is a first guess}}
\DoxyCodeLine{771   \textcolor{keywordtype}{integer},  \textcolor{keywordtype}{intent(in)}    :: nz\textcolor{comment}{   !< The number of layers in Rlist}}
\DoxyCodeLine{772 \textcolor{keywordtype}{  real},     \textcolor{keywordtype}{intent(out)}   :: wt\textcolor{comment}{   !< The weight of layer k for interpolation, nondim}}
\DoxyCodeLine{773 \textcolor{keywordtype}{  real},     \textcolor{keywordtype}{intent(out)}   :: wt\_p\textcolor{comment}{ !< The weight of layer k+1 for interpolation, nondim}}
\DoxyCodeLine{774 }
\DoxyCodeLine{775   \textcolor{comment}{! This subroutine finds location of R\_in in an increasing ordered}}
\DoxyCodeLine{776   \textcolor{comment}{! list, Rlist, returning as k the element such that}}
\DoxyCodeLine{777   \textcolor{comment}{!  Rlist(k) <= R\_in < Rlist(k+1), and where wt and wt\_p are the linear}}
\DoxyCodeLine{778   \textcolor{comment}{! weights that should be assigned to elements k and k+1.}}
\DoxyCodeLine{779 }
\DoxyCodeLine{780   \textcolor{keywordtype}{integer} :: k\_upper, k\_lower, k\_new, inc}
\DoxyCodeLine{781 }
\DoxyCodeLine{782   \textcolor{comment}{! First, bracket the desired point.}}
\DoxyCodeLine{783   \textcolor{keywordflow}{if} ((k < 1) .or. (k > nz)) k = nz/2}
\DoxyCodeLine{784 }
\DoxyCodeLine{785   k\_upper = k ; k\_lower = k ; inc = 1}
\DoxyCodeLine{786   \textcolor{keywordflow}{if} (r\_in < rlist(k)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{787     \textcolor{keywordflow}{do}}
\DoxyCodeLine{788       k\_lower = max(k\_lower-\/inc, 1)}
\DoxyCodeLine{789       \textcolor{keywordflow}{if} ((k\_lower == 1) .or. (r\_in >= rlist(k\_lower))) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{790       k\_upper = k\_lower}
\DoxyCodeLine{791       inc = inc*2}
\DoxyCodeLine{792 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{793   \textcolor{keywordflow}{else}}
\DoxyCodeLine{794     \textcolor{keywordflow}{do}}
\DoxyCodeLine{795       k\_upper = min(k\_upper+inc, nz)}
\DoxyCodeLine{796       \textcolor{keywordflow}{if} ((k\_upper == nz) .or. (r\_in < rlist(k\_upper))) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{797       k\_lower = k\_upper}
\DoxyCodeLine{798       inc = inc*2}
\DoxyCodeLine{799 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{800 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{801 }
\DoxyCodeLine{802   \textcolor{keywordflow}{if} ((k\_lower == 1) .and. (r\_in <= rlist(k\_lower))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{803     k = 1 ; wt = 1.0 ; wt\_p = 0.0}
\DoxyCodeLine{804   \textcolor{keywordflow}{elseif} ((k\_upper == nz) .and. (r\_in >= rlist(k\_upper))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{805     k = nz-\/1 ; wt = 0.0 ; wt\_p = 1.0}
\DoxyCodeLine{806   \textcolor{keywordflow}{else}}
\DoxyCodeLine{807     \textcolor{keywordflow}{do}}
\DoxyCodeLine{808       \textcolor{keywordflow}{if} (k\_upper <= k\_lower+1) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{809       k\_new = (k\_upper + k\_lower) / 2}
\DoxyCodeLine{810       \textcolor{keywordflow}{if} (r\_in < rlist(k\_new)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{811         k\_upper = k\_new}
\DoxyCodeLine{812       \textcolor{keywordflow}{else}}
\DoxyCodeLine{813         k\_lower = k\_new}
\DoxyCodeLine{814 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{815 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{816 }
\DoxyCodeLine{817 \textcolor{comment}{!   Uncomment this as a code check}}
\DoxyCodeLine{818 \textcolor{comment}{!    if ((R\_in < Rlist(k\_lower)) .or. (R\_in >= Rlist(k\_upper)) .or. (k\_upper-\/k\_lower /= 1)) \&}}
\DoxyCodeLine{819 \textcolor{comment}{!      write (*,*) "Error: ",R\_in," is not between R(",k\_lower,") = ", \&}}
\DoxyCodeLine{820 \textcolor{comment}{!        Rlist(k\_lower)," and R(",k\_upper,") = ",Rlist(k\_upper),"."}}
\DoxyCodeLine{821     k = k\_lower}
\DoxyCodeLine{822     wt = (rlist(k\_upper) -\/ r\_in) / (rlist(k\_upper) -\/ rlist(k\_lower))}
\DoxyCodeLine{823     wt\_p = 1.0 -\/ wt}
\DoxyCodeLine{824 }
\DoxyCodeLine{825 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{826 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_ae7ada8fb77b23b1b4cfb10d8c8b0ba50}\label{namespacemom__diagnostics_ae7ada8fb77b23b1b4cfb10d8c8b0ba50}} 
\index{mom\_diagnostics@{mom\_diagnostics}!mom\_diagnostics\_end@{mom\_diagnostics\_end}}
\index{mom\_diagnostics\_end@{mom\_diagnostics\_end}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{mom\_diagnostics\_end()}{mom\_diagnostics\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::mom\+\_\+diagnostics\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), pointer}]{CS,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(inout)}]{A\+Dp }\end{DoxyParamCaption})}



Deallocate memory associated with the diagnostics module. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Control structure returned by a previous call to diagnostics\+\_\+init. \\
\hline
\mbox{\texttt{ in,out}}  & {\em adp} & structure with pointers to accelerations in momentum equation. \\
\hline
\end{DoxyParams}


Definition at line 2236 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2237   \textcolor{keywordtype}{type}(diagnostics\_CS),   \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Control structure returned by a}}
\DoxyCodeLine{2238 \textcolor{comment}{                                               !! previous call to diagnostics\_init.}}
\DoxyCodeLine{2239   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),  \textcolor{keywordtype}{intent(inout)} :: ADp\textcolor{comment}{ !< structure with pointers to}}
\DoxyCodeLine{2240 \textcolor{comment}{                                               !! accelerations in momentum equation.}}
\DoxyCodeLine{2241   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{2242 }
\DoxyCodeLine{2243   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%e))          \textcolor{keyword}{deallocate}(cs\%e)}
\DoxyCodeLine{2244   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%e\_D))        \textcolor{keyword}{deallocate}(cs\%e\_D)}
\DoxyCodeLine{2245   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE))         \textcolor{keyword}{deallocate}(cs\%KE)}
\DoxyCodeLine{2246   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%dKE\_dt))     \textcolor{keyword}{deallocate}(cs\%dKE\_dt)}
\DoxyCodeLine{2247   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%PE\_to\_KE))   \textcolor{keyword}{deallocate}(cs\%PE\_to\_KE)}
\DoxyCodeLine{2248   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_Coradv))  \textcolor{keyword}{deallocate}(cs\%KE\_Coradv)}
\DoxyCodeLine{2249   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_adv))     \textcolor{keyword}{deallocate}(cs\%KE\_adv)}
\DoxyCodeLine{2250   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_visc))    \textcolor{keyword}{deallocate}(cs\%KE\_visc)}
\DoxyCodeLine{2251   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_horvisc)) \textcolor{keyword}{deallocate}(cs\%KE\_horvisc)}
\DoxyCodeLine{2252   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_dia))     \textcolor{keyword}{deallocate}(cs\%KE\_dia)}
\DoxyCodeLine{2253   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%dv\_dt))      \textcolor{keyword}{deallocate}(cs\%dv\_dt)}
\DoxyCodeLine{2254   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%dh\_dt))      \textcolor{keyword}{deallocate}(cs\%dh\_dt)}
\DoxyCodeLine{2255   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%du\_dt))      \textcolor{keyword}{deallocate}(cs\%du\_dt)}
\DoxyCodeLine{2256   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%h\_Rlay))     \textcolor{keyword}{deallocate}(cs\%h\_Rlay)}
\DoxyCodeLine{2257   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%uh\_Rlay))    \textcolor{keyword}{deallocate}(cs\%uh\_Rlay)}
\DoxyCodeLine{2258   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%vh\_Rlay))    \textcolor{keyword}{deallocate}(cs\%vh\_Rlay)}
\DoxyCodeLine{2259   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%uhGM\_Rlay))  \textcolor{keyword}{deallocate}(cs\%uhGM\_Rlay)}
\DoxyCodeLine{2260   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%vhGM\_Rlay))  \textcolor{keyword}{deallocate}(cs\%vhGM\_Rlay)}
\DoxyCodeLine{2261 }
\DoxyCodeLine{2262   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%gradKEu))    \textcolor{keyword}{deallocate}(adp\%gradKEu)}
\DoxyCodeLine{2263   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%gradKEu))    \textcolor{keyword}{deallocate}(adp\%gradKEu)}
\DoxyCodeLine{2264   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%du\_dt\_visc)) \textcolor{keyword}{deallocate}(adp\%du\_dt\_visc)}
\DoxyCodeLine{2265   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%dv\_dt\_visc)) \textcolor{keyword}{deallocate}(adp\%dv\_dt\_visc)}
\DoxyCodeLine{2266   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%du\_dt\_dia))  \textcolor{keyword}{deallocate}(adp\%du\_dt\_dia)}
\DoxyCodeLine{2267   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%dv\_dt\_dia))  \textcolor{keyword}{deallocate}(adp\%dv\_dt\_dia)}
\DoxyCodeLine{2268   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%du\_other))   \textcolor{keyword}{deallocate}(adp\%du\_other)}
\DoxyCodeLine{2269   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%dv\_other))   \textcolor{keyword}{deallocate}(adp\%dv\_other)}
\DoxyCodeLine{2270 }
\DoxyCodeLine{2271   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%diag\_hfrac\_u)) \textcolor{keyword}{deallocate}(adp\%diag\_hfrac\_u)}
\DoxyCodeLine{2272   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(adp\%diag\_hfrac\_v)) \textcolor{keyword}{deallocate}(adp\%diag\_hfrac\_v)}
\DoxyCodeLine{2273 }
\DoxyCodeLine{2274   \textcolor{keywordflow}{do} m=1,cs\%num\_time\_deriv ; \textcolor{keyword}{deallocate}(cs\%prev\_val(m)\%p) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2275 }
\DoxyCodeLine{2276   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{2277 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_ae8281123dfff124b0a362ea9fd1e0078}\label{namespacemom__diagnostics_ae8281123dfff124b0a362ea9fd1e0078}} 
\index{mom\_diagnostics@{mom\_diagnostics}!mom\_diagnostics\_init@{mom\_diagnostics\_init}}
\index{mom\_diagnostics\_init@{mom\_diagnostics\_init}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{mom\_diagnostics\_init()}{mom\_diagnostics\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::mom\+\_\+diagnostics\+\_\+init (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+internal\+\_\+state), intent(in)}]{M\+IS,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(inout)}]{A\+Dp,  }\item[{type(cont\+\_\+diag\+\_\+ptrs), intent(inout)}]{C\+Dp,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), pointer}]{CS,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv }\end{DoxyParamCaption})}



This subroutine registers various diagnostics and allocates space for fields that other diagnostis depend upon. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em mis} & For \char`\"{}\+M\+O\+M Internal State\char`\"{} a set of pointers to the fields and accelerations that make up the ocean\textquotesingle{}s internal physical state. \\
\hline
\mbox{\texttt{ in,out}}  & {\em adp} & Structure with pointers to momentum equation terms. \\
\hline
\mbox{\texttt{ in,out}}  & {\em cdp} & Structure with pointers to continuity equation terms. \\
\hline
\mbox{\texttt{ in}}  & {\em time} & Current model time. \\
\hline
\mbox{\texttt{ in}}  & {\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}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters. \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & Structure to regulate diagnostic output. \\
\hline
 & {\em cs} & Pointer set to point to control structure for this module. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables. \\
\hline
\end{DoxyParams}


Definition at line 1492 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1493   \textcolor{keywordtype}{type}(ocean\_internal\_state), \textcolor{keywordtype}{intent(in)}    :: MIS\textcolor{comment}{  !< For "MOM Internal State" a set of pointers to}}
\DoxyCodeLine{1494 \textcolor{comment}{                                                    !! the fields and accelerations that make up the}}
\DoxyCodeLine{1495 \textcolor{comment}{                                                    !! ocean's internal physical state.}}
\DoxyCodeLine{1496   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),      \textcolor{keywordtype}{intent(inout)} :: ADp\textcolor{comment}{  !< Structure with pointers to momentum equation}}
\DoxyCodeLine{1497 \textcolor{comment}{                                                    !! terms.}}
\DoxyCodeLine{1498   \textcolor{keywordtype}{type}(cont\_diag\_ptrs),       \textcolor{keywordtype}{intent(inout)} :: CDp\textcolor{comment}{  !< Structure with pointers to continuity}}
\DoxyCodeLine{1499 \textcolor{comment}{                                                    !! equation terms.}}
\DoxyCodeLine{1500   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< Current model time.}}
\DoxyCodeLine{1501   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{1502   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure.}}
\DoxyCodeLine{1503   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1504   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time}}
\DoxyCodeLine{1505 \textcolor{comment}{                                                    !! parameters.}}
\DoxyCodeLine{1506   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},    \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< Structure to regulate diagnostic output.}}
\DoxyCodeLine{1507   \textcolor{keywordtype}{type}(diagnostics\_CS),       \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< Pointer set to point to control structure}}
\DoxyCodeLine{1508 \textcolor{comment}{                                                    !! for this module.}}
\DoxyCodeLine{1509   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),      \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< A structure pointing to various}}
\DoxyCodeLine{1510 \textcolor{comment}{                                                    !! thermodynamic variables.}}
\DoxyCodeLine{1511 }
\DoxyCodeLine{1512   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1513 \textcolor{keywordtype}{  real} :: omega, f2\_min, convert\_H}
\DoxyCodeLine{1514   \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{1515 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{1516 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_diagnostics"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{1517   \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units}
\DoxyCodeLine{1518 \textcolor{keywordtype}{  real} :: wave\_speed\_min      \textcolor{comment}{! A floor in the first mode speed below which 0 is returned [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1519 \textcolor{keywordtype}{  real} :: wave\_speed\_tol      \textcolor{comment}{! The fractional tolerance for finding the wave speeds [nondim]}}
\DoxyCodeLine{1520   \textcolor{keywordtype}{logical} :: better\_speed\_est \textcolor{comment}{! If true, use a more robust estimate of the first}}
\DoxyCodeLine{1521                               \textcolor{comment}{! mode wave speed as the starting point for iterations.}}
\DoxyCodeLine{1522   \textcolor{keywordtype}{logical} :: use\_temperature, adiabatic}
\DoxyCodeLine{1523   \textcolor{keywordtype}{logical} :: default\_2018\_answers, remap\_answers\_2018}
\DoxyCodeLine{1524   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, nz, nkml, nkbl}
\DoxyCodeLine{1525   \textcolor{keywordtype}{integer} :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, i, j}
\DoxyCodeLine{1526 }
\DoxyCodeLine{1527   is   = g\%isc  ; ie   = g\%iec  ; js   = g\%jsc  ; je   = g\%jec}
\DoxyCodeLine{1528   isq  = g\%IscB ; ieq  = g\%IecB ; jsq  = g\%JscB ; jeq  = g\%JecB}
\DoxyCodeLine{1529   isd  = g\%isd  ; ied  = g\%ied  ; jsd  = g\%jsd  ; jed  = g\%jed ; nz = g\%ke}
\DoxyCodeLine{1530   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{1531 }
\DoxyCodeLine{1532   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1533     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM\_diagnostics\_init called with an associated "}// \&}
\DoxyCodeLine{1534                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{1535     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1536 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1537   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{1538 }
\DoxyCodeLine{1539   cs\%diag => diag}
\DoxyCodeLine{1540   use\_temperature = \textcolor{keyword}{associated}(tv\%T)}
\DoxyCodeLine{1541   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADIABATIC"}, adiabatic, default=.false., \&}
\DoxyCodeLine{1542                  do\_not\_log=.true.)}
\DoxyCodeLine{1543 }
\DoxyCodeLine{1544   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{1545   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{1546   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DIAG\_EBT\_MONO\_N2\_COLUMN\_FRACTION"}, cs\%mono\_N2\_column\_fraction, \&}
\DoxyCodeLine{1547                  \textcolor{stringliteral}{"The lower fraction of water column over which N2 is limited as monotonic "}// \&}
\DoxyCodeLine{1548                  \textcolor{stringliteral}{"for the purposes of calculating the equivalent barotropic wave speed."}, \&}
\DoxyCodeLine{1549                  units=\textcolor{stringliteral}{'nondim'}, default=0.)}
\DoxyCodeLine{1550   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DIAG\_EBT\_MONO\_N2\_DEPTH"}, cs\%mono\_N2\_depth, \&}
\DoxyCodeLine{1551                  \textcolor{stringliteral}{"The depth below which N2 is limited as monotonic for the "}// \&}
\DoxyCodeLine{1552                  \textcolor{stringliteral}{"purposes of calculating the equivalent barotropic wave speed."}, \&}
\DoxyCodeLine{1553                  units=\textcolor{stringliteral}{'m'}, scale=us\%m\_to\_Z, default=-\/1.)}
\DoxyCodeLine{1554   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERNAL\_WAVE\_SPEED\_TOL"}, wave\_speed\_tol, \&}
\DoxyCodeLine{1555                  \textcolor{stringliteral}{"The fractional tolerance for finding the wave speeds."}, \&}
\DoxyCodeLine{1556                  units=\textcolor{stringliteral}{"nondim"}, default=0.001)}
\DoxyCodeLine{1557   \textcolor{comment}{!\#\#\# Set defaults so that wave\_speed\_min*wave\_speed\_tol >= 1e-\/9 m s-\/1}}
\DoxyCodeLine{1558   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERNAL\_WAVE\_SPEED\_MIN"}, wave\_speed\_min, \&}
\DoxyCodeLine{1559                  \textcolor{stringliteral}{"A floor in the first mode speed below which 0 used instead."}, \&}
\DoxyCodeLine{1560                  units=\textcolor{stringliteral}{"m s-\/1"}, default=0.0, scale=us\%m\_s\_to\_L\_T)}
\DoxyCodeLine{1561   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INTERNAL\_WAVE\_SPEED\_BETTER\_EST"}, better\_speed\_est, \&}
\DoxyCodeLine{1562                  \textcolor{stringliteral}{"If true, use a more robust estimate of the first mode wave speed as the "}//\&}
\DoxyCodeLine{1563                  \textcolor{stringliteral}{"starting point for iterations."}, default=.false.) \textcolor{comment}{!\#\#\# Change the default.}}
\DoxyCodeLine{1564   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{1565                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{1566                  default=.false.)}
\DoxyCodeLine{1567   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, remap\_answers\_2018, \&}
\DoxyCodeLine{1568                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//\&}
\DoxyCodeLine{1569                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//\&}
\DoxyCodeLine{1570                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{1571 }
\DoxyCodeLine{1572   \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1573     thickness\_units = \textcolor{stringliteral}{"m"} ; flux\_units = \textcolor{stringliteral}{"m3 s-\/1"} ; convert\_h = gv\%H\_to\_m}
\DoxyCodeLine{1574   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1575     thickness\_units = \textcolor{stringliteral}{"kg m-\/2"} ; flux\_units = \textcolor{stringliteral}{"kg s-\/1"} ; convert\_h = gv\%H\_to\_kg\_m2}
\DoxyCodeLine{1576 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1577 }
\DoxyCodeLine{1578   cs\%id\_masscello = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'masscello'}, diag\%axesTL,\&}
\DoxyCodeLine{1579       time, \textcolor{stringliteral}{'Mass per unit area of liquid ocean grid cell'}, \textcolor{stringliteral}{'kg m-\/2'},           \&}
\DoxyCodeLine{1580       standard\_name=\textcolor{stringliteral}{'sea\_water\_mass\_per\_unit\_area'}, v\_extensive=.true.)}
\DoxyCodeLine{1581 }
\DoxyCodeLine{1582   cs\%id\_masso = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'masso'}, time,  \&}
\DoxyCodeLine{1583       diag, \textcolor{stringliteral}{'Mass of liquid ocean'}, \textcolor{stringliteral}{'kg'}, standard\_name=\textcolor{stringliteral}{'sea\_water\_mass'})}
\DoxyCodeLine{1584 }
\DoxyCodeLine{1585   cs\%id\_thkcello = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'thkcello'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1586       long\_name = \textcolor{stringliteral}{'Cell Thickness'}, standard\_name=\textcolor{stringliteral}{'cell\_thickness'}, \&}
\DoxyCodeLine{1587       units=\textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m, v\_extensive=.true.)}
\DoxyCodeLine{1588   cs\%id\_h\_pre\_sync = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_pre\_sync'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1589       long\_name = \textcolor{stringliteral}{'Cell thickness from the previous timestep'}, \&}
\DoxyCodeLine{1590       units=\textcolor{stringliteral}{'m'}, conversion=gv\%H\_to\_m, v\_extensive=.true.)}
\DoxyCodeLine{1591 }
\DoxyCodeLine{1592   \textcolor{comment}{! Note that CS\%id\_volcello would normally be registered here but because it is a "cell measure" and}}
\DoxyCodeLine{1593   \textcolor{comment}{! must be registered first. We earlier stored the handle of volcello but need it here for posting}}
\DoxyCodeLine{1594   \textcolor{comment}{! by this module.}}
\DoxyCodeLine{1595   cs\%id\_volcello = diag\_get\_volume\_cell\_measure\_dm\_id(diag)}
\DoxyCodeLine{1596 }
\DoxyCodeLine{1597   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1598     \textcolor{keywordflow}{if} (tv\%T\_is\_conT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1599       cs\%id\_Tpot = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'temp'}, diag\%axesTL, \&}
\DoxyCodeLine{1600           time, \textcolor{stringliteral}{'Potential Temperature'}, \textcolor{stringliteral}{'degC'})}
\DoxyCodeLine{1601 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1602     \textcolor{keywordflow}{if} (tv\%S\_is\_absS) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1603       cs\%id\_Sprac = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'salt'}, diag\%axesTL, \&}
\DoxyCodeLine{1604           time, \textcolor{stringliteral}{'Salinity'}, \textcolor{stringliteral}{'psu'})}
\DoxyCodeLine{1605 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1606 }
\DoxyCodeLine{1607     cs\%id\_tob = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'tob'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1608         long\_name=\textcolor{stringliteral}{'Sea Water Potential Temperature at Sea Floor'}, \&}
\DoxyCodeLine{1609         standard\_name=\textcolor{stringliteral}{'sea\_water\_potential\_temperature\_at\_sea\_floor'}, units=\textcolor{stringliteral}{'degC'})}
\DoxyCodeLine{1610     cs\%id\_sob = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'sob'},diag\%axesT1, time, \&}
\DoxyCodeLine{1611         long\_name=\textcolor{stringliteral}{'Sea Water Salinity at Sea Floor'}, \&}
\DoxyCodeLine{1612         standard\_name=\textcolor{stringliteral}{'sea\_water\_salinity\_at\_sea\_floor'}, units=\textcolor{stringliteral}{'psu'})}
\DoxyCodeLine{1613 }
\DoxyCodeLine{1614     cs\%id\_temp\_layer\_ave = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'temp\_layer\_ave'}, \&}
\DoxyCodeLine{1615         diag\%axesZL, time, \textcolor{stringliteral}{'Layer Average Ocean Temperature'}, \textcolor{stringliteral}{'degC'})}
\DoxyCodeLine{1616     cs\%id\_salt\_layer\_ave = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'salt\_layer\_ave'}, \&}
\DoxyCodeLine{1617         diag\%axesZL, time, \textcolor{stringliteral}{'Layer Average Ocean Salinity'}, \textcolor{stringliteral}{'psu'})}
\DoxyCodeLine{1618 }
\DoxyCodeLine{1619     cs\%id\_thetaoga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'thetaoga'}, \&}
\DoxyCodeLine{1620         time, diag, \textcolor{stringliteral}{'Global Mean Ocean Potential Temperature'}, \textcolor{stringliteral}{'degC'},\&}
\DoxyCodeLine{1621         standard\_name=\textcolor{stringliteral}{'sea\_water\_potential\_temperature'})}
\DoxyCodeLine{1622     cs\%id\_soga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'soga'}, \&}
\DoxyCodeLine{1623         time, diag, \textcolor{stringliteral}{'Global Mean Ocean Salinity'}, \textcolor{stringliteral}{'psu'}, \&}
\DoxyCodeLine{1624         standard\_name=\textcolor{stringliteral}{'sea\_water\_salinity'})}
\DoxyCodeLine{1625 }
\DoxyCodeLine{1626     cs\%id\_tosga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sst\_global'}, time, diag,\&}
\DoxyCodeLine{1627         long\_name=\textcolor{stringliteral}{'Global Area Average Sea Surface Temperature'},                \&}
\DoxyCodeLine{1628         units=\textcolor{stringliteral}{'degC'}, standard\_name=\textcolor{stringliteral}{'sea\_surface\_temperature'},                  \&}
\DoxyCodeLine{1629         cmor\_field\_name=\textcolor{stringliteral}{'tosga'}, cmor\_standard\_name=\textcolor{stringliteral}{'sea\_surface\_temperature'},  \&}
\DoxyCodeLine{1630         cmor\_long\_name=\textcolor{stringliteral}{'Sea Surface Temperature'})}
\DoxyCodeLine{1631     cs\%id\_sosga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sss\_global'}, time, diag,\&}
\DoxyCodeLine{1632         long\_name=\textcolor{stringliteral}{'Global Area Average Sea Surface Salinity'},                   \&}
\DoxyCodeLine{1633         units=\textcolor{stringliteral}{'psu'}, standard\_name=\textcolor{stringliteral}{'sea\_surface\_salinity'},                      \&}
\DoxyCodeLine{1634         cmor\_field\_name=\textcolor{stringliteral}{'sosga'}, cmor\_standard\_name=\textcolor{stringliteral}{'sea\_surface\_salinity'},     \&}
\DoxyCodeLine{1635         cmor\_long\_name=\textcolor{stringliteral}{'Sea Surface Salinity'})}
\DoxyCodeLine{1636 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1637 }
\DoxyCodeLine{1638   cs\%id\_u = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u'}, diag\%axesCuL, time,              \&}
\DoxyCodeLine{1639       \textcolor{stringliteral}{'Zonal velocity'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s, cmor\_field\_name=\textcolor{stringliteral}{'uo'}, \&}
\DoxyCodeLine{1640       cmor\_standard\_name=\textcolor{stringliteral}{'sea\_water\_x\_velocity'}, cmor\_long\_name=\textcolor{stringliteral}{'Sea Water X Velocity'})}
\DoxyCodeLine{1641   cs\%id\_v = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v'}, diag\%axesCvL, time,                  \&}
\DoxyCodeLine{1642       \textcolor{stringliteral}{'Meridional velocity'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s, cmor\_field\_name=\textcolor{stringliteral}{'vo'}, \&}
\DoxyCodeLine{1643       cmor\_standard\_name=\textcolor{stringliteral}{'sea\_water\_y\_velocity'}, cmor\_long\_name=\textcolor{stringliteral}{'Sea Water Y Velocity'})}
\DoxyCodeLine{1644   cs\%id\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1645       \textcolor{stringliteral}{'Layer Thickness'}, thickness\_units, v\_extensive=.true., conversion=convert\_h)}
\DoxyCodeLine{1646 }
\DoxyCodeLine{1647   cs\%id\_e = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'e'}, diag\%axesTi, time, \&}
\DoxyCodeLine{1648       \textcolor{stringliteral}{'Interface Height Relative to Mean Sea Level'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{1649   \textcolor{keywordflow}{if} (cs\%id\_e>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%e,isd,ied,jsd,jed,nz+1)}
\DoxyCodeLine{1650 }
\DoxyCodeLine{1651   cs\%id\_e\_D = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'e\_D'}, diag\%axesTi, time, \&}
\DoxyCodeLine{1652       \textcolor{stringliteral}{'Interface Height above the Seafloor'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{1653   \textcolor{keywordflow}{if} (cs\%id\_e\_D>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%e\_D,isd,ied,jsd,jed,nz+1)}
\DoxyCodeLine{1654 }
\DoxyCodeLine{1655   cs\%id\_Rml = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Rml'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1656       \textcolor{stringliteral}{'Mixed Layer Coordinate Potential Density'}, \textcolor{stringliteral}{'kg m-\/3'}, conversion=us\%R\_to\_kg\_m3)}
\DoxyCodeLine{1657 }
\DoxyCodeLine{1658   cs\%id\_Rcv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Rho\_cv'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1659       \textcolor{stringliteral}{'Coordinate Potential Density'}, \textcolor{stringliteral}{'kg m-\/3'}, conversion=us\%R\_to\_kg\_m3)}
\DoxyCodeLine{1660 }
\DoxyCodeLine{1661   cs\%id\_rhopot0 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'rhopot0'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1662       \textcolor{stringliteral}{'Potential density referenced to surface'}, \textcolor{stringliteral}{'kg m-\/3'}, conversion=us\%R\_to\_kg\_m3)}
\DoxyCodeLine{1663   cs\%id\_rhopot2 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'rhopot2'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1664       \textcolor{stringliteral}{'Potential density referenced to 2000 dbar'}, \textcolor{stringliteral}{'kg m-\/3'}, conversion=us\%R\_to\_kg\_m3)}
\DoxyCodeLine{1665   cs\%id\_rhoinsitu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'rhoinsitu'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1666       \textcolor{stringliteral}{'In situ density'}, \textcolor{stringliteral}{'kg m-\/3'}, conversion=us\%R\_to\_kg\_m3)}
\DoxyCodeLine{1667   cs\%id\_drho\_dT = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'drho\_dT'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1668       \textcolor{stringliteral}{'Partial derivative of rhoinsitu with respect to temperature (alpha)'}, \textcolor{stringliteral}{'kg m-\/3 degC-\/1'})}
\DoxyCodeLine{1669   cs\%id\_drho\_dS = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'drho\_dS'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1670       \textcolor{stringliteral}{'Partial derivative of rhoinsitu with respect to salinity (beta)'}, \textcolor{stringliteral}{'kg\string^2 g-\/1 m-\/3'})}
\DoxyCodeLine{1671 }
\DoxyCodeLine{1672   cs\%id\_du\_dt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dudt'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{1673       \textcolor{stringliteral}{'Zonal Acceleration'}, \textcolor{stringliteral}{'m s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1674   \textcolor{keywordflow}{if} ((cs\%id\_du\_dt>0) .and. .not.\textcolor{keyword}{associated}(cs\%du\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1675     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%du\_dt,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1676     \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%u), mis\%u, cs\%du\_dt, cs)}
\DoxyCodeLine{1677 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1678 }
\DoxyCodeLine{1679   cs\%id\_dv\_dt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dvdt'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{1680       \textcolor{stringliteral}{'Meridional Acceleration'}, \textcolor{stringliteral}{'m s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1681   \textcolor{keywordflow}{if} ((cs\%id\_dv\_dt>0) .and. .not.\textcolor{keyword}{associated}(cs\%dv\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1682     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%dv\_dt,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1683     \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%v), mis\%v, cs\%dv\_dt, cs)}
\DoxyCodeLine{1684 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1685 }
\DoxyCodeLine{1686   cs\%id\_dh\_dt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dhdt'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1687       \textcolor{stringliteral}{'Thickness tendency'}, trim(thickness\_units)//\textcolor{stringliteral}{" s-\/1"}, conversion=convert\_h*us\%s\_to\_T, v\_extensive=.true.)}
\DoxyCodeLine{1688   \textcolor{keywordflow}{if} ((cs\%id\_dh\_dt>0) .and. .not.\textcolor{keyword}{associated}(cs\%dh\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1689     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%dh\_dt,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1690     \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%h), mis\%h, cs\%dh\_dt, cs)}
\DoxyCodeLine{1691 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1692 }
\DoxyCodeLine{1693   \textcolor{comment}{!CS\%id\_hf\_du\_dt = register\_diag\_field('ocean\_model', 'hf\_dudt', diag\%axesCuL, Time, \&}}
\DoxyCodeLine{1694   \textcolor{comment}{!    'Fractional Thickness-\/weighted Zonal Acceleration', 'm s-\/2', v\_extensive=.true., \&}}
\DoxyCodeLine{1695   \textcolor{comment}{!    conversion=US\%L\_T2\_to\_m\_s2)}}
\DoxyCodeLine{1696   \textcolor{comment}{!if (CS\%id\_hf\_du\_dt > 0) then}}
\DoxyCodeLine{1697   \textcolor{comment}{!  call safe\_alloc\_ptr(CS\%hf\_du\_dt,IsdB,IedB,jsd,jed,nz)}}
\DoxyCodeLine{1698   \textcolor{comment}{!  if (.not.associated(CS\%du\_dt)) then}}
\DoxyCodeLine{1699   \textcolor{comment}{!    call safe\_alloc\_ptr(CS\%du\_dt,IsdB,IedB,jsd,jed,nz)}}
\DoxyCodeLine{1700   \textcolor{comment}{!    call register\_time\_deriv(lbound(MIS\%u), MIS\%u, CS\%du\_dt, CS)}}
\DoxyCodeLine{1701   \textcolor{comment}{!  endif}}
\DoxyCodeLine{1702   \textcolor{comment}{!  call safe\_alloc\_ptr(ADp\%diag\_hfrac\_u,IsdB,IedB,jsd,jed,nz)}}
\DoxyCodeLine{1703   \textcolor{comment}{!endif}}
\DoxyCodeLine{1704 }
\DoxyCodeLine{1705   \textcolor{comment}{!CS\%id\_hf\_dv\_dt = register\_diag\_field('ocean\_model', 'hf\_dvdt', diag\%axesCvL, Time, \&}}
\DoxyCodeLine{1706   \textcolor{comment}{!    'Fractional Thickness-\/weighted Meridional Acceleration', 'm s-\/2', v\_extensive=.true., \&}}
\DoxyCodeLine{1707   \textcolor{comment}{!    conversion=US\%L\_T2\_to\_m\_s2)}}
\DoxyCodeLine{1708   \textcolor{comment}{!if (CS\%id\_hf\_dv\_dt > 0) then}}
\DoxyCodeLine{1709   \textcolor{comment}{!  call safe\_alloc\_ptr(CS\%hf\_dv\_dt,isd,ied,JsdB,JedB,nz)}}
\DoxyCodeLine{1710   \textcolor{comment}{!  if (.not.associated(CS\%dv\_dt)) then}}
\DoxyCodeLine{1711   \textcolor{comment}{!    call safe\_alloc\_ptr(CS\%dv\_dt,isd,ied,JsdB,JedB,nz)}}
\DoxyCodeLine{1712   \textcolor{comment}{!    call register\_time\_deriv(lbound(MIS\%v), MIS\%v, CS\%dv\_dt, CS)}}
\DoxyCodeLine{1713   \textcolor{comment}{!  endif}}
\DoxyCodeLine{1714   \textcolor{comment}{!  call safe\_alloc\_ptr(ADp\%diag\_hfrac\_v,isd,ied,Jsd,JedB,nz)}}
\DoxyCodeLine{1715   \textcolor{comment}{!endif}}
\DoxyCodeLine{1716 }
\DoxyCodeLine{1717   cs\%id\_hf\_du\_dt\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_dudt\_2d'}, diag\%axesCu1, time, \&}
\DoxyCodeLine{1718       \textcolor{stringliteral}{'Depth-\/sum Fractional Thickness-\/weighted Zonal Acceleration'}, \textcolor{stringliteral}{'m s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1719   \textcolor{keywordflow}{if} (cs\%id\_hf\_du\_dt\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1720     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs\%du\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1721       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%du\_dt,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1722       \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%u), mis\%u, cs\%du\_dt, cs)}
\DoxyCodeLine{1723 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1724     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%diag\_hfrac\_u,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1725 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1726 }
\DoxyCodeLine{1727   cs\%id\_hf\_dv\_dt\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hf\_dvdt\_2d'}, diag\%axesCv1, time, \&}
\DoxyCodeLine{1728       \textcolor{stringliteral}{'Depth-\/sum Fractional Thickness-\/weighted Meridional Acceleration'}, \textcolor{stringliteral}{'m s-\/2'}, conversion=us\%L\_T2\_to\_m\_s2)}
\DoxyCodeLine{1729   \textcolor{keywordflow}{if} (cs\%id\_hf\_dv\_dt\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1730     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs\%dv\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1731       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%dv\_dt,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1732       \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%v), mis\%v, cs\%dv\_dt, cs)}
\DoxyCodeLine{1733 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1734     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%diag\_hfrac\_v,isd,ied,jsd,jedb,nz)}
\DoxyCodeLine{1735 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1736 }
\DoxyCodeLine{1737   \textcolor{comment}{! layer thickness variables}}
\DoxyCodeLine{1738   \textcolor{comment}{!if (GV\%nk\_rho\_varies > 0) then}}
\DoxyCodeLine{1739     cs\%id\_h\_Rlay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_rho'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1740         \textcolor{stringliteral}{'Layer thicknesses in pure potential density coordinates'}, \&}
\DoxyCodeLine{1741         thickness\_units, conversion=convert\_h)}
\DoxyCodeLine{1742     \textcolor{keywordflow}{if} (cs\%id\_h\_Rlay>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%h\_Rlay,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1743 }
\DoxyCodeLine{1744     cs\%id\_uh\_Rlay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'uh\_rho'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{1745         \textcolor{stringliteral}{'Zonal volume transport in pure potential density coordinates'}, \&}
\DoxyCodeLine{1746         flux\_units, conversion=us\%L\_to\_m**2*us\%s\_to\_T*convert\_h)}
\DoxyCodeLine{1747     \textcolor{keywordflow}{if} (cs\%id\_uh\_Rlay>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%uh\_Rlay,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1748 }
\DoxyCodeLine{1749     cs\%id\_vh\_Rlay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vh\_rho'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{1750         \textcolor{stringliteral}{'Meridional volume transport in pure potential density coordinates'}, \&}
\DoxyCodeLine{1751         flux\_units, conversion=us\%L\_to\_m**2*us\%s\_to\_T*convert\_h)}
\DoxyCodeLine{1752     \textcolor{keywordflow}{if} (cs\%id\_vh\_Rlay>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%vh\_Rlay,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1753 }
\DoxyCodeLine{1754     cs\%id\_uhGM\_Rlay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'uhGM\_rho'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{1755         \textcolor{stringliteral}{'Zonal volume transport due to interface height diffusion in pure potential '}//\&}
\DoxyCodeLine{1756         \textcolor{stringliteral}{'density coordinates'}, flux\_units, conversion=us\%L\_to\_m**2*us\%s\_to\_T*convert\_h)}
\DoxyCodeLine{1757     \textcolor{keywordflow}{if} (cs\%id\_uhGM\_Rlay>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%uhGM\_Rlay,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{1758 }
\DoxyCodeLine{1759     cs\%id\_vhGM\_Rlay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vhGM\_rho'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{1760         \textcolor{stringliteral}{'Meridional volume transport due to interface height diffusion in pure potential '}//\&}
\DoxyCodeLine{1761         \textcolor{stringliteral}{'density coordinates'}, flux\_units, conversion=us\%L\_to\_m**2*us\%s\_to\_T*convert\_h)}
\DoxyCodeLine{1762     \textcolor{keywordflow}{if} (cs\%id\_vhGM\_Rlay>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%vhGM\_Rlay,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{1763   \textcolor{comment}{!endif}}
\DoxyCodeLine{1764 }
\DoxyCodeLine{1765 }
\DoxyCodeLine{1766   \textcolor{comment}{! terms in the kinetic energy budget}}
\DoxyCodeLine{1767   cs\%id\_KE = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'KE'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1768       \textcolor{stringliteral}{'Layer kinetic energy per unit mass'}, \&}
\DoxyCodeLine{1769       \textcolor{stringliteral}{'m2 s-\/2'}, conversion=us\%L\_T\_to\_m\_s**2)}
\DoxyCodeLine{1770   \textcolor{keywordflow}{if} (cs\%id\_KE>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%KE,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1771 }
\DoxyCodeLine{1772   cs\%id\_dKEdt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dKE\_dt'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1773       \textcolor{stringliteral}{'Kinetic Energy Tendency of Layer'}, \&}
\DoxyCodeLine{1774       \textcolor{stringliteral}{'m3 s-\/3'}, conversion=gv\%H\_to\_m*(us\%L\_T\_to\_m\_s**2)*us\%s\_to\_T)}
\DoxyCodeLine{1775   \textcolor{keywordflow}{if} (cs\%id\_dKEdt>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%dKE\_dt,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1776 }
\DoxyCodeLine{1777   cs\%id\_PE\_to\_KE = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PE\_to\_KE'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1778       \textcolor{stringliteral}{'Potential to Kinetic Energy Conversion of Layer'}, \&}
\DoxyCodeLine{1779       \textcolor{stringliteral}{'m3 s-\/3'}, conversion=gv\%H\_to\_m*(us\%L\_T\_to\_m\_s**2)*us\%s\_to\_T)}
\DoxyCodeLine{1780   \textcolor{keywordflow}{if} (cs\%id\_PE\_to\_KE>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%PE\_to\_KE,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1781 }
\DoxyCodeLine{1782   cs\%id\_KE\_Coradv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'KE\_Coradv'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1783       \textcolor{stringliteral}{'Kinetic Energy Source from Coriolis and Advection'}, \&}
\DoxyCodeLine{1784       \textcolor{stringliteral}{'m3 s-\/3'}, conversion=gv\%H\_to\_m*(us\%L\_T\_to\_m\_s**2)*us\%s\_to\_T)}
\DoxyCodeLine{1785   \textcolor{keywordflow}{if} (cs\%id\_KE\_Coradv>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%KE\_Coradv,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1786 }
\DoxyCodeLine{1787   cs\%id\_KE\_adv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'KE\_adv'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1788       \textcolor{stringliteral}{'Kinetic Energy Source from Advection'}, \&}
\DoxyCodeLine{1789       \textcolor{stringliteral}{'m3 s-\/3'}, conversion=gv\%H\_to\_m*(us\%L\_T\_to\_m\_s**2)*us\%s\_to\_T)}
\DoxyCodeLine{1790   \textcolor{keywordflow}{if} (cs\%id\_KE\_adv>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%KE\_adv,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1791 }
\DoxyCodeLine{1792   cs\%id\_KE\_visc = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'KE\_visc'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1793       \textcolor{stringliteral}{'Kinetic Energy Source from Vertical Viscosity and Stresses'}, \&}
\DoxyCodeLine{1794       \textcolor{stringliteral}{'m3 s-\/3'}, conversion=gv\%H\_to\_m*(us\%L\_T\_to\_m\_s**2)*us\%s\_to\_T)}
\DoxyCodeLine{1795   \textcolor{keywordflow}{if} (cs\%id\_KE\_visc>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%KE\_visc,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1796 }
\DoxyCodeLine{1797   cs\%id\_KE\_horvisc = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'KE\_horvisc'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1798       \textcolor{stringliteral}{'Kinetic Energy Source from Horizontal Viscosity'}, \&}
\DoxyCodeLine{1799       \textcolor{stringliteral}{'m3 s-\/3'}, conversion=gv\%H\_to\_m*(us\%L\_T\_to\_m\_s**2)*us\%s\_to\_T)}
\DoxyCodeLine{1800   \textcolor{keywordflow}{if} (cs\%id\_KE\_horvisc>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%KE\_horvisc,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1801 }
\DoxyCodeLine{1802   \textcolor{keywordflow}{if} (.not. adiabatic) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1803     cs\%id\_KE\_dia = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'KE\_dia'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1804         \textcolor{stringliteral}{'Kinetic Energy Source from Diapycnal Diffusion'}, \&}
\DoxyCodeLine{1805         \textcolor{stringliteral}{'m3 s-\/3'}, conversion=gv\%H\_to\_m*(us\%L\_T\_to\_m\_s**2)*us\%s\_to\_T)}
\DoxyCodeLine{1806     \textcolor{keywordflow}{if} (cs\%id\_KE\_dia>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%KE\_dia,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1807 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1808 }
\DoxyCodeLine{1809   \textcolor{comment}{! gravity wave CFLs}}
\DoxyCodeLine{1810   cs\%id\_cg1 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'cg1'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1811       \textcolor{stringliteral}{'First baroclinic gravity wave speed'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{1812   cs\%id\_Rd1 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Rd1'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1813       \textcolor{stringliteral}{'First baroclinic deformation radius'}, \textcolor{stringliteral}{'m'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{1814   cs\%id\_cfl\_cg1 = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CFL\_cg1'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1815       \textcolor{stringliteral}{'CFL of first baroclinic gravity wave = dt*cg1*(1/dx+1/dy)'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{1816   cs\%id\_cfl\_cg1\_x = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CFL\_cg1\_x'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1817       \textcolor{stringliteral}{'i-\/component of CFL of first baroclinic gravity wave = dt*cg1*/dx'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{1818   cs\%id\_cfl\_cg1\_y = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'CFL\_cg1\_y'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1819       \textcolor{stringliteral}{'j-\/component of CFL of first baroclinic gravity wave = dt*cg1*/dy'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{1820   cs\%id\_cg\_ebt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'cg\_ebt'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1821       \textcolor{stringliteral}{'Equivalent barotropic gravity wave speed'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{1822   cs\%id\_Rd\_ebt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Rd\_ebt'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1823       \textcolor{stringliteral}{'Equivalent barotropic deformation radius'}, \textcolor{stringliteral}{'m'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{1824   cs\%id\_p\_ebt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'p\_ebt'}, diag\%axesTL, time, \&}
\DoxyCodeLine{1825       \textcolor{stringliteral}{'Equivalent barotropic modal strcuture'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{1826 }
\DoxyCodeLine{1827   \textcolor{keywordflow}{if} ((cs\%id\_cg1>0) .or. (cs\%id\_Rd1>0) .or. (cs\%id\_cfl\_cg1>0) .or. \&}
\DoxyCodeLine{1828       (cs\%id\_cfl\_cg1\_x>0) .or. (cs\%id\_cfl\_cg1\_y>0) .or. \&}
\DoxyCodeLine{1829       (cs\%id\_cg\_ebt>0) .or. (cs\%id\_Rd\_ebt>0) .or. (cs\%id\_p\_ebt>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1830     \textcolor{keyword}{call }wave\_speed\_init(cs\%wave\_speed\_CSp, remap\_answers\_2018=remap\_answers\_2018, \&}
\DoxyCodeLine{1831                          better\_speed\_est=better\_speed\_est, min\_speed=wave\_speed\_min, \&}
\DoxyCodeLine{1832                          wave\_speed\_tol=wave\_speed\_tol)}
\DoxyCodeLine{1833     \textcolor{keyword}{call }wave\_speed\_init(cs\%wave\_speed\_CSp, remap\_answers\_2018=remap\_answers\_2018)}
\DoxyCodeLine{1834     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%cg1,isd,ied,jsd,jed)}
\DoxyCodeLine{1835     \textcolor{keywordflow}{if} (cs\%id\_Rd1>0)       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%Rd1,isd,ied,jsd,jed)}
\DoxyCodeLine{1836     \textcolor{keywordflow}{if} (cs\%id\_Rd\_ebt>0)    \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%Rd1,isd,ied,jsd,jed)}
\DoxyCodeLine{1837     \textcolor{keywordflow}{if} (cs\%id\_cfl\_cg1>0)   \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%cfl\_cg1,isd,ied,jsd,jed)}
\DoxyCodeLine{1838     \textcolor{keywordflow}{if} (cs\%id\_cfl\_cg1\_x>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%cfl\_cg1\_x,isd,ied,jsd,jed)}
\DoxyCodeLine{1839     \textcolor{keywordflow}{if} (cs\%id\_cfl\_cg1\_y>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%cfl\_cg1\_y,isd,ied,jsd,jed)}
\DoxyCodeLine{1840     \textcolor{keywordflow}{if} (cs\%id\_p\_ebt>0) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%p\_ebt,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{1841 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1842 }
\DoxyCodeLine{1843   cs\%id\_mass\_wt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'mass\_wt'}, diag\%axesT1, time,  \&}
\DoxyCodeLine{1844       \textcolor{stringliteral}{'The column mass for calculating mass-\/weighted average properties'}, \textcolor{stringliteral}{'kg m-\/2'}, conversion=us\%RZ\_to\_kg\_m2)}
\DoxyCodeLine{1845 }
\DoxyCodeLine{1846   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1847     cs\%id\_temp\_int = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'temp\_int'}, diag\%axesT1, time,                \&}
\DoxyCodeLine{1848         \textcolor{stringliteral}{'Density weighted column integrated potential temperature'}, \textcolor{stringliteral}{'degC kg m-\/2'}, conversion=us\%RZ\_to\_kg\_m2, \&}
\DoxyCodeLine{1849         cmor\_field\_name=\textcolor{stringliteral}{'opottempmint'},                                                               \&}
\DoxyCodeLine{1850         cmor\_long\_name=\textcolor{stringliteral}{'integral\_wrt\_depth\_of\_product\_of\_sea\_water\_density\_and\_potential\_temperature'},\&}
\DoxyCodeLine{1851         cmor\_standard\_name=\textcolor{stringliteral}{'Depth integrated density times potential temperature'})}
\DoxyCodeLine{1852 }
\DoxyCodeLine{1853     cs\%id\_salt\_int = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'salt\_int'}, diag\%axesT1, time,   \&}
\DoxyCodeLine{1854         \textcolor{stringliteral}{'Density weighted column integrated salinity'}, \textcolor{stringliteral}{'psu kg m-\/2'}, conversion=us\%RZ\_to\_kg\_m2, \&}
\DoxyCodeLine{1855         cmor\_field\_name=\textcolor{stringliteral}{'somint'},                                                        \&}
\DoxyCodeLine{1856         cmor\_long\_name=\textcolor{stringliteral}{'integral\_wrt\_depth\_of\_product\_of\_sea\_water\_density\_and\_salinity'},\&}
\DoxyCodeLine{1857         cmor\_standard\_name=\textcolor{stringliteral}{'Depth integrated density times salinity'})}
\DoxyCodeLine{1858 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1859 }
\DoxyCodeLine{1860   cs\%id\_col\_mass = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'col\_mass'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1861       \textcolor{stringliteral}{'The column integrated in situ density'}, \textcolor{stringliteral}{'kg m-\/2'}, conversion=us\%RZ\_to\_kg\_m2)}
\DoxyCodeLine{1862 }
\DoxyCodeLine{1863   cs\%id\_col\_ht = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'col\_height'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1864       \textcolor{stringliteral}{'The height of the water column'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{1865   cs\%id\_pbo = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'pbo'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1866       long\_name=\textcolor{stringliteral}{'Sea Water Pressure at Sea Floor'}, standard\_name=\textcolor{stringliteral}{'sea\_water\_pressure\_at\_sea\_floor'}, \&}
\DoxyCodeLine{1867       units=\textcolor{stringliteral}{'Pa'}, conversion=us\%RL2\_T2\_to\_Pa)}
\DoxyCodeLine{1868 }
\DoxyCodeLine{1869   \textcolor{keyword}{call }set\_dependent\_diagnostics(mis, adp, cdp, g, cs)}
\DoxyCodeLine{1870 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_ac756556059608d88e6a4ef34a07e60ee}\label{namespacemom__diagnostics_ac756556059608d88e6a4ef34a07e60ee}} 
\index{mom\_diagnostics@{mom\_diagnostics}!post\_surface\_dyn\_diags@{post\_surface\_dyn\_diags}}
\index{post\_surface\_dyn\_diags@{post\_surface\_dyn\_diags}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{post\_surface\_dyn\_diags()}{post\_surface\_dyn\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::post\+\_\+surface\+\_\+dyn\+\_\+diags (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1surface__diag__ids}{surface\+\_\+diag\+\_\+ids}}), intent(in)}]{I\+Ds,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(diag\+\_\+ctrl), intent(in)}]{diag,  }\item[{type(surface), intent(in)}]{sfc\+\_\+state,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{ssh }\end{DoxyParamCaption})}



This routine posts diagnostics of various dynamic ocean surface quantities, including velocities, speed and sea surface height, at the time the ocean state is reported back to the caller. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ids} & A structure with the diagnostic I\+Ds. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & regulates diagnostic output \\
\hline
\mbox{\texttt{ in}}  & {\em sfc\+\_\+state} & structure describing the ocean surface state \\
\hline
\mbox{\texttt{ in}}  & {\em ssh} & Time mean surface height without corrections for ice displacement \mbox{[}m\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1227 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1228   \textcolor{keywordtype}{type}(surface\_diag\_IDs),   \textcolor{keywordtype}{intent(in)} :: IDs\textcolor{comment}{ !< A structure with the diagnostic IDs.}}
\DoxyCodeLine{1229   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< ocean grid structure}}
\DoxyCodeLine{1230   \textcolor{keywordtype}{type}(diag\_ctrl),          \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< regulates diagnostic output}}
\DoxyCodeLine{1231   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(in)} :: sfc\_state\textcolor{comment}{ !< structure describing the ocean surface state}}
\DoxyCodeLine{1232 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{1233                             \textcolor{keywordtype}{intent(in)} :: ssh\textcolor{comment}{ !< Time mean surface height without corrections for ice displacement [m]}}
\DoxyCodeLine{1234 }
\DoxyCodeLine{1235   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1236 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: speed  \textcolor{comment}{! The surface speed [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{1237   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1238 }
\DoxyCodeLine{1239   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1240 }
\DoxyCodeLine{1241   \textcolor{keywordflow}{if} (ids\%id\_ssh > 0) \&}
\DoxyCodeLine{1242     \textcolor{keyword}{call }post\_data(ids\%id\_ssh, ssh, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1243 }
\DoxyCodeLine{1244   \textcolor{keywordflow}{if} (ids\%id\_ssu > 0) \&}
\DoxyCodeLine{1245     \textcolor{keyword}{call }post\_data(ids\%id\_ssu, sfc\_state\%u, diag, mask=g\%mask2dCu)}
\DoxyCodeLine{1246 }
\DoxyCodeLine{1247   \textcolor{keywordflow}{if} (ids\%id\_ssv > 0) \&}
\DoxyCodeLine{1248     \textcolor{keyword}{call }post\_data(ids\%id\_ssv, sfc\_state\%v, diag, mask=g\%mask2dCv)}
\DoxyCodeLine{1249 }
\DoxyCodeLine{1250   \textcolor{keywordflow}{if} (ids\%id\_speed > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1251     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1252       speed(i,j) = sqrt(0.5*(sfc\_state\%u(i-\/1,j)**2 + sfc\_state\%u(i,j)**2) + \&}
\DoxyCodeLine{1253                         0.5*(sfc\_state\%v(i,j-\/1)**2 + sfc\_state\%v(i,j)**2))}
\DoxyCodeLine{1254 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1255     \textcolor{keyword}{call }post\_data(ids\%id\_speed, speed, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1256 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1257 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_a6fc7dbf8144ba279cc9b7856780ba5d6}\label{namespacemom__diagnostics_a6fc7dbf8144ba279cc9b7856780ba5d6}} 
\index{mom\_diagnostics@{mom\_diagnostics}!post\_surface\_thermo\_diags@{post\_surface\_thermo\_diags}}
\index{post\_surface\_thermo\_diags@{post\_surface\_thermo\_diags}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{post\_surface\_thermo\_diags()}{post\_surface\_thermo\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::post\+\_\+surface\+\_\+thermo\+\_\+diags (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1surface__diag__ids}{surface\+\_\+diag\+\_\+ids}}), intent(in)}]{I\+Ds,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(diag\+\_\+ctrl), intent(in)}]{diag,  }\item[{real, intent(in)}]{dt\+\_\+int,  }\item[{type(surface), intent(in)}]{sfc\+\_\+state,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{ssh,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(in)}]{ssh\+\_\+ibc }\end{DoxyParamCaption})}



This routine posts diagnostics of various ocean surface and integrated quantities at the time the ocean state is reported back to the caller. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ids} & A structure with the diagnostic I\+Ds. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & regulates diagnostic output \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+int} & total time step associated with these diagnostics \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em sfc\+\_\+state} & structure describing the ocean surface state \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em ssh} & Time mean surface height without corrections for ice displacement \mbox{[}m\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em ssh\+\_\+ibc} & Time mean surface height with corrections for ice displacement and the inverse barometer \mbox{[}m\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1263 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1265   \textcolor{keywordtype}{type}(surface\_diag\_IDs),   \textcolor{keywordtype}{intent(in)} :: IDs\textcolor{comment}{ !< A structure with the diagnostic IDs.}}
\DoxyCodeLine{1266   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< ocean grid structure}}
\DoxyCodeLine{1267   \textcolor{keywordtype}{type}(verticalGrid\_type),  \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{  !< ocean vertical grid structure}}
\DoxyCodeLine{1268   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1269   \textcolor{keywordtype}{type}(diag\_ctrl),          \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{  !< regulates diagnostic output}}
\DoxyCodeLine{1270 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)} :: dt\_int\textcolor{comment}{ !< total time step associated with these diagnostics [T \string~> s].}}
\DoxyCodeLine{1271   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(in)} :: sfc\_state\textcolor{comment}{ !< structure describing the ocean surface state}}
\DoxyCodeLine{1272   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),    \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{  !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{1273 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{1274                             \textcolor{keywordtype}{intent(in)} :: ssh\textcolor{comment}{ !< Time mean surface height without corrections for ice displacement [m]}}
\DoxyCodeLine{1275 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(in)} :: ssh\_ibc\textcolor{comment}{ !< Time mean surface height with corrections}}
\DoxyCodeLine{1276 \textcolor{comment}{                                                  !! for ice displacement and the inverse barometer [m]}}
\DoxyCodeLine{1277 }
\DoxyCodeLine{1278 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: work\_2d  \textcolor{comment}{! A 2-\/d work array}}
\DoxyCodeLine{1279 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{1280     zos  \textcolor{comment}{! dynamic sea lev (zero area mean) from inverse-\/barometer adjusted ssh [m]}}
\DoxyCodeLine{1281 \textcolor{keywordtype}{  real} :: I\_time\_int    \textcolor{comment}{! The inverse of the time interval [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{1282 \textcolor{keywordtype}{  real} :: zos\_area\_mean, volo, ssh\_ga}
\DoxyCodeLine{1283   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1284 }
\DoxyCodeLine{1285   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1286 }
\DoxyCodeLine{1287   \textcolor{comment}{! area mean SSH}}
\DoxyCodeLine{1288   \textcolor{keywordflow}{if} (ids\%id\_ssh\_ga > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1289     ssh\_ga = global\_area\_mean(ssh, g)}
\DoxyCodeLine{1290     \textcolor{keyword}{call }post\_data(ids\%id\_ssh\_ga, ssh\_ga, diag)}
\DoxyCodeLine{1291 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1292 }
\DoxyCodeLine{1293   \textcolor{comment}{! post the dynamic sea level, zos, and zossq.}}
\DoxyCodeLine{1294   \textcolor{comment}{! zos is ave\_ssh with sea ice inverse barometer removed,}}
\DoxyCodeLine{1295   \textcolor{comment}{! and with zero global area mean.}}
\DoxyCodeLine{1296   \textcolor{keywordflow}{if} (ids\%id\_zos > 0 .or. ids\%id\_zossq > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1297     zos(:,:) = 0.0}
\DoxyCodeLine{1298     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1299       zos(i,j) = ssh\_ibc(i,j)}
\DoxyCodeLine{1300 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1301     zos\_area\_mean = global\_area\_mean(zos, g)}
\DoxyCodeLine{1302     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1303       zos(i,j) = zos(i,j) -\/ g\%mask2dT(i,j)*zos\_area\_mean}
\DoxyCodeLine{1304 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1305     \textcolor{keywordflow}{if} (ids\%id\_zos > 0) \textcolor{keyword}{call }post\_data(ids\%id\_zos, zos, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1306     \textcolor{keywordflow}{if} (ids\%id\_zossq > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1307       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1308         work\_2d(i,j) = zos(i,j)*zos(i,j)}
\DoxyCodeLine{1309 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1310       \textcolor{keyword}{call }post\_data(ids\%id\_zossq, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1311 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1312 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1313 }
\DoxyCodeLine{1314   \textcolor{comment}{! post total volume of the liquid ocean}}
\DoxyCodeLine{1315   \textcolor{keywordflow}{if} (ids\%id\_volo > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1316     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1317       work\_2d(i,j) = g\%mask2dT(i,j)*(ssh(i,j) + us\%Z\_to\_m*g\%bathyT(i,j))}
\DoxyCodeLine{1318 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1319     volo = global\_area\_integral(work\_2d, g)}
\DoxyCodeLine{1320     \textcolor{keyword}{call }post\_data(ids\%id\_volo, volo, diag)}
\DoxyCodeLine{1321 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1322 }
\DoxyCodeLine{1323   \textcolor{comment}{! Use Adcroft's rule of reciprocals; it does the right thing here.}}
\DoxyCodeLine{1324   i\_time\_int = 0.0 ; \textcolor{keywordflow}{if} (dt\_int > 0.0) i\_time\_int = 1.0 / dt\_int}
\DoxyCodeLine{1325 }
\DoxyCodeLine{1326   \textcolor{comment}{! post time-\/averaged rate of frazil formation}}
\DoxyCodeLine{1327   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%frazil) .and. (ids\%id\_fraz > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1328     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1329       work\_2d(i,j) = tv\%frazil(i,j) * i\_time\_int}
\DoxyCodeLine{1330 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1331     \textcolor{keyword}{call }post\_data(ids\%id\_fraz, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1332 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1333 }
\DoxyCodeLine{1334   \textcolor{comment}{! post time-\/averaged salt deficit}}
\DoxyCodeLine{1335   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%salt\_deficit) .and. (ids\%id\_salt\_deficit > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1336     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1337       work\_2d(i,j) = tv\%salt\_deficit(i,j) * i\_time\_int}
\DoxyCodeLine{1338 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1339     \textcolor{keyword}{call }post\_data(ids\%id\_salt\_deficit, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1340 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1341 }
\DoxyCodeLine{1342   \textcolor{comment}{! post temperature of P-\/E+R}}
\DoxyCodeLine{1343   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%TempxPmE) .and. (ids\%id\_Heat\_PmE > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1344     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1345       work\_2d(i,j) = tv\%TempxPmE(i,j) * (tv\%C\_p * i\_time\_int)}
\DoxyCodeLine{1346 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1347     \textcolor{keyword}{call }post\_data(ids\%id\_Heat\_PmE, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1348 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1349 }
\DoxyCodeLine{1350   \textcolor{comment}{! post geothermal heating or internal heat source/sinks}}
\DoxyCodeLine{1351   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%internal\_heat) .and. (ids\%id\_intern\_heat > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1352     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1353       work\_2d(i,j) = tv\%internal\_heat(i,j) * (tv\%C\_p * i\_time\_int)}
\DoxyCodeLine{1354 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1355     \textcolor{keyword}{call }post\_data(ids\%id\_intern\_heat, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1356 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1357 }
\DoxyCodeLine{1358   \textcolor{keywordflow}{if} (tv\%T\_is\_conT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1359     \textcolor{comment}{! Internal T\&S variables are conservative temperature \& absolute salinity}}
\DoxyCodeLine{1360     \textcolor{keywordflow}{if} (ids\%id\_sstcon > 0) \textcolor{keyword}{call }post\_data(ids\%id\_sstcon, sfc\_state\%SST, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1361     \textcolor{comment}{! Use TEOS-\/10 function calls convert T\&S diagnostics from conservative temp}}
\DoxyCodeLine{1362     \textcolor{comment}{! to potential temperature.}}
\DoxyCodeLine{1363     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1364       work\_2d(i,j) = gsw\_pt\_from\_ct(sfc\_state\%SSS(i,j), sfc\_state\%SST(i,j))}
\DoxyCodeLine{1365 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1366     \textcolor{keywordflow}{if} (ids\%id\_sst > 0) \textcolor{keyword}{call }post\_data(ids\%id\_sst, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1367   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1368     \textcolor{comment}{! Internal T\&S variables are potential temperature \& practical salinity}}
\DoxyCodeLine{1369     \textcolor{keywordflow}{if} (ids\%id\_sst > 0) \textcolor{keyword}{call }post\_data(ids\%id\_sst, sfc\_state\%SST, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1370 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1371 }
\DoxyCodeLine{1372   \textcolor{keywordflow}{if} (tv\%S\_is\_absS) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1373     \textcolor{comment}{! Internal T\&S variables are conservative temperature \& absolute salinity}}
\DoxyCodeLine{1374     \textcolor{keywordflow}{if} (ids\%id\_sssabs > 0) \textcolor{keyword}{call }post\_data(ids\%id\_sssabs, sfc\_state\%SSS, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1375     \textcolor{comment}{! Use TEOS-\/10 function calls convert T\&S diagnostics from absolute salinity}}
\DoxyCodeLine{1376     \textcolor{comment}{! to practical salinity.}}
\DoxyCodeLine{1377     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1378       work\_2d(i,j) = gsw\_sp\_from\_sr(sfc\_state\%SSS(i,j))}
\DoxyCodeLine{1379 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1380     \textcolor{keywordflow}{if} (ids\%id\_sss > 0) \textcolor{keyword}{call }post\_data(ids\%id\_sss, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1381   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1382     \textcolor{comment}{! Internal T\&S variables are potential temperature \& practical salinity}}
\DoxyCodeLine{1383     \textcolor{keywordflow}{if} (ids\%id\_sss > 0) \textcolor{keyword}{call }post\_data(ids\%id\_sss, sfc\_state\%SSS, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1384 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1385 }
\DoxyCodeLine{1386   \textcolor{keywordflow}{if} (ids\%id\_sst\_sq > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1387     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1388       work\_2d(i,j) = sfc\_state\%SST(i,j)*sfc\_state\%SST(i,j)}
\DoxyCodeLine{1389 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1390     \textcolor{keyword}{call }post\_data(ids\%id\_sst\_sq, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1391 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1392   \textcolor{keywordflow}{if} (ids\%id\_sss\_sq > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1393     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1394       work\_2d(i,j) = sfc\_state\%SSS(i,j)*sfc\_state\%SSS(i,j)}
\DoxyCodeLine{1395 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1396     \textcolor{keyword}{call }post\_data(ids\%id\_sss\_sq, work\_2d, diag, mask=g\%mask2dT)}
\DoxyCodeLine{1397 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1398 }
\DoxyCodeLine{1399   \textcolor{keyword}{call }coupler\_type\_send\_data(sfc\_state\%tr\_fields, get\_diag\_time\_end(diag))}
\DoxyCodeLine{1400 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_acab7430159d4702301069d0d4f82f45c}\label{namespacemom__diagnostics_acab7430159d4702301069d0d4f82f45c}} 
\index{mom\_diagnostics@{mom\_diagnostics}!post\_transport\_diagnostics@{post\_transport\_diagnostics}}
\index{post\_transport\_diagnostics@{post\_transport\_diagnostics}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{post\_transport\_diagnostics()}{post\_transport\_diagnostics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::post\+\_\+transport\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{uhtr,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, g \%ke), intent(in)}]{vhtr,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1transport__diag__ids}{transport\+\_\+diag\+\_\+ids}}), intent(in)}]{I\+Ds,  }\item[{type(diag\+\_\+grid\+\_\+storage), intent(inout)}]{diag\+\_\+pre\+\_\+dyn,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag,  }\item[{real, intent(in)}]{dt\+\_\+trans,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{Reg }\end{DoxyParamCaption})}



This routine posts diagnostics of the transports, including the subgridscale contributions. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em uhtr} & Accumulated zonal thickness fluxes used to advect tracers \mbox{[}H L2 $\sim$$>$ m3 or kg\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em vhtr} & Accumulated meridional thickness fluxes used to advect tracers \mbox{[}H L2 $\sim$$>$ m3 or kg\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h} & The updated layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em ids} & A structure with the diagnostic I\+Ds. \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag\+\_\+pre\+\_\+dyn} & Stored grids from before dynamics \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & regulates diagnostic output \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+trans} & total time step associated with the transports \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
 & {\em reg} & Pointer to the tracer registry \\
\hline
\end{DoxyParams}


Definition at line 1406 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1408   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< ocean grid structure}}
\DoxyCodeLine{1409   \textcolor{keywordtype}{type}(verticalGrid\_type),  \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< ocean vertical grid structure}}
\DoxyCodeLine{1410   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1411 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: uhtr\textcolor{comment}{ !< Accumulated zonal thickness fluxes}}
\DoxyCodeLine{1412 \textcolor{comment}{                                                 !! used to advect tracers [H L2 \string~> m3 or kg]}}
\DoxyCodeLine{1413 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: vhtr\textcolor{comment}{ !< Accumulated meridional thickness fluxes}}
\DoxyCodeLine{1414 \textcolor{comment}{                                                 !! used to advect tracers [H L2 \string~> m3 or kg]}}
\DoxyCodeLine{1415 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \&}
\DoxyCodeLine{1416                             \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{   !< The updated layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1417   \textcolor{keywordtype}{type}(transport\_diag\_IDs), \textcolor{keywordtype}{intent(in)}    :: IDs\textcolor{comment}{ !< A structure with the diagnostic IDs.}}
\DoxyCodeLine{1418   \textcolor{keywordtype}{type}(diag\_grid\_storage),  \textcolor{keywordtype}{intent(inout)} :: diag\_pre\_dyn\textcolor{comment}{ !< Stored grids from before dynamics}}
\DoxyCodeLine{1419   \textcolor{keywordtype}{type}(diag\_ctrl),          \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< regulates diagnostic output}}
\DoxyCodeLine{1420 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: dt\_trans\textcolor{comment}{ !< total time step associated with the transports [T \string~> s].}}
\DoxyCodeLine{1421   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}     :: Reg\textcolor{comment}{ !< Pointer to the tracer registry}}
\DoxyCodeLine{1422 }
\DoxyCodeLine{1423   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1424 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G), SZJ\_(G))} :: umo2d \textcolor{comment}{! Diagnostics of integrated mass transport [R Z L2 T-\/1 \string~> kg s-\/1]}}
\DoxyCodeLine{1425 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJB\_(G))} :: vmo2d \textcolor{comment}{! Diagnostics of integrated mass transport [R Z L2 T-\/1 \string~> kg s-\/1]}}
\DoxyCodeLine{1426 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G), SZJ\_(G), SZK\_(G))} :: umo \textcolor{comment}{! Diagnostics of layer mass transport [R Z L2 T-\/1 \string~> kg s-\/1]}}
\DoxyCodeLine{1427 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJB\_(G), SZK\_(G))} :: vmo \textcolor{comment}{! Diagnostics of layer mass transport [R Z L2 T-\/1 \string~> kg s-\/1]}}
\DoxyCodeLine{1428 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}    :: h\_tend \textcolor{comment}{! Change in layer thickness due to dynamics}}
\DoxyCodeLine{1429                           \textcolor{comment}{! [H s-\/1 \string~> m s-\/1 or kg m-\/2 s-\/1].}}
\DoxyCodeLine{1430 \textcolor{keywordtype}{  real} :: Idt             \textcolor{comment}{! The inverse of the time interval [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{1431 \textcolor{keywordtype}{  real} :: H\_to\_RZ\_dt   \textcolor{comment}{! A conversion factor from accumulated transports to fluxes}}
\DoxyCodeLine{1432                           \textcolor{comment}{! [R Z H-\/1 T-\/1 \string~> kg m-\/3 s-\/1 or s-\/1].}}
\DoxyCodeLine{1433   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{1434   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{1435 }
\DoxyCodeLine{1436   idt = 1. / dt\_trans}
\DoxyCodeLine{1437   h\_to\_rz\_dt = gv\%H\_to\_RZ * idt}
\DoxyCodeLine{1438 }
\DoxyCodeLine{1439   \textcolor{keyword}{call }diag\_save\_grids(diag)}
\DoxyCodeLine{1440   \textcolor{keyword}{call }diag\_copy\_storage\_to\_diag(diag, diag\_pre\_dyn)}
\DoxyCodeLine{1441 }
\DoxyCodeLine{1442   \textcolor{keywordflow}{if} (ids\%id\_umo\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1443     umo2d(:,:) = 0.0}
\DoxyCodeLine{1444     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-\/1,ie}
\DoxyCodeLine{1445       umo2d(i,j) = umo2d(i,j) + uhtr(i,j,k) * h\_to\_rz\_dt}
\DoxyCodeLine{1446 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1447     \textcolor{keyword}{call }post\_data(ids\%id\_umo\_2d, umo2d, diag)}
\DoxyCodeLine{1448 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1449   \textcolor{keywordflow}{if} (ids\%id\_umo > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1450     \textcolor{comment}{! Convert to kg/s.}}
\DoxyCodeLine{1451     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-\/1,ie}
\DoxyCodeLine{1452       umo(i,j,k) = uhtr(i,j,k) * h\_to\_rz\_dt}
\DoxyCodeLine{1453 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1454     \textcolor{keyword}{call }post\_data(ids\%id\_umo, umo, diag, alt\_h = diag\_pre\_dyn\%h\_state)}
\DoxyCodeLine{1455 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1456   \textcolor{keywordflow}{if} (ids\%id\_vmo\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1457     vmo2d(:,:) = 0.0}
\DoxyCodeLine{1458     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-\/1,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1459       vmo2d(i,j) = vmo2d(i,j) + vhtr(i,j,k) * h\_to\_rz\_dt}
\DoxyCodeLine{1460 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1461     \textcolor{keyword}{call }post\_data(ids\%id\_vmo\_2d, vmo2d, diag)}
\DoxyCodeLine{1462 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1463   \textcolor{keywordflow}{if} (ids\%id\_vmo > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1464     \textcolor{comment}{! Convert to kg/s.}}
\DoxyCodeLine{1465     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js-\/1,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1466       vmo(i,j,k) = vhtr(i,j,k) * h\_to\_rz\_dt}
\DoxyCodeLine{1467 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1468     \textcolor{keyword}{call }post\_data(ids\%id\_vmo, vmo, diag, alt\_h = diag\_pre\_dyn\%h\_state)}
\DoxyCodeLine{1469 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1470 }
\DoxyCodeLine{1471   \textcolor{keywordflow}{if} (ids\%id\_uhtr > 0) \textcolor{keyword}{call }post\_data(ids\%id\_uhtr, uhtr, diag, alt\_h = diag\_pre\_dyn\%h\_state)}
\DoxyCodeLine{1472   \textcolor{keywordflow}{if} (ids\%id\_vhtr > 0) \textcolor{keyword}{call }post\_data(ids\%id\_vhtr, vhtr, diag, alt\_h = diag\_pre\_dyn\%h\_state)}
\DoxyCodeLine{1473   \textcolor{keywordflow}{if} (ids\%id\_dynamics\_h > 0) \textcolor{keyword}{call }post\_data(ids\%id\_dynamics\_h, diag\_pre\_dyn\%h\_state, diag, \&}
\DoxyCodeLine{1474                                             alt\_h = diag\_pre\_dyn\%h\_state)}
\DoxyCodeLine{1475   \textcolor{comment}{! Post the change in thicknesses}}
\DoxyCodeLine{1476   \textcolor{keywordflow}{if} (ids\%id\_dynamics\_h\_tendency > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1477     h\_tend(:,:,:) = 0.}
\DoxyCodeLine{1478     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1479       h\_tend(i,j,k) = (h(i,j,k) -\/ diag\_pre\_dyn\%h\_state(i,j,k))*idt}
\DoxyCodeLine{1480 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1481     \textcolor{keyword}{call }post\_data(ids\%id\_dynamics\_h\_tendency, h\_tend, diag, alt\_h = diag\_pre\_dyn\%h\_state)}
\DoxyCodeLine{1482 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1483 }
\DoxyCodeLine{1484   \textcolor{keyword}{call }post\_tracer\_transport\_diagnostics(g, gv, reg, diag\_pre\_dyn\%h\_state, diag)}
\DoxyCodeLine{1485 }
\DoxyCodeLine{1486   \textcolor{keyword}{call }diag\_restore\_grids(diag)}
\DoxyCodeLine{1487 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_ae9e2f6374b60bc78898a3c462174f90d}\label{namespacemom__diagnostics_ae9e2f6374b60bc78898a3c462174f90d}} 
\index{mom\_diagnostics@{mom\_diagnostics}!register\_surface\_diags@{register\_surface\_diags}}
\index{register\_surface\_diags@{register\_surface\_diags}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{register\_surface\_diags()}{register\_surface\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::register\+\_\+surface\+\_\+diags (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1surface__diag__ids}{surface\+\_\+diag\+\_\+ids}}), intent(inout)}]{I\+Ds,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv }\end{DoxyParamCaption})}



Register diagnostics of the surface state and integrated quantities. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & current model time \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em ids} & A structure with the diagnostic I\+Ds. \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & regulates diagnostic output \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\end{DoxyParams}


Definition at line 1875 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1876   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{  !< current model time}}
\DoxyCodeLine{1877   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{     !< ocean grid structure}}
\DoxyCodeLine{1878   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1879   \textcolor{keywordtype}{type}(surface\_diag\_IDs),  \textcolor{keywordtype}{intent(inout)} :: IDs\textcolor{comment}{   !< A structure with the diagnostic IDs.}}
\DoxyCodeLine{1880   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{  !< regulates diagnostic output}}
\DoxyCodeLine{1881   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{    !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{1882 }
\DoxyCodeLine{1883   \textcolor{comment}{! Vertically integrated, budget, and surface state diagnostics}}
\DoxyCodeLine{1884   ids\%id\_volo = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'volo'}, time, diag,\&}
\DoxyCodeLine{1885       long\_name=\textcolor{stringliteral}{'Total volume of liquid ocean'}, units=\textcolor{stringliteral}{'m3'},            \&}
\DoxyCodeLine{1886       standard\_name=\textcolor{stringliteral}{'sea\_water\_volume'})}
\DoxyCodeLine{1887   ids\%id\_zos = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'zos'}, diag\%axesT1, time,\&}
\DoxyCodeLine{1888       standard\_name = \textcolor{stringliteral}{'sea\_surface\_height\_above\_geoid'},                   \&}
\DoxyCodeLine{1889       long\_name= \textcolor{stringliteral}{'Sea surface height above geoid'}, units=\textcolor{stringliteral}{'m'})}
\DoxyCodeLine{1890   ids\%id\_zossq = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'zossq'}, diag\%axesT1, time,\&}
\DoxyCodeLine{1891       standard\_name=\textcolor{stringliteral}{'square\_of\_sea\_surface\_height\_above\_geoid'},             \&}
\DoxyCodeLine{1892       long\_name=\textcolor{stringliteral}{'Square of sea surface height above geoid'}, units=\textcolor{stringliteral}{'m2'})}
\DoxyCodeLine{1893   ids\%id\_ssh = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SSH'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1894       \textcolor{stringliteral}{'Sea Surface Height'}, \textcolor{stringliteral}{'m'})}
\DoxyCodeLine{1895   ids\%id\_ssh\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ssh\_ga'}, time, diag,\&}
\DoxyCodeLine{1896       long\_name=\textcolor{stringliteral}{'Area averaged sea surface height'}, units=\textcolor{stringliteral}{'m'},            \&}
\DoxyCodeLine{1897       standard\_name=\textcolor{stringliteral}{'area\_averaged\_sea\_surface\_height'})}
\DoxyCodeLine{1898   ids\%id\_ssu = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SSU'}, diag\%axesCu1, time, \&}
\DoxyCodeLine{1899       \textcolor{stringliteral}{'Sea Surface Zonal Velocity'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{1900   ids\%id\_ssv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SSV'}, diag\%axesCv1, time, \&}
\DoxyCodeLine{1901       \textcolor{stringliteral}{'Sea Surface Meridional Velocity'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{1902   ids\%id\_speed = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'speed'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1903       \textcolor{stringliteral}{'Sea Surface Speed'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{1904 }
\DoxyCodeLine{1905   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%T)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1906     ids\%id\_sst = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SST'}, diag\%axesT1, time,     \&}
\DoxyCodeLine{1907         \textcolor{stringliteral}{'Sea Surface Temperature'}, \textcolor{stringliteral}{'degC'}, cmor\_field\_name=\textcolor{stringliteral}{'tos'}, \&}
\DoxyCodeLine{1908         cmor\_long\_name=\textcolor{stringliteral}{'Sea Surface Temperature'},                                \&}
\DoxyCodeLine{1909         cmor\_standard\_name=\textcolor{stringliteral}{'sea\_surface\_temperature'})}
\DoxyCodeLine{1910     ids\%id\_sst\_sq = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SST\_sq'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1911         \textcolor{stringliteral}{'Sea Surface Temperature Squared'}, \textcolor{stringliteral}{'degC2'}, cmor\_field\_name=\textcolor{stringliteral}{'tossq'}, \&}
\DoxyCodeLine{1912         cmor\_long\_name=\textcolor{stringliteral}{'Square of Sea Surface Temperature '},                      \&}
\DoxyCodeLine{1913         cmor\_standard\_name=\textcolor{stringliteral}{'square\_of\_sea\_surface\_temperature'})}
\DoxyCodeLine{1914     ids\%id\_sss = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SSS'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1915         \textcolor{stringliteral}{'Sea Surface Salinity'}, \textcolor{stringliteral}{'psu'}, cmor\_field\_name=\textcolor{stringliteral}{'sos'}, \&}
\DoxyCodeLine{1916         cmor\_long\_name=\textcolor{stringliteral}{'Sea Surface Salinity'},                            \&}
\DoxyCodeLine{1917         cmor\_standard\_name=\textcolor{stringliteral}{'sea\_surface\_salinity'})}
\DoxyCodeLine{1918     ids\%id\_sss\_sq = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SSS\_sq'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1919         \textcolor{stringliteral}{'Sea Surface Salinity Squared'}, \textcolor{stringliteral}{'psu'}, cmor\_field\_name=\textcolor{stringliteral}{'sossq'}, \&}
\DoxyCodeLine{1920         cmor\_long\_name=\textcolor{stringliteral}{'Square of Sea Surface Salinity '},                     \&}
\DoxyCodeLine{1921         cmor\_standard\_name=\textcolor{stringliteral}{'square\_of\_sea\_surface\_salinity'})}
\DoxyCodeLine{1922     \textcolor{keywordflow}{if} (tv\%T\_is\_conT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1923       ids\%id\_sstcon = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'conSST'}, diag\%axesT1, time,     \&}
\DoxyCodeLine{1924           \textcolor{stringliteral}{'Sea Surface Conservative Temperature'}, \textcolor{stringliteral}{'Celsius'})}
\DoxyCodeLine{1925 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1926     \textcolor{keywordflow}{if} (tv\%S\_is\_absS) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1927       ids\%id\_sssabs = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'absSSS'}, diag\%axesT1, time,     \&}
\DoxyCodeLine{1928           \textcolor{stringliteral}{'Sea Surface Absolute Salinity'}, \textcolor{stringliteral}{'g kg-\/1'})}
\DoxyCodeLine{1929 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1930     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%frazil)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1931       ids\%id\_fraz = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'frazil'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1932             \textcolor{stringliteral}{'Heat from frazil formation'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%QRZ\_T\_to\_W\_m2, \&}
\DoxyCodeLine{1933             cmor\_field\_name=\textcolor{stringliteral}{'hfsifrazil'}, \&}
\DoxyCodeLine{1934             cmor\_standard\_name=\textcolor{stringliteral}{'heat\_flux\_into\_sea\_water\_due\_to\_frazil\_ice\_formation'}, \&}
\DoxyCodeLine{1935             cmor\_long\_name=\textcolor{stringliteral}{'Heat Flux into Sea Water due to Frazil Ice Formation'})}
\DoxyCodeLine{1936 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1937 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1938 }
\DoxyCodeLine{1939   ids\%id\_salt\_deficit = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'salt\_deficit'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1940          \textcolor{stringliteral}{'Salt sink in ocean due to ice flux'}, \&}
\DoxyCodeLine{1941          \textcolor{stringliteral}{'psu m-\/2 s-\/1'}, conversion=us\%RZ\_T\_to\_kg\_m2s)}
\DoxyCodeLine{1942   ids\%id\_Heat\_PmE = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Heat\_PmE'}, diag\%axesT1, time, \&}
\DoxyCodeLine{1943          \textcolor{stringliteral}{'Heat flux into ocean from mass flux into ocean'}, \&}
\DoxyCodeLine{1944          \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%QRZ\_T\_to\_W\_m2)}
\DoxyCodeLine{1945   ids\%id\_intern\_heat = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'internal\_heat'}, diag\%axesT1, time,\&}
\DoxyCodeLine{1946          \textcolor{stringliteral}{'Heat flux into ocean from geothermal or other internal sources'}, \&}
\DoxyCodeLine{1947          \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%QRZ\_T\_to\_W\_m2)}
\DoxyCodeLine{1948 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_addfe6cd212e836194ccaf737bcc5cce8}\label{namespacemom__diagnostics_addfe6cd212e836194ccaf737bcc5cce8}} 
\index{mom\_diagnostics@{mom\_diagnostics}!register\_time\_deriv@{register\_time\_deriv}}
\index{register\_time\_deriv@{register\_time\_deriv}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{register\_time\_deriv()}{register\_time\_deriv()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::register\+\_\+time\+\_\+deriv (\begin{DoxyParamCaption}\item[{integer, dimension(3), intent(in)}]{lb,  }\item[{real, dimension(lb(1)\+:,lb(2)\+:,\+:), target}]{f\+\_\+ptr,  }\item[{real, dimension(lb(1)\+:,lb(2)\+:,\+:), target}]{deriv\+\_\+ptr,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine registers fields to calculate a diagnostic time derivative. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em lb} & Lower index bound of f\+\_\+ptr \\
\hline
 & {\em f\+\_\+ptr} & Time derivative operand \\
\hline
 & {\em deriv\+\_\+ptr} & Time derivative of f\+\_\+ptr \\
\hline
 & {\em cs} & Control structure returned by previous call to diagnostics\+\_\+init. \\
\hline
\end{DoxyParams}


Definition at line 1154 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1155   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{dimension(3)} :: lb\textcolor{comment}{     !< Lower index bound of f\_ptr}}
\DoxyCodeLine{1156 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(lb(1):,lb(2):,:)}, \textcolor{keywordtype}{target} :: f\_ptr}
\DoxyCodeLine{1157                                               \textcolor{comment}{!< Time derivative operand}}
\DoxyCodeLine{1158 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(lb(1):,lb(2):,:)}, \textcolor{keywordtype}{target} :: deriv\_ptr}
\DoxyCodeLine{1159                                               \textcolor{comment}{!< Time derivative of f\_ptr}}
\DoxyCodeLine{1160   \textcolor{keywordtype}{type}(diagnostics\_CS),  \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{        !< Control structure returned by previous call to}}
\DoxyCodeLine{1161 \textcolor{comment}{                                              !! diagnostics\_init.}}
\DoxyCodeLine{1162 }
\DoxyCodeLine{1163   \textcolor{comment}{! This subroutine registers fields to calculate a diagnostic time derivative.}}
\DoxyCodeLine{1164   \textcolor{comment}{! NOTE: Lower bound is required for grid indexing in calculate\_derivs().}}
\DoxyCodeLine{1165   \textcolor{comment}{!       We assume that the vertical axis is 1-\/indexed.}}
\DoxyCodeLine{1166 }
\DoxyCodeLine{1167   \textcolor{keywordtype}{integer} :: m\textcolor{comment}{      !< New index of deriv\_ptr in CS\%deriv}}
\DoxyCodeLine{1168   \textcolor{keywordtype}{integer} :: ub(3)\textcolor{comment}{  !< Upper index bound of f\_ptr, based on shape.}}
\DoxyCodeLine{1169 }
\DoxyCodeLine{1170   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{1171          \textcolor{stringliteral}{"register\_time\_deriv: Module must be initialized before it is used."})}
\DoxyCodeLine{1172 }
\DoxyCodeLine{1173   \textcolor{keywordflow}{if} (cs\%num\_time\_deriv >= max\_fields\_) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1174     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"MOM\_diagnostics:  Attempted to register more than "} // \&}
\DoxyCodeLine{1175                    \textcolor{stringliteral}{"MAX\_FIELDS\_ diagnostic time derivatives via register\_time\_deriv."})}
\DoxyCodeLine{1176     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1177 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1178 }
\DoxyCodeLine{1179   m = cs\%num\_time\_deriv+1 ; cs\%num\_time\_deriv = m}
\DoxyCodeLine{1180 }
\DoxyCodeLine{1181   ub(:) = lb(:) + shape(f\_ptr) -\/ 1}
\DoxyCodeLine{1182 }
\DoxyCodeLine{1183   cs\%nlay(m) = \textcolor{keyword}{size}(f\_ptr, 3)}
\DoxyCodeLine{1184   cs\%deriv(m)\%p => deriv\_ptr}
\DoxyCodeLine{1185   \textcolor{keyword}{allocate}(cs\%prev\_val(m)\%p(lb(1):ub(1), lb(2):ub(2), cs\%nlay(m)))}
\DoxyCodeLine{1186 }
\DoxyCodeLine{1187   cs\%var\_ptr(m)\%p => f\_ptr}
\DoxyCodeLine{1188   cs\%prev\_val(m)\%p(:,:,:) = f\_ptr(:,:,:)}
\DoxyCodeLine{1189 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_ac16b7c49e4a4b5ea2beb426bc5270ee9}\label{namespacemom__diagnostics_ac16b7c49e4a4b5ea2beb426bc5270ee9}} 
\index{mom\_diagnostics@{mom\_diagnostics}!register\_transport\_diags@{register\_transport\_diags}}
\index{register\_transport\_diags@{register\_transport\_diags}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{register\_transport\_diags()}{register\_transport\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::register\+\_\+transport\+\_\+diags (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1transport__diag__ids}{transport\+\_\+diag\+\_\+ids}}), intent(inout)}]{I\+Ds,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag }\end{DoxyParamCaption})}



Register certain diagnostics related to transports. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & current model time \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em ids} & A structure with the diagnostic I\+Ds. \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & regulates diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 1952 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1953   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{  !< current model time}}
\DoxyCodeLine{1954   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{     !< ocean grid structure}}
\DoxyCodeLine{1955   \textcolor{keywordtype}{type}(verticalGrid\_type),  \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{    !< ocean vertical grid structure}}
\DoxyCodeLine{1956   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1957   \textcolor{keywordtype}{type}(transport\_diag\_IDs), \textcolor{keywordtype}{intent(inout)} :: IDs\textcolor{comment}{   !< A structure with the diagnostic IDs.}}
\DoxyCodeLine{1958   \textcolor{keywordtype}{type}(diag\_ctrl),          \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{  !< regulates diagnostic output}}
\DoxyCodeLine{1959 }
\DoxyCodeLine{1960 \textcolor{keywordtype}{  real} :: H\_convert}
\DoxyCodeLine{1961   \textcolor{keywordtype}{character(len=48)} :: thickness\_units}
\DoxyCodeLine{1962 }
\DoxyCodeLine{1963   thickness\_units = get\_thickness\_units(gv)}
\DoxyCodeLine{1964   \textcolor{keywordflow}{if} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1965     h\_convert = gv\%H\_to\_m}
\DoxyCodeLine{1966   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1967     h\_convert = gv\%H\_to\_kg\_m2}
\DoxyCodeLine{1968 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1969 }
\DoxyCodeLine{1970   \textcolor{comment}{! Diagnostics related to tracer and mass transport}}
\DoxyCodeLine{1971   ids\%id\_uhtr = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'uhtr'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{1972       \textcolor{stringliteral}{'Accumulated zonal thickness fluxes to advect tracers'}, \textcolor{stringliteral}{'kg'}, \&}
\DoxyCodeLine{1973       y\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., conversion=h\_convert*us\%L\_to\_m**2)}
\DoxyCodeLine{1974   ids\%id\_vhtr = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vhtr'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{1975       \textcolor{stringliteral}{'Accumulated meridional thickness fluxes to advect tracers'}, \textcolor{stringliteral}{'kg'}, \&}
\DoxyCodeLine{1976       x\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true., conversion=h\_convert*us\%L\_to\_m**2)}
\DoxyCodeLine{1977   ids\%id\_umo = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'umo'}, \&}
\DoxyCodeLine{1978       diag\%axesCuL, time, \textcolor{stringliteral}{'Ocean Mass X Transport'}, \&}
\DoxyCodeLine{1979       \textcolor{stringliteral}{'kg s-\/1'}, conversion=us\%RZ\_T\_to\_kg\_m2s*us\%L\_to\_m**2, \&}
\DoxyCodeLine{1980       standard\_name=\textcolor{stringliteral}{'ocean\_mass\_x\_transport'}, y\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true.)}
\DoxyCodeLine{1981   ids\%id\_vmo = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vmo'}, \&}
\DoxyCodeLine{1982       diag\%axesCvL, time, \textcolor{stringliteral}{'Ocean Mass Y Transport'}, \&}
\DoxyCodeLine{1983       \textcolor{stringliteral}{'kg s-\/1'}, conversion=us\%RZ\_T\_to\_kg\_m2s*us\%L\_to\_m**2, \&}
\DoxyCodeLine{1984       standard\_name=\textcolor{stringliteral}{'ocean\_mass\_y\_transport'}, x\_cell\_method=\textcolor{stringliteral}{'sum'}, v\_extensive=.true.)}
\DoxyCodeLine{1985   ids\%id\_umo\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'umo\_2d'}, \&}
\DoxyCodeLine{1986       diag\%axesCu1, time, \textcolor{stringliteral}{'Ocean Mass X Transport Vertical Sum'}, \&}
\DoxyCodeLine{1987       \textcolor{stringliteral}{'kg s-\/1'}, conversion=us\%RZ\_T\_to\_kg\_m2s*us\%L\_to\_m**2, \&}
\DoxyCodeLine{1988       standard\_name=\textcolor{stringliteral}{'ocean\_mass\_x\_transport\_vertical\_sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'})}
\DoxyCodeLine{1989   ids\%id\_vmo\_2d = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vmo\_2d'}, \&}
\DoxyCodeLine{1990       diag\%axesCv1, time, \textcolor{stringliteral}{'Ocean Mass Y Transport Vertical Sum'}, \&}
\DoxyCodeLine{1991       \textcolor{stringliteral}{'kg s-\/1'}, conversion=us\%RZ\_T\_to\_kg\_m2s*us\%L\_to\_m**2, \&}
\DoxyCodeLine{1992       standard\_name=\textcolor{stringliteral}{'ocean\_mass\_y\_transport\_vertical\_sum'}, x\_cell\_method=\textcolor{stringliteral}{'sum'})}
\DoxyCodeLine{1993   ids\%id\_dynamics\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'dynamics\_h'},  \&}
\DoxyCodeLine{1994       diag\%axesTl, time, \textcolor{stringliteral}{'Change in layer thicknesses due to horizontal dynamics'}, \&}
\DoxyCodeLine{1995       \textcolor{stringliteral}{'m s-\/1'}, v\_extensive=.true., conversion=gv\%H\_to\_m)}
\DoxyCodeLine{1996   ids\%id\_dynamics\_h\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'dynamics\_h\_tendency'},  \&}
\DoxyCodeLine{1997       diag\%axesTl, time, \textcolor{stringliteral}{'Change in layer thicknesses due to horizontal dynamics'}, \&}
\DoxyCodeLine{1998       \textcolor{stringliteral}{'m s-\/1'}, v\_extensive=.true., conversion=gv\%H\_to\_m*us\%s\_to\_T)}
\DoxyCodeLine{1999 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_a90a92410576d955e89d2aa4e3f6d7402}\label{namespacemom__diagnostics_a90a92410576d955e89d2aa4e3f6d7402}} 
\index{mom\_diagnostics@{mom\_diagnostics}!set\_dependent\_diagnostics@{set\_dependent\_diagnostics}}
\index{set\_dependent\_diagnostics@{set\_dependent\_diagnostics}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{set\_dependent\_diagnostics()}{set\_dependent\_diagnostics()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diagnostics\+::set\+\_\+dependent\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+internal\+\_\+state), intent(in)}]{M\+IS,  }\item[{type(accel\+\_\+diag\+\_\+ptrs), intent(inout)}]{A\+Dp,  }\item[{type(cont\+\_\+diag\+\_\+ptrs), intent(inout)}]{C\+Dp,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diagnostics_1_1diagnostics__cs}{diagnostics\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine sets up diagnostics upon which other diagnostics depend. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em mis} & For \char`\"{}\+M\+O\+M Internal State\char`\"{} a set of pointers to the fields and accelerations making up ocean internal physical state. \\
\hline
\mbox{\texttt{ in,out}}  & {\em adp} & Structure pointing to accelerations in momentum equation. \\
\hline
\mbox{\texttt{ in,out}}  & {\em cdp} & Structure pointing to terms in continuity equation. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
 & {\em cs} & Pointer to the control structure for this module. \\
\hline
\end{DoxyParams}


Definition at line 2177 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2178   \textcolor{keywordtype}{type}(ocean\_internal\_state), \textcolor{keywordtype}{intent(in)}    :: MIS\textcolor{comment}{ !< For "MOM Internal State" a set of pointers to}}
\DoxyCodeLine{2179 \textcolor{comment}{                                                   !! the fields and accelerations making up ocean}}
\DoxyCodeLine{2180 \textcolor{comment}{                                                   !! internal physical state.}}
\DoxyCodeLine{2181   \textcolor{keywordtype}{type}(accel\_diag\_ptrs),      \textcolor{keywordtype}{intent(inout)} :: ADp\textcolor{comment}{ !< Structure pointing to accelerations in}}
\DoxyCodeLine{2182 \textcolor{comment}{                                                   !! momentum equation.}}
\DoxyCodeLine{2183   \textcolor{keywordtype}{type}(cont\_diag\_ptrs),       \textcolor{keywordtype}{intent(inout)} :: CDp\textcolor{comment}{ !< Structure pointing to terms in continuity}}
\DoxyCodeLine{2184 \textcolor{comment}{                                                   !! equation.}}
\DoxyCodeLine{2185   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< The ocean's grid structure.}}
\DoxyCodeLine{2186   \textcolor{keywordtype}{type}(diagnostics\_CS),       \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Pointer to the control structure for this}}
\DoxyCodeLine{2187 \textcolor{comment}{                                                   !! module.}}
\DoxyCodeLine{2188 }
\DoxyCodeLine{2189 \textcolor{comment}{! This subroutine sets up diagnostics upon which other diagnostics depend.}}
\DoxyCodeLine{2190   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, nz}
\DoxyCodeLine{2191   isd  = g\%isd  ; ied  = g\%ied  ; jsd  = g\%jsd  ; jed  = g\%jed ; nz = g\%ke}
\DoxyCodeLine{2192   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{2193 }
\DoxyCodeLine{2194   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%dKE\_dt) .or. \textcolor{keyword}{associated}(cs\%PE\_to\_KE) .or. \&}
\DoxyCodeLine{2195       \textcolor{keyword}{associated}(cs\%KE\_CorAdv) .or. \textcolor{keyword}{associated}(cs\%KE\_adv) .or. \&}
\DoxyCodeLine{2196       \textcolor{keyword}{associated}(cs\%KE\_visc) .or. \textcolor{keyword}{associated}(cs\%KE\_horvisc) .or. \&}
\DoxyCodeLine{2197       \textcolor{keyword}{associated}(cs\%KE\_dia)) \&}
\DoxyCodeLine{2198     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%KE,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{2199 }
\DoxyCodeLine{2200   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%dKE\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2201     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs\%du\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2202       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%du\_dt,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{2203       \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%u), mis\%u, cs\%du\_dt, cs)}
\DoxyCodeLine{2204 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2205     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs\%dv\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2206       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%dv\_dt,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{2207       \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%v), mis\%v, cs\%dv\_dt, cs)}
\DoxyCodeLine{2208 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2209     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs\%dh\_dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2210       \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%dh\_dt,isd,ied,jsd,jed,nz)}
\DoxyCodeLine{2211       \textcolor{keyword}{call }register\_time\_deriv(lbound(mis\%h), mis\%h, cs\%dh\_dt, cs)}
\DoxyCodeLine{2212 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2213 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2214 }
\DoxyCodeLine{2215   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_adv)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2216     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%gradKEu,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{2217     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%gradKEv,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{2218 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2219 }
\DoxyCodeLine{2220   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_visc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2221     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%du\_dt\_visc,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{2222     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%dv\_dt\_visc,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{2223 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2224 }
\DoxyCodeLine{2225   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%KE\_dia)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2226     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%du\_dt\_dia,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{2227     \textcolor{keyword}{call }safe\_alloc\_ptr(adp\%dv\_dt\_dia,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{2228 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2229 }
\DoxyCodeLine{2230   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%uhGM\_Rlay)) \textcolor{keyword}{call }safe\_alloc\_ptr(cdp\%uhGM,isdb,iedb,jsd,jed,nz)}
\DoxyCodeLine{2231   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%vhGM\_Rlay)) \textcolor{keyword}{call }safe\_alloc\_ptr(cdp\%vhGM,isd,ied,jsdb,jedb,nz)}
\DoxyCodeLine{2232 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diagnostics_af505e1356cf2f8172d27b60136b928e4}\label{namespacemom__diagnostics_af505e1356cf2f8172d27b60136b928e4}} 
\index{mom\_diagnostics@{mom\_diagnostics}!write\_static\_fields@{write\_static\_fields}}
\index{write\_static\_fields@{write\_static\_fields}!mom\_diagnostics@{mom\_diagnostics}}
\doxysubsubsection{\texorpdfstring{write\_static\_fields()}{write\_static\_fields()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diagnostics\+::write\+\_\+static\+\_\+fields (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(diag\+\_\+ctrl), intent(inout), target}]{diag }\end{DoxyParamCaption})}



Offers the static fields in the ocean grid type for output via the diag\+\_\+manager. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & regulates diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 2003 of file M\+O\+M\+\_\+diagnostics.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2004   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< ocean grid structure}}
\DoxyCodeLine{2005   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< ocean vertical grid structure}}
\DoxyCodeLine{2006   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{2007   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{2008   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< regulates diagnostic output}}
\DoxyCodeLine{2009 }
\DoxyCodeLine{2010   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{2011   \textcolor{keywordtype}{integer} :: id}
\DoxyCodeLine{2012   \textcolor{keywordtype}{logical} :: use\_temperature}
\DoxyCodeLine{2013 }
\DoxyCodeLine{2014   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolat'}, diag\%axesT1, \&}
\DoxyCodeLine{2015         \textcolor{stringliteral}{'Latitude of tracer (T) points'}, \textcolor{stringliteral}{'degrees\_north'})}
\DoxyCodeLine{2016   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLatT, diag, .true.)}
\DoxyCodeLine{2017 }
\DoxyCodeLine{2018   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolon'}, diag\%axesT1, \&}
\DoxyCodeLine{2019         \textcolor{stringliteral}{'Longitude of tracer (T) points'}, \textcolor{stringliteral}{'degrees\_east'})}
\DoxyCodeLine{2020   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLonT, diag, .true.)}
\DoxyCodeLine{2021 }
\DoxyCodeLine{2022   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolat\_c'}, diag\%axesB1, \&}
\DoxyCodeLine{2023         \textcolor{stringliteral}{'Latitude of corner (Bu) points'}, \textcolor{stringliteral}{'degrees\_north'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2024   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLatBu, diag, .true.)}
\DoxyCodeLine{2025 }
\DoxyCodeLine{2026   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolon\_c'}, diag\%axesB1, \&}
\DoxyCodeLine{2027         \textcolor{stringliteral}{'Longitude of corner (Bu) points'}, \textcolor{stringliteral}{'degrees\_east'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2028   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLonBu, diag, .true.)}
\DoxyCodeLine{2029 }
\DoxyCodeLine{2030   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolat\_v'}, diag\%axesCv1, \&}
\DoxyCodeLine{2031         \textcolor{stringliteral}{'Latitude of meridional velocity (Cv) points'}, \textcolor{stringliteral}{'degrees\_north'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2032   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLatCv, diag, .true.)}
\DoxyCodeLine{2033 }
\DoxyCodeLine{2034   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolon\_v'}, diag\%axesCv1, \&}
\DoxyCodeLine{2035         \textcolor{stringliteral}{'Longitude of meridional velocity (Cv) points'}, \textcolor{stringliteral}{'degrees\_east'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2036   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLonCv, diag, .true.)}
\DoxyCodeLine{2037 }
\DoxyCodeLine{2038   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolat\_u'}, diag\%axesCu1, \&}
\DoxyCodeLine{2039         \textcolor{stringliteral}{'Latitude of zonal velocity (Cu) points'}, \textcolor{stringliteral}{'degrees\_north'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2040   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLatCu, diag, .true.)}
\DoxyCodeLine{2041 }
\DoxyCodeLine{2042   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'geolon\_u'}, diag\%axesCu1, \&}
\DoxyCodeLine{2043         \textcolor{stringliteral}{'Longitude of zonal velocity (Cu) points'}, \textcolor{stringliteral}{'degrees\_east'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2044   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%geoLonCu, diag, .true.)}
\DoxyCodeLine{2045 }
\DoxyCodeLine{2046   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_t'}, diag\%axesT1, \&}
\DoxyCodeLine{2047         \textcolor{stringliteral}{'Surface area of tracer (T) cells'}, \textcolor{stringliteral}{'m2'}, conversion=us\%L\_to\_m**2, \&}
\DoxyCodeLine{2048         cmor\_field\_name=\textcolor{stringliteral}{'areacello'}, cmor\_standard\_name=\textcolor{stringliteral}{'cell\_area'}, \&}
\DoxyCodeLine{2049         cmor\_long\_name=\textcolor{stringliteral}{'Ocean Grid-\/Cell Area'}, \&}
\DoxyCodeLine{2050         x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'}, area\_cell\_method=\textcolor{stringliteral}{'sum'})}
\DoxyCodeLine{2051   \textcolor{keywordflow}{if} (id > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2052     \textcolor{keyword}{call }post\_data(id, g\%areaT, diag, .true.)}
\DoxyCodeLine{2053     \textcolor{keyword}{call }diag\_register\_area\_ids(diag, id\_area\_t=id)}
\DoxyCodeLine{2054 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2055 }
\DoxyCodeLine{2056   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_u'}, diag\%axesCu1, \&}
\DoxyCodeLine{2057         \textcolor{stringliteral}{'Surface area of x-\/direction flow (U) cells'}, \textcolor{stringliteral}{'m2'}, conversion=us\%L\_to\_m**2, \&}
\DoxyCodeLine{2058         cmor\_field\_name=\textcolor{stringliteral}{'areacello\_cu'}, cmor\_standard\_name=\textcolor{stringliteral}{'cell\_area'}, \&}
\DoxyCodeLine{2059         cmor\_long\_name=\textcolor{stringliteral}{'Ocean Grid-\/Cell Area'}, \&}
\DoxyCodeLine{2060         x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'}, area\_cell\_method=\textcolor{stringliteral}{'sum'})}
\DoxyCodeLine{2061   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%areaCu, diag, .true.)}
\DoxyCodeLine{2062 }
\DoxyCodeLine{2063   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_v'}, diag\%axesCv1, \&}
\DoxyCodeLine{2064         \textcolor{stringliteral}{'Surface area of y-\/direction flow (V) cells'}, \textcolor{stringliteral}{'m2'}, conversion=us\%L\_to\_m**2, \&}
\DoxyCodeLine{2065         cmor\_field\_name=\textcolor{stringliteral}{'areacello\_cv'}, cmor\_standard\_name=\textcolor{stringliteral}{'cell\_area'}, \&}
\DoxyCodeLine{2066         cmor\_long\_name=\textcolor{stringliteral}{'Ocean Grid-\/Cell Area'}, \&}
\DoxyCodeLine{2067         x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'}, area\_cell\_method=\textcolor{stringliteral}{'sum'})}
\DoxyCodeLine{2068   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%areaCv, diag, .true.)}
\DoxyCodeLine{2069 }
\DoxyCodeLine{2070   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_q'}, diag\%axesB1, \&}
\DoxyCodeLine{2071         \textcolor{stringliteral}{'Surface area of B-\/grid flow (Q) cells'}, \textcolor{stringliteral}{'m2'}, conversion=us\%L\_to\_m**2, \&}
\DoxyCodeLine{2072         cmor\_field\_name=\textcolor{stringliteral}{'areacello\_bu'}, cmor\_standard\_name=\textcolor{stringliteral}{'cell\_area'}, \&}
\DoxyCodeLine{2073         cmor\_long\_name=\textcolor{stringliteral}{'Ocean Grid-\/Cell Area'}, \&}
\DoxyCodeLine{2074         x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'}, area\_cell\_method=\textcolor{stringliteral}{'sum'})}
\DoxyCodeLine{2075   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%areaBu, diag, .true.)}
\DoxyCodeLine{2076 }
\DoxyCodeLine{2077   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'depth\_ocean'}, diag\%axesT1,  \&}
\DoxyCodeLine{2078         \textcolor{stringliteral}{'Depth of the ocean at tracer points'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m, \&}
\DoxyCodeLine{2079         standard\_name=\textcolor{stringliteral}{'sea\_floor\_depth\_below\_geoid'},                     \&}
\DoxyCodeLine{2080         cmor\_field\_name=\textcolor{stringliteral}{'deptho'}, cmor\_long\_name=\textcolor{stringliteral}{'Sea Floor Depth'},      \&}
\DoxyCodeLine{2081         cmor\_standard\_name=\textcolor{stringliteral}{'sea\_floor\_depth\_below\_geoid'}, area=diag\%axesT1\%id\_area, \&}
\DoxyCodeLine{2082         x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, area\_cell\_method=\textcolor{stringliteral}{'mean'})}
\DoxyCodeLine{2083   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%bathyT, diag, .true., mask=g\%mask2dT)}
\DoxyCodeLine{2084 }
\DoxyCodeLine{2085   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'wet'}, diag\%axesT1, \&}
\DoxyCodeLine{2086         \textcolor{stringliteral}{'0 if land, 1 if ocean at tracer points'}, \textcolor{stringliteral}{'none'}, area=diag\%axesT1\%id\_area)}
\DoxyCodeLine{2087   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%mask2dT, diag, .true.)}
\DoxyCodeLine{2088 }
\DoxyCodeLine{2089   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'wet\_c'}, diag\%axesB1, \&}
\DoxyCodeLine{2090         \textcolor{stringliteral}{'0 if land, 1 if ocean at corner (Bu) points'}, \textcolor{stringliteral}{'none'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2091   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%mask2dBu, diag, .true.)}
\DoxyCodeLine{2092 }
\DoxyCodeLine{2093   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'wet\_u'}, diag\%axesCu1, \&}
\DoxyCodeLine{2094         \textcolor{stringliteral}{'0 if land, 1 if ocean at zonal velocity (Cu) points'}, \textcolor{stringliteral}{'none'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2095   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%mask2dCu, diag, .true.)}
\DoxyCodeLine{2096 }
\DoxyCodeLine{2097   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'wet\_v'}, diag\%axesCv1, \&}
\DoxyCodeLine{2098         \textcolor{stringliteral}{'0 if land, 1 if ocean at meridional velocity (Cv) points'}, \textcolor{stringliteral}{'none'}, interp\_method=\textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2099   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%mask2dCv, diag, .true.)}
\DoxyCodeLine{2100 }
\DoxyCodeLine{2101   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Coriolis'}, diag\%axesB1, \&}
\DoxyCodeLine{2102         \textcolor{stringliteral}{'Coriolis parameter at corner (Bu) points'}, \textcolor{stringliteral}{'s-\/1'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%s\_to\_T)}
\DoxyCodeLine{2103   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%CoriolisBu, diag, .true.)}
\DoxyCodeLine{2104 }
\DoxyCodeLine{2105   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dxt'}, diag\%axesT1, \&}
\DoxyCodeLine{2106         \textcolor{stringliteral}{'Delta(x) at thickness/tracer points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2107   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dxT, diag, .true.)}
\DoxyCodeLine{2108 }
\DoxyCodeLine{2109   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dyt'}, diag\%axesT1, \&}
\DoxyCodeLine{2110         \textcolor{stringliteral}{'Delta(y) at thickness/tracer points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2111   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dyT, diag, .true.)}
\DoxyCodeLine{2112 }
\DoxyCodeLine{2113   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dxCu'}, diag\%axesCu1, \&}
\DoxyCodeLine{2114         \textcolor{stringliteral}{'Delta(x) at u points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2115   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dxCu, diag, .true.)}
\DoxyCodeLine{2116 }
\DoxyCodeLine{2117   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dyCu'}, diag\%axesCu1, \&}
\DoxyCodeLine{2118         \textcolor{stringliteral}{'Delta(y) at u points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2119   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dyCu, diag, .true.)}
\DoxyCodeLine{2120 }
\DoxyCodeLine{2121   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dxCv'}, diag\%axesCv1, \&}
\DoxyCodeLine{2122         \textcolor{stringliteral}{'Delta(x) at v points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2123   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dxCv, diag, .true.)}
\DoxyCodeLine{2124 }
\DoxyCodeLine{2125   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dyCv'}, diag\%axesCv1, \&}
\DoxyCodeLine{2126         \textcolor{stringliteral}{'Delta(y) at v points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2127   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dyCv, diag, .true.)}
\DoxyCodeLine{2128 }
\DoxyCodeLine{2129   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dyCuo'}, diag\%axesCu1, \&}
\DoxyCodeLine{2130         \textcolor{stringliteral}{'Open meridional grid spacing at u points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2131   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dy\_Cu, diag, .true.)}
\DoxyCodeLine{2132 }
\DoxyCodeLine{2133   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'dxCvo'}, diag\%axesCv1, \&}
\DoxyCodeLine{2134         \textcolor{stringliteral}{'Open zonal grid spacing at v points (meter)'}, \textcolor{stringliteral}{'m'}, interp\_method=\textcolor{stringliteral}{'none'}, conversion=us\%L\_to\_m)}
\DoxyCodeLine{2135   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%dx\_Cv, diag, .true.)}
\DoxyCodeLine{2136 }
\DoxyCodeLine{2137   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sin\_rot'}, diag\%axesT1, \&}
\DoxyCodeLine{2138         \textcolor{stringliteral}{'sine of the clockwise angle of the ocean grid north to true north'}, \textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2139   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%sin\_rot, diag, .true.)}
\DoxyCodeLine{2140 }
\DoxyCodeLine{2141   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'cos\_rot'}, diag\%axesT1, \&}
\DoxyCodeLine{2142         \textcolor{stringliteral}{'cosine of the clockwise angle of the ocean grid north to true north'}, \textcolor{stringliteral}{'none'})}
\DoxyCodeLine{2143   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%cos\_rot, diag, .true.)}
\DoxyCodeLine{2144 }
\DoxyCodeLine{2145 }
\DoxyCodeLine{2146   \textcolor{comment}{! This static diagnostic is from CF 1.8, and is the fraction of a cell}}
\DoxyCodeLine{2147   \textcolor{comment}{! covered by ocean, given as a percentage (poorly named).}}
\DoxyCodeLine{2148   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_t\_percent'}, diag\%axesT1, \&}
\DoxyCodeLine{2149         \textcolor{stringliteral}{'Percentage of cell area covered by ocean'}, \textcolor{stringliteral}{'\%'}, conversion=100.0, \&}
\DoxyCodeLine{2150         cmor\_field\_name=\textcolor{stringliteral}{'sftof'}, cmor\_standard\_name=\textcolor{stringliteral}{'SeaAreaFraction'}, \&}
\DoxyCodeLine{2151         cmor\_long\_name=\textcolor{stringliteral}{'Sea Area Fraction'}, \&}
\DoxyCodeLine{2152         x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, area\_cell\_method=\textcolor{stringliteral}{'mean'})}
\DoxyCodeLine{2153   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, g\%mask2dT, diag, .true.)}
\DoxyCodeLine{2154 }
\DoxyCodeLine{2155 }
\DoxyCodeLine{2156   id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'Rho\_0'}, diag\%axesNull, \&}
\DoxyCodeLine{2157        \textcolor{stringliteral}{'mean ocean density used with the Boussinesq approximation'}, \&}
\DoxyCodeLine{2158        \textcolor{stringliteral}{'kg m-\/3'}, conversion=us\%R\_to\_kg\_m3, cmor\_field\_name=\textcolor{stringliteral}{'rhozero'}, \&}
\DoxyCodeLine{2159        cmor\_standard\_name=\textcolor{stringliteral}{'reference\_sea\_water\_density\_for\_boussinesq\_approximation'}, \&}
\DoxyCodeLine{2160        cmor\_long\_name=\textcolor{stringliteral}{'reference sea water density for boussinesq approximation'})}
\DoxyCodeLine{2161   \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, gv\%Rho0, diag, .true.)}
\DoxyCodeLine{2162 }
\DoxyCodeLine{2163   use\_temperature = \textcolor{keyword}{associated}(tv\%T)}
\DoxyCodeLine{2164   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2165     id = register\_static\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'C\_p'}, diag\%axesNull, \&}
\DoxyCodeLine{2166          \textcolor{stringliteral}{'heat capacity of sea water'}, \textcolor{stringliteral}{'J kg-\/1 K-\/1'}, conversion=us\%Q\_to\_J\_kg, \&}
\DoxyCodeLine{2167          cmor\_field\_name=\textcolor{stringliteral}{'cpocean'}, \&}
\DoxyCodeLine{2168          cmor\_standard\_name=\textcolor{stringliteral}{'specific\_heat\_capacity\_of\_sea\_water'}, \&}
\DoxyCodeLine{2169          cmor\_long\_name=\textcolor{stringliteral}{'specific\_heat\_capacity\_of\_sea\_water'})}
\DoxyCodeLine{2170     \textcolor{keywordflow}{if} (id > 0) \textcolor{keyword}{call }post\_data(id, tv\%C\_p, diag, .true.)}
\DoxyCodeLine{2171 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2172 }

\end{DoxyCode}
