FORTRAN Reference Manual
Statements
FORTRAN Reference Manual—528615-001
7-54
FUNCTION Statement
output the value of 100 for I, and 20.03 for Y.
Given the preceding input record, the following statements output the value of 10 for J,
and 0.23 for B.
READ (6, 11) j, b
11 FORMAT (BN, I3, F5.2)
PRINT *, j, b
FUNCTION Statement
The FUNCTION statement designates the beginning of a function subprogram.
type
is INTEGER, INTEGER*2, INTEGER*4, INTEGER*8, REAL, DOUBLE
PRECISION, COMPLEX, LOGICAL, or CHARACTER [* len].
func-name
is the name of the function subprogram designated by the FUNCTION statement.
dmy
is a variable, array, RECORD, or dummy procedure name that designates a
dummy argument.
Considerations
•
The FUNCTION subprogram can include multiple entry points (see the ENTRY
Statement on page 7-33) and zero or more RETURN statements (see the
RETURN Statement
on page 7-95). Terminate the FUNCTION subprogram with an
END statement.
•
You can specify the type of the function name implicitly according to the default
FORTRAN convention, or explicitly by a type entry preceding the word
FUNCTION or in a type declaration statement after the FUNCTION statement.
However, if you override the default, you must include that specification in both the
calling program and the FUNCTION statement.
•
func-name has the scope of an executable program and must be different from
any other external name.
•
You must assign a value to the function name (or any of its other names defined by
ENTRY statements) at least once during the execution of the function subprogram.
•
dmy is unique to the program unit which begins with the FUNCTION statement and
ends with the END statement; it must not appear in an EQUIVALENCE,
[ type ] FUNCTION func-name ( [ dmy [, dmy ]... ] )










