5 implicit none (type, external)
9 integer, allocatable
:: x(:)
12 do i
= 1, omp_get_num_devices() + 1
13 !$omp target firstprivate(x)
14 if (allocated(x
)) error
stop
16 if (allocated(x
)) error
stop
19 do i
= 1, omp_get_num_devices() + 1
20 !$omp target firstprivate(x, i)
21 if (allocated(x
)) error
stop
23 if (any (x
/= [10,20,30,40] + i
)) error
stop
27 if (allocated(x
)) error
stop
32 do i
= 1, omp_get_num_devices() + 1
33 !$omp target firstprivate(x, i)
34 if (i
<= 0) error
stop
35 if (.not
.allocated(x
)) error
stop
36 if (size(x
) /= 4) error
stop
37 if (lbound(x
,1) /= 1) error
stop
38 if (any (x
/= [1,2,3,4])) error
stop
39 ! no reallocation, just malloced + assignment
41 if (any (x
/= [10,20,30,40] + i
)) error
stop
45 if (.not
.allocated(x
)) error
stop
46 if (size(x
) /= 4) error
stop
47 if (lbound(x
,1) /= 1) error
stop
48 if (any (x
/= [1,2,3,4])) error
stop
54 character(len
=:), allocatable
:: x(:)
55 character(len
=5) :: str
58 str
= "abcde" ! work around for PR fortran/91544
59 do i
= 1, omp_get_num_devices() + 1
60 !$omp target firstprivate(x)
61 if (allocated(x
)) error
stop
63 if (allocated(x
)) error
stop
66 do i
= 1, omp_get_num_devices() + 1
67 !$omp target firstprivate(x, i)
68 if (allocated(x
)) error
stop
69 ! no reallocation, just malloced + assignment
70 x
= [character(len
=2+i
) :: str
,"fhji","klmno"]
71 if (len(x
) /= 2+i
) error
stop
72 if (any (x
/= [character(len
=2+i
) :: str
,"fhji","klmno"])) error
stop
76 if (allocated(x
)) error
stop
79 x
= [character(len
=4) :: "ABCDE","FHJI","KLMNO"]
81 do i
= 1, omp_get_num_devices() + 1
82 !$omp target firstprivate(x, i)
83 if (i
<= 0) error
stop
84 if (.not
.allocated(x
)) error
stop
85 if (size(x
) /= 3) error
stop
86 if (lbound(x
,1) /= 1) error
stop
87 if (len(x
) /= 4) error
stop
88 if (any (x
/= [character(len
=4) :: "ABCDE","FHJI","KLMNO"])) error
stop
89 !! Reallocation runs into the issue PR fortran/105538
91 !!x = [character(len=2+i) :: str,"fhji","klmno"]
92 !!if (len(x) /= 2+i) error stop
93 !!if (any (x /= [character(len=2+i) :: str,"fhji","klmno"])) error stop
97 x
= [character(len
=4) :: "abcde","fhji","klmno"]
98 if (any (x
/= [character(len
=4) :: "abcde","fhji","klmno"])) error
stop
100 if (.not
.allocated(x
)) error
stop
101 if (lbound(x
,1) /= 1) error
stop
102 if (size(x
) /= 3) error
stop
103 if (len(x
) /= 4) error
stop
104 if (any (x
/= [character(len
=4) :: "ABCDE","FHJI","KLMNO"])) error
stop