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


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

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

\subsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \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 \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}


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

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



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


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


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


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


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


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}
