COSMOS v7.655  COSMOSv7655
(AirShowerMC)
cstack.f
Go to the documentation of this file.
1 ! stacking tracking information
2 !
3  subroutine cpush(a)
4  implicit none
5 #include "Zmaxdef.h"
6 #include "Ztrack.h"
7 #include "Zstackv.h"
8 #include "Zevhnv.h"
9  type(track)::a
10  character*70 msg
11 
12 !
13 ! call cifDead(a, icon) ! this is moved to after cpop.
14 ! ! so some ptcl may be stored even if
15 ! ! low energy.
16 ! if(icon .eq. 0) then
17  if( a%p%code /= 0) then
18  if( stack_pos .ge. max_stack_size) then
19  write(msg,*) 'stack area full=',max_stack_size
20  call cerrormsg(msg, 0)
21  else
22  stack_pos = stack_pos + 1
23  stack(stack_pos) = a
24  endif
25  else
26 ! although very rare, 0 code appears; neglect it (once /5 days)
27 
28  write(0,*) ' code=0 appeared subcode=',a%p%subcode
29  write(0,*) ' charge=',a%p%charge
30  write(0,*) ' px,py, pz, E, mass=',a%p%fm%p(1:4), a%p%mass
31  write(0,*) ' neglected for stacking in cstack.f'
32  write(0,*) 'ActiveMdl=',activemdl
33 !c call checkstat("in cpush")
34  endif
35  end
36 !------------------------------------------------------------
37  subroutine cpop(a, remain)
38  implicit none
39 #include "Zmaxdef.h"
40 #include "Ztrack.h"
41 #include "Zstackv.h"
42  type(track)::a
43 
44  integer remain
45 !
46 ! remain: int. is the number of ptcls remaining unprocessed
47 ! including the current one to be processed now.
48  if( stack_pos .le. 0) then
49  remain = 0
50  else
51  remain = stack_pos
52  a = stack(stack_pos)
53  stack_pos = stack_pos -1
54  endif
55  end
56  subroutine cgetstacked(stackpos, aTrack, icon)
57  implicit none
58 #include "Zmaxdef.h"
59 #include "Ztrack.h"
60 #include "Zstackv.h"
61  integer stackpos ! input. stack pos from which track is
62  ! to be extracted.
63  type(track)::aTrack ! output extracted track.
64  integer icon ! output. 0 OK 1--> no. track at stackpos
65 ! diff. from cpop; Stack_pos is not affected.
66  if(stackpos .le. stack_pos .and. stackpos .ge. 1) then
67  atrack = stack(stackpos)
68  icon = 0
69  else
70  icon = 1
71  endif
72  end
73 
74 !---------------------------------------------------------
75  subroutine cinitstack
76 ! initialize stack.
77  implicit none
78 #include "Zmaxdef.h"
79 #include "Ztrack.h"
80 #include "Zstackv.h"
81  stack_pos = 0
82  end
83  subroutine cgetcurrentstackpos(stackpos)
84  implicit none
85 #include "Zmaxdef.h"
86 #include "Ztrack.h"
87 #include "Zstackv.h"
88  integer stackpos
89  stackpos=stack_pos
90  end
91  subroutine cresetstackpos(stackpos)
92  implicit none
93 #include "Zmaxdef.h"
94 #include "Ztrack.h"
95 #include "Zstackv.h"
96  integer stackpos
97  stack_pos=stackpos
98  end
99 
100 
101  subroutine csortstack
102 ! sort stack dscending order
103  implicit none
104 #include "Zmaxdef.h"
105 #include "Ztrack.h"
106 #include "Zstackv.h"
107  real*8 erg(max_stack_size)
108  type(track)::sorted(max_stack_size)
109  integer idx(max_stack_size)
110 
111  integer i, j, k
112  type(track)::temp
113  do i = 1, stack_pos
114  erg(i) = stack(i)%p%fm%p(4)
115  enddo
116 
117  call kqsortd(erg, idx, stack_pos)
118  call ksortinv(idx, stack_pos)
119 
120  do i = 1, stack_pos
121  sorted(i) = stack(idx(i))
122  enddo
123 
124  do i = 1, stack_pos
125  stack(i) = sorted(i)
126  enddo
127  end
128 
129 
130 
131 
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
Definition: Ztrack.h:44
subroutine cpop(a, remain)
Definition: cstack.f:38
subroutine cinitstack
Definition: cstack.f:76
subroutine kqsortd(A, ORD, N)
Definition: kqsortd.f:23
subroutine ksortinv(idx, n)
Definition: ksortinv.f:2
subroutine cgetstacked(stackpos, aTrack, icon)
Definition: cstack.f:57
subroutine csortstack
Definition: cstack.f:102
subroutine cresetstackpos(stackpos)
Definition: cstack.f:92
subroutine cpush(a)
Definition: cstack.f:4
subroutine cgetcurrentstackpos(stackpos)
Definition: cstack.f:84