HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
SUBROUTINE
Chapter 10474
SUBROUTINE
Begins the definition of a subroutine subprogram.
Syntax
[RECURSIVE] SUBROUTINE
subr-name
[([
dummy-arg-list
])]
subr-name
is the name of a subroutine.
dummy-arg-list
is a comma-separated list of zero or more of
dummy-arg-name
or the asterisk
character (*).
As indicated by the syntax, the parentheses surrounding the dummy
arguments may be omitted if there are no dummy arguments.
Description
The SUBROUTINE statement is the first statement of a subroutine subprogram.
The following rules and restrictions apply to subroutines:
A subroutine is either an external, module, or internal subprogram.
If a subroutine calls itself directly or indirectly, the word RECURSIVE must appear in the
SUBROUTINE statement. If the keyword RECURSIVE is specified, the subroutine interface is
explicit within the subprogram.
The keyword SUBROUTINE must appear on the END statement if the subroutine is a module
or internal procedure.
An asterisk in a subroutine dummy argument list designates an alternate return.
The interface of an internal subroutine is explicit in its host. The interface of a module
subroutine is explicit within the module, and if it is public, it is explicit in all program
units using the module. The interface of an external subroutine is implicit, but may be
made explicit by the use of an interface block.
Examples
Consider the following subroutines:
! A subroutine definition with two arguments.
SUBROUTINE exchange (x, y)
temp = x; x = y; y = temp
END SUBROUTINE exchange