-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
from dennisdjensen https://github.com/dennisdjensen/fortran-testanything license included in this commit. renamed test.f08 to test.f90 because *.f90 is what we have mkmf looking for updated buildfunctions to include the fortran-testanything code for developer tests only removed the local threed_model_mod.f90 (using the template model path like other developer tests)
- Loading branch information
1 parent
6c73b04
commit 8dabf8d
Showing
7 changed files
with
499 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Copyright 2015 Dennis Decker Jensen | ||
|
||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
! Template parameter: wp (working precision) | ||
! Template free identifiers: testline, tests | ||
subroutine is(got, expected, msg) | ||
integer(kind=wp), intent(in) :: got, expected | ||
character(len=*), intent(in), optional :: msg | ||
character(len=:), allocatable :: testmsg, idmsg | ||
character(len=120) gotmsg, expectedmsg | ||
logical good | ||
|
||
if (present(msg)) then | ||
allocate(character(len=len_trim(msg)+20) :: testmsg, idmsg) | ||
write (unit=idmsg, fmt='(A,A,A)') 'Failed test: "', trim(msg), '"' | ||
testmsg = trim(msg) | ||
else | ||
allocate(character(len=30) :: testmsg, idmsg) | ||
write (unit=idmsg, fmt='(A,I0)') 'Failed test no. ', tests + 1 | ||
testmsg = "" | ||
end if | ||
write (unit=gotmsg, fmt='(A,I0)') ' got: ', got | ||
write (unit=expectedmsg, fmt='(A,I0)') 'expected: ', expected | ||
|
||
good = got == expected | ||
call testline(good, testmsg, idmsg, gotmsg, expectedmsg) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
! Template parameter: wp (working precision) | ||
! Template free identifiers: testline, tests | ||
subroutine isabs(got, expected, eps, msg) | ||
real(kind=wp), intent(in) :: got, expected | ||
character(len=*), intent(in), optional :: msg | ||
real(kind=wp), intent(in), optional :: eps | ||
character(len=:), allocatable :: testmsg, idmsg | ||
character(len=120) gotmsg, expectedmsg | ||
real(kind=wp) tolerance | ||
logical good | ||
|
||
if (present(msg)) then | ||
allocate(character(len=len_trim(msg)+20) :: testmsg, idmsg) | ||
write (unit=idmsg, fmt='(A,A,A)') 'Failed test: "', trim(msg), '"' | ||
testmsg = trim(msg) | ||
else | ||
allocate(character(len=30) :: testmsg, idmsg) | ||
write (unit=idmsg, fmt='(A,I0)') 'Failed test no. ', tests + 1 | ||
testmsg = "" | ||
end if | ||
write (unit=gotmsg, fmt='(A,G0)') ' got: ', got | ||
write (unit=expectedmsg, fmt='(A,G0)') 'expected: ', expected | ||
|
||
if (present(eps)) then | ||
tolerance = eps | ||
else | ||
tolerance = epsilon(got) | ||
end if | ||
! eps = 0.5e-10_wp | ||
! Absolute accuracy within the 10 least significant digits | ||
good = abs(got - expected) < tolerance | ||
call testline(good, testmsg, idmsg, gotmsg, expectedmsg) | ||
end | ||
|
||
subroutine isrel(got, expected, eps, msg) | ||
real(kind=wp), intent(in) :: got, expected | ||
character(len=*), intent(in), optional :: msg | ||
real(kind=wp), intent(in), optional :: eps | ||
real(kind=wp) tolerance | ||
|
||
! eps = (abs(a) + abs(b)) * 0.5e-10_wp | ||
! Relative accuracy within the 10 most significant digits | ||
tolerance = (abs(got) + abs(expected)) | ||
if (present(eps)) then | ||
tolerance = tolerance * eps | ||
else | ||
tolerance = tolerance * epsilon(got) | ||
end if | ||
call isabs(got, expected, tolerance, msg) | ||
end | ||
|
||
subroutine isnear(got, expected, eps, msg) | ||
real(kind=wp), intent(in) :: got, expected | ||
character(len=*), intent(in), optional :: msg | ||
real(kind=wp), intent(in), optional :: eps | ||
character(len=:), allocatable :: testmsg, idmsg | ||
character(len=120) gotmsg, expectedmsg | ||
real(kind=wp) tolerance | ||
logical good | ||
|
||
if (present(msg)) then | ||
allocate(character(len=len_trim(msg)+20) :: testmsg, idmsg) | ||
write (unit=idmsg, fmt='(A,A,A)') 'Failed test: "', trim(msg), '"' | ||
testmsg = trim(msg) | ||
else | ||
allocate(character(len=30) :: testmsg, idmsg) | ||
write (unit=idmsg, fmt='(A,I0)') 'Failed test no. ', tests + 1 | ||
testmsg = "" | ||
end if | ||
write (unit=gotmsg, fmt='(A,G0)') ' got: ', got | ||
write (unit=expectedmsg, fmt='(A,G0)') 'expected: ', expected | ||
|
||
if (present(eps)) then | ||
tolerance = eps | ||
else | ||
tolerance = epsilon(got) ! minimun eps for which 1 + eps /= 1 | ||
end if | ||
! Relative accuracy around 1.0_wp | ||
! Semantics of isnear means using <=, and not <, c.f. epsilon(got) | ||
good = abs(got / expected - 1.0_wp) <= tolerance | ||
call testline(good, testmsg, idmsg, gotmsg, expectedmsg) | ||
end | ||
|
Oops, something went wrong.