1! Offloading test checking interaction of an explicit derived type member
2! mapping of an array with bounds when mapped to target using a combination of
3! update, enter and exit directives.
4! REQUIRES: flang, amdgpu
5
6! RUN: %libomptarget-compile-fortran-run-and-check-generic
7program main
8    type :: scalar_array
9        integer(4) :: array(10)
10    end type scalar_array
11
12    type(scalar_array) :: scalar_arr
13
14    do I = 1, 10
15        scalar_arr%array(I) = I + I
16    end do
17
18  !$omp target enter data map(to: scalar_arr%array(3:6))
19
20    ! overwrite our target data with an update.
21    do I = 1, 10
22        scalar_arr%array(I) = 10
23    end do
24
25  !$omp target update to(scalar_arr%array(3:6))
26
27  ! The compiler/runtime is less friendly about read/write out of
28  ! bounds when using enter and exit, we have to specifically loop
29  ! over the correct range
30   !$omp target
31    do i=3,6
32        scalar_arr%array(i) = scalar_arr%array(i) + i
33    end do
34  !$omp end target
35
36  !$omp target exit data map(from: scalar_arr%array(3:6))
37
38  print*, scalar_arr%array
39end program
40
41!CHECK: 10 10 13 14 15 16 10 10 10 10
42