Visible to Intel only — GUID: GUID-218EF9CE-4AE9-4920-A6CC-9491590D1A83
Visible to Intel only — GUID: GUID-218EF9CE-4AE9-4920-A6CC-9491590D1A83
General Rules for Function and Subroutine Subprograms
A subprogram can be an external, module, or internal subprogram.
The END statement for an external, module, or internal subroutine is of the form END [SUBROUTINE [NAME]]. The END statement for an external, module, or internal function is END [FUNCTION [NAME]]. The definition of a separate module procedure that begins with a MODULE PROCEDURE statement must end with an END PROCEDURE [name] statement.
If a subprogram name appears after the END statement, it must be the same as the name specified in the SUBROUTINE, FUNCTION, or MODULE PROCEDURE statement.
Function and subroutine subprograms can change the values of their arguments, and the calling program can use the changed values.
A SUBROUTINE or FUNCTION statement can be optionally preceded by an OPTIONS statement.
Dummy arguments (except for dummy pointers or dummy procedures) can be specified with an intent and can be made optional.
Before Fortran 2018, subroutines and functions were assumed to be non-recursive by default. Procedures had to be explicitly declared as RECURSIVE, either with the RECURSIVE keyword in the SUBROUTINE or FUNCTION statement, by specifying an option on the command line, or in an OPTIONS statement.
Fortran 2018 made subroutines and functions recursive by default. Non-recursive procedures can be declared as such with the NON_RECURSIVE keyword. Intel® Fortran currently treats procedures that are not specifically declared as RECURSIVE or NON_RECURSIVE as non-recursive. To get the Fortran 2018 default recursion behavior, specify the assume recursion or standard-semantics compiler option. This behavior will change in a later release.