1! Program to test the power (**) operator
2program testpow
3   implicit none
4   real(kind=4) r, s, two
5   real(kind=8) :: q
6   complex(kind=4) :: c, z
7   real, parameter :: del = 0.0001
8   integer i, j
9
10   i = 2
11   j = i ** 10
12   if (abs (j - 1024) .gt. del) STOP 1
13   j = i ** (-10)
14   if (abs (j - 0) .gt. del) STOP 2
15   j = i ** 0
16   if (abs (j - 1) .gt. del) STOP 3
17   i = 1
18   j = i ** 10
19   if (abs (j - 1) .gt. del) STOP 4
20   j = i ** (-10)
21   if (abs (j - 1) .gt. del) STOP 5
22   j = i ** 0
23   if (abs (j - 1) .gt. del) STOP 6
24   i = -1
25   j = i ** 10
26   if (abs (j - 1) .gt. del) STOP 7
27   j = i ** (-10)
28   if (abs (j - 1) .gt. del) STOP 8
29   j = i ** 0
30   if (abs (j - 1) .gt. del) STOP 9
31   j = i ** 11
32   if (abs (j - (-1)) .gt. del) STOP 10
33   j = i ** (-11)
34   if (abs (j - (-1)) .gt. del) STOP 11
35
36   c = (2.0, 3.0)
37   z = c ** 2
38   if (abs(z - (-5.0, 12.0)) .gt. del) STOP 12
39   z = c ** 7
40   if (abs(z - (6554.0, 4449.0)) .gt. del) STOP 13
41
42   two = 2.0
43
44   r = two ** 1
45   if (abs (r - 2.0) .gt. del) STOP 14
46   r = two ** 2
47   if (abs (r - 4.0) .gt. del) STOP 15
48   r = two ** 3
49   if (abs (r - 8.0) .gt. del) STOP 16
50   r = two ** 4
51   if (abs (r - 16.0) .gt. del) STOP 17
52   r = two ** 0
53   if (abs (r - 1.0) .gt. del) STOP 18
54   r = two ** (-1)
55   if (abs (r - 0.5) .gt. del) STOP 19
56   r = two ** (-2)
57   if (abs (r - 0.25) .gt. del) STOP 20
58   r = two ** (-4)
59   if (abs (r - 0.0625) .gt. del) STOP 21
60   s = 3.0
61   r = two ** s
62   if (abs (r - 8.0) .gt. del) STOP 22
63   s = -3.0
64   r = two ** s
65   if (abs (r - 0.125) .gt. del) STOP 23
66   i = 3
67   r = two ** i
68   if (abs (r - 8.0) .gt. del) STOP 24
69   i = -3
70   r = two ** i
71   if (abs (r - 0.125) .gt. del) STOP 25
72   c = (2.0, 3.0)
73   c = c ** two
74   if (abs(c - (-5.0, 12.0)) .gt. del) STOP 26
75end program
76