pset-1.f90 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. ! { dg-do run }
  2. program test
  3. implicit none
  4. integer, allocatable :: a1(:)
  5. integer, allocatable :: b1(:)
  6. integer, allocatable :: c1(:)
  7. integer, allocatable :: b2(:,:)
  8. integer, allocatable :: c3(:,:,:)
  9. allocate (a1(5))
  10. if (.not.allocated (a1)) call abort()
  11. a1 = 10
  12. !$acc parallel copy(a1(1:5))
  13. a1(1) = 1
  14. a1(2) = 2
  15. a1(3) = 3
  16. a1(4) = 4
  17. a1(5) = 5
  18. !$acc end parallel
  19. if (a1(1) .ne. 1) call abort
  20. if (a1(2) .ne. 2) call abort
  21. if (a1(3) .ne. 3) call abort
  22. if (a1(4) .ne. 4) call abort
  23. if (a1(5) .ne. 5) call abort
  24. deallocate(a1)
  25. allocate (a1(0:4))
  26. if (.not.allocated (a1)) call abort()
  27. a1 = 10
  28. !$acc parallel copy(a1(0:4))
  29. a1(0) = 1
  30. a1(1) = 2
  31. a1(2) = 3
  32. a1(3) = 4
  33. a1(4) = 5
  34. !$acc end parallel
  35. if (a1(0) .ne. 1) call abort
  36. if (a1(1) .ne. 2) call abort
  37. if (a1(2) .ne. 3) call abort
  38. if (a1(3) .ne. 4) call abort
  39. if (a1(4) .ne. 5) call abort
  40. deallocate(a1)
  41. allocate (b2(5,5))
  42. if (.not.allocated (b2)) call abort()
  43. b2 = 11
  44. !$acc parallel copy(b2(1:5,1:5))
  45. b2(1,1) = 1
  46. b2(2,2) = 2
  47. b2(3,3) = 3
  48. b2(4,4) = 4
  49. b2(5,5) = 5
  50. !$acc end parallel
  51. if (b2(1,1) .ne. 1) call abort
  52. if (b2(2,2) .ne. 2) call abort
  53. if (b2(3,3) .ne. 3) call abort
  54. if (b2(4,4) .ne. 4) call abort
  55. if (b2(5,5) .ne. 5) call abort
  56. deallocate(b2)
  57. allocate (b2(0:4,0:4))
  58. if (.not.allocated (b2)) call abort()
  59. b2 = 11
  60. !$acc parallel copy(b2(0:4,0:4))
  61. b2(0,0) = 1
  62. b2(1,1) = 2
  63. b2(2,2) = 3
  64. b2(3,3) = 4
  65. b2(4,4) = 5
  66. !$acc end parallel
  67. if (b2(0,0) .ne. 1) call abort
  68. if (b2(1,1) .ne. 2) call abort
  69. if (b2(2,2) .ne. 3) call abort
  70. if (b2(3,3) .ne. 4) call abort
  71. if (b2(4,4) .ne. 5) call abort
  72. deallocate(b2)
  73. allocate (c3(5,5,5))
  74. if (.not.allocated (c3)) call abort()
  75. c3 = 12
  76. !$acc parallel copy(c3(1:5,1:5,1:5))
  77. c3(1,1,1) = 1
  78. c3(2,2,2) = 2
  79. c3(3,3,3) = 3
  80. c3(4,4,4) = 4
  81. c3(5,5,5) = 5
  82. !$acc end parallel
  83. if (c3(1,1,1) .ne. 1) call abort
  84. if (c3(2,2,2) .ne. 2) call abort
  85. if (c3(3,3,3) .ne. 3) call abort
  86. if (c3(4,4,4) .ne. 4) call abort
  87. if (c3(5,5,5) .ne. 5) call abort
  88. deallocate(c3)
  89. allocate (c3(0:4,0:4,0:4))
  90. if (.not.allocated (c3)) call abort()
  91. c3 = 12
  92. !$acc parallel copy(c3(0:4,0:4,0:4))
  93. c3(0,0,0) = 1
  94. c3(1,1,1) = 2
  95. c3(2,2,2) = 3
  96. c3(3,3,3) = 4
  97. c3(4,4,4) = 5
  98. !$acc end parallel
  99. if (c3(0,0,0) .ne. 1) call abort
  100. if (c3(1,1,1) .ne. 2) call abort
  101. if (c3(2,2,2) .ne. 3) call abort
  102. if (c3(3,3,3) .ne. 4) call abort
  103. if (c3(4,4,4) .ne. 5) call abort
  104. deallocate(c3)
  105. allocate (a1(5))
  106. if (.not.allocated (a1)) call abort()
  107. allocate (b1(5))
  108. if (.not.allocated (b1)) call abort()
  109. allocate (c1(5))
  110. if (.not.allocated (c1)) call abort()
  111. a1 = 10
  112. b1 = 3
  113. c1 = 7
  114. !$acc parallel copyin(a1(1:5)) create(c1(1:5)) copyout(b1(1:5))
  115. c1(1) = a1(1)
  116. c1(2) = a1(2)
  117. c1(3) = a1(3)
  118. c1(4) = a1(4)
  119. c1(5) = a1(5)
  120. b1(1) = c1(1)
  121. b1(2) = c1(2)
  122. b1(3) = c1(3)
  123. b1(4) = c1(4)
  124. b1(5) = c1(5)
  125. !$acc end parallel
  126. if (b1(1) .ne. 10) call abort
  127. if (b1(2) .ne. 10) call abort
  128. if (b1(3) .ne. 10) call abort
  129. if (b1(4) .ne. 10) call abort
  130. if (b1(5) .ne. 10) call abort
  131. deallocate(a1)
  132. deallocate(b1)
  133. deallocate(c1)
  134. allocate (a1(0:4))
  135. if (.not.allocated (a1)) call abort()
  136. allocate (b1(0:4))
  137. if (.not.allocated (b1)) call abort()
  138. allocate (c1(0:4))
  139. if (.not.allocated (c1)) call abort()
  140. a1 = 10
  141. b1 = 3
  142. c1 = 7
  143. !$acc parallel copyin(a1(0:4)) create(c1(0:4)) copyout(b1(0:4))
  144. c1(0) = a1(0)
  145. c1(1) = a1(1)
  146. c1(2) = a1(2)
  147. c1(3) = a1(3)
  148. c1(4) = a1(4)
  149. b1(0) = c1(0)
  150. b1(1) = c1(1)
  151. b1(2) = c1(2)
  152. b1(3) = c1(3)
  153. b1(4) = c1(4)
  154. !$acc end parallel
  155. if (b1(0) .ne. 10) call abort
  156. if (b1(1) .ne. 10) call abort
  157. if (b1(2) .ne. 10) call abort
  158. if (b1(3) .ne. 10) call abort
  159. if (b1(4) .ne. 10) call abort
  160. deallocate(a1)
  161. deallocate(b1)
  162. deallocate(c1)
  163. allocate (a1(5))
  164. if (.not.allocated (a1)) call abort()
  165. a1 = 10
  166. !$acc parallel copy(a1(2:3))
  167. a1(2) = 2
  168. a1(3) = 3
  169. !$acc end parallel
  170. if (a1(1) .ne. 10) call abort
  171. if (a1(2) .ne. 2) call abort
  172. if (a1(3) .ne. 3) call abort
  173. if (a1(4) .ne. 10) call abort
  174. if (a1(5) .ne. 10) call abort
  175. deallocate(a1)
  176. end program test