A function or subroutine subprogram is a subprogram that has a FUNCTION or SUBROUTINE statement as its first statement. You can also specify a function in a statement function statement. An external function or subroutine subprogram is a program unit.
An internal subprogram is declared after the CONTAINS statement in the main program, a module subprogram, or an external subprogram, but before the END statement of the host program. The name of an internal subprogram must not be defined in the specification section in the host scoping unit.
An external procedure has global scope with respect to the executable program. In the calling program unit, you can specify the interface to an external procedure in an interface block or you can define the external procedure name with the EXTERNAL attribute.
A
subprogram can contain any statement except PROGRAM, BLOCK DATA, MODULE,
and
SUBMODULE
statements. An internal subprogram cannot contain an ENTRY statement
or an internal subprogram.