~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to madgraph/iolibs/template_files/loop_optimized/loop_matrix_standalone.inc

  • Committer: olivier Mattelaer
  • Date: 2015-03-05 00:14:16 UTC
  • mfrom: (258.1.9 2.3)
  • mto: (258.8.1 2.3)
  • mto: This revision was merged to the branch mainline in revision 259.
  • Revision ID: olivier.mattelaer@uclouvain.be-20150305001416-y9mzeykfzwnl9t0j
partial merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
%(process_lines)s
14
14
C  
15
15
      IMPLICIT NONE
 
16
C
 
17
C USER CUSTOMIZABLE OPTIONS
 
18
 
19
## if(ComputeColorFlows) {
 
20
C The variables below are just used in the context of a JAMP consistency check turned off by default.
 
21
      %(real_dp_format)s JAMP_DOUBLECHECK_THRES
 
22
      PARAMETER (JAMP_DOUBLECHECK_THRES=1.0d-9)
 
23
      LOGICAL DIRECT_ME_COMPUTATION, ME_COMPUTATION_FROM_JAMP
 
24
C     Modify the logicals below to chose how the ME must be computed
 
25
C        DIRECT_ME_COMPUTATION    = Each loop amplitude is squared individually against all amplitudes with its own color factor.
 
26
C        ME_COMPUTATION_FROM_JAMP = Amplitudes are first projected onto color flows (many less of them) which are then squared to form the ME.
 
27
C     When setting both computation method to .TRUE., their systematic comparisons will be printed out.
 
28
## if(LoopInduced) {
 
29
      DATA DIRECT_ME_COMPUTATION/.FALSE./
 
30
      DATA ME_COMPUTATION_FROM_JAMP/.TRUE./
 
31
## } else {
 
32
      DATA DIRECT_ME_COMPUTATION/.TRUE./
 
33
      DATA ME_COMPUTATION_FROM_JAMP/.FALSE./
 
34
## }
 
35
## }
 
36
C     This parameter is designed for the check timing command of MG5. It skips the loop reduction.
 
37
      LOGICAL SKIPLOOPEVAL
 
38
      PARAMETER (SKIPLOOPEVAL=.FALSE.)
 
39
C     For timing checks. Stops the code after having only initialized its arrays from the external data files 
 
40
          LOGICAL BOOTANDSTOP
 
41
      PARAMETER (BOOTANDSTOP=.FALSE.)
 
42
## if(TIRCaching) {
 
43
      INTEGER TIR_CACHE_SIZE
 
44
C To change memory foot-print of MadLoop, you can change this parameter to be 0,1 or 2 *and recompile*.
 
45
C Notice that this will impact MadLoop speed performances in the context of stability checks.
 
46
      include 'tir_cache_size.inc'
 
47
## }
16
48
C  
17
49
C CONSTANTS
18
50
C
27
59
      PARAMETER ( ColorDenomFName='ColorDenomFactors.dat')
28
60
      PARAMETER ( Proc_Prefix='%(proc_prefix)s')
29
61
 
30
 
          %(nbornamps_decl)s
 
62
## if (not LoopInduced) {
 
63
          INTEGER NBORNAMPS
 
64
      PARAMETER (NBORNAMPS=%(nbornamps)d)
 
65
## }
31
66
      INTEGER    NLOOPS, NLOOPGROUPS, NCTAMPS
32
67
      PARAMETER (NLOOPS=%(nloops)d, NLOOPGROUPS=%(nloop_groups)d, NCTAMPS=%(nctamps)d)
 
68
      INTEGER    NLOOPAMPS
 
69
      PARAMETER (NLOOPAMPS=%(nloopamps)d)
33
70
      INTEGER    NCOLORROWS
34
 
          PARAMETER (NCOLORROWS=%(nloopamps)d)
 
71
          PARAMETER (NCOLORROWS=NLOOPAMPS)
35
72
          INTEGER    NEXTERNAL
36
73
      PARAMETER (NEXTERNAL=%(nexternal)d)
37
74
      INTEGER    NWAVEFUNCS,NLOOPWAVEFUNCS
65
102
C     Only CutTools provides QP
66
103
      INTEGER QP_NLOOPLIB
67
104
      PARAMETER (QP_NLOOPLIB=1)
68
 
C     This parameter is designed for the check timing command of MG5
69
 
      LOGICAL SKIPLOOPEVAL
70
 
      PARAMETER (SKIPLOOPEVAL=.FALSE.)
71
 
          LOGICAL BOOTANDSTOP
72
 
      PARAMETER (BOOTANDSTOP=.FALSE.)
73
105
          INTEGER MAXSTABILITYLENGTH
74
106
          DATA MAXSTABILITYLENGTH/20/
75
107
          common/%(proc_prefix)sstability_tests/maxstabilitylength
 
108
 
76
109
C  
77
110
C ARGUMENTS 
78
111
C  
93
126
C  
94
127
C LOCAL VARIABLES 
95
128
C  
96
 
      INTEGER I,J,K,H,DUMMY,I_QP_LIB
 
129
      INTEGER I,J,K,H,HEL_MULT,I_QP_LIB,DUMMY
97
130
 
98
131
      CHARACTER*512 ParamFN,HelConfigFN,LoopFilterFN,ColorNumFN,ColorDenomFN,HelFilterFN
99
132
          CHARACTER*512 TMP
120
153
      LOGICAL EVAL_DONE(MAXSTABILITYLENGTH)
121
154
          LOGICAL DOING_QP_EVALS
122
155
      INTEGER STAB_INDEX,BASIC_CT_MODE
123
 
          INTEGER N_DP_EVAL, N_QP_EVAL
124
 
          DATA N_DP_EVAL/1/
125
 
          DATA N_QP_EVAL/1/
 
156
 
 
157
## if(LoopInduced){       
 
158
C This is used for loop-induced where the reference scale for comparisons is inferred from the first 30 points at most
 
159
      INTEGER MAXNREF_EVALS
 
160
      PARAMETER (MAXNREF_EVALS=30)
 
161
      %(real_dp_format)s REF_EVALS(MAXNREF_EVALS)
 
162
      DATA REF_EVALS/MAXNREF_EVALS*ZERO/
 
163
      INTEGER NPSPOINTS
 
164
      DATA NPSPOINTS/0/      
 
165
## }
 
166
 
126
167
          %(real_dp_format)s ACC(0:NSQUAREDSO)
127
168
          %(real_dp_format)s DP_RES(3,0:NSQUAREDSO,MAXSTABILITYLENGTH)
128
169
C QP_RES STORES THE QUADRUPLE PRECISION RESULT OBTAINED FROM DIFFERENT EVALUATION METHODS IN ORDER TO ASSESS STABILITY.
134
175
          %(real_dp_format)s HELSAVED(3,NCOMB)
135
176
          INTEGER ITEMP
136
177
          LOGICAL LTEMP
137
 
          %(real_dp_format)s BORNBUFF(0:NSQSO_BORN)
138
 
          %(real_dp_format)s BUFFR(3,0:NSQUAREDSO),BUFFR_BIS(3,0:NSQUAREDSO),TEMP(0:3,0:NSQUAREDSO),TEMP1(0:NSQUAREDSO),TEMP2
 
178
          %(real_dp_format)s BORNBUFF(0:NSQSO_BORN),TMPR
 
179
          %(real_dp_format)s BUFFR(3,0:NSQUAREDSO),BUFFR_BIS(3,0:NSQUAREDSO),TEMP(0:3,0:NSQUAREDSO),TEMP1(0:NSQUAREDSO)
 
180
## if(not AmplitudeReduction){
 
181
          %(real_dp_format)s TEMP2
 
182
## }else{
 
183
          %(real_dp_format)s TEMP2(3)
 
184
## }
 
185
## if(ComputeColorFlows) {
 
186
          %(real_dp_format)s BUFFRES(0:3,0:NSQUAREDSO)
 
187
## }
139
188
          %(complex_dp_format)s COEFS(MAXLWFSIZE,0:VERTEXMAXCOEFS-1,MAXLWFSIZE)
140
189
      %(complex_dp_format)s CFTOT
141
190
          LOGICAL FOUNDHELFILTER,FOUNDLOOPFILTER
144
193
      LOGICAL LOOPFILTERBUFF(NSQUAREDSO,NLOOPGROUPS)
145
194
          DATA ((LOOPFILTERBUFF(J,I),J=1,NSQUAREDSO),I=1,NLOOPGROUPS)/NSQSOXNLG*.FALSE./
146
195
 
 
196
      LOGICAL AUTOMATIC_TIR_CACHE_CLEARING
 
197
      DATA AUTOMATIC_TIR_CACHE_CLEARING/.TRUE./
 
198
      COMMON/%(proc_prefix)sRUNTIME_OPTIONS/AUTOMATIC_TIR_CACHE_CLEARING
 
199
 
147
200
          INTEGER IDEN
148
201
      %(den_factor_line)s
149
202
          INTEGER HELAVGFACTOR
161
214
C
162
215
C FUNCTIONS
163
216
C
 
217
          INTEGER %(proc_prefix)sTIRCACHE_INDEX
164
218
      INTEGER %(proc_prefix)sML5SOINDEX_FOR_BORN_AMP
165
219
          INTEGER %(proc_prefix)sML5SOINDEX_FOR_LOOP_AMP
166
220
          INTEGER %(proc_prefix)sML5SQSOINDEX
167
221
      INTEGER %(proc_prefix)sISSAME
168
222
      LOGICAL %(proc_prefix)sISZERO
169
223
      INTEGER SET_RET_CODE_U
 
224
## if(LoopInduced){
 
225
          %(real_dp_format)s Median
 
226
## }
170
227
C  
171
228
C GLOBAL VARIABLES
172
229
C  
174
231
          include 'mp_coupl.inc'
175
232
          include 'MadLoopParams.inc'
176
233
 
 
234
## if(ComputeColorFlows) {
 
235
      %(real_dp_format)s RES_FROM_JAMP(0:3,0:NSQUAREDSO)
 
236
          common/%(proc_prefix)sDOUBLECHECK_JAMP/RES_FROM_JAMP,DIRECT_ME_COMPUTATION,ME_COMPUTATION_FROM_JAMP
 
237
## }
 
238
 
177
239
      LOGICAL CHOSEN_SO_CONFIGS(NSQUAREDSO)
178
240
          DATA CHOSEN_SO_CONFIGS/%(chosen_so_configs)s/
179
241
      COMMON/%(proc_prefix)sCHOSEN_LOOP_SQSO/CHOSEN_SO_CONFIGS
180
242
 
 
243
          INTEGER N_DP_EVAL, N_QP_EVAL
 
244
          DATA N_DP_EVAL/1/
 
245
          DATA N_QP_EVAL/1/
 
246
          COMMON/%(proc_prefix)sN_EVALS/N_DP_EVAL,N_QP_EVAL
 
247
 
181
248
          LOGICAL CHECKPHASE
182
249
          DATA CHECKPHASE/.TRUE./
183
250
          LOGICAL HELDOUBLECHECKED
192
259
          DATA MP_DONE/.FALSE./
193
260
          common/%(proc_prefix)sMP_DONE/MP_DONE
194
261
C     A FLAG TO DENOTE WHETHER THE CORRESPONDING LOOPLIBS ARE AVAILABLE OR NOT
195
 
          LOGICAL LOOPLIBS_AVAILABLE(4)
196
 
          %(data_looplibs_av)s
 
262
      LOGICAL LOOPLIBS_AVAILABLE(4)
 
263
      DATA LOOPLIBS_AVAILABLE/%(data_looplibs_av)s/
197
264
          common/%(proc_prefix)sLOOPLIBS_AV/ LOOPLIBS_AVAILABLE
198
265
C     A FLAG TO DENOTE WHETHER THE CORRESPONDING DIRECTION TESTS AVAILABLE OR NOT IN THE LOOPLIBS
199
266
C     PJFry++ and Golem95 do not support direction test
200
 
          LOGICAL LOOPLIBS_DIRECTEST(4)
201
 
          DATA LOOPLIBS_DIRECTEST /.TRUE.,.FALSE.,.TRUE.,.FALSE./
 
267
      LOGICAL LOOPLIBS_DIRECTEST(4)
 
268
          DATA LOOPLIBS_DIRECTEST /.TRUE.,.TRUE.,.TRUE.,.TRUE./
202
269
 
203
270
C     PS CAN POSSIBILY BE PASSED THROUGH IMPROVE_PS BUT IS NOT MODIFIED FOR THE PURPOSE OF THE STABILITY TEST
204
271
C     EVEN THOUGH THEY ARE PUT IN COMMON BLOCK, FOR NOW THEY ARE NOT USED ANYWHERE ELSE
232
299
          INTEGER USERHEL
233
300
          DATA USERHEL/-1/
234
301
          common/%(proc_prefix)sUSERCHOICE/USERHEL
235
 
 
 
302
          
236
303
C     This integer can be accessed by an external user to set its target squared split order.
237
304
C     If set to a value different than -1, the code will try to avoid computing anything which
238
305
C     does not contribute to contributions of squared split orders SQSO_TARGET and below.
264
331
          INTEGER INDEX_QP_TOOLS(QP_NLOOPLIB+1)
265
332
          common/%(proc_prefix)sLOOP_TOOLS/QP_TOOLS_AVAILABLE,INDEX_QP_TOOLS
266
333
 
267
 
          %(dp_born_amps_decl)s   
 
334
## if(not LoopInduced) {
 
335
          %(complex_dp_format)s AMP(NBORNAMPS)
 
336
          common/%(proc_prefix)sAMPS/AMP
 
337
## }
268
338
          %(complex_dp_format)s W(20,NWAVEFUNCS)
269
339
          common/%(proc_prefix)sW/W  
270
340
 
275
345
          %(complex_dp_format)s PL(0:3,0:NLOOPWAVEFUNCS)
276
346
          common/%(proc_prefix)sWL/WL,PL
277
347
 
 
348
## if(not AmplitudeReduction){
278
349
          %(complex_dp_format)s LOOPCOEFS(0:LOOPMAXCOEFS-1,NSQUAREDSO,NLOOPGROUPS)
 
350
## } else {
 
351
          %(complex_dp_format)s LOOPCOEFS(0:LOOPMAXCOEFS-1,NLOOPGROUPS)
 
352
## }
279
353
          common/%(proc_prefix)sLCOEFS/LOOPCOEFS
280
354
 
 
355
## if(AmplitudeReduction) {
 
356
C This flag is used to prevent the re-computation of the OpenLoop coefficients when changing the CTMode for the stability test.
 
357
          LOGICAL SKIP_LOOPNUM_COEFS_CONSTRUCTION
 
358
          DATA SKIP_LOOPNUM_COEFS_CONSTRUCTION/.FALSE./
 
359
          COMMON/%(proc_prefix)sSKIP_COEFS/SKIP_LOOPNUM_COEFS_CONSTRUCTION
 
360
## }
 
361
 
 
362
## if(TIRCaching){
 
363
          LOGICAL TIR_DONE(NLOOPGROUPS)
 
364
          COMMON/%(proc_prefix)sTIRCACHING/TIR_DONE
 
365
## }
 
366
 
 
367
## if(not AmplitudeReduction){
281
368
      %(complex_dp_format)s AMPL(3,NCTAMPS)
 
369
## } else {
 
370
      %(complex_dp_format)s AMPL(3,NLOOPAMPS)
 
371
## }
282
372
          common/%(proc_prefix)sAMPL/AMPL
283
373
 
284
374
      %(complex_dp_format)s LOOPRES(3,NSQUAREDSO,NLOOPGROUPS)
285
375
          LOGICAL S(NSQUAREDSO,NLOOPGROUPS)
286
376
          common/%(proc_prefix)sLOOPRES/LOOPRES,S
287
 
 
 
377
          
288
378
          INTEGER CF_D(NCOLORROWS,%(color_matrix_size)s)
289
379
          INTEGER CF_N(NCOLORROWS,%(color_matrix_size)s)
290
380
          common/%(proc_prefix)sCF/CF_D,CF_N
321
411
C ----------
322
412
 
323
413
IF(ML_INIT) THEN
 
414
  ML_INIT = .FALSE.
324
415
  CALL PRINT_MADLOOP_BANNER()
325
416
  TMP = 'auto'
326
417
  CALL setMadLoopPath(TMP)
327
418
  CALL JOINPATH(MLPATH,PARAMFNAME,PARAMFN)
328
419
  CALL MADLOOPPARAMREADER(PARAMFN,.TRUE.)
329
 
  ML_INIT = .FALSE.
 
420
## if(LoopInduced){
 
421
  IF(.NOT.LoopInitStartOver) THEN
 
422
    WRITE(*,*) 'INFO: For loop-induced processes it is preferable to always set the parameter LoopInitStartOver to True, so it is hard-set here to True.'
 
423
    LoopInitStartOver=.TRUE.
 
424
  ENDIF
 
425
  IF(.NOT.HelInitStartOver) THEN
 
426
    WRITE(*,*) "INFO: For loop-induced processes it is preferable to always set the parameter HelInitStartOver to True, so it is hard-set here to True.'
 
427
    HelInitStartOver=.TRUE.
 
428
  ENDIF
 
429
  IF (CheckCycle.LT.5) THEN
 
430
    WRITE(*,*) "INFO: Due to the dynamic setting of the reference scale for contributions comparisons, it is preferable to set the parameter CheckCycle to a value larger than 4, so it is hard-set here to 5.'
 
431
    CheckCycle=5
 
432
  ENDIF
 
433
## }
 
434
 
 
435
C Make sure that NROTATIONS_QP and NROTATIONS_DP are set to zero if AUTOMATIC_TIR_CACHE_CLEARING is disabled.
 
436
  if(.NOT.AUTOMATIC_TIR_CACHE_CLEARING) THEN
 
437
    IF(NROTATIONS_DP.NE.0.or.NROTATIONS_QP.NE.0) THEN
 
438
      WRITE(*,*) 'INFO: AUTOMATIC_TIR_CACHE_CLEARING is disabled, so MadLoop automatically resets NROTATIONS_DP and NROTATIONS_QP to 0.'
 
439
      NROTATIONS_QP=0
 
440
      NROTATIONS_DP=0
 
441
    ENDIF
 
442
  ENDIF
330
443
ENDIF
331
444
 
332
 
IF(NTRY.EQ.0) THEN
333
 
C  CALL MADLOOPPARAMREADER(paramFileName,.TRUE.)
334
445
  QP_TOOLS_AVAILABLE=.FALSE.
335
446
  INDEX_QP_TOOLS(1:QP_NLOOPLIB+1)=0
336
447
C SKIP THE ONES THAT NOT AVAILABLE
367
478
 
368
479
  CALL %(proc_prefix)sSET_N_EVALS(N_DP_EVAL,N_QP_EVAL)  
369
480
 
370
 
  HELDOUBLECHECKED=.NOT.DoubleCheckHelicityFilter
371
 
OPEN(1, FILE=LoopFilterFN, err=100, status='OLD',           action='READ')
372
 
  DO J=1,NLOOPGROUPS
373
 
    READ(1,*,END=101) (GOODAMP(I,J),I=1,NSQUAREDSO)
374
 
  ENDDO
375
 
  GOTO 101
376
 
100  CONTINUE
377
 
  FOUNDLOOPFILTER=.FALSE.
378
 
  DO J=1,NLOOPGROUPS
379
 
    DO I=1,NSQUAREDSO
380
 
          GOODAMP(I,J)=(.NOT.USELOOPFILTER)
381
 
        ENDDO
382
 
  ENDDO
383
 
101  CONTINUE
384
 
CLOSE(1)
385
 
 
386
 
OPEN(1, FILE=HelFilterFN, err=102, status='OLD',           action='READ')
387
 
  DO I=1,NCOMB
388
 
    READ(1,*,END=103) GOODHEL(I)
389
 
  ENDDO
390
 
  GOTO 103
391
 
102  CONTINUE
392
 
  FOUNDHELFILTER=.FALSE.
393
 
  DO J=1,NCOMB
394
 
        GOODHEL(J)=1
395
 
  ENDDO
396
 
103  CONTINUE
397
 
CLOSE(1)
398
 
 
399
481
OPEN(1, FILE=ColorNumFN, err=104, status='OLD',           action='READ')
400
482
  DO I=1,NCOLORROWS
401
483
    READ(1,*,END=105) (CF_N(I,J),J=1,%(color_matrix_size)s)
444
526
    WRITE(*,*) 'Stopped by user request.'
445
527
    stop
446
528
  ENDIF
447
 
ENDIF
448
 
 
449
 
%(compute_born)s
450
 
 
451
 
%(set_reference)s
 
529
 
 
530
IF(NTRY.EQ.0) THEN
 
531
  HELDOUBLECHECKED=(.NOT.DoubleCheckHelicityFilter).OR.(HelicityFilterLevel.eq.0)
 
532
OPEN(1, FILE=LoopFilterFN, err=100, status='OLD',           action='READ')
 
533
  DO J=1,NLOOPGROUPS
 
534
    READ(1,*,END=101) (GOODAMP(I,J),I=1,NSQUAREDSO)
 
535
  ENDDO
 
536
  GOTO 101
 
537
100  CONTINUE
 
538
  FOUNDLOOPFILTER=.FALSE.
 
539
  DO J=1,NLOOPGROUPS
 
540
    DO I=1,NSQUAREDSO
 
541
          GOODAMP(I,J)=(.NOT.USELOOPFILTER)
 
542
        ENDDO
 
543
  ENDDO
 
544
101  CONTINUE
 
545
CLOSE(1)
 
546
 
 
547
IF (HelicityFilterLevel.eq.0) then
 
548
  FOUNDHELFILTER=.TRUE.
 
549
  DO J=1,NCOMB
 
550
        GOODHEL(J)=1
 
551
  ENDDO
 
552
  GOTO 122
 
553
ENDIF
 
554
OPEN(1, FILE=HelFilterFN, err=102, status='OLD',           action='READ')
 
555
  DO I=1,NCOMB
 
556
    READ(1,*,END=103) GOODHEL(I)
 
557
  ENDDO
 
558
  GOTO 103
 
559
102  CONTINUE
 
560
  FOUNDHELFILTER=.FALSE.
 
561
  DO J=1,NCOMB
 
562
        GOODHEL(J)=1
 
563
  ENDDO
 
564
103  CONTINUE
 
565
CLOSE(1)
 
566
IF (HelicityFilterLevel.eq.1) then
 
567
C We must make sure to remove the matching-helicity optimisation, as requested by the user.
 
568
  DO J=1,NCOMB
 
569
    IF ((GOODHEL(J).GT.1).OR.(GOODHEL(J).LT.HELOFFSET)) THEN
 
570
          GOODHEL(J)=1
 
571
        ENDIF
 
572
  ENDDO
 
573
ENDIF
 
574
122  CONTINUE
 
575
ENDIF
 
576
 
 
577
## if(LoopInduced){
 
578
C The born is of course 0 for loop-induced processes.
 
579
DO I=0,NSQUAREDSO
 
580
  ANS(0,I)=0.0d0
 
581
ENDDO
 
582
## }else{
 
583
C First compute the borns, it will store them in ANS(0,I)
 
584
C It is left untouched for the rest of MadLoop evaluation.
 
585
C Notice that the squared split order index I does NOT
 
586
C correspond to the same ordering of J for the loop ME 
 
587
C results stored in ANS(K,J), with K in [1-3].The ordering 
 
588
C of each can be obtained with ML5SOINDEX_FOR_SQUARED_ORDERS 
 
589
C and SQSOINDEX_FROM_ORDERS for the loop ME and born ME 
 
590
C respectively. For this to work, we assume that there is 
 
591
C always more squared split orders in the loop ME than in the
 
592
C born ME, which is practically always true. In any case, only
 
593
C the split_order summed value I=0 is used in ML5 code.
 
594
DO I=0,NSQSO_BORN
 
595
  BORNBUFF(I)=0.0d0
 
596
ENDDO
 
597
CALL %(proc_prefix)sSMATRIXHEL_SPLITORDERS(P_USER,USERHEL,BORNBUFF(0))
 
598
DO I=0,NSQSO_BORN
 
599
  ANS(0,I)=BORNBUFF(I)
 
600
ENDDO
 
601
## }
 
602
 
 
603
## if(LoopInduced){
 
604
C For loop-induced, the reference for comparison is set later from the total contribution of the previous PS point considered.
 
605
C But you can edit here the value to be used for the first PS points.    
 
606
IF (NPSPOINTS.EQ.0) THEN
 
607
  REF=1.0D-50
 
608
ELSE
 
609
  IF(NPSPOINTS.GE.MAXNREF_EVALS) THEN
 
610
    REF=Median(REF_EVALS,MAXNREF_EVALS)
 
611
  ELSE
 
612
    REF=Median(REF_EVALS,NPSPOINTS)
 
613
  ENDIF
 
614
ENDIF
 
615
## }else{
 
616
C We set here the reference to the born summed over all split orders
 
617
REF=0.0d0
 
618
DO I=1,NSQSO_BORN
 
619
REF=REF+ANS(0,I)
 
620
ENDDO
 
621
## }
452
622
 
453
623
MP_DONE=.FALSE.
454
624
MP_DONE_ONCE=.FALSE.
460
630
  EVAL_DONE(I)=.FALSE.
461
631
ENDDO
462
632
 
 
633
## if(LoopInduced) {
 
634
C For loop-induced processes, we should make sure not to use the first points
 
635
C to set the filters because it doesn't have a reasonable REF scale yet.
 
636
IF(.NOT.BYPASS_CHECK.AND.NPSPOINTS.GE.1) THEN
 
637
## } else {
463
638
IF(.NOT.BYPASS_CHECK) THEN
 
639
## }
464
640
  NTRY=NTRY+1
465
641
ENDIF
466
642
 
483
659
CHECKPHASE=(NTRY.LE.CHECKCYCLE).AND.(((.NOT.FOUNDLOOPFILTER).AND.USELOOPFILTER).OR.(.NOT.FOUNDHELFILTER))
484
660
 
485
661
IF (WriteOutFilters) THEN
486
 
IF ((.NOT. CHECKPHASE).AND.(.NOT.FOUNDHELFILTER)) THEN
487
 
 
 
662
IF ((HelicityFilterLevel.ne.0).AND.(.NOT. CHECKPHASE).AND.(.NOT.FOUNDHELFILTER)) THEN
488
663
OPEN(1, FILE=HelFilterFN, err=110, status='NEW',action='WRITE')
489
664
  DO I=1,NCOMB
490
665
    WRITE(1,*) GOODHEL(I)  
550
725
  ENDDO
551
726
ENDDO
552
727
 
 
728
## if(TIRCaching){
 
729
IF (AUTOMATIC_TIR_CACHE_CLEARING) THEN
 
730
  CALL %(proc_prefix)sCLEAR_TIR_CACHE()
 
731
ENDIF
 
732
## }
 
733
 
553
734
IF (ImprovePSPoint.ge.0) THEN
554
735
C Make the input PS more precise (exact onshell and energy-momentum conservation)
555
736
  CALL %(proc_prefix)sIMPROVE_PS_POINT_PRECISION(PS)
565
746
  DO I=0,NSQUAREDSO
566
747
    BUFFR(K,I)=0.0d0
567
748
  ENDDO
 
749
## if(not AmplitudeReduction){
568
750
  DO I=1,NCTAMPS
 
751
## }else{
 
752
  DO I=1,NLOOPAMPS
 
753
## }
569
754
    AMPL(K,I)=(0.0d0,0.0d0)
570
755
  ENDDO
571
756
ENDDO
572
 
C     USE THE FIRST LOOP REDUCTION LIBRARY AND THE FIRST QP LOOP REDUCTION LIBRARY
 
757
 
 
758
C Start by using the first available loop reduction library and qp library.
573
759
I_LIB=1
574
760
I_QP_LIB=1
 
761
 
 
762
goto 208
 
763
C MadLoop jumps to this label during stability checks when it recomputes a rotated PS point
575
764
200 CONTINUE
 
765
C For the computation of a rotated version of this PS point we must reset the TIR cache since this changes the definition of the loop denominators.
 
766
CALL %(proc_prefix)sCLEAR_TIR_CACHE()
 
767
208 CONTINUE
 
768
## if(AmplitudeReduction) {
 
769
SKIP_LOOPNUM_COEFS_CONSTRUCTION=.FALSE.
 
770
GOTO 308
 
771
C MadLoop jumps to this label during stability checks when it recomputes the same PS point with a different CTMode
 
772
300 CONTINUE
 
773
C Of course the trick of reusing coefficients when reducing at the amplitude level only works when computing one helicity at a time
 
774
if (USERHEL.ne.-1) THEN
 
775
  SKIP_LOOPNUM_COEFS_CONSTRUCTION = .TRUE.
 
776
ENDIF
 
777
308 CONTINUE
 
778
## if(ComputeColorFlows) {
 
779
C We don't want to re-initialized the following quantities when checking the helicity filter. (which jumps to label 205 to probe each helicity).
 
780
C We however want to re-initialize them for each new computation part of the stability check (which jumps to label 200)
 
781
C This code is therefore placed before 205 and after 200.
 
782
CALL %(proc_prefix)sREINITIALIZE_CUMULATIVE_ARRAYS()
 
783
IF (ME_COMPUTATION_FROM_JAMP) THEN
 
784
C If both ME computational methods have been used, then the ME computation from color flows was stored in RES_FROM_JAMP and we must reset it here.
 
785
  DO I=0,NSQUAREDSO
 
786
    DO K=0,3
 
787
      RES_FROM_JAMP(K,I)=0.0d0
 
788
    ENDDO
 
789
  ENDDO
 
790
ENDIF
 
791
IF ((.NOT.DIRECT_ME_COMPUTATION).AND.ME_COMPUTATION_FROM_JAMP) THEN
 
792
C When computing the ME with color flows, the Born ME will be computed as well, so we reset here the result obtained from the smatrix call above.
 
793
DO I=0,NSQUAREDSO
 
794
  ANS(0,I)=0.0d0
 
795
ENDDO
 
796
ENDIF
 
797
## }
 
798
 
 
799
## if(iregi_available) {
 
800
C     Free cache when using IREGI
 
801
      IF(IREGIRECY.AND.MLReductionLib(I_LIB).EQ.3) THEN
 
802
        CALL IREGI_FREE_PS()
 
803
      ENDIF
 
804
## }
 
805
 
 
806
## if(TIRCaching){
 
807
C Even if the user did ask to turn off the automatic TIR cache clearing, we must do it now if the CTModeIndex rolls over the size of the TIR cache employed.
 
808
C Notice that we must do that only when processing a new CT mode as part of the stability test and not when computing a new helicity as part of the filtering process.
 
809
C This we check that we are not in the initialization phase.
 
810
C If we are not in CTModeRun=-1, then we never need to clear the cache since the TIR will always be used for a unique computation (not stab test).
 
811
C Also, it is clear that if we are running OPP when reaching this line, then we shouldn't clear the TIR cache as it might still be useful later.
 
812
C Finally, notice that the conditional statement below should never be true except you have TIR library supporting quadruple precision or when TIR_CACHE_SIZE<2.
 
813
IF((.NOT.CHECKPHASE.AND.(HELDOUBLECHECKED)).and.CTMODERUN.eq.-1.and.MLReductionLib(I_LIB).ne.1..AND.(%(proc_prefix)sTIRCACHE_INDEX(CTMODE).eq.(TIR_CACHE_SIZE+1))) THEN
 
814
  CALL %(proc_prefix)sCLEAR_TIR_CACHE()
 
815
ENDIF
 
816
## }
 
817
 
 
818
## }
 
819
 
 
820
C MadLoop jumps to this label during initialization when it goes to the computation of the next helicity.
 
821
205 CONTINUE
576
822
 
577
823
IF (.NOT.MP_PS_SET.AND.(CTMODE.EQ.0.OR.CTMODE.GE.4)) THEN
578
824
  CALL %(proc_prefix)sSET_MP_PS(P_USER)
584
830
CTCALL_REQ_SO_DONE=.FALSE.
585
831
FILTER_SO = (.NOT.CHECKPHASE).AND.HELDOUBLECHECKED.AND.(SQSO_TARGET.ne.-1)
586
832
 
 
833
## if(not AmplitudeReduction){
587
834
DO I=1,NLOOPGROUPS
588
835
  DO J=0,LOOPMAXCOEFS-1
589
836
    DO K=1,NSQUAREDSO
591
838
        ENDDO
592
839
  ENDDO
593
840
ENDDO
 
841
## }
594
842
 
595
843
DO I=1,NLOOPGROUPS
596
844
  DO J=1,3
597
845
    DO K=1,NSQUAREDSO  
598
 
      LOOPRES(J,K,I)=0.0d0
 
846
      LOOPRES(J,K,I)=(0.0d0,0.0d0)
599
847
        ENDDO
600
848
  ENDDO
601
849
ENDDO
608
856
 
609
857
C Check if we directly go to multiple precision
610
858
IF (CTMODE.GE.4) THEN
 
859
## if(not AmplitudeReduction){
611
860
  IF (.NOT.MP_DONE) THEN
612
861
    CALL %(proc_prefix)sMP_COMPUTE_LOOP_COEFS(MP_P,BUFFR_BIS)
613
862
C   It should be safe to directly set MP_DONE to true already here. But maybe I overlooked something.
617
866
C double precision evaluation as it as already been
618
867
c computed in quadruple precision.
619
868
  goto 300
 
869
## }else{
 
870
  CALL %(proc_prefix)sMP_COMPUTE_LOOP_COEFS(MP_P,BUFFR_BIS)
 
871
## if(ComputeColorFlows) {
 
872
    IF ((.NOT.DIRECT_ME_COMPUTATION).AND.ME_COMPUTATION_FROM_JAMP) THEN
 
873
C   If the ME's are computed from the color flows only, we must update the NLO part of ANS from BUFFR_BIS and the Born part of ANS using RES_FROM_JAMP(0,*)
 
874
      DO I=0,NSQUAREDSO
 
875
        ANS(0,I)=RES_FROM_JAMP(0,I)
 
876
        DO K=1,3
 
877
          ANS(K,I)=BUFFR_BIS(K,I)
 
878
        ENDDO
 
879
      ENDDO
 
880
    ENDIF
 
881
## }
 
882
C We must skip the double precision computation of both loop amplitudes and CT amplitudes because they will all be computed in MP_COMPUTE_LOOP_COEFS.
 
883
  goto 301
 
884
## }
620
885
ENDIF
621
886
 
622
887
DO H=1,NCOMB
624
889
  DO I=1,NEXTERNAL
625
890
    NHEL(I)=HELC(I,H)
626
891
  ENDDO
627
 
 
 
892
  
628
893
  UVCT_REQ_SO_DONE=.FALSE.
629
894
  CT_REQ_SO_DONE=.FALSE.
630
895
  LOOP_REQ_SO_DONE=.FALSE.
 
896
 
 
897
  IF (.NOT.CHECKPHASE.AND.HELDOUBLECHECKED.AND.HELPICKED.EQ.-1) THEN
 
898
    HEL_MULT=GOODHEL(H)
 
899
  ELSE
 
900
    HEL_MULT=1
 
901
  ENDIF
 
902
 
 
903
## if(AmplitudeReduction){
 
904
  CTCALL_REQ_SO_DONE=.FALSE.
 
905
  
 
906
C The coefficient were already computed previously with another CTMode, so we can skip them
 
907
  IF (SKIP_LOOPNUM_COEFS_CONSTRUCTION) THEN
 
908
    GOTO 4000
 
909
  ENDIF
 
910
  
 
911
  DO I=1,NLOOPGROUPS
 
912
    DO J=0,LOOPMAXCOEFS-1
 
913
      LOOPCOEFS(J,I)=(0.0d0,0.0d0)
 
914
    ENDDO
 
915
  ENDDO
 
916
  
 
917
  DO K=1,3
 
918
    DO I=1,NLOOPAMPS
 
919
      AMPL(K,I)=(0.0d0,0.0d0)
 
920
    ENDDO
 
921
  ENDDO
 
922
## }
631
923
 
632
924
C Helas calls for the born amplitudes and counterterms associated to given loops
633
925
  %(born_ct_helas_calls)s
644
936
3000 CONTINUE
645
937
  UVCT_REQ_SO_DONE=.TRUE.
646
938
 
647
 
  IF (.NOT.CHECKPHASE.AND.HELDOUBLECHECKED.AND.HELPICKED.EQ.-1) THEN
648
 
    DUMMY=GOODHEL(H)
649
 
  ELSE
650
 
    DUMMY=1
651
 
  ENDIF
652
 
  DO I=1,%(nctamps_or_nloopamps)s
653
 
    DO J=1,%(nbornamps_or_nloopamps)s
 
939
## if(not AmplitudeReduction) {
 
940
  DO I=1,NCTAMPS
 
941
    DO J=1,NBORNAMPS
654
942
          CFTOT=DCMPLX(CF_N(I,J)/DBLE(ABS(CF_D(I,J))),0.0d0)
655
943
      IF(CF_D(I,J).LT.0) CFTOT=CFTOT*IMAG1
656
 
          %(squaring)s
 
944
      ITEMP = %(proc_prefix)sML5SQSOINDEX(%(proc_prefix)sML5SOINDEX_FOR_LOOP_AMP(I),%(proc_prefix)sML5SOINDEX_FOR_BORN_AMP(J))
 
945
          IF (.NOT.FILTER_SO.OR.SQSO_TARGET.EQ.ITEMP) THEN
 
946
        DO K=1,3
 
947
          TEMP2 = 2.0d0*HEL_MULT*DBLE(CFTOT*AMPL(K,I)*DCONJG(AMP(J)))
 
948
          ANS(K,ITEMP)=ANS(K,ITEMP)+TEMP2
 
949
          ANS(K,0)=ANS(K,0)+TEMP2
 
950
        ENDDO
 
951
      ENDIF
657
952
    ENDDO
658
953
  ENDDO
 
954
## }
659
955
  
660
956
  %(coef_construction)s
661
957
4000 CONTINUE
662
958
  LOOP_REQ_SO_DONE=.TRUE.
663
959
 
 
960
## if(AmplitudeReduction) {
 
961
  IF(SKIPLOOPEVAL) THEN
 
962
    GOTO 5000
 
963
  ENDIF
 
964
  DO I=1,NSQUAREDSO
 
965
    DO J=1,NLOOPGROUPS
 
966
      S(I,J)=.TRUE.
 
967
    ENDDO
 
968
  ENDDO
 
969
C We need the dummy argument I_SO for the squared order index to conform to the structure that the call to the LOOP* subroutine takes for processes with Born diagrams.
 
970
  I_SO=1
 
971
%(loop_CT_calls)s
 
972
5000 CONTINUE
 
973
  CTCALL_REQ_SO_DONE=.TRUE.
 
974
 
 
975
## if(ComputeColorFlows) {
 
976
  IF (DIRECT_ME_COMPUTATION) THEN
 
977
## }
 
978
  DO I=1,NLOOPAMPS
 
979
## if(not LoopInduced) {
 
980
    DO J=1,NBORNAMPS
 
981
## } else {
 
982
    DO J=1,NLOOPAMPS
 
983
## }
 
984
          CFTOT=DCMPLX(CF_N(I,J)/DBLE(ABS(CF_D(I,J))),0.0d0)
 
985
      IF(CF_D(I,J).LT.0) CFTOT=CFTOT*IMAG1
 
986
## if(not LoopInduced) {
 
987
      ITEMP = %(proc_prefix)sML5SQSOINDEX(%(proc_prefix)sML5SOINDEX_FOR_LOOP_AMP(I),%(proc_prefix)sML5SOINDEX_FOR_BORN_AMP(J))
 
988
      DO K=1,3
 
989
        TEMP2(K) = 2.0d0*HEL_MULT*DBLE(CFTOT*AMPL(K,I)*DCONJG(AMP(J)))
 
990
      ENDDO
 
991
## } else {
 
992
      ITEMP = %(proc_prefix)sML5SQSOINDEX(%(proc_prefix)sML5SOINDEX_FOR_LOOP_AMP(I),%(proc_prefix)sML5SOINDEX_FOR_LOOP_AMP(J))
 
993
      TEMP2(1) = HEL_MULT*DBLE(CFTOT*(AMPL(1,I)*DCONJG(AMPL(1,J))))
 
994
C Computing the quantities below is not strictly necessary since the result should be finite
 
995
C It is however a good cross-check.
 
996
      TEMP2(2) = HEL_MULT*DBLE(CFTOT*(AMPL(2,I)*DCONJG(AMPL(1,J)) + AMPL(1,I)*DCONJG(AMPL(2,J))))
 
997
      TEMP2(3) = HEL_MULT*DBLE(CFTOT*(AMPL(3,I)*DCONJG(AMPL(1,J)) + AMPL(1,I)*DCONJG(AMPL(3,J))+AMPL(2,I)*DCONJG(AMPL(2,J))))
 
998
## }
 
999
C To mimick the structure of the squared amplitude reduction, we add here the squared counterterm contribution directly to the result ANS() and put the loop contributions in the LOOPRES array which will be added to ANS later
 
1000
      IF (I.LE.NCTAMPS) THEN
 
1001
        IF (.NOT.FILTER_SO.OR.SQSO_TARGET.EQ.ITEMP) THEN
 
1002
          DO K=1,3
 
1003
            ANS(K,ITEMP)=ANS(K,ITEMP)+TEMP2(K)
 
1004
            ANS(K,0)=ANS(K,0)+TEMP2(K)
 
1005
          ENDDO
 
1006
        ENDIF
 
1007
      ELSE
 
1008
        DO K=1,3
 
1009
          LOOPRES(K,ITEMP,I-NCTAMPS)=LOOPRES(K,ITEMP,I-NCTAMPS)+TEMP2(K)
 
1010
C During the evaluation of the AMPL, we had stored the stability in S(1,*) so we now copy over this flag to the relevant contributing Squared orders.
 
1011
          S(ITEMP,I-NCTAMPS)=S(1,I-NCTAMPS)
 
1012
        ENDDO
 
1013
      ENDIF
 
1014
    ENDDO
 
1015
  ENDDO
 
1016
## }
 
1017
## if(ComputeColorFlows) {
 
1018
ENDIF
 
1019
## }
 
1020
 
 
1021
## if(ComputeColorFlows){
 
1022
C We should compute the color flow either if it contributes to the final result (i.e. not used just for the filtering), or if the computation is only done from the color flows
 
1023
IF (((.NOT.DIRECT_ME_COMPUTATION).AND.ME_COMPUTATION_FROM_JAMP).OR.(H.EQ.USERHEL.OR.USERHEL.EQ.-1)) THEN
 
1024
C The cumulative quantities must only be computed if that helicity contributes according to user request (second argument of the subroutine below).
 
1025
  CALL %(proc_prefix)sCOMPUTE_COLOR_FLOWS(HEL_MULT,(H.EQ.USERHEL.OR.USERHEL.EQ.-1))
 
1026
  IF(ME_COMPUTATION_FROM_JAMP) THEN
 
1027
    CALL %(proc_prefix)sCOMPUTE_RES_FROM_JAMP(BUFFRES,HEL_MULT)
 
1028
    IF(((.NOT.DIRECT_ME_COMPUTATION).AND.ME_COMPUTATION_FROM_JAMP)) THEN
 
1029
C     If the computation from the color flow is the only form of computation, we directly update the answer.
 
1030
      DO K=0,3
 
1031
        DO I=0,NSQUAREDSO
 
1032
          ANS(K,I)=ANS(K,I)+BUFFRES(K,I)
 
1033
        ENDDO
 
1034
      ENDDO
 
1035
C   When setting up the loop filter, it is important to set the quantitied LOOPRES.
 
1036
C   Notice that you may have a more powerful filter with the direct computation mode because it can filter vanishing loop contributions for a particular squared split order only
 
1037
C   The quantity LOOPRES defined below is not physical, but it's ok since it is only intended for the loop filtering.
 
1038
     IF(.NOT.FOUNDLOOPFILTER.AND.USELOOPFILTER) THEN
 
1039
        DO J=1,NLOOPGROUPS
 
1040
          DO I=1,NSQUAREDSO
 
1041
            DO K=1,3
 
1042
              LOOPRES(K,I,J)=LOOPRES(K,I,J)+AMPL(K,NCTAMPS+J)
 
1043
            ENDDO
 
1044
          ENDDO
 
1045
        ENDDO
 
1046
      ENDIF
 
1047
C   The if statement below is not strictly necessary but makes it clear when it is executed.
 
1048
    ELSEIF(H.EQ.USERHEL.OR.USERHEL.EQ.-1) THEN
 
1049
C     If both computational method is used, then we must just update RES_FROM_JAMP
 
1050
      DO K=0,3
 
1051
        DO I=0,NSQUAREDSO
 
1052
          RES_FROM_JAMP(K,I)=RES_FROM_JAMP(K,I)+BUFFRES(K,I)
 
1053
        ENDDO
 
1054
      ENDDO
 
1055
    ENDIF
 
1056
  ENDIF
 
1057
ENDIF
 
1058
## }
 
1059
 
664
1060
  ENDIF
665
1061
ENDDO
666
1062
 
 
1063
## if(not AmplitudeReduction){
667
1064
%(coef_merging)s
 
1065
## }
668
1066
 
 
1067
## if (ComputeColorFlows) {
 
1068
IF(DIRECT_ME_COMPUTATION) THEN
 
1069
C Lines below are not necessary when computing the ME from color flows
 
1070
## }
669
1071
DO I=0,NSQUAREDSO
670
1072
  DO J=1,3
671
1073
    BUFFR_BIS(J,I)=ANS(J,I)
672
1074
  ENDDO
673
1075
ENDDO
674
 
 
 
1076
## if (ComputeColorFlows) {
 
1077
ENDIF
 
1078
## }
 
1079
 
 
1080
 
 
1081
## if(not AmplitudeReduction){
 
1082
C MadLoop jumps to this label during stability checks when it recomputes the same PS point with a different CTMode
675
1083
300 CONTINUE
 
1084
 
 
1085
## if(iregi_available) {
676
1086
C     Free cache when using IREGI
677
 
%(iregi_free_ps)s
678
 
 
 
1087
      IF(IREGIRECY.AND.MLReductionLib(I_LIB).EQ.3) THEN
 
1088
        CALL IREGI_FREE_PS()
 
1089
      ENDIF
 
1090
## }
 
1091
 
 
1092
## if(TIRCaching){
 
1093
C Even if the user did ask to turn off the automatic TIR cache clearing, we must do it now if the CTModeIndex rolls over the size of the TIR cache employed.
 
1094
C Notice that we must do that only when processing a new CT mode as part of the stability test and not when computing a new helicity as part of the filtering process.
 
1095
C This we check that we are not in the initialization phase.
 
1096
C If we are not in CTModeRun=-1, then we never need to clear the cache since the TIR will always be used for a unique computation (not stab test).
 
1097
C Also, it is clear that if we are running OPP when reaching this line, then we shouldn't clear the TIR cache as it might still be useful later.
 
1098
C Finally, notice that the conditional statement below should never be true except you have TIR library supporting quadruple precision or when TIR_CACHE_SIZE<2.
 
1099
IF((.NOT.CHECKPHASE.AND.(HELDOUBLECHECKED)).AND.CTMODERUN.eq.-1.and.MLReductionLib(I_LIB).ne.1.AND.(%(proc_prefix)sTIRCACHE_INDEX(CTMODE).eq.(TIR_CACHE_SIZE+1))) THEN
 
1100
  CALL %(proc_prefix)sCLEAR_TIR_CACHE()
 
1101
ENDIF
 
1102
## }
 
1103
 
 
1104
## }else{
 
1105
C MadLoop jumps to this label just after having called the subroutine %(proc_prefix)sMP_COMPUTE_LOOP_COEFS to compute OpenLoop coefficients in quadruple precision (and not double precision as done above)
 
1106
301 CONTINUE
 
1107
## }
 
1108
 
 
1109
## if (ComputeColorFlows) {
 
1110
IF(DIRECT_ME_COMPUTATION) THEN
 
1111
C Lines below are not necessary when computing the ME from color flows
 
1112
## }
679
1113
DO I=0,NSQUAREDSO
680
1114
  DO J=1,3
681
1115
    ANS(J,I)=BUFFR_BIS(J,I)
682
1116
  ENDDO
683
1117
ENDDO
 
1118
## if (ComputeColorFlows) {
 
1119
ENDIF
 
1120
## }
 
1121
 
 
1122
## if (ComputeColorFlows) {
 
1123
IF ((.NOT.DIRECT_ME_COMPUTATION).AND.ME_COMPUTATION_FROM_JAMP) THEN
 
1124
C We can skip the update of ANS if it was computed from color flows
 
1125
  GOTO 1226
 
1126
ENDIF
 
1127
## }
684
1128
 
685
1129
IF(SKIPLOOPEVAL) THEN
686
1130
  GOTO 1226
687
1131
ENDIF
688
1132
 
 
1133
## if(not AmplitudeReduction){
689
1134
DO I_SO=1,NSQUAREDSO
690
1135
  DO J=1,NLOOPGROUPS
691
1136
    S(I_SO,J)=.TRUE.
697
1142
  CTCALL_REQ_SO_DONE=.TRUE.
698
1143
5001 CONTINUE
699
1144
ENDDO
 
1145
## }
700
1146
 
701
 
%(actualize_ans)s
 
1147
DO I=1,NLOOPGROUPS
 
1148
  LTEMP=.TRUE.
 
1149
  DO K=1,NSQUAREDSO
 
1150
    IF (.NOT.FILTER_SO.OR.SQSO_TARGET.EQ.K) THEN
 
1151
      IF (.NOT.S(K,I)) LTEMP=.FALSE.
 
1152
      DO J=1,3
 
1153
        ANS(J,K)=ANS(J,K)+LOOPRES(J,K,I)
 
1154
        ANS(J,0)=ANS(J,0)+LOOPRES(J,K,I)
 
1155
      ENDDO
 
1156
    ENDIF
 
1157
  ENDDO
 
1158
  IF((CTMODERUN.NE.-1).AND..NOT.CHECKPHASE.AND.(.NOT.LTEMP)) THEN
 
1159
    WRITE(*,*) '##W03 WARNING Contribution ',I,' is unstable.'           
 
1160
  ENDIF
 
1161
ENDDO
702
1162
 
703
1163
1226 CONTINUE
704
1164
 
716
1176
  HELSAVED(2,HELPICKED)=ANS(2,0)
717
1177
  HELSAVED(3,HELPICKED)=ANS(3,0)
718
1178
 
719
 
  IF (CHECKPHASE) THEN
 
1179
## if(LoopInduced){
 
1180
C We make sure not to perform any check when NTRY is 0 because this means that
 
1181
C the REF scale has not been set to the result of the evaluation for the first PS point.
 
1182
## }
 
1183
  IF (CHECKPHASE.AND.NTRY.NE.0) THEN
720
1184
C   SET THE HELICITY FILTER
721
1185
    IF(.NOT.FOUNDHELFILTER) THEN
722
1186
          HEL_INCONSISTENT=.FALSE.
724
1188
        IF(NTRY.EQ.1) THEN
725
1189
              GOODHEL(HELPICKED)=-HELOFFSET
726
1190
            ELSEIF(GOODHEL(HELPICKED).NE.-HELOFFSET) THEN
727
 
                  WRITE(*,*) '##W02A WARNING Inconsistent helicity ',HELPICKED
 
1191
                  WRITE(*,*) '##W02A WARNING Inconsistent zero helicity ',HELPICKED
728
1192
                  IF(HELINITSTARTOVER) THEN
729
1193
                WRITE(*,*) '##I01 INFO Initialization starting over because of inconsistency in the helicity filter setup.'
730
1194
                NTRY=0
732
1196
                    HEL_INCONSISTENT=.TRUE.
733
1197
                  ENDIF
734
1198
                ENDIF
735
 
      ELSE
 
1199
      ELSEIF(HelicityFilterLevel.gt.1) THEN
736
1200
            DO H=1,HELPICKED-1
737
1201
                  IF(GOODHEL(H).GT.-HELOFFSET) THEN
738
1202
C           Be looser for helicity check, bring a factor 100
739
1203
                    DUMMY=%(proc_prefix)sISSAME(ANS(1,0),HELSAVED(1,H),REF,.FALSE.)
740
1204
                    IF(DUMMY.NE.0) THEN
741
 
                      IF(NTRY.EQ.1) THEN
 
1205
              IF(NTRY.EQ.1) THEN
742
1206
C               Set the matching helicity to be contributing once more
743
1207
                        GOODHEL(H)=GOODHEL(H)+DUMMY
744
1208
C               Use an offset to clearly show it is linked to an other one and to avoid overlap
745
1209
                            GOODHEL(HELPICKED)=-H-HELOFFSET
746
1210
C             Make sure we have paired this hel config to the same one last PS point
747
1211
                          ELSEIF(GOODHEL(HELPICKED).NE.(-H-HELOFFSET)) THEN
748
 
                            WRITE(*,*) '##W02B WARNING Inconsistent helicity ',HELPICKED
 
1212
                            WRITE(*,*) '##W02B WARNING Inconsistent matching helicity ',HELPICKED
749
1213
                        IF(HELINITSTARTOVER) THEN
750
1214
                      WRITE(*,*) '##I01 INFO Initialization starting over because of inconsistency in the helicity filter setup.'
751
1215
                      NTRY=0
756
1220
                        ENDIF
757
1221
                  ENDIF
758
1222
                ENDDO
759
 
          ENDIF
 
1223
      ENDIF
760
1224
          IF(HEL_INCONSISTENT) THEN
761
1225
C This helicity has unstable filter so we will always compute it by itself.
762
1226
C We therefore also need to remove it from the multiplicative factor of the corresponding helicity.
789
1253
          DO I=1,NLOOPGROUPS
790
1254
            DO J=1,NSQUAREDSO
791
1255
          IF(.NOT.%(proc_prefix)sIsZero(ABS(LOOPRES(1,J,I))+ABS(LOOPRES(2,J,I))+ABS(LOOPRES(3,J,I)),(REF*1.0d-4),I,J)) THEN
792
 
            IF(NTRY.EQ.1) THEN
 
1256
              IF(NTRY.EQ.1) THEN
793
1257
                  GOODAMP(J,I)=.TRUE.
794
1258
                      LOOPFILTERBUFF(J,I)=.TRUE.
795
1259
                ELSEIF(.NOT.LOOPFILTERBUFF(J,I)) THEN
840
1304
  IF(HELPICKED.NE.NCOMB) THEN
841
1305
    HELPICKED=HELPICKED+1
842
1306
        MP_DONE=.FALSE.
843
 
    goto 200
 
1307
    goto 205
844
1308
  ELSE
845
1309
C   Useful printout
846
1310
c    do I=1,NCOMB
854
1318
        ANS(K,I)=BUFFR(K,I)
855
1319
      ENDDO
856
1320
        ENDDO
 
1321
## if(LoopInduced){
 
1322
C Update of REF_EVALS (only for loop-induced processes).
 
1323
    REF_EVALS(MOD(NPSPOINTS,MAXNREF_EVALS)+1) = ABS(ANS(1,0)) + ABS(ANS(2,0)) + ABS(ANS(3,0))
 
1324
C We add one here to the number of PS points used for building the reference scale for comparisons.
 
1325
C It might be that when asking for specific helicities, the user started with a vanishing helicity
 
1326
C not filtered yet. In this case, the new ref would remain zero. So we want to check for this
 
1327
C and wait for a point for which the evaluation won't be zero.
 
1328
    IF(NPSPOINTS.GE.MAXNREF_EVALS) THEN
 
1329
      TMPR=MEDIAN(REF_EVALS,MAXNREF_EVALS)
 
1330
    ELSE
 
1331
      TMPR=MEDIAN(REF_EVALS,NPSPOINTS+1)
 
1332
    ENDIF
 
1333
    IF (TMPR.NE.0.0d0) THEN
 
1334
      NPSPOINTS = NPSPOINTS+1
 
1335
    ENDIF
 
1336
## }
857
1337
        IF(NTRY.EQ.0) THEN
858
1338
          NATTEMPTS=NATTEMPTS+1
859
1339
          IF(NATTEMPTS.EQ.MAXATTEMPTS) THEN
862
1342
          ENDIF
863
1343
        ENDIF
864
1344
  ENDIF
865
 
 
866
 
ENDIF
867
 
 
 
1345
## if(LoopInduced){
 
1346
ELSE
 
1347
C When not in checking mode, update the ref for the first MAXNREF_EVALS points (Not really important since the ref. scale shouldn't be used anymore at this stage).
 
1348
C Is is possible to simply remove the if statement below to have a running reference scale which always depends on the MAXNREF_EVALS *last* evaluations. 
 
1349
    if (NPSPOINTS.LE.MAXNREF_EVALS) THEN
 
1350
      REF_EVALS(MOD(NPSPOINTS,MAXNREF_EVALS)+1) = ABS(ANS(1,0)) + ABS(ANS(2,0)) + ABS(ANS(3,0))
 
1351
      NPSPOINTS = NPSPOINTS+1
 
1352
    ENDIF
 
1353
## }
 
1354
ENDIF
 
1355
 
 
1356
## if (ComputeColorFlows) {
 
1357
C When computing the ME from the color flows, we also compute the born ME from them, so we must apply the normalization factors to the born ME as well.
 
1358
IF(((.NOT.DIRECT_ME_COMPUTATION).AND.ME_COMPUTATION_FROM_JAMP)) THEN
 
1359
  ITEMP=0
 
1360
ELSE
 
1361
  ITEMP=1
 
1362
ENDIF
 
1363
DO K=ITEMP,3
 
1364
## } else {
868
1365
DO K=1,3
 
1366
## }
869
1367
  DO I=0,NSQUAREDSO
870
1368
    ANS(K,I)=ANS(K,I)/DBLE(IDEN)
871
1369
    IF (USERHEL.NE.-1) THEN
874
1372
  ENDDO
875
1373
ENDDO
876
1374
 
 
1375
## if (ComputeColorFlows) {
 
1376
IF (DIRECT_ME_COMPUTATION.AND.ME_COMPUTATION_FROM_JAMP) THEN
 
1377
  WRITE(*,*) ' ================================= '
 
1378
  WRITE(*,*) ' === JAMP double-checking test === '
 
1379
  WRITE(*,*) ' ================================= '
 
1380
  CALL %(proc_prefix)sWRITE_MOM(P)
 
1381
  DO J=1,NSQUAREDSO+1
 
1382
C We should finish by the summed orders
 
1383
    I = MOD(J,NSQUAREDSO+1)
 
1384
    IF (I.EQ.0) THEN
 
1385
      WRITE(*,*) ' > Checking the sum of all chosen squared split orders'    
 
1386
    ELSE
 
1387
      WRITE(*,*) ' > Checking squared split order #',I
 
1388
    ENDIF
 
1389
## if (LoopInduced) {
 
1390
    DO K=1,1
 
1391
## } else {
 
1392
    DO K=0,3
 
1393
## }
 
1394
      RES_FROM_JAMP(K,I)=RES_FROM_JAMP(K,I)/DBLE(IDEN)
 
1395
      IF (USERHEL.NE.-1) THEN
 
1396
        RES_FROM_JAMP(K,I)=RES_FROM_JAMP(K,I)*HELAVGFACTOR
 
1397
      ENDIF
 
1398
      IF (K.eq.0) WRITE(*,*) ' || Born :' 
 
1399
      IF (K.eq.1) WRITE(*,*) ' || Finite part :' 
 
1400
      IF (K.eq.2) WRITE(*,*) ' || Single pole residue :' 
 
1401
      IF (K.eq.3) WRITE(*,*) ' || Double pole residue :' 
 
1402
      WRITE(*,*) ' --> Direct result        =',ANS(K,I)
 
1403
      WRITE(*,*) ' --> Computed from JAMPS  =',RES_FROM_JAMP(K,I)
 
1404
      IF((RES_FROM_JAMP(K,I)+ANS(K,I)).EQ.0.0d0) THEN
 
1405
        TMPR = ABS(RES_FROM_JAMP(K,I)-ANS(K,I))      
 
1406
      ELSE
 
1407
        TMPR = ABS((ANS(K,I)-RES_FROM_JAMP(K,I))/((ANS(K,I)+RES_FROM_JAMP(K,I))/2.0d0))
 
1408
      ENDIF
 
1409
      WRITE(*,*) ' --> Relative diff.       =',TMPR
 
1410
      IF(TMPR.GT.JAMP_DOUBLECHECK_THRES) THEN
 
1411
         STOP 'Consistency cross-check of JAMPS failed.'
 
1412
      ENDIF
 
1413
    ENDDO
 
1414
  ENDDO
 
1415
  WRITE(*,*) ' ================================= '
 
1416
ENDIF
 
1417
## }
 
1418
 
877
1419
IF(.NOT.CHECKPHASE.AND.HELDOUBLECHECKED.AND.(CTMODERUN.EQ.-1)) THEN
878
1420
  STAB_INDEX=STAB_INDEX+1  
879
1421
  IF(DOING_QP_EVALS.AND.MLReductionLib(I_LIB).EQ.1) THEN
902
1444
  IF(.NOT.EVAL_DONE(2)) THEN
903
1445
        EVAL_DONE(2)=.TRUE.
904
1446
        IF(LOOPLIBS_DIRECTEST(MLReductionLib(I_LIB)))THEN 
905
 
        CTMODE=BASIC_CT_MODE+1
906
 
        goto 300
907
 
        ELSE
908
 
C   NO DIRECTION TEST LIBRARIES: e.g. PJFry++ and Golem95
909
 
        STAB_INDEX=STAB_INDEX+1
910
 
        IF(DOING_QP_EVALS)THEN
911
 
        DO I=0,NSQUAREDSO
912
 
        DO K=1,3
913
 
          QP_RES(K,I,STAB_INDEX)=ANS(K,I)
914
 
        ENDDO
915
 
        ENDDO
916
 
        ELSE
917
 
        DO I=0,NSQUAREDSO
918
 
        DO K=1,3
919
 
          DP_RES(K,I,STAB_INDEX)=ANS(K,I)
920
 
        ENDDO
921
 
        ENDDO
922
 
        ENDIF
923
 
        ENDIF
 
1447
          CTMODE=BASIC_CT_MODE+1
 
1448
          goto 300
 
1449
    ELSE
 
1450
C     If some TIR library would not support the loop direction test (they all do for now), then we would just copy the answer from mode 1 and carry on.
 
1451
          STAB_INDEX=STAB_INDEX+1
 
1452
          IF(DOING_QP_EVALS)THEN
 
1453
            DO I=0,NSQUAREDSO
 
1454
              DO K=1,3
 
1455
                QP_RES(K,I,STAB_INDEX)=ANS(K,I)
 
1456
              ENDDO
 
1457
            ENDDO
 
1458
          ELSE
 
1459
            DO I=0,NSQUAREDSO
 
1460
          DO K=1,3
 
1461
            DP_RES(K,I,STAB_INDEX)=ANS(K,I)
 
1462
          ENDDO
 
1463
        ENDDO
 
1464
          ENDIF
 
1465
    ENDIF
924
1466
  ENDIF
925
1467
 
926
1468
  CTMODE=BASIC_CT_MODE
1227
1769
                    IF(.NOT.%(proc_prefix)sIsZero(ABS(resB(J))+ABS(resA(J)),ref,-1,-1)) THEN
1228
1770
                      GOTO 1231
1229
1771
                        ENDIF
1230
 
C         Be loser for helicity comparison, so bring a factor 100
1231
 
                  ELSEIF(.NOT.%(proc_prefix)sIsZero((resA(J)/resB(J))-DBLE(WGT_TO_TRY(I)),ref*100.0d0,-1,-1)) THEN
 
1772
C         Be looser for helicity comparison, so bring a factor 100
 
1773
                  ELSEIF(.NOT.%(proc_prefix)sIsZero(ABS((resA(J)/resB(J))-DBLE(WGT_TO_TRY(I))),1.0d0,-1,-1)) THEN
1232
1774
                    GOTO 1231               
1233
1775
                  ENDIF
1234
1776
                ENDDO
1415
1957
      INTEGER I,J
1416
1958
          INTEGER SQPLITORDERS(NSQSO,NSO)
1417
1959
          %(SquaredSO)s
 
1960
          COMMON/%(proc_prefix)sML5SQPLITORDERS/SQPLITORDERS
1418
1961
C
1419
1962
C BEGIN CODE
1420
1963
C
1497
2040
C
1498
2041
C CONSTANTS
1499
2042
C      
1500
 
 
1501
2043
      INTEGER    NSO, NSQUAREDSO, NAMPSO
1502
2044
          PARAMETER (NSO=%(nSO)d, NSQUAREDSO=%(nSquaredSO)d, NAMPSO=%(nAmpSO)d)
1503
2045
C
1510
2052
      INTEGER I, SQORDERS(NSO)
1511
2053
      INTEGER AMPSPLITORDERS(NAMPSO,NSO)
1512
2054
          %(ampsplitorders)s
 
2055
          COMMON/%(proc_prefix)sML5AMPSPLITORDERS/AMPSPLITORDERS
1513
2056
C
1514
2057
C FUNCTION
1515
2058
C
1523
2066
          %(proc_prefix)sML5SQSOINDEX=%(proc_prefix)sML5SOINDEX_FOR_SQUARED_ORDERS(SQORDERS)
1524
2067
          END
1525
2068
 
 
2069
C This is the inverse subroutine of ML5SOINDEX_FOR_SQUARED_ORDERS. Not directly useful, but provided nonetheless.
 
2070
      SUBROUTINE %(proc_prefix)sML5GET_SQUARED_ORDERS_FOR_SOINDEX(SOINDEX,ORDERS)
 
2071
C
 
2072
C This functions returns the orders identified by the squared split order index in argument. Order values correspond to following list of couplings (and in this order):
 
2073
C %(split_order_str_list)s
 
2074
C
 
2075
C CONSTANTS
 
2076
C
 
2077
      INTEGER    NSO, NSQSO
 
2078
          PARAMETER (NSO=%(nSO)d, NSQSO=%(nSquaredSO)d)
 
2079
C
 
2080
C ARGUMENTS
 
2081
C
 
2082
      INTEGER SOINDEX, ORDERS(NSO)
 
2083
C
 
2084
C LOCAL VARIABLES
 
2085
C
 
2086
      INTEGER I
 
2087
          INTEGER SQPLITORDERS(NSQSO,NSO)
 
2088
          COMMON/%(proc_prefix)sML5SQPLITORDERS/SQPLITORDERS      
 
2089
C
 
2090
C BEGIN CODE
 
2091
C
 
2092
      IF (SOINDEX.gt.0.and.SOINDEX.le.NSQSO) THEN
 
2093
        DO I=1,NSO
 
2094
          ORDERS(I) =  SQPLITORDERS(SOINDEX,I)
 
2095
        ENDDO
 
2096
        RETURN
 
2097
      ENDIF
 
2098
 
 
2099
          WRITE(*,*) 'ERROR:: Stopping function %(proc_prefix)sML5GET_SQUARED_ORDERS_FOR_SOINDEX'
 
2100
          WRITE(*,*) 'Could not find squared orders index ',SOINDEX
 
2101
          STOP
 
2102
 
 
2103
      END SUBROUTINE
 
2104
 
 
2105
C This is the inverse subroutine of getting amplitude SO orders. Not directly useful, but provided nonetheless.
 
2106
      SUBROUTINE %(proc_prefix)sML5GET_ORDERS_FOR_AMPSOINDEX(SOINDEX,ORDERS)
 
2107
C
 
2108
C This functions returns the orders identified by the split order index in argument. Order values correspond to following list of couplings (and in this order):
 
2109
C %(split_order_str_list)s
 
2110
C
 
2111
C CONSTANTS
 
2112
C
 
2113
      INTEGER    NSO, NAMPSO
 
2114
          PARAMETER (NSO=%(nSO)d, NAMPSO=%(nAmpSO)d)
 
2115
C
 
2116
C ARGUMENTS
 
2117
C
 
2118
      INTEGER SOINDEX, ORDERS(NSO)
 
2119
C
 
2120
C LOCAL VARIABLES
 
2121
C
 
2122
      INTEGER I
 
2123
      INTEGER AMPSPLITORDERS(NAMPSO,NSO)
 
2124
          COMMON/%(proc_prefix)sML5AMPSPLITORDERS/AMPSPLITORDERS
 
2125
C
 
2126
C BEGIN CODE
 
2127
C
 
2128
      IF (SOINDEX.gt.0.and.SOINDEX.le.NAMPSO) THEN
 
2129
        DO I=1,NSO
 
2130
          ORDERS(I) =  AMPSPLITORDERS(SOINDEX,I)
 
2131
        ENDDO
 
2132
        RETURN
 
2133
      ENDIF
 
2134
 
 
2135
          WRITE(*,*) 'ERROR:: Stopping function %(proc_prefix)sML5GET_ORDERS_FOR_AMPSOINDEX'
 
2136
          WRITE(*,*) 'Could not find amplitude split orders index ',SOINDEX
 
2137
          STOP
 
2138
 
 
2139
      END SUBROUTINE
 
2140
 
 
2141
 
 
2142
C This function is not directly useful, but included for completeness
 
2143
      INTEGER FUNCTION %(proc_prefix)sML5SOINDEX_FOR_AMPORDERS(ORDERS)
 
2144
C
 
2145
C This functions returns the integer index identifying the amplitude split orders passed in argument which correspond to the values of the following list of couplings (and in this order):
 
2146
C %(split_order_str_list)s
 
2147
C
 
2148
C CONSTANTS
 
2149
C
 
2150
      INTEGER    NSO, NAMPSO
 
2151
          PARAMETER (NSO=%(nSO)d, NAMPSO=%(nAmpSO)d)
 
2152
C
 
2153
C ARGUMENTS
 
2154
C
 
2155
      INTEGER ORDERS(NSO)
 
2156
C
 
2157
C LOCAL VARIABLES
 
2158
C
 
2159
      INTEGER I,J
 
2160
      INTEGER AMPSPLITORDERS(NAMPSO,NSO)
 
2161
          COMMON/%(proc_prefix)sML5AMPSPLITORDERS/AMPSPLITORDERS
 
2162
C
 
2163
C BEGIN CODE
 
2164
C
 
2165
      DO I=1,NAMPSO
 
2166
            DO J=1,NSO
 
2167
                  IF (ORDERS(J).NE.AMPSPLITORDERS(I,J)) GOTO 1009
 
2168
                ENDDO
 
2169
                %(proc_prefix)sML5SOINDEX_FOR_AMPORDERS = I
 
2170
                RETURN
 
2171
1009    CONTINUE
 
2172
          ENDDO
 
2173
 
 
2174
          WRITE(*,*) 'ERROR:: Stopping function %(proc_prefix)sML5SOINDEX_FOR_AMPORDERS'
 
2175
          WRITE(*,*) 'Could not find squared orders ',(ORDERS(I),I=1,NSO)
 
2176
          STOP
 
2177
 
 
2178
      END
 
2179
 
1526
2180
C --=========================================--
1527
2181
C   Definition of additional access routines
1528
2182
C --=========================================--
1540
2194
 
1541
2195
          ALWAYS_TEST_STABILITY = ONOFF
1542
2196
 
1543
 
          END
1544
 
 
 
2197
          END SUBROUTINE
 
2198
 
 
2199
          SUBROUTINE %(proc_prefix)sSET_AUTOMATIC_TIR_CACHE_CLEARING(ONOFF)
 
2200
C
 
2201
C This function can be called by the MadLoop user so as to manually chose when
 
2202
C to reset the TIR cache.
 
2203
C
 
2204
                IMPLICIT NONE
 
2205
 
 
2206
            include 'MadLoopParams.inc'
 
2207
 
 
2208
                LOGICAL ONOFF
 
2209
 
 
2210
        LOGICAL AUTOMATIC_TIR_CACHE_CLEARING
 
2211
        DATA AUTOMATIC_TIR_CACHE_CLEARING/.TRUE./
 
2212
        COMMON/%(proc_prefix)sRUNTIME_OPTIONS/AUTOMATIC_TIR_CACHE_CLEARING
 
2213
        
 
2214
            INTEGER N_DP_EVAL, N_QP_EVAL
 
2215
            COMMON/%(proc_prefix)sN_EVALS/N_DP_EVAL,N_QP_EVAL
 
2216
 
 
2217
## if(not TIRCaching){
 
2218
       WRITE(*,*) 'Warning: No TIR caching implemented. Call to SET_AUTOMATIC_TIR_CACHE_CLEARING did nothing.'
 
2219
## } else {
 
2220
 
 
2221
                AUTOMATIC_TIR_CACHE_CLEARING = ONOFF
 
2222
                
 
2223
                IF (NRotations_DP.ne.0.or.NRotations_QP.ne.0) THEN
 
2224
                  WRITE(*,*) 'Warning: One cannot remove the TIR cache automatic clearing while at the same time keeping Lorentz rotations for stability tests.'
 
2225
                  WRITE(*,*) 'MadLoop will therefore automatically set NRotations_DP and NRotations_QP to 0.'
 
2226
                  NRotations_DP = 0
 
2227
                  NRotations_QP = 0
 
2228
                  CALL %(proc_prefix)sSET_N_EVALS(N_DP_EVAL,N_QP_EVAL)
 
2229
                ENDIF
 
2230
## }
 
2231
          END SUBROUTINE
 
2232
          
1545
2233
          SUBROUTINE %(proc_prefix)sSET_COUPLINGORDERS_TARGET(SOTARGET)
1546
2234
          IMPLICIT NONE
1547
2235
C
1748
2436
          RET_CODE=100*H+10*T+U
1749
2437
 
1750
2438
          END
 
2439
          
 
2440
C The subroutine below perform clean-up duties for MadLoop like de-allocating
 
2441
c arrays
 
2442
          SUBROUTINE %(proc_prefix)sEXIT_MADLOOP()
 
2443
## if(ComputeColorFlows) {
 
2444
            CALL %(proc_prefix)sDEALLOCATE_COLOR_FLOWS()
 
2445
## }
 
2446
        CONTINUE
 
2447
          END
 
2448