-qrecur
種類
用途
指定是否可以遞迴呼叫外部子程式。
不建議。
語法
@PROCESS:
@PROCESS RECUR | NORECUR 預設值
-qnorecur
用法
若為新程式,請使用 RECURSIVE 關鍵字,其提供符合標準的方式來使用遞迴程序。
如果您指定 -qrecur 選項,編譯器必須假設任何程序都可以遞迴。 遞迴程序的程式碼產生可能效率較低。 使用 RECURSIVE 關鍵字,您可以確切指定遞迴的程序。
當您使用下列指令來編譯包含遞迴呼叫的程式時,請指定 -qnosave 以自動執行預設儲存類別:
- 若為 .f、.F、 .f77 及 .F77 檔案: xlf
- 若為任何原始檔: f77 及 fort77
範例
! 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 