\hypertarget{namespacemom__diag__mediator}{}\section{mom\+\_\+diag\+\_\+mediator Module Reference}
\label{namespacemom__diag__mediator}\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}


\subsection{Detailed Description}
The subroutines here provide convenient wrappers to the fms diag\+\_\+manager interfaces with additional diagnostic capabilies. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}
\begin{DoxyCompactList}\small\item\em A group of 1D axes that comprise a 1\+D/2\+D/3D mesh. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}
\begin{DoxyCompactList}\small\item\em The following data type a list of diagnostic fields an their variants, as well as variables that control the handling of model output. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diag__mediator_1_1diag__dsamp}{diag\+\_\+dsamp}}
\begin{DoxyCompactList}\small\item\em Contained for down sampled masks. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diag__mediator_1_1diag__grid__storage}{diag\+\_\+grid\+\_\+storage}}
\begin{DoxyCompactList}\small\item\em Stores all the remapping grids and the model\textquotesingle{}s native space thicknesses. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diag__mediator_1_1diag__grids__type}{diag\+\_\+grids\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Contains an array to store a diagnostic target grid. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}
\begin{DoxyCompactList}\small\item\em This type is used to represent a diagnostic at the diag\+\_\+mediator level. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__diag__mediator_1_1diagcs__dsamp}{diagcs\+\_\+dsamp}}
\begin{DoxyCompactList}\small\item\em Container for down sampling information. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__diag__mediator_1_1downsample__diag__field}{downsample\+\_\+diag\+\_\+field}}
\begin{DoxyCompactList}\small\item\em Down sample a diagnostic field. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__diag__mediator_1_1downsample__field}{downsample\+\_\+field}}
\begin{DoxyCompactList}\small\item\em Down sample a field. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__diag__mediator_1_1downsample__mask}{downsample\+\_\+mask}}
\begin{DoxyCompactList}\small\item\em Down sample the mask of a field. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__diag__mediator_1_1post__data}{post\+\_\+data}}
\begin{DoxyCompactList}\small\item\em Make a diagnostic available for averaging or output. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a76c9267c7744e3573f78afbaa0b716a5}{set\+\_\+axes\+\_\+info}} (G, GV, US, param\+\_\+file, diag\+\_\+cs, set\+\_\+vertical)
\begin{DoxyCompactList}\small\item\em Sets up diagnostics axes. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a1abcee77dbc8e8a48f4b48144fc0923c}{set\+\_\+axes\+\_\+info\+\_\+dsamp}} (G, GV, param\+\_\+file, diag\+\_\+cs, id\+\_\+zl\+\_\+native, id\+\_\+zi\+\_\+native)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a19d8a5e2782eb57ab3d7824028fafd56}{set\+\_\+masks\+\_\+for\+\_\+axes}} (G, diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em set\+\_\+masks\+\_\+for\+\_\+axes sets up the 2d and 3d masks for diagnostics using the current grid recorded after calling \mbox{\hyperlink{namespacemom__diag__mediator_aa78e69709084d0097b3e01bbd83d3509}{diag\+\_\+update\+\_\+remap\+\_\+grids()}} \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_ade968ef275fa55cf8a2301debdd7e88a}{set\+\_\+masks\+\_\+for\+\_\+axes\+\_\+dsamp}} (G, diag\+\_\+cs)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a2795a8a8618f945a9a0830f461d3e42d}{diag\+\_\+register\+\_\+area\+\_\+ids}} (diag\+\_\+cs, id\+\_\+area\+\_\+t, id\+\_\+area\+\_\+q)
\begin{DoxyCompactList}\small\item\em Attaches the id of cell areas to axes groups for use with cell\+\_\+measures. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a820eb49d3acf041c630ce1373bef799e}{register\+\_\+cell\+\_\+measure}} (G, diag, Time)
\begin{DoxyCompactList}\small\item\em Sets a handle inside diagnostics mediator to associate 3d cell measures. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a6affd997646a278d7fca03174a5a06ad}{diag\+\_\+associate\+\_\+volume\+\_\+cell\+\_\+measure}} (diag\+\_\+cs, id\+\_\+h\+\_\+volume)
\begin{DoxyCompactList}\small\item\em Attaches the id of cell volumes to axes groups for use with cell\+\_\+measures. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespacemom__diag__mediator_aba626173ff1459bd423b1902425d1908}{diag\+\_\+get\+\_\+volume\+\_\+cell\+\_\+measure\+\_\+dm\+\_\+id}} (diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Returns diag\+\_\+manager id for cell measure of h-\/cells. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_ab9f767ec24a860cb71cae264560272a8}{define\+\_\+axes\+\_\+group}} (diag\+\_\+cs, handles, axes, nz, vertical\+\_\+coordinate\+\_\+number, x\+\_\+cell\+\_\+method, y\+\_\+cell\+\_\+method, v\+\_\+cell\+\_\+method, is\+\_\+h\+\_\+point, is\+\_\+q\+\_\+point, is\+\_\+u\+\_\+point, is\+\_\+v\+\_\+point, is\+\_\+layer, is\+\_\+interface, is\+\_\+native, needs\+\_\+remapping, needs\+\_\+interpolating, xyave\+\_\+axes)
\begin{DoxyCompactList}\small\item\em Defines a group of \char`\"{}axes\char`\"{} from list of handles. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a51129041d5b42f6546c087111465f639}{define\+\_\+axes\+\_\+group\+\_\+dsamp}} (diag\+\_\+cs, handles, axes, dl, nz, vertical\+\_\+coordinate\+\_\+number, x\+\_\+cell\+\_\+method, y\+\_\+cell\+\_\+method, v\+\_\+cell\+\_\+method, is\+\_\+h\+\_\+point, is\+\_\+q\+\_\+point, is\+\_\+u\+\_\+point, is\+\_\+v\+\_\+point, is\+\_\+layer, is\+\_\+interface, is\+\_\+native, needs\+\_\+remapping, needs\+\_\+interpolating, xyave\+\_\+axes)
\begin{DoxyCompactList}\small\item\em Defines a group of downsampled \char`\"{}axes\char`\"{} from list of handles. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a36d062ce991a3bd7250b3224e6508eb5}{set\+\_\+diag\+\_\+mediator\+\_\+grid}} (G, diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Set up the array extents for doing diagnostics. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_ab98d892c30de2ee865416e519eacfd79}{post\+\_\+data\+\_\+0d}} (diag\+\_\+field\+\_\+id, field, diag\+\_\+cs, is\+\_\+static)
\begin{DoxyCompactList}\small\item\em Make a real scalar diagnostic available for averaging or output. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_ab5b75b68fa1742ce312c371f4b2c6ac1}{post\+\_\+data\+\_\+1d\+\_\+k}} (diag\+\_\+field\+\_\+id, field, diag\+\_\+cs, is\+\_\+static)
\begin{DoxyCompactList}\small\item\em Make a real 1-\/d array diagnostic available for averaging or output. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a2b87038d2cfd2f6709ecb9f4481e0e75}{post\+\_\+data\+\_\+2d}} (diag\+\_\+field\+\_\+id, field, diag\+\_\+cs, is\+\_\+static, mask)
\begin{DoxyCompactList}\small\item\em Make a real 2-\/d array diagnostic available for averaging or output. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a633c4a461809f5843ac522616db8f382}{post\+\_\+data\+\_\+2d\+\_\+low}} (diag, field, diag\+\_\+cs, is\+\_\+static, mask)
\begin{DoxyCompactList}\small\item\em Make a real 2-\/d array diagnostic available for averaging or output using a \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}} instead of an integer id. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a70116fa6034dcf977a8bdcb4d81f9207}{post\+\_\+data\+\_\+3d}} (diag\+\_\+field\+\_\+id, field, diag\+\_\+cs, is\+\_\+static, mask, alt\+\_\+h)
\begin{DoxyCompactList}\small\item\em Make a real 3-\/d array diagnostic available for averaging or output. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_ae11cae949c3f8cf68d2c70f656aa9c54}{post\+\_\+data\+\_\+3d\+\_\+low}} (diag, field, diag\+\_\+cs, is\+\_\+static, mask)
\begin{DoxyCompactList}\small\item\em Make a real 3-\/d array diagnostic available for averaging or output using a \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}} instead of an integer id. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_ab41a1779c5edb50aa7256477cef952ae}{post\+\_\+xy\+\_\+average}} (diag\+\_\+cs, diag, field)
\begin{DoxyCompactList}\small\item\em Post the horizontally area-\/averaged diagnostic. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a91244f765f2964dfb11f8787f65042f1}{enable\+\_\+averaging}} (time\+\_\+int\+\_\+in, time\+\_\+end\+\_\+in, diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em This subroutine enables the accumulation of time averages over the specified time interval. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_ada4d9d69fb0d79a0fe20a307eaf1ca9c}{enable\+\_\+averages}} (time\+\_\+int, time\+\_\+end, diag\+\_\+\+CS, T\+\_\+to\+\_\+s)
\begin{DoxyCompactList}\small\item\em Enable the accumulation of time averages over the specified time interval in time units. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a1761df399ba39742e34ab989469da0f2}{disable\+\_\+averaging}} (diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Call this subroutine to avoid averaging any offered fields. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__diag__mediator_a0be5d1cbc6c6f8f63950ce7d9bc6455a}{query\+\_\+averaging\+\_\+enabled}} (diag\+\_\+cs, time\+\_\+int, time\+\_\+end)
\begin{DoxyCompactList}\small\item\em Call this subroutine to determine whether the averaging is currently enabled. .true. is returned if it is. \end{DoxyCompactList}\item 
type(time\+\_\+type) function, public \mbox{\hyperlink{namespacemom__diag__mediator_a76e845bc64dfd5116f41fe90922b7937}{get\+\_\+diag\+\_\+time\+\_\+end}} (diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em This function returns the valid end time for use with diagnostics that are handled outside of the M\+O\+M6 diagnostics infrastructure. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespacemom__diag__mediator_ada491446bf7216fe101e6b0f6ed551e1}{register\+\_\+diag\+\_\+field}} (module\+\_\+name, field\+\_\+name, axes\+\_\+in, init\+\_\+time, long\+\_\+name, units, missing\+\_\+value, range, mask\+\_\+variant, standard\+\_\+name, verbose, do\+\_\+not\+\_\+log, err\+\_\+msg, interp\+\_\+method, tile\+\_\+count, cmor\+\_\+field\+\_\+name, cmor\+\_\+long\+\_\+name, cmor\+\_\+units, cmor\+\_\+standard\+\_\+name, cell\+\_\+methods, x\+\_\+cell\+\_\+method, y\+\_\+cell\+\_\+method, v\+\_\+cell\+\_\+method, conversion, v\+\_\+extensive)
\begin{DoxyCompactList}\small\item\em Returns the \char`\"{}diag\+\_\+mediator\char`\"{} handle for a group (native, C\+M\+OR, z-\/coord, ...) of diagnostics derived from one field. \end{DoxyCompactList}\item 
logical function \mbox{\hyperlink{namespacemom__diag__mediator_ae50b35cba800ac5fd8975929fd2b9f4a}{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+cmor}} (dm\+\_\+id, module\+\_\+name, field\+\_\+name, axes, init\+\_\+time, long\+\_\+name, units, missing\+\_\+value, range, mask\+\_\+variant, standard\+\_\+name, verbose, do\+\_\+not\+\_\+log, err\+\_\+msg, interp\+\_\+method, tile\+\_\+count, cmor\+\_\+field\+\_\+name, cmor\+\_\+long\+\_\+name, cmor\+\_\+units, cmor\+\_\+standard\+\_\+name, cell\+\_\+methods, x\+\_\+cell\+\_\+method, y\+\_\+cell\+\_\+method, v\+\_\+cell\+\_\+method, conversion, v\+\_\+extensive)
\begin{DoxyCompactList}\small\item\em Returns True if either the native or C\+M\+Or version of the diagnostic were registered. Updates \textquotesingle{}dm\+\_\+id\textquotesingle{} after calling \mbox{\hyperlink{namespacemom__diag__mediator_aca4a32fea8dade9f51e076a56b9bad2b}{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes()}} for both native and C\+M\+OR variants of the field. \end{DoxyCompactList}\item 
integer function \mbox{\hyperlink{namespacemom__diag__mediator_aca4a32fea8dade9f51e076a56b9bad2b}{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes}} (module\+\_\+name, field\+\_\+name, axes, init\+\_\+time, long\+\_\+name, units, missing\+\_\+value, range, mask\+\_\+variant, standard\+\_\+name, verbose, do\+\_\+not\+\_\+log, err\+\_\+msg, interp\+\_\+method, tile\+\_\+count)
\begin{DoxyCompactList}\small\item\em Returns an F\+MS id from register\+\_\+diag\+\_\+field\+\_\+fms (the diag\+\_\+manager routine) after expanding axes (axes-\/group) into handles and conditionally adding an F\+MS area\+\_\+id for cell\+\_\+measures. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a8415b33a337b1fbc7535688eca85ab37}{add\+\_\+diag\+\_\+to\+\_\+list}} (diag\+\_\+cs, dm\+\_\+id, fms\+\_\+id, this\+\_\+diag, axes, module\+\_\+name, field\+\_\+name, msg)
\begin{DoxyCompactList}\small\item\em Create a diagnostic type and attached to list. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a14d405e0958e6e58797253c52c666cdb}{add\+\_\+xyz\+\_\+method}} (diag, axes, x\+\_\+cell\+\_\+method, y\+\_\+cell\+\_\+method, v\+\_\+cell\+\_\+method, v\+\_\+extensive)
\begin{DoxyCompactList}\small\item\em Adds the encoded \char`\"{}cell\+\_\+methods\char`\"{} for a diagnostics as a diag\% property This allows access to the cell\+\_\+method for a given diagnostics at the time of sending. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_ae0f04c145cb120fc2ab6cbfe9f166392}{attach\+\_\+cell\+\_\+methods}} (id, axes, ostring, cell\+\_\+methods, x\+\_\+cell\+\_\+method, y\+\_\+cell\+\_\+method, v\+\_\+cell\+\_\+method, v\+\_\+extensive)
\begin{DoxyCompactList}\small\item\em Attaches \char`\"{}cell\+\_\+methods\char`\"{} attribute to a variable based on defaults for \mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}} or optional arguments. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespacemom__diag__mediator_afb4254e1cfbbcfc43028f14915173f80}{register\+\_\+scalar\+\_\+field}} (module\+\_\+name, field\+\_\+name, init\+\_\+time, diag\+\_\+cs, long\+\_\+name, units, missing\+\_\+value, range, standard\+\_\+name, do\+\_\+not\+\_\+log, err\+\_\+msg, interp\+\_\+method, cmor\+\_\+field\+\_\+name, cmor\+\_\+long\+\_\+name, cmor\+\_\+units, cmor\+\_\+standard\+\_\+name)
\item 
integer function, public \mbox{\hyperlink{namespacemom__diag__mediator_a87fa69b9e2ba3205756d93e1e13e1dc7}{register\+\_\+static\+\_\+field}} (module\+\_\+name, field\+\_\+name, axes, long\+\_\+name, units, missing\+\_\+value, range, mask\+\_\+variant, standard\+\_\+name, do\+\_\+not\+\_\+log, interp\+\_\+method, tile\+\_\+count, cmor\+\_\+field\+\_\+name, cmor\+\_\+long\+\_\+name, cmor\+\_\+units, cmor\+\_\+standard\+\_\+name, area, x\+\_\+cell\+\_\+method, y\+\_\+cell\+\_\+method, area\+\_\+cell\+\_\+method, conversion)
\begin{DoxyCompactList}\small\item\em Registers a static diagnostic, returning an integer handle. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_ae002ca447acba252bf7bdc042e75a01e}{describe\+\_\+option}} (opt\+\_\+name, value, diag\+\_\+\+CS)
\begin{DoxyCompactList}\small\item\em Describe an option setting in the diagnostic files. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespacemom__diag__mediator_a21267e25d12fa3e5d2540d2a299d2d2c}{ocean\+\_\+register\+\_\+diag}} (var\+\_\+desc, G, diag\+\_\+\+CS, day)
\begin{DoxyCompactList}\small\item\em Registers a diagnostic using the information encapsulated in the vardesc type argument and returns an integer handle to this diagostic. That integer handle is negative if the diagnostic is unused. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_ae8ac8a662308a9e766249fdf29956560}{diag\+\_\+mediator\+\_\+infrastructure\+\_\+init}} (err\+\_\+msg)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a3c99ff49de6d5e43f0d1bba79290eb71}{diag\+\_\+mediator\+\_\+init}} (G, GV, US, nz, param\+\_\+file, diag\+\_\+cs, doc\+\_\+file\+\_\+dir)
\begin{DoxyCompactList}\small\item\em diag\+\_\+mediator\+\_\+init initializes the M\+OM diag\+\_\+mediator and opens the available diagnostics file, if appropriate. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_abe52776bc4a161c4912ce1987acaf1c1}{diag\+\_\+set\+\_\+state\+\_\+ptrs}} (h, T, S, eqn\+\_\+of\+\_\+state, diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Set pointers to the default state fields used to remap diagnostics. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_aa78e69709084d0097b3e01bbd83d3509}{diag\+\_\+update\+\_\+remap\+\_\+grids}} (diag\+\_\+cs, alt\+\_\+h, alt\+\_\+T, alt\+\_\+S, update\+\_\+intensive, update\+\_\+extensive)
\begin{DoxyCompactList}\small\item\em Build/update vertical grids for diagnostic remapping. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_aebf8dcc4bac8028f24a80fa5f1f1ca5b}{diag\+\_\+masks\+\_\+set}} (G, nz, diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Sets up the 2d and 3d masks for native diagnostics. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_ab6b7493efa5caee06547dafdba29361b}{diag\+\_\+mediator\+\_\+close\+\_\+registration}} (diag\+\_\+\+CS)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a780f8870b442c730208d66d1ff0b4ac0}{diag\+\_\+mediator\+\_\+end}} (time, diag\+\_\+\+CS, end\+\_\+diag\+\_\+manager)
\item 
character(len=15) function \mbox{\hyperlink{namespacemom__diag__mediator_a82d9bb70db16b1113304936c82d40e82}{i2s}} (a, n\+\_\+in)
\begin{DoxyCompactList}\small\item\em Convert the first n elements (up to 3) of an integer array to an underscore delimited string. \end{DoxyCompactList}\item 
integer function \mbox{\hyperlink{namespacemom__diag__mediator_a3f7442639213320f7429e2288a79fda2}{get\+\_\+new\+\_\+diag\+\_\+id}} (diag\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Returns a new diagnostic id, it may be necessary to expand the diagnostics array. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a883862f004e30bbc5211f38635511ba0}{initialize\+\_\+diag\+\_\+type}} (diag)
\begin{DoxyCompactList}\small\item\em Initializes a \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}} (used after allocating new memory) \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a1b0bed2113a0c268eafd1bafbb48bd4f}{alloc\+\_\+diag\+\_\+with\+\_\+id}} (diag\+\_\+id, diag\+\_\+cs, diag)
\begin{DoxyCompactList}\small\item\em Make a new diagnostic. Either use memory which is in the array of \textquotesingle{}primary\textquotesingle{} diagnostics, or if that is in use, insert it to the list of secondary diags. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a65fe8d329cf5dbfd08c98874a7a64407}{log\+\_\+available\+\_\+diag}} (used, module\+\_\+name, field\+\_\+name, cell\+\_\+methods\+\_\+string, comment, diag\+\_\+\+CS, long\+\_\+name, units, standard\+\_\+name)
\begin{DoxyCompactList}\small\item\em Log a diagnostic to the available diagnostics file. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_af410974feba66bf49817eccb7d1b6426}{log\+\_\+chksum\+\_\+diag}} (docunit, description, chksum)
\begin{DoxyCompactList}\small\item\em Log the diagnostic chksum to the chksum diag file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a6f596247402f21fa60bfdf1e73c41044}{diag\+\_\+grid\+\_\+storage\+\_\+init}} (grid\+\_\+storage, G, diag)
\begin{DoxyCompactList}\small\item\em Allocates fields necessary to store diagnostic remapping fields. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a4c15fc11c4d220ebcdd38adb692950db}{diag\+\_\+copy\+\_\+diag\+\_\+to\+\_\+storage}} (grid\+\_\+storage, h\+\_\+state, diag)
\begin{DoxyCompactList}\small\item\em Copy from the main diagnostic arrays to the grid storage as well as the native thicknesses. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_acfce430f0605a56afdb438107afc0d47}{diag\+\_\+copy\+\_\+storage\+\_\+to\+\_\+diag}} (diag, grid\+\_\+storage)
\begin{DoxyCompactList}\small\item\em Copy from the stored diagnostic arrays to the main diagnostic grids. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_aba48dd8ac75fdf10eda85f8183c2b39e}{diag\+\_\+save\+\_\+grids}} (diag)
\begin{DoxyCompactList}\small\item\em Save the current diagnostic grids in the temporary structure within diag. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a7a21b53f286a9a214cc6aac4e34eb78b}{diag\+\_\+restore\+\_\+grids}} (diag)
\begin{DoxyCompactList}\small\item\em Restore the diagnostic grids from the temporary structure within diag. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__mediator_a4f82f684f05d581ea5b62a9c62a54af3}{diag\+\_\+grid\+\_\+storage\+\_\+end}} (grid\+\_\+storage)
\begin{DoxyCompactList}\small\item\em Deallocates the fields in the remapping fields container. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a5f2fcd6b3aa44f8d4f6259d8cf365f04}{downsample\+\_\+diag\+\_\+masks\+\_\+set}} (G, nz, diag\+\_\+cs)
\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a902b3d966dae0a8f0011d98d8697e22d}{downsample\+\_\+diag\+\_\+indices\+\_\+get}} (fo1, fo2, dl, diag\+\_\+cs, isv, iev, jsv, jev)
\begin{DoxyCompactList}\small\item\em Get the diagnostics-\/compute indices (to be passed to send\+\_\+data) based on the shape of the diag field (the same way they are deduced for non-\/downsampled fields) \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a30395d7b955b819afa3942700dedead1}{downsample\+\_\+diag\+\_\+field\+\_\+3d}} (locfield, locfield\+\_\+dsamp, dl, diag\+\_\+cs, diag, isv, iev, jsv, jev, mask)
\begin{DoxyCompactList}\small\item\em This subroutine allocates and computes a downsampled array from an input array It also determines the diagnostics-\/compurte indices for the downsampled array 3d interface. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_ac19dd9879fd5c480c4bd27d6e7b8c0cf}{downsample\+\_\+diag\+\_\+field\+\_\+2d}} (locfield, locfield\+\_\+dsamp, dl, diag\+\_\+cs, diag, isv, iev, jsv, jev, mask)
\begin{DoxyCompactList}\small\item\em This subroutine allocates and computes a downsampled array from an input array It also determines the diagnostics-\/compurte indices for the downsampled array 2d interface. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a640ec8fac9bad1d0af6f737d7e816403}{downsample\+\_\+field\+\_\+3d}} (field\+\_\+in, field\+\_\+out, dl, method, mask, diag\+\_\+cs, diag, isv\+\_\+o, jsv\+\_\+o, isv\+\_\+d, iev\+\_\+d, jsv\+\_\+d, jev\+\_\+d)
\begin{DoxyCompactList}\small\item\em This subroutine allocates and computes a down sampled 3d array given an input array The down sample method is based on the \char`\"{}cell\+\_\+methods\char`\"{} for the diagnostics as explained in the above table. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_aa46e12f1318ed96f60035cdd32e4157a}{downsample\+\_\+field\+\_\+2d}} (field\+\_\+in, field\+\_\+out, dl, method, mask, diag\+\_\+cs, diag, isv\+\_\+o, jsv\+\_\+o, isv\+\_\+d, iev\+\_\+d, jsv\+\_\+d, jev\+\_\+d)
\begin{DoxyCompactList}\small\item\em This subroutine allocates and computes a down sampled 2d array given an input array The down sample method is based on the \char`\"{}cell\+\_\+methods\char`\"{} for the diagnostics as explained in the above table. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a8e211bead8fe3f37da32dfa010b55b90}{downsample\+\_\+mask\+\_\+2d}} (field\+\_\+in, field\+\_\+out, dl, isc\+\_\+o, jsc\+\_\+o, isc\+\_\+d, iec\+\_\+d, jsc\+\_\+d, jec\+\_\+d, isd\+\_\+d, ied\+\_\+d, jsd\+\_\+d, jed\+\_\+d)
\begin{DoxyCompactList}\small\item\em Allocate and compute the 2d down sampled mask The masks are down sampled based on a minority rule, i.\+e., a coarse cell is open (1) if at least one of the sub-\/cells are open, otherwise it\textquotesingle{}s closed (0) \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__diag__mediator_a0b0fe5fefbf6a1e9a5b1642f5852cdb6}{downsample\+\_\+mask\+\_\+3d}} (field\+\_\+in, field\+\_\+out, dl, isc\+\_\+o, jsc\+\_\+o, isc\+\_\+d, iec\+\_\+d, jsc\+\_\+d, jec\+\_\+d, isd\+\_\+d, ied\+\_\+d, jsd\+\_\+d, jed\+\_\+d)
\begin{DoxyCompactList}\small\item\em Allocate and compute the 3d down sampled mask The masks are down sampled based on a minority rule, i.\+e., a coarse cell is open (1) if at least one of the sub-\/cells are open, otherwise it\textquotesingle{}s closed (0) \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a3247fad19fce000fcb4af1a3cf21a3f2}\label{namespacemom__diag__mediator_a3247fad19fce000fcb4af1a3cf21a3f2}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a3247fad19fce000fcb4af1a3cf21a3f2}{psp}} =121
\begin{DoxyCompactList}\small\item\em x\+:point,y\+:sum,z\+:point \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a2f079e2e2550b5ec1887179c37e5cce5}\label{namespacemom__diag__mediator_a2f079e2e2550b5ec1887179c37e5cce5}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a2f079e2e2550b5ec1887179c37e5cce5}{pss}} =122
\begin{DoxyCompactList}\small\item\em x\+:point,y\+:sum,z\+:point \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a0614439e5299ca5d575bc820ec697b4a}\label{namespacemom__diag__mediator_a0614439e5299ca5d575bc820ec697b4a}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a0614439e5299ca5d575bc820ec697b4a}{psm}} =123
\begin{DoxyCompactList}\small\item\em x\+:point,y\+:sum,z\+:mean \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a17abc676880db0f0ce2764d01161e216}\label{namespacemom__diag__mediator_a17abc676880db0f0ce2764d01161e216}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a17abc676880db0f0ce2764d01161e216}{pmp}} =131
\begin{DoxyCompactList}\small\item\em x\+:point,y\+:mean,z\+:point \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a7730b6ffaeb382cbe497cd9772b858fc}\label{namespacemom__diag__mediator_a7730b6ffaeb382cbe497cd9772b858fc}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a7730b6ffaeb382cbe497cd9772b858fc}{pmm}} =133
\begin{DoxyCompactList}\small\item\em x\+:point,y\+:mean,z\+:mean \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_acaa7d531b586a9217d5a8e6f25023c91}\label{namespacemom__diag__mediator_acaa7d531b586a9217d5a8e6f25023c91}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_acaa7d531b586a9217d5a8e6f25023c91}{spp}} =211
\begin{DoxyCompactList}\small\item\em x\+:sum,y\+:point,z\+:point \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_aae1bf1b1fd0d54e8d0cf13c4aca9f689}\label{namespacemom__diag__mediator_aae1bf1b1fd0d54e8d0cf13c4aca9f689}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_aae1bf1b1fd0d54e8d0cf13c4aca9f689}{sps}} =212
\begin{DoxyCompactList}\small\item\em x\+:sum,y\+:point,z\+:sum \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_ab60866bce3c6b88951f1cedb5a4c319b}\label{namespacemom__diag__mediator_ab60866bce3c6b88951f1cedb5a4c319b}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_ab60866bce3c6b88951f1cedb5a4c319b}{ssp}} =221
\begin{DoxyCompactList}\small\item\em x\+:sum;y\+:sum,z\+:point \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a374b829068930f39f211bbc74c550d73}\label{namespacemom__diag__mediator_a374b829068930f39f211bbc74c550d73}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a374b829068930f39f211bbc74c550d73}{mpp}} =311
\begin{DoxyCompactList}\small\item\em x\+:mean,y\+:point,z\+:point \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_af4984649b7e1a295998abb48415fad5c}\label{namespacemom__diag__mediator_af4984649b7e1a295998abb48415fad5c}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_af4984649b7e1a295998abb48415fad5c}{mpm}} =313
\begin{DoxyCompactList}\small\item\em x\+:mean,y\+:point,z\+:mean \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_aaf71efbbdb0b8287772a119750e5127e}\label{namespacemom__diag__mediator_aaf71efbbdb0b8287772a119750e5127e}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_aaf71efbbdb0b8287772a119750e5127e}{mmp}} =331
\begin{DoxyCompactList}\small\item\em x\+:mean,y\+:mean,z\+:point \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a2f08495ffe07bb4ee3f5f11e4432f7e6}\label{namespacemom__diag__mediator_a2f08495ffe07bb4ee3f5f11e4432f7e6}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a2f08495ffe07bb4ee3f5f11e4432f7e6}{mms}} =332
\begin{DoxyCompactList}\small\item\em x\+:mean,y\+:mean,z\+:sum \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_ac603c1e0276955bd0dff297f71a63629}\label{namespacemom__diag__mediator_ac603c1e0276955bd0dff297f71a63629}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_ac603c1e0276955bd0dff297f71a63629}{sss}} =222
\begin{DoxyCompactList}\small\item\em x\+:sum,y\+:sum,z\+:sum \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a54cd7394f3ad400f4a19155e313bcd22}\label{namespacemom__diag__mediator_a54cd7394f3ad400f4a19155e313bcd22}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a54cd7394f3ad400f4a19155e313bcd22}{mmm}} =333
\begin{DoxyCompactList}\small\item\em x\+:mean,y\+:mean,z\+:mean \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_aee297aa161d60188320e803751df9ce4}\label{namespacemom__diag__mediator_aee297aa161d60188320e803751df9ce4}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_aee297aa161d60188320e803751df9ce4}{msk}} =-\/1
\begin{DoxyCompactList}\small\item\em Use the downsample method of a mask. \end{DoxyCompactList}\end{DoxyCompactItemize}
\textbf{ }\par
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a882fc994662be43d067bb1f59a2662bb}\label{namespacemom__diag__mediator_a882fc994662be43d067bb1f59a2662bb}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a882fc994662be43d067bb1f59a2662bb}{id\+\_\+clock\+\_\+diag\+\_\+mediator}}
\begin{DoxyCompactList}\small\item\em C\+PU clocks. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_a8a8e75119f340f174cfef580ded1dd79}\label{namespacemom__diag__mediator_a8a8e75119f340f174cfef580ded1dd79}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_a8a8e75119f340f174cfef580ded1dd79}{id\+\_\+clock\+\_\+diag\+\_\+remap}}
\begin{DoxyCompactList}\small\item\em C\+PU clocks. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__diag__mediator_affaf7f9c1f9fc0c35f4a41c9b30b04e6}\label{namespacemom__diag__mediator_affaf7f9c1f9fc0c35f4a41c9b30b04e6}} 
integer \mbox{\hyperlink{namespacemom__diag__mediator_affaf7f9c1f9fc0c35f4a41c9b30b04e6}{id\+\_\+clock\+\_\+diag\+\_\+grid\+\_\+updates}}
\begin{DoxyCompactList}\small\item\em C\+PU clocks. \end{DoxyCompactList}\end{DoxyCompactItemize}



\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__diag__mediator_a8415b33a337b1fbc7535688eca85ab37}\label{namespacemom__diag__mediator_a8415b33a337b1fbc7535688eca85ab37}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!add\+\_\+diag\+\_\+to\+\_\+list@{add\+\_\+diag\+\_\+to\+\_\+list}}
\index{add\+\_\+diag\+\_\+to\+\_\+list@{add\+\_\+diag\+\_\+to\+\_\+list}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{add\+\_\+diag\+\_\+to\+\_\+list()}{add\_diag\_to\_list()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::add\+\_\+diag\+\_\+to\+\_\+list (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), pointer}]{diag\+\_\+cs,  }\item[{integer, intent(inout)}]{dm\+\_\+id,  }\item[{integer, intent(in)}]{fms\+\_\+id,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), pointer}]{this\+\_\+diag,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(in), target}]{axes,  }\item[{character(len=$\ast$), intent(in)}]{module\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{field\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{msg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Create a diagnostic type and attached to list. 


\begin{DoxyParams}[1]{Parameters}
 & {\em diag\+\_\+cs} & Diagnostics mediator control structure\\
\hline
\mbox{\tt in,out}  & {\em dm\+\_\+id} & The diag\+\_\+mediator ID for this diagnostic group\\
\hline
\mbox{\tt in}  & {\em fms\+\_\+id} & The F\+MS diag\+\_\+manager ID for this diagnostic\\
\hline
 & {\em this\+\_\+diag} & This diagnostic\\
\hline
\mbox{\tt in}  & {\em axes} & Container w/ up to 3 integer handles that indicates axes for this field\\
\hline
\mbox{\tt in}  & {\em module\+\_\+name} & Name of this module, usually \char`\"{}ocean\+\_\+model\char`\"{} or \char`\"{}ice\+\_\+shelf\+\_\+model\char`\"{}\\
\hline
\mbox{\tt in}  & {\em field\+\_\+name} & Name of diagnostic\\
\hline
\mbox{\tt in}  & {\em msg} & Message for errors \\
\hline
\end{DoxyParams}


Definition at line 2454 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2454   \textcolor{keywordtype}{type}(diag\_ctrl),        \textcolor{keywordtype}{pointer}       :: diag\_cs\textcolor{comment}{ !< Diagnostics mediator control structure}
2455   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(inout)} :: dm\_id\textcolor{comment}{ !< The diag\_mediator ID for this diagnostic group}
2456   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)}    :: fms\_id\textcolor{comment}{ !< The FMS diag\_manager ID for this diagnostic}
2457   \textcolor{keywordtype}{type}(diag\_type),        \textcolor{keywordtype}{pointer}       :: this\_diag\textcolor{comment}{ !< This diagnostic}
2458   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: axes\textcolor{comment}{ !< Container w/ up to 3 integer handles that}
2459 \textcolor{comment}{                                                !! indicates axes for this field}
2460   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: module\_name\textcolor{comment}{ !< Name of this module, usually}
2461 \textcolor{comment}{                                                       !! "ocean\_model" or "ice\_shelf\_model"}
2462   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: field\_name\textcolor{comment}{ !< Name of diagnostic}
2463   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: msg\textcolor{comment}{ !< Message for errors}
2464 
2465   \textcolor{comment}{! If the diagnostic is needed obtain a diag\_mediator ID (if needed)}
2466   \textcolor{keywordflow}{if} (dm\_id == -1) dm\_id = get\_new\_diag\_id(diag\_cs)
2467   \textcolor{comment}{! Create a new diag\_type to store links in}
2468   \textcolor{keyword}{call }alloc\_diag\_with\_id(dm\_id, diag\_cs, this\_diag)
2469   \textcolor{keyword}{call }assert(\textcolor{keyword}{associated}(this\_diag), trim(msg)//\textcolor{stringliteral}{': diag\_type allocation failed'})
2470   \textcolor{comment}{! Record FMS id, masks and conversion factor, in diag\_type}
2471   this\_diag%fms\_diag\_id = fms\_id
2472   this\_diag%debug\_str = trim(module\_name)//\textcolor{stringliteral}{"-"}//trim(field\_name)
2473   this\_diag%axes => axes
2474 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a14d405e0958e6e58797253c52c666cdb}\label{namespacemom__diag__mediator_a14d405e0958e6e58797253c52c666cdb}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!add\+\_\+xyz\+\_\+method@{add\+\_\+xyz\+\_\+method}}
\index{add\+\_\+xyz\+\_\+method@{add\+\_\+xyz\+\_\+method}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{add\+\_\+xyz\+\_\+method()}{add\_xyz\_method()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::add\+\_\+xyz\+\_\+method (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), pointer}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(in)}]{axes,  }\item[{character(len=$\ast$), intent(in), optional}]{x\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{y\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{v\+\_\+cell\+\_\+method,  }\item[{logical, intent(in), optional}]{v\+\_\+extensive }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Adds the encoded \char`\"{}cell\+\_\+methods\char`\"{} for a diagnostics as a diag\% property This allows access to the cell\+\_\+method for a given diagnostics at the time of sending. 


\begin{DoxyParams}[1]{Parameters}
 & {\em diag} & This diagnostic\\
\hline
\mbox{\tt in}  & {\em axes} & Container w/ up to 3 integer handles that indicates axes for this field\\
\hline
\mbox{\tt in}  & {\em x\+\_\+cell\+\_\+method} & Specifies the cell method for the x-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em y\+\_\+cell\+\_\+method} & Specifies the cell method for the y-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em v\+\_\+cell\+\_\+method} & Specifies the cell method for the vertical direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em v\+\_\+extensive} & True for vertically extensive fields (vertically integrated). Default/absent for intensive. \\
\hline
\end{DoxyParams}


Definition at line 2480 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2480   \textcolor{keywordtype}{type}(diag\_type),          \textcolor{keywordtype}{pointer}       :: diag\textcolor{comment}{ !< This diagnostic}
2481   \textcolor{keywordtype}{type}(axes\_grp),             \textcolor{keywordtype}{intent(in)}  :: axes\textcolor{comment}{ !< Container w/ up to 3 integer handles that indicates}
2482 \textcolor{comment}{                                                  !! axes for this field}
2483   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: x\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the
       x-direction.}
2484 \textcolor{comment}{                                                         !! Use '' have no method.}
2485   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: y\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the
       y-direction.}
2486 \textcolor{comment}{                                                         !! Use '' have no method.}
2487   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: v\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the vertical
       direction.}
2488 \textcolor{comment}{                                                         !! Use '' have no method.}
2489   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: v\_extensive\textcolor{comment}{ !< True for vertically extensive fields}
2490 \textcolor{comment}{                                                         !! (vertically integrated). Default/absent for
       intensive.}
2491   \textcolor{keywordtype}{integer} :: xyz\_method
2492   \textcolor{keywordtype}{character(len=9)} :: mstr
2493 
2494   \textcolor{comment}{!This is a simple way to encode the cell method information made from 3 strings}
2495   \textcolor{comment}{!(x\_cell\_method,y\_cell\_method,v\_cell\_method) in a 3 digit integer xyz}
2496   \textcolor{comment}{!x\_cell\_method,y\_cell\_method,v\_cell\_method can each be 'point' or 'sum' or 'mean'}
2497   \textcolor{comment}{!We can encode these with setting  1 for 'point', 2 for 'sum, 3 for 'mean' in}
2498   \textcolor{comment}{!the 100s position for x, 10s position for y, 1s position for z}
2499   \textcolor{comment}{!E.g., x:sum,y:point,z:mean is 213}
2500 
2501   xyz\_method = 111
2502 
2503   mstr = diag%axes%v\_cell\_method
2504   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_extensive)) \textcolor{keywordflow}{then}
2505      \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_cell\_method)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"attach\_cell\_methods: "} // &
2506           \textcolor{stringliteral}{'Vertical cell method was specified along with the vertically extensive flag.'})
2507      \textcolor{keywordflow}{if}(v\_extensive) \textcolor{keywordflow}{then}
2508         mstr=\textcolor{stringliteral}{'sum'}
2509      \textcolor{keywordflow}{else}
2510         mstr=\textcolor{stringliteral}{'mean'}
2511 \textcolor{keywordflow}{     endif}
2512   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(v\_cell\_method)) \textcolor{keywordflow}{then}
2513      mstr = v\_cell\_method
2514 \textcolor{keywordflow}{  endif}
2515   \textcolor{keywordflow}{if} (trim(mstr)==\textcolor{stringliteral}{'sum'}) \textcolor{keywordflow}{then}
2516      xyz\_method = xyz\_method + 1
2517   \textcolor{keywordflow}{elseif} (trim(mstr)==\textcolor{stringliteral}{'mean'}) \textcolor{keywordflow}{then}
2518      xyz\_method = xyz\_method + 2
2519 \textcolor{keywordflow}{  endif}
2520 
2521   mstr = diag%axes%y\_cell\_method
2522   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(y\_cell\_method)) mstr = y\_cell\_method
2523   \textcolor{keywordflow}{if} (trim(mstr)==\textcolor{stringliteral}{'sum'}) \textcolor{keywordflow}{then}
2524      xyz\_method = xyz\_method + 10
2525   \textcolor{keywordflow}{elseif} (trim(mstr)==\textcolor{stringliteral}{'mean'}) \textcolor{keywordflow}{then}
2526      xyz\_method = xyz\_method + 20
2527 \textcolor{keywordflow}{  endif}
2528 
2529   mstr = diag%axes%x\_cell\_method
2530   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(x\_cell\_method)) mstr = x\_cell\_method
2531   \textcolor{keywordflow}{if} (trim(mstr)==\textcolor{stringliteral}{'sum'}) \textcolor{keywordflow}{then}
2532      xyz\_method = xyz\_method + 100
2533   \textcolor{keywordflow}{elseif} (trim(mstr)==\textcolor{stringliteral}{'mean'}) \textcolor{keywordflow}{then}
2534      xyz\_method = xyz\_method + 200
2535 \textcolor{keywordflow}{  endif}
2536 
2537   diag%xyz\_method = xyz\_method
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a1b0bed2113a0c268eafd1bafbb48bd4f}\label{namespacemom__diag__mediator_a1b0bed2113a0c268eafd1bafbb48bd4f}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!alloc\+\_\+diag\+\_\+with\+\_\+id@{alloc\+\_\+diag\+\_\+with\+\_\+id}}
\index{alloc\+\_\+diag\+\_\+with\+\_\+id@{alloc\+\_\+diag\+\_\+with\+\_\+id}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{alloc\+\_\+diag\+\_\+with\+\_\+id()}{alloc\_diag\_with\_id()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::alloc\+\_\+diag\+\_\+with\+\_\+id (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{diag\+\_\+id,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout), target}]{diag\+\_\+cs,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), pointer}]{diag }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Make a new diagnostic. Either use memory which is in the array of \textquotesingle{}primary\textquotesingle{} diagnostics, or if that is in use, insert it to the list of secondary diags. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+id} & id for the diagnostic\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & structure used to regulate diagnostic output\\
\hline
 & {\em diag} & structure representing a diagnostic (inout) \\
\hline
\end{DoxyParams}


Definition at line 3523 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3523   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in   )} :: diag\_id\textcolor{comment}{ !< id for the diagnostic}
3524   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{ !< structure used to regulate diagnostic output}
3525   \textcolor{keywordtype}{type}(diag\_type),         \textcolor{keywordtype}{pointer}       :: diag\textcolor{comment}{    !< structure representing a diagnostic (inout)}
3526 
3527   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: tmp => null()
3528 
3529   \textcolor{keywordflow}{if} (.not. diag\_cs%diags(diag\_id)%in\_use) \textcolor{keywordflow}{then}
3530     diag => diag\_cs%diags(diag\_id)
3531   \textcolor{keywordflow}{else}
3532     \textcolor{keyword}{allocate}(diag)
3533     tmp => diag\_cs%diags(diag\_id)%next
3534     diag\_cs%diags(diag\_id)%next => diag
3535     diag%next => tmp
3536 \textcolor{keywordflow}{  endif}
3537   diag%in\_use = .true.
3538 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ae0f04c145cb120fc2ab6cbfe9f166392}\label{namespacemom__diag__mediator_ae0f04c145cb120fc2ab6cbfe9f166392}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!attach\+\_\+cell\+\_\+methods@{attach\+\_\+cell\+\_\+methods}}
\index{attach\+\_\+cell\+\_\+methods@{attach\+\_\+cell\+\_\+methods}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{attach\+\_\+cell\+\_\+methods()}{attach\_cell\_methods()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::attach\+\_\+cell\+\_\+methods (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{id,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(in)}]{axes,  }\item[{character(len=$\ast$), intent(out)}]{ostring,  }\item[{character(len=$\ast$), intent(in), optional}]{cell\+\_\+methods,  }\item[{character(len=$\ast$), intent(in), optional}]{x\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{y\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{v\+\_\+cell\+\_\+method,  }\item[{logical, intent(in), optional}]{v\+\_\+extensive }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Attaches \char`\"{}cell\+\_\+methods\char`\"{} attribute to a variable based on defaults for \mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}} or optional arguments. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em id} & Handle to diagnostic\\
\hline
\mbox{\tt in}  & {\em axes} & Container w/ up to 3 integer handles that indicates axes for this field\\
\hline
\mbox{\tt out}  & {\em ostring} & The cell\+\_\+methods strings that would appear in the file\\
\hline
\mbox{\tt in}  & {\em cell\+\_\+methods} & String to append as cell\+\_\+methods attribute. Use \textquotesingle{}\textquotesingle{} to have no attribute. If present, this overrides the default constructed from the default for each individual axis direction.\\
\hline
\mbox{\tt in}  & {\em x\+\_\+cell\+\_\+method} & Specifies the cell method for the x-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em y\+\_\+cell\+\_\+method} & Specifies the cell method for the y-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em v\+\_\+cell\+\_\+method} & Specifies the cell method for the vertical direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em v\+\_\+extensive} & True for vertically extensive fields (vertically integrated). Default/absent for intensive. \\
\hline
\end{DoxyParams}


Definition at line 2543 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2543   \textcolor{keywordtype}{integer},                    \textcolor{keywordtype}{intent(in)}  :: id\textcolor{comment}{ !< Handle to diagnostic}
2544   \textcolor{keywordtype}{type}(axes\_grp),             \textcolor{keywordtype}{intent(in)}  :: axes\textcolor{comment}{ !< Container w/ up to 3 integer handles that indicates}
2545 \textcolor{comment}{                                                  !! axes for this field}
2546   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(out)} :: ostring\textcolor{comment}{ !< The cell\_methods strings that would appear in the
       file}
2547   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: cell\_methods\textcolor{comment}{ !< String to append as cell\_methods attribute.}
2548 \textcolor{comment}{                                                         !! Use '' to have no attribute. If present, this}
2549 \textcolor{comment}{                                                         !! overrides the default constructed from the
       default}
2550 \textcolor{comment}{                                                         !! for each individual axis direction.}
2551   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: x\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the
       x-direction.}
2552 \textcolor{comment}{                                                         !! Use '' have no method.}
2553   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: y\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the
       y-direction.}
2554 \textcolor{comment}{                                                         !! Use '' have no method.}
2555   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: v\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the vertical
       direction.}
2556 \textcolor{comment}{                                                         !! Use '' have no method.}
2557   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: v\_extensive\textcolor{comment}{ !< True for vertically extensive fields}
2558 \textcolor{comment}{                                                         !! (vertically integrated). Default/absent for
       intensive.}
2559   \textcolor{comment}{! Local variables}
2560   \textcolor{keywordtype}{character(len=9)} :: axis\_name
2561   \textcolor{keywordtype}{logical} :: x\_mean, y\_mean, x\_sum, y\_sum
2562 
2563   x\_mean = .false.
2564   y\_mean = .false.
2565   x\_sum = .false.
2566   y\_sum = .false.
2567 
2568   ostring = \textcolor{stringliteral}{''}
2569   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cell\_methods)) \textcolor{keywordflow}{then}
2570     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(x\_cell\_method) .or. \textcolor{keyword}{present}(y\_cell\_method) .or. \textcolor{keyword}{present}(v\_cell\_method) &
2571         .or. \textcolor{keyword}{present}(v\_extensive)) \textcolor{keywordflow}{then}
2572       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"attach\_cell\_methods: "} // &
2573            \textcolor{stringliteral}{'Individual direction cell method was specified along with a "cell\_methods" string.'})
2574 \textcolor{keywordflow}{    endif}
2575     \textcolor{keywordflow}{if} (len(trim(cell\_methods))>0) \textcolor{keywordflow}{then}
2576       \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(cell\_methods))
2577       ostring = trim(cell\_methods)
2578 \textcolor{keywordflow}{    endif}
2579   \textcolor{keywordflow}{else}
2580     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(x\_cell\_method)) \textcolor{keywordflow}{then}
2581       \textcolor{keywordflow}{if} (len(trim(x\_cell\_method))>0) \textcolor{keywordflow}{then}
2582         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(1), axis\_name)
2583         \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(x\_cell\_method))
2584         ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' '}//trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(x\_cell\_method)
2585         \textcolor{keywordflow}{if} (trim(x\_cell\_method)==\textcolor{stringliteral}{'mean'}) x\_mean=.true.
2586         \textcolor{keywordflow}{if} (trim(x\_cell\_method)==\textcolor{stringliteral}{'sum'}) x\_sum=.true.
2587 \textcolor{keywordflow}{      endif}
2588     \textcolor{keywordflow}{else}
2589       \textcolor{keywordflow}{if} (len(trim(axes%x\_cell\_method))>0) \textcolor{keywordflow}{then}
2590         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(1), axis\_name)
2591         \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(axes%x\_cell\_method))
2592         ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' '}//trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(axes%x\_cell\_method)
2593         \textcolor{keywordflow}{if} (trim(axes%x\_cell\_method)==\textcolor{stringliteral}{'mean'}) x\_mean=.true.
2594         \textcolor{keywordflow}{if} (trim(axes%x\_cell\_method)==\textcolor{stringliteral}{'sum'}) x\_sum=.true.
2595 \textcolor{keywordflow}{      endif}
2596 \textcolor{keywordflow}{    endif}
2597     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(y\_cell\_method)) \textcolor{keywordflow}{then}
2598       \textcolor{keywordflow}{if} (len(trim(y\_cell\_method))>0) \textcolor{keywordflow}{then}
2599         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(2), axis\_name)
2600         \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(y\_cell\_method))
2601         ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' '}//trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(y\_cell\_method)
2602         \textcolor{keywordflow}{if} (trim(y\_cell\_method)==\textcolor{stringliteral}{'mean'}) y\_mean=.true.
2603         \textcolor{keywordflow}{if} (trim(y\_cell\_method)==\textcolor{stringliteral}{'sum'}) y\_sum=.true.
2604 \textcolor{keywordflow}{      endif}
2605     \textcolor{keywordflow}{else}
2606       \textcolor{keywordflow}{if} (len(trim(axes%y\_cell\_method))>0) \textcolor{keywordflow}{then}
2607         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(2), axis\_name)
2608         \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(axes%y\_cell\_method))
2609         ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' '}//trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(axes%y\_cell\_method)
2610         \textcolor{keywordflow}{if} (trim(axes%y\_cell\_method)==\textcolor{stringliteral}{'mean'}) y\_mean=.true.
2611         \textcolor{keywordflow}{if} (trim(axes%y\_cell\_method)==\textcolor{stringliteral}{'sum'}) y\_sum=.true.
2612 \textcolor{keywordflow}{      endif}
2613 \textcolor{keywordflow}{    endif}
2614     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_cell\_method)) \textcolor{keywordflow}{then}
2615       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_extensive)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"attach\_cell\_methods: "} // &
2616            \textcolor{stringliteral}{'Vertical cell method was specified along with the vertically extensive flag.'})
2617       \textcolor{keywordflow}{if} (len(trim(v\_cell\_method))>0) \textcolor{keywordflow}{then}
2618         \textcolor{keywordflow}{if} (axes%rank==1) \textcolor{keywordflow}{then}
2619           \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(1), axis\_name)
2620         \textcolor{keywordflow}{elseif} (axes%rank==3) \textcolor{keywordflow}{then}
2621           \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(3), axis\_name)
2622 \textcolor{keywordflow}{        endif}
2623         \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(v\_cell\_method))
2624         ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' '}//trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(v\_cell\_method)
2625 \textcolor{keywordflow}{      endif}
2626     \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(v\_extensive)) \textcolor{keywordflow}{then}
2627      \textcolor{keywordflow}{if}(v\_extensive) \textcolor{keywordflow}{then}
2628       \textcolor{keywordflow}{if} (axes%rank==1) \textcolor{keywordflow}{then}
2629         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(1), axis\_name)
2630       \textcolor{keywordflow}{elseif} (axes%rank==3) \textcolor{keywordflow}{then}
2631         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(3), axis\_name)
2632 \textcolor{keywordflow}{      endif}
2633       \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':sum'})
2634       ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' '}//trim(axis\_name)//\textcolor{stringliteral}{':sum'}
2635 \textcolor{keywordflow}{     endif}
2636     \textcolor{keywordflow}{else}
2637       \textcolor{keywordflow}{if} (len(trim(axes%v\_cell\_method))>0) \textcolor{keywordflow}{then}
2638         \textcolor{keywordflow}{if} (axes%rank==1) \textcolor{keywordflow}{then}
2639           \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(1), axis\_name)
2640         \textcolor{keywordflow}{elseif} (axes%rank==3) \textcolor{keywordflow}{then}
2641           \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(3), axis\_name)
2642 \textcolor{keywordflow}{        endif}
2643         \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(axes%v\_cell\_method))
2644         ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' '}//trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(axes%v\_cell\_method)
2645 \textcolor{keywordflow}{      endif}
2646 \textcolor{keywordflow}{    endif}
2647     \textcolor{keywordflow}{if} (x\_mean .and. y\_mean) \textcolor{keywordflow}{then}
2648       \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, \textcolor{stringliteral}{'area:mean'})
2649       ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' area:mean'}
2650     \textcolor{keywordflow}{elseif} (x\_sum .and. y\_sum) \textcolor{keywordflow}{then}
2651       \textcolor{keyword}{call }diag\_field\_add\_attribute(id, \textcolor{stringliteral}{'cell\_methods'}, \textcolor{stringliteral}{'area:sum'})
2652       ostring = trim(adjustl(ostring))//\textcolor{stringliteral}{' area:sum'}
2653 \textcolor{keywordflow}{    endif}
2654 \textcolor{keywordflow}{  endif}
2655   ostring = adjustl(ostring)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ab9f767ec24a860cb71cae264560272a8}\label{namespacemom__diag__mediator_ab9f767ec24a860cb71cae264560272a8}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!define\+\_\+axes\+\_\+group@{define\+\_\+axes\+\_\+group}}
\index{define\+\_\+axes\+\_\+group@{define\+\_\+axes\+\_\+group}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{define\+\_\+axes\+\_\+group()}{define\_axes\_group()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::define\+\_\+axes\+\_\+group (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag\+\_\+cs,  }\item[{integer, dimension(\+:), intent(in)}]{handles,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(out)}]{axes,  }\item[{integer, intent(in), optional}]{nz,  }\item[{integer, intent(in), optional}]{vertical\+\_\+coordinate\+\_\+number,  }\item[{character(len=$\ast$), intent(in), optional}]{x\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{y\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{v\+\_\+cell\+\_\+method,  }\item[{logical, intent(in), optional}]{is\+\_\+h\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+q\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+u\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+v\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+layer,  }\item[{logical, intent(in), optional}]{is\+\_\+interface,  }\item[{logical, intent(in), optional}]{is\+\_\+native,  }\item[{logical, intent(in), optional}]{needs\+\_\+remapping,  }\item[{logical, intent(in), optional}]{needs\+\_\+interpolating,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), optional, target}]{xyave\+\_\+axes }\end{DoxyParamCaption})}



Defines a group of \char`\"{}axes\char`\"{} from list of handles. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+cs} & Diagnostics control structure\\
\hline
\mbox{\tt in}  & {\em handles} & A list of 1D axis handles\\
\hline
\mbox{\tt out}  & {\em axes} & The group of 1D axes\\
\hline
\mbox{\tt in}  & {\em nz} & Number of layers in this diagnostic grid\\
\hline
\mbox{\tt in}  & {\em vertical\+\_\+coordinate\+\_\+number} & Index number for vertical coordinate\\
\hline
\mbox{\tt in}  & {\em x\+\_\+cell\+\_\+method} & A x-\/direction cell method used to construct the \char`\"{}cell\+\_\+methods\char`\"{} attribute in CF convention\\
\hline
\mbox{\tt in}  & {\em y\+\_\+cell\+\_\+method} & A y-\/direction cell method used to construct the \char`\"{}cell\+\_\+methods\char`\"{} attribute in CF convention\\
\hline
\mbox{\tt in}  & {\em v\+\_\+cell\+\_\+method} & A vertical direction cell method used to construct the \char`\"{}cell\+\_\+methods\char`\"{} attribute in CF convention\\
\hline
\mbox{\tt in}  & {\em is\+\_\+h\+\_\+point} & If true, indicates this axes group for h-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+q\+\_\+point} & If true, indicates this axes group for q-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+u\+\_\+point} & If true, indicates this axes group for u-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+v\+\_\+point} & If true, indicates this axes group for v-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+layer} & If true, indicates that this axes group is for a layer vertically-\/located field.\\
\hline
\mbox{\tt in}  & {\em is\+\_\+interface} & If true, indicates that this axes group is for an interface vertically-\/located field.\\
\hline
\mbox{\tt in}  & {\em is\+\_\+native} & If true, indicates that this axes group is for a native model grid. False for any other grid.\\
\hline
\mbox{\tt in}  & {\em needs\+\_\+remapping} & If true, indicates that this axes group is for a intensive layer-\/located field that must be remapped to these axes. Used for rank$>$2.\\
\hline
\mbox{\tt in}  & {\em needs\+\_\+interpolating} & If true, indicates that this axes group is for a sampled interface-\/located field that must be interpolated to these axes. Used for rank$>$2.\\
\hline
 & {\em xyave\+\_\+axes} & The corresponding axes group for horizontally area-\/average diagnostics \\
\hline
\end{DoxyParams}


Definition at line 1001 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1001   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},    \textcolor{keywordtype}{intent(in)}  :: diag\_cs\textcolor{comment}{ !< Diagnostics control structure}
1002   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)},      \textcolor{keywordtype}{intent(in)}  :: handles\textcolor{comment}{ !< A list of 1D axis handles}
1003   \textcolor{keywordtype}{type}(axes\_grp),             \textcolor{keywordtype}{intent(out)} :: axes\textcolor{comment}{    !< The group of 1D axes}
1004   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: nz\textcolor{comment}{      !< Number of layers in this diagnostic grid}
1005   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: vertical\_coordinate\_number\textcolor{comment}{ !< Index number for vertical
       coordinate}
1006   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: x\_cell\_method\textcolor{comment}{ !< A x-direction cell method used to construct
       the}
1007 \textcolor{comment}{                                                           !! "cell\_methods" attribute in CF convention}
1008   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: y\_cell\_method\textcolor{comment}{ !< A y-direction cell method used to construct
       the}
1009 \textcolor{comment}{                                                           !! "cell\_methods" attribute in CF convention}
1010   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: v\_cell\_method\textcolor{comment}{ !< A vertical direction cell method used to
       construct}
1011 \textcolor{comment}{                                                        !! the "cell\_methods" attribute in CF convention}
1012   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_h\_point\textcolor{comment}{ !< If true, indicates this axes group for h-point}
1013 \textcolor{comment}{                                                        !! located fields}
1014   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_q\_point\textcolor{comment}{ !< If true, indicates this axes group for q-point}
1015 \textcolor{comment}{                                                        !! located fields}
1016   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_u\_point\textcolor{comment}{ !< If true, indicates this axes group for}
1017 \textcolor{comment}{                                                        !! u-point located fields}
1018   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_v\_point\textcolor{comment}{ !< If true, indicates this axes group for}
1019 \textcolor{comment}{                                                        !! v-point located fields}
1020   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_layer\textcolor{comment}{   !< If true, indicates that this axes group is}
1021 \textcolor{comment}{                                                        !! for a layer vertically-located field.}
1022   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_interface\textcolor{comment}{ !< If true, indicates that this axes group}
1023 \textcolor{comment}{                                                        !! is for an interface vertically-located field.}
1024   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_native\textcolor{comment}{  !< If true, indicates that this axes group is}
1025 \textcolor{comment}{                                                        !! for a native model grid. False for any other
       grid.}
1026   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: needs\_remapping\textcolor{comment}{ !< If true, indicates that this axes group is}
1027 \textcolor{comment}{                                                        !! for a intensive layer-located field that must}
1028 \textcolor{comment}{                                                        !! be remapped to these axes. Used for rank>2.}
1029   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: needs\_interpolating\textcolor{comment}{ !< If true, indicates that this axes group}
1030 \textcolor{comment}{                                                        !! is for a sampled interface-located field that
       must}
1031 \textcolor{comment}{                                                        !! be interpolated to these axes. Used for rank>2.}
1032   \textcolor{keywordtype}{type}(axes\_grp),   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{target}      :: xyave\_axes\textcolor{comment}{ !< The corresponding axes group for horizontally}
1033 \textcolor{comment}{                                                        !! area-average diagnostics}
1034   \textcolor{comment}{! Local variables}
1035   \textcolor{keywordtype}{integer} :: n
1036 
1037   n = \textcolor{keyword}{size}(handles)
1038   \textcolor{keywordflow}{if} (n<1 .or. n>3) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"define\_axes\_group: wrong size for list of handles!"})
1039   \textcolor{keyword}{allocate}( axes%handles(n) )
1040   axes%id = i2s(handles, n) \textcolor{comment}{! Identifying string}
1041   axes%rank = n
1042   axes%handles(:) = handles(:)
1043   axes%diag\_cs => diag\_cs \textcolor{comment}{! A [circular] link back to the diag\_cs structure}
1044   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(x\_cell\_method)) \textcolor{keywordflow}{then}
1045     \textcolor{keywordflow}{if} (axes%rank<2) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'define\_axes\_group: '} // &
1046                                            \textcolor{stringliteral}{'Can not set x\_cell\_method for rank<2.'})
1047     axes%x\_cell\_method = trim(x\_cell\_method)
1048   \textcolor{keywordflow}{else}
1049     axes%x\_cell\_method = \textcolor{stringliteral}{''}
1050 \textcolor{keywordflow}{  endif}
1051   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(y\_cell\_method)) \textcolor{keywordflow}{then}
1052     \textcolor{keywordflow}{if} (axes%rank<2) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'define\_axes\_group: '} // &
1053                                            \textcolor{stringliteral}{'Can not set y\_cell\_method for rank<2.'})
1054     axes%y\_cell\_method = trim(y\_cell\_method)
1055   \textcolor{keywordflow}{else}
1056     axes%y\_cell\_method = \textcolor{stringliteral}{''}
1057 \textcolor{keywordflow}{  endif}
1058   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_cell\_method)) \textcolor{keywordflow}{then}
1059     \textcolor{keywordflow}{if} (axes%rank/=1 .and. axes%rank/=3) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'define\_axes\_group: '} // &
1060                                            \textcolor{stringliteral}{'Can not set v\_cell\_method for rank<>1 or 3.'})
1061     axes%v\_cell\_method = trim(v\_cell\_method)
1062   \textcolor{keywordflow}{else}
1063     axes%v\_cell\_method = \textcolor{stringliteral}{''}
1064 \textcolor{keywordflow}{  endif}
1065   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(nz)) axes%nz = nz
1066   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(vertical\_coordinate\_number)) axes%vertical\_coordinate\_number = vertical\_coordinate\_number
1067   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_h\_point)) axes%is\_h\_point = is\_h\_point
1068   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_q\_point)) axes%is\_q\_point = is\_q\_point
1069   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_u\_point)) axes%is\_u\_point = is\_u\_point
1070   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_v\_point)) axes%is\_v\_point = is\_v\_point
1071   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_layer)) axes%is\_layer = is\_layer
1072   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_interface)) axes%is\_interface = is\_interface
1073   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_native)) axes%is\_native = is\_native
1074   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(needs\_remapping)) axes%needs\_remapping = needs\_remapping
1075   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(needs\_interpolating)) axes%needs\_interpolating = needs\_interpolating
1076   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(xyave\_axes)) axes%xyave\_axes => xyave\_axes
1077 
1078   \textcolor{comment}{! Setup masks for this axes group}
1079   axes%mask2d => null()
1080   \textcolor{keywordflow}{if} (axes%rank==2) \textcolor{keywordflow}{then}
1081     \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%mask2d => diag\_cs%mask2dT
1082     \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%mask2d => diag\_cs%mask2dCu
1083     \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%mask2d => diag\_cs%mask2dCv
1084     \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%mask2d => diag\_cs%mask2dBu
1085 \textcolor{keywordflow}{  endif}
1086   \textcolor{comment}{! A static 3d mask for non-native coordinates can only be setup when a grid is available}
1087   axes%mask3d => null()
1088   \textcolor{keywordflow}{if} (axes%rank==3 .and. axes%is\_native) \textcolor{keywordflow}{then}
1089     \textcolor{comment}{! Native variables can/should use the native masks copied into diag\_cs}
1090     \textcolor{keywordflow}{if} (axes%is\_layer) \textcolor{keywordflow}{then}
1091       \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%mask3d => diag\_cs%mask3dTL
1092       \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%mask3d => diag\_cs%mask3dCuL
1093       \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%mask3d => diag\_cs%mask3dCvL
1094       \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%mask3d => diag\_cs%mask3dBL
1095     \textcolor{keywordflow}{elseif} (axes%is\_interface) \textcolor{keywordflow}{then}
1096       \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%mask3d => diag\_cs%mask3dTi
1097       \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%mask3d => diag\_cs%mask3dCui
1098       \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%mask3d => diag\_cs%mask3dCvi
1099       \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%mask3d => diag\_cs%mask3dBi
1100 \textcolor{keywordflow}{    endif}
1101 \textcolor{keywordflow}{  endif}
1102 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a51129041d5b42f6546c087111465f639}\label{namespacemom__diag__mediator_a51129041d5b42f6546c087111465f639}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!define\+\_\+axes\+\_\+group\+\_\+dsamp@{define\+\_\+axes\+\_\+group\+\_\+dsamp}}
\index{define\+\_\+axes\+\_\+group\+\_\+dsamp@{define\+\_\+axes\+\_\+group\+\_\+dsamp}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{define\+\_\+axes\+\_\+group\+\_\+dsamp()}{define\_axes\_group\_dsamp()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::define\+\_\+axes\+\_\+group\+\_\+dsamp (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag\+\_\+cs,  }\item[{integer, dimension(\+:), intent(in)}]{handles,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(out)}]{axes,  }\item[{integer, intent(in)}]{dl,  }\item[{integer, intent(in), optional}]{nz,  }\item[{integer, intent(in), optional}]{vertical\+\_\+coordinate\+\_\+number,  }\item[{character(len=$\ast$), intent(in), optional}]{x\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{y\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{v\+\_\+cell\+\_\+method,  }\item[{logical, intent(in), optional}]{is\+\_\+h\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+q\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+u\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+v\+\_\+point,  }\item[{logical, intent(in), optional}]{is\+\_\+layer,  }\item[{logical, intent(in), optional}]{is\+\_\+interface,  }\item[{logical, intent(in), optional}]{is\+\_\+native,  }\item[{logical, intent(in), optional}]{needs\+\_\+remapping,  }\item[{logical, intent(in), optional}]{needs\+\_\+interpolating,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), optional, target}]{xyave\+\_\+axes }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Defines a group of downsampled \char`\"{}axes\char`\"{} from list of handles. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+cs} & Diagnostics control structure\\
\hline
\mbox{\tt in}  & {\em handles} & A list of 1D axis handles\\
\hline
\mbox{\tt out}  & {\em axes} & The group of 1D axes\\
\hline
\mbox{\tt in}  & {\em dl} & Downsample level\\
\hline
\mbox{\tt in}  & {\em nz} & Number of layers in this diagnostic grid\\
\hline
\mbox{\tt in}  & {\em vertical\+\_\+coordinate\+\_\+number} & Index number for vertical coordinate\\
\hline
\mbox{\tt in}  & {\em x\+\_\+cell\+\_\+method} & A x-\/direction cell method used to construct the \char`\"{}cell\+\_\+methods\char`\"{} attribute in CF convention\\
\hline
\mbox{\tt in}  & {\em y\+\_\+cell\+\_\+method} & A y-\/direction cell method used to construct the \char`\"{}cell\+\_\+methods\char`\"{} attribute in CF convention\\
\hline
\mbox{\tt in}  & {\em v\+\_\+cell\+\_\+method} & A vertical direction cell method used to construct the \char`\"{}cell\+\_\+methods\char`\"{} attribute in CF convention\\
\hline
\mbox{\tt in}  & {\em is\+\_\+h\+\_\+point} & If true, indicates this axes group for h-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+q\+\_\+point} & If true, indicates this axes group for q-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+u\+\_\+point} & If true, indicates this axes group for u-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+v\+\_\+point} & If true, indicates this axes group for v-\/point located fields\\
\hline
\mbox{\tt in}  & {\em is\+\_\+layer} & If true, indicates that this axes group is for a layer vertically-\/located field.\\
\hline
\mbox{\tt in}  & {\em is\+\_\+interface} & If true, indicates that this axes group is for an interface vertically-\/located field.\\
\hline
\mbox{\tt in}  & {\em is\+\_\+native} & If true, indicates that this axes group is for a native model grid. False for any other grid.\\
\hline
\mbox{\tt in}  & {\em needs\+\_\+remapping} & If true, indicates that this axes group is for a intensive layer-\/located field that must be remapped to these axes. Used for rank$>$2.\\
\hline
\mbox{\tt in}  & {\em needs\+\_\+interpolating} & If true, indicates that this axes group is for a sampled interface-\/located field that must be interpolated to these axes. Used for rank$>$2.\\
\hline
 & {\em xyave\+\_\+axes} & The corresponding axes group for horizontally area-\/average diagnostics \\
\hline
\end{DoxyParams}


Definition at line 1112 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1112   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},    \textcolor{keywordtype}{intent(in)}  :: diag\_cs\textcolor{comment}{ !< Diagnostics control structure}
1113   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)},      \textcolor{keywordtype}{intent(in)}  :: handles\textcolor{comment}{ !< A list of 1D axis handles}
1114   \textcolor{keywordtype}{type}(axes\_grp),             \textcolor{keywordtype}{intent(out)} :: axes\textcolor{comment}{    !< The group of 1D axes}
1115   \textcolor{keywordtype}{integer},                    \textcolor{keywordtype}{intent(in)}  :: dl\textcolor{comment}{      !< Downsample level}
1116   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: nz\textcolor{comment}{      !< Number of layers in this diagnostic grid}
1117   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: vertical\_coordinate\_number\textcolor{comment}{ !< Index number for vertical
       coordinate}
1118   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: x\_cell\_method\textcolor{comment}{ !< A x-direction cell method used to construct
       the}
1119 \textcolor{comment}{                                                           !! "cell\_methods" attribute in CF convention}
1120   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: y\_cell\_method\textcolor{comment}{ !< A y-direction cell method used to construct
       the}
1121 \textcolor{comment}{                                                           !! "cell\_methods" attribute in CF convention}
1122   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: v\_cell\_method\textcolor{comment}{ !< A vertical direction cell method used to
       construct}
1123 \textcolor{comment}{                                                        !! the "cell\_methods" attribute in CF convention}
1124   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_h\_point\textcolor{comment}{ !< If true, indicates this axes group for h-point}
1125 \textcolor{comment}{                                                        !! located fields}
1126   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_q\_point\textcolor{comment}{ !< If true, indicates this axes group for q-point}
1127 \textcolor{comment}{                                                        !! located fields}
1128   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_u\_point\textcolor{comment}{ !< If true, indicates this axes group for}
1129 \textcolor{comment}{                                                        !! u-point located fields}
1130   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_v\_point\textcolor{comment}{ !< If true, indicates this axes group for}
1131 \textcolor{comment}{                                                        !! v-point located fields}
1132   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_layer\textcolor{comment}{   !< If true, indicates that this axes group is}
1133 \textcolor{comment}{                                                        !! for a layer vertically-located field.}
1134   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_interface\textcolor{comment}{ !< If true, indicates that this axes group}
1135 \textcolor{comment}{                                                        !! is for an interface vertically-located field.}
1136   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: is\_native\textcolor{comment}{  !< If true, indicates that this axes group is}
1137 \textcolor{comment}{                                                        !! for a native model grid. False for any other
       grid.}
1138   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: needs\_remapping\textcolor{comment}{ !< If true, indicates that this axes group is}
1139 \textcolor{comment}{                                                        !! for a intensive layer-located field that must}
1140 \textcolor{comment}{                                                        !! be remapped to these axes. Used for rank>2.}
1141   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: needs\_interpolating\textcolor{comment}{ !< If true, indicates that this axes group}
1142 \textcolor{comment}{                                                        !! is for a sampled interface-located field that
       must}
1143 \textcolor{comment}{                                                        !! be interpolated to these axes. Used for rank>2.}
1144   \textcolor{keywordtype}{type}(axes\_grp),   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{target}      :: xyave\_axes\textcolor{comment}{ !< The corresponding axes group for horizontally}
1145 \textcolor{comment}{                                                        !! area-average diagnostics}
1146   \textcolor{comment}{! Local variables}
1147   \textcolor{keywordtype}{integer} :: n
1148 
1149   n = \textcolor{keyword}{size}(handles)
1150   \textcolor{keywordflow}{if} (n<1 .or. n>3) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"define\_axes\_group: wrong size for list of handles!"})
1151   \textcolor{keyword}{allocate}( axes%handles(n) )
1152   axes%id = i2s(handles, n) \textcolor{comment}{! Identifying string}
1153   axes%rank = n
1154   axes%handles(:) = handles(:)
1155   axes%diag\_cs => diag\_cs \textcolor{comment}{! A [circular] link back to the diag\_cs structure}
1156   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(x\_cell\_method)) \textcolor{keywordflow}{then}
1157     \textcolor{keywordflow}{if} (axes%rank<2) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'define\_axes\_group: '} // &
1158                                            \textcolor{stringliteral}{'Can not set x\_cell\_method for rank<2.'})
1159     axes%x\_cell\_method = trim(x\_cell\_method)
1160   \textcolor{keywordflow}{else}
1161     axes%x\_cell\_method = \textcolor{stringliteral}{''}
1162 \textcolor{keywordflow}{  endif}
1163   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(y\_cell\_method)) \textcolor{keywordflow}{then}
1164     \textcolor{keywordflow}{if} (axes%rank<2) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'define\_axes\_group: '} // &
1165                                            \textcolor{stringliteral}{'Can not set y\_cell\_method for rank<2.'})
1166     axes%y\_cell\_method = trim(y\_cell\_method)
1167   \textcolor{keywordflow}{else}
1168     axes%y\_cell\_method = \textcolor{stringliteral}{''}
1169 \textcolor{keywordflow}{  endif}
1170   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_cell\_method)) \textcolor{keywordflow}{then}
1171     \textcolor{keywordflow}{if} (axes%rank/=1 .and. axes%rank/=3) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'define\_axes\_group: '} // &
1172                                            \textcolor{stringliteral}{'Can not set v\_cell\_method for rank<>1 or 3.'})
1173     axes%v\_cell\_method = trim(v\_cell\_method)
1174   \textcolor{keywordflow}{else}
1175     axes%v\_cell\_method = \textcolor{stringliteral}{''}
1176 \textcolor{keywordflow}{  endif}
1177   axes%downsample\_level = dl
1178   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(nz)) axes%nz = nz
1179   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(vertical\_coordinate\_number)) axes%vertical\_coordinate\_number = vertical\_coordinate\_number
1180   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_h\_point)) axes%is\_h\_point = is\_h\_point
1181   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_q\_point)) axes%is\_q\_point = is\_q\_point
1182   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_u\_point)) axes%is\_u\_point = is\_u\_point
1183   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_v\_point)) axes%is\_v\_point = is\_v\_point
1184   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_layer)) axes%is\_layer = is\_layer
1185   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_interface)) axes%is\_interface = is\_interface
1186   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_native)) axes%is\_native = is\_native
1187   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(needs\_remapping)) axes%needs\_remapping = needs\_remapping
1188   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(needs\_interpolating)) axes%needs\_interpolating = needs\_interpolating
1189   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(xyave\_axes)) axes%xyave\_axes => xyave\_axes
1190 
1191   \textcolor{comment}{! Setup masks for this axes group}
1192 
1193   axes%mask2d => null()
1194   \textcolor{keywordflow}{if} (axes%rank==2) \textcolor{keywordflow}{then}
1195     \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%mask2d => diag\_cs%mask2dT
1196     \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%mask2d => diag\_cs%mask2dCu
1197     \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%mask2d => diag\_cs%mask2dCv
1198     \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%mask2d => diag\_cs%mask2dBu
1199 \textcolor{keywordflow}{  endif}
1200   \textcolor{comment}{! A static 3d mask for non-native coordinates can only be setup when a grid is available}
1201   axes%mask3d => null()
1202   \textcolor{keywordflow}{if} (axes%rank==3 .and. axes%is\_native) \textcolor{keywordflow}{then}
1203     \textcolor{comment}{! Native variables can/should use the native masks copied into diag\_cs}
1204     \textcolor{keywordflow}{if} (axes%is\_layer) \textcolor{keywordflow}{then}
1205       \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%mask3d => diag\_cs%mask3dTL
1206       \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%mask3d => diag\_cs%mask3dCuL
1207       \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%mask3d => diag\_cs%mask3dCvL
1208       \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%mask3d => diag\_cs%mask3dBL
1209     \textcolor{keywordflow}{elseif} (axes%is\_interface) \textcolor{keywordflow}{then}
1210       \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%mask3d => diag\_cs%mask3dTi
1211       \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%mask3d => diag\_cs%mask3dCui
1212       \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%mask3d => diag\_cs%mask3dCvi
1213       \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%mask3d => diag\_cs%mask3dBi
1214 \textcolor{keywordflow}{    endif}
1215 \textcolor{keywordflow}{  endif}
1216 
1217   axes%dsamp(dl)%mask2d => null()
1218   \textcolor{keywordflow}{if} (axes%rank==2) \textcolor{keywordflow}{then}
1219     \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%dsamp(dl)%mask2d => diag\_cs%dsamp(dl)%mask2dT
1220     \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%dsamp(dl)%mask2d => diag\_cs%dsamp(dl)%mask2dCu
1221     \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%dsamp(dl)%mask2d => diag\_cs%dsamp(dl)%mask2dCv
1222     \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%dsamp(dl)%mask2d => diag\_cs%dsamp(dl)%mask2dBu
1223 \textcolor{keywordflow}{  endif}
1224   \textcolor{comment}{! A static 3d mask for non-native coordinates can only be setup when a grid is available}
1225   axes%dsamp(dl)%mask3d => null()
1226   \textcolor{keywordflow}{if} (axes%rank==3 .and. axes%is\_native) \textcolor{keywordflow}{then}
1227     \textcolor{comment}{! Native variables can/should use the native masks copied into diag\_cs}
1228     \textcolor{keywordflow}{if} (axes%is\_layer) \textcolor{keywordflow}{then}
1229       \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dTL
1230       \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dCuL
1231       \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dCvL
1232       \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dBL
1233     \textcolor{keywordflow}{elseif} (axes%is\_interface) \textcolor{keywordflow}{then}
1234       \textcolor{keywordflow}{if} (axes%is\_h\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dTi
1235       \textcolor{keywordflow}{if} (axes%is\_u\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dCui
1236       \textcolor{keywordflow}{if} (axes%is\_v\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dCvi
1237       \textcolor{keywordflow}{if} (axes%is\_q\_point) axes%dsamp(dl)%mask3d => diag\_cs%dsamp(dl)%mask3dBi
1238 \textcolor{keywordflow}{    endif}
1239 \textcolor{keywordflow}{  endif}
1240 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ae002ca447acba252bf7bdc042e75a01e}\label{namespacemom__diag__mediator_ae002ca447acba252bf7bdc042e75a01e}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!describe\+\_\+option@{describe\+\_\+option}}
\index{describe\+\_\+option@{describe\+\_\+option}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{describe\+\_\+option()}{describe\_option()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::describe\+\_\+option (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{opt\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{value,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+\+CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Describe an option setting in the diagnostic files. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em opt\+\_\+name} & The name of the option\\
\hline
\mbox{\tt in}  & {\em value} & A character string with the setting of the option.\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 2909 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2909   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: opt\_name\textcolor{comment}{ !< The name of the option}
2910   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: \textcolor{keywordtype}{value}\textcolor{comment}{   !< A character string with the setting of the option.}
2911   \textcolor{keywordtype}{type}(diag\_ctrl),  \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
2912 
2913   \textcolor{keywordtype}{character(len=240)} :: mesg
2914   \textcolor{keywordtype}{integer} :: len\_ind
2915 
2916   len\_ind = len\_trim(\textcolor{keywordtype}{value})  \textcolor{comment}{! Add error handling for long values?}
2917 
2918   mesg = \textcolor{stringliteral}{"    ! "}//trim(opt\_name)//\textcolor{stringliteral}{": "}//trim(\textcolor{keywordtype}{value})
2919   \textcolor{keyword}{write}(diag\_cs%available\_diag\_doc\_unit, \textcolor{stringliteral}{'(a)'}) trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a6affd997646a278d7fca03174a5a06ad}\label{namespacemom__diag__mediator_a6affd997646a278d7fca03174a5a06ad}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+associate\+\_\+volume\+\_\+cell\+\_\+measure@{diag\+\_\+associate\+\_\+volume\+\_\+cell\+\_\+measure}}
\index{diag\+\_\+associate\+\_\+volume\+\_\+cell\+\_\+measure@{diag\+\_\+associate\+\_\+volume\+\_\+cell\+\_\+measure}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+associate\+\_\+volume\+\_\+cell\+\_\+measure()}{diag\_associate\_volume\_cell\_measure()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+associate\+\_\+volume\+\_\+cell\+\_\+measure (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs,  }\item[{integer, intent(in)}]{id\+\_\+h\+\_\+volume }\end{DoxyParamCaption})}



Attaches the id of cell volumes to axes groups for use with cell\+\_\+measures. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Diagnostics control structure\\
\hline
\mbox{\tt in}  & {\em id\+\_\+h\+\_\+volume} & Diag\+\_\+manager id for volume of h-\/cells \\
\hline
\end{DoxyParams}


Definition at line 966 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
966   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{     !< Diagnostics control structure}
967   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)}    :: id\_h\_volume\textcolor{comment}{ !< Diag\_manager id for volume of h-cells}
968   \textcolor{comment}{! Local variables}
969   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: tmp => null()
970 
971   \textcolor{keywordflow}{if} (id\_h\_volume<=0) \textcolor{keywordflow}{return} \textcolor{comment}{! Do nothing}
972   diag\_cs%volume\_cell\_measure\_dm\_id = id\_h\_volume \textcolor{comment}{! Record for diag\_get\_volume\_cell\_measure\_dm\_id()}
973 
974   \textcolor{comment}{! Set the cell measure for this axes group to the FMS id in this coordinate system}
975   diag\_cs%diags(id\_h\_volume)%axes%id\_volume = diag\_cs%diags(id\_h\_volume)%fms\_diag\_id
976 
977   tmp => diag\_cs%diags(id\_h\_volume)%next \textcolor{comment}{! First item in the list, if any}
978   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (\textcolor{keyword}{associated}(tmp))
979     \textcolor{comment}{! Set the cell measure for this axes group to the FMS id in this coordinate system}
980     tmp%axes%id\_volume = tmp%fms\_diag\_id
981     tmp => tmp%next \textcolor{comment}{! Move to next axes group for this field}
982 \textcolor{keywordflow}{  enddo}
983 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a4c15fc11c4d220ebcdd38adb692950db}\label{namespacemom__diag__mediator_a4c15fc11c4d220ebcdd38adb692950db}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+copy\+\_\+diag\+\_\+to\+\_\+storage@{diag\+\_\+copy\+\_\+diag\+\_\+to\+\_\+storage}}
\index{diag\+\_\+copy\+\_\+diag\+\_\+to\+\_\+storage@{diag\+\_\+copy\+\_\+diag\+\_\+to\+\_\+storage}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+copy\+\_\+diag\+\_\+to\+\_\+storage()}{diag\_copy\_diag\_to\_storage()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+copy\+\_\+diag\+\_\+to\+\_\+storage (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__grid__storage}{diag\+\_\+grid\+\_\+storage}}), intent(inout)}]{grid\+\_\+storage,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h\+\_\+state,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag }\end{DoxyParamCaption})}



Copy from the main diagnostic arrays to the grid storage as well as the native thicknesses. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em grid\+\_\+storage} & Structure containing a snapshot of the target grids\\
\hline
\mbox{\tt in}  & {\em h\+\_\+state} & Current model thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em diag} & Diagnostic control structure used as the contructor \\
\hline
\end{DoxyParams}


Definition at line 3613 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3613   \textcolor{keywordtype}{type}(diag\_grid\_storage), \textcolor{keywordtype}{intent(inout)} :: grid\_storage\textcolor{comment}{ !< Structure containing a snapshot of the target
       grids}
3614   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(in)}    :: h\_state\textcolor{comment}{     !< Current model thicknesses [H ~> m or kg m-2]}
3615   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(in)}    :: diag\textcolor{comment}{     !< Diagnostic control structure used as the contructor}
3616 
3617   \textcolor{keywordtype}{integer} :: m
3618 
3619   \textcolor{comment}{! Don't do anything else if there are no remapped coordinates}
3620   \textcolor{keywordflow}{if} (grid\_storage%num\_diag\_coords < 1) \textcolor{keywordflow}{return}
3621 
3622   grid\_storage%h\_state(:,:,:) = h\_state(:,:,:)
3623   \textcolor{keywordflow}{do} m = 1,grid\_storage%num\_diag\_coords
3624     \textcolor{keywordflow}{if} (diag%diag\_remap\_cs(m)%nz > 0) &
3625       grid\_storage%diag\_grids(m)%h(:,:,:) = diag%diag\_remap\_cs(m)%h(:,:,:)
3626 \textcolor{keywordflow}{  enddo}
3627 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_acfce430f0605a56afdb438107afc0d47}\label{namespacemom__diag__mediator_acfce430f0605a56afdb438107afc0d47}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+copy\+\_\+storage\+\_\+to\+\_\+diag@{diag\+\_\+copy\+\_\+storage\+\_\+to\+\_\+diag}}
\index{diag\+\_\+copy\+\_\+storage\+\_\+to\+\_\+diag@{diag\+\_\+copy\+\_\+storage\+\_\+to\+\_\+diag}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+copy\+\_\+storage\+\_\+to\+\_\+diag()}{diag\_copy\_storage\_to\_diag()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+copy\+\_\+storage\+\_\+to\+\_\+diag (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__grid__storage}{diag\+\_\+grid\+\_\+storage}}), intent(in)}]{grid\+\_\+storage }\end{DoxyParamCaption})}



Copy from the stored diagnostic arrays to the main diagnostic grids. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag} & Diagnostic control structure used as the contructor\\
\hline
\mbox{\tt in}  & {\em grid\+\_\+storage} & Structure containing a snapshot of the target grids \\
\hline
\end{DoxyParams}


Definition at line 3632 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3632   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{     !< Diagnostic control structure used as the contructor}
3633   \textcolor{keywordtype}{type}(diag\_grid\_storage), \textcolor{keywordtype}{intent(in)}    :: grid\_storage\textcolor{comment}{ !< Structure containing a snapshot of the target
       grids}
3634 
3635   \textcolor{keywordtype}{integer} :: m
3636 
3637   \textcolor{comment}{! Don't do anything else if there are no remapped coordinates}
3638   \textcolor{keywordflow}{if} (grid\_storage%num\_diag\_coords < 1) \textcolor{keywordflow}{return}
3639 
3640   diag%diag\_grid\_overridden = .true.
3641   \textcolor{keywordflow}{do} m = 1,grid\_storage%num\_diag\_coords
3642     \textcolor{keywordflow}{if} (diag%diag\_remap\_cs(m)%nz > 0) &
3643       diag%diag\_remap\_cs(m)%h(:,:,:) = grid\_storage%diag\_grids(m)%h(:,:,:)
3644 \textcolor{keywordflow}{  enddo}
3645 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_aba626173ff1459bd423b1902425d1908}\label{namespacemom__diag__mediator_aba626173ff1459bd423b1902425d1908}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+get\+\_\+volume\+\_\+cell\+\_\+measure\+\_\+dm\+\_\+id@{diag\+\_\+get\+\_\+volume\+\_\+cell\+\_\+measure\+\_\+dm\+\_\+id}}
\index{diag\+\_\+get\+\_\+volume\+\_\+cell\+\_\+measure\+\_\+dm\+\_\+id@{diag\+\_\+get\+\_\+volume\+\_\+cell\+\_\+measure\+\_\+dm\+\_\+id}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+get\+\_\+volume\+\_\+cell\+\_\+measure\+\_\+dm\+\_\+id()}{diag\_get\_volume\_cell\_measure\_dm\_id()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+get\+\_\+volume\+\_\+cell\+\_\+measure\+\_\+dm\+\_\+id (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs }\end{DoxyParamCaption})}



Returns diag\+\_\+manager id for cell measure of h-\/cells. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+cs} & Diagnostics control structure \\
\hline
\end{DoxyParams}


Definition at line 988 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
988   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)} :: diag\_cs\textcolor{comment}{   !< Diagnostics control structure}
989 
990   diag\_get\_volume\_cell\_measure\_dm\_id = diag\_cs%volume\_cell\_measure\_dm\_id
991 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a4f82f684f05d581ea5b62a9c62a54af3}\label{namespacemom__diag__mediator_a4f82f684f05d581ea5b62a9c62a54af3}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+grid\+\_\+storage\+\_\+end@{diag\+\_\+grid\+\_\+storage\+\_\+end}}
\index{diag\+\_\+grid\+\_\+storage\+\_\+end@{diag\+\_\+grid\+\_\+storage\+\_\+end}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+grid\+\_\+storage\+\_\+end()}{diag\_grid\_storage\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+grid\+\_\+storage\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__grid__storage}{diag\+\_\+grid\+\_\+storage}}), intent(inout)}]{grid\+\_\+storage }\end{DoxyParamCaption})}



Deallocates the fields in the remapping fields container. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em grid\+\_\+storage} & Structure containing a snapshot of the target grids \\
\hline
\end{DoxyParams}


Definition at line 3683 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3683   \textcolor{keywordtype}{type}(diag\_grid\_storage), \textcolor{keywordtype}{intent(inout)} :: grid\_storage\textcolor{comment}{ !< Structure containing a snapshot of the target
       grids}
3684   \textcolor{comment}{! Local variables}
3685   \textcolor{keywordtype}{integer} :: m, nz
3686 
3687   \textcolor{comment}{! Don't do anything else if there are no remapped coordinates}
3688   \textcolor{keywordflow}{if} (grid\_storage%num\_diag\_coords < 1) \textcolor{keywordflow}{return}
3689 
3690   \textcolor{comment}{! Deallocate memory for the native space}
3691   \textcolor{keyword}{deallocate}(grid\_storage%h\_state)
3692   \textcolor{comment}{! Loop through and deallocate memory for the grid on each target coordinate}
3693   \textcolor{keywordflow}{do} m = 1, grid\_storage%num\_diag\_coords
3694     \textcolor{keyword}{deallocate}(grid\_storage%diag\_grids(m)%h)
3695 \textcolor{keywordflow}{  enddo}
3696   \textcolor{comment}{! Deallocate diagnostic remapping structures}
3697   \textcolor{keyword}{deallocate}(grid\_storage%diag\_grids)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a6f596247402f21fa60bfdf1e73c41044}\label{namespacemom__diag__mediator_a6f596247402f21fa60bfdf1e73c41044}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+grid\+\_\+storage\+\_\+init@{diag\+\_\+grid\+\_\+storage\+\_\+init}}
\index{diag\+\_\+grid\+\_\+storage\+\_\+init@{diag\+\_\+grid\+\_\+storage\+\_\+init}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+grid\+\_\+storage\+\_\+init()}{diag\_grid\_storage\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+grid\+\_\+storage\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__grid__storage}{diag\+\_\+grid\+\_\+storage}}), intent(inout)}]{grid\+\_\+storage,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag }\end{DoxyParamCaption})}



Allocates fields necessary to store diagnostic remapping fields. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em grid\+\_\+storage} & Structure containing a snapshot of the target grids\\
\hline
\mbox{\tt in}  & {\em g} & Horizontal grid\\
\hline
\mbox{\tt in}  & {\em diag} & Diagnostic control structure used as the contructor template for this routine \\
\hline
\end{DoxyParams}


Definition at line 3588 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3588   \textcolor{keywordtype}{type}(diag\_grid\_storage), \textcolor{keywordtype}{intent(inout)} :: grid\_storage\textcolor{comment}{ !< Structure containing a snapshot of the target
       grids}
3589   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{           !< Horizontal grid}
3590   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(in)}    :: diag\textcolor{comment}{        !< Diagnostic control structure used as the
       contructor}
3591 \textcolor{comment}{                                                        !! template for this routine}
3592 
3593   \textcolor{keywordtype}{integer} :: m, nz
3594   grid\_storage%num\_diag\_coords = diag%num\_diag\_coords
3595 
3596   \textcolor{comment}{! Don't do anything else if there are no remapped coordinates}
3597   \textcolor{keywordflow}{if} (grid\_storage%num\_diag\_coords < 1) \textcolor{keywordflow}{return}
3598 
3599   \textcolor{comment}{! Allocate memory for the native space}
3600   \textcolor{keyword}{allocate}(grid\_storage%h\_state(g%isd:g%ied,g%jsd:g%jed, g%ke))
3601   \textcolor{comment}{! Allocate diagnostic remapping structures}
3602   \textcolor{keyword}{allocate}(grid\_storage%diag\_grids(diag%num\_diag\_coords))
3603   \textcolor{comment}{! Loop through and allocate memory for the grid on each target coordinate}
3604   \textcolor{keywordflow}{do} m = 1, diag%num\_diag\_coords
3605     nz = diag%diag\_remap\_cs(m)%nz
3606     \textcolor{keyword}{allocate}(grid\_storage%diag\_grids(m)%h(g%isd:g%ied,g%jsd:g%jed, nz))
3607 \textcolor{keywordflow}{  enddo}
3608 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_aebf8dcc4bac8028f24a80fa5f1f1ca5b}\label{namespacemom__diag__mediator_aebf8dcc4bac8028f24a80fa5f1f1ca5b}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+masks\+\_\+set@{diag\+\_\+masks\+\_\+set}}
\index{diag\+\_\+masks\+\_\+set@{diag\+\_\+masks\+\_\+set}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+masks\+\_\+set()}{diag\_masks\_set()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+masks\+\_\+set (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in), target}]{G,  }\item[{integer, intent(in)}]{nz,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), pointer}]{diag\+\_\+cs }\end{DoxyParamCaption})}



Sets up the 2d and 3d masks for native diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean grid type.\\
\hline
\mbox{\tt in}  & {\em nz} & The number of layers in the model\textquotesingle{}s native grid.\\
\hline
 & {\em diag\+\_\+cs} & A pointer to a type with many variables used for diagnostics \\
\hline
\end{DoxyParams}


Definition at line 3344 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3344   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< The ocean grid type.}
3345   \textcolor{keywordtype}{integer},                       \textcolor{keywordtype}{intent(in)} :: nz\textcolor{comment}{ !< The number of layers in the model's native grid.}
3346   \textcolor{keywordtype}{type}(diag\_ctrl),               \textcolor{keywordtype}{pointer}    :: diag\_cs\textcolor{comment}{ !< A pointer to a type with many variables}
3347 \textcolor{comment}{                                                       !! used for diagnostics}
3348   \textcolor{comment}{! Local variables}
3349   \textcolor{keywordtype}{integer} :: k
3350 
3351   \textcolor{comment}{! 2d masks point to the model masks since they are identical}
3352   diag\_cs%mask2dT  => g%mask2dT
3353   diag\_cs%mask2dBu => g%mask2dBu
3354   diag\_cs%mask2dCu => g%mask2dCu
3355   diag\_cs%mask2dCv => g%mask2dCv
3356 
3357   \textcolor{comment}{! 3d native masks are needed by diag\_manager but the native variables}
3358   \textcolor{comment}{! can only be masked 2d - for ocean points, all layers exists.}
3359   \textcolor{keyword}{allocate}(diag\_cs%mask3dTL(g%isd:g%ied,g%jsd:g%jed,1:nz))
3360   \textcolor{keyword}{allocate}(diag\_cs%mask3dBL(g%IsdB:g%IedB,g%JsdB:g%JedB,1:nz))
3361   \textcolor{keyword}{allocate}(diag\_cs%mask3dCuL(g%IsdB:g%IedB,g%jsd:g%jed,1:nz))
3362   \textcolor{keyword}{allocate}(diag\_cs%mask3dCvL(g%isd:g%ied,g%JsdB:g%JedB,1:nz))
3363   \textcolor{keywordflow}{do} k=1,nz
3364     diag\_cs%mask3dTL(:,:,k) = diag\_cs%mask2dT(:,:)
3365     diag\_cs%mask3dBL(:,:,k) = diag\_cs%mask2dBu(:,:)
3366     diag\_cs%mask3dCuL(:,:,k) = diag\_cs%mask2dCu(:,:)
3367     diag\_cs%mask3dCvL(:,:,k) = diag\_cs%mask2dCv(:,:)
3368 \textcolor{keywordflow}{  enddo}
3369   \textcolor{keyword}{allocate}(diag\_cs%mask3dTi(g%isd:g%ied,g%jsd:g%jed,1:nz+1))
3370   \textcolor{keyword}{allocate}(diag\_cs%mask3dBi(g%IsdB:g%IedB,g%JsdB:g%JedB,1:nz+1))
3371   \textcolor{keyword}{allocate}(diag\_cs%mask3dCui(g%IsdB:g%IedB,g%jsd:g%jed,1:nz+1))
3372   \textcolor{keyword}{allocate}(diag\_cs%mask3dCvi(g%isd:g%ied,g%JsdB:g%JedB,1:nz+1))
3373   \textcolor{keywordflow}{do} k=1,nz+1
3374     diag\_cs%mask3dTi(:,:,k) = diag\_cs%mask2dT(:,:)
3375     diag\_cs%mask3dBi(:,:,k) = diag\_cs%mask2dBu(:,:)
3376     diag\_cs%mask3dCui(:,:,k) = diag\_cs%mask2dCu(:,:)
3377     diag\_cs%mask3dCvi(:,:,k) = diag\_cs%mask2dCv(:,:)
3378 \textcolor{keywordflow}{  enddo}
3379 
3380   \textcolor{comment}{!Allocate and initialize the downsampled masks}
3381   \textcolor{keyword}{call }downsample\_diag\_masks\_set(g, nz, diag\_cs)
3382 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ab6b7493efa5caee06547dafdba29361b}\label{namespacemom__diag__mediator_ab6b7493efa5caee06547dafdba29361b}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+mediator\+\_\+close\+\_\+registration@{diag\+\_\+mediator\+\_\+close\+\_\+registration}}
\index{diag\+\_\+mediator\+\_\+close\+\_\+registration@{diag\+\_\+mediator\+\_\+close\+\_\+registration}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+mediator\+\_\+close\+\_\+registration()}{diag\_mediator\_close\_registration()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+mediator\+\_\+close\+\_\+registration (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+\+CS }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 3386 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3386   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(inout)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
3387 
3388   \textcolor{keywordtype}{integer} :: i
3389 
3390   \textcolor{keywordflow}{if} (diag\_cs%available\_diag\_doc\_unit > -1) \textcolor{keywordflow}{then}
3391     \textcolor{keyword}{close}(diag\_cs%available\_diag\_doc\_unit) ; diag\_cs%available\_diag\_doc\_unit = -2
3392 \textcolor{keywordflow}{  endif}
3393 
3394   \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
3395     \textcolor{keyword}{call }diag\_remap\_diag\_registration\_closed(diag\_cs%diag\_remap\_cs(i))
3396 \textcolor{keywordflow}{  enddo}
3397 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a780f8870b442c730208d66d1ff0b4ac0}\label{namespacemom__diag__mediator_a780f8870b442c730208d66d1ff0b4ac0}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+mediator\+\_\+end@{diag\+\_\+mediator\+\_\+end}}
\index{diag\+\_\+mediator\+\_\+end@{diag\+\_\+mediator\+\_\+end}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+mediator\+\_\+end()}{diag\_mediator\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+mediator\+\_\+end (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{time,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+\+CS,  }\item[{logical, intent(in), optional}]{end\+\_\+diag\+\_\+manager }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & The current model time\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em end\+\_\+diag\+\_\+manager} & If true, call diag\+\_\+manager\+\_\+end() \\
\hline
\end{DoxyParams}


Definition at line 3401 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3401   \textcolor{keywordtype}{type}(time\_type),   \textcolor{keywordtype}{intent(in)}  :: time\textcolor{comment}{ !< The current model time}
3402   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(inout)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
3403   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: end\_diag\_manager\textcolor{comment}{ !< If true, call diag\_manager\_end()}
3404 
3405   \textcolor{comment}{! Local variables}
3406   \textcolor{keywordtype}{integer} :: i
3407 
3408   \textcolor{keywordflow}{if} (diag\_cs%available\_diag\_doc\_unit > -1) \textcolor{keywordflow}{then}
3409     \textcolor{keyword}{close}(diag\_cs%available\_diag\_doc\_unit) ; diag\_cs%available\_diag\_doc\_unit = -3
3410 \textcolor{keywordflow}{  endif}
3411   \textcolor{keywordflow}{if} (diag\_cs%chksum\_iounit > -1) \textcolor{keywordflow}{then}
3412     \textcolor{keyword}{close}(diag\_cs%chksum\_iounit) ; diag\_cs%chksum\_iounit = -3
3413 \textcolor{keywordflow}{  endif}
3414 
3415   \textcolor{keyword}{deallocate}(diag\_cs%diags)
3416 
3417   \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
3418     \textcolor{keyword}{call }diag\_remap\_end(diag\_cs%diag\_remap\_cs(i))
3419 \textcolor{keywordflow}{  enddo}
3420 
3421   \textcolor{keyword}{call }diag\_grid\_storage\_end(diag\_cs%diag\_grid\_temp)
3422   \textcolor{keyword}{deallocate}(diag\_cs%mask3dTL)
3423   \textcolor{keyword}{deallocate}(diag\_cs%mask3dBL)
3424   \textcolor{keyword}{deallocate}(diag\_cs%mask3dCuL)
3425   \textcolor{keyword}{deallocate}(diag\_cs%mask3dCvL)
3426   \textcolor{keyword}{deallocate}(diag\_cs%mask3dTi)
3427   \textcolor{keyword}{deallocate}(diag\_cs%mask3dBi)
3428   \textcolor{keyword}{deallocate}(diag\_cs%mask3dCui)
3429   \textcolor{keyword}{deallocate}(diag\_cs%mask3dCvi)
3430   \textcolor{keywordflow}{do} i=2,max\_dsamp\_lev
3431      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask2dT)
3432      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask2dBu)
3433      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask2dCu)
3434      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask2dCv)
3435      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dTL)
3436      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dBL)
3437      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dCuL)
3438      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dCvL)
3439      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dTi)
3440      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dBi)
3441      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dCui)
3442      \textcolor{keyword}{deallocate}(diag\_cs%dsamp(i)%mask3dCvi)
3443 \textcolor{keywordflow}{  enddo}
3444 
3445 \textcolor{preprocessor}{#if defined(DEBUG) || defined(\_\_DO\_SAFETY\_CHECKS\_\_)}
3446 \textcolor{preprocessor}{}  \textcolor{keyword}{deallocate}(diag\_cs%h\_old)
3447 \textcolor{preprocessor}{#endif}
3448 \textcolor{preprocessor}{}
3449   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(end\_diag\_manager)) \textcolor{keywordflow}{then}
3450     \textcolor{keywordflow}{if} (end\_diag\_manager) \textcolor{keyword}{call }diag\_manager\_end(time)
3451 \textcolor{keywordflow}{  endif}
3452 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ae8ac8a662308a9e766249fdf29956560}\label{namespacemom__diag__mediator_ae8ac8a662308a9e766249fdf29956560}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+mediator\+\_\+infrastructure\+\_\+init@{diag\+\_\+mediator\+\_\+infrastructure\+\_\+init}}
\index{diag\+\_\+mediator\+\_\+infrastructure\+\_\+init@{diag\+\_\+mediator\+\_\+infrastructure\+\_\+init}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+mediator\+\_\+infrastructure\+\_\+init()}{diag\_mediator\_infrastructure\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+mediator\+\_\+infrastructure\+\_\+init (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(out), optional}]{err\+\_\+msg }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt out}  & {\em err\+\_\+msg} & An error message \\
\hline
\end{DoxyParams}


Definition at line 3029 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3029   \textcolor{comment}{! This subroutine initializes the FMS diag\_manager.}
3030   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: err\_msg\textcolor{comment}{ !< An error message}
3031 
3032   \textcolor{keyword}{call }diag\_manager\_init(err\_msg=err\_msg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a3c99ff49de6d5e43f0d1bba79290eb71}\label{namespacemom__diag__mediator_a3c99ff49de6d5e43f0d1bba79290eb71}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+mediator\+\_\+init@{diag\+\_\+mediator\+\_\+init}}
\index{diag\+\_\+mediator\+\_\+init@{diag\+\_\+mediator\+\_\+init}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+mediator\+\_\+init()}{diag\_mediator\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+mediator\+\_\+init (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout), target}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in), target}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), target}]{US,  }\item[{integer, intent(in)}]{nz,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs,  }\item[{character(len=$\ast$), intent(in), optional}]{doc\+\_\+file\+\_\+dir }\end{DoxyParamCaption})}



diag\+\_\+mediator\+\_\+init initializes the M\+OM diag\+\_\+mediator and opens the available diagnostics file, if appropriate. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The ocean grid type.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em nz} & The number of layers in the model\textquotesingle{}s native grid.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & A pointer to a type with many variables used for diagnostics\\
\hline
\mbox{\tt in}  & {\em doc\+\_\+file\+\_\+dir} & A directory in which to create the file \\
\hline
\end{DoxyParams}


Definition at line 3038 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3038   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The ocean grid type.}
3039   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{ !< The ocean vertical grid structure}
3040   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}
3041   \textcolor{keywordtype}{integer},                    \textcolor{keywordtype}{intent(in)}    :: nz\textcolor{comment}{    !< The number of layers in the model's native grid.}
3042   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file structure}
3043   \textcolor{keywordtype}{type}(diag\_ctrl),            \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{ !< A pointer to a type with many variables}
3044 \textcolor{comment}{                                                     !! used for diagnostics}
3045   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: doc\_file\_dir\textcolor{comment}{ !< A directory in which to create the}
3046 \textcolor{comment}{                                                     !! file}
3047 
3048   \textcolor{comment}{! This subroutine initializes the diag\_mediator and the diag\_manager.}
3049   \textcolor{comment}{! The grid type should have its dimensions set by this point, but it}
3050   \textcolor{comment}{! is not necessary that the metrics and axis labels be set up yet.}
3051 
3052   \textcolor{comment}{! Local variables}
3053   \textcolor{keywordtype}{integer} :: ios, i, new\_unit
3054   \textcolor{keywordtype}{logical} :: opened, new\_file
3055   \textcolor{keywordtype}{logical} :: answers\_2018, default\_2018\_answers
3056   \textcolor{keywordtype}{character(len=8)}   :: this\_pe
3057   \textcolor{keywordtype}{character(len=240)} :: doc\_file, doc\_file\_dflt, doc\_path
3058   \textcolor{keywordtype}{character(len=240)}, \textcolor{keywordtype}{allocatable} :: diag\_coords(:)
3059   \textcolor{comment}{! This include declares and sets the variable "version".}
3060 \textcolor{preprocessor}{# include "version\_variable.h"}
3061 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)} :: mdl = \textcolor{stringliteral}{"MOM\_diag\_mediator"} \textcolor{comment}{! This module's name.}
3062   \textcolor{keywordtype}{character(len=32)} :: filename\_appendix = \textcolor{stringliteral}{''} \textcolor{comment}{!fms appendix to filename for ensemble runs}
3063 
3064   id\_clock\_diag\_mediator = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean diagnostics framework)'}, grain=clock\_module)
3065   id\_clock\_diag\_remap = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean diagnostics remapping)'}, grain=clock\_routine)
3066   id\_clock\_diag\_grid\_updates = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean diagnostics grid updates)'}, grain=clock\_routine)
3067 
3068   \textcolor{comment}{! Allocate and initialize list of all diagnostics (and variants)}
3069   \textcolor{keyword}{allocate}(diag\_cs%diags(diag\_alloc\_chunk\_size))
3070   diag\_cs%next\_free\_diag\_id = 1
3071   \textcolor{keywordflow}{do} i=1, diag\_alloc\_chunk\_size
3072     \textcolor{keyword}{call }initialize\_diag\_type(diag\_cs%diags(i))
3073 \textcolor{keywordflow}{  enddo}
3074 
3075   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
3076   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
3077 
3078   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'NUM\_DIAG\_COORDS'}, diag\_cs%num\_diag\_coords, &
3079                  \textcolor{stringliteral}{'The number of diagnostic vertical coordinates to use. '}//&
3080                  \textcolor{stringliteral}{'For each coordinate, an entry in DIAG\_COORDS must be provided.'}, &
3081                  default=1)
3082   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
3083                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
3084                  default=.false.)
3085   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, answers\_2018, &
3086                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//&
3087                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//&
3088                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
3089   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'USE\_GRID\_SPACE\_DIAGNOSTIC\_AXES'}, diag\_cs%grid\_space\_axes, &
3090                  \textcolor{stringliteral}{'If true, use a grid index coordinate convention for diagnostic axes. '},&
3091                  default=.false.)
3092 
3093   \textcolor{keywordflow}{if} (diag\_cs%num\_diag\_coords>0) \textcolor{keywordflow}{then}
3094     \textcolor{keyword}{allocate}(diag\_coords(diag\_cs%num\_diag\_coords))
3095     \textcolor{keywordflow}{if} (diag\_cs%num\_diag\_coords==1) \textcolor{keywordflow}{then} \textcolor{comment}{! The default is to provide just one instance of Z*}
3096       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'DIAG\_COORDS'}, diag\_coords, &
3097                  \textcolor{stringliteral}{'A list of string tuples associating diag\_table modules to '}//&
3098                  \textcolor{stringliteral}{'a coordinate definition used for diagnostics. Each string '}//&
3099                  \textcolor{stringliteral}{'is of the form "MODULE\_SUFFIX PARAMETER\_SUFFIX COORDINATE\_NAME".'}, &
3100                  default=\textcolor{stringliteral}{'z Z ZSTAR'})
3101     \textcolor{keywordflow}{else} \textcolor{comment}{! If using more than 1 diagnostic coordinate, all must be explicitly defined}
3102       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'DIAG\_COORDS'}, diag\_coords, &
3103                  \textcolor{stringliteral}{'A list of string tuples associating diag\_table modules to '}//&
3104                  \textcolor{stringliteral}{'a coordinate definition used for diagnostics. Each string '}//&
3105                  \textcolor{stringliteral}{'is of the form "MODULE\_SUFFIX,PARAMETER\_SUFFIX,COORDINATE\_NAME".'}, &
3106                  fail\_if\_missing=.true.)
3107 \textcolor{keywordflow}{    endif}
3108     \textcolor{keyword}{allocate}(diag\_cs%diag\_remap\_cs(diag\_cs%num\_diag\_coords))
3109     \textcolor{comment}{! Initialize each diagnostic vertical coordinate}
3110     \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
3111       \textcolor{keyword}{call }diag\_remap\_init(diag\_cs%diag\_remap\_cs(i), diag\_coords(i), answers\_2018=answers\_2018)
3112 \textcolor{keywordflow}{    enddo}
3113     \textcolor{keyword}{deallocate}(diag\_coords)
3114 \textcolor{keywordflow}{  endif}
3115 
3116   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'DIAG\_MISVAL'}, diag\_cs%missing\_value, &
3117                  \textcolor{stringliteral}{'Set the default missing value to use for diagnostics.'}, &
3118                  default=1.e20)
3119   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{'DIAG\_AS\_CHKSUM'}, diag\_cs%diag\_as\_chksum, &
3120                  \textcolor{stringliteral}{'Instead of writing diagnostics to the diag manager, write '}//&
3121                  \textcolor{stringliteral}{'a text file containing the checksum (bitcount) of the array.'},  &
3122                  default=.false.)
3123 
3124   \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) &
3125     diag\_cs%num\_chksum\_diags = 0
3126 
3127   \textcolor{comment}{! Keep pointers grid, h, T, S needed diagnostic remapping}
3128   diag\_cs%G => g
3129   diag\_cs%GV => gv
3130   diag\_cs%US => us
3131   diag\_cs%h => null()
3132   diag\_cs%T => null()
3133   diag\_cs%S => null()
3134   diag\_cs%eqn\_of\_state => null()
3135 
3136   \textcolor{keyword}{allocate}(diag\_cs%h\_begin(g%isd:g%ied,g%jsd:g%jed,nz))
3137 \textcolor{preprocessor}{#if defined(DEBUG) || defined(\_\_DO\_SAFETY\_CHECKS\_\_)}
3138 \textcolor{preprocessor}{}  \textcolor{keyword}{allocate}(diag\_cs%h\_old(g%isd:g%ied,g%jsd:g%jed,nz))
3139   diag\_cs%h\_old(:,:,:) = 0.0
3140 \textcolor{preprocessor}{#endif}
3141 \textcolor{preprocessor}{}
3142   diag\_cs%is = g%isc - (g%isd-1) ; diag\_cs%ie = g%iec - (g%isd-1)
3143   diag\_cs%js = g%jsc - (g%jsd-1) ; diag\_cs%je = g%jec - (g%jsd-1)
3144   diag\_cs%isd = g%isd ; diag\_cs%ied = g%ied
3145   diag\_cs%jsd = g%jsd ; diag\_cs%jed = g%jed
3146 
3147   \textcolor{comment}{!Downsample indices for dl=2 (should be generalized to arbitrary dl, perhaps via a G array)}
3148   diag\_cs%dsamp(2)%isc = g%HId2%isc - (g%HId2%isd-1) ; diag\_cs%dsamp(2)%iec = g%HId2%iec - (g%HId2%isd-1)
3149   diag\_cs%dsamp(2)%jsc = g%HId2%jsc - (g%HId2%jsd-1) ; diag\_cs%dsamp(2)%jec = g%HId2%jec - (g%HId2%jsd-1)
3150   diag\_cs%dsamp(2)%isd = g%HId2%isd ; diag\_cs%dsamp(2)%ied = g%HId2%ied
3151   diag\_cs%dsamp(2)%jsd = g%HId2%jsd ; diag\_cs%dsamp(2)%jed = g%HId2%jed
3152   diag\_cs%dsamp(2)%isg = g%HId2%isg ; diag\_cs%dsamp(2)%ieg = g%HId2%ieg
3153   diag\_cs%dsamp(2)%jsg = g%HId2%jsg ; diag\_cs%dsamp(2)%jeg = g%HId2%jeg
3154   diag\_cs%dsamp(2)%isgB = g%HId2%isgB ; diag\_cs%dsamp(2)%iegB = g%HId2%iegB
3155   diag\_cs%dsamp(2)%jsgB = g%HId2%jsgB ; diag\_cs%dsamp(2)%jegB = g%HId2%jegB
3156 
3157   \textcolor{comment}{! Initialze available diagnostic log file}
3158   \textcolor{keywordflow}{if} (is\_root\_pe() .and. (diag\_cs%available\_diag\_doc\_unit < 0)) \textcolor{keywordflow}{then}
3159     \textcolor{keyword}{write}(this\_pe,\textcolor{stringliteral}{'(i6.6)'}) pe\_here()
3160     doc\_file\_dflt = \textcolor{stringliteral}{"available\_diags."}//this\_pe
3161     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"AVAILABLE\_DIAGS\_FILE"}, doc\_file, &
3162                  \textcolor{stringliteral}{"A file into which to write a list of all available "}//&
3163                  \textcolor{stringliteral}{"ocean diagnostics that can be included in a diag\_table."}, &
3164                  default=doc\_file\_dflt, do\_not\_log=(diag\_cs%available\_diag\_doc\_unit/=-1))
3165     \textcolor{keywordflow}{if} (len\_trim(doc\_file) > 0) \textcolor{keywordflow}{then}
3166       new\_file = .true. ; \textcolor{keywordflow}{if} (diag\_cs%available\_diag\_doc\_unit /= -1) new\_file = .false.
3167     \textcolor{comment}{! Find an unused unit number.}
3168       \textcolor{keywordflow}{do} new\_unit=512,42,-1
3169         \textcolor{keyword}{inquire}( new\_unit, opened=opened)
3170         \textcolor{keywordflow}{if} (.not.opened) \textcolor{keywordflow}{exit}
3171 \textcolor{keywordflow}{      enddo}
3172       \textcolor{keywordflow}{if} (opened) \textcolor{keyword}{call }mom\_error(fatal, &
3173           \textcolor{stringliteral}{"diag\_mediator\_init failed to find an unused unit number."})
3174 
3175       doc\_path = doc\_file
3176       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(doc\_file\_dir)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (len\_trim(doc\_file\_dir) > 0) \textcolor{keywordflow}{then}
3177         doc\_path = trim(slasher(doc\_file\_dir))//trim(doc\_file)
3178 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ endif}
3179 
3180       diag\_cs%available\_diag\_doc\_unit = new\_unit
3181 
3182       \textcolor{keywordflow}{if} (new\_file) \textcolor{keywordflow}{then}
3183         \textcolor{keyword}{open}(diag\_cs%available\_diag\_doc\_unit, file=trim(doc\_path), access=\textcolor{stringliteral}{'SEQUENTIAL'}, form=\textcolor{stringliteral}{'FORMATTED'}, &
3184              action=\textcolor{stringliteral}{'WRITE'}, status=\textcolor{stringliteral}{'REPLACE'}, iostat=ios)
3185       \textcolor{keywordflow}{else} \textcolor{comment}{! This file is being reopened, and should be appended.}
3186         \textcolor{keyword}{open}(diag\_cs%available\_diag\_doc\_unit, file=trim(doc\_path), access=\textcolor{stringliteral}{'SEQUENTIAL'}, form=\textcolor{stringliteral}{'FORMATTED'}, &
3187              action=\textcolor{stringliteral}{'WRITE'}, status=\textcolor{stringliteral}{'OLD'}, position=\textcolor{stringliteral}{'APPEND'}, iostat=ios)
3188 \textcolor{keywordflow}{      endif}
3189       \textcolor{keyword}{inquire}(diag\_cs%available\_diag\_doc\_unit, opened=opened)
3190       \textcolor{keywordflow}{if} ((.not.opened) .or. (ios /= 0)) \textcolor{keywordflow}{then}
3191         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Failed to open available diags file "}//trim(doc\_path)//\textcolor{stringliteral}{"."})
3192 \textcolor{keywordflow}{      endif}
3193 \textcolor{keywordflow}{    endif}
3194 \textcolor{keywordflow}{  endif}
3195 
3196   \textcolor{keywordflow}{if} (is\_root\_pe() .and. (diag\_cs%chksum\_iounit < 0) .and. diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
3197     \textcolor{comment}{!write(this\_pe,'(i6.6)') PE\_here()}
3198     \textcolor{comment}{!doc\_file\_dflt = "chksum\_diag."//this\_pe}
3199     doc\_file\_dflt = \textcolor{stringliteral}{"chksum\_diag"}
3200     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CHKSUM\_DIAG\_FILE"}, doc\_file, &
3201                  \textcolor{stringliteral}{"A file into which to write all checksums of the "}//&
3202                  \textcolor{stringliteral}{"diagnostics listed in the diag\_table."}, &
3203                  default=doc\_file\_dflt, do\_not\_log=(diag\_cs%chksum\_iounit/=-1))
3204 
3205     \textcolor{keyword}{call }get\_filename\_appendix(filename\_appendix)
3206     \textcolor{keywordflow}{if} (len\_trim(filename\_appendix) > 0) \textcolor{keywordflow}{then}
3207       doc\_file = trim(doc\_file) //\textcolor{stringliteral}{'.'}//trim(filename\_appendix)
3208 \textcolor{keywordflow}{    endif}
3209 \textcolor{preprocessor}{#ifdef STATSLABEL}
3210 \textcolor{preprocessor}{}    doc\_file = trim(doc\_file)//\textcolor{stringliteral}{"."}//trim(adjustl(statslabel))
3211 \textcolor{preprocessor}{#endif}
3212 \textcolor{preprocessor}{}
3213     \textcolor{keywordflow}{if} (len\_trim(doc\_file) > 0) \textcolor{keywordflow}{then}
3214       new\_file = .true. ; \textcolor{keywordflow}{if} (diag\_cs%chksum\_iounit /= -1) new\_file = .false.
3215     \textcolor{comment}{! Find an unused unit number.}
3216       \textcolor{keywordflow}{do} new\_unit=512,42,-1
3217         \textcolor{keyword}{inquire}( new\_unit, opened=opened)
3218         \textcolor{keywordflow}{if} (.not.opened) \textcolor{keywordflow}{exit}
3219 \textcolor{keywordflow}{      enddo}
3220       \textcolor{keywordflow}{if} (opened) \textcolor{keyword}{call }mom\_error(fatal, &
3221           \textcolor{stringliteral}{"diag\_mediator\_init failed to find an unused unit number."})
3222 
3223       doc\_path = doc\_file
3224       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(doc\_file\_dir)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (len\_trim(doc\_file\_dir) > 0) \textcolor{keywordflow}{then}
3225         doc\_path = trim(slasher(doc\_file\_dir))//trim(doc\_file)
3226 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ endif}
3227 
3228       diag\_cs%chksum\_iounit = new\_unit
3229 
3230       \textcolor{keywordflow}{if} (new\_file) \textcolor{keywordflow}{then}
3231         \textcolor{keyword}{open}(diag\_cs%chksum\_iounit, file=trim(doc\_path), access=\textcolor{stringliteral}{'SEQUENTIAL'}, form=\textcolor{stringliteral}{'FORMATTED'}, &
3232              action=\textcolor{stringliteral}{'WRITE'}, status=\textcolor{stringliteral}{'REPLACE'}, iostat=ios)
3233       \textcolor{keywordflow}{else} \textcolor{comment}{! This file is being reopened, and should be appended.}
3234         \textcolor{keyword}{open}(diag\_cs%chksum\_iounit, file=trim(doc\_path), access=\textcolor{stringliteral}{'SEQUENTIAL'}, form=\textcolor{stringliteral}{'FORMATTED'}, &
3235              action=\textcolor{stringliteral}{'WRITE'}, status=\textcolor{stringliteral}{'OLD'}, position=\textcolor{stringliteral}{'APPEND'}, iostat=ios)
3236 \textcolor{keywordflow}{      endif}
3237       \textcolor{keyword}{inquire}(diag\_cs%chksum\_iounit, opened=opened)
3238       \textcolor{keywordflow}{if} ((.not.opened) .or. (ios /= 0)) \textcolor{keywordflow}{then}
3239         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Failed to open checksum diags file "}//trim(doc\_path)//\textcolor{stringliteral}{"."})
3240 \textcolor{keywordflow}{      endif}
3241 \textcolor{keywordflow}{    endif}
3242 \textcolor{keywordflow}{  endif}
3243 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a2795a8a8618f945a9a0830f461d3e42d}\label{namespacemom__diag__mediator_a2795a8a8618f945a9a0830f461d3e42d}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+register\+\_\+area\+\_\+ids@{diag\+\_\+register\+\_\+area\+\_\+ids}}
\index{diag\+\_\+register\+\_\+area\+\_\+ids@{diag\+\_\+register\+\_\+area\+\_\+ids}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+register\+\_\+area\+\_\+ids()}{diag\_register\_area\_ids()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+register\+\_\+area\+\_\+ids (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs,  }\item[{integer, intent(in), optional}]{id\+\_\+area\+\_\+t,  }\item[{integer, intent(in), optional}]{id\+\_\+area\+\_\+q }\end{DoxyParamCaption})}



Attaches the id of cell areas to axes groups for use with cell\+\_\+measures. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Diagnostics control structure\\
\hline
\mbox{\tt in}  & {\em id\+\_\+area\+\_\+t} & Diag\+\_\+mediator id for area of h-\/cells\\
\hline
\mbox{\tt in}  & {\em id\+\_\+area\+\_\+q} & Diag\+\_\+mediator id for area of q-\/cells \\
\hline
\end{DoxyParams}


Definition at line 922 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
922   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{   !< Diagnostics control structure}
923   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: id\_area\_t\textcolor{comment}{ !< Diag\_mediator id for area of h-cells}
924   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: id\_area\_q\textcolor{comment}{ !< Diag\_mediator id for area of q-cells}
925   \textcolor{comment}{! Local variables}
926   \textcolor{keywordtype}{integer} :: fms\_id, i
927   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(id\_area\_t)) \textcolor{keywordflow}{then}
928     fms\_id = diag\_cs%diags(id\_area\_t)%fms\_diag\_id
929     diag\_cs%axesT1%id\_area = fms\_id
930     diag\_cs%axesTi%id\_area = fms\_id
931     diag\_cs%axesTL%id\_area = fms\_id
932     \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
933       diag\_cs%remap\_axesTL(i)%id\_area = fms\_id
934       diag\_cs%remap\_axesTi(i)%id\_area = fms\_id
935 \textcolor{keywordflow}{    enddo}
936 \textcolor{keywordflow}{  endif}
937   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(id\_area\_q)) \textcolor{keywordflow}{then}
938     fms\_id = diag\_cs%diags(id\_area\_q)%fms\_diag\_id
939     diag\_cs%axesB1%id\_area = fms\_id
940     diag\_cs%axesBi%id\_area = fms\_id
941     diag\_cs%axesBL%id\_area = fms\_id
942     \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
943       diag\_cs%remap\_axesBL(i)%id\_area = fms\_id
944       diag\_cs%remap\_axesBi(i)%id\_area = fms\_id
945 \textcolor{keywordflow}{    enddo}
946 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a7a21b53f286a9a214cc6aac4e34eb78b}\label{namespacemom__diag__mediator_a7a21b53f286a9a214cc6aac4e34eb78b}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+restore\+\_\+grids@{diag\+\_\+restore\+\_\+grids}}
\index{diag\+\_\+restore\+\_\+grids@{diag\+\_\+restore\+\_\+grids}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+restore\+\_\+grids()}{diag\_restore\_grids()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+restore\+\_\+grids (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag }\end{DoxyParamCaption})}



Restore the diagnostic grids from the temporary structure within diag. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag} & Diagnostic control structure used as the contructor \\
\hline
\end{DoxyParams}


Definition at line 3666 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3666   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{     !< Diagnostic control structure used as the contructor}
3667 
3668   \textcolor{keywordtype}{integer} :: m
3669 
3670   \textcolor{comment}{! Don't do anything else if there are no remapped coordinates}
3671   \textcolor{keywordflow}{if} (diag%num\_diag\_coords < 1) \textcolor{keywordflow}{return}
3672 
3673   diag%diag\_grid\_overridden = .false.
3674   \textcolor{keywordflow}{do} m = 1,diag%num\_diag\_coords
3675     \textcolor{keywordflow}{if} (diag%diag\_remap\_cs(m)%nz > 0) &
3676       diag%diag\_remap\_cs(m)%h(:,:,:) = diag%diag\_grid\_temp%diag\_grids(m)%h(:,:,:)
3677 \textcolor{keywordflow}{  enddo}
3678 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_aba48dd8ac75fdf10eda85f8183c2b39e}\label{namespacemom__diag__mediator_aba48dd8ac75fdf10eda85f8183c2b39e}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+save\+\_\+grids@{diag\+\_\+save\+\_\+grids}}
\index{diag\+\_\+save\+\_\+grids@{diag\+\_\+save\+\_\+grids}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+save\+\_\+grids()}{diag\_save\_grids()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+save\+\_\+grids (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag }\end{DoxyParamCaption})}



Save the current diagnostic grids in the temporary structure within diag. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag} & Diagnostic control structure used as the contructor \\
\hline
\end{DoxyParams}


Definition at line 3650 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3650   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{     !< Diagnostic control structure used as the contructor}
3651 
3652   \textcolor{keywordtype}{integer} :: m
3653 
3654   \textcolor{comment}{! Don't do anything else if there are no remapped coordinates}
3655   \textcolor{keywordflow}{if} (diag%num\_diag\_coords < 1) \textcolor{keywordflow}{return}
3656 
3657   \textcolor{keywordflow}{do} m = 1,diag%num\_diag\_coords
3658     \textcolor{keywordflow}{if} (diag%diag\_remap\_cs(m)%nz > 0) &
3659       diag%diag\_grid\_temp%diag\_grids(m)%h(:,:,:) = diag%diag\_remap\_cs(m)%h(:,:,:)
3660 \textcolor{keywordflow}{  enddo}
3661 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_abe52776bc4a161c4912ce1987acaf1c1}\label{namespacemom__diag__mediator_abe52776bc4a161c4912ce1987acaf1c1}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+set\+\_\+state\+\_\+ptrs@{diag\+\_\+set\+\_\+state\+\_\+ptrs}}
\index{diag\+\_\+set\+\_\+state\+\_\+ptrs@{diag\+\_\+set\+\_\+state\+\_\+ptrs}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+set\+\_\+state\+\_\+ptrs()}{diag\_set\_state\_ptrs()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+set\+\_\+state\+\_\+ptrs (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:), intent(in), target}]{h,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), target}]{T,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), target}]{S,  }\item[{type(eos\+\_\+type), intent(in), target}]{eqn\+\_\+of\+\_\+state,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs }\end{DoxyParamCaption})}



Set pointers to the default state fields used to remap diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em h} & the model thickness array \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em t} & the model temperature array\\
\hline
\mbox{\tt in}  & {\em s} & the model salinity array\\
\hline
\mbox{\tt in}  & {\em eqn\+\_\+of\+\_\+state} & Equation of state structure\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & diag mediator control structure \\
\hline
\end{DoxyParams}


Definition at line 3248 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3248   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in   )} :: h\textcolor{comment}{ !< the model thickness array [H ~> m or kg m-2]}
3249   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in   )} :: T\textcolor{comment}{ !< the model temperature array}
3250   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in   )} :: S\textcolor{comment}{ !< the model salinity array}
3251   \textcolor{keywordtype}{type}(EOS\_type),         \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in   )} :: eqn\_of\_state\textcolor{comment}{ !< Equation of state structure}
3252   \textcolor{keywordtype}{type}(diag\_ctrl),                \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{ !< diag mediator control structure}
3253 
3254   \textcolor{comment}{! Keep pointers to h, T, S needed for the diagnostic remapping}
3255   diag\_cs%h => h
3256   diag\_cs%T => t
3257   diag\_cs%S => s
3258   diag\_cs%eqn\_of\_state => eqn\_of\_state
3259 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_aa78e69709084d0097b3e01bbd83d3509}\label{namespacemom__diag__mediator_aa78e69709084d0097b3e01bbd83d3509}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!diag\+\_\+update\+\_\+remap\+\_\+grids@{diag\+\_\+update\+\_\+remap\+\_\+grids}}
\index{diag\+\_\+update\+\_\+remap\+\_\+grids@{diag\+\_\+update\+\_\+remap\+\_\+grids}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{diag\+\_\+update\+\_\+remap\+\_\+grids()}{diag\_update\_remap\_grids()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::diag\+\_\+update\+\_\+remap\+\_\+grids (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), optional, target}]{alt\+\_\+h,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), optional, target}]{alt\+\_\+T,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), optional, target}]{alt\+\_\+S,  }\item[{logical, intent(in), optional}]{update\+\_\+intensive,  }\item[{logical, intent(in), optional}]{update\+\_\+extensive }\end{DoxyParamCaption})}



Build/update vertical grids for diagnostic remapping. 

\begin{DoxyNote}{Note}
The target grids need to be updated whenever sea surface height changes.
\end{DoxyNote}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Diagnostics control structure\\
\hline
\mbox{\tt in}  & {\em alt\+\_\+h} & Used if remapped grids should be something other than the current thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em alt\+\_\+t} & Used if remapped grids should be something other than the current temperatures\\
\hline
\mbox{\tt in}  & {\em alt\+\_\+s} & Used if remapped grids should be something other than the current salinity\\
\hline
\mbox{\tt in}  & {\em update\+\_\+intensive} & If true (default), update the grids used for intensive diagnostics\\
\hline
\mbox{\tt in}  & {\em update\+\_\+extensive} & If true (not default), update the grids used for intensive diagnostics \\
\hline
\end{DoxyParams}


Definition at line 3266 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3266   \textcolor{keywordtype}{type}(diag\_ctrl),        \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{      !< Diagnostics control structure}
3267   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in   )} :: alt\_h(:,:,:)\textcolor{comment}{ !< Used if remapped grids should be something other
       than}
3268 \textcolor{comment}{                                                        !! the current thicknesses [H ~> m or kg m-2]}
3269   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in   )} :: alt\_T(:,:,:)\textcolor{comment}{ !< Used if remapped grids should be something other
       than}
3270 \textcolor{comment}{                                                        !! the current temperatures}
3271   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in   )} :: alt\_S(:,:,:)\textcolor{comment}{ !< Used if remapped grids should be something other
       than}
3272 \textcolor{comment}{                                                        !! the current salinity}
3273   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},      \textcolor{keywordtype}{intent(in   )} :: update\_intensive\textcolor{comment}{ !< If true (default), update the grids used for}
3274 \textcolor{comment}{                                                            !! intensive diagnostics}
3275   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},      \textcolor{keywordtype}{intent(in   )} :: update\_extensive\textcolor{comment}{ !< If true (not default), update the grids used
       for}
3276 \textcolor{comment}{                                                            !! intensive diagnostics}
3277   \textcolor{comment}{! Local variables}
3278   \textcolor{keywordtype}{integer} :: i
3279   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: h\_diag => null() \textcolor{comment}{! The layer thickneses for diagnostics [H ~> m or kg
       m-2]}
3280   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: T\_diag => null(), s\_diag => null()
3281   \textcolor{keywordtype}{logical} :: update\_intensive\_local, update\_extensive\_local
3282 
3283   \textcolor{comment}{! Set values based on optional input arguments}
3284   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(alt\_h)) \textcolor{keywordflow}{then}
3285     h\_diag => alt\_h
3286   \textcolor{keywordflow}{else}
3287     h\_diag => diag\_cs%h
3288 \textcolor{keywordflow}{  endif}
3289 
3290   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(alt\_t)) \textcolor{keywordflow}{then}
3291     t\_diag => alt\_t
3292   \textcolor{keywordflow}{else}
3293     t\_diag => diag\_cs%T
3294 \textcolor{keywordflow}{  endif}
3295 
3296   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(alt\_s)) \textcolor{keywordflow}{then}
3297     s\_diag => alt\_s
3298   \textcolor{keywordflow}{else}
3299     s\_diag => diag\_cs%S
3300 \textcolor{keywordflow}{  endif}
3301 
3302   \textcolor{comment}{! Defaults here are based on wanting to update intensive quantities frequently as soon as the model state
       changes.}
3303   \textcolor{comment}{! Conversely, for extensive quantities, in an effort to close budgets and to be consistent with the total
       time}
3304   \textcolor{comment}{! tendency, we construct the diagnostic grid at the beginning of the baroclinic timestep and remap all
       extensive}
3305   \textcolor{comment}{! quantities to the same grid}
3306   update\_intensive\_local = .true.
3307   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(update\_intensive)) update\_intensive\_local = update\_intensive
3308   update\_extensive\_local = .false.
3309   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(update\_extensive)) update\_extensive\_local = update\_extensive
3310 
3311   \textcolor{keywordflow}{if} (id\_clock\_diag\_grid\_updates>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_grid\_updates)
3312 
3313   \textcolor{keywordflow}{if} (diag\_cs%diag\_grid\_overridden) \textcolor{keywordflow}{then}
3314      \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"diag\_update\_remap\_grids was called, but current grids in "}// &
3315                            \textcolor{stringliteral}{"diagnostic structure have been overridden"})
3316 \textcolor{keywordflow}{  endif}
3317 
3318   \textcolor{keywordflow}{if} (update\_intensive\_local) \textcolor{keywordflow}{then}
3319     \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
3320       \textcolor{keyword}{call }diag\_remap\_update(diag\_cs%diag\_remap\_cs(i), diag\_cs%G, diag\_cs%GV, diag\_cs%US, h\_diag, t\_diag, 
      s\_diag, &
3321                              diag\_cs%eqn\_of\_state, diag\_cs%diag\_remap\_cs(i)%h)
3322 \textcolor{keywordflow}{    enddo}
3323 \textcolor{keywordflow}{  endif}
3324   \textcolor{keywordflow}{if} (update\_extensive\_local) \textcolor{keywordflow}{then}
3325     diag\_cs%h\_begin(:,:,:) = diag\_cs%h(:,:,:)
3326     \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
3327       \textcolor{keyword}{call }diag\_remap\_update(diag\_cs%diag\_remap\_cs(i), diag\_cs%G, diag\_cs%GV, diag\_cs%US, h\_diag, t\_diag, 
      s\_diag, &
3328                              diag\_cs%eqn\_of\_state, diag\_cs%diag\_remap\_cs(i)%h\_extensive)
3329 \textcolor{keywordflow}{    enddo}
3330 \textcolor{keywordflow}{  endif}
3331 
3332 \textcolor{preprocessor}{#if defined(DEBUG) || defined(\_\_DO\_SAFETY\_CHECKS\_\_)}
3333 \textcolor{preprocessor}{}  \textcolor{comment}{! Keep a copy of H - used to check whether grids are up-to-date}
3334   \textcolor{comment}{! when doing remapping.}
3335   diag\_cs%h\_old(:,:,:) = diag\_cs%h(:,:,:)
3336 \textcolor{preprocessor}{#endif}
3337 \textcolor{preprocessor}{}
3338   \textcolor{keywordflow}{if} (id\_clock\_diag\_grid\_updates>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_grid\_updates)
3339 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a1761df399ba39742e34ab989469da0f2}\label{namespacemom__diag__mediator_a1761df399ba39742e34ab989469da0f2}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!disable\+\_\+averaging@{disable\+\_\+averaging}}
\index{disable\+\_\+averaging@{disable\+\_\+averaging}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{disable\+\_\+averaging()}{disable\_averaging()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::disable\+\_\+averaging (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs }\end{DoxyParamCaption})}



Call this subroutine to avoid averaging any offered fields. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 1906 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1906   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(inout)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1907 
1908   diag\_cs%time\_int = 0.0
1909   diag\_cs%ave\_enabled = .false.
1910 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ac19dd9879fd5c480c4bd27d6e7b8c0cf}\label{namespacemom__diag__mediator_ac19dd9879fd5c480c4bd27d6e7b8c0cf}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+diag\+\_\+field\+\_\+2d@{downsample\+\_\+diag\+\_\+field\+\_\+2d}}
\index{downsample\+\_\+diag\+\_\+field\+\_\+2d@{downsample\+\_\+diag\+\_\+field\+\_\+2d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+diag\+\_\+field\+\_\+2d()}{downsample\_diag\_field\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+diag\+\_\+field\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:), pointer}]{locfield,  }\item[{real, dimension(\+:,\+:), intent(inout), allocatable}]{locfield\+\_\+dsamp,  }\item[{integer, intent(in)}]{dl,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(in)}]{diag,  }\item[{integer, intent(inout)}]{isv,  }\item[{integer, intent(inout)}]{iev,  }\item[{integer, intent(inout)}]{jsv,  }\item[{integer, intent(inout)}]{jev,  }\item[{real, dimension(\+:,\+:), intent(in), optional, target}]{mask }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine allocates and computes a downsampled array from an input array It also determines the diagnostics-\/compurte indices for the downsampled array 2d interface. 


\begin{DoxyParams}[1]{Parameters}
 & {\em locfield} & Input array pointer\\
\hline
\mbox{\tt in,out}  & {\em locfield\+\_\+dsamp} & Output (downsampled) array\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em diag} & A structure describing the diagnostic to post\\
\hline
\mbox{\tt in}  & {\em dl} & Level of down sampling\\
\hline
\mbox{\tt in,out}  & {\em isv} & i-\/start index for diagnostics\\
\hline
\mbox{\tt in,out}  & {\em iev} & i-\/end index for diagnostics\\
\hline
\mbox{\tt in,out}  & {\em jsv} & j-\/start index for diagnostics\\
\hline
\mbox{\tt in,out}  & {\em jev} & j-\/end index for diagnostics\\
\hline
\mbox{\tt in}  & {\em mask} & If present, use this real array as the data mask. \\
\hline
\end{DoxyParams}


Definition at line 3876 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3876   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: locfield\textcolor{comment}{ !< Input array pointer}
3877   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{intent(inout)} :: locfield\_dsamp\textcolor{comment}{ !< Output (downsampled) array}
3878   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
3879   \textcolor{keywordtype}{type}(diag\_type),   \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{    !< A structure describing the diagnostic to post}
3880   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dl\textcolor{comment}{                !< Level of down sampling}
3881   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: isv\textcolor{comment}{            !< i-start index for diagnostics}
3882   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: iev\textcolor{comment}{            !< i-end index for diagnostics}
3883   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: jsv\textcolor{comment}{            !< j-start index for diagnostics}
3884   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: jev\textcolor{comment}{            !< j-end index for diagnostics}
3885   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional},\textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: mask(:,:)\textcolor{comment}{ !< If present, use this real array as the data mask.}
3886   \textcolor{comment}{! Locals}
3887   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: locmask
3888   \textcolor{keywordtype}{integer} :: f1,f2,isv\_o,jsv\_o
3889 
3890   locmask => null()
3891   \textcolor{comment}{!Get the correct indices corresponding to input field}
3892   \textcolor{comment}{!Shape of the input diag field}
3893   f1=\textcolor{keyword}{size}(locfield,1)
3894   f2=\textcolor{keyword}{size}(locfield,2)
3895   \textcolor{comment}{!Save the extents of the original (fine) domain}
3896   isv\_o=isv;jsv\_o=jsv
3897   \textcolor{comment}{!Get the shape of the downsampled field and overwrite isv,iev,jsv,jev with them}
3898   \textcolor{keyword}{call }downsample\_diag\_indices\_get(f1,f2, dl, diag\_cs,isv,iev,jsv,jev)
3899   \textcolor{comment}{!Set the non-downsampled mask, it must be associated and initialized}
3900   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
3901      locmask => mask
3902   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(diag%axes%mask2d)) \textcolor{keywordflow}{then}
3903      locmask => diag%axes%mask2d
3904   \textcolor{keywordflow}{else}
3905      \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"downsample\_diag\_field\_2d: Cannot downsample without a mask!!! "})
3906 \textcolor{keywordflow}{  endif}
3907 
3908   \textcolor{keyword}{call }downsample\_field(locfield, locfield\_dsamp, dl, diag%xyz\_method, locmask, diag\_cs,diag, &
3909                       isv\_o,jsv\_o,isv,iev,jsv,jev)
3910 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a30395d7b955b819afa3942700dedead1}\label{namespacemom__diag__mediator_a30395d7b955b819afa3942700dedead1}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+diag\+\_\+field\+\_\+3d@{downsample\+\_\+diag\+\_\+field\+\_\+3d}}
\index{downsample\+\_\+diag\+\_\+field\+\_\+3d@{downsample\+\_\+diag\+\_\+field\+\_\+3d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+diag\+\_\+field\+\_\+3d()}{downsample\_diag\_field\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+diag\+\_\+field\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:), pointer}]{locfield,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout), allocatable}]{locfield\+\_\+dsamp,  }\item[{integer, intent(in)}]{dl,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(in)}]{diag,  }\item[{integer, intent(inout)}]{isv,  }\item[{integer, intent(inout)}]{iev,  }\item[{integer, intent(inout)}]{jsv,  }\item[{integer, intent(inout)}]{jev,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), optional, target}]{mask }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine allocates and computes a downsampled array from an input array It also determines the diagnostics-\/compurte indices for the downsampled array 3d interface. 


\begin{DoxyParams}[1]{Parameters}
 & {\em locfield} & Input array pointer\\
\hline
\mbox{\tt in,out}  & {\em locfield\+\_\+dsamp} & Output (downsampled) array\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em diag} & A structure describing the diagnostic to post\\
\hline
\mbox{\tt in}  & {\em dl} & Level of down sampling\\
\hline
\mbox{\tt in,out}  & {\em isv} & i-\/start index for diagnostics\\
\hline
\mbox{\tt in,out}  & {\em iev} & i-\/end index for diagnostics\\
\hline
\mbox{\tt in,out}  & {\em jsv} & j-\/start index for diagnostics\\
\hline
\mbox{\tt in,out}  & {\em jev} & j-\/end index for diagnostics\\
\hline
\mbox{\tt in}  & {\em mask} & If present, use this real array as the data mask. \\
\hline
\end{DoxyParams}


Definition at line 3835 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3835   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: locfield\textcolor{comment}{  !< Input array pointer}
3836   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{intent(inout)} :: locfield\_dsamp\textcolor{comment}{ !< Output (downsampled) array}
3837   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
3838   \textcolor{keywordtype}{type}(diag\_type),   \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{    !< A structure describing the diagnostic to post}
3839   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dl\textcolor{comment}{                !< Level of down sampling}
3840   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: isv\textcolor{comment}{            !< i-start index for diagnostics}
3841   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: iev\textcolor{comment}{            !< i-end index for diagnostics}
3842   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: jsv\textcolor{comment}{            !< j-start index for diagnostics}
3843   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(inout)} :: jev\textcolor{comment}{            !< j-end index for diagnostics}
3844   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional},\textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: mask(:,:,:)\textcolor{comment}{ !< If present, use this real array as the data mask.}
3845   \textcolor{comment}{! Locals}
3846   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: locmask
3847   \textcolor{keywordtype}{integer} :: f1,f2,isv\_o,jsv\_o
3848 
3849   locmask => null()
3850   \textcolor{comment}{!Get the correct indices corresponding to input field}
3851   \textcolor{comment}{!Shape of the input diag field}
3852   f1=\textcolor{keyword}{size}(locfield,1)
3853   f2=\textcolor{keyword}{size}(locfield,2)
3854   \textcolor{comment}{!Save the extents of the original (fine) domain}
3855   isv\_o=isv;jsv\_o=jsv
3856   \textcolor{comment}{!Get the shape of the downsampled field and overwrite isv,iev,jsv,jev with them}
3857   \textcolor{keyword}{call }downsample\_diag\_indices\_get(f1,f2, dl, diag\_cs,isv,iev,jsv,jev)
3858   \textcolor{comment}{!Set the non-downsampled mask, it must be associated and initialized}
3859   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
3860      locmask => mask
3861   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(diag%axes%mask3d)) \textcolor{keywordflow}{then}
3862      locmask => diag%axes%mask3d
3863   \textcolor{keywordflow}{else}
3864      \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"downsample\_diag\_field\_3d: Cannot downsample without a mask!!! "})
3865 \textcolor{keywordflow}{  endif}
3866 
3867   \textcolor{keyword}{call }downsample\_field(locfield, locfield\_dsamp, dl, diag%xyz\_method, locmask, diag\_cs, diag, &
3868                       isv\_o,jsv\_o,isv,iev,jsv,jev)
3869 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a902b3d966dae0a8f0011d98d8697e22d}\label{namespacemom__diag__mediator_a902b3d966dae0a8f0011d98d8697e22d}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+diag\+\_\+indices\+\_\+get@{downsample\+\_\+diag\+\_\+indices\+\_\+get}}
\index{downsample\+\_\+diag\+\_\+indices\+\_\+get@{downsample\+\_\+diag\+\_\+indices\+\_\+get}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+diag\+\_\+indices\+\_\+get()}{downsample\_diag\_indices\_get()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+diag\+\_\+indices\+\_\+get (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{fo1,  }\item[{integer, intent(in)}]{fo2,  }\item[{integer, intent(in)}]{dl,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{integer, intent(out)}]{isv,  }\item[{integer, intent(out)}]{iev,  }\item[{integer, intent(out)}]{jsv,  }\item[{integer, intent(out)}]{jev }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Get the diagnostics-\/compute indices (to be passed to send\+\_\+data) based on the shape of the diag field (the same way they are deduced for non-\/downsampled fields) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fo1} & The size of the diag field in x\\
\hline
\mbox{\tt in}  & {\em fo2} & The size of the diag field in y\\
\hline
\mbox{\tt in}  & {\em dl} & Integer downsample level\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt out}  & {\em isv} & i-\/start index for diagnostics\\
\hline
\mbox{\tt out}  & {\em iev} & i-\/end index for diagnostics\\
\hline
\mbox{\tt out}  & {\em jsv} & j-\/start index for diagnostics\\
\hline
\mbox{\tt out}  & {\em jev} & j-\/end index for diagnostics \\
\hline
\end{DoxyParams}


Definition at line 3762 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3762   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)}  :: fo1\textcolor{comment}{     !< The size of the diag field in x}
3763   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)}  :: fo2\textcolor{comment}{     !< The size of the diag field in y}
3764   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)}  :: dl\textcolor{comment}{      !< Integer downsample level}
3765   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)}  :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
3766   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(out)} :: isv\textcolor{comment}{     !< i-start index for diagnostics}
3767   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(out)} :: iev\textcolor{comment}{     !< i-end index for diagnostics}
3768   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(out)} :: jsv\textcolor{comment}{     !< j-start index for diagnostics}
3769   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(out)} :: jev\textcolor{comment}{     !< j-end index for diagnostics}
3770   \textcolor{comment}{! Local variables}
3771   \textcolor{keywordtype}{integer} :: dszi,cszi,dszj,cszj,f1,f2
3772   \textcolor{keywordtype}{character(len=500)} :: mesg
3773   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{save} :: first\_check = .true.
3774 
3775   \textcolor{comment}{!Check ONCE that the downsampled diag-compute domain is commensurate with the original}
3776   \textcolor{comment}{!non-downsampled diag-compute domain.}
3777   \textcolor{comment}{!This is a major limitation of the current implementation of the downsampled diagnostics.}
3778   \textcolor{comment}{!We assume that the compute domain can be subdivided to dl*dl cells, hence avoiding the need of halo
       updates.}
3779   \textcolor{comment}{!We want this check to error out only if there was a downsampled diagnostics requested and about to post
       that is}
3780   \textcolor{comment}{!why the check is here and not in the init routines. This check need to be done only once, hence the
       outer if.}
3781   \textcolor{keywordflow}{if}(first\_check) \textcolor{keywordflow}{then}
3782      \textcolor{keywordflow}{if}(mod(diag\_cs%ie-diag\_cs%is+1, dl) .ne. 0 .OR. mod(diag\_cs%je-diag\_cs%js+1, dl) .ne. 0) \textcolor{keywordflow}{then}
3783         \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"Non-commensurate downsampled domain is not supported. "}//&
3784              \textcolor{stringliteral}{"Please choose a layout such that NIGLOBAL/Layout\_X and NJGLOBAL/Layout\_Y are both divisible
       by dl="},dl,&
3785              \textcolor{stringliteral}{" Current domain extents: "}, diag\_cs%is,diag\_cs%ie, diag\_cs%js,diag\_cs%je
3786         \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"downsample\_diag\_indices\_get: "}//trim(mesg))
3787 \textcolor{keywordflow}{     endif}
3788      first\_check = .false.
3789 \textcolor{keywordflow}{  endif}
3790 
3791   cszi = diag\_cs%dsamp(dl)%iec-diag\_cs%dsamp(dl)%isc +1 ; dszi = diag\_cs%dsamp(dl)%ied-diag\_cs%dsamp(dl)
      %isd +1
3792   cszj = diag\_cs%dsamp(dl)%jec-diag\_cs%dsamp(dl)%jsc +1 ; dszj = diag\_cs%dsamp(dl)%jed-diag\_cs%dsamp(dl)
      %jsd +1
3793   isv = diag\_cs%dsamp(dl)%isc ; iev = diag\_cs%dsamp(dl)%iec
3794   jsv = diag\_cs%dsamp(dl)%jsc ; jev = diag\_cs%dsamp(dl)%jec
3795   f1 = fo1/dl
3796   f2 = fo2/dl
3797   \textcolor{comment}{!Correction for the symmetric case}
3798   \textcolor{keywordflow}{if} (diag\_cs%G%symmetric) \textcolor{keywordflow}{then}
3799      f1 = f1 + mod(fo1,dl)
3800      f2 = f2 + mod(fo2,dl)
3801 \textcolor{keywordflow}{  endif}
3802   \textcolor{keywordflow}{if} ( f1 == dszi ) \textcolor{keywordflow}{then}
3803      isv = diag\_cs%dsamp(dl)%isc ; iev = diag\_cs%dsamp(dl)%iec    \textcolor{comment}{! field on Data domain, take compute
       domain indcies}
3804   \textcolor{comment}{!The rest is not taken with the full MOM6 diag\_table}
3805   \textcolor{keywordflow}{elseif} ( f1 == dszi + 1 ) \textcolor{keywordflow}{then}
3806      isv = diag\_cs%dsamp(dl)%isc ; iev = diag\_cs%dsamp(dl)%iec+1   \textcolor{comment}{! Symmetric data domain}
3807   \textcolor{keywordflow}{elseif} ( f1 == cszi) \textcolor{keywordflow}{then}
3808      isv = 1 ; iev = (diag\_cs%dsamp(dl)%iec-diag\_cs%dsamp(dl)%isc) +1  \textcolor{comment}{! Computational domain}
3809   \textcolor{keywordflow}{elseif} ( f1 == cszi + 1 ) \textcolor{keywordflow}{then}
3810      isv = 1 ; iev = (diag\_cs%dsamp(dl)%iec-diag\_cs%dsamp(dl)%isc) +2  \textcolor{comment}{! Symmetric computational domain}
3811   \textcolor{keywordflow}{else}
3812      \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" peculiar size "},f1,\textcolor{stringliteral}{" in i-direction\(\backslash\)n"}//&
3813           \textcolor{stringliteral}{"does not match one of "}, cszi, cszi+1, dszi, dszi+1
3814      \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"downsample\_diag\_indices\_get: "}//trim(mesg))
3815 \textcolor{keywordflow}{  endif}
3816   \textcolor{keywordflow}{if} ( f2 == dszj ) \textcolor{keywordflow}{then}
3817      jsv = diag\_cs%dsamp(dl)%jsc ; jev = diag\_cs%dsamp(dl)%jec     \textcolor{comment}{! Data domain}
3818   \textcolor{keywordflow}{elseif} ( f2 == dszj + 1 ) \textcolor{keywordflow}{then}
3819      jsv = diag\_cs%dsamp(dl)%jsc ; jev = diag\_cs%dsamp(dl)%jec+1   \textcolor{comment}{! Symmetric data domain}
3820   \textcolor{keywordflow}{elseif} ( f2 == cszj) \textcolor{keywordflow}{then}
3821      jsv = 1 ; jev = (diag\_cs%dsamp(dl)%jec-diag\_cs%dsamp(dl)%jsc) +1  \textcolor{comment}{! Computational domain}
3822   \textcolor{keywordflow}{elseif} ( f2 == cszj + 1 ) \textcolor{keywordflow}{then}
3823      jsv = 1 ; jev = (diag\_cs%dsamp(dl)%jec-diag\_cs%dsamp(dl)%jsc) +2  \textcolor{comment}{! Symmetric computational domain}
3824   \textcolor{keywordflow}{else}
3825      \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" peculiar size "},f2,\textcolor{stringliteral}{" in j-direction\(\backslash\)n"}//&
3826           \textcolor{stringliteral}{"does not match one of "}, cszj, cszj+1, dszj, dszj+1
3827      \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"downsample\_diag\_indices\_get: "}//trim(mesg))
3828 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a5f2fcd6b3aa44f8d4f6259d8cf365f04}\label{namespacemom__diag__mediator_a5f2fcd6b3aa44f8d4f6259d8cf365f04}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+diag\+\_\+masks\+\_\+set@{downsample\+\_\+diag\+\_\+masks\+\_\+set}}
\index{downsample\+\_\+diag\+\_\+masks\+\_\+set@{downsample\+\_\+diag\+\_\+masks\+\_\+set}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+diag\+\_\+masks\+\_\+set()}{downsample\_diag\_masks\_set()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+diag\+\_\+masks\+\_\+set (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in), target}]{G,  }\item[{integer, intent(in)}]{nz,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), pointer}]{diag\+\_\+cs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean grid type.\\
\hline
\mbox{\tt in}  & {\em nz} & The number of layers in the model\textquotesingle{}s native grid.\\
\hline
 & {\em diag\+\_\+cs} & A pointer to a type with many variables used for diagnostics \\
\hline
\end{DoxyParams}


Definition at line 3703 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3703   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< The ocean grid type.}
3704   \textcolor{keywordtype}{integer},                       \textcolor{keywordtype}{intent(in)} :: nz\textcolor{comment}{ !< The number of layers in the model's native grid.}
3705   \textcolor{keywordtype}{type}(diag\_ctrl),               \textcolor{keywordtype}{pointer}    :: diag\_cs\textcolor{comment}{ !< A pointer to a type with many variables}
3706 \textcolor{comment}{                                                       !! used for diagnostics}
3707   \textcolor{comment}{! Local variables}
3708   \textcolor{keywordtype}{integer} :: i,j,k,ii,jj,dl
3709 
3710 \textcolor{comment}{!print*,'original c extents ',G%isc,G%iec,G%jsc,G%jec}
3711 \textcolor{comment}{!print*,'original c extents ',G%iscb,G%iecb,G%jscb,G%jecb}
3712 \textcolor{comment}{!print*,'coarse   c extents ',G%HId2%isc,G%HId2%iec,G%HId2%jsc,G%HId2%jec}
3713 \textcolor{comment}{!print*,'original d extents ',G%isd,G%ied,G%jsd,G%jed}
3714 \textcolor{comment}{!print*,'coarse   d extents ',G%HId2%isd,G%HId2%ied,G%HId2%jsd,G%HId2%jed}
3715 \textcolor{comment}{! original c  extents           5          52           5          52}
3716 \textcolor{comment}{! original cB-nonsym extents    5          52           5          52}
3717 \textcolor{comment}{! original cB-sym    extents    4          52           4          52}
3718 \textcolor{comment}{! coarse   c extents            3          26           3          26}
3719 \textcolor{comment}{! original d extents            1          56           1          56}
3720 \textcolor{comment}{! original dB-nonsym extents    1          56           1          56}
3721 \textcolor{comment}{! original dB-sym extents       0          56           0          56}
3722 \textcolor{comment}{! coarse   d extents            1          28           1          28}
3723 
3724   \textcolor{keywordflow}{do} dl=2,max\_dsamp\_lev
3725      \textcolor{comment}{! 2d mask}
3726      \textcolor{keyword}{call }downsample\_mask(g%mask2dT, diag\_cs%dsamp(dl)%mask2dT,  dl,g%isc, g%jsc,  &
3727           g%HId2%isc, g%HId2%iec, g%HId2%jsc, g%HId2%jec, g%HId2%isd, g%HId2%ied, g%HId2%jsd, g%HId2%jed)
3728      \textcolor{keyword}{call }downsample\_mask(g%mask2dBu,diag\_cs%dsamp(dl)%mask2dBu, dl,g%IscB,g%JscB, &
3729           g%HId2%IscB,g%HId2%IecB,g%HId2%JscB,g%HId2%JecB,g%HId2%IsdB,g%HId2%IedB,g%HId2%JsdB,g%HId2%JedB)
3730      \textcolor{keyword}{call }downsample\_mask(g%mask2dCu,diag\_cs%dsamp(dl)%mask2dCu, dl,g%IscB,g%JscB, &
3731           g%HId2%IscB,g%HId2%IecB,g%HId2%jsc, g%HId2%jec,g%HId2%IsdB,g%HId2%IedB,g%HId2%jsd, g%HId2%jed)
3732      \textcolor{keyword}{call }downsample\_mask(g%mask2dCv,diag\_cs%dsamp(dl)%mask2dCv, dl,g%isc ,g%JscB, &
3733           g%HId2%isc ,g%HId2%iec, g%HId2%JscB,g%HId2%JecB,g%HId2%isd ,g%HId2%ied, g%HId2%JsdB,g%HId2%JedB)
3734      \textcolor{comment}{! 3d native masks are needed by diag\_manager but the native variables}
3735      \textcolor{comment}{! can only be masked 2d - for ocean points, all layers exists.}
3736      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dTL(g%HId2%isd:g%HId2%ied,g%HId2%jsd:g%HId2%jed,1:nz))
3737      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dBL(g%HId2%IsdB:g%HId2%IedB,g%HId2%JsdB:g%HId2%JedB,1:nz))
3738      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dCuL(g%HId2%IsdB:g%HId2%IedB,g%HId2%jsd:g%HId2%jed,1:nz))
3739      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dCvL(g%HId2%isd:g%HId2%ied,g%HId2%JsdB:g%HId2%JedB,1:nz))
3740      \textcolor{keywordflow}{do} k=1,nz
3741         diag\_cs%dsamp(dl)%mask3dTL(:,:,k) = diag\_cs%dsamp(dl)%mask2dT(:,:)
3742         diag\_cs%dsamp(dl)%mask3dBL(:,:,k) = diag\_cs%dsamp(dl)%mask2dBu(:,:)
3743         diag\_cs%dsamp(dl)%mask3dCuL(:,:,k) = diag\_cs%dsamp(dl)%mask2dCu(:,:)
3744         diag\_cs%dsamp(dl)%mask3dCvL(:,:,k) = diag\_cs%dsamp(dl)%mask2dCv(:,:)
3745 \textcolor{keywordflow}{     enddo}
3746      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dTi(g%HId2%isd:g%HId2%ied,g%HId2%jsd:g%HId2%jed,1:nz+1))
3747      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dBi(g%HId2%IsdB:g%HId2%IedB,g%HId2%JsdB:g%HId2%JedB,1:nz+1))
3748      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dCui(g%HId2%IsdB:g%HId2%IedB,g%HId2%jsd:g%HId2%jed,1:nz+1))
3749      \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%mask3dCvi(g%HId2%isd:g%HId2%ied,g%HId2%JsdB:g%HId2%JedB,1:nz+1))
3750      \textcolor{keywordflow}{do} k=1,nz+1
3751         diag\_cs%dsamp(dl)%mask3dTi(:,:,k) = diag\_cs%dsamp(dl)%mask2dT(:,:)
3752         diag\_cs%dsamp(dl)%mask3dBi(:,:,k) = diag\_cs%dsamp(dl)%mask2dBu(:,:)
3753         diag\_cs%dsamp(dl)%mask3dCui(:,:,k) = diag\_cs%dsamp(dl)%mask2dCu(:,:)
3754         diag\_cs%dsamp(dl)%mask3dCvi(:,:,k) = diag\_cs%dsamp(dl)%mask2dCv(:,:)
3755 \textcolor{keywordflow}{     enddo}
3756 \textcolor{keywordflow}{  enddo}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_aa46e12f1318ed96f60035cdd32e4157a}\label{namespacemom__diag__mediator_aa46e12f1318ed96f60035cdd32e4157a}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+field\+\_\+2d@{downsample\+\_\+field\+\_\+2d}}
\index{downsample\+\_\+field\+\_\+2d@{downsample\+\_\+field\+\_\+2d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+field\+\_\+2d()}{downsample\_field\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+field\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:), pointer}]{field\+\_\+in,  }\item[{real, dimension(\+:,\+:), allocatable}]{field\+\_\+out,  }\item[{integer, intent(in)}]{dl,  }\item[{integer, intent(in)}]{method,  }\item[{real, dimension(\+:,\+:), pointer}]{mask,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(in)}]{diag,  }\item[{integer, intent(in)}]{isv\+\_\+o,  }\item[{integer, intent(in)}]{jsv\+\_\+o,  }\item[{integer, intent(in)}]{isv\+\_\+d,  }\item[{integer, intent(in)}]{iev\+\_\+d,  }\item[{integer, intent(in)}]{jsv\+\_\+d,  }\item[{integer, intent(in)}]{jev\+\_\+d }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine allocates and computes a down sampled 2d array given an input array The down sample method is based on the \char`\"{}cell\+\_\+methods\char`\"{} for the diagnostics as explained in the above table. 


\begin{DoxyParams}[1]{Parameters}
 & {\em field\+\_\+in} & Original field to be down sampled\\
\hline
 & {\em field\+\_\+out} & Down sampled field\\
\hline
\mbox{\tt in}  & {\em dl} & Level of down sampling\\
\hline
\mbox{\tt in}  & {\em method} & Sampling method\\
\hline
 & {\em mask} & Mask for field\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em diag} & A structure describing the diagnostic to post\\
\hline
\mbox{\tt in}  & {\em isv\+\_\+o} & Original i-\/start index\\
\hline
\mbox{\tt in}  & {\em jsv\+\_\+o} & Original j-\/start index\\
\hline
\mbox{\tt in}  & {\em isv\+\_\+d} & i-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em iev\+\_\+d} & i-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jsv\+\_\+d} & j-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jev\+\_\+d} & j-\/end index of down sampled data \\
\hline
\end{DoxyParams}


Definition at line 4107 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
4107   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: field\_in\textcolor{comment}{      !< Original field to be down sampled}
4108   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable} :: field\_out\textcolor{comment}{ !< Down sampled field}
4109   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dl\textcolor{comment}{                !< Level of down sampling}
4110   \textcolor{keywordtype}{integer},  \textcolor{keywordtype}{intent(in)} :: method\textcolor{comment}{           !< Sampling method}
4111   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: mask\textcolor{comment}{    !< Mask for field}
4112   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
4113   \textcolor{keywordtype}{type}(diag\_type),   \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{    !< A structure describing the diagnostic to post}
4114   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isv\_o\textcolor{comment}{             !< Original i-start index}
4115   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsv\_o\textcolor{comment}{             !< Original j-start index}
4116   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isv\_d\textcolor{comment}{             !< i-start index of down sampled data}
4117   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: iev\_d\textcolor{comment}{             !< i-end index of down sampled data}
4118   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsv\_d\textcolor{comment}{             !< j-start index of down sampled data}
4119   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jev\_d\textcolor{comment}{             !< j-end index of down sampled data}
4120   \textcolor{comment}{! Locals}
4121   \textcolor{keywordtype}{character(len=240)} :: mesg
4122   \textcolor{keywordtype}{integer} :: i,j,ii,jj,i0,j0,f1,f2,f\_in1,f\_in2
4123   \textcolor{keywordtype}{real} :: ave, total\_weight, weight
4124   \textcolor{keywordtype}{real} :: epsilon = 1.0e-20  \textcolor{comment}{! A negligibly small count of weights [nondim]}
4125   \textcolor{keywordtype}{real} :: eps\_area  \textcolor{comment}{! A negligibly small area [L2 ~> m2]}
4126   \textcolor{keywordtype}{real} :: eps\_len   \textcolor{comment}{! A negligibly small horizontal length [L ~> m]}
4127 
4128   eps\_len = 1.0e-20 * diag\_cs%G%US%m\_to\_L
4129   eps\_area = 1.0e-20 * diag\_cs%G%US%m\_to\_L**2
4130 
4131   \textcolor{comment}{! Allocate the down sampled field on the down sampled data domain}
4132 \textcolor{comment}{! 
       allocate(field\_out(diag\_cs%dsamp(dl)%isd:diag\_cs%dsamp(dl)%ied,diag\_cs%dsamp(dl)%jsd:diag\_cs%dsamp(dl)%jed))}
4133 \textcolor{comment}{!  allocate(field\_out(1:size(field\_in,1)/dl,1:size(field\_in,2)/dl))}
4134   \textcolor{comment}{! Fill the down sampled field on the down sampled diagnostics (almost always compuate) domain}
4135   f\_in1 = \textcolor{keyword}{size}(field\_in,1)
4136   f\_in2 = \textcolor{keyword}{size}(field\_in,2)
4137   f1 = f\_in1/dl
4138   f2 = f\_in2/dl
4139   \textcolor{comment}{! Correction for the symmetric case}
4140   \textcolor{keywordflow}{if} (diag\_cs%G%symmetric) \textcolor{keywordflow}{then}
4141      f1 = f1 + mod(f\_in1,dl)
4142      f2 = f2 + mod(f\_in2,dl)
4143 \textcolor{keywordflow}{  endif}
4144   \textcolor{keyword}{allocate}(field\_out(1:f1,1:f2))
4145 
4146   \textcolor{keywordflow}{if} (method == mmp) \textcolor{keywordflow}{then}
4147      \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4148         i0 = isv\_o+dl*(i-isv\_d)
4149         j0 = jsv\_o+dl*(j-jsv\_d)
4150         ave = 0.0
4151         total\_weight = 0.0
4152         \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4153 \textcolor{comment}{!        do ii=i0,i0+dl-1 ; do jj=j0,j0+dl-1}
4154            weight = mask(ii,jj)*diag\_cs%G%areaT(ii,jj)
4155            total\_weight = total\_weight + weight
4156            ave = ave+field\_in(ii,jj)*weight
4157 \textcolor{keyword}{        end}do; enddo
4158         field\_out(i,j)  = ave/(total\_weight + eps\_area)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4159 \textcolor{keyword}{     end}do; enddo
4160   \textcolor{keywordflow}{elseif}(method == ssp) \textcolor{keywordflow}{then}    \textcolor{comment}{! e.g., T\_dfxy\_cont\_tendency\_2d}
4161      \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4162         i0 = isv\_o+dl*(i-isv\_d)
4163         j0 = jsv\_o+dl*(j-jsv\_d)
4164         ave = 0.0
4165         total\_weight = 0.0
4166         \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4167 \textcolor{comment}{!        do ii=i0,i0+dl-1 ; do jj=j0,j0+dl-1}
4168            weight = mask(ii,jj)
4169            total\_weight = total\_weight + weight
4170            ave=ave+field\_in(ii,jj)*weight
4171 \textcolor{keyword}{        end}do; enddo
4172         field\_out(i,j)  = ave/(total\_weight+epsilon)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4173 \textcolor{keyword}{     end}do; enddo
4174   \textcolor{keywordflow}{elseif}(method == psp) \textcolor{keywordflow}{then}    \textcolor{comment}{! e.g., umo\_2d}
4175      \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4176         i0 = isv\_o+dl*(i-isv\_d)
4177         j0 = jsv\_o+dl*(j-jsv\_d)
4178         ave = 0.0
4179         total\_weight = 0.0
4180         ii=i0
4181         \textcolor{keywordflow}{do} jj=j0,j0+dl-1
4182            weight = mask(ii,jj)
4183            total\_weight = total\_weight +weight
4184            ave=ave+field\_in(ii,jj)*weight
4185 \textcolor{keywordflow}{        enddo}
4186         field\_out(i,j)  = ave/(total\_weight+epsilon)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4187 \textcolor{keyword}{     end}do; enddo
4188   \textcolor{keywordflow}{elseif}(method == spp) \textcolor{keywordflow}{then}    \textcolor{comment}{! e.g., vmo\_2d}
4189      \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4190         i0 = isv\_o+dl*(i-isv\_d)
4191         j0 = jsv\_o+dl*(j-jsv\_d)
4192         ave = 0.0
4193         total\_weight = 0.0
4194         jj=j0
4195         \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4196            weight = mask(ii,jj)
4197            total\_weight = total\_weight +weight
4198            ave=ave+field\_in(ii,jj)*weight
4199 \textcolor{keywordflow}{        enddo}
4200         field\_out(i,j)  = ave/(total\_weight+epsilon)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4201 \textcolor{keyword}{     end}do; enddo
4202   \textcolor{keywordflow}{elseif}(method == pmp) \textcolor{keywordflow}{then}
4203      \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4204         i0 = isv\_o+dl*(i-isv\_d)
4205         j0 = jsv\_o+dl*(j-jsv\_d)
4206         ave = 0.0
4207         total\_weight = 0.0
4208         ii=i0
4209         \textcolor{keywordflow}{do} jj=j0,j0+dl-1
4210            weight = mask(ii,jj) * diag\_cs%G%dyCu(ii,jj)\textcolor{comment}{!*diag\_cs%h(ii,jj,1) !Niki?}
4211            total\_weight = total\_weight +weight
4212            ave=ave+field\_in(ii,jj)*weight
4213 \textcolor{keywordflow}{        enddo}
4214         field\_out(i,j)  = ave/(total\_weight+eps\_len)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4215 \textcolor{keyword}{     end}do; enddo
4216   \textcolor{keywordflow}{elseif}(method == mpp) \textcolor{keywordflow}{then}
4217      \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4218         i0 = isv\_o+dl*(i-isv\_d)
4219         j0 = jsv\_o+dl*(j-jsv\_d)
4220         ave = 0.0
4221         total\_weight = 0.0
4222         jj=j0
4223         \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4224            weight = mask(ii,jj)* diag\_cs%G%dxCv(ii,jj)\textcolor{comment}{!*diag\_cs%h(ii,jj,1) !Niki?}
4225            total\_weight = total\_weight +weight
4226            ave=ave+field\_in(ii,jj)*weight
4227 \textcolor{keywordflow}{        enddo}
4228         field\_out(i,j)  = ave/(total\_weight+eps\_len)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4229 \textcolor{keyword}{     end}do; enddo
4230   \textcolor{keywordflow}{elseif}(method == msk) \textcolor{keywordflow}{then} \textcolor{comment}{!The input field is a mask, subsample}
4231      field\_out(:,:) = 0.0
4232      \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4233         i0 = isv\_o+dl*(i-isv\_d)
4234         j0 = jsv\_o+dl*(j-jsv\_d)
4235         ave = 0.0
4236         \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4237            ave=ave+field\_in(ii,jj)
4238 \textcolor{keyword}{        end}do; enddo
4239         \textcolor{keywordflow}{if}(ave > 0.0) field\_out(i,j)=1.0
4240 \textcolor{keyword}{     end}do; enddo
4241   \textcolor{keywordflow}{else}
4242      \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" unknown sampling method: "},method
4243      \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"downsample\_field\_2d: "}//trim(mesg)//\textcolor{stringliteral}{" "}//trim(diag%debug\_str))
4244 \textcolor{keywordflow}{  endif}
4245 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a640ec8fac9bad1d0af6f737d7e816403}\label{namespacemom__diag__mediator_a640ec8fac9bad1d0af6f737d7e816403}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+field\+\_\+3d@{downsample\+\_\+field\+\_\+3d}}
\index{downsample\+\_\+field\+\_\+3d@{downsample\+\_\+field\+\_\+3d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+field\+\_\+3d()}{downsample\_field\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+field\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:), pointer}]{field\+\_\+in,  }\item[{real, dimension(\+:,\+:,\+:), allocatable}]{field\+\_\+out,  }\item[{integer, intent(in)}]{dl,  }\item[{integer, intent(in)}]{method,  }\item[{real, dimension(\+:,\+:,\+:), pointer}]{mask,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(in)}]{diag,  }\item[{integer, intent(in)}]{isv\+\_\+o,  }\item[{integer, intent(in)}]{jsv\+\_\+o,  }\item[{integer, intent(in)}]{isv\+\_\+d,  }\item[{integer, intent(in)}]{iev\+\_\+d,  }\item[{integer, intent(in)}]{jsv\+\_\+d,  }\item[{integer, intent(in)}]{jev\+\_\+d }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine allocates and computes a down sampled 3d array given an input array The down sample method is based on the \char`\"{}cell\+\_\+methods\char`\"{} for the diagnostics as explained in the above table. 

\hypertarget{namespacemom__diag__mediator_downsampling}{}\subsection{The down sample algorithm}\label{namespacemom__diag__mediator_downsampling}
The down sample method could be deduced (before send\+\_\+data call) from the diagx\+\_\+cell\+\_\+method, diagy\+\_\+cell\+\_\+method and diagv\+\_\+cell\+\_\+method

This is the summary of the down sample algoritm for a diagnostic field f\+: \[ f(Id,Jd) = \sum_{i,j} f(Id+i,Jd+j) * weight(Id+i,Jd+j) / [ \sum_{i,j} weight(Id+i,Jd+j)] \] Here, i and j run from 0 to dl-\/1 (dl being the down sample level). Id,Jd are the down sampled (coarse grid) indices run over the coarsened compute grid, if and jf are the original (fine grid) indices.

\begin{DoxyVerb} Example   x_cell y_cell v_cell algorithm_id    implemented weight(if,jf)
 ---------------------------------------------------------------------------------------
 theta     mean   mean   mean   MMM =222        G%areaT(if,jf)*h(if,jf)
 u         point  mean   mean   PMM =022        dyCu(if,jf)*h(if,jf)*delta(if,Id)
 v         mean   point  mean   MPM =202        dxCv(if,jf)*h(if,jf)*delta(jf,Jd)
 ?         point  sum    mean   PSM =012        h(if,jf)*delta(if,Id)
 volcello  sum    sum    sum    SSS =111        1
 T_dfxy_co sum    sum    point  SSP =110        1
 umo       point  sum    sum    PSS =011        1*delta(if,Id)
 vmo       sum    point  sum    SPS =101        1*delta(jf,Jd)
 umo_2d    point  sum    point  PSP =010        1*delta(if,Id)
 vmo_2d    sum    point  point  SPP =100        1*delta(jf,Jd)
 ?         point  mean   point  PMP =020        dyCu(if,jf)*delta(if,Id)
 ?         mean   point  point  MPP =200        dxCv(if,jf)*delta(jf,Jd)
 w         mean   mean   point  MMP =220        G%areaT(if,jf)
 h*theta   mean   mean   sum    MMS =221        G%areaT(if,jf)

 delta is the Kronecker delta\end{DoxyVerb}



\begin{DoxyParams}[1]{Parameters}
 & {\em field\+\_\+in} & Original field to be down sampled\\
\hline
 & {\em field\+\_\+out} & down sampled field\\
\hline
\mbox{\tt in}  & {\em dl} & Level of down sampling\\
\hline
\mbox{\tt in}  & {\em method} & Sampling method\\
\hline
 & {\em mask} & Mask for field\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em diag} & A structure describing the diagnostic to post\\
\hline
\mbox{\tt in}  & {\em isv\+\_\+o} & Original i-\/start index\\
\hline
\mbox{\tt in}  & {\em jsv\+\_\+o} & Original j-\/start index\\
\hline
\mbox{\tt in}  & {\em isv\+\_\+d} & i-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em iev\+\_\+d} & i-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jsv\+\_\+d} & j-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jev\+\_\+d} & j-\/end index of down sampled data \\
\hline
\end{DoxyParams}


Definition at line 3951 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3951   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: field\_in\textcolor{comment}{      !< Original field to be down sampled}
3952   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: field\_out\textcolor{comment}{ !< down sampled field}
3953   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dl\textcolor{comment}{                !< Level of down sampling}
3954   \textcolor{keywordtype}{integer},  \textcolor{keywordtype}{intent(in)} :: method\textcolor{comment}{           !< Sampling method}
3955   \textcolor{keywordtype}{real},  \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: mask\textcolor{comment}{ !< Mask for field}
3956   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{   !< Structure used to regulate diagnostic output}
3957   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{      !< A structure describing the diagnostic to post}
3958   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isv\_o\textcolor{comment}{             !< Original i-start index}
3959   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsv\_o\textcolor{comment}{             !< Original j-start index}
3960   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isv\_d\textcolor{comment}{             !< i-start index of down sampled data}
3961   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: iev\_d\textcolor{comment}{             !< i-end index of down sampled data}
3962   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsv\_d\textcolor{comment}{             !< j-start index of down sampled data}
3963   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jev\_d\textcolor{comment}{             !< j-end index of down sampled data}
3964   \textcolor{comment}{! Locals}
3965   \textcolor{keywordtype}{character(len=240)} :: mesg
3966   \textcolor{keywordtype}{integer} :: i,j,ii,jj,i0,j0,f1,f2,f\_in1,f\_in2
3967   \textcolor{keywordtype}{integer} :: k,ks,ke
3968   \textcolor{keywordtype}{real} :: ave,total\_weight,weight
3969   \textcolor{keywordtype}{real} :: eps\_vol   \textcolor{comment}{! A negligibly small volume or mass [H L2 ~> m3 or kg]}
3970   \textcolor{keywordtype}{real} :: eps\_area  \textcolor{comment}{! A negligibly small area [L2 ~> m2]}
3971   \textcolor{keywordtype}{real} :: eps\_face  \textcolor{comment}{! A negligibly small face area [H L ~> m2 or kg m-1]}
3972 
3973   ks = 1 ; ke = \textcolor{keyword}{size}(field\_in,3)
3974   eps\_face = 1.0e-20 * diag\_cs%G%US%m\_to\_L * diag\_cs%GV%m\_to\_H
3975   eps\_area = 1.0e-20 * diag\_cs%G%US%m\_to\_L**2
3976   eps\_vol = 1.0e-20 * diag\_cs%G%US%m\_to\_L**2 * diag\_cs%GV%m\_to\_H
3977 
3978   \textcolor{comment}{! Allocate the down sampled field on the down sampled data domain}
3979 \textcolor{comment}{! 
       allocate(field\_out(diag\_cs%dsamp(dl)%isd:diag\_cs%dsamp(dl)%ied,diag\_cs%dsamp(dl)%jsd:diag\_cs%dsamp(dl)%jed,ks:ke))}
3980 \textcolor{comment}{!  allocate(field\_out(1:size(field\_in,1)/dl,1:size(field\_in,2)/dl,ks:ke))}
3981   f\_in1 = \textcolor{keyword}{size}(field\_in,1)
3982   f\_in2 = \textcolor{keyword}{size}(field\_in,2)
3983   f1 = f\_in1/dl
3984   f2 = f\_in2/dl
3985   \textcolor{comment}{!Correction for the symmetric case}
3986   \textcolor{keywordflow}{if} (diag\_cs%G%symmetric) \textcolor{keywordflow}{then}
3987      f1 = f1 + mod(f\_in1,dl)
3988      f2 = f2 + mod(f\_in2,dl)
3989 \textcolor{keywordflow}{  endif}
3990   \textcolor{keyword}{allocate}(field\_out(1:f1,1:f2,ks:ke))
3991 
3992   \textcolor{comment}{! Fill the down sampled field on the down sampled diagnostics (almost always compuate) domain}
3993   \textcolor{keywordflow}{if} (method == mmm) \textcolor{keywordflow}{then}
3994      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
3995         i0 = isv\_o+dl*(i-isv\_d)
3996         j0 = jsv\_o+dl*(j-jsv\_d)
3997         ave = 0.0
3998         total\_weight = 0.0
3999         \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4000 \textcolor{comment}{!        do ii=i0,i0+dl-1 ; do jj=j0,j0+dl-1 !This seems to be faster!!!!}
4001            weight = mask(ii,jj,k) * diag\_cs%G%areaT(ii,jj) * diag\_cs%h(ii,jj,k)
4002            total\_weight = total\_weight + weight
4003            ave = ave+field\_in(ii,jj,k) * weight
4004 \textcolor{keyword}{        end}do; enddo
4005         field\_out(i,j,k)  = ave/(total\_weight + eps\_vol)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4006 \textcolor{keyword}{     end}do; enddo; enddo
4007   \textcolor{keywordflow}{elseif} (method == sss) \textcolor{keywordflow}{then}    \textcolor{comment}{!e.g., volcello}
4008      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4009         i0 = isv\_o+dl*(i-isv\_d)
4010         j0 = jsv\_o+dl*(j-jsv\_d)
4011         ave = 0.0
4012         \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4013            weight = mask(ii,jj,k)
4014            ave = ave+field\_in(ii,jj,k)*weight
4015 \textcolor{keyword}{        end}do; enddo
4016         field\_out(i,j,k)  = ave \textcolor{comment}{!Masked Sum (total\_weight=1)}
4017 \textcolor{keyword}{     end}do; enddo; enddo
4018   \textcolor{keywordflow}{elseif}(method == mmp .or. method == mms) \textcolor{keywordflow}{then}    \textcolor{comment}{!e.g., T\_advection\_xy}
4019      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4020         i0 = isv\_o+dl*(i-isv\_d)
4021         j0 = jsv\_o+dl*(j-jsv\_d)
4022         ave = 0.0
4023         total\_weight = 0.0
4024         \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4025 \textcolor{comment}{!        do ii=i0,i0+dl-1 ; do jj=j0,j0+dl-1}
4026            weight = mask(ii,jj,k) * diag\_cs%G%areaT(ii,jj)
4027            total\_weight = total\_weight + weight
4028            ave = ave+field\_in(ii,jj,k)*weight
4029 \textcolor{keyword}{        end}do; enddo
4030         field\_out(i,j,k)  = ave / (total\_weight+eps\_area)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4031 \textcolor{keyword}{     end}do; enddo; enddo
4032   \textcolor{keywordflow}{elseif}(method == pmm) \textcolor{keywordflow}{then}
4033      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4034         i0 = isv\_o+dl*(i-isv\_d)
4035         j0 = jsv\_o+dl*(j-jsv\_d)
4036         ave = 0.0
4037         total\_weight = 0.0
4038         ii=i0
4039         \textcolor{keywordflow}{do} jj=j0,j0+dl-1
4040            weight =mask(ii,jj,k) * diag\_cs%G%dyCu(ii,jj) * diag\_cs%h(ii,jj,k)
4041            total\_weight = total\_weight +weight
4042            ave=ave+field\_in(ii,jj,k)*weight
4043 \textcolor{keywordflow}{        enddo}
4044         field\_out(i,j,k)  = ave/(total\_weight+eps\_face)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4045 \textcolor{keyword}{     end}do; enddo; enddo
4046   \textcolor{keywordflow}{elseif}(method == pss) \textcolor{keywordflow}{then}    \textcolor{comment}{!e.g. umo}
4047      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4048         i0 = isv\_o+dl*(i-isv\_d)
4049         j0 = jsv\_o+dl*(j-jsv\_d)
4050         ave = 0.0
4051         ii=i0
4052         \textcolor{keywordflow}{do} jj=j0,j0+dl-1
4053            weight =mask(ii,jj,k)
4054            ave=ave+field\_in(ii,jj,k)*weight
4055 \textcolor{keywordflow}{        enddo}
4056         field\_out(i,j,k)  = ave  \textcolor{comment}{!Masked Sum (total\_weight=1)}
4057 \textcolor{keyword}{     end}do; enddo; enddo
4058   \textcolor{keywordflow}{elseif}(method == sps) \textcolor{keywordflow}{then}    \textcolor{comment}{!e.g. vmo}
4059      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4060         i0 = isv\_o+dl*(i-isv\_d)
4061         j0 = jsv\_o+dl*(j-jsv\_d)
4062         ave = 0.0
4063         jj=j0
4064         \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4065            weight =mask(ii,jj,k)
4066            ave=ave+field\_in(ii,jj,k)*weight
4067 \textcolor{keywordflow}{        enddo}
4068         field\_out(i,j,k)  = ave  \textcolor{comment}{!Masked Sum (total\_weight=1)}
4069 \textcolor{keyword}{     end}do; enddo; enddo
4070   \textcolor{keywordflow}{elseif}(method == mpm) \textcolor{keywordflow}{then}
4071      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4072         i0 = isv\_o+dl*(i-isv\_d)
4073         j0 = jsv\_o+dl*(j-jsv\_d)
4074         ave = 0.0
4075         total\_weight = 0.0
4076         jj=j0
4077         \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4078            weight = mask(ii,jj,k) * diag\_cs%G%dxCv(ii,jj) * diag\_cs%h(ii,jj,k)
4079            total\_weight = total\_weight + weight
4080            ave=ave+field\_in(ii,jj,k)*weight
4081 \textcolor{keywordflow}{        enddo}
4082         field\_out(i,j,k)  = ave/(total\_weight+eps\_face)  \textcolor{comment}{!Avoid zero mask at all aggregating cells where
       ave=0.0}
4083 \textcolor{keyword}{     end}do; enddo; enddo
4084   \textcolor{keywordflow}{elseif}(method == msk) \textcolor{keywordflow}{then} \textcolor{comment}{!The input field is a mask, subsample}
4085      field\_out(:,:,:) = 0.0
4086      \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsv\_d,jev\_d ; \textcolor{keywordflow}{do} i=isv\_d,iev\_d
4087         i0 = isv\_o+dl*(i-isv\_d)
4088         j0 = jsv\_o+dl*(j-jsv\_d)
4089         ave = 0.0
4090         \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4091            ave=ave+field\_in(ii,jj,k)
4092 \textcolor{keyword}{        end}do; enddo
4093         \textcolor{keywordflow}{if}(ave > 0.0) field\_out(i,j,k)=1.0
4094 \textcolor{keyword}{     end}do; enddo; enddo
4095   \textcolor{keywordflow}{else}
4096      \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" unknown sampling method: "},method
4097      \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"downsample\_field\_3d: "}//trim(mesg)//\textcolor{stringliteral}{" "}//trim(diag%debug\_str))
4098 \textcolor{keywordflow}{  endif}
4099 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a8e211bead8fe3f37da32dfa010b55b90}\label{namespacemom__diag__mediator_a8e211bead8fe3f37da32dfa010b55b90}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+mask\+\_\+2d@{downsample\+\_\+mask\+\_\+2d}}
\index{downsample\+\_\+mask\+\_\+2d@{downsample\+\_\+mask\+\_\+2d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+mask\+\_\+2d()}{downsample\_mask\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+mask\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:), intent(in)}]{field\+\_\+in,  }\item[{real, dimension(\+:,\+:), pointer}]{field\+\_\+out,  }\item[{integer, intent(in)}]{dl,  }\item[{integer, intent(in)}]{isc\+\_\+o,  }\item[{integer, intent(in)}]{jsc\+\_\+o,  }\item[{integer, intent(in)}]{isc\+\_\+d,  }\item[{integer, intent(in)}]{iec\+\_\+d,  }\item[{integer, intent(in)}]{jsc\+\_\+d,  }\item[{integer, intent(in)}]{jec\+\_\+d,  }\item[{integer, intent(in)}]{isd\+\_\+d,  }\item[{integer, intent(in)}]{ied\+\_\+d,  }\item[{integer, intent(in)}]{jsd\+\_\+d,  }\item[{integer, intent(in)}]{jed\+\_\+d }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Allocate and compute the 2d down sampled mask The masks are down sampled based on a minority rule, i.\+e., a coarse cell is open (1) if at least one of the sub-\/cells are open, otherwise it\textquotesingle{}s closed (0) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em field\+\_\+in} & Original field to be down sampled\\
\hline
 & {\em field\+\_\+out} & Down sampled field\\
\hline
\mbox{\tt in}  & {\em dl} & Level of down sampling\\
\hline
\mbox{\tt in}  & {\em isc\+\_\+o} & Original i-\/start index\\
\hline
\mbox{\tt in}  & {\em jsc\+\_\+o} & Original j-\/start index\\
\hline
\mbox{\tt in}  & {\em isc\+\_\+d} & Computational i-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em iec\+\_\+d} & Computational i-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jsc\+\_\+d} & Computational j-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jec\+\_\+d} & Computational j-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em isd\+\_\+d} & Computational i-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em ied\+\_\+d} & Computational i-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jsd\+\_\+d} & Computational j-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jed\+\_\+d} & Computational j-\/end index of down sampled data \\
\hline
\end{DoxyParams}


Definition at line 4253 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
4253   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(in)} :: field\_in\textcolor{comment}{ !< Original field to be down sampled}
4254   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: field\_out\textcolor{comment}{   !< Down sampled field}
4255   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dl\textcolor{comment}{    !< Level of down sampling}
4256   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isc\_o\textcolor{comment}{ !< Original i-start index}
4257   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsc\_o\textcolor{comment}{ !< Original j-start index}
4258   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isc\_d\textcolor{comment}{ !< Computational i-start index of down sampled data}
4259   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: iec\_d\textcolor{comment}{ !< Computational i-end index of down sampled data}
4260   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsc\_d\textcolor{comment}{ !< Computational j-start index of down sampled data}
4261   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jec\_d\textcolor{comment}{ !< Computational j-end index of down sampled data}
4262   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isd\_d\textcolor{comment}{ !< Computational i-start index of down sampled data}
4263   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: ied\_d\textcolor{comment}{ !< Computational i-end index of down sampled data}
4264   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsd\_d\textcolor{comment}{ !< Computational j-start index of down sampled data}
4265   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jed\_d\textcolor{comment}{ !< Computational j-end index of down sampled data}
4266   \textcolor{comment}{! Locals}
4267   \textcolor{keywordtype}{integer} :: i,j,ii,jj,i0,j0
4268   \textcolor{keywordtype}{real}    :: tot\_non\_zero
4269   \textcolor{comment}{! down sampled mask = 0 unless the mask value of one of the down sampling cells is 1}
4270   \textcolor{keyword}{allocate}(field\_out(isd\_d:ied\_d,jsd\_d:jed\_d))
4271   field\_out(:,:) = 0.0
4272   \textcolor{keywordflow}{do} j=jsc\_d,jec\_d ; \textcolor{keywordflow}{do} i=isc\_d,iec\_d
4273      i0 = isc\_o+dl*(i-isc\_d)
4274      j0 = jsc\_o+dl*(j-jsc\_d)
4275      tot\_non\_zero = 0.0
4276      \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4277         tot\_non\_zero = tot\_non\_zero + field\_in(ii,jj)
4278 \textcolor{keyword}{     end}do;enddo
4279      \textcolor{keywordflow}{if}(tot\_non\_zero > 0.0) field\_out(i,j)=1.0
4280 \textcolor{keyword}{  end}do; enddo
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a0b0fe5fefbf6a1e9a5b1642f5852cdb6}\label{namespacemom__diag__mediator_a0b0fe5fefbf6a1e9a5b1642f5852cdb6}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!downsample\+\_\+mask\+\_\+3d@{downsample\+\_\+mask\+\_\+3d}}
\index{downsample\+\_\+mask\+\_\+3d@{downsample\+\_\+mask\+\_\+3d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{downsample\+\_\+mask\+\_\+3d()}{downsample\_mask\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::downsample\+\_\+mask\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{field\+\_\+in,  }\item[{real, dimension(\+:,\+:,\+:), pointer}]{field\+\_\+out,  }\item[{integer, intent(in)}]{dl,  }\item[{integer, intent(in)}]{isc\+\_\+o,  }\item[{integer, intent(in)}]{jsc\+\_\+o,  }\item[{integer, intent(in)}]{isc\+\_\+d,  }\item[{integer, intent(in)}]{iec\+\_\+d,  }\item[{integer, intent(in)}]{jsc\+\_\+d,  }\item[{integer, intent(in)}]{jec\+\_\+d,  }\item[{integer, intent(in)}]{isd\+\_\+d,  }\item[{integer, intent(in)}]{ied\+\_\+d,  }\item[{integer, intent(in)}]{jsd\+\_\+d,  }\item[{integer, intent(in)}]{jed\+\_\+d }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Allocate and compute the 3d down sampled mask The masks are down sampled based on a minority rule, i.\+e., a coarse cell is open (1) if at least one of the sub-\/cells are open, otherwise it\textquotesingle{}s closed (0) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em field\+\_\+in} & Original field to be down sampled\\
\hline
 & {\em field\+\_\+out} & down sampled field\\
\hline
\mbox{\tt in}  & {\em dl} & Level of down sampling\\
\hline
\mbox{\tt in}  & {\em isc\+\_\+o} & Original i-\/start index\\
\hline
\mbox{\tt in}  & {\em jsc\+\_\+o} & Original j-\/start index\\
\hline
\mbox{\tt in}  & {\em isc\+\_\+d} & Computational i-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em iec\+\_\+d} & Computational i-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jsc\+\_\+d} & Computational j-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jec\+\_\+d} & Computational j-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em isd\+\_\+d} & Computational i-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em ied\+\_\+d} & Computational i-\/end index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jsd\+\_\+d} & Computational j-\/start index of down sampled data\\
\hline
\mbox{\tt in}  & {\em jed\+\_\+d} & Computational j-\/end index of down sampled data \\
\hline
\end{DoxyParams}


Definition at line 4288 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
4288   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: field\_in\textcolor{comment}{ !< Original field to be down sampled}
4289   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: field\_out\textcolor{comment}{   !< down sampled field}
4290   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dl\textcolor{comment}{    !< Level of down sampling}
4291   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isc\_o\textcolor{comment}{ !< Original i-start index}
4292   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsc\_o\textcolor{comment}{ !< Original j-start index}
4293   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isc\_d\textcolor{comment}{ !< Computational i-start index of down sampled data}
4294   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: iec\_d\textcolor{comment}{ !< Computational i-end index of down sampled data}
4295   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsc\_d\textcolor{comment}{ !< Computational j-start index of down sampled data}
4296   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jec\_d\textcolor{comment}{ !< Computational j-end index of down sampled data}
4297   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: isd\_d\textcolor{comment}{ !< Computational i-start index of down sampled data}
4298   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: ied\_d\textcolor{comment}{ !< Computational i-end index of down sampled data}
4299   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jsd\_d\textcolor{comment}{ !< Computational j-start index of down sampled data}
4300   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: jed\_d\textcolor{comment}{ !< Computational j-end index of down sampled data}
4301   \textcolor{comment}{! Locals}
4302   \textcolor{keywordtype}{integer} :: i,j,ii,jj,i0,j0,k,ks,ke
4303   \textcolor{keywordtype}{real}    :: tot\_non\_zero
4304   \textcolor{comment}{! down sampled mask = 0 unless the mask value of one of the down sampling cells is 1}
4305   ks = lbound(field\_in,3) ; ke = ubound(field\_in,3)
4306   \textcolor{keyword}{allocate}(field\_out(isd\_d:ied\_d,jsd\_d:jed\_d,ks:ke))
4307   field\_out(:,:,:) = 0.0
4308   \textcolor{keywordflow}{do} k= ks,ke ; \textcolor{keywordflow}{do} j=jsc\_d,jec\_d ; \textcolor{keywordflow}{do} i=isc\_d,iec\_d
4309      i0 = isc\_o+dl*(i-isc\_d)
4310      j0 = jsc\_o+dl*(j-jsc\_d)
4311      tot\_non\_zero = 0.0
4312      \textcolor{keywordflow}{do} jj=j0,j0+dl-1 ; \textcolor{keywordflow}{do} ii=i0,i0+dl-1
4313         tot\_non\_zero = tot\_non\_zero + field\_in(ii,jj,k)
4314 \textcolor{keyword}{     end}do;enddo
4315      \textcolor{keywordflow}{if}(tot\_non\_zero > 0.0) field\_out(i,j,k)=1.0
4316 \textcolor{keyword}{  end}do; enddo; enddo
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ada4d9d69fb0d79a0fe20a307eaf1ca9c}\label{namespacemom__diag__mediator_ada4d9d69fb0d79a0fe20a307eaf1ca9c}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!enable\+\_\+averages@{enable\+\_\+averages}}
\index{enable\+\_\+averages@{enable\+\_\+averages}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{enable\+\_\+averages()}{enable\_averages()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::enable\+\_\+averages (\begin{DoxyParamCaption}\item[{real, intent(in)}]{time\+\_\+int,  }\item[{type(time\+\_\+type), intent(in)}]{time\+\_\+end,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+\+CS,  }\item[{real, intent(in), optional}]{T\+\_\+to\+\_\+s }\end{DoxyParamCaption})}



Enable the accumulation of time averages over the specified time interval in time units. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time\+\_\+int} & The time interval over which any values that are offered are valid \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+end} & The end time of the valid interval.\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & A structure that is used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em t\+\_\+to\+\_\+s} & A conversion factor for time\+\_\+int to \mbox{[}s\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 1886 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1886   \textcolor{keywordtype}{real},            \textcolor{keywordtype}{intent(in)}    :: time\_int\textcolor{comment}{ !< The time interval over which any values}
1887 \textcolor{comment}{                                             !! that are offered are valid [T ~> s].}
1888   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)}    :: time\_end\textcolor{comment}{ !< The end time of the valid interval.}
1889   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(inout)} :: diag\_CS\textcolor{comment}{  !< A structure that is used to regulate diagnostic output}
1890   \textcolor{keywordtype}{real},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: T\_to\_s\textcolor{comment}{   !< A conversion factor for time\_int to [s].}
1891 \textcolor{comment}{! This subroutine enables the accumulation of time averages over the specified time interval.}
1892 
1893   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(t\_to\_s)) \textcolor{keywordflow}{then}
1894     diag\_cs%time\_int = time\_int*t\_to\_s
1895   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(diag\_cs%US)) \textcolor{keywordflow}{then}
1896     diag\_cs%time\_int = time\_int*diag\_cs%US%T\_to\_s
1897   \textcolor{keywordflow}{else}
1898     diag\_cs%time\_int = time\_int
1899 \textcolor{keywordflow}{  endif}
1900   diag\_cs%time\_end = time\_end
1901   diag\_cs%ave\_enabled = .true.
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a91244f765f2964dfb11f8787f65042f1}\label{namespacemom__diag__mediator_a91244f765f2964dfb11f8787f65042f1}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!enable\+\_\+averaging@{enable\+\_\+averaging}}
\index{enable\+\_\+averaging@{enable\+\_\+averaging}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{enable\+\_\+averaging()}{enable\_averaging()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::enable\+\_\+averaging (\begin{DoxyParamCaption}\item[{real, intent(in)}]{time\+\_\+int\+\_\+in,  }\item[{type(time\+\_\+type), intent(in)}]{time\+\_\+end\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs }\end{DoxyParamCaption})}



This subroutine enables the accumulation of time averages over the specified time interval. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time\+\_\+int\+\_\+in} & The time interval \mbox{[}s\mbox{]} over which any values that are offered are valid.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+end\+\_\+in} & The end time of the valid interval\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 1871 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1871   \textcolor{keywordtype}{real},            \textcolor{keywordtype}{intent(in)}    :: time\_int\_in\textcolor{comment}{ !< The time interval [s] over which any}
1872 \textcolor{comment}{                                                !!  values that are offered are valid.}
1873   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)}    :: time\_end\_in\textcolor{comment}{ !< The end time of the valid interval}
1874   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(inout)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1875 
1876 \textcolor{comment}{! This subroutine enables the accumulation of time averages over the specified time interval.}
1877 
1878 \textcolor{comment}{!  if (num\_file==0) return}
1879   diag\_cs%time\_int = time\_int\_in
1880   diag\_cs%time\_end = time\_end\_in
1881   diag\_cs%ave\_enabled = .true.
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a76e845bc64dfd5116f41fe90922b7937}\label{namespacemom__diag__mediator_a76e845bc64dfd5116f41fe90922b7937}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!get\+\_\+diag\+\_\+time\+\_\+end@{get\+\_\+diag\+\_\+time\+\_\+end}}
\index{get\+\_\+diag\+\_\+time\+\_\+end@{get\+\_\+diag\+\_\+time\+\_\+end}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{get\+\_\+diag\+\_\+time\+\_\+end()}{get\_diag\_time\_end()}}
{\footnotesize\ttfamily type(time\+\_\+type) function, public mom\+\_\+diag\+\_\+mediator\+::get\+\_\+diag\+\_\+time\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs }\end{DoxyParamCaption})}



This function returns the valid end time for use with diagnostics that are handled outside of the M\+O\+M6 diagnostics infrastructure. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 1929 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1929   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(in)}  :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1930   \textcolor{keywordtype}{type}(time\_type) :: get\_diag\_time\_end
1931   \textcolor{comment}{!   This function returns the valid end time for diagnostics that are handled}
1932   \textcolor{comment}{! outside of the MOM6 infrastructure, such as via the generic tracer code.}
1933 
1934   get\_diag\_time\_end = diag\_cs%time\_end
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a3f7442639213320f7429e2288a79fda2}\label{namespacemom__diag__mediator_a3f7442639213320f7429e2288a79fda2}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!get\+\_\+new\+\_\+diag\+\_\+id@{get\+\_\+new\+\_\+diag\+\_\+id}}
\index{get\+\_\+new\+\_\+diag\+\_\+id@{get\+\_\+new\+\_\+diag\+\_\+id}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{get\+\_\+new\+\_\+diag\+\_\+id()}{get\_new\_diag\_id()}}
{\footnotesize\ttfamily integer function mom\+\_\+diag\+\_\+mediator\+::get\+\_\+new\+\_\+diag\+\_\+id (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns a new diagnostic id, it may be necessary to expand the diagnostics array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Diagnostics control structure \\
\hline
\end{DoxyParams}


Definition at line 3479 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3479   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{ !< Diagnostics control structure}
3480   \textcolor{comment}{! Local variables}
3481   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: tmp
3482   \textcolor{keywordtype}{integer} :: i
3483 
3484   \textcolor{keywordflow}{if} (diag\_cs%next\_free\_diag\_id > \textcolor{keyword}{size}(diag\_cs%diags)) \textcolor{keywordflow}{then}
3485     \textcolor{keyword}{call }assert(diag\_cs%next\_free\_diag\_id - \textcolor{keyword}{size}(diag\_cs%diags) == 1, &
3486                 \textcolor{stringliteral}{'get\_new\_diag\_id: inconsistent diag id'})
3487 
3488     \textcolor{comment}{! Increase the size of diag\_cs%diags and copy data over.}
3489     \textcolor{comment}{! Do not use move\_alloc() because it is not supported by Fortran 90}
3490     \textcolor{keyword}{allocate}(tmp(\textcolor{keyword}{size}(diag\_cs%diags)))
3491     tmp(:) = diag\_cs%diags(:)
3492     \textcolor{keyword}{deallocate}(diag\_cs%diags)
3493     \textcolor{keyword}{allocate}(diag\_cs%diags(\textcolor{keyword}{size}(tmp) + diag\_alloc\_chunk\_size))
3494     diag\_cs%diags(1:\textcolor{keyword}{size}(tmp)) = tmp(:)
3495     \textcolor{keyword}{deallocate}(tmp)
3496 
3497     \textcolor{comment}{! Initialize new part of the diag array.}
3498     \textcolor{keywordflow}{do} i=diag\_cs%next\_free\_diag\_id, \textcolor{keyword}{size}(diag\_cs%diags)
3499       \textcolor{keyword}{call }initialize\_diag\_type(diag\_cs%diags(i))
3500 \textcolor{keywordflow}{    enddo}
3501 \textcolor{keywordflow}{  endif}
3502 
3503   get\_new\_diag\_id = diag\_cs%next\_free\_diag\_id
3504   diag\_cs%next\_free\_diag\_id = diag\_cs%next\_free\_diag\_id + 1
3505 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a82d9bb70db16b1113304936c82d40e82}\label{namespacemom__diag__mediator_a82d9bb70db16b1113304936c82d40e82}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!i2s@{i2s}}
\index{i2s@{i2s}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{i2s()}{i2s()}}
{\footnotesize\ttfamily character(len=15) function mom\+\_\+diag\+\_\+mediator\+::i2s (\begin{DoxyParamCaption}\item[{integer, dimension(\+:), intent(in)}]{a,  }\item[{integer, intent(in), optional}]{n\+\_\+in }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Convert the first n elements (up to 3) of an integer array to an underscore delimited string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em a} & The array of integers to translate\\
\hline
\mbox{\tt in}  & {\em n\+\_\+in} & The number of elements to translate, by default all\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The returned string 
\end{DoxyReturn}


Definition at line 3457 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3457   \textcolor{comment}{! "Convert the first n elements of an integer array to a string."}
3458   \textcolor{comment}{! Perhaps this belongs elsewhere in the MOM6 code?}
3459   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: a\textcolor{comment}{    !< The array of integers to translate}
3460   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}    , \textcolor{keywordtype}{intent(in)} :: n\_in\textcolor{comment}{ !< The number of elements to translate, by default all}
3461   \textcolor{keywordtype}{character(len=15)} :: i2s\textcolor{comment}{ !< The returned string}
3462 
3463   \textcolor{keywordtype}{character(len=15)} :: i2s\_temp
3464   \textcolor{keywordtype}{integer} :: i,n
3465 
3466   n=\textcolor{keyword}{size}(a)
3467   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(n\_in)) n = n\_in
3468 
3469   i2s = \textcolor{stringliteral}{''}
3470   \textcolor{keywordflow}{do} i=1,min(n,3)
3471     \textcolor{keyword}{write} (i2s\_temp, \textcolor{stringliteral}{'(I4.4)'}) a(i)
3472     i2s = trim(i2s) //\textcolor{stringliteral}{'\_'}// trim(i2s\_temp)
3473 \textcolor{keywordflow}{  enddo}
3474   i2s = adjustl(i2s)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a883862f004e30bbc5211f38635511ba0}\label{namespacemom__diag__mediator_a883862f004e30bbc5211f38635511ba0}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!initialize\+\_\+diag\+\_\+type@{initialize\+\_\+diag\+\_\+type}}
\index{initialize\+\_\+diag\+\_\+type@{initialize\+\_\+diag\+\_\+type}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{initialize\+\_\+diag\+\_\+type()}{initialize\_diag\_type()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::initialize\+\_\+diag\+\_\+type (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(inout)}]{diag }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initializes a \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}} (used after allocating new memory) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em diag} & \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}} to be initialized \\
\hline
\end{DoxyParams}


Definition at line 3510 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3510   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< diag\_type to be initialized}
3511 
3512   diag%in\_use = .false.
3513   diag%fms\_diag\_id = -1
3514   diag%axes => null()
3515   diag%next => null()
3516   diag%conversion\_factor = 0.
3517 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a65fe8d329cf5dbfd08c98874a7a64407}\label{namespacemom__diag__mediator_a65fe8d329cf5dbfd08c98874a7a64407}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!log\+\_\+available\+\_\+diag@{log\+\_\+available\+\_\+diag}}
\index{log\+\_\+available\+\_\+diag@{log\+\_\+available\+\_\+diag}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{log\+\_\+available\+\_\+diag()}{log\_available\_diag()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::log\+\_\+available\+\_\+diag (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{used,  }\item[{character(len=$\ast$), intent(in)}]{module\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{field\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{cell\+\_\+methods\+\_\+string,  }\item[{character(len=$\ast$), intent(in)}]{comment,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+\+CS,  }\item[{character(len=$\ast$), intent(in), optional}]{long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{character(len=$\ast$), intent(in), optional}]{standard\+\_\+name }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Log a diagnostic to the available diagnostics file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em used} & Whether this diagnostic was in the diag\+\_\+table or not\\
\hline
\mbox{\tt in}  & {\em module\+\_\+name} & Name of the diagnostic module\\
\hline
\mbox{\tt in}  & {\em field\+\_\+name} & Name of this diagnostic field\\
\hline
\mbox{\tt in}  & {\em cell\+\_\+methods\+\_\+string} & The spatial component of the CF cell\+\_\+methods attribute\\
\hline
\mbox{\tt in}  & {\em comment} & A comment to append after \mbox{[}Used$\vert$\+Unused\mbox{]}\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & The diagnotics control structure\\
\hline
\mbox{\tt in}  & {\em long\+\_\+name} & CF long name of diagnostic\\
\hline
\mbox{\tt in}  & {\em units} & Units for diagnostic\\
\hline
\mbox{\tt in}  & {\em standard\+\_\+name} & CF standardized name of diagnostic \\
\hline
\end{DoxyParams}


Definition at line 3544 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3544   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: used\textcolor{comment}{ !< Whether this diagnostic was in the diag\_table or not}
3545   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: module\_name\textcolor{comment}{ !< Name of the diagnostic module}
3546   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: field\_name\textcolor{comment}{ !< Name of this diagnostic field}
3547   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: cell\_methods\_string\textcolor{comment}{ !< The spatial component of the CF cell\_methods
       attribute}
3548   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: comment\textcolor{comment}{ !< A comment to append after [Used|Unused]}
3549   \textcolor{keywordtype}{type}(diag\_ctrl),  \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{  !< The diagnotics control structure}
3550   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: long\_name\textcolor{comment}{ !< CF long name of diagnostic}
3551   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: units\textcolor{comment}{ !< Units for diagnostic}
3552   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: standard\_name\textcolor{comment}{ !< CF standardized name of diagnostic}
3553   \textcolor{comment}{! Local variables}
3554   \textcolor{keywordtype}{character(len=240)} :: mesg
3555 
3556   \textcolor{keywordflow}{if} (used) \textcolor{keywordflow}{then}
3557     mesg = \textcolor{stringliteral}{'"'}//trim(module\_name)//\textcolor{stringliteral}{'", "'}//trim(field\_name)//\textcolor{stringliteral}{'"  [Used]'}
3558   \textcolor{keywordflow}{else}
3559     mesg = \textcolor{stringliteral}{'"'}//trim(module\_name)//\textcolor{stringliteral}{'", "'}//trim(field\_name)//\textcolor{stringliteral}{'"  [Unused]'}
3560 \textcolor{keywordflow}{  endif}
3561   \textcolor{keywordflow}{if} (len(trim((comment)))>0) \textcolor{keywordflow}{then}
3562     \textcolor{keyword}{write}(diag\_cs%available\_diag\_doc\_unit, \textcolor{stringliteral}{'(a,x,"(",a,")")'}) trim(mesg),trim(comment)
3563   \textcolor{keywordflow}{else}
3564     \textcolor{keyword}{write}(diag\_cs%available\_diag\_doc\_unit, \textcolor{stringliteral}{'(a)'}) trim(mesg)
3565 \textcolor{keywordflow}{  endif}
3566   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(long\_name)) \textcolor{keyword}{call }describe\_option(\textcolor{stringliteral}{"long\_name"}, long\_name, diag\_cs)
3567   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units)) \textcolor{keyword}{call }describe\_option(\textcolor{stringliteral}{"units"}, units, diag\_cs)
3568   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(standard\_name)) &
3569     \textcolor{keyword}{call }describe\_option(\textcolor{stringliteral}{"standard\_name"}, standard\_name, diag\_cs)
3570   \textcolor{keywordflow}{if} (len(trim((cell\_methods\_string)))>0) &
3571     \textcolor{keyword}{call }describe\_option(\textcolor{stringliteral}{"cell\_methods"}, trim(cell\_methods\_string), diag\_cs)
3572 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_af410974feba66bf49817eccb7d1b6426}\label{namespacemom__diag__mediator_af410974feba66bf49817eccb7d1b6426}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!log\+\_\+chksum\+\_\+diag@{log\+\_\+chksum\+\_\+diag}}
\index{log\+\_\+chksum\+\_\+diag@{log\+\_\+chksum\+\_\+diag}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{log\+\_\+chksum\+\_\+diag()}{log\_chksum\_diag()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::log\+\_\+chksum\+\_\+diag (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{docunit,  }\item[{character(len=$\ast$), intent(in)}]{description,  }\item[{integer, intent(in)}]{chksum }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Log the diagnostic chksum to the chksum diag file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em docunit} & Handle of the log file\\
\hline
\mbox{\tt in}  & {\em description} & Name of the diagnostic module\\
\hline
\mbox{\tt in}  & {\em chksum} & chksum of the diagnostic \\
\hline
\end{DoxyParams}


Definition at line 3577 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
3577   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: docunit\textcolor{comment}{     !< Handle of the log file}
3578   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: description\textcolor{comment}{ !< Name of the diagnostic module}
3579   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: chksum\textcolor{comment}{      !< chksum of the diagnostic}
3580 
3581   \textcolor{keyword}{write}(docunit, \textcolor{stringliteral}{'(a,x,i9.8)'}) description, chksum
3582   \textcolor{keyword}{flush}(docunit)
3583 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a21267e25d12fa3e5d2540d2a299d2d2c}\label{namespacemom__diag__mediator_a21267e25d12fa3e5d2540d2a299d2d2c}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!ocean\+\_\+register\+\_\+diag@{ocean\+\_\+register\+\_\+diag}}
\index{ocean\+\_\+register\+\_\+diag@{ocean\+\_\+register\+\_\+diag}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{ocean\+\_\+register\+\_\+diag()}{ocean\_register\_diag()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+diag\+\_\+mediator\+::ocean\+\_\+register\+\_\+diag (\begin{DoxyParamCaption}\item[{type(vardesc), intent(in)}]{var\+\_\+desc,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag\+\_\+\+CS,  }\item[{type(time\+\_\+type), intent(in)}]{day }\end{DoxyParamCaption})}



Registers a diagnostic using the information encapsulated in the vardesc type argument and returns an integer handle to this diagostic. That integer handle is negative if the diagnostic is unused. 

\begin{DoxyReturn}{Returns}
An integer handle to this diagnostic.
\end{DoxyReturn}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em var\+\_\+desc} & The vardesc type describing the diagnostic\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid type\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & The diagnotic control structure\\
\hline
\mbox{\tt in}  & {\em day} & The current model time \\
\hline
\end{DoxyParams}


Definition at line 2926 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2926   \textcolor{keywordtype}{integer} :: ocean\_register\_diag\textcolor{comment}{  !< An integer handle to this diagnostic.}
2927   \textcolor{keywordtype}{type}(vardesc),         \textcolor{keywordtype}{intent(in)} :: var\_desc\textcolor{comment}{ !< The vardesc type describing the diagnostic}
2928   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{        !< The ocean's grid type}
2929   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{target} :: diag\_CS\textcolor{comment}{  !< The diagnotic control structure}
2930   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)} :: day\textcolor{comment}{      !< The current model time}
2931 
2932   \textcolor{keywordtype}{character(len=64)} :: var\_name         \textcolor{comment}{! A variable's name.}
2933   \textcolor{keywordtype}{character(len=48)} :: units            \textcolor{comment}{! A variable's units.}
2934   \textcolor{keywordtype}{character(len=240)} :: longname        \textcolor{comment}{! A variable's longname.}
2935   \textcolor{keywordtype}{character(len=8)} :: hor\_grid, z\_grid  \textcolor{comment}{! Variable grid info.}
2936   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{pointer} :: axes => null()
2937 
2938   \textcolor{keyword}{call }query\_vardesc(var\_desc, units=units, longname=longname, hor\_grid=hor\_grid, &
2939                      z\_grid=z\_grid, caller=\textcolor{stringliteral}{"ocean\_register\_diag"})
2940 
2941   \textcolor{comment}{! Use the hor\_grid and z\_grid components of vardesc to determine the}
2942   \textcolor{comment}{! desired axes to register the diagnostic field for.}
2943   \textcolor{keywordflow}{select case} (z\_grid)
2944 
2945     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"L"})
2946       \textcolor{keywordflow}{select case} (hor\_grid)
2947         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"q"})
2948           axes => diag\_cs%axesBL
2949         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"h"})
2950           axes => diag\_cs%axesTL
2951         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"u"})
2952           axes => diag\_cs%axesCuL
2953         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"v"})
2954           axes => diag\_cs%axesCvL
2955         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Bu"})
2956           axes => diag\_cs%axesBL
2957         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"T"})
2958           axes => diag\_cs%axesTL
2959         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Cu"})
2960           axes => diag\_cs%axesCuL
2961         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Cv"})
2962           axes => diag\_cs%axesCvL
2963         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"z"})
2964           axes => diag\_cs%axeszL
2965 \textcolor{keywordflow}{        case default}
2966           \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ocean\_register\_diag: "} // &
2967               \textcolor{stringliteral}{"unknown hor\_grid component "}//trim(hor\_grid))
2968 \textcolor{keywordflow}{      end select}
2969 
2970     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"i"})
2971       \textcolor{keywordflow}{select case} (hor\_grid)
2972         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"q"})
2973           axes => diag\_cs%axesBi
2974         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"h"})
2975           axes => diag\_cs%axesTi
2976         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"u"})
2977           axes => diag\_cs%axesCui
2978         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"v"})
2979           axes => diag\_cs%axesCvi
2980         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Bu"})
2981           axes => diag\_cs%axesBi
2982         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"T"})
2983           axes => diag\_cs%axesTi
2984         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Cu"})
2985           axes => diag\_cs%axesCui
2986         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Cv"})
2987           axes => diag\_cs%axesCvi
2988         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"z"})
2989           axes => diag\_cs%axeszi
2990 \textcolor{keywordflow}{        case default}
2991           \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ocean\_register\_diag: "} // &
2992             \textcolor{stringliteral}{"unknown hor\_grid component "}//trim(hor\_grid))
2993 \textcolor{keywordflow}{      end select}
2994 
2995     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"1"})
2996       \textcolor{keywordflow}{select case} (hor\_grid)
2997         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"q"})
2998           axes => diag\_cs%axesB1
2999         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"h"})
3000           axes => diag\_cs%axesT1
3001         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"u"})
3002           axes => diag\_cs%axesCu1
3003         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"v"})
3004           axes => diag\_cs%axesCv1
3005         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Bu"})
3006           axes => diag\_cs%axesB1
3007         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"T"})
3008           axes => diag\_cs%axesT1
3009         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Cu"})
3010           axes => diag\_cs%axesCu1
3011         \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"Cv"})
3012           axes => diag\_cs%axesCv1
3013 \textcolor{keywordflow}{        case default}
3014           \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ocean\_register\_diag: "} // &
3015             \textcolor{stringliteral}{"unknown hor\_grid component "}//trim(hor\_grid))
3016 \textcolor{keywordflow}{      end select}
3017 
3018 \textcolor{keywordflow}{    case default}
3019       \textcolor{keyword}{call }mom\_error(fatal,&
3020         \textcolor{stringliteral}{"ocean\_register\_diag: unknown z\_grid component "}//trim(z\_grid))
3021 \textcolor{keywordflow}{  end select}
3022 
3023   ocean\_register\_diag = register\_diag\_field(\textcolor{stringliteral}{"ocean\_model"}, trim(var\_name), &
3024           axes, day, trim(longname), trim(units), missing\_value=-1.0e+34)
3025 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ab98d892c30de2ee865416e519eacfd79}\label{namespacemom__diag__mediator_ab98d892c30de2ee865416e519eacfd79}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!post\+\_\+data\+\_\+0d@{post\+\_\+data\+\_\+0d}}
\index{post\+\_\+data\+\_\+0d@{post\+\_\+data\+\_\+0d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{post\+\_\+data\+\_\+0d()}{post\_data\_0d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::post\+\_\+data\+\_\+0d (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{diag\+\_\+field\+\_\+id,  }\item[{real, intent(in)}]{field,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag\+\_\+cs,  }\item[{logical, intent(in), optional}]{is\+\_\+static }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Make a real scalar diagnostic available for averaging or output. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+field\+\_\+id} & The id for an output variable returned by a previous call to register\+\_\+diag\+\_\+field.\\
\hline
\mbox{\tt in}  & {\em field} & real value being offered for output or averaging\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em is\+\_\+static} & If true, this is a static field that is always offered. \\
\hline
\end{DoxyParams}


Definition at line 1257 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1257   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: diag\_field\_id\textcolor{comment}{ !< The id for an output variable returned by a}
1258 \textcolor{comment}{                                                 !! previous call to register\_diag\_field.}
1259   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: field\textcolor{comment}{         !< real value being offered for output or averaging}
1260   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1261   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: is\_static\textcolor{comment}{ !< If true, this is a static field that is always offered.}
1262 
1263   \textcolor{comment}{! Local variables}
1264   \textcolor{keywordtype}{real} :: locfield
1265   \textcolor{keywordtype}{logical} :: used, is\_stat
1266   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: diag => null()
1267 
1268   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_mediator)
1269   is\_stat = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_static)) is\_stat = is\_static
1270 
1271   \textcolor{comment}{! Iterate over list of diag 'variants', e.g. CMOR aliases, call send\_data}
1272   \textcolor{comment}{! for each one.}
1273   \textcolor{keyword}{call }assert(diag\_field\_id < diag\_cs%next\_free\_diag\_id, &
1274               \textcolor{stringliteral}{'post\_data\_0d: Unregistered diagnostic id'})
1275   diag => diag\_cs%diags(diag\_field\_id)
1276 
1277   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (\textcolor{keyword}{associated}(diag))
1278     locfield = field
1279     \textcolor{keywordflow}{if} (diag%conversion\_factor /= 0.) &
1280       locfield = locfield * diag%conversion\_factor
1281 
1282     \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
1283       \textcolor{keyword}{call }chksum0(locfield, diag%debug\_str, logunit=diag\_cs%chksum\_iounit)
1284     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (is\_stat) \textcolor{keywordflow}{then}
1285       used = send\_data(diag%fms\_diag\_id, locfield)
1286     \textcolor{keywordflow}{elseif} (diag\_cs%ave\_enabled) \textcolor{keywordflow}{then}
1287       used = send\_data(diag%fms\_diag\_id, locfield, diag\_cs%time\_end)
1288 \textcolor{keywordflow}{    endif}
1289     diag => diag%next
1290 \textcolor{keywordflow}{  enddo}
1291 
1292   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_mediator)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ab5b75b68fa1742ce312c371f4b2c6ac1}\label{namespacemom__diag__mediator_ab5b75b68fa1742ce312c371f4b2c6ac1}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!post\+\_\+data\+\_\+1d\+\_\+k@{post\+\_\+data\+\_\+1d\+\_\+k}}
\index{post\+\_\+data\+\_\+1d\+\_\+k@{post\+\_\+data\+\_\+1d\+\_\+k}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{post\+\_\+data\+\_\+1d\+\_\+k()}{post\_data\_1d\_k()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::post\+\_\+data\+\_\+1d\+\_\+k (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{diag\+\_\+field\+\_\+id,  }\item[{real, dimension(\+:), intent(in), target}]{field,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag\+\_\+cs,  }\item[{logical, intent(in), optional}]{is\+\_\+static }\end{DoxyParamCaption})}



Make a real 1-\/d array diagnostic available for averaging or output. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+field\+\_\+id} & The id for an output variable returned by a previous call to register\+\_\+diag\+\_\+field.\\
\hline
\mbox{\tt in}  & {\em field} & 1-\/d array being offered for output or averaging\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em is\+\_\+static} & If true, this is a static field that is always offered. \\
\hline
\end{DoxyParams}


Definition at line 1297 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1297   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: diag\_field\_id\textcolor{comment}{ !< The id for an output variable returned by a}
1298 \textcolor{comment}{                                                 !! previous call to register\_diag\_field.}
1299   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{target},      \textcolor{keywordtype}{intent(in)} :: field(:)\textcolor{comment}{      !< 1-d array being offered for output or averaging}
1300   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1301   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: is\_static\textcolor{comment}{ !< If true, this is a static field that is always offered.}
1302 
1303   \textcolor{comment}{! Local variables}
1304   \textcolor{keywordtype}{logical} :: used  \textcolor{comment}{! The return value of send\_data is not used for anything.}
1305   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{pointer} :: locfield => null()
1306   \textcolor{keywordtype}{logical} :: is\_stat
1307   \textcolor{keywordtype}{integer} :: k, ks, ke
1308   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: diag => null()
1309 
1310   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_mediator)
1311   is\_stat = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_static)) is\_stat = is\_static
1312 
1313   \textcolor{comment}{! Iterate over list of diag 'variants', e.g. CMOR aliases.}
1314   \textcolor{keyword}{call }assert(diag\_field\_id < diag\_cs%next\_free\_diag\_id, &
1315               \textcolor{stringliteral}{'post\_data\_1d\_k: Unregistered diagnostic id'})
1316   diag => diag\_cs%diags(diag\_field\_id)
1317   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (\textcolor{keyword}{associated}(diag))
1318 
1319     \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.)) \textcolor{keywordflow}{then}
1320       ks = lbound(field,1) ; ke = ubound(field,1)
1321       \textcolor{keyword}{allocate}( locfield( ks:ke ) )
1322 
1323       \textcolor{keywordflow}{do} k=ks,ke
1324         \textcolor{keywordflow}{if} (field(k) == diag\_cs%missing\_value) \textcolor{keywordflow}{then}
1325           locfield(k) = diag\_cs%missing\_value
1326         \textcolor{keywordflow}{else}
1327           locfield(k) = field(k) * diag%conversion\_factor
1328 \textcolor{keywordflow}{        endif}
1329 \textcolor{keywordflow}{      enddo}
1330     \textcolor{keywordflow}{else}
1331       locfield => field
1332 \textcolor{keywordflow}{    endif}
1333 
1334     \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
1335       \textcolor{keyword}{call }zchksum(locfield, diag%debug\_str, logunit=diag\_cs%chksum\_iounit)
1336     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (is\_stat) \textcolor{keywordflow}{then}
1337       used = send\_data(diag%fms\_diag\_id, locfield)
1338     \textcolor{keywordflow}{elseif} (diag\_cs%ave\_enabled) \textcolor{keywordflow}{then}
1339       used = send\_data(diag%fms\_diag\_id, locfield, diag\_cs%time\_end, weight=diag\_cs%time\_int)
1340 \textcolor{keywordflow}{    endif}
1341     \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.)) \textcolor{keyword}{deallocate}( locfield )
1342 
1343     diag => diag%next
1344 \textcolor{keywordflow}{  enddo}
1345 
1346   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_mediator)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a2b87038d2cfd2f6709ecb9f4481e0e75}\label{namespacemom__diag__mediator_a2b87038d2cfd2f6709ecb9f4481e0e75}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!post\+\_\+data\+\_\+2d@{post\+\_\+data\+\_\+2d}}
\index{post\+\_\+data\+\_\+2d@{post\+\_\+data\+\_\+2d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{post\+\_\+data\+\_\+2d()}{post\_data\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::post\+\_\+data\+\_\+2d (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{diag\+\_\+field\+\_\+id,  }\item[{real, dimension(\+:,\+:), intent(in)}]{field,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag\+\_\+cs,  }\item[{logical, intent(in), optional}]{is\+\_\+static,  }\item[{real, dimension(\+:,\+:), intent(in), optional}]{mask }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Make a real 2-\/d array diagnostic available for averaging or output. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+field\+\_\+id} & The id for an output variable returned by a previous call to register\+\_\+diag\+\_\+field.\\
\hline
\mbox{\tt in}  & {\em field} & 2-\/d array being offered for output or averaging\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em is\+\_\+static} & If true, this is a static field that is always offered.\\
\hline
\mbox{\tt in}  & {\em mask} & If present, use this real array as the data mask. \\
\hline
\end{DoxyParams}


Definition at line 1351 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1351   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: diag\_field\_id\textcolor{comment}{ !< The id for an output variable returned by a}
1352 \textcolor{comment}{                                                 !! previous call to register\_diag\_field.}
1353   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: field(:,:)\textcolor{comment}{    !< 2-d array being offered for output or averaging}
1354   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1355   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: is\_static\textcolor{comment}{ !< If true, this is a static field that is always offered.}
1356   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: mask(:,:)\textcolor{comment}{ !< If present, use this real array as the data mask.}
1357 
1358   \textcolor{comment}{! Local variables}
1359   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: diag => null()
1360 
1361   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_mediator)
1362 
1363   \textcolor{comment}{! Iterate over list of diag 'variants' (e.g. CMOR aliases) and post each.}
1364   \textcolor{keyword}{call }assert(diag\_field\_id < diag\_cs%next\_free\_diag\_id, &
1365               \textcolor{stringliteral}{'post\_data\_2d: Unregistered diagnostic id'})
1366   diag => diag\_cs%diags(diag\_field\_id)
1367   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (\textcolor{keyword}{associated}(diag))
1368     \textcolor{keyword}{call }post\_data\_2d\_low(diag, field, diag\_cs, is\_static, mask)
1369     diag => diag%next
1370 \textcolor{keywordflow}{  enddo}
1371 
1372   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_mediator)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a633c4a461809f5843ac522616db8f382}\label{namespacemom__diag__mediator_a633c4a461809f5843ac522616db8f382}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!post\+\_\+data\+\_\+2d\+\_\+low@{post\+\_\+data\+\_\+2d\+\_\+low}}
\index{post\+\_\+data\+\_\+2d\+\_\+low@{post\+\_\+data\+\_\+2d\+\_\+low}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{post\+\_\+data\+\_\+2d\+\_\+low()}{post\_data\_2d\_low()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::post\+\_\+data\+\_\+2d\+\_\+low (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(in)}]{diag,  }\item[{real, dimension(\+:,\+:), intent(in), target}]{field,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{logical, intent(in), optional}]{is\+\_\+static,  }\item[{real, dimension(\+:,\+:), intent(in), optional, target}]{mask }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Make a real 2-\/d array diagnostic available for averaging or output using a \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}} instead of an integer id. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag} & A structure describing the diagnostic to post\\
\hline
\mbox{\tt in}  & {\em field} & 2-\/d array being offered for output or averaging\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em is\+\_\+static} & If true, this is a static field that is always offered.\\
\hline
\mbox{\tt in}  & {\em mask} & If present, use this real array as the data mask. \\
\hline
\end{DoxyParams}


Definition at line 1378 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1378   \textcolor{keywordtype}{type}(diag\_type),   \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{       !< A structure describing the diagnostic to post}
1379   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: field(:,:)\textcolor{comment}{ !< 2-d array being offered for output or averaging}
1380   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1381   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: is\_static\textcolor{comment}{ !< If true, this is a static field that is always offered.}
1382   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional},\textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: mask(:,:)\textcolor{comment}{ !< If present, use this real array as the data mask.}
1383 
1384   \textcolor{comment}{! Local variables}
1385   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: locfield
1386   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: locmask
1387   \textcolor{keywordtype}{character(len=300)} :: mesg
1388   \textcolor{keywordtype}{logical} :: used, is\_stat
1389   \textcolor{keywordtype}{integer} :: cszi, cszj, dszi, dszj
1390   \textcolor{keywordtype}{integer} :: isv, iev, jsv, jev, i, j, chksum, isv\_o,jsv\_o
1391   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: locfield\_dsamp
1392   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: locmask\_dsamp
1393   \textcolor{keywordtype}{integer} :: dl
1394 
1395   locfield => null()
1396   locmask => null()
1397   is\_stat = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_static)) is\_stat = is\_static
1398 
1399   \textcolor{comment}{! Determine the propery array indices, noting that because of the (:,:)}
1400   \textcolor{comment}{! declaration of field, symmetric arrays are using a SW-grid indexing,}
1401   \textcolor{comment}{! but non-symmetric arrays are using a NE-grid indexing.  Send\_data}
1402   \textcolor{comment}{! actually only uses the difference between ie and is to determine}
1403   \textcolor{comment}{! the output data size and assumes that halos are symmetric.}
1404   isv = diag\_cs%is ; iev = diag\_cs%ie ; jsv = diag\_cs%js ; jev = diag\_cs%je
1405 
1406   cszi = diag\_cs%ie-diag\_cs%is +1 ; dszi = diag\_cs%ied-diag\_cs%isd +1
1407   cszj = diag\_cs%je-diag\_cs%js +1 ; dszj = diag\_cs%jed-diag\_cs%jsd +1
1408   \textcolor{keywordflow}{if} ( \textcolor{keyword}{size}(field,1) == dszi ) \textcolor{keywordflow}{then}
1409     isv = diag\_cs%is ; iev = diag\_cs%ie     \textcolor{comment}{! Data domain}
1410   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,1) == dszi + 1 ) \textcolor{keywordflow}{then}
1411     isv = diag\_cs%is ; iev = diag\_cs%ie+1   \textcolor{comment}{! Symmetric data domain}
1412   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,1) == cszi) \textcolor{keywordflow}{then}
1413     isv = 1 ; iev = cszi                    \textcolor{comment}{! Computational domain}
1414   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,1) == cszi + 1 ) \textcolor{keywordflow}{then}
1415     isv = 1 ; iev = cszi+1                  \textcolor{comment}{! Symmetric computational domain}
1416   \textcolor{keywordflow}{else}
1417     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" peculiar size "},\textcolor{keyword}{size}(field,1),\textcolor{stringliteral}{" in i-direction\(\backslash\)n"}//&
1418        \textcolor{stringliteral}{"does not match one of "}, cszi, cszi+1, dszi, dszi+1
1419     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"post\_data\_2d\_low: "}//trim(diag%debug\_str)//trim(mesg))
1420 \textcolor{keywordflow}{  endif}
1421 
1422   \textcolor{keywordflow}{if} ( \textcolor{keyword}{size}(field,2) == dszj ) \textcolor{keywordflow}{then}
1423     jsv = diag\_cs%js ; jev = diag\_cs%je     \textcolor{comment}{! Data domain}
1424   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,2) == dszj + 1 ) \textcolor{keywordflow}{then}
1425     jsv = diag\_cs%js ; jev = diag\_cs%je+1   \textcolor{comment}{! Symmetric data domain}
1426   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,2) == cszj ) \textcolor{keywordflow}{then}
1427     jsv = 1 ; jev = cszj                    \textcolor{comment}{! Computational domain}
1428   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,2) == cszj+1 ) \textcolor{keywordflow}{then}
1429     jsv = 1 ; jev = cszj+1                  \textcolor{comment}{! Symmetric computational domain}
1430   \textcolor{keywordflow}{else}
1431     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" peculiar size "},\textcolor{keyword}{size}(field,2),\textcolor{stringliteral}{" in j-direction\(\backslash\)n"}//&
1432        \textcolor{stringliteral}{"does not match one of "}, cszj, cszj+1, dszj, dszj+1
1433     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"post\_data\_2d\_low: "}//trim(diag%debug\_str)//trim(mesg))
1434 \textcolor{keywordflow}{  endif}
1435 
1436   \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.)) \textcolor{keywordflow}{then}
1437     \textcolor{keyword}{allocate}( locfield( lbound(field,1):ubound(field,1), lbound(field,2):ubound(field,2) ) )
1438     \textcolor{keywordflow}{do} j=jsv,jev ; \textcolor{keywordflow}{do} i=isv,iev
1439       \textcolor{keywordflow}{if} (field(i,j) == diag\_cs%missing\_value) \textcolor{keywordflow}{then}
1440         locfield(i,j) = diag\_cs%missing\_value
1441       \textcolor{keywordflow}{else}
1442         locfield(i,j) = field(i,j) * diag%conversion\_factor
1443 \textcolor{keywordflow}{      endif}
1444 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1445     locfield(isv:iev,jsv:jev) = field(isv:iev,jsv:jev) * diag%conversion\_factor
1446   \textcolor{keywordflow}{else}
1447     locfield => field
1448 \textcolor{keywordflow}{  endif}
1449 
1450   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1451      locmask => mask
1452   \textcolor{keywordflow}{elseif}(.NOT. is\_stat) \textcolor{keywordflow}{then}
1453      \textcolor{keywordflow}{if}(\textcolor{keyword}{associated}(diag%axes%mask2d)) locmask => diag%axes%mask2d
1454 \textcolor{keywordflow}{  endif}
1455 
1456   dl=1
1457   \textcolor{keywordflow}{if}(.NOT. is\_stat) dl = diag%axes%downsample\_level \textcolor{comment}{!static field downsample i not supported yet}
1458   \textcolor{comment}{!Downsample the diag field and mask (if present)}
1459   \textcolor{keywordflow}{if} (dl > 1) \textcolor{keywordflow}{then}
1460      isv\_o=isv ; jsv\_o=jsv
1461      \textcolor{keyword}{call }downsample\_diag\_field(locfield, locfield\_dsamp, dl, diag\_cs, diag,isv,iev,jsv,jev, mask)
1462      \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.)) \textcolor{keyword}{deallocate}( locfield )
1463      locfield => locfield\_dsamp
1464      \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1465         \textcolor{keyword}{call }downsample\_field\_2d(locmask, locmask\_dsamp, dl, msk, locmask, diag\_cs,diag,isv\_o,jsv\_o,isv,iev
      ,jsv,jev)
1466         locmask => locmask\_dsamp
1467      \textcolor{keywordflow}{elseif}(\textcolor{keyword}{associated}(diag%axes%dsamp(dl)%mask2d)) \textcolor{keywordflow}{then}
1468         locmask => diag%axes%dsamp(dl)%mask2d
1469 \textcolor{keywordflow}{     endif}
1470 \textcolor{keywordflow}{  endif}
1471 
1472   \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
1473     \textcolor{keywordflow}{if} (diag%axes%is\_h\_point) \textcolor{keywordflow}{then}
1474       \textcolor{keyword}{call }hchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1475                    logunit=diag\_cs%chksum\_iounit)
1476     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (diag%axes%is\_u\_point) \textcolor{keywordflow}{then}
1477       \textcolor{keyword}{call }uchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1478                    logunit=diag\_cs%chksum\_iounit)
1479     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (diag%axes%is\_v\_point) \textcolor{keywordflow}{then}
1480       \textcolor{keyword}{call }vchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1481                    logunit=diag\_cs%chksum\_iounit)
1482     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (diag%axes%is\_q\_point) \textcolor{keywordflow}{then}
1483       \textcolor{keyword}{call }bchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1484                    logunit=diag\_cs%chksum\_iounit)
1485     \textcolor{keywordflow}{else}
1486       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"post\_data\_2d\_low: unknown axis type."})
1487 \textcolor{keywordflow}{    endif}
1488   \textcolor{keywordflow}{else}
1489     \textcolor{keywordflow}{if} (is\_stat) \textcolor{keywordflow}{then}
1490       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1491         \textcolor{keyword}{call }assert(\textcolor{keyword}{size}(locfield) == \textcolor{keyword}{size}(locmask), &
1492             \textcolor{stringliteral}{'post\_data\_2d\_low is\_stat: mask size mismatch: '}//diag%debug\_str)
1493         used = send\_data(diag%fms\_diag\_id, locfield, &
1494                          is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, rmask=locmask)
1495      \textcolor{comment}{!elseif (associated(diag%axes%mask2d)) then}
1496      \textcolor{comment}{!  used = send\_data(diag%fms\_diag\_id, locfield, &}
1497      \textcolor{comment}{!                   is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, rmask=diag%axes%mask2d)}
1498       \textcolor{keywordflow}{else}
1499         used = send\_data(diag%fms\_diag\_id, locfield, &
1500                          is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev)
1501 \textcolor{keywordflow}{      endif}
1502     \textcolor{keywordflow}{elseif} (diag\_cs%ave\_enabled) \textcolor{keywordflow}{then}
1503       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(locmask)) \textcolor{keywordflow}{then}
1504         \textcolor{keyword}{call }assert(\textcolor{keyword}{size}(locfield) == \textcolor{keyword}{size}(locmask), &
1505             \textcolor{stringliteral}{'post\_data\_2d\_low: mask size mismatch: '}//diag%debug\_str)
1506         used = send\_data(diag%fms\_diag\_id, locfield, diag\_cs%time\_end, &
1507                          is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, &
1508                          weight=diag\_cs%time\_int, rmask=locmask)
1509       \textcolor{keywordflow}{else}
1510         used = send\_data(diag%fms\_diag\_id, locfield, diag\_cs%time\_end, &
1511                          is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, &
1512                          weight=diag\_cs%time\_int)
1513 \textcolor{keywordflow}{      endif}
1514 \textcolor{keywordflow}{    endif}
1515 \textcolor{keywordflow}{  endif}
1516   \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.) .and. dl<2) &
1517     \textcolor{keyword}{deallocate}( locfield )
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a70116fa6034dcf977a8bdcb4d81f9207}\label{namespacemom__diag__mediator_a70116fa6034dcf977a8bdcb4d81f9207}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!post\+\_\+data\+\_\+3d@{post\+\_\+data\+\_\+3d}}
\index{post\+\_\+data\+\_\+3d@{post\+\_\+data\+\_\+3d}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{post\+\_\+data\+\_\+3d()}{post\_data\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::post\+\_\+data\+\_\+3d (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{diag\+\_\+field\+\_\+id,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{field,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in), target}]{diag\+\_\+cs,  }\item[{logical, intent(in), optional}]{is\+\_\+static,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), optional}]{mask,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), optional, target}]{alt\+\_\+h }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Make a real 3-\/d array diagnostic available for averaging or output. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+field\+\_\+id} & The id for an output variable returned by a previous call to register\+\_\+diag\+\_\+field.\\
\hline
\mbox{\tt in}  & {\em field} & 3-\/d array being offered for output or averaging\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em is\+\_\+static} & If true, this is a static field that is always offered.\\
\hline
\mbox{\tt in}  & {\em mask} & If present, use this real array as the data mask.\\
\hline
\mbox{\tt in}  & {\em alt\+\_\+h} & An alternate thickness to use for vertically \\
\hline
\end{DoxyParams}


Definition at line 1522 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1522 
1523   \textcolor{keywordtype}{integer},           \textcolor{keywordtype}{intent(in)} :: diag\_field\_id\textcolor{comment}{ !< The id for an output variable returned by a}
1524 \textcolor{comment}{                                                 !! previous call to register\_diag\_field.}
1525   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: field(:,:,:)\textcolor{comment}{  !< 3-d array being offered for output or averaging}
1526   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1527   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: is\_static\textcolor{comment}{ !< If true, this is a static field that is always offered.}
1528   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: mask(:,:,:)\textcolor{comment}{ !< If present, use this real array as the data mask.}
1529   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, &
1530          \textcolor{keywordtype}{target}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: alt\_h\textcolor{comment}{  !< An alternate thickness to use for vertically}
1531 \textcolor{comment}{                                                !! remapping this diagnostic [H ~> m or kg m-2].}
1532 
1533   \textcolor{comment}{! Local variables}
1534   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: diag => null()
1535   \textcolor{keywordtype}{integer} :: nz, i, j, k
1536   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: remapped\_field
1537   \textcolor{keywordtype}{logical} :: staggered\_in\_x, staggered\_in\_y
1538   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: h\_diag => null()
1539 
1540   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_mediator)
1541 
1542   \textcolor{comment}{! For intensive variables only, we can choose to use a different diagnostic grid}
1543   \textcolor{comment}{! to map to}
1544   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(alt\_h)) \textcolor{keywordflow}{then}
1545     h\_diag => alt\_h
1546   \textcolor{keywordflow}{else}
1547     h\_diag => diag\_cs%h
1548 \textcolor{keywordflow}{  endif}
1549 
1550   \textcolor{comment}{! Iterate over list of diag 'variants', e.g. CMOR aliases, different vertical}
1551   \textcolor{comment}{! grids, and post each.}
1552   \textcolor{keyword}{call }assert(diag\_field\_id < diag\_cs%next\_free\_diag\_id, &
1553               \textcolor{stringliteral}{'post\_data\_3d: Unregistered diagnostic id'})
1554   diag => diag\_cs%diags(diag\_field\_id)
1555   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (\textcolor{keyword}{associated}(diag))
1556     \textcolor{keyword}{call }assert(\textcolor{keyword}{associated}(diag%axes), \textcolor{stringliteral}{'post\_data\_3d: axes is not associated'})
1557 
1558     staggered\_in\_x = diag%axes%is\_u\_point .or. diag%axes%is\_q\_point
1559     staggered\_in\_y = diag%axes%is\_v\_point .or. diag%axes%is\_q\_point
1560 
1561     \textcolor{keywordflow}{if} (diag%v\_extensive .and. .not.diag%axes%is\_native) \textcolor{keywordflow}{then}
1562       \textcolor{comment}{! The field is vertically integrated and needs to be re-gridded}
1563       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1564         \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"post\_data\_3d: no mask for regridded field."})
1565 \textcolor{keywordflow}{      endif}
1566 
1567       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_remap)
1568       \textcolor{keyword}{allocate}(remapped\_field(\textcolor{keyword}{size}(field,1), \textcolor{keyword}{size}(field,2), diag%axes%nz))
1569       \textcolor{keyword}{call }vertically\_reintegrate\_diag\_field(                                    &
1570         diag\_cs%diag\_remap\_cs(diag%axes%vertical\_coordinate\_number), diag\_cs%G,  &
1571         diag\_cs%h\_begin,                                                         &
1572         diag\_cs%diag\_remap\_cs(diag%axes%vertical\_coordinate\_number)%h\_extensive, &
1573         staggered\_in\_x, staggered\_in\_y, diag%axes%mask3d, field, remapped\_field)
1574       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_remap)
1575       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(diag%axes%mask3d)) \textcolor{keywordflow}{then}
1576         \textcolor{comment}{! Since 3d masks do not vary in the vertical, just use as much as is}
1577         \textcolor{comment}{! needed.}
1578         \textcolor{keyword}{call }post\_data\_3d\_low(diag, remapped\_field, diag\_cs, is\_static, &
1579                               mask=diag%axes%mask3d)
1580       \textcolor{keywordflow}{else}
1581         \textcolor{keyword}{call }post\_data\_3d\_low(diag, remapped\_field, diag\_cs, is\_static)
1582 \textcolor{keywordflow}{      endif}
1583       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_remap)
1584       \textcolor{keyword}{deallocate}(remapped\_field)
1585       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_remap)
1586     \textcolor{keywordflow}{elseif} (diag%axes%needs\_remapping) \textcolor{keywordflow}{then}
1587       \textcolor{comment}{! Remap this field to another vertical coordinate.}
1588       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1589         \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"post\_data\_3d: no mask for regridded field."})
1590 \textcolor{keywordflow}{      endif}
1591 
1592       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_remap)
1593       \textcolor{keyword}{allocate}(remapped\_field(\textcolor{keyword}{size}(field,1), \textcolor{keyword}{size}(field,2), diag%axes%nz))
1594       \textcolor{keyword}{call }diag\_remap\_do\_remap(diag\_cs%diag\_remap\_cs(diag%axes%vertical\_coordinate\_number), &
1595               diag\_cs%G, diag\_cs%GV, h\_diag, staggered\_in\_x, staggered\_in\_y, &
1596               diag%axes%mask3d, field, remapped\_field)
1597       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_remap)
1598       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(diag%axes%mask3d)) \textcolor{keywordflow}{then}
1599         \textcolor{comment}{! Since 3d masks do not vary in the vertical, just use as much as is}
1600         \textcolor{comment}{! needed.}
1601         \textcolor{keyword}{call }post\_data\_3d\_low(diag, remapped\_field, diag\_cs, is\_static, &
1602                               mask=diag%axes%mask3d)
1603       \textcolor{keywordflow}{else}
1604         \textcolor{keyword}{call }post\_data\_3d\_low(diag, remapped\_field, diag\_cs, is\_static)
1605 \textcolor{keywordflow}{      endif}
1606       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_remap)
1607       \textcolor{keyword}{deallocate}(remapped\_field)
1608       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_remap)
1609     \textcolor{keywordflow}{elseif} (diag%axes%needs\_interpolating) \textcolor{keywordflow}{then}
1610       \textcolor{comment}{! Interpolate this field to another vertical coordinate.}
1611       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1612         \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"post\_data\_3d: no mask for regridded field."})
1613 \textcolor{keywordflow}{      endif}
1614 
1615       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_remap)
1616       \textcolor{keyword}{allocate}(remapped\_field(\textcolor{keyword}{size}(field,1), \textcolor{keyword}{size}(field,2), diag%axes%nz+1))
1617       \textcolor{keyword}{call }vertically\_interpolate\_diag\_field(diag\_cs%diag\_remap\_cs( &
1618               diag%axes%vertical\_coordinate\_number), &
1619               diag\_cs%G, h\_diag, staggered\_in\_x, staggered\_in\_y, &
1620               diag%axes%mask3d, field, remapped\_field)
1621       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_remap)
1622       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(diag%axes%mask3d)) \textcolor{keywordflow}{then}
1623         \textcolor{comment}{! Since 3d masks do not vary in the vertical, just use as much as is}
1624         \textcolor{comment}{! needed.}
1625         \textcolor{keyword}{call }post\_data\_3d\_low(diag, remapped\_field, diag\_cs, is\_static, &
1626                               mask=diag%axes%mask3d)
1627       \textcolor{keywordflow}{else}
1628         \textcolor{keyword}{call }post\_data\_3d\_low(diag, remapped\_field, diag\_cs, is\_static)
1629 \textcolor{keywordflow}{      endif}
1630       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diag\_remap)
1631       \textcolor{keyword}{deallocate}(remapped\_field)
1632       \textcolor{keywordflow}{if} (id\_clock\_diag\_remap>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_remap)
1633     \textcolor{keywordflow}{else}
1634       \textcolor{keyword}{call }post\_data\_3d\_low(diag, field, diag\_cs, is\_static, mask)
1635 \textcolor{keywordflow}{    endif}
1636     diag => diag%next
1637 \textcolor{keywordflow}{  enddo}
1638   \textcolor{keywordflow}{if} (id\_clock\_diag\_mediator>0) \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diag\_mediator)
1639 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ae11cae949c3f8cf68d2c70f656aa9c54}\label{namespacemom__diag__mediator_ae11cae949c3f8cf68d2c70f656aa9c54}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!post\+\_\+data\+\_\+3d\+\_\+low@{post\+\_\+data\+\_\+3d\+\_\+low}}
\index{post\+\_\+data\+\_\+3d\+\_\+low@{post\+\_\+data\+\_\+3d\+\_\+low}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{post\+\_\+data\+\_\+3d\+\_\+low()}{post\_data\_3d\_low()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::post\+\_\+data\+\_\+3d\+\_\+low (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(in)}]{diag,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), target}]{field,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{logical, intent(in), optional}]{is\+\_\+static,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), optional, target}]{mask }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Make a real 3-\/d array diagnostic available for averaging or output using a \mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}} instead of an integer id. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag} & A structure describing the diagnostic to post\\
\hline
\mbox{\tt in}  & {\em field} & 3-\/d array being offered for output or averaging\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em is\+\_\+static} & If true, this is a static field that is always offered.\\
\hline
\mbox{\tt in}  & {\em mask} & If present, use this real array as the data mask. \\
\hline
\end{DoxyParams}


Definition at line 1645 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1645   \textcolor{keywordtype}{type}(diag\_type),   \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{       !< A structure describing the diagnostic to post}
1646   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: field(:,:,:)\textcolor{comment}{ !< 3-d array being offered for output or averaging}
1647   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1648   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: is\_static\textcolor{comment}{ !< If true, this is a static field that is always offered.}
1649   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional},\textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: mask(:,:,:)\textcolor{comment}{ !< If present, use this real array as the data mask.}
1650 
1651   \textcolor{comment}{! Local variables}
1652   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: locfield
1653   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: locmask
1654   \textcolor{keywordtype}{character(len=300)} :: mesg
1655   \textcolor{keywordtype}{logical} :: used  \textcolor{comment}{! The return value of send\_data is not used for anything.}
1656   \textcolor{keywordtype}{logical} :: staggered\_in\_x, staggered\_in\_y
1657   \textcolor{keywordtype}{logical} :: is\_stat
1658   \textcolor{keywordtype}{integer} :: cszi, cszj, dszi, dszj
1659   \textcolor{keywordtype}{integer} :: isv, iev, jsv, jev, ks, ke, i, j, k, isv\_c, jsv\_c, isv\_o,jsv\_o
1660   \textcolor{keywordtype}{integer} :: chksum
1661   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: locfield\_dsamp
1662   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: locmask\_dsamp
1663   \textcolor{keywordtype}{integer} :: dl
1664 
1665   locfield => null()
1666   locmask => null()
1667   is\_stat = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(is\_static)) is\_stat = is\_static
1668 
1669   \textcolor{comment}{! Determine the proper array indices, noting that because of the (:,:)}
1670   \textcolor{comment}{! declaration of field, symmetric arrays are using a SW-grid indexing,}
1671   \textcolor{comment}{! but non-symmetric arrays are using a NE-grid indexing.  Send\_data}
1672   \textcolor{comment}{! actually only uses the difference between ie and is to determine}
1673   \textcolor{comment}{! the output data size and assumes that halos are symmetric.}
1674   isv = diag\_cs%is ; iev = diag\_cs%ie ; jsv = diag\_cs%js ; jev = diag\_cs%je
1675 
1676   cszi = (diag\_cs%ie-diag\_cs%is) +1 ; dszi = (diag\_cs%ied-diag\_cs%isd) +1
1677   cszj = (diag\_cs%je-diag\_cs%js) +1 ; dszj = (diag\_cs%jed-diag\_cs%jsd) +1
1678   \textcolor{keywordflow}{if} ( \textcolor{keyword}{size}(field,1) == dszi ) \textcolor{keywordflow}{then}
1679     isv = diag\_cs%is ; iev = diag\_cs%ie     \textcolor{comment}{! Data domain}
1680   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,1) == dszi + 1 ) \textcolor{keywordflow}{then}
1681     isv = diag\_cs%is ; iev = diag\_cs%ie+1   \textcolor{comment}{! Symmetric data domain}
1682   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,1) == cszi) \textcolor{keywordflow}{then}
1683     isv = 1 ; iev = cszi                    \textcolor{comment}{! Computational domain}
1684   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,1) == cszi + 1 ) \textcolor{keywordflow}{then}
1685     isv = 1 ; iev = cszi+1                  \textcolor{comment}{! Symmetric computational domain}
1686   \textcolor{keywordflow}{else}
1687     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" peculiar size "},\textcolor{keyword}{size}(field,1),\textcolor{stringliteral}{" in i-direction\(\backslash\)n"}//&
1688        \textcolor{stringliteral}{"does not match one of "}, cszi, cszi+1, dszi, dszi+1
1689     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"post\_data\_3d\_low: "}//trim(diag%debug\_str)//trim(mesg))
1690 \textcolor{keywordflow}{  endif}
1691 
1692   \textcolor{keywordflow}{if} ( \textcolor{keyword}{size}(field,2) == dszj ) \textcolor{keywordflow}{then}
1693     jsv = diag\_cs%js ; jev = diag\_cs%je     \textcolor{comment}{! Data domain}
1694   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,2) == dszj + 1 ) \textcolor{keywordflow}{then}
1695     jsv = diag\_cs%js ; jev = diag\_cs%je+1   \textcolor{comment}{! Symmetric data domain}
1696   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,2) == cszj ) \textcolor{keywordflow}{then}
1697     jsv = 1 ; jev = cszj                    \textcolor{comment}{! Computational domain}
1698   \textcolor{keywordflow}{elseif} ( \textcolor{keyword}{size}(field,2) == cszj+1 ) \textcolor{keywordflow}{then}
1699     jsv = 1 ; jev = cszj+1                  \textcolor{comment}{! Symmetric computational domain}
1700   \textcolor{keywordflow}{else}
1701     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{" peculiar size "},\textcolor{keyword}{size}(field,2),\textcolor{stringliteral}{" in j-direction\(\backslash\)n"}//&
1702        \textcolor{stringliteral}{"does not match one of "}, cszj, cszj+1, dszj, dszj+1
1703     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"post\_data\_3d\_low: "}//trim(diag%debug\_str)//trim(mesg))
1704 \textcolor{keywordflow}{  endif}
1705 
1706   ks = lbound(field,3) ; ke = ubound(field,3)
1707   \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.)) \textcolor{keywordflow}{then}
1708     \textcolor{keyword}{allocate}( locfield( lbound(field,1):ubound(field,1), lbound(field,2):ubound(field,2), ks:ke ) )
1709     \textcolor{comment}{! locfield(:,:,:) = 0.0  ! Zeroing out this array would be a good idea, but it appears}
1710                              \textcolor{comment}{! not to be necessary.}
1711     isv\_c = isv ; jsv\_c = jsv
1712     \textcolor{keywordflow}{if} (diag%fms\_xyave\_diag\_id>0) \textcolor{keywordflow}{then}
1713       staggered\_in\_x = diag%axes%is\_u\_point .or. diag%axes%is\_q\_point
1714       staggered\_in\_y = diag%axes%is\_v\_point .or. diag%axes%is\_q\_point
1715       \textcolor{comment}{! When averaging a staggered field, edge points are always required.}
1716       \textcolor{keywordflow}{if} (staggered\_in\_x) isv\_c = iev - (diag\_cs%ie - diag\_cs%is) - 1
1717       \textcolor{keywordflow}{if} (staggered\_in\_y) jsv\_c = jev - (diag\_cs%je - diag\_cs%js) - 1
1718       \textcolor{keywordflow}{if} (isv\_c < lbound(locfield,1)) \textcolor{keyword}{call }mom\_error(fatal, &
1719         \textcolor{stringliteral}{"It is an error to average a staggered diagnostic field that does not "}//&
1720         \textcolor{stringliteral}{"have i-direction space to represent the symmetric computational domain."})
1721       \textcolor{keywordflow}{if} (jsv\_c < lbound(locfield,2)) \textcolor{keyword}{call }mom\_error(fatal, &
1722         \textcolor{stringliteral}{"It is an error to average a staggered diagnostic field that does not "}//&
1723         \textcolor{stringliteral}{"have j-direction space to represent the symmetric computational domain."})
1724 \textcolor{keywordflow}{    endif}
1725 
1726     \textcolor{keywordflow}{do} k=ks,ke ; \textcolor{keywordflow}{do} j=jsv,jev ; \textcolor{keywordflow}{do} i=isv,iev
1727       \textcolor{keywordflow}{if} (field(i,j,k) == diag\_cs%missing\_value) \textcolor{keywordflow}{then}
1728         locfield(i,j,k) = diag\_cs%missing\_value
1729       \textcolor{keywordflow}{else}
1730         locfield(i,j,k) = field(i,j,k) * diag%conversion\_factor
1731 \textcolor{keywordflow}{      endif}
1732 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1733   \textcolor{keywordflow}{else}
1734     locfield => field
1735 \textcolor{keywordflow}{  endif}
1736 
1737   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1738      locmask => mask
1739   \textcolor{keywordflow}{elseif}(\textcolor{keyword}{associated}(diag%axes%mask3d)) \textcolor{keywordflow}{then}
1740      locmask => diag%axes%mask3d
1741 \textcolor{keywordflow}{  endif}
1742 
1743   dl=1
1744   \textcolor{keywordflow}{if}(.NOT. is\_stat) dl = diag%axes%downsample\_level \textcolor{comment}{!static field downsample i not supported yet}
1745   \textcolor{comment}{!Downsample the diag field and mask (if present)}
1746   \textcolor{keywordflow}{if} (dl > 1) \textcolor{keywordflow}{then}
1747      isv\_o=isv ; jsv\_o=jsv
1748      \textcolor{keyword}{call }downsample\_diag\_field(locfield, locfield\_dsamp, dl, diag\_cs, diag,isv,iev,jsv,jev, mask)
1749      \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.)) \textcolor{keyword}{deallocate}( locfield )
1750      locfield => locfield\_dsamp
1751      \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1752         \textcolor{keyword}{call }downsample\_field\_3d(locmask, locmask\_dsamp, dl, msk, locmask, diag\_cs,diag,isv\_o,jsv\_o,isv,iev
      ,jsv,jev)
1753         locmask => locmask\_dsamp
1754       \textcolor{keywordflow}{elseif}(\textcolor{keyword}{associated}(diag%axes%dsamp(dl)%mask3d)) \textcolor{keywordflow}{then}
1755         locmask => diag%axes%dsamp(dl)%mask3d
1756 \textcolor{keywordflow}{     endif}
1757 \textcolor{keywordflow}{  endif}
1758 
1759   \textcolor{keywordflow}{if} (diag%fms\_diag\_id>0) \textcolor{keywordflow}{then}
1760     \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
1761       \textcolor{keywordflow}{if} (diag%axes%is\_h\_point) \textcolor{keywordflow}{then}
1762         \textcolor{keyword}{call }hchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1763                      logunit=diag\_cs%chksum\_iounit)
1764       \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (diag%axes%is\_u\_point) \textcolor{keywordflow}{then}
1765         \textcolor{keyword}{call }uchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1766                      logunit=diag\_cs%chksum\_iounit)
1767       \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (diag%axes%is\_v\_point) \textcolor{keywordflow}{then}
1768         \textcolor{keyword}{call }vchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1769                      logunit=diag\_cs%chksum\_iounit)
1770       \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (diag%axes%is\_q\_point) \textcolor{keywordflow}{then}
1771         \textcolor{keyword}{call }bchksum(locfield, diag%debug\_str, diag\_cs%G%HI, &
1772                      logunit=diag\_cs%chksum\_iounit)
1773       \textcolor{keywordflow}{else}
1774         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"post\_data\_3d\_low: unknown axis type."})
1775 \textcolor{keywordflow}{      endif}
1776     \textcolor{keywordflow}{else}
1777       \textcolor{keywordflow}{if} (is\_stat) \textcolor{keywordflow}{then}
1778         \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mask)) \textcolor{keywordflow}{then}
1779           \textcolor{keyword}{call }assert(\textcolor{keyword}{size}(locfield) == \textcolor{keyword}{size}(locmask), &
1780               \textcolor{stringliteral}{'post\_data\_3d\_low is\_stat: mask size mismatch: '}//diag%debug\_str)
1781           used = send\_data(diag%fms\_diag\_id, locfield, &
1782                          is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, rmask=locmask)
1783        \textcolor{comment}{!elseif (associated(diag%axes%mask2d)) then}
1784        \textcolor{comment}{!  used = send\_data(diag%fms\_diag\_id, locfield, &}
1785        \textcolor{comment}{!                   is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, rmask=diag%axes%mask2d)}
1786         \textcolor{keywordflow}{else}
1787           used = send\_data(diag%fms\_diag\_id, locfield, &
1788                            is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev)
1789 \textcolor{keywordflow}{        endif}
1790       \textcolor{keywordflow}{elseif} (diag\_cs%ave\_enabled) \textcolor{keywordflow}{then}
1791         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(locmask)) \textcolor{keywordflow}{then}
1792           \textcolor{keyword}{call }assert(\textcolor{keyword}{size}(locfield) == \textcolor{keyword}{size}(locmask), &
1793               \textcolor{stringliteral}{'post\_data\_3d\_low: mask size mismatch: '}//diag%debug\_str)
1794           used = send\_data(diag%fms\_diag\_id, locfield, diag\_cs%time\_end, &
1795                            is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, &
1796                            weight=diag\_cs%time\_int, rmask=locmask)
1797         \textcolor{keywordflow}{else}
1798           used = send\_data(diag%fms\_diag\_id, locfield, diag\_cs%time\_end, &
1799                            is\_in=isv, js\_in=jsv, ie\_in=iev, je\_in=jev, &
1800                            weight=diag\_cs%time\_int)
1801 \textcolor{keywordflow}{        endif}
1802 \textcolor{keywordflow}{      endif}
1803 \textcolor{keywordflow}{    endif}
1804 \textcolor{keywordflow}{  endif}
1805 
1806   \textcolor{keywordflow}{if} (diag%fms\_xyave\_diag\_id>0) \textcolor{keywordflow}{then}
1807     \textcolor{keyword}{call }post\_xy\_average(diag\_cs, diag, locfield)
1808 \textcolor{keywordflow}{  endif}
1809 
1810   \textcolor{keywordflow}{if} ((diag%conversion\_factor /= 0.) .and. (diag%conversion\_factor /= 1.) .and. dl<2) &
1811     \textcolor{keyword}{deallocate}( locfield )
1812 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ab41a1779c5edb50aa7256477cef952ae}\label{namespacemom__diag__mediator_ab41a1779c5edb50aa7256477cef952ae}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!post\+\_\+xy\+\_\+average@{post\+\_\+xy\+\_\+average}}
\index{post\+\_\+xy\+\_\+average@{post\+\_\+xy\+\_\+average}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{post\+\_\+xy\+\_\+average()}{post\_xy\_average()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::post\+\_\+xy\+\_\+average (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__type}{diag\+\_\+type}}), intent(in)}]{diag,  }\item[{real, dimension(\+:,\+:,\+:), intent(in), target}]{field }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Post the horizontally area-\/averaged diagnostic. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag} & This diagnostic\\
\hline
\mbox{\tt in}  & {\em field} & Diagnostic field\\
\hline
\mbox{\tt in}  & {\em diag\+\_\+cs} & Diagnostics mediator control structure \\
\hline
\end{DoxyParams}


Definition at line 1817 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1817   \textcolor{keywordtype}{type}(diag\_type),   \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< This diagnostic}
1818   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: field(:,:,:)\textcolor{comment}{ !< Diagnostic field}
1819   \textcolor{keywordtype}{type}(diag\_ctrl),   \textcolor{keywordtype}{intent(in)} :: diag\_cs\textcolor{comment}{ !< Diagnostics mediator control structure}
1820   \textcolor{comment}{! Local variable}
1821   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(field,3))} :: averaged\_field
1822   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(size(field,3))} :: averaged\_mask
1823   \textcolor{keywordtype}{logical} :: staggered\_in\_x, staggered\_in\_y, used
1824   \textcolor{keywordtype}{integer} :: nz, remap\_nz, coord
1825 
1826   \textcolor{keywordflow}{if} (.not. diag\_cs%ave\_enabled) \textcolor{keywordflow}{then}
1827     \textcolor{keywordflow}{return}
1828 \textcolor{keywordflow}{  endif}
1829 
1830   staggered\_in\_x = diag%axes%is\_u\_point .or. diag%axes%is\_q\_point
1831   staggered\_in\_y = diag%axes%is\_v\_point .or. diag%axes%is\_q\_point
1832 
1833   \textcolor{keywordflow}{if} (diag%axes%is\_native) \textcolor{keywordflow}{then}
1834     \textcolor{keyword}{call }horizontally\_average\_diag\_field(diag\_cs%G, diag\_cs%GV, diag\_cs%h, &
1835                                          staggered\_in\_x, staggered\_in\_y, &
1836                                          diag%axes%is\_layer, diag%v\_extensive, &
1837                                          field, &
1838                                          averaged\_field, averaged\_mask)
1839   \textcolor{keywordflow}{else}
1840     nz = \textcolor{keyword}{size}(field, 3)
1841     coord = diag%axes%vertical\_coordinate\_number
1842     remap\_nz = diag\_cs%diag\_remap\_cs(coord)%nz
1843 
1844     \textcolor{keyword}{call }assert(diag\_cs%diag\_remap\_cs(coord)%initialized, &
1845                 \textcolor{stringliteral}{'post\_xy\_average: remap\_cs not initialized.'})
1846 
1847     \textcolor{keyword}{call }assert(implies(diag%axes%is\_layer, nz == remap\_nz), &
1848               \textcolor{stringliteral}{'post\_xy\_average: layer field dimension mismatch.'})
1849     \textcolor{keyword}{call }assert(implies(.not. diag%axes%is\_layer, nz == remap\_nz+1), &
1850               \textcolor{stringliteral}{'post\_xy\_average: interface field dimension mismatch.'})
1851 
1852     \textcolor{keyword}{call }horizontally\_average\_diag\_field(diag\_cs%G, diag\_cs%GV, &
1853                                          diag\_cs%diag\_remap\_cs(coord)%h, &
1854                                          staggered\_in\_x, staggered\_in\_y, &
1855                                          diag%axes%is\_layer, diag%v\_extensive, &
1856                                          field, &
1857                                          averaged\_field, averaged\_mask)
1858 \textcolor{keywordflow}{  endif}
1859 
1860   \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
1861     \textcolor{keyword}{call }zchksum(averaged\_field, trim(diag%debug\_str)//\textcolor{stringliteral}{'\_xyave'}, &
1862                  logunit=diag\_cs%chksum\_iounit)
1863   \textcolor{keywordflow}{else}
1864     used = send\_data(diag%fms\_xyave\_diag\_id, averaged\_field, diag\_cs%time\_end, &
1865                      weight=diag\_cs%time\_int, mask=averaged\_mask)
1866 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a0be5d1cbc6c6f8f63950ce7d9bc6455a}\label{namespacemom__diag__mediator_a0be5d1cbc6c6f8f63950ce7d9bc6455a}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!query\+\_\+averaging\+\_\+enabled@{query\+\_\+averaging\+\_\+enabled}}
\index{query\+\_\+averaging\+\_\+enabled@{query\+\_\+averaging\+\_\+enabled}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{query\+\_\+averaging\+\_\+enabled()}{query\_averaging\_enabled()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+diag\+\_\+mediator\+::query\+\_\+averaging\+\_\+enabled (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(in)}]{diag\+\_\+cs,  }\item[{real, intent(out), optional}]{time\+\_\+int,  }\item[{type(time\+\_\+type), intent(out), optional}]{time\+\_\+end }\end{DoxyParamCaption})}



Call this subroutine to determine whether the averaging is currently enabled. .true. is returned if it is. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt out}  & {\em time\+\_\+int} & Current setting of diagtime\+\_\+int \mbox{[}s\mbox{]}\\
\hline
\mbox{\tt out}  & {\em time\+\_\+end} & Current setting of diagtime\+\_\+end \\
\hline
\end{DoxyParams}


Definition at line 1916 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1916   \textcolor{keywordtype}{type}(diag\_ctrl),           \textcolor{keywordtype}{intent(in)}  :: diag\_CS\textcolor{comment}{  !< Structure used to regulate diagnostic output}
1917   \textcolor{keywordtype}{real},            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: time\_int\textcolor{comment}{ !< Current setting of diag%time\_int [s]}
1918   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: time\_end\textcolor{comment}{ !< Current setting of diag%time\_end}
1919   \textcolor{keywordtype}{logical} :: query\_averaging\_enabled
1920 
1921   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(time\_int)) time\_int = diag\_cs%time\_int
1922   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(time\_end)) time\_end = diag\_cs%time\_end
1923   query\_averaging\_enabled = diag\_cs%ave\_enabled
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a820eb49d3acf041c630ce1373bef799e}\label{namespacemom__diag__mediator_a820eb49d3acf041c630ce1373bef799e}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!register\+\_\+cell\+\_\+measure@{register\+\_\+cell\+\_\+measure}}
\index{register\+\_\+cell\+\_\+measure@{register\+\_\+cell\+\_\+measure}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{register\+\_\+cell\+\_\+measure()}{register\_cell\_measure()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::register\+\_\+cell\+\_\+measure (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout), target}]{diag,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})}



Sets a handle inside diagnostics mediator to associate 3d cell measures. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & Ocean grid structure\\
\hline
\mbox{\tt in,out}  & {\em diag} & Regulates diagnostic output\\
\hline
\mbox{\tt in}  & {\em time} & Model time \\
\hline
\end{DoxyParams}


Definition at line 951 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
951   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< Ocean grid structure}
952   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< Regulates diagnostic output}
953   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< Model time}
954   \textcolor{comment}{! Local variables}
955   \textcolor{keywordtype}{integer} :: id
956   id = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'volcello'}, diag%axesTL, &
957                            time, \textcolor{stringliteral}{'Ocean grid-cell volume'}, \textcolor{stringliteral}{'m3'}, &
958                            standard\_name=\textcolor{stringliteral}{'ocean\_volume'}, v\_extensive=.true., &
959                            x\_cell\_method=\textcolor{stringliteral}{'sum'}, y\_cell\_method=\textcolor{stringliteral}{'sum'})
960   \textcolor{keyword}{call }diag\_associate\_volume\_cell\_measure(diag, id)
961 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ada491446bf7216fe101e6b0f6ed551e1}\label{namespacemom__diag__mediator_ada491446bf7216fe101e6b0f6ed551e1}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!register\+\_\+diag\+\_\+field@{register\+\_\+diag\+\_\+field}}
\index{register\+\_\+diag\+\_\+field@{register\+\_\+diag\+\_\+field}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{register\+\_\+diag\+\_\+field()}{register\_diag\_field()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+diag\+\_\+mediator\+::register\+\_\+diag\+\_\+field (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{module\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{field\+\_\+name,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(in), target}]{axes\+\_\+in,  }\item[{type(time\+\_\+type), intent(in)}]{init\+\_\+time,  }\item[{character(len=$\ast$), intent(in), optional}]{long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{real, intent(in), optional}]{missing\+\_\+value,  }\item[{real, dimension(2), intent(in), optional}]{range,  }\item[{logical, intent(in), optional}]{mask\+\_\+variant,  }\item[{character(len=$\ast$), intent(in), optional}]{standard\+\_\+name,  }\item[{logical, intent(in), optional}]{verbose,  }\item[{logical, intent(in), optional}]{do\+\_\+not\+\_\+log,  }\item[{character(len=$\ast$), intent(out), optional}]{err\+\_\+msg,  }\item[{character(len=$\ast$), intent(in), optional}]{interp\+\_\+method,  }\item[{integer, intent(in), optional}]{tile\+\_\+count,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+field\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+standard\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cell\+\_\+methods,  }\item[{character(len=$\ast$), intent(in), optional}]{x\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{y\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{v\+\_\+cell\+\_\+method,  }\item[{real, intent(in), optional}]{conversion,  }\item[{logical, intent(in), optional}]{v\+\_\+extensive }\end{DoxyParamCaption})}



Returns the \char`\"{}diag\+\_\+mediator\char`\"{} handle for a group (native, C\+M\+OR, z-\/coord, ...) of diagnostics derived from one field. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em module\+\_\+name} & Name of this module, usually \char`\"{}ocean\+\_\+model\char`\"{} or \char`\"{}ice\+\_\+shelf\+\_\+model\char`\"{}\\
\hline
\mbox{\tt in}  & {\em field\+\_\+name} & Name of the diagnostic field\\
\hline
\mbox{\tt in}  & {\em axes\+\_\+in} & Container w/ up to 3 integer handles that indicates axes for this field\\
\hline
\mbox{\tt in}  & {\em init\+\_\+time} & Time at which a field is first available?\\
\hline
\mbox{\tt in}  & {\em long\+\_\+name} & Long name of a field.\\
\hline
\mbox{\tt in}  & {\em units} & Units of a field.\\
\hline
\mbox{\tt in}  & {\em standard\+\_\+name} & Standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em missing\+\_\+value} & A value that indicates missing values.\\
\hline
\mbox{\tt in}  & {\em range} & Valid range of a variable (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em mask\+\_\+variant} & If true a logical mask must be provided with \mbox{\hyperlink{interfacemom__diag__mediator_1_1post__data}{post\+\_\+data}} calls (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em verbose} & If true, F\+MS is verbose (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em do\+\_\+not\+\_\+log} & If true, do not log something (not used in M\+OM?)\\
\hline
\mbox{\tt out}  & {\em err\+\_\+msg} & String into which an error message might be placed (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em interp\+\_\+method} & If \textquotesingle{}none\textquotesingle{} indicates the field should not be interpolated as a scalar\\
\hline
\mbox{\tt in}  & {\em tile\+\_\+count} & no clue (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+long\+\_\+name} & C\+M\+OR long name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+units} & C\+M\+OR units of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+standard\+\_\+name} & C\+M\+OR standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em cell\+\_\+methods} & String to append as cell\+\_\+methods attribute. Use \textquotesingle{}\textquotesingle{} to have no attribute. If present, this overrides the default constructed from the default for each individual axis direction.\\
\hline
\mbox{\tt in}  & {\em x\+\_\+cell\+\_\+method} & Specifies the cell method for the x-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em y\+\_\+cell\+\_\+method} & Specifies the cell method for the y-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em v\+\_\+cell\+\_\+method} & Specifies the cell method for the vertical direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em conversion} & A value to multiply data by before writing to file\\
\hline
\mbox{\tt in}  & {\em v\+\_\+extensive} & True for vertically extensive fields (vertically integrated). Default/absent for intensive. \\
\hline
\end{DoxyParams}


Definition at line 1944 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1944   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: module\_name\textcolor{comment}{ !< Name of this module, usually "ocean\_model"}
1945 \textcolor{comment}{                                              !! or "ice\_shelf\_model"}
1946   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: field\_name\textcolor{comment}{ !< Name of the diagnostic field}
1947   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: axes\_in\textcolor{comment}{ !< Container w/ up to 3 integer handles that}
1948 \textcolor{comment}{                                             !! indicates axes for this field}
1949   \textcolor{keywordtype}{type}(time\_type),  \textcolor{keywordtype}{intent(in)} :: init\_time\textcolor{comment}{ !< Time at which a field is first available?}
1950   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: long\_name\textcolor{comment}{ !< Long name of a field.}
1951   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: units\textcolor{comment}{ !< Units of a field.}
1952   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: standard\_name\textcolor{comment}{ !< Standardized name associated with a field}
1953   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< A value that indicates missing values.}
1954   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: range(2)\textcolor{comment}{ !< Valid range of a variable (not used in MOM?)}
1955   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: mask\_variant\textcolor{comment}{ !< If true a logical mask must be provided with}
1956 \textcolor{comment}{                                                         !! post\_data calls (not used in MOM?)}
1957   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, FMS is verbose (not used in MOM?)}
1958   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: do\_not\_log\textcolor{comment}{ !< If true, do not log something (not used in MOM?)}
1959   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}:: err\_msg\textcolor{comment}{ !< String into which an error message might be}
1960 \textcolor{comment}{                                                         !! placed (not used in MOM?)}
1961   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: interp\_method\textcolor{comment}{ !< If 'none' indicates the field should not}
1962 \textcolor{comment}{                                                         !! be interpolated as a scalar}
1963   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: tile\_count\textcolor{comment}{ !< no clue (not used in MOM?)}
1964   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_field\_name\textcolor{comment}{ !< CMOR name of a field}
1965   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_long\_name\textcolor{comment}{ !< CMOR long name of a field}
1966   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_units\textcolor{comment}{ !< CMOR units of a field}
1967   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_standard\_name\textcolor{comment}{ !< CMOR standardized name associated with a
       field}
1968   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cell\_methods\textcolor{comment}{ !< String to append as cell\_methods attribute. Use
       '' to}
1969 \textcolor{comment}{                                                         !! have no attribute.  If present, this overrides
       the}
1970 \textcolor{comment}{                                                         !! default constructed from the default for}
1971 \textcolor{comment}{                                                         !! each individual axis direction.}
1972   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: x\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the x-direction.}
1973 \textcolor{comment}{                                                         !! Use '' have no method.}
1974   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: y\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the y-direction.}
1975 \textcolor{comment}{                                                         !! Use '' have no method.}
1976   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: v\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the vertical
       direction.}
1977 \textcolor{comment}{                                                         !! Use '' have no method.}
1978   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: conversion\textcolor{comment}{ !< A value to multiply data by before writing to
       file}
1979   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: v\_extensive\textcolor{comment}{ !< True for vertically extensive fields (vertically}
1980 \textcolor{comment}{                                                         !! integrated). Default/absent for intensive.}
1981   \textcolor{comment}{! Local variables}
1982   \textcolor{keywordtype}{real} :: MOM\_missing\_value
1983   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{pointer} :: diag\_cs => null()
1984   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{pointer} :: remap\_axes => null()
1985   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{pointer} :: axes => null()
1986   \textcolor{keywordtype}{integer} :: dm\_id, i, dl
1987   \textcolor{keywordtype}{character(len=256)} :: new\_module\_name
1988   \textcolor{keywordtype}{logical} :: active
1989 
1990   axes => axes\_in
1991   mom\_missing\_value = axes%diag\_cs%missing\_value
1992   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(missing\_value)) mom\_missing\_value = missing\_value
1993 
1994   diag\_cs => axes%diag\_cs
1995   dm\_id = -1
1996 
1997   \textcolor{keywordflow}{if} (axes\_in%id == diag\_cs%axesTL%id) \textcolor{keywordflow}{then}
1998      axes => diag\_cs%axesTL
1999   \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBL%id) \textcolor{keywordflow}{then}
2000      axes => diag\_cs%axesBL
2001   \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCuL%id ) \textcolor{keywordflow}{then}
2002      axes => diag\_cs%axesCuL
2003   \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvL%id) \textcolor{keywordflow}{then}
2004      axes => diag\_cs%axesCvL
2005   \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesTi%id) \textcolor{keywordflow}{then}
2006      axes => diag\_cs%axesTi
2007   \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBi%id) \textcolor{keywordflow}{then}
2008      axes => diag\_cs%axesBi
2009   \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCui%id ) \textcolor{keywordflow}{then}
2010      axes => diag\_cs%axesCui
2011   \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvi%id) \textcolor{keywordflow}{then}
2012      axes => diag\_cs%axesCvi
2013 \textcolor{keywordflow}{  endif}
2014 
2015   \textcolor{comment}{! Register the native diagnostic}
2016   active = register\_diag\_field\_expand\_cmor(dm\_id, module\_name, field\_name, axes, &
2017              init\_time, long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2018              range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2019              verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2020              interp\_method=interp\_method, tile\_count=tile\_count, &
2021              cmor\_field\_name=cmor\_field\_name, cmor\_long\_name=cmor\_long\_name, &
2022              cmor\_units=cmor\_units, cmor\_standard\_name=cmor\_standard\_name, &
2023              cell\_methods=cell\_methods, x\_cell\_method=x\_cell\_method, &
2024              y\_cell\_method=y\_cell\_method, v\_cell\_method=v\_cell\_method, &
2025              conversion=conversion, v\_extensive=v\_extensive)
2026 
2027   \textcolor{comment}{! For each diagnostic coordinate register the diagnostic again under a different module name}
2028   \textcolor{keywordflow}{do} i=1,diag\_cs%num\_diag\_coords
2029     new\_module\_name = trim(module\_name)//\textcolor{stringliteral}{'\_'}//trim(diag\_cs%diag\_remap\_cs(i)%diag\_module\_suffix)
2030 
2031     \textcolor{comment}{! Register diagnostics remapped to z vertical coordinate}
2032     \textcolor{keywordflow}{if} (axes\_in%rank == 3) \textcolor{keywordflow}{then}
2033       remap\_axes => null()
2034       \textcolor{keywordflow}{if} ((axes\_in%id == diag\_cs%axesTL%id)) \textcolor{keywordflow}{then}
2035           remap\_axes => diag\_cs%remap\_axesTL(i)
2036       \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBL%id) \textcolor{keywordflow}{then}
2037           remap\_axes => diag\_cs%remap\_axesBL(i)
2038       \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCuL%id ) \textcolor{keywordflow}{then}
2039           remap\_axes => diag\_cs%remap\_axesCuL(i)
2040       \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvL%id) \textcolor{keywordflow}{then}
2041           remap\_axes => diag\_cs%remap\_axesCvL(i)
2042       \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesTi%id) \textcolor{keywordflow}{then}
2043           remap\_axes => diag\_cs%remap\_axesTi(i)
2044       \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBi%id) \textcolor{keywordflow}{then}
2045           remap\_axes => diag\_cs%remap\_axesBi(i)
2046       \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCui%id ) \textcolor{keywordflow}{then}
2047           remap\_axes => diag\_cs%remap\_axesCui(i)
2048       \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvi%id) \textcolor{keywordflow}{then}
2049           remap\_axes => diag\_cs%remap\_axesCvi(i)
2050 \textcolor{keywordflow}{      endif}
2051       \textcolor{comment}{! When the MOM\_diag\_to\_Z module has been obsoleted we can assume remap\_axes will}
2052       \textcolor{comment}{! always exist but in the mean-time we have to do this check:}
2053       \textcolor{comment}{! call assert(associated(remap\_axes), 'register\_diag\_field: remap\_axes not set')}
2054       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(remap\_axes)) \textcolor{keywordflow}{then}
2055         \textcolor{keywordflow}{if} (remap\_axes%needs\_remapping .or. remap\_axes%needs\_interpolating) \textcolor{keywordflow}{then}
2056           active = register\_diag\_field\_expand\_cmor(dm\_id, new\_module\_name, field\_name, remap\_axes, &
2057                      init\_time, long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2058                      range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2059                      verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2060                      interp\_method=interp\_method, tile\_count=tile\_count, &
2061                      cmor\_field\_name=cmor\_field\_name, cmor\_long\_name=cmor\_long\_name, &
2062                      cmor\_units=cmor\_units, cmor\_standard\_name=cmor\_standard\_name, &
2063                      cell\_methods=cell\_methods, x\_cell\_method=x\_cell\_method, &
2064                      y\_cell\_method=y\_cell\_method, v\_cell\_method=v\_cell\_method, &
2065                      conversion=conversion, v\_extensive=v\_extensive)
2066           \textcolor{keywordflow}{if} (active) \textcolor{keywordflow}{then}
2067             \textcolor{keyword}{call }diag\_remap\_set\_active(diag\_cs%diag\_remap\_cs(i))
2068 \textcolor{keywordflow}{          endif}
2069 \textcolor{keywordflow}{        endif} \textcolor{comment}{! remap\_axes%needs\_remapping}
2070 \textcolor{keywordflow}{      endif} \textcolor{comment}{! associated(remap\_axes)}
2071 \textcolor{keywordflow}{    endif} \textcolor{comment}{! axes%rank == 3}
2072 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! i}
2073 
2074   \textcolor{comment}{!Register downsampled diagnostics}
2075   \textcolor{keywordflow}{do} dl=2,max\_dsamp\_lev
2076      \textcolor{comment}{! Do not attempt to checksum the downsampled diagnostics}
2077      \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) cycle
2078 
2079      new\_module\_name = trim(module\_name)//\textcolor{stringliteral}{'\_d2'}
2080 
2081      \textcolor{keywordflow}{if} (axes\_in%rank == 3 .or. axes\_in%rank == 2 ) \textcolor{keywordflow}{then}
2082         axes => null()
2083         \textcolor{keywordflow}{if} (axes\_in%id == diag\_cs%axesTL%id) \textcolor{keywordflow}{then}
2084            axes => diag\_cs%dsamp(dl)%axesTL
2085         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBL%id) \textcolor{keywordflow}{then}
2086            axes => diag\_cs%dsamp(dl)%axesBL
2087         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCuL%id ) \textcolor{keywordflow}{then}
2088            axes => diag\_cs%dsamp(dl)%axesCuL
2089         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvL%id) \textcolor{keywordflow}{then}
2090            axes => diag\_cs%dsamp(dl)%axesCvL
2091         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesTi%id) \textcolor{keywordflow}{then}
2092            axes => diag\_cs%dsamp(dl)%axesTi
2093         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBi%id) \textcolor{keywordflow}{then}
2094            axes => diag\_cs%dsamp(dl)%axesBi
2095         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCui%id ) \textcolor{keywordflow}{then}
2096            axes => diag\_cs%dsamp(dl)%axesCui
2097         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvi%id) \textcolor{keywordflow}{then}
2098            axes => diag\_cs%dsamp(dl)%axesCvi
2099         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesT1%id) \textcolor{keywordflow}{then}
2100            axes => diag\_cs%dsamp(dl)%axesT1
2101         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesB1%id) \textcolor{keywordflow}{then}
2102            axes => diag\_cs%dsamp(dl)%axesB1
2103         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCu1%id ) \textcolor{keywordflow}{then}
2104            axes => diag\_cs%dsamp(dl)%axesCu1
2105         \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCv1%id) \textcolor{keywordflow}{then}
2106            axes => diag\_cs%dsamp(dl)%axesCv1
2107         \textcolor{keywordflow}{else}
2108            \textcolor{comment}{!Niki: Should we worry about these, e.g., diag\_to\_Z\_CS?}
2109            \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"register\_diag\_field: Could not find a proper axes for "} &
2110                 //trim( new\_module\_name)//\textcolor{stringliteral}{"-"}//trim(field\_name))
2111 \textcolor{keywordflow}{        endif}
2112 \textcolor{keywordflow}{     endif}
2113      \textcolor{comment}{! Register the native diagnostic}
2114      \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(axes)) \textcolor{keywordflow}{then}
2115      active = register\_diag\_field\_expand\_cmor(dm\_id, new\_module\_name, field\_name, axes, &
2116                 init\_time, long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2117                 range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2118                 verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2119                 interp\_method=interp\_method, tile\_count=tile\_count, &
2120                 cmor\_field\_name=cmor\_field\_name, cmor\_long\_name=cmor\_long\_name, &
2121                 cmor\_units=cmor\_units, cmor\_standard\_name=cmor\_standard\_name, &
2122                 cell\_methods=cell\_methods, x\_cell\_method=x\_cell\_method, &
2123                 y\_cell\_method=y\_cell\_method, v\_cell\_method=v\_cell\_method, &
2124                 conversion=conversion, v\_extensive=v\_extensive)
2125 \textcolor{keywordflow}{     endif}
2126 
2127      \textcolor{comment}{! For each diagnostic coordinate register the diagnostic again under a different module name}
2128      \textcolor{keywordflow}{do} i=1,diag\_cs%num\_diag\_coords
2129         new\_module\_name = trim(module\_name)//\textcolor{stringliteral}{'\_'}//trim(diag\_cs%diag\_remap\_cs(i)%diag\_module\_suffix)//\textcolor{stringliteral}{'\_d2'}
2130 
2131         \textcolor{comment}{! Register diagnostics remapped to z vertical coordinate}
2132         \textcolor{keywordflow}{if} (axes\_in%rank == 3) \textcolor{keywordflow}{then}
2133            remap\_axes => null()
2134            \textcolor{keywordflow}{if} ((axes\_in%id == diag\_cs%axesTL%id)) \textcolor{keywordflow}{then}
2135               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesTL(i)
2136            \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBL%id) \textcolor{keywordflow}{then}
2137               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesBL(i)
2138            \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCuL%id ) \textcolor{keywordflow}{then}
2139               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesCuL(i)
2140            \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvL%id) \textcolor{keywordflow}{then}
2141               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesCvL(i)
2142            \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesTi%id) \textcolor{keywordflow}{then}
2143               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesTi(i)
2144            \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesBi%id) \textcolor{keywordflow}{then}
2145               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesBi(i)
2146            \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCui%id ) \textcolor{keywordflow}{then}
2147               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesCui(i)
2148            \textcolor{keywordflow}{elseif} (axes\_in%id == diag\_cs%axesCvi%id) \textcolor{keywordflow}{then}
2149               remap\_axes => diag\_cs%dsamp(dl)%remap\_axesCvi(i)
2150 \textcolor{keywordflow}{           endif}
2151 
2152            \textcolor{comment}{! When the MOM\_diag\_to\_Z module has been obsoleted we can assume remap\_axes will}
2153            \textcolor{comment}{! always exist but in the mean-time we have to do this check:}
2154            \textcolor{comment}{! call assert(associated(remap\_axes), 'register\_diag\_field: remap\_axes not set')}
2155            \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(remap\_axes)) \textcolor{keywordflow}{then}
2156               \textcolor{keywordflow}{if} (remap\_axes%needs\_remapping .or. remap\_axes%needs\_interpolating) \textcolor{keywordflow}{then}
2157                  active = register\_diag\_field\_expand\_cmor(dm\_id, new\_module\_name, field\_name, remap\_axes, &
2158                       init\_time, long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2159                       range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2160                       verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2161                       interp\_method=interp\_method, tile\_count=tile\_count, &
2162                       cmor\_field\_name=cmor\_field\_name, cmor\_long\_name=cmor\_long\_name, &
2163                       cmor\_units=cmor\_units, cmor\_standard\_name=cmor\_standard\_name, &
2164                       cell\_methods=cell\_methods, x\_cell\_method=x\_cell\_method, &
2165                       y\_cell\_method=y\_cell\_method, v\_cell\_method=v\_cell\_method, &
2166                       conversion=conversion, v\_extensive=v\_extensive)
2167                  \textcolor{keywordflow}{if} (active) \textcolor{keywordflow}{then}
2168                     \textcolor{keyword}{call }diag\_remap\_set\_active(diag\_cs%diag\_remap\_cs(i))
2169 \textcolor{keywordflow}{                 endif}
2170 \textcolor{keywordflow}{              endif} \textcolor{comment}{! remap\_axes%needs\_remapping}
2171 \textcolor{keywordflow}{           endif} \textcolor{comment}{! associated(remap\_axes)}
2172 \textcolor{keywordflow}{        endif} \textcolor{comment}{! axes%rank == 3}
2173 \textcolor{keywordflow}{     enddo} \textcolor{comment}{! i}
2174 \textcolor{keywordflow}{  enddo}
2175 
2176   register\_diag\_field = dm\_id
2177 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_aca4a32fea8dade9f51e076a56b9bad2b}\label{namespacemom__diag__mediator_aca4a32fea8dade9f51e076a56b9bad2b}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes@{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes}}
\index{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes@{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes()}{register\_diag\_field\_expand\_axes()}}
{\footnotesize\ttfamily integer function mom\+\_\+diag\+\_\+mediator\+::register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{module\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{field\+\_\+name,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(in), target}]{axes,  }\item[{type(time\+\_\+type), intent(in)}]{init\+\_\+time,  }\item[{character(len=$\ast$), intent(in), optional}]{long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{real, intent(in), optional}]{missing\+\_\+value,  }\item[{real, dimension(2), intent(in), optional}]{range,  }\item[{logical, intent(in), optional}]{mask\+\_\+variant,  }\item[{character(len=$\ast$), intent(in), optional}]{standard\+\_\+name,  }\item[{logical, intent(in), optional}]{verbose,  }\item[{logical, intent(in), optional}]{do\+\_\+not\+\_\+log,  }\item[{character(len=$\ast$), intent(out), optional}]{err\+\_\+msg,  }\item[{character(len=$\ast$), intent(in), optional}]{interp\+\_\+method,  }\item[{integer, intent(in), optional}]{tile\+\_\+count }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns an F\+MS id from register\+\_\+diag\+\_\+field\+\_\+fms (the diag\+\_\+manager routine) after expanding axes (axes-\/group) into handles and conditionally adding an F\+MS area\+\_\+id for cell\+\_\+measures. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em module\+\_\+name} & Name of this module, usually \char`\"{}ocean\+\_\+model\char`\"{} or \char`\"{}ice\+\_\+shelf\+\_\+model\char`\"{}\\
\hline
\mbox{\tt in}  & {\em field\+\_\+name} & Name of the diagnostic field\\
\hline
\mbox{\tt in}  & {\em axes} & Container w/ up to 3 integer handles that indicates axes for this field\\
\hline
\mbox{\tt in}  & {\em init\+\_\+time} & Time at which a field is first available?\\
\hline
\mbox{\tt in}  & {\em long\+\_\+name} & Long name of a field.\\
\hline
\mbox{\tt in}  & {\em units} & Units of a field.\\
\hline
\mbox{\tt in}  & {\em standard\+\_\+name} & Standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em missing\+\_\+value} & A value that indicates missing values.\\
\hline
\mbox{\tt in}  & {\em range} & Valid range of a variable (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em mask\+\_\+variant} & If true a logical mask must be provided with \mbox{\hyperlink{interfacemom__diag__mediator_1_1post__data}{post\+\_\+data}} calls (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em verbose} & If true, F\+MS is verbose (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em do\+\_\+not\+\_\+log} & If true, do not log something (not used in M\+OM?)\\
\hline
\mbox{\tt out}  & {\em err\+\_\+msg} & String into which an error message might be placed (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em interp\+\_\+method} & If \textquotesingle{}none\textquotesingle{} indicates the field should not be interpolated as a scalar\\
\hline
\mbox{\tt in}  & {\em tile\+\_\+count} & no clue (not used in M\+OM?) \\
\hline
\end{DoxyParams}


Definition at line 2352 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2352   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: module\_name\textcolor{comment}{ !< Name of this module, usually "ocean\_model"}
2353 \textcolor{comment}{                                              !! or "ice\_shelf\_model"}
2354   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: field\_name\textcolor{comment}{ !< Name of the diagnostic field}
2355   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: axes\textcolor{comment}{ !< Container w/ up to 3 integer handles that indicates}
2356 \textcolor{comment}{                                             !! axes for this field}
2357   \textcolor{keywordtype}{type}(time\_type),  \textcolor{keywordtype}{intent(in)} :: init\_time\textcolor{comment}{ !< Time at which a field is first available?}
2358   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: long\_name\textcolor{comment}{ !< Long name of a field.}
2359   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: units\textcolor{comment}{ !< Units of a field.}
2360   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: standard\_name\textcolor{comment}{ !< Standardized name associated with a field}
2361   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< A value that indicates missing values.}
2362   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: range(2)\textcolor{comment}{ !< Valid range of a variable (not used in MOM?)}
2363   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: mask\_variant\textcolor{comment}{ !< If true a logical mask must be provided}
2364 \textcolor{comment}{                                                         !! with post\_data calls (not used in MOM?)}
2365   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, FMS is verbose (not used in MOM?)}
2366   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: do\_not\_log\textcolor{comment}{ !< If true, do not log something}
2367 \textcolor{comment}{                                                       !! (not used in MOM?)}
2368   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}:: err\_msg\textcolor{comment}{ !< String into which an error message might be}
2369 \textcolor{comment}{                                                         !! placed (not used in MOM?)}
2370   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: interp\_method\textcolor{comment}{ !< If 'none' indicates the field should}
2371 \textcolor{comment}{                                                         !! not be interpolated as a scalar}
2372   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: tile\_count\textcolor{comment}{ !< no clue (not used in MOM?)}
2373   \textcolor{comment}{! Local variables}
2374   \textcolor{keywordtype}{integer} :: fms\_id, area\_id, volume\_id
2375 
2376   \textcolor{comment}{! This gets the cell area associated with the grid location of this variable}
2377   area\_id = axes%id\_area
2378   volume\_id = axes%id\_volume
2379 
2380   \textcolor{comment}{! Get the FMS diagnostic id}
2381   \textcolor{keywordflow}{if} (axes%diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
2382     fms\_id = axes%diag\_cs%num\_chksum\_diags + 1
2383     axes%diag\_cs%num\_chksum\_diags = fms\_id
2384   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(interp\_method) .or. axes%is\_h\_point) \textcolor{keywordflow}{then}
2385     \textcolor{comment}{! If interp\_method is provided we must use it}
2386     \textcolor{keywordflow}{if} (area\_id>0) \textcolor{keywordflow}{then}
2387       \textcolor{keywordflow}{if} (volume\_id>0) \textcolor{keywordflow}{then}
2388         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2389                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2390                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2391                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2392                  interp\_method=interp\_method, tile\_count=tile\_count, area=area\_id, volume=volume\_id)
2393       \textcolor{keywordflow}{else}
2394         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2395                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2396                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2397                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2398                  interp\_method=interp\_method, tile\_count=tile\_count, area=area\_id)
2399 \textcolor{keywordflow}{      endif}
2400     \textcolor{keywordflow}{else}
2401       \textcolor{keywordflow}{if} (volume\_id>0) \textcolor{keywordflow}{then}
2402         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2403                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2404                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2405                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2406                  interp\_method=interp\_method, tile\_count=tile\_count, volume=volume\_id)
2407       \textcolor{keywordflow}{else}
2408         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2409                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2410                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2411                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2412                  interp\_method=interp\_method, tile\_count=tile\_count)
2413 \textcolor{keywordflow}{      endif}
2414 \textcolor{keywordflow}{    endif}
2415   \textcolor{keywordflow}{else}
2416     \textcolor{comment}{! If interp\_method is not provided and the field is not at an h-point then interp\_method='none'}
2417     \textcolor{keywordflow}{if} (area\_id>0) \textcolor{keywordflow}{then}
2418       \textcolor{keywordflow}{if} (volume\_id>0) \textcolor{keywordflow}{then}
2419         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2420                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2421                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2422                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2423                  interp\_method=\textcolor{stringliteral}{'none'}, tile\_count=tile\_count, area=area\_id, volume=volume\_id)
2424       \textcolor{keywordflow}{else}
2425         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2426                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2427                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2428                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2429                  interp\_method=\textcolor{stringliteral}{'none'}, tile\_count=tile\_count, area=area\_id)
2430 \textcolor{keywordflow}{      endif}
2431     \textcolor{keywordflow}{else}
2432       \textcolor{keywordflow}{if} (volume\_id>0) \textcolor{keywordflow}{then}
2433         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2434                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2435                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2436                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2437                  interp\_method=\textcolor{stringliteral}{'none'}, tile\_count=tile\_count, volume=volume\_id)
2438       \textcolor{keywordflow}{else}
2439         fms\_id = register\_diag\_field\_fms(module\_name, field\_name, axes%handles, &
2440                  init\_time, long\_name=long\_name, units=units, missing\_value=missing\_value, &
2441                  range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2442                  verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2443                  interp\_method=\textcolor{stringliteral}{'none'}, tile\_count=tile\_count)
2444 \textcolor{keywordflow}{      endif}
2445 \textcolor{keywordflow}{    endif}
2446 \textcolor{keywordflow}{  endif}
2447 
2448   register\_diag\_field\_expand\_axes = fms\_id
2449 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ae50b35cba800ac5fd8975929fd2b9f4a}\label{namespacemom__diag__mediator_ae50b35cba800ac5fd8975929fd2b9f4a}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+cmor@{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+cmor}}
\index{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+cmor@{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+cmor}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+cmor()}{register\_diag\_field\_expand\_cmor()}}
{\footnotesize\ttfamily logical function mom\+\_\+diag\+\_\+mediator\+::register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+cmor (\begin{DoxyParamCaption}\item[{integer, intent(inout)}]{dm\+\_\+id,  }\item[{character(len=$\ast$), intent(in)}]{module\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{field\+\_\+name,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(in), target}]{axes,  }\item[{type(time\+\_\+type), intent(in)}]{init\+\_\+time,  }\item[{character(len=$\ast$), intent(in), optional}]{long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{real, intent(in), optional}]{missing\+\_\+value,  }\item[{real, dimension(2), intent(in), optional}]{range,  }\item[{logical, intent(in), optional}]{mask\+\_\+variant,  }\item[{character(len=$\ast$), intent(in), optional}]{standard\+\_\+name,  }\item[{logical, intent(in), optional}]{verbose,  }\item[{logical, intent(in), optional}]{do\+\_\+not\+\_\+log,  }\item[{character(len=$\ast$), intent(out), optional}]{err\+\_\+msg,  }\item[{character(len=$\ast$), intent(in), optional}]{interp\+\_\+method,  }\item[{integer, intent(in), optional}]{tile\+\_\+count,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+field\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+standard\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cell\+\_\+methods,  }\item[{character(len=$\ast$), intent(in), optional}]{x\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{y\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{v\+\_\+cell\+\_\+method,  }\item[{real, intent(in), optional}]{conversion,  }\item[{logical, intent(in), optional}]{v\+\_\+extensive }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns True if either the native or C\+M\+Or version of the diagnostic were registered. Updates \textquotesingle{}dm\+\_\+id\textquotesingle{} after calling \mbox{\hyperlink{namespacemom__diag__mediator_aca4a32fea8dade9f51e076a56b9bad2b}{register\+\_\+diag\+\_\+field\+\_\+expand\+\_\+axes()}} for both native and C\+M\+OR variants of the field. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em dm\+\_\+id} & The diag\+\_\+mediator ID for this diagnostic group\\
\hline
\mbox{\tt in}  & {\em module\+\_\+name} & Name of this module, usually \char`\"{}ocean\+\_\+model\char`\"{} or \char`\"{}ice\+\_\+shelf\+\_\+model\char`\"{}\\
\hline
\mbox{\tt in}  & {\em field\+\_\+name} & Name of the diagnostic field\\
\hline
\mbox{\tt in}  & {\em axes} & Container w/ up to 3 integer handles that indicates axes for this field\\
\hline
\mbox{\tt in}  & {\em init\+\_\+time} & Time at which a field is first available?\\
\hline
\mbox{\tt in}  & {\em long\+\_\+name} & Long name of a field.\\
\hline
\mbox{\tt in}  & {\em units} & Units of a field.\\
\hline
\mbox{\tt in}  & {\em standard\+\_\+name} & Standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em missing\+\_\+value} & A value that indicates missing values.\\
\hline
\mbox{\tt in}  & {\em range} & Valid range of a variable (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em mask\+\_\+variant} & If true a logical mask must be provided with \mbox{\hyperlink{interfacemom__diag__mediator_1_1post__data}{post\+\_\+data}} calls (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em verbose} & If true, F\+MS is verbose (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em do\+\_\+not\+\_\+log} & If true, do not log something (not used in M\+OM?)\\
\hline
\mbox{\tt out}  & {\em err\+\_\+msg} & String into which an error message might be placed (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em interp\+\_\+method} & If \textquotesingle{}none\textquotesingle{} indicates the field should not be interpolated as a scalar\\
\hline
\mbox{\tt in}  & {\em tile\+\_\+count} & no clue (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+long\+\_\+name} & C\+M\+OR long name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+units} & C\+M\+OR units of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+standard\+\_\+name} & C\+M\+OR standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em cell\+\_\+methods} & String to append as cell\+\_\+methods attribute. Use \textquotesingle{}\textquotesingle{} to have no attribute. If present, this overrides the default constructed from the default for each individual axis direction.\\
\hline
\mbox{\tt in}  & {\em x\+\_\+cell\+\_\+method} & Specifies the cell method for the x-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em y\+\_\+cell\+\_\+method} & Specifies the cell method for the y-\/direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em v\+\_\+cell\+\_\+method} & Specifies the cell method for the vertical direction. Use \textquotesingle{}\textquotesingle{} have no method.\\
\hline
\mbox{\tt in}  & {\em conversion} & A value to multiply data by before writing to file\\
\hline
\mbox{\tt in}  & {\em v\+\_\+extensive} & True for vertically extensive fields (vertically integrated). Default/absent for intensive. \\
\hline
\end{DoxyParams}


Definition at line 2187 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2187   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(inout)} :: dm\_id\textcolor{comment}{ !< The diag\_mediator ID for this diagnostic group}
2188   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: module\_name\textcolor{comment}{ !< Name of this module, usually "ocean\_model" or
       "ice\_shelf\_model"}
2189   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: field\_name\textcolor{comment}{ !< Name of the diagnostic field}
2190   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: axes\textcolor{comment}{ !< Container w/ up to 3 integer handles that indicates axes}
2191 \textcolor{comment}{                                             !! for this field}
2192   \textcolor{keywordtype}{type}(time\_type),  \textcolor{keywordtype}{intent(in)} :: init\_time\textcolor{comment}{ !< Time at which a field is first available?}
2193   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: long\_name\textcolor{comment}{ !< Long name of a field.}
2194   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: units\textcolor{comment}{ !< Units of a field.}
2195   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: standard\_name\textcolor{comment}{ !< Standardized name associated with a field}
2196   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< A value that indicates missing values.}
2197   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: range(2)\textcolor{comment}{ !< Valid range of a variable (not used in MOM?)}
2198   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: mask\_variant\textcolor{comment}{ !< If true a logical mask must be provided}
2199 \textcolor{comment}{                                                         !! with post\_data calls (not used in MOM?)}
2200   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, FMS is verbose (not used in MOM?)}
2201   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: do\_not\_log\textcolor{comment}{ !< If true, do not log something (not used in MOM?)}
2202   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}:: err\_msg\textcolor{comment}{ !< String into which an error message might be}
2203 \textcolor{comment}{                                                         !! placed (not used in MOM?)}
2204   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: interp\_method\textcolor{comment}{ !< If 'none' indicates the field should}
2205 \textcolor{comment}{                                                         !! not be interpolated as a scalar}
2206   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: tile\_count\textcolor{comment}{ !< no clue (not used in MOM?)}
2207   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_field\_name\textcolor{comment}{ !< CMOR name of a field}
2208   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_long\_name\textcolor{comment}{ !< CMOR long name of a field}
2209   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_units\textcolor{comment}{ !< CMOR units of a field}
2210   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_standard\_name\textcolor{comment}{ !< CMOR standardized name associated with a
       field}
2211   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cell\_methods\textcolor{comment}{ !< String to append as cell\_methods attribute.}
2212 \textcolor{comment}{                                                         !! Use '' to have no attribute. If present, this}
2213 \textcolor{comment}{                                                         !! overrides the default constructed from the
       default}
2214 \textcolor{comment}{                                                         !! for each individual axis direction.}
2215   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: x\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the x-direction.}
2216 \textcolor{comment}{                                                         !! Use '' have no method.}
2217   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: y\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the y-direction.}
2218 \textcolor{comment}{                                                         !! Use '' have no method.}
2219   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: v\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the vertical
       direction.}
2220 \textcolor{comment}{                                                         !! Use '' have no method.}
2221   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: conversion\textcolor{comment}{ !< A value to multiply data by before writing to
       file}
2222   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: v\_extensive\textcolor{comment}{ !< True for vertically extensive fields (vertically}
2223 \textcolor{comment}{                                                         !! integrated). Default/absent for intensive.}
2224   \textcolor{comment}{! Local variables}
2225   \textcolor{keywordtype}{real} :: MOM\_missing\_value
2226   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{pointer} :: diag\_cs => null()
2227   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: this\_diag => null()
2228   \textcolor{keywordtype}{integer} :: fms\_id, fms\_xyave\_id
2229   \textcolor{keywordtype}{character(len=256)} :: posted\_cmor\_units, posted\_cmor\_standard\_name, posted\_cmor\_long\_name, cm\_string, msg
2230 
2231   mom\_missing\_value = axes%diag\_cs%missing\_value
2232   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(missing\_value)) mom\_missing\_value = missing\_value
2233 
2234   register\_diag\_field\_expand\_cmor = .false.
2235   diag\_cs => axes%diag\_cs
2236 
2237   \textcolor{comment}{! Set up the 'primary' diagnostic, first get an underlying FMS id}
2238   fms\_id = register\_diag\_field\_expand\_axes(module\_name, field\_name, axes, init\_time, &
2239              long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2240              range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2241              verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2242              interp\_method=interp\_method, tile\_count=tile\_count)
2243   \textcolor{keywordflow}{if} (.not. diag\_cs%diag\_as\_chksum) &
2244     \textcolor{keyword}{call }attach\_cell\_methods(fms\_id, axes, cm\_string, cell\_methods, &
2245                              x\_cell\_method, y\_cell\_method, v\_cell\_method, &
2246                              v\_extensive=v\_extensive)
2247   \textcolor{keywordflow}{if} (is\_root\_pe() .and. diag\_cs%available\_diag\_doc\_unit > 0) \textcolor{keywordflow}{then}
2248     msg = \textcolor{stringliteral}{''}
2249     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) msg = \textcolor{stringliteral}{'CMOR equivalent is "'}//trim(cmor\_field\_name)//\textcolor{stringliteral}{'"'}
2250     \textcolor{keyword}{call }log\_available\_diag(fms\_id>0, module\_name, field\_name, cm\_string, &
2251                             msg, diag\_cs, long\_name, units, standard\_name)
2252 \textcolor{keywordflow}{  endif}
2253   \textcolor{comment}{! Associated horizontally area-averaged diagnostic}
2254   fms\_xyave\_id = diag\_field\_not\_found
2255   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(axes%xyave\_axes)) \textcolor{keywordflow}{then}
2256     fms\_xyave\_id = register\_diag\_field\_expand\_axes(module\_name, trim(field\_name)//\textcolor{stringliteral}{'\_xyave'}, &
2257              axes%xyave\_axes, init\_time, &
2258              long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2259              range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2260              verbose=verbose, do\_not\_log=do\_not\_log, err\_msg=err\_msg, &
2261              interp\_method=interp\_method, tile\_count=tile\_count)
2262     \textcolor{keywordflow}{if} (.not. diag\_cs%diag\_as\_chksum) &
2263       \textcolor{keyword}{call }attach\_cell\_methods(fms\_xyave\_id, axes%xyave\_axes, cm\_string, &
2264                                cell\_methods, v\_cell\_method, v\_extensive=v\_extensive)
2265     \textcolor{keywordflow}{if} (is\_root\_pe() .and. diag\_cs%available\_diag\_doc\_unit > 0) \textcolor{keywordflow}{then}
2266       msg = \textcolor{stringliteral}{''}
2267       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) msg = \textcolor{stringliteral}{'CMOR equivalent is "'}//trim(cmor\_field\_name)//\textcolor{stringliteral}{'\_xyave"'}
2268       \textcolor{keyword}{call }log\_available\_diag(fms\_xyave\_id>0, module\_name, trim(field\_name)//\textcolor{stringliteral}{'\_xyave'}, cm\_string, &
2269                               msg, diag\_cs, long\_name, units, standard\_name)
2270 \textcolor{keywordflow}{    endif}
2271 \textcolor{keywordflow}{  endif}
2272   this\_diag => null()
2273   \textcolor{keywordflow}{if} (fms\_id /= diag\_field\_not\_found .or. fms\_xyave\_id /= diag\_field\_not\_found) \textcolor{keywordflow}{then}
2274     \textcolor{keyword}{call }add\_diag\_to\_list(diag\_cs, dm\_id, fms\_id, this\_diag, axes, module\_name, field\_name, msg)
2275     this\_diag%fms\_xyave\_diag\_id = fms\_xyave\_id
2276     \textcolor{comment}{!Encode and save the cell methods for this diag}
2277     \textcolor{keyword}{call }add\_xyz\_method(this\_diag, axes, x\_cell\_method, y\_cell\_method, v\_cell\_method, v\_extensive)
2278     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_extensive)) this\_diag%v\_extensive = v\_extensive
2279     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(conversion)) this\_diag%conversion\_factor = conversion
2280     register\_diag\_field\_expand\_cmor = .true.
2281 \textcolor{keywordflow}{  endif}
2282 
2283   \textcolor{comment}{! For the CMOR variation of the above diagnostic}
2284   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name) .and. .not. diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
2285     \textcolor{comment}{! Fallback values for strings set to "NULL"}
2286     posted\_cmor\_units = \textcolor{stringliteral}{"not provided"}         \textcolor{comment}{!}
2287     posted\_cmor\_standard\_name = \textcolor{stringliteral}{"not provided"} \textcolor{comment}{! Values might be able to be replaced with a CS%missing
       field?}
2288     posted\_cmor\_long\_name = \textcolor{stringliteral}{"not provided"}     \textcolor{comment}{!}
2289 
2290     \textcolor{comment}{! If attributes are present for MOM variable names, use them first for the register\_diag\_field}
2291     \textcolor{comment}{! call for CMOR verison of the variable}
2292     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units)) posted\_cmor\_units = units
2293     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(standard\_name)) posted\_cmor\_standard\_name = standard\_name
2294     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(long\_name)) posted\_cmor\_long\_name = long\_name
2295 
2296     \textcolor{comment}{! If specified in the call to register\_diag\_field, override attributes with the CMOR versions}
2297     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_units)) posted\_cmor\_units = cmor\_units
2298     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_standard\_name)) posted\_cmor\_standard\_name = cmor\_standard\_name
2299     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_long\_name)) posted\_cmor\_long\_name = cmor\_long\_name
2300 
2301     fms\_id = register\_diag\_field\_expand\_axes(module\_name, cmor\_field\_name, axes, init\_time,    &
2302                long\_name=trim(posted\_cmor\_long\_name), units=trim(posted\_cmor\_units),                  &
2303                missing\_value=mom\_missing\_value, range=range, mask\_variant=mask\_variant,               &
2304                standard\_name=trim(posted\_cmor\_standard\_name), verbose=verbose, do\_not\_log=do\_not\_log, &
2305                err\_msg=err\_msg, interp\_method=interp\_method, tile\_count=tile\_count)
2306     \textcolor{keyword}{call }attach\_cell\_methods(fms\_id, axes, cm\_string, &
2307                              cell\_methods, x\_cell\_method, y\_cell\_method, v\_cell\_method, &
2308                              v\_extensive=v\_extensive)
2309     \textcolor{keywordflow}{if} (is\_root\_pe() .and. diag\_cs%available\_diag\_doc\_unit > 0) \textcolor{keywordflow}{then}
2310       msg = \textcolor{stringliteral}{'native name is "'}//trim(field\_name)//\textcolor{stringliteral}{'"'}
2311       \textcolor{keyword}{call }log\_available\_diag(fms\_id>0, module\_name, cmor\_field\_name, cm\_string, &
2312                               msg, diag\_cs, posted\_cmor\_long\_name, posted\_cmor\_units, &
2313                               posted\_cmor\_standard\_name)
2314 \textcolor{keywordflow}{    endif}
2315     \textcolor{comment}{! Associated horizontally area-averaged diagnostic}
2316     fms\_xyave\_id = diag\_field\_not\_found
2317     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(axes%xyave\_axes)) \textcolor{keywordflow}{then}
2318       fms\_xyave\_id = register\_diag\_field\_expand\_axes(module\_name, trim(cmor\_field\_name)//\textcolor{stringliteral}{'\_xyave'}, &
2319                axes%xyave\_axes, init\_time, &
2320                long\_name=trim(posted\_cmor\_long\_name), units=trim(posted\_cmor\_units),                  &
2321                missing\_value=mom\_missing\_value, range=range, mask\_variant=mask\_variant,               &
2322                standard\_name=trim(posted\_cmor\_standard\_name), verbose=verbose, do\_not\_log=do\_not\_log, &
2323                err\_msg=err\_msg, interp\_method=interp\_method, tile\_count=tile\_count)
2324       \textcolor{keyword}{call }attach\_cell\_methods(fms\_xyave\_id, axes%xyave\_axes, cm\_string, &
2325                                cell\_methods, v\_cell\_method, v\_extensive=v\_extensive)
2326       \textcolor{keywordflow}{if} (is\_root\_pe() .and. diag\_cs%available\_diag\_doc\_unit > 0) \textcolor{keywordflow}{then}
2327         msg = \textcolor{stringliteral}{'native name is "'}//trim(field\_name)//\textcolor{stringliteral}{'\_xyave"'}
2328         \textcolor{keyword}{call }log\_available\_diag(fms\_xyave\_id>0, module\_name, trim(cmor\_field\_name)//\textcolor{stringliteral}{'\_xyave'}, &
2329                                 cm\_string, msg, diag\_cs, posted\_cmor\_long\_name, posted\_cmor\_units, &
2330                                 posted\_cmor\_standard\_name)
2331 \textcolor{keywordflow}{      endif}
2332 \textcolor{keywordflow}{    endif}
2333     this\_diag => null()
2334     \textcolor{keywordflow}{if} (fms\_id /= diag\_field\_not\_found .or. fms\_xyave\_id /= diag\_field\_not\_found) \textcolor{keywordflow}{then}
2335       \textcolor{keyword}{call }add\_diag\_to\_list(diag\_cs, dm\_id, fms\_id, this\_diag, axes, module\_name, field\_name, msg)
2336       this\_diag%fms\_xyave\_diag\_id = fms\_xyave\_id
2337       \textcolor{comment}{!Encode and save the cell methods for this diag}
2338       \textcolor{keyword}{call }add\_xyz\_method(this\_diag, axes, x\_cell\_method, y\_cell\_method, v\_cell\_method, v\_extensive)
2339       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(v\_extensive)) this\_diag%v\_extensive = v\_extensive
2340       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(conversion)) this\_diag%conversion\_factor = conversion
2341       register\_diag\_field\_expand\_cmor = .true.
2342 \textcolor{keywordflow}{    endif}
2343 \textcolor{keywordflow}{  endif}
2344 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_afb4254e1cfbbcfc43028f14915173f80}\label{namespacemom__diag__mediator_afb4254e1cfbbcfc43028f14915173f80}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!register\+\_\+scalar\+\_\+field@{register\+\_\+scalar\+\_\+field}}
\index{register\+\_\+scalar\+\_\+field@{register\+\_\+scalar\+\_\+field}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{register\+\_\+scalar\+\_\+field()}{register\_scalar\_field()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+diag\+\_\+mediator\+::register\+\_\+scalar\+\_\+field (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{module\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{field\+\_\+name,  }\item[{type(time\+\_\+type), intent(in)}]{init\+\_\+time,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs,  }\item[{character(len=$\ast$), intent(in), optional}]{long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{real, intent(in), optional}]{missing\+\_\+value,  }\item[{real, dimension(2), intent(in), optional}]{range,  }\item[{character(len=$\ast$), intent(in), optional}]{standard\+\_\+name,  }\item[{logical, intent(in), optional}]{do\+\_\+not\+\_\+log,  }\item[{character(len=$\ast$), intent(out), optional}]{err\+\_\+msg,  }\item[{character(len=$\ast$), intent(in), optional}]{interp\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+field\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+standard\+\_\+name }\end{DoxyParamCaption})}

\begin{DoxyReturn}{Returns}
An integer handle for a diagnostic array.
\end{DoxyReturn}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em module\+\_\+name} & Name of this module, usually \char`\"{}ocean\+\_\+model\char`\"{} or \char`\"{}ice\+\_\+shelf\+\_\+model\char`\"{}\\
\hline
\mbox{\tt in}  & {\em field\+\_\+name} & Name of the diagnostic field\\
\hline
\mbox{\tt in}  & {\em init\+\_\+time} & Time at which a field is first available?\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output\\
\hline
\mbox{\tt in}  & {\em long\+\_\+name} & Long name of a field.\\
\hline
\mbox{\tt in}  & {\em units} & Units of a field.\\
\hline
\mbox{\tt in}  & {\em standard\+\_\+name} & Standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em missing\+\_\+value} & A value that indicates missing values.\\
\hline
\mbox{\tt in}  & {\em range} & Valid range of a variable (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em do\+\_\+not\+\_\+log} & If true, do not log something (not used in M\+OM?)\\
\hline
\mbox{\tt out}  & {\em err\+\_\+msg} & String into which an error message might be placed (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em interp\+\_\+method} & If \textquotesingle{}none\textquotesingle{} indicates the field should not be interpolated as a scalar\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+long\+\_\+name} & C\+M\+OR long name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+units} & C\+M\+OR units of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+standard\+\_\+name} & C\+M\+OR standardized name associated with a field \\
\hline
\end{DoxyParams}


Definition at line 2662 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2662   \textcolor{keywordtype}{integer} :: register\_scalar\_field\textcolor{comment}{ !< An integer handle for a diagnostic array.}
2663   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: module\_name\textcolor{comment}{ !< Name of this module, usually "ocean\_model"}
2664 \textcolor{comment}{                                              !! or "ice\_shelf\_model"}
2665   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: field\_name\textcolor{comment}{ !< Name of the diagnostic field}
2666   \textcolor{keywordtype}{type}(time\_type),  \textcolor{keywordtype}{intent(in)} :: init\_time\textcolor{comment}{ !< Time at which a field is first available?}
2667   \textcolor{keywordtype}{type}(diag\_ctrl),  \textcolor{keywordtype}{intent(inout)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
2668   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: long\_name\textcolor{comment}{ !< Long name of a field.}
2669   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: units\textcolor{comment}{ !< Units of a field.}
2670   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: standard\_name\textcolor{comment}{ !< Standardized name associated with a field}
2671   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< A value that indicates missing values.}
2672   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: range(2)\textcolor{comment}{ !< Valid range of a variable (not used in MOM?)}
2673   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: do\_not\_log\textcolor{comment}{ !< If true, do not log something (not used in MOM?)}
2674   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}:: err\_msg\textcolor{comment}{ !< String into which an error message might be}
2675 \textcolor{comment}{                                                         !! placed (not used in MOM?)}
2676   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: interp\_method\textcolor{comment}{ !< If 'none' indicates the field should not}
2677 \textcolor{comment}{                                                         !! be interpolated as a scalar}
2678   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_field\_name\textcolor{comment}{ !< CMOR name of a field}
2679   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_long\_name\textcolor{comment}{ !< CMOR long name of a field}
2680   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_units\textcolor{comment}{ !< CMOR units of a field}
2681   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_standard\_name\textcolor{comment}{ !< CMOR standardized name associated with a
       field}
2682 
2683   \textcolor{comment}{! Local variables}
2684   \textcolor{keywordtype}{real} :: MOM\_missing\_value
2685   \textcolor{keywordtype}{integer} :: dm\_id, fms\_id
2686   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: diag => null(), cmor\_diag => null()
2687   \textcolor{keywordtype}{character(len=256)} :: posted\_cmor\_units, posted\_cmor\_standard\_name, posted\_cmor\_long\_name
2688 
2689   mom\_missing\_value = diag\_cs%missing\_value
2690   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(missing\_value)) mom\_missing\_value = missing\_value
2691 
2692   dm\_id = -1
2693   diag => null()
2694   cmor\_diag => null()
2695 
2696   \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
2697     fms\_id = diag\_cs%num\_chksum\_diags + 1
2698     diag\_cs%num\_chksum\_diags = fms\_id
2699   \textcolor{keywordflow}{else}
2700     fms\_id = register\_diag\_field\_fms(module\_name, field\_name, init\_time, &
2701         long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2702         range=range, standard\_name=standard\_name, do\_not\_log=do\_not\_log, &
2703         err\_msg=err\_msg)
2704 \textcolor{keywordflow}{  endif}
2705 
2706   \textcolor{keywordflow}{if} (fms\_id /= diag\_field\_not\_found) \textcolor{keywordflow}{then}
2707     dm\_id = get\_new\_diag\_id(diag\_cs)
2708     \textcolor{keyword}{call }alloc\_diag\_with\_id(dm\_id, diag\_cs, diag)
2709     \textcolor{keyword}{call }assert(\textcolor{keyword}{associated}(diag), \textcolor{stringliteral}{'register\_scalar\_field: diag allocation failed'})
2710     diag%fms\_diag\_id = fms\_id
2711     diag%debug\_str = trim(module\_name)//\textcolor{stringliteral}{"-"}//trim(field\_name)
2712 \textcolor{keywordflow}{  endif}
2713 
2714   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) \textcolor{keywordflow}{then}
2715     \textcolor{comment}{! Fallback values for strings set to "not provided"}
2716     posted\_cmor\_units = \textcolor{stringliteral}{"not provided"}
2717     posted\_cmor\_standard\_name = \textcolor{stringliteral}{"not provided"}
2718     posted\_cmor\_long\_name = \textcolor{stringliteral}{"not provided"}
2719 
2720     \textcolor{comment}{! If attributes are present for MOM variable names, use them first for the register\_static\_field}
2721     \textcolor{comment}{! call for CMOR verison of the variable}
2722     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units)) posted\_cmor\_units = units
2723     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(standard\_name)) posted\_cmor\_standard\_name = standard\_name
2724     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(long\_name)) posted\_cmor\_long\_name = long\_name
2725 
2726     \textcolor{comment}{! If specified in the call to register\_static\_field, override attributes with the CMOR versions}
2727     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_units)) posted\_cmor\_units = cmor\_units
2728     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_standard\_name)) posted\_cmor\_standard\_name = cmor\_standard\_name
2729     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_long\_name)) posted\_cmor\_long\_name = cmor\_long\_name
2730 
2731     fms\_id = register\_diag\_field\_fms(module\_name, cmor\_field\_name, init\_time, &
2732        long\_name=trim(posted\_cmor\_long\_name), units=trim(posted\_cmor\_units), &
2733        missing\_value=mom\_missing\_value, range=range, &
2734        standard\_name=trim(posted\_cmor\_standard\_name), do\_not\_log=do\_not\_log, err\_msg=err\_msg)
2735     \textcolor{keywordflow}{if} (fms\_id /= diag\_field\_not\_found) \textcolor{keywordflow}{then}
2736       \textcolor{keywordflow}{if} (dm\_id == -1) \textcolor{keywordflow}{then}
2737         dm\_id = get\_new\_diag\_id(diag\_cs)
2738 \textcolor{keywordflow}{      endif}
2739       \textcolor{keyword}{call }alloc\_diag\_with\_id(dm\_id, diag\_cs, cmor\_diag)
2740       cmor\_diag%fms\_diag\_id = fms\_id
2741       cmor\_diag%debug\_str = trim(module\_name)//\textcolor{stringliteral}{"-"}//trim(cmor\_field\_name)
2742 \textcolor{keywordflow}{    endif}
2743 \textcolor{keywordflow}{  endif}
2744 
2745   \textcolor{comment}{! Document diagnostics in list of available diagnostics}
2746   \textcolor{keywordflow}{if} (is\_root\_pe() .and. diag\_cs%available\_diag\_doc\_unit > 0) \textcolor{keywordflow}{then}
2747     \textcolor{keyword}{call }log\_available\_diag(\textcolor{keyword}{associated}(diag), module\_name, field\_name, \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''}, diag\_cs, &
2748                             long\_name, units, standard\_name)
2749     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) \textcolor{keywordflow}{then}
2750       \textcolor{keyword}{call }log\_available\_diag(\textcolor{keyword}{associated}(cmor\_diag), module\_name, cmor\_field\_name, &
2751                               \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''}, diag\_cs, posted\_cmor\_long\_name, posted\_cmor\_units, &
2752                               posted\_cmor\_standard\_name)
2753 \textcolor{keywordflow}{    endif}
2754 \textcolor{keywordflow}{  endif}
2755 
2756   register\_scalar\_field = dm\_id
2757 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a87fa69b9e2ba3205756d93e1e13e1dc7}\label{namespacemom__diag__mediator_a87fa69b9e2ba3205756d93e1e13e1dc7}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!register\+\_\+static\+\_\+field@{register\+\_\+static\+\_\+field}}
\index{register\+\_\+static\+\_\+field@{register\+\_\+static\+\_\+field}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{register\+\_\+static\+\_\+field()}{register\_static\_field()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+diag\+\_\+mediator\+::register\+\_\+static\+\_\+field (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{module\+\_\+name,  }\item[{character(len=$\ast$), intent(in)}]{field\+\_\+name,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1axes__grp}{axes\+\_\+grp}}), intent(in), target}]{axes,  }\item[{character(len=$\ast$), intent(in), optional}]{long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{real, intent(in), optional}]{missing\+\_\+value,  }\item[{real, dimension(2), intent(in), optional}]{range,  }\item[{logical, intent(in), optional}]{mask\+\_\+variant,  }\item[{character(len=$\ast$), intent(in), optional}]{standard\+\_\+name,  }\item[{logical, intent(in), optional}]{do\+\_\+not\+\_\+log,  }\item[{character(len=$\ast$), intent(in), optional}]{interp\+\_\+method,  }\item[{integer, intent(in), optional}]{tile\+\_\+count,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+field\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+long\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+standard\+\_\+name,  }\item[{integer, intent(in), optional}]{area,  }\item[{character(len=$\ast$), intent(in), optional}]{x\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{y\+\_\+cell\+\_\+method,  }\item[{character(len=$\ast$), intent(in), optional}]{area\+\_\+cell\+\_\+method,  }\item[{real, intent(in), optional}]{conversion }\end{DoxyParamCaption})}



Registers a static diagnostic, returning an integer handle. 

\begin{DoxyReturn}{Returns}
An integer handle for a diagnostic array.
\end{DoxyReturn}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em module\+\_\+name} & Name of this module, usually \char`\"{}ocean\+\_\+model\char`\"{} or \char`\"{}ice\+\_\+shelf\+\_\+model\char`\"{}\\
\hline
\mbox{\tt in}  & {\em field\+\_\+name} & Name of the diagnostic field\\
\hline
\mbox{\tt in}  & {\em axes} & Container w/ up to 3 integer handles that indicates axes for this field\\
\hline
\mbox{\tt in}  & {\em long\+\_\+name} & Long name of a field.\\
\hline
\mbox{\tt in}  & {\em units} & Units of a field.\\
\hline
\mbox{\tt in}  & {\em standard\+\_\+name} & Standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em missing\+\_\+value} & A value that indicates missing values.\\
\hline
\mbox{\tt in}  & {\em range} & Valid range of a variable (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em mask\+\_\+variant} & If true a logical mask must be provided with \mbox{\hyperlink{interfacemom__diag__mediator_1_1post__data}{post\+\_\+data}} calls (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em do\+\_\+not\+\_\+log} & If true, do not log something (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em interp\+\_\+method} & If \textquotesingle{}none\textquotesingle{} indicates the field should not be interpolated as a scalar\\
\hline
\mbox{\tt in}  & {\em tile\+\_\+count} & no clue (not used in M\+OM?)\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+long\+\_\+name} & C\+M\+OR long name of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+units} & C\+M\+OR units of a field\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+standard\+\_\+name} & C\+M\+OR standardized name associated with a field\\
\hline
\mbox{\tt in}  & {\em area} & fms\+\_\+id for area\+\_\+t\\
\hline
\mbox{\tt in}  & {\em x\+\_\+cell\+\_\+method} & Specifies the cell method for the x-\/direction.\\
\hline
\mbox{\tt in}  & {\em y\+\_\+cell\+\_\+method} & Specifies the cell method for the y-\/direction.\\
\hline
\mbox{\tt in}  & {\em area\+\_\+cell\+\_\+method} & Specifies the cell method for area\\
\hline
\mbox{\tt in}  & {\em conversion} & A value to multiply data by before writing to file \\
\hline
\end{DoxyParams}


Definition at line 2766 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
2766   \textcolor{keywordtype}{integer} :: register\_static\_field\textcolor{comment}{ !< An integer handle for a diagnostic array.}
2767   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: module\_name\textcolor{comment}{ !< Name of this module, usually "ocean\_model"}
2768 \textcolor{comment}{                                              !! or "ice\_shelf\_model"}
2769   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: field\_name\textcolor{comment}{ !< Name of the diagnostic field}
2770   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: axes\textcolor{comment}{ !< Container w/ up to 3 integer handles that}
2771 \textcolor{comment}{                                             !! indicates axes for this field}
2772   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: long\_name\textcolor{comment}{ !< Long name of a field.}
2773   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: units\textcolor{comment}{ !< Units of a field.}
2774   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: standard\_name\textcolor{comment}{ !< Standardized name associated with a field}
2775   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< A value that indicates missing values.}
2776   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: range(2)\textcolor{comment}{ !< Valid range of a variable (not used in MOM?)}
2777   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: mask\_variant\textcolor{comment}{ !< If true a logical mask must be provided with}
2778 \textcolor{comment}{                                                         !! post\_data calls (not used in MOM?)}
2779   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: do\_not\_log\textcolor{comment}{ !< If true, do not log something (not used in MOM?)}
2780   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: interp\_method\textcolor{comment}{ !< If 'none' indicates the field should not}
2781 \textcolor{comment}{                                                         !! be interpolated as a scalar}
2782   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: tile\_count\textcolor{comment}{ !< no clue (not used in MOM?)}
2783   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_field\_name\textcolor{comment}{ !< CMOR name of a field}
2784   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_long\_name\textcolor{comment}{ !< CMOR long name of a field}
2785   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_units\textcolor{comment}{ !< CMOR units of a field}
2786   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_standard\_name\textcolor{comment}{ !< CMOR standardized name associated with a
       field}
2787   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: area\textcolor{comment}{ !< fms\_id for area\_t}
2788   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: x\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the x-direction.}
2789   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: y\_cell\_method\textcolor{comment}{ !< Specifies the cell method for the y-direction.}
2790   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: area\_cell\_method\textcolor{comment}{ !< Specifies the cell method for area}
2791   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: conversion\textcolor{comment}{ !< A value to multiply data by before writing to
       file}
2792 
2793   \textcolor{comment}{! Local variables}
2794   \textcolor{keywordtype}{real} :: MOM\_missing\_value
2795   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{pointer} :: diag\_cs => null()
2796   \textcolor{keywordtype}{type}(diag\_type), \textcolor{keywordtype}{pointer} :: diag => null(), cmor\_diag => null()
2797   \textcolor{keywordtype}{integer} :: dm\_id, fms\_id, cmor\_id
2798   \textcolor{keywordtype}{character(len=256)} :: posted\_cmor\_units, posted\_cmor\_standard\_name, posted\_cmor\_long\_name
2799   \textcolor{keywordtype}{character(len=9)} :: axis\_name
2800 
2801   mom\_missing\_value = axes%diag\_cs%missing\_value
2802   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(missing\_value)) mom\_missing\_value = missing\_value
2803 
2804   diag\_cs => axes%diag\_cs
2805   dm\_id = -1
2806   diag => null()
2807   cmor\_diag => null()
2808 
2809   \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
2810     fms\_id = diag\_cs%num\_chksum\_diags + 1
2811     diag\_cs%num\_chksum\_diags = fms\_id
2812   \textcolor{keywordflow}{else}
2813     fms\_id = register\_static\_field\_fms(module\_name, field\_name, axes%handles, &
2814            long\_name=long\_name, units=units, missing\_value=mom\_missing\_value, &
2815            range=range, mask\_variant=mask\_variant, standard\_name=standard\_name, &
2816            do\_not\_log=do\_not\_log, &
2817            interp\_method=interp\_method, tile\_count=tile\_count, area=area)
2818 \textcolor{keywordflow}{  endif}
2819 
2820   \textcolor{keywordflow}{if} (fms\_id /= diag\_field\_not\_found) \textcolor{keywordflow}{then}
2821     dm\_id = get\_new\_diag\_id(diag\_cs)
2822     \textcolor{keyword}{call }alloc\_diag\_with\_id(dm\_id, diag\_cs, diag)
2823     \textcolor{keyword}{call }assert(\textcolor{keyword}{associated}(diag), \textcolor{stringliteral}{'register\_static\_field: diag allocation failed'})
2824     diag%fms\_diag\_id = fms\_id
2825     diag%debug\_str = trim(module\_name)//\textcolor{stringliteral}{"-"}//trim(field\_name)
2826     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(conversion)) diag%conversion\_factor = conversion
2827 
2828     \textcolor{keywordflow}{if} (diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
2829       diag%axes => axes
2830     \textcolor{keywordflow}{else}
2831       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(x\_cell\_method)) \textcolor{keywordflow}{then}
2832         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(1), axis\_name)
2833         \textcolor{keyword}{call }diag\_field\_add\_attribute(fms\_id, \textcolor{stringliteral}{'cell\_methods'}, &
2834             trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(x\_cell\_method))
2835 \textcolor{keywordflow}{      endif}
2836       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(y\_cell\_method)) \textcolor{keywordflow}{then}
2837         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(2), axis\_name)
2838         \textcolor{keyword}{call }diag\_field\_add\_attribute(fms\_id, \textcolor{stringliteral}{'cell\_methods'}, &
2839             trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(y\_cell\_method))
2840 \textcolor{keywordflow}{      endif}
2841       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(area\_cell\_method)) \textcolor{keywordflow}{then}
2842         \textcolor{keyword}{call }diag\_field\_add\_attribute(fms\_id, \textcolor{stringliteral}{'cell\_methods'}, &
2843             \textcolor{stringliteral}{'area:'}//trim(area\_cell\_method))
2844 \textcolor{keywordflow}{      endif}
2845 \textcolor{keywordflow}{    endif}
2846 \textcolor{keywordflow}{  endif}
2847 
2848   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name) .and. .not. diag\_cs%diag\_as\_chksum) \textcolor{keywordflow}{then}
2849     \textcolor{comment}{! Fallback values for strings set to "not provided"}
2850     posted\_cmor\_units = \textcolor{stringliteral}{"not provided"}
2851     posted\_cmor\_standard\_name = \textcolor{stringliteral}{"not provided"}
2852     posted\_cmor\_long\_name = \textcolor{stringliteral}{"not provided"}
2853 
2854     \textcolor{comment}{! If attributes are present for MOM variable names, use them first for the register\_static\_field}
2855     \textcolor{comment}{! call for CMOR verison of the variable}
2856     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units)) posted\_cmor\_units = units
2857     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(standard\_name)) posted\_cmor\_standard\_name = standard\_name
2858     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(long\_name)) posted\_cmor\_long\_name = long\_name
2859 
2860     \textcolor{comment}{! If specified in the call to register\_static\_field, override attributes with the CMOR versions}
2861     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_units)) posted\_cmor\_units = cmor\_units
2862     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_standard\_name)) posted\_cmor\_standard\_name = cmor\_standard\_name
2863     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_long\_name)) posted\_cmor\_long\_name = cmor\_long\_name
2864 
2865     fms\_id = register\_static\_field\_fms(module\_name, cmor\_field\_name, &
2866       axes%handles, long\_name=trim(posted\_cmor\_long\_name), units=trim(posted\_cmor\_units), &
2867       missing\_value=mom\_missing\_value, range=range, mask\_variant=mask\_variant,            &
2868       standard\_name=trim(posted\_cmor\_standard\_name), do\_not\_log=do\_not\_log,               &
2869       interp\_method=interp\_method, tile\_count=tile\_count, area=area)
2870     \textcolor{keywordflow}{if} (fms\_id /= diag\_field\_not\_found) \textcolor{keywordflow}{then}
2871       \textcolor{keywordflow}{if} (dm\_id == -1) \textcolor{keywordflow}{then}
2872         dm\_id = get\_new\_diag\_id(diag\_cs)
2873 \textcolor{keywordflow}{      endif}
2874       \textcolor{keyword}{call }alloc\_diag\_with\_id(dm\_id, diag\_cs, cmor\_diag)
2875       cmor\_diag%fms\_diag\_id = fms\_id
2876       cmor\_diag%debug\_str = trim(module\_name)//\textcolor{stringliteral}{"-"}//trim(cmor\_field\_name)
2877       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(conversion)) cmor\_diag%conversion\_factor = conversion
2878       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(x\_cell\_method)) \textcolor{keywordflow}{then}
2879         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(1), axis\_name)
2880         \textcolor{keyword}{call }diag\_field\_add\_attribute(fms\_id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(x\_cell\_method))
2881 \textcolor{keywordflow}{      endif}
2882       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(y\_cell\_method)) \textcolor{keywordflow}{then}
2883         \textcolor{keyword}{call }get\_diag\_axis\_name(axes%handles(2), axis\_name)
2884         \textcolor{keyword}{call }diag\_field\_add\_attribute(fms\_id, \textcolor{stringliteral}{'cell\_methods'}, trim(axis\_name)//\textcolor{stringliteral}{':'}//trim(y\_cell\_method))
2885 \textcolor{keywordflow}{      endif}
2886       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(area\_cell\_method)) \textcolor{keywordflow}{then}
2887         \textcolor{keyword}{call }diag\_field\_add\_attribute(fms\_id, \textcolor{stringliteral}{'cell\_methods'}, \textcolor{stringliteral}{'area:'}//trim(area\_cell\_method))
2888 \textcolor{keywordflow}{      endif}
2889 \textcolor{keywordflow}{    endif}
2890 \textcolor{keywordflow}{  endif}
2891 
2892   \textcolor{comment}{! Document diagnostics in list of available diagnostics}
2893   \textcolor{keywordflow}{if} (is\_root\_pe() .and. diag\_cs%available\_diag\_doc\_unit > 0) \textcolor{keywordflow}{then}
2894     \textcolor{keyword}{call }log\_available\_diag(\textcolor{keyword}{associated}(diag), module\_name, field\_name, \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''}, diag\_cs, &
2895                             long\_name, units, standard\_name)
2896     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) \textcolor{keywordflow}{then}
2897       \textcolor{keyword}{call }log\_available\_diag(\textcolor{keyword}{associated}(cmor\_diag), module\_name, cmor\_field\_name, &
2898                               \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''}, diag\_cs, posted\_cmor\_long\_name, posted\_cmor\_units, &
2899                               posted\_cmor\_standard\_name)
2900 \textcolor{keywordflow}{    endif}
2901 \textcolor{keywordflow}{  endif}
2902 
2903   register\_static\_field = dm\_id
2904 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a76c9267c7744e3573f78afbaa0b716a5}\label{namespacemom__diag__mediator_a76c9267c7744e3573f78afbaa0b716a5}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!set\+\_\+axes\+\_\+info@{set\+\_\+axes\+\_\+info}}
\index{set\+\_\+axes\+\_\+info@{set\+\_\+axes\+\_\+info}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{set\+\_\+axes\+\_\+info()}{set\_axes\_info()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::set\+\_\+axes\+\_\+info (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs,  }\item[{logical, intent(in), optional}]{set\+\_\+vertical }\end{DoxyParamCaption})}



Sets up diagnostics axes. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\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}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Diagnostics control structure\\
\hline
\mbox{\tt in}  & {\em set\+\_\+vertical} & If true or missing, set up vertical axes \\
\hline
\end{DoxyParams}


Definition at line 349 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
349   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< Ocean grid structure}
350   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< ocean vertical grid structure}
351   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}
352   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file structure}
353   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{ !< Diagnostics control structure}
354   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: set\_vertical\textcolor{comment}{ !< If true or missing, set up}
355 \textcolor{comment}{                                                       !! vertical axes}
356   \textcolor{comment}{! Local variables}
357   \textcolor{keywordtype}{integer} :: id\_xq, id\_yq, id\_zl, id\_zi, id\_xh, id\_yh
358   \textcolor{keywordtype}{integer} :: id\_zl\_native, id\_zi\_native
359   \textcolor{keywordtype}{integer} :: i, j, k, nz
360   \textcolor{keywordtype}{real} :: zlev(GV%ke), zinter(GV%ke+1)
361   \textcolor{keywordtype}{logical} :: set\_vert
362   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: IaxB,iax
363   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: JaxB,jax
364 
365 
366   set\_vert = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(set\_vertical)) set\_vert = set\_vertical
367 
368 
369   \textcolor{keywordflow}{if} (diag\_cs%grid\_space\_axes) \textcolor{keywordflow}{then}
370      \textcolor{keyword}{allocate}(iaxb(g%IsgB:g%IegB))
371      \textcolor{keywordflow}{do} i=g%IsgB, g%IegB
372        iaxb(i)=\textcolor{keywordtype}{real}(i)
373 \textcolor{keywordflow}{     enddo}
374      \textcolor{keyword}{allocate}(iax(g%isg:g%ieg))
375      \textcolor{keywordflow}{do} i=g%isg, g%ieg
376        iax(i)=\textcolor{keywordtype}{real}(i)-0.5
377 \textcolor{keywordflow}{     enddo}
378      \textcolor{keyword}{allocate}(jaxb(g%JsgB:g%JegB))
379      \textcolor{keywordflow}{do} j=g%JsgB, g%JegB
380        jaxb(j)=\textcolor{keywordtype}{real}(j)
381 \textcolor{keywordflow}{     enddo}
382      \textcolor{keyword}{allocate}(jax(g%jsg:g%jeg))
383      \textcolor{keywordflow}{do} j=g%jsg, g%jeg
384        jax(j)=\textcolor{keywordtype}{real}(j)-0.5
385 \textcolor{keywordflow}{     enddo}
386 \textcolor{keywordflow}{  endif}
387 
388   \textcolor{comment}{! Horizontal axes for the native grids}
389   \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
390      \textcolor{keywordflow}{if} (diag\_cs%grid\_space\_axes) \textcolor{keywordflow}{then}
391         id\_xq = diag\_axis\_init(\textcolor{stringliteral}{'iq'}, iaxb(g%isgB:g%iegB), \textcolor{stringliteral}{'none'}, \textcolor{stringliteral}{'x'}, &
392              \textcolor{stringliteral}{'q point grid-space longitude'}, domain2=g%Domain%mpp\_domain, domain\_position=east)
393         id\_yq = diag\_axis\_init(\textcolor{stringliteral}{'jq'}, jaxb(g%jsgB:g%jegB), \textcolor{stringliteral}{'none'}, \textcolor{stringliteral}{'y'}, &
394          \textcolor{stringliteral}{'q point grid space latitude'}, domain2=g%Domain%mpp\_domain, domain\_position=north)
395      \textcolor{keywordflow}{else}
396         id\_xq = diag\_axis\_init(\textcolor{stringliteral}{'xq'}, g%gridLonB(g%isgB:g%iegB), g%x\_axis\_units, \textcolor{stringliteral}{'x'}, &
397              \textcolor{stringliteral}{'q point nominal longitude'}, domain2=g%Domain%mpp\_domain, domain\_position=east)
398         id\_yq = diag\_axis\_init(\textcolor{stringliteral}{'yq'}, g%gridLatB(g%jsgB:g%jegB), g%y\_axis\_units, \textcolor{stringliteral}{'y'}, &
399             \textcolor{stringliteral}{'q point nominal latitude'}, domain2=g%Domain%mpp\_domain, domain\_position=north)
400 \textcolor{keywordflow}{     endif}
401   \textcolor{keywordflow}{else}
402      \textcolor{keywordflow}{if} (diag\_cs%grid\_space\_axes) \textcolor{keywordflow}{then}
403         id\_xq = diag\_axis\_init(\textcolor{stringliteral}{'Iq'}, iaxb(g%isg:g%ieg), \textcolor{stringliteral}{'none'}, \textcolor{stringliteral}{'x'}, &
404              \textcolor{stringliteral}{'q point grid-space longitude'}, domain2=g%Domain%mpp\_domain, domain\_position=east)
405         id\_yq = diag\_axis\_init(\textcolor{stringliteral}{'Jq'}, jaxb(g%jsg:g%jeg), \textcolor{stringliteral}{'none'}, \textcolor{stringliteral}{'y'}, &
406              \textcolor{stringliteral}{'q point grid space latitude'}, domain2=g%Domain%mpp\_domain, domain\_position=north)
407      \textcolor{keywordflow}{else}
408         id\_xq = diag\_axis\_init(\textcolor{stringliteral}{'xq'}, g%gridLonB(g%isg:g%ieg), g%x\_axis\_units, \textcolor{stringliteral}{'x'}, &
409              \textcolor{stringliteral}{'q point nominal longitude'}, domain2=g%Domain%mpp\_domain, domain\_position=east)
410         id\_yq = diag\_axis\_init(\textcolor{stringliteral}{'yq'}, g%gridLatB(g%jsg:g%jeg), g%y\_axis\_units, \textcolor{stringliteral}{'y'}, &
411              \textcolor{stringliteral}{'q point nominal latitude'}, domain2=g%Domain%mpp\_domain, domain\_position=north)
412 \textcolor{keywordflow}{     endif}
413 \textcolor{keywordflow}{  endif}
414 
415 
416   \textcolor{keywordflow}{if} (diag\_cs%grid\_space\_axes) \textcolor{keywordflow}{then}
417      id\_xh = diag\_axis\_init(\textcolor{stringliteral}{'ih'}, iax(g%isg:g%ieg), \textcolor{stringliteral}{'none'}, \textcolor{stringliteral}{'x'}, &
418           \textcolor{stringliteral}{'h point grid-space longitude'}, domain2=g%Domain%mpp\_domain, domain\_position=east)
419      id\_yh = diag\_axis\_init(\textcolor{stringliteral}{'jh'}, jax(g%jsg:g%jeg), \textcolor{stringliteral}{'none'}, \textcolor{stringliteral}{'y'}, &
420          \textcolor{stringliteral}{'h point grid space latitude'}, domain2=g%Domain%mpp\_domain, domain\_position=north)
421   \textcolor{keywordflow}{else}
422      id\_xh = diag\_axis\_init(\textcolor{stringliteral}{'xh'}, g%gridLonT(g%isg:g%ieg), g%x\_axis\_units, \textcolor{stringliteral}{'x'}, &
423           \textcolor{stringliteral}{'h point nominal longitude'}, domain2=g%Domain%mpp\_domain)
424      id\_yh = diag\_axis\_init(\textcolor{stringliteral}{'yh'}, g%gridLatT(g%jsg:g%jeg), g%y\_axis\_units, \textcolor{stringliteral}{'y'}, &
425           \textcolor{stringliteral}{'h point nominal latitude'}, domain2=g%Domain%mpp\_domain)
426 \textcolor{keywordflow}{  endif}
427 
428   \textcolor{keywordflow}{if} (set\_vert) \textcolor{keywordflow}{then}
429     nz = gv%ke
430     zinter(1:nz+1) = gv%sInterface(1:nz+1)
431     zlev(1:nz) = gv%sLayer(1:nz)
432     id\_zl = diag\_axis\_init(\textcolor{stringliteral}{'zl'}, zlev, trim(gv%zAxisUnits), \textcolor{stringliteral}{'z'}, &
433                            \textcolor{stringliteral}{'Layer '}//trim(gv%zAxisLongName),     &
434                            direction=gv%direction)
435     id\_zi = diag\_axis\_init(\textcolor{stringliteral}{'zi'}, zinter, trim(gv%zAxisUnits), \textcolor{stringliteral}{'z'}, &
436                            \textcolor{stringliteral}{'Interface '}//trim(gv%zAxisLongName),   &
437                            direction=gv%direction)
438   \textcolor{keywordflow}{else}
439     id\_zl = -1 ; id\_zi = -1
440 \textcolor{keywordflow}{  endif}
441   id\_zl\_native = id\_zl ; id\_zi\_native = id\_zi
442   \textcolor{comment}{! Vertical axes for the interfaces and layers}
443   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_zi /), diag\_cs%axesZi, &
444        v\_cell\_method=\textcolor{stringliteral}{'point'}, is\_interface=.true.)
445   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_zl /), diag\_cs%axesZL, &
446        v\_cell\_method=\textcolor{stringliteral}{'mean'}, is\_layer=.true.)
447 
448   \textcolor{comment}{! Axis groupings for the model layers}
449   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yh, id\_zl /), diag\_cs%axesTL, &
450        x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
451        is\_h\_point=.true., is\_layer=.true., xyave\_axes=diag\_cs%axesZL)
452   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yq, id\_zl /), diag\_cs%axesBL, &
453        x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
454        is\_q\_point=.true., is\_layer=.true.)
455   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yh, id\_zl /), diag\_cs%axesCuL, &
456        x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
457        is\_u\_point=.true., is\_layer=.true., xyave\_axes=diag\_cs%axesZL)
458   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yq, id\_zl /), diag\_cs%axesCvL, &
459        x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
460        is\_v\_point=.true., is\_layer=.true., xyave\_axes=diag\_cs%axesZL)
461 
462   \textcolor{comment}{! Axis groupings for the model interfaces}
463   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yh, id\_zi /), diag\_cs%axesTi, &
464        x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
465        is\_h\_point=.true., is\_interface=.true., xyave\_axes=diag\_cs%axesZi)
466   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yq, id\_zi /), diag\_cs%axesBi, &
467        x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
468        is\_q\_point=.true., is\_interface=.true.)
469   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yh, id\_zi /), diag\_cs%axesCui, &
470        x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
471        is\_u\_point=.true., is\_interface=.true., xyave\_axes=diag\_cs%axesZi)
472   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yq, id\_zi /), diag\_cs%axesCvi, &
473        x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
474        is\_v\_point=.true., is\_interface=.true., xyave\_axes=diag\_cs%axesZi)
475 
476   \textcolor{comment}{! Axis groupings for 2-D arrays}
477   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yh /), diag\_cs%axesT1, &
478        x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, is\_h\_point=.true.)
479   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yq /), diag\_cs%axesB1, &
480        x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, is\_q\_point=.true.)
481   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yh /), diag\_cs%axesCu1, &
482        x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, is\_u\_point=.true.)
483   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yq /), diag\_cs%axesCv1, &
484        x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, is\_v\_point=.true.)
485 
486   \textcolor{comment}{! Axis group for special null axis from diag manager}
487   \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ null\_axis\_id /), diag\_cs%axesNull)
488 
489 
490   \textcolor{comment}{!Non-native Non-downsampled}
491   \textcolor{keywordflow}{if} (diag\_cs%num\_diag\_coords>0) \textcolor{keywordflow}{then}
492     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesZL(diag\_cs%num\_diag\_coords))
493     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesTL(diag\_cs%num\_diag\_coords))
494     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesBL(diag\_cs%num\_diag\_coords))
495     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesCuL(diag\_cs%num\_diag\_coords))
496     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesCvL(diag\_cs%num\_diag\_coords))
497     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesZi(diag\_cs%num\_diag\_coords))
498     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesTi(diag\_cs%num\_diag\_coords))
499     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesBi(diag\_cs%num\_diag\_coords))
500     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesCui(diag\_cs%num\_diag\_coords))
501     \textcolor{keyword}{allocate}(diag\_cs%remap\_axesCvi(diag\_cs%num\_diag\_coords))
502 \textcolor{keywordflow}{  endif}
503 
504   \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
505     \textcolor{comment}{! For each possible diagnostic coordinate}
506     \textcolor{keyword}{call }diag\_remap\_configure\_axes(diag\_cs%diag\_remap\_cs(i), gv, us, param\_file)
507 
508     \textcolor{comment}{! Allocate these arrays since the size of the diagnostic array is now known}
509     \textcolor{keyword}{allocate}(diag\_cs%diag\_remap\_cs(i)%h(g%isd:g%ied,g%jsd:g%jed, diag\_cs%diag\_remap\_cs(i)%nz))
510     \textcolor{keyword}{allocate}(diag\_cs%diag\_remap\_cs(i)%h\_extensive(g%isd:g%ied,g%jsd:g%jed, diag\_cs%diag\_remap\_cs(i)%nz))
511 
512     \textcolor{comment}{! This vertical coordinate has been configured so can be used.}
513     \textcolor{keywordflow}{if} (diag\_remap\_axes\_configured(diag\_cs%diag\_remap\_cs(i))) \textcolor{keywordflow}{then}
514 
515       \textcolor{comment}{! This fetches the 1D-axis id for layers and interfaces and overwrite}
516       \textcolor{comment}{! id\_zl and id\_zi from above. It also returns the number of layers.}
517       \textcolor{keyword}{call }diag\_remap\_get\_axes\_info(diag\_cs%diag\_remap\_cs(i), nz, id\_zl, id\_zi)
518 
519       \textcolor{comment}{! Axes for z layers}
520       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_zl /), diag\_cs%remap\_axesZL(i), &
521            nz=nz, vertical\_coordinate\_number=i, &
522            v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
523            is\_h\_point=.true., is\_layer=.true., is\_native=.false., needs\_remapping=.true.)
524       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yh, id\_zl /), diag\_cs%remap\_axesTL(i), &
525            nz=nz, vertical\_coordinate\_number=i, &
526            x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
527            is\_h\_point=.true., is\_layer=.true., is\_native=.false., needs\_remapping=.true., &
528            xyave\_axes=diag\_cs%remap\_axesZL(i))
529 
530        \textcolor{comment}{!! \(\backslash\)note Remapping for B points is not yet implemented so needs\_remapping is not}
531        \textcolor{comment}{!! provided for remap\_axesBL}
532       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yq, id\_zl /), diag\_cs%remap\_axesBL(i), &
533            nz=nz, vertical\_coordinate\_number=i, &
534            x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
535            is\_q\_point=.true., is\_layer=.true., is\_native=.false.)
536 
537       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yh, id\_zl /), diag\_cs%remap\_axesCuL(i), &
538            nz=nz, vertical\_coordinate\_number=i, &
539            x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
540            is\_u\_point=.true., is\_layer=.true., is\_native=.false., needs\_remapping=.true., &
541            xyave\_axes=diag\_cs%remap\_axesZL(i))
542 
543       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yq, id\_zl /), diag\_cs%remap\_axesCvL(i), &
544            nz=nz, vertical\_coordinate\_number=i, &
545            x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
546            is\_v\_point=.true., is\_layer=.true., is\_native=.false., needs\_remapping=.true., &
547            xyave\_axes=diag\_cs%remap\_axesZL(i))
548 
549       \textcolor{comment}{! Axes for z interfaces}
550       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_zi /), diag\_cs%remap\_axesZi(i), &
551            nz=nz, vertical\_coordinate\_number=i, &
552            v\_cell\_method=\textcolor{stringliteral}{'point'}, &
553            is\_h\_point=.true., is\_interface=.true., is\_native=.false., needs\_interpolating=.true.)
554       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yh, id\_zi /), diag\_cs%remap\_axesTi(i), &
555            nz=nz, vertical\_coordinate\_number=i, &
556            x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
557            is\_h\_point=.true., is\_interface=.true., is\_native=.false., needs\_interpolating=.true., &
558            xyave\_axes=diag\_cs%remap\_axesZi(i))
559 
560       \textcolor{comment}{!! \(\backslash\)note Remapping for B points is not yet implemented so needs\_remapping is not provided for
       remap\_axesBi}
561       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yq, id\_zi /), diag\_cs%remap\_axesBi(i), &
562            nz=nz, vertical\_coordinate\_number=i, &
563            x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
564            is\_q\_point=.true., is\_interface=.true., is\_native=.false.)
565 
566       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xq, id\_yh, id\_zi /), diag\_cs%remap\_axesCui(i), &
567            nz=nz, vertical\_coordinate\_number=i, &
568            x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
569            is\_u\_point=.true., is\_interface=.true., is\_native=.false., &
570            needs\_interpolating=.true., xyave\_axes=diag\_cs%remap\_axesZi(i))
571 
572       \textcolor{keyword}{call }define\_axes\_group(diag\_cs, (/ id\_xh, id\_yq, id\_zi /), diag\_cs%remap\_axesCvi(i), &
573            nz=nz, vertical\_coordinate\_number=i, &
574            x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
575            is\_v\_point=.true., is\_interface=.true., is\_native=.false., &
576            needs\_interpolating=.true., xyave\_axes=diag\_cs%remap\_axesZi(i))
577 \textcolor{keywordflow}{    endif}
578 \textcolor{keywordflow}{  enddo}
579 
580   \textcolor{keywordflow}{if} (diag\_cs%grid\_space\_axes) \textcolor{keywordflow}{then}
581      \textcolor{keyword}{deallocate}(iaxb,iax,jaxb,jax)
582 \textcolor{keywordflow}{  endif}
583   \textcolor{comment}{!Define the downsampled axes}
584   \textcolor{keyword}{call }set\_axes\_info\_dsamp(g, gv, param\_file, diag\_cs, id\_zl\_native, id\_zi\_native)
585 
586   \textcolor{keyword}{call }diag\_grid\_storage\_init(diag\_cs%diag\_grid\_temp, g, diag\_cs)
587 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a1abcee77dbc8e8a48f4b48144fc0923c}\label{namespacemom__diag__mediator_a1abcee77dbc8e8a48f4b48144fc0923c}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!set\+\_\+axes\+\_\+info\+\_\+dsamp@{set\+\_\+axes\+\_\+info\+\_\+dsamp}}
\index{set\+\_\+axes\+\_\+info\+\_\+dsamp@{set\+\_\+axes\+\_\+info\+\_\+dsamp}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{set\+\_\+axes\+\_\+info\+\_\+dsamp()}{set\_axes\_info\_dsamp()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::set\+\_\+axes\+\_\+info\+\_\+dsamp (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs,  }\item[{integer, intent(in)}]{id\+\_\+zl\+\_\+native,  }\item[{integer, intent(in)}]{id\+\_\+zi\+\_\+native }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\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 param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Diagnostics control structure\\
\hline
\mbox{\tt in}  & {\em id\+\_\+zl\+\_\+native} & ID of native layers\\
\hline
\mbox{\tt in}  & {\em id\+\_\+zi\+\_\+native} & ID of native interfaces \\
\hline
\end{DoxyParams}


Definition at line 591 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
591   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< Ocean grid structure}
592   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{ !< ocean vertical grid structure}
593   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file structure}
594   \textcolor{keywordtype}{type}(diag\_ctrl),       \textcolor{keywordtype}{intent(inout)} :: diag\_cs\textcolor{comment}{ !< Diagnostics control structure}
595   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: id\_zl\_native\textcolor{comment}{ !< ID of native layers}
596   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: id\_zi\_native\textcolor{comment}{ !< ID of native interfaces}
597 
598   \textcolor{comment}{! Local variables}
599   \textcolor{keywordtype}{integer} :: id\_xq, id\_yq, id\_zl, id\_zi, id\_xh, id\_yh
600   \textcolor{keywordtype}{integer} :: i, j, k, nz, dl
601   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{pointer} :: gridLonT\_dsamp =>null()
602   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{pointer} :: gridLatT\_dsamp =>null()
603   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{pointer} :: gridLonB\_dsamp =>null()
604   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{pointer} :: gridLatB\_dsamp =>null()
605 
606   id\_zl = id\_zl\_native ; id\_zi = id\_zi\_native
607   \textcolor{comment}{!Axes group for native downsampled diagnostics}
608   \textcolor{keywordflow}{do} dl=2,max\_dsamp\_lev
609      \textcolor{keywordflow}{if}(dl .ne. 2) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"set\_axes\_info\_dsamp: Downsample level other than 2 is not
       supported yet!"})
610      \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
611         \textcolor{keyword}{allocate}(gridlonb\_dsamp(diag\_cs%dsamp(dl)%isgB:diag\_cs%dsamp(dl)%iegB))
612         \textcolor{keyword}{allocate}(gridlatb\_dsamp(diag\_cs%dsamp(dl)%jsgB:diag\_cs%dsamp(dl)%jegB))
613         \textcolor{keywordflow}{do} i=diag\_cs%dsamp(dl)%isgB,diag\_cs%dsamp(dl)%iegB;  gridlonb\_dsamp(i) = g%gridLonB(g%isgB+dl*i);\textcolor{keywordflow}{
       enddo}
614         \textcolor{keywordflow}{do} j=diag\_cs%dsamp(dl)%jsgB,diag\_cs%dsamp(dl)%jegB;  gridlatb\_dsamp(j) = g%gridLatB(g%jsgB+dl*j);\textcolor{keywordflow}{
       enddo}
615         id\_xq = diag\_axis\_init(\textcolor{stringliteral}{'xq'}, gridlonb\_dsamp, g%x\_axis\_units, \textcolor{stringliteral}{'x'}, &
616                   \textcolor{stringliteral}{'q point nominal longitude'}, domain2=g%Domain%mpp\_domain\_d2)
617         id\_yq = diag\_axis\_init(\textcolor{stringliteral}{'yq'}, gridlatb\_dsamp, g%y\_axis\_units, \textcolor{stringliteral}{'y'}, &
618                   \textcolor{stringliteral}{'q point nominal latitude'}, domain2=g%Domain%mpp\_domain\_d2)
619         \textcolor{keyword}{deallocate}(gridlonb\_dsamp,gridlatb\_dsamp)
620      \textcolor{keywordflow}{else}
621         \textcolor{keyword}{allocate}(gridlonb\_dsamp(diag\_cs%dsamp(dl)%isg:diag\_cs%dsamp(dl)%ieg))
622         \textcolor{keyword}{allocate}(gridlatb\_dsamp(diag\_cs%dsamp(dl)%jsg:diag\_cs%dsamp(dl)%jeg))
623         \textcolor{keywordflow}{do} i=diag\_cs%dsamp(dl)%isg,diag\_cs%dsamp(dl)%ieg;  gridlonb\_dsamp(i) = g%gridLonB(g%isg+dl*i-2);\textcolor{keywordflow}{
       enddo}
624         \textcolor{keywordflow}{do} j=diag\_cs%dsamp(dl)%jsg,diag\_cs%dsamp(dl)%jeg;  gridlatb\_dsamp(j) = g%gridLatB(g%jsg+dl*j-2);\textcolor{keywordflow}{
       enddo}
625         id\_xq = diag\_axis\_init(\textcolor{stringliteral}{'xq'}, gridlonb\_dsamp, g%x\_axis\_units, \textcolor{stringliteral}{'x'}, &
626                   \textcolor{stringliteral}{'q point nominal longitude'}, domain2=g%Domain%mpp\_domain\_d2)
627         id\_yq = diag\_axis\_init(\textcolor{stringliteral}{'yq'}, gridlatb\_dsamp, g%y\_axis\_units, \textcolor{stringliteral}{'y'}, &
628                   \textcolor{stringliteral}{'q point nominal latitude'}, domain2=g%Domain%mpp\_domain\_d2)
629         \textcolor{keyword}{deallocate}(gridlonb\_dsamp,gridlatb\_dsamp)
630 \textcolor{keywordflow}{     endif}
631 
632      \textcolor{keyword}{allocate}(gridlont\_dsamp(diag\_cs%dsamp(dl)%isg:diag\_cs%dsamp(dl)%ieg))
633      \textcolor{keyword}{allocate}(gridlatt\_dsamp(diag\_cs%dsamp(dl)%jsg:diag\_cs%dsamp(dl)%jeg))
634      \textcolor{keywordflow}{do} i=diag\_cs%dsamp(dl)%isg,diag\_cs%dsamp(dl)%ieg;  gridlont\_dsamp(i) = g%gridLonT(g%isg+dl*i-2);\textcolor{keywordflow}{ enddo}
635      \textcolor{keywordflow}{do} j=diag\_cs%dsamp(dl)%jsg,diag\_cs%dsamp(dl)%jeg;  gridlatt\_dsamp(j) = g%gridLatT(g%jsg+dl*j-2);\textcolor{keywordflow}{ enddo}
636      id\_xh = diag\_axis\_init(\textcolor{stringliteral}{'xh'}, gridlont\_dsamp, g%x\_axis\_units, \textcolor{stringliteral}{'x'}, &
637           \textcolor{stringliteral}{'h point nominal longitude'}, domain2=g%Domain%mpp\_domain\_d2)
638      id\_yh = diag\_axis\_init(\textcolor{stringliteral}{'yh'}, gridlatt\_dsamp, g%y\_axis\_units, \textcolor{stringliteral}{'y'}, &
639           \textcolor{stringliteral}{'h point nominal latitude'}, domain2=g%Domain%mpp\_domain\_d2)
640 
641      \textcolor{keyword}{deallocate}(gridlont\_dsamp,gridlatt\_dsamp)
642 
643      \textcolor{comment}{! Axis groupings for the model layers}
644      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yh, id\_zl /), diag\_cs%dsamp(dl)%axesTL, dl, &
645           x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
646           is\_h\_point=.true., is\_layer=.true., xyave\_axes=diag\_cs%axesZL)
647      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yq, id\_zl /), diag\_cs%dsamp(dl)%axesBL, dl, &
648           x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
649           is\_q\_point=.true., is\_layer=.true.)
650      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yh, id\_zl /), diag\_cs%dsamp(dl)%axesCuL, dl, &
651           x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
652           is\_u\_point=.true., is\_layer=.true., xyave\_axes=diag\_cs%axesZL)
653      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yq, id\_zl /), diag\_cs%dsamp(dl)%axesCvL, dl, &
654           x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
655           is\_v\_point=.true., is\_layer=.true., xyave\_axes=diag\_cs%axesZL)
656 
657      \textcolor{comment}{! Axis groupings for the model interfaces}
658      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yh, id\_zi /), diag\_cs%dsamp(dl)%axesTi, dl, &
659           x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
660           is\_h\_point=.true., is\_interface=.true., xyave\_axes=diag\_cs%axesZi)
661      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yq, id\_zi /), diag\_cs%dsamp(dl)%axesBi, dl, &
662           x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
663           is\_q\_point=.true., is\_interface=.true.)
664      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yh, id\_zi /), diag\_cs%dsamp(dl)%axesCui, dl, &
665           x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
666           is\_u\_point=.true., is\_interface=.true., xyave\_axes=diag\_cs%axesZi)
667      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yq, id\_zi /), diag\_cs%dsamp(dl)%axesCvi, dl, &
668           x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
669           is\_v\_point=.true., is\_interface=.true., xyave\_axes=diag\_cs%axesZi)
670 
671      \textcolor{comment}{! Axis groupings for 2-D arrays}
672      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yh /), diag\_cs%dsamp(dl)%axesT1, dl, &
673           x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, is\_h\_point=.true.)
674      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yq /), diag\_cs%dsamp(dl)%axesB1, dl, &
675           x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, is\_q\_point=.true.)
676      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yh /), diag\_cs%dsamp(dl)%axesCu1, dl, &
677           x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, is\_u\_point=.true.)
678      \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yq /), diag\_cs%dsamp(dl)%axesCv1, dl, &
679           x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, is\_v\_point=.true.)
680 
681      \textcolor{comment}{!Non-native axes}
682      \textcolor{keywordflow}{if} (diag\_cs%num\_diag\_coords>0) \textcolor{keywordflow}{then}
683         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesTL(diag\_cs%num\_diag\_coords))
684         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesBL(diag\_cs%num\_diag\_coords))
685         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesCuL(diag\_cs%num\_diag\_coords))
686         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesCvL(diag\_cs%num\_diag\_coords))
687         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesTi(diag\_cs%num\_diag\_coords))
688         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesBi(diag\_cs%num\_diag\_coords))
689         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesCui(diag\_cs%num\_diag\_coords))
690         \textcolor{keyword}{allocate}(diag\_cs%dsamp(dl)%remap\_axesCvi(diag\_cs%num\_diag\_coords))
691 \textcolor{keywordflow}{     endif}
692 
693      \textcolor{keywordflow}{do} i=1, diag\_cs%num\_diag\_coords
694         \textcolor{comment}{! For each possible diagnostic coordinate}
695         \textcolor{comment}{!call diag\_remap\_configure\_axes(diag\_cs%diag\_remap\_cs(i), GV, param\_file)}
696 
697         \textcolor{comment}{! This vertical coordinate has been configured so can be used.}
698         \textcolor{keywordflow}{if} (diag\_remap\_axes\_configured(diag\_cs%diag\_remap\_cs(i))) \textcolor{keywordflow}{then}
699 
700            \textcolor{comment}{! This fetches the 1D-axis id for layers and interfaces and overwrite}
701            \textcolor{comment}{! id\_zl and id\_zi from above. It also returns the number of layers.}
702            \textcolor{keyword}{call }diag\_remap\_get\_axes\_info(diag\_cs%diag\_remap\_cs(i), nz, id\_zl, id\_zi)
703 
704            \textcolor{comment}{! Axes for z layers}
705            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yh, id\_zl /), diag\_cs%dsamp(dl)%remap\_axesTL(
      i), dl, &
706                 nz=nz, vertical\_coordinate\_number=i, &
707                 x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
708                 is\_h\_point=.true., is\_layer=.true., is\_native=.false., needs\_remapping=.true., &
709                 xyave\_axes=diag\_cs%remap\_axesZL(i))
710 
711            \textcolor{comment}{!! \(\backslash\)note Remapping for B points is not yet implemented so needs\_remapping is not}
712            \textcolor{comment}{!! provided for remap\_axesBL}
713            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yq, id\_zl /), diag\_cs%dsamp(dl)%remap\_axesBL(
      i), dl, &
714                 nz=nz, vertical\_coordinate\_number=i, &
715                 x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
716                 is\_q\_point=.true., is\_layer=.true., is\_native=.false.)
717 
718            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yh, id\_zl /), diag\_cs%dsamp(dl)%remap\_axesCuL
      (i), dl, &
719                 nz=nz, vertical\_coordinate\_number=i, &
720                 x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
721                 is\_u\_point=.true., is\_layer=.true., is\_native=.false., needs\_remapping=.true., &
722                 xyave\_axes=diag\_cs%remap\_axesZL(i))
723 
724            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yq, id\_zl /), diag\_cs%dsamp(dl)%remap\_axesCvL
      (i), dl, &
725                 nz=nz, vertical\_coordinate\_number=i, &
726                 x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'mean'}, &
727                 is\_v\_point=.true., is\_layer=.true., is\_native=.false., needs\_remapping=.true., &
728                 xyave\_axes=diag\_cs%remap\_axesZL(i))
729 
730            \textcolor{comment}{! Axes for z interfaces}
731            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yh, id\_zi /), diag\_cs%dsamp(dl)%remap\_axesTi(
      i), dl, &
732                 nz=nz, vertical\_coordinate\_number=i, &
733                 x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
734                 is\_h\_point=.true., is\_interface=.true., is\_native=.false., needs\_interpolating=.true., &
735                 xyave\_axes=diag\_cs%remap\_axesZi(i))
736 
737            \textcolor{comment}{!! \(\backslash\)note Remapping for B points is not yet implemented so needs\_remapping is not provided for
       remap\_axesBi}
738            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yq, id\_zi /), diag\_cs%dsamp(dl)%remap\_axesBi(
      i), dl, &
739                 nz=nz, vertical\_coordinate\_number=i, &
740                 x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
741                 is\_q\_point=.true., is\_interface=.true., is\_native=.false.)
742 
743            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xq, id\_yh, id\_zi /), diag\_cs%dsamp(dl)%remap\_axesCui
      (i), dl, &
744                 nz=nz, vertical\_coordinate\_number=i, &
745                 x\_cell\_method=\textcolor{stringliteral}{'point'}, y\_cell\_method=\textcolor{stringliteral}{'mean'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
746                 is\_u\_point=.true., is\_interface=.true., is\_native=.false., &
747                 needs\_interpolating=.true., xyave\_axes=diag\_cs%remap\_axesZi(i))
748 
749            \textcolor{keyword}{call }define\_axes\_group\_dsamp(diag\_cs, (/ id\_xh, id\_yq, id\_zi /), diag\_cs%dsamp(dl)%remap\_axesCvi
      (i), dl, &
750                 nz=nz, vertical\_coordinate\_number=i, &
751                 x\_cell\_method=\textcolor{stringliteral}{'mean'}, y\_cell\_method=\textcolor{stringliteral}{'point'}, v\_cell\_method=\textcolor{stringliteral}{'point'}, &
752                 is\_v\_point=.true., is\_interface=.true., is\_native=.false., &
753                 needs\_interpolating=.true., xyave\_axes=diag\_cs%remap\_axesZi(i))
754 \textcolor{keywordflow}{        endif}
755 \textcolor{keywordflow}{     enddo}
756 \textcolor{keywordflow}{  enddo}
757 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a36d062ce991a3bd7250b3224e6508eb5}\label{namespacemom__diag__mediator_a36d062ce991a3bd7250b3224e6508eb5}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!set\+\_\+diag\+\_\+mediator\+\_\+grid@{set\+\_\+diag\+\_\+mediator\+\_\+grid}}
\index{set\+\_\+diag\+\_\+mediator\+\_\+grid@{set\+\_\+diag\+\_\+mediator\+\_\+grid}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{set\+\_\+diag\+\_\+mediator\+\_\+grid()}{set\_diag\_mediator\_grid()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::set\+\_\+diag\+\_\+mediator\+\_\+grid (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), intent(inout)}]{diag\+\_\+cs }\end{DoxyParamCaption})}



Set up the array extents for doing diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in,out}  & {\em diag\+\_\+cs} & Structure used to regulate diagnostic output \\
\hline
\end{DoxyParams}


Definition at line 1245 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
1245   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}
1246   \textcolor{keywordtype}{type}(diag\_ctrl),  \textcolor{keywordtype}{intent(inout)} :: diag\_CS\textcolor{comment}{ !< Structure used to regulate diagnostic output}
1247 
1248   diag\_cs%is = g%isc - (g%isd-1) ; diag\_cs%ie = g%iec - (g%isd-1)
1249   diag\_cs%js = g%jsc - (g%jsd-1) ; diag\_cs%je = g%jec - (g%jsd-1)
1250   diag\_cs%isd = g%isd ; diag\_cs%ied = g%ied
1251   diag\_cs%jsd = g%jsd ; diag\_cs%jed = g%jed
1252 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_a19d8a5e2782eb57ab3d7824028fafd56}\label{namespacemom__diag__mediator_a19d8a5e2782eb57ab3d7824028fafd56}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!set\+\_\+masks\+\_\+for\+\_\+axes@{set\+\_\+masks\+\_\+for\+\_\+axes}}
\index{set\+\_\+masks\+\_\+for\+\_\+axes@{set\+\_\+masks\+\_\+for\+\_\+axes}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{set\+\_\+masks\+\_\+for\+\_\+axes()}{set\_masks\_for\_axes()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+mediator\+::set\+\_\+masks\+\_\+for\+\_\+axes (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in), target}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), pointer}]{diag\+\_\+cs }\end{DoxyParamCaption})}



set\+\_\+masks\+\_\+for\+\_\+axes sets up the 2d and 3d masks for diagnostics using the current grid recorded after calling \mbox{\hyperlink{namespacemom__diag__mediator_aa78e69709084d0097b3e01bbd83d3509}{diag\+\_\+update\+\_\+remap\+\_\+grids()}} 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean grid type.\\
\hline
 & {\em diag\+\_\+cs} & A pointer to a type with many variables used for diagnostics \\
\hline
\end{DoxyParams}


Definition at line 764 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
764   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The ocean grid type.}
765   \textcolor{keywordtype}{type}(diag\_ctrl),               \textcolor{keywordtype}{pointer}    :: diag\_cs\textcolor{comment}{ !< A pointer to a type with many variables}
766 \textcolor{comment}{                                                       !! used for diagnostics}
767   \textcolor{comment}{! Local variables}
768   \textcolor{keywordtype}{integer} :: c, nk, i, j, k, ii, jj
769   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{pointer} :: axes => null(), h\_axes => null() \textcolor{comment}{! Current axes, for convenience}
770 
771   \textcolor{keywordflow}{do} c=1, diag\_cs%num\_diag\_coords
772     \textcolor{comment}{! This vertical coordinate has been configured so can be used.}
773     \textcolor{keywordflow}{if} (diag\_remap\_axes\_configured(diag\_cs%diag\_remap\_cs(c))) \textcolor{keywordflow}{then}
774 
775       \textcolor{comment}{! Level/layer h-points in diagnostic coordinate}
776       axes => diag\_cs%remap\_axesTL(c)
777       nk = axes%nz
778       \textcolor{keyword}{allocate}( axes%mask3d(g%isd:g%ied,g%jsd:g%jed,nk) ) ; axes%mask3d(:,:,:) = 0.
779       \textcolor{keyword}{call }diag\_remap\_calc\_hmask(diag\_cs%diag\_remap\_cs(c), g, axes%mask3d)
780 
781       h\_axes => diag\_cs%remap\_axesTL(c) \textcolor{comment}{! Use the h-point masks to generate the u-, v- and q- masks}
782 
783       \textcolor{comment}{! Level/layer u-points in diagnostic coordinate}
784       axes => diag\_cs%remap\_axesCuL(c)
785       \textcolor{keyword}{call }assert(axes%nz == nk, \textcolor{stringliteral}{'set\_masks\_for\_axes: vertical size mismatch at u-layers'})
786       \textcolor{keyword}{call }assert(.not. \textcolor{keyword}{associated}(axes%mask3d), \textcolor{stringliteral}{'set\_masks\_for\_axes: already associated'})
787       \textcolor{keyword}{allocate}( axes%mask3d(g%IsdB:g%IedB,g%jsd:g%jed,nk) ) ; axes%mask3d(:,:,:) = 0.
788       \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc-1,g%iec
789         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,k) + h\_axes%mask3d(i+1,j,k) > 0.) axes%mask3d(i,j,k) = 1.
790 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
791 
792       \textcolor{comment}{! Level/layer v-points in diagnostic coordinate}
793       axes => diag\_cs%remap\_axesCvL(c)
794       \textcolor{keyword}{call }assert(axes%nz == nk, \textcolor{stringliteral}{'set\_masks\_for\_axes: vertical size mismatch at v-layers'})
795       \textcolor{keyword}{call }assert(.not. \textcolor{keyword}{associated}(axes%mask3d), \textcolor{stringliteral}{'set\_masks\_for\_axes: already associated'})
796       \textcolor{keyword}{allocate}( axes%mask3d(g%isd:g%ied,g%JsdB:g%JedB,nk) ) ; axes%mask3d(:,:,:) = 0.
797       \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j=g%jsc-1,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
798         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,k) + h\_axes%mask3d(i,j+1,k) > 0.) axes%mask3d(i,j,k) = 1.
799 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
800 
801       \textcolor{comment}{! Level/layer q-points in diagnostic coordinate}
802       axes => diag\_cs%remap\_axesBL(c)
803       \textcolor{keyword}{call }assert(axes%nz == nk, \textcolor{stringliteral}{'set\_masks\_for\_axes: vertical size mismatch at q-layers'})
804       \textcolor{keyword}{call }assert(.not. \textcolor{keyword}{associated}(axes%mask3d), \textcolor{stringliteral}{'set\_masks\_for\_axes: already associated'})
805       \textcolor{keyword}{allocate}( axes%mask3d(g%IsdB:g%IedB,g%JsdB:g%JedB,nk) ) ; axes%mask3d(:,:,:) = 0.
806       \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j=g%jsc-1,g%jec ; \textcolor{keywordflow}{do} i=g%isc-1,g%iec
807         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,k) + h\_axes%mask3d(i+1,j+1,k) + &
808             h\_axes%mask3d(i+1,j,k) + h\_axes%mask3d(i,j+1,k) > 0.) axes%mask3d(i,j,k) = 1.
809 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
810 
811       \textcolor{comment}{! Interface h-points in diagnostic coordinate (w-point)}
812       axes => diag\_cs%remap\_axesTi(c)
813       \textcolor{keyword}{call }assert(axes%nz == nk, \textcolor{stringliteral}{'set\_masks\_for\_axes: vertical size mismatch at h-interfaces'})
814       \textcolor{keyword}{call }assert(.not. \textcolor{keyword}{associated}(axes%mask3d), \textcolor{stringliteral}{'set\_masks\_for\_axes: already associated'})
815       \textcolor{keyword}{allocate}( axes%mask3d(g%isd:g%ied,g%jsd:g%jed,nk+1) ) ; axes%mask3d(:,:,:) = 0.
816       \textcolor{keywordflow}{do} j=g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i=g%isc-1,g%iec+1
817         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,1) > 0.) axes%mask3d(i,j,1) = 1.
818         \textcolor{keywordflow}{do} k = 2, nk
819           \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,k-1) + h\_axes%mask3d(i,j,k) > 0.) axes%mask3d(i,j,k) = 1.
820 \textcolor{keywordflow}{        enddo}
821         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,nk) > 0.) axes%mask3d(i,j,nk+1) = 1.
822 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
823 
824       h\_axes => diag\_cs%remap\_axesTi(c) \textcolor{comment}{! Use the w-point masks to generate the u-, v- and q- masks}
825 
826       \textcolor{comment}{! Interface u-points in diagnostic coordinate}
827       axes => diag\_cs%remap\_axesCui(c)
828       \textcolor{keyword}{call }assert(axes%nz == nk, \textcolor{stringliteral}{'set\_masks\_for\_axes: vertical size mismatch at u-interfaces'})
829       \textcolor{keyword}{call }assert(.not. \textcolor{keyword}{associated}(axes%mask3d), \textcolor{stringliteral}{'set\_masks\_for\_axes: already associated'})
830       \textcolor{keyword}{allocate}( axes%mask3d(g%IsdB:g%IedB,g%jsd:g%jed,nk+1) ) ; axes%mask3d(:,:,:) = 0.
831       \textcolor{keywordflow}{do} k = 1, nk+1 ; \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc-1,g%iec
832         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,k) + h\_axes%mask3d(i+1,j,k) > 0.) axes%mask3d(i,j,k) = 1.
833 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
834 
835       \textcolor{comment}{! Interface v-points in diagnostic coordinate}
836       axes => diag\_cs%remap\_axesCvi(c)
837       \textcolor{keyword}{call }assert(axes%nz == nk, \textcolor{stringliteral}{'set\_masks\_for\_axes: vertical size mismatch at v-interfaces'})
838       \textcolor{keyword}{call }assert(.not. \textcolor{keyword}{associated}(axes%mask3d), \textcolor{stringliteral}{'set\_masks\_for\_axes: already associated'})
839       \textcolor{keyword}{allocate}( axes%mask3d(g%isd:g%ied,g%JsdB:g%JedB,nk+1) ) ; axes%mask3d(:,:,:) = 0.
840       \textcolor{keywordflow}{do} k = 1, nk+1 ; \textcolor{keywordflow}{do} j=g%jsc-1,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
841         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,k) + h\_axes%mask3d(i,j+1,k) > 0.) axes%mask3d(i,j,k) = 1.
842 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
843 
844       \textcolor{comment}{! Interface q-points in diagnostic coordinate}
845       axes => diag\_cs%remap\_axesBi(c)
846       \textcolor{keyword}{call }assert(axes%nz == nk, \textcolor{stringliteral}{'set\_masks\_for\_axes: vertical size mismatch at q-interfaces'})
847       \textcolor{keyword}{call }assert(.not. \textcolor{keyword}{associated}(axes%mask3d), \textcolor{stringliteral}{'set\_masks\_for\_axes: already associated'})
848       \textcolor{keyword}{allocate}( axes%mask3d(g%IsdB:g%IedB,g%JsdB:g%JedB,nk+1) ) ; axes%mask3d(:,:,:) = 0.
849       \textcolor{keywordflow}{do} k = 1, nk ; \textcolor{keywordflow}{do} j=g%jsc-1,g%jec ; \textcolor{keywordflow}{do} i=g%isc-1,g%iec
850         \textcolor{keywordflow}{if} (h\_axes%mask3d(i,j,k) + h\_axes%mask3d(i+1,j+1,k) + &
851             h\_axes%mask3d(i+1,j,k) + h\_axes%mask3d(i,j+1,k) > 0.) axes%mask3d(i,j,k) = 1.
852 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
853 \textcolor{keywordflow}{    endif}
854 \textcolor{keywordflow}{  enddo}
855 
856   \textcolor{comment}{!Allocate and initialize the downsampled masks for the axes}
857   \textcolor{keyword}{call }set\_masks\_for\_axes\_dsamp(g, diag\_cs)
858 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__mediator_ade968ef275fa55cf8a2301debdd7e88a}\label{namespacemom__diag__mediator_ade968ef275fa55cf8a2301debdd7e88a}} 
\index{mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}!set\+\_\+masks\+\_\+for\+\_\+axes\+\_\+dsamp@{set\+\_\+masks\+\_\+for\+\_\+axes\+\_\+dsamp}}
\index{set\+\_\+masks\+\_\+for\+\_\+axes\+\_\+dsamp@{set\+\_\+masks\+\_\+for\+\_\+axes\+\_\+dsamp}!mom\+\_\+diag\+\_\+mediator@{mom\+\_\+diag\+\_\+mediator}}
\subsubsection{\texorpdfstring{set\+\_\+masks\+\_\+for\+\_\+axes\+\_\+dsamp()}{set\_masks\_for\_axes\_dsamp()}}
{\footnotesize\ttfamily subroutine mom\+\_\+diag\+\_\+mediator\+::set\+\_\+masks\+\_\+for\+\_\+axes\+\_\+dsamp (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in), target}]{G,  }\item[{type(\mbox{\hyperlink{structmom__diag__mediator_1_1diag__ctrl}{diag\+\_\+ctrl}}), pointer}]{diag\+\_\+cs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean grid type.\\
\hline
 & {\em diag\+\_\+cs} & A pointer to a type with many variables used for diagnostics \\
\hline
\end{DoxyParams}


Definition at line 862 of file M\+O\+M\+\_\+diag\+\_\+mediator.\+F90.


\begin{DoxyCode}
862   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The ocean grid type.}
863   \textcolor{keywordtype}{type}(diag\_ctrl),               \textcolor{keywordtype}{pointer}    :: diag\_cs\textcolor{comment}{ !< A pointer to a type with many variables}
864 \textcolor{comment}{                                                       !! used for diagnostics}
865   \textcolor{comment}{! Local variables}
866   \textcolor{keywordtype}{integer} :: c, nk, i, j, k, ii, jj
867   \textcolor{keywordtype}{integer} :: dl
868   \textcolor{keywordtype}{type}(axes\_grp), \textcolor{keywordtype}{pointer} :: axes => null(), h\_axes => null() \textcolor{comment}{! Current axes, for convenience}
869 
870   \textcolor{comment}{!Each downsampled axis needs both downsampled and non-downsampled mask}
871   \textcolor{comment}{!The downsampled mask is needed for sending out the diagnostics output via diag\_manager}
872   \textcolor{comment}{!The non-downsampled mask is needed for downsampling the diagnostics field}
873   \textcolor{keywordflow}{do} dl=2,max\_dsamp\_lev
874      \textcolor{keywordflow}{if}(dl .ne. 2) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"set\_masks\_for\_axes\_dsamp: Downsample level other than 2 is not
       supported!"})
875      \textcolor{keywordflow}{do} c=1, diag\_cs%num\_diag\_coords
876         \textcolor{comment}{! Level/layer h-points in diagnostic coordinate}
877         axes => diag\_cs%remap\_axesTL(c)
878         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesTL(c)%dsamp(dl)%mask3d, dl,g%isc, g
      %jsc,  &
879           g%HId2%isc, g%HId2%iec, g%HId2%jsc, g%HId2%jec, g%HId2%isd, g%HId2%ied, g%HId2%jsd, g%HId2%jed)
880         diag\_cs%dsamp(dl)%remap\_axesTL(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
881         \textcolor{comment}{! Level/layer u-points in diagnostic coordinate}
882         axes => diag\_cs%remap\_axesCuL(c)
883         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesCuL(c)%dsamp(dl)%mask3d, dl,g%IscB,g
      %JscB, &
884           g%HId2%IscB,g%HId2%IecB,g%HId2%jsc, g%HId2%jec,g%HId2%IsdB,g%HId2%IedB,g%HId2%jsd, g%HId2%jed)
885         diag\_cs%dsamp(dl)%remap\_axesCul(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
886         \textcolor{comment}{! Level/layer v-points in diagnostic coordinate}
887         axes => diag\_cs%remap\_axesCvL(c)
888         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesCvL(c)%dsamp(dl)%mask3d, dl,g%isc ,g
      %JscB, &
889           g%HId2%isc ,g%HId2%iec, g%HId2%JscB,g%HId2%JecB,g%HId2%isd ,g%HId2%ied, g%HId2%JsdB,g%HId2%JedB)
890         diag\_cs%dsamp(dl)%remap\_axesCvL(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
891         \textcolor{comment}{! Level/layer q-points in diagnostic coordinate}
892         axes => diag\_cs%remap\_axesBL(c)
893         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesBL(c)%dsamp(dl)%mask3d, dl,g%IscB,g
      %JscB, &
894           g%HId2%IscB,g%HId2%IecB,g%HId2%JscB,g%HId2%JecB,g%HId2%IsdB,g%HId2%IedB,g%HId2%JsdB,g%HId2%JedB)
895         diag\_cs%dsamp(dl)%remap\_axesBL(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
896         \textcolor{comment}{! Interface h-points in diagnostic coordinate (w-point)}
897         axes => diag\_cs%remap\_axesTi(c)
898         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesTi(c)%dsamp(dl)%mask3d, dl,g%isc, g
      %jsc,  &
899           g%HId2%isc, g%HId2%iec, g%HId2%jsc, g%HId2%jec, g%HId2%isd, g%HId2%ied, g%HId2%jsd, g%HId2%jed)
900         diag\_cs%dsamp(dl)%remap\_axesTi(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
901         \textcolor{comment}{! Interface u-points in diagnostic coordinate}
902         axes => diag\_cs%remap\_axesCui(c)
903         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesCui(c)%dsamp(dl)%mask3d, dl,g%IscB,g
      %JscB, &
904           g%HId2%IscB,g%HId2%IecB,g%HId2%jsc, g%HId2%jec,g%HId2%IsdB,g%HId2%IedB,g%HId2%jsd, g%HId2%jed)
905         diag\_cs%dsamp(dl)%remap\_axesCui(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
906         \textcolor{comment}{! Interface v-points in diagnostic coordinate}
907         axes => diag\_cs%remap\_axesCvi(c)
908         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesCvi(c)%dsamp(dl)%mask3d, dl,g%isc ,g
      %JscB, &
909           g%HId2%isc ,g%HId2%iec, g%HId2%JscB,g%HId2%JecB,g%HId2%isd ,g%HId2%ied, g%HId2%JsdB,g%HId2%JedB)
910         diag\_cs%dsamp(dl)%remap\_axesCvi(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
911         \textcolor{comment}{! Interface q-points in diagnostic coordinate}
912         axes => diag\_cs%remap\_axesBi(c)
913         \textcolor{keyword}{call }downsample\_mask(axes%mask3d, diag\_cs%dsamp(dl)%remap\_axesBi(c)%dsamp(dl)%mask3d, dl,g%IscB,g
      %JscB, &
914           g%HId2%IscB,g%HId2%IecB,g%HId2%JscB,g%HId2%JecB,g%HId2%IsdB,g%HId2%IedB,g%HId2%JsdB,g%HId2%JedB)
915         diag\_cs%dsamp(dl)%remap\_axesBi(c)%mask3d => axes%mask3d \textcolor{comment}{!set non-downsampled mask}
916 \textcolor{keywordflow}{     enddo}
917 \textcolor{keywordflow}{  enddo}
\end{DoxyCode}
