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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
c************************************************************************
c** **
c** MadGraph/MadEvent Interface to FeynRules **
c** **
c** C. Duhr (Louvain U.) - M. Herquet (NIKHEF) **
c** **
c************************************************************************
c *************************************************************************
c ** **
c ** LHA format reading routines **
c ** **
c *************************************************************************
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c ++
c ++ LHA_islatin -> islatin=true if letter is a latin letter
c ++
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine LHA_islatin(letter,islatin)
implicit none
logical islatin
character letter
character*26 ref
integer i
islatin=.false.
ref='abcdefghijklmnopqrstuvwxyz'
call LHA_case_trap(letter)
do i=1,26
if(letter .eq. ref(i:i)) islatin=.true.
end do
end
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c ++
c ++ LHA_isnum -> isnum=true if letter is a number
c ++
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine LHA_isnum(letter,isnum)
implicit none
logical isnum
character letter
character*10 ref
integer i
isnum=.false.
ref='1234567890'
do i=1,10
if(letter .eq. ref(i:i)) isnum=.true.
end do
end
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c ++
c ++ LHA_firststring -> first is the first "word" of string
c ++ Warning: string is returned with first REMOVED!
c ++
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine LHA_firststring(first,string)
implicit none
character*(*) string
character*(*) first
if(len_trim(string).le.0) return
do while(string(1:1) .eq. ' ')
string=string(2:len(string))
end do
if (index(string,' ').gt.1) then
first=string(1:index(string,' ')-1)
string=string(index(string,' '):len(string))
else
first=string
end if
end
subroutine LHA_case_trap(name)
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c ++
c ++ LHA_case_trap -> change string to lower case
c ++
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
implicit none
character*20 name
integer i,k
do i=1,20
k=ichar(name(i:i))
if(k.ge.65.and.k.le.90) then !upper case A-Z
k=ichar(name(i:i))+32
name(i:i)=char(k)
endif
enddo
return
end
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c ++
c ++ LHA_blockread -> read a LHA line and return parameter name (evntually found in
c ++ a ref file) and value
c ++
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine LHA_blockread(blockname,buff,par,val,found)
implicit none
character*132 buff,buffer,curr_ref,curr_buff
character*20 blockname,val,par,temp,first_ref,first_line
logical fopened
integer ref_file/20/
logical islast,isnum,found
character*20 temp_val
c *********************************************************************
c Try to find a correspondance in ident_card
c
call LHA_open_file(ref_file,'ident_card.dat',fopened)
if(.not. fopened) goto 99 ! If the file does not exist -> no matter, use default!
islast=.false.
found=.false.
do while(.not. found)!run over reference file
! read a line
read(ref_file,'(a132)',end=99,err=99) buffer
! Seek a corresponding blockname
call LHA_firststring(temp,buffer)
call LHA_case_trap(temp)
if(temp .eq. blockname) then
! Seek for a corresponding LHA code
curr_ref=buffer
curr_buff=buff
first_ref=''
first_line=''
do while((.not. islast).and.(first_ref .eq. first_line))
call LHA_firststring(first_ref,curr_ref)
call LHA_firststring(first_line,curr_buff)
call LHA_islatin(first_ref(1:1),islast)
if (islast) then
par=first_ref
val=first_line ! If found set param name & value
found=.true.
end if
end do
end if
end do
close(ref_file)
99 return
end
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c ++
c ++ LHA_loadcard -> Open a LHA file and load all model param in a table
c ++
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine LHA_loadcard(param_name,npara,param,value)
implicit none
integer maxpara
parameter (maxpara=1000)
character*20 param(maxpara),value(maxpara),val,par
character*20 blockname
integer npara
logical fopened,found
integer iunit,GL,logfile
character*20 ctemp
character*132 buff
character*5 tag
character*132 temp
character*(*) param_name
data iunit/21/
data logfile/22/
GL=0
npara=1
param(1)=' '
value(1)=' '
! Try to open param-card file
call LHA_open_file(iunit,param_name,fopened)
if(.not.fopened) then
print *,'Error: Could not open file',param_name
print *,'Exiting'
stop
endif
! Try to open log file
open (unit = logfile, file = "param.log")
! Scan the data file
do while(.true.)
read(iunit,'(a132)',end=99,err=99) buff
if(buff(1:1) .ne.'#') then ! Skip comments and empty lines
tag=buff(1:5)
call LHA_case_trap(tag) ! Select decay/block tag
if(tag .eq. 'block') then ! If we are in a block, get the blockname
temp=buff(7:132)
call LHA_firststring(blockname,temp)
call LHA_case_trap(blockname)
else if (tag .eq. 'decay') then ! If we are in a decay, directly try to get back the correct name/value pair
blockname='decay'
temp=buff(7:132)
call LHA_blockread(blockname,temp,par,val,found)
if(found) GL=1
else if ((tag .eq. 'qnumbers').or.(tag.eq.'')) then! if qnumbers or empty tag do nothing
temp=buff(7:132)
else ! If we are in valid block, try to get back a name/value pair
call LHA_blockread(blockname,buff,par,val,found)
if(found) GL=1
end if
!if LHA_blockread has been called, record name and value
if(GL .eq. 1) then
value(npara)=val
ctemp=par
call LHA_case_trap(ctemp)
param(npara)=ctemp
npara=npara+1
GL=0
write (logfile,*) 'Parameter ',ctemp,' has been read with value ',val
endif
endif
enddo
npara=npara-1
c close(iunit)
close(logfile)
99 return
end
subroutine LHA_get_real(npara,param,value,name,var,def_value)
c----------------------------------------------------------------------------------
c finds the parameter named "name" in param and associate to "value" in value
c----------------------------------------------------------------------------------
implicit none
c
c parameters
c
integer maxpara
parameter (maxpara=1000)
c
c arguments
c
integer npara
character*20 param(maxpara),value(maxpara)
character*(*) name
real*8 var,def_value_num
character*20 c_param,c_name,ctemp
character*19 def_value
c
c local
c
logical found
integer i
c
c start
c
i=1
found=.false.
do while(.not.found.and.i.le.npara)
ctemp=param(i)
call LHA_firststring(c_param,ctemp)
ctemp=name
call LHA_firststring(c_name,ctemp)
call LHA_case_trap(c_name)
call LHA_case_trap(c_param)
found = (c_param .eq. c_name)
if (found) then
read(value(i),*) var
end if
i=i+1
enddo
if (.not.found) then
read(def_value,*) def_value_num
write (*,*) "Warning: parameter ",name," not found"
write (*,*) " setting it to default value ",def_value_num
var=def_value_num
endif
return
end
c
subroutine LHA_open_file(lun,filename,fopened)
c***********************************************************************
c ÊÊÊÊopens file input-card.dat in current directory or above
c***********************************************************************
implicit none
c
c ÊÊÊÊArguments
c
integer lun
logical fopened
character*(*) filename
character*90 tempname
integer fine
integer dirup,i
c-----
c ÊBegin Code
c-----
c
c ÊÊÊÊfirst check that we will end in the main directory
c
open(unit=lun,file=filename,status='old',ERR=20)
c write(*,*) 'read model file ',filename
fopened=.true.
return
20 tempname=filename
fine=index(tempname,' ')
if(fine.eq.0) fine=len(tempname)
tempname=tempname(1:fine)
c
c ÊÊÊÊÊÊÊÊif I have to read a card
c
if(index(filename,"_card").gt.0) then
tempname='./Cards/'//tempname
endif
fopened=.false.
do i=0,5
open(unit=lun,file=tempname,status='old',ERR=30)
fopened=.true.
c write(*,*) 'read model file ',tempname
exit
30 tempname='../'//tempname
if (i.eq.5)then
write(*,*) 'Warning: file ',filename,' not found in the parent directories!'
stop
endif
enddo
return
end
|