- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a simple recursive function that causes compilation with ifc to fail. It's as if recursion is not being allowed. The errors reported are:
The code compiles fine with PGI and SGI MIPSPro compilers. Here is the function:
I don't see any relevant options in the manual, that I am not already using. I am compiling with the flags: -O2 -opt_report -WB -mp -openmp -fpp1 -auto -pc64 -c -cm -w95 -tpp7 -xW.
Thanks for any suggestions,
jfk.
I have a simple recursive function that causes compilation with ifc to fail. It's as if recursion is not being allowed. The errors reported are:
splinen = ( (x+n/2.)*splinen(x+0.5,n-1) ^ Error 282 at (612:tfed.f) : This is not the name of a function but of a function result * +(n/2.-x)*splinen(x-0.5,n-1))/(n-1) ^ Error 282 at (613:tfed.f) : This is not the name of a function but of a function result
The code compiles fine with PGI and SGI MIPSPro compilers. Here is the function:
RECURSIVE FUNCTION splinen(x,n) REAL x INTEGER n IF(n.eq.1) THEN IF(x.ge.-0.5 .and. x<0.5 ) THEN splinen = 1 ELSE splinen = 0 END IF RETURN ENDIF IF(abs(x)>n/2.) THEN splinen = 0 RETURN ENDIF splinen = ( (x+n/2.)*splinen(x+0.5,n-1) F +(n/2.-x)*splinen(x-0.5,n-1))/(n-1) RETURN END
I don't see any relevant options in the manual, that I am not already using. I am compiling with the flags: -O2 -opt_report -WB -mp -openmp -fpp1 -auto -pc64 -c -cm -w95 -tpp7 -xW.
Thanks for any suggestions,
jfk.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might try writing the function like this:
RECURSIVE FUNCTION splinen(x,n) RESULT(answer)
REAL x
INTEGER n,answer
IF(n.eq.1) THEN
IF(x.ge.-0.5 .and. x<0.5 ) THEN
answer = 1
ELSE
answer = 0
END IF
RETURN
ENDIF
IF(abs(x)>n/2.) THEN
answer = 0
RETURN
ENDIF
answer = ( (x+n/2.)*splinen(x+0.5,n-1)+(n/2.-x)*splinen(x-0.5,n-1))/(n-1)
END FUNCTION splinen
RECURSIVE FUNCTION splinen(x,n) RESULT(answer)
REAL x
INTEGER n,answer
IF(n.eq.1) THEN
IF(x.ge.-0.5 .and. x<0.5 ) THEN
answer = 1
ELSE
answer = 0
END IF
RETURN
ENDIF
IF(abs(x)>n/2.) THEN
answer = 0
RETURN
ENDIF
answer = ( (x+n/2.)*splinen(x+0.5,n-1)+(n/2.-x)*splinen(x-0.5,n-1))/(n-1)
END FUNCTION splinen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Obviously I didn't look closely enough at the code to see that the problem was not the recursive call but the variable with the same name as the function :) So your suggestion of course fixed the problem. Many thanks.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page