URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gfortran.fortran-torture/] [execute/] [arrayarg.f90] - Rev 303
Compare with Previous | Blame | View Log
! Program to test arrays! The program outputs a series of numbers.! Two digit numbers beginning with 0, 1, 2 or 3 is a normal.! Three digit numbers starting with 4 indicate an error.! Using 1D arrays isn't a sufficient test, the first dimension is often! handled specially.! Fixed size parametersubroutine f1 (a)implicit noneinteger, dimension (5, 8) :: aif (a(1, 1) .ne. 42) call abortif (a(5, 8) .ne. 43) call abortend subroutineprogram testprogimplicit noneinteger, dimension(3:7, 4:11) :: aa(:,:) = 0a(3, 4) = 42a(7, 11) = 43call test(a)containssubroutine test (parm)implicit none! parameterinteger, dimension(2:, 3:) :: parm! Known size arryinteger, dimension(5, 8) :: a! Known size array with different boundsinteger, dimension(4:8, 3:10) :: b! Unknown size arraysinteger, dimension(:, :), allocatable :: c, d, e! Vectorsinteger, dimension(5) :: v1integer, dimension(10, 10) :: v2integer nexternal f1! Same sizeallocate (c(5,8))! Same size, different boundsallocate (d(11:15, 12:19))! A larger arrayallocate (e(15, 24))a(:,:) = 0b(:,:) = 0c(:,:) = 0d(:,:) = 0a(1,1) = 42b(4, 3) = 42c(1,1) = 42d(11,12) = 42a(5, 8) = 43b(8, 10) = 43c(5, 8) = 43d(15, 19) = 43v2(:, :) = 0do n=1,5v1(n) = nend dov2 (3, 1::2) = v1 (5:1:-1)v1 = v1 + 1if (v1(1) .ne. 2) call abortif (v2(3, 3) .ne. 4) call abort! Passing whole arrayscall f1 (a)call f1 (b)call f1 (c)call f2 (a)call f2 (b)call f2 (c)! passing expressionsa(1,1) = 41a(5,8) = 42call f1(a+1)call f2(a+1)a(1,1) = 42a(5,8) = 43call f1 ((a + b) / 2)call f2 ((a + b) / 2)! Passing whole arrays as sectionscall f1 (a(:,:))call f1 (b(:,:))call f1 (c(:,:))call f2 (a(:,:))call f2 (b(:,:))call f2 (c(:,:))! Passing sectionse(:,:) = 0e(2, 3) = 42e(6, 10) = 43n = 3call f1 (e(2:6, n:10))call f2 (e(2:6, n:10))! Vector subscripts! v1= index plus one, v2(3, ::2) = reverse of indexe(:,:) = 0e(2, 3) = 42e(6, 10) = 43call f1 (e(v1, n:10))call f2 (e(v1, n:10))! Double vector subscripte(:,:) = 0e(6, 3) = 42e(2, 10) = 43!These are not resolved properlycall f1 (e(v1(v2(3, ::2)), n:10))call f2 (e(v1(v2(3, ::2)), n:10))! non-contiguous sectionse(:,:) = 0e(1, 1) = 42e(13, 22) = 43n = 3call f1 (e(1:15:3, 1:24:3))call f2 (e(::3, ::n))! non-contiguous sections with boundse(:,:) = 0e(3, 4) = 42e(11, 18) = 43n = 19call f1 (e(3:11:2, 4:n:2))call f2 (e(3:11:2, 4:n:2))! Passing a dummy variablecall f1 (parm)call f2 (parm)end subroutine! Assumed shape parametersubroutine f2 (a)integer, dimension (1:, 1:) :: aif (a(1, 1) .ne. 42) call abortif (a(5, 8) .ne. 43) call abortend subroutineend program
