1! RUN: %python %S/../test_errors.py %s %flang -fopenmp 2! OpenMP Version 4.5 3! Various checks with the ordered construct 4 5SUBROUTINE WORK(I) 6 INTEGER I 7END SUBROUTINE WORK 8 9SUBROUTINE ORDERED_GOOD(N) 10 INTEGER N, I, A(10), B(10), C(10) 11 !$OMP SIMD 12 DO I = 1,N 13 IF (I <= 10) THEN 14 !$OMP ORDERED SIMD 15 CALL WORK(I) 16 !$OMP END ORDERED 17 ENDIF 18 END DO 19 !$OMP END SIMD 20END SUBROUTINE ORDERED_GOOD 21 22SUBROUTINE ORDERED_BAD(N) 23 INTEGER N, I, A(10), B(10), C(10) 24 25 !$OMP DO SIMD 26 DO I = 1,N 27 IF (I <= 10) THEN 28 !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause. 29 !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter 30 !$OMP ORDERED 31 CALL WORK(I) 32 !$OMP END ORDERED 33 ENDIF 34 END DO 35 !$OMP END DO SIMD 36 37 !$OMP PARALLEL DO 38 DO I = 1,N 39 IF (I <= 10) THEN 40 !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter 41 !$OMP ORDERED 42 CALL WORK(I) 43 !$OMP END ORDERED 44 ENDIF 45 END DO 46 !$OMP END PARALLEL DO 47 48 !$OMP CRITICAL 49 DO I = 1,N 50 IF (I <= 10) THEN 51 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 52 !$OMP ORDERED 53 CALL WORK(I) 54 !$OMP END ORDERED 55 ENDIF 56 END DO 57 !$OMP END CRITICAL 58 59 !$OMP CRITICAL 60 WRITE(*,*) I 61 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 62 !$OMP ORDERED 63 CALL WORK(I) 64 !$OMP END ORDERED 65 !$OMP END CRITICAL 66 67 !$OMP ORDERED 68 WRITE(*,*) I 69 IF (I <= 10) THEN 70 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 71 !$OMP ORDERED 72 CALL WORK(I) 73 !$OMP END ORDERED 74 ENDIF 75 !$OMP END ORDERED 76 77 !$OMP TASK 78 C = C - A * B 79 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 80 !$OMP ORDERED 81 CALL WORK(I) 82 !$OMP END ORDERED 83 !$OMP END TASK 84 85 !$OMP TASKLOOP 86 DO I = 1,N 87 IF (I <= 10) THEN 88 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 89 !$OMP ORDERED 90 CALL WORK(I) 91 !$OMP END ORDERED 92 ENDIF 93 END DO 94 !$OMP END TASKLOOP 95 96 !$OMP CRITICAL 97 C = C - A * B 98 !$OMP MASTER 99 DO I = 1,N 100 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 101 !$OMP ORDERED 102 CALL WORK(I) 103 !$OMP END ORDERED 104 END DO 105 !$OMP END MASTER 106 !$OMP END CRITICAL 107 108 !$OMP ORDERED 109 C = C - A * B 110 !$OMP MASTER 111 DO I = 1,N 112 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 113 !$OMP ORDERED 114 CALL WORK(I) 115 !$OMP END ORDERED 116 END DO 117 !$OMP END MASTER 118 !$OMP END ORDERED 119 120 !$OMP TASK 121 C = C - A * B 122 !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region. 123 !$OMP MASTER 124 DO I = 1,N 125 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 126 !$OMP ORDERED 127 CALL WORK(I) 128 !$OMP END ORDERED 129 END DO 130 !$OMP END MASTER 131 !$OMP END TASK 132 133 !$OMP TASKLOOP 134 DO J= 1,N 135 C = C - A * B 136 !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region. 137 !$OMP MASTER 138 DO I = 1,N 139 !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region. 140 !$OMP ORDERED 141 CALL WORK(I) 142 !$OMP END ORDERED 143 END DO 144 !$OMP END MASTER 145 END DO 146 !$OMP END TASKLOOP 147 148END SUBROUTINE ORDERED_BAD 149