| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! TS 29113 |
| 4 |
! 7.2 RANK (A) |
| 5 |
! Description. Rank of a data object. |
| 6 |
! Class. Inquiry function. |
| 7 |
! Argument. |
| 8 |
! A shall be a scalar or array of any type. |
| 9 |
! Result Characteristics. Default integer scalar. |
| 10 |
! Result Value. The result is the rank of A. |
| 11 |
|
| 12 |
program test |
| 13 |
|
| 14 |
! Define some arrays for testing. |
| 15 |
integer, target :: x1(5) |
| 16 |
integer :: y1(0:9) |
| 17 |
integer, pointer :: p1(:) |
| 18 |
integer, allocatable :: a1(:) |
| 19 |
integer, target :: x3(2,3,4) |
| 20 |
integer :: y3(0:1,-3:-1,4) |
| 21 |
integer, pointer :: p3(:,:,:) |
| 22 |
integer, allocatable :: a3(:,:,:) |
| 23 |
integer :: x |
| 24 |
|
| 25 |
! Test the 1-dimensional arrays. |
| 26 |
if (rank (x1) .ne. 1) stop 201 |
| 27 |
call testit (x1, 1) |
| 28 |
call test1 (x1) |
| 29 |
if (rank (y1) .ne. 1) stop 202 |
| 30 |
call testit (y1, 1) |
| 31 |
call test1 (y1) |
| 32 |
if (rank (p1) .ne. 1) stop 203 |
| 33 |
p1 => x1 |
| 34 |
call testit (p1, 1) |
| 35 |
if (rank (p1) .ne. 1) stop 204 |
| 36 |
call test1 (p1) |
| 37 |
if (rank (a1) .ne. 1) stop 205 |
| 38 |
allocate (a1(5)) |
| 39 |
if (rank (a1) .ne. 1) stop 206 |
| 40 |
call testit (a1, 1) |
| 41 |
call test1 (a1) |
| 42 |
|
| 43 |
! Test the multi-dimensional arrays. |
| 44 |
if (rank (x3) .ne. 3) stop 207 |
| 45 |
call testit (x3, 3) |
| 46 |
call test1 (x3) |
| 47 |
call test3 (x3, 1, 2, 1, 3) |
| 48 |
if (rank (y3) .ne. 3) stop 208 |
| 49 |
call test3 (y3, 0, 1, -3, -1) |
| 50 |
if (rank (p3) .ne. 3) stop 209 |
| 51 |
p3 => x3 |
| 52 |
call testit (p3, 3) |
| 53 |
call test1 (p3) |
| 54 |
if (rank (p3) .ne. 3) stop 210 |
| 55 |
call test3 (p3, 1, 2, 1, 3) |
| 56 |
if (rank (a3) .ne. 3) stop 211 |
| 57 |
allocate (a3(2,3,4)) |
| 58 |
call testit (a3, 3) |
| 59 |
call test1 (a3) |
| 60 |
if (rank (a3) .ne. 3) stop 212 |
| 61 |
call test3 (a3, 1, 2, 1, 3) |
| 62 |
|
| 63 |
! Test scalars. |
| 64 |
if (rank (x) .ne. 0) stop 213 |
| 65 |
call testit (x, 0) |
| 66 |
call test0 (x) |
| 67 |
if (rank (-1) .ne. 0) stop 214 |
| 68 |
call test0 (-1) |
| 69 |
if (rank (x1(1)) .ne. 0) stop 215 |
| 70 |
call test0 (x1(1)) |
| 71 |
|
| 72 |
contains |
| 73 |
|
| 74 |
subroutine testit (a, r) |
| 75 |
integer :: a(..) |
| 76 |
integer :: r |
| 77 |
|
| 78 |
if (r .ne. rank(a)) stop 101 |
| 79 |
end subroutine |
| 80 |
|
| 81 |
subroutine test0 (a) |
| 82 |
integer :: a(..) |
| 83 |
if (rank (a) .ne. 0) stop 103 |
| 84 |
call testit (a, 0) |
| 85 |
end subroutine |
| 86 |
|
| 87 |
subroutine test1 (a) |
| 88 |
integer :: a(*) |
| 89 |
call testit (a, 1) |
| 90 |
end subroutine |
| 91 |
|
| 92 |
subroutine test3 (a, l1, u1, l2, u2) |
| 93 |
implicit none |
| 94 |
integer :: l1, u1, l2, u2 |
| 95 |
integer :: a(l1:u1, l2:u2, *) |
| 96 |
call testit (a, 3) |
| 97 |
end subroutine |
| 98 |
|
| 99 |
end program |