24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

-qrecur Option<br />

Syntax<br />

-qrecur | -qnorecur<br />

RECUR | NORECUR<br />

Not recommended. Specifies whether external subprograms may be called<br />

recursively. For new programs, use the RECURSIVE keyword, which provides a<br />

standard-con<strong>for</strong>ming way of using recursive procedures. If you specify the -qrecur<br />

option, the compiler must assume that any procedure could be recursive. Code<br />

generation <strong>for</strong> recursive procedures may be less efficient. Using the RECURSIVE<br />

keyword allows you to specify exactly which procedures are recursive.<br />

Examples<br />

! The following RECUR recursive function:<br />

@process recur<br />

function factorial (n)<br />

integer factorial<br />

if (n .eq. 0) then<br />

factorial = 1<br />

else<br />

factorial = n * factorial (n-1)<br />

end if<br />

end function factorial<br />

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

recursive function factorial (n) result (res)<br />

integer res<br />

if (n .eq. 0) then<br />

res = 1<br />

else<br />

res = n * factorial (n-1)<br />

end if<br />

end function factorial<br />

Restrictions<br />

If you use the xlf, xlf_r, xlf_r7, f77, or <strong>for</strong>t77 command to compile programs that<br />

contain recursive calls, specify -qnosave to make the default storage class<br />

automatic.<br />

224 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!