SCALE-RM
scale_specfunc.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
14  !-----------------------------------------------------------------------------
15  !
16  !++ used modules
17  !
18  use scale_precision
19  use scale_stdio
20  !-----------------------------------------------------------------------------
21  implicit none
22  private
23  !-----------------------------------------------------------------------------
24  !
25  !++ Public procedure
26  !
27  public :: sf_gamma
28 
29  !-----------------------------------------------------------------------------
30  !
31  !++ Public parameters & variables
32  !
33  !-----------------------------------------------------------------------------
34  !
35  !++ Private procedure
36  !
37  !-----------------------------------------------------------------------------
38  !
39  !++ Private parameters & variables
40  !
41  !-----------------------------------------------------------------------------
42 contains
43  !-----------------------------------------------------------------------------
45  ! Lanczos approximation
46  ! g = 7.0, N = 8
47  function sf_gamma(x)
48  implicit none
49 
50  real(RP), intent(in) :: x
51  real(RP) :: SF_gamma
52 
53  real(DP), parameter :: LRTP = 0.9189385332046727_dp ! log(sqrt(2*PI))
54  real(DP) :: Ag, dx, work
55  !---------------------------------------------------------------------------
56 
57  dx = real(x-1.0_rp, kind=dp)
58 
59  ag = 0.999999999999809932276847004735_dp &
60  + 676.520368121885098567009190444_dp / ( dx + 1.0_dp ) &
61  - 1259.13921672240287047156078755_dp / ( dx + 2.0_dp ) &
62  + 771.323428777653078848652825889_dp / ( dx + 3.0_dp ) &
63  - 176.615029162140599065845513540_dp / ( dx + 4.0_dp ) &
64  + 12.5073432786869048144589368533_dp / ( dx + 5.0_dp ) &
65  - 0.138571095265720116895547069851_dp / ( dx + 6.0_dp ) &
66  + 9.98436957801957085956266899569e-6_dp / ( dx + 7.0_dp ) &
67  + 1.50563273514931155833835577539e-7_dp / ( dx + 8.0_dp )
68 
69  work = exp( lrtp + (dx+0.5_dp)*log(dx+7.5_dp) - (dx+7.5_dp) + log(ag) )
70  sf_gamma = real(work, kind=rp)
71 
72  return
73  end function sf_gamma
74 
75 end module scale_specfunc
real(rp) function, public sf_gamma(x)
Gamma function.
module STDIO
Definition: scale_stdio.F90:12
integer, parameter, public dp
Definition: dc_types.f90:27
module SPECFUNC
subroutine, public log(type, message)
Definition: dc_log.f90:133
module PRECISION
integer, parameter, public rp