1! { dg-do run }
2
3! Test of explicit attach/detach clauses and attachment counters. There are no
4! acc_attach/acc_detach API routines in Fortran.
5
6program dtype
7  use openacc
8  implicit none
9  integer, parameter :: n = 512
10  type mytype
11    integer, allocatable :: a(:)
12  end type mytype
13  integer i
14
15  type(mytype) :: var
16
17  allocate(var%a(1:n))
18
19  call acc_copyin(var)
20  call acc_copyin(var%a)
21
22  !$acc enter data attach(var%a)
23
24!$acc parallel loop attach(var%a)
25  do i = 1,n
26    var%a(i) = i
27  end do
28!$acc end parallel loop
29
30  !$acc exit data detach(var%a)
31
32  call acc_copyout(var%a)
33  call acc_copyout(var)
34
35  do i = 1,n
36    if (i .ne. var%a(i)) stop 1
37  end do
38
39  deallocate(var%a)
40
41end program dtype
42