COSMOS v7.655  COSMOSv7655
(AirShowerMC)
readAndput.f
Go to the documentation of this file.
1 
2 ! this part is used only by rank 0
3 ! to read .dat created by each rank and reduce it
4 ! and to store data as a single file
5  limit(1) = reallimitg
6  limit(2) = reallimite
7  limit(3) = reallimitmu
8  limit(4) = reallimith
9 
10  do k = 1, ansites
11  do j = 1, 4
12  do l = 1,nfai
13  do i = 1, nrbin
14  nrfairec(i, l, j, k)=0
15  enddo
16  enddo
17  enddo
18  enddo
19 ! single file to store combined all .dat
20  msg=' '
21  msg =dir(1:lengdir)//"/"//execid(1:lengid)//".dat"
22 !///////////
23  write(0,*) ' asking main file opening'
24 !///////
25  call copenfw2(fnodat+1, msg, 1, icon)
26  if(icon .gt. 1) then
27  write(0,*) ' icon=', icon
28  call cerrormsg(msg, 1)
29  call cerrormsg('could not be opened', 0)
30  endif
31 
32  do rankc = 1, mpisize
33  rank = rankc -1
34  write(numbr, '("rank-",i5)') rank
35  call kseblk(numbr, '{', lengnr)
36  msg = ' '
37  msg =dir(1:lengdir)//"/"//execid(1:lengid)//
38  * "-@."//numbr(1:lengnr)//".dat"
39  call copenfw2(fnodat, msg, 2, icon)
40  if(icon .gt. 1) then
41  write(0,*) ' icon=', icon
42  call cerrormsg(msg, 1)
43  call cerrormsg('could not be opened', 0)
44  endif
45 
46  do while(.true.)
47  read(fnodat,end=100) bufc, (buf(i), i=1, bufc)
48  do i = 1, bufc
49 
50  ldep = buf(i).ldep
51  depidx = w2il(ldep)
52  faiidx= buf(i).faiidx
53  ridx = buf(i).ridx
54  codex = buf(i).code
55  codex = min(codex, 4)
56  wgt = buf(i).wgt
57  if( nrfaireca(ridx, faiidx, codex, depidx) .gt.
58  * limit(codex) ) then
59 ! accept with this prob.
60  prob = limit(codex)/
61  * nrfaireca(ridx, faiidx, codex, depidx)
62 
63  else
64  prob = 1.0
65  endif
66 
67  if( prob .gt. 1.) then
68  wwgt = wgt
69  accept = .true.
70  else
71  prob = prob * wgt
72  if(prob .gt. 1.) then
73  accept = .true.
74  wwgt = prob
75  else
76  call rndc(u)
77  if(u .lt. prob) then
78  accept = .true.
79  wwgt= 1.
80  else
81  accept = .false.
82  endif
83  endif
84  endif
85  if(accept) then
86  nrfairec(ridx, faiidx, codex, depidx)=
87  * nrfairec(ridx, faiidx, codex, depidx) + wwgt
88  if(keepweight) then
89  write(fnodat+1,
90  * '(6i3, 1pE11.3, 0p,f6.1,1p2E11.3,0p, 2f8.4,f10.6,1pE11.3)')
91  * buf(i).ldep, buf(i).code, buf(i).subcode,
92  * buf(i).charge, buf(i).ridx, buf(i).faiidx,
93  * buf(i).rinmu, buf(i).fai, buf(i).ek,
94  * buf(i).t, buf(i).wx, buf(i).wy, buf(i).wz,
95  * wwgt
96  else
97  write(fnodat+1,
98  * '(6i3, 1pE11.3, 0p,f6.1,1p2E11.3,0p, 2f8.4,f10.6)')
99  * buf(i).ldep, buf(i).code, buf(i).subcode,
100  * buf(i).charge, buf(i).ridx, buf(i).faiidx,
101  * buf(i).rinmu, buf(i).fai, buf(i).ek,
102  * buf(i).t, buf(i).wx, buf(i).wy, buf(i).wz
103  endif
104  endif
105  enddo
106  enddo
107  100 continue
108  close(fnodat)
109  enddo ! all rank end
110  close(fnodat+1)
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
nodes i
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 rndc(u)
Definition: rnd.f:91
integer mpisize
Definition: Zmpibasic.h:1
! timing nrbin
Definition: Zprivate2.h:12
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
subroutine copenfw2(io, fnin, form, icon)
Definition: copenf.f:205
*Zfirst p fm *Zfirst p Zfirst p code
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p charge
Definition: ZavoidUnionMap.h:1
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 ! knockon is considered Obsolete *PhotoProd false
Definition: cblkElemag.h:7
nodes t
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos Zfirst pos *Zfirst pos *Zfirst Zfirst vec w *Zfirst vec w Zfirst vec *Zfirst wgt
Definition: ZavoidUnionMap.h:1
subroutine kseblk(text, c, lc)
Definition: kseblk.f:18
! timing nfai
Definition: Zprivate2.h:12
*Zfirst p fm *Zfirst p Zfirst p Zfirst p subcode
Definition: ZavoidUnionMap.h:1