Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28657 Discussions

recursive function can't pass compile

sinozhan
Beginner
327 Views

recursive function f(n) result(ff_result)
implicit none
integer::n,ff_result
if(n==0)then
ff_result=0
else if (n==1.or.n==2)then
ff_result=1
else
ff_result=f(n-1)+f(n-2)!+f(n-3) ! error occurs at this line.

! Error: The same named entity from different modules and/or program units

!cannotbe referenced.
endif
end function f

!*************************************************
program recursivation
implicit none
integer ::i
interface

recursive function f(n) result(ff_result)
integer::n,ff_result
end function f
endinterface
do i=1,10
print*,f(i)
enddo
pause
end program recursivation

! please help me,thanks a lot.

0 Kudos
3 Replies
Steven_L_Intel1
Employee
327 Views
Turn off "Check generated interfaces" under the Fortran > Diagnostics.
0 Kudos
sinozhan
Beginner
327 Views
Thank you very much , administrator.
0 Kudos
Steven_L_Intel1
Employee
327 Views
By the way, this is a compiler bug that is in the process of being fixed. I'm puzzled as to why we're suddenly seeing multiple reports of it, as the bug has been there for a while...
0 Kudos
Reply