Intel® Fortran Compiler 16.0 User and Reference Guide

IMPURE

Keyword: Asserts that a user-defined procedure has side effects.

Description

This kind of procedure is specified by using the prefix IMPURE in a FUNCTION or SUBROUTINE statement. By default all user-defined procedures are impure, that is, they are allowed to have side effects, except for elemental procedures.

An IMPURE elemental procedure has the restrictions that apply to elemental procedures, but it does not have any of the restrictions of PURE elemental procedures.

An impure elemental procedure can have side effects and it can contain the following:

An impure elemental procedure cannot be referenced in a context that requires a procedure to be pure; for example:

Example

module my_rand_mod
integer, save :: my_rand_seed (8)

  contains
    impure elemental subroutine my_rand (r)

    ! my_rand updates module variable my_rand_seed (an array)
    ! and returns the next value of a “pseudo” random sequence in
    ! output dummy argument r

      real, intent(out) :: r

      ! code goes here
      
    end subroutine my_rand
end module my_rand_mod

See Also