Next: Examples of NEW
Up: The INDEPENDENT Directive
Previous: Examples of INDEPENDENT
The NEW clause asserts that the named variables act as
private variables to each iteration of the INDEPENDENT loop.
That is, there would be no interfering assignments and uses in the
loop, and thus no change in ghe behavior of the program, if new
objects were created for the NEW variables for each iteration
of the DO loop and those objects were destroyed at the end of
each iteration. Thus, no values flow into NEW variables from
execution before the loop, no values flow from NEW variables
to execution after the loop, and (most importantly) no values flow
from one iteration to another through NEW variables.
-
- Advice to users.A pointer or allocatable variable may appear in a NEW
clause. The interpretation of the paragraph above, in these cases,
is that one should not rely on the value, the association status, or
the allocation status of such a variable on entry to the loop;
rather, such variables should be allocated or pointer assigned in
the loop body before they are used. It would also be advisable to
deallocate or nullify such a variable in the loop body after its
last use as well.
(End of advice to users.)
-
- Rationale.NEW variables provide the means to declare temporaries in
INDEPENDENT loops. Without this feature, many
conceptually independent loops would need substantial rewriting
(including expansion of scalars into arrays) to meet the rather
strict requirements described above. Note that a temporary must be
declared NEW only at the innermost lexical level at which
it is assigned, since all enclosing INDEPENDENT assertions
must take that NEW into account. Note also that index
variables for nested DO loops must be declared
NEW; the alternative was to limit the scope of an index
variable to the loop itself, which changes Fortran semantics.
FORALL indices, however, are restricted by the semantics of
the FORALL; they require no NEW declarations.
(End of rationale.)
Next: Examples of NEW
Up: The INDEPENDENT Directive
Previous: Examples of INDEPENDENT