1! { dg-do run } 2! 3! CO_BROADCAST 4! 5program test 6 implicit none 7 intrinsic co_broadcast 8 9 type t 10 integer :: i 11 character(len=1) :: c 12 real(8) :: x(3), y(3) 13 end type t 14 15 integer :: i, j(10), stat 16 complex :: a(5,5) 17 character(kind=1, len=5) :: str1, errstr 18 character(kind=4, len=8) :: str2(2) 19 type(t) :: dt(4) 20 21 i = 1 22 j = 55 23 a = 99.0 24 str1 = 1_"XXXXX" 25 str2 = 4_"YYYYYYYY" 26 dt = t(1, 'C', [1.,2.,3.], [3,3,3]) 27 errstr = "ZZZZZ" 28 29 if (this_image() == num_images()) then 30 i = 2 31 j = 66 32 a = -99.0 33 str1 = 1_"abcd" 34 str2 = 4_"12 3 4 5" 35 dt = t(-1, 'a', [3.,1.,8.], [99,24,5]) 36 end if 37 sync all 38 39 call co_broadcast(i, source_image=num_images(), stat=stat, errmsg=errstr) 40 if (stat /= 0) STOP 1 41 if (errstr /= "ZZZZZ") STOP 2 42 if (i /= 2) STOP 3 43 44 call co_broadcast(j, source_image=num_images(), stat=stat, errmsg=errstr) 45 if (stat /= 0) STOP 4 46 if (errstr /= "ZZZZZ") STOP 5 47 if (any (j /= 66)) STOP 1 48 49 call co_broadcast(a, source_image=num_images(), stat=stat, errmsg=errstr) 50 if (stat /= 0) STOP 6 51 if (errstr /= "ZZZZZ") STOP 7 52 if (any (a /= -99.0)) STOP 2 53 54 call co_broadcast(str1, source_image=num_images(), stat=stat, errmsg=errstr) 55 if (stat /= 0) STOP 8 56 if (errstr /= "ZZZZZ") STOP 9 57 if (str1 /= "abcd") STOP 10 58 59 call co_broadcast(str2, source_image=num_images(), stat=stat, errmsg=errstr) 60 if (stat /= 0) STOP 11 61 if (errstr /= "ZZZZZ") STOP 12 62 if (any (str2 /= 4_"12 3 4 5")) STOP 3 63 64 call co_broadcast(dt, source_image=num_images(), stat=stat, errmsg=errstr) 65 if (stat /= 0) STOP 13 66 if (errstr /= "ZZZZZ") STOP 14 67 if (any (dt(:)%i /= -1)) STOP 15 68 if (any (dt(:)%c /= 'a')) STOP 16 69 if (any (dt(:)%x(1) /= 3.)) STOP 17 70 if (any (dt(:)%x(2) /= 1.)) STOP 18 71 if (any (dt(:)%x(3) /= 8.)) STOP 19 72 if (any (dt(:)%y(1) /= 99.)) STOP 20 73 if (any (dt(:)%y(2) /= 24.)) STOP 21 74 if (any (dt(:)%y(3) /= 5.)) STOP 22 75 76 sync all 77 dt = t(1, 'C', [1.,2.,3.], [3,3,3]) 78 sync all 79 if (this_image() == num_images()) then 80 str2 = 4_"001122" 81 dt(2:4) = t(-2, 'i', [9.,2.,3.], [4,44,321]) 82 end if 83 84 call co_broadcast(str2(::2), source_image=num_images(), stat=stat, & 85 errmsg=errstr) 86 if (stat /= 0) STOP 23 87 if (errstr /= "ZZZZZ") STOP 24 88 if (str2(1) /= 4_"001122") STOP 25 89 if (this_image() == num_images()) then 90 if (str2(1) /= 4_"001122") STOP 26 91 else 92 if (str2(2) /= 4_"12 3 4 5") STOP 27 93 end if 94 95 call co_broadcast(dt(2::2), source_image=num_images(), stat=stat, & 96 errmsg=errstr) 97 if (stat /= 0) STOP 28 98 if (errstr /= "ZZZZZ") STOP 29 99 if (this_image() == num_images()) then 100 if (any (dt(1:1)%i /= 1)) STOP 30 101 if (any (dt(1:1)%c /= 'C')) STOP 31 102 if (any (dt(1:1)%x(1) /= 1.)) STOP 32 103 if (any (dt(1:1)%x(2) /= 2.)) STOP 33 104 if (any (dt(1:1)%x(3) /= 3.)) STOP 34 105 if (any (dt(1:1)%y(1) /= 3.)) STOP 35 106 if (any (dt(1:1)%y(2) /= 3.)) STOP 36 107 if (any (dt(1:1)%y(3) /= 3.)) STOP 37 108 109 if (any (dt(2:)%i /= -2)) STOP 38 110 if (any (dt(2:)%c /= 'i')) STOP 39 111 if (any (dt(2:)%x(1) /= 9.)) STOP 40 112 if (any (dt(2:)%x(2) /= 2.)) STOP 41 113 if (any (dt(2:)%x(3) /= 3.)) STOP 42 114 if (any (dt(2:)%y(1) /= 4.)) STOP 43 115 if (any (dt(2:)%y(2) /= 44.)) STOP 44 116 if (any (dt(2:)%y(3) /= 321.)) STOP 45 117 else 118 if (any (dt(1::2)%i /= 1)) STOP 46 119 if (any (dt(1::2)%c /= 'C')) STOP 47 120 if (any (dt(1::2)%x(1) /= 1.)) STOP 48 121 if (any (dt(1::2)%x(2) /= 2.)) STOP 49 122 if (any (dt(1::2)%x(3) /= 3.)) STOP 50 123 if (any (dt(1::2)%y(1) /= 3.)) STOP 51 124 if (any (dt(1::2)%y(2) /= 3.)) STOP 52 125 if (any (dt(1::2)%y(3) /= 3.)) STOP 53 126 127 if (any (dt(2::2)%i /= -2)) STOP 54 128 if (any (dt(2::2)%c /= 'i')) STOP 55 129 if (any (dt(2::2)%x(1) /= 9.)) STOP 56 130 if (any (dt(2::2)%x(2) /= 2.)) STOP 57 131 if (any (dt(2::2)%x(3) /= 3.)) STOP 58 132 if (any (dt(2::2)%y(1) /= 4.)) STOP 59 133 if (any (dt(2::2)%y(2) /= 44.)) STOP 60 134 if (any (dt(2::2)%y(3) /= 321.)) STOP 61 135 endif 136end program test 137