Subroutine vs function

Applies to: fortran

A Fortran function returns one value; a subroutine returns results through intent(out) arguments and is invoked with call. Use a subroutine when a procedure produces several outputs or none.

call forces(q, s, lift, drag)   ! returns lift and drag via arguments
l = lift_fn(cl, q, s)           ! a function returns one value

See also: module, intent, do-loop