~maddevelopers/mg5amcnlo/3.0.1

« back to all changes in this revision

Viewing changes to vendor/IREGI/src/qcdloop/ff/ffinit.f

  • Committer: Marco Zaro
  • Date: 2014-01-27 16:54:10 UTC
  • mfrom: (78.124.55 MG5_aMC_2.1)
  • Revision ID: marco.zaro@gmail.com-20140127165410-5lma8c2hzbzm426j
merged with lp:~maddevelopers/madgraph5/MG5_aMC_2.1 r 267

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
*       $Id: ffinit.f,v 1.9 1996/04/26 10:39:03 gj Exp $
 
2
*###[ ffini:
 
3
        subroutine ffini
 
4
***#[*comment:***********************************************************
 
5
*       calculate a lot of commonly-used constants in the common block  *
 
6
*       /ffcnst/. also set the precision, maximum loss of digits and    *
 
7
*       the minimum value the logarithm accepts in /prec/.              *
 
8
***#]*comment:***********************************************************
 
9
*  #[ declarations:
 
10
        implicit none
 
11
        integer i,j,init,ioldp(13,12),isgrop(10,12),ji
 
12
        save init
 
13
        DOUBLE PRECISION s,sold
 
14
        DOUBLE COMPLEX cs
 
15
        include 'ff.h'
 
16
        DOUBLE PRECISION delta
 
17
        common /ffcut/ delta
 
18
        data init /0/
 
19
        data ioldp/1,2,3,4, 5,6,7,8,9,10, 11,12,13,
 
20
     +             4,1,2,3, 8,5,6,7,10,9, 11,13,12,
 
21
     +             3,4,1,2, 7,8,5,6,9,10, 11,12,13,
 
22
     +             2,3,4,1, 6,7,8,5,10,9, 11,13,12,
 
23
     +             4,2,3,1, 10,6,9,8,7,5, 12,11,13,
 
24
     +             1,3,2,4, 9,6,10,8,5,7, 12,11,13,
 
25
     +             1,2,4,3, 5,10,7,9,8,6, 13,12,11,
 
26
     +             1,4,3,2, 8,7,6,5,9,10, 11,13,12,
 
27
     +             3,4,2,1, 7,10,5,9,6,8, 13,12,11,
 
28
     +             2,3,1,4, 6,9,8,10,5,7, 12,13,11,
 
29
     +             4,2,1,3, 10,5,9,7,8,6, 13,11,12,
 
30
     +             1,3,4,2, 9,7,10,5,8,6, 13,11,12/
 
31
        data isgrop/
 
32
     +          +1,+1,+1,+1, +1,+1,+1,+1, +1,+1,
 
33
     +          +1,+1,+1,+1, +1,+1,+1,+1, -1,+1,
 
34
     +          +1,+1,+1,+1, +1,+1,+1,+1, -1,-1,
 
35
     +          +1,+1,+1,+1, +1,+1,+1,+1, +1,-1,
 
36
     +          +1,+1,+1,+1, -1,+1,+1,-1, +1,-1,
 
37
     +          +1,+1,+1,+1, -1,-1,+1,+1, -1,+1,
 
38
     +          +1,+1,+1,+1, +1,+1,-1,+1, +1,+1,
 
39
     +          +1,+1,+1,+1, -1,-1,-1,-1, +1,-1,
 
40
     +          +1,+1,+1,+1, -1,+1,+1,+1, -1,-1,
 
41
     +          +1,+1,+1,+1, +1,+1,+1,-1, +1,-1,
 
42
     +          +1,+1,+1,+1, -1,+1,+1,-1, -1,-1,
 
43
     +          +1,+1,+1,+1, -1,-1,+1,+1, -1,-1/
 
44
*  #] declarations:
 
45
*  #[ check:
 
46
*       check whether tehre is anything to do
 
47
        if ( init .ne. 0 ) return
 
48
        init = 1
 
49
        print *,'===================================================='
 
50
        print *,'  FF 2.0, a package to evaluate one-loop integrals'
 
51
        print *,'written by G. J. van Oldenborgh, NIKHEF-H, Amsterdam'
 
52
        print *,'===================================================='
 
53
        print *,'for the algorithms used see preprint NIKHEF-H 89/17,'
 
54
        print *,'''New Algorithms for One-loop Integrals'', by G.J. van'
 
55
        print *,'Oldenborgh and J.A.M. Vermaseren, published in '
 
56
        print *,'Zeitschrift fuer Physik C46(1990)425.'
 
57
        print *,'===================================================='
 
58
*  #] check:
 
59
*  #[ precision etc:
 
60
        lwrite = .TRUE.
 
61
        nevent = -1
 
62
*
 
63
*       the loss of accuracy in any single subtraction at which
 
64
*       (timeconsuming) corrective action is to be taken is
 
65
*
 
66
        xloss = 0.125
 
67
*
 
68
*       the precision to which real calculations are done is
 
69
*
 
70
        precx = 1
 
71
        sold = 0
 
72
        do 1 i=1,1000
 
73
            precx = precx/2
 
74
            s = exp(log(1+precx))
 
75
            if ( s .eq. sold ) goto 2
 
76
            sold = s
 
77
    1   continue
 
78
    2   continue
 
79
        precx = precx*8
 
80
*       (take three bits for safety)
 
81
        if ( lwrite ) print *,'ffini: precx = ',precx
 
82
*
 
83
*       the precision to which complex calculations are done is
 
84
*
 
85
        precc = 1
 
86
        sold = 0
 
87
        do 3 i=1,1000
 
88
            precc = precc/2
 
89
            cs = exp(log(DCMPLX(1+precc,x0)))
 
90
            if ( DBLE(cs) .eq. sold ) goto 4
 
91
            sold = DBLE(cs)
 
92
    3   continue
 
93
    4   continue
 
94
        precc = precc*8
 
95
*       (take three bits for safety)
 
96
        if ( lwrite ) print *,'ffini: precc = ',precc
 
97
*
 
98
*       for efficiency tke them equal if they are not too different
 
99
*
 
100
        if ( precx/precc .lt. 4 .and. precx/precc .gt. .25 ) then
 
101
            precx = max(precc,precx)
 
102
            precc = max(precc,precx)
 
103
        endif
 
104
*
 
105
*       and the minimum value the logarithm accepts without complaining
 
106
*       about arguments zero is (DOUBLE PRECISION cq DOUBLE COMPLEX)
 
107
*
 
108
        s = 1
 
109
        xalogm = 1
 
110
        do 5 i=1,10000
 
111
            s = s/2
 
112
            if ( 2*abs(s) .ne. xalogm ) goto 6
 
113
            xalogm = abs(s)
 
114
    5   continue
 
115
    6   continue
 
116
        if ( xalogm.eq.0 ) xalogm = 1d-308
 
117
        if ( lwrite ) print *,'ffini: xalogm = ',xalogm
 
118
        s = 1
 
119
        xclogm = abs(DCMPLX(s))
 
120
        do 7 i=1,10000
 
121
            s = s/2
 
122
            if ( 2*abs(DCMPLX(s)) .ne. xclogm ) goto 8
 
123
            xclogm = abs(DCMPLX(s))
 
124
    7   continue
 
125
    8   continue
 
126
        if ( xclogm.eq.0 ) xclogm = 1d-308
 
127
        if ( lwrite ) print *,'ffini: xclogm = ',xclogm
 
128
*
 
129
*       These values are for Absoft, Apollo fortran (68000):
 
130
*       xalogm = 1.D-308
 
131
*       xclogm = 1.D-18
 
132
*       These values are for VAX g_float
 
133
*       xalogm = 1.D-308
 
134
*       xclogm = 1.D-308
 
135
*       These values are for Gould fort (because of div_zz)
 
136
*       xalogm = 1.D-75
 
137
*       xclogm = 1.D-36
 
138
        xalog2 = sqrt(xalogm)
 
139
        xclog2 = sqrt(xclogm)
 
140
*  #] precision etc:
 
141
*  #[ constants:
 
142
*
 
143
*       calculate the coefficients of the series expansion
 
144
*       li2(x) = sum bn*z^n/(n+1)!, z = -log(1-x), bn are the
 
145
*       bernouilli numbers (zero for odd n>1).
 
146
*
 
147
        bf(1) = - 1.D+0/4.D+0
 
148
        bf(2) = + 1.D+0/36.D+0
 
149
        bf(3) = - 1.D+0/36.D+2
 
150
        bf(4) = + 1.D+0/21168.D+1
 
151
        bf(5) = - 1.D+0/108864.D+2
 
152
        bf(6) = + 1.D+0/52690176.D+1
 
153
        bf(7) = - 691.D+0/16999766784.D+3
 
154
        bf(8) = + 1.D+0/1120863744.D+3
 
155
        bf(9) = - 3617.D+0/18140058832896.D+4
 
156
        bf(10) = + 43867.D+0/97072790126247936.D+3
 
157
        bf(11) = - 174611.D+0/168600109166641152.D+5
 
158
        bf(12) = + 77683.D+0/32432530090601152512.D+4
 
159
        bf(13) = - 236364091.D+0/4234560341829359173632.D+7
 
160
        bf(14) = + 657931.D+0/5025632054039239458816.D+6
 
161
        bf(15) = - 3392780147.D+0/109890470493622010006470656.D+7
 
162
        bf(16)=+172.3168255201D+0/2355349904102724211909.3102313472D+6
 
163
        bf(17)=-770.9321041217D+0/4428491985594062112714.2791446528D+8
 
164
        bf(18)=( 0.4157635644614046176D-28)
 
165
        bf(19)=(-0.9962148488284986022D-30)
 
166
        bf(20)=( 0.2394034424896265390D-31)
 
167
*
 
168
*       inverses of integers:
 
169
*
 
170
        do 10 i=1,30
 
171
            xninv(i) = x1/i
 
172
            xn2inv(i) = x1/(i*i)
 
173
   10   continue
 
174
*
 
175
*       inverses of faculties of integers:
 
176
*
 
177
        xinfac(1) = x1
 
178
        do 20 i=2,30
 
179
            xinfac(i) = xinfac(i-1)/i
 
180
   20   continue
 
181
*
 
182
*       inx: p(inx(i,j)) = isgn(i,j)*(s(i)-s(j))
 
183
*
 
184
        inx(1,1) = -9999
 
185
        inx(2,1) = 5
 
186
        inx(3,1) = 9
 
187
        inx(4,1) = 8
 
188
        inx(1,2) = 5
 
189
        inx(2,2) = -9999
 
190
        inx(3,2) = 6
 
191
        inx(4,2) = 10
 
192
        inx(1,3) = 9
 
193
        inx(2,3) = 6
 
194
        inx(3,3) = -9999
 
195
        inx(4,3) = 7
 
196
        inx(1,4) = 8
 
197
        inx(2,4) = 10
 
198
        inx(3,4) = 7
 
199
        inx(4,4) = -9999
 
200
        isgn(1,1) = -9999
 
201
        isgn(2,1) = +1
 
202
        isgn(3,1) = -1
 
203
        isgn(4,1) = -1
 
204
        isgn(1,2) = -1
 
205
        isgn(2,2) = -9999
 
206
        isgn(3,2) = +1
 
207
        isgn(4,2) = +1
 
208
        isgn(1,3) = +1
 
209
        isgn(2,3) = -1
 
210
        isgn(3,3) = -9999
 
211
        isgn(4,3) = +1
 
212
        isgn(1,4) = +1
 
213
        isgn(2,4) = -1
 
214
        isgn(3,4) = -1
 
215
        isgn(4,4) = -9999
 
216
        do 40 i=1,12
 
217
            do 30 j=1,13
 
218
                iold(j,i) = ioldp(j,i)
 
219
   30       continue
 
220
            do 35 j=1,10
 
221
                isgrot(j,i) = isgrop(j,i)
 
222
   35       continue
 
223
   40   continue
 
224
        inx5(1,1) = -9999
 
225
        inx5(1,2) =  6
 
226
        inx5(1,3) = 11
 
227
        inx5(1,4) = 14
 
228
        inx5(1,5) = 10
 
229
        inx5(2,1) =  6
 
230
        inx5(2,2) = -9999
 
231
        inx5(2,3) =  7
 
232
        inx5(2,4) = 12
 
233
        inx5(2,5) = 15
 
234
        inx5(3,1) = 11
 
235
        inx5(3,2) =  7
 
236
        inx5(3,3) = -9999
 
237
        inx5(3,4) =  8
 
238
        inx5(3,5) = 13
 
239
        inx5(4,1) = 14
 
240
        inx5(4,2) = 12
 
241
        inx5(4,3) =  8
 
242
        inx5(4,4) = -9999
 
243
        inx5(4,5) =  9
 
244
        inx5(5,1) = 10
 
245
        inx5(5,2) = 15
 
246
        inx5(5,3) = 13
 
247
        inx5(5,4) =  9
 
248
        inx5(5,5) = -9999
 
249
*       isgn5 is not yet used.
 
250
        do i=1,5
 
251
            do j=1,5
 
252
                isgn5(i,j) = -9999
 
253
            enddo
 
254
        enddo
 
255
*
 
256
        inx6(1,1) = -9999
 
257
        inx6(1,2) =  7
 
258
        inx6(1,3) = 13
 
259
        inx6(1,4) = 19
 
260
        inx6(1,5) = 17
 
261
        inx6(1,6) = 12
 
262
        inx6(2,1) =  7
 
263
        inx6(2,2) = -9999
 
264
        inx6(2,3) =  8
 
265
        inx6(2,4) = 14
 
266
        inx6(2,5) = 20
 
267
        inx6(2,6) = 18
 
268
        inx6(3,1) = 13
 
269
        inx6(3,2) =  8
 
270
        inx6(3,3) = -9999
 
271
        inx6(3,4) =  9
 
272
        inx6(3,5) = 15
 
273
        inx6(3,6) = 21
 
274
        inx6(4,1) = 19
 
275
        inx6(4,2) = 14
 
276
        inx6(4,3) =  9
 
277
        inx6(4,4) = -9999
 
278
        inx6(4,5) = 10
 
279
        inx6(4,6) = 16
 
280
        inx6(5,1) = 17
 
281
        inx6(5,2) = 20
 
282
        inx6(5,3) = 15
 
283
        inx6(5,4) = 10
 
284
        inx6(5,5) = -9999
 
285
        inx6(5,6) = 11
 
286
        inx6(6,1) = 12
 
287
        inx6(6,2) = 18
 
288
        inx6(6,3) = 21
 
289
        inx6(6,4) = 16
 
290
        inx6(6,5) = 11
 
291
        inx6(6,6) = -9999
 
292
*       isgn6 is used.
 
293
        do i=1,6
 
294
            do j=1,6
 
295
                ji = j-i
 
296
                if ( ji.gt.+3 ) ji = ji - 6
 
297
                if ( ji.lt.-3 ) ji = ji + 6
 
298
                if ( ji.eq.0 ) then
 
299
                    isgn6(j,i) = -9999
 
300
                elseif ( abs(ji).eq.3 ) then
 
301
                    if ( i.lt.0 ) then
 
302
                        isgn6(j,i) = -1
 
303
                    else
 
304
                        isgn6(j,i) = +1
 
305
                    endif
 
306
                elseif ( ji.gt.0 ) then
 
307
                    isgn6(j,i) = +1
 
308
                elseif ( ji.lt.0 ) then
 
309
                    isgn6(j,i) = -1
 
310
                else
 
311
                    print *,'ffini: internal error in isgn6'
 
312
                    stop
 
313
                endif
 
314
            enddo
 
315
        enddo
 
316
*
 
317
*  #] constants:
 
318
*  #[ defaults for flags:
 
319
        nevent = 0
 
320
*
 
321
*       the debugging flags.
 
322
*
 
323
        lwrite = .FALSE.
 
324
        ltest = .FALSE.
 
325
        lwarn = .TRUE.
 
326
        ldc3c4 = .FALSE.
 
327
        l4also = .FALSE.
 
328
        lmem = .FALSE.
 
329
        ldot = .FALSE.
 
330
        idot = 0
 
331
*
 
332
*       Specify which root to take in cases were two are possible
 
333
*       it may be advantageous to change this to -1 (debugging hook)
 
334
*
 
335
        isgn34 = 1
 
336
        isgnal = 1
 
337
*
 
338
*       the cutoff has to be initialized because of the memory mechansim
 
339
*
 
340
        delta = 0
 
341
*
 
342
*       the scheme used for the complex scalar functions:
 
343
*
 
344
*       nschem = 1: do not use the complex mass at all
 
345
*                2: only use the complex mass in linearly divergent terms
 
346
*                3: also use the complex mass in divergent logs UNDEFINED
 
347
*                4: use the complex mass in the C0 if there are
 
348
*                   divergent logs
 
349
*                5: include the almost-divergent threshold terms from
 
350
*                   (m,m,0) vertices
 
351
*                6: include the (s-m^2)*log(s-m^2) threshold terms from
 
352
*                   (m1+m2),m1,m2) vertices
 
353
*                7: full complex computation
 
354
*       (only in the ffz... functions):
 
355
*       onshel = .FALSE.: use the offshell p^2 everywhere
 
356
*                .TRUE.:  use the onshell p^2 except in complex parts
 
357
*
 
358
        nschem = 7
 
359
        onshel = .TRUE.
 
360
*
 
361
*       the precision wanted in the complex D0 (and hence E0) when
 
362
*       nschem=7, these are calculated via Taylor exoansion in the real
 
363
*       one and hence expensive.
 
364
*
 
365
        reqprc = 1.e-8
 
366
*
 
367
*       in some schemes, for onshel=.FALSE.,
 
368
*       when |p^2-Re(m^2)| < nwidth*|Im(m^2)| special action is taken
 
369
*
 
370
        nwidth = 5
 
371
*
 
372
*       a flag to indicate the validity of differences smuggled to the
 
373
*       IR routines in the C0 (ff internal only)
 
374
*
 
375
        lsmug = .FALSE.
 
376
*
 
377
*  #] defaults for flags:
 
378
*###] ffini:
 
379
        end
 
380
*###[ ffexi:
 
381
        subroutine ffexi
 
382
***#[*comment:***********************************************************
 
383
*       check a lot of commonly-used constants in the common block      *
 
384
*       /ffcnst/.                                                       *
 
385
***#]*comment:***********************************************************
 
386
*  #[ declarations:
 
387
        implicit none
 
388
        integer i,ier
 
389
        include 'ff.h'
 
390
*  #] declarations:
 
391
*  #[ checks:
 
392
*
 
393
*       calculate the coefficients of the series expansion
 
394
*       li2(x) = sum bn*z^n/(n+1)!, z = -log(1-x), bn are the
 
395
*       bernouilli numbers (zero for odd n>1).
 
396
*
 
397
        if ( bf(1) .ne. - 1.D+0/4.D+0 )
 
398
     +  print *,'ffexi: error: bf(1) is corrupted'
 
399
        if ( bf(2) .ne. + 1.D+0/36.D+0 )
 
400
     +  print *,'ffexi: error: bf(2) is corrupted'
 
401
        if ( bf(3) .ne. - 1.D+0/36.D+2 )
 
402
     +  print *,'ffexi: error: bf(3) is corrupted'
 
403
        if ( bf(4) .ne. + 1.D+0/21168.D+1 )
 
404
     +  print *,'ffexi: error: bf(4) is corrupted'
 
405
        if ( bf(5) .ne. - 1.D+0/108864.D+2 )
 
406
     +  print *,'ffexi: error: bf(5) is corrupted'
 
407
        if ( bf(6) .ne. + 1.D+0/52690176.D+1 )
 
408
     +  print *,'ffexi: error: bf(6) is corrupted'
 
409
        if ( bf(7) .ne. - 691.D+0/16999766784.D+3 )
 
410
     +  print *,'ffexi: error: bf(7) is corrupted'
 
411
        if ( bf(8) .ne. + 1.D+0/1120863744.D+3 )
 
412
     +  print *,'ffexi: error: bf(8) is corrupted'
 
413
        if ( bf(9) .ne. - 3617.D+0/18140058832896.D+4 )
 
414
     +  print *,'ffexi: error: bf(9) is corrupted'
 
415
        if ( bf(10) .ne. + 43867.D+0/97072790126247936.D+3 )
 
416
     +  print *,'ffexi: error: bf(10) is corrupted'
 
417
        if ( bf(11) .ne. - 174611.D+0/168600109166641152.D+5 )
 
418
     +  print *,'ffexi: error: bf(11) is corrupted'
 
419
        if ( bf(12) .ne. + 77683.D+0/32432530090601152512.D+4 )
 
420
     +  print *,'ffexi: error: bf(12) is corrupted'
 
421
        if ( bf(13) .ne. - 236364091.D+0/4234560341829359173632.D+7 )
 
422
     +  print *,'ffexi: error: bf(13) is corrupted'
 
423
        if ( bf(14) .ne. + 657931.D+0/5025632054039239458816.D+6 )
 
424
     +  print *,'ffexi: error: bf(14) is corrupted'
 
425
        if ( bf(15) .ne. -3392780147.D+0/109890470493622010006470656.D+7
 
426
     +  ) print *,'ffexi: error: bf(15) is corrupted'
 
427
        if ( bf(16).ne.+172.3168255201D+0/2355349904102724211909.3102313
 
428
     +  472D+6 )
 
429
     +  print *,'ffexi: error: bf(16) is corrupted'
 
430
        if ( bf(17).ne.-770.9321041217D+0/4428491985594062112714.2791446
 
431
     +  528D+8 )
 
432
     +  print *,'ffexi: error: bf(17) is corrupted'
 
433
        if ( bf(18).ne.( 0.4157635644614046176D-28) )
 
434
     +  print *,'ffexi: error: bf(18) is corrupted'
 
435
        if ( bf(19).ne.(-0.9962148488284986022D-30) )
 
436
     +  print *,'ffexi: error: bf(19) is corrupted'
 
437
        if ( bf(20).ne.( 0.2394034424896265390D-31) )
 
438
     +  print *,'ffexi: error: bf(20) is corrupted'
 
439
*
 
440
*       inverses of integers:
 
441
*
 
442
        do 10 i=1,20
 
443
            if ( abs(xninv(i)-x1/i) .gt. precx*xninv(i) ) print *,
 
444
     +          'ffexi: error: xninv(',i,') is not 1/',i,': ',
 
445
     +          xninv(i),xninv(i)-x1/i
 
446
   10   continue
 
447
*
 
448
*  #] checks:
 
449
*  #[ print summary of errors and warning:
 
450
        ier = 0
 
451
        call fferr(999,ier)
 
452
*  #] print summary of errors and warning:
 
453
*###] ffexi:
 
454
        end
 
455
*###[ fferr:
 
456
        subroutine fferr(nerr,ierr)
 
457
***#[*comment:***********************************************************
 
458
*                                                                       *
 
459
*       generates an errormessage #nerr with severity 2                 *
 
460
*       nerr=999 gives a frequency listing of all errors                *
 
461
*                                                                       *
 
462
***#]*comment:***********************************************************
 
463
*  #[ declarations:
 
464
        implicit none
 
465
        integer nmax
 
466
        parameter (nmax=100)
 
467
        integer nerr,ierr,ifile
 
468
        character*80 error(nmax),error1
 
469
        logical locwrt
 
470
        integer noccur(nmax),init,i,ier,inone,nnerr,nomore
 
471
        save error,noccur,init,locwrt,nomore
 
472
        include 'ff.h'
 
473
*  #] declarations:
 
474
*  #[ data:
 
475
        data locwrt /.TRUE./
 
476
        data nomore /-1/
 
477
        data noccur /nmax*0/
 
478
        data init /0/
 
479
        if ( init.eq.0 ) then
 
480
            init = 1
 
481
            do 1 i=1,nmax
 
482
                error(i) =
 
483
     +          'fferr:  error:   illegal value for ierr'
 
484
    1       continue
 
485
            call ffopen(ifile,'fferr.dat',ier)
 
486
            if ( ier .ne. 0 ) goto 100
 
487
            rewind(ifile)
 
488
            read(ifile,'(a)')error1
 
489
            read(ifile,'(a)')error1
 
490
            do 90 i=1,10000
 
491
                read(ifile,'(i4,a80)',end=110,err=110)ier,error1
 
492
                if ( ier .lt. 1 .or. ier .gt. nmax ) then
 
493
                    print '(a,i3)','fferr:  error: wild error number ',
 
494
     +                                                          ier
 
495
                    print '(a,a)','>>> ',error1
 
496
                    goto 90
 
497
                endif
 
498
                error(ier) = error1
 
499
   90       continue
 
500
            goto 110
 
501
  100       continue
 
502
            print '(a)',
 
503
     +          'fferr:  warning cannot open fferr.dat with error texts'
 
504
  110       continue
 
505
            close(ifile)
 
506
        endif
 
507
*  #] data:
 
508
*  #[ nerr=999:
 
509
        if ( nerr .eq. 999 ) then
 
510
*           print out total numbers...
 
511
            print '(a)',' '
 
512
            print '(a)','total number of errors and warnings'
 
513
            print '(a)','==================================='
 
514
            inone = 1
 
515
            do 10 i=1,nmax
 
516
                if ( noccur(i) .gt. 0 ) then
 
517
                    print '(a,i8,a,i3,a,a)','fferr: ',noccur(i),
 
518
     +                  ' times ',i,': ',error(i)
 
519
                    noccur(i) = 0
 
520
                    inone = 0
 
521
                endif
 
522
   10       continue
 
523
            if ( inone.eq.1 ) print '(a)','fferr: no errors'
 
524
            if ( lwarn ) then
 
525
                call ffwarn(999,ierr,x1,x1)
 
526
            else
 
527
                print '(a)','the warning system has been disabled'
 
528
            endif
 
529
            print '(a)',' '
 
530
            return
 
531
        endif
 
532
*  #] nerr=999:
 
533
*  #[ print error:
 
534
        if ( nerr .lt. 1 .or. nerr .gt. nmax ) then
 
535
            nnerr = nmax
 
536
        else
 
537
            nnerr = nerr
 
538
        endif
 
539
        noccur(nnerr) = noccur(nnerr) + 1
 
540
        ierr = ierr + 100
 
541
 
 
542
        if ( nevent .eq. nomore ) return
 
543
 
 
544
        if ( locwrt ) then
 
545
            print '(a,i6,a,i6,a,i8)','fferr: id nr ',id,'/',idsub,
 
546
     +          ', event nr ',nevent
 
547
            print '(a,i6,a,a)','error nr',nerr,': ',error(nnerr)
 
548
        endif
 
549
 
 
550
        if ( nerr .eq. 100 ) then
 
551
*           we found a matherror - discard all errors from now till next
 
552
*           event
 
553
            nomore = nevent
 
554
        endif
 
555
 
 
556
*  #] print error:
 
557
*###] fferr:
 
558
        end
 
559
*###[ ffwarn:
 
560
        subroutine ffwarn(nerr,ierr,som,xmax)
 
561
***#[*comment:***********************************************************
 
562
*                                                                       *
 
563
*       The warning routine.  A warning is aloss of precision greater   *
 
564
*       than xloss (which is default set in ffini), whenever in a       *
 
565
*       subtraction the result is smaller than xloss*max(operands) this *
 
566
*       routine is called.  Now the strategy is to remember these       *
 
567
*       warnings until a 998 message is obtained; then all warnings of  *
 
568
*       the previous event are printed.  The rationale is that one      *
 
569
*       makes this call if too much preciasion is lost only.            *
 
570
*       nerr=999 gives a frequency listing of all warnings              *
 
571
*                                                                       *
 
572
*       Input:  nerr    integer the id of the warning message, see the  *
 
573
*                               file ffwarn.dat or 998 or 999           *
 
574
*               ierr    integer the usual error flag: number of digits  *
 
575
*                               lost so far                             *
 
576
*               som     real    the result of the addition              *
 
577
*               xmax    real    the largest operand                     *
 
578
*                                                                       *
 
579
*       Output: ierr    integer is raised by the number of digits lost  *
 
580
*                               the tolerated loss of xloss             *
 
581
*                                                                       *
 
582
*       NOTE: This routine needs a file ffwarn.dat with the warning     *
 
583
*       texts, it is very system dependent where to pick it up          *
 
584
*       set the PATH variable to your own taste.                        *
 
585
*                                                                       *
 
586
***#]*comment:***********************************************************
 
587
*  #[ declarations:
 
588
        implicit none
 
589
        integer nmax
 
590
        parameter (nmax=300)
 
591
*
 
592
*       arguments
 
593
*
 
594
        integer nerr,ierr
 
595
        DOUBLE PRECISION som,xmax
 
596
*
 
597
*       local variables
 
598
*
 
599
        integer memmax
 
600
        parameter (memmax = 1000)
 
601
        character*80 warn(nmax),warn1
 
602
        integer noccur(nmax),init,i,ier,inone,nnerr,ilost,
 
603
     +          nermem(memmax),losmem(memmax),idmem(memmax),
 
604
     +          idsmem(memmax),laseve,imem,ifile
 
605
        DOUBLE PRECISION xlosti(nmax),xlost
 
606
        save warn,noccur,init,xlosti,nermem,losmem,idmem,idsmem,
 
607
     +          laseve,imem
 
608
*
 
609
*       common blocks
 
610
*
 
611
        include 'ff.h'
 
612
        include 'aa.h'
 
613
*  #] declarations:
 
614
*  #[ data:
 
615
        data noccur /nmax*0/
 
616
        data init /0/
 
617
        if ( init.eq.0 .and. nerr.ne.999 ) then
 
618
            init = 1
 
619
            do 1 i=1,nmax
 
620
                warn(i) =
 
621
     +          'ffwarn:  warning:   illegal value for ierr'
 
622
                xlosti(i) = 0
 
623
    1       continue
 
624
            call ffopen(ifile,'ffwarn.dat',ier)
 
625
            if ( ier.ne.0 ) goto 100
 
626
            rewind(ifile)
 
627
            read(ifile,'(a)')warn1
 
628
            read(ifile,'(a)')warn1
 
629
            do 90 i=1,10000
 
630
                read(ifile,'(i4,a80)',end=110,err=110)ier,warn1
 
631
                if ( warn1.eq.' ' ) goto 90
 
632
                if ( ier.lt.1 .or. ier.gt.nmax ) then
 
633
                    print '(a,i3)','ffwarn: error: wild warning number '
 
634
     +                                                          ,ier
 
635
                    print '(a,a)','>>> ',warn1
 
636
                    goto 90
 
637
                endif
 
638
                warn(ier) = warn1
 
639
   90       continue
 
640
            goto 110
 
641
  100       continue
 
642
            print '(a)',
 
643
     +      'ffwarn: warning cannot open ffwarn.dat with warning texts'
 
644
  110       continue
 
645
            close(ifile)
 
646
            laseve = -1
 
647
            imem = 1
 
648
        endif
 
649
*  #] data:
 
650
*  #[ nerr=999:
 
651
        if ( nerr.eq.999 ) then
 
652
*           print out total numbers...
 
653
            inone = 1
 
654
            do 10 i=1,nmax
 
655
                if ( noccur(i) .gt. 0 ) then
 
656
                    print '(a,i8,a,i3,a,a)','ffwarn: ',noccur(i),
 
657
     +                  ' times ',i,': ',warn(i)
 
658
                    print '(a,g12.3,a)',
 
659
     +                  '     (lost at most a factor ',xlosti(i),')'
 
660
                    noccur(i) = 0
 
661
                    xlosti(i) = 0
 
662
                    inone = 0
 
663
                endif
 
664
   10       continue
 
665
            if ( inone.eq.1 ) print '(a)','ffwarn: no warnings'
 
666
            return
 
667
        endif
 
668
*  #] nerr=999:
 
669
*  #[ print warning:
 
670
        if ( nerr .eq. 998 ) then
 
671
            if ( nevent .ne. laseve ) return
 
672
            do 20 i=1,imem-1
 
673
                if ( nermem(i).ne.0 ) then
 
674
                    print '(a,i6,a,i6,a,i8)','ffwarn: id nr ',idmem(i),
 
675
     +                  '/',idsmem(i),', event nr ',nevent
 
676
                    print '(a,i6,a,a)','warning nr ',nermem(i),': ',
 
677
     +                  warn(nermem(i))
 
678
                    print '(a,i3,a)','     (lost ',losmem(i),' digits)'
 
679
                endif
 
680
   20       continue
 
681
            imem = 1
 
682
            return
 
683
        endif
 
684
*  #] print warning:
 
685
*  #[ collect warnings:
 
686
*
 
687
*       bring in range
 
688
*
 
689
        if ( nerr .lt. 1 .or. nerr .gt. nmax ) then
 
690
            nnerr = nmax
 
691
        else
 
692
            nnerr = nerr
 
693
        endif
 
694
*
 
695
*       bookkeeping
 
696
*
 
697
        noccur(nnerr) = noccur(nnerr) + 1
 
698
        if ( som .ne. 0 ) then
 
699
            xlost = abs(xmax/som)
 
700
        elseif ( xmax .ne. 0 ) then
 
701
            xlost = 1/precx
 
702
        else
 
703
            xlost = 1
 
704
        endif
 
705
        xlosti(nnerr) = max(xlosti(nnerr),xlost)
 
706
        if ( xlost*xloss .gt. xalogm ) then
 
707
            ilost = 1 + int(abs(log10(xlost*xloss)))
 
708
        else
 
709
            ilost = 0
 
710
        endif
 
711
        ierr = ierr + ilost
 
712
*
 
713
*       nice place to stop when debugging
 
714
*
 
715
        if ( ilost.ge.10 ) then
 
716
            ilost = ilost + 1 - init
 
717
        endif
 
718
*
 
719
*       add to memory
 
720
*
 
721
        if ( laseve .ne. nevent ) then
 
722
            imem = 1
 
723
            laseve = nevent
 
724
        endif
 
725
        if ( imem .le. memmax ) then
 
726
            idmem(imem) = id
 
727
            idsmem(imem) = idsub
 
728
            nermem(imem) = nerr
 
729
            losmem(imem) = ilost
 
730
            imem = imem + 1
 
731
        endif
 
732
*
 
733
*       print directly if lwrite TRUE
 
734
*
 
735
        if ( awrite .or. lwrite ) then
 
736
            imem = imem - 1
 
737
            print '(a,i6,a,i6,a,i8)','ffwarn: id nr ',idmem(imem),'/',
 
738
     +                  idsmem(imem),', event nr ',nevent
 
739
            print '(a,i6,a,a)','warning nr ',nermem(imem),': ',
 
740
     +                  warn(nnerr)
 
741
            print '(a,i3,a)','     (lost ',losmem(imem),' digits)'
 
742
        endif
 
743
*  #] collect warnings:
 
744
*###] ffwarn:
 
745
        end
 
746
*###[ ffopen:
 
747
        subroutine ffopen(ifile,name,ier)
 
748
*
 
749
*       opens a data file and returns the unit number.
 
750
*
 
751
        implicit none
 
752
*
 
753
*       arguments
 
754
*
 
755
        integer ifile,ier
 
756
        character*(*) name
 
757
*
 
758
        logical lopen
 
759
        character*128 path,fullname
 
760
*
 
761
        include 'ff.h'
 
762
*
 
763
        ier = 0
 
764
        do 10 ifile = 10,100
 
765
            inquire(ifile,opened=lopen)
 
766
            if ( .not.lopen ) goto 20
 
767
   10   continue
 
768
   20   continue
 
769
*
 
770
*       Adjust PATH to suit your own directory structure
 
771
*       I could use a getenv() here, but that may not work
 
772
*       on PC/Mac/...
 
773
*       VMS users: use something like the following lines instead
 
774
*       fullname = 'USR$LOCAL[GEERT]'//name
 
775
*       open(ifile,file=fullname,status='OLD',READONLY,err=100)
 
776
*
 
777
*       first try - my home directory
 
778
        path = '/user/gj/lib/'
 
779
        fullname = path(1:index(path,' ')-1)//name
 
780
        open(ifile,file=fullname,status='OLD',err=30)
 
781
        return
 
782
   30   continue
 
783
*       second try - the system directory
 
784
        path = '/usr/local/ff/'
 
785
        fullname = path(1:index(path,' ')-1)//name
 
786
        open(ifile,file=fullname,status='OLD',err=40)
 
787
        return
 
788
*       file could not be found
 
789
   40   continue
 
790
        print *,'ffopen: error: could not open ',fullname
 
791
        print *,'        adjust path in ffopen (ffinit.f)'
 
792
        ier = -1
 
793
*###] ffopen:
 
794
        end
 
795
*###[ ffbnd:
 
796
        DOUBLE PRECISION function ffbnd(n1,n2,array)
 
797
*************************************************************************
 
798
*                                                                       *
 
799
*       calculate bound = (precx*|a(n1)/a(n1+n2)|^(1/n2) which is the   *
 
800
*       maximum value of x in a series expansion sum_(i=n1)^(n1+n2)     *
 
801
*       a(i)*x(i) to give a result of accuracy precx (actually of |next *
 
802
*       term| < prec                                                    *
 
803
*                                                                       *
 
804
*************************************************************************
 
805
        implicit none
 
806
        integer n1,n2
 
807
        DOUBLE PRECISION array(n1+n2)
 
808
        include 'ff.h'
 
809
        if ( array(n1+n2) .eq. 0 ) then
 
810
           print *,'ffbnd: fatal: array not intialized; did you call ',
 
811
     +          'ffini?'
 
812
           stop
 
813
        endif
 
814
        ffbnd = (precx*abs(array(n1)/array(n1+n2)))**(1/DBLE(n2))
 
815
*###] ffbnd:
 
816
        end
 
817
*###[ ffbndc:
 
818
        DOUBLE PRECISION function ffbndc(n1,n2,carray)
 
819
*************************************************************************
 
820
*                                                                       *
 
821
*       calculate bound = (precc*|a(n1)/a(n1+n2)|^(1/n2) which is the   *
 
822
*       maximum value of x in a series expansion sum_(i=n1)^(n1+n2)     *
 
823
*       a(i)*x(i) to give a result of accuracy precc (actually of |next *
 
824
*       term| < prec                                                    *
 
825
*                                                                       *
 
826
*************************************************************************
 
827
        implicit none
 
828
        integer n1,n2
 
829
        DOUBLE COMPLEX carray(n1+n2)
 
830
        include 'ff.h'
 
831
        if ( carray(n1+n2) .eq. 0 ) then
 
832
           print *,'ffbnd: fatal: array not intialized; did you call ',
 
833
     +          'ffini?'
 
834
           stop
 
835
        endif
 
836
        ffbndc = (precc*abs(carray(n1)/carray(n1+n2)))**(1/DBLE(n2))
 
837
*###] ffbndc:
 
838
        end
 
839
*###[ ffroot:
 
840
        subroutine ffroot(xm,xp,a,b,c,d,ier)
 
841
***#[*comment:***********************************************************
 
842
*                                                                       *
 
843
*       Calculate the roots of the equation                             *
 
844
*               a*x^2 - 2*b*x + c = 0                                   *
 
845
*       given by                                                        *
 
846
*               x = (b +/- d )/a        xp*xm = c/a                     *
 
847
*                                                                       *
 
848
***#]*comment:***********************************************************
 
849
*  #[ declarations:
 
850
        implicit none
 
851
*
 
852
*       arguments:
 
853
*
 
854
        integer ier
 
855
        DOUBLE PRECISION xm,xp,a,b,c,d
 
856
*
 
857
*       local variables:
 
858
*
 
859
        DOUBLE PRECISION s1,s2,s3,rloss
 
860
*
 
861
*       common blocks:
 
862
*
 
863
        include 'ff.h'
 
864
*  #] declarations:
 
865
*  #[ check input:
 
866
        if ( a .eq. 0 ) then
 
867
            call fferr(39,ier)
 
868
            if ( b.gt.0 .eqv. d.gt.0 ) then
 
869
                xp = 1/xalogm
 
870
                xm = c/(b+d)
 
871
            else
 
872
                xp = c/(b-d)
 
873
                xm = 1/xalogm
 
874
            endif
 
875
            return
 
876
        endif
 
877
*       if ( lwrite ) print *,'ffroot: a,b,c,d = ',a,b,c,d
 
878
*  #] check input:
 
879
*  #[ calculations:
 
880
        if ( d .eq. 0 ) then
 
881
            xm = b / a
 
882
            xp = xm
 
883
        elseif ( b .gt. 0 .eqv.  d .gt. 0 ) then
 
884
            xp = ( b + d ) / a
 
885
            xm = c / (a*xp)
 
886
        else
 
887
            xm = ( b - d ) / a
 
888
            xp = c / (a*xm)
 
889
        endif
 
890
*  #] calculations:
 
891
*  #[ test output:
 
892
        if ( ltest ) then
 
893
            rloss = xloss*DBLE(10)**(-2-mod(ier,50))
 
894
            if ( xm .ne. 0 ) then
 
895
                s1 = a*xm
 
896
                s2 = 2*b
 
897
                s3 = c/xm
 
898
                if ( rloss*abs(s1-s2+s3) .gt. precx*max(abs(s1),abs(s2),
 
899
     +                  abs(s3)) ) then
 
900
                    print *,'ffroot: error: xm not root! ',s1,s2,s3,
 
901
     +                  s1-s2+s3,ier
 
902
                endif
 
903
            endif
 
904
            if ( xp .ne. 0 ) then
 
905
                s1 = a*xp
 
906
                s2 = 2*b
 
907
                s3 = c/xp
 
908
                if ( rloss*abs(s1-s2+s3) .gt. precx*max(abs(s1),abs(s2),
 
909
     +                  abs(s3)) ) then
 
910
                    print *,'ffroot: error: xp not root! ',s1,s2,s3,
 
911
     +                  s1-s2+s3,ier
 
912
                endif
 
913
            endif
 
914
        endif
 
915
*  #] test output:
 
916
*###] ffroot:
 
917
        end
 
918
*###[ ffcoot:
 
919
        subroutine ffcoot(xm,xp,a,b,c,d,ier)
 
920
***#[*comment:***********************************************************
 
921
*                                                                       *
 
922
*       Calculate the roots of the equation                             *
 
923
*               a*x^2 - 2*b*x + c = 0                                   *
 
924
*       given by                                                        *
 
925
*               x = (b +/- d )/a        xp*xm = c/a                     *
 
926
*                                                                       *
 
927
***#]*comment:***********************************************************
 
928
*  #[ declarations:
 
929
        implicit none
 
930
*
 
931
*       arguments:
 
932
*
 
933
        integer ier
 
934
        DOUBLE COMPLEX xm,xp,a,b,c,d
 
935
*
 
936
*       local variables:
 
937
*
 
938
        DOUBLE COMPLEX s1,s2,s3,cc
 
939
        DOUBLE PRECISION absc,rloss
 
940
*
 
941
*       common blocks:
 
942
*
 
943
        include 'ff.h'
 
944
*
 
945
*       statement function
 
946
*
 
947
        absc(cc) = abs(DBLE(cc)) + abs(DIMAG(cc))
 
948
*  #] declarations:
 
949
*  #[ check input:
 
950
        if ( a .eq. 0 ) then
 
951
            call fferr(38,ier)
 
952
            if ( DBLE(b).gt.0 .eqv. DBLE(d).gt.0 ) then
 
953
                xp = 1/xclogm
 
954
                xm = c/(b+d)
 
955
            else
 
956
                xp = c/(b-d)
 
957
                xm = 1/xclogm
 
958
            endif
 
959
            return
 
960
        endif
 
961
*       if ( lwrite ) print *,'ffroot: a,b,c,d = ',a,b,c,d
 
962
*  #] check input:
 
963
*  #[ calculations:
 
964
        cc = b+d
 
965
        if ( d .eq. 0 ) then
 
966
            xm = b / a
 
967
            xp = xm
 
968
        elseif ( absc(cc) .gt. xloss*absc(d) ) then
 
969
            xp = ( b + d ) / a
 
970
            xm = c / (a*xp)
 
971
        else
 
972
            xm = ( b - d ) / a
 
973
            xp = c / (a*xm)
 
974
        endif
 
975
*  #] calculations:
 
976
*  #[ test output:
 
977
        if ( ltest ) then
 
978
            rloss = xloss**2*DBLE(10)**(-mod(ier,50))
 
979
            if ( absc(xm) .gt. xclogm ) then
 
980
                s1 = a*xm
 
981
                s2 = 2*b
 
982
                s3 = c/xm
 
983
                cc = s1-s2+s3
 
984
                if ( rloss*absc(cc).gt.precc*max(absc(s1),absc(
 
985
     +                  s2),absc(s3)) ) print *,
 
986
     +                  'ffcoot: error: xm not root! ',s1,s2,s3,s1-s2+s3
 
987
            endif
 
988
            if ( absc(xp) .gt. xclogm ) then
 
989
                s1 = a*xp
 
990
                s2 = 2*b
 
991
                s3 = c/xp
 
992
                cc = s1-s2+s3
 
993
                if ( rloss*absc(cc).gt.precc*max(absc(s1),absc(
 
994
     +                  s2),absc(s3)) ) print *,
 
995
     +                  'ffcoot: error: xp not root! ',s1,s2,s3,s1-s2+s3
 
996
            endif
 
997
        endif
 
998
*  #] test output:
 
999
*###] ffcoot:
 
1000
        end
 
1001
*###[ ffxhck:
 
1002
        subroutine ffxhck(xpi,dpipj,ns,ier)
 
1003
***#[*comment:***********************************************************
 
1004
*                                                                       *
 
1005
*       check whether the differences dpipj are compatible with xpi     *
 
1006
*                                                                       *
 
1007
***#]*comment:***********************************************************
 
1008
*  #[ declarations:
 
1009
        implicit none
 
1010
        integer ns,ier
 
1011
        DOUBLE PRECISION xpi(ns),dpipj(ns,ns)
 
1012
        integer i,j
 
1013
        DOUBLE PRECISION xheck,rloss
 
1014
        include 'ff.h'
 
1015
*  #] declarations:
 
1016
*  #[ calculations:
 
1017
        if ( ier.lt.0 ) then
 
1018
            print *,'ffxhck: error: ier < 0 ',ier
 
1019
            ier=0
 
1020
        endif
 
1021
        rloss = xloss**2*DBLE(10)**(-mod(ier,50))
 
1022
        do 20 i=1,ns
 
1023
            do 10 j=1,ns
 
1024
                xheck = dpipj(j,i) - xpi(j) + xpi(i)
 
1025
                if ( rloss*abs(xheck) .gt. precx*max(abs(dpipj(j,i)),
 
1026
     +                  abs(xpi(j)),abs(xpi(i))) ) then
 
1027
                    print *,'ffxhck: error: dpipj(',j,i,') <> xpi(',j,
 
1028
     +                  ') - xpi(',i,'):',dpipj(j,i),xpi(j),xpi(i),
 
1029
     +                  xheck,ier
 
1030
                    if ( lwrite ) ier = ier + 100
 
1031
                endif
 
1032
   10       continue
 
1033
   20   continue
 
1034
*  #] calculations:
 
1035
*###] ffxhck:
 
1036
        end
 
1037
*###[ ffchck:
 
1038
        subroutine ffchck(cpi,cdpipj,ns,ier)
 
1039
***#[*comment:***********************************************************
 
1040
*                                                                       *
 
1041
*       check whether the differences cdpipj are compatible with cpi    *
 
1042
*                                                                       *
 
1043
***#]*comment:***********************************************************
 
1044
*  #[ declarations:
 
1045
        implicit none
 
1046
        integer ns,ier
 
1047
        DOUBLE COMPLEX cpi(ns),cdpipj(ns,ns),c
 
1048
        integer i,j
 
1049
        DOUBLE COMPLEX check
 
1050
        DOUBLE PRECISION absc,rloss
 
1051
        include 'ff.h'
 
1052
        absc(c) = abs(DBLE(c)) + abs(DIMAG(c))
 
1053
*  #] declarations:
 
1054
*  #[ calculations:
 
1055
        if ( ier.lt.0 ) then
 
1056
            print *,'ffchck: error: ier < 0 ',ier
 
1057
            ier=0
 
1058
        endif
 
1059
        rloss = xloss**2*DBLE(10)**(-mod(ier,50))
 
1060
        do 20 i=1,ns
 
1061
            do 10 j=1,ns
 
1062
                check = cdpipj(j,i) - cpi(j) + cpi(i)
 
1063
                if ( rloss*absc(check) .gt. precc*max(absc(
 
1064
     +                  cdpipj(j,i)),absc(cpi(j)),absc(cpi(i))) ) then
 
1065
                    print *,'ffchck: error: cdpipj(',j,i,') <> cpi(',j,
 
1066
     +                 ') - cpi(',i,'):',cdpipj(j,i),cpi(j),cpi(i),
 
1067
     +                 check,ier
 
1068
                    if ( lwrite ) ier = ier + 100
 
1069
                endif
 
1070
   10       continue
 
1071
   20   continue
 
1072
*  #] calculations:
 
1073
*###] ffchck:
 
1074
        end
 
1075
*###[ nffeta:
 
1076
        integer function nffeta(ca,cb,ier)
 
1077
***#[*comment:***********************************************************
 
1078
*       calculates                                                      *
 
1079
*                                                                       *
 
1080
*       eta(a,b)/(2*i*pi) = ( thIm(-a)*thIm(-b)*thIm(a*b)               *
 
1081
*                               - thIm(a)*thIm(b)*thIm(-a*b) )          *
 
1082
*                                                                       *
 
1083
*       with thIm(a) = theta(Im(a))                                     *
 
1084
***#]*comment:***********************************************************
 
1085
*  #[ declarations:
 
1086
        implicit none
 
1087
        integer ier
 
1088
        DOUBLE COMPLEX ca,cb
 
1089
        DOUBLE PRECISION a,b,ab,rab
 
1090
        include 'ff.h'
 
1091
*  #] declarations:
 
1092
*  #[ calculations:
 
1093
        a = DIMAG(ca)
 
1094
        b = DIMAG(cb)
 
1095
        if ( a*b .lt. 0 ) then
 
1096
            nffeta = 0
 
1097
            return
 
1098
        endif
 
1099
        rab = DBLE(ca)*DBLE(cb) - a*b
 
1100
        ab = DBLE(ca)*b + a*DBLE(cb)
 
1101
        if ( abs(ab) .lt. precc*abs(DBLE(ca)*b) ) then
 
1102
            call fferr(32,ier)
 
1103
            if ( lwrite ) print *,'a,b = ',ca,cb,
 
1104
     +          ' (no precision left in DIMAG(ab)=',ab,')'
 
1105
        endif
 
1106
        if ( a .lt. 0 .and. b .lt. 0 .and. ab .gt. 0 ) then
 
1107
            nffeta = 1
 
1108
        elseif ( a .gt. 0 .and. b .gt. 0 .and. ab .lt. 0 ) then
 
1109
            nffeta = -1
 
1110
        elseif ( a .eq. 0 .and. DBLE(ca) .le. 0 .or.
 
1111
     +           b .eq. 0 .and. DBLE(cb) .le. 0 .or.
 
1112
     +           ab .eq. 0 .and. rab .le. 0 ) then
 
1113
            call fferr(32,ier)
 
1114
            if ( ltest .or. lwrite ) print *,'a,b = ',ca,cb
 
1115
            nffeta = 0
 
1116
        else
 
1117
            nffeta = 0
 
1118
        endif
 
1119
*  #] calculations:
 
1120
*###] nffeta:
 
1121
        end
 
1122
*###[ nffet1:
 
1123
        integer function nffet1(ca,cb,cc,ier)
 
1124
***#[*comment:***********************************************************
 
1125
*       calculates the same eta with three input variables              *
 
1126
*                                                                       *
 
1127
*       et1(a,b)/(2*i*pi) = ( thIm(-a)*thIm(-b)*thIm(c)                 *
 
1128
*                               - thIm(a)*thIm(b)*thIm(-c) )            *
 
1129
*                                                                       *
 
1130
*       with thIm(a) = theta(Im(a))                                     *
 
1131
***#]*comment:***********************************************************
 
1132
*  #[ declarations:
 
1133
        implicit none
 
1134
        integer ier
 
1135
        DOUBLE COMPLEX ca,cb,cc,c
 
1136
        DOUBLE PRECISION a,b,ab,abp,absc
 
1137
        include 'ff.h'
 
1138
        absc(c) = abs(DBLE(c)) + abs(DIMAG(c))
 
1139
*  #] declarations:
 
1140
*  #[ check input:
 
1141
        if ( ltest .and. DIMAG(ca)*DIMAG(cb) .gt. 0 .and. DBLE(ca)*DBLE(
 
1142
     +          cb) .ne. 0 ) then
 
1143
            ab = DIMAG(cc)
 
1144
            abp = DIMAG(ca*cb)
 
1145
            if ( xloss*abs(abp) .lt. precc*absc(ca)*absc(cb) )
 
1146
     +          abp = 0
 
1147
            if ( ab .gt. 0 .and. abp .lt. 0 .or. ab .lt. 0 .and. abp
 
1148
     +          .gt. 0  ) then
 
1149
                print *,'nffet1: error:  sgn im(ca*cb) != sgn im(cc): ',
 
1150
     +                  ab,abp
 
1151
            endif
 
1152
        endif
 
1153
*  #] check input:
 
1154
*  #[ calculations:
 
1155
        a = DIMAG(ca)
 
1156
        b = DIMAG(cb)
 
1157
        if ( a .gt. 0 .neqv. b .gt. 0 ) then
 
1158
            nffet1 = 0
 
1159
            return
 
1160
        endif
 
1161
        ab = DIMAG(cc)
 
1162
        if ( a .lt. 0 .and. b .lt. 0 .and. ab .gt. 0 ) then
 
1163
            nffet1 = 1
 
1164
        elseif ( a .gt. 0 .and. b .gt. 0 .and. ab .lt. 0 ) then
 
1165
            nffet1 = -1
 
1166
        elseif ( a .eq. 0 .and. DBLE(ca) .le. 0 .or.
 
1167
     +           b .eq. 0 .and. DBLE(cb) .le. 0 .or.
 
1168
     +           ab .eq. 0 .and. DBLE(cc) .le. 0 ) then
 
1169
            call fferr(33,ier)
 
1170
            if ( ltest.or.lwrite ) print *,'a,b,ab = ',ca,cb,cc
 
1171
            nffet1 = 1
 
1172
        else
 
1173
            nffet1 = 0
 
1174
        endif
 
1175
*  #] calculations:
 
1176
*###] nffet1:
 
1177
        end
 
1178
*###[ ffcayl:
 
1179
        subroutine ffcayl(cs,z,coeff,n,ier)
 
1180
***#[*comment:***********************************************************
 
1181
*                                                                       *
 
1182
*       Do a Taylor expansion in z with real coefficients coeff(i)      *
 
1183
*                                                                       *
 
1184
*       Input:  z               complex                                 *
 
1185
*               coeff(n)        real                                    *
 
1186
*               n               integer                                 *
 
1187
*                                                                       *
 
1188
*       Output  cs              complex         \sum_{i=1} z^i coeff(i) *
 
1189
*                                                                       *
 
1190
***#]*comment:***********************************************************
 
1191
*  #[ declarations:
 
1192
        implicit none
 
1193
*
 
1194
*       arguments
 
1195
*
 
1196
        integer n,ier
 
1197
        DOUBLE PRECISION coeff(n)
 
1198
        DOUBLE COMPLEX z,cs
 
1199
*
 
1200
*       local variables
 
1201
*
 
1202
        integer i
 
1203
        DOUBLE PRECISION absc
 
1204
        DOUBLE COMPLEX c,zi,csi
 
1205
*
 
1206
*       common blocks
 
1207
*
 
1208
        include 'ff.h'
 
1209
*
 
1210
*       statement function
 
1211
*
 
1212
        absc(c) = abs(DBLE(c)) + abs(DIMAG(c))
 
1213
*
 
1214
*  #] declarations:
 
1215
*  #[ work:
 
1216
        cs = z*DBLE(coeff(1))
 
1217
        if ( absc(z) .lt. precc ) return
 
1218
        zi = z
 
1219
        do 10 i=2,n
 
1220
            zi = zi*z
 
1221
            csi = zi*DBLE(coeff(i))
 
1222
            cs = cs + csi
 
1223
            if ( absc(csi) .lt. precc*absc(cs) ) goto 20
 
1224
   10   continue
 
1225
        call ffwarn(9,ier,precc,absc(csi))
 
1226
   20   continue
 
1227
*  #] work:
 
1228
*###] ffcayl:
 
1229
        end
 
1230
*###[ fftayl:
 
1231
        subroutine fftayl(s,z,coeff,n,ier)
 
1232
***#[*comment:***********************************************************
 
1233
*                                                                       *
 
1234
*       Do a Taylor expansion in z with real coefficients coeff(i)      *
 
1235
*                                                                       *
 
1236
*       Input:  z               real                                    *
 
1237
*               coeff(n)        real                                    *
 
1238
*               n               integer                                 *
 
1239
*                                                                       *
 
1240
*       Output  cs              real            \sum_{i=1} z^i coeff(i) *
 
1241
*                                                                       *
 
1242
***#]*comment:***********************************************************
 
1243
*  #[ declarations:
 
1244
        implicit none
 
1245
*
 
1246
*       arguments
 
1247
*
 
1248
        integer n,ier
 
1249
        DOUBLE PRECISION coeff(n),z,s
 
1250
*
 
1251
*       local variables
 
1252
*
 
1253
        integer i
 
1254
        DOUBLE PRECISION zi,si
 
1255
*
 
1256
*       common blocks
 
1257
*
 
1258
        include 'ff.h'
 
1259
*
 
1260
*  #] declarations:
 
1261
*  #[ work:
 
1262
        s = coeff(1)*z
 
1263
        if ( abs(z) .lt. precx ) return
 
1264
        zi = z
 
1265
        do 10 i=2,n
 
1266
            zi = zi*z
 
1267
            si = coeff(i)*zi
 
1268
            s = s + si
 
1269
            if ( abs(si) .lt. precx*abs(s) ) goto 20
 
1270
   10   continue
 
1271
        call ffwarn(9,ier,precx,si)
 
1272
   20   continue
 
1273
*  #] work:
 
1274
*###] fftayl:
 
1275
        end
 
1276