Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/serial-fpp/test_fixtured_suite_fpp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ subroutine random_test_case_run(this)
integer :: nn

nn = -1
scopeptrs = scope_pointers()
allocate(scopeptrs, source=scope_pointers())
! scopeptrs(1): current scope - random_test_case instance
! scopeptrs(2): first enclosing scope - random_test_suite instance
if (size(scopeptrs) < 2)&
Expand Down
2 changes: 1 addition & 1 deletion example/serial/test_fixtured_suite.f90
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ subroutine random_test_case_run(this)
integer :: nn

nn = -1
scopeptrs = scope_pointers()
allocate(scopeptrs, source=scope_pointers())
! scopeptrs(1): current scope - random_test_case instance
! scopeptrs(2): first enclosing scope - random_test_suite instance
if (size(scopeptrs) < 2)&
Expand Down
2 changes: 1 addition & 1 deletion example/serial/test_simple.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ subroutine test_cotan()

real(r32), allocatable :: yvals(:,:)

yvals = cotanvals
allocate(yvals, source=cotanvals)
! We add a "bug" for the 3rd element to demonstrate the failure
yvals(1, 2) = yvals(1, 2) + 0.1_r32

Expand Down
22 changes: 14 additions & 8 deletions src/fortuno/checkers/int_template.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
& checkresult)
return
end if
match = value1 == value2
allocate(match(size(value1, dim=1)))
match(:) = value1 == value2
mismatchloc = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("mismatching integer values",&
Expand Down Expand Up @@ -77,7 +78,8 @@
& checkresult)
return
end if
match = value1 == value2
allocate(match(size(value1, dim=1), size(value1, dim=2)))
match(:,:) = value1 == value2
mismatchloc = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("mismatching integer values",&
Expand Down Expand Up @@ -106,7 +108,8 @@
logical, allocatable :: match(:)
integer(i64) :: mismatchloc(1)

match = value1 == value2
allocate(match(size(value1, dim=1)))
match(:) = value1 == value2
mismatchloc = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("mismatching integer values",&
Expand Down Expand Up @@ -134,7 +137,8 @@
logical, allocatable :: match(:)
integer(i64) :: mismatchloc(1)

match = value1 == value2
allocate(match(size(value2, dim=1)))
match(:) = value1 == value2
mismatchloc = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("mismatching integer values",&
Expand All @@ -147,7 +151,7 @@
end function all_equal_r0_r1


!> Checks whether two integer rank 1 arrays are equal.
!> Checks whether a scalar integer is equal to an integer rank 2 array.
function all_equal_r2_r0(value1, value2) result(checkresult)

!> First value to check
Expand All @@ -162,7 +166,8 @@
logical, allocatable :: match(:,:)
integer(i64) :: mismatchloc(2)

match = value1 == value2
allocate(match(size(value1, dim=1), size(value1, dim=2)))
match(:,:) = value1 == value2
mismatchloc = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("mismatching integer values",&
Expand All @@ -175,7 +180,7 @@
end function all_equal_r2_r0


!> Checks whether two integer rank 1 arrays are equal.
!> Checks whether a scalar integer is equal to an integer rank 2 array.
function all_equal_r0_r2(value1, value2) result(checkresult)

!> First value to check
Expand All @@ -190,7 +195,8 @@
logical, allocatable :: match(:,:)
integer(i64) :: mismatchloc(2)

match = value1 == value2
allocate(match(size(value2, dim=1), size(value2, dim=2)))
match(:,:) = value1 == value2
mismatchloc = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("mismatching integer values",&
Expand Down
18 changes: 12 additions & 6 deletions src/fortuno/checkers/real_template.inc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
& checkresult)
return
end if
match = is_close_elem(value1, value2, atol=atol, rtol=rtol)
allocate(match(size(value1, dim=1)))
match(:) = is_close_elem(value1, value2, atol=atol, rtol=rtol)
mismatchloc(:) = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("real values differing beyond tolerance",&
Expand Down Expand Up @@ -95,7 +96,8 @@
& checkresult)
return
end if
match = is_close_elem(value1, value2, atol=atol, rtol=rtol)
allocate(match(size(value1, dim=1), size(value1, dim=2)))
match(:,:) = is_close_elem(value1, value2, atol=atol, rtol=rtol)
mismatchloc(:) = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("real values differing beyond tolerance",&
Expand Down Expand Up @@ -130,7 +132,8 @@
logical, allocatable :: match(:)
integer(i64) :: mismatchloc(1)

match = is_close_elem(value1, value2, atol=atol, rtol=rtol)
allocate(match(size(value1, dim=1)))
match(:) = is_close_elem(value1, value2, atol=atol, rtol=rtol)
mismatchloc(:) = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("real values differing beyond tolerance",&
Expand Down Expand Up @@ -164,7 +167,8 @@
logical, allocatable :: match(:)
integer(i64) :: mismatchloc(1)

match = is_close_elem(value1, value2, atol=atol, rtol=rtol)
allocate(match(size(value2, dim=1)))
match(:) = is_close_elem(value1, value2, atol=atol, rtol=rtol)
mismatchloc(:) = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("real values differing beyond tolerance",&
Expand Down Expand Up @@ -198,7 +202,8 @@
logical, allocatable :: match(:,:)
integer(i64) :: mismatchloc(2)

match = is_close_elem(value1, value2, atol=atol, rtol=rtol)
allocate(match(size(value1, dim=1), size(value1, dim=2)))
match(:,:) = is_close_elem(value1, value2, atol=atol, rtol=rtol)
mismatchloc(:) = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("real values differing beyond tolerance",&
Expand Down Expand Up @@ -233,7 +238,8 @@
logical, allocatable :: match(:,:)
integer(i64) :: mismatchloc(2)

match = is_close_elem(value1, value2, atol=atol, rtol=rtol)
allocate(match(size(value2, dim=1), size(value2, dim=2)))
match(:,:) = is_close_elem(value1, value2, atol=atol, rtol=rtol)
mismatchloc(:) = findloc(match, .false., kind=i64)
if (all(mismatchloc /= 0)) then
call add_value_mismatch_details("real values differing beyond tolerance",&
Expand Down
12 changes: 6 additions & 6 deletions src/fortuno/cmdapp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,19 @@ function default_argument_defs() result(argdefs)
! & helpmsg="show list of tests to run and exit"),&
! & &
! & argument_def("tests", argtypes%stringlist,&
! & helpmsg="list of tests and suites to include or to exclude when prefixed with '~' (e.g.&
! & 'somesuite ~somesuite/avoidedtest' would run all tests except 'avoidedtest' in the test&
! & suite 'somesuite')")&
! & helpmsg="list of tests and suites to include or to exclude when prefixed with '~' (e.g. " //&
! & "'somesuite ~somesuite/avoidedtest' would run all tests except 'avoidedtest' in the test " //&
! & "suite 'somesuite')")&
Comment on lines +173 to +175
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we use sting addition, if Fortran has a perfect feature of breaking strings into continuation lines? I don't see the point for this change...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it makes no sense, but GCC with warnings enabled will catch what you currently have. Unlike most of the warning fixes, which affect fortuno's test cases (we don't build by default), this one gets caught by Octopus's CI.

So the point is either client codes are forced into disabling specific warnings or one does a trivial patch upstream. Alternatively, we discussed scoping compiler flags on a per library basis some time ago, but since Cristian's left, this is a non-starter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked gfortran 15.2:

gfortran -Dfortuno_EXPORTS -I[...]fortuno/src/modules -I[...]fortuno/src/fortuno/checkers -I[...]fortuno/include -fcheck=all -std=f2018 -Wall -pedantic -g -Jmodules -fPIC -c [...]fortuno/src/fortuno/cmdapp.f90 -o CMakeFiles/fortuno.dir/fortuno/cmdapp.f90.o

which does not produce any warnings in cmdapp.f90. Do you use any other flags, which trigger this warning? Or does the warning appear in your case with the most recent gfortran? (In case, they fixed it in recent gfortran versions, I would probably tend to keep the original formulation. I kind consider Fortuno also as a demonstration of best practices when programming in modern Fortran.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I also checked GFortran 13.2 now and I do not get any warnings for cmdapp.f90 with the -std=f2018 -Wall -pedantic flag combination. Do you use an older compiler (which could cause other troubles due to compiler bugs) or a different warning level setting?

! & &
! & ]
! -}{+
allocate(argdefs(2))
argdefs(1) = argument_def("list", argtypes%bool, shortopt="l", longopt="list",&
& helpmsg="show list of tests to run and exit")
argdefs(2) = argument_def("tests", argtypes%stringlist,&
& helpmsg="list of tests and suites to include or to exclude when prefixed with '~' (e.g.&
& 'somesuite ~somesuite/avoidedtest' would run all tests except 'avoidedtest' in the test&
& suite 'somesuite')")
& helpmsg="list of tests and suites to include or to exclude when prefixed with '~' (e.g. " // &
& "'somesuite ~somesuite/avoidedtest' would run all tests except 'avoidedtest' in the test " // &
& "suite 'somesuite')")
Comment on lines +183 to +185
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment just above. Let's keep the original form, unless there is a really convincing argument for the change.

! +}

end function default_argument_defs
Expand Down
12 changes: 4 additions & 8 deletions src/fortuno/consolelogger.f90
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,9 @@ subroutine console_logger_log_drive_result(this, driveresult)

maxitems = maxval([sum(driveresult%suitestats, dim=1), sum(driveresult%teststats)])
numfieldwidth = len(str(maxitems))
call log_summary_("# Suite set-ups", driveresult%suiteresults(1, :),&
& driveresult%suitestats(:, 1), numfieldwidth)
call log_summary_("# Suite tear-downs", driveresult%suiteresults(2, :),&
& driveresult%suitestats(:, 2), numfieldwidth)
call log_summary_("# Test runs", driveresult%testresults, driveresult%teststats,&
& numfieldwidth)
call log_summary_("# Suite set-ups", driveresult%suitestats(:, 1), numfieldwidth)
call log_summary_("# Suite tear-downs", driveresult%suitestats(:, 2), numfieldwidth)
call log_summary_("# Test runs", driveresult%teststats, numfieldwidth)
call log_success_(driveresult%successful)

end subroutine console_logger_log_drive_result
Expand Down Expand Up @@ -366,9 +363,8 @@ end subroutine write_failure_info_


!! Logs test summary
subroutine log_summary_(header, testresults, teststats, numfieldwidth)
subroutine log_summary_(header, teststats, numfieldwidth)
character(*), intent(in) :: header
type(test_result), intent(in) :: testresults(:)
integer, intent(in) :: teststats(:)
integer, intent(in) :: numfieldwidth

Expand Down