| 1 |
implicit none |
| 2 |
type t |
| 3 |
integer, allocatable :: a, b(:) |
| 4 |
end type t |
| 5 |
type(t) :: x, y, z |
| 6 |
integer :: i |
| 7 |
|
| 8 |
!$omp target |
| 9 |
if (allocated(x%a)) stop 1 |
| 10 |
if (allocated(x%b)) stop 2 |
| 11 |
!$omp end target |
| 12 |
|
| 13 |
allocate(x%a, x%b(-4:6)) |
| 14 |
x%b(:) = [(i, i=-4,6)] |
| 15 |
|
| 16 |
!$omp target |
| 17 |
if (.not. allocated(x%a)) stop 3 |
| 18 |
if (.not. allocated(x%b)) stop 4 |
| 19 |
if (lbound(x%b,1) /= -4) stop 5 |
| 20 |
if (ubound(x%b,1) /= 6) stop 6 |
| 21 |
if (any (x%b /= [(i, i=-4,6)])) stop 7 |
| 22 |
!$omp end target |
| 23 |
|
| 24 |
|
| 25 |
! The following only works with arrays due to |
| 26 |
! PR fortran/96668 |
| 27 |
|
| 28 |
!$omp target enter data map(to: y, z) |
| 29 |
|
| 30 |
!$omp target |
| 31 |
if (allocated(y%b)) stop 8 |
| 32 |
if (allocated(z%b)) stop 9 |
| 33 |
!$omp end target |
| 34 |
|
| 35 |
allocate(y%b(5), z%b(3)) |
| 36 |
y%b = 42 |
| 37 |
z%b = 99 |
| 38 |
|
| 39 |
! (implicitly) 'tofrom' mapped |
| 40 |
! Planned for OpenMP 6.0 (but common extension) |
| 41 |
! OpenMP <= 5.0 unclear |
| 42 |
!$omp target |
| 43 |
if (.not.allocated(y%b)) stop 10 |
| 44 |
if (any (y%b /= 42)) stop 11 |
| 45 |
!$omp end target |
| 46 |
|
| 47 |
! always map: OpenMP 5.1 (clarified) |
| 48 |
!$omp target map(always, tofrom: z) |
| 49 |
if (.not.allocated(z%b)) stop 12 |
| 50 |
if (any (z%b /= 99)) stop 13 |
| 51 |
!$omp end target |
| 52 |
|
| 53 |
end |