The TELEMAC-MASCARET system  trunk
gammln.f
Go to the documentation of this file.
1 ! ***************
2  FUNCTION gammln
3 ! ***************
4 !
5  &( xx , deupi )
6 !
7 !***********************************************************************
8 ! TOMAWAC V6P1 15/06/2011
9 !***********************************************************************
10 !
11 !brief COMPUTES THE NATURAL LOGARITHM FOR THE GAMMA FUNCTION
12 !+ (EULER FUNCTION OF SECOND-KIND).
13 !
14 !note IF XX IS AN INTEGER NOTED N, GAMMA(N) = (N-1)!
15 !
16 !reference "NUMERICAL RECIPES. THE ART OF SCIENTIFIC COMPUTING",
17 !+ PRESS ET AL. (1989). (CF. PP 156-157)
18 !
19 !history M. BENOIT
20 !+ 15/11/95
21 !+ V1P0
22 !+ CREATED
23 !
24 !history M. BENOIT
25 !+ 07/11/96
26 !+ V1P2
27 !+ MODIFIED
28 !
29 !history N.DURAND (HRW), S.E.BOURBAN (HRW)
30 !+ 13/07/2010
31 !+ V6P0
32 !+ Translation of French comments within the FORTRAN sources into
33 !+ English comments
34 !
35 !history N.DURAND (HRW), S.E.BOURBAN (HRW)
36 !+ 21/08/2010
37 !+ V6P0
38 !+ Creation of DOXYGEN tags for automated documentation and
39 !+ cross-referencing of the FORTRAN sources
40 !
41 !history G.MATTAROLO (EDF - LNHE)
42 !+ 15/06/2011
43 !+ V6P1
44 !+ Translation of French names of the variables in argument
45 !
46 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47 !| DEUPI |-->| 2.PI
48 !| XX |-->| VALUE AT WHICH LOG(GAMMA) IS CALCULATED
49 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50 !
51  USE interface_tomawac, ex_gammln => gammln
52  IMPLICIT NONE
53 !
54 !.....VARIABLES IN ARGUMENT
55 ! """"""""""""""""""""
56  DOUBLE PRECISION GAMMLN
57  DOUBLE PRECISION,INTENT(IN) :: XX , DEUPI
58 !
59 !.....LOCAL VARIABLES
60 ! """""""""""""""""
61  INTEGER J
62  DOUBLE PRECISION STP , X , XC , TMP , SER , AUX
63  DOUBLE PRECISION COF(6)
64 !
65 !
66  cof(1)= 76.180091730d0
67  cof(2)=-86.505320330d0
68  cof(3)= 24.014098220d0
69  cof(4)= -1.231739516d0
70  cof(5)= 0.001208580d0
71  cof(6)= -0.000005364d0
72  stp = 2.506628275d0
73 !
74  IF (xx.LT.1.d0) THEN
75  xc=2.d0-xx
76  ELSE
77  xc=xx
78  ENDIF
79  x=xc-1.d0
80  tmp=x+5.5d0
81  tmp=(x+0.5d0)*log(tmp)-tmp
82  ser=1.d0
83  DO j=1,6
84  x=x+1.d0
85  ser=ser+cof(j)/x
86  ENDDO ! J
87  gammln=tmp+log(stp*ser)
88  IF (xx.LT.1d0) THEN
89  aux=0.5d0*deupi*(1.d0-xx)
90  gammln=log(aux/sin(aux))-gammln
91  ENDIF
92 !
93  RETURN
94  END
double precision function gammln(XX, DEUPI)
Definition: gammln.f:7