Next: Pure procedure interfaces
Up: Pure Procedure Declaration
Previous: Pure function definition
The following constraints are added to Rule R1219 in Section 12.5.2.3 of
the Fortran 90 standard (defining subroutine-subprogram):
- The specification-part of a pure subroutine must specify
the intents of all dummy arguments except procedure arguments and
arguments that have the POINTER attribute.
- A local variable declared in the specification-part or
internal-function-part of a pure subroutine must not have the
SAVE attribute.
- The execution-part or internal-subprogram-part of
a pure subroutine must not use a dummy parameter with INTENT(IN),
a global variable, or an object that is storage associated with a
global variable, or a subobject thereof, in the following contexts:
- As the assignment variable of an assignment-stmt;
- As a DO variable or implied DO
variable, or as a index-name in a forall-triplet-spec;
- As an input-item in a read-stmt;
- As an internal-file-unit in a write-stmt;
- As an IOSTAT= or SIZE= specifier in
an I/O statement.
- In an assign-stmt;
- As the pointer-object or target
of a pointer-assignment-stmt;
- As the expr of an assignment-stmt
whose assignment variable is of a derived type, or is a
pointer to a derived type, that has a pointer component
at any level of component selection;
- As an allocate-object or stat-variable in an allocate-stmt or deallocate-stmt, or as a pointer-object in a
nullify-stmt;
- As an actual argument associated with a dummy
argument with INTENT (OUT) or INTENT(INOUT)
or with the POINTER attribute.
- Any procedure referenced in a pure subroutine, including one
referenced via a defined operation or assignment, must be pure.
- A dummy argument of a pure subroutine may be explicitly aligned
only with another dummy argument, and may not be explicitly
distributed or given the INHERIT attribute.
- In a pure subroutine, a local variable may be explicitly aligned
only with another local variable or a dummy argument. A local variable
may not be explicitly distributed.
- In a pure subroutine, a dummy argument or local variable must not
have the DYNAMIC attribute.
- In a pure subroutine, a global variable must not appear in a realign-directive or redistribute-directive.
- A pure subroutine must not contain a print-stmt,
open-stmt, close-stmt, backspace-stmt,
endfile-stmt, rewind-stmt, inquire-stmt,
or a read-stmt or write-stmt whose
io-unit is an external-file-unit or *.
- A pure subroutine must not contain a pause-stmt or
stop-stmt.
- Rationale.
The constraints for pure subroutines are based on the same principles
as for pure functions, except that side effects to INTENT(OUT)
and INTENT(INOUT) dummy arguments are permitted. Pointer dummy
arguments are always treated as INTENT(INOUT).
-
Pure subroutines are included to allow subroutine calls from pure
procedures in a safe way, and to allow forall-assignments to be defined assignments.
Next: Pure procedure interfaces
Up: Pure Procedure Declaration
Previous: Pure function definition
paula@erc.msstate.edu
Thu Jul 21 17:05:43 CDT 1994