1 ! Test OpenACC data regions with a copy-in of optional arguments.
8 integer, parameter :: n
= 64
10 integer :: a_int
, b_int
, c_int
, res_int
11 integer :: a_arr(n
), b_arr(n
), c_arr(n
), res_arr(n
)
12 integer, allocatable
:: a_alloc(:), b_alloc(:), c_alloc(:), res_alloc(:)
18 call test_int(res_int
, a_int
)
19 if (res_int
.ne
. a_int
) stop 1
21 call test_int(res_int
, a_int
, b_int
)
22 if (res_int
.ne
. a_int
* b_int
) stop 2
24 call test_int(res_int
, a_int
, b_int
, c_int
)
25 if (res_int
.ne
. a_int
* b_int
+ c_int
) stop 3
33 call test_array(res_arr
, a_arr
)
35 if (res_arr(i
) .ne
. a_arr(i
)) stop 4
38 call test_array(res_arr
, a_arr
, b_arr
)
40 if (res_arr(i
) .ne
. a_arr(i
) * b_arr(i
)) stop 5
43 call test_array(res_arr
, a_arr
, b_arr
, c_arr
)
45 if (res_arr(i
) .ne
. a_arr(i
) * b_arr(i
) + c_arr(i
)) stop 6
51 allocate (res_alloc(n
))
55 b_alloc(i
) = n
- i
+ 1
59 call test_allocatable(res_alloc
, a_alloc
)
61 if (res_alloc(i
) .ne
. a_alloc(i
)) stop 7
64 call test_allocatable(res_alloc
, a_alloc
, b_alloc
)
66 if (res_alloc(i
) .ne
. a_alloc(i
) * b_alloc(i
)) stop 8
69 call test_allocatable(res_alloc
, a_alloc
, b_alloc
, c_alloc
)
71 if (res_alloc(i
) .ne
. a_alloc(i
) * b_alloc(i
) + c_alloc(i
)) stop 9
77 deallocate (res_alloc
)
79 subroutine test_int(res
, a
, b
, c
)
82 integer, optional
:: b
, c
84 !$acc data copyin(a, b, c) copyout(res)
88 if (present(b
)) res
= res
* b
90 if (present(c
)) res
= res
+ c
93 end subroutine test_int
95 subroutine test_array(res
, a
, b
, c
)
98 integer, optional
:: b(n
), c(n
)
100 !$acc data copyin(a, b, c) copyout(res)
108 if (present(b
)) res(i
) = res(i
) * b(i
)
113 if (present(c
)) res(i
) = res(i
) + c(i
)
116 end subroutine test_array
118 subroutine test_allocatable(res
, a
, b
, c
)
119 integer, allocatable
:: res(:)
120 integer, allocatable
:: a(:)
121 integer, allocatable
, optional
:: b(:), c(:)
123 !$acc data copyin(a, b, c) copyout(res)
131 if (present(b
)) res(i
) = res(i
) * b(i
)
136 if (present(c
)) res(i
) = res(i
) + c(i
)
139 end subroutine test_allocatable