Skip to content

Commit

Permalink
Have all ranks error stop on failed correctness check
Browse files Browse the repository at this point in the history
Previously only the root rank stopped, which I don't think was raceproof.

Co-authored-by: Willem Deconinck <[email protected]>
  • Loading branch information
samhatfield and wdeconinck committed Aug 25, 2023
1 parent 36e81b5 commit 258620d
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/programs/ectrans-benchmark.F90
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ program transform_test

character(len=16) :: cgrid = ''

integer :: ierr

!===================================================================================================

#include "setup_trans0.h"
Expand Down Expand Up @@ -801,18 +803,30 @@ program transform_test
write(nout,*)

if (ncheck > 0) then
! If the maximum spectral norm error across all fields is greater than 100 times the machine
! epsilon, fail the test
if (zmaxerrg > real(ncheck, jprb) * epsilon(1.0_jprb)) then
write(nout, '(a)') '*******************************'
write(nout, '(a)') 'Correctness test failed'
write(nout, '(a,1e7.2)') 'Maximum spectral norm error = ', zmaxerrg
write(nout, '(a,1e7.2)') 'Error tolerance = ', real(ncheck, jprb) * epsilon(1.0_jprb)
write(nout, '(a)') '*******************************'
error stop
endif
ierr = 0
if (myproc == 1) then
! If the maximum spectral norm error across all fields is greater than 100 times the machine
! epsilon, fail the test
if (zmaxerrg > real(ncheck, jprb) * epsilon(1.0_jprb)) then
write(nout, '(a)') '*******************************'
write(nout, '(a)') 'Correctness test failed'
write(nout, '(a,1e7.2)') 'Maximum spectral norm error = ', zmaxerrg
write(nout, '(a,1e7.2)') 'Error tolerance = ', real(ncheck, jprb) * epsilon(1.0_jprb)
write(nout, '(a)') '*******************************'
ierr = 1
endif
endif

! Root rank broadcasts the correctness checker result to the other ranks
if (luse_mpi) then
call mpl_broadcast(ierr, ktag=0)
endif

! Halt if correctness checker failed
if (ierr == 1) then
error stop
endif
endif
endif
endif

if (luse_mpi) then
Expand Down

0 comments on commit 258620d

Please sign in to comment.