158 lines · plain
1! REQUIRES: openmp_runtime2 3! RUN: %python %S/../test_errors.py %s %flang %openmp_flags4! OpenMP version 5.0.05! 2.13.3 parallel sections Construct6! The restrictions for the parallel construct and the sections construct apply7program OmpConstructSections018 use omp_lib9 integer :: section_count = 010 integer, parameter :: NT = 411 integer :: i, array(10)12 type my_type13 integer :: array(10)14 end type my_type15 type(my_type) :: my_var16 print *, 'section_count', section_count17 do i = 1, 1018 array(i) = i19 end do20!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause21!$omp parallel sections shared(array(i))22!$omp end parallel sections23!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause24!$omp parallel sections shared(my_var%array)25!$omp end parallel sections26 27!ERROR: invalid branch into an OpenMP structured block28!ERROR: invalid branch into an OpenMP structured block29!ERROR: invalid branch into an OpenMP structured block30 if (NT) 20, 30, 4031!ERROR: invalid branch into an OpenMP structured block32 goto 2033!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause34!$omp parallel sections private(my_var%array)35 !$omp section36 print *, "This is a single statement structured block"37 !$omp section38 !ERROR: invalid branch into an OpenMP structured block39 !ERROR: invalid branch leaving an OpenMP structured block40 open (10, file="random-file-name.txt", err=30)41 !ERROR: invalid branch into an OpenMP structured block42 !ERROR: invalid branch leaving an OpenMP structured block43 open (10, file="random-file-name.txt", err=40)44 !$omp section45 section_count = section_count + 14620 print *, 'Entering into section'47 call calledFromWithinSection()48 print *, 'section_count', section_count49 !$omp section50 section_count = section_count + 151 print *, 'section_count', section_count52 !ERROR: invalid branch leaving an OpenMP structured block53 goto 1054 !$omp section5530 print *, "Error in opening file"56!$omp end parallel sections5710 print *, 'Jump from section'58!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause59!$omp parallel sections private(array(i))60 !$omp section6140 print *, 'Error in opening file'62!$omp end parallel sections63end program OmpConstructSections0164 65function returnFromSections()66 !$omp parallel sections67 !$omp section68 !ERROR: RETURN statement is not allowed in a PARALLEL SECTIONS construct69 RETURN70 !$omp end parallel sections71end function72 73subroutine calledFromWithinSection()74 print *, "I am called from within a 'section' structured block"75 return76end subroutine calledFromWithinSection77 78subroutine continueWithinSections()79 integer i80 do i = 1, 1081 print *, "Statement within loop but outside section construct"82 !$omp parallel sections83 !$omp section84 IF (i .EQ. 5) THEN85 !ERROR: CYCLE to construct outside of PARALLEL SECTIONS construct is not allowed86 CYCLE87 END IF88 !$omp end parallel sections89 print *, "Statement within loop but outside section contruct"90 end do91 92 !$omp parallel sections93 !$omp section94 do i = 1, 1095 CYCLE96 end do97 !$omp end parallel sections98 99 !$omp parallel sections100 !$omp section101 loop_1: do i = 1, 10102 IF (i .EQ. 5) THEN103 CYCLE loop_1104 END IF105 end do loop_1106 !$omp end parallel sections107 108 loop_2: do i = 1, 10109 !$omp parallel sections110 !$omp section111 IF (i .EQ. 5) THEN112 !ERROR: CYCLE to construct 'loop_2' outside of PARALLEL SECTIONS construct is not allowed113 CYCLE loop_2114 END IF115 !$omp end parallel sections116 end do loop_2117end subroutine continueWithinSections118 119subroutine breakWithinSections()120 loop_3: do i = 1, 10121 !$omp parallel sections122 !$omp section123 IF (i .EQ. 5) THEN124 !ERROR: EXIT to construct 'loop_3' outside of PARALLEL SECTIONS construct is not allowed125 EXIT loop_3126 END IF127 !$omp end parallel sections128 end do loop_3129 130 loop_4: do i = 1, 10131 !$omp parallel sections132 !$omp section133 IF (i .EQ. 5) THEN134 !ERROR: EXIT to construct outside of PARALLEL SECTIONS construct is not allowed135 EXIT136 END IF137 !$omp end parallel sections138 end do loop_4139 140 !$omp parallel sections141 !$omp section142 do i = 1, 10143 IF (i .EQ. 5) THEN144 EXIT145 END IF146 end do147 !$omp end parallel sections148 149 !$omp parallel sections150 !$omp section151 loop_5: do i = 1, 10152 IF (i .EQ. 5) THEN153 EXIT loop_5154 END IF155 end do loop_5156 !$omp end parallel sections157end subroutine breakWithinSections158