Merge lp:~maddevelopers/mg5amcnlo/virtual_polyfit_EW into lp:~maddevelopers/mg5amcnlo/3.0.2

Proposed by Rikkert Frederix
Status: Merged
Merged at revision: 973
Proposed branch: lp:~maddevelopers/mg5amcnlo/virtual_polyfit_EW
Merge into: lp:~maddevelopers/mg5amcnlo/3.0.2
Diff against target: 1828 lines (+1113/-345)
15 files modified
Template/NLO/Cards/FKS_params.dat (+10/-6)
Template/NLO/SubProcesses/BinothLHA.f (+1/-2)
Template/NLO/SubProcesses/BinothLHA_OLP.f (+1/-1)
Template/NLO/SubProcesses/FKSParamReader.f (+0/-252)
Template/NLO/SubProcesses/FKSParams.f90 (+248/-0)
Template/NLO/SubProcesses/FKSParams.inc (+0/-31)
Template/NLO/SubProcesses/check_poles.f (+1/-1)
Template/NLO/SubProcesses/driver_mintFO.f (+1/-3)
Template/NLO/SubProcesses/driver_mintMC.f (+1/-3)
Template/NLO/SubProcesses/fks_singular.f (+31/-12)
Template/NLO/SubProcesses/makefile_fks_dir (+3/-3)
Template/NLO/SubProcesses/mint_module.f90 (+58/-20)
Template/NLO/SubProcesses/polfit.f (+720/-0)
madgraph/interface/amcatnlo_run_interface.py (+27/-2)
madgraph/iolibs/export_fks.py (+11/-9)
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/virtual_polyfit_EW
Reviewer Review Type Date Requested Status
marco zaro Approve
Review via email: mp+372681@code.launchpad.net

Description of the change

Replaced the grids to determine the approximate virtual by a polynomial fit using the polfit.f code (by Shampine, Davenport and Huddleston). It's still based on doing this one dimension at a time, but the polynomial fit is smoother than the grids, since the latter required rather coarse binning and had fixed bins which could not be adjusted to follow the importance sampling.

Also needed to replace the FKSParamReader with a fortran90 module to be able to use it correctly in the mint_module.f90

To post a comment you must log in.
Revision history for this message
marco zaro (marco-zaro) wrote :

Thanks Rikkert,
the code changes look correct, for what I can understand of the polyfit module
I have tried p p > t t~ [QCD QED], results are compatible within the uncertainty (also split-order by split-order). The Polyfit run is generally (much) faster:
If I require 1 per mil accuracy for that process, without polyfit it took 18 minutes on my macbook, while with polyfit less than 8, so great job!!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Template/NLO/Cards/FKS_params.dat'
--- Template/NLO/Cards/FKS_params.dat 2017-08-04 19:52:15 +0000
+++ Template/NLO/Cards/FKS_params.dat 2019-09-12 11:14:33 +0000
@@ -153,6 +153,16 @@
1530.005d01530.005d0
154! Default :: 0.005d0154! Default :: 0.005d0
155!155!
156! Use a polynomial fit for the virtual corrections. Gets a better accuracy,
157! but uses more memmory and disk space.
158#UsePolyVirtual
159.True.
160! Default :: .True.
161!
162! ==========================================================================
163! Combination of matrix elements
164! ==========================================================================
165!
156! For fixed order calculations only (ignored for (N)LO+PS runs): This166! For fixed order calculations only (ignored for (N)LO+PS runs): This
157! parameter determines if parton flavour configurations with idential167! parameter determines if parton flavour configurations with idential
158! matrix elements should be separated at the level of the analysis or168! matrix elements should be separated at the level of the analysis or
@@ -170,11 +180,5 @@
170! Default :: .false.180! Default :: .false.
171!181!
172! ==========================================================================182! ==========================================================================
173! Arbitrary numerical parameters used in the FKS formalism
174! ==========================================================================
175!
176! To be implemented by the FKS authors
177!
178! ==========================================================================
179! End of FKS_params.dat file183! End of FKS_params.dat file
180! ==========================================================================184! ==========================================================================
181185
=== modified file 'Template/NLO/SubProcesses/BinothLHA.f'
--- Template/NLO/SubProcesses/BinothLHA.f 2017-06-23 14:14:03 +0000
+++ Template/NLO/SubProcesses/BinothLHA.f 2019-09-12 11:14:33 +0000
@@ -4,12 +4,11 @@
4c that calls the OLP and returns the virtual weights. For convenience4c that calls the OLP and returns the virtual weights. For convenience
5c also the born_wgt is passed to this subroutine.5c also the born_wgt is passed to this subroutine.
6c6c
7 use FKSParams
7 implicit none8 implicit none
8 include "nexternal.inc"9 include "nexternal.inc"
9 include "coupl.inc"10 include "coupl.inc"
10 include 'born_nhel.inc'11 include 'born_nhel.inc'
11c general MadFKS parameters
12 include 'FKSParams.inc'
13 double precision pi, zero,mone12 double precision pi, zero,mone
14 parameter (pi=3.1415926535897932385d0)13 parameter (pi=3.1415926535897932385d0)
15 parameter (zero=0d0)14 parameter (zero=0d0)
1615
=== modified file 'Template/NLO/SubProcesses/BinothLHA_OLP.f'
--- Template/NLO/SubProcesses/BinothLHA_OLP.f 2015-08-13 09:26:37 +0000
+++ Template/NLO/SubProcesses/BinothLHA_OLP.f 2019-09-12 11:14:33 +0000
@@ -6,11 +6,11 @@
6c6c
7C************************************************************************7C************************************************************************
8c8c
9 use FKSParams
9 implicit none10 implicit none
10 include "nexternal.inc"11 include "nexternal.inc"
11 include "coupl.inc"12 include "coupl.inc"
12 include "Binoth_proc.inc"13 include "Binoth_proc.inc"
13 include "FKSParams.inc"
14 double precision pi14 double precision pi
15 parameter (pi=3.1415926535897932385d0)15 parameter (pi=3.1415926535897932385d0)
16 double precision pin(0:3,nexternal-1),p(0:4,nexternal-1)16 double precision pin(0:3,nexternal-1),p(0:4,nexternal-1)
1717
=== removed file 'Template/NLO/SubProcesses/FKSParamReader.f'
--- Template/NLO/SubProcesses/FKSParamReader.f 2017-09-01 10:34:24 +0000
+++ Template/NLO/SubProcesses/FKSParamReader.f 1970-01-01 00:00:00 +0000
@@ -1,252 +0,0 @@
1 subroutine FKSParamReader(filename, printParam, force)
2
3 implicit none
4
5 logical HasReadOnce, force
6 data HasReadOnce/.FALSE./
7
8
9 character(*) filename
10 CHARACTER*64 buff, buff2, mode
11 include "FKSParams.inc"
12 include "orders.inc"
13
14 integer i,j
15
16 logical printParam, couldRead, paramPrinted
17 data paramPrinted/.FALSE./
18 couldRead=.False.
19! Default parameters
20
21 if (HasReadOnce.and..not.force) then
22 goto 901
23 endif
24
25! Make sure to have default parameters if not set
26! in the FKSParams.dat card (if it is an old one for instance)
27 call DefaultFKSParam()
28
29 open(68, file=fileName, err=676, action='READ')
30 do
31 read(68,*,end=999) buff
32 if(index(buff,'#').eq.1) then
33
34 if (buff .eq. '#IRPoleCheckThreshold') then
35 read(68,*,end=999) IRPoleCheckThreshold
36 if (IRPoleCheckThreshold .lt. -1.01d0 ) then
37 stop 'IRPoleCheckThreshold must be >= -1.0d0.'
38 endif
39
40 elseif (buff .eq. '#PrecisionVirtualAtRunTime') then
41 read(68,*,end=999) PrecisionVirtualAtRunTime
42 if (IRPoleCheckThreshold .lt. -1.01d0 ) then
43 stop 'PrecisionVirtualAtRunTime must be >= -1.0d0.'
44 endif
45
46 else if (buff .eq. '#NHelForMCoverHels') then
47 read(68,*,end=999) NHelForMCoverHels
48 if (NHelForMCoverHels .lt. -1) then
49 stop 'NHelForMCoverHels must be >= -1.'
50 endif
51 else if (buff .eq. '#QCD^2==') then
52 read(68,*,end=999) QCD_squared_selected
53 if (QCD_squared_selected .lt. -1) then
54 stop 'QCD_squared_selected must be >= -1.'
55 endif
56 else if (buff .eq. '#QED^2==') then
57 read(68,*,end=999) QED_squared_selected
58 if (QED_squared_selected .lt. -1) then
59 stop 'QED_squared_selected must be >= -1.'
60 endif
61 else if (buff .eq. '#VirtualFraction') then
62 read(68,*,end=999) Virt_fraction
63 if (Virt_fraction .lt. 0 .or. virt_fraction .gt.1) then
64 stop 'VirtualFraction should be a fraction'/
65 $ /' between 0 and 1'
66 endif
67 else if (buff .eq. '#MinVirtualFraction') then
68 read(68,*,end=999) Min_Virt_fraction
69 if (min_virt_fraction .lt. 0 .or. min_virt_fraction .gt.1)
70 $ then
71 stop 'VirtualFraction should be a fraction'/
72 $ /' between 0 and 1'
73 endif
74 else if (buff .eq. '#SeparateFlavourConfigurations') then
75 read(68,*,end=999) separate_flavour_configs
76
77 else if (buff .eq. '#VetoedContributionTypes') then
78 read(68,*,end=999) VetoedContributionTypes(0)
79 if (VetoedContributionTypes(0) .lt. 0.or.
80 & VetoedContributionTypes(0) .gt. maxContribsSelected) then
81 write(*,*) 'VetoedContributionTypes length should be '/
82 & /'>= 0 and <=',maxContribsSelected
83 stop 'Format error in FKS_params.dat.'
84 endif
85 read(68,*,end=999) (VetoedContributionTypes(I),I=1,
86 $ VetoedContributionTypes(0))
87 do I=1,VetoedContributionTypes(0)
88 if (VetoedContributionTypes(I).lt.1.or.
89 $ VetoedContributionTypes(I).gt.maxContribType) then
90 write(*,*) 'VetoedContributionTypes must be >=1 and '/
91 & /'<=',maxContribType
92 stop 'Format error in FKS_params.dat.'
93 endif
94 enddo
95 do I=VetoedContributionTypes(0)+1,maxContribsSelected
96 VetoedContributionTypes(I)=-1
97 enddo
98
99 else if (buff .eq. '#SelectedContributionTypes') then
100 read(68,*,end=999) SelectedContributionTypes(0)
101 if (SelectedContributionTypes(0) .lt. 0 .or.
102 & SelectedContributionTypes(0) .gt. maxContribsSelected) then
103 write(*,*) 'SelectedContributionTypes length should be '/
104 & /'>= 0 and <=',maxContribsSelected
105 stop 'Format error in FKS_params.dat.'
106 endif
107 read(68,*,end=999) (SelectedContributionTypes(I),I=1,
108 $ SelectedContributionTypes(0))
109 do I=1,SelectedContributionTypes(0)
110 if (SelectedContributionTypes(I).lt.1.or.
111 $ SelectedContributionTypes(I).gt.maxContribType) then
112 write(*,*) 'SelectedContributionTypes must be >=1 and '/
113 & /'<=',maxContribType
114 stop 'Format error in FKS_params.dat.'
115 endif
116 enddo
117 do I=SelectedContributionTypes(0)+1,maxContribsSelected
118 SelectedContributionTypes(I)=-1
119 enddo
120
121 else if (buff .eq. '#SelectedCouplingOrders') then
122 read(68,*,end=999) SelectedCouplingOrders(1,0)
123 if (SelectedCouplingOrders(1,0) .lt. 0 .or.
124 & SelectedCouplingOrders(1,0) .gt. maxCouplingsSelected) then
125 write(*,*) 'SelectedCouplingOrders length should be >='/
126 & /' 0 and <=',maxCouplingsSelected
127 stop 'Format error in FKS_params.dat.'
128 endif
129 do j = 2, maxCouplingTypes
130 SelectedCouplingOrders(j,0) = SelectedCouplingOrders(1,0)
131 enddo
132 do j = 1, SelectedCouplingOrders(1,0)
133 read(68,*,end=999) (SelectedCouplingOrders(i,j),i=1,
134 $ nsplitorders)
135 do i=nsplitorders+1,maxCouplingTypes
136 SelectedCouplingOrders(i,j)=-1
137 enddo
138 enddo
139
140 else
141 write(*,*) 'The parameter name ',buff(2:),
142 &' is not reckognized.'
143 stop 'Format error in FKS_params.dat.'
144 endif
145 endif
146 enddo
147 999 continue
148 couldRead=.True.
149 goto 998
150
151 676 continue
152 write(*,*) 'ERROR :: MadFKS parameter file ',fileName,
153 &' could not be found or is malformed. Please specify it.'
154 stop
155C Below is the code if one desires to let the code continue with
156C a non existing or malformed parameter file
157 write(*,*) 'WARNING :: The file ',fileName,' could not be ',
158 & ' open or did not contain the necessary information. The ',
159 & ' default MadFKS parameters will be used.'
160 call DefaultFKSParam()
161 goto 998
162
163 998 continue
164
165 if(printParam.and..not.paramPrinted) then
166 write(*,*)
167 & '==============================================================='
168 if (couldRead) then
169 write(*,*) 'INFO: MadFKS read these parameters from '
170 &,filename
171 else
172 write(*,*) 'INFO: MadFKS used the default parameters.'
173 endif
174 write(*,*)
175 & '==============================================================='
176 write(*,*) ' > IRPoleCheckThreshold = ',IRPoleCheckThreshold
177 write(*,*) ' > PrecisionVirtualAtRunTime = '
178 $ ,PrecisionVirtualAtRunTime
179 if (SelectedContributionTypes(0).gt.0) then
180 write(*,*) ' > SelectedContributionTypes = ',
181 & (SelectedContributionTypes(I),I=1,SelectedContributionTypes(0))
182 else
183 write(*,*) ' > SelectedContributionTypes = All'
184 endif
185 if (VetoedContributionTypes(0).gt.0) then
186 write(*,*) ' > VetoedContributionTypes = ',
187 & (VetoedContributionTypes(I),I=1,VetoedContributionTypes(0))
188 else
189 write(*,*) ' > VetoedContributionTypes = None'
190 endif
191 if (QCD_squared_selected.eq.-1) then
192 write(*,*) ' > QCD_squared_selected = All'
193 else
194 write(*,*) ' > QCD_squared_selected = ',QCD_squared_selected
195 endif
196 if (QED_squared_selected.eq.-1) then
197 write(*,*) ' > QED_squared_selected = All'
198 else
199 write(*,*) ' > QED_squared_selected = ',QED_squared_selected
200 endif
201 if (SelectedCouplingOrders(1,0).gt.0) then
202 do j=1,SelectedCouplingOrders(1,0)
203 write(*,*) ' > SelectedCouplingOrders(',j,') = ',
204 & (SelectedCouplingOrders(i,j),i=1,nsplitorders)
205 enddo
206 else
207 write(*,*) ' > SelectedCouplingOrders = All'
208 endif
209 write(*,*) ' > NHelForMCoverHels = ',NHelForMCoverHels
210 write(*,*) ' > VirtualFraction = ',Virt_fraction
211 write(*,*) ' > MinVirtualFraction = ',Min_virt_fraction
212 write(*,*) ' > SeparateFlavourConfigs = ',separate_flavour_configs
213 write(*,*)
214 & '==============================================================='
215 paramPrinted=.TRUE.
216 endif
217
218 close(68)
219 HasReadOnce=.TRUE.
220 901 continue
221 end
222
223 subroutine DefaultFKSParam()
224
225 implicit none
226 integer i,j
227 include "FKSParams.inc"
228
229 IRPoleCheckThreshold=1.0d-5
230 NHelForMCoverHels=5
231 PrecisionVirtualAtRunTime=1d-3
232 Virt_fraction=1d0
233 QED_squared_selected=-1
234 QCD_squared_selected=-1
235 Min_virt_fraction=0.005d0
236 separate_flavour_configs=.false.
237 IncludeBornContributions=.true.
238 SelectedContributionTypes(0)=0
239 VetoedContributionTypes(0)=0
240 do i=1, maxContribsSelected
241 SelectedContributionTypes(I)=-1
242 VetoedContributionTypes(I)=-1
243 enddo
244 do j=1,maxCouplingTypes
245 SelectedCouplingOrders(j,0) = 0
246 enddo
247 do j=1,maxCouplingsSelected
248 do i=1,maxCouplingTypes
249 SelectedCouplingOrders(i,j) = -1
250 enddo
251 enddo
252 end
2530
=== added file 'Template/NLO/SubProcesses/FKSParams.f90'
--- Template/NLO/SubProcesses/FKSParams.f90 1970-01-01 00:00:00 +0000
+++ Template/NLO/SubProcesses/FKSParams.f90 2019-09-12 11:14:33 +0000
@@ -0,0 +1,248 @@
1!====================================================================
2!
3! Define common block with all general parameters used by MadFKS
4! See their definitions in the file FKS_params.dat.
5!
6!====================================================================
7module FKSParams
8 character(len=64), parameter :: paramFileName='FKS_params.dat'
9 integer,parameter :: maxContribsSelected=100, &
10 maxCouplingsSelected=100, &
11 maxContribType=15, &
12 maxCouplingTypes=20
13 real*8 :: IRPoleCheckThreshold,Virt_fraction, PrecisionVirtualAtRunTime,Min_virt_fraction
14 integer :: NHelForMCoverHels,VetoedContributionTypes(0:maxContribsSelected), &
15 SelectedContributionTypes(0:maxContribsSelected),QED_squared_selected, &
16 SelectedCouplingOrders(maxCouplingTypes,0:maxCouplingsSelected), &
17 QCD_squared_selected
18 logical :: separate_flavour_configs,IncludeBornContributions,use_poly_virtual
19
20contains
21
22 subroutine FKSParamReader(filename, printParam, force)
23 ! Reads the file 'filename' and sets the parameters found in that file.
24 implicit none
25 logical, save :: HasReadOnce=.False.,paramPrinted=.false.
26 logical :: force,couldRead,printParam
27 character(*) :: filename
28 CHARACTER(len=64) :: buff, buff2, mode
29 include "orders.inc"
30 integer :: i,j
31 couldRead=.False.
32 if (HasReadOnce.and..not.force) then
33 goto 901
34 endif
35! Make sure to have default parameters if not set in the FKSParams.dat card
36! (if it is an old one for instance)
37 call DefaultFKSParam()
38! Overwrite the default parameters from file:
39 open(68, file=fileName, err=676, action='READ')
40 do
41 read(68,*,end=999) buff
42 if(index(buff,'#').eq.1) then
43 if (buff .eq. '#IRPoleCheckThreshold') then
44 read(68,*,end=999) IRPoleCheckThreshold
45 if (IRPoleCheckThreshold .lt. -1.01d0 ) then
46 stop 'IRPoleCheckThreshold must be >= -1.0d0.'
47 endif
48 elseif (buff .eq. '#PrecisionVirtualAtRunTime') then
49 read(68,*,end=999) PrecisionVirtualAtRunTime
50 if (IRPoleCheckThreshold .lt. -1.01d0 ) then
51 stop 'PrecisionVirtualAtRunTime must be >= -1.0d0.'
52 endif
53 else if (buff .eq. '#NHelForMCoverHels') then
54 read(68,*,end=999) NHelForMCoverHels
55 if (NHelForMCoverHels .lt. -1) then
56 stop 'NHelForMCoverHels must be >= -1.'
57 endif
58 else if (buff .eq. '#QCD^2==') then
59 read(68,*,end=999) QCD_squared_selected
60 if (QCD_squared_selected .lt. -1) then
61 stop 'QCD_squared_selected must be >= -1.'
62 endif
63 else if (buff .eq. '#QED^2==') then
64 read(68,*,end=999) QED_squared_selected
65 if (QED_squared_selected .lt. -1) then
66 stop 'QED_squared_selected must be >= -1.'
67 endif
68 else if (buff .eq. '#VirtualFraction') then
69 read(68,*,end=999) Virt_fraction
70 if (Virt_fraction .lt. 0 .or. virt_fraction .gt.1) then
71 stop 'VirtualFraction should be a fraction between 0 and 1'
72 endif
73 else if (buff .eq. '#MinVirtualFraction') then
74 read(68,*,end=999) Min_Virt_fraction
75 if (min_virt_fraction .lt. 0 .or. min_virt_fraction .gt.1) then
76 stop 'VirtualFraction should be a fraction between 0 and 1'
77 endif
78 else if (buff .eq. '#SeparateFlavourConfigurations') then
79 read(68,*,end=999) separate_flavour_configs
80 else if (buff .eq. '#UsePolyVirtual') then
81 read(68,*,end=999) use_poly_virtual
82 else if (buff .eq. '#VetoedContributionTypes') then
83 read(68,*,end=999) VetoedContributionTypes(0)
84 if (VetoedContributionTypes(0) .lt. 0.or. &
85 VetoedContributionTypes(0) .gt. maxContribsSelected) then
86 write(*,*) 'VetoedContributionTypes length should be >= 0 and <=', &
87 maxContribsSelected
88 stop 'Format error in FKS_params.dat.'
89 endif
90 read(68,*,end=999) (VetoedContributionTypes(I),I=1,VetoedContributionTypes(0))
91 do I=1,VetoedContributionTypes(0)
92 if (VetoedContributionTypes(I).lt.1.or. &
93 VetoedContributionTypes(I).gt.maxContribType) then
94 write(*,*) 'VetoedContributionTypes must be >=1 and <=',maxContribType
95 stop 'Format error in FKS_params.dat.'
96 endif
97 enddo
98 do I=VetoedContributionTypes(0)+1,maxContribsSelected
99 VetoedContributionTypes(I)=-1
100 enddo
101
102 else if (buff .eq. '#SelectedContributionTypes') then
103 read(68,*,end=999) SelectedContributionTypes(0)
104 if (SelectedContributionTypes(0) .lt. 0 .or. &
105 SelectedContributionTypes(0) .gt. maxContribsSelected) then
106 write(*,*) 'SelectedContributionTypes length should be >= 0 and <=', &
107 maxContribsSelected
108 stop 'Format error in FKS_params.dat.'
109 endif
110 read(68,*,end=999) (SelectedContributionTypes(I),I=1,SelectedContributionTypes(0))
111 do I=1,SelectedContributionTypes(0)
112 if (SelectedContributionTypes(I).lt.1.or. &
113 SelectedContributionTypes(I).gt.maxContribType) then
114 write(*,*) 'SelectedContributionTypes must be >=1 and <=',maxContribType
115 stop 'Format error in FKS_params.dat.'
116 endif
117 enddo
118 do I=SelectedContributionTypes(0)+1,maxContribsSelected
119 SelectedContributionTypes(I)=-1
120 enddo
121 else if (buff .eq. '#SelectedCouplingOrders') then
122 read(68,*,end=999) SelectedCouplingOrders(1,0)
123 if (SelectedCouplingOrders(1,0) .lt. 0 .or. &
124 SelectedCouplingOrders(1,0) .gt. maxCouplingsSelected) then
125 write(*,*) 'SelectedCouplingOrders length should be >= 0 and <=', &
126 maxCouplingsSelected
127 stop 'Format error in FKS_params.dat.'
128 endif
129 do j = 2, maxCouplingTypes
130 SelectedCouplingOrders(j,0) = SelectedCouplingOrders(1,0)
131 enddo
132 do j = 1, SelectedCouplingOrders(1,0)
133 read(68,*,end=999) (SelectedCouplingOrders(i,j),i=1,nsplitorders)
134 do i=nsplitorders+1,maxCouplingTypes
135 SelectedCouplingOrders(i,j)=-1
136 enddo
137 enddo
138 else
139 write(*,*) 'The parameter name ',buff(2:),'is not reckognized.'
140 stop 'Format error in FKS_params.dat.'
141 endif
142 endif
143 enddo
144999 continue
145 couldRead=.True.
146 goto 998
147
148676 continue
149 write(*,*) 'ERROR :: MadFKS parameter file ',fileName, &
150 ' could not be found or is malformed. Please specify it.'
151 stop
152 ! Below is the code if one desires to let the code continue with
153 ! a non existing or malformed parameter file
154 write(*,*) 'WARNING :: The file ',fileName,' could not be ', &
155 ' open or did not contain the necessary information. The ', &
156 ' default MadFKS parameters will be used.'
157 call DefaultFKSParam()
158 goto 998
159998 continue
160
161 if(printParam.and..not.paramPrinted) then
162 write(*,*) &
163 '==============================================================='
164 if (couldRead) then
165 write(*,*) 'INFO: MadFKS read these parameters from ',filename
166 else
167 write(*,*) 'INFO: MadFKS used the default parameters.'
168 endif
169 write(*,*) &
170 '==============================================================='
171 write(*,*) ' > IRPoleCheckThreshold = ',IRPoleCheckThreshold
172 write(*,*) ' > PrecisionVirtualAtRunTime = ',PrecisionVirtualAtRunTime
173 if (SelectedContributionTypes(0).gt.0) then
174 write(*,*) ' > SelectedContributionTypes = ', &
175 (SelectedContributionTypes(I),I=1,SelectedContributionTypes(0))
176 else
177 write(*,*) ' > SelectedContributionTypes = All'
178 endif
179 if (VetoedContributionTypes(0).gt.0) then
180 write(*,*) ' > VetoedContributionTypes = ', &
181 (VetoedContributionTypes(I),I=1,VetoedContributionTypes(0))
182 else
183 write(*,*) ' > VetoedContributionTypes = None'
184 endif
185 if (QCD_squared_selected.eq.-1) then
186 write(*,*) ' > QCD_squared_selected = All'
187 else
188 write(*,*) ' > QCD_squared_selected = ',QCD_squared_selected
189 endif
190 if (QED_squared_selected.eq.-1) then
191 write(*,*) ' > QED_squared_selected = All'
192 else
193 write(*,*) ' > QED_squared_selected = ',QED_squared_selected
194 endif
195 if (SelectedCouplingOrders(1,0).gt.0) then
196 do j=1,SelectedCouplingOrders(1,0)
197 write(*,*) ' > SelectedCouplingOrders(',j,') = ', &
198 (SelectedCouplingOrders(i,j),i=1,nsplitorders)
199 enddo
200 else
201 write(*,*) ' > SelectedCouplingOrders = All'
202 endif
203 write(*,*) ' > NHelForMCoverHels = ',NHelForMCoverHels
204 write(*,*) ' > VirtualFraction = ',Virt_fraction
205 write(*,*) ' > MinVirtualFraction = ',Min_virt_fraction
206 write(*,*) ' > SeparateFlavourConfigs = ',separate_flavour_configs
207 write(*,*) ' > UsePolyVirtual = ',use_poly_virtual
208 write(*,*) &
209 '==============================================================='
210 paramPrinted=.TRUE.
211 endif
212
213 close(68)
214 HasReadOnce=.TRUE.
215901 continue
216 end subroutine FKSParamReader
217
218 subroutine DefaultFKSParam()
219 ! Sets the default parameters
220 implicit none
221 integer i,j
222 IRPoleCheckThreshold=1.0d-5
223 NHelForMCoverHels=5
224 PrecisionVirtualAtRunTime=1d-3
225 Virt_fraction=1d0
226 QED_squared_selected=-1
227 QCD_squared_selected=-1
228 Min_virt_fraction=0.005d0
229 separate_flavour_configs=.false.
230 use_poly_virtual=.true.
231 IncludeBornContributions=.true.
232 SelectedContributionTypes(0)=0
233 VetoedContributionTypes(0)=0
234 do i=1, maxContribsSelected
235 SelectedContributionTypes(I)=-1
236 VetoedContributionTypes(I)=-1
237 enddo
238 do j=1,maxCouplingTypes
239 SelectedCouplingOrders(j,0) = 0
240 enddo
241 do j=1,maxCouplingsSelected
242 do i=1,maxCouplingTypes
243 SelectedCouplingOrders(i,j) = -1
244 enddo
245 enddo
246 end subroutine DefaultFKSParam
247
248end module FKSParams
0249
=== removed file 'Template/NLO/SubProcesses/FKSParams.inc'
--- Template/NLO/SubProcesses/FKSParams.inc 2017-08-04 19:52:15 +0000
+++ Template/NLO/SubProcesses/FKSParams.inc 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
1!====================================================================
2!
3! Define common block with all general parameters used by MadFKS
4! See their definitions in the file FKS_params.dat.
5!
6!====================================================================
7
8 character*64 paramFileName
9 parameter ( paramFileName='FKS_params.dat')
10
11 integer maxContribsSelected, maxCouplingsSelected
12 parameter( maxContribsSelected=100, maxCouplingsSelected=100 )
13 integer maxContribType, maxCouplingTypes
14 parameter ( maxContribType=15, maxCouplingTypes=20 )
15
16 real*8 IRPoleCheckThreshold,Virt_fraction,
17 & PrecisionVirtualAtRunTime,Min_virt_fraction
18
19 integer NHelForMCoverHels, VetoedContributionTypes(0:maxContribsSelected),
20 & SelectedContributionTypes(0:maxContribsSelected),
21 & QED_squared_selected, QCD_squared_selected,
22 & SelectedCouplingOrders(maxCouplingTypes,0:maxCouplingsSelected)
23
24 logical separate_flavour_configs, IncludeBornContributions
25
26 common /FKSPARAMS/IRPoleCheckThreshold,virt_fraction,
27 & PrecisionVirtualAtRunTime,min_virt_fraction,
28 & NHelForMCoverHels,separate_flavour_configs,
29 & QCD_squared_selected, QED_squared_selected,
30 & VetoedContributionTypes, SelectedContributionTypes,
31 & SelectedCouplingOrders
320
=== modified file 'Template/NLO/SubProcesses/check_poles.f'
--- Template/NLO/SubProcesses/check_poles.f 2018-12-21 15:27:32 +0000
+++ Template/NLO/SubProcesses/check_poles.f 2019-09-12 11:14:33 +0000
@@ -3,6 +3,7 @@
3c This is the driver for the whole calulation3c This is the driver for the whole calulation
4c**************************************************************************4c**************************************************************************
5 use mint_module5 use mint_module
6 use FKSParams
6 implicit none7 implicit none
7C8C
8C CONSTANTS9C CONSTANTS
@@ -64,7 +65,6 @@
64 common /to_polecheck/force_polecheck, polecheck_passed65 common /to_polecheck/force_polecheck, polecheck_passed
65 integer ret_code_ml66 integer ret_code_ml
66 common /to_ret_code/ret_code_ml67 common /to_ret_code/ret_code_ml
67 include 'FKSParams.inc'
68 68
69C-----69C-----
70C BEGIN CODE70C BEGIN CODE
7171
=== modified file 'Template/NLO/SubProcesses/driver_mintFO.f'
--- Template/NLO/SubProcesses/driver_mintFO.f 2019-09-12 09:03:04 +0000
+++ Template/NLO/SubProcesses/driver_mintFO.f 2019-09-12 11:14:33 +0000
@@ -4,6 +4,7 @@
4c**************************************************************************4c**************************************************************************
5 use extra_weights5 use extra_weights
6 use mint_module6 use mint_module
7 use FKSParams
7 implicit none8 implicit none
8C9C
9C CONSTANTS10C CONSTANTS
@@ -66,9 +67,6 @@
66 include "timing_variables.inc"67 include "timing_variables.inc"
67 real*4 tOther, tTot68 real*4 tOther, tTot
6869
69c general MadFKS parameters
70 include "FKSParams.inc"
71
72c applgrid70c applgrid
73 integer iappl71 integer iappl
74 common /for_applgrid/ iappl72 common /for_applgrid/ iappl
7573
=== modified file 'Template/NLO/SubProcesses/driver_mintMC.f'
--- Template/NLO/SubProcesses/driver_mintMC.f 2019-09-12 09:03:04 +0000
+++ Template/NLO/SubProcesses/driver_mintMC.f 2019-09-12 11:14:33 +0000
@@ -4,6 +4,7 @@
4c**************************************************************************4c**************************************************************************
5 use extra_weights5 use extra_weights
6 use mint_module6 use mint_module
7 use FKSParams
7 implicit none8 implicit none
8C9C
9C CONSTANTS10C CONSTANTS
@@ -74,9 +75,6 @@
74 include "timing_variables.inc"75 include "timing_variables.inc"
75 real*4 tOther, tTot76 real*4 tOther, tTot
7677
77c general MadFKS parameters
78 include "FKSParams.inc"
79
80 double precision deravg,derstd,dermax,xi_i_fks_ev_der_max78 double precision deravg,derstd,dermax,xi_i_fks_ev_der_max
81 & ,y_ij_fks_ev_der_max79 & ,y_ij_fks_ev_der_max
82 integer ntot_granny,derntot,ncase(0:6)80 integer ntot_granny,derntot,ncase(0:6)
8381
=== modified file 'Template/NLO/SubProcesses/fks_singular.f'
--- Template/NLO/SubProcesses/fks_singular.f 2019-09-12 09:03:04 +0000
+++ Template/NLO/SubProcesses/fks_singular.f 2019-09-12 11:14:33 +0000
@@ -1456,6 +1456,7 @@
1456c contribution1456c contribution
1457 use weight_lines1457 use weight_lines
1458 use extra_weights1458 use extra_weights
1459 use FKSParams
1459 implicit none1460 implicit none
1460 include 'nexternal.inc'1461 include 'nexternal.inc'
1461 include 'run.inc'1462 include 'run.inc'
@@ -1463,7 +1464,6 @@
1463 include 'coupl.inc'1464 include 'coupl.inc'
1464 include 'fks_info.inc'1465 include 'fks_info.inc'
1465 include 'q_es.inc'1466 include 'q_es.inc'
1466 include 'FKSParams.inc'
1467 include 'orders.inc'1467 include 'orders.inc'
1468 integer type,i,j1468 integer type,i,j
1469 logical foundIt,foundOrders1469 logical foundIt,foundOrders
@@ -1651,6 +1651,7 @@
1651 use weight_lines1651 use weight_lines
1652 use extra_weights1652 use extra_weights
1653 use mint_module1653 use mint_module
1654 use FKSParams
1654 implicit none1655 implicit none
1655 include 'nexternal.inc'1656 include 'nexternal.inc'
1656 include 'run.inc'1657 include 'run.inc'
@@ -1658,7 +1659,6 @@
1658 include 'timing_variables.inc'1659 include 'timing_variables.inc'
1659 include 'genps.inc'1660 include 'genps.inc'
1660 include 'orders.inc'1661 include 'orders.inc'
1661 include 'FKSParams.inc'
1662 integer orders(nsplitorders)1662 integer orders(nsplitorders)
1663 integer i,j,k,iamp,icontr_orig1663 integer i,j,k,iamp,icontr_orig
1664 logical virt_found1664 logical virt_found
@@ -2011,11 +2011,11 @@
2011c wgts() array to include the weights.2011c wgts() array to include the weights.
2012 use weight_lines2012 use weight_lines
2013 use extra_weights2013 use extra_weights
2014 use FKSParams
2014 implicit none2015 implicit none
2015 include 'nexternal.inc'2016 include 'nexternal.inc'
2016 include 'run.inc'2017 include 'run.inc'
2017 include 'timing_variables.inc'2018 include 'timing_variables.inc'
2018 include 'FKSParams.inc'
2019 include 'genps.inc'2019 include 'genps.inc'
2020 integer i,kr,kf,iwgt_save,dd2020 integer i,kr,kf,iwgt_save,dd
2021 double precision xlum(maxscales),dlum,pi,mu2_r(maxscales),c_mu2_r2021 double precision xlum(maxscales),dlum,pi,mu2_r(maxscales),c_mu2_r
@@ -2094,11 +2094,11 @@
2094c computations (ickkw.eq.-1).2094c computations (ickkw.eq.-1).
2095 use weight_lines2095 use weight_lines
2096 use extra_weights2096 use extra_weights
2097 use FKSParams
2097 implicit none2098 implicit none
2098 include 'nexternal.inc'2099 include 'nexternal.inc'
2099 include 'run.inc'2100 include 'run.inc'
2100 include 'timing_variables.inc'2101 include 'timing_variables.inc'
2101 include 'FKSParams.inc'
2102 include 'genps.inc'2102 include 'genps.inc'
2103 integer i,ks,kh,iwgt_save2103 integer i,ks,kh,iwgt_save
2104 double precision xlum(maxscales),dlum,pi,mu2_r(maxscales)2104 double precision xlum(maxscales),dlum,pi,mu2_r(maxscales)
@@ -2200,11 +2200,11 @@
2200c wgts() array to include the weights.2200c wgts() array to include the weights.
2201 use weight_lines2201 use weight_lines
2202 use extra_weights2202 use extra_weights
2203 use FKSParams
2203 implicit none2204 implicit none
2204 include 'nexternal.inc'2205 include 'nexternal.inc'
2205 include 'run.inc'2206 include 'run.inc'
2206 include 'timing_variables.inc'2207 include 'timing_variables.inc'
2207 include 'FKSParams.inc'
2208 include 'genps.inc'2208 include 'genps.inc'
2209 integer n,izero,i,nn2209 integer n,izero,i,nn
2210 parameter (izero=0)2210 parameter (izero=0)
@@ -5877,12 +5877,22 @@
5877 tOLP=tOLP+(tAfter-tBefore)5877 tOLP=tOLP+(tAfter-tBefore)
5878 virtual_over_born=virt_wgt/born_wgt5878 virtual_over_born=virt_wgt/born_wgt
5879 if (ickkw.ne.-1) then5879 if (ickkw.ne.-1) then
5880 virt_wgt=virt_wgt-average_virtual(0,ichan)*born_wgt5880 if (use_poly_virtual) then
5881 virt_wgt=virt_wgt-polyfit(0)*born_wgt
5882 else
5883 virt_wgt=virt_wgt-average_virtual(0,ichan)*born_wgt
5884 endif
5881 do iamp=1,amp_split_size5885 do iamp=1,amp_split_size
5882 if (amp_split_virt(iamp).eq.0d0) cycle5886 if (amp_split_virt(iamp).eq.0d0) cycle
5887 if (use_poly_virtual) then
5888 amp_split_virt(iamp)=amp_split_virt(iamp)-
5889 $ polyfit(iamp)
5890 $ *amp_split_born_for_virt(iamp)
5891 else
5883 amp_split_virt(iamp)=amp_split_virt(iamp)-5892 amp_split_virt(iamp)=amp_split_virt(iamp)-
5884 $ average_virtual(iamp,ichan)5893 $ average_virtual(iamp,ichan)
5885 $ *amp_split_born_for_virt(iamp)5894 $ *amp_split_born_for_virt(iamp)
5895 endif
5886 enddo5896 enddo
5887 endif5897 endif
5888 if (abrv.ne.'virt') then5898 if (abrv.ne.'virt') then
@@ -5902,12 +5912,21 @@
5902 $ amp_split_virt_save(1:amp_split_size)5912 $ amp_split_virt_save(1:amp_split_size)
5903 endif5913 endif
5904 if (abrv(1:4).ne.'virt' .and. ickkw.ne.-1) then5914 if (abrv(1:4).ne.'virt' .and. ickkw.ne.-1) then
5905 avv_wgt=average_virtual(0,ichan)*born_wgt5915 if (use_poly_virtual) then
5906 do iamp=1, amp_split_size5916 avv_wgt=polyfit(0)*born_wgt
5907 if (amp_split_born_for_virt(iamp).eq.0d0) cycle5917 do iamp=1, amp_split_size
5908 amp_split_avv(iamp)= average_virtual(iamp,ichan)5918 if (amp_split_born_for_virt(iamp).eq.0d0) cycle
5909 $ *amp_split_born_for_virt(iamp)5919 amp_split_avv(iamp)= polyfit(iamp)
5910 enddo5920 $ *amp_split_born_for_virt(iamp)
5921 enddo
5922 else
5923 avv_wgt=average_virtual(0,ichan)*born_wgt
5924 do iamp=1, amp_split_size
5925 if (amp_split_born_for_virt(iamp).eq.0d0) cycle
5926 amp_split_avv(iamp)= average_virtual(iamp,ichan)
5927 $ *amp_split_born_for_virt(iamp)
5928 enddo
5929 endif
5911 endif5930 endif
59125931
5913c eq.(MadFKS.C.13)5932c eq.(MadFKS.C.13)
59145933
=== modified file 'Template/NLO/SubProcesses/makefile_fks_dir'
--- Template/NLO/SubProcesses/makefile_fks_dir 2018-12-21 15:27:32 +0000
+++ Template/NLO/SubProcesses/makefile_fks_dir 2019-09-12 11:14:33 +0000
@@ -26,16 +26,16 @@
2626
27# Files for all executables27# Files for all executables
28FILES= $(patsubst %.f,%.o,$(wildcard parton_lum_*.f)) $(patsubst \28FILES= $(patsubst %.f,%.o,$(wildcard parton_lum_*.f)) $(patsubst \
29 %.f,%.o,$(wildcard matrix_*.f)) real_me_chooser.o \29 %.f,%.o,$(wildcard matrix_*.f)) FKSParams.o real_me_chooser.o \
30 chooser_functions.o genps_fks.o setcuts.o setscales.o \30 chooser_functions.o genps_fks.o setcuts.o setscales.o \
31 veto_xsec.o $(patsubst %.f,%.o,$(wildcard b_sf_???.f)) \31 veto_xsec.o $(patsubst %.f,%.o,$(wildcard b_sf_???.f)) \
32 born.o sborn_sf.o extra_cnt_wrapper.o $(patsubst \32 born.o sborn_sf.o extra_cnt_wrapper.o $(patsubst \
33 %.f,%.o,$(wildcard born_cnt_*.f)) fks_Sij.o \33 %.f,%.o,$(wildcard born_cnt_*.f)) fks_Sij.o \
34 $(fastjetfortran_madfks) fks_singular.o montecarlocounter.o \34 $(fastjetfortran_madfks) fks_singular.o montecarlocounter.o \
35 reweight_xsec.o boostwdir2.o initcluster.o cluster.o \35 reweight_xsec.o boostwdir2.o initcluster.o cluster.o \
36 splitorders_stuff.o reweight.o get_color.o FKSParamReader.o \36 splitorders_stuff.o reweight.o get_color.o \
37 iproc_map.o MC_integer.o $(reweight_xsec_events_pdf_dummy) \37 iproc_map.o MC_integer.o $(reweight_xsec_events_pdf_dummy) \
38 $(applgrid_interface) weight_lines.o mint_module.o38 $(applgrid_interface) weight_lines.o mint_module.o polfit.o
3939
40# Files needed for mintFO & mintMC40# Files needed for mintFO & mintMC
41RUN= $(FO_ANALYSE) $(FILES) cuts.o pythia_unlops.o recluster.o \41RUN= $(FO_ANALYSE) $(FILES) cuts.o pythia_unlops.o recluster.o \
4242
=== modified file 'Template/NLO/SubProcesses/mint_module.f90'
--- Template/NLO/SubProcesses/mint_module.f90 2019-08-15 13:57:46 +0000
+++ Template/NLO/SubProcesses/mint_module.f90 2019-09-12 11:14:33 +0000
@@ -64,8 +64,8 @@
64! nintegrals>6 : virtual and born order by order64! nintegrals>6 : virtual and born order by order
65!65!
6666
67
68module mint_module67module mint_module
68 use FKSParams ! contains use_poly_virtual
69 implicit none69 implicit none
70 integer, parameter, private :: nintervals=32 ! max number of intervals in the integration grids70 integer, parameter, private :: nintervals=32 ! max number of intervals in the integration grids
71 integer, parameter, public :: ndimmax=60 ! max number of dimensions of the integral71 integer, parameter, public :: ndimmax=60 ! max number of dimensions of the integral
@@ -92,7 +92,7 @@
92 integer, dimension(maxchannels), public :: iconfigs92 integer, dimension(maxchannels), public :: iconfigs
93 double precision, public :: accuracy,min_virt_fraction_mint,wgt_mult93 double precision, public :: accuracy,min_virt_fraction_mint,wgt_mult
94 double precision, dimension(0:n_ave_virt,maxchannels), public :: average_virtual94 double precision, dimension(0:n_ave_virt,maxchannels), public :: average_virtual
95 double precision, dimension(0:n_ave_virt), public :: virt_wgt_mint,born_wgt_mint95 double precision, dimension(0:n_ave_virt), public :: virt_wgt_mint,born_wgt_mint,polyfit
96 double precision, dimension(maxchannels), public :: virtual_fraction96 double precision, dimension(maxchannels), public :: virtual_fraction
97 double precision, dimension(nintegrals,0:maxchannels), public :: ans,unc97 double precision, dimension(nintegrals,0:maxchannels), public :: ans,unc
98 logical :: only_virt,new_point,pass_cuts_check98 logical :: only_virt,new_point,pass_cuts_check
@@ -340,9 +340,13 @@
340 ! overwrite xgrid with the new xgrid340 ! overwrite xgrid with the new xgrid
341 if (regridded(kchan)) xgrid(1:nint_used,1:ndim,kchan)=xgrid_new(1:nint_used,1:ndim)341 if (regridded(kchan)) xgrid(1:nint_used,1:ndim,kchan)=xgrid_new(1:nint_used,1:ndim)
342 enddo342 enddo
343 do k_ord_virt=0,n_ord_virt343 if (use_poly_virtual) then
344 call regrid_ave_virt(k_ord_virt)344 call do_polyfit()
345 enddo345 else
346 do k_ord_virt=0,n_ord_virt
347 call regrid_ave_virt(k_ord_virt)
348 enddo
349 endif
346! Regrid the MC over integers (used for the MC over FKS dirs)350! Regrid the MC over integers (used for the MC over FKS dirs)
347 call regrid_MC_integer351 call regrid_MC_integer
348 end subroutine update_integration_grids352 end subroutine update_integration_grids
@@ -664,10 +668,18 @@
664 isix=2*k_ord_virt+6668 isix=2*k_ord_virt+6
665 endif669 endif
666 if (f(ithree).ne.0d0) then670 if (f(ithree).ne.0d0) then
667 f(isix)=f(isix)/virtual_fraction(ichan)671 born=f(isix)
668 virtual=(f(ithree)+average_virtual(k_ord_virt,ichan)*f(isix))*virtual_fraction(ichan)672 ! virt_wgt_mint=(virtual-average_virtual*born)/virtual_fraction. Compensate:
669 born=f(isix)*virtual_fraction(ichan)673 if (use_poly_virtual) then
670 call fill_ave_virt(x,k_ord_virt,virtual,born)674 virtual=f(ithree)*virtual_fraction(ichan)+ &
675 polyfit(k_ord_virt)*f(isix)
676 call add_point_polyfit(ichan,k_ord_virt,x(1:ndim-3), &
677 virtual/born,born/wgt_mult)
678 else
679 virtual=f(ithree)*virtual_fraction(ichan)+ &
680 average_virtual(k_ord_virt,ichan)*f(isix)
681 call fill_ave_virt(x,k_ord_virt,virtual,born)
682 endif
671 else683 else
672 f(isix)=0d0684 f(isix)=0d0
673 endif685 endif
@@ -801,7 +813,11 @@
801 if(imode.eq.0) nhits(icell(kdim),kdim,ichan)=nhits(icell(kdim),kdim,ichan)+1813 if(imode.eq.0) nhits(icell(kdim),kdim,ichan)=nhits(icell(kdim),kdim,ichan)+1
802 enddo814 enddo
803 do k_ord_virt=0,n_ord_virt815 do k_ord_virt=0,n_ord_virt
804 call get_ave_virt(x,k_ord_virt)816 if (use_poly_virtual) then
817 call get_polyfit(ichan,k_ord_virt,x(1:ndim-3),polyfit(k_ord_virt))
818 else
819 call get_ave_virt(x,k_ord_virt)
820 endif
805 enddo821 enddo
806 end subroutine get_random_x822 end subroutine get_random_x
807 823
@@ -988,14 +1004,18 @@
9881004
989 subroutine reset_mint_grids1005 subroutine reset_mint_grids
990 implicit none1006 implicit none
991 integer :: kdim,kchan,kint,k_ord_virt1007 integer :: kdim,kchan,kint
992 do kint=0,nint_used1008 do kint=0,nint_used
993 xgrid(kint,1:ndim,1:nchans)=dble(kint)/nint_used1009 xgrid(kint,1:ndim,1:nchans)=dble(kint)/nint_used
994 enddo1010 enddo
995 nhits(1:nint_used,1:ndim,1:nchans)=01011 nhits(1:nint_used,1:ndim,1:nchans)=0
996 regridded(1:nchans)=.true.1012 regridded(1:nchans)=.true.
997 nhits_in_grids(1:nchans)=01013 nhits_in_grids(1:nchans)=0
998 call init_ave_virt1014 if (use_poly_virtual) then
1015 call init_polyfit(ndim-3,nchans,n_ord_virt,1000)
1016 else
1017 call init_ave_virt
1018 endif
999 ans_chan(0:nchans)=0d01019 ans_chan(0:nchans)=0d0
1000 if (double_events) then1020 if (double_events) then
1001 ! when double events, start with the very first channel only. For the1021 ! when double events, start with the very first channel only. For the
@@ -1032,11 +1052,13 @@
1032 write (12,*) 'MAX',(ymax(j,i,kchan),i=1,ndim)1052 write (12,*) 'MAX',(ymax(j,i,kchan),i=1,ndim)
1033 enddo1053 enddo
1034 endif1054 endif
1035 do j=1,nintervals_virt1055 if (.not.use_poly_virtual) then
1036 do k=0,n_ord_virt1056 do j=1,nintervals_virt
1037 write (12,*) 'AVE',(ave_virt(j,i,k,kchan),i=1,ndim)1057 do k=0,n_ord_virt
1058 write (12,*) 'AVE',(ave_virt(j,i,k,kchan),i=1,ndim)
1059 enddo
1038 enddo1060 enddo
1039 enddo1061 endif
1040 if (imode.ge.1) then1062 if (imode.ge.1) then
1041 write (12,*) 'MAX',ymax_virt(kchan)1063 write (12,*) 'MAX',ymax_virt(kchan)
1042 endif1064 endif
@@ -1046,6 +1068,7 @@
1046 write (12,*) 'AVE',virtual_fraction(kchan),average_virtual(0,kchan)1068 write (12,*) 'AVE',virtual_fraction(kchan),average_virtual(0,kchan)
1047 enddo1069 enddo
1048 write (12,*) 'IDE',(ifold(i),i=1,ndim)1070 write (12,*) 'IDE',(ifold(i),i=1,ndim)
1071 if (use_poly_virtual) call save_polyfit(12)
1049 close (12)1072 close (12)
1050 end subroutine write_grids_to_file1073 end subroutine write_grids_to_file
1051 1074
@@ -1053,6 +1076,7 @@
1053! Read the MINT integration grids from file1076! Read the MINT integration grids from file
1054 implicit none1077 implicit none
1055 integer :: i,j,k,kchan,idum1078 integer :: i,j,k,kchan,idum
1079 integer,dimension(maxchannels) :: points
1056 character(len=3) :: dummy1080 character(len=3) :: dummy
1057 open (unit=12, file='mint_grids',status='old')1081 open (unit=12, file='mint_grids',status='old')
1058 ans(1,0)=0d01082 ans(1,0)=0d0
@@ -1066,11 +1090,13 @@
1066 read (12,*) dummy,(ymax(j,i,kchan),i=1,ndim)1090 read (12,*) dummy,(ymax(j,i,kchan),i=1,ndim)
1067 enddo1091 enddo
1068 endif1092 endif
1069 do j=1,nintervals_virt1093 if (.not.use_poly_virtual) then
1070 do k=0,n_ord_virt1094 do j=1,nintervals_virt
1071 read (12,*) dummy,(ave_virt(j,i,k,kchan),i=1,ndim)1095 do k=0,n_ord_virt
1096 read (12,*) dummy,(ave_virt(j,i,k,kchan),i=1,ndim)
1097 enddo
1072 enddo1098 enddo
1073 enddo1099 endif
1074 if (imode.ge.2) then1100 if (imode.ge.2) then
1075 read (12,*) dummy,ymax_virt(kchan)1101 read (12,*) dummy,ymax_virt(kchan)
1076 endif1102 endif
@@ -1083,6 +1109,18 @@
1083 enddo1109 enddo
1084 read (12,*) dummy,(ifold(i),i=1,ndim)1110 read (12,*) dummy,(ifold(i),i=1,ndim)
1085 unc(1,0)=sqrt(unc(1,0))1111 unc(1,0)=sqrt(unc(1,0))
1112 ! polyfit stuff:
1113 if (use_poly_virtual) then
1114 do kchan=1,nchans
1115 read (12,*) dummy,points(kchan)
1116 enddo
1117 do kchan=1,nchans
1118 backspace(12)
1119 enddo
1120 call init_polyfit(ndim-3,nchans,n_ord_virt,maxval(points(1:nchans)))
1121 call restore_polyfit(12)
1122 call do_polyfit()
1123 endif
1086 close (12)1124 close (12)
1087! check for zero cross-section: if restoring grids corresponding to1125! check for zero cross-section: if restoring grids corresponding to
1088! sigma=0, just terminate the run1126! sigma=0, just terminate the run
10891127
=== added file 'Template/NLO/SubProcesses/polfit.f'
--- Template/NLO/SubProcesses/polfit.f 1970-01-01 00:00:00 +0000
+++ Template/NLO/SubProcesses/polfit.f 2019-09-12 11:14:33 +0000
@@ -0,0 +1,720 @@
1 subroutine init_polyfit(ndims,nchans,k_ord_virt,npoints)
2! wrapper subroutine that saves all information that's needed for calls
3! to the polfit() and pvalue() subroutines. Since I was too lazy to
4! write a proper module, use fortran entry statements to jump to the
5! right locations in this subroutine.
6 implicit none
7 integer ndims,nchans,ndim,nchan,maxpoint,maxdeg,ierr,i,ichan,ic
8 $ ,iunit,npoints,n_ord_virt,k_ord_virt,ko
9 integer,allocatable,dimension(:) :: n
10 integer,allocatable,dimension(:,:,:) :: ndeg
11 real*8,allocatable,dimension(:) :: r,yp,a
12 real*8,allocatable,dimension(:,:,:) :: y,w,x2d,temp3
13 real*8,allocatable,dimension(:,:,:,:) :: a2d
14 logical,allocatable,dimension(:) :: valid_ord_virt
15 parameter (maxdeg=20)
16 real*8 absXS,virt,ave_fun,fun_at_x,eps,sum_w,yfit,x(*)
17 logical fit_done,verbose
18 parameter (verbose=.false.)
19 character(len=3) :: dummy
20 save
21 maxpoint=npoints
22 nchan=nchans
23 ndim=ndims
24 n_ord_virt=k_ord_virt
25 if (allocated(ndeg)) deallocate(ndeg)
26 allocate(ndeg(ndim,0:n_ord_virt,nchan))
27 if (allocated(n)) deallocate(n)
28 allocate(n(nchan))
29 if (allocated(a)) deallocate(a)
30 allocate(a(maxpoint*3+maxdeg*3+3))
31 if (allocated(y)) deallocate(y)
32 allocate(y(maxpoint,0:n_ord_virt,nchan))
33 if (allocated(w)) deallocate(w)
34 allocate(w(maxpoint,0:n_ord_virt,nchan))
35 if (allocated(r)) deallocate(r)
36 allocate(r(maxpoint))
37 if (allocated(yp)) deallocate(yp)
38 allocate(yp(maxdeg))
39 if (allocated(x2d)) deallocate(x2d)
40 allocate(x2d(maxpoint,ndim,nchan))
41 if (allocated(a2d)) deallocate(a2d)
42 allocate(a2d(maxdeg*3+3,ndim,0:n_ord_virt,nchan))
43 if (allocated(valid_ord_virt)) deallocate(valid_ord_virt)
44 allocate(valid_ord_virt(0:n_ord_virt))
45 n(1:nchan)=0
46 fit_done=.false.
47 valid_ord_virt(0:n_ord_virt)=.false.
48 return
49
50 entry add_point_polyfit(ichan,k_ord_virt,x,virt,absXS)
51 ! only increment 'n' and 'x2d' if it's the zeroth "order" in the
52 ! virtual/born ratio
53 valid_ord_virt(k_ord_virt)=.true.
54 if (k_ord_virt.eq.0) then
55 if (n(ichan).eq.maxpoint) then
56! increase the size of the allocated variables:
57 maxpoint=maxpoint+1000
58 allocate(temp3(maxpoint,0:n_ord_virt,nchan))
59 do i=1,nchan
60 temp3(1:n(i),0:n_ord_virt,i)=y(1:n(i),0:n_ord_virt,i)
61 enddo
62 call move_alloc(temp3,y)
63 allocate(temp3(maxpoint,0:n_ord_virt,nchan))
64 do i=1,nchan
65 temp3(1:n(i),0:n_ord_virt,i)=w(1:n(i),0:n_ord_virt,i)
66 enddo
67 call move_alloc(temp3,w)
68 deallocate(r)
69 allocate(r(maxpoint))
70 allocate(temp3(maxpoint,ndim,nchan))
71 do i=1,nchan
72 temp3(1:n(i),1:ndim,i)=x2d(1:n(i),1:ndim,i)
73 enddo
74 call move_alloc(temp3,x2d)
75 deallocate(a)
76 allocate(a(maxpoint*3+maxdeg*3+3))
77 endif
78 n(ichan)=n(ichan)+1
79! add the point to the saved information
80 do i=1,ndim
81 x2d(n(ichan),i,ichan)=x(i)
82 enddo
83! initialise all to zero
84 y(n(ichan),0:n_ord_virt,ichan)=0d0
85 w(n(ichan),0:n_ord_virt,ichan)=0d0
86 endif
87 y(n(ichan),k_ord_virt,ichan)=virt
88 w(n(ichan),k_ord_virt,ichan)=sqrt(abs(absXS))
89 return
90
91 entry do_polyfit()
92 ! perform the fit for each dimension and each channel
93 do ic=1,nchan
94 do ko=0,n_ord_virt
95 if (.not.valid_ord_virt(ko)) cycle
96 do i=1,ndim
97 eps=-1d0
98 call polfit(n(ic),x2d(1,i,ic),y(1,ko,ic),w(1,ko,ic)
99 $ ,maxdeg,ndeg(i,ko,ic),eps,r,ierr,a)
100 ! this is the information used by pvalue() to interpolate
101 ! later:
102 a2d(1:maxdeg*3+3,i,ko,ic)=a(1:maxdeg*3+3)
103 ! print something in the logs:
104 if (verbose) write (*,'(a,i3,i3,i3,i8,i3,i3,f10.4)')
105 $ 'polyfit -',ic,ko,i,n(ic),ndeg(i,ko,ic),ierr,eps
106 enddo
107 enddo
108 enddo
109 fit_done=.true.
110 return
111
112 entry get_polyfit(ichan,k_ord_virt,x,fun_at_x)
113 ! if we haven't do a fit to the data, just return zero. This is
114 ! typically the case only during the very first iteration.
115 if ((.not.fit_done) .or. (.not.valid_ord_virt(k_ord_virt))) then
116 fun_at_x=0d0
117 return
118 endif
119 ! Do the interpolation. Since we have several dimensions, we use
120 ! the following:
121 ! f(x) = average + sum_i (f_i(x_i)-average)
122 ! where 'i' loops over all dimensions. In other words, the
123 ! information from each of the separate dimensions should only add
124 ! (or subtract) something from the average value. To obtain the
125 ! average, simply call pvalue() to return the zeroth-order
126 ! polynomial.
127 fun_at_x=0d0
128 do i=1,ndim
129 a(1:maxdeg*3+3)=a2d(1:maxdeg*3+3,i,k_ord_virt,ichan)
130 call pvalue(ndeg(i,k_ord_virt,ichan),0,x(i),yfit,yp,a)
131 call pvalue(0,0,x(i),ave_fun,yp,a)
132 fun_at_x=fun_at_x+(yfit-ave_fun)+ave_fun/dble(ndim)
133 enddo
134 return
135
136 entry save_polyfit(iunit)
137 do ic=1,nchan
138 write (iunit,*) 'POL',n(ic)
139 enddo
140 do ic=1,nchan
141 do i=1,n(ic)
142 write (iunit,*) 'POL',x2d(i,1:ndim,ic),
143 & y(i,0:n_ord_virt,ic),w(i,0:n_ord_virt,ic)
144 enddo
145 enddo
146 return
147
148 entry restore_polyfit(iunit)
149 do ic=1,nchan
150 read (iunit,*) dummy,n(ic)
151 enddo
152 do ic=1,nchan
153 do i=1,n(ic)
154 read (iunit,*) dummy,x2d(i,1:ndim,ic)
155 & ,y(i,0:n_ord_virt,ic),w(i,0:n_ord_virt,ic)
156 enddo
157 enddo
158 do ic=1,nchan
159 do ko=0,n_ord_virt
160 do i=1,n(ic)
161 if (y(i,ko,ic).ne.0d0) valid_ord_virt(ko)=.true.
162 enddo
163 enddo
164 enddo
165 if (verbose) write (*,*) 'polyfit - valid orders virt'
166 $ ,valid_ord_virt(0:n_ord_virt)
167 return
168 end
169
170
171
172
173
174*DECK POLFIT
175 SUBROUTINE POLFIT (N, X, Y, W, MAXDEG, NDEG, EPS, R, IERR, A)
176c
177c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
178cRF: make double precision and replace DO-loops and arirthmic
179c IF-statements to comply more modern standards. Since we made it
180c double precision, the 'extended, partial-double' precision part has
181c become useless. Could remove it, but there is no real reason for
182c that (should only be marginally faster).
183c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
184c
185C***BEGIN PROLOGUE POLFIT
186C***PURPOSE Fit discrete data in a least squares sense by polynomials
187C in one variable.
188C***LIBRARY SLATEC
189C***CATEGORY K1A1A2
190C***TYPE SINGLE PRECISION (POLFIT-S, DPOLFT-D)
191C***KEYWORDS CURVE FITTING, DATA FITTING, LEAST SQUARES, POLYNOMIAL FIT
192C***AUTHOR Shampine, L. F., (SNLA)
193C Davenport, S. M., (SNLA)
194C Huddleston, R. E., (SNLL)
195C***DESCRIPTION
196C
197C Abstract
198C
199C Given a collection of points X(I) and a set of values Y(I) which
200C correspond to some function or measurement at each of the X(I),
201C subroutine POLFIT computes the weighted least-squares polynomial
202C fits of all degrees up to some degree either specified by the user
203C or determined by the routine. The fits thus obtained are in
204C orthogonal polynomial form. Subroutine PVALUE may then be
205C called to evaluate the fitted polynomials and any of their
206C derivatives at any point. The subroutine PCOEF may be used to
207C express the polynomial fits as powers of (X-C) for any specified
208C point C.
209C
210C The parameters for POLFIT are
211C
212C Input --
213C N - the number of data points. The arrays X, Y and W
214C must be dimensioned at least N (N .GE. 1).
215C X - array of values of the independent variable. These
216C values may appear in any order and need not all be
217C distinct.
218C Y - array of corresponding function values.
219C W - array of positive values to be used as weights. If
220C W(1) is negative, POLFIT will set all the weights
221C to 1.0, which means unweighted least squares error
222C will be minimized. To minimize relative error, the
223C user should set the weights to: W(I) = 1.0/Y(I)**2,
224C I = 1,...,N .
225C MAXDEG - maximum degree to be allowed for polynomial fit.
226C MAXDEG may be any non-negative integer less than N.
227C Note -- MAXDEG cannot be equal to N-1 when a
228C statistical test is to be used for degree selection,
229C i.e., when input value of EPS is negative.
230C EPS - specifies the criterion to be used in determining
231C the degree of fit to be computed.
232C (1) If EPS is input negative, POLFIT chooses the
233C degree based on a statistical F test of
234C significance. One of three possible
235C significance levels will be used: .01, .05 or
236C .10. If EPS=-1.0 , the routine will
237C automatically select one of these levels based
238C on the number of data points and the maximum
239C degree to be considered. If EPS is input as
240C -.01, -.05, or -.10, a significance level of
241C .01, .05, or .10, respectively, will be used.
242C (2) If EPS is set to 0., POLFIT computes the
243C polynomials of degrees 0 through MAXDEG .
244C (3) If EPS is input positive, EPS is the RMS
245C error tolerance which must be satisfied by the
246C fitted polynomial. POLFIT will increase the
247C degree of fit until this criterion is met or
248C until the maximum degree is reached.
249C
250C Output --
251C NDEG - degree of the highest degree fit computed.
252C EPS - RMS error of the polynomial of degree NDEG .
253C R - vector of dimension at least NDEG containing values
254C of the fit of degree NDEG at each of the X(I) .
255C Except when the statistical test is used, these
256C values are more accurate than results from subroutine
257C PVALUE normally are.
258C IERR - error flag with the following possible values.
259C 1 -- indicates normal execution, i.e., either
260C (1) the input value of EPS was negative, and the
261C computed polynomial fit of degree NDEG
262C satisfies the specified F test, or
263C (2) the input value of EPS was 0., and the fits of
264C all degrees up to MAXDEG are complete, or
265C (3) the input value of EPS was positive, and the
266C polynomial of degree NDEG satisfies the RMS
267C error requirement.
268C 2 -- invalid input parameter. At least one of the input
269C parameters has an illegal value and must be corrected
270C before POLFIT can proceed. Valid input results
271C when the following restrictions are observed
272C N .GE. 1
273C 0 .LE. MAXDEG .LE. N-1 for EPS .GE. 0.
274C 0 .LE. MAXDEG .LE. N-2 for EPS .LT. 0.
275C W(1)=-1.0 or W(I) .GT. 0., I=1,...,N .
276C 3 -- cannot satisfy the RMS error requirement with a
277C polynomial of degree no greater than MAXDEG . Best
278C fit found is of degree MAXDEG .
279C 4 -- cannot satisfy the test for significance using
280C current value of MAXDEG . Statistically, the
281C best fit found is of order NORD . (In this case,
282C NDEG will have one of the values: MAXDEG-2,
283C MAXDEG-1, or MAXDEG). Using a higher value of
284C MAXDEG may result in passing the test.
285C A - work and output array having at least 3N+3MAXDEG+3
286C locations
287C
288C Note - POLFIT calculates all fits of degrees up to and including
289C NDEG . Any or all of these fits can be evaluated or
290C expressed as powers of (X-C) using PVALUE and PCOEF
291C after just one call to POLFIT .
292C
293C***REFERENCES L. F. Shampine, S. M. Davenport and R. E. Huddleston,
294C Curve fitting by polynomials in one variable, Report
295C SLA-74-0270, Sandia Laboratories, June 1974.
296C***ROUTINES CALLED PVALUE, XERMSG
297C***REVISION HISTORY (YYMMDD)
298C 740601 DATE WRITTEN
299C 890531 Changed all specific intrinsics to generic. (WRB)
300C 890531 REVISION DATE from Version 3.2
301C 891214 Prologue converted to Version 4.0 format. (BAB)
302C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
303C 920501 Reformatted the REFERENCES section. (WRB)
304C 920527 Corrected erroneous statements in DESCRIPTION. (WRB)
305C*** END PROLOGUE POLFIT
306 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
307 DOUBLE PRECISION TEMD1,TEMD2
308 DIMENSION X(*), Y(*), W(*), R(*), A(*), YP(0)
309 DIMENSION CO(4,3)
310 SAVE CO
311 DATA CO(1,1), CO(2,1), CO(3,1), CO(4,1), CO(1,2), CO(2,2),
312 1 CO(3,2), CO(4,2), CO(1,3), CO(2,3), CO(3,3),
313 2 CO(4,3)/-13.086850,-2.4648165,-3.3846535,-1.2973162,
314 3 -3.3381146,-1.7812271,-3.2578406,-1.6589279,
315 4 -1.6282703,-1.3152745,-3.2640179,-1.9829776/
316C*** FIRST EXECUTABLE STATEMENT POLFIT
317 M = ABS(N)
318 IF (M .EQ. 0) GO TO 30
319 IF (MAXDEG .LT. 0) GO TO 30
320 A(1) = MAXDEG
321 MOP1 = MAXDEG + 1
322 IF (M .LT. MOP1) GO TO 30
323 IF (EPS .LT. 0.0 .AND. M .EQ. MOP1) GO TO 30
324 XM = M
325 ETST = EPS*EPS*XM
326 IF (W(1) .LT. 0.0) GO TO 2
327 DO I = 1,M
328 IF (W(I) .LE. 0.0) GO TO 30
329 enddo
330 GO TO 4
331 2 DO I = 1,M
332 W(I) = 1.0
333 enddo
334 4 IF (EPS .GE. 0.0) GO TO 8
335C
336C DETERMINE SIGNIFICANCE LEVEL INDEX TO BE USED IN STATISTICAL TEST FOR
337C CHOOSING DEGREE OF POLYNOMIAL FIT
338C
339 IF (EPS .GT. (-.55)) GO TO 5
340 IDEGF = M - MAXDEG - 1
341 KSIG = 1
342 IF (IDEGF .LT. 10) KSIG = 2
343 IF (IDEGF .LT. 5) KSIG = 3
344 GO TO 8
345 5 KSIG = 1
346 IF (EPS .LT. (-.03)) KSIG = 2
347 IF (EPS .LT. (-.07)) KSIG = 3
348C
349C INITIALIZE INDEXES AND COEFFICIENTS FOR FITTING
350C
351 8 K1 = MAXDEG + 1
352 K2 = K1 + MAXDEG
353 K3 = K2 + MAXDEG + 2
354 K4 = K3 + M
355 K5 = K4 + M
356 DO I = 2,K4
357 A(I) = 0.0
358 enddo
359 W11 = 0.0
360 IF (N .LT. 0) GO TO 11
361C
362C UNCONSTRAINED CASE
363C
364 DO I = 1,M
365 K4PI = K4 + I
366 A(K4PI) = 1.0
367 W11 = W11 + W(I)
368 enddo
369 GO TO 13
370C
371C CONSTRAINED CASE
372C
373 11 DO I = 1,M
374 K4PI = K4 + I
375 W11 = W11 + W(I)*A(K4PI)**2
376 enddo
377C
378C COMPUTE FIT OF DEGREE ZERO
379C
380 13 TEMD1 = 0.0D0
381 DO I = 1,M
382 K4PI = K4 + I
383 TEMD1 = TEMD1 + DBLE(W(I))*DBLE(Y(I))*DBLE(A(K4PI))
384 enddo
385 TEMD1 = TEMD1/DBLE(W11)
386 A(K2+1) = TEMD1
387 SIGJ = 0.0
388 DO I = 1,M
389 K4PI = K4 + I
390 K5PI = K5 + I
391 TEMD2 = TEMD1*DBLE(A(K4PI))
392 R(I) = TEMD2
393 A(K5PI) = TEMD2 - DBLE(R(I))
394 SIGJ = SIGJ + W(I)*((Y(I)-R(I)) - A(K5PI))**2
395 enddo
396 J = 0
397C
398C SEE IF POLYNOMIAL OF DEGREE 0 SATISFIES THE DEGREE SELECTION CRITERION
399C
400 if (eps.lt.0d0) then
401 goto 24
402 elseif (eps.eq.0d0) then
403 goto 26
404 else
405 goto 27
406 endif
407
408C
409C INCREMENT DEGREE
410C
411 16 J = J + 1
412 JP1 = J + 1
413 K1PJ = K1 + J
414 K2PJ = K2 + J
415 SIGJM1 = SIGJ
416C
417C COMPUTE NEW B COEFFICIENT EXCEPT WHEN J = 1
418C
419 IF (J .GT. 1) A(K1PJ) = W11/W1
420C
421C COMPUTE NEW A COEFFICIENT
422C
423 TEMD1 = 0.0D0
424 DO I = 1,M
425 K4PI = K4 + I
426 TEMD2 = A(K4PI)
427 TEMD1 = TEMD1 + DBLE(X(I))*DBLE(W(I))*TEMD2*TEMD2
428 enddo
429 A(JP1) = TEMD1/DBLE(W11)
430C
431C EVALUATE ORTHOGONAL POLYNOMIAL AT DATA POINTS
432C
433 W1 = W11
434 W11 = 0.0
435 DO I = 1,M
436 K3PI = K3 + I
437 K4PI = K4 + I
438 TEMP = A(K3PI)
439 A(K3PI) = A(K4PI)
440 A(K4PI) = (X(I)-A(JP1))*A(K3PI) - A(K1PJ)*TEMP
441 W11 = W11 + W(I)*A(K4PI)**2
442 enddo
443C
444C GET NEW ORTHOGONAL POLYNOMIAL COEFFICIENT USING PARTIAL DOUBLE
445C PRECISION
446C
447 TEMD1 = 0.0D0
448 DO I = 1,M
449 K4PI = K4 + I
450 K5PI = K5 + I
451 TEMD2 = DBLE(W(I))*DBLE((Y(I)-R(I))-A(K5PI))*DBLE(A(K4PI))
452 TEMD1 = TEMD1 + TEMD2
453 enddo
454 TEMD1 = TEMD1/DBLE(W11)
455 A(K2PJ+1) = TEMD1
456C
457C UPDATE POLYNOMIAL EVALUATIONS AT EACH OF THE DATA POINTS, AND
458C ACCUMULATE SUM OF SQUARES OF ERRORS. THE POLYNOMIAL EVALUATIONS ARE
459C COMPUTED AND STORED IN EXTENDED PRECISION. FOR THE I-TH DATA POINT,
460C THE MOST SIGNIFICANT BITS ARE STORED IN R(I) , AND THE LEAST
461C SIGNIFICANT BITS ARE IN A(K5PI) .
462C
463 SIGJ = 0.0
464 DO I = 1,M
465 K4PI = K4 + I
466 K5PI = K5 + I
467 TEMD2 = DBLE(R(I)) + DBLE(A(K5PI)) + TEMD1*DBLE(A(K4PI))
468 R(I) = TEMD2
469 A(K5PI) = TEMD2 - DBLE(R(I))
470 SIGJ = SIGJ + W(I)*((Y(I)-R(I)) - A(K5PI))**2
471 enddo
472C
473C SEE IF DEGREE SELECTION CRITERION HAS BEEN SATISFIED OR IF DEGREE
474C MAXDEG HAS BEEN REACHED
475C
476 if (eps.lt.0d0) then
477 goto 23
478 elseif (eps.eq.0d0) then
479 goto 26
480 else
481 goto 27
482 endif
483C
484C COMPUTE F STATISTICS (INPUT EPS .LT. 0.)
485C
486 23 IF (SIGJ .EQ. 0.0) GO TO 29
487 DEGF = M - J - 1
488 DEN = (CO(4,KSIG)*DEGF + 1.0)*DEGF
489 FCRIT = (((CO(3,KSIG)*DEGF) + CO(2,KSIG))*DEGF + CO(1,KSIG))/DEN
490 FCRIT = FCRIT*FCRIT
491 F = (SIGJM1 - SIGJ)*DEGF/SIGJ
492 IF (F .LT. FCRIT) GO TO 25
493C
494C POLYNOMIAL OF DEGREE J SATISFIES F TEST
495C
496 24 SIGPAS = SIGJ
497 JPAS = J
498 NFAIL = 0
499 IF (MAXDEG .EQ. J) GO TO 32
500 GO TO 16
501C
502C POLYNOMIAL OF DEGREE J FAILS F TEST. IF THERE HAVE BEEN THREE
503C SUCCESSIVE FAILURES, A STATISTICALLY BEST DEGREE HAS BEEN FOUND.
504C
505 25 NFAIL = NFAIL + 1
506 IF (NFAIL .GE. 3) GO TO 29
507 IF (MAXDEG .EQ. J) GO TO 32
508 GO TO 16
509C
510C RAISE THE DEGREE IF DEGREE MAXDEG HAS NOT YET BEEN REACHED (INPUT
511C EPS = 0.)
512C
513 26 IF (MAXDEG .EQ. J) GO TO 28
514 GO TO 16
515C
516C SEE IF RMS ERROR CRITERION IS SATISFIED (INPUT EPS .GT. 0.)
517C
518 27 IF (SIGJ .LE. ETST) GO TO 28
519 IF (MAXDEG .EQ. J) GO TO 31
520 GO TO 16
521C
522C RETURNS
523C
524 28 IERR = 1
525 NDEG = J
526 SIG = SIGJ
527 GO TO 33
528 29 IERR = 1
529 NDEG = JPAS
530 SIG = SIGPAS
531 GO TO 33
532 30 IERR = 2
533 write (*,*) 'SLATEC', 'POLFIT', 'INVALID INPUT PARAMETER.', 2,
534 + 1
535 stop 1
536 GO TO 37
537 31 IERR = 3
538 NDEG = MAXDEG
539 SIG = SIGJ
540 GO TO 33
541 32 IERR = 4
542 NDEG = JPAS
543 SIG = SIGPAS
544C
545 33 A(K3) = NDEG
546C
547C WHEN STATISTICAL TEST HAS BEEN USED, EVALUATE THE BEST POLYNOMIAL AT
548C ALL THE DATA POINTS IF R DOES NOT ALREADY CONTAIN THESE VALUES
549C
550 IF(EPS .GE. 0.0 .OR. NDEG .EQ. MAXDEG) GO TO 36
551 NDER = 0
552 DO I = 1,M
553 CALL PVALUE (NDEG,NDER,X(I),R(I),YP,A)
554 enddo
555 36 EPS = SQRT(SIG/XM)
556 37 RETURN
557 END
558
559
560*DECK PVALUE
561 SUBROUTINE PVALUE (L, NDER, X, YFIT, YP, A)
562c
563cRF: make double precision and replace DO-loops to comply with more
564c modern standards
565c
566C***BEGIN PROLOGUE PVALUE
567C***PURPOSE Use the coefficients generated by POLFIT to evaluate the
568C polynomial fit of degree L, along with the first NDER of
569C its derivatives, at a specified point.
570C***LIBRARY SLATEC
571C***CATEGORY K6
572C***TYPE SINGLE PRECISION (PVALUE-S, DP1VLU-D)
573C***KEYWORDS CURVE FITTING, LEAST SQUARES, POLYNOMIAL APPROXIMATION
574C***AUTHOR Shampine, L. F., (SNLA)
575C Davenport, S. M., (SNLA)
576C***DESCRIPTION
577C
578C Written by L. F. Shampine and S. M. Davenport.
579C
580C Abstract
581C
582C The subroutine PVALUE uses the coefficients generated by POLFIT
583C to evaluate the polynomial fit of degree L , along with the first
584C NDER of its derivatives, at a specified point. Computationally
585C stable recurrence relations are used to perform this task.
586C
587C The parameters for PVALUE are
588C
589C Input --
590C L - the degree of polynomial to be evaluated. L may be
591C any non-negative integer which is less than or equal
592C to NDEG , the highest degree polynomial provided
593C by POLFIT .
594C NDER - the number of derivatives to be evaluated. NDER
595C may be 0 or any positive value. If NDER is less
596C than 0, it will be treated as 0.
597C X - the argument at which the polynomial and its
598C derivatives are to be evaluated.
599C A - work and output array containing values from last
600C call to POLFIT .
601C
602C Output --
603C YFIT - value of the fitting polynomial of degree L at X
604C YP - array containing the first through NDER derivatives
605C of the polynomial of degree L . YP must be
606C dimensioned at least NDER in the calling program.
607C
608C***REFERENCES L. F. Shampine, S. M. Davenport and R. E. Huddleston,
609C Curve fitting by polynomials in one variable, Report
610C SLA-74-0270, Sandia Laboratories, June 1974.
611C***ROUTINES CALLED XERMSG
612C***REVISION HISTORY (YYMMDD)
613C 740601 DATE WRITTEN
614C 890531 Changed all specific intrinsics to generic. (WRB)
615C 890531 REVISION DATE from Version 3.2
616C 891214 Prologue converted to Version 4.0 format. (BAB)
617C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
618C 900510 Convert XERRWV calls to XERMSG calls. (RWC)
619C 920501 Reformatted the REFERENCES section. (WRB)
620C*** END PROLOGUE PVALUE
621 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
622 DIMENSION YP(*),A(*)
623 CHARACTER*8 XERN1, XERN2
624C***FIRST EXECUTABLE STATEMENT PVALUE
625 IF (L .LT. 0) GO TO 12
626 NDO = MAX(NDER,0)
627 NDO = MIN(NDO,L)
628 MAXORD = A(1) + 0.5
629 K1 = MAXORD + 1
630 K2 = K1 + MAXORD
631 K3 = K2 + MAXORD + 2
632 NORD = A(K3) + 0.5
633 IF (L .GT. NORD) GO TO 11
634 K4 = K3 + L + 1
635 IF (NDER .LT. 1) GO TO 2
636 DO I = 1,NDER
637 YP(I) = 0.0
638 enddo
639 2 IF (L .GE. 2) GO TO 4
640 IF (L .EQ. 1) GO TO 3
641C
642C L IS 0
643C
644 VAL = A(K2+1)
645 GO TO 10
646C
647C L IS 1
648C
649 3 CC = A(K2+2)
650 VAL = A(K2+1) + (X-A(2))*CC
651 IF (NDER .GE. 1) YP(1) = CC
652 GO TO 10
653C
654C L IS GREATER THAN 1
655C
656 4 NDP1 = NDO + 1
657 K3P1 = K3 + 1
658 K4P1 = K4 + 1
659 LP1 = L + 1
660 LM1 = L - 1
661 ILO = K3 + 3
662 IUP = K4 + NDP1
663 DO I = ILO,IUP
664 A(I) = 0.0
665 enddo
666 DIF = X - A(LP1)
667 KC = K2 + LP1
668 A(K4P1) = A(KC)
669 A(K3P1) = A(KC-1) + DIF*A(K4P1)
670 A(K3+2) = A(K4P1)
671C
672C EVALUATE RECURRENCE RELATIONS FOR FUNCTION VALUE AND DERIVATIVES
673C
674 DO I = 1,LM1
675 IN = L - I
676 INP1 = IN + 1
677 K1I = K1 + INP1
678 IC = K2 + IN
679 DIF = X - A(INP1)
680 VAL = A(IC) + DIF*A(K3P1) - A(K1I)*A(K4P1)
681 IF (NDO .LE. 0) GO TO 8
682 DO N = 1,NDO
683 K3PN = K3P1 + N
684 K4PN = K4P1 + N
685 YP(N) = DIF*A(K3PN) + N*A(K3PN-1) - A(K1I)*A(K4PN)
686 enddo
687C
688C SAVE VALUES NEEDED FOR NEXT EVALUATION OF RECURRENCE RELATIONS
689C
690 DO N = 1,NDO
691 K3PN = K3P1 + N
692 K4PN = K4P1 + N
693 A(K4PN) = A(K3PN)
694 A(K3PN) = YP(N)
695 enddo
696 8 A(K4P1) = A(K3P1)
697 A(K3P1) = VAL
698 enddo
699C
700C NORMAL RETURN OR ABORT DUE TO ERROR
701C
702 10 YFIT = VAL
703 RETURN
704C
705 11 WRITE (XERN1, '(I8)') L
706 WRITE (XERN2, '(I8)') NORD
707 write (*,*) 'SLATEC', 'PVALUE',
708 * 'THE ORDER OF POLYNOMIAL EVALUATION, L = ' // XERN1 //
709 * ' REQUESTED EXCEEDS THE HIGHEST ORDER FIT, NORD = ' // XERN2 //
710 * ', COMPUTED BY POLFIT -- EXECUTION TERMINATED.', 8, 2
711 stop 1
712 RETURN
713C
714 12 write (*,*) 'SLATEC', 'PVALUE',
715 + 'INVALID INPUT PARAMETER. ORDER OF POLYNOMIAL EVALUATION ' //
716 + 'REQUESTED IS NEGATIVE -- EXECUTION TERMINATED.', 2, 2
717 stop 1
718 RETURN
719 END
720
0721
=== modified file 'madgraph/interface/amcatnlo_run_interface.py'
--- madgraph/interface/amcatnlo_run_interface.py 2019-08-28 08:02:11 +0000
+++ madgraph/interface/amcatnlo_run_interface.py 2019-09-12 11:14:33 +0000
@@ -2376,9 +2376,12 @@
2376 # latter is only the only line that contains integers.2376 # latter is only the only line that contains integers.
2377 for j,fs in enumerate([files_mint_grids,files_MC_integer]):2377 for j,fs in enumerate([files_mint_grids,files_MC_integer]):
2378 linesoffiles=[]2378 linesoffiles=[]
2379 polyfit_data=[]
2379 for f in fs:2380 for f in fs:
2380 with open(f,'r+') as fi:2381 with open(f,'r+') as fi:
2381 linesoffiles.append(fi.readlines())2382 data=fi.readlines()
2383 linesoffiles.append([ dat for dat in data if 'POL' not in dat.split()[0] ])
2384 polyfit_data.append([ dat for dat in data if 'POL' in dat.split()[0] ])
2382 to_write=[]2385 to_write=[]
2383 for rowgrp in zip(*linesoffiles):2386 for rowgrp in zip(*linesoffiles):
2384 action=list(set([row.strip().split()[0] for row in rowgrp])) # list(set()) structure to remove duplicants2387 action=list(set([row.strip().split()[0] for row in rowgrp])) # list(set()) structure to remove duplicants
@@ -2414,8 +2417,30 @@
2414 write_string.append(int(sum(floatgrp)/len(floatgrp)))2417 write_string.append(int(sum(floatgrp)/len(floatgrp)))
2415 else:2418 else:
2416 raise aMCatNLOError('Unknown action for combining grids: %s' % action[0])2419 raise aMCatNLOError('Unknown action for combining grids: %s' % action[0])
2417
2418 to_write.append(action[0] + " " + (" ".join(str(ws) for ws in write_string)) + "\n")2420 to_write.append(action[0] + " " + (" ".join(str(ws) for ws in write_string)) + "\n")
2421
2422 if polyfit_data:
2423 # special for data regarding virtuals. Need to simply append
2424 # all the data, but skipping doubles.
2425 for i,onefile in enumerate(polyfit_data):
2426 # Get the number of channels, and the number of PS points per channel
2427 data_amount_in_file=[int(oneline.split()[1]) for oneline in onefile if len(oneline.split())==2]
2428 if i==0:
2429 filtered_list=[ [] for i in range(len(data_amount_in_file)) ]
2430 start=len(data_amount_in_file)
2431 for channel,channel_size in enumerate(data_amount_in_file):
2432 end=start+channel_size
2433 for data_channel in onefile[start:end]:
2434 if data_channel not in filtered_list[channel]:
2435 filtered_list[channel].append(data_channel)
2436 start=end
2437 # The amount of data in each file (per channel):
2438 for channel in filtered_list:
2439 to_write.append("POL " + str(len(channel)) + "\n")
2440 # All the data:
2441 for ch in filtered_list:
2442 for dat in ch:
2443 to_write.append(dat)
2419 # write the data over the master location2444 # write the data over the master location
2420 if j==0:2445 if j==0:
2421 with open(pjoin(location,'mint_grids'),'w') as f:2446 with open(pjoin(location,'mint_grids'),'w') as f:
24222447
=== modified file 'madgraph/iolibs/export_fks.py'
--- madgraph/iolibs/export_fks.py 2019-08-15 13:09:08 +0000
+++ madgraph/iolibs/export_fks.py 2019-09-12 11:14:33 +0000
@@ -624,8 +624,7 @@
624 'FKS_params.dat',624 'FKS_params.dat',
625 'initial_states_map.dat',625 'initial_states_map.dat',
626 'OLE_order.olc',626 'OLE_order.olc',
627 'FKSParams.inc',627 'FKSParams.f90',
628 'FKSParamReader.f',
629 'cuts.inc',628 'cuts.inc',
630 'unlops.inc',629 'unlops.inc',
631 'pythia_unlops.f',630 'pythia_unlops.f',
@@ -688,7 +687,8 @@
688 'randinit',687 'randinit',
689 'sudakov.inc',688 'sudakov.inc',
690 'maxconfigs.inc',689 'maxconfigs.inc',
691 'timing_variables.inc']690 'timing_variables.inc',
691 'polfit.f']
692692
693 for file in linkfiles:693 for file in linkfiles:
694 ln('../' + file , '.')694 ln('../' + file , '.')
@@ -1149,24 +1149,26 @@
11491149
1150 amp_split_size=len(amp_split_orders)1150 amp_split_size=len(amp_split_orders)
11511151
1152 text = 'C The orders to be integrated for the Born and at NLO\n'1152 text = '! The orders to be integrated for the Born and at NLO\n'
1153 text += 'integer nsplitorders\n'1153 text += 'integer nsplitorders\n'
1154 text += 'parameter (nsplitorders=%d)\n' % len(split_orders)1154 text += 'parameter (nsplitorders=%d)\n' % len(split_orders)
1155 text += 'character*3 ordernames(nsplitorders)\n'1155 text += 'character*3 ordernames(nsplitorders)\n'
1156 text += 'data ordernames / %s /\n' % ', '.join(['"%3s"' % o for o in split_orders])1156 text += 'data ordernames / %s /\n' % ', '.join(['"%3s"' % o for o in split_orders])
1157 text += 'integer born_orders(nsplitorders), nlo_orders(nsplitorders)\n'1157 text += 'integer born_orders(nsplitorders), nlo_orders(nsplitorders)\n'
1158 text += 'C the order of the coupling orders is %s\n' % ', '.join(split_orders)1158 text += '! the order of the coupling orders is %s\n' % ', '.join(split_orders)
1159 text += 'data born_orders / %s /\n' % ', '.join([str(max_born_orders[o]) for o in split_orders])1159 text += 'data born_orders / %s /\n' % ', '.join([str(max_born_orders[o]) for o in split_orders])
1160 text += 'data nlo_orders / %s /\n' % ', '.join([str(max_nlo_orders[o]) for o in split_orders])1160 text += 'data nlo_orders / %s /\n' % ', '.join([str(max_nlo_orders[o]) for o in split_orders])
1161 text += 'C The position of the QCD /QED orders in the array\n'1161 text += '! The position of the QCD /QED orders in the array\n'
1162 text += 'integer qcd_pos, qed_pos\n'1162 text += 'integer qcd_pos, qed_pos\n'
1163 text += 'C if = -1, then it is not in the split_orders\n'1163 text += '! if = -1, then it is not in the split_orders\n'
1164 text += 'parameter (qcd_pos = %d)\n' % qcd_pos1164 text += 'parameter (qcd_pos = %d)\n' % qcd_pos
1165 text += 'parameter (qed_pos = %d)\n' % qed_pos1165 text += 'parameter (qed_pos = %d)\n' % qed_pos
1166 text += 'C this is to keep track of the various coupling combinations entering each ME\n'1166 text += '! this is to keep track of the various \n'
1167 text += '! coupling combinations entering each ME\n'
1167 text += 'integer amp_split_size, amp_split_size_born\n'1168 text += 'integer amp_split_size, amp_split_size_born\n'
1168 text += 'parameter (amp_split_size = %d)\n' % amp_split_size1169 text += 'parameter (amp_split_size = %d)\n' % amp_split_size
1169 text += 'parameter (amp_split_size_born = %d) ! the first entries in amp_split are for the born\n' % amp_split_size_born1170 text += '! the first entries in the next line in amp_split are for the born \n'
1171 text += 'parameter (amp_split_size_born = %d)\n' % amp_split_size_born
1170 text += 'double precision amp_split(amp_split_size)\n'1172 text += 'double precision amp_split(amp_split_size)\n'
1171 text += 'double complex amp_split_cnt(amp_split_size,2,nsplitorders)\n'1173 text += 'double complex amp_split_cnt(amp_split_size,2,nsplitorders)\n'
1172 text += 'common /to_amp_split/amp_split, amp_split_cnt\n'1174 text += 'common /to_amp_split/amp_split, amp_split_cnt\n'

Subscribers

People subscribed via source and target branches

to all changes: