MOM6
mom_checksums::chksum Interface Reference

Detailed Description

Definition at line 69 of file MOM_checksums.F90.

Private functions

subroutine chksum1d (array, mesg, start_i, end_i, compare_PEs)
 chksum1d does a checksum of a 1-dimensional array. More...
 
subroutine chksum2d (array, mesg)
 chksum2d does a checksum of all data in a 2-d array. More...
 
subroutine chksum3d (array, mesg)
 chksum3d does a checksum of all data in a 2-d array. More...
 

Functions and subroutines

◆ chksum1d()

subroutine mom_checksums::chksum::chksum1d ( real, dimension(:), intent(in)  array,
character(len=*), intent(in)  mesg,
integer, intent(in), optional  start_i,
integer, intent(in), optional  end_i,
logical, intent(in), optional  compare_PEs 
)
private

chksum1d does a checksum of a 1-dimensional array.

Parameters
[in]arrayThe array to be summed (index starts at 1).
[in]mesgAn identifying message.
[in]start_iThe starting index for the sum (default 1)
[in]end_iThe ending index for the sum (default all)
[in]compare_pesIf true, compare across PEs instead of summing and list the root_PE value (default true)

Definition at line 1201 of file MOM_checksums.F90.

1201  real, dimension(:), intent(in) :: array !< The array to be summed (index starts at 1).
1202  character(len=*), intent(in) :: mesg !< An identifying message.
1203  integer, optional, intent(in) :: start_i !< The starting index for the sum (default 1)
1204  integer, optional, intent(in) :: end_i !< The ending index for the sum (default all)
1205  logical, optional, intent(in) :: compare_pes !< If true, compare across PEs instead of summing
1206  !! and list the root_PE value (default true)
1207 
1208  integer :: is, ie, i, bc, sum1, sum_bc
1209  integer :: bitcount
1210  real :: sum
1211  real, allocatable :: sum_here(:)
1212  logical :: compare
1213  integer :: pe_num ! pe number of the data
1214  integer :: npes ! Total number of processsors
1215 
1216  is = lbound(array,1) ; ie = ubound(array,1)
1217  if (present(start_i)) is = start_i
1218  if (present(end_i)) ie = end_i
1219  compare = .true. ; if (present(compare_pes)) compare = compare_pes
1220 
1221  sum = 0.0 ; sum_bc = 0
1222  do i=is,ie
1223  sum = sum + array(i)
1224  bc = bitcount(abs(array(i)))
1225  sum_bc = sum_bc + bc
1226  enddo
1227 
1228  pe_num = pe_here() + 1 - root_pe() ; npes = num_pes()
1229  allocate(sum_here(npes)) ; sum_here(:) = 0.0 ; sum_here(pe_num) = sum
1230  call sum_across_pes(sum_here,npes)
1231 
1232  sum1 = sum_bc
1233  call sum_across_pes(sum1)
1234 
1235  if (.not.compare) then
1236  sum = 0.0
1237  do i=1,npes ; sum = sum + sum_here(i) ; enddo
1238  sum_bc = sum1
1239  elseif (is_root_pe()) then
1240  if (sum1 /= npes*sum_bc) &
1241  write(0, '(A40," bitcounts do not match across PEs: ",I12,1X,I12)') &
1242  mesg, sum1, npes*sum_bc
1243  do i=1,npes ; if (sum /= sum_here(i)) then
1244  write(0, '(A40," PE ",i4," sum mismatches root_PE: ",3(ES22.13,1X))') &
1245  mesg, i, sum_here(i), sum, sum_here(i)-sum
1246  endif ; enddo
1247  endif
1248  deallocate(sum_here)
1249 
1250  if (is_root_pe()) &
1251  write(0,'(A50,1X,ES25.16,1X,I12)') mesg, sum, sum_bc
1252 
int bitcount(double *x)
Definition: bitcount.c:22

◆ chksum2d()

subroutine mom_checksums::chksum::chksum2d ( real, dimension(:,:)  array,
character(len=*)  mesg 
)
private

chksum2d does a checksum of all data in a 2-d array.

Definition at line 1261 of file MOM_checksums.F90.

1261 
1262  real, dimension(:,:) :: array
1263  character(len=*) :: mesg
1264 
1265  integer :: bitcount
1266  integer :: xs,xe,ys,ye,i,j,sum1,bc
1267  real :: sum
1268 
1269  xs = lbound(array,1) ; xe = ubound(array,1)
1270  ys = lbound(array,2) ; ye = ubound(array,2)
1271 
1272  sum = 0.0 ; sum1 = 0
1273  do i=xs,xe ; do j=ys,ye
1274  bc = bitcount(abs(array(i,j)))
1275  sum1 = sum1 + bc
1276  enddo ; enddo
1277  call sum_across_pes(sum1)
1278 
1279  sum = reproducing_sum(array(:,:))
1280 
1281  if (is_root_pe()) &
1282  write(0,'(A50,1X,ES25.16,1X,I12)') mesg, sum, sum1
1283 ! write(0,'(A40,1X,Z16.16,1X,Z16.16,1X,ES25.16,1X,I12)') &
1284 ! mesg, sum, sum1, sum, sum1
1285 
int bitcount(double *x)
Definition: bitcount.c:22

◆ chksum3d()

subroutine mom_checksums::chksum::chksum3d ( real, dimension(:,:,:)  array,
character(len=*)  mesg 
)
private

chksum3d does a checksum of all data in a 2-d array.

Definition at line 1290 of file MOM_checksums.F90.

1290 
1291  real, dimension(:,:,:) :: array
1292  character(len=*) :: mesg
1293 
1294  integer :: bitcount
1295  integer :: xs,xe,ys,ye,zs,ze,i,j,k, bc,sum1
1296  real :: sum
1297 
1298  xs = lbound(array,1) ; xe = ubound(array,1)
1299  ys = lbound(array,2) ; ye = ubound(array,2)
1300  zs = lbound(array,3) ; ze = ubound(array,3)
1301 
1302  sum = 0.0 ; sum1 = 0
1303  do i=xs,xe ; do j=ys,ye ; do k=zs,ze
1304  bc = bitcount(abs(array(i,j,k)))
1305  sum1 = sum1 + bc
1306  enddo ; enddo ; enddo
1307 
1308  call sum_across_pes(sum1)
1309  sum = reproducing_sum(array(:,:,:))
1310 
1311  if (is_root_pe()) &
1312  write(0,'(A50,1X,ES25.16,1X,I12)') mesg, sum, sum1
1313 ! write(0,'(A40,1X,Z16.16,1X,Z16.16,1X,ES25.16,1X,I12)') &
1314 ! mesg, sum, sum1, sum, sum1
1315 
int bitcount(double *x)
Definition: bitcount.c:22

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