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


\doxysubsection{Detailed Description}
Routines to calculate checksums of various array and vector types. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__checksums_a609fca199ad94da0d2e2ae06e24e178a}\label{namespacemom__checksums_a609fca199ad94da0d2e2ae06e24e178a}} 
integer, parameter \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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 \mbox{\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}


\doxysubsection{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em x} & Number to be bitcount \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2191 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< Number to be bitcount}}
\DoxyCodeLine{2192 }
\DoxyCodeLine{2193   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: xk = kind(x)  \textcolor{comment}{!< Kind type of x}}
\DoxyCodeLine{2194 }
\DoxyCodeLine{2195   \textcolor{comment}{! NOTE: Assumes that reals and integers of kind=xk are the same size}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em fmsg} & A checksum code-\/location specific preamble \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message supplied by top-\/level caller \\
\hline
\mbox{\texttt{ in}}  & {\em bc0} & The bitcount of the non-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2077   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-\/location specific preamble}}
\DoxyCodeLine{2078   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-\/level caller}}
\DoxyCodeLine{2079   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-\/shifted array}}
\DoxyCodeLine{2080   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}}
\DoxyCodeLine{2081 }
\DoxyCodeLine{2082   \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em fmsg} & A checksum code-\/location specific preamble \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message supplied by top-\/level caller \\
\hline
\mbox{\texttt{ in}}  & {\em bc0} & The bitcount of the non-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcsw} & The bitcount of the southwest-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2142   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-\/location specific preamble}}
\DoxyCodeLine{2143   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-\/level caller}}
\DoxyCodeLine{2144   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-\/shifted array}}
\DoxyCodeLine{2145   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcSW\textcolor{comment}{ !< The bitcount of the southwest-\/shifted array}}
\DoxyCodeLine{2146   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}}
\DoxyCodeLine{2147 }
\DoxyCodeLine{2148   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,2(A,I9,1X),A)'}) \&}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em fmsg} & A checksum code-\/location specific preamble \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message supplied by top-\/level caller \\
\hline
\mbox{\texttt{ in}}  & {\em amean} & The mean value of the array \\
\hline
\mbox{\texttt{ in}}  & {\em amin} & The minimum value of the array \\
\hline
\mbox{\texttt{ in}}  & {\em amax} & The maximum value of the array \\
\hline
\mbox{\texttt{ in}}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2154   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-\/location specific preamble}}
\DoxyCodeLine{2155   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-\/level caller}}
\DoxyCodeLine{2156 \textcolor{keywordtype}{  real},             \textcolor{keywordtype}{intent(in)} :: aMean\textcolor{comment}{ !< The mean value of the array}}
\DoxyCodeLine{2157 \textcolor{keywordtype}{  real},             \textcolor{keywordtype}{intent(in)} :: aMin\textcolor{comment}{ !< The minimum value of the array}}
\DoxyCodeLine{2158 \textcolor{keywordtype}{  real},             \textcolor{keywordtype}{intent(in)} :: aMax\textcolor{comment}{ !< The maximum value of the array}}
\DoxyCodeLine{2159   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}}
\DoxyCodeLine{2160 }
\DoxyCodeLine{2161   \textcolor{comment}{! NOTE: We add zero to aMin and aMax to remove any negative zeros.}}
\DoxyCodeLine{2162   \textcolor{comment}{! This is due to inconsistencies of signed zero in local vs MPI calculations.}}
\DoxyCodeLine{2163 }
\DoxyCodeLine{2164   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,3(A,ES25.16,1X),A)'}) \&}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em fmsg} & A checksum code-\/location specific preamble \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message supplied by top-\/level caller \\
\hline
\mbox{\texttt{ in}}  & {\em bc0} & The bitcount of the non-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcsw} & The bitcount for SW shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcse} & The bitcount for SE shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcnw} & The bitcount for NW shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcne} & The bitcount for NE shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2088   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-\/location specific preamble}}
\DoxyCodeLine{2089   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-\/level caller}}
\DoxyCodeLine{2090   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-\/shifted array}}
\DoxyCodeLine{2091   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcSW\textcolor{comment}{ !< The bitcount for SW shifted array}}
\DoxyCodeLine{2092   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcSE\textcolor{comment}{ !< The bitcount for SE shifted array}}
\DoxyCodeLine{2093   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcNW\textcolor{comment}{ !< The bitcount for NW shifted array}}
\DoxyCodeLine{2094   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcNE\textcolor{comment}{ !< The bitcount for NE shifted array}}
\DoxyCodeLine{2095   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}}
\DoxyCodeLine{2096 }
\DoxyCodeLine{2097   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,5(A,I10,1X),A)'}) \&}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em fmsg} & A checksum code-\/location specific preamble \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message supplied by top-\/level caller \\
\hline
\mbox{\texttt{ in}}  & {\em bc0} & The bitcount of the non-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcn} & The bitcount for N shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcs} & The bitcount for S shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bce} & The bitcount for E shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcw} & The bitcount for W shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2103   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-\/location specific preamble}}
\DoxyCodeLine{2104   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-\/level caller}}
\DoxyCodeLine{2105   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-\/shifted array}}
\DoxyCodeLine{2106   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcN\textcolor{comment}{ !< The bitcount for N shifted array}}
\DoxyCodeLine{2107   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcS\textcolor{comment}{ !< The bitcount for S shifted array}}
\DoxyCodeLine{2108   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcE\textcolor{comment}{ !< The bitcount for E shifted array}}
\DoxyCodeLine{2109   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcW\textcolor{comment}{ !< The bitcount for W shifted array}}
\DoxyCodeLine{2110   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}}
\DoxyCodeLine{2111 }
\DoxyCodeLine{2112   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,5(A,I10,1X),A)'}) \&}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em fmsg} & A checksum code-\/location specific preamble \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message supplied by top-\/level caller \\
\hline
\mbox{\texttt{ in}}  & {\em bc0} & The bitcount of the non-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcs} & The bitcount of the south-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2118   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-\/location specific preamble}}
\DoxyCodeLine{2119   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-\/level caller}}
\DoxyCodeLine{2120   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-\/shifted array}}
\DoxyCodeLine{2121   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcS\textcolor{comment}{  !< The bitcount of the south-\/shifted array}}
\DoxyCodeLine{2122   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}}
\DoxyCodeLine{2123 }
\DoxyCodeLine{2124   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,2(A,I10,1X),A)'}) \&}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em fmsg} & A checksum code-\/location specific preamble \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message supplied by top-\/level caller \\
\hline
\mbox{\texttt{ in}}  & {\em bc0} & The bitcount of the non-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em bcw} & The bitcount of the west-\/shifted array \\
\hline
\mbox{\texttt{ in}}  & {\em iounit} & Checksum logger IO unit \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2130   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: fmsg\textcolor{comment}{ !< A checksum code-\/location specific preamble}}
\DoxyCodeLine{2131   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< An identifying message supplied by top-\/level caller}}
\DoxyCodeLine{2132   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bc0\textcolor{comment}{  !< The bitcount of the non-\/shifted array}}
\DoxyCodeLine{2133   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: bcW\textcolor{comment}{  !< The bitcount of the west-\/shifted array}}
\DoxyCodeLine{2134   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: iounit\textcolor{comment}{ !< Checksum logger IO unit}}
\DoxyCodeLine{2135 }
\DoxyCodeLine{2136   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{write}(iounit, \textcolor{stringliteral}{'(A,2(A,I10,1X),A)'}) \&}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em scalar} & The array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{89 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: scalar\textcolor{comment}{                !< The array to be checksummed}}
\DoxyCodeLine{90   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{     !< An identifying message}}
\DoxyCodeLine{91 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{      !< A scaling factor for this array.}}
\DoxyCodeLine{92   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{93 }
\DoxyCodeLine{94 \textcolor{keywordtype}{  real} :: scaling\textcolor{comment}{   !< Explicit rescaling factor}}
\DoxyCodeLine{95   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}}
\DoxyCodeLine{96 \textcolor{keywordtype}{  real} :: rs\textcolor{comment}{        !< Rescaled scalar}}
\DoxyCodeLine{97   \textcolor{keywordtype}{integer} :: bc\textcolor{comment}{     !< Scalar bitcount}}
\DoxyCodeLine{98 }
\DoxyCodeLine{99   \textcolor{keywordflow}{if} (checkfornans .and. is\_nan(scalar)) \&}
\DoxyCodeLine{100     \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))}
\DoxyCodeLine{101 }
\DoxyCodeLine{102   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale}
\DoxyCodeLine{103   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit}
\DoxyCodeLine{104 }
\DoxyCodeLine{105   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{106     rs = scaling * scalar}
\DoxyCodeLine{107     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{108       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{" scalar:"}, rs, rs, rs, mesg, iounit)}
\DoxyCodeLine{109 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{110 }
\DoxyCodeLine{111   \textcolor{keywordflow}{if} (.not. writechksums) \textcolor{keywordflow}{return}}
\DoxyCodeLine{112 }
\DoxyCodeLine{113   bc = mod(bitcount(abs(scaling * scalar)), bc\_modulus)}
\DoxyCodeLine{114   \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{115     \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{" scalar:"}, bc, mesg, iounit)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em array} & The array to be summed (index starts at 1). \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message. \\
\hline
\mbox{\texttt{ in}}  & {\em start\+\_\+i} & The starting index for the sum (default 1) \\
\hline
\mbox{\texttt{ in}}  & {\em end\+\_\+i} & The ending index for the sum (default all) \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{1887 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{   !< The array to be summed (index starts at 1).}}
\DoxyCodeLine{1888   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{    !< An identifying message.}}
\DoxyCodeLine{1889   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)} :: start\_i\textcolor{comment}{ !< The starting index for the sum (default 1)}}
\DoxyCodeLine{1890   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)} :: end\_i\textcolor{comment}{   !< The ending index for the sum (default all)}}
\DoxyCodeLine{1891   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)} :: compare\_PEs\textcolor{comment}{ !< If true, compare across PEs instead of summing}}
\DoxyCodeLine{1892 \textcolor{comment}{                                                !! and list the root\_PE value (default true)}}
\DoxyCodeLine{1893 }
\DoxyCodeLine{1894   \textcolor{keywordtype}{integer} :: is, ie, i, bc, sum1, sum\_bc}
\DoxyCodeLine{1895 \textcolor{keywordtype}{  real} :: sum}
\DoxyCodeLine{1896 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable} :: sum\_here(:)}
\DoxyCodeLine{1897   \textcolor{keywordtype}{logical} :: compare}
\DoxyCodeLine{1898   \textcolor{keywordtype}{integer} :: pe\_num   \textcolor{comment}{! pe number of the data}}
\DoxyCodeLine{1899   \textcolor{keywordtype}{integer} :: nPEs     \textcolor{comment}{! Total number of processsors}}
\DoxyCodeLine{1900 }
\DoxyCodeLine{1901   is = lbound(array,1) ; ie = ubound(array,1)}
\DoxyCodeLine{1902   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(start\_i)) is = start\_i}
\DoxyCodeLine{1903   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(end\_i)) ie = end\_i}
\DoxyCodeLine{1904   compare = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(compare\_pes)) compare = compare\_pes}
\DoxyCodeLine{1905 }
\DoxyCodeLine{1906   sum = 0.0 ; sum\_bc = 0}
\DoxyCodeLine{1907   \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1908     sum = sum + array(i)}
\DoxyCodeLine{1909     bc = bitcount(abs(array(i)))}
\DoxyCodeLine{1910     sum\_bc = sum\_bc + bc}
\DoxyCodeLine{1911 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1912 }
\DoxyCodeLine{1913   pe\_num = pe\_here() + 1 -\/ root\_pe() ; npes = num\_pes()}
\DoxyCodeLine{1914   \textcolor{keyword}{allocate}(sum\_here(npes)) ; sum\_here(:) = 0.0 ; sum\_here(pe\_num) = sum}
\DoxyCodeLine{1915   \textcolor{keyword}{call }sum\_across\_pes(sum\_here,npes)}
\DoxyCodeLine{1916 }
\DoxyCodeLine{1917   sum1 = sum\_bc}
\DoxyCodeLine{1918   \textcolor{keyword}{call }sum\_across\_pes(sum1)}
\DoxyCodeLine{1919 }
\DoxyCodeLine{1920   \textcolor{keywordflow}{if} (.not.compare) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1921     sum = 0.0}
\DoxyCodeLine{1922     \textcolor{keywordflow}{do} i=1,npes ; sum = sum + sum\_here(i) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1923     sum\_bc = sum1}
\DoxyCodeLine{1924   \textcolor{keywordflow}{elseif} (is\_root\_pe()) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1925     \textcolor{keywordflow}{if} (sum1 /= npes*sum\_bc) \&}
\DoxyCodeLine{1926       \textcolor{keyword}{write}(0, \textcolor{stringliteral}{'(A40," bitcounts do not match across PEs: ",I12,1X,I12)'}) \&}
\DoxyCodeLine{1927             mesg, sum1, npes*sum\_bc}
\DoxyCodeLine{1928     \textcolor{keywordflow}{do} i=1,npes ; \textcolor{keywordflow}{if} (sum /= sum\_here(i)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1929       \textcolor{keyword}{write}(0, \textcolor{stringliteral}{'(A40," PE ",i4," sum mismatches root\_PE: ",3(ES22.13,1X))'}) \&}
\DoxyCodeLine{1930             mesg, i, sum\_here(i), sum, sum\_here(i)-\/sum}
\DoxyCodeLine{1931 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1932 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1933   \textcolor{keyword}{deallocate}(sum\_here)}
\DoxyCodeLine{1934 }
\DoxyCodeLine{1935   \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1936     \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(A50,1X,ES25.16,1X,I12)'}) mesg, sum, sum\_bc}
\DoxyCodeLine{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}}
\doxysubsubsection{\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}{0}
\DoxyCodeLine{1945 }
\DoxyCodeLine{1946 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1947   \textcolor{keywordtype}{character(len=*)} :: mesg\textcolor{comment}{  !< An identifying message}}
\DoxyCodeLine{1948 }
\DoxyCodeLine{1949   \textcolor{keywordtype}{integer} :: xs,xe,ys,ye,i,j,sum1,bc}
\DoxyCodeLine{1950 \textcolor{keywordtype}{  real} :: sum}
\DoxyCodeLine{1951 }
\DoxyCodeLine{1952   xs = lbound(array,1) ; xe = ubound(array,1)}
\DoxyCodeLine{1953   ys = lbound(array,2) ; ye = ubound(array,2)}
\DoxyCodeLine{1954 }
\DoxyCodeLine{1955   sum = 0.0 ; sum1 = 0}
\DoxyCodeLine{1956   \textcolor{keywordflow}{do} i=xs,xe ; \textcolor{keywordflow}{do} j=ys,ye}
\DoxyCodeLine{1957     bc = bitcount(abs(array(i,j)))}
\DoxyCodeLine{1958     sum1 = sum1 + bc}
\DoxyCodeLine{1959 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1960   \textcolor{keyword}{call }sum\_across\_pes(sum1)}
\DoxyCodeLine{1961 }
\DoxyCodeLine{1962   sum = reproducing\_sum(array(:,:))}
\DoxyCodeLine{1963 }
\DoxyCodeLine{1964   \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1965     \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(A50,1X,ES25.16,1X,I12)'}) mesg, sum, sum1}
\DoxyCodeLine{1966 \textcolor{comment}{!    write(0,'(A40,1X,Z16.16,1X,Z16.16,1X,ES25.16,1X,I12)') \&}}
\DoxyCodeLine{1967 \textcolor{comment}{!      mesg, sum, sum1, sum, sum1}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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}{0}
\DoxyCodeLine{1973 }
\DoxyCodeLine{1974 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1975   \textcolor{keywordtype}{character(len=*)} :: mesg\textcolor{comment}{  !< An identifying message}}
\DoxyCodeLine{1976 }
\DoxyCodeLine{1977   \textcolor{keywordtype}{integer} :: xs,xe,ys,ye,zs,ze,i,j,k, bc,sum1}
\DoxyCodeLine{1978 \textcolor{keywordtype}{  real} :: sum}
\DoxyCodeLine{1979 }
\DoxyCodeLine{1980   xs = lbound(array,1) ; xe = ubound(array,1)}
\DoxyCodeLine{1981   ys = lbound(array,2) ; ye = ubound(array,2)}
\DoxyCodeLine{1982   zs = lbound(array,3) ; ze = ubound(array,3)}
\DoxyCodeLine{1983 }
\DoxyCodeLine{1984   sum = 0.0 ; sum1 = 0}
\DoxyCodeLine{1985   \textcolor{keywordflow}{do} i=xs,xe ; \textcolor{keywordflow}{do} j=ys,ye ; \textcolor{keywordflow}{do} k=zs,ze}
\DoxyCodeLine{1986     bc = bitcount(abs(array(i,j,k)))}
\DoxyCodeLine{1987     sum1 = sum1 + bc}
\DoxyCodeLine{1988 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1989 }
\DoxyCodeLine{1990   \textcolor{keyword}{call }sum\_across\_pes(sum1)}
\DoxyCodeLine{1991   sum = reproducing\_sum(array(:,:,:))}
\DoxyCodeLine{1992 }
\DoxyCodeLine{1993   \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1994     \textcolor{keyword}{write}(0,\textcolor{stringliteral}{'(A50,1X,ES25.16,1X,I12)'}) mesg, sum, sum1}
\DoxyCodeLine{1995 \textcolor{comment}{!    write(0,'(A40,1X,Z16.16,1X,Z16.16,1X,ES25.16,1X,I12)') \&}}
\DoxyCodeLine{1996 \textcolor{comment}{!      mesg, sum, sum1, sum, sum1}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em hi\+\_\+m} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em array\+\_\+m} & The array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain. \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


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


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


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


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


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


\begin{DoxyCode}{0}
\DoxyCodeLine{2182   \textcolor{comment}{! Wrapper for MOM\_error to help place specific break points in debuggers}}
\DoxyCodeLine{2183   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: signal\textcolor{comment}{ !< An error severity level, such as FATAL or WARNING}}
\DoxyCodeLine{2184   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: message\textcolor{comment}{ !< An error message}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em hi\+\_\+m} & Horizontal index bounds of the model grid \\
\hline
\mbox{\texttt{ in}}  & {\em array\+\_\+m} & Field array on the model grid \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


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


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


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1204   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\_m\textcolor{comment}{ !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1206   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}}
\DoxyCodeLine{1207   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{1208   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{1209 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}}
\DoxyCodeLine{1210   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{1211 }
\DoxyCodeLine{1212 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}}
\DoxyCodeLine{1213 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array}
\DoxyCodeLine{1214   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI   \textcolor{comment}{! Horizontal index bounds of the input grid}}
\DoxyCodeLine{1215 \textcolor{keywordtype}{  real} :: scaling}
\DoxyCodeLine{1216   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}}
\DoxyCodeLine{1217   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{1218 \textcolor{keywordtype}{  real} :: aMean, aMin, aMax}
\DoxyCodeLine{1219   \textcolor{keywordtype}{integer} :: bc0, bcSW, bcSE, bcNW, bcNE, hshift}
\DoxyCodeLine{1220   \textcolor{keywordtype}{integer} :: bcN, bcS, bcE, bcW}
\DoxyCodeLine{1221   \textcolor{keywordtype}{logical} :: do\_corners}
\DoxyCodeLine{1222   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}}
\DoxyCodeLine{1223 }
\DoxyCodeLine{1224   \textcolor{comment}{! Rotate array to the input grid}}
\DoxyCodeLine{1225   turns = hi\_m\%turns}
\DoxyCodeLine{1226   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1227     \textcolor{keyword}{allocate}(hi)}
\DoxyCodeLine{1228     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -\/turns, hi)}
\DoxyCodeLine{1229     \textcolor{keyword}{allocate}(array(hi\%isd:hi\%ied, hi\%jsd:hi\%jed, \textcolor{keyword}{size}(array\_m, 3)))}
\DoxyCodeLine{1230     \textcolor{keyword}{call }rotate\_array(array\_m, -\/turns, array)}
\DoxyCodeLine{1231   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1232     hi => hi\_m}
\DoxyCodeLine{1233     array => array\_m}
\DoxyCodeLine{1234 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1235 }
\DoxyCodeLine{1236   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1237     \textcolor{keywordflow}{if} (is\_nan(array(hi\%isc:hi\%iec,hi\%jsc:hi\%jec,:))) \&}
\DoxyCodeLine{1238       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))}
\DoxyCodeLine{1239 \textcolor{comment}{!   if (is\_NaN(array)) \&}}
\DoxyCodeLine{1240 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}}
\DoxyCodeLine{1241 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1242 }
\DoxyCodeLine{1243   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale}
\DoxyCodeLine{1244   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit}
\DoxyCodeLine{1245 }
\DoxyCodeLine{1246   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1247     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1248       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), \&}
\DoxyCodeLine{1249                                lbound(array,2):ubound(array,2), \&}
\DoxyCodeLine{1250                                lbound(array,3):ubound(array,3)) )}
\DoxyCodeLine{1251       rescaled\_array(:,:,:) = 0.0}
\DoxyCodeLine{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}
\DoxyCodeLine{1253         rescaled\_array(i,j,k) = scale*array(i,j,k)}
\DoxyCodeLine{1254 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1255 }
\DoxyCodeLine{1256       \textcolor{keyword}{call }substats(hi, rescaled\_array, amean, amin, amax)}
\DoxyCodeLine{1257       \textcolor{keyword}{deallocate}(rescaled\_array)}
\DoxyCodeLine{1258     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1259       \textcolor{keyword}{call }substats(hi, array, amean, amin, amax)}
\DoxyCodeLine{1260 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1261 }
\DoxyCodeLine{1262     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1263       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-\/point:"}, amean, amin, amax, mesg, iounit)}
\DoxyCodeLine{1264 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1265 }
\DoxyCodeLine{1266   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1267 }
\DoxyCodeLine{1268   hshift = default\_shift}
\DoxyCodeLine{1269   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift}
\DoxyCodeLine{1270   \textcolor{keywordflow}{if} (hshift<0) hshift = hi\%ied-\/hi\%iec}
\DoxyCodeLine{1271 }
\DoxyCodeLine{1272   \textcolor{keywordflow}{if} ( hi\%isc-\/hshift<hi\%isd .or. hi\%iec+hshift>hi\%ied .or. \&}
\DoxyCodeLine{1273        hi\%jsc-\/hshift<hi\%jsd .or. hi\%jec+hshift>hi\%jed ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1274     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: haloshift ='},hshift}
\DoxyCodeLine{1275     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: isd,isc,iec,ied='},hi\%isd,hi\%isc,hi\%iec,hi\%ied}
\DoxyCodeLine{1276     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: jsd,jsc,jec,jed='},hi\%jsd,hi\%jsc,hi\%jec,hi\%jed}
\DoxyCodeLine{1277     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_h\_3d '}//trim(mesg))}
\DoxyCodeLine{1278 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1279 }
\DoxyCodeLine{1280   bc0 = subchk(array, hi, 0, 0, scaling)}
\DoxyCodeLine{1281 }
\DoxyCodeLine{1282   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1283     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-\/point:"}, bc0, mesg, iounit)}
\DoxyCodeLine{1284     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1285 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1286 }
\DoxyCodeLine{1287   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners}
\DoxyCodeLine{1288 }
\DoxyCodeLine{1289   \textcolor{keywordflow}{if} (do\_corners) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1290     bcsw = subchk(array, hi, -\/hshift, -\/hshift, scaling)}
\DoxyCodeLine{1291     bcse = subchk(array, hi, hshift, -\/hshift, scaling)}
\DoxyCodeLine{1292     bcnw = subchk(array, hi, -\/hshift, hshift, scaling)}
\DoxyCodeLine{1293     bcne = subchk(array, hi, hshift, hshift, scaling)}
\DoxyCodeLine{1294 }
\DoxyCodeLine{1295     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1296       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-\/point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)}
\DoxyCodeLine{1297   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1298     bcs = subchk(array, hi, 0, -\/hshift, scaling)}
\DoxyCodeLine{1299     bce = subchk(array, hi, hshift, 0, scaling)}
\DoxyCodeLine{1300     bcw = subchk(array, hi, -\/hshift, 0, scaling)}
\DoxyCodeLine{1301     bcn = subchk(array, hi, 0, hshift, scaling)}
\DoxyCodeLine{1302 }
\DoxyCodeLine{1303     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1304       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"h-\/point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)}
\DoxyCodeLine{1305 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1306 }
\DoxyCodeLine{1307   \textcolor{keyword}{contains}}
\DoxyCodeLine{1308 }
\DoxyCodeLine{1309   \textcolor{keyword}{integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)}
\DoxyCodeLine{1310     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{1311 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(HI\%isd:,HI\%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1312     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i-\/ direction array shift for this checksum}}
\DoxyCodeLine{1313     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j-\/ direction array shift for this checksum}}
\DoxyCodeLine{1314 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}}
\DoxyCodeLine{1315     \textcolor{keywordtype}{integer} :: i, j, k, bc}
\DoxyCodeLine{1316     subchk = 0}
\DoxyCodeLine{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}
\DoxyCodeLine{1318       bc = bitcount(abs(scale*array(i,j,k)))}
\DoxyCodeLine{1319       subchk = subchk + bc}
\DoxyCodeLine{1320 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1321     \textcolor{keyword}{call }sum\_across\_pes(subchk)}
\DoxyCodeLine{1322     subchk=mod(subchk, bc\_modulus)}
\DoxyCodeLine{1323   \textcolor{keyword}{end function }subchk}
\DoxyCodeLine{1324 }
\DoxyCodeLine{1325   \textcolor{keyword}{subroutine }substats(HI, array, aMean, aMin, aMax)}
\DoxyCodeLine{1326     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{1327 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(HI\%isd:,HI\%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1328 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMean\textcolor{comment}{ !<  Array mean}}
\DoxyCodeLine{1329 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMin\textcolor{comment}{ !< Array minimum}}
\DoxyCodeLine{1330 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMax\textcolor{comment}{ !< Array maximum}}
\DoxyCodeLine{1331 }
\DoxyCodeLine{1332     \textcolor{keywordtype}{integer} :: i, j, k, n}
\DoxyCodeLine{1333 }
\DoxyCodeLine{1334     amin = array(hi\%isc,hi\%jsc,1)}
\DoxyCodeLine{1335     amax = array(hi\%isc,hi\%jsc,1)}
\DoxyCodeLine{1336     n = 0}
\DoxyCodeLine{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}
\DoxyCodeLine{1338       amin = min(amin, array(i,j,k))}
\DoxyCodeLine{1339       amax = max(amax, array(i,j,k))}
\DoxyCodeLine{1340       n = n + 1}
\DoxyCodeLine{1341 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1342     amean = reproducing\_sum(array(hi\%isc:hi\%iec,hi\%jsc:hi\%jec,:))}
\DoxyCodeLine{1343     \textcolor{keyword}{call }sum\_across\_pes(n)}
\DoxyCodeLine{1344     \textcolor{keyword}{call }min\_across\_pes(amin)}
\DoxyCodeLine{1345     \textcolor{keyword}{call }max\_across\_pes(amax)}
\DoxyCodeLine{1346     amean = amean / real(n)}
\DoxyCodeLine{1347   \textcolor{keyword}{end subroutine }substats}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em mesg} & Identifying messages \\
\hline
\mbox{\texttt{ in}}  & {\em hi} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em arraya} & The first array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em arrayb} & The second array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain. \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{453   \textcolor{keywordtype}{character(len=*)},                 \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Identifying messages}}
\DoxyCodeLine{454   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{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}}
\DoxyCodeLine{457   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}}
\DoxyCodeLine{458 \textcolor{comment}{                                                            !! symmetric computational domain.}}
\DoxyCodeLine{459   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{460   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{461 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}}
\DoxyCodeLine{462   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{463   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}}
\DoxyCodeLine{464 \textcolor{comment}{                                                              !! a scalar, rather than vector}}
\DoxyCodeLine{465 }
\DoxyCodeLine{466   \textcolor{keywordtype}{logical} :: sym}
\DoxyCodeLine{467   \textcolor{keywordtype}{logical} :: vector\_pair}
\DoxyCodeLine{468   \textcolor{keywordtype}{integer} :: turns}
\DoxyCodeLine{469   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI\_in}
\DoxyCodeLine{470 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: arrayA\_in, arrayB\_in}
\DoxyCodeLine{471 }
\DoxyCodeLine{472   vector\_pair = .true.}
\DoxyCodeLine{473   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair}
\DoxyCodeLine{474 }
\DoxyCodeLine{475   turns = hi\%turns}
\DoxyCodeLine{476   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{477     \textcolor{comment}{! Rotate field back to the input grid}}
\DoxyCodeLine{478     \textcolor{keyword}{allocate}(hi\_in)}
\DoxyCodeLine{479     \textcolor{keyword}{call }rotate\_hor\_index(hi, -\/turns, hi\_in)}
\DoxyCodeLine{480     \textcolor{keyword}{allocate}(arraya\_in(hi\_in\%IsdB:hi\_in\%IedB, hi\_in\%JsdB:hi\_in\%JedB))}
\DoxyCodeLine{481     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in\%IsdB:hi\_in\%IedB, hi\_in\%JsdB:hi\_in\%JedB))}
\DoxyCodeLine{482 }
\DoxyCodeLine{483     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}}
\DoxyCodeLine{484       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{485     \textcolor{keywordflow}{else}}
\DoxyCodeLine{486       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{487 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{488   \textcolor{keywordflow}{else}}
\DoxyCodeLine{489     hi\_in => hi}
\DoxyCodeLine{490     arraya\_in => arraya}
\DoxyCodeLine{491     arrayb\_in => arrayb}
\DoxyCodeLine{492 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{493 }
\DoxyCodeLine{494   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric}
\DoxyCodeLine{495 }
\DoxyCodeLine{496   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{497     \textcolor{keyword}{call }chksum\_b\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, symmetric=sym, \&}
\DoxyCodeLine{498                      omit\_corners=omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{499     \textcolor{keyword}{call }chksum\_b\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, symmetric=sym, \&}
\DoxyCodeLine{500                      omit\_corners=omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{501   \textcolor{keywordflow}{else}}
\DoxyCodeLine{502     \textcolor{keyword}{call }chksum\_b\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, symmetric=sym, scale=scale, \&}
\DoxyCodeLine{503                      logunit=logunit)}
\DoxyCodeLine{504     \textcolor{keyword}{call }chksum\_b\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, symmetric=sym, scale=scale, \&}
\DoxyCodeLine{505                      logunit=logunit)}
\DoxyCodeLine{506 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em mesg} & Identifying messages \\
\hline
\mbox{\texttt{ in}}  & {\em hi} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em arraya} & The first array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em arrayb} & The second array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain. \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{513   \textcolor{keywordtype}{character(len=*)},                    \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< Identifying messages}}
\DoxyCodeLine{514   \textcolor{keywordtype}{type}(hor\_index\_type),      \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{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}}
\DoxyCodeLine{517   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{518   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}}
\DoxyCodeLine{519 \textcolor{comment}{                                                               !! symmetric computational domain.}}
\DoxyCodeLine{520   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{521 \textcolor{keywordtype}{  real},                      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}}
\DoxyCodeLine{522   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{523   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}}
\DoxyCodeLine{524 \textcolor{comment}{                                                              !! a scalar, rather than vector}}
\DoxyCodeLine{525 }
\DoxyCodeLine{526   \textcolor{keywordtype}{logical} :: sym}
\DoxyCodeLine{527   \textcolor{keywordtype}{logical} :: vector\_pair}
\DoxyCodeLine{528   \textcolor{keywordtype}{integer} :: turns}
\DoxyCodeLine{529   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI\_in}
\DoxyCodeLine{530 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: arrayA\_in, arrayB\_in}
\DoxyCodeLine{531 }
\DoxyCodeLine{532   vector\_pair = .true.}
\DoxyCodeLine{533   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair}
\DoxyCodeLine{534 }
\DoxyCodeLine{535   turns = hi\%turns}
\DoxyCodeLine{536   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{537     \textcolor{comment}{! Rotate field back to the input grid}}
\DoxyCodeLine{538     \textcolor{keyword}{allocate}(hi\_in)}
\DoxyCodeLine{539     \textcolor{keyword}{call }rotate\_hor\_index(hi, -\/turns, hi\_in)}
\DoxyCodeLine{540     \textcolor{keyword}{allocate}(arraya\_in(hi\_in\%IsdB:hi\_in\%IedB, hi\_in\%JsdB:hi\_in\%JedB, \textcolor{keyword}{size}(arraya, 3)))}
\DoxyCodeLine{541     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in\%IsdB:hi\_in\%IedB, hi\_in\%JsdB:hi\_in\%JedB, \textcolor{keyword}{size}(arrayb, 3)))}
\DoxyCodeLine{542 }
\DoxyCodeLine{543     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}}
\DoxyCodeLine{544       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{545     \textcolor{keywordflow}{else}}
\DoxyCodeLine{546       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{547 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{548   \textcolor{keywordflow}{else}}
\DoxyCodeLine{549     hi\_in => hi}
\DoxyCodeLine{550     arraya\_in => arraya}
\DoxyCodeLine{551     arrayb\_in => arrayb}
\DoxyCodeLine{552 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{553 }
\DoxyCodeLine{554   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{555     \textcolor{keyword}{call }chksum\_b\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, symmetric, \&}
\DoxyCodeLine{556                      omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{557     \textcolor{keyword}{call }chksum\_b\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, symmetric, \&}
\DoxyCodeLine{558                      omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{559   \textcolor{keywordflow}{else}}
\DoxyCodeLine{560     \textcolor{keyword}{call }chksum\_b\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, symmetric=symmetric, scale=scale, \&}
\DoxyCodeLine{561                      logunit=logunit)}
\DoxyCodeLine{562     \textcolor{keyword}{call }chksum\_b\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, symmetric=symmetric, scale=scale, \&}
\DoxyCodeLine{563                      logunit=logunit)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em mesg} & Identifying messages \\
\hline
\mbox{\texttt{ in}}  & {\em hi} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em arraya} & The first array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em arrayb} & The second array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{202   \textcolor{keywordtype}{character(len=*)},                 \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< Identifying messages}}
\DoxyCodeLine{203   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{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}}
\DoxyCodeLine{206   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{207   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{208 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}}
\DoxyCodeLine{209   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{210   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}}
\DoxyCodeLine{211 \textcolor{comment}{                                                              !! a scalar, rather than vector}}
\DoxyCodeLine{212   \textcolor{keywordtype}{logical} :: vector\_pair}
\DoxyCodeLine{213   \textcolor{keywordtype}{integer} :: turns}
\DoxyCodeLine{214   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI\_in}
\DoxyCodeLine{215 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: arrayA\_in, arrayB\_in}
\DoxyCodeLine{216 }
\DoxyCodeLine{217   vector\_pair = .true.}
\DoxyCodeLine{218   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair}
\DoxyCodeLine{219 }
\DoxyCodeLine{220   turns = hi\%turns}
\DoxyCodeLine{221   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{222     \textcolor{comment}{! Rotate field back to the input grid}}
\DoxyCodeLine{223     \textcolor{keyword}{allocate}(hi\_in)}
\DoxyCodeLine{224     \textcolor{keyword}{call }rotate\_hor\_index(hi, -\/turns, hi\_in)}
\DoxyCodeLine{225     \textcolor{keyword}{allocate}(arraya\_in(hi\_in\%isd:hi\_in\%ied, hi\_in\%jsd:hi\_in\%jed))}
\DoxyCodeLine{226     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in\%isd:hi\_in\%ied, hi\_in\%jsd:hi\_in\%jed))}
\DoxyCodeLine{227 }
\DoxyCodeLine{228     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}}
\DoxyCodeLine{229       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{230     \textcolor{keywordflow}{else}}
\DoxyCodeLine{231       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{232 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{233   \textcolor{keywordflow}{else}}
\DoxyCodeLine{234     hi\_in => hi}
\DoxyCodeLine{235     arraya\_in => arraya}
\DoxyCodeLine{236     arrayb\_in => arrayb}
\DoxyCodeLine{237 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{238 }
\DoxyCodeLine{239   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{240     \textcolor{keyword}{call }chksum\_h\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, omit\_corners, \&}
\DoxyCodeLine{241                      scale=scale, logunit=logunit)}
\DoxyCodeLine{242     \textcolor{keyword}{call }chksum\_h\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, omit\_corners, \&}
\DoxyCodeLine{243                      scale=scale, logunit=logunit)}
\DoxyCodeLine{244   \textcolor{keywordflow}{else}}
\DoxyCodeLine{245     \textcolor{keyword}{call }chksum\_h\_2d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, scale=scale, logunit=logunit)}
\DoxyCodeLine{246     \textcolor{keyword}{call }chksum\_h\_2d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, scale=scale, logunit=logunit)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em mesg} & Identifying messages \\
\hline
\mbox{\texttt{ in}}  & {\em hi} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em arraya} & The first array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em arrayb} & The second array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{253   \textcolor{keywordtype}{character(len=*)},                    \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{ !< Identifying messages}}
\DoxyCodeLine{254   \textcolor{keywordtype}{type}(hor\_index\_type),      \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{   !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{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}}
\DoxyCodeLine{257   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{258   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{259 \textcolor{keywordtype}{  real},                      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}}
\DoxyCodeLine{260   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{261 }
\DoxyCodeLine{262   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe}}
\DoxyCodeLine{263 \textcolor{comment}{                                                              !! a scalar, rather than vector}}
\DoxyCodeLine{264   \textcolor{keywordtype}{logical} :: vector\_pair}
\DoxyCodeLine{265   \textcolor{keywordtype}{integer} :: turns}
\DoxyCodeLine{266   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI\_in}
\DoxyCodeLine{267 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: arrayA\_in, arrayB\_in}
\DoxyCodeLine{268 }
\DoxyCodeLine{269   vector\_pair = .true.}
\DoxyCodeLine{270   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair}
\DoxyCodeLine{271 }
\DoxyCodeLine{272   turns = hi\%turns}
\DoxyCodeLine{273   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{274     \textcolor{comment}{! Rotate field back to the input grid}}
\DoxyCodeLine{275     \textcolor{keyword}{allocate}(hi\_in)}
\DoxyCodeLine{276     \textcolor{keyword}{call }rotate\_hor\_index(hi, -\/turns, hi\_in)}
\DoxyCodeLine{277     \textcolor{keyword}{allocate}(arraya\_in(hi\_in\%isd:hi\_in\%ied, hi\_in\%jsd:hi\_in\%jed, \textcolor{keyword}{size}(arraya, 3)))}
\DoxyCodeLine{278     \textcolor{keyword}{allocate}(arrayb\_in(hi\_in\%isd:hi\_in\%ied, hi\_in\%jsd:hi\_in\%jed, \textcolor{keyword}{size}(arrayb, 3)))}
\DoxyCodeLine{279 }
\DoxyCodeLine{280     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}}
\DoxyCodeLine{281       \textcolor{keyword}{call }rotate\_vector(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{282     \textcolor{keywordflow}{else}}
\DoxyCodeLine{283       \textcolor{keyword}{call }rotate\_array\_pair(arraya, arrayb, -\/turns, arraya\_in, arrayb\_in)}
\DoxyCodeLine{284 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{285   \textcolor{keywordflow}{else}}
\DoxyCodeLine{286     hi\_in => hi}
\DoxyCodeLine{287     arraya\_in => arraya}
\DoxyCodeLine{288     arrayb\_in => arrayb}
\DoxyCodeLine{289 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{290 }
\DoxyCodeLine{291   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{292     \textcolor{keyword}{call }chksum\_h\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, haloshift, omit\_corners, \&}
\DoxyCodeLine{293                      scale=scale, logunit=logunit)}
\DoxyCodeLine{294     \textcolor{keyword}{call }chksum\_h\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, haloshift, omit\_corners, \&}
\DoxyCodeLine{295                      scale=scale, logunit=logunit)}
\DoxyCodeLine{296   \textcolor{keywordflow}{else}}
\DoxyCodeLine{297     \textcolor{keyword}{call }chksum\_h\_3d(arraya\_in, \textcolor{stringliteral}{'x '}//mesg, hi\_in, scale=scale, logunit=logunit)}
\DoxyCodeLine{298     \textcolor{keyword}{call }chksum\_h\_3d(arrayb\_in, \textcolor{stringliteral}{'y '}//mesg, hi\_in, scale=scale, logunit=logunit)}
\DoxyCodeLine{299 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{300 }
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em hi\+\_\+m} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em array\+\_\+m} & The array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain. \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


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


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


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1526   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\_m\textcolor{comment}{ !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1528   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}}
\DoxyCodeLine{1529   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{1530   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}}
\DoxyCodeLine{1531 \textcolor{comment}{                                                             !! symmetric computational domain.}}
\DoxyCodeLine{1532   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{1533 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}}
\DoxyCodeLine{1534   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{1535 }
\DoxyCodeLine{1536 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}}
\DoxyCodeLine{1537 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array}
\DoxyCodeLine{1538   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI   \textcolor{comment}{! Horizontal index bounds of the input grid}}
\DoxyCodeLine{1539 \textcolor{keywordtype}{  real} :: scaling}
\DoxyCodeLine{1540   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}}
\DoxyCodeLine{1541   \textcolor{keywordtype}{integer} :: i, j, k, Is}
\DoxyCodeLine{1542 \textcolor{keywordtype}{  real} :: aMean, aMin, aMax}
\DoxyCodeLine{1543   \textcolor{keywordtype}{integer} :: bc0, bcSW, bcSE, bcNW, bcNE, hshift}
\DoxyCodeLine{1544   \textcolor{keywordtype}{integer} :: bcN, bcS, bcE, bcW}
\DoxyCodeLine{1545   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats}
\DoxyCodeLine{1546   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}}
\DoxyCodeLine{1547 }
\DoxyCodeLine{1548   \textcolor{comment}{! Rotate array to the input grid}}
\DoxyCodeLine{1549   turns = hi\_m\%turns}
\DoxyCodeLine{1550   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1551     \textcolor{keyword}{allocate}(hi)}
\DoxyCodeLine{1552     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -\/turns, hi)}
\DoxyCodeLine{1553     \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1554       \textcolor{comment}{! Arrays originating from v-\/points must be handled by vchksum}}
\DoxyCodeLine{1555       \textcolor{keyword}{allocate}(array(hi\%isd:hi\%ied, hi\%JsdB:hi\%JedB, \textcolor{keyword}{size}(array\_m, 3)))}
\DoxyCodeLine{1556       \textcolor{keyword}{call }rotate\_array(array\_m, -\/turns, array)}
\DoxyCodeLine{1557       \textcolor{keyword}{call }vchksum(array, mesg, hi, haloshift, symmetric, omit\_corners, scale, logunit)}
\DoxyCodeLine{1558       \textcolor{keywordflow}{return}}
\DoxyCodeLine{1559     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1560       \textcolor{keyword}{allocate}(array(hi\%IsdB:hi\%IedB, hi\%jsd:hi\%jed, \textcolor{keyword}{size}(array\_m, 3)))}
\DoxyCodeLine{1561       \textcolor{keyword}{call }rotate\_array(array\_m, -\/turns, array)}
\DoxyCodeLine{1562 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1563   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1564     hi => hi\_m}
\DoxyCodeLine{1565     array => array\_m}
\DoxyCodeLine{1566 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1567 }
\DoxyCodeLine{1568   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1569     \textcolor{keywordflow}{if} (is\_nan(array(hi\%IscB:hi\%IecB,hi\%jsc:hi\%jec,:))) \&}
\DoxyCodeLine{1570       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))}
\DoxyCodeLine{1571 \textcolor{comment}{!   if (is\_NaN(array)) \&}}
\DoxyCodeLine{1572 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}}
\DoxyCodeLine{1573 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1574 }
\DoxyCodeLine{1575   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale}
\DoxyCodeLine{1576   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit}
\DoxyCodeLine{1577   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric}
\DoxyCodeLine{1578   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1579 }
\DoxyCodeLine{1580   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1581     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1582       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), \&}
\DoxyCodeLine{1583                                lbound(array,2):ubound(array,2), \&}
\DoxyCodeLine{1584                                lbound(array,3):ubound(array,3)) )}
\DoxyCodeLine{1585       rescaled\_array(:,:,:) = 0.0}
\DoxyCodeLine{1586       is = hi\%isc ; \textcolor{keywordflow}{if} (sym\_stats) is = hi\%isc-\/1}
\DoxyCodeLine{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}
\DoxyCodeLine{1588         rescaled\_array(i,j,k) = scale*array(i,j,k)}
\DoxyCodeLine{1589 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1590       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)}
\DoxyCodeLine{1591       \textcolor{keyword}{deallocate}(rescaled\_array)}
\DoxyCodeLine{1592     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1593       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)}
\DoxyCodeLine{1594 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1595     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1596       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-\/point:"}, amean, amin, amax, mesg, iounit)}
\DoxyCodeLine{1597 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1598 }
\DoxyCodeLine{1599   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1600 }
\DoxyCodeLine{1601   hshift = default\_shift}
\DoxyCodeLine{1602   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift}
\DoxyCodeLine{1603   \textcolor{keywordflow}{if} (hshift<0) hshift = hi\%ied-\/hi\%iec}
\DoxyCodeLine{1604 }
\DoxyCodeLine{1605   \textcolor{keywordflow}{if} ( hi\%isc-\/hshift<hi\%isd .or. hi\%iec+hshift>hi\%ied .or. \&}
\DoxyCodeLine{1606        hi\%jsc-\/hshift<hi\%jsd .or. hi\%jec+hshift>hi\%jed ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1607     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_3d: haloshift ='},hshift}
\DoxyCodeLine{1608     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_3d: isd,isc,iec,ied='},hi\%isd,hi\%isc,hi\%iec,hi\%ied}
\DoxyCodeLine{1609     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_u\_3d: jsd,jsc,jec,jed='},hi\%jsd,hi\%jsc,hi\%jec,hi\%jed}
\DoxyCodeLine{1610     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_u\_3d '}//trim(mesg))}
\DoxyCodeLine{1611 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1612 }
\DoxyCodeLine{1613   bc0 = subchk(array, hi, 0, 0, scaling)}
\DoxyCodeLine{1614 }
\DoxyCodeLine{1615   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric}
\DoxyCodeLine{1616 }
\DoxyCodeLine{1617   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1618     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-\/point:"}, bc0, mesg, iounit)}
\DoxyCodeLine{1619     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1620 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1621 }
\DoxyCodeLine{1622   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners}
\DoxyCodeLine{1623 }
\DoxyCodeLine{1624   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1625     bcw = subchk(array, hi, -\/hshift-\/1, 0, scaling)}
\DoxyCodeLine{1626     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg\_w(\textcolor{stringliteral}{"u-\/point:"}, bc0, bcw, mesg, iounit)}
\DoxyCodeLine{1627   \textcolor{keywordflow}{elseif} (do\_corners) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1628     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1629       bcsw = subchk(array, hi, -\/hshift-\/1, -\/hshift, scaling)}
\DoxyCodeLine{1630       bcnw = subchk(array, hi, -\/hshift-\/1, hshift, scaling)}
\DoxyCodeLine{1631     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1632       bcsw = subchk(array, hi, -\/hshift, -\/hshift, scaling)}
\DoxyCodeLine{1633       bcnw = subchk(array, hi, -\/hshift, hshift, scaling)}
\DoxyCodeLine{1634 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1635     bcse = subchk(array, hi, hshift, -\/hshift, scaling)}
\DoxyCodeLine{1636     bcne = subchk(array, hi, hshift, hshift, scaling)}
\DoxyCodeLine{1637 }
\DoxyCodeLine{1638     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1639       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"u-\/point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)}
\DoxyCodeLine{1640   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1641     bcs = subchk(array, hi, 0, -\/hshift, scaling)}
\DoxyCodeLine{1642     bce = subchk(array, hi, hshift, 0, scaling)}
\DoxyCodeLine{1643     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1644       bcw = subchk(array, hi, -\/hshift-\/1, 0, scaling)}
\DoxyCodeLine{1645     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1646       bcw = subchk(array, hi, -\/hshift, 0, scaling)}
\DoxyCodeLine{1647 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1648     bcn = subchk(array, hi, 0, hshift, scaling)}
\DoxyCodeLine{1649 }
\DoxyCodeLine{1650     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1651       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"u-\/point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)}
\DoxyCodeLine{1652 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1653 }
\DoxyCodeLine{1654   \textcolor{keyword}{contains}}
\DoxyCodeLine{1655 }
\DoxyCodeLine{1656   \textcolor{keyword}{integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)}
\DoxyCodeLine{1657     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{1658 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(HI\%IsdB:,HI\%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1659     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i-\/ direction array shift for this checksum}}
\DoxyCodeLine{1660     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j-\/ direction array shift for this checksum}}
\DoxyCodeLine{1661 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}}
\DoxyCodeLine{1662     \textcolor{keywordtype}{integer} :: i, j, k, bc}
\DoxyCodeLine{1663     subchk = 0}
\DoxyCodeLine{1664     \textcolor{comment}{! This line deliberately uses the h-\/point computational domain.}}
\DoxyCodeLine{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}
\DoxyCodeLine{1666       bc = bitcount(abs(scale*array(i,j,k)))}
\DoxyCodeLine{1667       subchk = subchk + bc}
\DoxyCodeLine{1668 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1669     \textcolor{keyword}{call }sum\_across\_pes(subchk)}
\DoxyCodeLine{1670     subchk=mod(subchk, bc\_modulus)}
\DoxyCodeLine{1671   \textcolor{keyword}{end function }subchk}
\DoxyCodeLine{1672 }
\DoxyCodeLine{1673   \textcolor{keyword}{subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)}
\DoxyCodeLine{1674     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{1675 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(HI\%IsdB:,HI\%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1676     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}}
\DoxyCodeLine{1677 \textcolor{comment}{                                              !! full symmetric computational domain.}}
\DoxyCodeLine{1678 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMean\textcolor{comment}{ !< Array mean}}
\DoxyCodeLine{1679 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMin\textcolor{comment}{ !< Array minimum}}
\DoxyCodeLine{1680 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMax\textcolor{comment}{ !< Array maximum}}
\DoxyCodeLine{1681 }
\DoxyCodeLine{1682     \textcolor{keywordtype}{integer} :: i, j, k, n, IsB}
\DoxyCodeLine{1683 }
\DoxyCodeLine{1684     isb = hi\%isc ; \textcolor{keywordflow}{if} (sym\_stats) isb = hi\%isc-\/1}
\DoxyCodeLine{1685 }
\DoxyCodeLine{1686     amin = array(hi\%isc,hi\%jsc,1) ; amax = amin}
\DoxyCodeLine{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}
\DoxyCodeLine{1688       amin = min(amin, array(i,j,k))}
\DoxyCodeLine{1689       amax = max(amax, array(i,j,k))}
\DoxyCodeLine{1690 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1691     \textcolor{comment}{! This line deliberately uses the h-\/point computational domain.}}
\DoxyCodeLine{1692     amean = reproducing\_sum(array(hi\%isc:hi\%iec,hi\%jsc:hi\%jec,:))}
\DoxyCodeLine{1693     n = (1 + hi\%jec -\/ hi\%jsc) * (1 + hi\%iec -\/ hi\%isc) * \textcolor{keyword}{size}(array,3)}
\DoxyCodeLine{1694     \textcolor{keyword}{call }sum\_across\_pes(n)}
\DoxyCodeLine{1695     \textcolor{keyword}{call }min\_across\_pes(amin)}
\DoxyCodeLine{1696     \textcolor{keyword}{call }max\_across\_pes(amax)}
\DoxyCodeLine{1697     amean = amean / real(n)}
\DoxyCodeLine{1698   \textcolor{keyword}{end subroutine }substats}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em mesg} & Identifying messages \\
\hline
\mbox{\texttt{ in}}  & {\em hi} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em arrayu} & The u-\/component array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em arrayv} & The v-\/component array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain. \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for these arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{737   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Identifying messages}}
\DoxyCodeLine{738   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{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}}
\DoxyCodeLine{741   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{742   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}}
\DoxyCodeLine{743 \textcolor{comment}{                                                             !! symmetric computational domain.}}
\DoxyCodeLine{744   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{745 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for these arrays.}}
\DoxyCodeLine{746   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{747   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe a}}
\DoxyCodeLine{748 \textcolor{comment}{                                                               !! a scalar, rather than vector}}
\DoxyCodeLine{749   \textcolor{keywordtype}{logical} :: vector\_pair}
\DoxyCodeLine{750   \textcolor{keywordtype}{integer} :: turns}
\DoxyCodeLine{751   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI\_in}
\DoxyCodeLine{752 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: arrayU\_in, arrayV\_in}
\DoxyCodeLine{753 }
\DoxyCodeLine{754   vector\_pair = .true.}
\DoxyCodeLine{755   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair}
\DoxyCodeLine{756 }
\DoxyCodeLine{757   turns = hi\%turns}
\DoxyCodeLine{758   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{759     \textcolor{comment}{! Rotate field back to the input grid}}
\DoxyCodeLine{760     \textcolor{keyword}{allocate}(hi\_in)}
\DoxyCodeLine{761     \textcolor{keyword}{call }rotate\_hor\_index(hi, -\/turns, hi\_in)}
\DoxyCodeLine{762     \textcolor{keyword}{allocate}(arrayu\_in(hi\_in\%IsdB:hi\_in\%IedB, hi\_in\%jsd:hi\_in\%jed))}
\DoxyCodeLine{763     \textcolor{keyword}{allocate}(arrayv\_in(hi\_in\%isd:hi\_in\%ied, hi\_in\%JsdB:hi\_in\%JedB))}
\DoxyCodeLine{764 }
\DoxyCodeLine{765     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}}
\DoxyCodeLine{766       \textcolor{keyword}{call }rotate\_vector(arrayu, arrayv, -\/turns, arrayu\_in, arrayv\_in)}
\DoxyCodeLine{767     \textcolor{keywordflow}{else}}
\DoxyCodeLine{768       \textcolor{keyword}{call }rotate\_array\_pair(arrayu, arrayv, -\/turns, arrayu\_in, arrayv\_in)}
\DoxyCodeLine{769 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{770   \textcolor{keywordflow}{else}}
\DoxyCodeLine{771     hi\_in => hi}
\DoxyCodeLine{772     arrayu\_in => arrayu}
\DoxyCodeLine{773     arrayv\_in => arrayv}
\DoxyCodeLine{774 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{775 }
\DoxyCodeLine{776   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{777     \textcolor{keyword}{call }chksum\_u\_2d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, haloshift, symmetric, \&}
\DoxyCodeLine{778                      omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{779     \textcolor{keyword}{call }chksum\_v\_2d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, haloshift, symmetric, \&}
\DoxyCodeLine{780                      omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{781   \textcolor{keywordflow}{else}}
\DoxyCodeLine{782     \textcolor{keyword}{call }chksum\_u\_2d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, symmetric=symmetric, \&}
\DoxyCodeLine{783                      scale=scale, logunit=logunit)}
\DoxyCodeLine{784     \textcolor{keyword}{call }chksum\_v\_2d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, symmetric=symmetric, \&}
\DoxyCodeLine{785                      scale=scale, logunit=logunit)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em mesg} & Identifying messages \\
\hline
\mbox{\texttt{ in}}  & {\em hi} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em arrayu} & The u-\/component array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em arrayv} & The v-\/component array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain. \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for these arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{792   \textcolor{keywordtype}{character(len=*)},                    \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{   !< Identifying messages}}
\DoxyCodeLine{793   \textcolor{keywordtype}{type}(hor\_index\_type),      \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{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}}
\DoxyCodeLine{796   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{797   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}}
\DoxyCodeLine{798 \textcolor{comment}{                                                               !! symmetric computational domain.}}
\DoxyCodeLine{799   \textcolor{keywordtype}{logical},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{800 \textcolor{keywordtype}{  real},                      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for these arrays.}}
\DoxyCodeLine{801   \textcolor{keywordtype}{integer},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{802   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scalar\_pair\textcolor{comment}{ !< If true, then the arrays describe a}}
\DoxyCodeLine{803 \textcolor{comment}{                                                               !! a scalar, rather than vector}}
\DoxyCodeLine{804   \textcolor{keywordtype}{logical} :: vector\_pair}
\DoxyCodeLine{805   \textcolor{keywordtype}{integer} :: turns}
\DoxyCodeLine{806   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI\_in}
\DoxyCodeLine{807 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: arrayU\_in, arrayV\_in}
\DoxyCodeLine{808 }
\DoxyCodeLine{809   vector\_pair = .true.}
\DoxyCodeLine{810   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scalar\_pair)) vector\_pair = .not. scalar\_pair}
\DoxyCodeLine{811 }
\DoxyCodeLine{812   turns = hi\%turns}
\DoxyCodeLine{813   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{814     \textcolor{comment}{! Rotate field back to the input grid}}
\DoxyCodeLine{815     \textcolor{keyword}{allocate}(hi\_in)}
\DoxyCodeLine{816     \textcolor{keyword}{call }rotate\_hor\_index(hi, -\/turns, hi\_in)}
\DoxyCodeLine{817     \textcolor{keyword}{allocate}(arrayu\_in(hi\_in\%IsdB:hi\_in\%IedB, hi\_in\%jsd:hi\_in\%jed, \textcolor{keyword}{size}(arrayu, 3)))}
\DoxyCodeLine{818     \textcolor{keyword}{allocate}(arrayv\_in(hi\_in\%isd:hi\_in\%ied, hi\_in\%JsdB:hi\_in\%JedB, \textcolor{keyword}{size}(arrayv, 3)))}
\DoxyCodeLine{819 }
\DoxyCodeLine{820     \textcolor{keywordflow}{if} (vector\_pair) \textcolor{keywordflow}{then}}
\DoxyCodeLine{821       \textcolor{keyword}{call }rotate\_vector(arrayu, arrayv, -\/turns, arrayu\_in, arrayv\_in)}
\DoxyCodeLine{822     \textcolor{keywordflow}{else}}
\DoxyCodeLine{823       \textcolor{keyword}{call }rotate\_array\_pair(arrayu, arrayv, -\/turns, arrayu\_in, arrayv\_in)}
\DoxyCodeLine{824 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{825   \textcolor{keywordflow}{else}}
\DoxyCodeLine{826     hi\_in => hi}
\DoxyCodeLine{827     arrayu\_in => arrayu}
\DoxyCodeLine{828     arrayv\_in => arrayv}
\DoxyCodeLine{829 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{830 }
\DoxyCodeLine{831   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{832     \textcolor{keyword}{call }chksum\_u\_3d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, haloshift, symmetric, \&}
\DoxyCodeLine{833                      omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{834     \textcolor{keyword}{call }chksum\_v\_3d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, haloshift, symmetric, \&}
\DoxyCodeLine{835                      omit\_corners, scale=scale, logunit=logunit)}
\DoxyCodeLine{836   \textcolor{keywordflow}{else}}
\DoxyCodeLine{837     \textcolor{keyword}{call }chksum\_u\_3d(arrayu\_in, \textcolor{stringliteral}{'u '}//mesg, hi\_in, symmetric=symmetric, \&}
\DoxyCodeLine{838                      scale=scale, logunit=logunit)}
\DoxyCodeLine{839     \textcolor{keyword}{call }chksum\_v\_3d(arrayv\_in, \textcolor{stringliteral}{'v '}//mesg, hi\_in, symmetric=symmetric, \&}
\DoxyCodeLine{840                      scale=scale, logunit=logunit)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em hi\+\_\+m} & A horizontal index type \\
\hline
\mbox{\texttt{ in}}  & {\em array\+\_\+m} & The array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message \\
\hline
\mbox{\texttt{ in}}  & {\em haloshift} & The width of halos to check (default 0) \\
\hline
\mbox{\texttt{ in}}  & {\em symmetric} & If true, do the checksums on the full symmetric computational domain. \\
\hline
\mbox{\texttt{ in}}  & {\em omit\+\_\+corners} & If true, avoid checking diagonal shifts \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


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


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


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


\begin{DoxyCode}{0}
\DoxyCodeLine{1705   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\_m\textcolor{comment}{ !< A horizontal index type}}
\DoxyCodeLine{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}}
\DoxyCodeLine{1707   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}}
\DoxyCodeLine{1708   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}}
\DoxyCodeLine{1709   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}}
\DoxyCodeLine{1710 \textcolor{comment}{                                                             !! symmetric computational domain.}}
\DoxyCodeLine{1711   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}}
\DoxyCodeLine{1712 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}}
\DoxyCodeLine{1713   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}}
\DoxyCodeLine{1714 }
\DoxyCodeLine{1715 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}}
\DoxyCodeLine{1716 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array}
\DoxyCodeLine{1717   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI   \textcolor{comment}{! Horizontal index bounds of the input grid}}
\DoxyCodeLine{1718 \textcolor{keywordtype}{  real} :: scaling}
\DoxyCodeLine{1719   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}}
\DoxyCodeLine{1720   \textcolor{keywordtype}{integer} :: i, j, k, Js}
\DoxyCodeLine{1721   \textcolor{keywordtype}{integer} :: bc0, bcSW, bcSE, bcNW, bcNE, hshift}
\DoxyCodeLine{1722   \textcolor{keywordtype}{integer} :: bcN, bcS, bcE, bcW}
\DoxyCodeLine{1723 \textcolor{keywordtype}{  real} :: aMean, aMin, aMax}
\DoxyCodeLine{1724   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats}
\DoxyCodeLine{1725   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}}
\DoxyCodeLine{1726 }
\DoxyCodeLine{1727   \textcolor{comment}{! Rotate array to the input grid}}
\DoxyCodeLine{1728   turns = hi\_m\%turns}
\DoxyCodeLine{1729   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1730     \textcolor{keyword}{allocate}(hi)}
\DoxyCodeLine{1731     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -\/turns, hi)}
\DoxyCodeLine{1732     \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1733       \textcolor{comment}{! Arrays originating from u-\/points must be handled by uchksum}}
\DoxyCodeLine{1734       \textcolor{keyword}{allocate}(array(hi\%IsdB:hi\%IedB, hi\%jsd:hi\%jed, \textcolor{keyword}{size}(array\_m, 3)))}
\DoxyCodeLine{1735       \textcolor{keyword}{call }rotate\_array(array\_m, -\/turns, array)}
\DoxyCodeLine{1736       \textcolor{keyword}{call }uchksum(array, mesg, hi, haloshift, symmetric, omit\_corners, scale, logunit)}
\DoxyCodeLine{1737       \textcolor{keywordflow}{return}}
\DoxyCodeLine{1738     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1739       \textcolor{keyword}{allocate}(array(hi\%isd:hi\%ied, hi\%JsdB:hi\%JedB, \textcolor{keyword}{size}(array\_m, 3)))}
\DoxyCodeLine{1740       \textcolor{keyword}{call }rotate\_array(array\_m, -\/turns, array)}
\DoxyCodeLine{1741 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1742   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1743     hi => hi\_m}
\DoxyCodeLine{1744     array => array\_m}
\DoxyCodeLine{1745 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1746 }
\DoxyCodeLine{1747   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1748     \textcolor{keywordflow}{if} (is\_nan(array(hi\%isc:hi\%iec,hi\%JscB:hi\%JecB,:))) \&}
\DoxyCodeLine{1749       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))}
\DoxyCodeLine{1750 \textcolor{comment}{!   if (is\_NaN(array)) \&}}
\DoxyCodeLine{1751 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}}
\DoxyCodeLine{1752 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1753 }
\DoxyCodeLine{1754   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale}
\DoxyCodeLine{1755   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit}
\DoxyCodeLine{1756   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric}
\DoxyCodeLine{1757   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1758 }
\DoxyCodeLine{1759   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1760     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1761       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), \&}
\DoxyCodeLine{1762                                lbound(array,2):ubound(array,2), \&}
\DoxyCodeLine{1763                                lbound(array,3):ubound(array,3)) )}
\DoxyCodeLine{1764       rescaled\_array(:,:,:) = 0.0}
\DoxyCodeLine{1765       js = hi\%jsc ; \textcolor{keywordflow}{if} (sym\_stats) js = hi\%jsc-\/1}
\DoxyCodeLine{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}
\DoxyCodeLine{1767         rescaled\_array(i,j,k) = scale*array(i,j,k)}
\DoxyCodeLine{1768 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1769       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)}
\DoxyCodeLine{1770       \textcolor{keyword}{deallocate}(rescaled\_array)}
\DoxyCodeLine{1771     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1772       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)}
\DoxyCodeLine{1773 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1774     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1775       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-\/point:"}, amean, amin, amax, mesg, iounit)}
\DoxyCodeLine{1776 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1777 }
\DoxyCodeLine{1778   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1779 }
\DoxyCodeLine{1780   hshift = default\_shift}
\DoxyCodeLine{1781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift}
\DoxyCodeLine{1782   \textcolor{keywordflow}{if} (hshift<0) hshift = hi\%ied-\/hi\%iec}
\DoxyCodeLine{1783 }
\DoxyCodeLine{1784   \textcolor{keywordflow}{if} ( hi\%isc-\/hshift<hi\%isd .or. hi\%iec+hshift>hi\%ied .or. \&}
\DoxyCodeLine{1785        hi\%jsc-\/hshift<hi\%jsd .or. hi\%jec+hshift>hi\%jed ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1786     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: haloshift ='},hshift}
\DoxyCodeLine{1787     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: isd,isc,iec,ied='},hi\%isd,hi\%isc,hi\%iec,hi\%ied}
\DoxyCodeLine{1788     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: jsd,jsc,jec,jed='},hi\%jsd,hi\%jsc,hi\%jec,hi\%jed}
\DoxyCodeLine{1789     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_v\_3d '}//trim(mesg))}
\DoxyCodeLine{1790 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1791 }
\DoxyCodeLine{1792   bc0 = subchk(array, hi, 0, 0, scaling)}
\DoxyCodeLine{1793 }
\DoxyCodeLine{1794   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric}
\DoxyCodeLine{1795 }
\DoxyCodeLine{1796   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1797     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-\/point:"}, bc0, mesg, iounit)}
\DoxyCodeLine{1798     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1799 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1800 }
\DoxyCodeLine{1801   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners}
\DoxyCodeLine{1802 }
\DoxyCodeLine{1803   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1804     bcs = subchk(array, hi, 0, -\/hshift-\/1, scaling)}
\DoxyCodeLine{1805     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg\_s(\textcolor{stringliteral}{"v-\/point:"}, bc0, bcs, mesg, iounit)}
\DoxyCodeLine{1806   \textcolor{keywordflow}{elseif} (do\_corners) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1807     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1808       bcsw = subchk(array, hi, -\/hshift, -\/hshift-\/1, scaling)}
\DoxyCodeLine{1809       bcse = subchk(array, hi, hshift, -\/hshift-\/1, scaling)}
\DoxyCodeLine{1810     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1811       bcsw = subchk(array, hi, -\/hshift, -\/hshift, scaling)}
\DoxyCodeLine{1812       bcse = subchk(array, hi, hshift, -\/hshift, scaling)}
\DoxyCodeLine{1813 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1814     bcnw = subchk(array, hi, -\/hshift, hshift, scaling)}
\DoxyCodeLine{1815     bcne = subchk(array, hi, hshift, hshift, scaling)}
\DoxyCodeLine{1816 }
\DoxyCodeLine{1817     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1818       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-\/point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)}
\DoxyCodeLine{1819   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1820     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1821       bcs = subchk(array, hi, 0, -\/hshift-\/1, scaling)}
\DoxyCodeLine{1822     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1823       bcs = subchk(array, hi, 0, -\/hshift, scaling)}
\DoxyCodeLine{1824 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1825     bce = subchk(array, hi, hshift, 0, scaling)}
\DoxyCodeLine{1826     bcw = subchk(array, hi, -\/hshift, 0, scaling)}
\DoxyCodeLine{1827     bcn = subchk(array, hi, 0, hshift, scaling)}
\DoxyCodeLine{1828 }
\DoxyCodeLine{1829     \textcolor{keywordflow}{if} (is\_root\_pe()) \&}
\DoxyCodeLine{1830       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"v-\/point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)}
\DoxyCodeLine{1831 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1832 }
\DoxyCodeLine{1833   \textcolor{keyword}{contains}}
\DoxyCodeLine{1834 }
\DoxyCodeLine{1835   \textcolor{keyword}{integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)}
\DoxyCodeLine{1836     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{1837 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(HI\%isd:,HI\%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1838     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i-\/ direction array shift for this checksum}}
\DoxyCodeLine{1839     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j-\/ direction array shift for this checksum}}
\DoxyCodeLine{1840 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}}
\DoxyCodeLine{1841     \textcolor{keywordtype}{integer} :: i, j, k, bc}
\DoxyCodeLine{1842     subchk = 0}
\DoxyCodeLine{1843     \textcolor{comment}{! This line deliberately uses the h-\/point computational domain.}}
\DoxyCodeLine{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}
\DoxyCodeLine{1845       bc = bitcount(abs(scale*array(i,j,k)))}
\DoxyCodeLine{1846       subchk = subchk + bc}
\DoxyCodeLine{1847 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1848     \textcolor{keyword}{call }sum\_across\_pes(subchk)}
\DoxyCodeLine{1849     subchk=mod(subchk, bc\_modulus)}
\DoxyCodeLine{1850   \textcolor{keyword}{end function }subchk}
\DoxyCodeLine{1851 }
\DoxyCodeLine{1852   \textcolor{comment}{!subroutine subStats(HI, array, mesg, sym\_stats)}}
\DoxyCodeLine{1853   \textcolor{keyword}{subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)}
\DoxyCodeLine{1854     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}}
\DoxyCodeLine{1855 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{dimension(HI\%isd:,HI\%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}}
\DoxyCodeLine{1856     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}}
\DoxyCodeLine{1857 \textcolor{comment}{                                              !! full symmetric computational domain.}}
\DoxyCodeLine{1858 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMean\textcolor{comment}{   !< Mean of array over domain}}
\DoxyCodeLine{1859 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMin\textcolor{comment}{    !< Minimum of array over domain}}
\DoxyCodeLine{1860 \textcolor{keywordtype}{    real}, \textcolor{keywordtype}{intent(out)} :: aMax\textcolor{comment}{    !< Maximum of array over domain}}
\DoxyCodeLine{1861 }
\DoxyCodeLine{1862     \textcolor{keywordtype}{integer} :: i, j, k, n, JsB}
\DoxyCodeLine{1863 }
\DoxyCodeLine{1864     jsb = hi\%jsc ; \textcolor{keywordflow}{if} (sym\_stats) jsb = hi\%jsc-\/1}
\DoxyCodeLine{1865 }
\DoxyCodeLine{1866     amin = array(hi\%isc,hi\%jsc,1) ; amax = amin}
\DoxyCodeLine{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}
\DoxyCodeLine{1868       amin = min(amin, array(i,j,k))}
\DoxyCodeLine{1869       amax = max(amax, array(i,j,k))}
\DoxyCodeLine{1870 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1871     \textcolor{comment}{! This line deliberately uses the h-\/point computational domain.}}
\DoxyCodeLine{1872     amean = reproducing\_sum(array(hi\%isc:hi\%iec,hi\%jsc:hi\%jec,:))}
\DoxyCodeLine{1873     n = (1 + hi\%jec -\/ hi\%jsc) * (1 + hi\%iec -\/ hi\%isc) * \textcolor{keyword}{size}(array,3)}
\DoxyCodeLine{1874     \textcolor{keyword}{call }sum\_across\_pes(n)}
\DoxyCodeLine{1875     \textcolor{keyword}{call }min\_across\_pes(amin)}
\DoxyCodeLine{1876     \textcolor{keyword}{call }max\_across\_pes(amax)}
\DoxyCodeLine{1877     amean = amean / real(n)}
\DoxyCodeLine{1878   \textcolor{keyword}{end subroutine }substats}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ 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}{0}
\DoxyCodeLine{2002 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The value to be checked for NaNs.}}
\DoxyCodeLine{2003   \textcolor{keywordtype}{logical} :: is\_NaN\_0d}
\DoxyCodeLine{2004 }
\DoxyCodeLine{2005  \textcolor{comment}{!is\_NaN\_0d = (((x < 0.0) .and. (x >= 0.0)) .or. \&}}
\DoxyCodeLine{2006  \textcolor{comment}{!          (.not.(x < 0.0) .and. .not.(x >= 0.0)))}}
\DoxyCodeLine{2007   \textcolor{keywordflow}{if} (((x < 0.0) .and. (x >= 0.0)) .or. \&}
\DoxyCodeLine{2008             (.not.(x < 0.0) .and. .not.(x >= 0.0))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2009     is\_nan\_0d = .true.}
\DoxyCodeLine{2010   \textcolor{keywordflow}{else}}
\DoxyCodeLine{2011     is\_nan\_0d = .false.}
\DoxyCodeLine{2012 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em x} & The array to be checked for Na\+Ns. \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{2018 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The array to be checked for NaNs.}}
\DoxyCodeLine{2019   \textcolor{keywordtype}{logical},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: skip\_mpp\textcolor{comment}{  !< If true, only check this array only}}
\DoxyCodeLine{2020 \textcolor{comment}{                                              !! on the local PE (default false).}}
\DoxyCodeLine{2021   \textcolor{keywordtype}{logical} :: is\_NaN\_1d}
\DoxyCodeLine{2022 }
\DoxyCodeLine{2023   \textcolor{keywordtype}{integer} :: i, n}
\DoxyCodeLine{2024   \textcolor{keywordtype}{logical} :: call\_mpp}
\DoxyCodeLine{2025 }
\DoxyCodeLine{2026   n = 0}
\DoxyCodeLine{2027   \textcolor{keywordflow}{do} i = lbound(x,1), ubound(x,1)}
\DoxyCodeLine{2028     \textcolor{keywordflow}{if} (is\_nan\_0d(x(i))) n = n + 1}
\DoxyCodeLine{2029 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2030   call\_mpp = .true.}
\DoxyCodeLine{2031   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(skip\_mpp)) call\_mpp = .not.skip\_mpp}
\DoxyCodeLine{2032 }
\DoxyCodeLine{2033   \textcolor{keywordflow}{if} (call\_mpp) \textcolor{keyword}{call }sum\_across\_pes(n)}
\DoxyCodeLine{2034   is\_nan\_1d = .false.}
\DoxyCodeLine{2035   \textcolor{keywordflow}{if} (n>0) is\_nan\_1d = .true.}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ 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}{0}
\DoxyCodeLine{2041 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The array to be checked for NaNs.}}
\DoxyCodeLine{2042   \textcolor{keywordtype}{logical} :: is\_NaN\_2d}
\DoxyCodeLine{2043 }
\DoxyCodeLine{2044   \textcolor{keywordtype}{integer} :: i, j, n}
\DoxyCodeLine{2045 }
\DoxyCodeLine{2046   n = 0}
\DoxyCodeLine{2047   \textcolor{keywordflow}{do} j = lbound(x,2), ubound(x,2) ; \textcolor{keywordflow}{do} i = lbound(x,1), ubound(x,1)}
\DoxyCodeLine{2048     \textcolor{keywordflow}{if} (is\_nan\_0d(x(i,j))) n = n + 1}
\DoxyCodeLine{2049 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2050   \textcolor{keyword}{call }sum\_across\_pes(n)}
\DoxyCodeLine{2051   is\_nan\_2d = .false.}
\DoxyCodeLine{2052   \textcolor{keywordflow}{if} (n>0) is\_nan\_2d = .true.}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ 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}{0}
\DoxyCodeLine{2058 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< The array to be checked for NaNs.}}
\DoxyCodeLine{2059   \textcolor{keywordtype}{logical} :: is\_NaN\_3d}
\DoxyCodeLine{2060 }
\DoxyCodeLine{2061   \textcolor{keywordtype}{integer} :: i, j, k, n}
\DoxyCodeLine{2062 }
\DoxyCodeLine{2063   n = 0}
\DoxyCodeLine{2064   \textcolor{keywordflow}{do} k = lbound(x,3), ubound(x,3)}
\DoxyCodeLine{2065     \textcolor{keywordflow}{do} j = lbound(x,2), ubound(x,2) ; \textcolor{keywordflow}{do} i = lbound(x,1), ubound(x,1)}
\DoxyCodeLine{2066       \textcolor{keywordflow}{if} (is\_nan\_0d(x(i,j,k))) n = n + 1}
\DoxyCodeLine{2067 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2068 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2069   \textcolor{keyword}{call }sum\_across\_pes(n)}
\DoxyCodeLine{2070   is\_nan\_3d = .false.}
\DoxyCodeLine{2071   \textcolor{keywordflow}{if} (n>0) is\_nan\_3d = .true.}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ 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}{0}
\DoxyCodeLine{2171   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{2172 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{2173 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{2174 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_checksums"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{2175 }
\DoxyCodeLine{2176   \textcolor{keyword}{call }log\_version(param\_file, mdl, version)}
\DoxyCodeLine{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}}
\doxysubsubsection{\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{\texttt{ in}}  & {\em array} & The array to be checksummed \\
\hline
\mbox{\texttt{ in}}  & {\em mesg} & An identifying message \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor for this array. \\
\hline
\mbox{\texttt{ in}}  & {\em logunit} & IO unit for checksum logging \\
\hline
\end{DoxyParams}


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


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

\end{DoxyCode}
