Skip to content

Commit

Permalink
feat: add and aggregate mpp_chksum unit tests (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
rem1776 authored Apr 6, 2022
1 parent 16003bb commit 6692f95
Show file tree
Hide file tree
Showing 5 changed files with 373 additions and 133 deletions.
14 changes: 7 additions & 7 deletions test_fms/mpp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ check_PROGRAMS = test_mpp \
test_minmax \
test_mpp_sendrecv \
test_global_arrays \
test_chksum_int \
test_mpp_update_domains_ad \
test_mpp_transmit \
test_mpp_alltoall \
Expand All @@ -67,7 +66,8 @@ check_PROGRAMS = test_mpp \
test_mpp_global_sum_ad \
test_mpp_init_logfile \
test_mpp_clock_begin_end_id \
test_mpp_nesting
test_mpp_nesting \
test_mpp_chksum

# These are the sources for the tests.
test_mpp_SOURCES = test_mpp.F90
Expand Down Expand Up @@ -116,7 +116,6 @@ test_update_domains_performance_SOURCES = \
test_minmax_SOURCES = test_minmax.F90
test_mpp_update_domains_ad_SOURCES = test_mpp_update_domains_ad.F90
test_global_arrays_SOURCES = test_global_arrays.F90
test_chksum_int_SOURCES = test_chksum_int.F90
test_redistribute_int_SOURCES = test_redistribute_int.F90
test_mpp_transmit_SOURCES = test_mpp_transmit.F90
test_mpp_alltoall_SOURCES = test_mpp_alltoall.F90
Expand All @@ -133,6 +132,7 @@ test_stdin_SOURCES=test_stdin.F90
test_mpp_init_logfile_SOURCES=test_mpp_init_logfile.F90
test_mpp_clock_begin_end_id_SOURCES=test_mpp_clock_begin_end_id.F90
test_super_grid_SOURCES = test_super_grid.F90
test_mpp_chksum_SOURCES = test_mpp_chksum.F90

# Run the test programs.
TESTS = test_mpp_domains2.sh \
Expand Down Expand Up @@ -161,7 +161,6 @@ TESTS = test_mpp_domains2.sh \
test_update_domains_performance.sh \
test_minmax.sh \
test_mpp_sendrecv.sh \
test_chksum_int.sh \
test_mpp_update_domains_ad.sh \
test_mpp_transmit.sh \
test_mpp_alltoall.sh \
Expand All @@ -171,7 +170,8 @@ TESTS = test_mpp_domains2.sh \
test_mpp_init_logfile.sh \
test_mpp_clock_begin_end_id.sh \
test_super_grid.sh \
test_mpp_nesting.sh
test_mpp_nesting.sh \
test_mpp_chksum.sh

# Define test file extensions and log driver
TEST_EXTENSIONS = .sh
Expand Down Expand Up @@ -204,7 +204,6 @@ EXTRA_DIST = test_mpp_domains2.sh \
test_minmax.sh \
test_mpp_sendrecv.sh \
test_global_arrays.sh \
test_chksum_int.sh \
test_redistribute_int.sh \
test_mpp_update_domains_ad.sh \
test_mpp_transmit.sh \
Expand All @@ -215,7 +214,8 @@ EXTRA_DIST = test_mpp_domains2.sh \
test_mpp_init_logfile.sh \
test_mpp_clock_begin_end_id.sh \
test_super_grid.sh \
test_mpp_nesting.sh
test_mpp_nesting.sh \
test_mpp_chksum.sh

fill_halo.mod: fill_halo.$(OBJEXT)
compare_data_checksums.mod: compare_data_checksums.$(OBJEXT)
Expand Down
84 changes: 0 additions & 84 deletions test_fms/mpp/test_chksum_int.F90

This file was deleted.

39 changes: 0 additions & 39 deletions test_fms/mpp/test_mpp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ program test !test various aspects of mpp_mod
call test_mpp_max()
if( pe.EQ.root ) print *, '------------------> Finished test_mpp_max <------------------'

if( pe.EQ.root ) print *, '------------------> Calling test_mpp_chksum <------------------'
call test_mpp_chksum()
if( pe.EQ.root ) print *, '------------------> Finished test_mpp_chksum <------------------'

!test of pointer sharing
if( pe.EQ.root )then
allocate( d(n) )
Expand Down Expand Up @@ -112,41 +108,6 @@ subroutine test_mpp_max

end subroutine test_mpp_max

subroutine test_mpp_chksum()

if( modulo(n,npes).EQ.0 )then !only set up for even division
n2 = 1024
a = 0.d0
if( pe.EQ.root )call random_number(a(1:n2))

call mpp_sync()
call mpp_transmit( put_data=a(1), plen=n2, to_pe=ALL_PES, &
get_data=a(1), glen=n2, from_pe=root )
call mpp_sync_self ()

m= n2/npes

allocate( c(m) )
c = a(pe*m+1:pe*m+m)

if( pe.EQ.root )then
print *
print *, '------------------ > Test mpp_chksum <------------------ '
print *, 'This test shows that a whole array and a distributed array give identical checksums.'
end if

if ( mpp_chksum(a(1:n2),(/pe/)) .NE. mpp_chksum(c) ) then
call mpp_error(FATAL, &
& 'Test mpp_chksum fails: a whole array and a distributed array did not give identical checksums')
else
print *, 'For pe=', pe, ' chksum(a(1:1024))=chksum(c(1:1024))='
endif

else
call mpp_error(FATAL, 'Test mpp_chksum: cannot run this test since n cannot be evenly by npes')
end if

end subroutine test_mpp_chksum

subroutine test_shared_pointers(locd,n)
integer(i8_kind), intent(in) :: locd
Expand Down
Loading

0 comments on commit 6692f95

Please sign in to comment.