-qrecur

Category

Deprecated options

Purpose

Specifies whether external subprograms may be called recursively.

Not recommended.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-norecur-.   
>>- -q--+-recur---+--------------------------------------------><

@PROCESS:

@PROCESS RECUR | NORECUR

Defaults

-qnorecur

Usage

For new programs, use the RECURSIVE keyword, which provides a standards-conforming way of using recursive procedures.

If you specify the -qrecur option, the compiler must assume that any procedure could be recursive. Code generation for recursive procedures may be less efficient. With the RECURSIVE keyword, you can specify exactly which procedures are recursive.

When you use the following commands to compile programs that contain recursive calls, specify -qnosave to make the default storage class automatic:
  • For .f, .F, .f77 and .F77 files: xlf
  • For any source files: f77 and fort77

Examples

! The following RECUR recursive function:

        @process recur
        function factorial (n)
        integer factorial
        if (n .eq. 0) then
           factorial = 1
        else
           factorial = n * factorial (n-1)
        end if
        end function factorial

! can be rewritten to use F90/F95 RECURSIVE/RESULT features:

        recursive function factorial (n) result (res)
        integer res
        if (n .eq. 0) then
           res = 1
        else
           res = n * factorial (n-1)
        end if
        end function factorial