\hypertarget{namespacemom__forcing__type}{}\section{mom\+\_\+forcing\+\_\+type Module Reference}
\label{namespacemom__forcing__type}\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}


\subsection{Detailed Description}
This module implements boundary forcing for M\+O\+M6. 

\hypertarget{namespacemom__forcing__type_section_fluxes}{}\subsection{Boundary fluxes}\label{namespacemom__forcing__type_section_fluxes}
The ocean is a forced-\/dissipative system. Forcing occurs at the boundaries, and this module mediates the various forcing terms from momentum, heat, salt, and mass. Boundary fluxes from other tracers are treated by coupling to biogeochemical models. We here present elements of how M\+O\+M6 assumes boundary fluxes are passed into the ocean.

Note that all fluxes are positive into the ocean. For surface boundary fluxes, that means fluxes are positive downward. For example, a positive shortwave flux warms the ocean.\hypertarget{namespacemom__forcing__type_subsection_momentum_fluxes}{}\subsubsection{Surface boundary momentum fluxes}\label{namespacemom__forcing__type_subsection_momentum_fluxes}
The ocean surface exchanges momentum with the overlying atmosphere, sea ice, and land ice. The momentum is exchanged as a horizontal stress (Newtons per squared meter\+: N/m2) imposed on the upper ocean grid cell.\hypertarget{namespacemom__forcing__type_subsection_mass_fluxes}{}\subsubsection{Surface boundary mass fluxes}\label{namespacemom__forcing__type_subsection_mass_fluxes}
The ocean gains or loses mass through evaporation, precipitation, sea ice melt/form, and and river runoff. Positive mass fluxes add mass to the liquid ocean. The boundary mass flux units are (kilogram per square meter per sec\+: kg/(m2/sec)).


\begin{DoxyItemize}
\item Evaporation field can in fact represent a mass loss (evaporation) or mass gain (condensation in foggy areas).
\item sea ice formation leads to mass moving from the liquid ocean to the ice model, and melt adds liquid to the ocean.
\item Precipitation can be liquid or frozen (snow). Furthermore, in some versions of the G\+F\+DL coupler, precipitation can be negative. The reason is that the ice model combines precipitation with ice melt and ice formation. This limitation of the ice model diagnostics should be overcome future versions.
\item River runoff can be liquid or frozen. Frozen runoff is often associated with calving land-\/ice and/or ice bergs.
\end{DoxyItemize}\hypertarget{namespacemom__forcing__type_subsection_salt_fluxes}{}\subsubsection{Surface boundary salt fluxes}\label{namespacemom__forcing__type_subsection_salt_fluxes}
Over most of the ocean, there is no exchange of salt with the atmosphere. However, the liquid ocean exchanges salt with sea ice. When ice forms, it extracts salt from ice pockets and discharges the salt into the liquid ocean. The salt concentration of sea ice is therefore much lower (around 5ppt) than liquid seawater (around 30-\/35ppt in high latitudes).

For ocean-\/ice models run with a prescribed atmosphere, such as in the C\+O\+R\+E/\+O\+M\+M\+IP simulations, it is necessary to employ a surface restoring term to the k=1 salinity equation, thus imposing a salt flux onto the ocean even outside of sea ice regimes. This salt flux is non-\/physical, and represents a limitation of the ocean-\/ice models run without an interactive atmosphere. Sometimes this salt flux is converted to an implied fresh water flux. However, doing so generally leads to changes in the sea level, unless a global normalization is provided to zero-\/out the net water flux. As a complement, for models with a restoring salt flux, one may choose to zero-\/out the net salt entering the ocean. There are pros/cons of each approach.\hypertarget{namespacemom__forcing__type_subsection_heat_fluxes}{}\subsubsection{Surface boundary heat fluxes}\label{namespacemom__forcing__type_subsection_heat_fluxes}
There are many terms that contribute to boundary-\/related heating of the k=1 surface model grid cell. We here outline details of this heat, with each term having units W/m2.

The net flux of heat crossing ocean surface is stored in the diagnostic array \char`\"{}hfds\char`\"{}. This array is computed as \[ \mbox{hfds = shortwave + longwave + latent + sensible + mass transfer + frazil + restore + flux adjustments} \]


\begin{DoxyItemize}
\item shortwave (SW) = shortwave radiation (always warms ocean)
\item longwave (LW) = longwave radiation (generally cools ocean)
\item latent (L\+AT) = turbulent latent heat loss due to evaporation (liquid to vapor) or melt (snow to liquid); generally cools the ocean
\item sensible (S\+E\+NS) = turbulent heat transfer due to differences in air-\/sea or ice-\/sea temperature
\item mass transfer (M\+A\+SS) = heat transfer due to heat content of mass (e.\+g., E-\/\+P+R) transferred across ocean surface; computed relative to 0 Celsius
\item frazil (F\+R\+AZ) = heat transferred to form frazil sea ice (positive heating of liquid ocean)
\item restore (R\+ES) = heat from surface damping sometimes imposed in non-\/coupled model simulations .
\item restore (flux adjustments) = heat from surface flux adjustment.
\end{DoxyItemize}\hypertarget{namespacemom__forcing__type_subsubsection_SW}{}\paragraph{Treatment of shortwave}\label{namespacemom__forcing__type_subsubsection_SW}
The shortwave field itself is split into two pieces\+:


\begin{DoxyItemize}
\item shortwave = penetrative SW + non-\/penetrative SW
\item non-\/penetrative = non-\/downwelling shortwave; portion of SW totally absorbed in the k=1 cell. The non-\/penetrative SW is combined with L\+W+\+L\+A\+T+\+S\+E\+N\+S+seaice\+\_\+melt\+\_\+heat in net\+\_\+heat inside routine extract\+Fluxes1d. Notably, for many cases, non-\/penetrative SW = 0.
\item penetrative = that portion of shortwave penetrating below a tiny surface layer. This is the downwelling shortwave. Penetrative SW participates in the penetrative SW heating of k=1,nz cells, with the amount of penetration dependent on optical properties.
\end{DoxyItemize}\hypertarget{namespacemom__forcing__type_subsubsection_bdy_heating}{}\paragraph{Convergence of heat into the k=1 cell}\label{namespacemom__forcing__type_subsubsection_bdy_heating}
The convergence of boundary-\/related heat into surface grid cell is given by the difference in the net heat entering the top of the k=1 cell and the penetrative SW leaving the bottom of the cell. \begin{eqnarray*} Q(k=1) &=& \mbox{hfds} - \mbox{pen}\_\mbox{SW(leaving bottom of k=1)} \\ &=& \mbox{nonpen}\_\mbox{SW} + (\mbox{pen}\_\mbox{SW(enter k=1)}-\mbox{pen}\_\mbox{SW(leave k=1)}) + \mbox{LW+LAT+SENS+MASS+FRAZ+RES} \\ &=& \mbox{nonpen}\_\mbox{SW}+ \mbox{LW+LAT+SENS+MASS+FRAZ+RES} + [\mbox{pen}\_\mbox{SW(enter k=1)} - \mbox{pen}\_\mbox{SW(leave k=1)}] \end{eqnarray*} The convergence of the penetrative shortwave flux is given by $ \mbox{pen}\_\mbox{SW (enter k)}-\mbox{pen}\_\mbox{SW (leave k)}$. This term appears for all cells k=1,nz. It is diagnosed as \char`\"{}rsdoabsorb\char`\"{} inside module M\+O\+M6/src/parameterizations/vertical/\+M\+O\+M\+\_\+diabatic\+\_\+aux.\+F90 \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\hyperlink{interfacemom__forcing__type_1_1allocate__forcing__type}{allocate\+\_\+forcing\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Allocate the fields of a (flux) forcing type, based on either a set of input flags for each group of fields, or a pre-\/allocated reference forcing. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__forcing__type_1_1allocate__mech__forcing}{allocate\+\_\+mech\+\_\+forcing}}
\begin{DoxyCompactList}\small\item\em Allocate the fields of a mechanical forcing type, based on either a set of input flags for each group of fields, or a pre-\/allocated reference forcing. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}
\begin{DoxyCompactList}\small\item\em Structure that contains pointers to the boundary forcing used to drive the liquid ocean simulated by M\+OM. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__forcing__type_1_1forcing__diags}{forcing\+\_\+diags}}
\begin{DoxyCompactList}\small\item\em Structure that defines the id handles for the forcing type. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}
\begin{DoxyCompactList}\small\item\em Structure that contains pointers to the mechanical forcing at the surface used to drive the liquid ocean simulated by M\+OM. Data in this type is allocated in the module \mbox{\hyperlink{MOM__surface__forcing_8F90_source}{M\+O\+M\+\_\+surface\+\_\+forcing.\+F90}}, of which there are three versions\+: solo, coupled, and ice-\/shelf. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a6bf986155aba959222a117ca40ba7e0d}{extractfluxes1d}} (G, GV, US, fluxes, optics, nsw, j, dt, Flux\+Rescale\+Depth, use\+River\+Heat\+Content, use\+Calving\+Heat\+Content, h, T, net\+Mass\+In\+Out, net\+Mass\+Out, net\+\_\+heat, net\+\_\+salt, pen\+\_\+\+S\+W\+\_\+bnd, tv, aggregate\+\_\+\+FW, nonpen\+SW, netmass\+In\+Out\+\_\+rate, net\+\_\+\+Heat\+\_\+\+Rate, net\+\_\+salt\+\_\+rate, pen\+\_\+sw\+\_\+bnd\+\_\+\+Rate, skip\+\_\+diags)
\begin{DoxyCompactList}\small\item\em This subroutine extracts fluxes from the surface fluxes type. It works on a j-\/row for optimization purposes. The 2d (i,j) wrapper is the next subroutine below. This routine multiplies fluxes by dt, so that the result is an accumulation of fluxes over a time step. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_abb28aefef337fc656fd719eaff7a3b60}{extractfluxes2d}} (G, GV, US, fluxes, optics, nsw, dt, Flux\+Rescale\+Depth, use\+River\+Heat\+Content, use\+Calving\+Heat\+Content, h, T, net\+Mass\+In\+Out, net\+Mass\+Out, net\+\_\+heat, Net\+\_\+salt, Pen\+\_\+\+S\+W\+\_\+bnd, tv, aggregate\+\_\+\+FW)
\begin{DoxyCompactList}\small\item\em 2d wrapper for 1d extract fluxes from surface fluxes type. This subroutine extracts fluxes from the surface fluxes type. It multiplies the fluxes by dt, so that the result is an accumulation of the fluxes over a time step. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a406a512f0d5b45c873fa91110ca7c387}{calculatebuoyancyflux1d}} (G, GV, US, fluxes, optics, nsw, h, Temp, Salt, tv, j, buoyancy\+Flux, net\+Heat\+Minus\+SW, net\+Salt, skip\+\_\+diags)
\begin{DoxyCompactList}\small\item\em This routine calculates surface buoyancy flux by adding up the heat, FW \& salt fluxes. These are actual fluxes, with units of stuff per time. Setting dt=1 in the call to extract\+Fluxes routine allows us to get \char`\"{}stuf per time\char`\"{} rather than the time integrated fluxes needed in other routines that call extract\+Fluxes. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_ae84373c4a259bd04330ec673af0fa536}{calculatebuoyancyflux2d}} (G, GV, US, fluxes, optics, h, Temp, Salt, tv, buoyancy\+Flux, net\+Heat\+Minus\+SW, net\+Salt, skip\+\_\+diags)
\begin{DoxyCompactList}\small\item\em Calculates surface buoyancy flux by adding up the heat, FW and salt fluxes, for 2d arrays. This is a wrapper for calculate\+Buoyancy\+Flux1d. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a1c4ecd1a779a55e9304b0997088a4815}{mom\+\_\+forcing\+\_\+chksum}} (mesg, fluxes, G, US, haloshift)
\begin{DoxyCompactList}\small\item\em Write out chksums for thermodynamic fluxes. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_afe942ca75b30c226fdfcdedcecad920f}{mom\+\_\+mech\+\_\+forcing\+\_\+chksum}} (mesg, forces, G, US, haloshift)
\begin{DoxyCompactList}\small\item\em Write out chksums for the driving mechanical forces. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_a2e3834f8d25c92142d450de74fa68f91}{mech\+\_\+forcing\+\_\+singlepointprint}} (forces, G, i, j, mesg)
\begin{DoxyCompactList}\small\item\em Write out values of the mechanical forcing arrays at the i,j location. This is a debugging tool. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a1048a8e80ebd47f83b91772c02aedba2}{forcing\+\_\+singlepointprint}} (fluxes, G, i, j, mesg)
\begin{DoxyCompactList}\small\item\em Write out values of the fluxes arrays at the i,j location. This is a debugging tool. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_ad4a8e0b876c8082f77352a25a56b86e9}{register\+\_\+forcing\+\_\+type\+\_\+diags}} (Time, diag, US, use\+\_\+temperature, handles, use\+\_\+berg\+\_\+fluxes)
\begin{DoxyCompactList}\small\item\em Register members of the forcing type for diagnostics. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_aab6d8e5da1aafc8a73875e2de61822f9}{forcing\+\_\+accumulate}} (flux\+\_\+tmp, forces, fluxes, G, wt2)
\begin{DoxyCompactList}\small\item\em Accumulate the forcing over time steps, taking input from a mechanical forcing type and a temporary forcing-\/flux type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a839c0241813c94b40b6861e2ad8bdc91}{fluxes\+\_\+accumulate}} (flux\+\_\+tmp, fluxes, G, wt2, forces)
\begin{DoxyCompactList}\small\item\em Accumulate the thermodynamic fluxes over time steps. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a44ade8a584921047fcf960f4cdb9914c}{copy\+\_\+common\+\_\+forcing\+\_\+fields}} (forces, fluxes, G, skip\+\_\+pres)
\begin{DoxyCompactList}\small\item\em This subroutine copies the computational domains of common forcing fields from a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type to a (thermodynamic) forcing type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a1e4c747c49b67bb20b322c7b807de036}{set\+\_\+derived\+\_\+forcing\+\_\+fields}} (forces, fluxes, G, US, Rho0)
\begin{DoxyCompactList}\small\item\em This subroutine calculates certain derived forcing fields based on information from a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type and stores them in a (thermodynamic) forcing type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a9ee72ee836f7326d0957a4094d8f0231}{set\+\_\+net\+\_\+mass\+\_\+forcing}} (fluxes, forces, G, US)
\begin{DoxyCompactList}\small\item\em This subroutine determines the net mass source to the ocean from a (thermodynamic) forcing type and stores it in a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a67f6972e0e0dd6c0b6b4bbea9ff6b5ef}{get\+\_\+net\+\_\+mass\+\_\+forcing}} (fluxes, G, US, net\+\_\+mass\+\_\+src)
\begin{DoxyCompactList}\small\item\em This subroutine calculates determines the net mass source to the ocean from a (thermodynamic) forcing type and stores it in a provided array. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_aa8ee4e3dace6d294ceb8bfe445dead1b}{copy\+\_\+back\+\_\+forcing\+\_\+fields}} (fluxes, forces, G)
\begin{DoxyCompactList}\small\item\em This subroutine copies the computational domains of common forcing fields from a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type to a (thermodynamic) forcing type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a014d07725581af8ede287ea2a2322259}{mech\+\_\+forcing\+\_\+diags}} (forces\+\_\+in, dt, G, time\+\_\+end, diag, handles)
\begin{DoxyCompactList}\small\item\em Offer mechanical forcing fields for diagnostics for those fields registered as part of register\+\_\+forcing\+\_\+type\+\_\+diags. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a18fc44b1946351373f626fcc5aabc340}{forcing\+\_\+diagnostics}} (fluxes\+\_\+in, sfc\+\_\+state, G\+\_\+in, US, time\+\_\+end, diag, handles)
\begin{DoxyCompactList}\small\item\em Offer buoyancy forcing fields for diagnostics for those fields registered as part of register\+\_\+forcing\+\_\+type\+\_\+diags. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_a392847be3b991a4fdda885dd759d2b78}{allocate\+\_\+forcing\+\_\+by\+\_\+group}} (G, fluxes, water, heat, ustar, press, shelf, iceberg, salt, fix\+\_\+accum\+\_\+bug)
\begin{DoxyCompactList}\small\item\em Conditionally allocate fields within the forcing type. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_a9217574bff645ceeff9e15dc133a6031}{allocate\+\_\+forcing\+\_\+by\+\_\+ref}} (fluxes\+\_\+ref, G, fluxes)
\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_abd84b619cbabd15a33640be270be71a8}{allocate\+\_\+mech\+\_\+forcing\+\_\+by\+\_\+group}} (G, forces, stress, ustar, shelf, press, iceberg)
\begin{DoxyCompactList}\small\item\em Conditionally allocate fields within the mechanical forcing type using control flags. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_a8b0e58eae39f6285c6e929922b5874a9}{allocate\+\_\+mech\+\_\+forcing\+\_\+from\+\_\+ref}} (forces\+\_\+ref, G, forces)
\begin{DoxyCompactList}\small\item\em Conditionally allocate fields within the mechanical forcing type based on a reference forcing. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_a237dc2330bf133bf3365a924d26b0b37}{get\+\_\+forcing\+\_\+groups}} (fluxes, water, heat, ustar, press, shelf, iceberg, salt, heat\+\_\+added, buoy)
\begin{DoxyCompactList}\small\item\em Return flags indicating which groups of forcings are allocated. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_a2db9d1c071a26c092f662bd30afb2039}{get\+\_\+mech\+\_\+forcing\+\_\+groups}} (forces, stress, ustar, shelf, press, iceberg)
\begin{DoxyCompactList}\small\item\em Return flags indicating which groups of mechanical forcings are allocated. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__forcing__type_aa9a495456715378fe3dd5fb2bd21eec8}{myalloc}} (array, is, ie, js, je, flag)
\begin{DoxyCompactList}\small\item\em Allocates and zeroes-\/out array. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a432b1cbc47ab082b64bf7007a8674973}{deallocate\+\_\+forcing\+\_\+type}} (fluxes)
\begin{DoxyCompactList}\small\item\em Deallocate the forcing type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_aaadc0cd523729cb059cb62a2a224970b}{deallocate\+\_\+mech\+\_\+forcing}} (forces)
\begin{DoxyCompactList}\small\item\em Deallocate the mechanical forcing type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a904033b8a97fed683d795460b555ce9b}{rotate\+\_\+forcing}} (fluxes\+\_\+in, fluxes, turns)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__forcing__type_a7b1d8f7fa2ffad01d699febbf042ac74}{rotate\+\_\+mech\+\_\+forcing}} (forces\+\_\+in, turns, forces)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__forcing__type_a392847be3b991a4fdda885dd759d2b78}\label{namespacemom__forcing__type_a392847be3b991a4fdda885dd759d2b78}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!allocate\+\_\+forcing\+\_\+by\+\_\+group@{allocate\+\_\+forcing\+\_\+by\+\_\+group}}
\index{allocate\+\_\+forcing\+\_\+by\+\_\+group@{allocate\+\_\+forcing\+\_\+by\+\_\+group}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{allocate\+\_\+forcing\+\_\+by\+\_\+group()}{allocate\_forcing\_by\_group()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::allocate\+\_\+forcing\+\_\+by\+\_\+group (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{logical, intent(in), optional}]{water,  }\item[{logical, intent(in), optional}]{heat,  }\item[{logical, intent(in), optional}]{ustar,  }\item[{logical, intent(in), optional}]{press,  }\item[{logical, intent(in), optional}]{shelf,  }\item[{logical, intent(in), optional}]{iceberg,  }\item[{logical, intent(in), optional}]{salt,  }\item[{logical, intent(in), optional}]{fix\+\_\+accum\+\_\+bug }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Conditionally allocate fields within the forcing type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & Ocean grid structure\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em water} & If present and true, allocate water fluxes\\
\hline
\mbox{\tt in}  & {\em heat} & If present and true, allocate heat fluxes\\
\hline
\mbox{\tt in}  & {\em ustar} & If present and true, allocate ustar and related fields\\
\hline
\mbox{\tt in}  & {\em press} & If present and true, allocate p\+\_\+surf and related fields\\
\hline
\mbox{\tt in}  & {\em shelf} & If present and true, allocate fluxes for ice-\/shelf\\
\hline
\mbox{\tt in}  & {\em iceberg} & If present and true, allocate fluxes for icebergs\\
\hline
\mbox{\tt in}  & {\em salt} & If present and true, allocate salt fluxes\\
\hline
\mbox{\tt in}  & {\em fix\+\_\+accum\+\_\+bug} & If present and true, avoid using a bug in accumulation of ustar\+\_\+gustless \\
\hline
\end{DoxyParams}


Definition at line 2867 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2867   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{       !< Ocean grid structure}
2868   \textcolor{keywordtype}{type}(forcing),      \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{  !< A structure containing thermodynamic forcing fields}
2869   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: water\textcolor{comment}{   !< If present and true, allocate water fluxes}
2870   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: heat\textcolor{comment}{    !< If present and true, allocate heat fluxes}
2871   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: ustar\textcolor{comment}{   !< If present and true, allocate ustar and related fields}
2872   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: press\textcolor{comment}{   !< If present and true, allocate p\_surf and related fields}
2873   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: shelf\textcolor{comment}{   !< If present and true, allocate fluxes for ice-shelf}
2874   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: iceberg\textcolor{comment}{ !< If present and true, allocate fluxes for icebergs}
2875   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: salt\textcolor{comment}{    !< If present and true, allocate salt fluxes}
2876   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: fix\_accum\_bug\textcolor{comment}{ !< If present and true, avoid using a bug in}
2877 \textcolor{comment}{                                               !! accumulation of ustar\_gustless}
2878 
2879   \textcolor{comment}{! Local variables}
2880   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
2881   \textcolor{keywordtype}{logical} :: heat\_water
2882 
2883   isd  = g%isd   ; ied  = g%ied    ; jsd  = g%jsd   ; jed  = g%jed
2884   isdb = g%IsdB  ; iedb = g%IedB   ; jsdb = g%JsdB  ; jedb = g%JedB
2885 
2886   \textcolor{keyword}{call }myalloc(fluxes%ustar,isd,ied,jsd,jed, ustar)
2887   \textcolor{keyword}{call }myalloc(fluxes%ustar\_gustless,isd,ied,jsd,jed, ustar)
2888 
2889   \textcolor{keyword}{call }myalloc(fluxes%evap,isd,ied,jsd,jed, water)
2890   \textcolor{keyword}{call }myalloc(fluxes%lprec,isd,ied,jsd,jed, water)
2891   \textcolor{keyword}{call }myalloc(fluxes%fprec,isd,ied,jsd,jed, water)
2892   \textcolor{keyword}{call }myalloc(fluxes%vprec,isd,ied,jsd,jed, water)
2893   \textcolor{keyword}{call }myalloc(fluxes%lrunoff,isd,ied,jsd,jed, water)
2894   \textcolor{keyword}{call }myalloc(fluxes%frunoff,isd,ied,jsd,jed, water)
2895   \textcolor{keyword}{call }myalloc(fluxes%seaice\_melt,isd,ied,jsd,jed, water)
2896   \textcolor{keyword}{call }myalloc(fluxes%netMassOut,isd,ied,jsd,jed, water)
2897   \textcolor{keyword}{call }myalloc(fluxes%netMassIn,isd,ied,jsd,jed, water)
2898   \textcolor{keyword}{call }myalloc(fluxes%netSalt,isd,ied,jsd,jed, water)
2899   \textcolor{keyword}{call }myalloc(fluxes%seaice\_melt\_heat,isd,ied,jsd,jed, heat)
2900   \textcolor{keyword}{call }myalloc(fluxes%sw,isd,ied,jsd,jed, heat)
2901   \textcolor{keyword}{call }myalloc(fluxes%lw,isd,ied,jsd,jed, heat)
2902   \textcolor{keyword}{call }myalloc(fluxes%latent,isd,ied,jsd,jed, heat)
2903   \textcolor{keyword}{call }myalloc(fluxes%sens,isd,ied,jsd,jed, heat)
2904   \textcolor{keyword}{call }myalloc(fluxes%latent\_evap\_diag,isd,ied,jsd,jed, heat)
2905   \textcolor{keyword}{call }myalloc(fluxes%latent\_fprec\_diag,isd,ied,jsd,jed, heat)
2906   \textcolor{keyword}{call }myalloc(fluxes%latent\_frunoff\_diag,isd,ied,jsd,jed, heat)
2907 
2908   \textcolor{keyword}{call }myalloc(fluxes%salt\_flux,isd,ied,jsd,jed, salt)
2909 
2910   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(heat) .and. \textcolor{keyword}{present}(water)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (heat .and. water) \textcolor{keywordflow}{then}
2911     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_cond,isd,ied,jsd,jed, .true.)
2912     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_icemelt,isd,ied,jsd,jed, .true.)
2913     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_lprec,isd,ied,jsd,jed, .true.)
2914     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_fprec,isd,ied,jsd,jed, .true.)
2915     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_vprec,isd,ied,jsd,jed, .true.)
2916     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_lrunoff,isd,ied,jsd,jed, .true.)
2917     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_frunoff,isd,ied,jsd,jed, .true.)
2918     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_massout,isd,ied,jsd,jed, .true.)
2919     \textcolor{keyword}{call }myalloc(fluxes%heat\_content\_massin,isd,ied,jsd,jed, .true.)
2920 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}
2921 
2922   \textcolor{keyword}{call }myalloc(fluxes%p\_surf,isd,ied,jsd,jed, press)
2923 
2924   \textcolor{keyword}{call }myalloc(fluxes%frac\_shelf\_h,isd,ied,jsd,jed, shelf)
2925   \textcolor{keyword}{call }myalloc(fluxes%ustar\_shelf,isd,ied,jsd,jed, shelf)
2926   \textcolor{keyword}{call }myalloc(fluxes%iceshelf\_melt,isd,ied,jsd,jed, shelf)
2927 
2928   \textcolor{comment}{!These fields should only on allocated when iceberg area is being passed through the coupler.}
2929   \textcolor{keyword}{call }myalloc(fluxes%ustar\_berg,isd,ied,jsd,jed, iceberg)
2930   \textcolor{keyword}{call }myalloc(fluxes%area\_berg,isd,ied,jsd,jed, iceberg)
2931   \textcolor{keyword}{call }myalloc(fluxes%mass\_berg,isd,ied,jsd,jed, iceberg)
2932 
2933   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fix\_accum\_bug)) fluxes%gustless\_accum\_bug = .not.fix\_accum\_bug
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a9217574bff645ceeff9e15dc133a6031}\label{namespacemom__forcing__type_a9217574bff645ceeff9e15dc133a6031}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!allocate\+\_\+forcing\+\_\+by\+\_\+ref@{allocate\+\_\+forcing\+\_\+by\+\_\+ref}}
\index{allocate\+\_\+forcing\+\_\+by\+\_\+ref@{allocate\+\_\+forcing\+\_\+by\+\_\+ref}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{allocate\+\_\+forcing\+\_\+by\+\_\+ref()}{allocate\_forcing\_by\_ref()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::allocate\+\_\+forcing\+\_\+by\+\_\+ref (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes\+\_\+ref,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(out)}]{fluxes }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes\+\_\+ref} & Reference fluxes\\
\hline
\mbox{\tt in}  & {\em g} & Grid metric of target fluxes\\
\hline
\mbox{\tt out}  & {\em fluxes} & Target fluxes \\
\hline
\end{DoxyParams}


Definition at line 2938 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2938   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(in)} :: fluxes\_ref\textcolor{comment}{  !< Reference fluxes}
2939   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{        !< Grid metric of target fluxes}
2940   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(out)} :: fluxes\textcolor{comment}{     !< Target fluxes}
2941 
2942   \textcolor{keywordtype}{logical} :: do\_ustar, do\_water, do\_heat, do\_salt, do\_press, do\_shelf, &
2943       do\_iceberg, do\_heat\_added, do\_buoy
2944 
2945   \textcolor{keyword}{call }get\_forcing\_groups(fluxes\_ref, do\_water, do\_heat, do\_ustar, do\_press, &
2946       do\_shelf, do\_iceberg, do\_salt, do\_heat\_added, do\_buoy)
2947 
2948   \textcolor{keyword}{call }allocate\_forcing\_type(g, fluxes, do\_water, do\_heat, do\_ustar, &
2949       do\_press, do\_shelf, do\_iceberg, do\_salt)
2950 
2951   \textcolor{comment}{! The following fluxes would typically be allocated by the driver}
2952   \textcolor{keyword}{call }myalloc(fluxes%sw\_vis\_dir, g%isd, g%ied, g%jsd, g%jed, &
2953       \textcolor{keyword}{associated}(fluxes\_ref%sw\_vis\_dir))
2954   \textcolor{keyword}{call }myalloc(fluxes%sw\_vis\_dif, g%isd, g%ied, g%jsd, g%jed, &
2955       \textcolor{keyword}{associated}(fluxes\_ref%sw\_vis\_dif))
2956   \textcolor{keyword}{call }myalloc(fluxes%sw\_nir\_dir, g%isd, g%ied, g%jsd, g%jed, &
2957       \textcolor{keyword}{associated}(fluxes\_ref%sw\_nir\_dir))
2958   \textcolor{keyword}{call }myalloc(fluxes%sw\_nir\_dif, g%isd, g%ied, g%jsd, g%jed, &
2959       \textcolor{keyword}{associated}(fluxes\_ref%sw\_nir\_dif))
2960 
2961   \textcolor{keyword}{call }myalloc(fluxes%salt\_flux\_in, g%isd, g%ied, g%jsd, g%jed, &
2962       \textcolor{keyword}{associated}(fluxes\_ref%salt\_flux\_in))
2963   \textcolor{keyword}{call }myalloc(fluxes%salt\_flux\_added, g%isd, g%ied, g%jsd, g%jed, &
2964       \textcolor{keyword}{associated}(fluxes\_ref%salt\_flux\_added))
2965 
2966   \textcolor{keyword}{call }myalloc(fluxes%p\_surf\_full, g%isd, g%ied, g%jsd, g%jed, &
2967       \textcolor{keyword}{associated}(fluxes\_ref%p\_surf\_full))
2968 
2969   \textcolor{keyword}{call }myalloc(fluxes%heat\_added, g%isd, g%ied, g%jsd, g%jed, &
2970       \textcolor{keyword}{associated}(fluxes\_ref%heat\_added))
2971   \textcolor{keyword}{call }myalloc(fluxes%buoy, g%isd, g%ied, g%jsd, g%jed, &
2972       \textcolor{keyword}{associated}(fluxes\_ref%buoy))
2973 
2974   \textcolor{keyword}{call }myalloc(fluxes%TKE\_tidal, g%isd, g%ied, g%jsd, g%jed, &
2975       \textcolor{keyword}{associated}(fluxes\_ref%TKE\_tidal))
2976   \textcolor{keyword}{call }myalloc(fluxes%ustar\_tidal, g%isd, g%ied, g%jsd, g%jed, &
2977       \textcolor{keyword}{associated}(fluxes\_ref%ustar\_tidal))
2978 
2979   \textcolor{comment}{! This flag would normally be set by a control flag in allocate\_forcing\_type.}
2980   \textcolor{comment}{! Here we copy the flag from the reference forcing.}
2981   fluxes%gustless\_accum\_bug = fluxes\_ref%gustless\_accum\_bug
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_abd84b619cbabd15a33640be270be71a8}\label{namespacemom__forcing__type_abd84b619cbabd15a33640be270be71a8}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!allocate\+\_\+mech\+\_\+forcing\+\_\+by\+\_\+group@{allocate\+\_\+mech\+\_\+forcing\+\_\+by\+\_\+group}}
\index{allocate\+\_\+mech\+\_\+forcing\+\_\+by\+\_\+group@{allocate\+\_\+mech\+\_\+forcing\+\_\+by\+\_\+group}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{allocate\+\_\+mech\+\_\+forcing\+\_\+by\+\_\+group()}{allocate\_mech\_forcing\_by\_group()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::allocate\+\_\+mech\+\_\+forcing\+\_\+by\+\_\+group (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(inout)}]{forces,  }\item[{logical, intent(in), optional}]{stress,  }\item[{logical, intent(in), optional}]{ustar,  }\item[{logical, intent(in), optional}]{shelf,  }\item[{logical, intent(in), optional}]{press,  }\item[{logical, intent(in), optional}]{iceberg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Conditionally allocate fields within the mechanical forcing type using control flags. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & Ocean grid structure\\
\hline
\mbox{\tt in,out}  & {\em forces} & Forcing fields structure\\
\hline
\mbox{\tt in}  & {\em stress} & If present and true, allocate taux, tauy\\
\hline
\mbox{\tt in}  & {\em ustar} & If present and true, allocate ustar and related fields\\
\hline
\mbox{\tt in}  & {\em shelf} & If present and true, allocate forces for ice-\/shelf\\
\hline
\mbox{\tt in}  & {\em press} & If present and true, allocate p\+\_\+surf and related fields\\
\hline
\mbox{\tt in}  & {\em iceberg} & If present and true, allocate forces for icebergs \\
\hline
\end{DoxyParams}


Definition at line 2989 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2989   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{       !< Ocean grid structure}
2990   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{  !< Forcing fields structure}
2991 
2992   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: stress\textcolor{comment}{  !< If present and true, allocate taux, tauy}
2993   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: ustar\textcolor{comment}{   !< If present and true, allocate ustar and related fields}
2994   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: shelf\textcolor{comment}{   !< If present and true, allocate forces for ice-shelf}
2995   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: press\textcolor{comment}{   !< If present and true, allocate p\_surf and related fields}
2996   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)} :: iceberg\textcolor{comment}{ !< If present and true, allocate forces for icebergs}
2997 
2998   \textcolor{comment}{! Local variables}
2999   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
3000   \textcolor{keywordtype}{logical} :: heat\_water
3001 
3002   isd  = g%isd   ; ied  = g%ied    ; jsd  = g%jsd   ; jed  = g%jed
3003   isdb = g%IsdB  ; iedb = g%IedB   ; jsdb = g%JsdB  ; jedb = g%JedB
3004 
3005   \textcolor{keyword}{call }myalloc(forces%taux,isdb,iedb,jsd,jed, stress)
3006   \textcolor{keyword}{call }myalloc(forces%tauy,isd,ied,jsdb,jedb, stress)
3007 
3008   \textcolor{keyword}{call }myalloc(forces%ustar,isd,ied,jsd,jed, ustar)
3009 
3010   \textcolor{keyword}{call }myalloc(forces%p\_surf,isd,ied,jsd,jed, press)
3011   \textcolor{keyword}{call }myalloc(forces%p\_surf\_full,isd,ied,jsd,jed, press)
3012   \textcolor{keyword}{call }myalloc(forces%net\_mass\_src,isd,ied,jsd,jed, press)
3013 
3014   \textcolor{keyword}{call }myalloc(forces%rigidity\_ice\_u,isdb,iedb,jsd,jed, shelf)
3015   \textcolor{keyword}{call }myalloc(forces%rigidity\_ice\_v,isd,ied,jsdb,jedb, shelf)
3016   \textcolor{keyword}{call }myalloc(forces%frac\_shelf\_u,isdb,iedb,jsd,jed, shelf)
3017   \textcolor{keyword}{call }myalloc(forces%frac\_shelf\_v,isd,ied,jsdb,jedb, shelf)
3018 
3019   \textcolor{comment}{!These fields should only on allocated when iceberg area is being passed through the coupler.}
3020   \textcolor{keyword}{call }myalloc(forces%area\_berg,isd,ied,jsd,jed, iceberg)
3021   \textcolor{keyword}{call }myalloc(forces%mass\_berg,isd,ied,jsd,jed, iceberg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a8b0e58eae39f6285c6e929922b5874a9}\label{namespacemom__forcing__type_a8b0e58eae39f6285c6e929922b5874a9}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!allocate\+\_\+mech\+\_\+forcing\+\_\+from\+\_\+ref@{allocate\+\_\+mech\+\_\+forcing\+\_\+from\+\_\+ref}}
\index{allocate\+\_\+mech\+\_\+forcing\+\_\+from\+\_\+ref@{allocate\+\_\+mech\+\_\+forcing\+\_\+from\+\_\+ref}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{allocate\+\_\+mech\+\_\+forcing\+\_\+from\+\_\+ref()}{allocate\_mech\_forcing\_from\_ref()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::allocate\+\_\+mech\+\_\+forcing\+\_\+from\+\_\+ref (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces\+\_\+ref,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(out)}]{forces }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Conditionally allocate fields within the mechanical forcing type based on a reference forcing. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces\+\_\+ref} & Reference forcing fields\\
\hline
\mbox{\tt in}  & {\em g} & Grid metric of target forcing\\
\hline
\mbox{\tt out}  & {\em forces} & Mechanical forcing fields \\
\hline
\end{DoxyParams}


Definition at line 3028 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3028   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(in)} :: forces\_ref\textcolor{comment}{  !< Reference forcing fields}
3029   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{      !< Grid metric of target forcing}
3030   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(out)} :: forces\textcolor{comment}{   !< Mechanical forcing fields}
3031 
3032   \textcolor{keywordtype}{logical} :: do\_stress, do\_ustar, do\_shelf, do\_press, do\_iceberg
3033 
3034   \textcolor{comment}{! Identify the active fields in the reference forcing}
3035   \textcolor{keyword}{call }get\_mech\_forcing\_groups(forces\_ref, do\_stress, do\_ustar, do\_shelf, &
3036                               do\_press, do\_iceberg)
3037 
3038   \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, do\_stress, do\_ustar, do\_shelf, &
3039                              do\_press, do\_iceberg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a406a512f0d5b45c873fa91110ca7c387}\label{namespacemom__forcing__type_a406a512f0d5b45c873fa91110ca7c387}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!calculatebuoyancyflux1d@{calculatebuoyancyflux1d}}
\index{calculatebuoyancyflux1d@{calculatebuoyancyflux1d}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{calculatebuoyancyflux1d()}{calculatebuoyancyflux1d()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::calculatebuoyancyflux1d (\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(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(optics\+\_\+type), pointer}]{optics,  }\item[{integer, intent(in)}]{nsw,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{Temp,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{Salt,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{integer, intent(in)}]{j,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%ke+1), intent(inout)}]{buoyancy\+Flux,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(inout)}]{net\+Heat\+Minus\+SW,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(inout)}]{net\+Salt,  }\item[{logical, intent(in), optional}]{skip\+\_\+diags }\end{DoxyParamCaption})}



This routine calculates surface buoyancy flux by adding up the heat, FW \& salt fluxes. These are actual fluxes, with units of stuff per time. Setting dt=1 in the call to extract\+Fluxes routine allows us to get \char`\"{}stuf per time\char`\"{} rather than the time integrated fluxes needed in other routines that call extract\+Fluxes. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & ocean grid\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & surface fluxes\\
\hline
 & {\em optics} & penetrating SW optics\\
\hline
\mbox{\tt in}  & {\em nsw} & The number of frequency bands of penetrating shortwave radiation\\
\hline
\mbox{\tt in}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em temp} & prognostic temp \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em salt} & salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em tv} & thermodynamics type\\
\hline
\mbox{\tt in}  & {\em j} & j-\/row to work on\\
\hline
\mbox{\tt in,out}  & {\em buoyancyflux} & buoyancy fluxes \mbox{[}L2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em netheatminussw} & surf Heat flux \mbox{[}degC H s-\/1 $\sim$$>$ degC m s-\/1 or degC kg m-\/2 s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em netsalt} & surf salt flux \mbox{[}ppt H s-\/1 $\sim$$>$ ppt m s-\/1 or ppt kg m-\/2 s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em skip\+\_\+diags} & If present and true, skip calculating diagnostics inside extract\+Fluxes1d() \\
\hline
\end{DoxyParams}


Definition at line 889 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
889   \textcolor{keywordtype}{type}(ocean\_grid\_type),                    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{              !< ocean grid}
890   \textcolor{keywordtype}{type}(verticalGrid\_type),                  \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{             !< ocean vertical grid
       structure}
891   \textcolor{keywordtype}{type}(unit\_scale\_type),                    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{             !< A dimensional unit scaling
       type}
892   \textcolor{keywordtype}{type}(forcing),                            \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{         !< surface fluxes}
893   \textcolor{keywordtype}{type}(optics\_type),                        \textcolor{keywordtype}{pointer}       :: optics\textcolor{comment}{         !< penetrating SW optics}
894   \textcolor{keywordtype}{integer},                                  \textcolor{keywordtype}{intent(in)}    :: nsw\textcolor{comment}{            !< The number of frequency
       bands of}
895 \textcolor{comment}{                                                                            !! penetrating shortwave
       radiation}
896   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{              !< layer thickness [H ~> m or
       kg m-2]}
897   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: Temp\textcolor{comment}{           !< prognostic temp [degC]}
898   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: Salt\textcolor{comment}{           !< salinity [ppt]}
899   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                    \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{             !< thermodynamics type}
900   \textcolor{keywordtype}{integer},                                  \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{              !< j-row to work on}
901   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(G)+1)},       \textcolor{keywordtype}{intent(inout)} :: buoyancyFlux\textcolor{comment}{   !< buoyancy fluxes [L2 T-3 ~>
       m2 s-3]}
902   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))},                 \textcolor{keywordtype}{intent(inout)} :: netHeatMinusSW\textcolor{comment}{ !< surf Heat flux}
903 \textcolor{comment}{                                                                      !! [degC H s-1 ~> degC m s-1 or degC
       kg m-2 s-1]}
904   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))},                 \textcolor{keywordtype}{intent(inout)} :: netSalt\textcolor{comment}{        !< surf salt flux}
905 \textcolor{comment}{                                                                      !! [ppt H s-1 ~> ppt m s-1 or ppt kg
       m-2 s-1]}
906   \textcolor{keywordtype}{logical},                        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: skip\_diags\textcolor{comment}{     !< If present and true, skip
       calculating}
907 \textcolor{comment}{                                                                            !! diagnostics inside
       extractFluxes1d()}
908   \textcolor{comment}{! local variables}
909   \textcolor{keywordtype}{integer}                               :: k
910   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{parameter}                       :: dt = 1.    \textcolor{comment}{! to return a rate from extractFluxes1d}
911   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}              :: netH       \textcolor{comment}{! net FW flux [H s-1 ~> m s-1 or kg m-2 s-1]}
912   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}              :: netEvap    \textcolor{comment}{! net FW flux leaving ocean via evaporation}
913                                                       \textcolor{comment}{! [H s-1 ~> m s-1 or kg m-2 s-1]}
914   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}              :: netHeat    \textcolor{comment}{! net temp flux [degC H s-1 ~> degC m s-2 or degC kg
       m-2 s-1]}
915   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(max(nsw,1), SZI\_(G))}  :: penSWbnd   \textcolor{comment}{! penetrating SW radiation by band}
916                                                       \textcolor{comment}{! [degC H ~> degC m or degC kg m-2]}
917   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}              :: pressure   \textcolor{comment}{! pressure at the surface [R L2 T-2 ~> Pa]}
918   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}              :: dRhodT     \textcolor{comment}{! density partial derivative wrt temp [R degC-1 ~> kg
       m-3 degC-1]}
919   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}              :: dRhodS     \textcolor{comment}{! density partial derivative wrt saln [R ppt-1 ~> kg
       m-3 ppt-1]}
920   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(G)+1)}    :: netPen     \textcolor{comment}{! The net penetrating shortwave radiation at each
       level}
921                                                       \textcolor{comment}{! [degC H ~> degC m or degC kg m-2]}
922 
923   \textcolor{keywordtype}{logical} :: useRiverHeatContent
924   \textcolor{keywordtype}{logical} :: useCalvingHeatContent
925   \textcolor{keywordtype}{real}    :: depthBeforeScalingFluxes  \textcolor{comment}{! A depth scale [H ~> m or kg m-2]}
926   \textcolor{keywordtype}{real}    :: GoRho \textcolor{comment}{! The gravitational acceleration divided by mean density times some}
927                    \textcolor{comment}{! unit conversion factors [L2 H-1 s R-1 T-3 ~> m4 kg-1 s-2 or m7 kg-2 s-2]}
928   \textcolor{keywordtype}{real}    :: H\_limit\_fluxes            \textcolor{comment}{! Another depth scale [H ~> m or kg m-2]}
929   \textcolor{keywordtype}{integer} :: i
930 
931   \textcolor{comment}{!  smg: what do we do when have heat fluxes from calving and river?}
932   useriverheatcontent   = .false.
933   usecalvingheatcontent = .false.
934 
935   depthbeforescalingfluxes = max( gv%Angstrom\_H, 1.e-30*gv%m\_to\_H )
936   pressure(:) = 0.
937   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%p\_surf)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=g%isc,g%iec ; pressure(i) = tv%p\_surf(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
938   gorho       = (gv%g\_Earth * gv%H\_to\_Z*us%T\_to\_s) / gv%Rho0
939 
940   h\_limit\_fluxes = depthbeforescalingfluxes
941 
942   \textcolor{comment}{! The surface forcing is contained in the fluxes type.}
943   \textcolor{comment}{! We aggregate the thermodynamic forcing for a time step into the following:}
944   \textcolor{comment}{! netH       = water added/removed via surface fluxes [H s-1 ~> m s-1 or kg m-2 s-1]}
945   \textcolor{comment}{! netHeat    = heat via surface fluxes [degC H s-1 ~> degC m s-1 or degC kg m-2 s-1]}
946   \textcolor{comment}{! netSalt    = salt via surface fluxes [ppt H s-1 ~> ppt m s-1 or gSalt m-2 s-1]}
947   \textcolor{comment}{! Note that unlike other calls to extractFLuxes1d() that return the time-integrated flux}
948   \textcolor{comment}{! this call returns the rate because dt=1}
949   \textcolor{keyword}{call }extractfluxes1d(g, gv, us, fluxes, optics, nsw, j, dt*us%s\_to\_T,               &
950                 depthbeforescalingfluxes, useriverheatcontent, usecalvingheatcontent, &
951                 h(:,j,:), temp(:,j,:), neth, netevap, netheatminussw,                 &
952                 netsalt, penswbnd, tv, .false., skip\_diags=skip\_diags)
953 
954   \textcolor{comment}{! Sum over bands and attenuate as a function of depth}
955   \textcolor{comment}{! netPen is the netSW as a function of depth}
956   \textcolor{keyword}{call }sumswoverbands(g, gv, us, h(:,j,:), optics\_nbands(optics), optics, j, dt*us%s\_to\_T, &
957                       h\_limit\_fluxes, .true., penswbnd, netpen)
958 
959   \textcolor{comment}{! Density derivatives}
960   \textcolor{keyword}{call }calculate\_density\_derivs(temp(:,j,1), salt(:,j,1), pressure, drhodt, drhods, &
961                                 tv%eqn\_of\_state, eos\_domain(g%HI))
962 
963   \textcolor{comment}{! Adjust netSalt to reflect dilution effect of FW flux}
964   netsalt(g%isc:g%iec) = netsalt(g%isc:g%iec) - salt(g%isc:g%iec,j,1) * neth(g%isc:g%iec) \textcolor{comment}{! ppt H/s}
965 
966   \textcolor{comment}{! Add in the SW heating for purposes of calculating the net}
967   \textcolor{comment}{! surface buoyancy flux affecting the top layer.}
968   \textcolor{comment}{!netHeat(:) = netHeatMinusSW(:) + sum( penSWbnd, dim=1 )}
969   netheat(g%isc:g%iec) = netheatminussw(g%isc:g%iec) + netpen(g%isc:g%iec,1) \textcolor{comment}{! K H/s}
970 
971   \textcolor{comment}{! Convert to a buoyancy flux, excluding penetrating SW heating}
972   buoyancyflux(g%isc:g%iec,1) = - gorho * ( drhods(g%isc:g%iec) * netsalt(g%isc:g%iec) + &
973                                              drhodt(g%isc:g%iec) * netheat(g%isc:g%iec) ) \textcolor{comment}{! [L2 T-3 ~> m2
       s-3]}
974   \textcolor{comment}{! We also have a penetrative buoyancy flux associated with penetrative SW}
975   \textcolor{keywordflow}{do} k=2, g%ke+1
976     buoyancyflux(g%isc:g%iec,k) = - gorho * ( drhodt(g%isc:g%iec) * netpen(g%isc:g%iec,k) ) \textcolor{comment}{! [L2 T-3 ~> m2
       s-3]}
977 \textcolor{keywordflow}{  enddo}
978 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_ae84373c4a259bd04330ec673af0fa536}\label{namespacemom__forcing__type_ae84373c4a259bd04330ec673af0fa536}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!calculatebuoyancyflux2d@{calculatebuoyancyflux2d}}
\index{calculatebuoyancyflux2d@{calculatebuoyancyflux2d}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{calculatebuoyancyflux2d()}{calculatebuoyancyflux2d()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::calculatebuoyancyflux2d (\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(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(optics\+\_\+type), pointer}]{optics,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{Temp,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{Salt,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke+1), intent(inout)}]{buoyancy\+Flux,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(inout), optional}]{net\+Heat\+Minus\+SW,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(inout), optional}]{net\+Salt,  }\item[{logical, intent(in), optional}]{skip\+\_\+diags }\end{DoxyParamCaption})}



Calculates surface buoyancy flux by adding up the heat, FW and salt fluxes, for 2d arrays. This is a wrapper for calculate\+Buoyancy\+Flux1d. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & ocean grid\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & surface fluxes\\
\hline
 & {\em optics} & SW ocean optics\\
\hline
\mbox{\tt in}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em temp} & temperature \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em salt} & salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em tv} & thermodynamics type\\
\hline
\mbox{\tt in,out}  & {\em buoyancyflux} & buoyancy fluxes \mbox{[}L2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em netheatminussw} & surf temp flux \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em netsalt} & surf salt flux \mbox{[}ppt H $\sim$$>$ ppt m or ppt kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em skip\+\_\+diags} & If present and true, skip calculating diagnostics inside extract\+Fluxes1d() \\
\hline
\end{DoxyParams}


Definition at line 986 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
986   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{      !< ocean grid}
987   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{     !< ocean vertical grid structure}
988   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{     !< A dimensional unit scaling type}
989   \textcolor{keywordtype}{type}(forcing),                              \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< surface fluxes}
990   \textcolor{keywordtype}{type}(optics\_type),                          \textcolor{keywordtype}{pointer}       :: optics\textcolor{comment}{ !< SW ocean optics}
991   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{      !< layer thickness [H ~> m or kg m-2]}
992   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}    :: Temp\textcolor{comment}{   !< temperature [degC]}
993   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},   \textcolor{keywordtype}{intent(in)}    :: Salt\textcolor{comment}{   !< salinity [ppt]}
994   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< thermodynamics type}
995   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G)+1)}, \textcolor{keywordtype}{intent(inout)} :: buoyancyFlux\textcolor{comment}{   !< buoyancy fluxes [L2 T-3 ~>
       m2 s-3]}
996   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: netHeatMinusSW\textcolor{comment}{ !< surf temp flux}
997 \textcolor{comment}{                                                                              !! [degC H ~> degC m or degC
       kg m-2]}
998   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: netSalt\textcolor{comment}{        !< surf salt flux}
999 \textcolor{comment}{                                                                              !! [ppt H ~> ppt m or ppt kg
       m-2]}
1000   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                          \textcolor{keywordtype}{intent(in)}    :: skip\_diags\textcolor{comment}{     !< If present and true, skip
       calculating}
1001 \textcolor{comment}{                                                                              !! diagnostics inside
       extractFluxes1d()}
1002   \textcolor{comment}{! local variables}
1003   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension( SZI\_(G) )} :: netT \textcolor{comment}{! net temperature flux [degC H s-1 ~> degC m s-2 or degC kg m-2 s-1]}
1004   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension( SZI\_(G) )} :: netS \textcolor{comment}{! net saln flux !! [ppt H s-1 ~> ppt m s-1 or ppt kg m-2 s-1]}
1005   \textcolor{keywordtype}{integer} :: j
1006 
1007   nett(g%isc:g%iec) = 0. ; nets(g%isc:g%iec) = 0.
1008 
1009   \textcolor{comment}{!$OMP parallel do default(shared) firstprivate(netT,netS)}
1010   \textcolor{keywordflow}{do} j=g%jsc,g%jec
1011     \textcolor{keyword}{call }calculatebuoyancyflux1d(g, gv, us, fluxes, optics, optics\_nbands(optics), h, temp, salt, &
1012                                  tv, j, buoyancyflux(:,j,:), nett, nets, skip\_diags=skip\_diags)
1013     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(netheatminussw)) netheatminussw(g%isc:g%iec,j) = nett(g%isc:g%iec)
1014     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(netsalt)) netsalt(g%isc:g%iec,j) = nets(g%isc:g%iec)
1015 \textcolor{keywordflow}{  enddo}
1016 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_aa8ee4e3dace6d294ceb8bfe445dead1b}\label{namespacemom__forcing__type_aa8ee4e3dace6d294ceb8bfe445dead1b}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!copy\+\_\+back\+\_\+forcing\+\_\+fields@{copy\+\_\+back\+\_\+forcing\+\_\+fields}}
\index{copy\+\_\+back\+\_\+forcing\+\_\+fields@{copy\+\_\+back\+\_\+forcing\+\_\+fields}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{copy\+\_\+back\+\_\+forcing\+\_\+fields()}{copy\_back\_forcing\_fields()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::copy\+\_\+back\+\_\+forcing\+\_\+fields (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(inout)}]{forces,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G }\end{DoxyParamCaption})}



This subroutine copies the computational domains of common forcing fields from a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type to a (thermodynamic) forcing type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em g} & grid type \\
\hline
\end{DoxyParams}


Definition at line 2199 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2199   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)}    :: fluxes\textcolor{comment}{   !< A structure containing thermodynamic forcing fields}
2200   \textcolor{keywordtype}{type}(mech\_forcing),      \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{   !< A structure with the driving mechanical forces}
2201   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{        !< grid type}
2202 
2203   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
2204   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
2205 
2206   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar) .and. \textcolor{keyword}{associated}(fluxes%ustar)) \textcolor{keywordflow}{then}
2207     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2208       forces%ustar(i,j) = fluxes%ustar(i,j)
2209 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2210 \textcolor{keywordflow}{  endif}
2211 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a44ade8a584921047fcf960f4cdb9914c}\label{namespacemom__forcing__type_a44ade8a584921047fcf960f4cdb9914c}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!copy\+\_\+common\+\_\+forcing\+\_\+fields@{copy\+\_\+common\+\_\+forcing\+\_\+fields}}
\index{copy\+\_\+common\+\_\+forcing\+\_\+fields@{copy\+\_\+common\+\_\+forcing\+\_\+fields}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{copy\+\_\+common\+\_\+forcing\+\_\+fields()}{copy\_common\_forcing\_fields()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::copy\+\_\+common\+\_\+forcing\+\_\+fields (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{logical, intent(in), optional}]{skip\+\_\+pres }\end{DoxyParamCaption})}



This subroutine copies the computational domains of common forcing fields from a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type to a (thermodynamic) forcing type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em g} & grid type\\
\hline
\mbox{\tt in}  & {\em skip\+\_\+pres} & If present and true, do not copy pressure fields. \\
\hline
\end{DoxyParams}


Definition at line 2061 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2061   \textcolor{keywordtype}{type}(mech\_forcing),      \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{   !< A structure with the driving mechanical forces}
2062   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{   !< A structure containing thermodynamic forcing fields}
2063   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{        !< grid type}
2064   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: skip\_pres\textcolor{comment}{ !< If present and true, do not copy pressure fields.}
2065 
2066   \textcolor{keywordtype}{logical} :: do\_pres
2067   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
2068   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
2069 
2070   do\_pres = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(skip\_pres)) do\_pres = .not.skip\_pres
2071 
2072   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar) .and. \textcolor{keyword}{associated}(fluxes%ustar)) \textcolor{keywordflow}{then}
2073     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2074       fluxes%ustar(i,j) = forces%ustar(i,j)
2075 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2076 \textcolor{keywordflow}{  endif}
2077 
2078   \textcolor{keywordflow}{if} (do\_pres) \textcolor{keywordflow}{then}
2079     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf) .and. \textcolor{keyword}{associated}(fluxes%p\_surf)) \textcolor{keywordflow}{then}
2080       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2081         fluxes%p\_surf(i,j) = forces%p\_surf(i,j)
2082 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2083 \textcolor{keywordflow}{    endif}
2084 
2085     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf\_full) .and. \textcolor{keyword}{associated}(fluxes%p\_surf\_full)) \textcolor{keywordflow}{then}
2086       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2087         fluxes%p\_surf\_full(i,j) = forces%p\_surf\_full(i,j)
2088 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2089 \textcolor{keywordflow}{    endif}
2090 
2091     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf\_SSH, forces%p\_surf\_full)) \textcolor{keywordflow}{then}
2092       fluxes%p\_surf\_SSH => fluxes%p\_surf\_full
2093     \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(forces%p\_surf\_SSH, forces%p\_surf)) \textcolor{keywordflow}{then}
2094       fluxes%p\_surf\_SSH => fluxes%p\_surf
2095 \textcolor{keywordflow}{    endif}
2096 \textcolor{keywordflow}{  endif}
2097 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a432b1cbc47ab082b64bf7007a8674973}\label{namespacemom__forcing__type_a432b1cbc47ab082b64bf7007a8674973}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!deallocate\+\_\+forcing\+\_\+type@{deallocate\+\_\+forcing\+\_\+type}}
\index{deallocate\+\_\+forcing\+\_\+type@{deallocate\+\_\+forcing\+\_\+type}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{deallocate\+\_\+forcing\+\_\+type()}{deallocate\_forcing\_type()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::deallocate\+\_\+forcing\+\_\+type (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes }\end{DoxyParamCaption})}



Deallocate the forcing type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em fluxes} & Forcing fields structure \\
\hline
\end{DoxyParams}


Definition at line 3115 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3115   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< Forcing fields structure}
3116 
3117   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar))                \textcolor{keyword}{deallocate}(fluxes%ustar)
3118   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar\_gustless))       \textcolor{keyword}{deallocate}(fluxes%ustar\_gustless)
3119   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%buoy))                 \textcolor{keyword}{deallocate}(fluxes%buoy)
3120   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw))                   \textcolor{keyword}{deallocate}(fluxes%sw)
3121   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat))     \textcolor{keyword}{deallocate}(fluxes%seaice\_melt\_heat)
3122   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_vis\_dir))           \textcolor{keyword}{deallocate}(fluxes%sw\_vis\_dir)
3123   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_vis\_dif))           \textcolor{keyword}{deallocate}(fluxes%sw\_vis\_dif)
3124   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_nir\_dir))           \textcolor{keyword}{deallocate}(fluxes%sw\_nir\_dir)
3125   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_nir\_dif))           \textcolor{keyword}{deallocate}(fluxes%sw\_nir\_dif)
3126   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lw))                   \textcolor{keyword}{deallocate}(fluxes%lw)
3127   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent))               \textcolor{keyword}{deallocate}(fluxes%latent)
3128   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent\_evap\_diag))     \textcolor{keyword}{deallocate}(fluxes%latent\_evap\_diag)
3129   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent\_fprec\_diag))    \textcolor{keyword}{deallocate}(fluxes%latent\_fprec\_diag)
3130   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent\_frunoff\_diag))  \textcolor{keyword}{deallocate}(fluxes%latent\_frunoff\_diag)
3131   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens))                 \textcolor{keyword}{deallocate}(fluxes%sens)
3132   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_added))           \textcolor{keyword}{deallocate}(fluxes%heat\_added)
3133   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff)) \textcolor{keyword}{deallocate}(fluxes%heat\_content\_lrunoff)
3134   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff)) \textcolor{keyword}{deallocate}(fluxes%heat\_content\_frunoff)
3135   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt)) \textcolor{keyword}{deallocate}(fluxes%heat\_content\_icemelt)
3136   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lprec))   \textcolor{keyword}{deallocate}(fluxes%heat\_content\_lprec)
3137   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_fprec))   \textcolor{keyword}{deallocate}(fluxes%heat\_content\_fprec)
3138   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_cond))    \textcolor{keyword}{deallocate}(fluxes%heat\_content\_cond)
3139   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_massout)) \textcolor{keyword}{deallocate}(fluxes%heat\_content\_massout)
3140   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_massin))  \textcolor{keyword}{deallocate}(fluxes%heat\_content\_massin)
3141   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap))                 \textcolor{keyword}{deallocate}(fluxes%evap)
3142   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec))                \textcolor{keyword}{deallocate}(fluxes%lprec)
3143   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%fprec))                \textcolor{keyword}{deallocate}(fluxes%fprec)
3144   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%vprec))                \textcolor{keyword}{deallocate}(fluxes%vprec)
3145   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lrunoff))              \textcolor{keyword}{deallocate}(fluxes%lrunoff)
3146   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frunoff))              \textcolor{keyword}{deallocate}(fluxes%frunoff)
3147   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt))          \textcolor{keyword}{deallocate}(fluxes%seaice\_melt)
3148   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux))            \textcolor{keyword}{deallocate}(fluxes%salt\_flux)
3149   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf\_full))          \textcolor{keyword}{deallocate}(fluxes%p\_surf\_full)
3150   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf))               \textcolor{keyword}{deallocate}(fluxes%p\_surf)
3151   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%TKE\_tidal))            \textcolor{keyword}{deallocate}(fluxes%TKE\_tidal)
3152   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar\_tidal))          \textcolor{keyword}{deallocate}(fluxes%ustar\_tidal)
3153   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar\_shelf))          \textcolor{keyword}{deallocate}(fluxes%ustar\_shelf)
3154   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%iceshelf\_melt))        \textcolor{keyword}{deallocate}(fluxes%iceshelf\_melt)
3155   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frac\_shelf\_h))         \textcolor{keyword}{deallocate}(fluxes%frac\_shelf\_h)
3156   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar\_berg))           \textcolor{keyword}{deallocate}(fluxes%ustar\_berg)
3157   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%area\_berg))            \textcolor{keyword}{deallocate}(fluxes%area\_berg)
3158   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%mass\_berg))            \textcolor{keyword}{deallocate}(fluxes%mass\_berg)
3159 
3160   \textcolor{keyword}{call }coupler\_type\_destructor(fluxes%tr\_fluxes)
3161 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_aaadc0cd523729cb059cb62a2a224970b}\label{namespacemom__forcing__type_aaadc0cd523729cb059cb62a2a224970b}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!deallocate\+\_\+mech\+\_\+forcing@{deallocate\+\_\+mech\+\_\+forcing}}
\index{deallocate\+\_\+mech\+\_\+forcing@{deallocate\+\_\+mech\+\_\+forcing}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{deallocate\+\_\+mech\+\_\+forcing()}{deallocate\_mech\_forcing()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::deallocate\+\_\+mech\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(inout)}]{forces }\end{DoxyParamCaption})}



Deallocate the mechanical forcing type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em forces} & Forcing fields structure \\
\hline
\end{DoxyParams}


Definition at line 3167 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3167   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{  !< Forcing fields structure}
3168 
3169   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%taux))  \textcolor{keyword}{deallocate}(forces%taux)
3170   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%tauy))  \textcolor{keyword}{deallocate}(forces%tauy)
3171   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) \textcolor{keyword}{deallocate}(forces%ustar)
3172   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf))         \textcolor{keyword}{deallocate}(forces%p\_surf)
3173   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf\_full))    \textcolor{keyword}{deallocate}(forces%p\_surf\_full)
3174   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%net\_mass\_src))   \textcolor{keyword}{deallocate}(forces%net\_mass\_src)
3175   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%rigidity\_ice\_u)) \textcolor{keyword}{deallocate}(forces%rigidity\_ice\_u)
3176   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%rigidity\_ice\_v)) \textcolor{keyword}{deallocate}(forces%rigidity\_ice\_v)
3177   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%frac\_shelf\_u))   \textcolor{keyword}{deallocate}(forces%frac\_shelf\_u)
3178   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%frac\_shelf\_v))   \textcolor{keyword}{deallocate}(forces%frac\_shelf\_v)
3179   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%area\_berg))      \textcolor{keyword}{deallocate}(forces%area\_berg)
3180   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%mass\_berg))      \textcolor{keyword}{deallocate}(forces%mass\_berg)
3181 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a6bf986155aba959222a117ca40ba7e0d}\label{namespacemom__forcing__type_a6bf986155aba959222a117ca40ba7e0d}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!extractfluxes1d@{extractfluxes1d}}
\index{extractfluxes1d@{extractfluxes1d}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{extractfluxes1d()}{extractfluxes1d()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::extractfluxes1d (\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(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(optics\+\_\+type), pointer}]{optics,  }\item[{integer, intent(in)}]{nsw,  }\item[{integer, intent(in)}]{j,  }\item[{real, intent(in)}]{dt,  }\item[{real, intent(in)}]{Flux\+Rescale\+Depth,  }\item[{logical, intent(in)}]{use\+River\+Heat\+Content,  }\item[{logical, intent(in)}]{use\+Calving\+Heat\+Content,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%ke), intent(in)}]{h,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%ke), intent(in)}]{T,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out)}]{net\+Mass\+In\+Out,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out)}]{net\+Mass\+Out,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out)}]{net\+\_\+heat,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out)}]{net\+\_\+salt,  }\item[{real, dimension(max(1,nsw),g\%isd\+:g\%ied), intent(out)}]{pen\+\_\+\+S\+W\+\_\+bnd,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{logical, intent(in)}]{aggregate\+\_\+\+FW,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out), optional}]{nonpen\+SW,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out), optional}]{netmass\+In\+Out\+\_\+rate,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out), optional}]{net\+\_\+\+Heat\+\_\+\+Rate,  }\item[{real, dimension( g \%isd\+: g \%ied), intent(out), optional}]{net\+\_\+salt\+\_\+rate,  }\item[{real, dimension(max(1,nsw),g\%isd\+:g\%ied), intent(out), optional}]{pen\+\_\+sw\+\_\+bnd\+\_\+\+Rate,  }\item[{logical, intent(in), optional}]{skip\+\_\+diags }\end{DoxyParamCaption})}



This subroutine extracts fluxes from the surface fluxes type. It works on a j-\/row for optimization purposes. The 2d (i,j) wrapper is the next subroutine below. This routine multiplies fluxes by dt, so that the result is an accumulation of fluxes over a time step. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & structure containing pointers to possible forcing fields. N\+U\+LL unused fields.\\
\hline
 & {\em optics} & pointer to optics\\
\hline
\mbox{\tt in}  & {\em nsw} & number of bands of penetrating SW\\
\hline
\mbox{\tt in}  & {\em j} & j-\/index to work on\\
\hline
\mbox{\tt in}  & {\em dt} & The time step for these fluxes \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em fluxrescaledepth} & min ocean depth before fluxes are scaled away \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em useriverheatcontent} & logical for river heat content\\
\hline
\mbox{\tt in}  & {\em usecalvingheatcontent} & logical for calving heat content\\
\hline
\mbox{\tt in}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em t} & layer temperatures \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt out}  & {\em netmassinout} & net mass flux (non-\/\+Bouss) or volume flux (if Bouss) of water in/out of ocean over a time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em netmassout} & net mass flux (non-\/\+Bouss) or volume flux (if Bouss) of water leaving ocean surface over a time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. net\+Mass\+Out $<$ 0 means mass leaves ocean.\\
\hline
\mbox{\tt out}  & {\em net\+\_\+heat} & net heat at the surface accumulated over a time step for coupler + restoring. Exclude two terms from net\+\_\+heat\+: (1) downwelling (penetrative) SW, (2) evaporation heat content, (since do not yet know evap temperature). \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em net\+\_\+salt} & surface salt flux into the ocean accumulated over a time step \mbox{[}ppt H $\sim$$>$ ppt m or ppt kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em pen\+\_\+sw\+\_\+bnd} & penetrating SW flux, split into bands. \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]} and array size nsw x G isd\+: G ied, where nsw=number of SW bands in pen\+\_\+\+S\+W\+\_\+bnd. This heat flux is not part of net\+\_\+heat.\\
\hline
\mbox{\tt in,out}  & {\em tv} & structure containing pointers to available thermodynamic fields. Used to keep track of the heat flux associated with net mass fluxes into the ocean.\\
\hline
\mbox{\tt in}  & {\em aggregate\+\_\+fw} & For determining how to aggregate forcing.\\
\hline
\mbox{\tt out}  & {\em nonpensw} & Non-\/penetrating SW used in net\+\_\+heat\\
\hline
\mbox{\tt out}  & {\em net\+\_\+heat\+\_\+rate} & Rate of net surface heating\\
\hline
\mbox{\tt out}  & {\em net\+\_\+salt\+\_\+rate} & Surface salt flux into the ocean\\
\hline
\mbox{\tt out}  & {\em netmassinout\+\_\+rate} & Rate of net mass flux into the ocean\\
\hline
\mbox{\tt out}  & {\em pen\+\_\+sw\+\_\+bnd\+\_\+rate} & Rate of penetrative shortwave heating\\
\hline
\mbox{\tt in}  & {\em skip\+\_\+diags} & If present and true, skip calculating diagnostics \\
\hline
\end{DoxyParams}


Definition at line 365 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
365 
366   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{              !< ocean grid structure}
367   \textcolor{keywordtype}{type}(verticalGrid\_type),  \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{             !< ocean vertical grid structure}
368   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{             !< A dimensional unit scaling type}
369   \textcolor{keywordtype}{type}(forcing),            \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{         !< structure containing pointers to possible}
370 \textcolor{comment}{                                                            !! forcing fields. NULL unused fields.}
371   \textcolor{keywordtype}{type}(optics\_type),        \textcolor{keywordtype}{pointer}       :: optics\textcolor{comment}{         !< pointer to optics}
372   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{intent(in)}    :: nsw\textcolor{comment}{            !< number of bands of penetrating SW}
373   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{              !< j-index to work on}
374   \textcolor{keywordtype}{real},                     \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{             !< The time step for these fluxes [T ~> s]}
375   \textcolor{keywordtype}{real},                     \textcolor{keywordtype}{intent(in)}    :: FluxRescaleDepth\textcolor{comment}{ !< min ocean depth before fluxes}
376 \textcolor{comment}{                                                            !! are scaled away [H ~> m or kg m-2]}
377   \textcolor{keywordtype}{logical},                  \textcolor{keywordtype}{intent(in)}    :: useRiverHeatContent\textcolor{comment}{   !< logical for river heat content}
378   \textcolor{keywordtype}{logical},                  \textcolor{keywordtype}{intent(in)}    :: useCalvingHeatContent\textcolor{comment}{ !< logical for calving heat content}
379   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(G))}, &
380                             \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{              !< layer thickness [H ~> m or kg m-2]}
381   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(G))}, &
382                             \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{              !< layer temperatures [degC]}
383   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, \textcolor{keywordtype}{intent(out)}   :: netMassInOut\textcolor{comment}{   !< net mass flux (non-Bouss) or volume flux}
384 \textcolor{comment}{                                                            !! (if Bouss) of water in/out of ocean over}
385 \textcolor{comment}{                                                            !! a time step [H ~> m or kg m-2]}
386   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, \textcolor{keywordtype}{intent(out)}   :: netMassOut\textcolor{comment}{     !< net mass flux (non-Bouss) or volume flux}
387 \textcolor{comment}{                                                            !! (if Bouss) of water leaving ocean surface}
388 \textcolor{comment}{                                                            !! over a time step [H ~> m or kg m-2].}
389 \textcolor{comment}{                                                            !! netMassOut < 0 means mass leaves ocean.}
390   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, \textcolor{keywordtype}{intent(out)}   :: net\_heat\textcolor{comment}{       !< net heat at the surface accumulated over a}
391 \textcolor{comment}{                                                            !! time step for coupler + restoring.}
392 \textcolor{comment}{                                                            !! Exclude two terms from net\_heat:}
393 \textcolor{comment}{                                                            !! (1) downwelling (penetrative) SW,}
394 \textcolor{comment}{                                                            !! (2) evaporation heat content,}
395 \textcolor{comment}{                                                            !! (since do not yet know evap temperature).}
396 \textcolor{comment}{                                                            !! [degC H ~> degC m or degC kg m-2].}
397   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, \textcolor{keywordtype}{intent(out)}   :: net\_salt\textcolor{comment}{       !< surface salt flux into the ocean}
398 \textcolor{comment}{                                                            !! accumulated over a time step}
399 \textcolor{comment}{                                                            !! [ppt H ~> ppt m or ppt kg m-2].}
400   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(max(1,nsw),G%isd:G%ied)}, \textcolor{keywordtype}{intent(out)} :: pen\_SW\_bnd\textcolor{comment}{ !< penetrating SW flux, split into
       bands.}
401 \textcolor{comment}{                                                            !! [degC H ~> degC m or degC kg m-2]}
402 \textcolor{comment}{                                                            !! and array size nsw x SZI\_(G), where}
403 \textcolor{comment}{                                                            !! nsw=number of SW bands in pen\_SW\_bnd.}
404 \textcolor{comment}{                                                            !! This heat flux is not part of net\_heat.}
405   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),    \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{             !< structure containing pointers to available}
406 \textcolor{comment}{                                                            !! thermodynamic fields. Used to keep}
407 \textcolor{comment}{                                                            !! track of the heat flux associated with net}
408 \textcolor{comment}{                                                            !! mass fluxes into the ocean.}
409   \textcolor{keywordtype}{logical},                  \textcolor{keywordtype}{intent(in)}    :: aggregate\_FW\textcolor{comment}{   !< For determining how to aggregate forcing.}
410   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, &
411                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: nonpenSW\textcolor{comment}{       !< Non-penetrating SW used in net\_heat}
412 \textcolor{comment}{                                                            !! [degC H ~> degC m or degC kg m-2].}
413 \textcolor{comment}{                                                            !! Summed over SW bands when diagnosing
       nonpenSW.}
414   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, &
415                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: net\_Heat\_rate\textcolor{comment}{  !< Rate of net surface heating}
416 \textcolor{comment}{                                                            !! [degC H T-1 ~> degC m s-1 or degC kg m-2
       s-1].}
417   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, &
418                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: net\_salt\_rate\textcolor{comment}{  !< Surface salt flux into the ocean}
419 \textcolor{comment}{                                                            !! [ppt H T-1 ~> ppt m s-1 or ppt kg m-2 s-1].}
420   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G))}, &
421                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: netmassInOut\_rate\textcolor{comment}{ !< Rate of net mass flux into the ocean}
422 \textcolor{comment}{                                                            !! [H T-1 ~> m s-1 or kg m-2 s-1].}
423   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(max(1,nsw),G%isd:G%ied)}, &
424                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: pen\_sw\_bnd\_rate\textcolor{comment}{ !< Rate of penetrative shortwave heating}
425 \textcolor{comment}{                                                             !! [degC H T-1 ~> degC m s-1 or degC kg m-2
       s-1].}
426   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: skip\_diags\textcolor{comment}{      !< If present and true, skip calculating
       diagnostics}
427 
428   \textcolor{comment}{! local}
429   \textcolor{keywordtype}{real} :: htot(SZI\_(G))       \textcolor{comment}{! total ocean depth [H ~> m or kg m-2]}
430   \textcolor{keywordtype}{real} :: Pen\_sw\_tot(SZI\_(G)) \textcolor{comment}{! sum across all bands of Pen\_SW [degC H ~> degC m or degC kg m-2].}
431   \textcolor{keywordtype}{real} :: pen\_sw\_tot\_rate(SZI\_(G)) \textcolor{comment}{! Summed rate of shortwave heating across bands}
432                               \textcolor{comment}{! [degC H T-1 ~> degC m s-1 or degC kg m-2 s-1]}
433   \textcolor{keywordtype}{real} :: Ih\_limit            \textcolor{comment}{! inverse depth at which surface fluxes start to be limited}
434                               \textcolor{comment}{! or 0 for no limiting [H-1 ~> m-1 or m2 kg-1]}
435   \textcolor{keywordtype}{real} :: scale               \textcolor{comment}{! scale scales away fluxes if depth < FluxRescaleDepth}
436   \textcolor{keywordtype}{real} :: I\_Cp                \textcolor{comment}{! 1.0 / C\_p [degC Q-1 ~> kg degC J-1]}
437   \textcolor{keywordtype}{real} :: I\_Cp\_Hconvert       \textcolor{comment}{! Unit conversion factors divided by the heat capacity}
438                               \textcolor{comment}{! [degC H R-1 Z-1 Q-1 ~> degC m3 J-1 or kg degC J-1]}
439   \textcolor{keywordtype}{logical} :: calculate\_diags  \textcolor{comment}{! Indicate to calculate/update diagnostic arrays}
440   \textcolor{keywordtype}{character(len=200)} :: mesg
441   \textcolor{keywordtype}{integer}            :: is, ie, nz, i, k, n
442 
443   \textcolor{keywordtype}{logical} :: do\_NHR, do\_NSR, do\_NMIOR, do\_PSWBR
444 
445   \textcolor{comment}{!BGR-Jul 5,2017\{}
446   \textcolor{comment}{! Initializes/sets logicals if 'rates' are requested}
447   \textcolor{comment}{! These factors are required for legacy reasons}
448   \textcolor{comment}{!  and therefore computed only when optional outputs are requested}
449   do\_nhr = .false.
450   do\_nsr = .false.
451   do\_nmior = .false.
452   do\_pswbr = .false.
453   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(net\_heat\_rate)) do\_nhr = .true.
454   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(net\_salt\_rate)) do\_nsr = .true.
455   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(netmassinout\_rate)) do\_nmior = .true.
456   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pen\_sw\_bnd\_rate)) do\_pswbr = .true.
457   \textcolor{comment}{!\}BGR}
458 
459   ih\_limit  = 0.0 ; \textcolor{keywordflow}{if} (fluxrescaledepth > 0.0) ih\_limit  = 1.0 / fluxrescaledepth
460   i\_cp      = 1.0 / fluxes%C\_p
461   i\_cp\_hconvert = 1.0 / (gv%H\_to\_RZ * fluxes%C\_p)
462 
463   is = g%isc ; ie = g%iec ; nz = g%ke
464 
465   calculate\_diags = .true.
466   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(skip\_diags)) calculate\_diags = .not. skip\_diags
467 
468   \textcolor{comment}{! error checking}
469 
470   \textcolor{keywordflow}{if} (nsw > 0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (nsw /= optics\_nbands(optics)) \textcolor{keyword}{call }mom\_error(warning, &
471     \textcolor{stringliteral}{"mismatch in the number of bands of shortwave radiation in MOM\_forcing\_type extract\_fluxes."})
472 \textcolor{keywordflow}{  endif}
473 
474   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(fluxes%sw)) \textcolor{keyword}{call }mom\_error(fatal, &
475     \textcolor{stringliteral}{"MOM\_forcing\_type extractFluxes1d: fluxes%sw is not associated."})
476 
477   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(fluxes%lw)) \textcolor{keyword}{call }mom\_error(fatal, &
478     \textcolor{stringliteral}{"MOM\_forcing\_type extractFluxes1d: fluxes%lw is not associated."})
479 
480   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(fluxes%latent)) \textcolor{keyword}{call }mom\_error(fatal, &
481     \textcolor{stringliteral}{"MOM\_forcing\_type extractFluxes1d: fluxes%latent is not associated."})
482 
483   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(fluxes%sens)) \textcolor{keyword}{call }mom\_error(fatal, &
484     \textcolor{stringliteral}{"MOM\_forcing\_type extractFluxes1d: fluxes%sens is not associated."})
485 
486   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(fluxes%evap)) \textcolor{keyword}{call }mom\_error(fatal, &
487     \textcolor{stringliteral}{"MOM\_forcing\_type extractFluxes1d: No evaporation defined."})
488 
489   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(fluxes%vprec)) \textcolor{keyword}{call }mom\_error(fatal, &
490     \textcolor{stringliteral}{"MOM\_forcing\_type extractFluxes1d: fluxes%vprec not defined."})
491 
492   \textcolor{keywordflow}{if} ((.not.\textcolor{keyword}{associated}(fluxes%lprec)) .or. &
493       (.not.\textcolor{keyword}{associated}(fluxes%fprec))) \textcolor{keyword}{call }mom\_error(fatal, &
494     \textcolor{stringliteral}{"MOM\_forcing\_type extractFluxes1d: No precipitation defined."})
495 
496   \textcolor{keywordflow}{do} i=is,ie ; htot(i) = h(i,1) ;\textcolor{keywordflow}{ enddo}
497   \textcolor{keywordflow}{do} k=2,nz ; \textcolor{keywordflow}{do} i=is,ie ; htot(i) = htot(i) + h(i,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
498 
499   \textcolor{keywordflow}{if} (nsw >= 1) \textcolor{keywordflow}{then}
500     \textcolor{keyword}{call }extract\_optics\_slice(optics, j, g, gv, pensw\_top=pen\_sw\_bnd)
501     \textcolor{keywordflow}{if} (do\_pswbr) \textcolor{keyword}{call }extract\_optics\_slice(optics, j, g, gv, pensw\_top=pen\_sw\_bnd\_rate)
502 \textcolor{keywordflow}{  endif}
503 
504   \textcolor{keywordflow}{do} i=is,ie
505 
506     scale = 1.0 ; \textcolor{keywordflow}{if} ((ih\_limit > 0.0) .and. (htot(i)*ih\_limit < 1.0)) scale = htot(i)*ih\_limit
507 
508     \textcolor{comment}{! Convert the penetrating shortwave forcing to (K * H) and reduce fluxes for shallow depths.}
509     \textcolor{comment}{! (H=m for Bouss, H=kg/m2 for non-Bouss)}
510     pen\_sw\_tot(i) = 0.0
511     \textcolor{keywordflow}{if} (nsw >= 1) \textcolor{keywordflow}{then}
512       \textcolor{keywordflow}{do} n=1,nsw
513         pen\_sw\_bnd(n,i) = i\_cp\_hconvert*scale*dt * max(0.0, pen\_sw\_bnd(n,i))
514         pen\_sw\_tot(i)   = pen\_sw\_tot(i) + pen\_sw\_bnd(n,i)
515 \textcolor{keywordflow}{      enddo}
516     \textcolor{keywordflow}{else}
517       pen\_sw\_bnd(1,i) = 0.0
518 \textcolor{keywordflow}{    endif}
519 
520     \textcolor{keywordflow}{if} (do\_pswbr) \textcolor{keywordflow}{then}  \textcolor{comment}{! Repeat the above code w/ dt=1s for legacy reasons}
521       pen\_sw\_tot\_rate(i) = 0.0
522       \textcolor{keywordflow}{if} (nsw >= 1) \textcolor{keywordflow}{then}
523         \textcolor{keywordflow}{do} n=1,nsw
524           pen\_sw\_bnd\_rate(n,i) = i\_cp\_hconvert*scale * max(0.0, pen\_sw\_bnd\_rate(n,i))
525           pen\_sw\_tot\_rate(i) = pen\_sw\_tot\_rate(i) + pen\_sw\_bnd\_rate(n,i)
526 \textcolor{keywordflow}{        enddo}
527       \textcolor{keywordflow}{else}
528         pen\_sw\_bnd\_rate(1,i) = 0.0
529 \textcolor{keywordflow}{      endif}
530 \textcolor{keywordflow}{    endif}
531 
532     \textcolor{comment}{! net volume/mass of liquid and solid passing through surface boundary fluxes}
533     netmassinout(i) = dt * (scale * &
534                                    (((((( fluxes%lprec(i,j)        &
535                                         + fluxes%fprec(i,j)      )  &
536                                         + fluxes%evap(i,j)       )  &
537                                         + fluxes%lrunoff(i,j)    )  &
538                                         + fluxes%vprec(i,j)      )  &
539                                         + fluxes%seaice\_melt(i,j))  &
540                                         + fluxes%frunoff(i,j)    ))
541 
542     \textcolor{keywordflow}{if} (do\_nmior) \textcolor{keywordflow}{then}  \textcolor{comment}{! Repeat the above code without multiplying by a timestep for legacy reasons}
543       netmassinout\_rate(i) = (scale * &
544                                    (((((( fluxes%lprec(i,j)      &
545                                         + fluxes%fprec(i,j)      )  &
546                                         + fluxes%evap(i,j)       )  &
547                                         + fluxes%lrunoff(i,j)    )  &
548                                         + fluxes%vprec(i,j)      )  &
549                                         + fluxes%seaice\_melt(i,j))  &
550                                         + fluxes%frunoff(i,j)   ))
551 \textcolor{keywordflow}{    endif}
552 
553     \textcolor{comment}{! smg:}
554     \textcolor{comment}{! for non-Bouss, we add/remove salt mass to total ocean mass. to conserve}
555     \textcolor{comment}{! total salt mass ocean+ice, the sea ice model must lose mass when salt mass}
556     \textcolor{comment}{! is added to the ocean, which may still need to be coded.  Not that the units}
557     \textcolor{comment}{! of netMassInOut are still kg\_m2, so no conversion to H should occur yet.}
558     \textcolor{keywordflow}{if} (.not.gv%Boussinesq .and. \textcolor{keyword}{associated}(fluxes%salt\_flux)) \textcolor{keywordflow}{then}
559       netmassinout(i) = netmassinout(i) + dt * (scale * fluxes%salt\_flux(i,j))
560       \textcolor{keywordflow}{if} (do\_nmior) netmassinout\_rate(i) = netmassinout\_rate(i) + &
561                                                (scale * fluxes%salt\_flux(i,j))
562 \textcolor{keywordflow}{    endif}
563 
564     \textcolor{comment}{! net volume/mass of water leaving the ocean.}
565     \textcolor{comment}{! check that fluxes are < 0, which means mass is indeed leaving.}
566     netmassout(i) = 0.0
567 
568     \textcolor{comment}{! evap > 0 means condensating water is added into ocean.}
569     \textcolor{comment}{! evap < 0 means evaporation of water from the ocean, in}
570     \textcolor{comment}{! which case heat\_content\_evap is computed in MOM\_diabatic\_driver.F90}
571     \textcolor{keywordflow}{if} (fluxes%evap(i,j) < 0.0) netmassout(i) = netmassout(i) + fluxes%evap(i,j)
572   \textcolor{comment}{!   if (associated(fluxes%heat\_content\_cond)) fluxes%heat\_content\_cond(i,j) = 0.0 !??? --AJA}
573 
574     \textcolor{comment}{! lprec < 0 means sea ice formation taking water from the ocean.}
575     \textcolor{comment}{! smg: we should split the ice melt/formation from the lprec}
576     \textcolor{keywordflow}{if} (fluxes%lprec(i,j) < 0.0) netmassout(i) = netmassout(i) + fluxes%lprec(i,j)
577 
578     \textcolor{comment}{! seaice\_melt < 0 means sea ice formation taking water from the ocean.}
579     \textcolor{keywordflow}{if} (fluxes%seaice\_melt(i,j) < 0.0) netmassout(i) = netmassout(i) + fluxes%seaice\_melt(i,j)
580 
581     \textcolor{comment}{! vprec < 0 means virtual evaporation arising from surface salinity restoring,}
582     \textcolor{comment}{! in which case heat\_content\_vprec is computed in MOM\_diabatic\_driver.F90.}
583     \textcolor{keywordflow}{if} (fluxes%vprec(i,j) < 0.0) netmassout(i) = netmassout(i) + fluxes%vprec(i,j)
584 
585     netmassout(i) = dt * scale * netmassout(i)
586 
587     \textcolor{comment}{! convert to H units (Bouss=meter or non-Bouss=kg/m^2)}
588     netmassinout(i) = gv%RZ\_to\_H * netmassinout(i)
589     \textcolor{keywordflow}{if} (do\_nmior) netmassinout\_rate(i) = gv%RZ\_to\_H * netmassinout\_rate(i)
590     netmassout(i)   = gv%RZ\_to\_H * netmassout(i)
591 
592     \textcolor{comment}{! surface heat fluxes from radiation and turbulent fluxes (K * H)}
593     \textcolor{comment}{! (H=m for Bouss, H=kg/m2 for non-Bouss)}
594 
595     \textcolor{comment}{! CIME provides heat flux from snow&ice melt (seaice\_melt\_heat), so this is added below}
596     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat)) \textcolor{keywordflow}{then}
597       net\_heat(i) = scale * dt * i\_cp\_hconvert * &
598                     ( fluxes%sw(i,j) + (((fluxes%lw(i,j) + fluxes%latent(i,j)) + fluxes%sens(i,j)) + &
599                       fluxes%seaice\_melt\_heat(i,j)) )
600       \textcolor{comment}{!Repeats above code w/ dt=1. for legacy reason}
601       \textcolor{keywordflow}{if} (do\_nhr)  net\_heat\_rate(i) = scale * i\_cp\_hconvert * &
602            ( fluxes%sw(i,j) + (((fluxes%lw(i,j) + fluxes%latent(i,j)) + fluxes%sens(i,j)) + &
603              fluxes%seaice\_melt\_heat(i,j)))
604     \textcolor{keywordflow}{else}
605       net\_heat(i) = scale * dt * i\_cp\_hconvert * &
606                     ( fluxes%sw(i,j) + ((fluxes%lw(i,j) + fluxes%latent(i,j)) + fluxes%sens(i,j)) )
607       \textcolor{comment}{!Repeats above code w/ dt=1. for legacy reason}
608       \textcolor{keywordflow}{if} (do\_nhr)  net\_heat\_rate(i) = scale * i\_cp\_hconvert * &
609            ( fluxes%sw(i,j) + ((fluxes%lw(i,j) + fluxes%latent(i,j)) + fluxes%sens(i,j)) )
610 \textcolor{keywordflow}{    endif}
611 
612     \textcolor{comment}{! Add heat flux from surface damping (restoring) (K * H) or flux adjustments.}
613     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_added)) \textcolor{keywordflow}{then}
614       net\_heat(i) = net\_heat(i) + (scale * (dt * i\_cp\_hconvert)) * fluxes%heat\_added(i,j)
615       \textcolor{keywordflow}{if} (do\_nhr) net\_heat\_rate(i) = net\_heat\_rate(i) + (scale * i\_cp\_hconvert) * fluxes%heat\_added(i,j)
616 \textcolor{keywordflow}{    endif}
617 
618     \textcolor{comment}{! Add explicit heat flux for runoff (which is part of the ice-ocean boundary}
619     \textcolor{comment}{! flux type). Runoff is otherwise added with a temperature of SST.}
620     \textcolor{keywordflow}{if} (useriverheatcontent) \textcolor{keywordflow}{then}
621       \textcolor{comment}{! remove lrunoff*SST here, to counteract its addition elsewhere}
622       net\_heat(i) = (net\_heat(i) + (scale*(dt * i\_cp\_hconvert)) * fluxes%heat\_content\_lrunoff(i,j)) - &
623                      (gv%RZ\_to\_H * (scale * dt)) * fluxes%lrunoff(i,j) * t(i,1)
624       \textcolor{comment}{!BGR-Jul 5, 2017\{}
625       \textcolor{comment}{!Intentionally neglect the following contribution to rate for legacy reasons.}
626       \textcolor{comment}{!if (do\_NHR) net\_heat\_rate(i) = (net\_heat\_rate(i) + (scale*I\_Cp\_Hconvert) *
       fluxes%heat\_content\_lrunoff(i,j)) - &}
627       \textcolor{comment}{!               (GV%RZ\_to\_H * (scale)) * fluxes%lrunoff(i,j) * T(i,1)}
628       \textcolor{comment}{!\}BGR}
629       \textcolor{keywordflow}{if} (calculate\_diags .and. \textcolor{keyword}{associated}(tv%TempxPmE)) \textcolor{keywordflow}{then}
630         tv%TempxPmE(i,j) = tv%TempxPmE(i,j) + (scale * dt) * &
631             (i\_cp*fluxes%heat\_content\_lrunoff(i,j) - fluxes%lrunoff(i,j)*t(i,1))
632 \textcolor{keywordflow}{      endif}
633 \textcolor{keywordflow}{    endif}
634 
635     \textcolor{comment}{! Add explicit heat flux for calving (which is part of the ice-ocean boundary}
636     \textcolor{comment}{! flux type). Calving is otherwise added with a temperature of SST.}
637     \textcolor{keywordflow}{if} (usecalvingheatcontent) \textcolor{keywordflow}{then}
638       \textcolor{comment}{! remove frunoff*SST here, to counteract its addition elsewhere}
639       net\_heat(i) = net\_heat(i) + (scale*(dt * i\_cp\_hconvert)) * fluxes%heat\_content\_frunoff(i,j) - &
640                     (gv%RZ\_to\_H * (scale * dt)) * fluxes%frunoff(i,j) * t(i,1)
641       \textcolor{comment}{!BGR-Jul 5, 2017\{}
642       \textcolor{comment}{!Intentionally neglect the following contribution to rate for legacy reasons.}
643 \textcolor{comment}{!      if (do\_NHR) net\_heat\_rate(i) = net\_heat\_rate(i) + (scale*I\_Cp\_Hconvert) *
       fluxes%heat\_content\_frunoff(i,j) - &}
644 \textcolor{comment}{!                    (GV%RZ\_to\_H * scale) * fluxes%frunoff(i,j) * T(i,1)}
645       \textcolor{comment}{!\}BGR}
646       \textcolor{keywordflow}{if} (calculate\_diags .and. \textcolor{keyword}{associated}(tv%TempxPmE)) \textcolor{keywordflow}{then}
647         tv%TempxPmE(i,j) = tv%TempxPmE(i,j) + (scale * dt) * &
648             (i\_cp*fluxes%heat\_content\_frunoff(i,j) - fluxes%frunoff(i,j)*t(i,1))
649 \textcolor{keywordflow}{      endif}
650 \textcolor{keywordflow}{    endif}
651 
652 \textcolor{comment}{! smg: new code}
653     \textcolor{comment}{! add heat from all terms that may add mass to the ocean (K * H).}
654     \textcolor{comment}{! if evap, lprec, or vprec < 0, then compute their heat content}
655     \textcolor{comment}{! inside MOM\_diabatic\_driver.F90 and fill in fluxes%heat\_content\_massout.}
656     \textcolor{comment}{! we do so since we do not here know the temperature}
657     \textcolor{comment}{! of water leaving the ocean, as it could be leaving from more than}
658     \textcolor{comment}{! one layer of the upper ocean in the case of very thin layers.}
659     \textcolor{comment}{! When evap, lprec, or vprec > 0, then we know their heat content here}
660     \textcolor{comment}{! via settings from inside of the appropriate config\_src driver files.}
661 \textcolor{comment}{!    if (associated(fluxes%heat\_content\_lprec)) then}
662 \textcolor{comment}{!      net\_heat(i) = net\_heat(i) + scale * dt * I\_Cp\_Hconvert * &}
663 \textcolor{comment}{!     (fluxes%heat\_content\_lprec(i,j)    + (fluxes%heat\_content\_fprec(i,j)   + &}
664 \textcolor{comment}{!     (fluxes%heat\_content\_lrunoff(i,j)  + (fluxes%heat\_content\_frunoff(i,j) + &}
665 \textcolor{comment}{!     (fluxes%heat\_content\_cond(i,j)     +  fluxes%heat\_content\_vprec(i,j))))))}
666 \textcolor{comment}{!    endif}
667 
668     \textcolor{keywordflow}{if} (fluxes%num\_msg < fluxes%max\_msg) \textcolor{keywordflow}{then}
669       \textcolor{keywordflow}{if} (pen\_sw\_tot(i) > 1.000001 * i\_cp\_hconvert*scale*dt*fluxes%sw(i,j)) \textcolor{keywordflow}{then}
670         fluxes%num\_msg = fluxes%num\_msg + 1
671         \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("Penetrating shortwave of ",1pe17.10, &}
672 \textcolor{stringliteral}{}\textcolor{stringliteral}{                    &" exceeds total shortwave of ",1pe17.10,&}
673 \textcolor{stringliteral}{}\textcolor{stringliteral}{                    &" at ",1pg11.4,"E, "1pg11.4,"N.")'}) &
674                pen\_sw\_tot(i), i\_cp\_hconvert*scale*dt * fluxes%sw(i,j), &
675                g%geoLonT(i,j), g%geoLatT(i,j)
676         \textcolor{keyword}{call }mom\_error(warning,mesg)
677 \textcolor{keywordflow}{      endif}
678 \textcolor{keywordflow}{    endif}
679 
680     \textcolor{comment}{! remove penetrative portion of the SW that is NOT absorbed within a}
681     \textcolor{comment}{! tiny layer at the top of the ocean.}
682     net\_heat(i) = net\_heat(i) - pen\_sw\_tot(i)
683     \textcolor{comment}{!Repeat above code for 'rate' term}
684     \textcolor{keywordflow}{if} (do\_nhr) net\_heat\_rate(i) = net\_heat\_rate(i) - pen\_sw\_tot\_rate(i)
685 
686     \textcolor{comment}{! diagnose non-downwelling SW}
687     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(nonpensw)) \textcolor{keywordflow}{then}
688       nonpensw(i) = scale * dt * i\_cp\_hconvert * fluxes%sw(i,j) - pen\_sw\_tot(i)
689 \textcolor{keywordflow}{    endif}
690 
691     \textcolor{comment}{! Salt fluxes}
692     net\_salt(i) = 0.0
693     \textcolor{keywordflow}{if} (do\_nsr) net\_salt\_rate(i) = 0.0
694     \textcolor{comment}{! Convert salt\_flux from kg (salt)/(m^2 * s) to}
695     \textcolor{comment}{! Boussinesq: (ppt * m)}
696     \textcolor{comment}{! non-Bouss:  (g/m^2)}
697     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux)) \textcolor{keywordflow}{then}
698       net\_salt(i) = (scale * dt * (1000.0 * fluxes%salt\_flux(i,j))) * gv%RZ\_to\_H
699       \textcolor{comment}{!Repeat above code for 'rate' term}
700       \textcolor{keywordflow}{if} (do\_nsr) net\_salt\_rate(i) = (scale * 1. * (1000.0 * fluxes%salt\_flux(i,j))) * gv%RZ\_to\_H
701 \textcolor{keywordflow}{    endif}
702 
703     \textcolor{comment}{! Diagnostics follow...}
704     \textcolor{keywordflow}{if} (calculate\_diags) \textcolor{keywordflow}{then}
705 
706       \textcolor{comment}{! Store Net\_salt for unknown reason?}
707       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux)) \textcolor{keywordflow}{then}
708         \textcolor{comment}{! This seems like a bad idea to me. -RWH}
709         \textcolor{keywordflow}{if} (calculate\_diags) fluxes%netSalt(i,j) = us%kg\_m2s\_to\_RZ\_T*net\_salt(i)
710 \textcolor{keywordflow}{      endif}
711 
712       \textcolor{comment}{! Initialize heat\_content\_massin that is diagnosed in mixedlayer\_convection or}
713       \textcolor{comment}{! applyBoundaryFluxes such that the meaning is as the sum of all incoming components.}
714       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_massin))  \textcolor{keywordflow}{then}
715         \textcolor{keywordflow}{if} (aggregate\_fw) \textcolor{keywordflow}{then}
716           \textcolor{keywordflow}{if} (netmassinout(i) > 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! net is "in"}
717             fluxes%heat\_content\_massin(i,j) = -fluxes%C\_p * netmassout(i) * t(i,1) * gv%H\_to\_RZ / dt
718           \textcolor{keywordflow}{else} \textcolor{comment}{! net is "out"}
719             fluxes%heat\_content\_massin(i,j) = fluxes%C\_p * ( netmassinout(i) - netmassout(i) ) * &
720                                                t(i,1) * gv%H\_to\_RZ / dt
721 \textcolor{keywordflow}{          endif}
722         \textcolor{keywordflow}{else}
723           fluxes%heat\_content\_massin(i,j) = 0.
724 \textcolor{keywordflow}{        endif}
725 \textcolor{keywordflow}{      endif}
726 
727       \textcolor{comment}{! Initialize heat\_content\_massout that is diagnosed in mixedlayer\_convection or}
728       \textcolor{comment}{! applyBoundaryFluxes such that the meaning is as the sum of all outgoing components.}
729       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_massout)) \textcolor{keywordflow}{then}
730         \textcolor{keywordflow}{if} (aggregate\_fw) \textcolor{keywordflow}{then}
731           \textcolor{keywordflow}{if} (netmassinout(i) > 0.0) \textcolor{keywordflow}{then} \textcolor{comment}{! net is "in"}
732             fluxes%heat\_content\_massout(i,j) = fluxes%C\_p * netmassout(i) * t(i,1) * gv%H\_to\_RZ / dt
733           \textcolor{keywordflow}{else} \textcolor{comment}{! net is "out"}
734             fluxes%heat\_content\_massout(i,j) = -fluxes%C\_p * ( netmassinout(i) - netmassout(i) ) * &
735                                                 t(i,1) * gv%H\_to\_RZ / dt
736 \textcolor{keywordflow}{          endif}
737         \textcolor{keywordflow}{else}
738           fluxes%heat\_content\_massout(i,j) = 0.0
739 \textcolor{keywordflow}{        endif}
740 \textcolor{keywordflow}{      endif}
741 
742       \textcolor{comment}{! smg: we should remove sea ice melt from lprec!!!}
743       \textcolor{comment}{! fluxes%lprec > 0 means ocean gains mass via liquid precipitation and/or sea ice melt.}
744       \textcolor{comment}{! When atmosphere does not provide heat of this precipitation, the ocean assumes}
745       \textcolor{comment}{! it enters the ocean at the SST.}
746       \textcolor{comment}{! fluxes%lprec < 0 means ocean loses mass via sea ice formation. As we do not yet know}
747       \textcolor{comment}{! the layer at which this mass is removed, we cannot compute it heat content. We must}
748       \textcolor{comment}{! wait until MOM\_diabatic\_driver.F90.}
749       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lprec)) \textcolor{keywordflow}{then}
750         \textcolor{keywordflow}{if} (fluxes%lprec(i,j) > 0.0) \textcolor{keywordflow}{then}
751           fluxes%heat\_content\_lprec(i,j) = fluxes%C\_p*fluxes%lprec(i,j)*t(i,1)
752         \textcolor{keywordflow}{else}
753           fluxes%heat\_content\_lprec(i,j) = 0.0
754 \textcolor{keywordflow}{        endif}
755 \textcolor{keywordflow}{      endif}
756 
757       \textcolor{comment}{! fprec SHOULD enter ocean at 0degC if atmos model does not provide fprec heat content.}
758       \textcolor{comment}{! However, we need to adjust netHeat above to reflect the difference between 0decC and SST}
759       \textcolor{comment}{! and until we do so fprec is treated like lprec and enters at SST. -AJA}
760       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_fprec)) \textcolor{keywordflow}{then}
761         \textcolor{keywordflow}{if} (fluxes%fprec(i,j) > 0.0) \textcolor{keywordflow}{then}
762           fluxes%heat\_content\_fprec(i,j) = fluxes%C\_p*fluxes%fprec(i,j)*t(i,1)
763         \textcolor{keywordflow}{else}
764           fluxes%heat\_content\_fprec(i,j) = 0.0
765 \textcolor{keywordflow}{        endif}
766 \textcolor{keywordflow}{      endif}
767 
768       \textcolor{comment}{! Following lprec and fprec, water flux due to sea ice melt (seaice\_melt) enters at SST - GMM}
769       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt)) \textcolor{keywordflow}{then}
770         \textcolor{keywordflow}{if} (fluxes%seaice\_melt(i,j) > 0.0) \textcolor{keywordflow}{then}
771           fluxes%heat\_content\_icemelt(i,j) = fluxes%C\_p*fluxes%seaice\_melt(i,j)*t(i,1)
772         \textcolor{keywordflow}{else}
773           fluxes%heat\_content\_icemelt(i,j) = 0.0
774 \textcolor{keywordflow}{        endif}
775 \textcolor{keywordflow}{      endif}
776 
777       \textcolor{comment}{! virtual precip associated with salinity restoring}
778       \textcolor{comment}{! vprec > 0 means add water to ocean, assumed to be at SST}
779       \textcolor{comment}{! vprec < 0 means remove water from ocean; set heat\_content\_vprec in MOM\_diabatic\_driver.F90}
780       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_vprec)) \textcolor{keywordflow}{then}
781         \textcolor{keywordflow}{if} (fluxes%vprec(i,j) > 0.0) \textcolor{keywordflow}{then}
782           fluxes%heat\_content\_vprec(i,j) = fluxes%C\_p*fluxes%vprec(i,j)*t(i,1)
783         \textcolor{keywordflow}{else}
784           fluxes%heat\_content\_vprec(i,j) = 0.0
785 \textcolor{keywordflow}{        endif}
786 \textcolor{keywordflow}{      endif}
787 
788       \textcolor{comment}{! fluxes%evap < 0 means ocean loses mass due to evaporation.}
789       \textcolor{comment}{! Evaporation leaves ocean surface at a temperature that has yet to be determined,}
790       \textcolor{comment}{! since we do not know the precise layer that the water evaporates.  We therefore}
791       \textcolor{comment}{! compute fluxes%heat\_content\_massout at the relevant point inside MOM\_diabatic\_driver.F90.}
792       \textcolor{comment}{! fluxes%evap > 0 means ocean gains moisture via condensation.}
793       \textcolor{comment}{! Condensation is assumed to drop into the ocean at the SST, just like lprec.}
794       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_cond)) \textcolor{keywordflow}{then}
795         \textcolor{keywordflow}{if} (fluxes%evap(i,j) > 0.0) \textcolor{keywordflow}{then}
796           fluxes%heat\_content\_cond(i,j) = fluxes%C\_p*fluxes%evap(i,j)*t(i,1)
797         \textcolor{keywordflow}{else}
798           fluxes%heat\_content\_cond(i,j) = 0.0
799 \textcolor{keywordflow}{        endif}
800 \textcolor{keywordflow}{      endif}
801 
802       \textcolor{comment}{! Liquid runoff enters ocean at SST if land model does not provide runoff heat content.}
803       \textcolor{keywordflow}{if} (.not. useriverheatcontent) \textcolor{keywordflow}{then}
804         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lrunoff) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff)) \textcolor{keywordflow}{then}
805           fluxes%heat\_content\_lrunoff(i,j) = fluxes%C\_p*fluxes%lrunoff(i,j)*t(i,1)
806 \textcolor{keywordflow}{        endif}
807 \textcolor{keywordflow}{      endif}
808 
809       \textcolor{comment}{! Icebergs enter ocean at SST if land model does not provide calving heat content.}
810       \textcolor{keywordflow}{if} (.not. usecalvingheatcontent) \textcolor{keywordflow}{then}
811         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frunoff) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff)) \textcolor{keywordflow}{then}
812           fluxes%heat\_content\_frunoff(i,j) = fluxes%C\_p*fluxes%frunoff(i,j)*t(i,1)
813 \textcolor{keywordflow}{        endif}
814 \textcolor{keywordflow}{      endif}
815 
816 \textcolor{keywordflow}{    endif} \textcolor{comment}{! calculate\_diags}
817 
818 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! i-loop}
819 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_abb28aefef337fc656fd719eaff7a3b60}\label{namespacemom__forcing__type_abb28aefef337fc656fd719eaff7a3b60}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!extractfluxes2d@{extractfluxes2d}}
\index{extractfluxes2d@{extractfluxes2d}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{extractfluxes2d()}{extractfluxes2d()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::extractfluxes2d (\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(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(optics\+\_\+type), pointer}]{optics,  }\item[{integer, intent(in)}]{nsw,  }\item[{real, intent(in)}]{dt,  }\item[{real, intent(in)}]{Flux\+Rescale\+Depth,  }\item[{logical, intent(in)}]{use\+River\+Heat\+Content,  }\item[{logical, intent(in)}]{use\+Calving\+Heat\+Content,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{T,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(out)}]{net\+Mass\+In\+Out,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(out)}]{net\+Mass\+Out,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(out)}]{net\+\_\+heat,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(out)}]{Net\+\_\+salt,  }\item[{real, dimension(max(1,nsw),g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{Pen\+\_\+\+S\+W\+\_\+bnd,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{logical, intent(in)}]{aggregate\+\_\+\+FW }\end{DoxyParamCaption})}



2d wrapper for 1d extract fluxes from surface fluxes type. This subroutine extracts fluxes from the surface fluxes type. It multiplies the fluxes by dt, so that the result is an accumulation of the fluxes over a time step. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & structure containing pointers to forcing.\\
\hline
 & {\em optics} & pointer to optics\\
\hline
\mbox{\tt in}  & {\em nsw} & number of bands of penetrating SW\\
\hline
\mbox{\tt in}  & {\em dt} & The time step for these fluxes \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em fluxrescaledepth} & min ocean depth before fluxes are scaled away \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em useriverheatcontent} & logical for river heat content\\
\hline
\mbox{\tt in}  & {\em usecalvingheatcontent} & logical for calving heat content\\
\hline
\mbox{\tt in}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em t} & layer temperatures \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt out}  & {\em netmassinout} & net mass flux (non-\/\+Bouss) or volume flux (if Bouss) of water in/out of ocean over a time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em netmassout} & net mass flux (non-\/\+Bouss) or volume flux (if Bouss) of water leaving ocean surface over a time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em net\+\_\+heat} & net heat at the surface accumulated over a time step associated with coupler + restore. Exclude two terms from net\+\_\+heat\+: (1) downwelling (penetrative) SW, (2) evaporation heat content, (since do not yet know temperature of evap). \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em net\+\_\+salt} & surface salt flux into the ocean accumulated over a time step \mbox{[}ppt H $\sim$$>$ ppt m or ppt kg m-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em pen\+\_\+sw\+\_\+bnd} & penetrating SW flux, by frequency band \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]} with array size nsw x G isd\+: G ied, where nsw=number of SW bands in pen\+\_\+\+S\+W\+\_\+bnd. This heat flux is not in net\+\_\+heat.\\
\hline
\mbox{\tt in,out}  & {\em tv} & structure containing pointers to available thermodynamic fields. Here it is used to keep track of the heat flux associated with net mass fluxes into the ocean.\\
\hline
\mbox{\tt in}  & {\em aggregate\+\_\+fw} & For determining how to aggregate the forcing. \\
\hline
\end{DoxyParams}


Definition at line 830 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
830 
831   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{              !< ocean grid structure}
832   \textcolor{keywordtype}{type}(verticalGrid\_type),          \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{             !< ocean vertical grid structure}
833   \textcolor{keywordtype}{type}(unit\_scale\_type),            \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{             !< A dimensional unit scaling type}
834   \textcolor{keywordtype}{type}(forcing),                    \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{         !< structure containing pointers to
       forcing.}
835   \textcolor{keywordtype}{type}(optics\_type),                \textcolor{keywordtype}{pointer}       :: optics\textcolor{comment}{         !< pointer to optics}
836   \textcolor{keywordtype}{integer},                          \textcolor{keywordtype}{intent(in)}    :: nsw\textcolor{comment}{            !< number of bands of penetrating SW}
837   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{             !< The time step for these fluxes [T ~>
       s]}
838   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{intent(in)}    :: FluxRescaleDepth\textcolor{comment}{ !< min ocean depth before fluxes}
839 \textcolor{comment}{                                                                    !! are scaled away [H ~> m or kg m-2]}
840   \textcolor{keywordtype}{logical},                          \textcolor{keywordtype}{intent(in)}    :: useRiverHeatContent\textcolor{comment}{   !< logical for river heat
       content}
841   \textcolor{keywordtype}{logical},                          \textcolor{keywordtype}{intent(in)}    :: useCalvingHeatContent\textcolor{comment}{ !< logical for calving heat
       content}
842   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
843                                     \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{              !< layer thickness [H ~> m or kg m-2]}
844   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, &
845                                     \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{              !< layer temperatures [degC]}
846   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)}   :: netMassInOut\textcolor{comment}{   !< net mass flux (non-Bouss) or volume
       flux}
847 \textcolor{comment}{                                                                    !! (if Bouss) of water in/out of ocean
       over}
848 \textcolor{comment}{                                                                    !! a time step [H ~> m or kg m-2]}
849   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)}   :: netMassOut\textcolor{comment}{     !< net mass flux (non-Bouss) or volume
       flux}
850 \textcolor{comment}{                                                                    !! (if Bouss) of water leaving ocean
       surface}
851 \textcolor{comment}{                                                                    !! over a time step [H ~> m or kg m-2].}
852   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)}   :: net\_heat\textcolor{comment}{       !< net heat at the surface accumulated
       over a}
853 \textcolor{comment}{                                                                    !! time step associated with coupler +
       restore.}
854 \textcolor{comment}{                                                                    !! Exclude two terms from net\_heat:}
855 \textcolor{comment}{                                                                    !! (1) downwelling (penetrative) SW,}
856 \textcolor{comment}{                                                                    !! (2) evaporation heat content,}
857 \textcolor{comment}{                                                                    !! (since do not yet know temperature
       of evap).}
858 \textcolor{comment}{                                                                    !! [degC H ~> degC m or degC kg m-2]}
859   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)}   :: net\_salt\textcolor{comment}{       !< surface salt flux into the ocean
       accumulated}
860 \textcolor{comment}{                                                                    !! over a time step [ppt H ~> ppt m or
       ppt kg m-2]}
861   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(max(1,nsw),G%isd:G%ied,G%jsd:G%jed)}, \textcolor{keywordtype}{intent(out)} :: pen\_SW\_bnd\textcolor{comment}{ !< penetrating SW flux, by
       frequency}
862 \textcolor{comment}{                                                                    !! band [degC H ~> degC m or degC kg
       m-2] with array}
863 \textcolor{comment}{                                                                    !! size nsw x SZI\_(G), where nsw=number
       of SW bands}
864 \textcolor{comment}{                                                                    !! in pen\_SW\_bnd. This heat flux is not
       in net\_heat.}
865   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),            \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{             !< structure containing pointers to
       available}
866 \textcolor{comment}{                                                                    !! thermodynamic fields. Here it is
       used to keep}
867 \textcolor{comment}{                                                                    !! track of the heat flux associated
       with net}
868 \textcolor{comment}{                                                                    !! mass fluxes into the ocean.}
869   \textcolor{keywordtype}{logical},                          \textcolor{keywordtype}{intent(in)}    :: aggregate\_FW\textcolor{comment}{   !< For determining how to aggregate the
       forcing.}
870 
871   \textcolor{keywordtype}{integer} :: j
872   \textcolor{comment}{!$OMP parallel do default(shared)}
873   \textcolor{keywordflow}{do} j=g%jsc, g%jec
874     \textcolor{keyword}{call }extractfluxes1d(g, gv, us, fluxes, optics, nsw, j, dt, &
875             fluxrescaledepth, useriverheatcontent, usecalvingheatcontent,&
876             h(:,j,:), t(:,j,:), netmassinout(:,j), netmassout(:,j),              &
877             net\_heat(:,j), net\_salt(:,j), pen\_sw\_bnd(:,:,j), tv, aggregate\_fw)
878 \textcolor{keywordflow}{  enddo}
879 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a839c0241813c94b40b6861e2ad8bdc91}\label{namespacemom__forcing__type_a839c0241813c94b40b6861e2ad8bdc91}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!fluxes\+\_\+accumulate@{fluxes\+\_\+accumulate}}
\index{fluxes\+\_\+accumulate@{fluxes\+\_\+accumulate}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{fluxes\+\_\+accumulate()}{fluxes\_accumulate()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::fluxes\+\_\+accumulate (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{flux\+\_\+tmp,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{real, intent(out)}]{wt2,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in), optional}]{forces }\end{DoxyParamCaption})}



Accumulate the thermodynamic fluxes over time steps. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em flux\+\_\+tmp} & A temporary structure with current thermodynamic forcing fields\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing time-\/averaged thermodynamic forcing fields\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt out}  & {\em wt2} & The relative weight of the new fluxes\\
\hline
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\end{DoxyParams}


Definition at line 1914 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
1914   \textcolor{keywordtype}{type}(forcing),             \textcolor{keywordtype}{intent(in)}    :: flux\_tmp\textcolor{comment}{ !< A temporary structure with current}
1915 \textcolor{comment}{                                                     !! thermodynamic forcing fields}
1916   \textcolor{keywordtype}{type}(forcing),             \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing time-averaged}
1917 \textcolor{comment}{                                                     !! thermodynamic forcing fields}
1918   \textcolor{keywordtype}{type}(ocean\_grid\_type),     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< The ocean's grid structure}
1919   \textcolor{keywordtype}{real},                      \textcolor{keywordtype}{intent(out)}   :: wt2\textcolor{comment}{    !< The relative weight of the new fluxes}
1920   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
1921 
1922   \textcolor{comment}{! This subroutine copies mechancal forcing from flux\_tmp to fluxes and}
1923   \textcolor{comment}{! stores the time-weighted averages of the various buoyancy fluxes in fluxes,}
1924   \textcolor{comment}{! and increments the amount of time over which the buoyancy forcing in fluxes should be}
1925   \textcolor{comment}{! applied based on the time interval stored in flux\_tmp.}
1926 
1927   \textcolor{keywordtype}{real} :: wt1
1928   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq, i0, j0
1929   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, isr, ier, jsr, jer
1930   is   = g%isc   ; ie   = g%iec    ; js   = g%jsc   ; je   = g%jec
1931   isq  = g%IscB  ; ieq  = g%IecB   ; jsq  = g%JscB  ; jeq  = g%JecB
1932   isd  = g%isd   ; ied  = g%ied    ; jsd  = g%jsd   ; jed  = g%jed
1933   isdb = g%IsdB  ; iedb = g%IedB   ; jsdb = g%JsdB  ; jedb = g%JedB
1934 
1935 
1936   \textcolor{keywordflow}{if} (fluxes%dt\_buoy\_accum < 0) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"fluxes\_accumulate: "}//&
1937      \textcolor{stringliteral}{"fluxes must be initialzed before it can be augmented."})
1938 
1939   \textcolor{comment}{! wt1 is the relative weight of the previous fluxes.}
1940   wt1 = fluxes%dt\_buoy\_accum / (fluxes%dt\_buoy\_accum + flux\_tmp%dt\_buoy\_accum)
1941   wt2 = 1.0 - wt1 \textcolor{comment}{! = flux\_tmp%dt\_buoy\_accum / (fluxes%dt\_buoy\_accum + flux\_tmp%dt\_buoy\_accum)}
1942   fluxes%dt\_buoy\_accum = fluxes%dt\_buoy\_accum + flux\_tmp%dt\_buoy\_accum
1943 
1944   \textcolor{comment}{! Copy over the pressure fields and accumulate averages of ustar, either from the forcing}
1945   \textcolor{comment}{! type or from the temporary fluxes type.}
1946   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(forces)) \textcolor{keywordflow}{then}
1947     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1948       fluxes%p\_surf(i,j) = forces%p\_surf(i,j)
1949       fluxes%p\_surf\_full(i,j) = forces%p\_surf\_full(i,j)
1950 
1951       fluxes%ustar(i,j) = wt1*fluxes%ustar(i,j) + wt2*forces%ustar(i,j)
1952 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1953   \textcolor{keywordflow}{else}
1954     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1955       fluxes%p\_surf(i,j) = flux\_tmp%p\_surf(i,j)
1956       fluxes%p\_surf\_full(i,j) = flux\_tmp%p\_surf\_full(i,j)
1957 
1958       fluxes%ustar(i,j) = wt1*fluxes%ustar(i,j) + wt2*flux\_tmp%ustar(i,j)
1959 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1960 \textcolor{keywordflow}{  endif}
1961 
1962   \textcolor{comment}{! Average the water, heat, and salt fluxes, and ustar.}
1963   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1964     \textcolor{keywordflow}{if} (fluxes%gustless\_accum\_bug) \textcolor{keywordflow}{then}
1965       fluxes%ustar\_gustless(i,j) = flux\_tmp%ustar\_gustless(i,j)
1966     \textcolor{keywordflow}{else}
1967       fluxes%ustar\_gustless(i,j) = wt1*fluxes%ustar\_gustless(i,j) + wt2*flux\_tmp%ustar\_gustless(i,j)
1968 \textcolor{keywordflow}{    endif}
1969 
1970     fluxes%evap(i,j) = wt1*fluxes%evap(i,j) + wt2*flux\_tmp%evap(i,j)
1971     fluxes%lprec(i,j) = wt1*fluxes%lprec(i,j) + wt2*flux\_tmp%lprec(i,j)
1972     fluxes%fprec(i,j) = wt1*fluxes%fprec(i,j) + wt2*flux\_tmp%fprec(i,j)
1973     fluxes%vprec(i,j) = wt1*fluxes%vprec(i,j) + wt2*flux\_tmp%vprec(i,j)
1974     fluxes%lrunoff(i,j) = wt1*fluxes%lrunoff(i,j) + wt2*flux\_tmp%lrunoff(i,j)
1975     fluxes%frunoff(i,j) = wt1*fluxes%frunoff(i,j) + wt2*flux\_tmp%frunoff(i,j)
1976     fluxes%seaice\_melt(i,j) = wt1*fluxes%seaice\_melt(i,j) + wt2*flux\_tmp%seaice\_melt(i,j)
1977     fluxes%sw(i,j) = wt1*fluxes%sw(i,j) + wt2*flux\_tmp%sw(i,j)
1978     fluxes%sw\_vis\_dir(i,j) = wt1*fluxes%sw\_vis\_dir(i,j) + wt2*flux\_tmp%sw\_vis\_dir(i,j)
1979     fluxes%sw\_vis\_dif(i,j) = wt1*fluxes%sw\_vis\_dif(i,j) + wt2*flux\_tmp%sw\_vis\_dif(i,j)
1980     fluxes%sw\_nir\_dir(i,j) = wt1*fluxes%sw\_nir\_dir(i,j) + wt2*flux\_tmp%sw\_nir\_dir(i,j)
1981     fluxes%sw\_nir\_dif(i,j) = wt1*fluxes%sw\_nir\_dif(i,j) + wt2*flux\_tmp%sw\_nir\_dif(i,j)
1982     fluxes%lw(i,j) = wt1*fluxes%lw(i,j) + wt2*flux\_tmp%lw(i,j)
1983     fluxes%latent(i,j) = wt1*fluxes%latent(i,j) + wt2*flux\_tmp%latent(i,j)
1984     fluxes%sens(i,j) = wt1*fluxes%sens(i,j) + wt2*flux\_tmp%sens(i,j)
1985 
1986     fluxes%salt\_flux(i,j) = wt1*fluxes%salt\_flux(i,j) + wt2*flux\_tmp%salt\_flux(i,j)
1987 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1988   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_added) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_added)) \textcolor{keywordflow}{then}
1989     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1990       fluxes%heat\_added(i,j) = wt1*fluxes%heat\_added(i,j) + wt2*flux\_tmp%heat\_added(i,j)
1991 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1992 \textcolor{keywordflow}{  endif}
1993   \textcolor{comment}{! These might always be associated, in which case they can be combined?}
1994   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_cond) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_cond)) \textcolor{keywordflow}{then}
1995     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1996       fluxes%heat\_content\_cond(i,j) = wt1*fluxes%heat\_content\_cond(i,j) + wt2*flux\_tmp%heat\_content\_cond(i,
      j)
1997 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1998 \textcolor{keywordflow}{  endif}
1999   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lprec) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_lprec)) \textcolor{keywordflow}{then}
2000     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2001       fluxes%heat\_content\_lprec(i,j) = wt1*fluxes%heat\_content\_lprec(i,j) + wt2*flux\_tmp%heat\_content\_lprec
      (i,j)
2002 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2003 \textcolor{keywordflow}{  endif}
2004   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_fprec) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_fprec)) \textcolor{keywordflow}{then}
2005     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2006       fluxes%heat\_content\_fprec(i,j) = wt1*fluxes%heat\_content\_fprec(i,j) + wt2*flux\_tmp%heat\_content\_fprec
      (i,j)
2007 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2008 \textcolor{keywordflow}{  endif}
2009   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_icemelt)) \textcolor{keywordflow}{then}
2010     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2011       fluxes%heat\_content\_icemelt(i,j) = wt1*fluxes%heat\_content\_icemelt(i,j) + wt2*flux\_tmp
      %heat\_content\_icemelt(i,j)
2012 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2013 \textcolor{keywordflow}{  endif}
2014   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_vprec) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_vprec)) \textcolor{keywordflow}{then}
2015     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2016       fluxes%heat\_content\_vprec(i,j) = wt1*fluxes%heat\_content\_vprec(i,j) + wt2*flux\_tmp%heat\_content\_vprec
      (i,j)
2017 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2018 \textcolor{keywordflow}{  endif}
2019   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_lrunoff)) \textcolor{keywordflow}{then}
2020     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2021       fluxes%heat\_content\_lrunoff(i,j) = wt1*fluxes%heat\_content\_lrunoff(i,j) + wt2*flux\_tmp
      %heat\_content\_lrunoff(i,j)
2022 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2023 \textcolor{keywordflow}{  endif}
2024   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_frunoff)) \textcolor{keywordflow}{then}
2025     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2026       fluxes%heat\_content\_frunoff(i,j) = wt1*fluxes%heat\_content\_frunoff(i,j) + wt2*flux\_tmp
      %heat\_content\_frunoff(i,j)
2027 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2028 \textcolor{keywordflow}{  endif}
2029   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt) .and. \textcolor{keyword}{associated}(flux\_tmp%heat\_content\_icemelt)) \textcolor{keywordflow}{then}
2030     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2031       fluxes%heat\_content\_icemelt(i,j) = wt1*fluxes%heat\_content\_icemelt(i,j) + wt2*flux\_tmp
      %heat\_content\_icemelt(i,j)
2032 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2033 \textcolor{keywordflow}{  endif}
2034 
2035   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar\_shelf) .and. \textcolor{keyword}{associated}(flux\_tmp%ustar\_shelf)) \textcolor{keywordflow}{then}
2036     \textcolor{keywordflow}{do} i=isd,ied ; \textcolor{keywordflow}{do} j=jsd,jed
2037       fluxes%ustar\_shelf(i,j)  = flux\_tmp%ustar\_shelf(i,j)
2038 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2039 \textcolor{keywordflow}{  endif}
2040   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%iceshelf\_melt) .and. \textcolor{keyword}{associated}(flux\_tmp%iceshelf\_melt)) \textcolor{keywordflow}{then}
2041     \textcolor{keywordflow}{do} i=isd,ied ; \textcolor{keywordflow}{do} j=jsd,jed
2042       fluxes%iceshelf\_melt(i,j)  = flux\_tmp%iceshelf\_melt(i,j)
2043 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2044 \textcolor{keywordflow}{  endif}
2045   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frac\_shelf\_h) .and. \textcolor{keyword}{associated}(flux\_tmp%frac\_shelf\_h)) \textcolor{keywordflow}{then}
2046     \textcolor{keywordflow}{do} i=isd,ied ; \textcolor{keywordflow}{do} j=jsd,jed
2047       fluxes%frac\_shelf\_h(i,j)  = flux\_tmp%frac\_shelf\_h(i,j)
2048 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2049 \textcolor{keywordflow}{  endif}
2050 
2051   \textcolor{keywordflow}{if} (coupler\_type\_initialized(fluxes%tr\_fluxes) .and. &
2052       coupler\_type\_initialized(flux\_tmp%tr\_fluxes)) &
2053     \textcolor{keyword}{call }coupler\_type\_increment\_data(flux\_tmp%tr\_fluxes, fluxes%tr\_fluxes, &
2054                               scale\_factor=wt2, scale\_prev=wt1)
2055 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_aab6d8e5da1aafc8a73875e2de61822f9}\label{namespacemom__forcing__type_aab6d8e5da1aafc8a73875e2de61822f9}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!forcing\+\_\+accumulate@{forcing\+\_\+accumulate}}
\index{forcing\+\_\+accumulate@{forcing\+\_\+accumulate}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{forcing\+\_\+accumulate()}{forcing\_accumulate()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::forcing\+\_\+accumulate (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{flux\+\_\+tmp,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{real, intent(out)}]{wt2 }\end{DoxyParamCaption})}



Accumulate the forcing over time steps, taking input from a mechanical forcing type and a temporary forcing-\/flux type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em flux\+\_\+tmp} & A temporary structure with current thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing time-\/averaged thermodynamic forcing fields\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt out}  & {\em wt2} & The relative weight of the new fluxes \\
\hline
\end{DoxyParams}


Definition at line 1895 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
1895   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(in)}    :: flux\_tmp\textcolor{comment}{ !< A temporary structure with current}
1896 \textcolor{comment}{                                                 !!thermodynamic forcing fields}
1897   \textcolor{keywordtype}{type}(mech\_forcing),    \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
1898   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing time-averaged}
1899 \textcolor{comment}{                                                 !! thermodynamic forcing fields}
1900   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< The ocean's grid structure}
1901   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(out)}   :: wt2\textcolor{comment}{    !< The relative weight of the new fluxes}
1902 
1903   \textcolor{comment}{! This subroutine copies mechancal forcing from flux\_tmp to fluxes and}
1904   \textcolor{comment}{! stores the time-weighted averages of the various buoyancy fluxes in fluxes,}
1905   \textcolor{comment}{! and increments the amount of time over which the buoyancy forcing should be}
1906   \textcolor{comment}{! applied, all via a call to fluxes accumulate.}
1907 
1908   \textcolor{keyword}{call }fluxes\_accumulate(flux\_tmp, fluxes, g, wt2, forces)
1909 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a18fc44b1946351373f626fcc5aabc340}\label{namespacemom__forcing__type_a18fc44b1946351373f626fcc5aabc340}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!forcing\+\_\+diagnostics@{forcing\+\_\+diagnostics}}
\index{forcing\+\_\+diagnostics@{forcing\+\_\+diagnostics}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{forcing\+\_\+diagnostics()}{forcing\_diagnostics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::forcing\+\_\+diagnostics (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in), target}]{fluxes\+\_\+in,  }\item[{type(surface), intent(in)}]{sfc\+\_\+state,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in), target}]{G\+\_\+in,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(time\+\_\+type), intent(in)}]{time\+\_\+end,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing__diags}{forcing\+\_\+diags}}), intent(inout)}]{handles }\end{DoxyParamCaption})}



Offer buoyancy forcing fields for diagnostics for those fields registered as part of register\+\_\+forcing\+\_\+type\+\_\+diags. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes\+\_\+in} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in}  & {\em g\+\_\+in} & Input grid type\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em time\+\_\+end} & The end time of the diagnostic interval.\\
\hline
\mbox{\tt in,out}  & {\em diag} & diagnostic regulator\\
\hline
\mbox{\tt in,out}  & {\em handles} & diagnostic ids \\
\hline
\end{DoxyParams}


Definition at line 2274 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2274   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: fluxes\_in\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
2275   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(in)}    :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
2276 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
2277   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: G\_in\textcolor{comment}{ !< Input grid type}
2278   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{        !< A dimensional unit scaling type}
2279   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: time\_end\textcolor{comment}{  !< The end time of the diagnostic interval.}
2280   \textcolor{keywordtype}{type}(diag\_ctrl),       \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{      !< diagnostic regulator}
2281   \textcolor{keywordtype}{type}(forcing\_diags),   \textcolor{keywordtype}{intent(inout)} :: handles\textcolor{comment}{   !< diagnostic ids}
2282 
2283   \textcolor{comment}{! local}
2284   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: G   \textcolor{comment}{! Grid metric on model index map}
2285   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{pointer} :: fluxes      \textcolor{comment}{! Fluxes on the model index map}
2286   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(diag%G),SZJ\_(diag%G))} :: res
2287   \textcolor{keywordtype}{real} :: total\_transport \textcolor{comment}{! for diagnosing integrated boundary transport}
2288   \textcolor{keywordtype}{real} :: ave\_flux        \textcolor{comment}{! for diagnosing averaged   boundary flux}
2289   \textcolor{keywordtype}{real} :: RZ\_T\_conversion \textcolor{comment}{! A combination of scaling factors for mass fluxes [kg T m-2 s-1 R-1 Z-1 ~> 1]}
2290   \textcolor{keywordtype}{real} :: I\_dt            \textcolor{comment}{! inverse time step [T-1 ~> s-1]}
2291   \textcolor{keywordtype}{real} :: ppt2mks         \textcolor{comment}{! conversion between ppt and mks}
2292   \textcolor{keywordtype}{integer} :: turns        \textcolor{comment}{! Number of index quarter turns}
2293   \textcolor{keywordtype}{integer} :: i,j,is,ie,js,je
2294 
2295   \textcolor{keyword}{call }cpu\_clock\_begin(handles%id\_clock\_forcing)
2296 
2297   \textcolor{comment}{! NOTE: post\_data expects data to be on the rotated index map, so any}
2298   \textcolor{comment}{!   rotations must be applied before saving the output.}
2299   turns = diag%G%HI%turns
2300   \textcolor{keywordflow}{if} (turns /= 0) \textcolor{keywordflow}{then}
2301     g => diag%G
2302     \textcolor{keyword}{allocate}(fluxes)
2303     \textcolor{keyword}{call }allocate\_forcing\_type(fluxes\_in, g, fluxes)
2304     \textcolor{keyword}{call }rotate\_forcing(fluxes\_in, fluxes, turns)
2305   \textcolor{keywordflow}{else}
2306     g => g\_in
2307     fluxes => fluxes\_in
2308 \textcolor{keywordflow}{  endif}
2309 
2310   rz\_t\_conversion = us%RZ\_T\_to\_kg\_m2s
2311   i\_dt    = 1.0 / fluxes%dt\_buoy\_accum
2312   ppt2mks = 1e-3
2313   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
2314 
2315   \textcolor{keyword}{call }enable\_averages(fluxes%dt\_buoy\_accum, time\_end, diag)
2316   \textcolor{comment}{! if (query\_averaging\_enabled(diag)) then}
2317 
2318     \textcolor{comment}{! post the diagnostics for surface mass fluxes ==================================}
2319 
2320     \textcolor{keywordflow}{if} (handles%id\_prcme > 0 .or. handles%id\_total\_prcme > 0 .or. handles%id\_prcme\_ga > 0) \textcolor{keywordflow}{then}
2321       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2322         res(i,j) = 0.0
2323         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec))       res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%lprec(i,j)
2324         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%fprec))       res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%fprec(i,j)
2325         \textcolor{comment}{! fluxes%cond is not needed because it is derived from %evap > 0}
2326         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap))        res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%evap(i,j)
2327         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lrunoff))     res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%lrunoff(i,j)
2328         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frunoff))     res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%frunoff(i,j)
2329         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%vprec))       res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%vprec(i,j)
2330         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt)) res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%seaice\_melt(i,j)
2331 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2332       \textcolor{keywordflow}{if} (handles%id\_prcme > 0) \textcolor{keyword}{call }post\_data(handles%id\_prcme, res, diag)
2333       \textcolor{keywordflow}{if} (handles%id\_total\_prcme > 0) \textcolor{keywordflow}{then}
2334         total\_transport = global\_area\_integral(res, g)
2335         \textcolor{keyword}{call }post\_data(handles%id\_total\_prcme, total\_transport, diag)
2336 \textcolor{keywordflow}{      endif}
2337       \textcolor{keywordflow}{if} (handles%id\_prcme\_ga > 0) \textcolor{keywordflow}{then}
2338         ave\_flux = global\_area\_mean(res, g)
2339         \textcolor{keyword}{call }post\_data(handles%id\_prcme\_ga, ave\_flux, diag)
2340 \textcolor{keywordflow}{      endif}
2341 \textcolor{keywordflow}{    endif}
2342 
2343     \textcolor{keywordflow}{if} (handles%id\_net\_massout > 0 .or. handles%id\_total\_net\_massout > 0) \textcolor{keywordflow}{then}
2344       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2345         res(i,j) = 0.0
2346         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) \textcolor{keywordflow}{then}
2347           \textcolor{keywordflow}{if} (fluxes%lprec(i,j) < 0.0) res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%lprec(i,j)
2348 \textcolor{keywordflow}{        endif}
2349         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%vprec)) \textcolor{keywordflow}{then}
2350           \textcolor{keywordflow}{if} (fluxes%vprec(i,j) < 0.0) res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%vprec(i,j)
2351 \textcolor{keywordflow}{        endif}
2352         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap)) \textcolor{keywordflow}{then}
2353           \textcolor{keywordflow}{if} (fluxes%evap(i,j) < 0.0) res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%evap(i,j)
2354 \textcolor{keywordflow}{        endif}
2355         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt)) \textcolor{keywordflow}{then}
2356           \textcolor{keywordflow}{if} (fluxes%seaice\_melt(i,j) < 0.0) &
2357             res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%seaice\_melt(i,j)
2358 \textcolor{keywordflow}{        endif}
2359 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2360       \textcolor{keywordflow}{if} (handles%id\_net\_massout > 0) \textcolor{keyword}{call }post\_data(handles%id\_net\_massout, res, diag)
2361       \textcolor{keywordflow}{if} (handles%id\_total\_net\_massout > 0) \textcolor{keywordflow}{then}
2362         total\_transport = global\_area\_integral(res, g)
2363         \textcolor{keyword}{call }post\_data(handles%id\_total\_net\_massout, total\_transport, diag)
2364 \textcolor{keywordflow}{      endif}
2365 \textcolor{keywordflow}{    endif}
2366 
2367     \textcolor{keywordflow}{if} (handles%id\_massout\_flux > 0 .and. \textcolor{keyword}{associated}(fluxes%netMassOut)) &
2368       \textcolor{keyword}{call }post\_data(handles%id\_massout\_flux,fluxes%netMassOut,diag)
2369 
2370     \textcolor{keywordflow}{if} (handles%id\_net\_massin > 0 .or. handles%id\_total\_net\_massin > 0) \textcolor{keywordflow}{then}
2371       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2372         res(i,j) = 0.0
2373 
2374         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%fprec)) &
2375           res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%fprec(i,j)
2376         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lrunoff)) &
2377           res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%lrunoff(i,j)
2378         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frunoff)) &
2379           res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%frunoff(i,j)
2380 
2381         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) \textcolor{keywordflow}{then}
2382           \textcolor{keywordflow}{if} (fluxes%lprec(i,j) > 0.0) res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%lprec(i,j)
2383 \textcolor{keywordflow}{        endif}
2384         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%vprec)) \textcolor{keywordflow}{then}
2385           \textcolor{keywordflow}{if} (fluxes%vprec(i,j) > 0.0) res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%vprec(i,j)
2386 \textcolor{keywordflow}{        endif}
2387         \textcolor{comment}{! fluxes%cond is not needed because it is derived from %evap > 0}
2388         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap)) \textcolor{keywordflow}{then}
2389           \textcolor{keywordflow}{if} (fluxes%evap(i,j) > 0.0) res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%evap(i,j)
2390 \textcolor{keywordflow}{        endif}
2391         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt)) \textcolor{keywordflow}{then}
2392           \textcolor{keywordflow}{if} (fluxes%seaice\_melt(i,j) > 0.0) &
2393             res(i,j) = res(i,j) + rz\_t\_conversion*fluxes%seaice\_melt(i,j)
2394 \textcolor{keywordflow}{        endif}
2395 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2396       \textcolor{keywordflow}{if} (handles%id\_net\_massin > 0) \textcolor{keyword}{call }post\_data(handles%id\_net\_massin, res, diag)
2397       \textcolor{keywordflow}{if} (handles%id\_total\_net\_massin > 0) \textcolor{keywordflow}{then}
2398         total\_transport = global\_area\_integral(res, g)
2399         \textcolor{keyword}{call }post\_data(handles%id\_total\_net\_massin, total\_transport, diag)
2400 \textcolor{keywordflow}{      endif}
2401 \textcolor{keywordflow}{    endif}
2402 
2403     \textcolor{keywordflow}{if} (handles%id\_massin\_flux > 0 .and. \textcolor{keyword}{associated}(fluxes%netMassIn)) &
2404       \textcolor{keyword}{call }post\_data(handles%id\_massin\_flux,fluxes%netMassIn,diag)
2405 
2406     \textcolor{keywordflow}{if} ((handles%id\_evap > 0) .and. \textcolor{keyword}{associated}(fluxes%evap)) &
2407       \textcolor{keyword}{call }post\_data(handles%id\_evap, fluxes%evap, diag)
2408     \textcolor{keywordflow}{if} ((handles%id\_total\_evap > 0) .and. \textcolor{keyword}{associated}(fluxes%evap)) \textcolor{keywordflow}{then}
2409       total\_transport = global\_area\_integral(fluxes%evap, g, scale=us%RZ\_T\_to\_kg\_m2s)
2410       \textcolor{keyword}{call }post\_data(handles%id\_total\_evap, total\_transport, diag)
2411 \textcolor{keywordflow}{    endif}
2412     \textcolor{keywordflow}{if} ((handles%id\_evap\_ga > 0) .and. \textcolor{keyword}{associated}(fluxes%evap)) \textcolor{keywordflow}{then}
2413       ave\_flux = global\_area\_mean(fluxes%evap, g, scale=us%RZ\_T\_to\_kg\_m2s)
2414       \textcolor{keyword}{call }post\_data(handles%id\_evap\_ga, ave\_flux, diag)
2415 \textcolor{keywordflow}{    endif}
2416 
2417     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec) .and. \textcolor{keyword}{associated}(fluxes%fprec)) \textcolor{keywordflow}{then}
2418       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2419         res(i,j) = rz\_t\_conversion* (fluxes%lprec(i,j) + fluxes%fprec(i,j))
2420 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2421       \textcolor{keywordflow}{if} (handles%id\_precip > 0) \textcolor{keyword}{call }post\_data(handles%id\_precip, res, diag)
2422       \textcolor{keywordflow}{if} (handles%id\_total\_precip > 0) \textcolor{keywordflow}{then}
2423         total\_transport = global\_area\_integral(res, g)
2424         \textcolor{keyword}{call }post\_data(handles%id\_total\_precip, total\_transport, diag)
2425 \textcolor{keywordflow}{      endif}
2426       \textcolor{keywordflow}{if} (handles%id\_precip\_ga > 0) \textcolor{keywordflow}{then}
2427         ave\_flux = global\_area\_mean(res, g)
2428         \textcolor{keyword}{call }post\_data(handles%id\_precip\_ga, ave\_flux, diag)
2429 \textcolor{keywordflow}{      endif}
2430 \textcolor{keywordflow}{    endif}
2431 
2432     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) \textcolor{keywordflow}{then}
2433       \textcolor{keywordflow}{if} (handles%id\_lprec > 0) \textcolor{keyword}{call }post\_data(handles%id\_lprec, fluxes%lprec, diag)
2434       \textcolor{keywordflow}{if} (handles%id\_total\_lprec > 0) \textcolor{keywordflow}{then}
2435         total\_transport = global\_area\_integral(fluxes%lprec, g, scale=us%RZ\_T\_to\_kg\_m2s)
2436         \textcolor{keyword}{call }post\_data(handles%id\_total\_lprec, total\_transport, diag)
2437 \textcolor{keywordflow}{      endif}
2438       \textcolor{keywordflow}{if} (handles%id\_lprec\_ga > 0) \textcolor{keywordflow}{then}
2439         ave\_flux = global\_area\_mean(fluxes%lprec, g, scale=us%RZ\_T\_to\_kg\_m2s)
2440         \textcolor{keyword}{call }post\_data(handles%id\_lprec\_ga, ave\_flux, diag)
2441 \textcolor{keywordflow}{      endif}
2442 \textcolor{keywordflow}{    endif}
2443 
2444     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%fprec)) \textcolor{keywordflow}{then}
2445       \textcolor{keywordflow}{if} (handles%id\_fprec > 0) \textcolor{keyword}{call }post\_data(handles%id\_fprec, fluxes%fprec, diag)
2446       \textcolor{keywordflow}{if} (handles%id\_total\_fprec > 0) \textcolor{keywordflow}{then}
2447         total\_transport = global\_area\_integral(fluxes%fprec, g, scale=us%RZ\_T\_to\_kg\_m2s)
2448         \textcolor{keyword}{call }post\_data(handles%id\_total\_fprec, total\_transport, diag)
2449 \textcolor{keywordflow}{      endif}
2450       \textcolor{keywordflow}{if} (handles%id\_fprec\_ga > 0) \textcolor{keywordflow}{then}
2451         ave\_flux = global\_area\_mean(fluxes%fprec, g, scale=us%RZ\_T\_to\_kg\_m2s)
2452         \textcolor{keyword}{call }post\_data(handles%id\_fprec\_ga, ave\_flux, diag)
2453 \textcolor{keywordflow}{      endif}
2454 \textcolor{keywordflow}{    endif}
2455 
2456     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%vprec)) \textcolor{keywordflow}{then}
2457       \textcolor{keywordflow}{if} (handles%id\_vprec > 0) \textcolor{keyword}{call }post\_data(handles%id\_vprec, fluxes%vprec, diag)
2458       \textcolor{keywordflow}{if} (handles%id\_total\_vprec > 0) \textcolor{keywordflow}{then}
2459         total\_transport = global\_area\_integral(fluxes%vprec, g, scale=us%RZ\_T\_to\_kg\_m2s)
2460         \textcolor{keyword}{call }post\_data(handles%id\_total\_vprec, total\_transport, diag)
2461 \textcolor{keywordflow}{      endif}
2462       \textcolor{keywordflow}{if} (handles%id\_vprec\_ga > 0) \textcolor{keywordflow}{then}
2463         ave\_flux = global\_area\_mean(fluxes%vprec, g, scale=us%RZ\_T\_to\_kg\_m2s)
2464         \textcolor{keyword}{call }post\_data(handles%id\_vprec\_ga, ave\_flux, diag)
2465 \textcolor{keywordflow}{      endif}
2466 \textcolor{keywordflow}{    endif}
2467 
2468     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lrunoff)) \textcolor{keywordflow}{then}
2469     \textcolor{keywordflow}{if} (handles%id\_lrunoff > 0) \textcolor{keyword}{call }post\_data(handles%id\_lrunoff, fluxes%lrunoff, diag)
2470       \textcolor{keywordflow}{if} (handles%id\_total\_lrunoff > 0) \textcolor{keywordflow}{then}
2471         total\_transport = global\_area\_integral(fluxes%lrunoff, g, scale=us%RZ\_T\_to\_kg\_m2s)
2472         \textcolor{keyword}{call }post\_data(handles%id\_total\_lrunoff, total\_transport, diag)
2473 \textcolor{keywordflow}{      endif}
2474 \textcolor{keywordflow}{    endif}
2475 
2476     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frunoff)) \textcolor{keywordflow}{then}
2477       \textcolor{keywordflow}{if} (handles%id\_frunoff > 0) \textcolor{keyword}{call }post\_data(handles%id\_frunoff, fluxes%frunoff, diag)
2478       \textcolor{keywordflow}{if} (handles%id\_total\_frunoff > 0) \textcolor{keywordflow}{then}
2479         total\_transport = global\_area\_integral(fluxes%frunoff, g, scale=us%RZ\_T\_to\_kg\_m2s)
2480         \textcolor{keyword}{call }post\_data(handles%id\_total\_frunoff, total\_transport, diag)
2481 \textcolor{keywordflow}{      endif}
2482 \textcolor{keywordflow}{    endif}
2483 
2484     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt)) \textcolor{keywordflow}{then}
2485       \textcolor{keywordflow}{if} (handles%id\_seaice\_melt > 0) \textcolor{keyword}{call }post\_data(handles%id\_seaice\_melt, fluxes%seaice\_melt, diag)
2486       \textcolor{keywordflow}{if} (handles%id\_total\_seaice\_melt > 0) \textcolor{keywordflow}{then}
2487         total\_transport = global\_area\_integral(fluxes%seaice\_melt, g, scale=us%RZ\_T\_to\_kg\_m2s)
2488         \textcolor{keyword}{call }post\_data(handles%id\_total\_seaice\_melt, total\_transport, diag)
2489 \textcolor{keywordflow}{      endif}
2490 \textcolor{keywordflow}{    endif}
2491 
2492     \textcolor{comment}{! post diagnostics for boundary heat fluxes ====================================}
2493 
2494     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_lrunoff > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff))  &
2495       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_lrunoff, fluxes%heat\_content\_lrunoff, diag)
2496     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_lrunoff > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff)) \textcolor{keywordflow}{then}
2497       total\_transport = global\_area\_integral(fluxes%heat\_content\_lrunoff, g, scale=us%QRZ\_T\_to\_W\_m2)
2498       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_lrunoff, total\_transport, diag)
2499 \textcolor{keywordflow}{    endif}
2500 
2501     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_frunoff > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff))  &
2502       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_frunoff, fluxes%heat\_content\_frunoff, diag)
2503     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_frunoff > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff)) \textcolor{keywordflow}{then}
2504       total\_transport = global\_area\_integral(fluxes%heat\_content\_frunoff, g, scale=us%QRZ\_T\_to\_W\_m2)
2505       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_frunoff, total\_transport, diag)
2506 \textcolor{keywordflow}{    endif}
2507 
2508     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_lprec > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_lprec))      &
2509       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_lprec, fluxes%heat\_content\_lprec, diag)
2510     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_lprec > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_lprec)) \textcolor{keywordflow}{then}
2511       total\_transport = global\_area\_integral(fluxes%heat\_content\_lprec, g, scale=us%QRZ\_T\_to\_W\_m2)
2512       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_lprec, total\_transport, diag)
2513 \textcolor{keywordflow}{    endif}
2514 
2515     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_fprec > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_fprec))      &
2516       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_fprec, fluxes%heat\_content\_fprec, diag)
2517     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_fprec > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_fprec)) \textcolor{keywordflow}{then}
2518       total\_transport = global\_area\_integral(fluxes%heat\_content\_fprec, g, scale=us%QRZ\_T\_to\_W\_m2)
2519       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_fprec, total\_transport, diag)
2520 \textcolor{keywordflow}{    endif}
2521 
2522     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_icemelt > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt))      &
2523       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_icemelt, fluxes%heat\_content\_icemelt, diag)
2524     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_icemelt > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt)) \textcolor{keywordflow}{then}
2525       total\_transport = global\_area\_integral(fluxes%heat\_content\_icemelt, g, scale=us%QRZ\_T\_to\_W\_m2)
2526       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_icemelt, total\_transport, diag)
2527 \textcolor{keywordflow}{    endif}
2528 
2529     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_vprec > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_vprec))      &
2530       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_vprec, fluxes%heat\_content\_vprec, diag)
2531     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_vprec > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_vprec)) \textcolor{keywordflow}{then}
2532       total\_transport = global\_area\_integral(fluxes%heat\_content\_vprec, g, scale=us%QRZ\_T\_to\_W\_m2)
2533       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_vprec, total\_transport, diag)
2534 \textcolor{keywordflow}{    endif}
2535 
2536     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_cond > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_cond))        &
2537       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_cond, fluxes%heat\_content\_cond, diag)
2538     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_cond > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_cond)) \textcolor{keywordflow}{then}
2539       total\_transport = global\_area\_integral(fluxes%heat\_content\_cond, g, scale=us%QRZ\_T\_to\_W\_m2)
2540       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_cond, total\_transport, diag)
2541 \textcolor{keywordflow}{    endif}
2542 
2543     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_massout > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_massout))  &
2544       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_massout, fluxes%heat\_content\_massout, diag)
2545     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_massout > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_massout)) \textcolor{keywordflow}{then}
2546       total\_transport = global\_area\_integral(fluxes%heat\_content\_massout, g, scale=us%QRZ\_T\_to\_W\_m2)
2547       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_massout, total\_transport, diag)
2548 \textcolor{keywordflow}{    endif}
2549 
2550     \textcolor{keywordflow}{if} ((handles%id\_heat\_content\_massin > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_massin))  &
2551       \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_massin, fluxes%heat\_content\_massin, diag)
2552     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_content\_massin > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_content\_massin)) \textcolor{keywordflow}{then}
2553       total\_transport = global\_area\_integral(fluxes%heat\_content\_massin, g, scale=us%QRZ\_T\_to\_W\_m2)
2554       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_massin, total\_transport, diag)
2555 \textcolor{keywordflow}{    endif}
2556 
2557     \textcolor{keywordflow}{if} (handles%id\_net\_heat\_coupler > 0 .or. handles%id\_total\_net\_heat\_coupler > 0 .or. &
2558         handles%id\_net\_heat\_coupler\_ga > 0. ) \textcolor{keywordflow}{then}
2559       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2560       res(i,j) = 0.0
2561       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%LW))               res(i,j) = res(i,j) + fluxes%lw(i,j)
2562       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent))           res(i,j) = res(i,j) + fluxes%latent(i,j)
2563       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens))             res(i,j) = res(i,j) + fluxes%sens(i,j)
2564       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%SW))               res(i,j) = res(i,j) + fluxes%sw(i,j)
2565       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat)) res(i,j) = res(i,j) + fluxes%seaice\_melt\_heat(i,j)
2566 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2567       \textcolor{keywordflow}{if} (handles%id\_net\_heat\_coupler > 0) \textcolor{keyword}{call }post\_data(handles%id\_net\_heat\_coupler, res, diag)
2568       \textcolor{keywordflow}{if} (handles%id\_total\_net\_heat\_coupler > 0) \textcolor{keywordflow}{then}
2569         total\_transport = global\_area\_integral(res, g, scale=us%QRZ\_T\_to\_W\_m2)
2570         \textcolor{keyword}{call }post\_data(handles%id\_total\_net\_heat\_coupler, total\_transport, diag)
2571 \textcolor{keywordflow}{      endif}
2572       \textcolor{keywordflow}{if} (handles%id\_net\_heat\_coupler\_ga > 0) \textcolor{keywordflow}{then}
2573         ave\_flux = global\_area\_mean(res, g, scale=us%QRZ\_T\_to\_W\_m2)
2574         \textcolor{keyword}{call }post\_data(handles%id\_net\_heat\_coupler\_ga, ave\_flux, diag)
2575 \textcolor{keywordflow}{      endif}
2576 \textcolor{keywordflow}{    endif}
2577 
2578     \textcolor{keywordflow}{if} (handles%id\_net\_heat\_surface > 0 .or. handles%id\_total\_net\_heat\_surface > 0 .or. &
2579         handles%id\_net\_heat\_surface\_ga > 0. ) \textcolor{keywordflow}{then}
2580       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2581         res(i,j) = 0.0
2582         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%LW))               res(i,j) = res(i,j) + fluxes%lw(i,j)
2583         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent))           res(i,j) = res(i,j) + fluxes%latent(i,j)
2584         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens))             res(i,j) = res(i,j) + fluxes%sens(i,j)
2585         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%SW))               res(i,j) = res(i,j) + fluxes%sw(i,j)
2586         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat)) res(i,j) = res(i,j) + fluxes%seaice\_melt\_heat(i,j)
2587         \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%frazil))         res(i,j) = res(i,j) + sfc\_state%frazil(i,j) * i\_dt
2588         \textcolor{comment}{!if (associated(sfc\_state%TempXpme)) then}
2589         \textcolor{comment}{!  res(i,j) = res(i,j) + sfc\_state%TempXpme(i,j) * fluxes%C\_p * I\_dt}
2590         \textcolor{comment}{!else}
2591           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff)) &
2592             res(i,j) = res(i,j) + fluxes%heat\_content\_lrunoff(i,j)
2593           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff)) &
2594             res(i,j) = res(i,j) + fluxes%heat\_content\_frunoff(i,j)
2595           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lprec)) &
2596             res(i,j) = res(i,j) + fluxes%heat\_content\_lprec(i,j)
2597           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_fprec)) &
2598             res(i,j) = res(i,j) + fluxes%heat\_content\_fprec(i,j)
2599           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt)) &
2600             res(i,j) = res(i,j) + fluxes%heat\_content\_icemelt(i,j)
2601           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_vprec)) &
2602             res(i,j) = res(i,j) + fluxes%heat\_content\_vprec(i,j)
2603           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_cond)) &
2604             res(i,j) = res(i,j) + fluxes%heat\_content\_cond(i,j)
2605           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_massout)) &
2606             res(i,j) = res(i,j) + fluxes%heat\_content\_massout(i,j)
2607         \textcolor{comment}{!endif}
2608         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_added)) res(i,j) = res(i,j) + fluxes%heat\_added(i,j)
2609 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2610       \textcolor{keywordflow}{if} (handles%id\_net\_heat\_surface > 0) \textcolor{keyword}{call }post\_data(handles%id\_net\_heat\_surface, res, diag)
2611 
2612       \textcolor{keywordflow}{if} (handles%id\_total\_net\_heat\_surface > 0) \textcolor{keywordflow}{then}
2613         total\_transport = global\_area\_integral(res, g, scale=us%QRZ\_T\_to\_W\_m2)
2614         \textcolor{keyword}{call }post\_data(handles%id\_total\_net\_heat\_surface, total\_transport, diag)
2615 \textcolor{keywordflow}{      endif}
2616       \textcolor{keywordflow}{if} (handles%id\_net\_heat\_surface\_ga > 0) \textcolor{keywordflow}{then}
2617         ave\_flux = global\_area\_mean(res, g, scale=us%QRZ\_T\_to\_W\_m2)
2618         \textcolor{keyword}{call }post\_data(handles%id\_net\_heat\_surface\_ga, ave\_flux, diag)
2619 \textcolor{keywordflow}{      endif}
2620 \textcolor{keywordflow}{    endif}
2621 
2622     \textcolor{keywordflow}{if} (handles%id\_heat\_content\_surfwater > 0 .or. handles%id\_total\_heat\_content\_surfwater > 0) \textcolor{keywordflow}{then}
2623       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2624         res(i,j) = 0.0
2625       \textcolor{comment}{! if (associated(sfc\_state%TempXpme)) then}
2626       \textcolor{comment}{!   res(i,j) = res(i,j) + sfc\_state%TempXpme(i,j) * fluxes%C\_p * I\_dt}
2627       \textcolor{comment}{! else}
2628           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff)) res(i,j) = res(i,j) + fluxes%heat\_content\_lrunoff(i,
      j)
2629           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff)) res(i,j) = res(i,j) + fluxes%heat\_content\_frunoff(i,
      j)
2630           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lprec))   res(i,j) = res(i,j) + fluxes%heat\_content\_lprec(i,j)
2631           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt)) res(i,j) = res(i,j) + fluxes%heat\_content\_icemelt(i,
      j)
2632           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_fprec))   res(i,j) = res(i,j) + fluxes%heat\_content\_fprec(i,j)
2633           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_vprec))   res(i,j) = res(i,j) + fluxes%heat\_content\_vprec(i,j)
2634           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_cond))    res(i,j) = res(i,j) + fluxes%heat\_content\_cond(i,j)
2635           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_massout)) res(i,j) = res(i,j) + fluxes%heat\_content\_massout(i,
      j)
2636       \textcolor{comment}{! endif}
2637 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2638       \textcolor{keywordflow}{if} (handles%id\_heat\_content\_surfwater > 0) \textcolor{keyword}{call }post\_data(handles%id\_heat\_content\_surfwater, res, 
      diag)
2639       \textcolor{keywordflow}{if} (handles%id\_total\_heat\_content\_surfwater > 0) \textcolor{keywordflow}{then}
2640         total\_transport = global\_area\_integral(res, g, scale=us%QRZ\_T\_to\_W\_m2)
2641         \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_content\_surfwater, total\_transport, diag)
2642 \textcolor{keywordflow}{      endif}
2643 \textcolor{keywordflow}{    endif}
2644 
2645     \textcolor{comment}{! for OMIP, hfrunoffds = heat content of liquid plus frozen runoff}
2646     \textcolor{keywordflow}{if} (handles%id\_hfrunoffds > 0) \textcolor{keywordflow}{then}
2647       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2648         res(i,j) = 0.0
2649         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff)) res(i,j) = res(i,j) + fluxes%heat\_content\_lrunoff(i,j)
2650         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff)) res(i,j) = res(i,j) + fluxes%heat\_content\_frunoff(i,j)
2651 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2652       \textcolor{keyword}{call }post\_data(handles%id\_hfrunoffds, res, diag)
2653 \textcolor{keywordflow}{    endif}
2654 
2655     \textcolor{comment}{! for OMIP, hfrainds = heat content of lprec + fprec + cond}
2656     \textcolor{keywordflow}{if} (handles%id\_hfrainds > 0) \textcolor{keywordflow}{then}
2657       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2658         res(i,j) = 0.0
2659         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lprec)) res(i,j) = res(i,j) + fluxes%heat\_content\_lprec(i,j)
2660         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_fprec)) res(i,j) = res(i,j) + fluxes%heat\_content\_fprec(i,j)
2661         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_cond)) res(i,j) = res(i,j) + fluxes%heat\_content\_cond(i,j)
2662 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2663       \textcolor{keyword}{call }post\_data(handles%id\_hfrainds, res, diag)
2664 \textcolor{keywordflow}{    endif}
2665 
2666     \textcolor{keywordflow}{if} ((handles%id\_LwLatSens > 0) .and. \textcolor{keyword}{associated}(fluxes%lw) .and. &
2667          \textcolor{keyword}{associated}(fluxes%latent) .and. \textcolor{keyword}{associated}(fluxes%sens)) \textcolor{keywordflow}{then}
2668       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2669         res(i,j) = (fluxes%lw(i,j) + fluxes%latent(i,j)) + fluxes%sens(i,j)
2670 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2671       \textcolor{keyword}{call }post\_data(handles%id\_LwLatSens, res, diag)
2672 \textcolor{keywordflow}{    endif}
2673 
2674     \textcolor{keywordflow}{if} ((handles%id\_total\_LwLatSens > 0) .and. \textcolor{keyword}{associated}(fluxes%lw) .and. &
2675          \textcolor{keyword}{associated}(fluxes%latent) .and. \textcolor{keyword}{associated}(fluxes%sens)) \textcolor{keywordflow}{then}
2676       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2677         res(i,j) = (fluxes%lw(i,j) + fluxes%latent(i,j)) + fluxes%sens(i,j)
2678 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2679       total\_transport = global\_area\_integral(res, g, scale=us%QRZ\_T\_to\_W\_m2)
2680       \textcolor{keyword}{call }post\_data(handles%id\_total\_LwLatSens, total\_transport, diag)
2681 \textcolor{keywordflow}{    endif}
2682 
2683     \textcolor{keywordflow}{if} ((handles%id\_LwLatSens\_ga > 0) .and. \textcolor{keyword}{associated}(fluxes%lw) .and. &
2684          \textcolor{keyword}{associated}(fluxes%latent) .and. \textcolor{keyword}{associated}(fluxes%sens)) \textcolor{keywordflow}{then}
2685       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2686         res(i,j) = ((fluxes%lw(i,j) + fluxes%latent(i,j)) + fluxes%sens(i,j))
2687 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
2688       ave\_flux = global\_area\_mean(res, g, scale=us%QRZ\_T\_to\_W\_m2)
2689       \textcolor{keyword}{call }post\_data(handles%id\_LwLatSens\_ga, ave\_flux, diag)
2690 \textcolor{keywordflow}{    endif}
2691 
2692     \textcolor{keywordflow}{if} ((handles%id\_sw > 0) .and. \textcolor{keyword}{associated}(fluxes%sw)) \textcolor{keywordflow}{then}
2693       \textcolor{keyword}{call }post\_data(handles%id\_sw, fluxes%sw, diag)
2694 \textcolor{keywordflow}{    endif}
2695     \textcolor{keywordflow}{if} ((handles%id\_sw\_vis > 0) .and. \textcolor{keyword}{associated}(fluxes%sw\_vis\_dir) .and. &
2696         \textcolor{keyword}{associated}(fluxes%sw\_vis\_dif)) \textcolor{keywordflow}{then}
2697       \textcolor{keyword}{call }post\_data(handles%id\_sw\_vis, fluxes%sw\_vis\_dir+fluxes%sw\_vis\_dif, diag)
2698 \textcolor{keywordflow}{    endif}
2699     \textcolor{keywordflow}{if} ((handles%id\_sw\_nir > 0) .and. \textcolor{keyword}{associated}(fluxes%sw\_nir\_dir) .and. &
2700         \textcolor{keyword}{associated}(fluxes%sw\_nir\_dif)) \textcolor{keywordflow}{then}
2701       \textcolor{keyword}{call }post\_data(handles%id\_sw\_nir, fluxes%sw\_nir\_dir+fluxes%sw\_nir\_dif, diag)
2702 \textcolor{keywordflow}{    endif}
2703     \textcolor{keywordflow}{if} ((handles%id\_total\_sw > 0) .and. \textcolor{keyword}{associated}(fluxes%sw)) \textcolor{keywordflow}{then}
2704       total\_transport = global\_area\_integral(fluxes%sw, g, scale=us%QRZ\_T\_to\_W\_m2)
2705       \textcolor{keyword}{call }post\_data(handles%id\_total\_sw, total\_transport, diag)
2706 \textcolor{keywordflow}{    endif}
2707     \textcolor{keywordflow}{if} ((handles%id\_sw\_ga > 0) .and. \textcolor{keyword}{associated}(fluxes%sw)) \textcolor{keywordflow}{then}
2708       ave\_flux = global\_area\_mean(fluxes%sw, g, scale=us%QRZ\_T\_to\_W\_m2)
2709       \textcolor{keyword}{call }post\_data(handles%id\_sw\_ga, ave\_flux, diag)
2710 \textcolor{keywordflow}{    endif}
2711 
2712     \textcolor{keywordflow}{if} ((handles%id\_lw > 0) .and. \textcolor{keyword}{associated}(fluxes%lw)) \textcolor{keywordflow}{then}
2713       \textcolor{keyword}{call }post\_data(handles%id\_lw, fluxes%lw, diag)
2714 \textcolor{keywordflow}{    endif}
2715     \textcolor{keywordflow}{if} ((handles%id\_total\_lw > 0) .and. \textcolor{keyword}{associated}(fluxes%lw)) \textcolor{keywordflow}{then}
2716       total\_transport = global\_area\_integral(fluxes%lw, g, scale=us%QRZ\_T\_to\_W\_m2)
2717       \textcolor{keyword}{call }post\_data(handles%id\_total\_lw, total\_transport, diag)
2718 \textcolor{keywordflow}{    endif}
2719     \textcolor{keywordflow}{if} ((handles%id\_lw\_ga > 0) .and. \textcolor{keyword}{associated}(fluxes%lw)) \textcolor{keywordflow}{then}
2720       ave\_flux = global\_area\_mean(fluxes%lw, g, scale=us%QRZ\_T\_to\_W\_m2)
2721       \textcolor{keyword}{call }post\_data(handles%id\_lw\_ga, ave\_flux, diag)
2722 \textcolor{keywordflow}{    endif}
2723 
2724     \textcolor{keywordflow}{if} ((handles%id\_lat > 0) .and. \textcolor{keyword}{associated}(fluxes%latent)) \textcolor{keywordflow}{then}
2725       \textcolor{keyword}{call }post\_data(handles%id\_lat, fluxes%latent, diag)
2726 \textcolor{keywordflow}{    endif}
2727     \textcolor{keywordflow}{if} ((handles%id\_total\_lat > 0) .and. \textcolor{keyword}{associated}(fluxes%latent)) \textcolor{keywordflow}{then}
2728       total\_transport = global\_area\_integral(fluxes%latent, g, scale=us%QRZ\_T\_to\_W\_m2)
2729       \textcolor{keyword}{call }post\_data(handles%id\_total\_lat, total\_transport, diag)
2730 \textcolor{keywordflow}{    endif}
2731     \textcolor{keywordflow}{if} ((handles%id\_lat\_ga > 0) .and. \textcolor{keyword}{associated}(fluxes%latent)) \textcolor{keywordflow}{then}
2732       ave\_flux = global\_area\_mean(fluxes%latent, g, scale=us%QRZ\_T\_to\_W\_m2)
2733       \textcolor{keyword}{call }post\_data(handles%id\_lat\_ga, ave\_flux, diag)
2734 \textcolor{keywordflow}{    endif}
2735 
2736     \textcolor{keywordflow}{if} ((handles%id\_lat\_evap > 0) .and. \textcolor{keyword}{associated}(fluxes%latent\_evap\_diag)) \textcolor{keywordflow}{then}
2737       \textcolor{keyword}{call }post\_data(handles%id\_lat\_evap, fluxes%latent\_evap\_diag, diag)
2738 \textcolor{keywordflow}{    endif}
2739     \textcolor{keywordflow}{if} ((handles%id\_total\_lat\_evap > 0) .and. \textcolor{keyword}{associated}(fluxes%latent\_evap\_diag)) \textcolor{keywordflow}{then}
2740       total\_transport = global\_area\_integral(fluxes%latent\_evap\_diag, g, scale=us%QRZ\_T\_to\_W\_m2)
2741       \textcolor{keyword}{call }post\_data(handles%id\_total\_lat\_evap, total\_transport, diag)
2742 \textcolor{keywordflow}{    endif}
2743 
2744     \textcolor{keywordflow}{if} ((handles%id\_lat\_fprec > 0) .and. \textcolor{keyword}{associated}(fluxes%latent\_fprec\_diag)) \textcolor{keywordflow}{then}
2745       \textcolor{keyword}{call }post\_data(handles%id\_lat\_fprec, fluxes%latent\_fprec\_diag, diag)
2746 \textcolor{keywordflow}{    endif}
2747     \textcolor{keywordflow}{if} ((handles%id\_total\_lat\_fprec > 0) .and. \textcolor{keyword}{associated}(fluxes%latent\_fprec\_diag)) \textcolor{keywordflow}{then}
2748       total\_transport = global\_area\_integral(fluxes%latent\_fprec\_diag, g, scale=us%QRZ\_T\_to\_W\_m2)
2749       \textcolor{keyword}{call }post\_data(handles%id\_total\_lat\_fprec, total\_transport, diag)
2750 \textcolor{keywordflow}{    endif}
2751 
2752     \textcolor{keywordflow}{if} ((handles%id\_lat\_frunoff > 0) .and. \textcolor{keyword}{associated}(fluxes%latent\_frunoff\_diag)) \textcolor{keywordflow}{then}
2753       \textcolor{keyword}{call }post\_data(handles%id\_lat\_frunoff, fluxes%latent\_frunoff\_diag, diag)
2754 \textcolor{keywordflow}{    endif}
2755     \textcolor{keywordflow}{if} (handles%id\_total\_lat\_frunoff > 0 .and. \textcolor{keyword}{associated}(fluxes%latent\_frunoff\_diag)) \textcolor{keywordflow}{then}
2756       total\_transport = global\_area\_integral(fluxes%latent\_frunoff\_diag, g, scale=us%QRZ\_T\_to\_W\_m2)
2757       \textcolor{keyword}{call }post\_data(handles%id\_total\_lat\_frunoff, total\_transport, diag)
2758 \textcolor{keywordflow}{    endif}
2759 
2760     \textcolor{keywordflow}{if} ((handles%id\_sens > 0) .and. \textcolor{keyword}{associated}(fluxes%sens)) \textcolor{keywordflow}{then}
2761       \textcolor{keyword}{call }post\_data(handles%id\_sens, fluxes%sens, diag)
2762 \textcolor{keywordflow}{    endif}
2763 
2764     \textcolor{keywordflow}{if} ((handles%id\_seaice\_melt\_heat > 0) .and. \textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat)) \textcolor{keywordflow}{then}
2765       \textcolor{keyword}{call }post\_data(handles%id\_seaice\_melt\_heat, fluxes%seaice\_melt\_heat, diag)
2766 \textcolor{keywordflow}{    endif}
2767 
2768     \textcolor{keywordflow}{if} ((handles%id\_total\_seaice\_melt\_heat > 0) .and. \textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat)) \textcolor{keywordflow}{then}
2769       total\_transport = global\_area\_integral(fluxes%seaice\_melt\_heat, g, scale=us%QRZ\_T\_to\_W\_m2)
2770       \textcolor{keyword}{call }post\_data(handles%id\_total\_seaice\_melt\_heat, total\_transport, diag)
2771 \textcolor{keywordflow}{    endif}
2772 
2773     \textcolor{keywordflow}{if} ((handles%id\_total\_sens > 0) .and. \textcolor{keyword}{associated}(fluxes%sens)) \textcolor{keywordflow}{then}
2774       total\_transport = global\_area\_integral(fluxes%sens, g, scale=us%QRZ\_T\_to\_W\_m2)
2775       \textcolor{keyword}{call }post\_data(handles%id\_total\_sens, total\_transport, diag)
2776 \textcolor{keywordflow}{    endif}
2777     \textcolor{keywordflow}{if} ((handles%id\_sens\_ga > 0) .and. \textcolor{keyword}{associated}(fluxes%sens)) \textcolor{keywordflow}{then}
2778       ave\_flux = global\_area\_mean(fluxes%sens, g, scale=us%QRZ\_T\_to\_W\_m2)
2779       \textcolor{keyword}{call }post\_data(handles%id\_sens\_ga, ave\_flux, diag)
2780 \textcolor{keywordflow}{    endif}
2781 
2782     \textcolor{keywordflow}{if} ((handles%id\_heat\_added > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_added)) \textcolor{keywordflow}{then}
2783       \textcolor{keyword}{call }post\_data(handles%id\_heat\_added, fluxes%heat\_added, diag)
2784 \textcolor{keywordflow}{    endif}
2785 
2786     \textcolor{keywordflow}{if} ((handles%id\_total\_heat\_added > 0) .and. \textcolor{keyword}{associated}(fluxes%heat\_added)) \textcolor{keywordflow}{then}
2787       total\_transport = global\_area\_integral(fluxes%heat\_added, g, scale=us%QRZ\_T\_to\_W\_m2)
2788       \textcolor{keyword}{call }post\_data(handles%id\_total\_heat\_added, total\_transport, diag)
2789 \textcolor{keywordflow}{    endif}
2790 
2791 
2792     \textcolor{comment}{! post the diagnostics for boundary salt fluxes ==========================}
2793 
2794     \textcolor{keywordflow}{if} ((handles%id\_saltflux > 0) .and. \textcolor{keyword}{associated}(fluxes%salt\_flux)) &
2795       \textcolor{keyword}{call }post\_data(handles%id\_saltflux, fluxes%salt\_flux, diag)
2796     \textcolor{keywordflow}{if} ((handles%id\_total\_saltflux > 0) .and. \textcolor{keyword}{associated}(fluxes%salt\_flux)) \textcolor{keywordflow}{then}
2797       total\_transport = ppt2mks*global\_area\_integral(fluxes%salt\_flux, g, scale=us%RZ\_T\_to\_kg\_m2s)
2798       \textcolor{keyword}{call }post\_data(handles%id\_total\_saltflux, total\_transport, diag)
2799 \textcolor{keywordflow}{    endif}
2800 
2801     \textcolor{keywordflow}{if} ((handles%id\_saltFluxAdded > 0) .and. \textcolor{keyword}{associated}(fluxes%salt\_flux\_added)) &
2802       \textcolor{keyword}{call }post\_data(handles%id\_saltFluxAdded, fluxes%salt\_flux\_added, diag)
2803     \textcolor{keywordflow}{if} ((handles%id\_total\_saltFluxAdded > 0) .and. \textcolor{keyword}{associated}(fluxes%salt\_flux\_added)) \textcolor{keywordflow}{then}
2804       total\_transport = ppt2mks*global\_area\_integral(fluxes%salt\_flux\_added, g, scale=us%RZ\_T\_to\_kg\_m2s)
2805       \textcolor{keyword}{call }post\_data(handles%id\_total\_saltFluxAdded, total\_transport, diag)
2806 \textcolor{keywordflow}{    endif}
2807 
2808     \textcolor{keywordflow}{if} (handles%id\_saltFluxIn > 0 .and. \textcolor{keyword}{associated}(fluxes%salt\_flux\_in)) &
2809       \textcolor{keyword}{call }post\_data(handles%id\_saltFluxIn, fluxes%salt\_flux\_in, diag)
2810     \textcolor{keywordflow}{if} ((handles%id\_total\_saltFluxIn > 0) .and. \textcolor{keyword}{associated}(fluxes%salt\_flux\_in)) \textcolor{keywordflow}{then}
2811       total\_transport = ppt2mks*global\_area\_integral(fluxes%salt\_flux\_in, g, scale=us%RZ\_T\_to\_kg\_m2s)
2812       \textcolor{keyword}{call }post\_data(handles%id\_total\_saltFluxIn, total\_transport, diag)
2813 \textcolor{keywordflow}{    endif}
2814 
2815     \textcolor{keywordflow}{if} (handles%id\_saltFluxGlobalAdj > 0)                                            &
2816       \textcolor{keyword}{call }post\_data(handles%id\_saltFluxGlobalAdj, fluxes%saltFluxGlobalAdj, diag)
2817     \textcolor{keywordflow}{if} (handles%id\_vPrecGlobalAdj > 0)                                               &
2818       \textcolor{keyword}{call }post\_data(handles%id\_vPrecGlobalAdj, fluxes%vPrecGlobalAdj, diag)
2819     \textcolor{keywordflow}{if} (handles%id\_netFWGlobalAdj > 0)                                               &
2820       \textcolor{keyword}{call }post\_data(handles%id\_netFWGlobalAdj, fluxes%netFWGlobalAdj, diag)
2821     \textcolor{keywordflow}{if} (handles%id\_saltFluxGlobalScl > 0)                                            &
2822       \textcolor{keyword}{call }post\_data(handles%id\_saltFluxGlobalScl, fluxes%saltFluxGlobalScl, diag)
2823     \textcolor{keywordflow}{if} (handles%id\_vPrecGlobalScl > 0)                                               &
2824       \textcolor{keyword}{call }post\_data(handles%id\_vPrecGlobalScl, fluxes%vPrecGlobalScl, diag)
2825     \textcolor{keywordflow}{if} (handles%id\_netFWGlobalScl > 0)                                               &
2826       \textcolor{keyword}{call }post\_data(handles%id\_netFWGlobalScl, fluxes%netFWGlobalScl, diag)
2827 
2828 
2829     \textcolor{comment}{! remaining boundary terms ==================================================}
2830 
2831     \textcolor{keywordflow}{if} ((handles%id\_psurf > 0) .and. \textcolor{keyword}{associated}(fluxes%p\_surf))                      &
2832       \textcolor{keyword}{call }post\_data(handles%id\_psurf, fluxes%p\_surf, diag)
2833 
2834     \textcolor{keywordflow}{if} ((handles%id\_TKE\_tidal > 0) .and. \textcolor{keyword}{associated}(fluxes%TKE\_tidal))               &
2835       \textcolor{keyword}{call }post\_data(handles%id\_TKE\_tidal, fluxes%TKE\_tidal, diag)
2836 
2837     \textcolor{keywordflow}{if} ((handles%id\_buoy > 0) .and. \textcolor{keyword}{associated}(fluxes%buoy))                         &
2838       \textcolor{keyword}{call }post\_data(handles%id\_buoy, fluxes%buoy, diag)
2839 
2840     \textcolor{keywordflow}{if} ((handles%id\_ustar > 0) .and. \textcolor{keyword}{associated}(fluxes%ustar)) &
2841       \textcolor{keyword}{call }post\_data(handles%id\_ustar, fluxes%ustar, diag)
2842 
2843     \textcolor{keywordflow}{if} ((handles%id\_ustar\_berg > 0) .and. \textcolor{keyword}{associated}(fluxes%ustar\_berg)) &
2844       \textcolor{keyword}{call }post\_data(handles%id\_ustar\_berg, fluxes%ustar\_berg, diag)
2845 
2846     \textcolor{keywordflow}{if} ((handles%id\_frac\_ice\_cover > 0) .and. \textcolor{keyword}{associated}(fluxes%frac\_shelf\_h)) &
2847       \textcolor{keyword}{call }post\_data(handles%id\_frac\_ice\_cover, fluxes%frac\_shelf\_h, diag)
2848 
2849     \textcolor{keywordflow}{if} ((handles%id\_ustar\_ice\_cover > 0) .and. \textcolor{keyword}{associated}(fluxes%ustar\_shelf)) &
2850       \textcolor{keyword}{call }post\_data(handles%id\_ustar\_ice\_cover, fluxes%ustar\_shelf, diag)
2851 
2852   \textcolor{comment}{! endif  ! query\_averaging\_enabled}
2853   \textcolor{keyword}{call }disable\_averaging(diag)
2854 
2855   \textcolor{keywordflow}{if} (turns /= 0) \textcolor{keywordflow}{then}
2856     \textcolor{keyword}{call }deallocate\_forcing\_type(fluxes)
2857     \textcolor{keyword}{deallocate}(fluxes)
2858 \textcolor{keywordflow}{  endif}
2859 
2860   \textcolor{keyword}{call }cpu\_clock\_end(handles%id\_clock\_forcing)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a1048a8e80ebd47f83b91772c02aedba2}\label{namespacemom__forcing__type_a1048a8e80ebd47f83b91772c02aedba2}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!forcing\+\_\+singlepointprint@{forcing\+\_\+singlepointprint}}
\index{forcing\+\_\+singlepointprint@{forcing\+\_\+singlepointprint}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{forcing\+\_\+singlepointprint()}{forcing\_singlepointprint()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::forcing\+\_\+singlepointprint (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{integer, intent(in)}]{i,  }\item[{integer, intent(in)}]{j,  }\item[{character(len=$\ast$), intent(in)}]{mesg }\end{DoxyParamCaption})}



Write out values of the fluxes arrays at the i,j location. This is a debugging tool. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em g} & Grid type\\
\hline
\mbox{\tt in}  & {\em mesg} & Message\\
\hline
\mbox{\tt in}  & {\em i} & i-\/index\\
\hline
\mbox{\tt in}  & {\em j} & j-\/index \\
\hline
\end{DoxyParams}


Definition at line 1173 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
1173   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
1174   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{      !< Grid type}
1175   \textcolor{keywordtype}{character(len=*)},      \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Message}
1176   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: i\textcolor{comment}{      !< i-index}
1177   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: j\textcolor{comment}{      !< j-index}
1178 
1179   \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(2a)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, forcing\_SinglePointPrint: Called from '},mesg
1180   \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(a,2es15.3)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, forcing\_SinglePointPrint: lon,lat = '},g%geoLonT(i,j),g%geoLatT(
      i,j)
1181   \textcolor{keyword}{call }locmsg(fluxes%ustar,\textcolor{stringliteral}{'ustar'})
1182   \textcolor{keyword}{call }locmsg(fluxes%buoy,\textcolor{stringliteral}{'buoy'})
1183   \textcolor{keyword}{call }locmsg(fluxes%sw,\textcolor{stringliteral}{'sw'})
1184   \textcolor{keyword}{call }locmsg(fluxes%sw\_vis\_dir,\textcolor{stringliteral}{'sw\_vis\_dir'})
1185   \textcolor{keyword}{call }locmsg(fluxes%sw\_vis\_dif,\textcolor{stringliteral}{'sw\_vis\_dif'})
1186   \textcolor{keyword}{call }locmsg(fluxes%sw\_nir\_dir,\textcolor{stringliteral}{'sw\_nir\_dir'})
1187   \textcolor{keyword}{call }locmsg(fluxes%sw\_nir\_dif,\textcolor{stringliteral}{'sw\_nir\_dif'})
1188   \textcolor{keyword}{call }locmsg(fluxes%lw,\textcolor{stringliteral}{'lw'})
1189   \textcolor{keyword}{call }locmsg(fluxes%latent,\textcolor{stringliteral}{'latent'})
1190   \textcolor{keyword}{call }locmsg(fluxes%latent\_evap\_diag,\textcolor{stringliteral}{'latent\_evap\_diag'})
1191   \textcolor{keyword}{call }locmsg(fluxes%latent\_fprec\_diag,\textcolor{stringliteral}{'latent\_fprec\_diag'})
1192   \textcolor{keyword}{call }locmsg(fluxes%latent\_frunoff\_diag,\textcolor{stringliteral}{'latent\_frunoff\_diag'})
1193   \textcolor{keyword}{call }locmsg(fluxes%sens,\textcolor{stringliteral}{'sens'})
1194   \textcolor{keyword}{call }locmsg(fluxes%evap,\textcolor{stringliteral}{'evap'})
1195   \textcolor{keyword}{call }locmsg(fluxes%lprec,\textcolor{stringliteral}{'lprec'})
1196   \textcolor{keyword}{call }locmsg(fluxes%fprec,\textcolor{stringliteral}{'fprec'})
1197   \textcolor{keyword}{call }locmsg(fluxes%vprec,\textcolor{stringliteral}{'vprec'})
1198   \textcolor{keyword}{call }locmsg(fluxes%seaice\_melt,\textcolor{stringliteral}{'seaice\_melt'})
1199   \textcolor{keyword}{call }locmsg(fluxes%seaice\_melt\_heat,\textcolor{stringliteral}{'seaice\_melt\_heat'})
1200   \textcolor{keyword}{call }locmsg(fluxes%p\_surf,\textcolor{stringliteral}{'p\_surf'})
1201   \textcolor{keyword}{call }locmsg(fluxes%salt\_flux,\textcolor{stringliteral}{'salt\_flux'})
1202   \textcolor{keyword}{call }locmsg(fluxes%TKE\_tidal,\textcolor{stringliteral}{'TKE\_tidal'})
1203   \textcolor{keyword}{call }locmsg(fluxes%ustar\_tidal,\textcolor{stringliteral}{'ustar\_tidal'})
1204   \textcolor{keyword}{call }locmsg(fluxes%lrunoff,\textcolor{stringliteral}{'lrunoff'})
1205   \textcolor{keyword}{call }locmsg(fluxes%frunoff,\textcolor{stringliteral}{'frunoff'})
1206   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_lrunoff,\textcolor{stringliteral}{'heat\_content\_lrunoff'})
1207   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_frunoff,\textcolor{stringliteral}{'heat\_content\_frunoff'})
1208   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_lprec,\textcolor{stringliteral}{'heat\_content\_lprec'})
1209   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_fprec,\textcolor{stringliteral}{'heat\_content\_fprec'})
1210   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_icemelt,\textcolor{stringliteral}{'heat\_content\_icemelt'})
1211   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_vprec,\textcolor{stringliteral}{'heat\_content\_vprec'})
1212   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_cond,\textcolor{stringliteral}{'heat\_content\_cond'})
1213   \textcolor{keyword}{call }locmsg(fluxes%heat\_content\_cond,\textcolor{stringliteral}{'heat\_content\_massout'})
1214 
1215   \textcolor{keyword}{contains}\textcolor{comment}{}
1216 \textcolor{comment}{  !> Format and write a message depending on associated state of array}
1217 \textcolor{keyword}{  subroutine }locmsg(array,aname)
1218     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: array\textcolor{comment}{ !< Array to write element from}
1219     \textcolor{keywordtype}{character(len=*)}              :: aname\textcolor{comment}{ !< Name of array}
1220 
1221     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(array)) \textcolor{keywordflow}{then}
1222       \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(3a,es15.3)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, forcing\_SinglePointPrint: '},trim(aname),\textcolor{stringliteral}{' = '},array(i,j)
1223     \textcolor{keywordflow}{else}
1224       \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(4a)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, forcing\_SinglePointPrint: '},trim(aname),\textcolor{stringliteral}{' is not associated.'}
1225 \textcolor{keywordflow}{    endif}
1226 \textcolor{keyword}{  end subroutine }locmsg
1227 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a237dc2330bf133bf3365a924d26b0b37}\label{namespacemom__forcing__type_a237dc2330bf133bf3365a924d26b0b37}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!get\+\_\+forcing\+\_\+groups@{get\+\_\+forcing\+\_\+groups}}
\index{get\+\_\+forcing\+\_\+groups@{get\+\_\+forcing\+\_\+groups}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{get\+\_\+forcing\+\_\+groups()}{get\_forcing\_groups()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::get\+\_\+forcing\+\_\+groups (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes,  }\item[{logical, intent(out)}]{water,  }\item[{logical, intent(out)}]{heat,  }\item[{logical, intent(out)}]{ustar,  }\item[{logical, intent(out)}]{press,  }\item[{logical, intent(out)}]{shelf,  }\item[{logical, intent(out)}]{iceberg,  }\item[{logical, intent(out)}]{salt,  }\item[{logical, intent(out)}]{heat\+\_\+added,  }\item[{logical, intent(out)}]{buoy }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Return flags indicating which groups of forcings are allocated. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes} & Reference flux fields\\
\hline
\mbox{\tt out}  & {\em water} & True if fluxes contains water-\/based fluxes\\
\hline
\mbox{\tt out}  & {\em heat} & True if fluxes contains heat-\/based fluxes\\
\hline
\mbox{\tt out}  & {\em ustar} & True if fluxes contains ustar fluxes\\
\hline
\mbox{\tt out}  & {\em press} & True if fluxes contains surface pressure\\
\hline
\mbox{\tt out}  & {\em shelf} & True if fluxes contains ice shelf fields\\
\hline
\mbox{\tt out}  & {\em iceberg} & True if fluxes contains iceberg fluxes\\
\hline
\mbox{\tt out}  & {\em salt} & True if fluxes contains salt flux\\
\hline
\mbox{\tt out}  & {\em heat\+\_\+added} & True if fluxes contains explicit heat\\
\hline
\mbox{\tt out}  & {\em buoy} & True if fluxes contains buoyancy fluxes \\
\hline
\end{DoxyParams}


Definition at line 3046 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3046   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{  !< Reference flux fields}
3047   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: water\textcolor{comment}{   !< True if fluxes contains water-based fluxes}
3048   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: heat\textcolor{comment}{    !< True if fluxes contains heat-based fluxes}
3049   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: ustar\textcolor{comment}{   !< True if fluxes contains ustar fluxes}
3050   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: press\textcolor{comment}{   !< True if fluxes contains surface pressure}
3051   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: shelf\textcolor{comment}{   !< True if fluxes contains ice shelf fields}
3052   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: iceberg\textcolor{comment}{ !< True if fluxes contains iceberg fluxes}
3053   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: salt\textcolor{comment}{    !< True if fluxes contains salt flux}
3054   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: heat\_added\textcolor{comment}{ !< True if fluxes contains explicit heat}
3055   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: buoy\textcolor{comment}{    !< True if fluxes contains buoyancy fluxes}
3056 
3057   \textcolor{comment}{! NOTE: heat, salt, heat\_added, and buoy would typically depend on each other}
3058   \textcolor{comment}{!   to some degree.  But since this would be enforced at the driver level,}
3059   \textcolor{comment}{!   we handle them here as independent flags.}
3060 
3061   ustar = \textcolor{keyword}{associated}(fluxes%ustar) &
3062       .and. \textcolor{keyword}{associated}(fluxes%ustar\_gustless)
3063   \textcolor{comment}{! TODO: Check for all associated fields, but for now just check one as a marker}
3064   water = \textcolor{keyword}{associated}(fluxes%evap)
3065   heat = \textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat)
3066   salt = \textcolor{keyword}{associated}(fluxes%salt\_flux)
3067   press = \textcolor{keyword}{associated}(fluxes%p\_surf)
3068   shelf = \textcolor{keyword}{associated}(fluxes%frac\_shelf\_h)
3069   iceberg = \textcolor{keyword}{associated}(fluxes%ustar\_berg)
3070   heat\_added = \textcolor{keyword}{associated}(fluxes%heat\_added)
3071   buoy = \textcolor{keyword}{associated}(fluxes%buoy)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a2db9d1c071a26c092f662bd30afb2039}\label{namespacemom__forcing__type_a2db9d1c071a26c092f662bd30afb2039}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!get\+\_\+mech\+\_\+forcing\+\_\+groups@{get\+\_\+mech\+\_\+forcing\+\_\+groups}}
\index{get\+\_\+mech\+\_\+forcing\+\_\+groups@{get\+\_\+mech\+\_\+forcing\+\_\+groups}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{get\+\_\+mech\+\_\+forcing\+\_\+groups()}{get\_mech\_forcing\_groups()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::get\+\_\+mech\+\_\+forcing\+\_\+groups (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces,  }\item[{logical, intent(out)}]{stress,  }\item[{logical, intent(out)}]{ustar,  }\item[{logical, intent(out)}]{shelf,  }\item[{logical, intent(out)}]{press,  }\item[{logical, intent(out)}]{iceberg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Return flags indicating which groups of mechanical forcings are allocated. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces} & Reference forcing fields\\
\hline
\mbox{\tt out}  & {\em stress} & True if forces contains wind stress fields\\
\hline
\mbox{\tt out}  & {\em ustar} & True if forces contains ustar field\\
\hline
\mbox{\tt out}  & {\em shelf} & True if forces contains ice shelf fields\\
\hline
\mbox{\tt out}  & {\em press} & True if forces contains pressure fields\\
\hline
\mbox{\tt out}  & {\em iceberg} & True if forces contains iceberg fields \\
\hline
\end{DoxyParams}


Definition at line 3077 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3077   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(in)} :: forces\textcolor{comment}{  !< Reference forcing fields}
3078   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: stress\textcolor{comment}{  !< True if forces contains wind stress fields}
3079   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: ustar\textcolor{comment}{   !< True if forces contains ustar field}
3080   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: shelf\textcolor{comment}{   !< True if forces contains ice shelf fields}
3081   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: press\textcolor{comment}{   !< True if forces contains pressure fields}
3082   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: iceberg\textcolor{comment}{ !< True if forces contains iceberg fields}
3083 
3084   stress = \textcolor{keyword}{associated}(forces%taux) &
3085       .and. \textcolor{keyword}{associated}(forces%tauy)
3086   ustar = \textcolor{keyword}{associated}(forces%ustar)
3087   shelf = \textcolor{keyword}{associated}(forces%rigidity\_ice\_u) &
3088       .and. \textcolor{keyword}{associated}(forces%rigidity\_ice\_v) &
3089       .and. \textcolor{keyword}{associated}(forces%frac\_shelf\_u) &
3090       .and. \textcolor{keyword}{associated}(forces%frac\_shelf\_v)
3091   press = \textcolor{keyword}{associated}(forces%p\_surf) &
3092       .and. \textcolor{keyword}{associated}(forces%p\_surf\_full) &
3093       .and. \textcolor{keyword}{associated}(forces%net\_mass\_src)
3094   iceberg = \textcolor{keyword}{associated}(forces%area\_berg) &
3095       .and. \textcolor{keyword}{associated}(forces%mass\_berg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a67f6972e0e0dd6c0b6b4bbea9ff6b5ef}\label{namespacemom__forcing__type_a67f6972e0e0dd6c0b6b4bbea9ff6b5ef}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!get\+\_\+net\+\_\+mass\+\_\+forcing@{get\+\_\+net\+\_\+mass\+\_\+forcing}}
\index{get\+\_\+net\+\_\+mass\+\_\+forcing@{get\+\_\+net\+\_\+mass\+\_\+forcing}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{get\+\_\+net\+\_\+mass\+\_\+forcing()}{get\_net\_mass\_forcing()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::get\+\_\+net\+\_\+mass\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(out)}]{net\+\_\+mass\+\_\+src }\end{DoxyParamCaption})}



This subroutine calculates determines the net mass source to the ocean from a (thermodynamic) forcing type and stores it in a provided array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em g} & The ocean grid type\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt out}  & {\em net\+\_\+mass\+\_\+src} & The net mass flux of water into the ocean \mbox{[}kg m-\/2 s-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 2159 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2159   \textcolor{keywordtype}{type}(forcing),                    \textcolor{keywordtype}{intent(in)}  :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing
       fields}
2160   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{      !< The ocean grid type}
2161   \textcolor{keywordtype}{type}(unit\_scale\_type),            \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{     !< A dimensional unit scaling type}
2162   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)} :: net\_mass\_src\textcolor{comment}{ !< The net mass flux of water into the
       ocean}
2163 \textcolor{comment}{                                                          !! [kg m-2 s-1].}
2164 
2165   \textcolor{keywordtype}{real} :: RZ\_T\_conversion \textcolor{comment}{! A combination of scaling factors for mass fluxes [kg T m-2 s-1 R-1 Z-1 ~> 1]}
2166   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
2167   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
2168 
2169   rz\_t\_conversion = us%RZ\_T\_to\_kg\_m2s
2170 
2171   net\_mass\_src(:,:) = 0.0
2172   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2173     net\_mass\_src(i,j) = net\_mass\_src(i,j) + rz\_t\_conversion*fluxes%lprec(i,j)
2174 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
2175   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%fprec)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2176     net\_mass\_src(i,j) = net\_mass\_src(i,j) + rz\_t\_conversion*fluxes%fprec(i,j)
2177 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
2178   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%vprec)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2179     net\_mass\_src(i,j) = net\_mass\_src(i,j) + rz\_t\_conversion*fluxes%vprec(i,j)
2180 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
2181   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lrunoff)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2182     net\_mass\_src(i,j) = net\_mass\_src(i,j) + rz\_t\_conversion*fluxes%lrunoff(i,j)
2183 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
2184   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frunoff)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2185     net\_mass\_src(i,j) = net\_mass\_src(i,j) + rz\_t\_conversion*fluxes%frunoff(i,j)
2186 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
2187   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2188     net\_mass\_src(i,j) = net\_mass\_src(i,j) + rz\_t\_conversion*fluxes%evap(i,j)
2189 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
2190   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2191     net\_mass\_src(i,j) = net\_mass\_src(i,j) + rz\_t\_conversion*fluxes%seaice\_melt(i,j)
2192 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
2193 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a014d07725581af8ede287ea2a2322259}\label{namespacemom__forcing__type_a014d07725581af8ede287ea2a2322259}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!mech\+\_\+forcing\+\_\+diags@{mech\+\_\+forcing\+\_\+diags}}
\index{mech\+\_\+forcing\+\_\+diags@{mech\+\_\+forcing\+\_\+diags}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{mech\+\_\+forcing\+\_\+diags()}{mech\_forcing\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::mech\+\_\+forcing\+\_\+diags (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in), target}]{forces\+\_\+in,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(time\+\_\+type), intent(in)}]{time\+\_\+end,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing__diags}{forcing\+\_\+diags}}), intent(inout)}]{handles }\end{DoxyParamCaption})}



Offer mechanical forcing fields for diagnostics for those fields registered as part of register\+\_\+forcing\+\_\+type\+\_\+diags. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces\+\_\+in} & mechanical forcing input fields\\
\hline
\mbox{\tt in}  & {\em dt} & time step for the forcing \mbox{[}s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em g} & grid type\\
\hline
\mbox{\tt in}  & {\em time\+\_\+end} & The end time of the diagnostic interval.\\
\hline
\mbox{\tt in,out}  & {\em diag} & diagnostic type\\
\hline
\mbox{\tt in,out}  & {\em handles} & diagnostic id for diag\+\_\+manager \\
\hline
\end{DoxyParams}


Definition at line 2217 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2217   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: forces\_in\textcolor{comment}{ !< mechanical forcing input fields}
2218   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{       !< time step for the forcing [s]}
2219   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{        !< grid type}
2220   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: time\_end\textcolor{comment}{ !< The end time of the diagnostic interval.}
2221   \textcolor{keywordtype}{type}(diag\_ctrl),       \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{     !< diagnostic type}
2222   \textcolor{keywordtype}{type}(forcing\_diags),   \textcolor{keywordtype}{intent(inout)} :: handles\textcolor{comment}{  !< diagnostic id for diag\_manager}
2223 
2224   \textcolor{keywordtype}{integer} :: i,j,is,ie,js,je
2225 
2226   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{pointer} :: forces
2227   \textcolor{keywordtype}{integer} :: turns
2228 
2229   \textcolor{keyword}{call }cpu\_clock\_begin(handles%id\_clock\_forcing)
2230 
2231   \textcolor{comment}{! NOTE: post\_data expects data to be on the rotated index map, so any}
2232   \textcolor{comment}{!   rotations must be applied before saving the output.}
2233   turns = diag%G%HI%turns
2234   \textcolor{keywordflow}{if} (turns /= 0) \textcolor{keywordflow}{then}
2235     \textcolor{keyword}{allocate}(forces)
2236     \textcolor{keyword}{call }allocate\_mech\_forcing(forces\_in, diag%G, forces)
2237     \textcolor{keyword}{call }rotate\_mech\_forcing(forces\_in, turns, forces)
2238   \textcolor{keywordflow}{else}
2239     forces => forces\_in
2240 \textcolor{keywordflow}{  endif}
2241 
2242   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
2243   \textcolor{keyword}{call }enable\_averaging(dt, time\_end, diag)
2244   \textcolor{comment}{! if (query\_averaging\_enabled(diag)) then}
2245 
2246     \textcolor{keywordflow}{if} ((handles%id\_taux > 0) .and. \textcolor{keyword}{associated}(forces%taux)) &
2247       \textcolor{keyword}{call }post\_data(handles%id\_taux, forces%taux, diag)
2248 
2249     \textcolor{keywordflow}{if} ((handles%id\_tauy > 0) .and. \textcolor{keyword}{associated}(forces%tauy)) &
2250       \textcolor{keyword}{call }post\_data(handles%id\_tauy, forces%tauy, diag)
2251 
2252     \textcolor{keywordflow}{if} ((handles%id\_mass\_berg > 0) .and. \textcolor{keyword}{associated}(forces%mass\_berg)) &
2253       \textcolor{keyword}{call }post\_data(handles%id\_mass\_berg, forces%mass\_berg, diag)
2254 
2255     \textcolor{keywordflow}{if} ((handles%id\_area\_berg > 0) .and. \textcolor{keyword}{associated}(forces%area\_berg)) &
2256       \textcolor{keyword}{call }post\_data(handles%id\_area\_berg, forces%area\_berg, diag)
2257 
2258   \textcolor{comment}{! endif}
2259 
2260   \textcolor{keyword}{call }disable\_averaging(diag)
2261 
2262   \textcolor{keywordflow}{if} (turns /= 0) \textcolor{keywordflow}{then}
2263     \textcolor{keyword}{call }deallocate\_mech\_forcing(forces)
2264     \textcolor{keyword}{deallocate}(forces)
2265 \textcolor{keywordflow}{  endif}
2266 
2267   \textcolor{keyword}{call }cpu\_clock\_end(handles%id\_clock\_forcing)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a2e3834f8d25c92142d450de74fa68f91}\label{namespacemom__forcing__type_a2e3834f8d25c92142d450de74fa68f91}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!mech\+\_\+forcing\+\_\+singlepointprint@{mech\+\_\+forcing\+\_\+singlepointprint}}
\index{mech\+\_\+forcing\+\_\+singlepointprint@{mech\+\_\+forcing\+\_\+singlepointprint}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{mech\+\_\+forcing\+\_\+singlepointprint()}{mech\_forcing\_singlepointprint()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::mech\+\_\+forcing\+\_\+singlepointprint (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{integer, intent(in)}]{i,  }\item[{integer, intent(in)}]{j,  }\item[{character(len=$\ast$), intent(in)}]{mesg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write out values of the mechanical forcing arrays at the i,j location. This is a debugging tool. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em g} & Grid type\\
\hline
\mbox{\tt in}  & {\em mesg} & Message\\
\hline
\mbox{\tt in}  & {\em i} & i-\/index\\
\hline
\mbox{\tt in}  & {\em j} & j-\/index \\
\hline
\end{DoxyParams}


Definition at line 1145 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
1145   \textcolor{keywordtype}{type}(mech\_forcing),    \textcolor{keywordtype}{intent(in)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
1146   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{      !< Grid type}
1147   \textcolor{keywordtype}{character(len=*)},      \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Message}
1148   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: i\textcolor{comment}{      !< i-index}
1149   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: j\textcolor{comment}{      !< j-index}
1150 
1151   \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(2a)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, forcing\_SinglePointPrint: Called from '},mesg
1152   \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(a,2es15.3)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, forcing\_SinglePointPrint: lon,lat = '},g%geoLonT(i,j),g%geoLatT(
      i,j)
1153   \textcolor{keyword}{call }locmsg(forces%taux,\textcolor{stringliteral}{'taux'})
1154   \textcolor{keyword}{call }locmsg(forces%tauy,\textcolor{stringliteral}{'tauy'})
1155 
1156   \textcolor{keyword}{contains}\textcolor{comment}{}
1157 \textcolor{comment}{  !> Format and write a message depending on associated state of array}
1158 \textcolor{keyword}{  subroutine }locmsg(array,aname)
1159     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: array\textcolor{comment}{ !< Array to write element from}
1160     \textcolor{keywordtype}{character(len=*)}              :: aname\textcolor{comment}{ !< Name of array}
1161 
1162     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(array)) \textcolor{keywordflow}{then}
1163       \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(3a,es15.3)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, mech\_forcing\_SinglePointPrint: '},trim(aname),\textcolor{stringliteral}{' = '},array(i,
      j)
1164     \textcolor{keywordflow}{else}
1165       \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(4a)'}) \textcolor{stringliteral}{'MOM\_forcing\_type, mech\_forcing\_SinglePointPrint: '},trim(aname),\textcolor{stringliteral}{' is not associated.'}
1166 \textcolor{keywordflow}{    endif}
1167 \textcolor{keyword}{  end subroutine }locmsg
1168 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a1c4ecd1a779a55e9304b0997088a4815}\label{namespacemom__forcing__type_a1c4ecd1a779a55e9304b0997088a4815}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!mom\+\_\+forcing\+\_\+chksum@{mom\+\_\+forcing\+\_\+chksum}}
\index{mom\+\_\+forcing\+\_\+chksum@{mom\+\_\+forcing\+\_\+chksum}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{mom\+\_\+forcing\+\_\+chksum()}{mom\_forcing\_chksum()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::mom\+\_\+forcing\+\_\+chksum (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{integer, intent(in), optional}]{haloshift }\end{DoxyParamCaption})}



Write out chksums for thermodynamic fluxes. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & message\\
\hline
\mbox{\tt in}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em g} & grid type\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em haloshift} & shift in halo \\
\hline
\end{DoxyParams}


Definition at line 1022 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
1022   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{      !< message}
1023   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)} :: fluxes\textcolor{comment}{    !< A structure containing thermodynamic forcing fields}
1024   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{         !< grid type}
1025   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{        !< A dimensional unit scaling type}
1026   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},       \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< shift in halo}
1027 
1028   \textcolor{keywordtype}{integer} :: is, ie, js, je, nz, hshift
1029   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
1030 
1031   hshift = 1 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1032 
1033   \textcolor{comment}{! Note that for the chksum calls to be useful for reproducing across PE}
1034   \textcolor{comment}{! counts, there must be no redundant points, so all variables use is..ie}
1035   \textcolor{comment}{! and js...je as their extent.}
1036   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar)) &
1037     \textcolor{keyword}{call }hchksum(fluxes%ustar, mesg//\textcolor{stringliteral}{" fluxes%ustar"}, g%HI, haloshift=hshift, scale=us%Z\_to\_m*us%s\_to\_T)
1038   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%buoy)) &
1039     \textcolor{keyword}{call }hchksum(fluxes%buoy, mesg//\textcolor{stringliteral}{" fluxes%buoy "}, g%HI, haloshift=hshift, scale=us%L\_to\_m**2*us%s\_to\_T**
      3)
1040   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw)) &
1041     \textcolor{keyword}{call }hchksum(fluxes%sw, mesg//\textcolor{stringliteral}{" fluxes%sw"}, g%HI, haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1042   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_vis\_dir)) &
1043     \textcolor{keyword}{call }hchksum(fluxes%sw\_vis\_dir, mesg//\textcolor{stringliteral}{" fluxes%sw\_vis\_dir"}, g%HI, haloshift=hshift, scale=us
      %QRZ\_T\_to\_W\_m2)
1044   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_vis\_dif)) &
1045     \textcolor{keyword}{call }hchksum(fluxes%sw\_vis\_dif, mesg//\textcolor{stringliteral}{" fluxes%sw\_vis\_dif"}, g%HI, haloshift=hshift, scale=us
      %QRZ\_T\_to\_W\_m2)
1046   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_nir\_dir)) &
1047     \textcolor{keyword}{call }hchksum(fluxes%sw\_nir\_dir, mesg//\textcolor{stringliteral}{" fluxes%sw\_nir\_dir"}, g%HI, haloshift=hshift, scale=us
      %QRZ\_T\_to\_W\_m2)
1048   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sw\_nir\_dif)) &
1049     \textcolor{keyword}{call }hchksum(fluxes%sw\_nir\_dif, mesg//\textcolor{stringliteral}{" fluxes%sw\_nir\_dif"}, g%HI, haloshift=hshift, scale=us
      %QRZ\_T\_to\_W\_m2)
1050   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lw)) &
1051     \textcolor{keyword}{call }hchksum(fluxes%lw, mesg//\textcolor{stringliteral}{" fluxes%lw"}, g%HI, haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1052   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent)) &
1053     \textcolor{keyword}{call }hchksum(fluxes%latent, mesg//\textcolor{stringliteral}{" fluxes%latent"}, g%HI, haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1054   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent\_evap\_diag)) &
1055     \textcolor{keyword}{call }hchksum(fluxes%latent\_evap\_diag, mesg//\textcolor{stringliteral}{" fluxes%latent\_evap\_diag"}, g%HI, &
1056                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1057   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent\_fprec\_diag)) &
1058     \textcolor{keyword}{call }hchksum(fluxes%latent\_fprec\_diag, mesg//\textcolor{stringliteral}{" fluxes%latent\_fprec\_diag"}, g%HI, &
1059                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1060   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%latent\_frunoff\_diag)) &
1061     \textcolor{keyword}{call }hchksum(fluxes%latent\_frunoff\_diag, mesg//\textcolor{stringliteral}{" fluxes%latent\_frunoff\_diag"}, g%HI, &
1062                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1063   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%sens)) &
1064     \textcolor{keyword}{call }hchksum(fluxes%sens, mesg//\textcolor{stringliteral}{" fluxes%sens"}, g%HI, haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1065   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%evap)) &
1066     \textcolor{keyword}{call }hchksum(fluxes%evap, mesg//\textcolor{stringliteral}{" fluxes%evap"}, g%HI, haloshift=hshift, scale=us%RZ\_T\_to\_kg\_m2s)
1067   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lprec)) &
1068     \textcolor{keyword}{call }hchksum(fluxes%lprec, mesg//\textcolor{stringliteral}{" fluxes%lprec"}, g%HI, haloshift=hshift, scale=us%RZ\_T\_to\_kg\_m2s)
1069   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%fprec)) &
1070     \textcolor{keyword}{call }hchksum(fluxes%fprec, mesg//\textcolor{stringliteral}{" fluxes%fprec"}, g%HI, haloshift=hshift, scale=us%RZ\_T\_to\_kg\_m2s)
1071   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%vprec)) &
1072     \textcolor{keyword}{call }hchksum(fluxes%vprec, mesg//\textcolor{stringliteral}{" fluxes%vprec"}, g%HI, haloshift=hshift, scale=us%RZ\_T\_to\_kg\_m2s)
1073   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt)) &
1074     \textcolor{keyword}{call }hchksum(fluxes%seaice\_melt, mesg//\textcolor{stringliteral}{" fluxes%seaice\_melt"}, g%HI, haloshift=hshift, scale=us
      %RZ\_T\_to\_kg\_m2s)
1075   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%seaice\_melt\_heat)) &
1076     \textcolor{keyword}{call }hchksum(fluxes%seaice\_melt\_heat, mesg//\textcolor{stringliteral}{" fluxes%seaice\_melt\_heat"}, g%HI, &
1077                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1078   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf)) &
1079     \textcolor{keyword}{call }hchksum(fluxes%p\_surf, mesg//\textcolor{stringliteral}{" fluxes%p\_surf"}, g%HI, haloshift=hshift , scale=us%RL2\_T2\_to\_Pa)
1080   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%salt\_flux)) &
1081     \textcolor{keyword}{call }hchksum(fluxes%salt\_flux, mesg//\textcolor{stringliteral}{" fluxes%salt\_flux"}, g%HI, haloshift=hshift, scale=us
      %RZ\_T\_to\_kg\_m2s)
1082   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%TKE\_tidal)) &
1083     \textcolor{keyword}{call }hchksum(fluxes%TKE\_tidal, mesg//\textcolor{stringliteral}{" fluxes%TKE\_tidal"}, g%HI, haloshift=hshift, &
1084                  scale=us%RZ3\_T3\_to\_W\_m2)
1085   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar\_tidal)) &
1086     \textcolor{keyword}{call }hchksum(fluxes%ustar\_tidal, mesg//\textcolor{stringliteral}{" fluxes%ustar\_tidal"}, g%HI, haloshift=hshift, scale=us%Z\_to\_m*
      us%s\_to\_T)
1087   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%lrunoff)) &
1088     \textcolor{keyword}{call }hchksum(fluxes%lrunoff, mesg//\textcolor{stringliteral}{" fluxes%lrunoff"}, g%HI, haloshift=hshift, scale=us%RZ\_T\_to\_kg\_m2s)
1089   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frunoff)) &
1090     \textcolor{keyword}{call }hchksum(fluxes%frunoff, mesg//\textcolor{stringliteral}{" fluxes%frunoff"}, g%HI, haloshift=hshift, scale=us%RZ\_T\_to\_kg\_m2s)
1091   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lrunoff)) &
1092     \textcolor{keyword}{call }hchksum(fluxes%heat\_content\_lrunoff, mesg//\textcolor{stringliteral}{" fluxes%heat\_content\_lrunoff"}, g%HI, &
1093                  haloshift=hshift, scale=us%RZ\_T\_to\_kg\_m2s)
1094   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_frunoff)) &
1095     \textcolor{keyword}{call }hchksum(fluxes%heat\_content\_frunoff, mesg//\textcolor{stringliteral}{" fluxes%heat\_content\_frunoff"}, g%HI, &
1096                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1097   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_lprec)) &
1098     \textcolor{keyword}{call }hchksum(fluxes%heat\_content\_lprec, mesg//\textcolor{stringliteral}{" fluxes%heat\_content\_lprec"}, g%HI,  &
1099                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1100   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_fprec)) &
1101     \textcolor{keyword}{call }hchksum(fluxes%heat\_content\_fprec, mesg//\textcolor{stringliteral}{" fluxes%heat\_content\_fprec"}, g%HI, &
1102                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1103   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_icemelt)) &
1104     \textcolor{keyword}{call }hchksum(fluxes%heat\_content\_icemelt, mesg//\textcolor{stringliteral}{" fluxes%heat\_content\_icemelt"}, g%HI, &
1105                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1106   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_cond)) &
1107     \textcolor{keyword}{call }hchksum(fluxes%heat\_content\_cond, mesg//\textcolor{stringliteral}{" fluxes%heat\_content\_cond"}, g%HI, &
1108                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
1109   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%heat\_content\_massout)) &
1110     \textcolor{keyword}{call }hchksum(fluxes%heat\_content\_massout, mesg//\textcolor{stringliteral}{" fluxes%heat\_content\_massout"}, g%HI, &
1111                  haloshift=hshift, scale=us%QRZ\_T\_to\_W\_m2)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_afe942ca75b30c226fdfcdedcecad920f}\label{namespacemom__forcing__type_afe942ca75b30c226fdfcdedcecad920f}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!mom\+\_\+mech\+\_\+forcing\+\_\+chksum@{mom\+\_\+mech\+\_\+forcing\+\_\+chksum}}
\index{mom\+\_\+mech\+\_\+forcing\+\_\+chksum@{mom\+\_\+mech\+\_\+forcing\+\_\+chksum}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{mom\+\_\+mech\+\_\+forcing\+\_\+chksum()}{mom\_mech\_forcing\_chksum()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::mom\+\_\+mech\+\_\+forcing\+\_\+chksum (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{integer, intent(in), optional}]{haloshift }\end{DoxyParamCaption})}



Write out chksums for the driving mechanical forces. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & message\\
\hline
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em g} & grid type\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em haloshift} & shift in halo \\
\hline
\end{DoxyParams}


Definition at line 1116 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
1116   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{      !< message}
1117   \textcolor{keywordtype}{type}(mech\_forcing),      \textcolor{keywordtype}{intent(in)} :: forces\textcolor{comment}{    !< A structure with the driving mechanical forces}
1118   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{         !< grid type}
1119   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{        !< A dimensional unit scaling type}
1120   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},       \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< shift in halo}
1121 
1122   \textcolor{keywordtype}{integer} :: is, ie, js, je, nz, hshift
1123   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
1124 
1125   hshift=1; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift=haloshift
1126 
1127   \textcolor{comment}{! Note that for the chksum calls to be useful for reproducing across PE}
1128   \textcolor{comment}{! counts, there must be no redundant points, so all variables use is..ie}
1129   \textcolor{comment}{! and js...je as their extent.}
1130   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%taux) .and. \textcolor{keyword}{associated}(forces%tauy)) &
1131     \textcolor{keyword}{call }uvchksum(mesg//\textcolor{stringliteral}{" forces%tau[xy]"}, forces%taux, forces%tauy, g%HI, &
1132                   haloshift=hshift, symmetric=.true., scale=us%RZ\_T\_to\_kg\_m2s*us%L\_T\_to\_m\_s)
1133   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf)) &
1134     \textcolor{keyword}{call }hchksum(forces%p\_surf, mesg//\textcolor{stringliteral}{" forces%p\_surf"}, g%HI, haloshift=hshift, scale=us%RL2\_T2\_to\_Pa)
1135   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) &
1136     \textcolor{keyword}{call }hchksum(forces%ustar, mesg//\textcolor{stringliteral}{" forces%ustar"}, g%HI, haloshift=hshift, scale=us%Z\_to\_m*us%s\_to\_T)
1137   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%rigidity\_ice\_u) .and. \textcolor{keyword}{associated}(forces%rigidity\_ice\_v)) &
1138     \textcolor{keyword}{call }uvchksum(mesg//\textcolor{stringliteral}{" forces%rigidity\_ice\_[uv]"}, forces%rigidity\_ice\_u, forces%rigidity\_ice\_v, &
1139                   g%HI, haloshift=hshift, symmetric=.true., scale=us%L\_to\_m**3*us%L\_to\_Z*us%s\_to\_T)
1140 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_aa9a495456715378fe3dd5fb2bd21eec8}\label{namespacemom__forcing__type_aa9a495456715378fe3dd5fb2bd21eec8}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!myalloc@{myalloc}}
\index{myalloc@{myalloc}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{myalloc()}{myalloc()}}
{\footnotesize\ttfamily subroutine mom\+\_\+forcing\+\_\+type\+::myalloc (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:), pointer}]{array,  }\item[{integer, intent(in)}]{is,  }\item[{integer, intent(in)}]{ie,  }\item[{integer, intent(in)}]{js,  }\item[{integer, intent(in)}]{je,  }\item[{logical, intent(in), optional}]{flag }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Allocates and zeroes-\/out array. 


\begin{DoxyParams}[1]{Parameters}
 & {\em array} & Array to be allocated\\
\hline
\mbox{\tt in}  & {\em is} & Start i-\/index\\
\hline
\mbox{\tt in}  & {\em ie} & End i-\/index\\
\hline
\mbox{\tt in}  & {\em js} & Start j-\/index\\
\hline
\mbox{\tt in}  & {\em je} & End j-\/index\\
\hline
\mbox{\tt in}  & {\em flag} & Flag to indicate to allocate \\
\hline
\end{DoxyParams}


Definition at line 3101 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3101   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: array\textcolor{comment}{ !< Array to be allocated}
3102   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: is\textcolor{comment}{ !< Start i-index}
3103   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: ie\textcolor{comment}{ !< End i-index}
3104   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: js\textcolor{comment}{ !< Start j-index}
3105   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: je\textcolor{comment}{ !< End j-index}
3106   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: flag\textcolor{comment}{ !< Flag to indicate to allocate}
3107 
3108   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(flag)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (flag) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(array)) \textcolor{keywordflow}{then}
3109     \textcolor{keyword}{allocate}(array(is:ie,js:je)) ; array(is:ie,js:je) = 0.0
3110 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_ad4a8e0b876c8082f77352a25a56b86e9}\label{namespacemom__forcing__type_ad4a8e0b876c8082f77352a25a56b86e9}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!register\+\_\+forcing\+\_\+type\+\_\+diags@{register\+\_\+forcing\+\_\+type\+\_\+diags}}
\index{register\+\_\+forcing\+\_\+type\+\_\+diags@{register\+\_\+forcing\+\_\+type\+\_\+diags}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{register\+\_\+forcing\+\_\+type\+\_\+diags()}{register\_forcing\_type\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::register\+\_\+forcing\+\_\+type\+\_\+diags (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{logical, intent(in)}]{use\+\_\+temperature,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing__diags}{forcing\+\_\+diags}}), intent(inout)}]{handles,  }\item[{logical, intent(in), optional}]{use\+\_\+berg\+\_\+fluxes }\end{DoxyParamCaption})}



Register members of the forcing type for diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & time type\\
\hline
\mbox{\tt in,out}  & {\em diag} & diagnostic control type\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em use\+\_\+temperature} & True if T/S are in use\\
\hline
\mbox{\tt in,out}  & {\em handles} & handles for diagnostics\\
\hline
\mbox{\tt in}  & {\em use\+\_\+berg\+\_\+fluxes} & If true, allow iceberg flux diagnostics \\
\hline
\end{DoxyParams}


Definition at line 1233 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
1233   \textcolor{keywordtype}{type}(time\_type),     \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{            !< time type}
1234   \textcolor{keywordtype}{type}(diag\_ctrl),     \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{            !< diagnostic control type}
1235   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{              !< A dimensional unit scaling type}
1236   \textcolor{keywordtype}{logical},             \textcolor{keywordtype}{intent(in)}    :: use\_temperature\textcolor{comment}{ !< True if T/S are in use}
1237   \textcolor{keywordtype}{type}(forcing\_diags), \textcolor{keywordtype}{intent(inout)} :: handles\textcolor{comment}{         !< handles for diagnostics}
1238   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},   \textcolor{keywordtype}{intent(in)}    :: use\_berg\_fluxes\textcolor{comment}{ !< If true, allow iceberg flux diagnostics}
1239 
1240   \textcolor{comment}{! Clock for forcing diagnostics}
1241   handles%id\_clock\_forcing=cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean forcing diagnostics)'}, grain=clock\_routine)
1242 
1243 
1244   handles%id\_taux = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'taux'}, diag%axesCu1, time,  &
1245         \textcolor{stringliteral}{'Zonal surface stress from ocean interactions with atmos and ice'}, &
1246         \textcolor{stringliteral}{'Pa'}, conversion=us%RZ\_T\_to\_kg\_m2s*us%L\_T\_to\_m\_s, &
1247         standard\_name=\textcolor{stringliteral}{'surface\_downward\_x\_stress'}, cmor\_field\_name=\textcolor{stringliteral}{'tauuo'},         &
1248         cmor\_units=\textcolor{stringliteral}{'N m-2'}, cmor\_long\_name=\textcolor{stringliteral}{'Surface Downward X Stress'},             &
1249         cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_x\_stress'})
1250 
1251   handles%id\_tauy = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'tauy'}, diag%axesCv1, time,  &
1252         \textcolor{stringliteral}{'Meridional surface stress ocean interactions with atmos and ice'}, &
1253         \textcolor{stringliteral}{'Pa'},  conversion=us%RZ\_T\_to\_kg\_m2s*us%L\_T\_to\_m\_s, &
1254         standard\_name=\textcolor{stringliteral}{'surface\_downward\_y\_stress'}, cmor\_field\_name=\textcolor{stringliteral}{'tauvo'},        &
1255         cmor\_units=\textcolor{stringliteral}{'N m-2'}, cmor\_long\_name=\textcolor{stringliteral}{'Surface Downward Y Stress'},            &
1256         cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_y\_stress'})
1257 
1258   handles%id\_ustar = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ustar'}, diag%axesT1, time, &
1259       \textcolor{stringliteral}{'Surface friction velocity = [(gustiness + tau\_magnitude)/rho0]^(1/2)'}, &
1260       \textcolor{stringliteral}{'m s-1'}, conversion=us%Z\_to\_m*us%s\_to\_T)
1261 
1262   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(use\_berg\_fluxes)) \textcolor{keywordflow}{then}
1263     \textcolor{keywordflow}{if} (use\_berg\_fluxes) \textcolor{keywordflow}{then}
1264       handles%id\_ustar\_berg = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ustar\_berg'}, diag%axesT1, time, &
1265           \textcolor{stringliteral}{'Friction velocity below iceberg '}, \textcolor{stringliteral}{'m s-1'}, conversion=us%Z\_to\_m*us%s\_to\_T)
1266 
1267       handles%id\_area\_berg = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'area\_berg'}, diag%axesT1, time, &
1268           \textcolor{stringliteral}{'Area of grid cell covered by iceberg '}, \textcolor{stringliteral}{'m2 m-2'})
1269 
1270       handles%id\_mass\_berg = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'mass\_berg'}, diag%axesT1, time, &
1271           \textcolor{stringliteral}{'Mass of icebergs '}, \textcolor{stringliteral}{'kg m-2'}, conversion=us%RZ\_to\_kg\_m2)
1272 
1273       handles%id\_ustar\_ice\_cover = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ustar\_ice\_cover'}, diag%axesT1, time,
       &
1274           \textcolor{stringliteral}{'Friction velocity below iceberg and ice shelf together'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%Z\_to\_m*us%s\_to\_T
      )
1275 
1276       handles%id\_frac\_ice\_cover = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'frac\_ice\_cover'}, diag%axesT1, time, &
1277           \textcolor{stringliteral}{'Area of grid cell below iceberg and ice shelf together '}, \textcolor{stringliteral}{'m2 m-2'})
1278 \textcolor{keywordflow}{    endif}
1279 \textcolor{keywordflow}{  endif}
1280 
1281   handles%id\_psurf = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'p\_surf'}, diag%axesT1, time, &
1282         \textcolor{stringliteral}{'Pressure at ice-ocean or atmosphere-ocean interface'}, &
1283         \textcolor{stringliteral}{'Pa'}, conversion=us%RL2\_T2\_to\_Pa, cmor\_field\_name=\textcolor{stringliteral}{'pso'}, &
1284         cmor\_long\_name=\textcolor{stringliteral}{'Sea Water Pressure at Sea Water Surface'}, &
1285         cmor\_standard\_name=\textcolor{stringliteral}{'sea\_water\_pressure\_at\_sea\_water\_surface'})
1286 
1287   handles%id\_TKE\_tidal = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'TKE\_tidal'}, diag%axesT1, time, &
1288         \textcolor{stringliteral}{'Tidal source of BBL mixing'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%RZ3\_T3\_to\_W\_m2)
1289 
1290   \textcolor{keywordflow}{if} (.not. use\_temperature) \textcolor{keywordflow}{then}
1291     handles%id\_buoy = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'buoy'}, diag%axesT1, time, &
1292           \textcolor{stringliteral}{'Buoyancy forcing'}, \textcolor{stringliteral}{'m2 s-3'}, conversion=us%L\_to\_m**2*us%s\_to\_T**3)
1293     \textcolor{keywordflow}{return}
1294 \textcolor{keywordflow}{  endif}
1295 
1296 
1297   \textcolor{comment}{!===============================================================}
1298   \textcolor{comment}{! surface mass flux maps}
1299 
1300   handles%id\_prcme = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PRCmE'}, diag%axesT1, time,                  &
1301         \textcolor{stringliteral}{'Net surface water flux (precip+melt+lrunoff+ice calving-evap)'}, \textcolor{stringliteral}{'kg m-2 s-1'}, &
1302         standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water'}, cmor\_field\_name=\textcolor{stringliteral}{'wfo'},                            &
1303         cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water'},cmor\_long\_name=\textcolor{stringliteral}{'Water Flux Into Sea Water'})
1304         \textcolor{comment}{! This diagnostic is rescaled to MKS units when combined.}
1305 
1306   handles%id\_evap = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'evap'}, diag%axesT1, time, &
1307        \textcolor{stringliteral}{'Evaporation/condensation at ocean surface (evaporation is negative)'}, &
1308        \textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s, &
1309        standard\_name=\textcolor{stringliteral}{'water\_evaporation\_flux'}, cmor\_field\_name=\textcolor{stringliteral}{'evs'}, &
1310        cmor\_standard\_name=\textcolor{stringliteral}{'water\_evaporation\_flux'}, &
1311        cmor\_long\_name=\textcolor{stringliteral}{'Water Evaporation Flux Where Ice Free Ocean over Sea'})
1312 
1313   \textcolor{comment}{! smg: seaice\_melt field requires updates to the sea ice model}
1314   handles%id\_seaice\_melt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'seaice\_melt'},       &
1315      diag%axesT1, time, \textcolor{stringliteral}{'water flux to ocean from snow/sea ice melting(> 0) or formation(< 0)'}, &
1316      \textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s, &
1317       standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_due\_to\_sea\_ice\_thermodynamics'},     &
1318       cmor\_field\_name=\textcolor{stringliteral}{'fsitherm'},                                                  &
1319       cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_due\_to\_sea\_ice\_thermodynamics'},&
1320       cmor\_long\_name=\textcolor{stringliteral}{'water flux to ocean from sea ice melt(> 0) or form(< 0)'})
1321 
1322   handles%id\_precip = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'precip'}, diag%axesT1, time, &
1323         \textcolor{stringliteral}{'Liquid + frozen precipitation into ocean'}, \textcolor{stringliteral}{'kg m-2 s-1'})
1324         \textcolor{comment}{! This diagnostic is rescaled to MKS units when combined.}
1325 
1326   handles%id\_fprec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'fprec'}, diag%axesT1, time,     &
1327         \textcolor{stringliteral}{'Frozen precipitation into ocean'}, &
1328         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s,   &
1329         standard\_name=\textcolor{stringliteral}{'snowfall\_flux'}, cmor\_field\_name=\textcolor{stringliteral}{'prsn'},                          &
1330         cmor\_standard\_name=\textcolor{stringliteral}{'snowfall\_flux'}, cmor\_long\_name=\textcolor{stringliteral}{'Snowfall Flux where Ice Free Ocean over Sea'})
1331 
1332   handles%id\_lprec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'lprec'}, diag%axesT1, time,       &
1333         \textcolor{stringliteral}{'Liquid precipitation into ocean'}, &
1334         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s,                 &
1335         standard\_name=\textcolor{stringliteral}{'rainfall\_flux'},                                                    &
1336         cmor\_field\_name=\textcolor{stringliteral}{'prlq'}, cmor\_standard\_name=\textcolor{stringliteral}{'rainfall\_flux'},                       &
1337         cmor\_long\_name=\textcolor{stringliteral}{'Rainfall Flux where Ice Free Ocean over Sea'})
1338 
1339   handles%id\_vprec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vprec'}, diag%axesT1, time, &
1340         \textcolor{stringliteral}{'Virtual liquid precip into ocean due to SSS restoring'}, &
1341         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s)
1342 
1343   handles%id\_frunoff = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'frunoff'}, diag%axesT1, time,    &
1344         \textcolor{stringliteral}{'Frozen runoff (calving) and iceberg melt into ocean'}, &
1345         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s, &
1346         standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_from\_icebergs'},                           &
1347         cmor\_field\_name=\textcolor{stringliteral}{'ficeberg'},                                                        &
1348         cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_from\_icebergs'},                      &
1349         cmor\_long\_name=\textcolor{stringliteral}{'Water Flux into Seawater from Icebergs'})
1350 
1351   handles%id\_lrunoff = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'lrunoff'}, diag%axesT1, time, &
1352         \textcolor{stringliteral}{'Liquid runoff (rivers) into ocean'}, &
1353         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s, &
1354         standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_from\_rivers'}, cmor\_field\_name=\textcolor{stringliteral}{'friver'},      &
1355         cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_from\_rivers'},                           &
1356         cmor\_long\_name=\textcolor{stringliteral}{'Water Flux into Sea Water From Rivers'})
1357 
1358   handles%id\_net\_massout = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'net\_massout'}, diag%axesT1, time, &
1359         \textcolor{stringliteral}{'Net mass leaving the ocean due to evaporation, seaice formation'}, \textcolor{stringliteral}{'kg m-2 s-1'})
1360         \textcolor{comment}{! This diagnostic is rescaled to MKS units when combined.}
1361 
1362   handles%id\_net\_massin  = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'net\_massin'}, diag%axesT1, time, &
1363         \textcolor{stringliteral}{'Net mass entering ocean due to precip, runoff, ice melt'}, \textcolor{stringliteral}{'kg m-2 s-1'})
1364         \textcolor{comment}{! This diagnostic is rescaled to MKS units when combined.}
1365 
1366   handles%id\_massout\_flux = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'massout\_flux'}, diag%axesT1, time, &
1367         \textcolor{stringliteral}{'Net mass flux of freshwater out of the ocean (used in the boundary flux calculation)'}, &
1368          \textcolor{stringliteral}{'kg m-2'}, conversion=diag%GV%H\_to\_kg\_m2)
1369         \textcolor{comment}{! This diagnostic is calculated in MKS units.}
1370 
1371   handles%id\_massin\_flux  = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'massin\_flux'}, diag%axesT1, time, &
1372         \textcolor{stringliteral}{'Net mass flux of freshwater into the ocean (used in boundary flux calculation)'}, \textcolor{stringliteral}{'kg m-2'})
1373         \textcolor{comment}{! This diagnostic is calculated in MKS units.}
1374 
1375   \textcolor{comment}{!=========================================================================}
1376   \textcolor{comment}{! area integrated surface mass transport, all are rescaled to MKS units before area integration.}
1377 
1378   handles%id\_total\_prcme = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_PRCmE'}, time, diag,         &
1379       long\_name=\textcolor{stringliteral}{'Area integrated net surface water flux (precip+melt+liq runoff+ice calving-evap)'},&
1380       units=\textcolor{stringliteral}{'kg s-1'}, standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_area\_integrated'},                   &
1381       cmor\_field\_name=\textcolor{stringliteral}{'total\_wfo'},                                                                 &
1382       cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_area\_integrated'},                              &
1383       cmor\_long\_name=\textcolor{stringliteral}{'Water Transport Into Sea Water Area Integrated'})
1384 
1385   handles%id\_total\_evap = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_evap'}, time, diag,&
1386       long\_name=\textcolor{stringliteral}{'Area integrated evap/condense at ocean surface'},                       &
1387       units=\textcolor{stringliteral}{'kg s-1'}, standard\_name=\textcolor{stringliteral}{'water\_evaporation\_flux\_area\_integrated'},           &
1388       cmor\_field\_name=\textcolor{stringliteral}{'total\_evs'},                                                      &
1389       cmor\_standard\_name=\textcolor{stringliteral}{'water\_evaporation\_flux\_area\_integrated'},                      &
1390       cmor\_long\_name=\textcolor{stringliteral}{'Evaporation Where Ice Free Ocean over Sea Area Integrated'})
1391 
1392   \textcolor{comment}{! seaice\_melt field requires updates to the sea ice model}
1393   handles%id\_total\_seaice\_melt = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_icemelt'}, time, diag, &
1394       long\_name=\textcolor{stringliteral}{'Area integrated sea ice melt (>0) or form (<0)'}, units=\textcolor{stringliteral}{'kg s-1'},                      &
1395       standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_due\_to\_sea\_ice\_thermodynamics\_area\_integrated'},         &
1396       cmor\_field\_name=\textcolor{stringliteral}{'total\_fsitherm'},                                                                &
1397       cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_due\_to\_sea\_ice\_thermodynamics\_area\_integrated'},    &
1398       cmor\_long\_name=\textcolor{stringliteral}{'Water Melt/Form from Sea Ice Area Integrated'})
1399 
1400   handles%id\_total\_precip = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_precip'}, time, diag, &
1401       long\_name=\textcolor{stringliteral}{'Area integrated liquid+frozen precip into ocean'}, units=\textcolor{stringliteral}{'kg s-1'})
1402 
1403   handles%id\_total\_fprec = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_fprec'}, time, diag,&
1404       long\_name=\textcolor{stringliteral}{'Area integrated frozen precip into ocean'}, units=\textcolor{stringliteral}{'kg s-1'},               &
1405       standard\_name=\textcolor{stringliteral}{'snowfall\_flux\_area\_integrated'},                                      &
1406       cmor\_field\_name=\textcolor{stringliteral}{'total\_prsn'},                                                       &
1407       cmor\_standard\_name=\textcolor{stringliteral}{'snowfall\_flux\_area\_integrated'},                                 &
1408       cmor\_long\_name=\textcolor{stringliteral}{'Snowfall Flux where Ice Free Ocean over Sea Area Integrated'})
1409 
1410   handles%id\_total\_lprec = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_lprec'}, time, diag,&
1411       long\_name=\textcolor{stringliteral}{'Area integrated liquid precip into ocean'}, units=\textcolor{stringliteral}{'kg s-1'},               &
1412       standard\_name=\textcolor{stringliteral}{'rainfall\_flux\_area\_integrated'},                                      &
1413       cmor\_field\_name=\textcolor{stringliteral}{'total\_pr'},                                                         &
1414       cmor\_standard\_name=\textcolor{stringliteral}{'rainfall\_flux\_area\_integrated'},                                 &
1415       cmor\_long\_name=\textcolor{stringliteral}{'Rainfall Flux where Ice Free Ocean over Sea Area Integrated'})
1416 
1417   handles%id\_total\_vprec = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_vprec'}, time, diag, &
1418       long\_name=\textcolor{stringliteral}{'Area integrated virtual liquid precip due to SSS restoring'}, units=\textcolor{stringliteral}{'kg s-1'})
1419 
1420   handles%id\_total\_frunoff = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_frunoff'}, time, diag,    &
1421       long\_name=\textcolor{stringliteral}{'Area integrated frozen runoff (calving) & iceberg melt into ocean'}, units=\textcolor{stringliteral}{'kg s-1'},&
1422       cmor\_field\_name=\textcolor{stringliteral}{'total\_ficeberg'},                                                           &
1423       cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_from\_icebergs\_area\_integrated'},               &
1424       cmor\_long\_name=\textcolor{stringliteral}{'Water Flux into Seawater from Icebergs Area Integrated'})
1425 
1426   handles%id\_total\_lrunoff = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_lrunoff'}, time, diag,&
1427       long\_name=\textcolor{stringliteral}{'Area integrated liquid runoff into ocean'}, units=\textcolor{stringliteral}{'kg s-1'},                   &
1428       cmor\_field\_name=\textcolor{stringliteral}{'total\_friver'},                                                         &
1429       cmor\_standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_from\_rivers\_area\_integrated'},             &
1430       cmor\_long\_name=\textcolor{stringliteral}{'Water Flux into Sea Water From Rivers Area Integrated'})
1431 
1432   handles%id\_total\_net\_massout = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_net\_massout'}, time, diag, &
1433       long\_name=\textcolor{stringliteral}{'Area integrated mass leaving ocean due to evap and seaice form'}, units=\textcolor{stringliteral}{'kg s-1'})
1434 
1435   handles%id\_total\_net\_massin = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_net\_massin'}, time, diag, &
1436       long\_name=\textcolor{stringliteral}{'Area integrated mass entering ocean due to predip, runoff, ice melt'}, units=\textcolor{stringliteral}{'kg s-1'})
1437 
1438   \textcolor{comment}{!=========================================================================}
1439   \textcolor{comment}{! area averaged surface mass transport}
1440 
1441   handles%id\_prcme\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'PRCmE\_ga'}, time, diag,             &
1442       long\_name=\textcolor{stringliteral}{'Area averaged net surface water flux (precip+melt+liq runoff+ice calving-evap)'},&
1443       units=\textcolor{stringliteral}{'kg m-2 s-1'}, standard\_name=\textcolor{stringliteral}{'water\_flux\_into\_sea\_water\_area\_averaged'},               &
1444       cmor\_field\_name=\textcolor{stringliteral}{'ave\_wfo'},                                                                 &
1445       cmor\_standard\_name=\textcolor{stringliteral}{'rainfall\_flux\_area\_averaged'},                                          &
1446       cmor\_long\_name=\textcolor{stringliteral}{'Water Transport Into Sea Water Area Averaged'})
1447 
1448   handles%id\_evap\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'evap\_ga'}, time, diag,&
1449       long\_name=\textcolor{stringliteral}{'Area averaged evap/condense at ocean surface'},                   &
1450       units=\textcolor{stringliteral}{'kg m-2 s-1'}, standard\_name=\textcolor{stringliteral}{'water\_evaporation\_flux\_area\_averaged'},   &
1451       cmor\_field\_name=\textcolor{stringliteral}{'ave\_evs'},                                                  &
1452       cmor\_standard\_name=\textcolor{stringliteral}{'water\_evaporation\_flux\_area\_averaged'},                  &
1453       cmor\_long\_name=\textcolor{stringliteral}{'Evaporation Where Ice Free Ocean over Sea Area Averaged'})
1454 
1455  handles%id\_lprec\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'lprec\_ga'}, time, diag,&
1456       long\_name=\textcolor{stringliteral}{'Area integrated liquid precip into ocean'}, units=\textcolor{stringliteral}{'kg m-2 s-1'},    &
1457       standard\_name=\textcolor{stringliteral}{'rainfall\_flux\_area\_averaged'},                                 &
1458       cmor\_field\_name=\textcolor{stringliteral}{'ave\_pr'},                                                    &
1459       cmor\_standard\_name=\textcolor{stringliteral}{'rainfall\_flux\_area\_averaged'},                            &
1460       cmor\_long\_name=\textcolor{stringliteral}{'Rainfall Flux where Ice Free Ocean over Sea Area Averaged'})
1461 
1462  handles%id\_fprec\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'fprec\_ga'}, time, diag,&
1463       long\_name=\textcolor{stringliteral}{'Area integrated frozen precip into ocean'}, units=\textcolor{stringliteral}{'kg m-2 s-1'},    &
1464       standard\_name=\textcolor{stringliteral}{'snowfall\_flux\_area\_averaged'},                                 &
1465       cmor\_field\_name=\textcolor{stringliteral}{'ave\_prsn'},                                                  &
1466       cmor\_standard\_name=\textcolor{stringliteral}{'snowfall\_flux\_area\_averaged'},                            &
1467       cmor\_long\_name=\textcolor{stringliteral}{'Snowfall Flux where Ice Free Ocean over Sea Area Averaged'})
1468 
1469   handles%id\_precip\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'precip\_ga'}, time, diag, &
1470       long\_name=\textcolor{stringliteral}{'Area averaged liquid+frozen precip into ocean'}, units=\textcolor{stringliteral}{'kg m-2 s-1'})
1471 
1472   handles%id\_vprec\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vrec\_ga'}, time, diag, &
1473       long\_name=\textcolor{stringliteral}{'Area averaged virtual liquid precip due to SSS restoring'}, units=\textcolor{stringliteral}{'kg m-2 s-1'})
1474 
1475   \textcolor{comment}{!===============================================================}
1476   \textcolor{comment}{! surface heat flux maps}
1477 
1478   handles%id\_heat\_content\_frunoff = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_frunoff'}, &
1479         diag%axesT1, time, \textcolor{stringliteral}{'Heat content (relative to 0C) of solid runoff into ocean'},         &
1480         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1481         standard\_name=\textcolor{stringliteral}{'temperature\_flux\_due\_to\_solid\_runoff\_expressed\_as\_heat\_flux\_into\_sea\_water'})
1482 
1483   handles%id\_heat\_content\_lrunoff = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_lrunoff'}, &
1484         diag%axesT1, time, \textcolor{stringliteral}{'Heat content (relative to 0C) of liquid runoff into ocean'},        &
1485         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1486         standard\_name=\textcolor{stringliteral}{'temperature\_flux\_due\_to\_runoff\_expressed\_as\_heat\_flux\_into\_sea\_water'})
1487 
1488   handles%id\_hfrunoffds = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hfrunoffds'},                            &
1489         diag%axesT1, time, \textcolor{stringliteral}{'Heat content (relative to 0C) of liquid+solid runoff into ocean'}, &
1490         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1491         standard\_name=\textcolor{stringliteral}{'temperature\_flux\_due\_to\_runoff\_expressed\_as\_heat\_flux\_into\_sea\_water'})
1492 
1493   handles%id\_heat\_content\_lprec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_lprec'},             &
1494         diag%axesT1,time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of liquid precip entering ocean'},           &
1495         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1496 
1497   handles%id\_heat\_content\_fprec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_fprec'},&
1498         diag%axesT1,time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of frozen prec entering ocean'},&
1499         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1500 
1501   handles%id\_heat\_content\_icemelt = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_icemelt'},&
1502         diag%axesT1,time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of water flux due to sea ice melting/freezing'},&
1503         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1504 
1505   handles%id\_heat\_content\_vprec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_vprec'},   &
1506         diag%axesT1,time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of virtual precip entering ocean'},&
1507         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1508 
1509   handles%id\_heat\_content\_cond = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_cond'},   &
1510         diag%axesT1,time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of water condensing into ocean'},&
1511         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1512 
1513   handles%id\_hfrainds = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'hfrainds'},                                 &
1514         diag%axesT1,time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of liquid+frozen precip entering ocean'},    &
1515         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1516         standard\_name=\textcolor{stringliteral}{'temperature\_flux\_due\_to\_rainfall\_expressed\_as\_heat\_flux\_into\_sea\_water'},&
1517         cmor\_long\_name=\textcolor{stringliteral}{'Heat Content (relative to 0degC) of Liquid + Frozen Precipitation'})
1518 
1519   handles%id\_heat\_content\_surfwater = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_surfwater'},&
1520          diag%axesT1, time,                                                                       &
1521         \textcolor{stringliteral}{'Heat content (relative to 0degC) of net water crossing ocean surface (frozen+liquid)'},   &
1522         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1523 
1524   handles%id\_heat\_content\_massout = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_massout'},             
               &
1525          diag%axesT1, time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of net mass leaving ocean ocean via evap and
       ice form'},&
1526         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2,                                                      &
1527         cmor\_field\_name=\textcolor{stringliteral}{'hfevapds'},                                                                        
               &
1528         cmor\_standard\_name=\textcolor{stringliteral}{'temperature\_flux\_due\_to\_evaporation\_expressed\_as\_heat\_flux\_out\_of\_sea\_water'},  
               &
1529         cmor\_long\_name=\textcolor{stringliteral}{'Heat Content (relative to 0degC) of Water Leaving Ocean via Evaporation and Ice
       Formation'})
1530 
1531   handles%id\_heat\_content\_massin = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_content\_massin'},   &
1532          diag%axesT1, time,\textcolor{stringliteral}{'Heat content (relative to 0degC) of net mass entering ocean ocean'},&
1533         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1534 
1535   handles%id\_net\_heat\_coupler = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'net\_heat\_coupler'},          &
1536         diag%axesT1,time,\textcolor{stringliteral}{'Surface ocean heat flux from SW+LW+latent+sensible+seaice\_melt\_heat (via the
       coupler)'},&
1537         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1538 
1539   handles%id\_net\_heat\_surface = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'net\_heat\_surface'},diag%axesT1, time,  &
1540         \textcolor{stringliteral}{'Surface ocean heat flux from SW+LW+lat+sens+mass transfer+frazil+restore+seaice\_melt\_heat or '}// &
1541         \textcolor{stringliteral}{'flux adjustments'}, &
1542         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1543         standard\_name=\textcolor{stringliteral}{'surface\_downward\_heat\_flux\_in\_sea\_water'}, cmor\_field\_name=\textcolor{stringliteral}{'hfds'},            &
1544         cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_heat\_flux\_in\_sea\_water'},           &
1545         cmor\_long\_name=\textcolor{stringliteral}{'Surface ocean heat flux from
       SW+LW+latent+sensible+masstransfer+frazil+seaice\_melt\_heat'})
1546 
1547   handles%id\_sw = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SW'}, diag%axesT1, time,  &
1548         \textcolor{stringliteral}{'Shortwave radiation flux into ocean'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2,                       
       &
1549         standard\_name=\textcolor{stringliteral}{'net\_downward\_shortwave\_flux\_at\_sea\_water\_surface'},      &
1550         cmor\_field\_name=\textcolor{stringliteral}{'rsntds'},                                              &
1551         cmor\_standard\_name=\textcolor{stringliteral}{'net\_downward\_shortwave\_flux\_at\_sea\_water\_surface'}, &
1552         cmor\_long\_name=\textcolor{stringliteral}{'Net Downward Shortwave Radiation at Sea Water Surface'})
1553   handles%id\_sw\_vis = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sw\_vis'}, diag%axesT1, time,     &
1554         \textcolor{stringliteral}{'Shortwave radiation direct and diffuse flux into the ocean in the visible band'}, &
1555         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1556   handles%id\_sw\_nir = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sw\_nir'}, diag%axesT1, time,     &
1557         \textcolor{stringliteral}{'Shortwave radiation direct and diffuse flux into the ocean in the near-infrared band'}, &
1558         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1559 
1560   handles%id\_LwLatSens = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'LwLatSens'}, diag%axesT1, time, &
1561         \textcolor{stringliteral}{'Combined longwave, latent, and sensible heating at ocean surface'}, \textcolor{stringliteral}{'W m-2'}, conversion=us
      %QRZ\_T\_to\_W\_m2)
1562 
1563   handles%id\_lw = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'LW'}, diag%axesT1, time, &
1564         \textcolor{stringliteral}{'Longwave radiation flux into ocean'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1565         standard\_name=\textcolor{stringliteral}{'surface\_net\_downward\_longwave\_flux'},                   &
1566         cmor\_field\_name=\textcolor{stringliteral}{'rlntds'},                                             &
1567         cmor\_standard\_name=\textcolor{stringliteral}{'surface\_net\_downward\_longwave\_flux'},              &
1568         cmor\_long\_name=\textcolor{stringliteral}{'Surface Net Downward Longwave Radiation'})
1569 
1570   handles%id\_lat = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'latent'}, diag%axesT1, time,                    &
1571         \textcolor{stringliteral}{'Latent heat flux into ocean due to fusion and evaporation (negative means ocean heat loss)'}, &
1572         \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, cmor\_field\_name=\textcolor{stringliteral}{'hflso'},                                &
1573         cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_latent\_heat\_flux'},                                       &
1574         cmor\_long\_name=\textcolor{stringliteral}{'Surface Downward Latent Heat Flux due to Evap + Melt Snow/Ice'})
1575 
1576   handles%id\_lat\_evap = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'latent\_evap'}, diag%axesT1, time, &
1577         \textcolor{stringliteral}{'Latent heat flux into ocean due to evaporation/condensation'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2
      )
1578 
1579   handles%id\_lat\_fprec = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'latent\_fprec\_diag'}, diag%axesT1, time,&
1580         \textcolor{stringliteral}{'Latent heat flux into ocean due to melting of frozen precipitation'}, \textcolor{stringliteral}{'W m-2'}, conversion=us
      %QRZ\_T\_to\_W\_m2, &
1581         cmor\_field\_name=\textcolor{stringliteral}{'hfsnthermds'},                                                             &
1582         cmor\_standard\_name=\textcolor{stringliteral}{'heat\_flux\_into\_sea\_water\_due\_to\_snow\_thermodynamics'},                  &
1583         cmor\_long\_name=\textcolor{stringliteral}{'Latent Heat to Melt Frozen Precipitation'})
1584 
1585   handles%id\_lat\_frunoff = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'latent\_frunoff'}, diag%axesT1, time, &
1586         \textcolor{stringliteral}{'Latent heat flux into ocean due to melting of icebergs'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1587         cmor\_field\_name=\textcolor{stringliteral}{'hfibthermds'},                                                             &
1588         cmor\_standard\_name=\textcolor{stringliteral}{'heat\_flux\_into\_sea\_water\_due\_to\_iceberg\_thermodynamics'},               &
1589         cmor\_long\_name=\textcolor{stringliteral}{'Latent Heat to Melt Frozen Runoff/Iceberg'})
1590 
1591   handles%id\_sens = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'sensible'}, diag%axesT1, time, &
1592         \textcolor{stringliteral}{'Sensible heat flux into ocean'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2,        &
1593         standard\_name=\textcolor{stringliteral}{'surface\_downward\_sensible\_heat\_flux'},                         &
1594         cmor\_field\_name=\textcolor{stringliteral}{'hfsso'},                                                     &
1595         cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_sensible\_heat\_flux'},                    &
1596         cmor\_long\_name=\textcolor{stringliteral}{'Surface Downward Sensible Heat Flux'})
1597 
1598   handles%id\_seaice\_melt\_heat = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'seaice\_melt\_heat'}, diag%axesT1, time,&
1599         \textcolor{stringliteral}{'Heat flux into ocean due to snow and sea ice melt/freeze'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2, &
1600         standard\_name=\textcolor{stringliteral}{'snow\_ice\_melt\_heat\_flux'},                         &
1601   \textcolor{comment}{!GMM TODO cmor\_field\_name='hfsso',                                                     &}
1602         cmor\_standard\_name=\textcolor{stringliteral}{'snow\_ice\_melt\_heat\_flux'},                    &
1603         cmor\_long\_name=\textcolor{stringliteral}{'Heat flux into ocean from snow and sea ice melt'})
1604 
1605   handles%id\_heat\_added = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'heat\_added'}, diag%axesT1, time, &
1606         \textcolor{stringliteral}{'Flux Adjustment or restoring surface heat flux into ocean'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%QRZ\_T\_to\_W\_m2)
1607 
1608 
1609   \textcolor{comment}{!===============================================================}
1610   \textcolor{comment}{! area integrated surface heat fluxes}
1611 
1612   handles%id\_total\_heat\_content\_frunoff = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                     &
1613       \textcolor{stringliteral}{'total\_heat\_content\_frunoff'}, time, diag,                                                    &
1614       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of solid runoff'},                   &
1615       units=\textcolor{stringliteral}{'W'}, cmor\_field\_name=\textcolor{stringliteral}{'total\_hfsolidrunoffds'},                                          &
1616       cmor\_standard\_name=                                                                          &
1617       \textcolor{stringliteral}{'temperature\_flux\_due\_to\_solid\_runoff\_expressed\_as\_heat\_flux\_into\_sea\_water\_area\_integrated'},&
1618       cmor\_long\_name=                                                                              &
1619       \textcolor{stringliteral}{'Temperature Flux due to Solid Runoff Expressed as Heat Flux into Sea Water Area Integrated'})
1620 
1621   handles%id\_total\_heat\_content\_lrunoff = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},               &
1622       \textcolor{stringliteral}{'total\_heat\_content\_lrunoff'}, time, diag,                                              &
1623       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of liquid runoff'},            &
1624       units=\textcolor{stringliteral}{'W'}, cmor\_field\_name=\textcolor{stringliteral}{'total\_hfrunoffds'},                                         &
1625       cmor\_standard\_name=                                                                    &
1626       \textcolor{stringliteral}{'temperature\_flux\_due\_to\_runoff\_expressed\_as\_heat\_flux\_into\_sea\_water\_area\_integrated'},&
1627       cmor\_long\_name=                                                                        &
1628       \textcolor{stringliteral}{'Temperature Flux due to Runoff Expressed as Heat Flux into Sea Water Area Integrated'})
1629 
1630   handles%id\_total\_heat\_content\_lprec = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                   &
1631       \textcolor{stringliteral}{'total\_heat\_content\_lprec'}, time, diag,                                                  &
1632       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of liquid precip'},              &
1633       units=\textcolor{stringliteral}{'W'}, cmor\_field\_name=\textcolor{stringliteral}{'total\_hfrainds'},                                             &
1634       cmor\_standard\_name=                                                                      &
1635       \textcolor{stringliteral}{'temperature\_flux\_due\_to\_rainfall\_expressed\_as\_heat\_flux\_into\_sea\_water\_area\_integrated'},&
1636       cmor\_long\_name=                                                                          &
1637       \textcolor{stringliteral}{'Temperature Flux due to Rainfall Expressed as Heat Flux into Sea Water Area Integrated'})
1638 
1639   handles%id\_total\_heat\_content\_fprec = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},     &
1640       \textcolor{stringliteral}{'total\_heat\_content\_fprec'}, time, diag,                                    &
1641       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of frozen precip'},&
1642       units=\textcolor{stringliteral}{'W'})
1643 
1644   handles%id\_total\_heat\_content\_icemelt = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},     &
1645       \textcolor{stringliteral}{'total\_heat\_content\_icemelt'}, time, diag,long\_name=                          &
1646       \textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of water flux due sea ice melting/freezing'}, &
1647       units=\textcolor{stringliteral}{'W'})
1648 
1649   handles%id\_total\_heat\_content\_vprec = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},      &
1650       \textcolor{stringliteral}{'total\_heat\_content\_vprec'}, time, diag,                                     &
1651       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of virtual precip'},&
1652       units=\textcolor{stringliteral}{'W'})
1653 
1654   handles%id\_total\_heat\_content\_cond = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},   &
1655       \textcolor{stringliteral}{'total\_heat\_content\_cond'}, time, diag,                                  &
1656       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of condensate'},&
1657       units=\textcolor{stringliteral}{'W'})
1658 
1659   handles%id\_total\_heat\_content\_surfwater = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},          &
1660       \textcolor{stringliteral}{'total\_heat\_content\_surfwater'}, time, diag,                                         &
1661       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of water crossing surface'},&
1662       units=\textcolor{stringliteral}{'W'})
1663 
1664   handles%id\_total\_heat\_content\_massout = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                      &
1665       \textcolor{stringliteral}{'total\_heat\_content\_massout'}, time, diag,                                                     &
1666       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of water leaving ocean'},             &
1667       units=\textcolor{stringliteral}{'W'},                                                                                    &
1668       cmor\_field\_name=\textcolor{stringliteral}{'total\_hfevapds'},                                                             &
1669       cmor\_standard\_name=                                                                           &
1670       \textcolor{stringliteral}{'temperature\_flux\_due\_to\_evaporation\_expressed\_as\_heat\_flux\_out\_of\_sea\_water\_area\_integrated'},&
1671       cmor\_long\_name=\textcolor{stringliteral}{'Heat Flux Out of Sea Water due to Evaporating Water Area Integrated'})
1672 
1673   handles%id\_total\_heat\_content\_massin = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},           &
1674       \textcolor{stringliteral}{'total\_heat\_content\_massin'}, time, diag,                                          &
1675       long\_name=\textcolor{stringliteral}{'Area integrated heat content (relative to 0C) of water entering ocean'},&
1676       units=\textcolor{stringliteral}{'W'})
1677 
1678   handles%id\_total\_net\_heat\_coupler = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                       &
1679       \textcolor{stringliteral}{'total\_net\_heat\_coupler'}, time, diag,                                                      &
1680       long\_name=\textcolor{stringliteral}{'Area integrated surface heat flux from SW+LW+latent+sensible+seaice\_melt\_heat (via the
       coupler)'},&
1681       units=\textcolor{stringliteral}{'W'})
1682 
1683   handles%id\_total\_net\_heat\_surface = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                      &
1684       \textcolor{stringliteral}{'total\_net\_heat\_surface'}, time, diag,                                                     &
1685       long\_name=\textcolor{stringliteral}{'Area integrated surface heat flux from SW+LW+lat+sens+mass+frazil+restore or flux
       adjustments'}, &
1686       units=\textcolor{stringliteral}{'W'},                                                                                &
1687       cmor\_field\_name=\textcolor{stringliteral}{'total\_hfds'},                                                             &
1688       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_heat\_flux\_in\_sea\_water\_area\_integrated'},             &
1689       cmor\_long\_name=                                                                           &
1690       \textcolor{stringliteral}{'Surface Ocean Heat Flux from SW+LW+latent+sensible+mass transfer+frazil Area Integrated'})
1691 
1692   handles%id\_total\_sw = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                                &
1693       \textcolor{stringliteral}{'total\_sw'}, time, diag,                                                               &
1694       long\_name=\textcolor{stringliteral}{'Area integrated net downward shortwave at sea water surface'},              &
1695       units=\textcolor{stringliteral}{'W'},                                                                            &
1696       cmor\_field\_name=\textcolor{stringliteral}{'total\_rsntds'},                                                       &
1697       cmor\_standard\_name=\textcolor{stringliteral}{'net\_downward\_shortwave\_flux\_at\_sea\_water\_surface\_area\_integrated'},&
1698       cmor\_long\_name=                                                                       &
1699       \textcolor{stringliteral}{'Net Downward Shortwave Radiation at Sea Water Surface Area Integrated'})
1700 
1701   handles%id\_total\_LwLatSens = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},&
1702       \textcolor{stringliteral}{'total\_LwLatSens'}, time, diag,                               &
1703       long\_name=\textcolor{stringliteral}{'Area integrated longwave+latent+sensible heating'},&
1704       units=\textcolor{stringliteral}{'W'})
1705 
1706   handles%id\_total\_lw = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                  &
1707       \textcolor{stringliteral}{'total\_lw'}, time, diag,                                                 &
1708       long\_name=\textcolor{stringliteral}{'Area integrated net downward longwave at sea water surface'}, &
1709       units=\textcolor{stringliteral}{'W'},                                                              &
1710       cmor\_field\_name=\textcolor{stringliteral}{'total\_rlntds'},                                         &
1711       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_net\_downward\_longwave\_flux\_area\_integrated'},&
1712       cmor\_long\_name=                                                         &
1713       \textcolor{stringliteral}{'Surface Net Downward Longwave Radiation Area Integrated'})
1714 
1715   handles%id\_total\_lat = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                &
1716       \textcolor{stringliteral}{'total\_lat'}, time, diag,                                               &
1717       long\_name=\textcolor{stringliteral}{'Area integrated surface downward latent heat flux'},         &
1718       units=\textcolor{stringliteral}{'W'},                                                             &
1719       cmor\_field\_name=\textcolor{stringliteral}{'total\_hflso'},                                         &
1720       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_latent\_heat\_flux\_area\_integrated'},&
1721       cmor\_long\_name=                                                        &
1722       \textcolor{stringliteral}{'Surface Downward Latent Heat Flux Area Integrated'})
1723 
1724   handles%id\_total\_lat\_evap = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},      &
1725       \textcolor{stringliteral}{'total\_lat\_evap'}, time, diag,                                     &
1726       long\_name=\textcolor{stringliteral}{'Area integrated latent heat flux due to evap/condense'},&
1727       units=\textcolor{stringliteral}{'W'})
1728 
1729   handles%id\_total\_lat\_fprec = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                            &
1730       \textcolor{stringliteral}{'total\_lat\_fprec'}, time, diag,                                                           &
1731       long\_name=\textcolor{stringliteral}{'Area integrated latent heat flux due to melting frozen precip'},               &
1732       units=\textcolor{stringliteral}{'W'},                                                                               &
1733       cmor\_field\_name=\textcolor{stringliteral}{'total\_hfsnthermds'},                                                     &
1734       cmor\_standard\_name=\textcolor{stringliteral}{'heat\_flux\_into\_sea\_water\_due\_to\_snow\_thermodynamics\_area\_integrated'},&
1735       cmor\_long\_name=                                                                          &
1736       \textcolor{stringliteral}{'Latent Heat to Melt Frozen Precipitation Area Integrated'})
1737 
1738   handles%id\_total\_lat\_frunoff = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                             &
1739       \textcolor{stringliteral}{'total\_lat\_frunoff'}, time, diag,                                                            &
1740       long\_name=\textcolor{stringliteral}{'Area integrated latent heat flux due to melting icebergs'},                       &
1741       units=\textcolor{stringliteral}{'W'},                                                                                  &
1742       cmor\_field\_name=\textcolor{stringliteral}{'total\_hfibthermds'},                                                        &
1743       cmor\_standard\_name=\textcolor{stringliteral}{'heat\_flux\_into\_sea\_water\_due\_to\_iceberg\_thermodynamics\_area\_integrated'},&
1744       cmor\_long\_name=                                                                             &
1745       \textcolor{stringliteral}{'Heat Flux into Sea Water due to Iceberg Thermodynamics Area Integrated'})
1746 
1747   handles%id\_total\_sens = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                 &
1748       \textcolor{stringliteral}{'total\_sens'}, time, diag,                                                &
1749       long\_name=\textcolor{stringliteral}{'Area integrated downward sensible heat flux'},                 &
1750       units=\textcolor{stringliteral}{'W'},                                                               &
1751       cmor\_field\_name=\textcolor{stringliteral}{'total\_hfsso'},                                           &
1752       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_sensible\_heat\_flux\_area\_integrated'},&
1753       cmor\_long\_name=                                                          &
1754       \textcolor{stringliteral}{'Surface Downward Sensible Heat Flux Area Integrated'})
1755 
1756   handles%id\_total\_heat\_added = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},&
1757       \textcolor{stringliteral}{'total\_heat\_adjustment'}, time, diag,                               &
1758       long\_name=\textcolor{stringliteral}{'Area integrated surface heat flux from restoring and/or flux adjustment'},   &
1759       units=\textcolor{stringliteral}{'W'})
1760 
1761   handles%id\_total\_seaice\_melt\_heat = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},&
1762       \textcolor{stringliteral}{'total\_seaice\_melt\_heat'}, time, diag,                               &
1763       long\_name=\textcolor{stringliteral}{'Area integrated surface heat flux from snow and sea ice melt'},   &
1764       units=\textcolor{stringliteral}{'W'})
1765 
1766   \textcolor{comment}{!===============================================================}
1767   \textcolor{comment}{! area averaged surface heat fluxes}
1768 
1769   handles%id\_net\_heat\_coupler\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                       &
1770       \textcolor{stringliteral}{'net\_heat\_coupler\_ga'}, time, diag,                                                      &
1771       long\_name=\textcolor{stringliteral}{'Area averaged surface heat flux from SW+LW+latent+sensible+seaice\_melt\_heat (via the
       coupler)'},&
1772       units=\textcolor{stringliteral}{'W m-2'})
1773 
1774   handles%id\_net\_heat\_surface\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                       &
1775       \textcolor{stringliteral}{'net\_heat\_surface\_ga'}, time, diag, long\_name=                                                     &
1776       \textcolor{stringliteral}{'Area averaged surface heat flux from SW+LW+lat+sens+mass+frazil+restore+seaice\_melt\_heat or flux
       adjustments'}, &
1777       units=\textcolor{stringliteral}{'W m-2'},                                                                          &
1778       cmor\_field\_name=\textcolor{stringliteral}{'ave\_hfds'},                                                             &
1779       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_heat\_flux\_in\_sea\_water\_area\_averaged'},             &
1780       cmor\_long\_name=                                                                         &
1781       \textcolor{stringliteral}{'Surface Ocean Heat Flux from SW+LW+latent+sensible+mass transfer+frazil Area Averaged'})
1782 
1783   handles%id\_sw\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                                 &
1784       \textcolor{stringliteral}{'sw\_ga'}, time, diag,                                                                &
1785       long\_name=\textcolor{stringliteral}{'Area averaged net downward shortwave at sea water surface'},              &
1786       units=\textcolor{stringliteral}{'W m-2'},                                                                      &
1787       cmor\_field\_name=\textcolor{stringliteral}{'ave\_rsntds'},                                                       &
1788       cmor\_standard\_name=\textcolor{stringliteral}{'net\_downward\_shortwave\_flux\_at\_sea\_water\_surface\_area\_averaged'},&
1789       cmor\_long\_name=                                                                     &
1790       \textcolor{stringliteral}{'Net Downward Shortwave Radiation at Sea Water Surface Area Averaged'})
1791 
1792   handles%id\_LwLatSens\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},&
1793       \textcolor{stringliteral}{'LwLatSens\_ga'}, time, diag,                               &
1794       long\_name=\textcolor{stringliteral}{'Area averaged longwave+latent+sensible heating'},&
1795       units=\textcolor{stringliteral}{'W m-2'})
1796 
1797   handles%id\_lw\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                   &
1798       \textcolor{stringliteral}{'lw\_ga'}, time, diag,                                                  &
1799       long\_name=\textcolor{stringliteral}{'Area averaged net downward longwave at sea water surface'}, &
1800       units=\textcolor{stringliteral}{'W m-2'},                                                        &
1801       cmor\_field\_name=\textcolor{stringliteral}{'ave\_rlntds'},                                         &
1802       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_net\_downward\_longwave\_flux\_area\_averaged'},&
1803       cmor\_long\_name=                                                       &
1804       \textcolor{stringliteral}{'Surface Net Downward Longwave Radiation Area Averaged'})
1805 
1806   handles%id\_lat\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                 &
1807       \textcolor{stringliteral}{'lat\_ga'}, time, diag,                                                &
1808       long\_name=\textcolor{stringliteral}{'Area averaged surface downward latent heat flux'},         &
1809       units=\textcolor{stringliteral}{'W m-2'},                                                       &
1810       cmor\_field\_name=\textcolor{stringliteral}{'ave\_hflso'},                                         &
1811       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_latent\_heat\_flux\_area\_averaged'},&
1812       cmor\_long\_name=                                                      &
1813       \textcolor{stringliteral}{'Surface Downward Latent Heat Flux Area Averaged'})
1814 
1815   handles%id\_sens\_ga = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},                  &
1816       \textcolor{stringliteral}{'sens\_ga'}, time, diag,                                                 &
1817       long\_name=\textcolor{stringliteral}{'Area averaged downward sensible heat flux'},                 &
1818       units=\textcolor{stringliteral}{'W m-2'},                                                         &
1819       cmor\_field\_name=\textcolor{stringliteral}{'ave\_hfsso'},                                           &
1820       cmor\_standard\_name=\textcolor{stringliteral}{'surface\_downward\_sensible\_heat\_flux\_area\_averaged'},&
1821       cmor\_long\_name=                                                        &
1822       \textcolor{stringliteral}{'Surface Downward Sensible Heat Flux Area Averaged'})
1823 
1824 
1825   \textcolor{comment}{!===============================================================}
1826   \textcolor{comment}{! maps of surface salt fluxes, virtual precip fluxes, and adjustments}
1827 
1828   handles%id\_saltflux = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'salt\_flux'}, diag%axesT1, time,&
1829         \textcolor{stringliteral}{'Net salt flux into ocean at surface (restoring + sea-ice)'},                      &
1830         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s, &
1831         cmor\_field\_name=\textcolor{stringliteral}{'sfdsi'}, cmor\_standard\_name=\textcolor{stringliteral}{'downward\_sea\_ice\_basal\_salt\_flux'}, &
1832         cmor\_long\_name=\textcolor{stringliteral}{'Downward Sea Ice Basal Salt Flux'})
1833 
1834   handles%id\_saltFluxIn = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'salt\_flux\_in'}, diag%axesT1, time, &
1835         \textcolor{stringliteral}{'Salt flux into ocean at surface from coupler'}, &
1836         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s)
1837 
1838   handles%id\_saltFluxAdded = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'salt\_flux\_added'}, &
1839         diag%axesT1,time,\textcolor{stringliteral}{'Salt flux into ocean at surface due to restoring or flux adjustment'}, &
1840         units=\textcolor{stringliteral}{'kg m-2 s-1'}, conversion=us%RZ\_T\_to\_kg\_m2s)
1841 
1842   handles%id\_saltFluxGlobalAdj = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},              &
1843         \textcolor{stringliteral}{'salt\_flux\_global\_restoring\_adjustment'}, time, diag,                       &
1844         \textcolor{stringliteral}{'Adjustment needed to balance net global salt flux into ocean at surface'}, &
1845          units=\textcolor{stringliteral}{'kg m-2 s-1'}) \textcolor{comment}{!, conversion=US%RZ\_T\_to\_kg\_m2s)}
1846 
1847   handles%id\_vPrecGlobalAdj = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},  &
1848         \textcolor{stringliteral}{'vprec\_global\_adjustment'}, time, diag,                      &
1849         \textcolor{stringliteral}{'Adjustment needed to adjust net vprec into ocean to zero'}, &
1850         \textcolor{stringliteral}{'kg m-2 s-1'})
1851 
1852   handles%id\_netFWGlobalAdj = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},       &
1853         \textcolor{stringliteral}{'net\_fresh\_water\_global\_adjustment'}, time, diag,                 &
1854         \textcolor{stringliteral}{'Adjustment needed to adjust net fresh water into ocean to zero'},&
1855         \textcolor{stringliteral}{'kg m-2 s-1'})
1856 
1857   handles%id\_saltFluxGlobalScl = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},            &
1858         \textcolor{stringliteral}{'salt\_flux\_global\_restoring\_scaling'}, time, diag,                        &
1859         \textcolor{stringliteral}{'Scaling applied to balance net global salt flux into ocean at surface'}, &
1860         \textcolor{stringliteral}{'nondim'})
1861 
1862   handles%id\_vPrecGlobalScl = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},&
1863         \textcolor{stringliteral}{'vprec\_global\_scaling'}, time, diag,                       &
1864         \textcolor{stringliteral}{'Scaling applied to adjust net vprec into ocean to zero'}, &
1865         \textcolor{stringliteral}{'nondim'})
1866 
1867   handles%id\_netFWGlobalScl = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},      &
1868         \textcolor{stringliteral}{'net\_fresh\_water\_global\_scaling'}, time, diag,                   &
1869         \textcolor{stringliteral}{'Scaling applied to adjust net fresh water into ocean to zero'}, &
1870         \textcolor{stringliteral}{'nondim'})
1871 
1872   \textcolor{comment}{!===============================================================}
1873   \textcolor{comment}{! area integrals of surface salt fluxes}
1874 
1875   handles%id\_total\_saltflux = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'},          &
1876       \textcolor{stringliteral}{'total\_salt\_flux'}, time, diag,                                        &
1877       long\_name=\textcolor{stringliteral}{'Area integrated surface salt flux'}, units=\textcolor{stringliteral}{'kg'},            &
1878       cmor\_field\_name=\textcolor{stringliteral}{'total\_sfdsi'},                                        &
1879       cmor\_units=\textcolor{stringliteral}{'kg s-1'},                                                  &
1880       cmor\_standard\_name=\textcolor{stringliteral}{'downward\_sea\_ice\_basal\_salt\_flux\_area\_integrated'},&
1881       cmor\_long\_name=\textcolor{stringliteral}{'Downward Sea Ice Basal Salt Flux Area Integrated'})
1882 
1883   handles%id\_total\_saltFluxIn = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_salt\_Flux\_In'}, &
1884       time, diag, long\_name=\textcolor{stringliteral}{'Area integrated surface salt flux at surface from coupler'}, units=\textcolor{stringliteral}{'kg'})
1885 
1886   handles%id\_total\_saltFluxAdded = register\_scalar\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'total\_salt\_Flux\_Added'}, &
1887       time, diag, long\_name=\textcolor{stringliteral}{'Area integrated surface salt flux due to restoring or flux adjustment'}, units=\textcolor{stringliteral}{
      'kg'})
1888 
1889 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a904033b8a97fed683d795460b555ce9b}\label{namespacemom__forcing__type_a904033b8a97fed683d795460b555ce9b}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!rotate\+\_\+forcing@{rotate\+\_\+forcing}}
\index{rotate\+\_\+forcing@{rotate\+\_\+forcing}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{rotate\+\_\+forcing()}{rotate\_forcing()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::rotate\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{integer, intent(in)}]{turns }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes\+\_\+in} & Input forcing struct\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & Rotated forcing struct\\
\hline
\mbox{\tt in}  & {\em turns} & Number of quarter turns \\
\hline
\end{DoxyParams}


Definition at line 3187 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3187   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(in)}  :: fluxes\_in\textcolor{comment}{     !< Input forcing struct}
3188   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{      !< Rotated forcing struct}
3189   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: turns\textcolor{comment}{                !< Number of quarter turns}
3190 
3191   \textcolor{keywordtype}{logical} :: do\_ustar, do\_water, do\_heat, do\_salt, do\_press, do\_shelf, &
3192       do\_iceberg, do\_heat\_added, do\_buoy
3193 
3194   \textcolor{keyword}{call }get\_forcing\_groups(fluxes\_in, do\_water, do\_heat, do\_ustar, do\_press, &
3195       do\_shelf, do\_iceberg, do\_salt, do\_heat\_added, do\_buoy)
3196 
3197   \textcolor{keywordflow}{if} (do\_ustar) \textcolor{keywordflow}{then}
3198     \textcolor{keyword}{call }rotate\_array(fluxes\_in%ustar, turns, fluxes%ustar)
3199     \textcolor{keyword}{call }rotate\_array(fluxes\_in%ustar\_gustless, turns, fluxes%ustar\_gustless)
3200 \textcolor{keywordflow}{  endif}
3201 
3202   \textcolor{keywordflow}{if} (do\_water) \textcolor{keywordflow}{then}
3203     \textcolor{keyword}{call }rotate\_array(fluxes\_in%evap, turns, fluxes%evap)
3204     \textcolor{keyword}{call }rotate\_array(fluxes\_in%lprec, turns, fluxes%lprec)
3205     \textcolor{keyword}{call }rotate\_array(fluxes\_in%fprec, turns, fluxes%fprec)
3206     \textcolor{keyword}{call }rotate\_array(fluxes\_in%vprec, turns, fluxes%vprec)
3207     \textcolor{keyword}{call }rotate\_array(fluxes\_in%lrunoff, turns, fluxes%lrunoff)
3208     \textcolor{keyword}{call }rotate\_array(fluxes\_in%frunoff, turns, fluxes%frunoff)
3209     \textcolor{keyword}{call }rotate\_array(fluxes\_in%seaice\_melt, turns, fluxes%seaice\_melt)
3210     \textcolor{keyword}{call }rotate\_array(fluxes\_in%netMassOut, turns, fluxes%netMassOut)
3211     \textcolor{keyword}{call }rotate\_array(fluxes\_in%netMassIn, turns, fluxes%netMassIn)
3212     \textcolor{keyword}{call }rotate\_array(fluxes\_in%netSalt, turns, fluxes%netSalt)
3213 \textcolor{keywordflow}{  endif}
3214 
3215   \textcolor{keywordflow}{if} (do\_heat) \textcolor{keywordflow}{then}
3216     \textcolor{keyword}{call }rotate\_array(fluxes\_in%seaice\_melt\_heat, turns, fluxes%seaice\_melt\_heat)
3217     \textcolor{keyword}{call }rotate\_array(fluxes\_in%sw, turns, fluxes%sw)
3218     \textcolor{keyword}{call }rotate\_array(fluxes\_in%lw, turns, fluxes%lw)
3219     \textcolor{keyword}{call }rotate\_array(fluxes\_in%latent, turns, fluxes%latent)
3220     \textcolor{keyword}{call }rotate\_array(fluxes\_in%sens, turns, fluxes%sens)
3221     \textcolor{keyword}{call }rotate\_array(fluxes\_in%latent\_evap\_diag, turns, fluxes%latent\_evap\_diag)
3222     \textcolor{keyword}{call }rotate\_array(fluxes\_in%latent\_fprec\_diag, turns, fluxes%latent\_fprec\_diag)
3223     \textcolor{keyword}{call }rotate\_array(fluxes\_in%latent\_frunoff\_diag, turns, fluxes%latent\_frunoff\_diag)
3224 \textcolor{keywordflow}{  endif}
3225 
3226   \textcolor{keywordflow}{if} (do\_salt) \textcolor{keywordflow}{then}
3227     \textcolor{keyword}{call }rotate\_array(fluxes\_in%salt\_flux, turns, fluxes%salt\_flux)
3228 \textcolor{keywordflow}{  endif}
3229 
3230   \textcolor{keywordflow}{if} (do\_heat .and. do\_water) \textcolor{keywordflow}{then}
3231     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_cond, turns, fluxes%heat\_content\_cond)
3232     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_icemelt, turns, fluxes%heat\_content\_icemelt)
3233     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_lprec, turns, fluxes%heat\_content\_lprec)
3234     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_fprec, turns, fluxes%heat\_content\_fprec)
3235     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_vprec, turns, fluxes%heat\_content\_vprec)
3236     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_lrunoff, turns, fluxes%heat\_content\_lrunoff)
3237     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_frunoff, turns, fluxes%heat\_content\_frunoff)
3238     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_massout, turns, fluxes%heat\_content\_massout)
3239     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_content\_massin, turns, fluxes%heat\_content\_massin)
3240 \textcolor{keywordflow}{  endif}
3241 
3242   \textcolor{keywordflow}{if} (do\_press) \textcolor{keywordflow}{then}
3243     \textcolor{keyword}{call }rotate\_array(fluxes\_in%p\_surf, turns, fluxes%p\_surf)
3244 \textcolor{keywordflow}{  endif}
3245 
3246   \textcolor{keywordflow}{if} (do\_shelf) \textcolor{keywordflow}{then}
3247     \textcolor{keyword}{call }rotate\_array(fluxes\_in%frac\_shelf\_h, turns, fluxes%frac\_shelf\_h)
3248     \textcolor{keyword}{call }rotate\_array(fluxes\_in%ustar\_shelf, turns, fluxes%ustar\_shelf)
3249     \textcolor{keyword}{call }rotate\_array(fluxes\_in%iceshelf\_melt, turns, fluxes%iceshelf\_melt)
3250 \textcolor{keywordflow}{  endif}
3251 
3252   \textcolor{keywordflow}{if} (do\_iceberg) \textcolor{keywordflow}{then}
3253     \textcolor{keyword}{call }rotate\_array(fluxes\_in%ustar\_berg, turns, fluxes%ustar\_berg)
3254     \textcolor{keyword}{call }rotate\_array(fluxes\_in%area\_berg, turns, fluxes%area\_berg)
3255     \textcolor{keyword}{call }rotate\_array(fluxes\_in%iceshelf\_melt, turns, fluxes%iceshelf\_melt)
3256 \textcolor{keywordflow}{  endif}
3257 
3258   \textcolor{keywordflow}{if} (do\_heat\_added) \textcolor{keywordflow}{then}
3259     \textcolor{keyword}{call }rotate\_array(fluxes\_in%heat\_added, turns, fluxes%heat\_added)
3260 \textcolor{keywordflow}{  endif}
3261 
3262   \textcolor{comment}{! The following fields are handled by drivers rather than control flags.}
3263   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%sw\_vis\_dir)) &
3264     \textcolor{keyword}{call }rotate\_array(fluxes\_in%sw\_vis\_dir, turns, fluxes%sw\_vis\_dir)
3265   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%sw\_vis\_dif)) &
3266     \textcolor{keyword}{call }rotate\_array(fluxes\_in%sw\_vis\_dif, turns, fluxes%sw\_vis\_dif)
3267   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%sw\_nir\_dir)) &
3268     \textcolor{keyword}{call }rotate\_array(fluxes\_in%sw\_nir\_dir, turns, fluxes%sw\_nir\_dir)
3269   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%sw\_nir\_dif)) &
3270     \textcolor{keyword}{call }rotate\_array(fluxes\_in%sw\_nir\_dif, turns, fluxes%sw\_nir\_dif)
3271 
3272   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%salt\_flux\_in)) &
3273     \textcolor{keyword}{call }rotate\_array(fluxes\_in%salt\_flux\_in, turns, fluxes%salt\_flux\_in)
3274   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%salt\_flux\_added)) &
3275     \textcolor{keyword}{call }rotate\_array(fluxes\_in%salt\_flux\_added, turns, fluxes%salt\_flux\_added)
3276 
3277   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%p\_surf\_full)) &
3278     \textcolor{keyword}{call }rotate\_array(fluxes\_in%p\_surf\_full, turns, fluxes%p\_surf\_full)
3279 
3280   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%buoy)) &
3281     \textcolor{keyword}{call }rotate\_array(fluxes\_in%buoy, turns, fluxes%buoy)
3282 
3283   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%TKE\_tidal)) &
3284     \textcolor{keyword}{call }rotate\_array(fluxes\_in%TKE\_tidal, turns, fluxes%TKE\_tidal)
3285   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\_in%ustar\_tidal)) &
3286     \textcolor{keyword}{call }rotate\_array(fluxes\_in%ustar\_tidal, turns, fluxes%ustar\_tidal)
3287 
3288   \textcolor{comment}{! TODO: tracer flux rotation}
3289   \textcolor{keywordflow}{if} (coupler\_type\_initialized(fluxes%tr\_fluxes)) &
3290     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Rotation of tracer BC fluxes not yet implemented."})
3291 
3292   \textcolor{comment}{! Scalars and flags}
3293   fluxes%accumulate\_p\_surf = fluxes\_in%accumulate\_p\_surf
3294 
3295   fluxes%vPrecGlobalAdj = fluxes\_in%vPrecGlobalAdj
3296   fluxes%saltFluxGlobalAdj = fluxes\_in%saltFluxGlobalAdj
3297   fluxes%netFWGlobalAdj = fluxes\_in%netFWGlobalAdj
3298   fluxes%vPrecGlobalScl = fluxes\_in%vPrecGlobalScl
3299   fluxes%saltFluxGlobalScl = fluxes\_in%saltFluxGlobalScl
3300   fluxes%netFWGlobalScl = fluxes\_in%netFWGlobalScl
3301 
3302   fluxes%fluxes\_used = fluxes\_in%fluxes\_used
3303   fluxes%dt\_buoy\_accum = fluxes\_in%dt\_buoy\_accum
3304   fluxes%C\_p = fluxes\_in%C\_p
3305   \textcolor{comment}{! NOTE: gustless\_accum\_bug is set during allocation}
3306 
3307   fluxes%num\_msg = fluxes\_in%num\_msg
3308   fluxes%max\_msg = fluxes\_in%max\_msg
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a7b1d8f7fa2ffad01d699febbf042ac74}\label{namespacemom__forcing__type_a7b1d8f7fa2ffad01d699febbf042ac74}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!rotate\+\_\+mech\+\_\+forcing@{rotate\+\_\+mech\+\_\+forcing}}
\index{rotate\+\_\+mech\+\_\+forcing@{rotate\+\_\+mech\+\_\+forcing}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{rotate\+\_\+mech\+\_\+forcing()}{rotate\_mech\_forcing()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::rotate\+\_\+mech\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces\+\_\+in,  }\item[{integer, intent(in)}]{turns,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(inout)}]{forces }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces\+\_\+in} & Forcing on the input domain\\
\hline
\mbox{\tt in}  & {\em turns} & Number of quarter-\/turns\\
\hline
\mbox{\tt in,out}  & {\em forces} & Forcing on the rotated domain \\
\hline
\end{DoxyParams}


Definition at line 3313 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
3313   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(in)}  :: forces\_in\textcolor{comment}{  !< Forcing on the input domain}
3314   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: turns\textcolor{comment}{                  !< Number of quarter-turns}
3315   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{   !< Forcing on the rotated domain}
3316 
3317   \textcolor{keywordtype}{logical} :: do\_stress, do\_ustar, do\_shelf, do\_press, do\_iceberg
3318 
3319   \textcolor{keyword}{call }get\_mech\_forcing\_groups(forces\_in, do\_stress, do\_ustar, do\_shelf, &
3320                               do\_press, do\_iceberg)
3321 
3322   \textcolor{keywordflow}{if} (do\_stress) &
3323     \textcolor{keyword}{call }rotate\_vector(forces\_in%taux, forces\_in%tauy, turns, &
3324         forces%taux, forces%tauy)
3325 
3326   \textcolor{keywordflow}{if} (do\_ustar) &
3327     \textcolor{keyword}{call }rotate\_array(forces\_in%ustar, turns, forces%ustar)
3328 
3329   \textcolor{keywordflow}{if} (do\_shelf) \textcolor{keywordflow}{then}
3330     \textcolor{keyword}{call }rotate\_array\_pair( &
3331       forces\_in%rigidity\_ice\_u, forces\_in%rigidity\_ice\_v, turns, &
3332       forces%rigidity\_ice\_u, forces%rigidity\_ice\_v &
3333     )
3334     \textcolor{keyword}{call }rotate\_array\_pair( &
3335       forces\_in%frac\_shelf\_u, forces\_in%frac\_shelf\_v, turns, &
3336       forces%frac\_shelf\_u, forces%frac\_shelf\_v &
3337     )
3338 \textcolor{keywordflow}{  endif}
3339 
3340   \textcolor{keywordflow}{if} (do\_press) \textcolor{keywordflow}{then}
3341     \textcolor{comment}{! NOTE: p\_surf\_SSH either points to p\_surf or p\_surf\_full}
3342     \textcolor{keyword}{call }rotate\_array(forces\_in%p\_surf, turns, forces%p\_surf)
3343     \textcolor{keyword}{call }rotate\_array(forces\_in%p\_surf\_full, turns, forces%p\_surf\_full)
3344     \textcolor{keyword}{call }rotate\_array(forces\_in%net\_mass\_src, turns, forces%net\_mass\_src)
3345 \textcolor{keywordflow}{  endif}
3346 
3347   \textcolor{keywordflow}{if} (do\_iceberg) \textcolor{keywordflow}{then}
3348     \textcolor{keyword}{call }rotate\_array(forces\_in%area\_berg, turns, forces%area\_berg)
3349     \textcolor{keyword}{call }rotate\_array(forces\_in%mass\_berg, turns, forces%mass\_berg)
3350 \textcolor{keywordflow}{  endif}
3351 
3352   \textcolor{comment}{! Copy fields}
3353   forces%dt\_force\_accum = forces\_in%dt\_force\_accum
3354   forces%net\_mass\_src\_set = forces\_in%net\_mass\_src\_set
3355   forces%accumulate\_p\_surf = forces\_in%accumulate\_p\_surf
3356   forces%accumulate\_rigidity = forces\_in%accumulate\_rigidity
3357   forces%initialized = forces\_in%initialized
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a1e4c747c49b67bb20b322c7b807de036}\label{namespacemom__forcing__type_a1e4c747c49b67bb20b322c7b807de036}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!set\+\_\+derived\+\_\+forcing\+\_\+fields@{set\+\_\+derived\+\_\+forcing\+\_\+fields}}
\index{set\+\_\+derived\+\_\+forcing\+\_\+fields@{set\+\_\+derived\+\_\+forcing\+\_\+fields}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{set\+\_\+derived\+\_\+forcing\+\_\+fields()}{set\_derived\_forcing\_fields()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::set\+\_\+derived\+\_\+forcing\+\_\+fields (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(in)}]{forces,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(inout)}]{fluxes,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{Rho0 }\end{DoxyParamCaption})}



This subroutine calculates certain derived forcing fields based on information from a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type and stores them in a (thermodynamic) forcing type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em g} & grid type\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em rho0} & A reference density of seawater \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}, as used to calculate ustar. \\
\hline
\end{DoxyParams}


Definition at line 2103 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2103   \textcolor{keywordtype}{type}(mech\_forcing),      \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{   !< A structure with the driving mechanical forces}
2104   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{   !< A structure containing thermodynamic forcing fields}
2105   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{        !< grid type}
2106   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{       !< A dimensional unit scaling type}
2107   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: Rho0\textcolor{comment}{     !< A reference density of seawater [R ~> kg m-3],}
2108 \textcolor{comment}{                                                     !! as used to calculate ustar.}
2109 
2110   \textcolor{keywordtype}{real} :: taux2, tauy2 \textcolor{comment}{! Squared wind stress components [R2 L2 Z2 T-4 ~> Pa2].}
2111   \textcolor{keywordtype}{real} :: Irho0        \textcolor{comment}{! Inverse of the mean density rescaled to [Z L-1 R-1 ~> m3 kg-1]}
2112   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
2113   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
2114 
2115   irho0 = us%L\_to\_Z / rho0
2116 
2117   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%taux) .and. \textcolor{keyword}{associated}(forces%tauy) .and. &
2118       \textcolor{keyword}{associated}(fluxes%ustar\_gustless)) \textcolor{keywordflow}{then}
2119     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
2120       taux2 = 0.0
2121       \textcolor{keywordflow}{if} ((g%mask2dCu(i-1,j) + g%mask2dCu(i,j)) > 0) &
2122         taux2 = (g%mask2dCu(i-1,j) * forces%taux(i-1,j)**2 + &
2123                  g%mask2dCu(i,j) * forces%taux(i,j)**2) / &
2124                 (g%mask2dCu(i-1,j) + g%mask2dCu(i,j))
2125       tauy2 = 0.0
2126       \textcolor{keywordflow}{if} ((g%mask2dCv(i,j-1) + g%mask2dCv(i,j)) > 0) &
2127         tauy2 = (g%mask2dCv(i,j-1) * forces%tauy(i,j-1)**2 + &
2128                  g%mask2dCv(i,j) * forces%tauy(i,j)**2) / &
2129                 (g%mask2dCv(i,j-1) + g%mask2dCv(i,j))
2130 
2131       \textcolor{keywordflow}{if} (fluxes%gustless\_accum\_bug) \textcolor{keywordflow}{then}
2132         \textcolor{comment}{! This change is just for computational efficiency, but it is wrapped with another change.}
2133         fluxes%ustar\_gustless(i,j) = sqrt(us%L\_to\_Z * sqrt(taux2 + tauy2) / rho0)
2134       \textcolor{keywordflow}{else}
2135         fluxes%ustar\_gustless(i,j) = sqrt(sqrt(taux2 + tauy2) * irho0)
2136 \textcolor{keywordflow}{      endif}
2137 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2138 \textcolor{keywordflow}{  endif}
2139 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__forcing__type_a9ee72ee836f7326d0957a4094d8f0231}\label{namespacemom__forcing__type_a9ee72ee836f7326d0957a4094d8f0231}} 
\index{mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}!set\+\_\+net\+\_\+mass\+\_\+forcing@{set\+\_\+net\+\_\+mass\+\_\+forcing}}
\index{set\+\_\+net\+\_\+mass\+\_\+forcing@{set\+\_\+net\+\_\+mass\+\_\+forcing}!mom\+\_\+forcing\+\_\+type@{mom\+\_\+forcing\+\_\+type}}
\subsubsection{\texorpdfstring{set\+\_\+net\+\_\+mass\+\_\+forcing()}{set\_net\_mass\_forcing()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+forcing\+\_\+type\+::set\+\_\+net\+\_\+mass\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1forcing}{forcing}}), intent(in)}]{fluxes,  }\item[{type(\mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}}), intent(inout)}]{forces,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US }\end{DoxyParamCaption})}



This subroutine determines the net mass source to the ocean from a (thermodynamic) forcing type and stores it in a \mbox{\hyperlink{structmom__forcing__type_1_1mech__forcing}{mech\+\_\+forcing}} type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em g} & The ocean grid type \\
\hline
\end{DoxyParams}


Definition at line 2146 of file M\+O\+M\+\_\+forcing\+\_\+type.\+F90.


\begin{DoxyCode}
2146   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(in)}    :: fluxes\textcolor{comment}{   !< A structure containing thermodynamic forcing fields}
2147   \textcolor{keywordtype}{type}(mech\_forcing),      \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{   !< A structure with the driving mechanical forces}
2148   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{       !< A dimensional unit scaling type}
2149   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{        !< The ocean grid type}
2150 
2151   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%net\_mass\_src)) &
2152     \textcolor{keyword}{call }get\_net\_mass\_forcing(fluxes, g, us, forces%net\_mass\_src)
2153 
\end{DoxyCode}
