Recursion

The RECURSIVE keyword must be specified if, directly or indirectly:
  • The function invokes itself
  • The function invokes a function defined by an ENTRY statement in the same subprogram
  • An entry procedure in the same subprogram invokes itself
  • An entry procedure in the same subprogram invokes another entry procedure in the same subprogram
  • An entry procedure in the same subprogram invokes the subprogram defined by the FUNCTION statement.

A function that directly invokes itself requires that both the RECURSIVE and RESULT keywords be specified. The presence of both keywords makes the procedure interface explicit within the subprogram.

If name is of type character, its length cannot be an asterisk if the function is recursive.

If RECURSIVE is specified, the result variable has a default storage class of automatic.

You can also call external procedures recursively when you specify the -qrecur compiler option, although IBM® Open XL Fortran disregards this option if the FUNCTION statement specifies either RECURSIVE or RESULT.