aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/coarray/codimension.f90
blob: 077cbefb393f5bda36811ea5faffb16a34a04974 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
! { dg-do run }
!
! Based on coarray_lib_token_4.f90 but checking whether the bounds
! are correctly handled.
!
program test_caf
  implicit none
  integer, allocatable :: A(:)[:]
  integer, save :: B(3)[*]
  integer :: i

  allocate (A(3)[*])
  A = [1, 2, 3 ] 
  B = [9, 7, 4 ]
  call foo (A, A, test=1)
  call foo (A(2:3), B, test=2)
  call foo (B, A, test=3)
contains
  subroutine foo(x, y, test)
    integer :: x(:)[*]
    integer, contiguous :: y(:)[*]
    integer :: test
    integer :: i, j
    call bar (x)
    call expl (y)
    i = lcobound(x, dim=1)
    j = ucobound(x, dim=1)
    if (i /= 1 .or. j /= num_images()) STOP 1
    i = lcobound(y, dim=1)
    j = ucobound(y, dim=1)
    if (i /= 1 .or. j /= num_images()) STOP 2
  end subroutine foo

  subroutine bar(y)
    integer :: y(:)[*]
    integer :: i, j
    i = lcobound(y, dim=1)
    j = ucobound(y, dim=1)
    if (i /= 1 .or. j /= num_images()) STOP 3
  end subroutine bar

  subroutine expl(z)
    integer :: z(*)[*]
    integer :: i, j
    i = lcobound(z, dim=1)
    j = ucobound(z, dim=1)
    if (i /= 1 .or. j /= num_images()) STOP 4
  end subroutine expl
end program test_caf