      REAL FUNCTION LOGAM(X)
C LOGAM IS A FUNCTION WHICH COMPUTES THE LOG OF GAMMA(X) WHERE X IS
C  RESTRICTED TO INTEGER OR INTEGER+1/3 VALUES.X.GT.0 LESS
C THAN 1006.
       DIMENSION G(200)
      REAL N,NN
      DATA C2/.83333333333333E-1/,C3/-.33333333333333E-1/
      DATA C4/-.28571428571429/
      DATA G(  1)/+.57236494292470 E+ 0/,G(  2)/+.00000000000000 E+ 0/
      DATA G(  3)/-.12078223763525 E+ 0/,G(  4)/+.00000000000000 E+ 0/
      DATA G(  5)/+.28468287047292 E+ 0/,G(  6)/+.69314718055995 E+ 0/
      DATA G(  7)/+.12009736023471 E+ 1/,G(  8)/+.17917594692281 E+ 1/
      DATA G(  9)/+.24537365708424 E+ 1/,G( 10)/+.31780538303479 E+ 1/
      DATA G( 11)/+.39578139676187 E+ 1/,G( 12)/+.47874917427820 E+ 1/
      DATA G( 13)/+.56625620598571 E+ 1/,G( 14)/+.65792512120101 E+ 1/
      DATA G( 15)/+.75343642367587 E+ 1/,G( 16)/+.85251613610654 E+ 1/
      DATA G( 17)/+.95492672573010 E+ 1/,G( 18)/+.10604602902745 E+ 2/
      DATA G( 19)/+.11689333420797 E+ 2/,G( 20)/+.12801827480081 E+ 2/
      DATA G( 21)/+.13940625219404 E+ 2/,G( 22)/+.15104412573076 E+ 2/
      DATA G( 23)/+.16292000476567 E+ 2/,G( 24)/+.17502307845874 E+ 2/
      DATA G( 25)/+.18734347511936 E+ 2/,G( 26)/+.19987214495662 E+ 2/
      DATA G( 27)/+.21260076156245 E+ 2/,G( 28)/+.22552163853123 E+ 2/
      DATA G( 29)/+.23862765841689 E+ 2/,G( 30)/+.25191221182739 E+ 2/
      DATA G( 31)/+.26536914491116 E+ 2/,G( 32)/+.27899271383841 E+ 2/
      DATA G( 33)/+.29277754515041 E+ 2/,G( 34)/+.30671860106081 E+ 2/
      DATA G( 35)/+.32081114895947 E+ 2/,G( 36)/+.33505073450137 E+ 2/
      DATA G( 37)/+.34943315776877 E+ 2/,G( 38)/+.36395445208033 E+ 2/
      DATA G( 39)/+.37861086508961 E+ 2/,G( 40)/+.39339884187199 E+ 2/
      DATA G( 41)/+.40831500974531 E+ 2/,G( 42)/+.42335616460753 E+ 2/
      DATA G( 43)/+.43851925860675 E+ 2/,G( 44)/+.45380138898477 E+ 2/
      DATA G( 45)/+.46919978795809 E+ 2/,G( 46)/+.48471181351835 E+ 2/
      DATA G( 47)/+.50033494105019 E+ 2/,G( 48)/+.51606675567764 E+ 2/
      DATA G( 49)/+.53190494526169 E+ 2/,G( 50)/+.54784729398112 E+ 2/
      DATA G( 51)/+.56389167643720 E+ 2/,G( 52)/+.58003605222981 E+ 2/
      DATA G( 53)/+.59627846095884 E+ 2/,G( 54)/+.61261701761002 E+ 2/
      DATA G( 55)/+.62904990828877 E+ 2/,G( 56)/+.64557538627006 E+ 2/
      DATA G( 57)/+.66219176833549 E+ 2/,G( 58)/+.67889743137182 E+ 2/
      DATA G( 59)/+.69569080920824 E+ 2/,G( 60)/+.71257038967168 E+ 2/
      DATA G( 61)/+.72953471184169 E+ 2/,G( 62)/+.74658236348830 E+ 2/
      DATA G( 63)/+.76371197867783 E+ 2/,G( 64)/+.78092223553315 E+ 2/
      DATA G( 65)/+.79821185413614 E+ 2/,G( 66)/+.81557959456115 E+ 2/
      DATA G( 67)/+.83302425502950 E+ 2/,G( 68)/+.85054467017582 E+ 2/
      DATA G( 69)/+.86813970941781 E+ 2/,G( 70)/+.88580827542198 E+ 2/
      DATA G( 71)/+.90354930265818 E+ 2/,G( 72)/+.92136175603687 E+ 2/
      DATA G( 73)/+.93924462962300 E+ 2/,G( 74)/+.95719694542143 E+ 2/
      DATA G( 75)/+.97521775222888 E+ 2/,G( 76)/+.99330612454787 E+ 2/
      DATA G( 77)/+.10114611615586 E+ 3/,G( 78)/+.10296819861451 E+ 3/
      DATA G( 79)/+.10479677439716 E+ 3/,G( 80)/+.10663176026064 E+ 3/
      DATA G( 81)/+.10847307506907 E+ 3/,G( 82)/+.11032063971476 E+ 3/
      DATA G( 83)/+.11217437704318 E+ 3/,G( 84)/+.11403421178146 E+ 3/
      DATA G( 85)/+.11590007047041 E+ 3/,G( 86)/+.11777188139975 E+ 3/
      DATA G( 87)/+.11964957454634 E+ 3/,G( 88)/+.12153308151544 E+ 3/
      DATA G( 89)/+.12342233548444 E+ 3/,G( 90)/+.12531727114936 E+ 3/
      DATA G( 91)/+.12721782467361 E+ 3/,G( 92)/+.12912393363913 E+ 3/
      DATA G( 93)/+.13103553699957 E+ 3/,G( 94)/+.13295257503562 E+ 3/
      DATA G( 95)/+.13487498931216 E+ 3/,G( 96)/+.13680272263733 E+ 3/
      DATA G( 97)/+.13873571902320 E+ 3/,G( 98)/+.14067392364823 E+ 3/
      DATA G( 99)/+.14261728282115 E+ 3/,G(100)/+.14456574394634 E+ 3/
      DATA G(101)/+.14651925549072 E+ 3/,G(102)/+.14847776695177 E+ 3/
      DATA G(103)/+.15044122882700 E+ 3/,G(104)/+.15240959258450 E+ 3/
      DATA G(105)/+.15438281063467 E+ 3/,G(106)/+.15636083630308 E+ 3/
      DATA G(107)/+.15834362380427 E+ 3/,G(108)/+.16033112821663 E+ 3/
      DATA G(109)/+.16232330545817 E+ 3/,G(110)/+.16432011226320 E+ 3/
      DATA G(111)/+.16632150615984 E+ 3/,G(112)/+.16832744544843 E+ 3/
      DATA G(113)/+.17033788918059 E+ 3/,G(114)/+.17235279713916 E+ 3/
      DATA G(115)/+.17437212981875 E+ 3/,G(116)/+.17639584840700 E+ 3/
      DATA G(117)/+.17842391476655 E+ 3/,G(118)/+.18045629141754 E+ 3/
      DATA G(119)/+.18249294152079 E+ 3/,G(120)/+.18453382886145 E+ 3/
      DATA G(121)/+.18657891783334 E+ 3/,G(122)/+.18862817342367 E+ 3/
      DATA G(123)/+.19068156119837 E+ 3/,G(124)/+.19273904728784 E+ 3/
      DATA G(125)/+.19480059837319 E+ 3/,G(126)/+.19686618167289 E+ 3/
      DATA G(127)/+.19893576492993 E+ 3/,G(128)/+.20100931639928 E+ 3/
      DATA G(129)/+.20308680483583 E+ 3/,G(130)/+.20516819948264 E+ 3/
      DATA G(131)/+.20725347005963 E+ 3/,G(132)/+.20934258675254 E+ 3/
      DATA G(133)/+.21143552020227 E+ 3/,G(134)/+.21353224149456 E+ 3/
      DATA G(135)/+.21563272214993 E+ 3/,G(136)/+.21773693411395 E+ 3/
      DATA G(137)/+.21984484974781 E+ 3/,G(138)/+.22195644181913 E+ 3/
      DATA G(139)/+.22407168349308 E+ 3/,G(140)/+.22619054832373 E+ 3/
      DATA G(141)/+.22831301024565 E+ 3/,G(142)/+.23043904356578 E+ 3/
      DATA G(143)/+.23256862295547 E+ 3/,G(144)/+.23470172344282 E+ 3/
      DATA G(145)/+.23683832040517 E+ 3/,G(146)/+.23897838956183 E+ 3/
      DATA G(147)/+.24112190696703 E+ 3/,G(148)/+.24326884900298 E+ 3/
      DATA G(149)/+.24541919237325 E+ 3/,G(150)/+.24757291409619 E+ 3/
      DATA G(151)/+.24972999149863 E+ 3/,G(152)/+.25189040220972 E+ 3/
      DATA G(153)/+.25405412415489 E+ 3/,G(154)/+.25622113555001 E+ 3/
      DATA G(155)/+.25839141489572 E+ 3/,G(156)/+.26056494097186 E+ 3/
      DATA G(157)/+.26274169283208 E+ 3/,G(158)/+.26492164979855 E+ 3/
      DATA G(159)/+.26710479145687 E+ 3/,G(160)/+.26929109765102 E+ 3/
      DATA G(161)/+.27148054847853 E+ 3/,G(162)/+.27367312428569 E+ 3/
      DATA G(163)/+.27586880566295 E+ 3/,G(164)/+.27806757344037 E+ 3/
      DATA G(165)/+.28026940868320 E+ 3/,G(166)/+.28247429268763 E+ 3/
      DATA G(167)/+.28468220697654 E+ 3/,G(168)/+.28689313329543 E+ 3/
      DATA G(169)/+.28910705360840 E+ 3/,G(170)/+.29132395009427 E+ 3/
      DATA G(171)/+.29354380514276 E+ 3/,G(172)/+.29576660135076 E+ 3/
      DATA G(173)/+.29799232151870 E+ 3/,G(174)/+.30022094864701 E+ 3/
      DATA G(175)/+.30245246593264 E+ 3/,G(176)/+.30468685676567 E+ 3/
      DATA G(177)/+.30692410472600 E+ 3/,G(178)/+.30916419358015 E+ 3/
      DATA G(179)/+.31140710727802 E+ 3/,G(180)/+.31365282994988 E+ 3/
      DATA G(181)/+.31590134590330 E+ 3/,G(182)/+.31815263962021 E+ 3/
      DATA G(183)/+.32040669575401 E+ 3/,G(184)/+.32266349912673 E+ 3/
      DATA G(185)/+.32492303472629 E+ 3/,G(186)/+.32718528770378 E+ 3/
      DATA G(187)/+.32945024337081 E+ 3/,G(188)/+.33171788719693 E+ 3/
      DATA G(189)/+.33398820480710 E+ 3/,G(190)/+.33626118197920 E+ 3/
      DATA G(191)/+.33853680464160 E+ 3/,G(192)/+.34081505887080 E+ 3/
      DATA G(193)/+.34309593088909 E+ 3/,G(194)/+.34537940706227 E+ 3/
      DATA G(195)/+.34766547389743 E+ 3/,G(196)/+.34995411804077 E+ 3/
      DATA G(197)/+.35224532627544 E+ 3/,G(198)/+.35453908551944 E+ 3/
      DATA G(199)/+.35683538282361 E+ 3/,G(200)/+.35913420536958 E+ 3/
      IF(X.GT.100.)GO TO 1
      I=2.0*X+.2
C  THE .2 IS TO ENSURE THAT I IS NOT TRUNCATED TO 1 LESS THAN DESIRED.
      LOGAM=G(I)
      GO TO 2
    1 N=X-1.0
      XBAR=(N+.5)*ALOG(N)-N+.91893853320467
      NN=1.0/(N*N)
      TEMP=C2/N
      XBAR=XBAR+TEMP
      TEMP=TEMP*C3*NN
      XBAR=XBAR+TEMP
      TEMP=TEMP*C4*NN
      LOGAM=XBAR+TEMP
    2 RETURN
      END
