1 ! FIRSTPRIVATE: CLASS(*) + derived types
2 program select_type_openmp
6 type, extends(t
) :: t_int
9 type, extends(t
) :: t_char1
10 character(len
=:, kind
=1), allocatable
:: str
12 type, extends(t
) :: t_char4
13 character(len
=:, kind
=4), allocatable
:: str
15 class(*), allocatable
:: val1
, val1a
, val2
, val3
17 call sub() ! local var
19 call sub2(val1
, val1a
, val2
, val3
) ! allocatable args
21 allocate(val1
, source
=t_int(7))
22 allocate(val1a
, source
=t_int(7))
23 allocate(val2
, source
=t_char1("abcdef"))
24 allocate(val3
, source
=t_char4(4_
"zyx4"))
25 call sub3(val1
, val1a
, val2
, val3
) ! nonallocatable vars
26 deallocate(val1
, val1a
, val2
, val3
)
29 class(*), allocatable
:: val1
, val1a
, val2
, val3
30 allocate(val1a
, source
=t_int(7))
31 allocate(val2
, source
=t_char1("abcdef"))
32 allocate(val3
, source
=t_char4(4_
"zyx4"))
34 if (allocated(val1
)) stop 1
36 !$OMP PARALLEL firstprivate(val1, val1a, val2, val3)
37 if (allocated(val1
)) stop 2
38 if (.not
.allocated(val1a
)) stop 3
39 if (.not
.allocated(val2
)) stop 4
40 if (.not
.allocated(val3
)) stop 5
42 allocate(val1
, source
=t_int(7))
46 if (val1
%i
/= 7) stop 6
54 if (val1a
%i
/= 7) stop 8
62 if (len(val2
%str
) /= 6) stop 10
63 if (val2
%str
/= "abcdef") stop 11
71 if (len(val3
%str
) /= 4) stop 13
72 if (val3
%str
/= 4_
"zyx4") stop 14
80 if (len(val3
%str
) /= 4) stop 16
81 if (val3
%str
/= 4_
"AbCd") stop 17
89 if (len(val2
%str
) /= 6) stop 19
90 if (val2
%str
/= "123456") stop 20
98 if (val1
%i
/= 8) stop 22
106 if (val1a
%i
/= 8) stop 24
113 if (allocated(val1
)) stop 26
114 if (.not
. allocated(val1a
)) stop 27
115 if (.not
. allocated(val2
)) stop 28
119 if (len(val2
%str
) /= 6) stop 29
120 if (val2
%str
/= "abcdef") stop 30
126 if (len(val3
%str
) /= 4) stop 32
127 if (val3
%str
/= 4_
"zyx4") stop 33
131 deallocate(val1a
,val2
, val3
)
134 subroutine sub2(val1
, val1a
, val2
, val3
)
135 class(*), allocatable
:: val1
, val1a
, val2
, val3
137 allocate(val1a
, source
=t_int(7))
138 allocate(val2
, source
=t_char1("abcdef"))
139 allocate(val3
, source
=t_char4(4_
"zyx4"))
141 if (allocated(val1
)) stop 35
143 !$OMP PARALLEL firstprivate(val1, val1a, val2, val3)
144 if (allocated(val1
)) stop 36
145 if (.not
.allocated(val1a
)) stop 37
146 if (.not
.allocated(val2
)) stop 38
147 if (.not
.allocated(val3
)) stop 39
149 allocate(val1
, source
=t_int(7))
153 if (val1
%i
/= 7) stop 40
161 if (val1a
%i
/= 7) stop 42
169 if (len(val2
%str
) /= 6) stop 44
170 if (val2
%str
/= "abcdef") stop 45
178 if (len(val3
%str
) /= 4) stop 47
179 if (val3
%str
/= 4_
"zyx4") stop 48
187 if (len(val3
%str
) /= 4) stop 50
188 if (val3
%str
/= 4_
"AbCd") stop 51
196 if (len(val2
%str
) /= 6) stop 53
197 if (val2
%str
/= "123456") stop 54
205 if (val1
%i
/= 8) stop 56
213 if (val1a
%i
/= 8) stop 58
220 if (allocated(val1
)) stop 60
221 if (.not
. allocated(val1a
)) stop 61
222 if (.not
. allocated(val2
)) stop 62
226 if (len(val2
%str
) /= 6) stop 63
227 if (val2
%str
/= "abcdef") stop 64
234 if (len(val3
%str
) /= 4) stop 66
235 if (val3
%str
/= 4_
"zyx4") stop 67
240 deallocate(val1a
, val2
, val3
)
243 subroutine sub3(val1
, val1a
, val2
, val3
)
244 class(*) :: val1
, val1a
, val2
, val3
247 !$OMP PARALLEL firstprivate(val1, val1a, val2, val3)
250 if (val1
%i
/= 7) stop 69
258 if (val1a
%i
/= 7) stop 71
266 if (len(val2
%str
) /= 6) stop 73
267 if (val2
%str
/= "abcdef") stop 74
275 if (len(val3
%str
) /= 4) stop 76
276 if (val3
%str
/= 4_
"zyx4") stop 77
284 if (len(val3
%str
) /= 4) stop 79
285 if (val3
%str
/= 4_
"AbCd") stop 80
293 if (len(val2
%str
) /= 6) stop 82
294 if (val2
%str
/= "123456") stop 83
302 if (val1
%i
/= 8) stop 85
310 if (val1a
%i
/= 8) stop 87
319 if (len(val2
%str
) /= 6) stop 89
320 if (val2
%str
/= "abcdef") stop 90
327 if (len(val3
%str
) /= 4) stop 92
328 if (val3
%str
/= 4_
"zyx4") stop 93
334 end program select_type_openmp