IMPURE attribute
Standard: F77 F90 F95 F2003 F2008
  Example Program

The IMPURE keyword may appear only in the prefix of a FUNCTION or SUBROUTINE statement.
The IMPURE keyword specifies that all procedures defined by this subprogram are “impure”; that is, they are permitted to have side effects. (A subprogram can define several procedures by using the ENTRY statement.)

This attribute only has meaning when combined with the ELEMENTAL attribute, as it disables the otherwise “implicitly PURE” semantics of the ELEMENTAL attribute. However, it might be considered useful for documentation purposes for nonelemental procedures.

An impure elemental procedure is applied to its array arguments in array element order. This ensures that the semantics of any side effects are deterministic.

Typical uses of an impure elemental include things like printing intermediate values when debugging, terminating the program with an appropriate message if an error is discovered, and counting the number of times an operation is performed (instrumentation).

ELEMENTAL attribute, ENTRY statement, FUNCTION statement, PURE attribute, RECURSIVE attribute, RESULT clause, SUBROUTINE statement