2 ! { dg-options "-fcoarray=lib -lcaf_single" }
3 ! { dg-additional-options "-latomic" { target libatomic_available } }
5 ! Contributed by Damian Rouson
6 ! Check the new _caf_send_by_ref()-routine.
7 ! Same as coarray_alloc_comp_2 but for pointers.
15 integer, pointer :: indices(:)
16 real, dimension(2,5,3) :: volume
17 integer, pointer :: scalar
19 integer, pointer :: matrix(:,:)
20 real, pointer :: dynvol(:,:,:)
24 type(mytype), pointer :: vec(:)
25 type(mytype), pointer :: mat(:,:)
28 type(mytype), save :: object[*]
29 type(arrtype), save :: bar[*]
30 integer :: i,j,me,neighbor
32 real, allocatable :: volume(:,:,:), vol2(:,:,:)
33 real :: vol_static(2,5,3)
38 neighbor = merge(1,me+1,me==num_images())
39 allocate(object%indices(5), object%scalar, object%matrix(10,7), object%dynvol(2,5,3))
40 object[neighbor]%indices=[(i,i=1,5)]
41 object[neighbor]%i = 37
42 object[neighbor]%scalar = 42
43 vol_static = reshape([(i, i=1, 2*5*3)], [2, 5, 3])
44 object[neighbor]%volume = vol_static
45 object[neighbor]%matrix = reshape([(i, i=1, 70)], [10, 7])
46 object[neighbor]%dynvol = vol_static
48 if (object%scalar /= 42) STOP 1
49 if (any( object%indices /= [1,2,3,4,5] )) STOP 2
50 if (any( object%matrix /= reshape([(i, i=1, 70)], [10, 7]))) STOP 3
51 if (any( object%volume /= vol_static)) STOP 4
52 if (any( object%dynvol /= vol_static)) STOP 5
56 object[neighbor]%volume(:, ::2, :) = 42
57 object[neighbor]%dynvol(:, ::2, :) = 42
58 if (any( object%volume /= vol2)) STOP 6
59 if (any( object%dynvol /= vol2)) STOP 7
61 allocate(bar%vec(-2:2))
63 bar[neighbor]%vec(1)%volume = vol_static
64 if (any(bar%vec(1)%volume /= vol_static)) STOP 8
66 allocate(bar%vec(1)%scalar, bar%vec(0)%scalar, bar%vec(1)%indices(3))
68 bar[neighbor]%vec(1)%scalar = i
69 if (.not. associated(bar%vec(1)%scalar)) STOP 9
70 if (bar%vec(1)%scalar /= 15) STOP 10
72 bar[neighbor]%vec(0)%scalar = 27
73 if (.not. associated(bar%vec(0)%scalar)) STOP 11
74 if (bar%vec(0)%scalar /= 27) STOP 12
76 bar[neighbor]%vec(1)%indices = [ 3, 4, 15 ]
77 allocate(bar%vec(2)%indices(5))
78 bar[neighbor]%vec(2)%indices = 89
80 if (.not. associated(bar%vec(1)%indices)) STOP 13
81 if (associated(bar%vec(-2)%indices)) STOP 14
82 if (associated(bar%vec(-1)%indices)) STOP 15
83 if (associated(bar%vec( 0)%indices)) STOP 16
84 if (.not. associated(bar%vec( 2)%indices)) STOP 17
85 if (any(bar%vec(2)%indices /= 89)) STOP 18
87 if (any (bar%vec(1)%indices /= [ 3,4,15])) STOP 19