When autoscoping a variable that does not have implicit scope, the compiler checks the use of the variable against the above rules S1–S3 in the given order if it is a scalar, and against the above rule A1 if it is an array. If a rule matches, the compiler will scope the variable according to the matching rule. If a rule does not match, the compiler tries the next rule. If the compiler is unable to find a match, the compiler gives up attempting to determine the scope of that variable and it is scoped SHARED and the binding parallel region is serialized as if an IF (.FALSE.) or if(0) clause were specified.
There are two reasons why autoscoping fails. One is that the use of the variable does not match any of the rules. The other is that the source code is too complex for the compiler to do a sufficient analysis. Function calls, complicated array subscripts, memory aliasing, and user-implemented synchronizations are some typical causes. (See 5.5 Known Limitations of the Current Implementation.)
For Fortran, if a variable is autoscoped by an __auto or default(__auto) clause and the variable has a predetermined scope according to the OpenMP Specification, then the compiler will scope it according to that predetermined scope.
For Fortran, the following variables have predetermined scopes:
Variables and common blocks appearing in threadprivate directives are threadprivate.
The loop iteration variable in the do-loop of a do or parallel do construct is private in that construct.
Variables used as loop iteration variables in sequential loops in a parallel construct are private in the parallel construct.
Implied DO or FORALL indices are private.
Cray pointees inherit the sharing attribute of the storage with which their Cray Fortran pointers are associated.
For C/C++, if a variable is autoscoped by an __auto or default(__auto) clause and the variable has a predetermined scope according to the OpenMP Specification, then the compiler will scope it according to that predetermined scope.
For C/C++, the following variables have predetermined scopes:
Variables appearing in threadprivate directives are threadprivate.
Variables with automatic storage duration which are declared in a scope inside the construct are private.
Variables with heap allocated storage are shared.
Static data members are shared.
The loop iteration variable in the for-loop of a for or parallel for construct is private in that construct.
Variables with const-qualified type having no mutable member are shared.
Autoscoping in C and C++ applies only to basic data types: integer, floating point, and pointer. If a user specifies a structure variable or class variable to be autoscoped, the compiler will scope the variable as shared and the enclosing parallel region will be executed by a single thread.