OpenMP* usage requires variable to be shared

OpenMP* requires variables used in certain contexts to be shared variables.

Various OpenMP* constructs are used to control shared variables. These constructs don't make sense when they are applied to non-shared or "thread private" variables. Specifically ,PRIVATE variables may not appear in the variable list for a FIRSTPRIVATE or LASTPRIVATE directive. Similarly, a variable in a REDUCTION clause of a worksharing construct must be shared in the outer region. This diagnostic indicates that one of these constraints was violated.

ID

Observation

Description

1

OpenMP usage error

The place the non-shared variable was used improperly

Examples


    module mod
    contains
    subroutine sub(last, N)
    integer last, i, N
!$OMP DO LASTPRIVATE(last)
    do i = 1, N
        last = i
    end do
!$OMP END DO
    end subroutine sub
    end module mod

    use mod
    integer, parameter :: N=10
    integer last
    real, dimension(N) :: a
    a = 1.0
!$OMP PARALLEL SHARED(a, b, c) PRIVATE(last)
    call sub(last, N)
!$OMP END PARALLEL
    end
        

Copyright © 2010, Intel Corporation. All rights reserved.