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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
! { dg-do run }
! { dg-options "-fcoarray=single" }
!
! PR fortran/18918
!
! Contributed by John Reid.
!
program ex2
implicit none
real, allocatable :: z(:)[:]
integer :: image
character(len=128) :: str
allocate(z(3)[*])
write(*,*) 'z allocated on image',this_image()
sync all
if (this_image()==1) then
z = 1.2
do image = 2, num_images() ! { dg-warning "will be executed zero times" }
write(*,*) 'Assigning z(:) on image',image
z(:)[image] = z
end do
end if
sync all
str = repeat('X', len(str))
write(str,*) 'z=',z(:),' on image',this_image()
if (str /= " z= 1.20000005 1.20000005 1.20000005 on image 1") &
call abort
str = repeat('X', len(str))
write(str,*) 'z=',z,' on image',this_image()
if (str /= " z= 1.20000005 1.20000005 1.20000005 on image 1") &
call abort
str = repeat('X', len(str))
write(str,*) 'z=',z(1:3)[this_image()],' on image',this_image()
if (str /= " z= 1.20000005 1.20000005 1.20000005 on image 1") &
call abort
call ex2a()
call ex5()
end
subroutine ex2a()
implicit none
real, allocatable :: z(:,:)[:,:]
integer :: image
character(len=128) :: str
allocate(z(2,2)[1,*])
write(*,*) 'z allocated on image',this_image()
sync all
if (this_image()==1) then
z = 1.2
do image = 2, num_images() ! { dg-warning "will be executed zero times" }
write(*,*) 'Assigning z(:) on image',image
z(:,:)[1,image] = z
end do
end if
sync all
str = repeat('X', len(str))
write(str,*) 'z=',z(:,:),' on image',this_image()
if (str /= " z= 1.20000005 1.20000005 1.20000005 1.20000005 on image 1") &
call abort
str = repeat('X', len(str))
write(str,*) 'z=',z,' on image',this_image()
if (str /= " z= 1.20000005 1.20000005 1.20000005 1.20000005 on image 1") &
call abort
end subroutine ex2a
subroutine ex5
implicit none
integer :: me
real, save :: w(4)[*]
character(len=128) :: str
me = this_image()
w = me
str = repeat('X', len(str))
write(str,*) 'In main on image',this_image(), 'w= ',w
if (str /= " In main on image 1 w= 1.00000000 1.00000000 1.00000000 1.00000000") &
call abort
str = repeat('X', len(str))
write(str,*) 'In main on image',this_image(), 'w= ',w(1:4)
if (str /= " In main on image 1 w= 1.00000000 1.00000000 1.00000000 1.00000000") &
call abort
str = repeat('X', len(str))
write(str,*) 'In main on image',this_image(), 'w= ',w(:)[1]
if (str /= " In main on image 1 w= 1.00000000 1.00000000 1.00000000 1.00000000") &
call abort
sync all
call ex5_sub(me,w)
end subroutine ex5
subroutine ex5_sub(n,w)
implicit none
integer :: n
real :: w(n)
character(len=75) :: str
str = repeat('X', len(str))
write(str,*) 'In sub on image',this_image(), 'w= ',w
if (str /= " In sub on image 1 w= 1.00000000") &
call abort
end subroutine ex5_sub
|