1 ! Test propagation of optional arguments from within an OpenACC parallel region.
8 integer, parameter :: n
= 64
11 integer :: a_arr(n
), b_arr(n
), res_arr(n
)
12 integer, allocatable
:: a_alloc(:), b_alloc(:), res_alloc(:)
14 call test_int_caller(res_int
, 5)
15 if (res_int
.ne
. 10) stop 1
17 call test_int_caller(res_int
, 2, 3)
18 if (res_int
.ne
. 11) stop 2
25 call test_array_caller(res_arr
, a_arr
)
27 if (res_arr(i
) .ne
. 2 * a_arr(i
)) stop 3
30 call test_array_caller(res_arr
, a_arr
, b_arr
)
32 if (res_arr(i
) .ne
. a_arr(i
) * b_arr(i
) + a_arr(i
) + b_arr(i
)) stop 4
37 allocate(res_alloc(n
))
41 b_alloc(i
) = n
- i
+ 1
44 call test_array_caller(res_arr
, a_arr
)
46 if (res_arr(i
) .ne
. 2 * a_alloc(i
)) stop 5
49 call test_array_caller(res_arr
, a_arr
, b_arr
)
51 if (res_arr(i
) .ne
. a_arr(i
) * b_alloc(i
) + a_alloc(i
) + b_alloc(i
)) stop 6
58 subroutine test_int_caller(res
, a
, b
)
60 integer, optional
:: b
62 !$acc data copyin(a, b) copyout (res)
65 if (present(b
)) res
= res
* b
66 call test_int_callee(res
, a
, b
)
69 end subroutine test_int_caller
71 subroutine test_int_callee(res
, a
, b
)
74 integer, optional
:: b
77 if (present(b
)) res
= res
+ b
78 end subroutine test_int_callee
80 subroutine test_array_caller(res
, a
, b
)
81 integer :: res(n
), a(n
), i
82 integer, optional
:: b(n
)
84 !$acc data copyin(a, b) copyout(res)
89 if (present(b
)) res(i
) = res(i
) * b(i
)
91 call test_array_callee(res
, a
, b
)
94 end subroutine test_array_caller
96 subroutine test_array_callee(res
, a
, b
)
98 integer :: res(n
), a(n
), i
99 integer, optional
:: b(n
)
102 res(i
) = res(i
) + a(i
)
103 if (present(b
)) res(i
) = res(i
) + b(i
)
105 end subroutine test_array_callee
107 subroutine test_allocatable_caller(res
, a
, b
)
109 integer, allocatable
:: res(:), a(:)
110 integer, allocatable
, optional
:: b(:)
112 !$acc data copyin(a, b) copyout(res)
117 if (present(b
)) res(i
) = res(i
) * b(i
)
119 call test_array_callee(res
, a
, b
)
122 end subroutine test_allocatable_caller
124 subroutine test_allocatable_callee(res
, a
, b
)
127 integer, allocatable
:: res(:), a(:)
128 integer, allocatable
, optional
:: b(:)
131 res(i
) = res(i
) + a(i
)
132 if (present(b
)) res(i
) = res(i
) + b(i
)
134 end subroutine test_allocatable_callee