Is it safe to list optional fortran function argument in OpenMP shared clause?

240 views Asked by At

I write a Fortran code like the one shown below.

module optional_arg
    contains

    subroutine foobar(opt_arg)
        integer, intent(in), optional :: opt_arg

        !$omp parallel default(none) shared(opt_arg)
        if (present(opt_arg)) then
        end if
        !$omp end parallel
    end subroutine foobar
end module optional_arg

The module has a function foobar() with an optional formal argument opt_arg. The subroutine contains an OpenMP-block. I need to list that optional argument in a shared() clause.

Is that safe to do so?

I was unable to find the answer in the official OpenMP 4.0 specifications. I am worried, because in a regular Fortran code it is not allowed to reference an optional variable unless it is actually present.

Upd. Compilers do not complain:

  • GNU Fortran (GCC) 4.10.0 20140718 (experimental): gfortran -Wall -Wextra -fopenmp -c optional_arg.F90

  • NAG Fortran Compiler Release 6.0(Hibiya) Build 1042: nagfor -openmp -c optional_arg.F90

0

There are 0 answers