COSMOS v7.655  COSMOSv7655
(AirShowerMC)
ciniSegAtoms.f
Go to the documentation of this file.
1  subroutine cinisegatmos
2 ! read the atmosphere data
3 !
4  implicit none
5 #include "Zmanager.h"
6 #include "Zmanagerp.h"
7 #include "Zearth.h"
8 #include "Zatmos.h"
9 
10  integer icon, ios, i
11  character*100 msg
12 
13  call copenf(tempdev, atmosfile, icon)
14  if(icon .ne. 0) stop 9999
15  call cskipcomment(tempdev, icon)
16  if(icon .ne. 0) stop 9999
17 
18  nodes = 0
19  mostz = 0
20  do while( .true. )
21  read(tempdev, *, iostat=ios)
22  * atmos%z(nodes+1), atmos%T(nodes+1), atmos%P(nodes+1),
23  * atmos%rho(nodes+1), atmos%a(nodes+1), atmos%d0(nodes+1),
24  * atmos%cumd(nodes+1), atmos%H(nodes+1)
25  if(ios .ne. 0) goto 10
26  if(nodes .ge. maxnodes) then
27  write(msg,*) 'numbr of nodes for atmosphere > ', maxnodes
28  call cerrormsg(msg, 0)
29  endif
30  nodes = nodes + 1
31  if(mostz .eq. 0 .and. znode(nodes) .gt. 2900.) then
32  mostz = nodes
33  endif
34 ! write(0,*) Znode(nodes), Anode(nodes)
35  enddo
36  10 continue
37 ! write(*, *) " # of nodal points =", nodes, ' mostz', mostz
38 
39  do i=1, nodes-1
40  if(anode(i) .ne. 0.) then
41  fd1i(i) = fd1(znode(i+1), anode(i), znode(i),
42  * scalehnode(i))
43  rhopnode(i) = rhonode(i) *(-1.d0 -1.d0/anode(i)) *
44  * anode(i)/scalehnode(i)
45  pwp(i) =-2.d0-1.d0/anode(i)
46  else
47  fd0i(i) = fd0( znode(i+1), znode(i), scalehnode(i) )
48  endif
49  enddo
50  endif
51  end
52 ! *********************************
53  real*8 function cvh2den(z)
54 ! *********************************
55 ! gives density of air at a given vertical height.
56 
57 !
58  implicit none
59 #include "Zatmos.h"
60 
61  real*8 z ! input. vertical height in m
62 ! function value: density in kg/m3.
63  integer i
64 
65  if( z .ge. znode(mostz) .and. z .lt. znode(mostz+1)) then
66  i = mostz
67  elseif( z .ge znode(mostz + 1) .and. z .lt. znode(mostz+2) then
68  i = mostz + 1
69  else
70  do i = mostz, 2, -1
71  if(z .ge. znode(i-1) .and. z .lt. znode(i)) then
72  goto 100
73  endif
74  enddo
75  call kdwhereis(z, nodes, znode, 1, i)
76  if(i .eq. 0) then
77  call cerrormsg('height becomes too small ', 0)
78  endif
79  endif
80  100 continue
81  if(anode(i) .ne. 0.)then
82  cvh2den =
83  * rhonode(i) *
84  * (1.0 + anode(i)*
85  * (z-znode(i))/scalehnode(i) )**(-1.0-1.d0/anode(i))
86  else
87  cvh2den =
88  * rhonode(i) * exp(- (z-znode(i))/scalehnode(i))
89  endif
90  end
91 ! *************************
92  real*8 function cvh2thick(z)
93 ! vertical height to thickness of air above that point.
94 ! z: input. vertical height in m
95 ! function value. output. thickness in kg/m2.
96 !
97 !
98  implicit none
99 #include "Zearth.h"
100 #include "Zstdatmos.h"
101 #include "Zatmos.h"
102 
103  real*8 z ! input
104  integer i
105 
106 #include "Zstdatmosf.h"
107 
108 
109 ! The gramage between given heights, z1 and z2 is by
110 !
111 ! d = D0node *(fd(z1) - fd(z2)) where
112 !
113 ! fd(z) = (1+ a(z-z0)/H(z0))**(-1/a) (a != 0)
114 !
115 ! = exp(-(z-z0)/H ) (a = 0)
116 
117  if( z .ge. znode(mostz) .and. z .lt. znode(mostz+1)) then
118  i = mostz
119  elseif( z .ge znode(mostz + 1) .and. z .lt. znode(mostz+2) then
120  i = mostz + 1
121  else
122  do i = mostz, 2, -1
123  if(z .ge. znode(i-1) .and. z .lt. znode(i)) then
124  goto 100
125  endif
126  enddo
127  call kdwhereis(z, nodes, znode, 1, i)
128  if(i .eq. 0) then
129  call cerrormsg('height becomes too small ', 0)
130  endif
131  endif
132  100 continue
133 
134  if(anode(i) .ne. 0.)then
135  cvh2thick = dsumnode(i) -
136  * d0node(i) * (
137  * 1.0- fd1(z, anode(i), znode(i), scalehnode(i))
138  * )
139  else
140  cvh2thick = dsumnode(i) +
141  * d0node(i) * (1. -
142  * fd0(z, znode(i), scalehnode(i) )
143  * )
144  endif
145  end
146 ! *************************
147  real*8 function cvthick2h(t)
148 ! vertical thickness to vertical height conversion
149 ! t: input. vertical tikness in kg/m2
150 ! function value. output. height in m.
151 !
152 !
153  implicit none
154 #include "Zatmos.h"
155 
156  integer i
157 
158  real*8 t, temp
159 
160 
161  if( z .ge. znode(mostz) .and. z .lt. znode(mostz+1)) then
162  i = mostz
163  elseif( z .ge znode(mostz + 1) .and. z .lt. znode(mostz+2) then
164  i = mostz + 1
165  else
166  do i = mostz, 2, -1
167  if(z .ge. znode(i-1) .and. z .lt. znode(i)) then
168  goto 100
169  endif
170  enddo
171  call kdwhereis(z, nodes, znode, 1, i)
172  if(i .eq. 0) then
173  call cerrormsg('height becomes too small ', 0)
174  endif
175  endif
176  100 continue
177 
178  if(anode(i) .ne. 0. )then
179 ! cvh2thick = Dsumnode(i) -
180 ! * D0node(i) * (
181 ! * 1.0- fd1(z, Anode(i), Znode(i), Scalehnode(i))
182 ! * )
183 ! solve above eq.
184  temp =1.0 - (dsumnode(i) - t )/d0node(i)
185 
186  cvthick2h = (1.0 - temp**(-anode(i)))*
187  * scalehnode(i)/anode(i) + znode(i)
188  else
189 ! t = Dsumnode(i) +
190 ! * D0node(i) * (1. -
191 ! * fD0(z, Znode(i), Scalehnode(i) )
192 ! * )
193 ! solve above eq.
194  temp =1.0- (t -dsumnode(i)) /d0node(i)
195 ! temp = exp(-(z-z0)/H )
196  cvthick2h =znode(i)- log(temp)*scalehnode(i)
197  endif
198  end
199 ! *********************************
200  real*8 function cvh2denp(z)
201 ! *********************************
202 ! gives derivative of the density of
203 ! air at a given vertical height.
204 ! h: vertical height in m
205 ! function value: dRhonode/dz density in kg/m4
206 !
207  implicit none
208 c---- include 'Zearth.h'
209 #include "Zearth.h"
210 c---- include 'Zstdatmos.h'
211 #include "Zstdatmos.h"
212 !
213  integer i
214 
215  real*8 z
216 
217 
218  if( z .ge. znode(mostz) .and. z .lt. znode(mostz+1)) then
219  i = mostz
220  elseif( z .ge znode(mostz + 1) .and. z .lt. znode(mostz+2) then
221  i = mostz + 1
222  else
223  do i = mostz, 2, -1
224  if(z .ge. znode(i-1) .and. z .lt. znode(i)) then
225  goto 100
226  endif
227  enddo
228  call kdwhereis(z, nodes, znode, 1, i)
229  if(i .eq. 0) then
230  call cerrormsg('height becomes too small ', 0)
231  endif
232  endif
233  100 continue
234 
235  if(anode(i) .ne. 0.)then
236  cvh2denp =
237 ! * Rhonode(i-1) *(-1.D0node -1.D0node/Anode(i-1)) *
238 ! * Anode(i-1)/Scalehnode(i-1) * = Rhonodep(i)
239  * rhopnode(i) *
240  * (1.d0 + anode(i)*
241 ! * (z-Znode(i))/Scalehnode(i) )**(-2.d0-1.d0/Anode(i))
242  * (z-znode(i))/scalehnode(i) )**pwp(i)
243  else
244  cvh2denp =
245  * -rhonode(i) * exp(- (z-znode(i))/scalehnode(i))
246  * /scalehnode(i)
247  endif
248  end
249 ! *********************************
250  real*8 function cvh2den2p(z)
251 ! *********************************
252 ! gives double derivative of the density of
253 ! air at a given vertical height.
254 ! h: vertical height in m
255 ! function value: d (dRhonode/dz)/dz density in kg/m5
256 !
257  implicit none
258 c---- include 'Zearth.h'
259 #include "Zearth.h"
260 c---- include 'Zstdatmos.h'
261 #include "Zstdatmos.h"
262 !
263  integer i
264 
265  real*8 z
266 
267  if(first) call cstdatmos0
268 
269 ! check if z < 11.2km
270  if(z .lt. znode(2)) then
271  cvh2den2p = rhonode00 * pw*(pw-1.d0node)/hl/hl
272  * * ( (ha - z)/hl )**(pw-2.d0node)
273  else
274  do i = 3, nodes
275  if(z .lt. znode(i) .or. i .eq. nodes ) then
276  if(anode(i-1) .ne. 0.)then
277  cvh2den2p =
278  * rhonodep(i) * pwp(i) *anode(i-1)/scalehnode(i-1)*
279  * (1.d0node + anode(i-1)*
280  * (z-znode(i-1))/scalehnode(i-1) )**(pwp(i)-1.d0node)
281  goto 10
282  else
283  cvh2den2p =
284  * rhonode(i-1) * exp(- (z-znode(i-1))/scalehnode(i-1))
285  * /scalehnode(i-1)**2
286  goto 10
287  endif
288  endif
289  enddo
290  10 continue
291  endif
292  end
293 
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
nodes z
real *8 function cvthick2h(t)
Definition: ciniSegAtoms.f:148
real *8 function cvh2denp(z)
Definition: ciniSegAtoms.f:201
subroutine kdwhereis(x, in, a, step, loc)
Definition: kdwhereis.f:27
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon true
Definition: cblkElemag.h:7
subroutine cinisegatmos
Definition: ciniSegAtoms.f:2
! common for std atmosphere real *AlmostVacH ! almost vacuum height real *AlmostVacT ! thickness there hl
Definition: Zstdatmos.h:7
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
subroutine copenf(io, fnin, icon)
Definition: copenf.f:8
real *8 function cvh2den2p(z)
Definition: ciniSegAtoms.f:251
! common for std atmosphere real *AlmostVacH ! almost vacuum height real *AlmostVacT ! thickness there hlhmi common comstdatm ha
Definition: Zstdatmos.h:7
real *8 function cvh2den(z)
Definition: ciniSegAtoms.f:54
subroutine cstdatmos0
! to be included just before the execution code ! density as a function of height real * fd1
Definition: Zstdatmosf.h:3
subroutine cskipcomment(io, icon)
Definition: cskipComment.f:19
real *8 function cvh2thick(z)
Definition: ciniSegAtoms.f:93