# Two block constructs in a PARALLEL region

**URL:** <https://fortran-lang.discourse.group/t/two-block-constructs-in-a-parallel-region/10687>\
**Category:** Uncategorized\
**Created:** [February 2, 2026, 3:31pm UTC](https://fortran-lang.discourse.group/t/two-block-constructs-in-a-parallel-region/10687 "2026-02-02T15:31:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkd2022](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jkd2022/32/1949_2.png) [@jkd2022](https://fortran-lang.discourse.group/u/jkd2022)\
**Post date:** [February 2, 2026, 3:31pm UTC](https://fortran-lang.discourse.group/t/two-block-constructs-in-a-parallel-region/10687/1 "2026-02-02T15:31:29Z")

</div>

I’d be grateful for some advice. Consider the following code:

```auto
program test
implicit none

!$OMP PARALLEL
block

end block
block

end block
!$OMP END PARALLEL

end program

```

Intel fortran (ifort and ifx) and GFortran versions 8 - 11 compile the code fine.

However, GFortran versions 14 and 15 yield:

```auto
> gfortran -fopenmp test.f90

test.f90:12:18:

12 | !$OMP END PARALLEL
   | 1
Error: Unexpected !$OMP END PARALLEL statement at (1)

```

This only happens when there are two blocks in the same PARALLEL region.

Is this somehow non-complaint OpenMP or a compiler bug?

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [February 2, 2026, 3:57pm UTC](https://fortran-lang.discourse.group/t/two-block-constructs-in-a-parallel-region/10687/2 "2026-02-02T15:57:19Z")

</div>

> [@jkd2022](#):
>
> ```auto
> !$OMP PARALLEL
> block
> 
> end block
> 
> ```

OpenMP 6.0 adds blocks as parallel scopes (screenshot taken from [this presentation](https://www.pop-coe.eu/sites/default/files/pop_files/pop-webinar-openmp6-part1.pdf))

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/1/1bae7e79ecf98e1c2738029d88c1b97d8b3ecf8a.png)

But I’m not sure if this is the issue here.

[GCC 12](https://gcc.gnu.org/projects/gomp/#omp6.0) added support for OpenMP _strictly structured blocks_, from OpenMP 5.2 spec, page 3:

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/0/0577dcb60c8bb3572b33c48873f752351990778c.png)

and page 52:

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/b/b6271ede206e6ea1590c367f7a7e79659bcabd76.png)

Perhaps this can be used as a workaround?

```auto
!$OMP PARALLEL
block
  block

  end block 
  block

  end block
end block

```

Edit: link to compiler explorer: [Compiler Explorer](https://godbolt.org/z/xsYro9KE9)

---

<div class="post-metadata">

**Author:** ![jkd2022](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jkd2022/32/1949_2.png) [@jkd2022](https://fortran-lang.discourse.group/u/jkd2022)\
**Post date:** [February 2, 2026, 4:26pm UTC](https://fortran-lang.discourse.group/t/two-block-constructs-in-a-parallel-region/10687/3 "2026-02-02T16:26:27Z")

</div>

Thanks @ivanpribec your workaround works.

However, I’ve since found that inserting a line of anything before the first block also fixes the problem:

```auto
program test
implicit none
integer i

!$OMP PARALLEL
i=1
block

end block
block

end block
!$OMP END PARALLEL

```

end program

I think this may be a compiler bug.

---

<div class="post-metadata">

**Author:** ![jkd2022](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jkd2022/32/1949_2.png) [@jkd2022](https://fortran-lang.discourse.group/u/jkd2022)\
**Post date:** [February 2, 2026, 8:21pm UTC](https://fortran-lang.discourse.group/t/two-block-constructs-in-a-parallel-region/10687/4 "2026-02-02T20:21:54Z")

</div>

> @ivanpribec  
> [GCC 12](https://gcc.gnu.org/projects/gomp/#omp6.0) added support for OpenMP _strictly structured blocks_, from OpenMP 5.2 spec, page 3:

I think you’re correct. I submitted a bug report [here](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123930) and the first comment indicated that the two block code is valid in OpenMP 5.0 but not in 5.1. Your workaround was also suggested.

A somewhat confusing change.

Anyway, thanks again.
