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

OpenMP compiler Directives

maria
Beginner
435 Views

I have an OpenMP compiler directives question.

The book I have states that a line begins with one of the following prefix keywords:
!$OMP ...
c$OMP...
*$OMP...
These will be treated as an openMP directive by openMP compiler and treated as a comment by a non-openmp compiler.

In my code, I have
'!$OMP parallel do 'which works fine. In addition, inside the parallel do region, I also have

'!$ I = OMP_GET_THREAD_NUM()'

which works fine for an openMP compiler and treated as a comment by a non-openmp compiler.

However, if I have
'!$OMP I = OMP_GET_THREAD_NUM()'

I will have invalid directive error when I compile it.

My question is why '!$ ' instead of '!$OMP ' works for this case? I thought that '!$OMP ' is standard prefix form for OpenMP. Is prefix different for openMP directive and library?






0 Kudos
1 Reply
TimP
Honored Contributor III
435 Views
!$ is a form of Fortran conditional compilation required by OpenMP standard. It works regardless of whether the line contains an OpenMP library call or some other code, although the most common usage may be to make OpenMP library function calls disappear when OpenMP compilation is turned off.
0 Kudos
Reply