Lahey/Fujitsu Fortran

Statement Functions

A statement function (see Statement Function) is a function defined on a single line with a single expression. It can only be referenced within the program unit in which it is defined. A statement function is best used where speed is more important than reusability in other locations, and where the function can be expressed in a single expression. The following is an example equivalent to the external function example in Functions:

program main
real :: a, b=3.6, c=3.8, square
square(x) = x*x
a = 3.7 + b + square(c) + sin(4.7)
print*, a