COSMOS v7.655  COSMOSv7655
(AirShowerMC)
kerfc.f File Reference

Go to the source code of this file.

Functions/Subroutines

real *8 function kerfc (x)
 

Function/Subroutine Documentation

◆ kerfc()

real*8 function kerfc ( real*8  x)

Definition at line 10 of file kerfc.f.

References d, d0, and parameter().

10 ! ***********************
11 !
12 ! complementary error function
13 ! = 1 - kerf(x).
14 ! Note. for x > 4, 1 - kerf(x) gives
15 ! poor result. Therefore we must use
16 ! kerfc directly.
17 !
18 ! Adapted from Mori's code in Maruzen book.
19 !
20  implicit none
21 
22  real*8 x
23  integer nm, nx, na
24  parameter(nm = 5, nx = 13, na = 5)
25 
26  real*8 cm(0:nm),cx(nx),cq(nx),ca(0:na)
27  real*8 sqrtpi, invpi, norm, cxi
28  parameter(sqrtpi = 1.772453850905516d0)
29  parameter(norm = 2.d0 / sqrtpi)
30 
31  parameter(invpi = 1. / 3.141592653589793d0)
32  parameter(cxi = 4.d0 / invpi)
33  real*8 xv, y, v
34  integer i
35 
36  data cm /
37  * 0.1000000000000000d+01,
38  * -0.3333333333333333d+00,
39  * 0.1000000000000000d+00,
40  * -0.2380952380952381d-01,
41  * 0.4629629629629630d-02,
42  * -0.7575757575757575d-03 /
43 !
44  data cx /
45  * 0.7788007830714048d+00,
46  * 0.3678794411714423d+00,
47  * 0.1053992245618643d+00,
48  * 0.1831563888873418d-01,
49  * 0.1930454136227709d-02,
50  * 0.1234098040866796d-03,
51  * 0.4785117392129009d-05,
52  * 0.1125351747192591d-06,
53  * 0.1605228055185612d-08,
54  * 0.1388794386496402d-10,
55  * 0.7287724095819692d-13,
56  * 0.2319522830243569d-15,
57  * 0.4477732441718302d-18 /
58  data cq /
59  * 0.2500000000000000d+00,
60  * 0.1000000000000000d+01,
61  * 0.2250000000000000d+01,
62  * 0.4000000000000000d+01,
63  * 0.6250000000000000d+01,
64  * 0.9000000000000000d+01,
65  * 0.1225000000000000d+02,
66  * 0.1600000000000000d+02,
67  * 0.2025000000000000d+02,
68  * 0.2500000000000000d+02,
69  * 0.3025000000000000d+02,
70  * 0.3600000000000000d+02,
71  * 0.4225000000000000d+02 /
72 !
73  data ca /
74  * 0.1000000000000000d+01,
75  * -0.1000000000000000d+01,
76  * 0.3000000000000000d+01,
77  * -0.1500000000000000d+02,
78  * 0.1050000000000000d+03,
79  * -0.9449999999999999d+03 /
80 !
81 
82  xv = abs(x)
83 
84  if (xv .le. 0.1d0) then
85  y = xv**2
86  v = cm(nm)
87  do i = nm - 1, 0, -1
88  v = cm(i) + y * v
89  enddo
90  kerfc = 1.d0 - norm * xv * v
91  elseif(xv .le. 100.0d0) then
92  y = xv**2
93  v = 1 / (2 * y)
94  do i = 1, nx
95  v = v + cx(i) / (cq(i) + y)
96  enddo
97  v = invpi * xv * exp(-y) * v
98  if (xv .lt. 6.0d0) then
99  v = v - 2 / (exp(cxi * xv) - 1)
100  end if
101  kerfc = v
102  else
103  y = 2 * xv**2
104  v = ca(na)
105  do i = na - 1, 0, -1
106  v = ca(i) + y * v
107  enddo
108  v = exp(-xv**2) / (sqrtpi * xv) * v
109  kerfc = v
110  endif
111 
112  if (x .lt. 0.) then
113  kerfc = 2.d0 - kerfc
114  endif
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
common ZdedxAir norm
Definition: ZdedxAir.h:2
nodes i
real *8 function kerfc(x)
Definition: kerfc.f:10
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
! constants thru Cosmos real * sqrtpi
Definition: Zglobalc.h:2
latitude latitude this system is used *****************************************************************! type coord sequence union map real y
Definition: Zcoord.h:25
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
! structure defining a particle at production ! Basic idea of what is to be contained in ! the particle structue is that dynamical ones should be included those derivable from the particle code ! is not included ******************************************************type fmom momentum sequence union map real e endmap map real * x
Definition: Zptcl.h:21
Here is the call graph for this function: