lib-10.f90 1.9 KB

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