COSMOS v7.655  COSMOSv7655
(AirShowerMC)
procLat0.f
Go to the documentation of this file.
1 !
2 ! read binary or ascii lateral histogram file and
3 ! analyse it: produces stdout with
4 ! faiidx, code, layer
5 ! r 2pir*rho
6 ! r 2pir*rho
7 ! ...
8 ! 0 0
9 ! next fai...
10 ! r 2pir*rho
11 ! ..
12 ! usage:
13 ! compile: make -f procLat.mk
14 ! see message by procLat
15 
16  implicit none
17  integer binorascii, reduced, nfraca
18  integer count, status
19  character*80 buf
20 ! get filename from command line argument
21  count = nargs()
22 
23  if(count .ne. 3) then
24  write(0,*) " ProcLat: ./procLat$ARCH",
25  * " bin input-r.hist"
26  write(0,*) " bin=1-->input is ascii file"
27  write(0,*) " bin=2--> binary file"
28  write(0,*)
29  * " filename: path to the input -r.hist file(<256 chars)"
30  stop 132
31  endif
32  call getarg(1, buf, status)
33  read(buf,*) binorascii
34  if(binorascii .ne. 1 .and. binorascii.ne. 2) then
35  write(0,*) ' error input to binOrascii=',binorascii
36  stop 444
37  endif
38 
39  if(binorascii .eq. 1) then
40 ! ascii file
41  call proclatascii
42  else
43 ! bin file
44  call proclatbin
45  endif
46  end
47 
48  subroutine proclatbin
49  implicit none
50 #include "../ZprivateSub.h"
51 #include "../../../Hist/Z90histc.h"
52 #include "../../../Hist/Z90histo.h"
53 #include "../../../Hist/Z90hist1.h"
54  character*80 buf
55  type(histogram1) h10 ! 1D histogram area
56 
57  character*6 histid0 ! get histogram id here
58  integer icon
59  real normf
60  data normf/-1.0/ ! use normalization as already done
61  integer ansites
62  data ansites/1/ ! number of layers where histogram was taken
63  integer fnoT/31/ ! file number.
64  character*256 filename
65 
66  integer ir, ifai
67  integer code
68  integer nbinhisto, status
69  integer kwhistReadAscii
70  integer i
71  integer klena
72  external klena
73  save
74 
75  call getarg(2, filename, status)
76 ! write(0,*) ' status=',status
77 ! write(0,*) 'file=',filename(1:klena(filename))
78 
79  open(fnot, file=filename,
80  * iostat=status, access='sequential',
81  * form='unformatted', action='read')
82  if(status .ne. 0 ) then
83  write(0,*) ' cannot open file ='
84  write(0,*) filename
85  stop 123
86  else
87 ! write(0,*) filename(1:klena(filename)),
88 ! * ' opened'
89  endif
90 
91 ! web sector region
92  do i = 1, ansites
93  do code = 1, 4
94  do ifai= 1, nfai
95  read( fnot, end=100 ) histid0
96  if( histid0 .ne. '#hist1' ) then
97  write(0,*) ' histogram is not 1-D: ',histid0
98  stop 111
99  endif
100  call kwhistr(h10, fnot, icon)
101 ! statistical calculation
102  call kwhists(h10, normf)
103 ! lat analysis
104  call proclat(h10, ifai, code, i)
105 ! deallocate
106  call kwhistd( h10 )
107  enddo
108  enddo
109  enddo
110  close(fnot)
111  return
112  100 continue
113  write(0,*) ' unexpected EOF '
114  stop 2345
115 ! **********************
116  entry proclatascii
117 ! **********************
118  call getarg(2, filename, status)
119 ! write(0,*) ' status=',status
120 ! write(0,*) 'file=',filename(1:klena(filename))
121 
122  open(fnot, file=filename,
123  * iostat=status, access='sequential',
124  * form='formatted', action='read')
125  if(status .ne. 0 ) then
126  write(0,*) ' cannot open file ='
127  write(0,*) filename
128  stop 222
129  else
130 ! write(0,*) filename(1:klena(filename)),
131 ! * ' opened '
132  endif
133 
134 
135  do i = 1, ansites
136  do code = 1, 4
137  do ifai= 1, nfai
138  nbinhisto=kwhistreadascii(h10, fnot)
139  if(nbinhisto .le. 0 ) then
140  write(0,*) ' ascii read failed'
141  stop 333
142  else
143 ! write(0,*) ' hist data =',nbinhisto
144  endif
145 ! call kwhistr(h10, fnoT, icon)
146 ! statistical calculation
147  call kwhists(h10, normf)
148 ! lat analysis
149  call proclat(h10, ifai, code, i)
150 ! deallocate
151  call kwhistd( h10 )
152  enddo
153  enddo
154  enddo
155  close(fnot)
156  end
void kwhistd(struct histogram1 *h)
subroutine proclat(h, idxf, code, layer)
Definition: procLat.f:4
subroutine proclatbin
Definition: procLat0.f:41
void kwhistr(struct histogram1 *h, FILE *bfnor, int icon)
void kwhists(struct histogram1 *h, float inorm)
! timing nfai
Definition: Zprivate2.h:12