FORTRAN Reference Manual
Program Units
FORTRAN Reference Manual—528615-001
4-4
Function Subprograms
additional information about the EXTERNAL and INTRINSIC statements, see 
Section 7, Statements.
Because you can compile FORTRAN program units independently, you must declare 
the data type of arguments both in the calling and referenced program unit, unless the 
arguments are typed by default.
Example
If you call the following function subprogram:
FUNCTION tinterest(principal, payment, rate, months)
.
END
using the statement,
total = tinterest(loans(cash, credit), pay, .06, 12 - x)
the execution of the function LOANS with arguments CASH and CREDIT provides the 
value of the first argument. The second argument is defined by the value of PAY. The 
constant .06 provides the value of the third argument, and the expression 12-X 
determines the value of the fourth argument.
Function Subprograms
A function subprogram returns a single value to the calling program unit. The calling 
program can be the main program, another function subprogram, a subroutine, or the 
function subprogram itself. As an extension to the ANSI standard, HP FORTRAN 
allows recursive functions.
A function subprogram executes when a calling program references its name in an 
expression. The function reference consists of the function name followed by an actual 
argument list, enclosed in parentheses. The parentheses are required also when there 
are no actual arguments. Figure 4-1
 on page 4-5 shows the relationship between the 
function subprogram and the calling program.










