Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

Compiler bug for named CRITICAL sections?

John_D_12
Beginner
478 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
Honored Contributor II
478 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.)

0 Kudos
jimdempseyatthecove
Honored Contributor III
478 Views

My preference is to append "_critical"

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

Jim Dempsey

0 Kudos
Reply