Compiling with OpenMP, Directive Format, and Diagnostics

To run the Intel® Fortran Compiler in OpenMP* mode, you need to invoke the Intel compiler with the

ifort -openmp input_file(s)

Before you run the multithreaded code, you can set the number of desired threads to the OpenMP environment variable, OMP_NUM_THREADS. See the OpenMP Environment Variables section for further information. The Intel Extensjon Routines topic describes the OpenMP extensions to the specification that have been added by Intel in the Intel® Fortran Compiler.

-openmp Option

The -openmp option enables the parallelizer to generate multithreaded code based on the OpenMP directives. The code can be executed in parallel on both uniprocessor and multiprocessor systems.

The -openmp option works with both -O0 (no optimization) and any optimization level of -O1,
(default) and -O3. Specifying -O0 with -openmp helps to debug OpenMP applications.

When you use the -openmp option, the compiler sets the -auto option (causes all variables to be allocated on the stack, rather than in local static storage.) for the compiler unless you specified it on the command line.

OpenMP Directive Format and Syntax

The OpenMP directives use the following format:

<prefix> <directive> [<clause> [[,] <clause> . . .]]

where the brackets above mean:

For fixed form source input, the prefix is !$omp or c$omp

For free form source input, the prefix is !$omp only.

The prefix is followed by the directive name; for example:

!$omp parallel

Since OpenMP directives begin with an exclamation point, the directives take the form of comments if you omit the -openmp option.

Syntax for Parallel Regions in the Source Code

The OpenMP constructs defining a parallel region have one of the following syntax forms:

!$omp <directive>
<structured block of code>
!$omp end <directive>

!$omp <directive>
<structured block of code>

!$omp <directive>

where <directive> is the name of a particular OpenMP directive.

OpenMP Diagnostic Reports

The -openmp_report{0|1|2} option controls the OpenMP parallelizer's diagnostic levels 0, 1, or 2 as follows:

-openmp_report0 = no diagnostic information is displayed.

-openmp_report1 = display diagnostics indicating loops, regions, and sections successfully parallelized.

-openmp_report2 = same as -openmp_report1 plus diagnostics indicating MASTER constructs, SINGLE constructs, CRITICAL constructs, ORDERED constructs, ATOMIC directives, etc. successfully handled.

The default is -openmp_report1.