1 ! Program to test FORALL construct
4 call actual_variable ()
5 call negative_stride ()
9 subroutine actual_variable ()
14 ! Actual variable 'x' and 'j' used as FORALL index
15 forall (x
= 1:3, j
= 1:4)
18 if (any (a
.ne
.reshape ((/1,1,1,2,2,2,3,3,3,4,4,4/), (/3,4/)))) call abort
19 if ((x
.ne
.-1).or
.(j
.ne
.100)) call abort
21 call actual_variable_2 (x
, j
, a
)
24 subroutine actual_variable_2(x
, j
, a
)
26 integer a(3,4), b(3,4)
28 ! Actual variable 'x' and 'j' used as FORALL index.
29 forall (x
=3:1:-1, j
=4:1:-1)
34 if (any (a
.ne
.reshape ((/1,1,1,2,2,2,3,3,3,4,4,4/), (/3,4/)))) call abort
35 if (any (b
.ne
.reshape ((/1,1,1,2,2,2,3,3,3,4,4,4/), (/3,4/)))) call abort
36 if ((x
.ne
.-1).or
.(j
.ne
.100)) call abort
39 subroutine negative_stride ()
43 ! FORALL with negative stride
44 forall (x
= 3:1:-1, j
= 4:1:-1)
47 if (any (a
.ne
.reshape ((/2,3,4,3,4,5,4,5,6,5,6,7/), (/3,4/)))) call abort
50 subroutine forall_index
53 ! FORALL with arbitrary number indexes
54 forall (i1
=1:2,i2
=1:2,i3
=1:2,i4
=1:2,i5
=1:2,i6
=1:2,i7
=1:2,i8
=1:2,i9
=1:2,&
56 a(i1
+2*i3
+4*i5
+8*i7
+16*i9
-30,i2
+2*i4
+4*i6
+8*i8
+16*i10
-30) = 1
58 if ((a(5,5).ne
.1).or
. (a(32,32).ne
.1)) call abort