Skip to content

Commit

Permalink
(mpi) hangs in testsuite with checks on single thread fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljprice committed Dec 20, 2024
1 parent ee1e177 commit 8905290
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/tests/test_derivs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ subroutine test_derivs(ntests,npass,string)
if (id==master .and. periodic .and. index(kernelname,'cubic') > 0) then
call get_neighbour_stats(trialmean,actualmean,maxtrial,maxactual,nrhocalc,nactual)
realneigh = 4./3.*pi*(hfact*radkern)**3
call checkval(actualmean,real(int(realneigh)),tiny(0.),nfailed(11),'mean nneigh')
call checkval(maxactual,int(realneigh),0,nfailed(12),'max nneigh')
call checkval(actualmean,real(int(realneigh)),tiny(0.),nfailed(11),'mean nneigh',thread_id=id)
call checkval(maxactual,int(realneigh),0,nfailed(12),'max nneigh',thread_id=id)
nexact = 2*nptot
call checkval(nrhocalc,nexact,0,nfailed(13),'n density calcs')
call checkval(nrhocalc,nexact,0,nfailed(13),'n density calcs',thread_id=id)
nexact = nptot*int(realneigh)
call checkval(nactual,nexact,0,nfailed(14),'total nneigh')
call checkval(nactual,nexact,0,nfailed(14),'total nneigh',thread_id=id)
endif
!
!--check that the timestep bin has been set
Expand Down Expand Up @@ -407,13 +407,13 @@ subroutine test_derivs(ntests,npass,string)
realneigh = 4./3.*pi*(hfact*radkern)**3
if (testall) then
nexact = nptot ! should be no iterations here
call checkval(nrhocalc,nexact,0,nfailed(17),'n density calcs')
call checkval(nrhocalc,nexact,0,nfailed(17),'n density calcs',thread_id=id)
endif
if (index(kernelname,'cubic') > 0) then
call checkval(actualmean,real(int(realneigh)),tiny(0.),nfailed(15),'mean nneigh')
call checkval(maxactual,int(realneigh),0,nfailed(16),'max nneigh')
call checkval(actualmean,real(int(realneigh)),tiny(0.),nfailed(15),'mean nneigh',thread_id=id)
call checkval(maxactual,int(realneigh),0,nfailed(16),'max nneigh',thread_id=id)
nexact = nptot*int(realneigh)
call checkval(nactual,nexact,0,nfailed(18),'total nneigh')
call checkval(nactual,nexact,0,nfailed(18),'total nneigh',thread_id=id)
endif
endif
!
Expand Down
37 changes: 29 additions & 8 deletions src/tests/utils_testsuite.f90
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ subroutine checkval1_r4(xi,val,tol,ndiff,label,thread_id)
real :: errtmp

ndiff = 0
call print_testinfo(trim(label))
call print_testinfo(trim(label),present(thread_id))

erri = abs(xi-val)
if (abs(val) > smallval) erri = erri/abs(val)
Expand Down Expand Up @@ -327,7 +327,7 @@ subroutine checkval1_r8(xi,val,tol,ndiff,label,thread_id)
real(kind=8) :: erri

ndiff = 0
call print_testinfo(trim(label))
call print_testinfo(trim(label),present(thread_id))

erri = abs(xi-val)
if (abs(val) > smallval) erri = erri/abs(val)
Expand Down Expand Up @@ -381,7 +381,7 @@ subroutine checkval1_int(ix,ival,itol,ndiff,label,thread_id)
integer :: erri

ndiff = 0
call print_testinfo(trim(label))
call print_testinfo(trim(label),present(thread_id))

erri = abs(ix-ival)
if (erri > itol) ndiff = 1
Expand All @@ -407,23 +407,37 @@ end subroutine checkval1_int
! checks a single, integer*8 value
!+
!----------------------------------------------------------------
subroutine checkval1_int8(ix,ival,itol,ndiff,label)
subroutine checkval1_int8(ix,ival,itol,ndiff,label,thread_id)
integer(kind=8), intent(in) :: ix
integer(kind=8), intent(in) :: ival
integer, intent(in) :: itol
integer, intent(out) :: ndiff
character(len=*), intent(in) :: label
integer, intent(in), optional :: thread_id
integer(kind=8) :: erri
integer :: itmp

ndiff = 0
call print_testinfo(trim(label))
call print_testinfo(trim(label),present(thread_id))

erri = abs(ix-ival)
if (erri > itol) ndiff = 1

itmp = int(erri)
call printresult(1,ndiff,itmp,itol)

if (present(thread_id) .or. nprocs==1) then
if (ndiff == 0) then
if (itol==0) then
write(*,"(a,i11,a,i12,a)") 'OK [got',ix,' should be',ival,']'
else
write(*,"(a,i11,a,i12,a,i5,a)") 'OK [got',ix,' should be',ival,', tol = ',itol,']'
endif
else
call printerr(label,int(ix),int(ival),itmp,itol)
endif
else
call printresult(1,ndiff,itmp,itol)
endif

end subroutine checkval1_int8

Expand Down Expand Up @@ -808,12 +822,19 @@ end subroutine printerr_logical
! formatting for initial test information
!+
!----------------------------------------------------------------
subroutine print_testinfo(string)
subroutine print_testinfo(string,always)
character(len=*), intent(in) :: string
logical, intent(in), optional :: always
character(len=20) :: fmtstring
integer :: ndots,istart
logical :: do_print

if (id==master) then
do_print = (id==master) ! by default only print on master MPI thread
if (present(always)) then
do_print = (id==master) .or. always ! override this when thread_id=id passed to checkval routines
endif

if (do_print) then
istart = 20
ndots = -1
do while(ndots < 2 .and. istart < 60)
Expand Down

0 comments on commit 8905290

Please sign in to comment.