Debian Codegraph @

gcc/testsuite/gfortran.dg/do_concurrent_14.f90

raw
1 ! { dg-do run }
2
3 module m
4 implicit none
5 type t
6 integer :: y = 44
7 integer, pointer :: ptr(:) => null()
8 end type t
9
10 ! No default initializers, cf. do_concurrent_12.f90
11 ! and PR fortran/101602 (comment 6)
12 type t2
13 integer :: y
14 integer, pointer :: ptr(:)
15 end type t2
16
17 contains
18
19 subroutine sub(x, y)
20 integer :: i
21 type(t) :: x, y(4)
22 type(t) :: a, b(3)
23 type(t2) :: x2, y2(4)
24 type(t2) :: a2, b2(3)
25 logical :: error = .false.
26 integer, target :: tgt(6)
27 integer, target :: tgt2(7)
28
29 x%y = 100
30 x%ptr => tgt
31 y(1)%y = 101
32 y(2)%y = 102
33 y(3)%y = 103
34 y(4)%y = 104
35 y(1)%ptr => tgt
36 y(2)%ptr => tgt
37 y(3)%ptr => tgt
38 y(4)%ptr => tgt
39
40 a%y = 105
41 a%ptr => tgt
42 b(1)%y = 106
43 b(2)%y = 107
44 b(3)%y = 108
45 b(1)%ptr => tgt
46 b(2)%ptr => tgt
47 b(3)%ptr => tgt
48
49 ! Copy values from 't' to associated 't2' variables
50 x2%y = x%y
51 x2%ptr => x%ptr
52 a2%y = a%y
53 a2%ptr => a%ptr
54 y2(:)%y = y(:)%y
55 do i = 1, size(y)
56 y2(i)%ptr => y(i)%ptr
57 end do
58 b2(:)%y = b(:)%y
59 do i = 1, size(b)
60 b2(i)%ptr => b(i)%ptr
61 end do
62
63 do concurrent (i = 1: 3) local_init(x,y,a,b) shared(error,tgt,tgt2) default(none)
64 if (x%y /= 100 &
65 .or. .not.associated (x%ptr, tgt) &
66 .or. y(1)%y /= 101 &
67 .or. y(2)%y /= 102 &
68 .or. y(3)%y /= 103 &
69 .or. y(4)%y /= 104 &
70 .or. .not.associated (y(1)%ptr, tgt) &
71 .or. .not.associated (y(2)%ptr, tgt) &
72 .or. .not.associated (y(3)%ptr, tgt) &
73 .or. .not.associated (y(4)%ptr, tgt) &
74 .or. a%y /= 105 &
75 .or. .not.associated (a%ptr, tgt) &
76 .or. b(1)%y /= 106 &
77 .or. b(2)%y /= 107 &
78 .or. b(3)%y /= 108 &
79 .or. .not.associated (b(1)%ptr, tgt) &
80 .or. .not.associated (b(2)%ptr, tgt) &
81 .or. .not.associated (b(3)%ptr, tgt)) &
82 error = .true.
83
84 x%y = 900
85 x%ptr => tgt
86 y(1)%y = 901
87 y(2)%y = 902
88 y(3)%y = 903
89 y(4)%y = 904
90 y(1)%ptr => tgt2
91 y(2)%ptr => tgt2
92 y(3)%ptr => tgt2
93 y(4)%ptr => tgt2
94
95 a%y = 905
96 a%ptr => tgt
97 b(1)%y = 906
98 b(2)%y = 907
99 b(3)%y = 908
100 b(1)%ptr => tgt2
101 b(2)%ptr => tgt2
102 b(3)%ptr => tgt2
103 end do
104
105 if (error) stop 1
106 if (x%y /= 100 &
107 .or. .not.associated (x%ptr, tgt) &
108 .or. y(1)%y /= 101 &
109 .or. y(2)%y /= 102 &
110 .or. y(3)%y /= 103 &
111 .or. y(4)%y /= 104 &
112 .or. .not.associated (y(1)%ptr, tgt) &
113 .or. .not.associated (y(2)%ptr, tgt) &
114 .or. .not.associated (y(3)%ptr, tgt) &
115 .or. .not.associated (y(4)%ptr, tgt) &
116 .or. a%y /= 105 &
117 .or. .not.associated (a%ptr, tgt) &
118 .or. b(1)%y /= 106 &
119 .or. b(2)%y /= 107 &
120 .or. b(3)%y /= 108 &
121 .or. .not.associated (b(1)%ptr, tgt) &
122 .or. .not.associated (b(2)%ptr, tgt) &
123 .or. .not.associated (b(3)%ptr, tgt)) &
124 stop 2
125
126 ! Use version without default initializers
127 do concurrent (i = 1: 3) local(x2,y2,a2,b2) shared(error,tgt,tgt2) default(none)
128 x2%y = 900
129 x2%ptr => tgt
130 y2(1)%y = 901
131 y2(2)%y = 902
132 y2(3)%y = 903
133 y2(4)%y = 904
134 y2(1)%ptr => tgt2
135 y2(2)%ptr => tgt2
136 y2(3)%ptr => tgt2
137 y2(4)%ptr => tgt2
138
139 a2%y = 905
140 a2%ptr => tgt
141 b2(1)%y = 906
142 b2(2)%y = 907
143 b2(3)%y = 908
144 b2(1)%ptr => tgt2
145 b2(2)%ptr => tgt2
146 b2(3)%ptr => tgt2
147 end do
148
149 if (error) stop 3
150 if (x2%y /= 100 &
151 .or. .not.associated (x2%ptr, tgt) &
152 .or. y2(1)%y /= 101 &
153 .or. y2(2)%y /= 102 &
154 .or. y2(3)%y /= 103 &
155 .or. y2(4)%y /= 104 &
156 .or. .not.associated (y2(1)%ptr, tgt) &
157 .or. .not.associated (y2(2)%ptr, tgt) &
158 .or. .not.associated (y2(3)%ptr, tgt) &
159 .or. .not.associated (y2(4)%ptr, tgt) &
160 .or. a2%y /= 105 &
161 .or. .not.associated (a2%ptr, tgt) &
162 .or. b2(1)%y /= 106 &
163 .or. b2(2)%y /= 107 &
164 .or. b2(3)%y /= 108 &
165 .or. .not.associated (b2(1)%ptr, tgt) &
166 .or. .not.associated (b2(2)%ptr, tgt) &
167 .or. .not.associated (b2(3)%ptr, tgt)) &
168 stop 4
169 end
170 end
171
172 use m
173 implicit none
174 type(t) :: q, r(4)
175 call sub(q,r)
176 end