HP Fortran Programmer's Reference (September 2007)

Program units and procedures
External procedures
Chapter 7 161
External procedures
External procedures are implemented as either functions or subroutines. The major difference
between the two is that a function subprogram returns a value and can therefore appear as an
operand in an expression.
The following sections describe both types of external procedures, including the following
topics:
Procedure definition
Procedure reference
Returning from a procedure call
Alternate entry points
For detailed information about any of the statements associated with procedures (for example,
SUBROUTINE and FUNCTION), refer to Chapter 10, “HP Fortran Statements.”
Procedure definition
The definition of an external procedure takes the form:
external-procedure-statement
[
specification-part
]
[
execution-part
]
[
internal-procedure-part
]
end-external-procedure-statement
external-procedure-statement
takes one of the following forms, depending on whether the procedure is a
subroutine or function
[RECURSIVE] SUBROUTINE
name
&
[([
dummy-arg-list
])]
[RECURSIVE][
type-spec
] FUNCTION
name
&
([
dummy-arg-list
]) [RESULT (
result-name
)]
where
name
is the name of the procedure;
type-spec
is the type of the
function’s result value; and
dummy-arg-list
is a comma-separated list of
dummy arguments, as described in “Arguments” on page 171. The
SUBROUTINE and FUNCTION statements are fully described in Chapter 10,
“HP Fortran Statements.”