OpenMP* NUM_THREADS clause has side-effects

An OpenMP* NUM_THREADS clause expression must not have any side-effects.

It is unspecified whether, in what order, or how many times any side-effects of the evaluation of the NUM_THREADS clause expressions occur. Therefore, the presence of a NUM_THREADS clause expression with side-effects renders the program undefined.

ID

Observation

Description

1

OpenMP usage error

The place the bad NUM_THREADS clause expression was specified

Example


    real r
    integer j, mysub
    common /cc/ j

    r = 2.7
    j = 1
!$OMP PARALLEL SHARED(r) NUM_THREADS(mysub() + j)
    call sub(r)
!$OMP END PARALLEL
    print *, r, j
    end

    function mysub()
        integer mysub, j
        common /cc/ j
        j = 2
        mysub = 1
    end function mysub

    subroutine sub(r)
        real r
        r = r + 9.8
    end subroutine sub
        

Copyright © 2010, Intel Corporation. All rights reserved.