Intel® Fortran Compiler 17.0 Developer Guide and Reference

Nesting and Binding Rules

This section describes the dynamic nesting and binding rules for OpenMP* Fortran API directives.

Binding Rules

The following rules apply to dynamic binding:

Nesting Rules

The following rules apply to dynamic nesting:

Examples

The following example shows nested PARALLEL regions:

  !$OMP PARALLEL DEFAULT(SHARED)
  !$OMP DO
          DO I =1, N
  !$OMP PARALLEL SHARED(I,N)
  !$OMP DO
          DO J =1, N
            CALL WORK(I,J)
          END DO
  !$OMP END PARALLEL
        END DO
  !$OMP END PARALLEL

Note that the inner and outer DO directives bind to different PARALLEL regions.

The following shows a variation of the preceding example:

  !$OMP PARALLEL DEFAULT(SHARED)
  !$OMP DO
          DO I =1, N
             CALL SOME_WORK(I,N)
          END DO
  !$OMP END PARALLEL
        ...
        SUBROUTINE SOME_WORK(I,N)
  !$OMP PARALLEL DEFAULT(SHARED)
  !$OMP DO
          DO J =1, N
             CALL WORK(I,J)
          END DO
  !$OMP END PARALLEL
          RETURN
          END