Internal procedures are functions or subroutines that follow a CONTAINS statement in a program unit. The program unit in which the internal procedure appears is called its host.
Internal procedures can appear in the main program, in an external subprogram, or in a module subprogram.
An internal procedure takes the following form:
Rules and Behavior
Internal procedures are the same as external procedures, except for the following:
An internal procedure can reference itself (directly or indirectly); it can be referenced in the execution part of its host and in the execution part of any internal procedure contained in the same host (including itself).
The interface of an internal procedure is always explicit.
The following example shows an internal procedure:
PROGRAM COLOR_GUIDE ... CONTAINS FUNCTION HUE(BLUE) ! An internal procedure ... END FUNCTION HUE END PROGRAM
The following example program contains an internal subroutine
performs calculations that the main program then prints. The variables
c declared in the host
program are also known to the internal subroutine.
program INTERNAL ! shows use of internal subroutine and CONTAINS statement real a,b,c call find print *, c contains subroutine find read *, a,b c = sqrt(a**2 + b**2) end subroutine find end
For More Information: