Note the type, value, and formal arguments for a FUNCTION statement.
The function statement involves type, name, and formal arguments.
If type is not present in the FUNCTION statement, then the type of the function is determined by default and by any subsequent IMPLICIT or type statement. If type is present, then the function name cannot appear in other type statements.
Compiling with any of the options -dbl, -r8, -i2, or -xtypemap can alter the default data size assumed in the call to or definition of functions unless the data type size is explicitly declared. See Chapter 2 and the Fortran User Guide for details on these options.
The symbolic name of the function must appear as a variable name in the subprogram. The value of this variable, at the time of execution of the RETURN or END statement in the function subprogram, is the value of the function.
The list of arguments defines the number of formal arguments. The type of these formal arguments is defined by some combination of default, type statements, IMPLICIT statements, and DIMENSION statements.
The number of formal arguments must be the same as the number of actual arguments at the invocation of this function subprogram.
A function can assign values to formal arguments. These values are returned to the calling program when the RETURN or END statements are executed in the function subprogram.