\hypertarget{interfacemom__checksums_1_1qchksum}{}\doxysection{mom\+\_\+checksums\+::qchksum Interface Reference}
\label{interfacemom__checksums_1_1qchksum}\index{mom\_checksums::qchksum@{mom\_checksums::qchksum}}


\doxysubsection{Detailed Description}
This is an older interface that has been renamed Bchksum. 

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

\doxysubsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{interfacemom__checksums_1_1qchksum_a2ff682c3708ae99b3edcec4d0673e548}{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{interfacemom__checksums_1_1qchksum_a4ebdbc48705d623cc08692c5ab4d5980}{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}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This is an older interface that has been renamed Bchksum. 

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



\doxysubsection{Functions and subroutines}
\mbox{\Hypertarget{interfacemom__checksums_1_1qchksum_a2ff682c3708ae99b3edcec4d0673e548}\label{interfacemom__checksums_1_1qchksum_a2ff682c3708ae99b3edcec4d0673e548}} 
\index{mom\_checksums::qchksum@{mom\_checksums::qchksum}!chksum\_b\_2d@{chksum\_b\_2d}}
\index{chksum\_b\_2d@{chksum\_b\_2d}!mom\_checksums::qchksum@{mom\_checksums::qchksum}}
\doxysubsubsection{\texorpdfstring{chksum\_b\_2d()}{chksum\_b\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::qchksum\+::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 568 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{interfacemom__checksums_1_1qchksum_a4ebdbc48705d623cc08692c5ab4d5980}\label{interfacemom__checksums_1_1qchksum_a4ebdbc48705d623cc08692c5ab4d5980}} 
\index{mom\_checksums::qchksum@{mom\_checksums::qchksum}!chksum\_b\_3d@{chksum\_b\_3d}}
\index{chksum\_b\_3d@{chksum\_b\_3d}!mom\_checksums::qchksum@{mom\_checksums::qchksum}}
\doxysubsubsection{\texorpdfstring{chksum\_b\_3d()}{chksum\_b\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::qchksum\+::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 1352 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}


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}
