From 6bcce9e86b0b9a9c2774b7bbe3dbfca0e258f995 Mon Sep 17 00:00:00 2001
From: Hamed Abdolmaleki <h.abdolmalki@gmail.com>
Date: Wed, 15 Aug 2018 22:33:23 +0200
Subject: [PATCH 1/5] Fixed the QCDNUM error for external LHAPDF

---
 evolution.f | 581 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 581 insertions(+)
 create mode 100644 evolution.f

diff --git a/evolution.f b/evolution.f
new file mode 100644
index 000000000..fb79a541b
--- /dev/null
+++ b/evolution.f
@@ -0,0 +1,581 @@
+      subroutine Evolution
+
+*
+* DOALL = true : also evolves the Uplus and Dplus distribution.
+* This is not needed to calculate the DIS cross-sections,
+* but needed when one store all pdfs.
+*
+     
+c      implicit double precision (a-h,o-z)
+      implicit none
+#include "steering.inc"
+#include "pdfparam.inc"
+#include "thresholds.inc"
+#include "alphas.inc"
+#include "couplings.inc"
+#include "ntot.inc"
+#include "datasets.inc"
+c      common/thresholds/q0,qc,qb
+
+      double precision func0,func1,func24,func22
+
+      external func0            !input parton dists: iparam=0
+      external func1            !input parton dists: iparam=1
+      external func24           !input parton dists: iparam=24
+      external func22           !input parton dists: iparam=22
+      external func22text       ! text input
+      external func30
+
+      double precision def0, def1, def24, def22,pdfv,glu,glu1,x
+      double precision def30
+
+      dimension pdfv(-6:6)
+      dimension def22(-6:6,12)    !flavor composition
+      dimension def1(-6:6,12)    !flavor composition
+      dimension def0(-6:6,12)    !flavor composition
+      dimension def24(-6:6,12)    !flavor composition
+      dimension def30(-6:6,12)  !flavor composition
+
+      integer iq0, iqfrmq
+      double precision eps
+cjt test
+      integer nfin
+      double precision q2c,q2b
+
+      data nfin/0/
+      data q2c/3.D0/, q2b/25.D0/, q2b/200.D0/            !thresh and mu20
+
+*     ---------------------------------------------------------
+*     declaration related to alphas
+*     for RT code, transfer alpha S
+*     --------------------------------------------------------- 
+      double precision alphaszero
+
+*     ---------------------------------------------------------
+*     Subroutine of the external evolution codes
+*     --------------------------------------------------------- 
+      external LHAPDFsubr
+      external APFELsubr
+      external APFELsubrPhoton
+      external QEDEVOLsubr
+
+      double precision epsi
+      double precision hf_get_alphas,asRef
+
+*     ---------------------------------------------------------
+*     Save scale in a common to avoid APFEL to evolve if the
+*     scale does not change.
+*     --------------------------------------------------------- 
+      double precision q2p
+      common / PrevoiusQ / q2p
+
+      integer NextraSets
+
+cjt test 
+cv======
+cv Remark:
+cv need to make it working for h12k parametrisation 
+cv ----
+
+      data def0  /                                             ! just a copy of def22
+C--       tb  bb  cb  sb  ub  db   g   d   u   s   c   b   t
+C--       -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6  
+     +     0., 0., 0., 0., 0.,-1., 0., 1., 0., 0., 0., 0., 0., !dval
+     +     0., 0., 0., 0.,-1., 0., 0., 0., 1., 0., 0., 0., 0., !uval
+     +     0., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s+sbar
+     +     0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., !Ubar
+     +     0., 0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., ! Dbar
+     +     0., 0., 0., -1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s-sbar
+     +     78*0.    /
+
+
+
+
+      data def1  /
+C--     tb  bb  cb  sb  ub  db g   d   u   s   c   b   t
+C--     -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6  
+     +     0., 0., 0., 0., 0., 0., 0., 1., 0., 1., 0., 0., 0., !D
+     +     0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 1., 0., 0., !U
+     +     0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., !Ubar
+     +     0., 0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., !Dbar
+     +     0., 0., 0., -1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s-sbar
+     +     0., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s+sbar
+     +     78*0.    /
+
+
+      data def24  /
+cccvC--   tb  bb  cb  sb  ub  db   g   d   u   s   c   b   t
+cvC--     -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6  
+     +     0., 0., 0., 0., 0.,-1., 0., 1., 0., 0., 0., 0., 0., !dval
+     +     0., 0., 0., 0.,-1., 0., 0., 0., 1., 0., 0., 0., 0., !uval
+     +     0., 2., 2., 2., 2., 2., 0., 0., 0., 0., 0., 0., 0., !sea
+     +     0., 0., 0., 0., -1., 1., 0., 0., 0., 0., 0., 0., 0., !delta
+     +     0., 0., 0., -1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s-sbar
+     +     0., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s+sbar
+     +     78*0.    /
+
+      data def22  /
+C--       tb  bb  cb  sb  ub  db   g   d   u   s   c   b   t
+C--       -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6  
+     +     0., 0., 0., 0., 0.,-1., 0., 1., 0., 0., 0., 0., 0., !dval
+     +     0., 0., 0., 0.,-1., 0., 0., 0., 1., 0., 0., 0., 0., !uval
+     +     0., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s+sbar
+     +     0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., !Ubar
+     +     0., 0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., ! Dbar
+     +     0., 0., 0., -1., 0., 0., 0., 0., 0., 1., 0., 0., 0., !s-sbar
+     +     78*0.    /
+
+
+
+      data def30  /
+C--       tb  bb  cb   sb   ub   db   g   d   u   s   c   b   t
+C--       -6  -5  -4   -3   -2   -1   0   1   2   3   4   5   6  
+     +     0., 0., 0.,  0.,  0.,  1., 0., 1., 0., 0., 0., 0., 0., !d+
+     +     0., 0., 0.,  0.,  1.,  0., 0., 0., 1., 0., 0., 0., 0., !u+
+     +     0., 0., 0.,  1.,  0.,  0., 0., 0., 0., 1., 0., 0., 0., !s+
+     +     0., 0., 0.,  0.,  0., -1., 0., 1., 0., 0., 0., 0., 0., !d-
+     +     0., 0., 0.,  0., -1.,  0., 0., 0., 1., 0., 0., 0., 0., !u-
+     +     0., 0., 0., -1.,  0.,  0., 0., 0., 0., 1., 0., 0., 0., !s-
+     +     78*0.    /
+
+      integer i
+*
+*     Set parameters of the initial scale PDFs to be used by MELA
+*
+      if (mod(hfscheme,10).eq.6) then
+         call SetxFitterParametersMELA(parubar,pardbar,
+     1                                 paruval,pardval,
+     2                                 parglue,
+     3                                 fstrange,fcharm)
+      endif
+
+c      call grpars(nx,xmi,xma,nq,qmi,qma,nord)
+
+      q0=starting_scale
+
+c      iqc  = iqfrmq(qc)         !charm threshold
+c      iqb  = iqfrmq(qb)         !bottom threshold
+c      call setcbt(nfin,iqc,iqb,999) !thesholds in the vfns
+
+      iq0  = iqfrmq(q0)         !starting scale
+
+*
+*     Initialize alphas
+*
+      if (itheory.eq.0.or.itheory.eq.11) then
+         call setalf(dble(alphas),Mz*Mz)
+      else
+*     Make sure that alphas is correctly set at the Z mass
+         call SetMaxFlavourPDFs(5)
+         call SetMaxFlavourAlpha(5)
+         call SetAlphaQCDRef(dble(alphas),dble(Mz))
+         asref = HF_Get_alphas(dble(starting_scale))
+         call SetAlphaQCDRef(asref,dsqrt(dble(starting_scale)))
+      endif
+      alphaSzero = hf_get_alphas(1D0)
+      call RT_SetAlphaS(alphaSzero)
+
+      NextraSets = 0
+      if (ExtraPdfs) then
+         NextraSets = 1
+      endif
+
+C ---- LHAPDF ----
+      if(IPDFSET.eq.5) then
+         call EXTPDF(LHAPDFsubr,IPDFSET,NextraSets,dble(0.001),epsi)
+         return
+C ---- APFEL ----
+      elseif (IPDFSET.eq.7) then
+         if(itheory.eq.35)then
+            q2p = starting_scale
+            call SetPDFSet("external")
+            call EXTPDF(APFELsubrPhoton,IPDFSET,1,dble(0.001),epsi)
+         else
+*     6 flavours (default)
+            q2p = starting_scale
+            call SetPDFSet("external")
+            call SetMaxFlavourPDFs(6)
+            call SetMaxFlavourAlpha(6)
+            call EXTPDF(APFELsubr,IPDFSET,0,dble(0.001),epsi)
+C
+C     If the use of the H-VFNS is required, enable the evolutions
+C     with different values of NFmax
+C
+            if(UseHVFNS)then
+*     5 flavours
+               q2p = starting_scale
+               call SetPDFSet("external")
+               call SetMaxFlavourPDFs(5)
+               call SetMaxFlavourAlpha(5)
+               call EXTPDF(APFELsubr,IPDFSET+1,0,dble(0.001),epsi)
+*     4 flavours (redefine alphas)
+               q2p   = starting_scale
+               call SetPDFSet("external")
+               call SetMaxFlavourPDFs(4)
+               call SetMaxFlavourAlpha(4)
+               call EXTPDF(APFELsubr,IPDFSET+2,0,dble(0.001),epsi)
+*     3 flavours (redefine alphas)
+               q2p   = starting_scale
+               call SetPDFSet("external")
+               call SetMaxFlavourPDFs(3)
+               call SetMaxFlavourAlpha(3)
+               call EXTPDF(APFELsubr,IPDFSET+3,0,dble(0.001),epsi)
+            endif
+         endif
+         return
+C ---- QEDEVOL ----
+      elseif (IPDFSET.eq.8) then
+         call qedevol_main
+CC         call EXTPDF(QEDEVOLsubr,IPDFSET,1,dble(0.001),epsi)
+         return
+      endif
+
+cv ===
+      if (PDF_DECOMPOSITION.eq.'LHAPDF')  then
+         call evolfg(1,func0,def0,iq0,eps) !evolve all pdf's: LHAPDF
+
+      elseif (PDF_DECOMPOSITION.eq.'QCDNUM_GRID') then
+         call evolfg(1,func22text,def22,iq0,eps)
+
+      elseif (Index(PDF_DECOMPOSITION,'D_U_Dbar_Ubar').gt.0) then ! D,U,Dbar,Ubar 
+         call evolfg(1,func1,def1,iq0,eps) !evolve all pdf's: H1
+
+      elseif (Index(PDF_DECOMPOSITION,'Sea').gt.0) then
+         call evolfg(1,func24,def24,iq0,eps) !evolve all pdf's: ZEUS
+
+      elseif (PDF_DECOMPOSITION.eq.'Diffractive') then
+         call evolfg(1,func30,def30,iq0,eps) !evolve all pdf's: ZEUS diffractive (hard Pomeron)
+
+      elseif (Index(PDF_DECOMPOSITION,'Dbar_Ubar').gt.0) then
+         call evolfg(1,func22,def22,iq0,eps) ! uv, dv, Ubar, Dbar (and also strange)
+
+      else
+         print *,'Unknown PDF Decomposition: '//PDF_DECOMPOSITION
+         print *,'Stop in evolution'
+         call HF_Stop
+      endif
+
+      return
+      end
+
+*     ----------------------------------------------------
+      double precision function func0(id,x)
+*     ----------------------------------------------------
+      implicit double precision (a-h,o-z)
+#include "steering.inc"
+
+      double precision pdfval, q0
+      dimension pdfval(-6:6)
+
+      q0=sqrt(starting_scale)
+      
+      call evolvePDF(x, q0, pdfval)
+
+      if (id.eq.0) func0=pdfval(0)
+      if (id.eq.1) func0=pdfval(1)-pdfval(-1)
+      if (id.eq.2) func0=pdfval(2)-pdfval(-2)
+      if (id.eq.3) func0=pdfval(3)+pdfval(-3)
+      if (id.eq.4) func0=pdfval(-2)+pdfval(-4)
+      if (id.eq.5) func0=pdfval(-3)+pdfval(-1)
+      if (id.eq.6) func0=pdfval(3)-pdfval(-3)
+
+      return
+      end
+      
+
+*     ----------------------------------------------------
+      double precision function func1(id,x)
+*     ----------------------------------------------------
+      implicit double precision (a-h,o-z)
+#include "pdfparam.inc"
+
+      if (id.eq.0) func1=gluon(x)
+      if (id.eq.1) func1=H1D(x)
+      if (id.eq.2) func1=H1U(x)
+      if (id.eq.3) func1=Ubar(x)
+      if (id.eq.4) func1=Dbar(x)
+      if (id.eq.6) func1=2*qstrange(x)
+      if (id.eq.5) func1=0.d0
+
+      return
+      end
+      
+
+*     ----------------------------------------------------
+      double precision function func22(id,x)
+*     ----------------------------------------------------
+      implicit double precision (a-h,o-z)
+#include "pdfparam.inc"
+#include "steering.inc"
+
+      func22 = 0.D0
+      if (id.eq.0) func22=gluon(x)
+      if (id.eq.1) func22=dval(x)
+      if (id.eq.2) func22=uval(x)
+      if (id.eq.3) func22=2*qstrange(x)
+      if (id.eq.4) func22=ubar(x)
+      if (id.eq.5) func22=dbar(x)
+      if (id.eq.6) func22=0.d0
+
+      return
+      end
+
+
+*     ----------------------------------------------------
+      double precision function func22text(id,x)
+*     ----------------------------------------------------
+      implicit none
+      integer id
+      double precision x
+      double precision pdf_from_text
+C----------------------------
+      func22text = pdf_from_text(x,id)
+
+      return
+      end
+
+
+*     ----------------------------------------------------
+      double precision function func24(id,x)
+*     ----------------------------------------------------
+
+      implicit double precision (a-h,o-z)
+#include "pdfparam.inc"
+
+
+      if (id.eq.0) func24=gluon(x)
+      if (id.eq.1) func24=dval(x)
+      if (id.eq.2) func24=uval(x)
+      if (id.eq.3) func24=sea(x)
+      if (id.eq.4) func24=dbmub(x)
+      if (id.eq.5) func24=0.d0
+      if (id.eq.6) func24=0.d0
+
+      return
+      end
+
+
+
+*     ----------------------------------------------------
+      double precision function func30(id,x)
+*     ----------------------------------------------------
+
+      implicit double precision (a-h,o-z)
+#include "pdfparam.inc"
+      
+      PARAMETER(ParDumpFactor=1.d-3)
+      
+      dfac = dexp(-ParDumpFactor/(1.00001d0-x))
+      func30 = 0.D0
+      if (id.eq.0) then
+*ws: nchebglu in pdf_param.f must be 0
+*ws: initialized to 0 in read_steer.f
+         func30 = gluon(x)*dfac
+      elseif (id.eq.1.or.id.eq.2.or.id.eq.3) then
+*ws: NPOLYVAL in pdf_param.f must be 0
+*ws: initialized to 0 in read_steer.f
+         func30 = 2*Uval(x)*dfac
+      else
+      endif
+      return
+      end
+*
+************************************************************************
+*
+*     Subroutine that defines the PDFs to be evolved with APFEL.
+*     (predefined name)
+*
+************************************************************************
+      subroutine ExternalSetAPFEL(x,q0,xf)
+*
+      implicit none
+#include "steering.inc"
+**
+*     Input Variables
+*
+      double precision x
+      double precision q0
+**
+*     Internal Variables
+*
+      integer ipdf
+      double precision gluon
+      double precision pdf_from_text
+      double precision qstrange,Ubar,Dbar,H1U,H1D
+      double precision sea,dbmub,dval,uval
+      double precision photon
+      double precision dfac,ParDumpFactor
+      parameter(ParDumpFactor=1.d-3)
+**
+*     Output Variables
+*
+      double precision xf(-6:7)
+*
+*     Set PDFs to zero
+*
+      do ipdf=-6,7
+         xf(ipdf) = 0d0
+      enddo
+      if(x.gt.1d0) x = 1d0
+*
+*     Construct PDFs addording to the PDF decomposition
+*
+      if(PDF_DECOMPOSITION.eq.'LHAPDF')then
+c         q0 = sqrt(starting_scale)
+         call evolvePDF(x, q0, xf)
+
+      elseif(PDF_DECOMPOSITION.eq.'QCDNUM_GRID')then
+         xf(-3) = ( pdf_from_text(x,3) - pdf_from_text(x,6) ) / 2d0
+         xf(-2) = pdf_from_text(x,4)
+         xf(-1) = pdf_from_text(x,5)
+         xf(0)  = pdf_from_text(x,0)
+         xf(1)  = pdf_from_text(x,1) - pdf_from_text(x,5)
+         xf(2)  = pdf_from_text(x,2) - pdf_from_text(x,4)
+         xf(3)  = ( pdf_from_text(x,3) + pdf_from_text(x,6) ) / 2d0
+
+      elseif(Index(PDF_DECOMPOSITION,'D_U_Dbar_Ubar').gt.0)then ! D,U,Dbar,Ubar 
+         xf(-3) = qstrange(x)
+         xf(-2) = Ubar(x)
+         xf(-1) = Dbar(x)
+         xf(0)  = gluon(x)
+         xf(1)  = H1D(x) - xf(-3)
+         xf(2)  = H1U(x)
+         xf(3)  = xf(-3)
+
+      elseif(Index(PDF_DECOMPOSITION,'Sea').gt.0)then
+         xf(-2) = sea(x) / 4d0 - dbmub(x) / 2d0
+         xf(-1) = sea(x) / 4d0 + dbmub(x) / 2d0
+         xf(0)  = gluon(x)
+         xf(1)  = dval(x) + xf(-1)
+         xf(2)  = uval(x) + xf(-2)
+
+      elseif(PDF_DECOMPOSITION.eq.'Diffractive')then
+         dfac = dexp(-ParDumpFactor/(1.00001d0-x))
+*
+         xf(-3) = dfac * Uval(x)
+         xf(-2) = xf(-3)
+         xf(-1) = xf(-3)
+         xf(0)  = dfac * gluon(x)
+         xf(1)  = xf(-3)
+         xf(2)  = xf(-3)
+         xf(3)  = xf(-3)
+
+      elseif(Index(PDF_DECOMPOSITION,'Dbar_Ubar').gt.0)then
+         xf(-3) = qstrange(x)
+         xf(-2) = ubar(x)
+         xf(-1) = dbar(x) - xf(-3)
+         xf(0)  = gluon(x)
+         xf(1)  = dval(x) + xf(-1)
+         xf(2)  = uval(x) + xf(-2)
+         xf(3)  = xf(-3)
+
+      else
+         print *,'Unknown PDF Decomposition: '//PDF_DECOMPOSITION
+         print *,'Stop in evolution'
+         call HF_Stop
+      endif
+*
+*     Photon PDF
+*
+      if(itheory.eq.35) xf(7) = photon(x)
+*
+      return
+      end
+
+
+      double precision function LHAPDFsubr(ipdf,x, qmu2,first)
+C--------H-A-----------------------------------------------
+C
+C External PDF reading for QCDNUM
+C
+C--------------------------------------------------------
+
+      implicit double precision (a-h,o-z)
+      dimension xf(-6:7)
+#include "steering.inc"
+      logical first
+      if ( ExtraPdfs ) then
+         call evolvePDFphoton(x, sqrt(qmu2), xf, xf(7))
+      else
+         call evolvePDF(x, sqrt(qmu2), xf)
+
+      endif
+      if(first) func = 0.D0
+      if(ipdf.eq. 0) func = xf(0)
+      if(ipdf.eq. 1) func = xf(2)
+      if(ipdf.eq. 2) func = xf(1)
+      if(ipdf.eq. 3) func = xf(3)
+      if(ipdf.eq. 4) func = xf(-2)
+      if(ipdf.eq. 5) func = xf(-1)
+      if(ipdf.eq. 6) func = xf(-3)
+      if(ipdf.eq. 7) func = 0.D0
+      if(ipdf.eq. 8) func = 0.D0
+      if(ipdf.eq. 9) func = 0.D0
+      if(ipdf.eq.10) func = 0.D0
+      if(ipdf.eq.11) func = 0.D0
+      if(ipdf.eq.12) func = 0.D0
+      if(ipdf.eq.13) func = xf(7)
+
+      return
+      end
+
+c --------------------------
+      Subroutine APFELsubr(x, qmu2, xf)
+C-------------------------------------------------------
+C
+C External PDF reading for APFEL
+C
+C--------------------------------------------------------
+      implicit none
+*
+#include "steering.inc"
+*
+      integer i
+      double precision x,qmu2
+      double precision xf(-6:6)
+
+      double precision q2p
+      common / PrevoiusQ / q2p
+*
+*     Perform evolution with APFEL only if the final scale has changed
+*
+      if(qmu2.ne.q2p)then
+         call EvolveAPFEL(dsqrt(q2p),dsqrt(qmu2))
+         call SetPDFSet("apfel")
+      endif
+*
+      call xPDFall(x,xf)
+      q2p = qmu2
+*
+      return
+      end
+*
+      Subroutine APFELsubrPhoton(x, qmu2, xf)
+C-------------------------------------------------------
+C
+C External PDF reading for APFEL (including the photon)
+C
+C--------------------------------------------------------
+      implicit none
+*
+#include "steering.inc"
+*
+      double precision x,qmu2
+      double precision xf(-6:7)
+
+      double precision q2p
+      common / PrevoiusQ / q2p
+*
+*     Perform evolution with APFEL only if the final scale has changed
+*
+      if(qmu2.ne.q2p)then
+c         call EvolveAPFEL(dsqrt(q2p),dsqrt(qmu2))
+c         call SetPDFSet("apfel")
+         call EvolveAPFEL(dsqrt(dble(starting_scale)),dsqrt(qmu2))
+      endif
+*
+      call xPDFallPhoton(x,xf)
+      q2p = qmu2
+*
+      return
+      end
-- 
GitLab


From 4dcb7ce87ecc1b9dc2ae9707b3f38c07270ee180 Mon Sep 17 00:00:00 2001
From: Hamed Abdolmaleki <h.abdolmalki@gmail.com>
Date: Wed, 15 Aug 2018 23:24:40 +0200
Subject: [PATCH 2/5] Fixed the QCDNUM error for external LHAPDF

---
 src/evolution.f | 48 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 34 insertions(+), 14 deletions(-)

diff --git a/src/evolution.f b/src/evolution.f
index c62c940d6..fb79a541b 100644
--- a/src/evolution.f
+++ b/src/evolution.f
@@ -182,21 +182,21 @@ c      call setcbt(nfin,iqc,iqb,999) !thesholds in the vfns
 
 C ---- LHAPDF ----
       if(IPDFSET.eq.5) then
-         call PDFEXT(LHAPDFsubr,IPDFSET,NextraSets,dble(0.001),epsi)
+         call EXTPDF(LHAPDFsubr,IPDFSET,NextraSets,dble(0.001),epsi)
          return
 C ---- APFEL ----
       elseif (IPDFSET.eq.7) then
          if(itheory.eq.35)then
             q2p = starting_scale
             call SetPDFSet("external")
-            call PDFEXT(APFELsubrPhoton,IPDFSET,1,dble(0.001),epsi)
+            call EXTPDF(APFELsubrPhoton,IPDFSET,1,dble(0.001),epsi)
          else
 *     6 flavours (default)
             q2p = starting_scale
             call SetPDFSet("external")
             call SetMaxFlavourPDFs(6)
             call SetMaxFlavourAlpha(6)
-            call PDFEXT(APFELsubr,IPDFSET,0,dble(0.001),epsi)
+            call EXTPDF(APFELsubr,IPDFSET,0,dble(0.001),epsi)
 C
 C     If the use of the H-VFNS is required, enable the evolutions
 C     with different values of NFmax
@@ -207,26 +207,26 @@ C
                call SetPDFSet("external")
                call SetMaxFlavourPDFs(5)
                call SetMaxFlavourAlpha(5)
-               call PDFEXT(APFELsubr,IPDFSET+1,0,dble(0.001),epsi)
+               call EXTPDF(APFELsubr,IPDFSET+1,0,dble(0.001),epsi)
 *     4 flavours (redefine alphas)
                q2p   = starting_scale
                call SetPDFSet("external")
                call SetMaxFlavourPDFs(4)
                call SetMaxFlavourAlpha(4)
-               call PDFEXT(APFELsubr,IPDFSET+2,0,dble(0.001),epsi)
+               call EXTPDF(APFELsubr,IPDFSET+2,0,dble(0.001),epsi)
 *     3 flavours (redefine alphas)
                q2p   = starting_scale
                call SetPDFSet("external")
                call SetMaxFlavourPDFs(3)
                call SetMaxFlavourAlpha(3)
-               call PDFEXT(APFELsubr,IPDFSET+3,0,dble(0.001),epsi)
+               call EXTPDF(APFELsubr,IPDFSET+3,0,dble(0.001),epsi)
             endif
          endif
          return
 C ---- QEDEVOL ----
       elseif (IPDFSET.eq.8) then
          call qedevol_main
-CC         call PDFEXT(QEDEVOLsubr,IPDFSET,1,dble(0.001),epsi)
+CC         call EXTPDF(QEDEVOLsubr,IPDFSET,1,dble(0.001),epsi)
          return
       endif
 
@@ -482,24 +482,44 @@ c         q0 = sqrt(starting_scale)
       return
       end
 
-      Subroutine LHAPDFsubr(x, qmu2, xf)
-C-------------------------------------------------------
+
+      double precision function LHAPDFsubr(ipdf,x, qmu2,first)
+C--------H-A-----------------------------------------------
 C
 C External PDF reading for QCDNUM
 C
 C--------------------------------------------------------
-      implicit none
-#include "steering.inc"
 
-      double precision x,qmu2
-      double precision xf(-6:7)
+      implicit double precision (a-h,o-z)
+      dimension xf(-6:7)
+#include "steering.inc"
+      logical first
       if ( ExtraPdfs ) then
          call evolvePDFphoton(x, sqrt(qmu2), xf, xf(7))
       else
          call evolvePDF(x, sqrt(qmu2), xf)
-      endif      
+
+      endif
+      if(first) func = 0.D0
+      if(ipdf.eq. 0) func = xf(0)
+      if(ipdf.eq. 1) func = xf(2)
+      if(ipdf.eq. 2) func = xf(1)
+      if(ipdf.eq. 3) func = xf(3)
+      if(ipdf.eq. 4) func = xf(-2)
+      if(ipdf.eq. 5) func = xf(-1)
+      if(ipdf.eq. 6) func = xf(-3)
+      if(ipdf.eq. 7) func = 0.D0
+      if(ipdf.eq. 8) func = 0.D0
+      if(ipdf.eq. 9) func = 0.D0
+      if(ipdf.eq.10) func = 0.D0
+      if(ipdf.eq.11) func = 0.D0
+      if(ipdf.eq.12) func = 0.D0
+      if(ipdf.eq.13) func = xf(7)
+
+      return
       end
 
+c --------------------------
       Subroutine APFELsubr(x, qmu2, xf)
 C-------------------------------------------------------
 C
-- 
GitLab


From 7dd4af71ab237f8281d56c74852662b57e7a091b Mon Sep 17 00:00:00 2001
From: Hamed Abdolmaleki <h.abdolmalki@gmail.com>
Date: Mon, 20 Aug 2018 18:54:33 +0200
Subject: [PATCH 3/5] Fixed the QCDNUM error for external LHAPDF

---
 src/evolution.f | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/src/evolution.f b/src/evolution.f
index fb79a541b..3976d5b97 100644
--- a/src/evolution.f
+++ b/src/evolution.f
@@ -233,7 +233,6 @@ CC         call EXTPDF(QEDEVOLsubr,IPDFSET,1,dble(0.001),epsi)
 cv ===
       if (PDF_DECOMPOSITION.eq.'LHAPDF')  then
          call evolfg(1,func0,def0,iq0,eps) !evolve all pdf's: LHAPDF
-
       elseif (PDF_DECOMPOSITION.eq.'QCDNUM_GRID') then
          call evolfg(1,func22text,def22,iq0,eps)
 
@@ -498,24 +497,24 @@ C--------------------------------------------------------
          call evolvePDFphoton(x, sqrt(qmu2), xf, xf(7))
       else
          call evolvePDF(x, sqrt(qmu2), xf)
-
+!         print*,"test PDF",x, sqrt(qmu2), xf(0)
       endif
-      if(first) func = 0.D0
-      if(ipdf.eq. 0) func = xf(0)
-      if(ipdf.eq. 1) func = xf(2)
-      if(ipdf.eq. 2) func = xf(1)
-      if(ipdf.eq. 3) func = xf(3)
-      if(ipdf.eq. 4) func = xf(-2)
-      if(ipdf.eq. 5) func = xf(-1)
-      if(ipdf.eq. 6) func = xf(-3)
-      if(ipdf.eq. 7) func = 0.D0
-      if(ipdf.eq. 8) func = 0.D0
-      if(ipdf.eq. 9) func = 0.D0
-      if(ipdf.eq.10) func = 0.D0
-      if(ipdf.eq.11) func = 0.D0
-      if(ipdf.eq.12) func = 0.D0
-      if(ipdf.eq.13) func = xf(7)
-
+      if(first) LHAPDFsubr = 0.D0
+      if(ipdf.eq. 0) LHAPDFsubr = xf(0)
+      if(ipdf.eq. 1) LHAPDFsubr = xf(1)
+      if(ipdf.eq. 2) LHAPDFsubr = xf(2)
+      if(ipdf.eq. 3) LHAPDFsubr = xf(3)
+      if(ipdf.eq. 4) LHAPDFsubr = xf(4)
+      if(ipdf.eq. 5) LHAPDFsubr = xf(5)
+      if(ipdf.eq. 6) LHAPDFsubr = xf(6)
+      if(ipdf.eq. -1) LHAPDFsubr = xf(-1)
+      if(ipdf.eq. -2) LHAPDFsubr = xf(-2)
+      if(ipdf.eq. -3) LHAPDFsubr = xf(-3)    
+      if(ipdf.eq. -4) LHAPDFsubr = xf(-4)
+      if(ipdf.eq. -5) LHAPDFsubr = xf(-5)
+      if(ipdf.eq. -6) LHAPDFsubr = xf(-6)
+
+!      end if
       return
       end
 
-- 
GitLab


From 446bc0e327e3b6013192e9560a811ec25af6493a Mon Sep 17 00:00:00 2001
From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch>
Date: Mon, 20 Aug 2018 21:12:34 +0200
Subject: [PATCH 4/5] qcdnum-17-01-14 in install script

---
 tools/install-xfitter | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/install-xfitter b/tools/install-xfitter
index b478bffd3..6fafb4385 100755
--- a/tools/install-xfitter
+++ b/tools/install-xfitter
@@ -6,8 +6,7 @@
 lhapdfver=6.2.1
 hoppetver=1.2.0
 applgridver=1.4.70
-# move to 17-01-14 ?
-qcdnumver=17-01-13
+qcdnumver=17-01-14
 apfelver=3.0.0
 melaver=2.0.1
 apfelgridver=1.0.1
-- 
GitLab


From 49f287156ea9aea97e201a0a177a5b5c8f7c8cd3 Mon Sep 17 00:00:00 2001
From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch>
Date: Mon, 20 Aug 2018 21:15:29 +0200
Subject: [PATCH 5/5] qcdnum-17-01-14 in configure

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 869c03662..400f9b63e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,7 +210,7 @@ else
   QCDNUMLIBS=`qcdnum-config --ldflags`
   AC_MSG_RESULT([Using $qcdnum_config version $QCDNUMVERS])
   AC_SUBST(QCDNUMLIBS)
-  AX_COMPARE_VERSION([17-01-13],[gt],[$QCDNUMVERS],[AC_MSG_ERROR([QCDNUM version outdated (17-01-13 or later needed).])],[])
+  AX_COMPARE_VERSION([17-01-14],[gt],[$QCDNUMVERS],[AC_MSG_ERROR([QCDNUM version outdated (17-01-14 or later needed).])],[])
 fi
 
 # check for lhapdf installation
-- 
GitLab