Debian Codegraph @

gcc/testsuite/gfortran.dg/coarray_collectives_17.f90

raw
1 ! { dg-do run }
2 ! { dg-options "-fcoarray=single" }
3 !
4 ! PR 100337
5 ! Test case inspired by code submitted by Brad Richardson
6
7 program main
8 implicit none
9
10 integer, parameter :: MESSAGE = 42
11 integer :: result
12
13 call myco_broadcast(MESSAGE, result, 1)
14
15 if (result /= MESSAGE) error stop 1
16 contains
17 subroutine myco_broadcast(m, r, source_image, stat, errmsg)
18 integer, intent(in) :: m
19 integer, intent(out) :: r
20 integer, intent(in) :: source_image
21 integer, intent(out), optional :: stat
22 character(len=*), intent(inout), optional :: errmsg
23
24 integer :: data_length
25
26 data_length = 1
27
28 call co_broadcast(data_length, source_image, stat, errmsg)
29
30 if (present(stat)) then
31 if (stat /= 0) return
32 end if
33
34 if (this_image() == source_image) then
35 r = m
36 end if
37
38 call co_broadcast(r, source_image, stat, errmsg)
39 end subroutine
40
41 end program
42