program main
  use vecadd_module
  integer(4), parameter :: n = 2**20
  real(4), allocatable, dimension(:) :: a, b, c

  allocate(a(n))
  allocate(b(n))
  allocate(c(n))

  !$acc data create(a,b) copyout(c)

  !$acc kernels
  do i = 1, n
    a(i) = i
    b(i) = i * 2.0
  end do
  !$acc end kernels

  !$acc host_data use_device(a,b,c)

    call vecadd_wrapper(n, a, b, c)

  !$acc end  host_data

  !$acc end data

  print '(1x, i10, F15.0)', (i, c(i), i=n-10,n)
end program
