SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/gammas.F90
Go to the documentation of this file.
00001 !     #########
00002       FUNCTION GAMMAS(PX)  RESULT(PGAMMA)
00003 !     ##################################
00004 !
00005 !
00006 !!****  *GAMMAS * -  Gamma  function
00007 !!
00008 !!
00009 !!    PURPOSE
00010 !!    -------
00011 !       The purpose of this function is to compute the Generalized gamma
00012 !    function of its argument.
00013 !
00014 !
00015 !!**  METHOD
00016 !!    ------
00017 !!
00018 !!    EXTERNAL
00019 !!    --------
00020 !!      NONE
00021 !!
00022 !!    IMPLICIT ARGUMENTS
00023 !!    ------------------
00024 !!      None
00025 !!
00026 !!    REFERENCE
00027 !!    ---------
00028 !!      Press, Teukolsky, Vetterling and Flannery: Numerical Recipes, 206-207
00029 !!
00030 !!    AUTHOR
00031 !!    ------
00032 !!      Jean-Pierre Pinty *LA/OMP*
00033 !!
00034 !!    MODIFICATIONS
00035 !!    -------------
00036 !!      Original     7/11/95
00037 !
00038 !*       0. DECLARATIONS
00039 !           ------------
00040 !
00041 !
00042 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00043 USE PARKIND1  ,ONLY : JPRB
00044 !
00045 IMPLICIT NONE
00046 !
00047 !*       0.1 declarations of arguments and result
00048 !
00049 REAL, INTENT(IN)                     :: PX
00050 REAL                                 :: PGAMMA
00051 !
00052 !*       0.2 declarations of local variables
00053 !
00054 INTEGER                              :: JJ ! Loop index
00055 REAL                                 :: ZSER,ZSTP,ZTMP,ZX,ZY,ZCOEF(6)
00056 REAL                                 :: ZPI
00057 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00058 !
00059 IF (LHOOK) CALL DR_HOOK('GAMMAS',0,ZHOOK_HANDLE)
00060 ZCOEF(1) = 76.18009172947146
00061 ZCOEF(2) =-86.50532032941677
00062 ZCOEF(3) = 24.01409824083091
00063 ZCOEF(4) = -1.231739572450155
00064 ZCOEF(5) =  0.1208650973866179E-2
00065 ZCOEF(6) = -0.5395239384953E-5
00066 ZSTP     =  2.5066282746310005
00067 !
00068 ZPI = 3.141592654
00069 IF (PX.LT.0.) THEN
00070   ZX = 1.- PX
00071 ELSE 
00072   ZX = PX
00073 END IF
00074 ZY = ZX
00075 ZTMP =  ZX + 5.5
00076 ZTMP = (ZX + 0.5)*ALOG(ZTMP) - ZTMP
00077 ZSER = 1.000000000190015
00078 !
00079 DO JJ = 1 , 6
00080   ZY = ZY + 1.0
00081   ZSER = ZSER + ZCOEF(JJ)/ZY
00082 END DO
00083 !
00084 IF (PX.LT.0.) THEN
00085   PGAMMA = ZPI/SIN(ZPI*PX)/EXP( ZTMP + ALOG( ZSTP*ZSER/ZX ) )
00086 ELSE
00087   PGAMMA = EXP( ZTMP + ALOG( ZSTP*ZSER/ZX ) )
00088 END IF
00089 IF (LHOOK) CALL DR_HOOK('GAMMAS',1,ZHOOK_HANDLE)
00090 !
00091 END FUNCTION GAMMAS