1 ! Program to test arrays
2 ! The program outputs a series of numbers.
3 ! Two digit numbers beginning with 0, 1, 2 or 3 is a normal.
4 ! Three digit numbers starting with 4 indicate an error.
5 ! Using 1D arrays isn't a sufficient test, the first dimension is often
11 integer, dimension (5, 8) :: a
13 if (a(1, 1) .ne. 42) call abort
15 if (a(5, 8) .ne. 43) call abort
21 integer, dimension(3:7, 4:11) :: a
27 subroutine test (parm)
30 integer, dimension(2:, 3:) :: parm
32 integer, dimension(5, 8) :: a
33 ! Known size array with different bounds
34 integer, dimension(4:8, 3:10) :: b
36 integer, dimension(:, :), allocatable :: c, d, e
38 integer, dimension(5) :: v1
39 integer, dimension(10, 10) :: v2
45 ! Same size, different bounds
46 allocate (d(11:15, 12:19))
67 v2 (3, 1::2) = v1 (5:1:-1)
70 if (v1(1) .ne. 2) call abort
71 if (v2(3, 3) .ne. 4) call abort
73 ! Passing whole arrays
89 ! Passing whole arrays as sections
101 call f1 (e(2:6, n:10))
102 call f2 (e(2:6, n:10))
104 ! v1= index plus one, v2(3, ::2) = reverse of index
108 call f1 (e(v1, n:10))
109 call f2 (e(v1, n:10))
110 ! Double vector subscript
114 !These are not resolved properly
115 call f1 (e(v1(v2(3, ::2)), n:10))
116 call f2 (e(v1(v2(3, ::2)), n:10))
117 ! non-contiguous sections
122 call f1 (e(1:15:3, 1:24:3))
123 call f2 (e(::3, ::n))
124 ! non-contiguous sections with bounds
129 call f1 (e(3:11:2, 4:n:2))
130 call f2 (e(3:11:2, 4:n:2))
132 ! Passing a dummy variable
136 ! Assumed shape parameter
138 integer, dimension (1:, 1:) :: a
140 if (a(1, 1) .ne. 42) call abort
142 if (a(5, 8) .ne. 43) call abort