OSDN Git Service

2010-04-06 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / array_alloc_3.f90
1 ! Like array_alloc_1.f90, but check multi-dimensional arrays.
2 ! { dg-do run }
3 program main
4   implicit none
5   call test ((/ 3, 4, 5 /), f ((/ 3, 4, 5 /)))
6 contains
7   subroutine test (expected, x)
8     integer, dimension (:,:,:) :: x
9     integer, dimension (3) :: expected
10     integer :: i, i1, i2, i3
11     do i = 1, 3
12       if (size (x, i) .ne. expected (i)) call abort
13     end do
14     do i1 = 1, expected (1)
15       do i2 = 1, expected (2)
16         do i3 = 1, expected (3)
17           if (x (i1, i2, i3) .ne. i1 + i2 * 10 + i3 * 100) call abort
18         end do
19       end do
20     end do
21   end subroutine test
22
23   function f (x)
24     integer, dimension (3) :: x
25     integer, dimension (x(1), x(2), x(3)) :: f
26     integer :: i1, i2, i3
27     do i1 = 1, x(1)
28       do i2 = 1, x(2)
29         do i3 = 1, x(3)
30           f (i1, i2, i3) = i1 + i2 * 10 + i3 * 100
31         end do
32       end do
33     end do
34   end function f
35 end program main