Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26758 Discussions

Compiler bug for named CRITICAL sections?

John_D_12
Beginner
128 Views

The following code:

program test
implicit none
call foo
end program

subroutine foo
implicit none
!$OMP CRITICAL(foo)
print *,'foo'
!$OMP END CRITICAL(foo)
return
end subroutine

... produces the compile-time error:

test.f90(11): error #6468: Invalid OpenMP* CRITICAL directive section name.   [FOO]
!$OMP CRITICAL(foo)
---------------^
test.f90(13): error #6413: This global name is invalid in this context.   [FOO]
!$OMP END CRITICAL(foo)
-------------------^
compilation aborted for test.f90 (code 1)

 

 

It appears that you cannot name OpenMP CRITICAL sections with the same name as the subroutine in (at least) Intel Fortran 16, 17 or 18.

Both GFortran and the PGI Fortran compile this code without errors.

I can't find anything about subroutine names being invalid CRITICAL section names in the OpenMP standard.

John.

 

0 Kudos
2 Replies
IanH
Black Belt
128 Views

The name of an openmp critical construct is a global entity (openmp 4.5 p150 line 14) - if it conflicts with other global entities then behaviour is unspecified.  External procedures are global entites too (F2008 16.2).

(Technically I think the openmp standard should be talking about conflicting global identifiers.)

jimdempseyatthecove
Black Belt
128 Views

My preference is to append "_critical"

#pragma omp critical(foo_critical)
...
#pragma omp end critical(foo_critical)

Jim Dempsey

Reply