Skip to content

Commit

Permalink
Write test fails to both stderr and stdout
Browse files Browse the repository at this point in the history
- Writing bad results to stderr and good results to stdout means
  there is no one place to see all results. This puts all results
  to stdout and in addition writes fails to stderr.
- Note that MOM_lateral_boundary_diffusion is incorrectly passing
  and so the posting to stderr is temporarily commented out (to
  avoid cluttering all our testing).
  • Loading branch information
adcroft committed Apr 8, 2020
1 parent 978d772 commit 3006337
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ALE/MOM_remapping.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,7 @@ logical function test_answer(verbose, n, u, u_true, label, tol)
do k = 1, n
if (abs(u(k) - u_true(k)) > tolerance) then
write(*,'(i4,1p2e24.16,a,1pe24.16,a)') k,u(k),u_true(k),' err=',u(k)-u_true(k),' < wrong'
write(0,'(i4,1p2e24.16,a,1pe24.16,a)') k,u(k),u_true(k),' err=',u(k)-u_true(k),' < wrong'
else
write(*,'(i4,1p2e24.16)') k,u(k),u_true(k)
endif
Expand Down
4 changes: 3 additions & 1 deletion src/framework/MOM_diag_vkernels.F90
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ logical function diag_vkernels_unit_tests(verbose)
4, (/0.,2.,6.,0./), (/mv,1.,3.,8.,mv/) )
diag_vkernels_unit_tests = diag_vkernels_unit_tests .or. fail

if (v) write(0,*) '- - - - - - - - - - reintegration tests - - - - - - - - -'
if (v) write(6,*) '- - - - - - - - - - reintegration tests - - - - - - - - -'

fail = test_reintegrate(v,mv,'Identity: 3 layer', &
3, (/1.,2.,3./), (/-5.,2.,1./), &
Expand Down Expand Up @@ -309,6 +309,7 @@ logical function test_interp(verbose, missing_value, msg, nsrc, h_src, u_src, nd
if (error==0.) then
write(6,'(i3,3(1pe24.16))') k,u_dest(k),u_true(k),u_dest(k)-u_true(k)
else
write(6,'(i3,3(1pe24.16),x,a)') k,u_dest(k),u_true(k),u_dest(k)-u_true(k),'<--- WRONG!'
write(0,'(i3,3(1pe24.16),x,a)') k,u_dest(k),u_true(k),u_dest(k)-u_true(k),'<--- WRONG!'
endif
enddo
Expand Down Expand Up @@ -347,6 +348,7 @@ logical function test_reintegrate(verbose, missing_value, msg, nsrc, h_src, uh_s
if (error==0.) then
write(6,'(i3,3(1pe24.16))') k,uh_dest(k),uh_true(k),uh_dest(k)-uh_true(k)
else
write(6,'(i3,3(1pe24.16),x,a)') k,uh_dest(k),uh_true(k),uh_dest(k)-uh_true(k),'<--- WRONG!'
write(0,'(i3,3(1pe24.16),x,a)') k,uh_dest(k),uh_true(k),uh_dest(k)-uh_true(k),'<--- WRONG!'
endif
enddo
Expand Down
2 changes: 2 additions & 0 deletions src/framework/MOM_random.F90
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,14 @@ logical function test_fn(verbose, good, label, rvalue, ivalue)

if (present(ivalue)) then
if (.not. good) then
write(6,'(1x,a,i10,1x,a,a)') 'random: result =',ivalue,label,' <------- FAIL!'
write(0,'(1x,a,i10,1x,a,a)') 'random: result =',ivalue,label,' <------- FAIL!'
elseif (verbose) then
write(6,'(1x,a,i10,1x,a)') 'random: result =',ivalue,label
endif
else
if (.not. good) then
write(6,'(1x,a,1pe15.8,1x,a,a)') 'random: result =',rvalue,label,' <------- FAIL!'
write(0,'(1x,a,1pe15.8,1x,a,a)') 'random: result =',rvalue,label,' <------- FAIL!'
elseif (verbose) then
write(6,'(1x,a,1pe15.8,1x,a)') 'random: result =',rvalue,label
Expand Down
10 changes: 8 additions & 2 deletions src/framework/MOM_string_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ logical function localTestS(verbose,str1,str2)
if (trim(str1)/=trim(str2)) localTestS=.true.
if (localTestS .or. verbose) then
write(*,*) '>'//trim(str1)//'<'
if (localTestS) write(*,*) trim(str1),':',trim(str2), '<-- FAIL'
if (localTestS) then
write(*,*) trim(str1),':',trim(str2), '<-- FAIL'
write(0,*) trim(str1),':',trim(str2), '<-- FAIL'
endif
endif
end function localTestS

Expand All @@ -375,7 +378,10 @@ logical function localTestI(verbose,i1,i2)
if (i1/=i2) localTestI=.true.
if (localTestI .or. verbose) then
write(*,*) i1,i2
if (localTestI) write(*,*) i1,'!=',i2, '<-- FAIL'
if (localTestI) then
write(*,*) i1,'!=',i2, '<-- FAIL'
write(0,*) i1,'!=',i2, '<-- FAIL'
endif
endif
end function localTestI

Expand Down
6 changes: 5 additions & 1 deletion src/tracer/MOM_lateral_boundary_diffusion.F90
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,12 @@ logical function test_layer_fluxes(verbose, nk, test_name, F_calc, F_ans)
do k=1,nk
if ( F_calc(k) /= F_ans(k) ) then
test_layer_fluxes = .true.
write(stdunit,*) "UNIT TEST FAILED: ", test_name
write(stdunit,*) "MOM_lateral_boundary_diffusion, UNIT TEST FAILED: ", test_name
write(stdunit,10) k, F_calc(k), F_ans(k)
! ### Once these unit tests are passing, and failures are caught properly,
! we will post failure notifications to both stdout and stderr.
!write(0,*) "MOM_lateral_boundary_diffusion, UNIT TEST FAILED: ", test_name
!write(0,10) k, F_calc(k), F_ans(k)
elseif (verbose) then
write(stdunit,10) k, F_calc(k), F_ans(k)
endif
Expand Down

0 comments on commit 3006337

Please sign in to comment.