LF Fortran 95

Statement Function


A statement function is a function defined by a single statement.


func-name ([dummy-args])=scalar-expr

func-name is the name of the function being defined.

dummy-args is a comma-separated list of dummy argument names.

scalar-expr is a scalar expression.


scalar-expr can be composed only of literal or named constants, scalar variables, array elements, references to functions and function dummy procedures, and intrinsic operators.

If a reference to a statement function appears in scalar-expr, its definition must have been provided earlier in the scoping unit and must not be the name of the statement function being defined.

Each scalar variable reference in scalar-expr must be either a reference to a dummy argument of the statement function or a reference to a variable local to the same scoping unit as the statement function statement.

The dummy arguments have a scope of the statement function statement.

A statement function must not be supplied as a procedure argument.


mean(a,b)=(a+b)/2 c=mean(2.0,3.0) ! c is assigned the value 2.5