I have CERN program which calculates the gamma function of complex argument, but I can't run the program because of lack of Fortran knowledge.
I have the following program:
PROGRAM Console1
IMPLICIT REAL *8 (A-H,O-Z)
COMPLEX *16 gama,z,w
z=cmplx(0,0.707106781186548d0)
gama=cgamma(0,z,w)
END
SUBROUTINE cgamma(mo, z, w)
INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(14, 60)
INTEGER, INTENT(IN) :: mo
COMPLEX (dp), INTENT(IN) :: z
COMPLEX (dp), INTENT(OUT) :: w
... the subroutine code here
END SUBROUTINE cgamma
and then error appears
error #6553: A function reference is invoking a subroutine subprogram. [CGAMMA]
Look at the error message:
defines
cgamma
as a (in this case external) subroutine.In the program
references
cgamma
as a function (returning a result to be assigned togama
). This is the incompatibility to which the error message refers.To resolve this you need to reference the subroutine with a
call
statement, or changecgamma
to be a function, returning an appropriate result.Given the design of the procedure (three arguments) I'd expect the function is intended.