1 ! Test OpenACC data regions with a copy-out of optional arguments.
8 integer, parameter :: n
= 64
10 integer :: a_int
, b_int
, res_int
11 integer :: a_arr(n
), b_arr(n
), res_arr(n
)
12 integer, allocatable
:: a_alloc(:), b_alloc(:), res_alloc(:)
16 call test_int(a_int
, b_int
)
17 if (res_int
.ne
. 0) stop 1
19 call test_int(a_int
, b_int
, res_int
)
20 if (res_int
.ne
. a_int
* b_int
) stop 2
28 call test_array(a_arr
, b_arr
)
30 if (res_arr(i
) .ne
. 0) stop 3
33 call test_array(a_arr
, b_arr
, res_arr
)
35 if (res_arr(i
) .ne
. a_arr(i
) * b_arr(i
)) stop 4
40 allocate (res_alloc(n
))
45 b_alloc(i
) = n
- i
+ 1
48 call test_allocatable(a_alloc
, b_alloc
)
50 if (res_alloc(i
) .ne
. 0) stop 5
53 call test_allocatable(a_alloc
, b_alloc
, res_alloc
)
55 if (res_alloc(i
) .ne
. a_alloc(i
) * b_alloc(i
)) stop 6
60 deallocate (res_alloc
)
62 subroutine test_int(a
, b
, res
)
64 integer, optional
:: res
66 !$acc data copyin(a, b) copyout(res)
68 if (present(res
)) res
= a
* b
71 end subroutine test_int
73 subroutine test_array(a
, b
, res
)
75 integer, optional
:: res(n
)
77 !$acc data copyin(a, b) copyout(res)
80 if (present(res
)) res(i
) = a(i
) * b(i
)
83 end subroutine test_array
85 subroutine test_allocatable(a
, b
, res
)
86 integer, allocatable
:: a(:), b(:)
87 integer, allocatable
, optional
:: res(:)
89 !$acc data copyin(a, b) copyout(res)
92 if (present(res
)) res(i
) = a(i
) * b(i
)
95 end subroutine test_allocatable