\hypertarget{namespacemom__checksums}{}\section{mom\+\_\+checksums Module Reference}
\label{namespacemom__checksums}\index{mom\+\_\+checksums@{mom\+\_\+checksums}}


\subsection{Detailed Description}
Routines to calculate checksums of various array and vector types. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \hyperlink{interfacemom__checksums_1_1bchksum}{bchksum}
\begin{DoxyCompactList}\small\item\em Checksums an array (2d or 3d) staggered at corner points. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1bchksum__pair}{bchksum\+\_\+pair}
\begin{DoxyCompactList}\small\item\em Checksums a pair of arrays (2d or 3d) staggered at corner points. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1chk__sum__msg}{chk\+\_\+sum\+\_\+msg}
\begin{DoxyCompactList}\small\item\em Write a message with either checksums or numerical statistics of arrays. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1chksum}{chksum}
\begin{DoxyCompactList}\small\item\em This is an older interface for 1-\/, 2-\/, or 3-\/D checksums. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1hchksum}{hchksum}
\begin{DoxyCompactList}\small\item\em Checksums an array (2d or 3d) staggered at tracer points. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1hchksum__pair}{hchksum\+\_\+pair}
\begin{DoxyCompactList}\small\item\em Checksums a pair of arrays (2d or 3d) staggered at tracer points. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1is__nan}{is\+\_\+nan}
\begin{DoxyCompactList}\small\item\em Returns .true. if any element of x is a NaN, and .false. otherwise. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1qchksum}{qchksum}
\begin{DoxyCompactList}\small\item\em This is an older interface that has been renamed Bchksum. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1uchksum}{uchksum}
\begin{DoxyCompactList}\small\item\em Checksums an array (2d or 3d) staggered at C-\/grid u points. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1uvchksum}{uvchksum}
\begin{DoxyCompactList}\small\item\em Checksums a pair velocity arrays (2d or 3d) staggered at C-\/grid locations. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__checksums_1_1vchksum}{vchksum}
\begin{DoxyCompactList}\small\item\em Checksums an array (2d or 3d) staggered at C-\/grid v points. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \hyperlink{namespacemom__checksums_a94aae972d8c543ede8792d20b9af94e2}{chksum0} (scalar, mesg, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksum a scalar field (consistent with array checksums) \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__checksums_a4407f1e35457aa61e99ed08ae13b9eeb}{zchksum} (array, mesg, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksum a 1d array (typically a column). \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_adf321aa5891602668005529a30f28225}{chksum\+\_\+pair\+\_\+h\+\_\+2d} (mesg, arrayA, arrayB, HI, haloshift, omit\+\_\+corners, scale, logunit, scalar\+\_\+pair)
\begin{DoxyCompactList}\small\item\em Checksums on a pair of 2d arrays staggered at tracer points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a5a74e7e80a1bb2b733459c5d7a5e3ea8}{chksum\+\_\+pair\+\_\+h\+\_\+3d} (mesg, arrayA, arrayB, HI, haloshift, omit\+\_\+corners, scale, logunit, scalar\+\_\+pair)
\begin{DoxyCompactList}\small\item\em Checksums on a pair of 3d arrays staggered at tracer points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a49992903b4b92e03a5933426154c4641}{chksum\+\_\+h\+\_\+2d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 2d array staggered at tracer points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_ac9d0ad082dc1fcf821f830f3274ea78b}{chksum\+\_\+pair\+\_\+b\+\_\+2d} (mesg, arrayA, arrayB, HI, haloshift, symmetric, omit\+\_\+corners, scale, logunit, scalar\+\_\+pair)
\begin{DoxyCompactList}\small\item\em Checksums on a pair of 2d arrays staggered at q-\/points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_af9f0a6d824a0203c4ce861086cfc6435}{chksum\+\_\+pair\+\_\+b\+\_\+3d} (mesg, arrayA, arrayB, HI, haloshift, symmetric, omit\+\_\+corners, scale, logunit, scalar\+\_\+pair)
\begin{DoxyCompactList}\small\item\em Checksums on a pair of 3d arrays staggered at q-\/points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_af3ee2725096bea4d0e532b02bd7a5983}{chksum\+\_\+b\+\_\+2d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 2d array staggered at corner points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a44f58e610aea8ed395c0fed97f020503}{chksum\+\_\+uv\+\_\+2d} (mesg, arrayU, arrayV, HI, haloshift, symmetric, omit\+\_\+corners, scale, logunit, scalar\+\_\+pair)
\begin{DoxyCompactList}\small\item\em Checksums a pair of 2d velocity arrays staggered at C-\/grid locations. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a316b025360732d72fc38a021b4fe0f7d}{chksum\+\_\+uv\+\_\+3d} (mesg, arrayU, arrayV, HI, haloshift, symmetric, omit\+\_\+corners, scale, logunit, scalar\+\_\+pair)
\begin{DoxyCompactList}\small\item\em Checksums a pair of 3d velocity arrays staggered at C-\/grid locations. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a490f31f536667d60912db5e96218563c}{chksum\+\_\+u\+\_\+2d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 2d array staggered at C-\/grid u points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_acc62cfde3303da03f62e86d98c124fc9}{chksum\+\_\+v\+\_\+2d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 2d array staggered at C-\/grid v points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a20f9718e4e53fb5584f8b1dc51dacf20}{chksum\+\_\+h\+\_\+3d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 3d array staggered at tracer points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a7eda888fdc2e22a7367662d76cbc193d}{chksum\+\_\+b\+\_\+3d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 3d array staggered at corner points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a5127df73a7ac181d76b8c9fc6eb55c55}{chksum\+\_\+u\+\_\+3d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 3d array staggered at C-\/grid u points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_add98802882151a1a03a70e6b6b7ae456}{chksum\+\_\+v\+\_\+3d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 3d array staggered at C-\/grid v points. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_aa064e020b99a0efca89590774af3454d}{chksum1d} (array, mesg, start\+\_\+i, end\+\_\+i, compare\+\_\+\+P\+Es)
\begin{DoxyCompactList}\small\item\em chksum1d does a checksum of a 1-\/dimensional array. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a06dcbee42e0aa2afca2803757905effd}{chksum2d} (array, mesg)
\begin{DoxyCompactList}\small\item\em chksum2d does a checksum of all data in a 2-\/d array. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a4538309762110054a606a863a2efcd40}{chksum3d} (array, mesg)
\begin{DoxyCompactList}\small\item\em chksum3d does a checksum of all data in a 2-\/d array. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__checksums_aa60d4336935b61bdb90e5f182d9a21ad}{is\+\_\+nan\+\_\+0d} (x)
\begin{DoxyCompactList}\small\item\em This function returns .true. if x is a NaN, and .false. otherwise. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__checksums_a2ae26d49eb294b8b0e6872cc1642eb4b}{is\+\_\+nan\+\_\+1d} (x, skip\+\_\+mpp)
\begin{DoxyCompactList}\small\item\em Returns .true. if any element of x is a NaN, and .false. otherwise. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__checksums_ae5399b160c30b9e0d9a806af7e322f8e}{is\+\_\+nan\+\_\+2d} (x)
\begin{DoxyCompactList}\small\item\em Returns .true. if any element of x is a NaN, and .false. otherwise. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__checksums_a1cfab80ba102a9eb5b77d6c5db2a298a}{is\+\_\+nan\+\_\+3d} (x)
\begin{DoxyCompactList}\small\item\em Returns .true. if any element of x is a NaN, and .false. otherwise. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a77a351d5fb63b21521d26bebb90bcfab}{chk\+\_\+sum\+\_\+msg1} (fmsg, bc0, mesg, iounit)
\begin{DoxyCompactList}\small\item\em Write a message including the checksum of the non-\/shifted array. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_afd3901de6e3cac8dd66aa0ea36011e4c}{chk\+\_\+sum\+\_\+msg5} (fmsg, bc0, bc\+SW, bc\+SE, bc\+NW, bc\+NE, mesg, iounit)
\begin{DoxyCompactList}\small\item\em Write a message including checksums of non-\/shifted and diagonally shifted arrays. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a2bbf928379ba9abdc67a2f6f93ea8c34}{chk\+\_\+sum\+\_\+msg\+\_\+nsew} (fmsg, bc0, bcN, bcS, bcE, bcW, mesg, iounit)
\begin{DoxyCompactList}\small\item\em Write a message including checksums of non-\/shifted and laterally shifted arrays. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a980dd3235b339afa9decbe8474a0bc58}{chk\+\_\+sum\+\_\+msg\+\_\+s} (fmsg, bc0, bcS, mesg, iounit)
\begin{DoxyCompactList}\small\item\em Write a message including checksums of non-\/shifted and southward shifted arrays. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_ad46f7b2b2e81477204b3eca85f920d11}{chk\+\_\+sum\+\_\+msg\+\_\+w} (fmsg, bc0, bcW, mesg, iounit)
\begin{DoxyCompactList}\small\item\em Write a message including checksums of non-\/shifted and westward shifted arrays. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a6d1676bbe17574f8eebcfcf3c2bd50fb}{chk\+\_\+sum\+\_\+msg2} (fmsg, bc0, bc\+SW, mesg, iounit)
\begin{DoxyCompactList}\small\item\em Write a message including checksums of non-\/shifted and southwestward shifted arrays. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a13fdbca7f1f980b4ecbd22e1ff32005e}{chk\+\_\+sum\+\_\+msg3} (fmsg, a\+Mean, a\+Min, a\+Max, mesg, iounit)
\begin{DoxyCompactList}\small\item\em Write a message including the global mean, maximum and minimum of an array. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__checksums_a4844ebcc4ee98794babd6b17219f5139}{mom\+\_\+checksums\+\_\+init} (param\+\_\+file)
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+checksums\+\_\+init initializes the M\+O\+M\+\_\+checksums module. As it happens, the only thing that it does is to log the version of this module. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__checksums_a6400a8423305b77e4aed5d1cb4c24520}{chksum\+\_\+error} (signal, message)
\begin{DoxyCompactList}\small\item\em A wrapper for M\+O\+M\+\_\+error used in the checksum code. \end{DoxyCompactList}\item 
integer function \hyperlink{namespacemom__checksums_a13c171528ae5ab341cf75ef302a5b930}{bitcount} (x)
\begin{DoxyCompactList}\small\item\em Does a bitcount of a number by first casting to an integer and then using B\+T\+E\+ST to check bit by bit. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__checksums_a609fca199ad94da0d2e2ae06e24e178a}\label{namespacemom__checksums_a609fca199ad94da0d2e2ae06e24e178a}} 
integer, parameter \hyperlink{namespacemom__checksums_a609fca199ad94da0d2e2ae06e24e178a}{bc\+\_\+modulus} = 1000000000
\begin{DoxyCompactList}\small\item\em Modulus of checksum bitcount. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__checksums_a5e41fc3e4aa870cf3b6981f369949191}\label{namespacemom__checksums_a5e41fc3e4aa870cf3b6981f369949191}} 
integer, parameter \hyperlink{namespacemom__checksums_a5e41fc3e4aa870cf3b6981f369949191}{default\+\_\+shift} =0
\begin{DoxyCompactList}\small\item\em The default array shift. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__checksums_a246a126645d805953f7613da1bb6f540}\label{namespacemom__checksums_a246a126645d805953f7613da1bb6f540}} 
logical \hyperlink{namespacemom__checksums_a246a126645d805953f7613da1bb6f540}{calculatestatistics} =.true.
\begin{DoxyCompactList}\small\item\em If true, report min, max and mean. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__checksums_aa78f9d01d1d270d7bb3848d2d11f4491}\label{namespacemom__checksums_aa78f9d01d1d270d7bb3848d2d11f4491}} 
logical \hyperlink{namespacemom__checksums_aa78f9d01d1d270d7bb3848d2d11f4491}{writechksums} =.true.
\begin{DoxyCompactList}\small\item\em If true, report the bitcount checksum. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__checksums_ac9e62143b2a9fb749c668d70767fd9d3}\label{namespacemom__checksums_ac9e62143b2a9fb749c668d70767fd9d3}} 
logical \hyperlink{namespacemom__checksums_ac9e62143b2a9fb749c668d70767fd9d3}{checkfornans} =.true.
\begin{DoxyCompactList}\small\item\em If true, checks array for Na\+Ns and cause F\+A\+T\+AL error is any are found. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__checksums_a13c171528ae5ab341cf75ef302a5b930}\label{namespacemom__checksums_a13c171528ae5ab341cf75ef302a5b930}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!bitcount@{bitcount}}
\index{bitcount@{bitcount}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{bitcount()}{bitcount()}}
{\footnotesize\ttfamily integer function mom\+\_\+checksums\+::bitcount (\begin{DoxyParamCaption}\item[{real, intent(in)}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Does a bitcount of a number by first casting to an integer and then using B\+T\+E\+ST to check bit by bit. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & Number to be bitcount \\
\hline
\end{DoxyParams}


Definition at line 2191 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2191   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< Number to be bitcount}
2192 
2193   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: xk = kind(x)  \textcolor{comment}{!< Kind type of x}
2194 
2195   \textcolor{comment}{! NOTE: Assumes that reals and integers of kind=xk are the same size}
2196   bitcount = popcnt(transfer(x, 1\_xk))
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a77a351d5fb63b21521d26bebb90bcfab}\label{namespacemom__checksums_a77a351d5fb63b21521d26bebb90bcfab}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chk\+\_\+sum\+\_\+msg1@{chk\+\_\+sum\+\_\+msg1}}
\index{chk\+\_\+sum\+\_\+msg1@{chk\+\_\+sum\+\_\+msg1}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chk\+\_\+sum\+\_\+msg1()}{chk\_sum\_msg1()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chk\+\_\+sum\+\_\+msg1 (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{fmsg,  }\item[{integer, intent(in)}]{bc0,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in)}]{iounit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write a message including the checksum of the non-\/shifted array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fmsg} & A checksum code-\/location specific preamble\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message supplied by top-\/level caller\\
\hline
\mbox{\tt in}  & {\em bc0} & The bitcount of the non-\/shifted array\\
\hline
\mbox{\tt in}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


Definition at line 2077 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2077   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-location specific preamble}
2078   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-level caller}
2079   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-shifted array}
2080   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}
2081 
2082   \textcolor{keywordflow}{if} (is\_root\_pe()) &
2083     \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,1(A,I10,X),A)'}) fmsg, \textcolor{stringliteral}{" c="}, bc0, trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a6d1676bbe17574f8eebcfcf3c2bd50fb}\label{namespacemom__checksums_a6d1676bbe17574f8eebcfcf3c2bd50fb}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chk\+\_\+sum\+\_\+msg2@{chk\+\_\+sum\+\_\+msg2}}
\index{chk\+\_\+sum\+\_\+msg2@{chk\+\_\+sum\+\_\+msg2}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chk\+\_\+sum\+\_\+msg2()}{chk\_sum\_msg2()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chk\+\_\+sum\+\_\+msg2 (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{fmsg,  }\item[{integer, intent(in)}]{bc0,  }\item[{integer, intent(in)}]{bc\+SW,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in)}]{iounit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write a message including checksums of non-\/shifted and southwestward shifted arrays. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fmsg} & A checksum code-\/location specific preamble\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message supplied by top-\/level caller\\
\hline
\mbox{\tt in}  & {\em bc0} & The bitcount of the non-\/shifted array\\
\hline
\mbox{\tt in}  & {\em bcsw} & The bitcount of the southwest-\/shifted array\\
\hline
\mbox{\tt in}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


Definition at line 2142 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2142   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-location specific preamble}
2143   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-level caller}
2144   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-shifted array}
2145   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcsw\textcolor{comment}{ !< The bitcount of the southwest-shifted array}
2146   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}
2147 
2148   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,2(A,I9,1X),A)'}) &
2149     fmsg, \textcolor{stringliteral}{" c="}, bc0, \textcolor{stringliteral}{"s/w="}, bcsw, trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a13fdbca7f1f980b4ecbd22e1ff32005e}\label{namespacemom__checksums_a13fdbca7f1f980b4ecbd22e1ff32005e}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chk\+\_\+sum\+\_\+msg3@{chk\+\_\+sum\+\_\+msg3}}
\index{chk\+\_\+sum\+\_\+msg3@{chk\+\_\+sum\+\_\+msg3}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chk\+\_\+sum\+\_\+msg3()}{chk\_sum\_msg3()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chk\+\_\+sum\+\_\+msg3 (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{fmsg,  }\item[{real, intent(in)}]{a\+Mean,  }\item[{real, intent(in)}]{a\+Min,  }\item[{real, intent(in)}]{a\+Max,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in)}]{iounit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write a message including the global mean, maximum and minimum of an array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fmsg} & A checksum code-\/location specific preamble\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message supplied by top-\/level caller\\
\hline
\mbox{\tt in}  & {\em amean} & The mean value of the array\\
\hline
\mbox{\tt in}  & {\em amin} & The minimum value of the array\\
\hline
\mbox{\tt in}  & {\em amax} & The maximum value of the array\\
\hline
\mbox{\tt in}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


Definition at line 2154 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2154   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-location specific preamble}
2155   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-level caller}
2156   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{intent(in)} :: amean\textcolor{comment}{ !< The mean value of the array}
2157   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{intent(in)} :: amin\textcolor{comment}{ !< The minimum value of the array}
2158   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{intent(in)} :: amax\textcolor{comment}{ !< The maximum value of the array}
2159   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}
2160 
2161   \textcolor{comment}{! NOTE: We add zero to aMin and aMax to remove any negative zeros.}
2162   \textcolor{comment}{! This is due to inconsistencies of signed zero in local vs MPI calculations.}
2163 
2164   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,3(A,ES25.16,1X),A)'}) &
2165     fmsg, \textcolor{stringliteral}{" mean="}, amean, \textcolor{stringliteral}{"min="}, (0. + amin), \textcolor{stringliteral}{"max="}, (0. + amax), trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_afd3901de6e3cac8dd66aa0ea36011e4c}\label{namespacemom__checksums_afd3901de6e3cac8dd66aa0ea36011e4c}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chk\+\_\+sum\+\_\+msg5@{chk\+\_\+sum\+\_\+msg5}}
\index{chk\+\_\+sum\+\_\+msg5@{chk\+\_\+sum\+\_\+msg5}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chk\+\_\+sum\+\_\+msg5()}{chk\_sum\_msg5()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chk\+\_\+sum\+\_\+msg5 (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{fmsg,  }\item[{integer, intent(in)}]{bc0,  }\item[{integer, intent(in)}]{bc\+SW,  }\item[{integer, intent(in)}]{bc\+SE,  }\item[{integer, intent(in)}]{bc\+NW,  }\item[{integer, intent(in)}]{bc\+NE,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in)}]{iounit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write a message including checksums of non-\/shifted and diagonally shifted arrays. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fmsg} & A checksum code-\/location specific preamble\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message supplied by top-\/level caller\\
\hline
\mbox{\tt in}  & {\em bc0} & The bitcount of the non-\/shifted array\\
\hline
\mbox{\tt in}  & {\em bcsw} & The bitcount for SW shifted array\\
\hline
\mbox{\tt in}  & {\em bcse} & The bitcount for SE shifted array\\
\hline
\mbox{\tt in}  & {\em bcnw} & The bitcount for NW shifted array\\
\hline
\mbox{\tt in}  & {\em bcne} & The bitcount for NE shifted array\\
\hline
\mbox{\tt in}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


Definition at line 2088 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2088   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-location specific preamble}
2089   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-level caller}
2090   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-shifted array}
2091   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcsw\textcolor{comment}{ !< The bitcount for SW shifted array}
2092   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcse\textcolor{comment}{ !< The bitcount for SE shifted array}
2093   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcnw\textcolor{comment}{ !< The bitcount for NW shifted array}
2094   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcne\textcolor{comment}{ !< The bitcount for NE shifted array}
2095   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}
2096 
2097   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,5(A,I10,1X),A)'}) &
2098     fmsg, \textcolor{stringliteral}{" c="}, bc0, \textcolor{stringliteral}{"sw="}, bcsw, \textcolor{stringliteral}{"se="}, bcse, \textcolor{stringliteral}{"nw="}, bcnw, \textcolor{stringliteral}{"ne="}, bcne, trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a2bbf928379ba9abdc67a2f6f93ea8c34}\label{namespacemom__checksums_a2bbf928379ba9abdc67a2f6f93ea8c34}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chk\+\_\+sum\+\_\+msg\+\_\+nsew@{chk\+\_\+sum\+\_\+msg\+\_\+nsew}}
\index{chk\+\_\+sum\+\_\+msg\+\_\+nsew@{chk\+\_\+sum\+\_\+msg\+\_\+nsew}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chk\+\_\+sum\+\_\+msg\+\_\+nsew()}{chk\_sum\_msg\_nsew()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chk\+\_\+sum\+\_\+msg\+\_\+nsew (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{fmsg,  }\item[{integer, intent(in)}]{bc0,  }\item[{integer, intent(in)}]{bcN,  }\item[{integer, intent(in)}]{bcS,  }\item[{integer, intent(in)}]{bcE,  }\item[{integer, intent(in)}]{bcW,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in)}]{iounit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write a message including checksums of non-\/shifted and laterally shifted arrays. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fmsg} & A checksum code-\/location specific preamble\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message supplied by top-\/level caller\\
\hline
\mbox{\tt in}  & {\em bc0} & The bitcount of the non-\/shifted array\\
\hline
\mbox{\tt in}  & {\em bcn} & The bitcount for N shifted array\\
\hline
\mbox{\tt in}  & {\em bcs} & The bitcount for S shifted array\\
\hline
\mbox{\tt in}  & {\em bce} & The bitcount for E shifted array\\
\hline
\mbox{\tt in}  & {\em bcw} & The bitcount for W shifted array\\
\hline
\mbox{\tt in}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
2103   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-location specific preamble}
2104   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-level caller}
2105   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-shifted array}
2106   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcn\textcolor{comment}{ !< The bitcount for N shifted array}
2107   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcs\textcolor{comment}{ !< The bitcount for S shifted array}
2108   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bce\textcolor{comment}{ !< The bitcount for E shifted array}
2109   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcw\textcolor{comment}{ !< The bitcount for W shifted array}
2110   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}
2111 
2112   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,5(A,I10,1X),A)'}) &
2113     fmsg, \textcolor{stringliteral}{" c="}, bc0, \textcolor{stringliteral}{"N="}, bcn, \textcolor{stringliteral}{"S="}, bcs, \textcolor{stringliteral}{"E="}, bce, \textcolor{stringliteral}{"W="}, bcw, trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a980dd3235b339afa9decbe8474a0bc58}\label{namespacemom__checksums_a980dd3235b339afa9decbe8474a0bc58}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chk\+\_\+sum\+\_\+msg\+\_\+s@{chk\+\_\+sum\+\_\+msg\+\_\+s}}
\index{chk\+\_\+sum\+\_\+msg\+\_\+s@{chk\+\_\+sum\+\_\+msg\+\_\+s}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chk\+\_\+sum\+\_\+msg\+\_\+s()}{chk\_sum\_msg\_s()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chk\+\_\+sum\+\_\+msg\+\_\+s (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{fmsg,  }\item[{integer, intent(in)}]{bc0,  }\item[{integer, intent(in)}]{bcS,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in)}]{iounit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write a message including checksums of non-\/shifted and southward shifted arrays. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fmsg} & A checksum code-\/location specific preamble\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message supplied by top-\/level caller\\
\hline
\mbox{\tt in}  & {\em bc0} & The bitcount of the non-\/shifted array\\
\hline
\mbox{\tt in}  & {\em bcs} & The bitcount of the south-\/shifted array\\
\hline
\mbox{\tt in}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


Definition at line 2118 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2118   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-location specific preamble}
2119   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-level caller}
2120   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-shifted array}
2121   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcs\textcolor{comment}{  !< The bitcount of the south-shifted array}
2122   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}
2123 
2124   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,2(A,I10,1X),A)'}) &
2125     fmsg, \textcolor{stringliteral}{" c="}, bc0, \textcolor{stringliteral}{"S="}, bcs, trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_ad46f7b2b2e81477204b3eca85f920d11}\label{namespacemom__checksums_ad46f7b2b2e81477204b3eca85f920d11}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chk\+\_\+sum\+\_\+msg\+\_\+w@{chk\+\_\+sum\+\_\+msg\+\_\+w}}
\index{chk\+\_\+sum\+\_\+msg\+\_\+w@{chk\+\_\+sum\+\_\+msg\+\_\+w}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chk\+\_\+sum\+\_\+msg\+\_\+w()}{chk\_sum\_msg\_w()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chk\+\_\+sum\+\_\+msg\+\_\+w (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{fmsg,  }\item[{integer, intent(in)}]{bc0,  }\item[{integer, intent(in)}]{bcW,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in)}]{iounit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Write a message including checksums of non-\/shifted and westward shifted arrays. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em fmsg} & A checksum code-\/location specific preamble\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message supplied by top-\/level caller\\
\hline
\mbox{\tt in}  & {\em bc0} & The bitcount of the non-\/shifted array\\
\hline
\mbox{\tt in}  & {\em bcw} & The bitcount of the west-\/shifted array\\
\hline
\mbox{\tt in}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


Definition at line 2130 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2130   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-location specific preamble}
2131   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-level caller}
2132   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-shifted array}
2133   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcw\textcolor{comment}{  !< The bitcount of the west-shifted array}
2134   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}
2135 
2136   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,2(A,I10,1X),A)'}) &
2137     fmsg, \textcolor{stringliteral}{" c="}, bc0, \textcolor{stringliteral}{"W="}, bcw, trim(mesg)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a94aae972d8c543ede8792d20b9af94e2}\label{namespacemom__checksums_a94aae972d8c543ede8792d20b9af94e2}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum0@{chksum0}}
\index{chksum0@{chksum0}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum0()}{chksum0()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+checksums\+::chksum0 (\begin{DoxyParamCaption}\item[{real, intent(in)}]{scalar,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})}



Checksum a scalar field (consistent with array checksums) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em scalar} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 89 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
89   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: scalar\textcolor{comment}{                !< The array to be checksummed}
90   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{     !< An identifying message}
91   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{      !< A scaling factor for this array.}
92   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
93 
94   \textcolor{keywordtype}{real} :: scaling\textcolor{comment}{   !< Explicit rescaling factor}
95   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
96   \textcolor{keywordtype}{real} :: rs\textcolor{comment}{        !< Rescaled scalar}
97   \textcolor{keywordtype}{integer} :: bc\textcolor{comment}{     !< Scalar bitcount}
98 
99   \textcolor{keywordflow}{if} (checkfornans .and. is\_nan(scalar)) &
100     \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
101 
102   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
103   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
104 
105   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
106     rs = scaling * scalar
107     \textcolor{keywordflow}{if} (is\_root\_pe()) &
108       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{" scalar:"}, rs, rs, rs, mesg, iounit)
109 \textcolor{keywordflow}{  endif}
110 
111   \textcolor{keywordflow}{if} (.not. writechksums) \textcolor{keywordflow}{return}
112 
113   bc = mod(bitcount(abs(scaling * scalar)), bc\_modulus)
114   \textcolor{keywordflow}{if} (is\_root\_pe()) &
115     \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{" scalar:"}, bc, mesg, iounit)
116 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_aa064e020b99a0efca89590774af3454d}\label{namespacemom__checksums_aa064e020b99a0efca89590774af3454d}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum1d@{chksum1d}}
\index{chksum1d@{chksum1d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum1d()}{chksum1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum1d (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{array,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{integer, intent(in), optional}]{start\+\_\+i,  }\item[{integer, intent(in), optional}]{end\+\_\+i,  }\item[{logical, intent(in), optional}]{compare\+\_\+\+P\+Es }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



chksum1d does a checksum of a 1-\/dimensional array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em array} & The array to be summed (index starts at 1).\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message.\\
\hline
\mbox{\tt in}  & {\em start\+\_\+i} & The starting index for the sum (default 1)\\
\hline
\mbox{\tt in}  & {\em end\+\_\+i} & The ending index for the sum (default all)\\
\hline
\mbox{\tt in}  & {\em compare\+\_\+pes} & If true, compare across P\+Es instead of summing and list the root\+\_\+\+PE value (default true) \\
\hline
\end{DoxyParams}


Definition at line 1887 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1887   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{   !< The array to be summed (index starts at 1).}
1888   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{    !< An identifying message.}
1889   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)} :: start\_i\textcolor{comment}{ !< The starting index for the sum (default 1)}
1890   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)} :: end\_i\textcolor{comment}{   !< The ending index for the sum (default all)}
1891   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)} :: compare\_pes\textcolor{comment}{ !< If true, compare across PEs instead of summing}
1892 \textcolor{comment}{                                                !! and list the root\_PE value (default true)}
1893 
1894   \textcolor{keywordtype}{integer} :: is, ie, i, bc, sum1, sum\_bc
1895   \textcolor{keywordtype}{real} :: sum
1896   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable} :: sum\_here(:)
1897   \textcolor{keywordtype}{logical} :: compare
1898   \textcolor{keywordtype}{integer} :: pe\_num   \textcolor{comment}{! pe number of the data}
1899   \textcolor{keywordtype}{integer} :: npes     \textcolor{comment}{! Total number of processsors}
1900 
1901   is = lbound(array,1) ; ie = ubound(array,1)
1902   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(start\_i)) is = start\_i
1903   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(end\_i)) ie = end\_i
1904   compare = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(compare\_pes)) compare = compare\_pes
1905 
1906   sum = 0.0 ; sum\_bc = 0
1907   \textcolor{keywordflow}{do} i=is,ie
1908     sum = sum + array(i)
1909     bc = bitcount(abs(array(i)))
1910     sum\_bc = sum\_bc + bc
1911 \textcolor{keywordflow}{  enddo}
1912 
1913   pe\_num = pe\_here() + 1 - root\_pe() ; npes = num\_pes()
1914   \textcolor{keyword}{allocate}(sum\_here(npes)) ; sum\_here(:) = 0.0 ; sum\_here(pe\_num) = sum
1915   \textcolor{keyword}{call }sum\_across\_pes(sum\_here,npes)
1916 
1917   sum1 = sum\_bc
1918   \textcolor{keyword}{call }sum\_across\_pes(sum1)
1919 
1920   \textcolor{keywordflow}{if} (.not.compare) \textcolor{keywordflow}{then}
1921     sum = 0.0
1922     \textcolor{keywordflow}{do} i=1,npes ; sum = sum + sum\_here(i) ;\textcolor{keywordflow}{ enddo}
1923     sum\_bc = sum1
1924   \textcolor{keywordflow}{elseif} (is\_root\_pe()) \textcolor{keywordflow}{then}
1925     \textcolor{keywordflow}{if} (sum1 /= npes*sum\_bc) &
1926       \textcolor{keyword}{write}(0, \textcolor{stringliteral}{'(A40," bitcounts do not match across PEs: ",I12,1X,I12)'}) &
1927             mesg, sum1, npes*sum\_bc
1928     \textcolor{keywordflow}{do} i=1,npes ; \textcolor{keywordflow}{if} (sum /= sum\_here(i)) \textcolor{keywordflow}{then}
1929       \textcolor{keyword}{write}(0, \textcolor{stringliteral}{'(A40," PE ",i4," sum mismatches root\_PE: ",3(ES22.13,1X))'}) &
1930             mesg, i, sum\_here(i), sum, sum\_here(i)-sum
1931 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo}
1932 \textcolor{keywordflow}{  endif}
1933   \textcolor{keyword}{deallocate}(sum\_here)
1934 
1935   \textcolor{keywordflow}{if} (is\_root\_pe()) &
1936     \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(A50,1X,ES25.16,1X,I12)'}) mesg, sum, sum\_bc
1937 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a06dcbee42e0aa2afca2803757905effd}\label{namespacemom__checksums_a06dcbee42e0aa2afca2803757905effd}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum2d@{chksum2d}}
\index{chksum2d@{chksum2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum2d()}{chksum2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum2d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:)}]{array,  }\item[{character(len=$\ast$)}]{mesg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



chksum2d does a checksum of all data in a 2-\/d array. 


\begin{DoxyParams}{Parameters}
{\em array} & The array to be checksummed\\
\hline
{\em mesg} & An identifying message \\
\hline
\end{DoxyParams}


Definition at line 1945 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1945 
1946   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)} :: array\textcolor{comment}{ !< The array to be checksummed}
1947   \textcolor{keywordtype}{character(len=*)} :: mesg\textcolor{comment}{  !< An identifying message}
1948 
1949   \textcolor{keywordtype}{integer} :: xs,xe,ys,ye,i,j,sum1,bc
1950   \textcolor{keywordtype}{real} :: sum
1951 
1952   xs = lbound(array,1) ; xe = ubound(array,1)
1953   ys = lbound(array,2) ; ye = ubound(array,2)
1954 
1955   sum = 0.0 ; sum1 = 0
1956   \textcolor{keywordflow}{do} i=xs,xe ; \textcolor{keywordflow}{do} j=ys,ye
1957     bc = bitcount(abs(array(i,j)))
1958     sum1 = sum1 + bc
1959 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1960   \textcolor{keyword}{call }sum\_across\_pes(sum1)
1961 
1962   sum = reproducing\_sum(array(:,:))
1963 
1964   \textcolor{keywordflow}{if} (is\_root\_pe()) &
1965     \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(A50,1X,ES25.16,1X,I12)'}) mesg, sum, sum1
1966 \textcolor{comment}{!    write(0,'(A40,1X,Z16.16,1X,Z16.16,1X,ES25.16,1X,I12)') &}
1967 \textcolor{comment}{!      mesg, sum, sum1, sum, sum1}
1968 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a4538309762110054a606a863a2efcd40}\label{namespacemom__checksums_a4538309762110054a606a863a2efcd40}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum3d@{chksum3d}}
\index{chksum3d@{chksum3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum3d()}{chksum3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum3d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:)}]{array,  }\item[{character(len=$\ast$)}]{mesg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



chksum3d does a checksum of all data in a 2-\/d array. 


\begin{DoxyParams}{Parameters}
{\em array} & The array to be checksummed\\
\hline
{\em mesg} & An identifying message \\
\hline
\end{DoxyParams}


Definition at line 1973 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1973 
1974   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)} :: array\textcolor{comment}{ !< The array to be checksummed}
1975   \textcolor{keywordtype}{character(len=*)} :: mesg\textcolor{comment}{  !< An identifying message}
1976 
1977   \textcolor{keywordtype}{integer} :: xs,xe,ys,ye,zs,ze,i,j,k, bc,sum1
1978   \textcolor{keywordtype}{real} :: sum
1979 
1980   xs = lbound(array,1) ; xe = ubound(array,1)
1981   ys = lbound(array,2) ; ye = ubound(array,2)
1982   zs = lbound(array,3) ; ze = ubound(array,3)
1983 
1984   sum = 0.0 ; sum1 = 0
1985   \textcolor{keywordflow}{do} i=xs,xe ; \textcolor{keywordflow}{do} j=ys,ye ; \textcolor{keywordflow}{do} k=zs,ze
1986     bc = bitcount(abs(array(i,j,k)))
1987     sum1 = sum1 + bc
1988 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1989 
1990   \textcolor{keyword}{call }sum\_across\_pes(sum1)
1991   sum = reproducing\_sum(array(:,:,:))
1992 
1993   \textcolor{keywordflow}{if} (is\_root\_pe()) &
1994     \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(A50,1X,ES25.16,1X,I12)'}) mesg, sum, sum1
1995 \textcolor{comment}{!    write(0,'(A40,1X,Z16.16,1X,Z16.16,1X,ES25.16,1X,I12)') &}
1996 \textcolor{comment}{!      mesg, sum, sum1, sum, sum1}
1997 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_af3ee2725096bea4d0e532b02bd7a5983}\label{namespacemom__checksums_af3ee2725096bea4d0e532b02bd7a5983}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+b\+\_\+2d@{chksum\+\_\+b\+\_\+2d}}
\index{chksum\+\_\+b\+\_\+2d@{chksum\+\_\+b\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+b\+\_\+2d()}{chksum\_b\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+b\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isdb\+:,hi\+\_\+m\%jsdb\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 2d array staggered at corner points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 570 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
570   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{     !< A horizontal index type}
571   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%IsdB:,HI\_m%JsdB:)}, &
572                         \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
573   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
574   \textcolor{keywordtype}{integer},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
575   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the}
576 \textcolor{comment}{                                                !! full symmetric computational domain.}
577   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
578   \textcolor{keywordtype}{real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
579   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
580 
581   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:)           \textcolor{comment}{! Field array on the input grid}
582   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: rescaled\_array
583   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
584   \textcolor{keywordtype}{real} :: scaling
585   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
586   \textcolor{keywordtype}{integer} :: i, j, is, js
587   \textcolor{keywordtype}{real} :: amean, amin, amax
588   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
589   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
590   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats
591   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
592 
593   \textcolor{comment}{! Rotate array to the input grid}
594   turns = hi\_m%turns
595   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
596     \textcolor{keyword}{allocate}(hi)
597     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
598     \textcolor{keyword}{allocate}(array(hi%IsdB:hi%IedB, hi%JsdB:hi%JedB))
599     \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
600   \textcolor{keywordflow}{else}
601     hi => hi\_m
602     array => array\_m
603 \textcolor{keywordflow}{  endif}
604 
605   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
606     \textcolor{keywordflow}{if} (is\_nan(array(hi%IscB:hi%IecB,hi%JscB:hi%JecB))) &
607       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
608 \textcolor{comment}{!   if (is\_NaN(array)) &}
609 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
610 \textcolor{keywordflow}{  endif}
611 
612   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
613   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
614   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric
615   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}
616 
617   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
618     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
619       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
620                                lbound(array,2):ubound(array,2)) )
621       rescaled\_array(:,:) = 0.0
622       is = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) is = hi%isc-1
623       js = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) js = hi%jsc-1
624       \textcolor{keywordflow}{do} j=js,hi%JecB ; \textcolor{keywordflow}{do} i=is,hi%IecB
625         rescaled\_array(i,j) = scale*array(i,j)
626 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
627       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)
628       \textcolor{keyword}{deallocate}(rescaled\_array)
629     \textcolor{keywordflow}{else}
630       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)
631 \textcolor{keywordflow}{    endif}
632     \textcolor{keywordflow}{if} (is\_root\_pe()) &
633       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"B-point:"}, amean, amin, amax, mesg, iounit)
634 \textcolor{keywordflow}{  endif}
635 
636   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
637 
638   hshift = default\_shift
639   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
640   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
641 
642   \textcolor{keywordflow}{if} ( hi%iscB-hshift<hi%isdB .or. hi%iecB+hshift>hi%iedB .or. &
643        hi%jscB-hshift<hi%jsdB .or. hi%jecB+hshift>hi%jedB ) \textcolor{keywordflow}{then}
644     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_B\_2d: haloshift ='},hshift
645     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_B\_2d: isd,isc,iec,ied='},hi%isdB,hi%iscB,hi%iecB,hi%iedB
646     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_B\_2d: jsd,jsc,jec,jed='},hi%jsdB,hi%jscB,hi%jecB,hi%jedB
647     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_B\_2d '}//trim(mesg))
648 \textcolor{keywordflow}{  endif}
649 
650   bc0 = subchk(array, hi, 0, 0, scaling)
651 
652   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
653 
654   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}
655     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"B-point:"}, bc0, mesg, iounit)
656     \textcolor{keywordflow}{return}
657 \textcolor{keywordflow}{  endif}
658 
659   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
660 
661   \textcolor{keywordflow}{if} (do\_corners) \textcolor{keywordflow}{then}
662     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
663       bcsw = subchk(array, hi, -hshift-1, -hshift-1, scaling)
664       bcse = subchk(array, hi, hshift, -hshift-1, scaling)
665       bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
666     \textcolor{keywordflow}{else}
667       bcsw = subchk(array, hi, -hshift, -hshift, scaling)
668       bcse = subchk(array, hi, hshift, -hshift, scaling)
669       bcnw = subchk(array, hi, -hshift, hshift, scaling)
670 \textcolor{keywordflow}{    endif}
671     bcne = subchk(array, hi, hshift, hshift, scaling)
672 
673     \textcolor{keywordflow}{if} (is\_root\_pe()) &
674       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"B-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
675   \textcolor{keywordflow}{else}
676     bcs = subchk(array, hi, 0, -hshift, scaling)
677     bce = subchk(array, hi, hshift, 0, scaling)
678     bcw = subchk(array, hi, -hshift, 0, scaling)
679     bcn = subchk(array, hi, 0, hshift, scaling)
680 
681     \textcolor{keywordflow}{if} (is\_root\_pe()) &
682       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"B-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
683 \textcolor{keywordflow}{  endif}
684 
685   \textcolor{keyword}{contains}
686 
687 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
688     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
689     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%JsdB:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
690     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
691     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
692     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
693     \textcolor{keywordtype}{integer} :: i, j, bc
694     subchk = 0
695     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
696     \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
697       bc = bitcount(abs(scale*array(i,j)))
698       subchk = subchk + bc
699 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
700     \textcolor{keyword}{call }sum\_across\_pes(subchk)
701     subchk=mod(subchk, bc\_modulus)
702 \textcolor{keyword}{  end function }subchk
703 
704 \textcolor{keyword}{  subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)
705     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
706     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%JsdB:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
707     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}
708 \textcolor{comment}{                                              !! full symmetric computational domain.}
709     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
710     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
711     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
712 
713     \textcolor{keywordtype}{integer} :: i, j, n, isb, jsb
714 
715     isb = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) isb = hi%isc-1
716     jsb = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) jsb = hi%jsc-1
717 
718     amin = array(hi%isc,hi%jsc) ; amax = amin
719     \textcolor{keywordflow}{do} j=jsb,hi%JecB ; \textcolor{keywordflow}{do} i=isb,hi%IecB
720       amin = min(amin, array(i,j))
721       amax = max(amax, array(i,j))
722 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
723     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
724     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec))
725     n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc)
726     \textcolor{keyword}{call }sum\_across\_pes(n)
727     \textcolor{keyword}{call }min\_across\_pes(amin)
728     \textcolor{keyword}{call }max\_across\_pes(amax)
729     amean = amean / \textcolor{keywordtype}{real}(n)
730 \textcolor{keyword}{  end subroutine }substats
731 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a7eda888fdc2e22a7367662d76cbc193d}\label{namespacemom__checksums_a7eda888fdc2e22a7367662d76cbc193d}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+b\+\_\+3d@{chksum\+\_\+b\+\_\+3d}}
\index{chksum\+\_\+b\+\_\+3d@{chksum\+\_\+b\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+b\+\_\+3d()}{chksum\_b\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+b\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isdb\+:,hi\+\_\+m\%jsdb\+:,\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 3d array staggered at corner points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 1354 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1354   \textcolor{keywordtype}{type}(hor\_index\_type),     \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{ !< A horizontal index type}
1355   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%IsdB:,HI\_m%JsdB:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
1356   \textcolor{keywordtype}{character(len=*)},                   \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
1357   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
1358   \textcolor{keywordtype}{logical},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
1359 \textcolor{comment}{                                                              !! symmetric computational domain.}
1360   \textcolor{keywordtype}{logical},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
1361   \textcolor{keywordtype}{real},                     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
1362   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
1363 
1364   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}
1365   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array
1366   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
1367   \textcolor{keywordtype}{real} :: scaling
1368   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
1369   \textcolor{keywordtype}{integer} :: i, j, k, is, js
1370   \textcolor{keywordtype}{real} :: amean, amin, amax
1371   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
1372   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
1373   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats
1374   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
1375 
1376   \textcolor{comment}{! Rotate array to the input grid}
1377   turns = hi\_m%turns
1378   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
1379     \textcolor{keyword}{allocate}(hi)
1380     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
1381     \textcolor{keyword}{allocate}(array(hi%IsdB:hi%IedB, hi%JsdB:hi%JedB, \textcolor{keyword}{size}(array\_m, 3)))
1382     \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1383   \textcolor{keywordflow}{else}
1384     hi => hi\_m
1385     array => array\_m
1386 \textcolor{keywordflow}{  endif}
1387 
1388   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
1389     \textcolor{keywordflow}{if} (is\_nan(array(hi%IscB:hi%IecB,hi%JscB:hi%JecB,:))) &
1390       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
1391 \textcolor{comment}{!   if (is\_NaN(array)) &}
1392 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
1393 \textcolor{keywordflow}{  endif}
1394 
1395   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
1396   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
1397   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric
1398   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}
1399 
1400   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
1401     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
1402       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
1403                                lbound(array,2):ubound(array,2), &
1404                                lbound(array,3):ubound(array,3)) )
1405       rescaled\_array(:,:,:) = 0.0
1406       is = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) is = hi%isc-1
1407       js = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) js = hi%jsc-1
1408       \textcolor{keywordflow}{do} k=1,\textcolor{keyword}{size}(array,3) ; \textcolor{keywordflow}{do} j=js,hi%JecB ; \textcolor{keywordflow}{do} i=is,hi%IecB
1409         rescaled\_array(i,j,k) = scale*array(i,j,k)
1410 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1411       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)
1412       \textcolor{keyword}{deallocate}(rescaled\_array)
1413     \textcolor{keywordflow}{else}
1414       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)
1415 \textcolor{keywordflow}{    endif}
1416 
1417     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1418       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"B-point:"}, amean, amin, amax, mesg, iounit)
1419 \textcolor{keywordflow}{  endif}
1420 
1421   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
1422 
1423   hshift = default\_shift
1424   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1425   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
1426 
1427   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
1428        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
1429     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_B\_3d: haloshift ='},hshift
1430     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_B\_3d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
1431     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_B\_3d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
1432     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_B\_3d '}//trim(mesg))
1433 \textcolor{keywordflow}{  endif}
1434 
1435   bc0 = subchk(array, hi, 0, 0, scaling)
1436 
1437   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
1438 
1439   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}
1440     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"B-point:"}, bc0, mesg, iounit)
1441     \textcolor{keywordflow}{return}
1442 \textcolor{keywordflow}{  endif}
1443 
1444   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
1445 
1446   \textcolor{keywordflow}{if} (do\_corners) \textcolor{keywordflow}{then}
1447     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1448       bcsw = subchk(array, hi, -hshift-1, -hshift-1, scaling)
1449       bcse = subchk(array, hi, hshift, -hshift-1, scaling)
1450       bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
1451     \textcolor{keywordflow}{else}
1452       bcsw = subchk(array, hi, -hshift-1, -hshift-1, scaling)
1453       bcse = subchk(array, hi, hshift, -hshift-1, scaling)
1454       bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
1455 \textcolor{keywordflow}{    endif}
1456     bcne = subchk(array, hi, hshift, hshift, scaling)
1457 
1458     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1459       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"B-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
1460   \textcolor{keywordflow}{else}
1461     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1462       bcs = subchk(array, hi, 0, -hshift-1, scaling)
1463       bcw = subchk(array, hi, -hshift-1, 0, scaling)
1464     \textcolor{keywordflow}{else}
1465       bcs = subchk(array, hi, 0, -hshift, scaling)
1466       bcw = subchk(array, hi, -hshift, 0, scaling)
1467 \textcolor{keywordflow}{    endif}
1468     bce = subchk(array, hi, hshift, 0, scaling)
1469     bcn = subchk(array, hi, 0, hshift, scaling)
1470 
1471     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1472       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"B-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
1473 \textcolor{keywordflow}{  endif}
1474 
1475   \textcolor{keyword}{contains}
1476 
1477 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
1478     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1479     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1480     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
1481     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
1482     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
1483     \textcolor{keywordtype}{integer} :: i, j, k, bc
1484     subchk = 0
1485     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1486     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj ; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
1487       bc = bitcount(abs(scale*array(i,j,k)))
1488       subchk = subchk + bc
1489 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1490     \textcolor{keyword}{call }sum\_across\_pes(subchk)
1491     subchk=mod(subchk, bc\_modulus)
1492 \textcolor{keyword}{  end function }subchk
1493 
1494 \textcolor{keyword}{  subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)
1495     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1496     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1497     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}
1498 \textcolor{comment}{                                              !! full symmetric computational domain.}
1499     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
1500     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
1501     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
1502 
1503     \textcolor{keywordtype}{integer} :: i, j, k, n, isb, jsb
1504 
1505     isb = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) isb = hi%isc-1
1506     jsb = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) jsb = hi%jsc-1
1507 
1508     amin = array(hi%isc,hi%jsc,1) ; amax = amin
1509     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=jsb,hi%JecB ; \textcolor{keywordflow}{do} i=isb,hi%IecB
1510       amin = min(amin, array(i,j,k))
1511       amax = max(amax, array(i,j,k))
1512 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1513     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))
1514     n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc) * \textcolor{keyword}{size}(array,3)
1515     \textcolor{keyword}{call }sum\_across\_pes(n)
1516     \textcolor{keyword}{call }min\_across\_pes(amin)
1517     \textcolor{keyword}{call }max\_across\_pes(amax)
1518     amean = amean / \textcolor{keywordtype}{real}(n)
1519 \textcolor{keyword}{  end subroutine }substats
1520 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a6400a8423305b77e4aed5d1cb4c24520}\label{namespacemom__checksums_a6400a8423305b77e4aed5d1cb4c24520}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+error@{chksum\+\_\+error}}
\index{chksum\+\_\+error@{chksum\+\_\+error}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+error()}{chksum\_error()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+error (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{signal,  }\item[{character(len=$\ast$), intent(in)}]{message }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



A wrapper for M\+O\+M\+\_\+error used in the checksum code. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em signal} & An error severity level, such as F\+A\+T\+AL or W\+A\+R\+N\+I\+NG\\
\hline
\mbox{\tt in}  & {\em message} & An error message \\
\hline
\end{DoxyParams}


Definition at line 2182 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2182   \textcolor{comment}{! Wrapper for MOM\_error to help place specific break points in debuggers}
2183   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: signal\textcolor{comment}{ !< An error severity level, such as FATAL or WARNING}
2184   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: message\textcolor{comment}{ !< An error message}
2185   \textcolor{keyword}{call }mom\_error(signal, message)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a49992903b4b92e03a5933426154c4641}\label{namespacemom__checksums_a49992903b4b92e03a5933426154c4641}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+h\+\_\+2d@{chksum\+\_\+h\+\_\+2d}}
\index{chksum\+\_\+h\+\_\+2d@{chksum\+\_\+h\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+h\+\_\+2d()}{chksum\_h\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+h\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isd\+:,hi\+\_\+m\%jsd\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 2d array staggered at tracer points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & Horizontal index bounds of the model grid\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & Field array on the model grid\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 306 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
306   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{    !< Horizontal index bounds of the model grid}
307   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isd:,HI\_m%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< Field array on the model grid}
308   \textcolor{keywordtype}{character(len=*)},                \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
309   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
310   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
311   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
312   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
313 
314   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:)           \textcolor{comment}{! Field array on the input grid}
315   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: rescaled\_array
316   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
317   \textcolor{keywordtype}{real} :: scaling
318   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
319   \textcolor{keywordtype}{integer} :: i, j
320   \textcolor{keywordtype}{real} :: amean, amin, amax
321   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
322   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
323   \textcolor{keywordtype}{logical} :: do\_corners
324   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
325 
326   \textcolor{comment}{! Rotate array to the input grid}
327   turns = hi\_m%turns
328   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
329     \textcolor{keyword}{allocate}(hi)
330     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
331     \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%jsd:hi%jed))
332     \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
333   \textcolor{keywordflow}{else}
334     hi => hi\_m
335     array => array\_m
336 \textcolor{keywordflow}{  endif}
337 
338   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
339     \textcolor{keywordflow}{if} (is\_nan(array(hi%isc:hi%iec,hi%jsc:hi%jec))) &
340       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
341 \textcolor{comment}{!   if (is\_NaN(array)) &}
342 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
343 \textcolor{keywordflow}{  endif}
344 
345   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
346   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
347 
348   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
349     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
350       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
351                                lbound(array,2):ubound(array,2)) )
352       rescaled\_array(:,:) = 0.0
353       \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
354         rescaled\_array(i,j) = scale*array(i,j)
355 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
356       \textcolor{keyword}{call }substats(hi, rescaled\_array, amean, amin, amax)
357       \textcolor{keyword}{deallocate}(rescaled\_array)
358     \textcolor{keywordflow}{else}
359       \textcolor{keyword}{call }substats(hi, array, amean, amin, amax)
360 \textcolor{keywordflow}{    endif}
361 
362     \textcolor{keywordflow}{if} (is\_root\_pe()) &
363       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, amean, amin, amax, mesg, iounit)
364 \textcolor{keywordflow}{  endif}
365 
366   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
367 
368   hshift = default\_shift
369   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
370   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
371 
372   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
373        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
374     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_2d: haloshift ='},hshift
375     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_2d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
376     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_2d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
377     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_h\_2d '}//trim(mesg))
378 \textcolor{keywordflow}{  endif}
379 
380   bc0 = subchk(array, hi, 0, 0, scaling)
381 
382   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
383     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, mesg, iounit)
384     \textcolor{keywordflow}{return}
385 \textcolor{keywordflow}{  endif}
386 
387   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
388 
389   \textcolor{keywordflow}{if} (do\_corners) \textcolor{keywordflow}{then}
390     bcsw = subchk(array, hi, -hshift, -hshift, scaling)
391     bcse = subchk(array, hi, hshift, -hshift, scaling)
392     bcnw = subchk(array, hi, -hshift, hshift, scaling)
393     bcne = subchk(array, hi, hshift, hshift, scaling)
394 
395     \textcolor{keywordflow}{if} (is\_root\_pe()) &
396       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
397   \textcolor{keywordflow}{else}
398     bcs = subchk(array, hi, 0, -hshift, scaling)
399     bce = subchk(array, hi, hshift, 0, scaling)
400     bcw = subchk(array, hi, -hshift, 0, scaling)
401     bcn = subchk(array, hi, 0, hshift, scaling)
402 
403     \textcolor{keywordflow}{if} (is\_root\_pe()) &
404       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"h-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
405 \textcolor{keywordflow}{  endif}
406 
407   \textcolor{keyword}{contains}
408 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
409     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
410     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
411     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
412     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
413     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
414     \textcolor{keywordtype}{integer} :: i, j, bc
415     subchk = 0
416     \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
417       bc = bitcount(abs(scale*array(i,j)))
418       subchk = subchk + bc
419 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
420     \textcolor{keyword}{call }sum\_across\_pes(subchk)
421     subchk=mod(subchk, bc\_modulus)
422 \textcolor{keyword}{  end function }subchk
423 
424 \textcolor{keyword}{  subroutine }substats(HI, array, aMean, aMin, aMax)
425     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
426     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
427     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
428     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
429     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
430 
431     \textcolor{keywordtype}{integer} :: i, j, n
432 
433     amin = array(hi%isc,hi%jsc)
434     amax = array(hi%isc,hi%jsc)
435     n = 0
436     \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
437       amin = min(amin, array(i,j))
438       amax = max(amax, array(i,j))
439       n = n + 1
440 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
441     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec))
442     \textcolor{keyword}{call }sum\_across\_pes(n)
443     \textcolor{keyword}{call }min\_across\_pes(amin)
444     \textcolor{keyword}{call }max\_across\_pes(amax)
445     amean = amean / \textcolor{keywordtype}{real}(n)
446 \textcolor{keyword}{  end subroutine }substats
447 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a20f9718e4e53fb5584f8b1dc51dacf20}\label{namespacemom__checksums_a20f9718e4e53fb5584f8b1dc51dacf20}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+h\+\_\+3d@{chksum\+\_\+h\+\_\+3d}}
\index{chksum\+\_\+h\+\_\+3d@{chksum\+\_\+h\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+h\+\_\+3d()}{chksum\_h\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+h\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isd\+:,hi\+\_\+m\%jsd\+:,\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 3d array staggered at tracer points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 1204 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1204   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{ !< A horizontal index type}
1205   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isd:,HI\_m%jsd:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
1206   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
1207   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
1208   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
1209   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
1210   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
1211 
1212   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}
1213   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array
1214   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
1215   \textcolor{keywordtype}{real} :: scaling
1216   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
1217   \textcolor{keywordtype}{integer} :: i, j, k
1218   \textcolor{keywordtype}{real} :: amean, amin, amax
1219   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
1220   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
1221   \textcolor{keywordtype}{logical} :: do\_corners
1222   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
1223 
1224   \textcolor{comment}{! Rotate array to the input grid}
1225   turns = hi\_m%turns
1226   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
1227     \textcolor{keyword}{allocate}(hi)
1228     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
1229     \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%jsd:hi%jed, \textcolor{keyword}{size}(array\_m, 3)))
1230     \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1231   \textcolor{keywordflow}{else}
1232     hi => hi\_m
1233     array => array\_m
1234 \textcolor{keywordflow}{  endif}
1235 
1236   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
1237     \textcolor{keywordflow}{if} (is\_nan(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))) &
1238       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
1239 \textcolor{comment}{!   if (is\_NaN(array)) &}
1240 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
1241 \textcolor{keywordflow}{  endif}
1242 
1243   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
1244   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
1245 
1246   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
1247     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
1248       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
1249                                lbound(array,2):ubound(array,2), &
1250                                lbound(array,3):ubound(array,3)) )
1251       rescaled\_array(:,:,:) = 0.0
1252       \textcolor{keywordflow}{do} k=1,\textcolor{keyword}{size}(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1253         rescaled\_array(i,j,k) = scale*array(i,j,k)
1254 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1255 
1256       \textcolor{keyword}{call }substats(hi, rescaled\_array, amean, amin, amax)
1257       \textcolor{keyword}{deallocate}(rescaled\_array)
1258     \textcolor{keywordflow}{else}
1259       \textcolor{keyword}{call }substats(hi, array, amean, amin, amax)
1260 \textcolor{keywordflow}{    endif}
1261 
1262     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1263       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, amean, amin, amax, mesg, iounit)
1264 \textcolor{keywordflow}{  endif}
1265 
1266   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
1267 
1268   hshift = default\_shift
1269   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1270   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
1271 
1272   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
1273        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
1274     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: haloshift ='},hshift
1275     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
1276     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
1277     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_h\_3d '}//trim(mesg))
1278 \textcolor{keywordflow}{  endif}
1279 
1280   bc0 = subchk(array, hi, 0, 0, scaling)
1281 
1282   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
1283     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, mesg, iounit)
1284     \textcolor{keywordflow}{return}
1285 \textcolor{keywordflow}{  endif}
1286 
1287   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
1288 
1289   \textcolor{keywordflow}{if} (do\_corners) \textcolor{keywordflow}{then}
1290     bcsw = subchk(array, hi, -hshift, -hshift, scaling)
1291     bcse = subchk(array, hi, hshift, -hshift, scaling)
1292     bcnw = subchk(array, hi, -hshift, hshift, scaling)
1293     bcne = subchk(array, hi, hshift, hshift, scaling)
1294 
1295     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1296       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
1297   \textcolor{keywordflow}{else}
1298     bcs = subchk(array, hi, 0, -hshift, scaling)
1299     bce = subchk(array, hi, hshift, 0, scaling)
1300     bcw = subchk(array, hi, -hshift, 0, scaling)
1301     bcn = subchk(array, hi, 0, hshift, scaling)
1302 
1303     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1304       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"h-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
1305 \textcolor{keywordflow}{  endif}
1306 
1307   \textcolor{keyword}{contains}
1308 
1309 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
1310     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1311     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1312     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
1313     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
1314     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
1315     \textcolor{keywordtype}{integer} :: i, j, k, bc
1316     subchk = 0
1317     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj ; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
1318       bc = bitcount(abs(scale*array(i,j,k)))
1319       subchk = subchk + bc
1320 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1321     \textcolor{keyword}{call }sum\_across\_pes(subchk)
1322     subchk=mod(subchk, bc\_modulus)
1323 \textcolor{keyword}{  end function }subchk
1324 
1325 \textcolor{keyword}{  subroutine }substats(HI, array, aMean, aMin, aMax)
1326     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1327     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1328     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !<  Array mean}
1329     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
1330     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
1331 
1332     \textcolor{keywordtype}{integer} :: i, j, k, n
1333 
1334     amin = array(hi%isc,hi%jsc,1)
1335     amax = array(hi%isc,hi%jsc,1)
1336     n = 0
1337     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1338       amin = min(amin, array(i,j,k))
1339       amax = max(amax, array(i,j,k))
1340       n = n + 1
1341 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1342     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))
1343     \textcolor{keyword}{call }sum\_across\_pes(n)
1344     \textcolor{keyword}{call }min\_across\_pes(amin)
1345     \textcolor{keyword}{call }max\_across\_pes(amax)
1346     amean = amean / \textcolor{keywordtype}{real}(n)
1347 \textcolor{keyword}{  end subroutine }substats
1348 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_ac9d0ad082dc1fcf821f830f3274ea78b}\label{namespacemom__checksums_ac9d0ad082dc1fcf821f830f3274ea78b}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+pair\+\_\+b\+\_\+2d@{chksum\+\_\+pair\+\_\+b\+\_\+2d}}
\index{chksum\+\_\+pair\+\_\+b\+\_\+2d@{chksum\+\_\+pair\+\_\+b\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+pair\+\_\+b\+\_\+2d()}{chksum\_pair\_b\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+pair\+\_\+b\+\_\+2d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, dimension(hi\%isd\+:,hi\%jsd\+:), intent(in), target}]{arrayA,  }\item[{real, dimension(hi\%isd\+:,hi\%jsd\+:), intent(in), target}]{arrayB,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{HI,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums on a pair of 2d arrays staggered at q-\/points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & Identifying messages\\
\hline
\mbox{\tt in}  & {\em hi} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em arraya} & The first array to be checksummed\\
\hline
\mbox{\tt in}  & {\em arrayb} & The second array to be checksummed\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging\\
\hline
\mbox{\tt in}  & {\em scalar\+\_\+pair} & If true, then the arrays describe a scalar, rather than vector \\
\hline
\end{DoxyParams}


Definition at line 453 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
453   \textcolor{keywordtype}{character(len=*)},                 \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Identifying messages}
454   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{     !< A horizontal index type}
455   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arraya\textcolor{comment}{ !< The first array to be checksummed}
456   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayb\textcolor{comment}{ !< The second array to be checksummed}
457   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
458 \textcolor{comment}{                                                            !! symmetric computational domain.}
459   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
460   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
461   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
462   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
463   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}
464 \textcolor{comment}{                                                              !! a scalar, rather than vector}
465 
466   \textcolor{keywordtype}{logical} :: sym
467   \textcolor{keywordtype}{logical} :: vector\_pair
468   \textcolor{keywordtype}{integer} :: turns
469   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi\_in
470   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: arraya\_in, arrayb\_in
471 
472   vector\_pair = .true.
473   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair
474 
475   turns = hi%turns
476   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
477     \textcolor{comment}{! Rotate field back to the input grid}
478     \textcolor{keyword}{allocate}(hi\_in)
479     \textcolor{keyword}{call }rotate\_hor\_index(hi, -turns, hi\_in)
480     \textcolor{keyword}{allocate}(arraya\_in(hi\_in%IsdB:hi\_in%IedB, hi\_in%JsdB:hi\_in%JedB))
481     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in%IsdB:hi\_in%IedB, hi\_in%JsdB:hi\_in%JedB))
482 
483     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}
484       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
485     \textcolor{keywordflow}{else}
486       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
487 \textcolor{keywordflow}{    endif}
488   \textcolor{keywordflow}{else}
489     hi\_in => hi
490     arraya\_in => arraya
491     arrayb\_in => arrayb
492 \textcolor{keywordflow}{  endif}
493 
494   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
495 
496   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}
497     \textcolor{keyword}{call }chksum\_b\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, symmetric=sym, &
498                      omit\_corners=omit\_corners, scale=scale, logunit=logunit)
499     \textcolor{keyword}{call }chksum\_b\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, symmetric=sym, &
500                      omit\_corners=omit\_corners, scale=scale, logunit=logunit)
501   \textcolor{keywordflow}{else}
502     \textcolor{keyword}{call }chksum\_b\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, symmetric=sym, scale=scale, &
503                      logunit=logunit)
504     \textcolor{keyword}{call }chksum\_b\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, symmetric=sym, scale=scale, &
505                      logunit=logunit)
506 \textcolor{keywordflow}{  endif}
507 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_af9f0a6d824a0203c4ce861086cfc6435}\label{namespacemom__checksums_af9f0a6d824a0203c4ce861086cfc6435}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+pair\+\_\+b\+\_\+3d@{chksum\+\_\+pair\+\_\+b\+\_\+3d}}
\index{chksum\+\_\+pair\+\_\+b\+\_\+3d@{chksum\+\_\+pair\+\_\+b\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+pair\+\_\+b\+\_\+3d()}{chksum\_pair\_b\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+pair\+\_\+b\+\_\+3d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, dimension(hi\%isdb\+:,hi\%jsdb\+:, \+:), intent(in), target}]{arrayA,  }\item[{real, dimension(hi\%isdb\+:,hi\%jsdb\+:, \+:), intent(in), target}]{arrayB,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{HI,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums on a pair of 3d arrays staggered at q-\/points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & Identifying messages\\
\hline
\mbox{\tt in}  & {\em hi} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em arraya} & The first array to be checksummed\\
\hline
\mbox{\tt in}  & {\em arrayb} & The second array to be checksummed\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging\\
\hline
\mbox{\tt in}  & {\em scalar\+\_\+pair} & If true, then the arrays describe a scalar, rather than vector \\
\hline
\end{DoxyParams}


Definition at line 513 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
513   \textcolor{keywordtype}{character(len=*)},                    \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< Identifying messages}
514   \textcolor{keywordtype}{type}(hor\_index\_type),      \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{     !< A horizontal index type}
515   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%JsdB:, :)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arraya\textcolor{comment}{ !< The first array to be checksummed}
516   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%JsdB:, :)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayb\textcolor{comment}{ !< The second array to be checksummed}
517   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
518   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
519 \textcolor{comment}{                                                               !! symmetric computational domain.}
520   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal
       shifts}
521   \textcolor{keywordtype}{real},                      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
522   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
523   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}
524 \textcolor{comment}{                                                              !! a scalar, rather than vector}
525 
526   \textcolor{keywordtype}{logical} :: sym
527   \textcolor{keywordtype}{logical} :: vector\_pair
528   \textcolor{keywordtype}{integer} :: turns
529   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi\_in
530   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: arraya\_in, arrayb\_in
531 
532   vector\_pair = .true.
533   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair
534 
535   turns = hi%turns
536   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
537     \textcolor{comment}{! Rotate field back to the input grid}
538     \textcolor{keyword}{allocate}(hi\_in)
539     \textcolor{keyword}{call }rotate\_hor\_index(hi, -turns, hi\_in)
540     \textcolor{keyword}{allocate}(arraya\_in(hi\_in%IsdB:hi\_in%IedB, hi\_in%JsdB:hi\_in%JedB, \textcolor{keyword}{size}(arraya, 3)))
541     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in%IsdB:hi\_in%IedB, hi\_in%JsdB:hi\_in%JedB, \textcolor{keyword}{size}(arrayb, 3)))
542 
543     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}
544       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
545     \textcolor{keywordflow}{else}
546       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
547 \textcolor{keywordflow}{    endif}
548   \textcolor{keywordflow}{else}
549     hi\_in => hi
550     arraya\_in => arraya
551     arrayb\_in => arrayb
552 \textcolor{keywordflow}{  endif}
553 
554   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}
555     \textcolor{keyword}{call }chksum\_b\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, symmetric, &
556                      omit\_corners, scale=scale, logunit=logunit)
557     \textcolor{keyword}{call }chksum\_b\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, symmetric, &
558                      omit\_corners, scale=scale, logunit=logunit)
559   \textcolor{keywordflow}{else}
560     \textcolor{keyword}{call }chksum\_b\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, symmetric=symmetric, scale=scale, &
561                      logunit=logunit)
562     \textcolor{keyword}{call }chksum\_b\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, symmetric=symmetric, scale=scale, &
563                      logunit=logunit)
564 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_adf321aa5891602668005529a30f28225}\label{namespacemom__checksums_adf321aa5891602668005529a30f28225}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+pair\+\_\+h\+\_\+2d@{chksum\+\_\+pair\+\_\+h\+\_\+2d}}
\index{chksum\+\_\+pair\+\_\+h\+\_\+2d@{chksum\+\_\+pair\+\_\+h\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+pair\+\_\+h\+\_\+2d()}{chksum\_pair\_h\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+pair\+\_\+h\+\_\+2d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, dimension(hi\%isd\+:,hi\%jsd\+:), intent(in), target}]{arrayA,  }\item[{real, dimension(hi\%isd\+:,hi\%jsd\+:), intent(in), target}]{arrayB,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{HI,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums on a pair of 2d arrays staggered at tracer points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & Identifying messages\\
\hline
\mbox{\tt in}  & {\em hi} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em arraya} & The first array to be checksummed\\
\hline
\mbox{\tt in}  & {\em arrayb} & The second array to be checksummed\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging\\
\hline
\mbox{\tt in}  & {\em scalar\+\_\+pair} & If true, then the arrays describe a scalar, rather than vector \\
\hline
\end{DoxyParams}


Definition at line 202 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
202   \textcolor{keywordtype}{character(len=*)},                 \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< Identifying messages}
203   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{     !< A horizontal index type}
204   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arraya\textcolor{comment}{ !< The first array to be checksummed}
205   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayb\textcolor{comment}{ !< The second array to be checksummed}
206   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
207   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
208   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
209   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
210   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}
211 \textcolor{comment}{                                                              !! a scalar, rather than vector}
212   \textcolor{keywordtype}{logical} :: vector\_pair
213   \textcolor{keywordtype}{integer} :: turns
214   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi\_in
215   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: arraya\_in, arrayb\_in
216 
217   vector\_pair = .true.
218   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair
219 
220   turns = hi%turns
221   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
222     \textcolor{comment}{! Rotate field back to the input grid}
223     \textcolor{keyword}{allocate}(hi\_in)
224     \textcolor{keyword}{call }rotate\_hor\_index(hi, -turns, hi\_in)
225     \textcolor{keyword}{allocate}(arraya\_in(hi\_in%isd:hi\_in%ied, hi\_in%jsd:hi\_in%jed))
226     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in%isd:hi\_in%ied, hi\_in%jsd:hi\_in%jed))
227 
228     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}
229       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
230     \textcolor{keywordflow}{else}
231       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
232 \textcolor{keywordflow}{    endif}
233   \textcolor{keywordflow}{else}
234     hi\_in => hi
235     arraya\_in => arraya
236     arrayb\_in => arrayb
237 \textcolor{keywordflow}{  endif}
238 
239   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}
240     \textcolor{keyword}{call }chksum\_h\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, omit\_corners, &
241                      scale=scale, logunit=logunit)
242     \textcolor{keyword}{call }chksum\_h\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, omit\_corners, &
243                      scale=scale, logunit=logunit)
244   \textcolor{keywordflow}{else}
245     \textcolor{keyword}{call }chksum\_h\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, scale=scale, logunit=logunit)
246     \textcolor{keyword}{call }chksum\_h\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, scale=scale, logunit=logunit)
247 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a5a74e7e80a1bb2b733459c5d7a5e3ea8}\label{namespacemom__checksums_a5a74e7e80a1bb2b733459c5d7a5e3ea8}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+pair\+\_\+h\+\_\+3d@{chksum\+\_\+pair\+\_\+h\+\_\+3d}}
\index{chksum\+\_\+pair\+\_\+h\+\_\+3d@{chksum\+\_\+pair\+\_\+h\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+pair\+\_\+h\+\_\+3d()}{chksum\_pair\_h\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+pair\+\_\+h\+\_\+3d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, dimension(hi\%isd\+:,hi\%jsd\+:, \+:), intent(in), target}]{arrayA,  }\item[{real, dimension(hi\%isd\+:,hi\%jsd\+:, \+:), intent(in), target}]{arrayB,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{HI,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums on a pair of 3d arrays staggered at tracer points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & Identifying messages\\
\hline
\mbox{\tt in}  & {\em hi} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em arraya} & The first array to be checksummed\\
\hline
\mbox{\tt in}  & {\em arrayb} & The second array to be checksummed\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging\\
\hline
\mbox{\tt in}  & {\em scalar\+\_\+pair} & If true, then the arrays describe a scalar, rather than vector \\
\hline
\end{DoxyParams}


Definition at line 253 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
253   \textcolor{keywordtype}{character(len=*)},                    \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< Identifying messages}
254   \textcolor{keywordtype}{type}(hor\_index\_type),      \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{   !< A horizontal index type}
255   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:, :)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arraya\textcolor{comment}{ !< The first array to be checksummed}
256   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:, :)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayb\textcolor{comment}{ !< The second array to be checksummed}
257   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
258   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal
       shifts}
259   \textcolor{keywordtype}{real},                      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
260   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
261 
262   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}
263 \textcolor{comment}{                                                              !! a scalar, rather than vector}
264   \textcolor{keywordtype}{logical} :: vector\_pair
265   \textcolor{keywordtype}{integer} :: turns
266   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi\_in
267   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: arraya\_in, arrayb\_in
268 
269   vector\_pair = .true.
270   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair
271 
272   turns = hi%turns
273   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
274     \textcolor{comment}{! Rotate field back to the input grid}
275     \textcolor{keyword}{allocate}(hi\_in)
276     \textcolor{keyword}{call }rotate\_hor\_index(hi, -turns, hi\_in)
277     \textcolor{keyword}{allocate}(arraya\_in(hi\_in%isd:hi\_in%ied, hi\_in%jsd:hi\_in%jed, \textcolor{keyword}{size}(arraya, 3)))
278     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in%isd:hi\_in%ied, hi\_in%jsd:hi\_in%jed, \textcolor{keyword}{size}(arrayb, 3)))
279 
280     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}
281       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
282     \textcolor{keywordflow}{else}
283       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -turns, arraya\_in, arrayb\_in)
284 \textcolor{keywordflow}{    endif}
285   \textcolor{keywordflow}{else}
286     hi\_in => hi
287     arraya\_in => arraya
288     arrayb\_in => arrayb
289 \textcolor{keywordflow}{  endif}
290 
291   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}
292     \textcolor{keyword}{call }chksum\_h\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, omit\_corners, &
293                      scale=scale, logunit=logunit)
294     \textcolor{keyword}{call }chksum\_h\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, omit\_corners, &
295                      scale=scale, logunit=logunit)
296   \textcolor{keywordflow}{else}
297     \textcolor{keyword}{call }chksum\_h\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, scale=scale, logunit=logunit)
298     \textcolor{keyword}{call }chksum\_h\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, scale=scale, logunit=logunit)
299 \textcolor{keywordflow}{  endif}
300 
301   \textcolor{comment}{! NOTE: automatic deallocation of array[AB]\_in}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a490f31f536667d60912db5e96218563c}\label{namespacemom__checksums_a490f31f536667d60912db5e96218563c}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+u\+\_\+2d@{chksum\+\_\+u\+\_\+2d}}
\index{chksum\+\_\+u\+\_\+2d@{chksum\+\_\+u\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+u\+\_\+2d()}{chksum\_u\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+u\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isdb\+:,hi\+\_\+m\%jsd\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 2d array staggered at C-\/grid u points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 847 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
847   \textcolor{keywordtype}{type}(hor\_index\_type),  \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{     !< A horizontal index type}
848   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%IsdB:,HI\_m%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
849   \textcolor{keywordtype}{character(len=*)},                \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
850   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
851   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
852 \textcolor{comment}{                                                           !! symmetric computational domain.}
853   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
854   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
855   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
856 
857   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:)           \textcolor{comment}{! Field array on the input grid}
858   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: rescaled\_array
859   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
860   \textcolor{keywordtype}{real} :: scaling
861   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
862   \textcolor{keywordtype}{integer} :: i, j, is
863   \textcolor{keywordtype}{real} :: amean, amin, amax
864   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
865   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
866   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats
867   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
868 
869   \textcolor{comment}{! Rotate array to the input grid}
870   turns = hi\_m%turns
871   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
872     \textcolor{keyword}{allocate}(hi)
873     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
874     \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}
875       \textcolor{comment}{! Arrays originating from v-points must be handled by vchksum}
876       \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%JsdB:hi%JedB))
877       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
878       \textcolor{keyword}{call }vchksum(array, mesg, hi, haloshift, symmetric, omit\_corners, scale, logunit)
879       \textcolor{keywordflow}{return}
880     \textcolor{keywordflow}{else}
881       \textcolor{keyword}{allocate}(array(hi%IsdB:hi%IedB, hi%jsd:hi%jed))
882       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
883 \textcolor{keywordflow}{    endif}
884   \textcolor{keywordflow}{else}
885     hi => hi\_m
886     array => array\_m
887 \textcolor{keywordflow}{  endif}
888 
889   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
890     \textcolor{keywordflow}{if} (is\_nan(array(hi%IscB:hi%IecB,hi%jsc:hi%jec))) &
891       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
892 \textcolor{comment}{!   if (is\_NaN(array)) &}
893 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
894 \textcolor{keywordflow}{  endif}
895 
896   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
897   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
898   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric
899   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}
900 
901   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
902     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
903       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
904                                lbound(array,2):ubound(array,2)) )
905       rescaled\_array(:,:) = 0.0
906       is = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) is = hi%isc-1
907       \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=is,hi%IecB
908         rescaled\_array(i,j) = scale*array(i,j)
909 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
910       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)
911       \textcolor{keyword}{deallocate}(rescaled\_array)
912     \textcolor{keywordflow}{else}
913       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)
914 \textcolor{keywordflow}{    endif}
915 
916     \textcolor{keywordflow}{if} (is\_root\_pe()) &
917       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-point:"}, amean, amin, amax, mesg, iounit)
918 \textcolor{keywordflow}{  endif}
919 
920   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
921 
922   hshift = default\_shift
923   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
924   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%iedB-hi%iecB
925 
926   \textcolor{keywordflow}{if} ( hi%iscB-hshift<hi%isdB .or. hi%iecB+hshift>hi%iedB .or. &
927        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
928     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_2d: haloshift ='},hshift
929     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_2d: isd,isc,iec,ied='},hi%isdB,hi%iscB,hi%iecB,hi%iedB
930     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_2d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
931     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_u\_2d '}//trim(mesg))
932 \textcolor{keywordflow}{  endif}
933 
934   bc0 = subchk(array, hi, 0, 0, scaling)
935 
936   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
937 
938   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}
939     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-point:"}, bc0, mesg, iounit)
940     \textcolor{keywordflow}{return}
941 \textcolor{keywordflow}{  endif}
942 
943   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
944 
945   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
946     bcw = subchk(array, hi, -hshift-1, 0, scaling)
947     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg\_w(\textcolor{stringliteral}{"u-point:"}, bc0, bcw, mesg, iounit)
948   \textcolor{keywordflow}{elseif} (do\_corners) \textcolor{keywordflow}{then}
949     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
950       bcsw = subchk(array, hi, -hshift-1, -hshift, scaling)
951       bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
952     \textcolor{keywordflow}{else}
953       bcsw = subchk(array, hi, -hshift, -hshift, scaling)
954       bcnw = subchk(array, hi, -hshift, hshift, scaling)
955 \textcolor{keywordflow}{    endif}
956     bcse = subchk(array, hi, hshift, -hshift, scaling)
957     bcne = subchk(array, hi, hshift, hshift, scaling)
958 
959     \textcolor{keywordflow}{if} (is\_root\_pe()) &
960       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
961   \textcolor{keywordflow}{else}
962     bcs = subchk(array, hi, 0, -hshift, scaling)
963     bce = subchk(array, hi, hshift, 0, scaling)
964     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
965       bcw = subchk(array, hi, -hshift-1, 0, scaling)
966     \textcolor{keywordflow}{else}
967       bcw = subchk(array, hi, -hshift, 0, scaling)
968 \textcolor{keywordflow}{    endif}
969     bcn = subchk(array, hi, 0, hshift, scaling)
970 
971     \textcolor{keywordflow}{if} (is\_root\_pe()) &
972       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"u-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
973 \textcolor{keywordflow}{  endif}
974 
975   \textcolor{keyword}{contains}
976 
977 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
978     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
979     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%jsd:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
980     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
981     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
982     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
983     \textcolor{keywordtype}{integer} :: i, j, bc
984     subchk = 0
985     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
986     \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
987       bc = bitcount(abs(scale*array(i,j)))
988       subchk = subchk + bc
989 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
990     \textcolor{keyword}{call }sum\_across\_pes(subchk)
991     subchk=mod(subchk, bc\_modulus)
992 \textcolor{keyword}{  end function }subchk
993 
994 \textcolor{keyword}{  subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)
995     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
996     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%jsd:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
997     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}
998 \textcolor{comment}{                                              !! full symmetric computational domain.}
999     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
1000     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
1001     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
1002 
1003     \textcolor{keywordtype}{integer} :: i, j, n, isb
1004 
1005     isb = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) isb = hi%isc-1
1006 
1007     amin = array(hi%isc,hi%jsc) ; amax = amin
1008     \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=isb,hi%IecB
1009       amin = min(amin, array(i,j))
1010       amax = max(amax, array(i,j))
1011 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1012     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1013     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec))
1014     n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc)
1015     \textcolor{keyword}{call }sum\_across\_pes(n)
1016     \textcolor{keyword}{call }min\_across\_pes(amin)
1017     \textcolor{keyword}{call }max\_across\_pes(amax)
1018     amean = amean / \textcolor{keywordtype}{real}(n)
1019 \textcolor{keyword}{  end subroutine }substats
1020 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a5127df73a7ac181d76b8c9fc6eb55c55}\label{namespacemom__checksums_a5127df73a7ac181d76b8c9fc6eb55c55}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+u\+\_\+3d@{chksum\+\_\+u\+\_\+3d}}
\index{chksum\+\_\+u\+\_\+3d@{chksum\+\_\+u\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+u\+\_\+3d()}{chksum\_u\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+u\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isdb\+:,hi\+\_\+m\%jsd\+:,\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 3d array staggered at C-\/grid u points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 1526 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1526   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{ !< A horizontal index type}
1527   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isdB:,HI\_m%Jsd:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
1528   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
1529   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
1530   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
1531 \textcolor{comment}{                                                             !! symmetric computational domain.}
1532   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
1533   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
1534   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
1535 
1536   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}
1537   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array
1538   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
1539   \textcolor{keywordtype}{real} :: scaling
1540   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
1541   \textcolor{keywordtype}{integer} :: i, j, k, is
1542   \textcolor{keywordtype}{real} :: amean, amin, amax
1543   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
1544   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
1545   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats
1546   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
1547 
1548   \textcolor{comment}{! Rotate array to the input grid}
1549   turns = hi\_m%turns
1550   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
1551     \textcolor{keyword}{allocate}(hi)
1552     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
1553     \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}
1554       \textcolor{comment}{! Arrays originating from v-points must be handled by vchksum}
1555       \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%JsdB:hi%JedB, \textcolor{keyword}{size}(array\_m, 3)))
1556       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1557       \textcolor{keyword}{call }vchksum(array, mesg, hi, haloshift, symmetric, omit\_corners, scale, logunit)
1558       \textcolor{keywordflow}{return}
1559     \textcolor{keywordflow}{else}
1560       \textcolor{keyword}{allocate}(array(hi%IsdB:hi%IedB, hi%jsd:hi%jed, \textcolor{keyword}{size}(array\_m, 3)))
1561       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1562 \textcolor{keywordflow}{    endif}
1563   \textcolor{keywordflow}{else}
1564     hi => hi\_m
1565     array => array\_m
1566 \textcolor{keywordflow}{  endif}
1567 
1568   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
1569     \textcolor{keywordflow}{if} (is\_nan(array(hi%IscB:hi%IecB,hi%jsc:hi%jec,:))) &
1570       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
1571 \textcolor{comment}{!   if (is\_NaN(array)) &}
1572 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
1573 \textcolor{keywordflow}{  endif}
1574 
1575   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
1576   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
1577   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric
1578   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}
1579 
1580   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
1581     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
1582       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
1583                                lbound(array,2):ubound(array,2), &
1584                                lbound(array,3):ubound(array,3)) )
1585       rescaled\_array(:,:,:) = 0.0
1586       is = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) is = hi%isc-1
1587       \textcolor{keywordflow}{do} k=1,\textcolor{keyword}{size}(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=is,hi%IecB
1588         rescaled\_array(i,j,k) = scale*array(i,j,k)
1589 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1590       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)
1591       \textcolor{keyword}{deallocate}(rescaled\_array)
1592     \textcolor{keywordflow}{else}
1593       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)
1594 \textcolor{keywordflow}{    endif}
1595     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1596       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-point:"}, amean, amin, amax, mesg, iounit)
1597 \textcolor{keywordflow}{  endif}
1598 
1599   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
1600 
1601   hshift = default\_shift
1602   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1603   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
1604 
1605   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
1606        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
1607     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_3d: haloshift ='},hshift
1608     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_3d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
1609     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_3d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
1610     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_u\_3d '}//trim(mesg))
1611 \textcolor{keywordflow}{  endif}
1612 
1613   bc0 = subchk(array, hi, 0, 0, scaling)
1614 
1615   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
1616 
1617   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}
1618     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-point:"}, bc0, mesg, iounit)
1619     \textcolor{keywordflow}{return}
1620 \textcolor{keywordflow}{  endif}
1621 
1622   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
1623 
1624   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
1625     bcw = subchk(array, hi, -hshift-1, 0, scaling)
1626     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg\_w(\textcolor{stringliteral}{"u-point:"}, bc0, bcw, mesg, iounit)
1627   \textcolor{keywordflow}{elseif} (do\_corners) \textcolor{keywordflow}{then}
1628     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1629       bcsw = subchk(array, hi, -hshift-1, -hshift, scaling)
1630       bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
1631     \textcolor{keywordflow}{else}
1632       bcsw = subchk(array, hi, -hshift, -hshift, scaling)
1633       bcnw = subchk(array, hi, -hshift, hshift, scaling)
1634 \textcolor{keywordflow}{    endif}
1635     bcse = subchk(array, hi, hshift, -hshift, scaling)
1636     bcne = subchk(array, hi, hshift, hshift, scaling)
1637 
1638     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1639       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
1640   \textcolor{keywordflow}{else}
1641     bcs = subchk(array, hi, 0, -hshift, scaling)
1642     bce = subchk(array, hi, hshift, 0, scaling)
1643     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1644       bcw = subchk(array, hi, -hshift-1, 0, scaling)
1645     \textcolor{keywordflow}{else}
1646       bcw = subchk(array, hi, -hshift, 0, scaling)
1647 \textcolor{keywordflow}{    endif}
1648     bcn = subchk(array, hi, 0, hshift, scaling)
1649 
1650     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1651       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"u-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
1652 \textcolor{keywordflow}{  endif}
1653 
1654   \textcolor{keyword}{contains}
1655 
1656 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
1657     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1658     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1659     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
1660     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
1661     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
1662     \textcolor{keywordtype}{integer} :: i, j, k, bc
1663     subchk = 0
1664     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1665     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj ; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
1666       bc = bitcount(abs(scale*array(i,j,k)))
1667       subchk = subchk + bc
1668 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1669     \textcolor{keyword}{call }sum\_across\_pes(subchk)
1670     subchk=mod(subchk, bc\_modulus)
1671 \textcolor{keyword}{  end function }subchk
1672 
1673 \textcolor{keyword}{  subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)
1674     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1675     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1676     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}
1677 \textcolor{comment}{                                              !! full symmetric computational domain.}
1678     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
1679     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
1680     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
1681 
1682     \textcolor{keywordtype}{integer} :: i, j, k, n, isb
1683 
1684     isb = hi%isc ; \textcolor{keywordflow}{if} (sym\_stats) isb = hi%isc-1
1685 
1686     amin = array(hi%isc,hi%jsc,1) ; amax = amin
1687     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=isb,hi%IecB
1688       amin = min(amin, array(i,j,k))
1689       amax = max(amax, array(i,j,k))
1690 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1691     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1692     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))
1693     n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc) * \textcolor{keyword}{size}(array,3)
1694     \textcolor{keyword}{call }sum\_across\_pes(n)
1695     \textcolor{keyword}{call }min\_across\_pes(amin)
1696     \textcolor{keyword}{call }max\_across\_pes(amax)
1697     amean = amean / \textcolor{keywordtype}{real}(n)
1698 \textcolor{keyword}{  end subroutine }substats
1699 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a44f58e610aea8ed395c0fed97f020503}\label{namespacemom__checksums_a44f58e610aea8ed395c0fed97f020503}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+uv\+\_\+2d@{chksum\+\_\+uv\+\_\+2d}}
\index{chksum\+\_\+uv\+\_\+2d@{chksum\+\_\+uv\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+uv\+\_\+2d()}{chksum\_uv\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+uv\+\_\+2d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, dimension(hi\%isdb\+:,hi\%jsd\+:), intent(in), target}]{arrayU,  }\item[{real, dimension(hi\%isd\+:,hi\%jsdb\+:), intent(in), target}]{arrayV,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{HI,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a pair of 2d velocity arrays staggered at C-\/grid locations. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & Identifying messages\\
\hline
\mbox{\tt in}  & {\em hi} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em arrayu} & The u-\/component array to be checksummed\\
\hline
\mbox{\tt in}  & {\em arrayv} & The v-\/component array to be checksummed\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for these arrays.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging\\
\hline
\mbox{\tt in}  & {\em scalar\+\_\+pair} & If true, then the arrays describe a a scalar, rather than vector \\
\hline
\end{DoxyParams}


Definition at line 737 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
737   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Identifying messages}
738   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{     !< A horizontal index type}
739   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayu\textcolor{comment}{ !< The u-component array to be
       checksummed}
740   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayv\textcolor{comment}{ !< The v-component array to be
       checksummed}
741   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
742   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
743 \textcolor{comment}{                                                             !! symmetric computational domain.}
744   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
745   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for these arrays.}
746   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
747   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe a}
748 \textcolor{comment}{                                                               !! a scalar, rather than vector}
749   \textcolor{keywordtype}{logical} :: vector\_pair
750   \textcolor{keywordtype}{integer} :: turns
751   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi\_in
752   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: arrayu\_in, arrayv\_in
753 
754   vector\_pair = .true.
755   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair
756 
757   turns = hi%turns
758   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
759     \textcolor{comment}{! Rotate field back to the input grid}
760     \textcolor{keyword}{allocate}(hi\_in)
761     \textcolor{keyword}{call }rotate\_hor\_index(hi, -turns, hi\_in)
762     \textcolor{keyword}{allocate}(arrayu\_in(hi\_in%IsdB:hi\_in%IedB, hi\_in%jsd:hi\_in%jed))
763     \textcolor{keyword}{allocate}(arrayv\_in(hi\_in%isd:hi\_in%ied, hi\_in%JsdB:hi\_in%JedB))
764 
765     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}
766       \textcolor{keyword}{call }rotate\_vector(arrayu, arrayv, -turns, arrayu\_in, arrayv\_in)
767     \textcolor{keywordflow}{else}
768       \textcolor{keyword}{call }rotate\_array\_pair(arrayu, arrayv, -turns, arrayu\_in, arrayv\_in)
769 \textcolor{keywordflow}{    endif}
770   \textcolor{keywordflow}{else}
771     hi\_in => hi
772     arrayu\_in => arrayu
773     arrayv\_in => arrayv
774 \textcolor{keywordflow}{  endif}
775 
776   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}
777     \textcolor{keyword}{call }chksum\_u\_2d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, haloshift, symmetric, &
778                      omit\_corners, scale=scale, logunit=logunit)
779     \textcolor{keyword}{call }chksum\_v\_2d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, haloshift, symmetric, &
780                      omit\_corners, scale=scale, logunit=logunit)
781   \textcolor{keywordflow}{else}
782     \textcolor{keyword}{call }chksum\_u\_2d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, symmetric=symmetric, &
783                      scale=scale, logunit=logunit)
784     \textcolor{keyword}{call }chksum\_v\_2d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, symmetric=symmetric, &
785                      scale=scale, logunit=logunit)
786 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a316b025360732d72fc38a021b4fe0f7d}\label{namespacemom__checksums_a316b025360732d72fc38a021b4fe0f7d}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+uv\+\_\+3d@{chksum\+\_\+uv\+\_\+3d}}
\index{chksum\+\_\+uv\+\_\+3d@{chksum\+\_\+uv\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+uv\+\_\+3d()}{chksum\_uv\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+uv\+\_\+3d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, dimension(hi\%isdb\+:,hi\%jsd\+:,\+:), intent(in), target}]{arrayU,  }\item[{real, dimension(hi\%isd\+:,hi\%jsdb\+:,\+:), intent(in), target}]{arrayV,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{HI,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a pair of 3d velocity arrays staggered at C-\/grid locations. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mesg} & Identifying messages\\
\hline
\mbox{\tt in}  & {\em hi} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em arrayu} & The u-\/component array to be checksummed\\
\hline
\mbox{\tt in}  & {\em arrayv} & The v-\/component array to be checksummed\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for these arrays.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging\\
\hline
\mbox{\tt in}  & {\em scalar\+\_\+pair} & If true, then the arrays describe a a scalar, rather than vector \\
\hline
\end{DoxyParams}


Definition at line 792 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
792   \textcolor{keywordtype}{character(len=*)},                    \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Identifying messages}
793   \textcolor{keywordtype}{type}(hor\_index\_type),      \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{     !< A horizontal index type}
794   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:,HI%jsd:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayu\textcolor{comment}{ !< The u-component array to be
       checksummed}
795   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: arrayv\textcolor{comment}{ !< The v-component array to be
       checksummed}
796   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
797   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
798 \textcolor{comment}{                                                               !! symmetric computational domain.}
799   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal
       shifts}
800   \textcolor{keywordtype}{real},                      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for these arrays.}
801   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
802   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe a}
803 \textcolor{comment}{                                                               !! a scalar, rather than vector}
804   \textcolor{keywordtype}{logical} :: vector\_pair
805   \textcolor{keywordtype}{integer} :: turns
806   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi\_in
807   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: arrayu\_in, arrayv\_in
808 
809   vector\_pair = .true.
810   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair
811 
812   turns = hi%turns
813   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
814     \textcolor{comment}{! Rotate field back to the input grid}
815     \textcolor{keyword}{allocate}(hi\_in)
816     \textcolor{keyword}{call }rotate\_hor\_index(hi, -turns, hi\_in)
817     \textcolor{keyword}{allocate}(arrayu\_in(hi\_in%IsdB:hi\_in%IedB, hi\_in%jsd:hi\_in%jed, \textcolor{keyword}{size}(arrayu, 3)))
818     \textcolor{keyword}{allocate}(arrayv\_in(hi\_in%isd:hi\_in%ied, hi\_in%JsdB:hi\_in%JedB, \textcolor{keyword}{size}(arrayv, 3)))
819 
820     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}
821       \textcolor{keyword}{call }rotate\_vector(arrayu, arrayv, -turns, arrayu\_in, arrayv\_in)
822     \textcolor{keywordflow}{else}
823       \textcolor{keyword}{call }rotate\_array\_pair(arrayu, arrayv, -turns, arrayu\_in, arrayv\_in)
824 \textcolor{keywordflow}{    endif}
825   \textcolor{keywordflow}{else}
826     hi\_in => hi
827     arrayu\_in => arrayu
828     arrayv\_in => arrayv
829 \textcolor{keywordflow}{  endif}
830 
831   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}
832     \textcolor{keyword}{call }chksum\_u\_3d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, haloshift, symmetric, &
833                      omit\_corners, scale=scale, logunit=logunit)
834     \textcolor{keyword}{call }chksum\_v\_3d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, haloshift, symmetric, &
835                      omit\_corners, scale=scale, logunit=logunit)
836   \textcolor{keywordflow}{else}
837     \textcolor{keyword}{call }chksum\_u\_3d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, symmetric=symmetric, &
838                      scale=scale, logunit=logunit)
839     \textcolor{keyword}{call }chksum\_v\_3d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, symmetric=symmetric, &
840                      scale=scale, logunit=logunit)
841 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_acc62cfde3303da03f62e86d98c124fc9}\label{namespacemom__checksums_acc62cfde3303da03f62e86d98c124fc9}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+v\+\_\+2d@{chksum\+\_\+v\+\_\+2d}}
\index{chksum\+\_\+v\+\_\+2d@{chksum\+\_\+v\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+v\+\_\+2d()}{chksum\_v\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+v\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isd\+:,hi\+\_\+m\%jsdb\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 2d array staggered at C-\/grid v points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 1026 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1026   \textcolor{keywordtype}{type}(hor\_index\_type),  \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{      !< A horizontal index type}
1027   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isd:,HI\_m%JsdB:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
1028   \textcolor{keywordtype}{character(len=*)},                \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
1029   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
1030   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
1031 \textcolor{comment}{                                                           !! symmetric computational domain.}
1032   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
1033   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
1034   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
1035 
1036   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:)           \textcolor{comment}{! Field array on the input grid}
1037   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: rescaled\_array
1038   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
1039   \textcolor{keywordtype}{real} :: scaling
1040   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
1041   \textcolor{keywordtype}{integer} :: i, j, js
1042   \textcolor{keywordtype}{real} :: amean, amin, amax
1043   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
1044   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
1045   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats
1046   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
1047 
1048   \textcolor{comment}{! Rotate array to the input grid}
1049   turns = hi\_m%turns
1050   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
1051     \textcolor{keyword}{allocate}(hi)
1052     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
1053     \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}
1054       \textcolor{comment}{! Arrays originating from u-points must be handled by uchksum}
1055       \textcolor{keyword}{allocate}(array(hi%IsdB:hi%IedB, hi%jsd:hi%jed))
1056       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1057       \textcolor{keyword}{call }uchksum(array, mesg, hi, haloshift, symmetric, omit\_corners, scale, logunit)
1058       \textcolor{keywordflow}{return}
1059     \textcolor{keywordflow}{else}
1060       \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%JsdB:hi%JedB))
1061       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1062 \textcolor{keywordflow}{    endif}
1063   \textcolor{keywordflow}{else}
1064     hi => hi\_m
1065     array => array\_m
1066 \textcolor{keywordflow}{  endif}
1067 
1068   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
1069     \textcolor{keywordflow}{if} (is\_nan(array(hi%isc:hi%iec,hi%JscB:hi%JecB))) &
1070       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
1071 \textcolor{comment}{!   if (is\_NaN(array)) &}
1072 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
1073 \textcolor{keywordflow}{  endif}
1074 
1075   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
1076   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
1077   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric
1078   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}
1079 
1080   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
1081     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
1082       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
1083                                lbound(array,2):ubound(array,2)) )
1084       rescaled\_array(:,:) = 0.0
1085       js = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) js = hi%jsc-1
1086       \textcolor{keywordflow}{do} j=js,hi%JecB ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1087         rescaled\_array(i,j) = scale*array(i,j)
1088 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1089       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)
1090       \textcolor{keyword}{deallocate}(rescaled\_array)
1091     \textcolor{keywordflow}{else}
1092       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)
1093 \textcolor{keywordflow}{    endif}
1094 
1095     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1096       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, amean, amin, amax, mesg, iounit)
1097 \textcolor{keywordflow}{  endif}
1098 
1099   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
1100 
1101   hshift = default\_shift
1102   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1103   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
1104 
1105   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
1106        hi%jscB-hshift<hi%jsdB .or. hi%jecB+hshift>hi%jedB ) \textcolor{keywordflow}{then}
1107     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_2d: haloshift ='},hshift
1108     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_2d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
1109     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_2d: jsd,jsc,jec,jed='},hi%jsdB,hi%jscB,hi%jecB,hi%jedB
1110     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_v\_2d '}//trim(mesg))
1111 \textcolor{keywordflow}{  endif}
1112 
1113   bc0 = subchk(array, hi, 0, 0, scaling)
1114 
1115   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
1116 
1117   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}
1118     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, bc0, mesg, iounit)
1119     \textcolor{keywordflow}{return}
1120 \textcolor{keywordflow}{  endif}
1121 
1122   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
1123 
1124   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
1125     bcs = subchk(array, hi, 0, -hshift-1, scaling)
1126     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg\_s(\textcolor{stringliteral}{"v-point:"}, bc0, bcs, mesg, iounit)
1127   \textcolor{keywordflow}{elseif} (do\_corners) \textcolor{keywordflow}{then}
1128     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1129       bcsw = subchk(array, hi, -hshift, -hshift-1, scaling)
1130       bcse = subchk(array, hi, hshift, -hshift-1, scaling)
1131     \textcolor{keywordflow}{else}
1132       bcsw = subchk(array, hi, -hshift, -hshift, scaling)
1133       bcse = subchk(array, hi, hshift, -hshift, scaling)
1134 \textcolor{keywordflow}{    endif}
1135     bcnw = subchk(array, hi, -hshift, hshift, scaling)
1136     bcne = subchk(array, hi, hshift, hshift, scaling)
1137 
1138     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1139       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
1140   \textcolor{keywordflow}{else}
1141     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1142       bcs = subchk(array, hi, 0, -hshift-1, scaling)
1143     \textcolor{keywordflow}{else}
1144       bcs = subchk(array, hi, 0, -hshift, scaling)
1145 \textcolor{keywordflow}{    endif}
1146     bce = subchk(array, hi, hshift, 0, scaling)
1147     bcw = subchk(array, hi, -hshift, 0, scaling)
1148     bcn = subchk(array, hi, 0, hshift, scaling)
1149 
1150     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1151       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"v-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
1152 \textcolor{keywordflow}{  endif}
1153 
1154   \textcolor{keyword}{contains}
1155 
1156 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
1157     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1158     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1159     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
1160     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
1161     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
1162     \textcolor{keywordtype}{integer} :: i, j, bc
1163     subchk = 0
1164     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1165     \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
1166       bc = bitcount(abs(scale*array(i,j)))
1167       subchk = subchk + bc
1168 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1169     \textcolor{keyword}{call }sum\_across\_pes(subchk)
1170     subchk=mod(subchk, bc\_modulus)
1171 \textcolor{keyword}{  end function }subchk
1172 
1173 \textcolor{keyword}{  subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)
1174     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1175     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1176     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}
1177 \textcolor{comment}{                                              !! full symmetric computational domain.}
1178     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
1179     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
1180     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
1181 
1182     \textcolor{keywordtype}{integer} :: i, j, n, jsb
1183 
1184     jsb = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) jsb = hi%jsc-1
1185 
1186     amin = array(hi%isc,hi%jsc) ; amax = amin
1187     \textcolor{keywordflow}{do} j=jsb,hi%JecB ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1188       amin = min(amin, array(i,j))
1189       amax = max(amax, array(i,j))
1190 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1191     \textcolor{comment}{! This line deliberately uses the h-computational domain.}
1192     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec))
1193     n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc)
1194     \textcolor{keyword}{call }sum\_across\_pes(n)
1195     \textcolor{keyword}{call }min\_across\_pes(amin)
1196     \textcolor{keyword}{call }max\_across\_pes(amax)
1197     amean = amean / \textcolor{keywordtype}{real}(n)
1198 \textcolor{keyword}{  end subroutine }substats
1199 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_add98802882151a1a03a70e6b6b7ae456}\label{namespacemom__checksums_add98802882151a1a03a70e6b6b7ae456}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!chksum\+\_\+v\+\_\+3d@{chksum\+\_\+v\+\_\+3d}}
\index{chksum\+\_\+v\+\_\+3d@{chksum\+\_\+v\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{chksum\+\_\+v\+\_\+3d()}{chksum\_v\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::chksum\+\_\+v\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isd\+:,hi\+\_\+m\%jsdb\+:,\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 3d array staggered at C-\/grid v points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & A horizontal index type\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em haloshift} & The width of halos to check (default 0)\\
\hline
\mbox{\tt in}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain.\\
\hline
\mbox{\tt in}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 1705 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1705   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{ !< A horizontal index type}
1706   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isd:,HI\_m%JsdB:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
1707   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
1708   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
1709   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
1710 \textcolor{comment}{                                                             !! symmetric computational domain.}
1711   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
1712   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
1713   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
1714 
1715   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}
1716   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array
1717   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
1718   \textcolor{keywordtype}{real} :: scaling
1719   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
1720   \textcolor{keywordtype}{integer} :: i, j, k, js
1721   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
1722   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
1723   \textcolor{keywordtype}{real} :: amean, amin, amax
1724   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats
1725   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
1726 
1727   \textcolor{comment}{! Rotate array to the input grid}
1728   turns = hi\_m%turns
1729   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
1730     \textcolor{keyword}{allocate}(hi)
1731     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
1732     \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}
1733       \textcolor{comment}{! Arrays originating from u-points must be handled by uchksum}
1734       \textcolor{keyword}{allocate}(array(hi%IsdB:hi%IedB, hi%jsd:hi%jed, \textcolor{keyword}{size}(array\_m, 3)))
1735       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1736       \textcolor{keyword}{call }uchksum(array, mesg, hi, haloshift, symmetric, omit\_corners, scale, logunit)
1737       \textcolor{keywordflow}{return}
1738     \textcolor{keywordflow}{else}
1739       \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%JsdB:hi%JedB, \textcolor{keyword}{size}(array\_m, 3)))
1740       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1741 \textcolor{keywordflow}{    endif}
1742   \textcolor{keywordflow}{else}
1743     hi => hi\_m
1744     array => array\_m
1745 \textcolor{keywordflow}{  endif}
1746 
1747   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
1748     \textcolor{keywordflow}{if} (is\_nan(array(hi%isc:hi%iec,hi%JscB:hi%JecB,:))) &
1749       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
1750 \textcolor{comment}{!   if (is\_NaN(array)) &}
1751 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
1752 \textcolor{keywordflow}{  endif}
1753 
1754   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
1755   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
1756   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric
1757   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}
1758 
1759   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
1760     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
1761       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
1762                                lbound(array,2):ubound(array,2), &
1763                                lbound(array,3):ubound(array,3)) )
1764       rescaled\_array(:,:,:) = 0.0
1765       js = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) js = hi%jsc-1
1766       \textcolor{keywordflow}{do} k=1,\textcolor{keyword}{size}(array,3) ; \textcolor{keywordflow}{do} j=js,hi%JecB ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1767         rescaled\_array(i,j,k) = scale*array(i,j,k)
1768 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1769       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)
1770       \textcolor{keyword}{deallocate}(rescaled\_array)
1771     \textcolor{keywordflow}{else}
1772       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)
1773 \textcolor{keywordflow}{    endif}
1774     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1775       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, amean, amin, amax, mesg, iounit)
1776 \textcolor{keywordflow}{  endif}
1777 
1778   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
1779 
1780   hshift = default\_shift
1781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1782   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
1783 
1784   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
1785        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
1786     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: haloshift ='},hshift
1787     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
1788     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
1789     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_v\_3d '}//trim(mesg))
1790 \textcolor{keywordflow}{  endif}
1791 
1792   bc0 = subchk(array, hi, 0, 0, scaling)
1793 
1794   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
1795 
1796   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}
1797     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, bc0, mesg, iounit)
1798     \textcolor{keywordflow}{return}
1799 \textcolor{keywordflow}{  endif}
1800 
1801   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
1802 
1803   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
1804     bcs = subchk(array, hi, 0, -hshift-1, scaling)
1805     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg\_s(\textcolor{stringliteral}{"v-point:"}, bc0, bcs, mesg, iounit)
1806   \textcolor{keywordflow}{elseif} (do\_corners) \textcolor{keywordflow}{then}
1807     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1808       bcsw = subchk(array, hi, -hshift, -hshift-1, scaling)
1809       bcse = subchk(array, hi, hshift, -hshift-1, scaling)
1810     \textcolor{keywordflow}{else}
1811       bcsw = subchk(array, hi, -hshift, -hshift, scaling)
1812       bcse = subchk(array, hi, hshift, -hshift, scaling)
1813 \textcolor{keywordflow}{    endif}
1814     bcnw = subchk(array, hi, -hshift, hshift, scaling)
1815     bcne = subchk(array, hi, hshift, hshift, scaling)
1816 
1817     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1818       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
1819   \textcolor{keywordflow}{else}
1820     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1821       bcs = subchk(array, hi, 0, -hshift-1, scaling)
1822     \textcolor{keywordflow}{else}
1823       bcs = subchk(array, hi, 0, -hshift, scaling)
1824 \textcolor{keywordflow}{    endif}
1825     bce = subchk(array, hi, hshift, 0, scaling)
1826     bcw = subchk(array, hi, -hshift, 0, scaling)
1827     bcn = subchk(array, hi, 0, hshift, scaling)
1828 
1829     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1830       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"v-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
1831 \textcolor{keywordflow}{  endif}
1832 
1833   \textcolor{keyword}{contains}
1834 
1835 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
1836     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1837     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1838     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
1839     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
1840     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
1841     \textcolor{keywordtype}{integer} :: i, j, k, bc
1842     subchk = 0
1843     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1844     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj ; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
1845       bc = bitcount(abs(scale*array(i,j,k)))
1846       subchk = subchk + bc
1847 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1848     \textcolor{keyword}{call }sum\_across\_pes(subchk)
1849     subchk=mod(subchk, bc\_modulus)
1850 \textcolor{keyword}{  end function }subchk
1851 
1852   \textcolor{comment}{!subroutine subStats(HI, array, mesg, sym\_stats)}
1853 \textcolor{keyword}{  subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)
1854     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1855     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1856     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}
1857 \textcolor{comment}{                                              !! full symmetric computational domain.}
1858     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{   !< Mean of array over domain}
1859     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{    !< Minimum of array over domain}
1860     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{    !< Maximum of array over domain}
1861 
1862     \textcolor{keywordtype}{integer} :: i, j, k, n, jsb
1863 
1864     jsb = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) jsb = hi%jsc-1
1865 
1866     amin = array(hi%isc,hi%jsc,1) ; amax = amin
1867     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=jsb,hi%JecB ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1868       amin = min(amin, array(i,j,k))
1869       amax = max(amax, array(i,j,k))
1870 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1871     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1872     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))
1873     n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc) * \textcolor{keyword}{size}(array,3)
1874     \textcolor{keyword}{call }sum\_across\_pes(n)
1875     \textcolor{keyword}{call }min\_across\_pes(amin)
1876     \textcolor{keyword}{call }max\_across\_pes(amax)
1877     amean = amean / \textcolor{keywordtype}{real}(n)
1878 \textcolor{keyword}{  end subroutine }substats
1879 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_aa60d4336935b61bdb90e5f182d9a21ad}\label{namespacemom__checksums_aa60d4336935b61bdb90e5f182d9a21ad}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!is\+\_\+nan\+\_\+0d@{is\+\_\+nan\+\_\+0d}}
\index{is\+\_\+nan\+\_\+0d@{is\+\_\+nan\+\_\+0d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{is\+\_\+nan\+\_\+0d()}{is\_nan\_0d()}}
{\footnotesize\ttfamily logical function mom\+\_\+checksums\+::is\+\_\+nan\+\_\+0d (\begin{DoxyParamCaption}\item[{real, intent(in)}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This function returns .true. if x is a NaN, and .false. otherwise. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & The value to be checked for Na\+Ns. \\
\hline
\end{DoxyParams}


Definition at line 2002 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2002   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The value to be checked for NaNs.}
2003   \textcolor{keywordtype}{logical} :: is\_nan\_0d
2004 
2005  \textcolor{comment}{!is\_NaN\_0d = (((x < 0.0) .and. (x >= 0.0)) .or. &}
2006  \textcolor{comment}{!          (.not.(x < 0.0) .and. .not.(x >= 0.0)))}
2007   \textcolor{keywordflow}{if} (((x < 0.0) .and. (x >= 0.0)) .or. &
2008             (.not.(x < 0.0) .and. .not.(x >= 0.0))) \textcolor{keywordflow}{then}
2009     is\_nan\_0d = .true.
2010   \textcolor{keywordflow}{else}
2011     is\_nan\_0d = .false.
2012 \textcolor{keywordflow}{  endif}
2013 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a2ae26d49eb294b8b0e6872cc1642eb4b}\label{namespacemom__checksums_a2ae26d49eb294b8b0e6872cc1642eb4b}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!is\+\_\+nan\+\_\+1d@{is\+\_\+nan\+\_\+1d}}
\index{is\+\_\+nan\+\_\+1d@{is\+\_\+nan\+\_\+1d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{is\+\_\+nan\+\_\+1d()}{is\_nan\_1d()}}
{\footnotesize\ttfamily logical function mom\+\_\+checksums\+::is\+\_\+nan\+\_\+1d (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{x,  }\item[{logical, intent(in), optional}]{skip\+\_\+mpp }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns .true. if any element of x is a NaN, and .false. otherwise. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & The array to be checked for Na\+Ns.\\
\hline
\mbox{\tt in}  & {\em skip\+\_\+mpp} & If true, only check this array only on the local PE (default false). \\
\hline
\end{DoxyParams}


Definition at line 2018 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2018   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The array to be checked for NaNs.}
2019   \textcolor{keywordtype}{logical},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: skip\_mpp\textcolor{comment}{  !< If true, only check this array only}
2020 \textcolor{comment}{                                              !! on the local PE (default false).}
2021   \textcolor{keywordtype}{logical} :: is\_nan\_1d
2022 
2023   \textcolor{keywordtype}{integer} :: i, n
2024   \textcolor{keywordtype}{logical} :: call\_mpp
2025 
2026   n = 0
2027   \textcolor{keywordflow}{do} i = lbound(x,1), ubound(x,1)
2028     \textcolor{keywordflow}{if} (is\_nan\_0d(x(i))) n = n + 1
2029 \textcolor{keywordflow}{  enddo}
2030   call\_mpp = .true.
2031   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(skip\_mpp)) call\_mpp = .not.skip\_mpp
2032 
2033   \textcolor{keywordflow}{if} (call\_mpp) \textcolor{keyword}{call }sum\_across\_pes(n)
2034   is\_nan\_1d = .false.
2035   \textcolor{keywordflow}{if} (n>0) is\_nan\_1d = .true.
2036 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_ae5399b160c30b9e0d9a806af7e322f8e}\label{namespacemom__checksums_ae5399b160c30b9e0d9a806af7e322f8e}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!is\+\_\+nan\+\_\+2d@{is\+\_\+nan\+\_\+2d}}
\index{is\+\_\+nan\+\_\+2d@{is\+\_\+nan\+\_\+2d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{is\+\_\+nan\+\_\+2d()}{is\_nan\_2d()}}
{\footnotesize\ttfamily logical function mom\+\_\+checksums\+::is\+\_\+nan\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:), intent(in)}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns .true. if any element of x is a NaN, and .false. otherwise. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & The array to be checked for Na\+Ns. \\
\hline
\end{DoxyParams}


Definition at line 2041 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2041   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The array to be checked for NaNs.}
2042   \textcolor{keywordtype}{logical} :: is\_nan\_2d
2043 
2044   \textcolor{keywordtype}{integer} :: i, j, n
2045 
2046   n = 0
2047   \textcolor{keywordflow}{do} j = lbound(x,2), ubound(x,2) ; \textcolor{keywordflow}{do} i = lbound(x,1), ubound(x,1)
2048     \textcolor{keywordflow}{if} (is\_nan\_0d(x(i,j))) n = n + 1
2049 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
2050   \textcolor{keyword}{call }sum\_across\_pes(n)
2051   is\_nan\_2d = .false.
2052   \textcolor{keywordflow}{if} (n>0) is\_nan\_2d = .true.
2053 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a1cfab80ba102a9eb5b77d6c5db2a298a}\label{namespacemom__checksums_a1cfab80ba102a9eb5b77d6c5db2a298a}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!is\+\_\+nan\+\_\+3d@{is\+\_\+nan\+\_\+3d}}
\index{is\+\_\+nan\+\_\+3d@{is\+\_\+nan\+\_\+3d}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{is\+\_\+nan\+\_\+3d()}{is\_nan\_3d()}}
{\footnotesize\ttfamily logical function mom\+\_\+checksums\+::is\+\_\+nan\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns .true. if any element of x is a NaN, and .false. otherwise. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & The array to be checked for Na\+Ns. \\
\hline
\end{DoxyParams}


Definition at line 2058 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2058   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The array to be checked for NaNs.}
2059   \textcolor{keywordtype}{logical} :: is\_nan\_3d
2060 
2061   \textcolor{keywordtype}{integer} :: i, j, k, n
2062 
2063   n = 0
2064   \textcolor{keywordflow}{do} k = lbound(x,3), ubound(x,3)
2065     \textcolor{keywordflow}{do} j = lbound(x,2), ubound(x,2) ; \textcolor{keywordflow}{do} i = lbound(x,1), ubound(x,1)
2066       \textcolor{keywordflow}{if} (is\_nan\_0d(x(i,j,k))) n = n + 1
2067 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
2068 \textcolor{keywordflow}{  enddo}
2069   \textcolor{keyword}{call }sum\_across\_pes(n)
2070   is\_nan\_3d = .false.
2071   \textcolor{keywordflow}{if} (n>0) is\_nan\_3d = .true.
2072 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a4844ebcc4ee98794babd6b17219f5139}\label{namespacemom__checksums_a4844ebcc4ee98794babd6b17219f5139}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!mom\+\_\+checksums\+\_\+init@{mom\+\_\+checksums\+\_\+init}}
\index{mom\+\_\+checksums\+\_\+init@{mom\+\_\+checksums\+\_\+init}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{mom\+\_\+checksums\+\_\+init()}{mom\_checksums\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+checksums\+::mom\+\_\+checksums\+\_\+init (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}



M\+O\+M\+\_\+checksums\+\_\+init initializes the M\+O\+M\+\_\+checksums module. As it happens, the only thing that it does is to log the version of this module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\end{DoxyParams}


Definition at line 2171 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
2171   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
2172 \textcolor{comment}{! This include declares and sets the variable "version".}
2173 \textcolor{preprocessor}{#include "version\_variable.h"}
2174 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_checksums"} \textcolor{comment}{! This module's name.}
2175 
2176   \textcolor{keyword}{call }log\_version(param\_file, mdl, version)
2177 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__checksums_a4407f1e35457aa61e99ed08ae13b9eeb}\label{namespacemom__checksums_a4407f1e35457aa61e99ed08ae13b9eeb}} 
\index{mom\+\_\+checksums@{mom\+\_\+checksums}!zchksum@{zchksum}}
\index{zchksum@{zchksum}!mom\+\_\+checksums@{mom\+\_\+checksums}}
\subsubsection{\texorpdfstring{zchksum()}{zchksum()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+checksums\+::zchksum (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{array,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})}



Checksum a 1d array (typically a column). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em array} & The array to be checksummed\\
\hline
\mbox{\tt in}  & {\em mesg} & An identifying message\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor for this array.\\
\hline
\mbox{\tt in}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


Definition at line 122 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
122   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{  !< The array to be checksummed}
123   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{     !< An identifying message}
124   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{      !< A scaling factor for this array.}
125   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
126 
127   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: rescaled\_array
128   \textcolor{keywordtype}{real} :: scaling
129   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
130   \textcolor{keywordtype}{integer} :: k
131   \textcolor{keywordtype}{real} :: amean, amin, amax
132   \textcolor{keywordtype}{integer} :: bc0
133 
134   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
135     \textcolor{keywordflow}{if} (is\_nan(array(:))) &
136       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
137 \textcolor{keywordflow}{  endif}
138 
139   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
140   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
141 
142   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
143     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
144       \textcolor{keyword}{allocate}(rescaled\_array(lbound(array,1):ubound(array,1)))
145       rescaled\_array(:) = 0.0
146       \textcolor{keywordflow}{do} k=1, \textcolor{keyword}{size}(array, 1)
147         rescaled\_array(k) = scale * array(k)
148 \textcolor{keywordflow}{      enddo}
149 
150       \textcolor{keyword}{call }substats(rescaled\_array, amean, amin, amax)
151       \textcolor{keyword}{deallocate}(rescaled\_array)
152     \textcolor{keywordflow}{else}
153       \textcolor{keyword}{call }substats(array, amean, amin, amax)
154 \textcolor{keywordflow}{    endif}
155 
156     \textcolor{keywordflow}{if} (is\_root\_pe()) &
157       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{" column:"}, amean, amin, amax, mesg, iounit)
158 \textcolor{keywordflow}{  endif}
159 
160   \textcolor{keywordflow}{if} (.not. writechksums) \textcolor{keywordflow}{return}
161 
162   bc0 = subchk(array, scaling)
163   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{" column:"}, bc0, mesg, iounit)
164 
165   \textcolor{keyword}{contains}
166 
167 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, scale)
168     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
169     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A scaling factor for this array.}
170     \textcolor{keywordtype}{integer} :: k, bc
171     subchk = 0
172     \textcolor{keywordflow}{do} k=lbound(array, 1), ubound(array, 1)
173       bc = bitcount(abs(scale * array(k)))
174       subchk = subchk + bc
175 \textcolor{keywordflow}{    enddo}
176     subchk=mod(subchk, bc\_modulus)
177 \textcolor{keyword}{  end function }subchk
178 
179 \textcolor{keyword}{  subroutine }substats(array, aMean, aMin, aMax)
180     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
181     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
182     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
183     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
184 
185     \textcolor{keywordtype}{integer} :: k, n
186 
187     amin = array(1)
188     amax = array(1)
189     n = 0
190     \textcolor{keywordflow}{do} k=lbound(array,1), ubound(array,1)
191       amin = min(amin, array(k))
192       amax = max(amax, array(k))
193       n = n + 1
194 \textcolor{keywordflow}{    enddo}
195     amean = sum(array(:)) / \textcolor{keywordtype}{real}(n)
196 \textcolor{keyword}{  end subroutine }substats
\end{DoxyCode}
