\hypertarget{interfacemom__checksums_1_1hchksum}{}\section{mom\+\_\+checksums\+::hchksum Interface Reference}
\label{interfacemom__checksums_1_1hchksum}\index{mom\_checksums::hchksum@{mom\_checksums::hchksum}}


\subsection{Detailed Description}
Checksums an array (2d or 3d) staggered at tracer points. 

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

\subsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{interfacemom__checksums_1_1hchksum_a040890630933e72e84c9cb1e05772ec6}{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{interfacemom__checksums_1_1hchksum_a792bb6c40192575ba9fd1d72077ee86d}{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}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Checksums an array (2d or 3d) staggered at tracer points. 

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



\subsection{Functions and subroutines}
\mbox{\Hypertarget{interfacemom__checksums_1_1hchksum_a040890630933e72e84c9cb1e05772ec6}\label{interfacemom__checksums_1_1hchksum_a040890630933e72e84c9cb1e05772ec6}} 
\index{mom\_checksums::hchksum@{mom\_checksums::hchksum}!chksum\_h\_2d@{chksum\_h\_2d}}
\index{chksum\_h\_2d@{chksum\_h\_2d}!mom\_checksums::hchksum@{mom\_checksums::hchksum}}
\subsubsection{\texorpdfstring{chksum\_h\_2d()}{chksum\_h\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::hchksum\+::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{interfacemom__checksums_1_1hchksum_a792bb6c40192575ba9fd1d72077ee86d}\label{interfacemom__checksums_1_1hchksum_a792bb6c40192575ba9fd1d72077ee86d}} 
\index{mom\_checksums::hchksum@{mom\_checksums::hchksum}!chksum\_h\_3d@{chksum\_h\_3d}}
\index{chksum\_h\_3d@{chksum\_h\_3d}!mom\_checksums::hchksum@{mom\_checksums::hchksum}}
\subsubsection{\texorpdfstring{chksum\_h\_3d()}{chksum\_h\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::hchksum\+::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}


The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/home/cermak/src/\+M\+O\+M6.\+devrob/src/framework/M\+O\+M\+\_\+checksums.\+F90\end{DoxyCompactItemize}
