1! RUN: %f18 -fdebug-pre-fir-tree -fparse-only %s | FileCheck %s
2
3! Test Pre-FIR Tree captures all the coarray related statements
4
5! CHECK: Subroutine test_coarray
6Subroutine test_coarray
7  use iso_fortran_env, only: team_type, event_type, lock_type
8  type(team_type) :: t
9  type(event_type) :: done
10  type(lock_type) :: alock
11  real :: y[10,*]
12  integer :: counter[*]
13  logical :: is_master
14  ! CHECK: <<ChangeTeamConstruct>>
15  change team(t, x[5,*] => y)
16    ! CHECK: AssignmentStmt
17    x = x[4, 1]
18  end team
19  ! CHECK: <<End ChangeTeamConstruct>>
20  ! CHECK: FormTeamStmt
21  form team(1, t)
22
23  ! CHECK: <<IfConstruct>>
24  if (this_image() == 1) then
25    ! CHECK: EventPostStmt
26    event post (done)
27  else
28    ! CHECK: EventWaitStmt
29    event wait (done)
30  end if
31  ! CHECK: <<End IfConstruct>>
32
33  ! CHECK: <<CriticalConstruct>>
34  critical
35    ! CHECK: AssignmentStmt
36    counter[1] = counter[1] + 1
37  end critical
38  ! CHECK: <<End CriticalConstruct>>
39
40  ! CHECK: LockStmt
41  lock(alock)
42  ! CHECK: PrintStmt
43  print *, "I have the lock"
44  ! CHECK: UnlockStmt
45  unlock(alock)
46
47  ! CHECK: SyncAllStmt
48  sync all
49  ! CHECK: SyncMemoryStmt
50  sync memory
51  ! CHECK: SyncTeamStmt
52  sync team(t)
53
54  ! CHECK: <<IfConstruct>>
55  if (this_image() == 1) then
56    ! CHECK: SyncImagesStmt
57    sync images(*)
58  else
59    ! CHECK: SyncImagesStmt
60    sync images(1)
61  end if
62  ! CHECK: <<End IfConstruct>>
63
64  ! CHECK: <<IfConstruct>>
65  if (y<0.) then
66    ! CHECK: FailImageStmt
67   fail image
68  end if
69  ! CHECK: <<End IfConstruct>>
70end
71