Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for
Did you mean:

SOLVED
Go to solution
Highlighted

## fortran compile ERROR !

First of all, I am almost unfamiliar with fortran language as well as compiler.

The version of Fortran compiler is B.11.11.71 (F90 v2.7.1), on HP D380 Server with HP-UX 11i OS.

The source code is as follows:
=============================================
RECURSIVE FUNCTION FACTORIAL( X )

real :: x, GAMMA

if ( X .gt. 12.0 ) then
FACTORIAL = GAMMA( X+1 )
else
if ( X .le. 1.0 ) then
FACTORIAL = 1.0
else
FACTORIAL = X * FACTORIAL( X-1 )
end if
end if

RETURN
END
=============================================

But when compiling, it shows that:
=============================================
# f90 -c factorial.f90
factorial.f90
external function FACTORIAL
FACTORIAL = X * FACTORIAL( X-1 )
^
Error 282 at (11:factorial.f90) : This is not the name of a function but of a function result

1 Error
f90: Errors detected.
=============================================

I really don't know what's wrong. Help me please !
Solution

## Re: fortran compile ERROR !

Hello:

I'm kind of rusty at Fortran, but I'd say all you need to do is something similar to this example from the HP docs:

RECURSIVE FUNCTION factorial (n) RESULT(r)
INTEGER :: n, r
IF (n.ne.0) THEN
r = n*factorial(n-1)
ELSE
r = 1
ENDIF
END FUNCTION factorial

Regards,
Dave