The value 1.7724538509055161 corresponds to the (correct) result from the (mathematical) gamma function with argument 0.5. The standard intrinsic function gamma
returns result corresponding to this gamma function.
In your program calling gamma
you have declared gamma to return a real*8
result, but you haven't given it the external
attribute, or made an interface available through other means. So, the intrinsic is to called instead: when compiling the main program the compiler "knows" about no alternative [I'd expect a compiler warning in such circumstances if you ask for it.]
I'd recommend that you call your function something other than gamma
rather than add the external
attribute. I'd even recommend that for a function which has an interface available in the program.
By "interface available", I mean you could:
- put your
gamma
function internal to the main program;
- put your
gamma
function in a module use
d by the main program;
- [offer an interface block.]
Consult your programming guide for details.
Finally, I'd also recommend one other thing: no real*8
. You can read many comments here on SO about that.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…