1 ! Test OpenACC unstructured enter data/exit data regions with optional
9 integer, parameter :: n
= 64
10 integer :: a(n
), b(n
), c(n
), res(n
)
11 integer :: x
, y
, z
, r
, i
21 if (res(i
) .ne
. a(i
)) stop 1
24 res
= test_array(a
, b
)
26 if (res(i
) .ne
. a(i
) * b(i
)) stop 2
29 res
= test_array(a
, b
, c
)
31 if (res(i
) .ne
. a(i
) * b(i
) + c(i
)) stop 3
42 if (r
.ne
. x
* y
) stop 5
45 if (r
.ne
. x
* y
+ z
) stop 6
47 function test_array(a
, b
, c
)
49 integer, optional
:: b(n
), c(n
)
50 integer :: test_array(n
), res(n
)
52 !$acc enter data copyin(a, b, c) create(res)
61 res(i
) = res(i
) * b(i
)
68 res(i
) = res(i
) + c(i
)
71 !$acc exit data copyout(res) delete(a, b, c)
74 end function test_array
76 function test_int(a
, b
, c
)
78 integer, optional
:: b
, c
79 integer :: test_int
, res
81 !$acc enter data copyin(a, b, c) create(res)
82 !$acc parallel present(a, b, c, res)
84 if (present(b
)) res
= res
* b
85 if (present(c
)) res
= res
+ c
87 !$acc exit data copyout(res) delete(a, b, c)