2018-01-22 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / allocatable9.f90
blob80bf5d389f3d264774c559bc045e39818f20d80d
1 ! { dg-do run }
3 integer, allocatable :: a, b(:), c(:,:)
4 logical :: l
5 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort
6 !$omp parallel private (a, b, c)
7 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort
8 allocate (a, b(-7:-1), c(2:3, 3:5))
9 if (.not.allocated (a)) call abort
10 if (.not.allocated (b) .or. size (b) /= 7) call abort
11 if (lbound (b, 1) /= -7 .or. ubound (b, 1) /= -1) call abort
12 if (.not.allocated (c) .or. size (c) /= 6) call abort
13 if (size (c, 1) /= 2 .or. size (c, 2) /= 3) call abort
14 if (lbound (c, 1) /= 2 .or. ubound (c, 1) /= 3) call abort
15 if (lbound (c, 2) /= 3 .or. ubound (c, 2) /= 5) call abort
16 a = 4
17 b = 3
18 c = 2
19 !$omp end parallel
20 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort
21 !$omp parallel firstprivate (a, b, c)
22 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort
23 allocate (a, b(-7:-1), c(2:3, 3:5))
24 if (.not.allocated (a)) call abort
25 if (.not.allocated (b) .or. size (b) /= 7) call abort
26 if (lbound (b, 1) /= -7 .or. ubound (b, 1) /= -1) call abort
27 if (.not.allocated (c) .or. size (c) /= 6) call abort
28 if (size (c, 1) /= 2 .or. size (c, 2) /= 3) call abort
29 if (lbound (c, 1) /= 2 .or. ubound (c, 1) /= 3) call abort
30 if (lbound (c, 2) /= 3 .or. ubound (c, 2) /= 5) call abort
31 a = 4
32 b = 3
33 c = 2
34 !$omp end parallel
35 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort
36 allocate (a, b(6:9), c(3, 8:9))
37 a = 2
38 b = 4
39 c = 5
40 if (.not.allocated (a)) call abort
41 if (.not.allocated (b) .or. size (b) /= 4) call abort
42 if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort
43 if (.not.allocated (c) .or. size (c) /= 6) call abort
44 if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort
45 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort
46 if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort
47 !$omp parallel firstprivate (a, b, c)
48 if (.not.allocated (a)) call abort
49 if (.not.allocated (b) .or. size (b) /= 4) call abort
50 if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort
51 if (.not.allocated (c) .or. size (c) /= 6) call abort
52 if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort
53 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort
54 if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort
55 if (a /= 2 .or. any (b .ne. 4) .or. any (c .ne. 5)) call abort
56 deallocate (a)
57 if (allocated (a)) call abort
58 allocate (a)
59 a = 8
60 b = (/ 1, 2, 3 /)
61 c = reshape ((/ 1, 2, 3, 4, 5, 6, 7, 8 /), (/ 2, 4 /))
62 if (.not.allocated (a)) call abort
63 if (.not.allocated (b) .or. size (b) /= 3) call abort
64 if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 3) call abort
65 if (.not.allocated (c) .or. size (c) /= 8) call abort
66 if (size (c, 1) /= 2 .or. size (c, 2) /= 4) call abort
67 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 2) call abort
68 if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 4) call abort
69 if (a /= 8 .or. b(2) /= 2 .or. c(1, 2) /= 3) call abort
70 !$omp end parallel
71 if (.not.allocated (a)) call abort
72 if (.not.allocated (b) .or. size (b) /= 4) call abort
73 if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort
74 if (.not.allocated (c) .or. size (c) /= 6) call abort
75 if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort
76 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort
77 if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort
78 if (a /= 2 .or. any (b .ne. 4) .or. any (c .ne. 5)) call abort
79 l = .false.
80 !$omp parallel sections lastprivate (a, b, c) firstprivate (l)
81 !$omp section
82 if (.not.allocated (a)) call abort
83 if (l) then
84 if (.not.allocated (b) .or. size (b) /= 6) call abort
85 if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 6) call abort
86 if (.not.allocated (c) .or. size (c) /= 8) call abort
87 if (size (c, 1) /= 4 .or. size (c, 2) /= 2) call abort
88 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 4) call abort
89 if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 2) call abort
90 if (a /= 12 .or. b(2) /= 8 .or. c(1, 2) /= 5) call abort
91 else
92 if (.not.allocated (b) .or. size (b) /= 4) call abort
93 if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort
94 if (.not.allocated (c) .or. size (c) /= 6) call abort
95 if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort
96 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort
97 if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort
98 end if
99 l = .true.
100 deallocate (a)
101 if (allocated (a)) call abort
102 allocate (a)
103 a = 8
104 b = (/ 1, 2, 3 /)
105 c = reshape ((/ 1, 2, 3, 4, 5, 6, 7, 8 /), (/ 2, 4 /))
106 if (.not.allocated (a)) call abort
107 if (.not.allocated (b) .or. size (b) /= 3) call abort
108 if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 3) call abort
109 if (.not.allocated (c) .or. size (c) /= 8) call abort
110 if (size (c, 1) /= 2 .or. size (c, 2) /= 4) call abort
111 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 2) call abort
112 if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 4) call abort
113 if (a /= 8 .or. b(2) /= 2 .or. c(1, 2) /= 3) call abort
114 !$omp section
115 if (.not.allocated (a)) call abort
116 if (l) then
117 if (.not.allocated (b) .or. size (b) /= 3) call abort
118 if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 3) call abort
119 if (.not.allocated (c) .or. size (c) /= 8) call abort
120 if (size (c, 1) /= 2 .or. size (c, 2) /= 4) call abort
121 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 2) call abort
122 if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 4) call abort
123 if (a /= 8 .or. b(2) /= 2 .or. c(1, 2) /= 3) call abort
124 else
125 if (.not.allocated (b) .or. size (b) /= 4) call abort
126 if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort
127 if (.not.allocated (c) .or. size (c) /= 6) call abort
128 if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort
129 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort
130 if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort
131 end if
132 l = .true.
133 deallocate (a)
134 if (allocated (a)) call abort
135 allocate (a)
136 a = 12
137 b = (/ 9, 8, 7, 6, 5, 4 /)
138 c = reshape ((/ 1, 2, 3, 4, 5, 6, 7, 8 /), (/ 4, 2 /))
139 if (.not.allocated (a)) call abort
140 if (.not.allocated (b) .or. size (b) /= 6) call abort
141 if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 6) call abort
142 if (.not.allocated (c) .or. size (c) /= 8) call abort
143 if (size (c, 1) /= 4 .or. size (c, 2) /= 2) call abort
144 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 4) call abort
145 if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 2) call abort
146 if (a /= 12 .or. b(2) /= 8 .or. c(1, 2) /= 5) call abort
147 !$omp end parallel sections
148 if (.not.allocated (a)) call abort
149 if (.not.allocated (b) .or. size (b) /= 6) call abort
150 if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 6) call abort
151 if (.not.allocated (c) .or. size (c) /= 8) call abort
152 if (size (c, 1) /= 4 .or. size (c, 2) /= 2) call abort
153 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 4) call abort
154 if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 2) call abort
155 if (a /= 12 .or. b(2) /= 8 .or. c(1, 2) /= 5) call abort