lib-8.f90 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ! { dg-do run }
  2. program main
  3. use openacc
  4. use iso_c_binding
  5. implicit none
  6. integer, target :: a_3d_i(10, 10, 10)
  7. complex a_3d_c(10, 10, 10)
  8. real a_3d_r(10, 10, 10)
  9. integer i, j, k
  10. complex c
  11. real r
  12. integer, parameter :: i_size = sizeof (i)
  13. integer, parameter :: c_size = sizeof (c)
  14. integer, parameter :: r_size = sizeof (r)
  15. if (acc_get_num_devices (acc_device_nvidia) .eq. 0) call exit
  16. call acc_init (acc_device_nvidia)
  17. call set3d (.FALSE., a_3d_i, a_3d_c, a_3d_r)
  18. call acc_copyin (a_3d_i)
  19. call acc_copyin (a_3d_c)
  20. call acc_copyin (a_3d_r)
  21. if (acc_is_present (a_3d_i) .neqv. .TRUE.) call abort
  22. if (acc_is_present (a_3d_c) .neqv. .TRUE.) call abort
  23. if (acc_is_present (a_3d_r) .neqv. .TRUE.) call abort
  24. do i = 1, 10
  25. do j = 1, 10
  26. do k = 1, 10
  27. if (acc_is_present (a_3d_i(i, j, k), i_size) .neqv. .TRUE.) call abort
  28. if (acc_is_present (a_3d_c(i, j, k), i_size) .neqv. .TRUE.) call abort
  29. if (acc_is_present (a_3d_r(i, j, k), i_size) .neqv. .TRUE.) call abort
  30. end do
  31. end do
  32. end do
  33. call acc_shutdown (acc_device_nvidia)
  34. contains
  35. subroutine set3d (clear, a_i, a_c, a_r)
  36. logical clear
  37. integer, dimension (:,:,:), intent (inout) :: a_i
  38. complex, dimension (:,:,:), intent (inout) :: a_c
  39. real, dimension (:,:,:), intent (inout) :: a_r
  40. integer i, j, k
  41. integer lb1, ub1, lb2, ub2, lb3, ub3
  42. lb1 = lbound (a_i, 1)
  43. ub1 = ubound (a_i, 1)
  44. lb2 = lbound (a_i, 2)
  45. ub2 = ubound (a_i, 2)
  46. lb3 = lbound (a_i, 3)
  47. ub3 = ubound (a_i, 3)
  48. do i = lb1, ub1
  49. do j = lb2, ub2
  50. do k = lb3, ub3
  51. if (clear) then
  52. a_i(i, j, k) = 0
  53. a_c(i, j, k) = cmplx (0.0, 0.0)
  54. a_r(i, j, k) = 0.0
  55. else
  56. a_i(i, j, k) = i
  57. a_c(i, j, k) = cmplx (i, j)
  58. a_r(i, j, k) = i
  59. end if
  60. end do
  61. end do
  62. end do
  63. end subroutine
  64. end program