1! { dg-do run }
2! { dg-options "-fcheck=all" }
3! { dg-shouldfail "Invalid image number -1 in SYNC IMAGES" }
4!
5! As sync_1, but with bounds checking enabled.
6! PR fortran/52161
7!
8! Coarray support
9! PR fortran/18918
10
11implicit none
12integer :: n
13character(len=30) :: str
14critical
15end critical
16myCr: critical
17end critical myCr
18
19!
20! Test SYNC ALL
21!
22sync all
23sync all ( )
24sync all (errmsg=str)
25
26n = 5
27sync all (stat=n)
28if (n /= 0) STOP 1
29
30n = 5
31sync all (stat=n,errmsg=str)
32if (n /= 0) STOP 2
33
34
35!
36! Test SYNC MEMORY
37!
38sync memory
39sync memory ( )
40sync memory (errmsg=str)
41
42n = 5
43sync memory (stat=n)
44if (n /= 0) STOP 3
45
46n = 5
47sync memory (errmsg=str,stat=n)
48if (n /= 0) STOP 4
49
50
51!
52! Test SYNC IMAGES
53!
54sync images (*)
55if (this_image() == 1) then
56    sync images (1)
57    sync images (1, errmsg=str)
58    sync images ([1])
59end if
60
61n = 5
62sync images (*, stat=n)
63if (n /= 0) STOP 5
64
65n = 5
66sync images (*,errmsg=str,stat=n)
67if (n /= 0) STOP 6
68
69n = -1
70sync images ( num_images() )
71sync images (n) ! Invalid: "-1"
72
73end
74
75! { dg-output "Fortran runtime error: Invalid image number -1 in SYNC IMAGES" }
76