COSMOS v7.655  COSMOSv7655
(AirShowerMC)
ascii2bin.f
Go to the documentation of this file.
1  program main
2  use modhistogram1
3  implicit none
4 
5  type(histogram1) h1
6 
7  integer klena
8  real normf
9  data normf/-1.0/ ! use normalization as already done
10  integer fnoI/31/, fnoO/32/ ! file number.
11  character*256 filename, Ofilename
12  integer kwhistReadAscii
13  integer status
14  integer filel
15  integer count
16  integer nbinhisto
17 !
18 ! read ascii 1-D histogram file and convert is to
19 ! a binary hist file
20 ! usage:
21 ! compile: make -f ascii2bin.mk
22 !
23 !
24 ! get filename from command line argument
25  count = nargs()
26 
27  if(count .ne. 2) then
28  write(0,*)
29  * " ascii2bin: convert 1D ascii histogram into binary histo"
30  write(0,*) "Usage: ./ascii2bin$ARCH asciiInputFile "
31  write(0,*) " asciiInputFile: its extension must be .ahist"
32  write(0,*) " If input is xxx.ahist, then output file name "
33  write(0,*) " is made to be ***** xxxx.hist **** "
34  stop 100
35  endif
36 
37  call getarg(1, filename, status)
38  filel = klena(filename)
39  write(0,*) status, filename(1:filel)
40  if(filel .le. 5 .or.
41  * filename(filel-5:filel) .ne. ".ahist" ) then
42  write(0,*) "input file name extension must be .ahist"
43  stop 111
44  endif
45  open(fnoi, file=filename,
46  * iostat=status, access='sequential',
47  * form='formatted', action='read')
48  if(status .ne. 0 ) then
49  write(0,*) ' cannot open file ='
50  write(0,*) filename
51  stop 222
52  endif
53  ofilename = filename(1:filel-6)//".hist"
54  open(fnoo, file=ofilename,
55  * iostat=status, access='sequential',
56  * form='unformatted', action='write')
57  if(status .ne. 0 ) then
58  write(0,*) "could not open file"
59  write(0,*) ofilename
60  stop 333
61  endif
62 
63  do while ( .true. )
64 ! alloc h1 and read
65  nbinhisto=kwhistreadascii(h1, fnoi)
66  if(nbinhisto .le. 0 ) exit
67 ! not needed ?
68  call kwhists(h1, normf)
69 ! write h1
70  call kwhistw(h1, fnoo)
71 ! dealloc h1
72  call kwhistd( h1)
73  enddo
74  close(fnoi)
75  close(fnoo)
76  end
void kwhistd(struct histogram1 *h)
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
program main
Definition: ascii2bin.f:1
void kwhists(struct histogram1 *h, float inorm)
void kwhistw(struct histogram1 *h, FILE *bfnow)