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


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

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

\subsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{interfacemom__checksums_1_1hchksum_a040890630933e72e84c9cb1e05772ec6}{chksum\+\_\+h\+\_\+2d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 2d array staggered at tracer points. \end{DoxyCompactList}\item 
subroutine \hyperlink{interfacemom__checksums_1_1hchksum_a792bb6c40192575ba9fd1d72077ee86d}{chksum\+\_\+h\+\_\+3d} (array\+\_\+m, mesg, H\+I\+\_\+m, haloshift, omit\+\_\+corners, scale, logunit)
\begin{DoxyCompactList}\small\item\em Checksums a 3d array staggered at tracer points. \end{DoxyCompactList}\end{DoxyCompactItemize}


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

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



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



Checksums a 2d array staggered at tracer points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+m} & Horizontal index bounds of the model grid\\
\hline
\mbox{\tt in}  & {\em array\+\_\+m} & Field array on the model grid\\
\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 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 306 of file M\+O\+M\+\_\+checksums.\+F90.


\begin{DoxyCode}
306   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{    !< Horizontal index bounds of the model grid}
307   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isd:,HI\_m%jsd:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< Field array on the model grid}
308   \textcolor{keywordtype}{character(len=*)},                \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
309   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
310   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
311   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
312   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
313 
314   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:)           \textcolor{comment}{! Field array on the input grid}
315   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: rescaled\_array
316   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
317   \textcolor{keywordtype}{real} :: scaling
318   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
319   \textcolor{keywordtype}{integer} :: i, j
320   \textcolor{keywordtype}{real} :: amean, amin, amax
321   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
322   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
323   \textcolor{keywordtype}{logical} :: do\_corners
324   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
325 
326   \textcolor{comment}{! Rotate array to the input grid}
327   turns = hi\_m%turns
328   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
329     \textcolor{keyword}{allocate}(hi)
330     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
331     \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%jsd:hi%jed))
332     \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
333   \textcolor{keywordflow}{else}
334     hi => hi\_m
335     array => array\_m
336 \textcolor{keywordflow}{  endif}
337 
338   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
339     \textcolor{keywordflow}{if} (is\_nan(array(hi%isc:hi%iec,hi%jsc:hi%jec))) &
340       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
341 \textcolor{comment}{!   if (is\_NaN(array)) &}
342 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
343 \textcolor{keywordflow}{  endif}
344 
345   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
346   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
347 
348   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
349     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
350       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
351                                lbound(array,2):ubound(array,2)) )
352       rescaled\_array(:,:) = 0.0
353       \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
354         rescaled\_array(i,j) = scale*array(i,j)
355 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
356       \textcolor{keyword}{call }substats(hi, rescaled\_array, amean, amin, amax)
357       \textcolor{keyword}{deallocate}(rescaled\_array)
358     \textcolor{keywordflow}{else}
359       \textcolor{keyword}{call }substats(hi, array, amean, amin, amax)
360 \textcolor{keywordflow}{    endif}
361 
362     \textcolor{keywordflow}{if} (is\_root\_pe()) &
363       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, amean, amin, amax, mesg, iounit)
364 \textcolor{keywordflow}{  endif}
365 
366   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
367 
368   hshift = default\_shift
369   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
370   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
371 
372   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
373        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
374     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_2d: haloshift ='},hshift
375     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_2d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
376     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_2d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
377     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_h\_2d '}//trim(mesg))
378 \textcolor{keywordflow}{  endif}
379 
380   bc0 = subchk(array, hi, 0, 0, scaling)
381 
382   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
383     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, mesg, iounit)
384     \textcolor{keywordflow}{return}
385 \textcolor{keywordflow}{  endif}
386 
387   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
388 
389   \textcolor{keywordflow}{if} (do\_corners) \textcolor{keywordflow}{then}
390     bcsw = subchk(array, hi, -hshift, -hshift, scaling)
391     bcse = subchk(array, hi, hshift, -hshift, scaling)
392     bcnw = subchk(array, hi, -hshift, hshift, scaling)
393     bcne = subchk(array, hi, hshift, hshift, scaling)
394 
395     \textcolor{keywordflow}{if} (is\_root\_pe()) &
396       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
397   \textcolor{keywordflow}{else}
398     bcs = subchk(array, hi, 0, -hshift, scaling)
399     bce = subchk(array, hi, hshift, 0, scaling)
400     bcw = subchk(array, hi, -hshift, 0, scaling)
401     bcn = subchk(array, hi, 0, hshift, scaling)
402 
403     \textcolor{keywordflow}{if} (is\_root\_pe()) &
404       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"h-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
405 \textcolor{keywordflow}{  endif}
406 
407   \textcolor{keyword}{contains}
408 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
409     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
410     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
411     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
412     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
413     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
414     \textcolor{keywordtype}{integer} :: i, j, bc
415     subchk = 0
416     \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
417       bc = bitcount(abs(scale*array(i,j)))
418       subchk = subchk + bc
419 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
420     \textcolor{keyword}{call }sum\_across\_pes(subchk)
421     subchk=mod(subchk, bc\_modulus)
422 \textcolor{keyword}{  end function }subchk
423 
424 \textcolor{keyword}{  subroutine }substats(HI, array, aMean, aMin, aMax)
425     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
426     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
427     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !< Array mean}
428     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
429     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
430 
431     \textcolor{keywordtype}{integer} :: i, j, n
432 
433     amin = array(hi%isc,hi%jsc)
434     amax = array(hi%isc,hi%jsc)
435     n = 0
436     \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
437       amin = min(amin, array(i,j))
438       amax = max(amax, array(i,j))
439       n = n + 1
440 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
441     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec))
442     \textcolor{keyword}{call }sum\_across\_pes(n)
443     \textcolor{keyword}{call }min\_across\_pes(amin)
444     \textcolor{keyword}{call }max\_across\_pes(amax)
445     amean = amean / \textcolor{keywordtype}{real}(n)
446 \textcolor{keyword}{  end subroutine }substats
447 
\end{DoxyCode}
\mbox{\Hypertarget{interfacemom__checksums_1_1hchksum_a792bb6c40192575ba9fd1d72077ee86d}\label{interfacemom__checksums_1_1hchksum_a792bb6c40192575ba9fd1d72077ee86d}} 
\index{mom\+\_\+checksums\+::hchksum@{mom\+\_\+checksums\+::hchksum}!chksum\+\_\+h\+\_\+3d@{chksum\+\_\+h\+\_\+3d}}
\index{chksum\+\_\+h\+\_\+3d@{chksum\+\_\+h\+\_\+3d}!mom\+\_\+checksums\+::hchksum@{mom\+\_\+checksums\+::hchksum}}
\subsubsection{\texorpdfstring{chksum\+\_\+h\+\_\+3d()}{chksum\_h\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+checksums\+::hchksum\+::chksum\+\_\+h\+\_\+3d (\begin{DoxyParamCaption}\item[{real, dimension(hi\+\_\+m\%isd\+:,hi\+\_\+m\%jsd\+:,\+:), intent(in), target}]{array\+\_\+m,  }\item[{character(len=$\ast$), intent(in)}]{mesg,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), target}]{H\+I\+\_\+m,  }\item[{integer, intent(in), optional}]{haloshift,  }\item[{logical, intent(in), optional}]{omit\+\_\+corners,  }\item[{real, intent(in), optional}]{scale,  }\item[{integer, intent(in), optional}]{logunit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Checksums a 3d array staggered at tracer points. 


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


\begin{DoxyCode}
1204   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(in)} :: hi\_m\textcolor{comment}{ !< A horizontal index type}
1205   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI\_m%isd:,HI\_m%jsd:,:)}, \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)} :: array\_m\textcolor{comment}{ !< The array to be checksummed}
1206   \textcolor{keywordtype}{character(len=*)},                  \textcolor{keywordtype}{intent(in)} :: mesg\textcolor{comment}{  !< An identifying message}
1207   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: haloshift\textcolor{comment}{ !< The width of halos to check (default 0)}
1208   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: omit\_corners\textcolor{comment}{ !< If true, avoid checking diagonal shifts}
1209   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{     !< A scaling factor for this array.}
1210   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: logunit\textcolor{comment}{ !< IO unit for checksum logging}
1211 
1212   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer} :: array(:,:,:)         \textcolor{comment}{! Field array on the input grid}
1213   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: rescaled\_array
1214   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi   \textcolor{comment}{! Horizontal index bounds of the input grid}
1215   \textcolor{keywordtype}{real} :: scaling
1216   \textcolor{keywordtype}{integer} :: iounit\textcolor{comment}{ !< Log IO unit}
1217   \textcolor{keywordtype}{integer} :: i, j, k
1218   \textcolor{keywordtype}{real} :: amean, amin, amax
1219   \textcolor{keywordtype}{integer} :: bc0, bcsw, bcse, bcnw, bcne, hshift
1220   \textcolor{keywordtype}{integer} :: bcn, bcs, bce, bcw
1221   \textcolor{keywordtype}{logical} :: do\_corners
1222   \textcolor{keywordtype}{integer} :: turns                      \textcolor{comment}{! Quarter turns from input to model grid}
1223 
1224   \textcolor{comment}{! Rotate array to the input grid}
1225   turns = hi\_m%turns
1226   \textcolor{keywordflow}{if} (modulo(turns, 4) /= 0) \textcolor{keywordflow}{then}
1227     \textcolor{keyword}{allocate}(hi)
1228     \textcolor{keyword}{call }rotate\_hor\_index(hi\_m, -turns, hi)
1229     \textcolor{keyword}{allocate}(array(hi%isd:hi%ied, hi%jsd:hi%jed, \textcolor{keyword}{size}(array\_m, 3)))
1230     \textcolor{keyword}{call }rotate\_array(array\_m, -turns, array)
1231   \textcolor{keywordflow}{else}
1232     hi => hi\_m
1233     array => array\_m
1234 \textcolor{keywordflow}{  endif}
1235 
1236   \textcolor{keywordflow}{if} (checkfornans) \textcolor{keywordflow}{then}
1237     \textcolor{keywordflow}{if} (is\_nan(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))) &
1238       \textcolor{keyword}{call }chksum\_error(fatal, \textcolor{stringliteral}{'NaN detected: '}//trim(mesg))
1239 \textcolor{comment}{!   if (is\_NaN(array)) &}
1240 \textcolor{comment}{!     call chksum\_error(FATAL, 'NaN detected in halo: '//trim(mesg))}
1241 \textcolor{keywordflow}{  endif}
1242 
1243   scaling = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) scaling = scale
1244   iounit = error\_unit; \textcolor{keywordflow}{if}(\textcolor{keyword}{present}(logunit)) iounit = logunit
1245 
1246   \textcolor{keywordflow}{if} (calculatestatistics) \textcolor{keywordflow}{then}
1247     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then}
1248       \textcolor{keyword}{allocate}( rescaled\_array(lbound(array,1):ubound(array,1), &
1249                                lbound(array,2):ubound(array,2), &
1250                                lbound(array,3):ubound(array,3)) )
1251       rescaled\_array(:,:,:) = 0.0
1252       \textcolor{keywordflow}{do} k=1,\textcolor{keyword}{size}(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1253         rescaled\_array(i,j,k) = scale*array(i,j,k)
1254 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1255 
1256       \textcolor{keyword}{call }substats(hi, rescaled\_array, amean, amin, amax)
1257       \textcolor{keyword}{deallocate}(rescaled\_array)
1258     \textcolor{keywordflow}{else}
1259       \textcolor{keyword}{call }substats(hi, array, amean, amin, amax)
1260 \textcolor{keywordflow}{    endif}
1261 
1262     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1263       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, amean, amin, amax, mesg, iounit)
1264 \textcolor{keywordflow}{  endif}
1265 
1266   \textcolor{keywordflow}{if} (.not.writechksums) \textcolor{keywordflow}{return}
1267 
1268   hshift = default\_shift
1269   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(haloshift)) hshift = haloshift
1270   \textcolor{keywordflow}{if} (hshift<0) hshift = hi%ied-hi%iec
1271 
1272   \textcolor{keywordflow}{if} ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
1273        hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) \textcolor{keywordflow}{then}
1274     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: haloshift ='},hshift
1275     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: isd,isc,iec,ied='},hi%isd,hi%isc,hi%iec,hi%ied
1276     \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'chksum\_h\_3d: jsd,jsc,jec,jed='},hi%jsd,hi%jsc,hi%jec,hi%jed
1277     \textcolor{keyword}{call }chksum\_error(fatal,\textcolor{stringliteral}{'Error in chksum\_h\_3d '}//trim(mesg))
1278 \textcolor{keywordflow}{  endif}
1279 
1280   bc0 = subchk(array, hi, 0, 0, scaling)
1281 
1282   \textcolor{keywordflow}{if} (hshift==0) \textcolor{keywordflow}{then}
1283     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, mesg, iounit)
1284     \textcolor{keywordflow}{return}
1285 \textcolor{keywordflow}{  endif}
1286 
1287   do\_corners = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(omit\_corners)) do\_corners = .not.omit\_corners
1288 
1289   \textcolor{keywordflow}{if} (do\_corners) \textcolor{keywordflow}{then}
1290     bcsw = subchk(array, hi, -hshift, -hshift, scaling)
1291     bcse = subchk(array, hi, hshift, -hshift, scaling)
1292     bcnw = subchk(array, hi, -hshift, hshift, scaling)
1293     bcne = subchk(array, hi, hshift, hshift, scaling)
1294 
1295     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1296       \textcolor{keyword}{call }chk\_sum\_msg(\textcolor{stringliteral}{"h-point:"}, bc0, bcsw, bcse, bcnw, bcne, mesg, iounit)
1297   \textcolor{keywordflow}{else}
1298     bcs = subchk(array, hi, 0, -hshift, scaling)
1299     bce = subchk(array, hi, hshift, 0, scaling)
1300     bcw = subchk(array, hi, -hshift, 0, scaling)
1301     bcn = subchk(array, hi, 0, hshift, scaling)
1302 
1303     \textcolor{keywordflow}{if} (is\_root\_pe()) &
1304       \textcolor{keyword}{call }chk\_sum\_msg\_nsew(\textcolor{stringliteral}{"h-point:"}, bc0, bcn, bcs, bce, bcw, mesg, iounit)
1305 \textcolor{keywordflow}{  endif}
1306 
1307   \textcolor{keyword}{contains}
1308 
1309 \textcolor{keyword}{  integer }\textcolor{keyword}{function }subchk(array, HI, di, dj, scale)
1310     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1311     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1312     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: di\textcolor{comment}{    !< i- direction array shift for this checksum}
1313     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: dj\textcolor{comment}{    !< j- direction array shift for this checksum}
1314     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A scaling factor for this array.}
1315     \textcolor{keywordtype}{integer} :: i, j, k, bc
1316     subchk = 0
1317     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc+dj,hi%jec+dj ; \textcolor{keywordflow}{do} i=hi%isc+di,hi%iec+di
1318       bc = bitcount(abs(scale*array(i,j,k)))
1319       subchk = subchk + bc
1320 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1321     \textcolor{keyword}{call }sum\_across\_pes(subchk)
1322     subchk=mod(subchk, bc\_modulus)
1323 \textcolor{keyword}{  end function }subchk
1324 
1325 \textcolor{keyword}{  subroutine }substats(HI, array, aMean, aMin, aMax)
1326     \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} ::  hi\textcolor{comment}{     !< A horizontal index type}
1327     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:,HI%jsd:,:)}, \textcolor{keywordtype}{intent(in)} :: array\textcolor{comment}{ !< The array to be checksummed}
1328     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amean\textcolor{comment}{ !<  Array mean}
1329     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amin\textcolor{comment}{ !< Array minimum}
1330     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: amax\textcolor{comment}{ !< Array maximum}
1331 
1332     \textcolor{keywordtype}{integer} :: i, j, k, n
1333 
1334     amin = array(hi%isc,hi%jsc,1)
1335     amax = array(hi%isc,hi%jsc,1)
1336     n = 0
1337     \textcolor{keywordflow}{do} k=lbound(array,3),ubound(array,3) ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1338       amin = min(amin, array(i,j,k))
1339       amax = max(amax, array(i,j,k))
1340       n = n + 1
1341 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1342     amean = reproducing\_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))
1343     \textcolor{keyword}{call }sum\_across\_pes(n)
1344     \textcolor{keyword}{call }min\_across\_pes(amin)
1345     \textcolor{keyword}{call }max\_across\_pes(amax)
1346     amean = amean / \textcolor{keywordtype}{real}(n)
1347 \textcolor{keyword}{  end subroutine }substats
1348 
\end{DoxyCode}


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