CHARACTER*5 FUNCTION BOOL(ARG) BOOL = 'TRUE' IF (ARG .LE. 0) BOOL = 'FALSE' RETURN END
In the above example, BOOL is defined as a function of type CHARACTER with a length of 5 characters. This function when called returns the string, TRUE or FALSE, depending on the value of the variable, ARG.
FUNCTION SQR (A) SQR = A*A RETURN END
In the above example, the function SQR is defined as function of type REAL by default, and returns the square of the number passed to it.
INTEGER FUNCTION FCN*2 ( A, B, C )
INTEGER*2 FUNCTION FCN ( A, B, C )