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.
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.)