-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_mult.f90
53 lines (40 loc) · 1.31 KB
/
test_mult.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
!--------------------------------------------------------------------------------------------------!
! $ uname -a && nagfor -O1 test_mult.f90 && ./a.out
! Linux 6.5.0-21-generic #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 9 13:32:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7143
! [NAG Fortran Compiler normal termination]
! 0.0000 0.0000
! WRONG! Product is zero
! ERROR STOP: 1
!--------------------------------------------------------------------------------------------------!
module test_mod
use iso_fortran_env, only : RP => REAL16
!use iso_fortran_env, only : RP => REAL32
!use iso_fortran_env, only : RP => REAL64
!use iso_fortran_env, only : RP => REAL128
implicit none
contains
function test(a, b, c) result(d)
real(RP), intent(in) :: a
real(RP), intent(in) :: b
real(RP), intent(in) :: c(2)
real(RP) :: d(2)
d = a * b * c
!d = a * (b * c) ! Fine
!d = c * b * a ! Fine
end function test
end module test_mod
program test_mult
use test_mod, only : RP, test
implicit none
real(RP) :: a = 0.99_RP
real(RP) :: b = 0.99_RP
real(RP) :: c(2) = [1.0_RP, 1.0_RP]
write (*, *) test(a, b, c)
if (all(abs(test(a, b, c)) <= 0)) then
write (*, *) "WRONG! Product is zero"
error stop 1
else
write (*, *) "RIGHT! Product is not zero"
end if
end program test_mult