SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
gammas.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  FUNCTION gammas(PX) RESULT(PGAMMA)
7 ! ##################################
8 !
9 !
10 !!**** *GAMMAS * - Gamma function
11 !!
12 !!
13 !! PURPOSE
14 !! -------
15 ! The purpose of this function is to compute the Generalized gamma
16 ! function of its argument.
17 !
18 !
19 !!** METHOD
20 !! ------
21 !!
22 !! EXTERNAL
23 !! --------
24 !! NONE
25 !!
26 !! IMPLICIT ARGUMENTS
27 !! ------------------
28 !! None
29 !!
30 !! REFERENCE
31 !! ---------
32 !! Press, Teukolsky, Vetterling and Flannery: Numerical Recipes, 206-207
33 !!
34 !! AUTHOR
35 !! ------
36 !! Jean-Pierre Pinty *LA/OMP*
37 !!
38 !! MODIFICATIONS
39 !! -------------
40 !! Original 7/11/95
41 !
42 !* 0. DECLARATIONS
43 ! ------------
44 !
45 !
46 USE yomhook ,ONLY : lhook, dr_hook
47 USE parkind1 ,ONLY : jprb
48 !
49 IMPLICIT NONE
50 !
51 !* 0.1 declarations of arguments and result
52 !
53 REAL, INTENT(IN) :: px
54 REAL :: pgamma
55 !
56 !* 0.2 declarations of local variables
57 !
58 INTEGER :: jj ! Loop index
59 REAL :: zser,zstp,ztmp,zx,zy,zcoef(6)
60 REAL :: zpi
61 REAL(KIND=JPRB) :: zhook_handle
62 !
63 IF (lhook) CALL dr_hook('GAMMAS',0,zhook_handle)
64 zcoef(1) = 76.18009172947146
65 zcoef(2) =-86.50532032941677
66 zcoef(3) = 24.01409824083091
67 zcoef(4) = -1.231739572450155
68 zcoef(5) = 0.1208650973866179e-2
69 zcoef(6) = -0.5395239384953e-5
70 zstp = 2.5066282746310005
71 !
72 zpi = 3.141592654
73 IF (px.LT.0.) THEN
74  zx = 1.- px
75 ELSE
76  zx = px
77 END IF
78 zy = zx
79 ztmp = zx + 5.5
80 ztmp = (zx + 0.5)*alog(ztmp) - ztmp
81 zser = 1.000000000190015
82 !
83 DO jj = 1 , 6
84  zy = zy + 1.0
85  zser = zser + zcoef(jj)/zy
86 END DO
87 !
88 IF (px.LT.0.) THEN
89  pgamma = zpi/sin(zpi*px)/exp( ztmp + alog( zstp*zser/zx ) )
90 ELSE
91  pgamma = exp( ztmp + alog( zstp*zser/zx ) )
92 END IF
93 IF (lhook) CALL dr_hook('GAMMAS',1,zhook_handle)
94 !
95 END FUNCTION gammas
real function gammas(PX)
Definition: gammas.F90:6