\hypertarget{interfacemom__checksums_1_1vchksum}{}\section{mom\+\_\+checksums\+:\+:vchksum Interface Reference}
\label{interfacemom__checksums_1_1vchksum}\index{mom\+\_\+checksums\+::vchksum@{mom\+\_\+checksums\+::vchksum}}


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

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

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


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

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



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



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\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 1026 of file M\+O\+M\+\_\+checksums.\+F90.


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



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\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 1705 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
1705   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: HI\_m\textcolor{comment}{ !< A horizontal index type}
1706   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isd:,HI\_m%JsdB:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
1707   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
1708   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
1709   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: symmetric\textcolor{comment}{ !< If true, do the checksums on the full}
1710 \textcolor{comment}{                                                             !! symmetric computational domain.}
1711   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
1712   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
1713   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
1714 
1715   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}
1716   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array
1717   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI   \textcolor{comment}{! Horizontal index bounds of the input grid}
1718   \textcolor{keywordtype}{real} :: scaling
1719   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
1720   \textcolor{keywordtype}{integer} :: i, j, k, Js
1721   \textcolor{keywordtype}{integer} :: bc0, bcSW, bcSE, bcNW, bcNE, hshift
1722   \textcolor{keywordtype}{integer} :: bcN, bcS, bcE, bcW
1723   \textcolor{keywordtype}{real} :: aMean, aMin, aMax
1724   \textcolor{keywordtype}{logical} :: do\_corners, sym, sym\_stats
1725   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
1726 
1727   \textcolor{comment}{! Rotate array to the input grid}
1728   turns = hi\_m%turns
1729   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
1730     \textcolor{keyword}{allocate}(hi)
1731     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
1732     \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}
1733       \textcolor{comment}{! Arrays originating from u-points must be handled by uchksum}
1734       \textcolor{keyword}{allocate}(array(hi%IsdB:hi%IedB, hi%jsd:hi%jed, \textcolor{keyword}{size}(array\_m, 3)))
1735       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1736       \textcolor{keyword}{call }uchksum(array, mesg, hi, haloshift, symmetric, omit\_corners, scale, logunit)
1737       \textcolor{keywordflow}{return}
1738     \textcolor{keywordflow}{else}
1739       \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%JsdB:hi%JedB, \textcolor{keyword}{size}(array\_m, 3)))
1740       \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1741 \textcolor{keywordflow}{    endif}
1742   \textcolor{keywordflow}{else}
1743     hi => hi\_m
1744     array => array\_m
1745 \textcolor{keywordflow}{  endif}
1746 
1747   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
1748     \textcolor{keywordflow}{if} (is\_nan(array(hi%isc:hi%iec,hi%JscB:hi%JecB,:))) &
1749       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
1750 \textcolor{comment}{!   if (is\_NaN(array)) &}
1751 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
1752 \textcolor{keywordflow}{  endif}
1753 
1754   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
1755   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
1756   sym\_stats = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym\_stats = symmetric
1757   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (haloshift > 0) sym\_stats = .true. ;\textcolor{keywordflow}{ endif}
1758 
1759   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
1760     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
1761       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
1762                                lbound(array,2):ubound(array,2), &
1763                                lbound(array,3):ubound(array,3)) )
1764       rescaled\_array(:,:,:) = 0.0
1765       js = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) js = hi%jsc-1
1766       \textcolor{keywordflow}{do} k=1,\textcolor{keyword}{size}(array,3) ; \textcolor{keywordflow}{do} j=js,hi%JecB ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1767         rescaled\_array(i,j,k) = scale*array(i,j,k)
1768 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1769       \textcolor{keyword}{call }substats(hi, rescaled\_array, sym\_stats, amean, amin, amax)
1770       \textcolor{keyword}{deallocate}(rescaled\_array)
1771     \textcolor{keywordflow}{else}
1772       \textcolor{keyword}{call }substats(hi, array, sym\_stats, amean, amin, amax)
1773 \textcolor{keywordflow}{    endif}
1774     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1775       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, amean, amin, amax, mesg, iounit)
1776 \textcolor{keywordflow}{  endif}
1777 
1778   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
1779 
1780   hshift = default\_shift
1781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1782   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
1783 
1784   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
1785        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
1786     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: haloshift ='},hshift
1787     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
1788     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_v\_3d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
1789     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_v\_3d '}//trim(mesg))
1790 \textcolor{keywordflow}{  endif}
1791 
1792   bc0 = subchk(array, hi, 0, 0, scaling)
1793 
1794   sym = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(symmetric)) sym = symmetric
1795 
1796   \textcolor{keywordflow}{if} ((hshift==0) .and. .not.sym) \textcolor{keywordflow}{then}
1797     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, bc0, mesg, iounit)
1798     \textcolor{keywordflow}{return}
1799 \textcolor{keywordflow}{  endif}
1800 
1801   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
1802 
1803   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
1804     bcs = subchk(array, hi, 0, -hshift-1, scaling)
1805     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg\_s(\textcolor{stringliteral}{"v-point:"}, bc0, bcs, mesg, iounit)
1806   \textcolor{keywordflow}{elseif} (do\_corners) \textcolor{keywordflow}{then}
1807     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1808       bcsw = subchk(array, hi, -hshift, -hshift-1, scaling)
1809       bcse = subchk(array, hi, hshift, -hshift-1, scaling)
1810     \textcolor{keywordflow}{else}
1811       bcsw = subchk(array, hi, -hshift, -hshift, scaling)
1812       bcse = subchk(array, hi, hshift, -hshift, scaling)
1813 \textcolor{keywordflow}{    endif}
1814     bcnw = subchk(array, hi, -hshift, hshift, scaling)
1815     bcne = subchk(array, hi, hshift, hshift, scaling)
1816 
1817     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1818       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"v-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
1819   \textcolor{keywordflow}{else}
1820     \textcolor{keywordflow}{if} (sym) \textcolor{keywordflow}{then}
1821       bcs = subchk(array, hi, 0, -hshift-1, scaling)
1822     \textcolor{keywordflow}{else}
1823       bcs = subchk(array, hi, 0, -hshift, scaling)
1824 \textcolor{keywordflow}{    endif}
1825     bce = subchk(array, hi, hshift, 0, scaling)
1826     bcw = subchk(array, hi, -hshift, 0, scaling)
1827     bcn = subchk(array, hi, 0, hshift, scaling)
1828 
1829     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1830       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"v-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
1831 \textcolor{keywordflow}{  endif}
1832 
1833   \textcolor{keyword}{contains}
1834 
1835 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
1836     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}
1837     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1838     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
1839     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
1840     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
1841     \textcolor{keywordtype}{integer} :: i, j, k, bc
1842     subchk = 0
1843     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1844     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj ; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
1845       bc = bitcount(abs(scale*array(i,j,k)))
1846       subchk = subchk + bc
1847 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1848     \textcolor{keyword}{call }sum\_across\_pes(subchk)
1849     subchk=mod(subchk, bc\_modulus)
1850 \textcolor{keyword}{  end function }subchk
1851 
1852   \textcolor{comment}{!subroutine subStats(HI, array, mesg, sym\_stats)}
1853 \textcolor{keyword}{  subroutine }substats(HI, array, sym\_stats, aMean, aMin, aMax)
1854     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  HI\textcolor{comment}{     !< A horizontal index type}
1855     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%JsdB:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1856     \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: sym\_stats\textcolor{comment}{ !< If true, evaluate the statistics on the}
1857 \textcolor{comment}{                                              !! full symmetric computational domain.}
1858     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: aMean\textcolor{comment}{   !< Mean of array over domain}
1859     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: aMin\textcolor{comment}{    !< Minimum of array over domain}
1860     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: aMax\textcolor{comment}{    !< Maximum of array over domain}
1861 
1862     \textcolor{keywordtype}{integer} :: i, j, k, n, JsB
1863 
1864     jsb = hi%jsc ; \textcolor{keywordflow}{if} (sym\_stats) jsb = hi%jsc-1
1865 
1866     amin = array(hi%isc,hi%jsc,1) ; amax = amin
1867     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=jsb,hi%JecB ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1868       amin = min(amin, array(i,j,k))
1869       amax = max(amax, array(i,j,k))
1870 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1871     \textcolor{comment}{! This line deliberately uses the h-point computational domain.}
1872     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))
1873     n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc) * \textcolor{keyword}{size}(array,3)
1874     \textcolor{keyword}{call }sum\_across\_pes(n)
1875     \textcolor{keyword}{call }min\_across\_pes(amin)
1876     \textcolor{keyword}{call }max\_across\_pes(amax)
1877     amean = amean / \textcolor{keywordtype}{real}(n)
1878 \textcolor{keyword}{  end subroutine }substats
1879 
\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}
