| 1 |
! Test complex munbers |
| 2 |
program testcmplx |
| 3 |
implicit none |
| 4 |
complex(kind=4) c, d |
| 5 |
complex(kind=8) z |
| 6 |
real(kind=4) x, y |
| 7 |
real(kind=8) q |
| 8 |
|
| 9 |
! cmplx intrinsic |
| 10 |
x = 3 |
| 11 |
y = 4 |
| 12 |
c = cmplx(x,y) |
| 13 |
if (c .ne. (3.0, 4.0)) STOP 1 |
| 14 |
x = 4 |
| 15 |
y = 3 |
| 16 |
z = cmplx(x, y, 8) |
| 17 |
if (z .ne. (4.0, 3.0)) STOP 2 |
| 18 |
z = c |
| 19 |
if (z .ne. (3.0, 4.0)) STOP 3 |
| 20 |
|
| 21 |
! dcmplx intrinsic |
| 22 |
x = 3 |
| 23 |
y = 4 |
| 24 |
z = dcmplx (x, y) |
| 25 |
if (z .ne. (3.0, 4.0)) STOP 4 |
| 26 |
|
| 27 |
! conjucates and aimag |
| 28 |
c = (1.0, 2.0) |
| 29 |
c = conjg (c) |
| 30 |
x = aimag (c) |
| 31 |
if (abs (c - (1.0, -2.0)) .gt. 0.001) STOP 5 |
| 32 |
if (x .ne. -2.0) STOP 6 |
| 33 |
z = (2.0, 1.0) |
| 34 |
z = conjg (z) |
| 35 |
q = aimag (z) |
| 36 |
if (z .ne. (2.0, -1.0)) STOP 7 |
| 37 |
if (q .ne. -1.0) STOP 8 |
| 38 |
|
| 39 |
! addition, subtraction and multiplication |
| 40 |
c = (1, 3) |
| 41 |
d = (5, 2) |
| 42 |
if (c + d .ne. ( 6, 5)) STOP 9 |
| 43 |
if (c - d .ne. (-4, 1)) STOP 10 |
| 44 |
if (c * d .ne. (-1, 17)) STOP 11 |
| 45 |
|
| 46 |
! test for constant folding |
| 47 |
if ((35.,-10.)**0.NE.(1.,0.)) STOP 12 |
| 48 |
end program |