From 30063376c92e6351bc98aeb34a746a11ef204e4c Mon Sep 17 00:00:00 2001 From: Alistair Adcroft Date: Wed, 8 Apr 2020 16:01:53 +0000 Subject: [PATCH] Write test fails to both stderr and stdout - 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). --- src/ALE/MOM_remapping.F90 | 1 + src/framework/MOM_diag_vkernels.F90 | 4 +++- src/framework/MOM_random.F90 | 2 ++ src/framework/MOM_string_functions.F90 | 10 ++++++++-- src/tracer/MOM_lateral_boundary_diffusion.F90 | 6 +++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ALE/MOM_remapping.F90 b/src/ALE/MOM_remapping.F90 index 6255a6fce8..e7e1052efe 100644 --- a/src/ALE/MOM_remapping.F90 +++ b/src/ALE/MOM_remapping.F90 @@ -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 diff --git a/src/framework/MOM_diag_vkernels.F90 b/src/framework/MOM_diag_vkernels.F90 index 43bf73c13d..b134be5bd6 100644 --- a/src/framework/MOM_diag_vkernels.F90 +++ b/src/framework/MOM_diag_vkernels.F90 @@ -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./), & @@ -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 @@ -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 diff --git a/src/framework/MOM_random.F90 b/src/framework/MOM_random.F90 index 6e254abed2..8dafc530ba 100644 --- a/src/framework/MOM_random.F90 +++ b/src/framework/MOM_random.F90 @@ -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 diff --git a/src/framework/MOM_string_functions.F90 b/src/framework/MOM_string_functions.F90 index 0a4058995a..33f9b69376 100644 --- a/src/framework/MOM_string_functions.F90 +++ b/src/framework/MOM_string_functions.F90 @@ -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 @@ -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 diff --git a/src/tracer/MOM_lateral_boundary_diffusion.F90 b/src/tracer/MOM_lateral_boundary_diffusion.F90 index 82e0d6a559..9c53e0e514 100644 --- a/src/tracer/MOM_lateral_boundary_diffusion.F90 +++ b/src/tracer/MOM_lateral_boundary_diffusion.F90 @@ -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