e.51.1.f90 923 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ! { dg-do run }
  2. module e_51_1_mod
  3. contains
  4. subroutine init (v1, v2, N)
  5. integer :: i, N
  6. real :: v1(N), v2(N)
  7. do i = 1, N
  8. v1(i) = i + 2.0
  9. v2(i) = i - 3.0
  10. end do
  11. end subroutine
  12. subroutine check (p, N)
  13. integer :: i, N
  14. real, parameter :: EPS = 0.00001
  15. real :: diff, p(N)
  16. do i = 1, N
  17. diff = p(i) - (i + 2.0) * (i - 3.0)
  18. if (diff > EPS .or. -diff > EPS) call abort
  19. end do
  20. end subroutine
  21. subroutine vec_mult (N)
  22. real :: p(N), v1(N), v2(N)
  23. integer :: i, N
  24. call init (v1, v2, N)
  25. !$omp target data map(to: v1, v2) map(from: p)
  26. !$omp target
  27. !$omp parallel do
  28. do i = 1, N
  29. p(i) = v1(i) * v2(i)
  30. end do
  31. !$omp end target
  32. !$omp end target data
  33. call check (p, N)
  34. end subroutine
  35. end module
  36. program e_51_1
  37. use e_51_1_mod, only : vec_mult
  38. integer :: n
  39. n = 1000
  40. call vec_mult (n)
  41. end program