Hello,
Possibly I miss some details with a new OpenMP-5.1 feature.
An OpenMP End Statement becomes optional if the opening statement
of an OpenMP construct is followed by a block-construct. An example
is given in the second program below which can be found at:
https://www.openmp.org/wp-content/uploads/openmp-examples-5-2.pdf
Does this new feature invalidate my code (the first program below),
or the block I wrote isn't strictly structured, or what I miss here?
Thanks in advance,
Ev. Drikos
----------------------------------------------------
$ cat my-code-4.5.f90 && gfc my-code-4.5.f90
program main
use omp_lib
implicit none
integer,parameter :: NT = 2, chunks=3
!$omp parallel num_threads(NT)
strictly_structured : block
print *, "chunks=", chunks
end block strictly_structured
print *, NT
!$omp end parallel
end
$
----------------------------------------------------
macbook:examples-5.1 suser$ cat directive_syntax_F_block.2.f90
program main
use omp_lib
implicit none
!$omp parallel num_threads(2)
if( omp_get_thread_num() == 0 ) &
print*, "Loosely structured block -- end required."
block ! BLOCK Fortran 2008
if( omp_get_thread_num() == 0 ) &
print*, " --"
end block
!$omp end parallel
!$omp parallel num_threads(2)
block
if( omp_get_thread_num() == 0 ) &
print*, "Strictly structured block -- end not required."
end block
!!$omp end parallel !is optional for strictly structured block
print*, "Sequential part"
!$omp parallel num_threads(2) !outer parallel
if( omp_get_thread_num() == 0 ) &
print*, "Outer, loosely structured block."
!$omp parallel num_threads(2) !inner parallel
block
if( omp_get_thread_num()==0)&
print*, "Inner, strictly structured block."
end block
!$omp end parallel
!$omp end parallel
! Two end directives are required here.
! A single "!$omp end parallel" terminator will fail.
! 1st end directive is assumed to be for inner parallel construct.
! 2nd end directive applies to outer parallel construct.
end program
macbook:examples-5.1 suser$