| 1 |
! Program to test the DOT_PRODUCT intrinsic |
| 2 |
program testforall |
| 3 |
implicit none |
| 4 |
integer, dimension (3) :: a |
| 5 |
integer, dimension (3) :: b |
| 6 |
real, dimension(3) :: c |
| 7 |
real r |
| 8 |
complex, dimension (2) :: z1 |
| 9 |
complex, dimension (2) :: z2 |
| 10 |
complex z |
| 11 |
|
| 12 |
a = (/1, 2, 3/); |
| 13 |
b = (/4, 5, 6/); |
| 14 |
c = (/4, 5, 6/); |
| 15 |
|
| 16 |
if (dot_product(a, b) .ne. 32) STOP 1 |
| 17 |
|
| 18 |
r = dot_product(a, c) |
| 19 |
if (abs(r - 32.0) .gt. 0.001) STOP 2 |
| 20 |
|
| 21 |
z1 = (/(1.0, 2.0), (2.0, 3.0)/) |
| 22 |
z2 = (/(3.0, 4.0), (4.0, 5.0)/) |
| 23 |
z = dot_product (z1, z2) |
| 24 |
if (abs (z - (34.0, -4.0)) .gt. 0.001) STOP 3 |
| 25 |
end program |