-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathopencount.f
147 lines (146 loc) · 4.18 KB
/
opencount.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
subroutine opencount(maxev)
implicit none
include 'pwhg_rnd.h'
integer maxev
character * 30 file
character * 20 pwgprefix
integer lprefix
common/cpwgprefix/pwgprefix,lprefix
integer ios
character * 7 string
real * 8 powheginput
external powheginput
integer nev,j,iun,iret
common/copencount/iun
maxev=0
file='pwgevents.lhe'
call pwhg_io_open_read(trim(file),iun,ios)
c open(unit=iun,file=file,status='old',iostat=ios)
if(ios.ne.0) then
do j=30,0,-1
if(file(j:j).ne.' ') exit
enddo
write(*,*)' file not found:',file(1:j)
write(*,*)' enter name of event file'
read(*,'(a)') file
call pwhg_io_open_read(trim(file),iun,ios)
c open(unit=iun,file=file,status='old',iostat=ios)
if(ios.ne.0) then
write(*,*) 'cannot open; aborting ...'
call exit(-1)
endif
c get the name prefix
j=index(file,'events')
if(j.gt.1) then
pwgprefix=file(1:j-1)
lprefix=j-1
else
lprefix=0
endif
c or a sequence number for manyseeds usage
if(file(j+6:j+6).eq.'-') then
rnd_cwhichseed=file(j+7:j+10)
else
rnd_cwhichseed='none'
endif
else
pwgprefix='pwg'
lprefix=3
rnd_cwhichseed='none'
endif
write(*,*) 'prefix: "'//pwgprefix(1:lprefix)//'",', ' seed: "'//
1 rnd_cwhichseed//'"'
c
write(*,*) ' Opened event file ',file
write(*,*) ' Counting events in ', file
write(*,*) ' This may take some time...'
1 continue
call pwhg_io_read(iun,string,iret)
if(iret /= 0) goto 2
c read(unit=iun,fmt='(a)',end=2) string
if(string.eq.'</event') then
maxev=maxev+1
goto 1
endif
goto 1
2 continue
write(*,*) ' Found ',maxev,' events in file ',file
if (maxev.eq.0) then
write(*,*) ' NO EVENTS!! Program exits'
call exit(3)
endif
call pwhg_io_rewind(iun)
end
subroutine opencountunit(maxev,iun)
implicit none
include 'pwhg_rnd.h'
integer maxev,iun
character * 30 file
character * 20 pwgprefix
integer lprefix
common/cpwgprefix/pwgprefix,lprefix
integer ios
character * 7 string
real * 8 powheginput
external powheginput
integer nev,j
call newunit(iun)
maxev=0
file='pwgevents.lhe'
call pwhg_io_open_read(trim(file),iun,ios)
c open(unit=iun,file=file,status='old',iostat=ios)
if(ios.ne.0) then
do j=30,0,-1
if(file(j:j).ne.' ') exit
enddo
write(*,*)' file not found:',file(1:j)
write(*,*)' enter name of event file'
read(*,'(a)') file
call pwhg_io_open_read(trim(file),iun,ios)
c open(unit=iun,file=file,status='old',iostat=ios)
if(ios.ne.0) then
write(*,*) 'cannot open; aborting ...'
call exit(-1)
endif
c get the name prefix
j=index(file,'events')
if(j.gt.1) then
pwgprefix=file(1:j-1)
lprefix=j-1
else
lprefix=0
endif
c or a sequence number for manyseeds usage
if(file(j+6:j+6).eq.'-') then
rnd_cwhichseed=file(j+7:j+10)
else
rnd_cwhichseed='none'
endif
else
pwgprefix='pwg'
lprefix=3
rnd_cwhichseed='none'
endif
write(*,*) 'prefix: "'//pwgprefix(1:lprefix)//'",', ' seed: "'//
1 rnd_cwhichseed//'"'
c
write(*,*) ' Opened event file ',file
write(*,*) ' Counting events in ', file
write(*,*) ' This may take some time...'
1 continue
call pwhg_io_read(iun,string,ios)
if(ios /= 0) goto 2
c read(unit=iun,fmt='(a)',end=2) string
if(string.eq.'</event') then
maxev=maxev+1
goto 1
endif
goto 1
2 continue
write(*,*) ' Found ',maxev,' events in file ',file
if (maxev.eq.0) then
write(*,*) ' NO EVENTS!! Program exits'
call exit(3)
endif
call pwhg_io_rewind(iun)
end