MOM6
mom_checksums::qchksum Interface Reference

Detailed Description

Definition at line 65 of file MOM_checksums.F90.

Private functions

subroutine chksum_b_2d (array, mesg, HI, haloshift, symmetric, omit_corners, scale)
 chksum_B_2d performs checksums on a 2d array staggered at corner points. More...
 
subroutine chksum_b_3d (array, mesg, HI, haloshift, symmetric, omit_corners, scale)
 chksum_B_3d performs checksums on a 3d array staggered at corner points. More...
 

Functions and subroutines

◆ chksum_b_2d()

subroutine mom_checksums::qchksum::chksum_b_2d ( real, dimension(hi%isdb:,hi%jsdb:), intent(in)  array,
character(len=*), intent(in)  mesg,
type(hor_index_type), intent(in)  HI,
integer, intent(in), optional  haloshift,
logical, intent(in), optional  symmetric,
logical, intent(in), optional  omit_corners,
real, intent(in), optional  scale 
)
private

chksum_B_2d performs checksums on a 2d array staggered at corner points.

Parameters
[in]hiA horizontal index type
[in]arrayThe array to be checksummed
[in]mesgAn identifying message
[in]haloshiftThe width of halos to check (default 0)
[in]symmetricIf true, do the checksums on the full symmetric computational domain.
[in]omit_cornersIf true, avoid checking diagonal shifts
[in]scaleA scaling factor for this array.

Definition at line 285 of file MOM_checksums.F90.

285  type(hor_index_type), intent(in) :: hi !< A horizontal index type
286  real, dimension(HI%IsdB:,HI%JsdB:), &
287  intent(in) :: array !< The array to be checksummed
288  character(len=*), intent(in) :: mesg !< An identifying message
289  integer, optional, intent(in) :: haloshift !< The width of halos to check (default 0)
290  logical, optional, intent(in) :: symmetric !< If true, do the checksums on the
291  !! full symmetric computational domain.
292  logical, optional, intent(in) :: omit_corners !< If true, avoid checking diagonal shifts
293  real, optional, intent(in) :: scale !< A scaling factor for this array.
294 
295  real :: scaling
296  integer :: bc0, bcsw, bcse, bcnw, bcne, hshift
297  integer :: bcn, bcs, bce, bcw
298  logical :: do_corners, sym, sym_stats
299 
300  if (checkfornans) then
301  if (is_nan(array(hi%IscB:hi%IecB,hi%JscB:hi%JecB))) &
302  call chksum_error(fatal, 'NaN detected: '//trim(mesg))
303 ! if (is_NaN(array)) &
304 ! call chksum_error(FATAL, 'NaN detected in halo: '//trim(mesg))
305  endif
306  scaling = 1.0 ; if (present(scale)) scaling = scale
307 
308  sym_stats = .false. ; if (present(symmetric)) sym_stats = symmetric
309  if (present(haloshift)) then ; if (haloshift > 0) sym_stats = .true. ; endif
310  if (calculatestatistics) call substats(hi, array, mesg, sym_stats, scaling)
311 
312  if (.not.writechksums) return
313 
314  hshift = default_shift
315  if (present(haloshift)) hshift = haloshift
316  if (hshift<0) hshift = hi%ied-hi%iec
317 
318  if ( hi%iscB-hshift<hi%isdB .or. hi%iecB+hshift>hi%iedB .or. &
319  hi%jscB-hshift<hi%jsdB .or. hi%jecB+hshift>hi%jedB ) then
320  write(0,*) 'chksum_B_2d: haloshift =',hshift
321  write(0,*) 'chksum_B_2d: isd,isc,iec,ied=',hi%isdB,hi%iscB,hi%iecB,hi%iedB
322  write(0,*) 'chksum_B_2d: jsd,jsc,jec,jed=',hi%jsdB,hi%jscB,hi%jecB,hi%jedB
323  call chksum_error(fatal,'Error in chksum_B_2d '//trim(mesg))
324  endif
325 
326  bc0 = subchk(array, hi, 0, 0, scaling)
327 
328  sym = .false. ; if (present(symmetric)) sym = symmetric
329 
330  if ((hshift==0) .and. .not.sym) then
331  if (is_root_pe()) call chk_sum_msg("B-point:",bc0,mesg)
332  return
333  endif
334 
335  do_corners = .true. ; if (present(omit_corners)) do_corners = .not.omit_corners
336 
337  if (do_corners) then
338  if (sym) then
339  bcsw = subchk(array, hi, -hshift-1, -hshift-1, scaling)
340  bcse = subchk(array, hi, hshift, -hshift-1, scaling)
341  bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
342  else
343  bcsw = subchk(array, hi, -hshift, -hshift, scaling)
344  bcse = subchk(array, hi, hshift, -hshift, scaling)
345  bcnw = subchk(array, hi, -hshift, hshift, scaling)
346  endif
347  bcne = subchk(array, hi, hshift, hshift, scaling)
348 
349  if (is_root_pe()) call chk_sum_msg("B-point:",bc0,bcsw,bcse,bcnw,bcne,mesg)
350  else
351  bcs = subchk(array, hi, 0, -hshift, scaling)
352  bce = subchk(array, hi, hshift, 0, scaling)
353  bcw = subchk(array, hi, -hshift, 0, scaling)
354  bcn = subchk(array, hi, 0, hshift, scaling)
355 
356  if (is_root_pe()) call chk_sum_msg_nsew("B-point:",bc0,bcn,bcs,bce,bcw,mesg)
357  endif
358 
359  contains
360 
361  integer function subchk(array, HI, di, dj, scale)
362  type(hor_index_type), intent(in) :: hi
363  real, dimension(HI%IsdB:,HI%JsdB:), intent(in) :: array
364  integer, intent(in) :: di, dj
365  real, intent(in) :: scale
366  integer :: bitcount, i, j, bc
367  subchk = 0
368  ! This line deliberately uses the h-point computational domain.
369  do j=hi%jsc+dj,hi%jec+dj; do i=hi%isc+di,hi%iec+di
370  bc = bitcount(abs(scale*array(i,j)))
371  subchk = subchk + bc
372  enddo; enddo
373  call sum_across_pes(subchk)
374  subchk=mod(subchk,1000000000)
375  end function subchk
376 
377  subroutine substats(HI, array, mesg, sym_stats, scale)
378  type(hor_index_type), intent(in) :: hi
379  real, dimension(HI%IsdB:,HI%JsdB:), intent(in) :: array
380  character(len=*), intent(in) :: mesg
381  logical, intent(in) :: sym_stats
382  real, intent(in) :: scale
383  integer :: i, j, n, isb, jsb
384  real :: amean, amin, amax
385 
386  isb = hi%isc ; if (sym_stats) isb = hi%isc-1
387  jsb = hi%jsc ; if (sym_stats) jsb = hi%jsc-1
388 
389  amin = array(hi%isc,hi%jsc) ; amax = amin
390  do j=jsb,hi%JecB ; do i=isb,hi%IecB
391  amin = min(amin, array(i,j))
392  amax = max(amax, array(i,j))
393  enddo ; enddo
394  ! This line deliberately uses the h-point computational domain.
395  amean = reproducing_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec))
396  n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc)
397  call sum_across_pes(n)
398  call min_across_pes(amin)
399  call max_across_pes(amax)
400  amean = amean / real(n)
401  if (is_root_pe()) call chk_sum_msg("B-point:",amean*scale,amin*scale,amax*scale,mesg)
402  end subroutine substats
403 
subroutine substats(HI, array, mesg, scale)
int bitcount(double *x)
Definition: bitcount.c:22
integer function subchk(array, HI, di, dj, scale)

◆ chksum_b_3d()

subroutine mom_checksums::qchksum::chksum_b_3d ( real, dimension(hi%isdb:,hi%jsdb:,:), intent(in)  array,
character(len=*), intent(in)  mesg,
type(hor_index_type), intent(in)  HI,
integer, intent(in), optional  haloshift,
logical, intent(in), optional  symmetric,
logical, intent(in), optional  omit_corners,
real, intent(in), optional  scale 
)
private

chksum_B_3d performs checksums on a 3d array staggered at corner points.

Parameters
[in]hiA horizontal index type
[in]arrayThe array to be checksummed
[in]mesgAn identifying message
[in]haloshiftThe width of halos to check (default 0)
[in]symmetricIf true, do the checksums on the full symmetric computational domain.
[in]omit_cornersIf true, avoid checking diagonal shifts
[in]scaleA scaling factor for this array.

Definition at line 814 of file MOM_checksums.F90.

814  type(hor_index_type), intent(in) :: hi !< A horizontal index type
815  real, dimension(HI%IsdB:,HI%JsdB:,:), intent(in) :: array !< The array to be checksummed
816  character(len=*), intent(in) :: mesg !< An identifying message
817  integer, optional, intent(in) :: haloshift !< The width of halos to check (default 0)
818  logical, optional, intent(in) :: symmetric !< If true, do the checksums on the full symmetric computational domain.
819  logical, optional, intent(in) :: omit_corners !< If true, avoid checking diagonal shifts
820  real, optional, intent(in) :: scale !< A scaling factor for this array.
821 
822  real :: scaling
823  integer :: bc0, bcsw, bcse, bcnw, bcne, hshift
824  integer :: bcn, bcs, bce, bcw
825  logical :: do_corners, sym, sym_stats
826 
827  if (checkfornans) then
828  if (is_nan(array(hi%IscB:hi%IecB,hi%JscB:hi%JecB,:))) &
829  call chksum_error(fatal, 'NaN detected: '//trim(mesg))
830 ! if (is_NaN(array)) &
831 ! call chksum_error(FATAL, 'NaN detected in halo: '//trim(mesg))
832  endif
833  scaling = 1.0 ; if (present(scale)) scaling = scale
834 
835  sym_stats = .false. ; if (present(symmetric)) sym_stats = symmetric
836  if (present(haloshift)) then ; if (haloshift > 0) sym_stats = .true. ; endif
837  if (calculatestatistics) call substats(hi, array, mesg, sym_stats, scaling)
838 
839  if (.not.writechksums) return
840 
841  hshift = default_shift
842  if (present(haloshift)) hshift = haloshift
843  if (hshift<0) hshift = hi%ied-hi%iec
844 
845  if ( hi%isc-hshift<hi%isd .or. hi%iec+hshift>hi%ied .or. &
846  hi%jsc-hshift<hi%jsd .or. hi%jec+hshift>hi%jed ) then
847  write(0,*) 'chksum_B_3d: haloshift =',hshift
848  write(0,*) 'chksum_B_3d: isd,isc,iec,ied=',hi%isd,hi%isc,hi%iec,hi%ied
849  write(0,*) 'chksum_B_3d: jsd,jsc,jec,jed=',hi%jsd,hi%jsc,hi%jec,hi%jed
850  call chksum_error(fatal,'Error in chksum_B_3d '//trim(mesg))
851  endif
852 
853  bc0 = subchk(array, hi, 0, 0, scaling)
854 
855  sym = .false. ; if (present(symmetric)) sym = symmetric
856 
857  if ((hshift==0) .and. .not.sym) then
858  if (is_root_pe()) call chk_sum_msg("B-point:",bc0,mesg)
859  return
860  endif
861 
862  do_corners = .true. ; if (present(omit_corners)) do_corners = .not.omit_corners
863 
864  if (do_corners) then
865  if (sym) then
866  bcsw = subchk(array, hi, -hshift-1, -hshift-1, scaling)
867  bcse = subchk(array, hi, hshift, -hshift-1, scaling)
868  bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
869  else
870  bcsw = subchk(array, hi, -hshift-1, -hshift-1, scaling)
871  bcse = subchk(array, hi, hshift, -hshift-1, scaling)
872  bcnw = subchk(array, hi, -hshift-1, hshift, scaling)
873  endif
874  bcne = subchk(array, hi, hshift, hshift, scaling)
875 
876  if (is_root_pe()) call chk_sum_msg("B-point:",bc0,bcsw,bcse,bcnw,bcne,mesg)
877  else
878  if (sym) then
879  bcs = subchk(array, hi, 0, -hshift-1, scaling)
880  bcw = subchk(array, hi, -hshift-1, 0, scaling)
881  else
882  bcs = subchk(array, hi, 0, -hshift, scaling)
883  bcw = subchk(array, hi, -hshift, 0, scaling)
884  endif
885  bce = subchk(array, hi, hshift, 0, scaling)
886  bcn = subchk(array, hi, 0, hshift, scaling)
887 
888  if (is_root_pe()) call chk_sum_msg_nsew("B-point:",bc0,bcn,bcs,bce,bcw,mesg)
889  endif
890 
891  contains
892 
893  integer function subchk(array, HI, di, dj, scale)
894  type(hor_index_type), intent(in) :: hi
895  real, dimension(HI%IsdB:,HI%JsdB:,:), intent(in) :: array
896  integer, intent(in) :: di, dj
897  real, intent(in) :: scale
898  integer :: bitcount, i, j, k, bc
899  subchk = 0
900  ! This line deliberately uses the h-point computational domain.
901  do k=lbound(array,3),ubound(array,3) ; do j=hi%jsc+dj,hi%jec+dj ; do i=hi%isc+di,hi%iec+di
902  bc = bitcount(abs(scale*array(i,j,k)))
903  subchk = subchk + bc
904  enddo ; enddo ; enddo
905  call sum_across_pes(subchk)
906  subchk=mod(subchk,1000000000)
907  end function subchk
908 
909  subroutine substats(HI, array, mesg, sym_stats, scale)
910  type(hor_index_type), intent(in) :: hi
911  real, dimension(HI%IsdB:,HI%JsdB:,:), intent(in) :: array
912  character(len=*), intent(in) :: mesg
913  logical, intent(in) :: sym_stats
914  real, intent(in) :: scale
915  integer :: i, j, k, n, isb, jsb
916  real :: amean, amin, amax
917 
918  isb = hi%isc ; if (sym_stats) isb = hi%isc-1
919  jsb = hi%jsc ; if (sym_stats) jsb = hi%jsc-1
920 
921  amin = array(hi%isc,hi%jsc,1) ; amax = amin
922  do k=lbound(array,3),ubound(array,3) ; do j=jsb,hi%JecB ; do i=isb,hi%IecB
923  amin = min(amin, array(i,j,k))
924  amax = max(amax, array(i,j,k))
925  enddo ; enddo ; enddo
926  amean = reproducing_sum(array(hi%isc:hi%iec,hi%jsc:hi%jec,:))
927  n = (1 + hi%jec - hi%jsc) * (1 + hi%iec - hi%isc) * size(array,3)
928  call sum_across_pes(n)
929  call min_across_pes(amin)
930  call max_across_pes(amax)
931  amean = amean / real(n)
932  if (is_root_pe()) call chk_sum_msg("B-point:",amean*scale,amin*scale,amax*scale,mesg)
933  end subroutine substats
934 
subroutine substats(HI, array, mesg, scale)
int bitcount(double *x)
Definition: bitcount.c:22
integer function subchk(array, HI, di, dj, scale)

The documentation for this interface was generated from the following file: