COSMOS v7.655  COSMOSv7655
(AirShowerMC)
getBasicHistoInfo.f
Go to the documentation of this file.
1 ! This is diff. from the one for "time".
2 ! Assume only 1 layer is contained in the -r.hist file
3 ! If multi layers are contained, need a lot of modification
4 !
5 ! read binary or ascii r histogram file and
6 ! get basic information: evid and write it in a
7 ! given file.
8 ! usage: make -f getBasicHistoInfo.mk
9 ! ./getBasicHistoInfo binOrascii filename tempfile
10 !
11 ! where binOrascii is 1 for ascii input file
12 ! 2 for binary //
13 ! filenname is path to the input histogram file
14 ! (<256 char)
15 ! tempfle: for memo to be used later.
16  implicit none
17  integer binorascii
18  integer count, status
19  character*80 buf
20 
21  count = nargs()
22  if(count .ne. 4) then
23  write(0,*)
24  * " must give bin filename tempfile as arguments"
25  write(0,*) " bin=1-->input is ascii file"
26  write(0,*) " bin=2--> binary file"
27  write(0,*) " filename: path to the input file"
28  write(0,*) " tempfile: path to the temporary working file"
29  write(0,*) " "
30  write(0,*) " you gave ", count-1, " arguments"
31  call getarg(1, buf, status)
32  write(0,*) " The first one was ", buf
33  stop 111
34  endif
35  call getarg(1, buf, status)
36  read(buf,*) binorascii
37  if(binorascii .ne. 1 .and. binorascii.ne. 2) then
38  write(0,*) ' error input to binOrascii=',binorascii
39  stop 111
40  endif
41 
42 
43  if(binorascii .eq. 1) then
44 ! ascii file
45  call proclatascii
46  else
47 ! bin file
48  call proclatbin
49  endif
50  end
51 
52  subroutine proclatbin
53  implicit none
54 #include "../ZprivateSub.h"
55 #include "../../../Hist/Z90histc.h"
56 #include "../../../Hist/Z90histo.h"
57 #include "../../../Hist/Z90hist1.h"
58  character*80 buf
59 
60  type(histogram1) h10 ! 1D histogram area
61 
62  character*6 histid0 ! get histogram id here
63  integer icon
64  real normf
65  data normf/-1.0/ ! use normalization as already done
66  integer ansites
67  data ansites/1/ ! number of layers where histogram was taken
68  integer fnoT/31/ ! file number for hist
69  integer fnoW/32/ ! file number for working
70  character*256 filename, tempfile
71 
72  integer ir, ifai
73  integer code
74  integer nbinhisto, mode, status
75  integer kwhistReadAscii
76  integer i
77 
78 
79  call getarg(2, filename, status)
80 ! write(0,*) status, filename
81  call getarg(3, tempfile, status)
82 
83  open(fnot, file=filename,
84  * iostat=status, access='sequential',
85  * form='unformatted', action='read')
86  if(status .ne. 0 ) then
87  write(0,*) ' cannot open file ='
88  write(0,*) filename
89  stop 111
90  endif
91  open(fnow, file=tempfile,
92  * iostat=status, access='sequential',
93  * form='formatted', action='write')
94  if(status .ne. 0 ) then
95  write(0,*) ' cannot open file ='
96  write(0,*) tempfile
97  stop 222
98  endif
99 
100  do i = 1, ansites
101  do code = 1, 4
102  do ifai= 1, nfai
103  read( fnot, end=100 ) histid0
104  if( histid0 .ne. '#hist1' ) then
105  write(0,*) ' histogram is not 1-D: ',histid0
106  stop 111
107  endif
108  call kwhistr(h10, fnot, icon)
109  write(fnow,'(a)') h10%c%id
110 ! deallocate
111  call kwhistd( h10 )
112  close(fnow)
113  close(fnot)
114  return ! *********
115  enddo
116  enddo
117  enddo
118  return
119  100 continue
120  write(0,*) ' unexpected EOF '
121  stop 2345
122 ! **********************
123  entry proclatascii
124 ! **********************
125 
126  call getarg(2, filename, status)
127 ! write(0,*) status, filename
128  call getarg(3, tempfile, status)
129  open(fnot, file=filename,
130  * iostat=status, access='sequential',
131  * form='formatted', action='read')
132  if(status .ne. 0 ) then
133  write(0,*) ' cannot open file ='
134  write(0,*) filename
135  stop 111
136  endif
137  open(fnow, file=tempfile,
138  * iostat=status, access='sequential',
139  * form='formatted', action='write')
140  if(status .ne. 0 ) then
141  write(0,*) ' cannot open file ='
142  write(0,*) tempfile
143  stop 111
144  endif
145 
146 ! web sector region
147  do i = 1, ansites
148  do code = 1, 4
149  do ifai= 1, nfai
150  nbinhisto=kwhistreadascii(h10, fnot)
151  if(nbinhisto .le. 0 ) then
152  write(0,*) ' ascii read failed'
153  stop 111
154  endif
155  write(fnow,'(a)') h10%c%id
156 ! deallocate
157  call kwhistd( h10 )
158  close(fnow)
159  close(fnot)
160  return ! *********
161  enddo
162  enddo
163  enddo
164  end
void kwhistd(struct histogram1 *h)
subroutine proclatbin
Definition: procLat0.f:41
void kwhistr(struct histogram1 *h, FILE *bfnor, int icon)
! timing nfai
Definition: Zprivate2.h:12