Log_gamma documentation

I am confused about log_gamma vs. lgamma.
In the GFortran doc, the syntax says log_gamma but the example uses lgamma.

In addition, the fortran-lang intrinsic doc shows a gamma_log function, which I suspect does not exist.

LGAMMA has been a GNU extension to Fortran Standard in gfortran since GCC 4.3 released in March 2008. Soon after that Fortran 2008 standard introduced LOG_GAMMA which was supported in GCC 4.4 (indeed, they changed only the name, leaving lgamma in the examples).

Still, if you use standard-choosing option -std=fxxxx, lgamma will be rejected. For -std=f2003 or earlier, also log_gamma will be rejected.

Edit: to make things even more messy, the GCC docs do not mention lgamma at all since then, but the function is recognized by the compiler.

If these procedures are given INTRINSIC or EXTERNAL attributes in the calling routine, then some of this compatibility checking can be done at compile time. Otherwise the errors are generated later at load time or, in the worst case, at run time when some unexpected procedure with different calling conventions is linked into your code.

I think IMPLICIT NONE (EXTERNAL) has recently beed added to the language (f2018) to help the programmer catch some of these cases. I’m not sure why INTRINSIC was not also added to the language at the same time. I guess the thinking is that if a subprogram is not external, then it must be intrinsic?

FUD? Are you serious? Seriously serious?
Well, to all those who, like @kargl, felt feared, uncertain and in doubt because of my error, I humbly apologize.

1 Like

I know exactly what U in FUD means. And you also exactly know that spreading FUD has nothing to do with the reasoning for uncertainty you put in your last message.
So just stop mobbing me.
That’s the last response to any of your messages in this forum, on any topic.

1 Like

It’s mentioned by the latest (12.1) docs: LOG_GAMMA (The GNU Fortran Compiler), but indeed the example still calls the GNU extension.

I’ve come across many log gamma function implementations in past Fortran codes, the oldest so far being the FLGAMA function in Stroud and Secrest’s Gaussian quadrature formulas dating back to 1966. It’s good we have an intrinsic function nowadays.