FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-106
SUBROUTINE Statement
SUBROUTINE Statement
The SUBROUTINE statement is the first statement of a subroutine.
name
is the symbolic name of the subroutine. It has the scope of an executable program.
dummy
is a variable name, an array name, a RECORD name, a dummy procedure name
or an asterisk, which corresponds to an alternate return specifier in a CALL
statement.
Considerations
A subroutine must begin with a SUBROUTINE statement and end with an END
statement.
A subroutine can include one or more ENTRY statements and one or more
RETURN statements.
The name of dummy has the scope of the subroutine. Do not declare it in an
EQUIVALENCE, PARAMETER, DATA, INTRINSIC, SAVE, or COMMON statement
(except as a common block name) within the program unit.
The subroutine name has the scope of an executable program and must be
different from any other external name.
The subroutine name must not be the same as any common block name declared
anywhere in the executable program.
For additional information about subroutines, see Section 4, Program Units.
Example
SUBROUTINE namelength (name, length)
CHARACTER name*(*)
length = LEN(name)
IF (length .GT. 80) THEN
PRINT *, 'YOUR ENTRY IS TOO LONG!'
END IF
END
SUBROUTINE name [ ( [ dummy [, dummy ]... ] ) ]