\hypertarget{interfacemom__checksums_1_1uchksum}{}\section{mom\+\_\+checksums\+:\+:uchksum Interface Reference}
\label{interfacemom__checksums_1_1uchksum}\index{mom\+\_\+checksums\+::uchksum@{mom\+\_\+checksums\+::uchksum}}


\subsection{Detailed Description}
Checksums an array (2d or 3d) staggered at C-\/grid u points. 

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

\subsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{interfacemom__checksums_1_1uchksum_adddc2d74992684e0e1fe9134fd350a32}{chksum\+\_\+u\+\_\+2d}} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 2d array staggered at C-\/grid u points. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{interfacemom__checksums_1_1uchksum_a68d90a17a90b5b1fa898066ef562533a}{chksum\+\_\+u\+\_\+3d}} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, symmetric, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 3d array staggered at C-\/grid u points. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Checksums an array (2d or 3d) staggered at C-\/grid u points. 

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



\subsection{Functions and subroutines}
\mbox{\Hypertarget{interfacemom__checksums_1_1uchksum_adddc2d74992684e0e1fe9134fd350a32}\label{interfacemom__checksums_1_1uchksum_adddc2d74992684e0e1fe9134fd350a32}} 
\index{mom\+\_\+checksums\+::uchksum@{mom\+\_\+checksums\+::uchksum}!chksum\+\_\+u\+\_\+2d@{chksum\+\_\+u\+\_\+2d}}
\index{chksum\+\_\+u\+\_\+2d@{chksum\+\_\+u\+\_\+2d}!mom\+\_\+checksums\+::uchksum@{mom\+\_\+checksums\+::uchksum}}
\subsubsection{\texorpdfstring{chksum\+\_\+u\+\_\+2d()}{chksum\_u\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::uchksum\+::chksum\+\_\+u\+\_\+2d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isdb\+:,hi\+\_\+m\%jsd\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{symmetric,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



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


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


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


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



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


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


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


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


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}
