1! Program to test array constructors
2program constructors
3   integer, dimension (4) :: a
4   integer, dimension (3, 2) :: b
5   integer i, j, k, l, m, n
6
7   a = (/1, (i,i=2,4)/)
8   do i = 1, 4
9      if (a(i) .ne. i) STOP 1
10   end do
11
12   b = reshape ((/0, 1, 2, 3, 4, 5/), (/3, 2/)) + 1
13   do i=1,3
14      if (b(i, 1) .ne. i) STOP 2
15      if (b(i, 2) .ne. i + 3) STOP 3
16   end do
17
18   k = 1
19   l = 2
20   m = 3
21   n = 4
22   ! The remainder assumes constant constructors work ok.
23   a = (/n, m, l, k/)
24   if (any (a .ne. (/4, 3, 2, 1/))) STOP 4
25   a = (/((/i+10, 42/), i = k, l)/)
26   if (any (a .ne. (/11, 42, 12, 42/))) STOP 5
27   a = (/(I, I=k,l) , (J, J=m,n)/)
28   if (any (a .ne. (/1, 2, 3, 4/))) STOP 6
29end program
30