Debian Codegraph @

gcc/testsuite/gfortran.dg/coarray/codimension.f90

raw
1 ! { dg-do run }
2 !
3 ! Based on coarray_lib_token_4.f90 but checking whether the bounds
4 ! are correctly handled.
5 !
6 program test_caf
7 implicit none
8 integer, allocatable :: A(:)[:]
9 integer, save :: B(3)[*]
10 integer :: i
11
12 allocate (A(3)[*])
13 A = [1, 2, 3 ]
14 B = [9, 7, 4 ]
15 call foo (A, A, test=1)
16 call foo (A(2:3), B, test=2)
17 call foo (B, A, test=3)
18 contains
19 subroutine foo(x, y, test)
20 integer :: x(:)[*]
21 integer, contiguous :: y(:)[*]
22 integer :: test
23 integer :: i, j
24 call bar (x)
25 call expl (y)
26 i = lcobound(x, dim=1)
27 j = ucobound(x, dim=1)
28 if (i /= 1 .or. j /= num_images()) STOP 1
29 i = lcobound(y, dim=1)
30 j = ucobound(y, dim=1)
31 if (i /= 1 .or. j /= num_images()) STOP 2
32 end subroutine foo
33
34 subroutine bar(y)
35 integer :: y(:)[*]
36 integer :: i, j
37 i = lcobound(y, dim=1)
38 j = ucobound(y, dim=1)
39 if (i /= 1 .or. j /= num_images()) STOP 3
40 end subroutine bar
41
42 subroutine expl(z)
43 integer :: z(*)[*]
44 integer :: i, j
45 i = lcobound(z, dim=1)
46 j = ucobound(z, dim=1)
47 if (i /= 1 .or. j /= num_images()) STOP 4
48 end subroutine expl
49 end program test_caf