Function (Fortran)

Applies to: fortran

A Fortran function is a procedure that returns a value, often named through a result variable.

function square(x) result(y)
  real, intent(in) :: x
  real :: y
  y = x*x
end function

See also: subroutine, result-clause