*DECK GAMLN REAL FUNCTION GAMLN (Z, IERR) C***BEGIN PROLOGUE GAMLN C***SUBSIDIARY C***PURPOSE Compute the logarithm of the Gamma function C***LIBRARY SLATEC C***CATEGORY C7A C***TYPE SINGLE PRECISION (GAMLN-S, DGAMLN-D) C***KEYWORDS LOGARITHM OF GAMMA FUNCTION C***AUTHOR Amos, D. E., (SNL) C***DESCRIPTION C C GAMLN COMPUTES THE NATURAL LOG OF THE GAMMA FUNCTION FOR C Z.GT.0. THE ASYMPTOTIC EXPANSION IS USED TO GENERATE VALUES C GREATER THAN ZMIN WHICH ARE ADJUSTED BY THE RECURSION C G(Z+1)=Z*G(Z) FOR Z.LE.ZMIN. THE FUNCTION WAS MADE AS C PORTABLE AS POSSIBLE BY COMPUTING ZMIN FROM THE NUMBER OF BASE C 10 DIGITS IN A WORD, RLN=MAX(-ALOG10(R1MACH(4)),0.5E-18) C LIMITED TO 18 DIGITS OF (RELATIVE) ACCURACY. C C SINCE INTEGER ARGUMENTS ARE COMMON, A TABLE LOOK UP ON 100 C VALUES IS USED FOR SPEED OF EXECUTION. C C DESCRIPTION OF ARGUMENTS C C INPUT C Z - REAL ARGUMENT, Z.GT.0.0E0 C C OUTPUT C GAMLN - NATURAL LOG OF THE GAMMA FUNCTION AT Z C IERR - ERROR FLAG C IERR=0, NORMAL RETURN, COMPUTATION COMPLETED C IERR=1, Z.LE.0.0E0, NO COMPUTATION C C***REFERENCES COMPUTATION OF BESSEL FUNCTIONS OF COMPLEX ARGUMENT C BY D. E. AMOS, SAND83-0083, MAY, 1983. C***ROUTINES CALLED I1MACH, R1MACH C***REVISION HISTORY (YYMMDD) C 830501 DATE WRITTEN C 830501 REVISION DATE from Version 3.2 C 910415 Prologue converted to Version 4.0 format. (BAB) C 920128 Category corrected. (WRB) C 921215 GAMLN defined for Z negative. (WRB) C***END PROLOGUE GAMLN