1 ! Test OpenACC declare directives with 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
)
17 call test_int(res_int
, a_int
)
18 if (res_int
.ne
. a_int
) stop 1
20 call test_int(res_int
, a_int
, b_int
)
21 if (res_int
.ne
. a_int
* b_int
) stop 2
23 call test_int(res_int
, a_int
, b_int
, c_int
)
24 if (res_int
.ne
. a_int
* b_int
+ c_int
) stop 3
32 call test_array(res_arr
, a_arr
)
34 if (res_arr(i
) .ne
. a_arr(i
)) stop 4
37 call test_array(res_arr
, a_arr
, b_arr
)
39 if (res_arr(i
) .ne
. a_arr(i
) * b_arr(i
)) stop 5
42 call test_array(res_arr
, a_arr
, b_arr
, c_arr
)
44 if (res_arr(i
) .ne
. a_arr(i
) * b_arr(i
) + c_arr(i
)) stop 6
47 subroutine test_int(res
, a
, b
, c
)
49 integer, optional
:: b
, c
50 !$acc declare present_or_copyin(a, b, c)
52 !$acc declare present_or_copyout(res)
56 if (present(b
)) res
= res
* b
57 if (present(c
)) res
= res
+ c
59 end subroutine test_int
61 subroutine test_array(res
, a
, b
, c
)
63 integer, optional
:: b(n
), c(n
)
64 !$acc declare present_or_copyin(a, b, c)
66 !$acc declare present_or_copyout(res)
76 res(i
) = res(i
) * b(i
)
83 res(i
) = res(i
) + c(i
)
86 end subroutine test_array