roll back of previous commit
authormorsch <andreas.morsch@cern.ch>
Mon, 13 Oct 2014 11:22:16 +0000 (13:22 +0200)
committermorsch <andreas.morsch@cern.ch>
Mon, 13 Oct 2014 11:22:16 +0000 (13:22 +0200)
LHAPDF/lhapdf-5.9.1/src/QCDNUM.F [new file with mode: 0644]
LHAPDF/lhapdf-5.9.1/src/wrapQCDNUM.F [new file with mode: 0644]
LHAPDF/lhapdf-5.9.1/src/wrapevolve.F [new file with mode: 0644]

diff --git a/LHAPDF/lhapdf-5.9.1/src/QCDNUM.F b/LHAPDF/lhapdf-5.9.1/src/QCDNUM.F
new file mode 100644 (file)
index 0000000..34de8fc
--- /dev/null
@@ -0,0 +1,27359 @@
+! -*- F90 -*-
+
+
+!DECK  ID>, QCDCOM.                                                     
+                                                                        
+!DECK  ID>, QCDCOM.                                                     
+                                                                        
+!------------------------QCDNUM COMMON BLOCKS---------------------      
+                                                                        
+!DECK  ID>, QCDNUM.                                                     
+                                                                        
+!DECK  ID>, QNINIT.                                                     
+                                                                        
+!     =================                                                 
+      SUBROUTINE QNINIT 
+!     =================                                                 
+                                                                        
+!---  QNINIT: initialisation.                                           
+!---  Called by user.                                                   
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*8 CHVERS,CHDATE 
+      COMMON/QCVERS/ CHVERS,CHDATE 
+                                                                        
+                                                                        
+      COMMON/QCCONS/                                                    &
+     &PI,PROTON,EUTRON,UCLEON,UDSCBT(6),AAM2H,BBM2H,AAM2L,BBM2L,        &
+     &AAAR2,BBBR2,FL_FAC,CBMSTF(4:7),CHARGE(4:7),                       &
+     &C1S3,C2S3,C4S3,C5S3,C8S3,C11S3,C14S3,C16S3,C20S3,C22S3,C28S3,     &
+     &C38S3,C40S3,C44S3,C52S3,C136S3,C11S6,C2S9,C4S9,C10S9,C14S9,C16S9, &
+     &C40S9,C44S9,C62S9,C112S9,C182S9,C11S12,C35S18,C61S12,C215S1,      &
+     &C29S12,CPI2S3,CPIA,CPIB,CPIC,CPID,CPIE,CPIF,CCA,CCF,CTF,CATF,CFTF 
+                                                                        
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      REAL                                                              &
+     &WGTFF1,WGTFG1,                                                    &
+     &WGTGF1,WGTGG1,                                                    &
+     &WGTPP2,WGTPM2,WGTNS2,                                             &
+     &WGTFF2,WGTFG2,                                                    &
+     &WGTGF2,WGTGG2,                                                    &
+     &WGTC2Q,WGTC2G,YNTC2Q,                                             &
+     &WGTCLQ,WGTCLG,WGTC3Q                                              
+                                                                        
+      COMMON/QCWEIT/                                                    &
+     &WGTFF1(MXX*(MXX+1)/2)    ,WGTFG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF1(MXX*(MXX+1)/2)    ,WGTGG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTPP2(MXX*(MXX+1)/2,3:5),WGTPM2(MXX*(MXX+1)/2,3:5),              &
+     &WGTNS2(MXX*(MXX+1)/2,3:5),                                        &
+     &WGTFF2(MXX*(MXX+1)/2,3:5),WGTFG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF2(MXX*(MXX+1)/2,3:5),WGTGG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTC2Q(MXX*(MXX+1)/2)    ,WGTC2G(MXX*(MXX+1)/2,3:5),              &
+     &WGTCLQ(MXX*(MXX+1)/2)    ,WGTCLG(MXX*(MXX+1)/2,3:5),              &
+     &WGTC3Q(MXX*(MXX+1)/2)    ,YNTC2Q(MXX)                             
+                                                                        
+      COMMON/QCWADR/ IWADR(MXX,MXX) 
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      CHARACTER*5 PNAM,STFNAM 
+      LOGICAL     LNFP 
+      COMMON /QCLNFP/ LNFP(0:30,3:5) 
+      COMMON /QCPNAM/ PNAM(0:30) 
+      COMMON /QCPWGT/ PWGT(0:10,0:30,3:5) 
+      COMMON /QCFNAM/ STFNAM(7) 
+                                                                        
+                                                                        
+      LOGICAL LTIME 
+      REAL T_START,T_END,T_SPENT 
+      COMMON/QCTIME/T_START(10),T_END(10),T_SPENT(10),N_CALLS(10),      &
+     &E_CALLS(10),LTIME                                                 
+      COMMON/QCFCNT/IFCNT(-1:1,5) 
+                                                                        
+      CHARACTER*7 TSNAM 
+      COMMON/QCTRCE/ TSNAM(0:19) 
+      COMMON/QCTRCI/ NTCAL(0:19),ITADR 
+!                                                                       
+! common added by MRW 18/3/05 to make silent mode for LHAPDF            
+!                                                                       
+      common/lhasilent/lhasilent 
+!                                                                       
+                                                                        
+      CHVERS = '16.12   ' 
+      CHDATE = '12-08-98' 
+                                                                        
+      LDOUBL = .TRUE. 
+      if(lhasilent.eq.0) then 
+      WRITE(6,'(/////)') 
+      WRITE(6,                                                          &
+     &'(8X,''+-----------------------------------------------+'')')     
+      WRITE(6,                                                          &
+     &'(8X,''|                                               |'')')     
+!      LDOUBL = .TRUE.                                                  
+      WRITE(6,                                                          &
+     &'(8X,''| You are using the double precision version of |'')')     
+      WRITE(6,                                                          &
+     &'(8X,''|                                               |'')')     
+      WRITE(6,                                                          &
+     &'(8X,''|              Q C D N U M '',A8,                          &
+     &     ''             |'')') CHVERS                                 
+      WRITE(6,                                                          &
+     &'(8X,''|                                               |'')')     
+      WRITE(6,                                                          &
+     &'(8X,''|         Author  : Michiel Botje               |'')')     
+      WRITE(6,                                                          &
+     &'(8X,''|         Email   : h24@nikhef.nl               |'')')     
+      WRITE(6,                                                          &
+     &'(8X,''|                                               |'')')     
+      WRITE(6,                                                          &
+     &'(8X,''|         Date    : '',A8,                                 &
+     &     ''                    |'')') CHDATE                          
+      WRITE(6,                                                          &
+     &'(8X,''|         Max NX  : '',I3,                                 &
+     &     ''                         |'')') MXX-1                      
+      WRITE(6,                                                          &
+     &'(8X,''|         Max NQ2 : '',I3,                                 &
+     &     ''                         |'')') MQ2-1                      
+      WRITE(6,                                                          &
+     &'(8X,''|                                               |'')')     
+      WRITE(6,                                                          &
+     &'(8X,''+-----------------------------------------------+'')')     
+      WRITE(6,'(/////)') 
+      endif 
+                                                                        
+      IORD   = 2 
+      IOLAST = -999 
+      Q0ALFA = 50. 
+      ALPHA0 = 0.180 
+      QALAST = -999. 
+      ASLAST = -999. 
+      SCAX0  = 0.20 
+      SCAQ0  = 1.D10 
+                                                                        
+      PI     = 3.14159265359 
+      PROTON = 0.9382796 
+      EUTRON = 0.9395731 
+      UCLEON = (PROTON + EUTRON) / 2. 
+      UDSCBT(1) = 0.005 
+      UDSCBT(2) = 0.01 
+      UDSCBT(3) = 0.3 
+      UDSCBT(4) = 1.5 
+      UDSCBT(5) = 5.0 
+      UDSCBT(6) = 188. 
+      CBMSTF(4) = UDSCBT(4) 
+      CBMSTF(5) = UDSCBT(4) 
+      CBMSTF(6) = UDSCBT(5) 
+      CBMSTF(7) = UDSCBT(5) 
+      CHARGE(4) = 4./9. 
+      CHARGE(5) = 4./9. 
+      CHARGE(6) = 1./9. 
+      CHARGE(7) = 1./9. 
+      AAM2H     = 1. 
+      BBM2H     = 0. 
+      AAM2L     = 1. 
+      BBM2L     = 0. 
+      AAAR2     = 1. 
+      BBBR2     = 0. 
+      FL_FAC    = 0. 
+      C1S3   = 1./3. 
+      C2S3   = 2./3. 
+      C4S3   = 4./3. 
+      C5S3   = 5./3. 
+      C8S3   = 8./3. 
+      C14S3  = 14./3. 
+      C16S3  = 16./3. 
+      C20S3  = 20./3. 
+      C28S3  = 28./3. 
+      C38S3  = 38./3. 
+      C40S3  = 40./3. 
+      C44S3  = 44./3. 
+      C52S3  = 52./3. 
+      C136S3 = 136./3. 
+      C11S6  = 11./6. 
+      C2S9   = 2./9. 
+      C4S9   = 4./9. 
+      C10S9  = 10./9. 
+      C14S9  = 14./9. 
+      C16S9  = 16./9. 
+      C40S9  = 40./9. 
+      C44S9  = 44./9. 
+      C62S9  = 62./9. 
+      C112S9 = 112./9. 
+      C182S9 = 182./9. 
+      C11S12 = 11./12. 
+      C35S18 = 35./18. 
+      C11S3  = 11./3. 
+      C22S3  = 22./3. 
+      C61S12 = 61./12. 
+      C215S1 = 215./12. 
+      C29S12 = 29./12. 
+      CPI2S3 = PI**2/3. 
+      CPIA   = 67./18. - CPI2S3/2. 
+      CPIB   = 4.*CPI2S3 
+      CPIC   = 17./18. + 3.5*CPI2S3 
+      CPID   = 367./36. - CPI2S3 
+      CPIE   = 5. - CPI2S3 
+      CPIF   = CPI2S3 - 218./9. 
+                                                                        
+      CCA    = 3. 
+      CCF    = (CCA*CCA-1.)/(2.*CCA) 
+      CTF    = 0.5 
+      CATF   = CCA*CTF 
+      CFTF   = CCF*CTF 
+                                                                        
+      DO I = 1,10 
+        T_SPENT(I) = 0. 
+        E_CALLS(I) = 0. 
+        N_CALLS(I) = 0 
+      ENDDO 
+      LTIME  = .FALSE. 
+                                                                        
+      LBMARK = .FALSE. 
+      LW1ANA = .TRUE. 
+      LW1NUM = .FALSE. 
+      LW2NUM = .TRUE. 
+      LW2STF = .TRUE. 
+      LWF2C  = .FALSE. 
+      LWF2B  = .FALSE. 
+      LWFLC  = .FALSE. 
+      LWFLB  = .FALSE. 
+      LIMCK  = .TRUE. 
+      LPLUS  = .TRUE. 
+      LALFOK = .FALSE. 
+      LDQ2OK = .FALSE. 
+      LWT1OK = .FALSE. 
+      LWT2OK = .FALSE. 
+      LWTFOK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+      LCLOWQ = .TRUE. 
+      LASOLD = .FALSE. 
+      DO I = 1,30 
+        DO J = 1,7 
+          LFFCAL(J,I)  = .FALSE. 
+        ENDDO 
+      ENDDO 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+      CALL QNFALS(LE_DONE,MXX) 
+      CALL QNINUL(IQL_LAST,10) 
+      CALL QNINUL(IQ0_LAST,10) 
+      CALL QNINUL(IQH_LAST,10) 
+                                                                        
+      ITADR = 0 
+      DO I = 0,19 
+        TSNAM(I) = '       ' 
+        NTCAL(I) = 0 
+      ENDDO 
+                                                                        
+      NXX    = 0 
+      NQ2    = 0 
+      NGRVER = 0 
+      NDFAST = 30 
+      XMICUT = -1. 
+      QMICUT = -1. 
+      QMACUT = -1. 
+      RS2CUT = -1. 
+      QMINAS = 0. 
+      THRS34 = -1.D10 
+      THRS45 =  1.D10 
+                                                                        
+      CALL VZERO_LHA (WGTFF1,MXX*(MXX+1)/2) 
+      CALL VZERO_LHA (WGTFG1,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTGF1,MXX*(MXX+1)/2) 
+      CALL VZERO_LHA (WGTGG1,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTPP2,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTPM2,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTNS2,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTFF2,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTFG2,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTGF2,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTGG2,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTC2Q,MXX*(MXX+1)/2) 
+      CALL VZERO_LHA (WGTC2G,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (YNTC2Q,MXX) 
+      CALL VZERO_LHA (WGTCLQ,MXX*(MXX+1)/2) 
+      CALL VZERO_LHA (WGTCLG,MXX*(MXX+1)*3/2) 
+      CALL VZERO_LHA (WGTC3Q,MXX*(MXX+1)/2) 
+                                                                        
+      CALL QNVNUL(PWGT,11*31*3) 
+      CALL QNINUL(NFMAP,MQ2) 
+      CALL QNINUL(MARKFF,MXX*MQ2) 
+      CALL QNINUL(MARKFH,MXX*MQ2) 
+      CALL QNINUL(MARKQQ,MQ2) 
+      CALL QNINUL(IDFAST,7*30) 
+      CALL QNINUL(IFCNT,3*5) 
+                                                                        
+      CALL QNVNUL(PDFQCD,MXX*MQ2*11) 
+      DO ID = 1,NDFMAX 
+        DO IX = 1,MXX 
+          DO IQ = 1,MQ2 
+            FSTORE(IX,IQ,30+ID) = -501. 
+          ENDDO 
+        ENDDO 
+      ENDDO 
+                                                                        
+      PNAM(0)   = 'GLUON' 
+      PNAM(1)   = 'SINGL' 
+      LNFP(0,3) = .TRUE. 
+      LNFP(0,4) = .TRUE. 
+      LNFP(0,5) = .TRUE. 
+      LNFP(1,3) = .TRUE. 
+      LNFP(1,4) = .TRUE. 
+      LNFP(1,5) = .TRUE. 
+      DO 10 I = 2,30 
+        PNAM(I)   = 'FREE ' 
+        LNFP(I,3) = .FALSE. 
+        LNFP(I,4) = .FALSE. 
+        LNFP(I,5) = .FALSE. 
+   10 END DO 
+      PWGT(0,0,3) = 1. 
+      PWGT(0,0,4) = 1. 
+      PWGT(0,0,5) = 1. 
+      PWGT(1,1,3) = 1. 
+      PWGT(1,1,4) = 1. 
+      PWGT(1,1,5) = 1. 
+      STFNAM(1)   = 'F2   ' 
+      STFNAM(2)   = 'FL   ' 
+      STFNAM(3)   = 'XF3  ' 
+      STFNAM(4)   = 'F2C  ' 
+      STFNAM(5)   = 'FLC  ' 
+      STFNAM(6)   = 'F2B  ' 
+      STFNAM(7)   = 'FLB  ' 
+                                                                        
+      CALL QTRACE('QNINIT ',0) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QTRACE.                                                     
+                                                                        
+!     ===============================                                   
+      SUBROUTINE QTRACE(SRNAM,IPRINT) 
+!     ===============================                                   
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*7 SRNAM 
+                                                                        
+      CHARACTER*7 TSNAM 
+      COMMON/QCTRCE/ TSNAM(0:19) 
+      COMMON/QCTRCI/ NTCAL(0:19),ITADR 
+                                                                        
+                                                                        
+      IF(IPRINT.EQ.0) THEN 
+                                                                        
+        IF(SRNAM.EQ.TSNAM(ITADR)) THEN 
+          NTCAL(ITADR) = NTCAL(ITADR) + 1 
+        ELSE 
+          ITADR = MOD(ITADR+1,20) 
+          TSNAM(ITADR) = SRNAM 
+          NTCAL(ITADR) = 1 
+        ENDIF 
+                                                                        
+      ELSE 
+                                                                        
+        WRITE(6,'(/'' ----------------------------'')') 
+                                                                        
+        K = -20 
+        DO I = ITADR+1,ITADR+19 
+          J = MOD(I,20) 
+          K = K+1 
+          WRITE(6,'(I4,2X,A7,''  #calls = '',I5)')                      &
+     &    K,TSNAM(J),NTCAL(J)                                           
+        ENDDO 
+        K = 0 
+        WRITE(6,'(I4,2X,A7,''  #calls = '',I5,''  <--- error'')')       &
+     &  K,TSNAM(ITADR),NTCAL(ITADR)                                     
+                                                                        
+        WRITE(6,'( '' ----------------------------'')') 
+                                                                        
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNDUMP.                                                     
+                                                                        
+!     ======================                                            
+      SUBROUTINE QNDUMP(LUN) 
+!     ======================                                            
+                                                                        
+!---  QNDUMP: write weight tables to LUN.                               
+!---  Called by user.                                                   
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+      CHARACTER*8 CHVERS,CHDATE 
+      COMMON/QCVERS/ CHVERS,CHDATE 
+                                                                        
+                                                                        
+      COMMON/QCCONS/                                                    &
+     &PI,PROTON,EUTRON,UCLEON,UDSCBT(6),AAM2H,BBM2H,AAM2L,BBM2L,        &
+     &AAAR2,BBBR2,FL_FAC,CBMSTF(4:7),CHARGE(4:7),                       &
+     &C1S3,C2S3,C4S3,C5S3,C8S3,C11S3,C14S3,C16S3,C20S3,C22S3,C28S3,     &
+     &C38S3,C40S3,C44S3,C52S3,C136S3,C11S6,C2S9,C4S9,C10S9,C14S9,C16S9, &
+     &C40S9,C44S9,C62S9,C112S9,C182S9,C11S12,C35S18,C61S12,C215S1,      &
+     &C29S12,CPI2S3,CPIA,CPIB,CPIC,CPID,CPIE,CPIF,CCA,CCF,CTF,CATF,CFTF 
+                                                                        
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      REAL                                                              &
+     &WGTFF1,WGTFG1,                                                    &
+     &WGTGF1,WGTGG1,                                                    &
+     &WGTPP2,WGTPM2,WGTNS2,                                             &
+     &WGTFF2,WGTFG2,                                                    &
+     &WGTGF2,WGTGG2,                                                    &
+     &WGTC2Q,WGTC2G,YNTC2Q,                                             &
+     &WGTCLQ,WGTCLG,WGTC3Q                                              
+                                                                        
+      COMMON/QCWEIT/                                                    &
+     &WGTFF1(MXX*(MXX+1)/2)    ,WGTFG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF1(MXX*(MXX+1)/2)    ,WGTGG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTPP2(MXX*(MXX+1)/2,3:5),WGTPM2(MXX*(MXX+1)/2,3:5),              &
+     &WGTNS2(MXX*(MXX+1)/2,3:5),                                        &
+     &WGTFF2(MXX*(MXX+1)/2,3:5),WGTFG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF2(MXX*(MXX+1)/2,3:5),WGTGG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTC2Q(MXX*(MXX+1)/2)    ,WGTC2G(MXX*(MXX+1)/2,3:5),              &
+     &WGTCLQ(MXX*(MXX+1)/2)    ,WGTCLG(MXX*(MXX+1)/2,3:5),              &
+     &WGTC3Q(MXX*(MXX+1)/2)    ,YNTC2Q(MXX)                             
+                                                                        
+      COMMON/QCWADR/ IWADR(MXX,MXX) 
+                                                                        
+                                                                        
+      REAL                                                              &
+     &WH_C0KG,WH_C1KG,WH_C1BKG,                                         &
+     &WH_C1KQ,WH_C1BKQ,WH_D1KQ,WH_D1BKQ                                 
+                                                                        
+      COMMON/QCHWGT/                                                    &
+     &WH_C0KG(0:MXX,MQ2,4:7),                                           &
+     &WH_C1KG(0:MXX,MQ2,4:7),WH_C1BKG(0:MXX,MQ2,4:7),                   &
+     &WH_C1KQ(0:MXX,MQ2,4:7),WH_C1BKQ(0:MXX,MQ2,4:7),                   &
+     &WH_D1KQ(0:MXX,MQ2,4:7),WH_D1BKQ(0:MXX,MQ2,4:7)                    
+                                                                        
+                                                                        
+      DIMENSION STOREM(6) 
+                                                                        
+      CALL QTRACE('QNDUMP ',0) 
+                                                                        
+      STOREM(1) = CBMSTF(4) 
+      STOREM(2) = CBMSTF(6) 
+      STOREM(3) = 0. 
+      STOREM(4) = 0. 
+      STOREM(5) = 0. 
+      STOREM(6) = 0. 
+                                                                        
+      WRITE(LUN) MXX,MQ2 
+      WRITE(LUN) CHVERS,CHDATE 
+      WRITE(LUN) STOREM 
+      WRITE(LUN) LWT1OK,LWT2OK,LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,      &
+     &           LPLUS                                                  
+      WRITE(LUN) XXTAB,Q2TAB,                                           &
+     &           NXX,NQ2,IQF2C,IQF2B,IQFLC,IQFLB                        
+      IF(LWT1OK) THEN 
+      WRITE(LUN) WGTFF1,WGTFG1,WGTGF1,WGTGG1 
+      ENDIF 
+      IF(LWT2OK) THEN 
+      WRITE(LUN) WGTPP2,WGTPM2,WGTNS2,WGTFF2,WGTFG2,WGTGF2,WGTGG2 
+      ENDIF 
+      IF(LWTFOK) THEN 
+      WRITE(LUN) WGTC2Q,WGTC2G,YNTC2Q,WGTCLQ,WGTCLG,WGTC3Q 
+      ENDIF 
+      IF(LWFCOK.OR.LWLCOK.OR.LWFBOK.OR.LWLBOK) THEN 
+      WRITE(LUN) WH_C0KG,WH_C1KG,WH_C1BKG,                              &
+     &           WH_C1KQ,WH_C1BKQ,WH_D1KQ,WH_D1BKQ                      
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNREAD.                                                     
+                                                                        
+!     =================================                                 
+      SUBROUTINE QNREAD(LUN,ISTOP,IERR) 
+!     =================================                                 
+                                                                        
+!---  QNDUMP: read weight tables from LUN.                              
+!---  Called by user.                                                   
+!---  Input  integer LUN                                                
+!---         integer ISTOP = 0 read the file                            
+!---                 ISTOP = 1 read only when ierr = 0                  
+!---                 ISTOP = 2 stop the program when ierr .ne. 0        
+!---  Output integer IERR  = 0 all ok                                   
+!---                       = 1 xgrid on file .ne. that in QCDNUM        
+!---                       = 2 file contains heavy quark weight tables a
+!---                           qgrid on file .ne. that in QCDNUM        
+!---                       = 3 file contains charm weight tables and    
+!---                           c mass on the file .ne. that in QCDNUM   
+!---                       = 4 file contains bottom weight tables and   
+!---                           b mass on the file .ne. that in QCDNUM   
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+      CHARACTER*8 CHVERS,CHDATE 
+      COMMON/QCVERS/ CHVERS,CHDATE 
+                                                                        
+                                                                        
+      COMMON/QCCONS/                                                    &
+     &PI,PROTON,EUTRON,UCLEON,UDSCBT(6),AAM2H,BBM2H,AAM2L,BBM2L,        &
+     &AAAR2,BBBR2,FL_FAC,CBMSTF(4:7),CHARGE(4:7),                       &
+     &C1S3,C2S3,C4S3,C5S3,C8S3,C11S3,C14S3,C16S3,C20S3,C22S3,C28S3,     &
+     &C38S3,C40S3,C44S3,C52S3,C136S3,C11S6,C2S9,C4S9,C10S9,C14S9,C16S9, &
+     &C40S9,C44S9,C62S9,C112S9,C182S9,C11S12,C35S18,C61S12,C215S1,      &
+     &C29S12,CPI2S3,CPIA,CPIB,CPIC,CPID,CPIE,CPIF,CCA,CCF,CTF,CATF,CFTF 
+                                                                        
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      REAL                                                              &
+     &WGTFF1,WGTFG1,                                                    &
+     &WGTGF1,WGTGG1,                                                    &
+     &WGTPP2,WGTPM2,WGTNS2,                                             &
+     &WGTFF2,WGTFG2,                                                    &
+     &WGTGF2,WGTGG2,                                                    &
+     &WGTC2Q,WGTC2G,YNTC2Q,                                             &
+     &WGTCLQ,WGTCLG,WGTC3Q                                              
+                                                                        
+      COMMON/QCWEIT/                                                    &
+     &WGTFF1(MXX*(MXX+1)/2)    ,WGTFG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF1(MXX*(MXX+1)/2)    ,WGTGG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTPP2(MXX*(MXX+1)/2,3:5),WGTPM2(MXX*(MXX+1)/2,3:5),              &
+     &WGTNS2(MXX*(MXX+1)/2,3:5),                                        &
+     &WGTFF2(MXX*(MXX+1)/2,3:5),WGTFG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF2(MXX*(MXX+1)/2,3:5),WGTGG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTC2Q(MXX*(MXX+1)/2)    ,WGTC2G(MXX*(MXX+1)/2,3:5),              &
+     &WGTCLQ(MXX*(MXX+1)/2)    ,WGTCLG(MXX*(MXX+1)/2,3:5),              &
+     &WGTC3Q(MXX*(MXX+1)/2)    ,YNTC2Q(MXX)                             
+                                                                        
+      COMMON/QCWADR/ IWADR(MXX,MXX) 
+                                                                        
+                                                                        
+      REAL                                                              &
+     &WH_C0KG,WH_C1KG,WH_C1BKG,                                         &
+     &WH_C1KQ,WH_C1BKQ,WH_D1KQ,WH_D1BKQ                                 
+                                                                        
+      COMMON/QCHWGT/                                                    &
+     &WH_C0KG(0:MXX,MQ2,4:7),                                           &
+     &WH_C1KG(0:MXX,MQ2,4:7),WH_C1BKG(0:MXX,MQ2,4:7),                   &
+     &WH_C1KQ(0:MXX,MQ2,4:7),WH_C1BKQ(0:MXX,MQ2,4:7),                   &
+     &WH_D1KQ(0:MXX,MQ2,4:7),WH_D1BKQ(0:MXX,MQ2,4:7)                    
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      CHARACTER*8 RHVERS,RHDATE 
+      LOGICAL     RWT1OK,RWT2OK,RWTFOK,RWFCOK 
+      LOGICAL     RWLCOK,RWFBOK,RWLBOK,RPLUS 
+      LOGICAL     LREADX,LREADQ,LREADB,LREADC 
+      DIMENSION   RMASS(6) 
+      DIMENSION   RXTAB(MXX),RQTAB(MQ2) 
+      DIMENSION   IRF2C(MQ2),IRF2B(MQ2),IRFLC(MQ2),IRFLB(MQ2) 
+!                                                                       
+! common added 18/3/05 by MRW                                           
+      common/lhasilent/lhasilent 
+                                                                        
+      CALL QTRACE('QNREAD ',0) 
+                                                                        
+      REWIND LUN 
+                                                                        
+!--   Setup the weight adresses                                         
+!--   (Usually done in QNFILW, but this routine might not be called)    
+      DO IX0 = 1,MXX 
+        DO IX = IX0,MXX 
+          IWADR(IX,IX0) = IWTAD(IX,IX0) 
+        ENDDO 
+      ENDDO 
+                                                                        
+!--   Read header information                                           
+      READ(LUN,ERR=500) KXX,KQ2 
+      IF(KXX.NE.MXX.OR.KQ2.NE.MQ2) THEN 
+        WRITE(6,'(/'' QNREAD: nxmax, nqmax on file  '',2I5,             &
+     &            /''         nxmax, nqmax in QCDNUM'',2I5,             &
+     &            /''         Incompatible ---> STOP'')')               &
+     &                        KXX,KQ2,MXX,MQ2                           
+        STOP 
+      ENDIF 
+      READ(LUN,ERR=500) RHVERS,RHDATE 
+      READ(RHVERS(1:2),'(I2)') IV 
+                                                                        
+!--   If ISTOP > 0 : stop when fileversion = QCDNUM15 or lower          
+!--   If ISTOP = 0 : read up to the weight tables                       
+      IF(IV.LE.15.AND.ISTOP.NE.0) THEN 
+        WRITE(6,'(/'' QNREAD: file was written with QCDNUM'',A8,        &
+     &             '' Incompatible ---> STOP'')')                       &
+     &   RHVERS                                                         
+        STOP 
+      ENDIF 
+      if(lhasilent.eq.0)                                                &
+     & WRITE(6,'(/'' QNREAD: file was written with QCDNUM'',A8)')       &
+     & RHVERS                                                           
+                                                                        
+      READ(LUN,ERR=500) RMASS 
+      READ(LUN,ERR=500) RWT1OK,RWT2OK,RWTFOK,RWFCOK,RWLCOK,RWFBOK,      &
+     &                  RWLBOK,RPLUS                                    
+      READ(LUN,ERR=500) RXTAB,RQTAB,                                    &
+     &                  NRX,NRQ,IRF2C,IRF2B,IRFLC,IRFLB                 
+                                                                        
+      IERR   = 0 
+      LREADX = .FALSE. 
+      LREADQ = .FALSE. 
+      LREADC = .FALSE. 
+      LREADB = .FALSE. 
+                                                                        
+!--   Check xgrid (if there is one already defined)                     
+      IF(NXX.NE.0)     THEN 
+        IF(NXX.NE.NRX) THEN 
+          IERR = 1 
+        ELSE 
+          DO IX = 1,NXX 
+            IF(RXTAB(IX).NE.XXTAB(IX)) IERR = 1 
+          ENDDO 
+        ENDIF 
+      ENDIF 
+                                                                        
+!--   What to do when xgrid is different                                
+      IF(IERR.EQ.1) THEN 
+        IF(ISTOP.EQ.1) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: X grid in memory different from that on file'',    &
+     &    '' ---> abandon reading'')')                                  
+          RETURN 
+        ENDIF 
+        IF(ISTOP.EQ.2) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: X grid in memory different from that on file'',    &
+     &    '' ---> STOP'')')                                             
+          STOP 
+        ENDIF 
+      ENDIF 
+                                                                        
+      IF(IERR.EQ.1.OR.NXX.LE.0) LREADX = .TRUE. 
+                                                                        
+!--   Check Q2 grid if there is one already defined and if there are    
+!--   heavy quark weight tables on the file                             
+      IF(NQ2.NE.0.AND.(RWFCOK.OR.RWLCOK.OR.RWFBOK.OR.RWLBOK)) THEN 
+        IF(NQ2.NE.NRQ) THEN 
+          IERR = 2 
+        ELSE 
+          DO IQ = 1,NQ2 
+            IF(RQTAB(IQ).NE.Q2TAB(IQ)) IERR = 2 
+          ENDDO 
+        ENDIF 
+      ENDIF 
+                                                                        
+!--   What to do when qgrid is different                                
+      IF(IERR.EQ.2) THEN 
+        IF(ISTOP.EQ.1) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: Q2 grid in memory different from that on file'',   &
+     &    '' ---> abandon reading'')')                                  
+          RETURN 
+        ENDIF 
+        IF(ISTOP.EQ.2) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: Q2 grid in memory different from that on file'',   &
+     &    '' ---> STOP'')')                                             
+          STOP 
+        ENDIF 
+      ENDIF 
+                                                                        
+      IF(IERR.EQ.2.OR.NQ2.LE.0) LREADQ = .TRUE. 
+                                                                        
+!--   Check charm mass if there are charm weight tables on the file     
+      IF(RWFCOK.OR.RWLCOK) THEN 
+        IF(IV.LE.15) THEN 
+          IF(RMASS(4).NE.CBMSTF(4)) IERR = 3 
+        ELSE 
+          IF(RMASS(1).NE.CBMSTF(4)) IERR = 3 
+        ENDIF 
+      ENDIF 
+                                                                        
+!--   What to do when charm mass is different                           
+      IF(IERR.EQ.3) THEN 
+        IF(ISTOP.EQ.1) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: Charm mass in memory different from that on file'',&
+     &    '' ---> abandon reading'')')                                  
+          RETURN 
+        ENDIF 
+        IF(ISTOP.EQ.2) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: Charm mass in memory different from that on'',     &
+     &    '' file ---> STOP'')')                                        
+          STOP 
+        ENDIF 
+        LREADC = .TRUE. 
+      ENDIF 
+                                                                        
+!--   Check bottom mass if there are bottom weight tables on the file   
+      IF(RWFBOK.OR.RWLBOK) THEN 
+        IF(IV.LE.15) THEN 
+          IF(RMASS(5).NE.CBMSTF(6)) IERR = 4 
+        ELSE 
+          IF(RMASS(2).NE.CBMSTF(6)) IERR = 4 
+        ENDIF 
+      ENDIF 
+                                                                        
+!--   What to do when bottom mass is different                          
+      IF(IERR.EQ.4) THEN 
+        IF(ISTOP.EQ.1) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: Bottom mass in memory different from that on'',    &
+     &    '' file ---> abandon reading'')')                             
+          RETURN 
+        ENDIF 
+        IF(ISTOP.EQ.2) THEN 
+          WRITE(6,'(/                                                   &
+     &    '' QNREAD: Bottom mass in memory different from that on'',    &
+     &    '' file ---> STOP'')')                                        
+          STOP 
+        ENDIF 
+        LREADB = .TRUE. 
+      ENDIF 
+                                                                        
+!--   ok..... continue.......                                           
+      LPLUS  = RPLUS 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+      IF(LREADX) THEN 
+!--     Copy xgrid to qcdnum common block                               
+        NXX = NRX 
+        DO IX = 1,NXX+1 
+          XXTAB(IX) = RXTAB(IX) 
+        ENDDO 
+        WRITE(6,'(/                                                     &
+     &    '' QNREAD: xgrid table read in (original overwritten)'')')    
+!--     Invalidate all weight tables since the grid has changed         
+        LWT1OK = .FALSE. 
+        LWT2OK = .FALSE. 
+        LWTFOK = .FALSE. 
+        LWFCOK = .FALSE. 
+        LWLCOK = .FALSE. 
+        LWFBOK = .FALSE. 
+        LWLBOK = .FALSE. 
+        LMARK  = .FALSE. 
+        NGRVER = NGRVER+1 
+!--     Invalidate all evolutions                                       
+        CALL QNFALS(LEVDONE,MXX*10) 
+!---    Update IFAILC                                                   
+        CALL GRSETC 
+!---    Update NFMAP                                                    
+        CALL QNSETT 
+!---    Update heavy quark xgrid                                        
+        CALL GXHDEF 
+      ENDIF 
+                                                                        
+      IF(LREADQ) THEN 
+!--     Copy q2 grid to common block                                    
+        NQ2 = NRQ 
+        DO IQ = 1,NQ2 
+          Q2TAB(IQ) = RQTAB(IQ) 
+        ENDDO 
+        WRITE(6,'(/                                                     &
+     &    '' QNREAD: qgrid table read in (original overwritten)'')')    
+!--     Invalidate hq weight tables since the grid has changed          
+        LALFOK = .FALSE. 
+        LDQ2OK = .FALSE. 
+        LWFCOK = .FALSE. 
+        LWLCOK = .FALSE. 
+        LWFBOK = .FALSE. 
+        LWLBOK = .FALSE. 
+        LMARK  = .FALSE. 
+        NGRVER = NGRVER + 1 
+!--     Invalidate all evolutions                                       
+        CALL QNFALS(LEVDONE,MXX*10) 
+!---    Update IFAILC                                                   
+        CALL GRSETC 
+!---    Update NFMAP                                                    
+        CALL QNSETT 
+      ENDIF 
+                                                                        
+      IF(LREADC) THEN 
+        IF(IV.LE.15) THEN 
+          UDSCBT(4) = RMASS(4) 
+          CBMSTF(4) = RMASS(4) 
+          CBMSTF(5) = RMASS(4) 
+        ELSE 
+          CBMSTF(4) = RMASS(1) 
+          CBMSTF(5) = RMASS(1) 
+        ENDIF 
+        WRITE(6,'(/                                                     &
+     &    '' QNREAD: charm mass read in (original overwritten)'')')     
+!--     Invalidate charm weight tables since charm mass has changed     
+        LWFCOK = .FALSE. 
+        LWLCOK = .FALSE. 
+!--     Invalidate alpha_s table                                        
+        LALFOK = .FALSE. 
+      ENDIF 
+                                                                        
+      IF(LREADB) THEN 
+        IF(IV.LE.15) THEN 
+          UDSCBT(5) = RMASS(5) 
+          CBMSTF(6) = RMASS(5) 
+          CBMSTF(7) = RMASS(5) 
+        ELSE 
+          CBMSTF(6) = RMASS(2) 
+          CBMSTF(7) = RMASS(2) 
+        ENDIF 
+        WRITE(6,'(/                                                     &
+     &    '' QNREAD: bottom mass read in (original overwritten)'')')    
+!--     Invalidate bottom weight tables since charm mass has changed    
+        LWFBOK = .FALSE. 
+        LWLBOK = .FALSE. 
+!--     Invalidate alpha_s table                                        
+        LALFOK = .FALSE. 
+      ENDIF 
+                                                                        
+      IF(IV.LE.15) THEN 
+        WRITE(6,'(/'' QNREAD: file was written with QCDNUM'',A8)')      &
+     &   RHVERS                                                         
+        WRITE(6,'( '' ------> Abandon reading the weight tables'')') 
+        RETURN 
+      ENDIF 
+                                                                        
+      IF(RWT1OK) THEN 
+        READ(LUN,ERR=500) WGTFF1,WGTFG1,WGTGF1,WGTGG1 
+        LWT1OK = .TRUE. 
+        if(lhasilent.eq.0)                                              &
+     &   WRITE(6,'(/'' QNREAD: LO weight tables read in'')')            
+      ENDIF 
+                                                                        
+      IF(RWT2OK) THEN 
+        READ(LUN,ERR=500) WGTPP2,WGTPM2,WGTNS2,WGTFF2,WGTFG2,WGTGF2,    &
+     &                    WGTGG2                                        
+        LWT2OK = .TRUE. 
+        if(lhasilent.eq.0)                                              &
+     &   WRITE(6,'(/'' QNREAD: NLO weight tables read in'')')           
+      ENDIF 
+                                                                        
+      IF(RWTFOK) THEN 
+        READ(LUN,ERR=500) WGTC2Q,WGTC2G,YNTC2Q,WGTCLQ,WGTCLG,WGTC3Q 
+        LWTFOK = .TRUE. 
+        if(lhasilent.eq.0)                                              &
+     &   WRITE(6,'(/'' QNREAD: F2, FL weight tables read in'')')        
+      ENDIF 
+                                                                        
+      IF(RWFCOK.OR.RWLCOK.OR.RWFBOK.OR.RWLBOK) THEN 
+        READ(LUN,ERR=500) WH_C0KG,WH_C1KG,WH_C1BKG,                     &
+     &                    WH_C1KQ,WH_C1BKQ,WH_D1KQ,WH_D1BKQ             
+        LWFCOK = RWFCOK 
+        LWLCOK = RWLCOK 
+        LWFBOK = RWFBOK 
+        LWLBOK = RWLBOK 
+        if(lhasilent.eq.0) then 
+        IF(RWFCOK)                                                      &
+     &  WRITE(6,'(/'' QNREAD: F2C weight tables read in'')')            
+        IF(RWLCOK)                                                      &
+     &  WRITE(6,'(/'' QNREAD: FLC weight tables read in'')')            
+        IF(RWFBOK)                                                      &
+     &  WRITE(6,'(/'' QNREAD: F2B weight tables read in'')')            
+        IF(RWLBOK)                                                      &
+     &  WRITE(6,'(/'' QNREAD: FLB weight tables read in'')')            
+        endif 
+      ENDIF 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+      WRITE(6,'(/'' QNREAD: cannot read file on lun = '',I5,            &
+     &           '' ---> STOP'')') LUN                                  
+                                                                        
+      CALL QTRACE('QNREAD ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, QNPRIN.                                                     
+!                                                                       
+!     ======================                                            
+      SUBROUTINE QNPRIN(LUN) 
+!     ======================                                            
+                                                                        
+!---  QNPRIN: print default + current setting of QCDNUM parameters.     
+!---  Called by QPRINT                                                  
+!---  Input parameter: LUN. To be opened by user unless LUN = 6.        
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+                                                                        
+      COMMON/QCCONS/                                                    &
+     &PI,PROTON,EUTRON,UCLEON,UDSCBT(6),AAM2H,BBM2H,AAM2L,BBM2L,        &
+     &AAAR2,BBBR2,FL_FAC,CBMSTF(4:7),CHARGE(4:7),                       &
+     &C1S3,C2S3,C4S3,C5S3,C8S3,C11S3,C14S3,C16S3,C20S3,C22S3,C28S3,     &
+     &C38S3,C40S3,C44S3,C52S3,C136S3,C11S6,C2S9,C4S9,C10S9,C14S9,C16S9, &
+     &C40S9,C44S9,C62S9,C112S9,C182S9,C11S12,C35S18,C61S12,C215S1,      &
+     &C29S12,CPI2S3,CPIA,CPIB,CPIC,CPID,CPIE,CPIF,CCA,CCF,CTF,CATF,CFTF 
+                                                                        
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      IF(RS2CUT.GE.0.) THEN 
+        RS2C = SQRT(RS2CUT) 
+      ELSE 
+        RS2C = RS2CUT 
+      ENDIF 
+                                                                        
+      WRITE(LUN,'(//'' +-------+---+-------+--------------+'',          &
+     & ''------------------------------------+'')')                     
+      WRITE(LUN,'(  '' | var   |typ| deflt |     value    |'',          &
+     & '' description                        |'')')                     
+      WRITE(LUN,'(  '' +-------+---+-------+--------------+'',          &
+     & ''------------------------------------+'')')                     
+      WRITE(LUN,'('' | W1ANA | L |   T   | '',6X,L1,5X,                 &
+     & '' | Analytical LO weight calculation   |'')') LW1ANA            
+      WRITE(LUN,'('' | W1NUM | L |   F   | '',6X,L1,5X,                 &
+     & '' | Numerical  LO weight calculation   |'')') LW1NUM            
+      WRITE(LUN,'('' | W2NUM | L |   T   | '',6X,L1,5X,                 &
+     & '' | Numerical NLO weight calculation   |'')') LW2NUM            
+      WRITE(LUN,'('' | W2STF | L |   T   | '',6X,L1,5X,                 &
+     & '' | Structure function NLO weights     |'')') LW2STF            
+      WRITE(LUN,'('' | WTF2C | L |   F   | '',6X,L1,5X,                 &
+     & '' | F2_charm  weight calculation       |'')') LWF2C             
+      WRITE(LUN,'('' | WTF2B | L |   F   | '',6X,L1,5X,                 &
+     & '' | F2_bottom weight calculation       |'')') LWF2B             
+      WRITE(LUN,'('' | WTFLC | L |   F   | '',6X,L1,5X,                 &
+     & '' | FL_charm  weight calculation       |'')') LWFLC             
+      WRITE(LUN,'('' | WTFLB | L |   F   | '',6X,L1,5X,                 &
+     & '' | FL_bottom weight calculation       |'')') LWFLB             
+      WRITE(LUN,'('' | LIMCK | L |   T   | '',6X,L1,5X,                 &
+     & '' | Check x, Q2 limits and cuts        |'')') LIMCK             
+      WRITE(LUN,'('' | CLOWQ | L |   T   | '',6X,L1,5X,                 &
+     & '' | Heavy F2,FL only for Q2 > 1.5 GeV2 |'')') LCLOWQ            
+      WRITE(LUN,'('' | ORDER | I |   2   | '',6X,I1,5X,                 &
+     & '' | LO (1) or NLO (2) calculations     |'')') IORD              
+      WRITE(LUN,'('' | SCAX0 | R |  0.20 | '',E12.5,                    &
+     & '' | x-grid  scale from log --> linear  |'')') SCAX0             
+      WRITE(LUN,'('' | SCAQ0 | R | +inf  | '',E12.5,                    &
+     & '' | Q2-grid scale from log --> linear  |'')') SCAQ0             
+      WRITE(LUN,'('' | MCSTF | R |  1.5  | '',E12.5,                    &
+     & '' | C mass for F2c, FLc (GeV)          |'')') CBMSTF(4)         
+      WRITE(LUN,'('' | MBSTF | R |  5.0  | '',E12.5,                    &
+     & '' | B mass for F2b, FLb (GeV)          |'')') CBMSTF(6)         
+      WRITE(LUN,'('' | MCALF | R |  1.5  | '',E12.5,                    &
+     & '' | C mass for alpha_s evolution (GeV) |'')') UDSCBT(4)         
+      WRITE(LUN,'('' | MBALF | R |  5.0  | '',E12.5,                    &
+     & '' | B mass for alpha_s evolution (GeV) |'')') UDSCBT(5)         
+      WRITE(LUN,'('' | MTALF | R | 188.  | '',E12.5,                    &
+     & '' | T mass for alpha_s evolution (GeV) |'')') UDSCBT(6)         
+      WRITE(LUN,'('' | ALFAS | R | 0.180 | '',E12.5,                    &
+     & '' | Value of alpha_s                   |'')') ALPHA0            
+      WRITE(LUN,'('' | ALFQ0 | R |  50.  | '',E12.5,                    &
+     & '' | Q2 where alpha_s is given (GeV2)   |'')') Q0ALFA            
+      WRITE(LUN,'('' | AAAR2 | R |  1.0  | '',E12.5,                    &
+     & '' | R2 = A*M2 + B (ren. scale)         |'')') AAAR2             
+      WRITE(LUN,'('' | BBBR2 | R |  0.0  | '',E12.5,                    &
+     & '' | R2 = A*M2 + B (ren. scale)         |'')') BBBR2             
+      WRITE(LUN,'('' | AAM2L | R |  1.0  | '',E12.5,                    &
+     & '' | M2 = A*Q2 + B (light fact. scale)  |'')') AAM2L             
+      WRITE(LUN,'('' | BBM2L | R |  0.0  | '',E12.5,                    &
+     & '' | M2 = A*Q2 + B (light fact. scale)  |'')') BBM2L             
+      WRITE(LUN,'('' | AAM2H | R |  1.0  | '',E12.5,                    &
+     & '' | M2 = A*Q2 + B (heavy fact. scale)  |'')') AAM2H             
+      WRITE(LUN,'('' | BBM2H | R |  0.0  | '',E12.5,                    &
+     & '' | M2 = A*Q2 + B (heavy fact. scale)  |'')') BBM2H             
+      WRITE(LUN,'(  '' +-------+---+-------+--------------+'',          &
+     & ''------------------------------------+'')')                     
+      WRITE(LUN,'('' | TCHRM | R | -inf  | '',E12.5,                    &
+     & '' | Charm threshold  (GeV2)            |'')') THRS34            
+      WRITE(LUN,'('' | TBOTT | R | +inf  | '',E12.5,                    &
+     & '' | Bottom threshold (GeV2)            |'')') THRS45            
+      WRITE(LUN,'('' | XMINC | R |  0.0  | '',E12.5,                    &
+     & '' | Xmin cut  (.le.0 = no cut)         |'')') XMICUT            
+      WRITE(LUN,'('' | QMINC | R |  0.0  | '',E12.5,                    &
+     & '' | Qmin cut  (.le.0 = no cut)         |'')') QMICUT            
+      WRITE(LUN,'('' | QMAXC | R |  0.0  | '',E12.5,                    &
+     & '' | Qmax cut  (.le.0 = no cut)         |'')') QMACUT            
+      WRITE(LUN,'('' | ROOTS | R |  0.0  | '',E12.5,                    &
+     & '' | Roots cut (.le.0 = no cut)         |'')') RS2C              
+      WRITE(LUN,'('' | QMINA | R |  0.0  | '',E12.5,                    &
+     & '' | Lowest Q2 gridpoint above Lambda2  |'')') QMINAS            
+      WRITE(LUN,'(  '' +-------+---+-------+--------------+'',          &
+     & ''------------------------------------+'')')                     
+      WRITE(LUN,'('' | ASOLD | L |   F   | '',6X,L1,5X,                 &
+     & '' | Use old (incorrect) a_s evolution  |'')') LASOLD            
+      WRITE(LUN,'('' | BMARK | L |   F   | '',6X,L1,5X,                 &
+     & '' | Do not use: for tests only         |'')') LBMARK            
+      WRITE(LUN,'('' | FLFAC | R |  0.0  | '',E12.5,                    &
+     & '' | Hands off : for experts only       |'')') BBM2H             
+      WRITE(LUN,'(  '' +-------+---+-------+--------------+'',          &
+     & ''------------------------------------+'')')                     
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNVERS.                                                     
+!                                                                       
+!     ==============================================                    
+      SUBROUTINE QNVERS(VERSION,LDOUBLE,NXMAX,NQMAX) 
+!     ==============================================                    
+                                                                        
+!---  QNVERS: return version number, dp flag and max # of gridpoints.   
+!---  Called by user.                                                   
+!---  Output variables: VERSION (character*8)                           
+!---                    LDOUBLE (logical)                               
+!---                    NXMAX, NQMAX (integer); set by parameter        
+!---                    statement in common block QCNXQM.               
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*8 VERSION 
+      LOGICAL     LDOUBLE 
+                                                                        
+      CHARACTER*8 CHVERS,CHDATE 
+      COMMON/QCVERS/ CHVERS,CHDATE 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      CALL QTRACE('QNVERS ',0) 
+                                                                        
+      VERSION = CHVERS 
+      LDOUBLE = LDOUBL 
+      NXMAX   = MXX-1 
+      NQMAX   = MQ2-1 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QPRINT.                                                     
+                                                                        
+!     ==========================                                        
+      SUBROUTINE QPRINT(LUN,OPT) 
+!     ==========================                                        
+                                                                        
+!---  QPRINT: steering routine to print various QCDNUM info on          
+!--           logical unit number LUN (to be opened by the user).       
+!---  Called by user.                                                   
+!---  Input integer LUN  :  locical unit number.                        
+!---        character OPT: 'A' (All)        print all info.             
+!---                       'B' (Booklist)   print pdf definitions.      
+!---                       'P' (Parameters) Parameter/option list.      
+!---                       'S' (Statistics) # STF function calls.       
+!---                       'T' (Timelog)    timelog.                    
+!---                       'X' (Xq2grid)    grid,thresholds,cuts.       
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) OPT 
+      CHARACTER*1   OPT1 
+                                                                        
+                                                                        
+      LOGICAL LTIME 
+      REAL T_START,T_END,T_SPENT 
+      COMMON/QCTIME/T_START(10),T_END(10),T_SPENT(10),N_CALLS(10),      &
+     &E_CALLS(10),LTIME                                                 
+      COMMON/QCFCNT/IFCNT(-1:1,5) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      REAL                                                              &
+     &WGTFF1,WGTFG1,                                                    &
+     &WGTGF1,WGTGG1,                                                    &
+     &WGTPP2,WGTPM2,WGTNS2,                                             &
+     &WGTFF2,WGTFG2,                                                    &
+     &WGTGF2,WGTGG2,                                                    &
+     &WGTC2Q,WGTC2G,YNTC2Q,                                             &
+     &WGTCLQ,WGTCLG,WGTC3Q                                              
+                                                                        
+      COMMON/QCWEIT/                                                    &
+     &WGTFF1(MXX*(MXX+1)/2)    ,WGTFG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF1(MXX*(MXX+1)/2)    ,WGTGG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTPP2(MXX*(MXX+1)/2,3:5),WGTPM2(MXX*(MXX+1)/2,3:5),              &
+     &WGTNS2(MXX*(MXX+1)/2,3:5),                                        &
+     &WGTFF2(MXX*(MXX+1)/2,3:5),WGTFG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF2(MXX*(MXX+1)/2,3:5),WGTGG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTC2Q(MXX*(MXX+1)/2)    ,WGTC2G(MXX*(MXX+1)/2,3:5),              &
+     &WGTCLQ(MXX*(MXX+1)/2)    ,WGTCLG(MXX*(MXX+1)/2,3:5),              &
+     &WGTC3Q(MXX*(MXX+1)/2)    ,YNTC2Q(MXX)                             
+                                                                        
+      COMMON/QCWADR/ IWADR(MXX,MXX) 
+                                                                        
+                                                                        
+      CALL QTRACE('QPRINT ',0) 
+                                                                        
+      IF(LENOCC_LHA(OPT).LT.1) GOTO 500 
+      OPT1 = OPT(1:1) 
+      CALL CLTOU_LHA(OPT1) 
+                                                                        
+                           !                                            
+      IF(OPT1.EQ.'T') THEN 
+        CALL QPTIME(LUN) 
+      ELSEIF(OPT1.EQ.'P') THEN 
+        CALL QNPRIN(LUN) 
+      ELSEIF(OPT1.EQ.'B') THEN 
+        CALL QNLIST(LUN) 
+      ELSEIF(OPT1.EQ.'S') THEN 
+        CALL QNSTAT(LUN) 
+      ELSEIF(OPT1.EQ.'X') THEN 
+        CALL QPGRID(LUN) 
+      ELSEIF(OPT1.EQ.'A') THEN 
+        CALL QNPRIN(LUN) 
+        CALL QNLIST(LUN) 
+        CALL QPGRID(LUN) 
+        CALL QNSTAT(LUN) 
+        CALL QPTIME(LUN) 
+      ELSE 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r QPRINT ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input LUN :'',I5   )') LUN 
+      WRITE(6,'( ''       OPT :'',A    )') OPT 
+      WRITE(6,'(/'' Option should be A, B, P, S, T or X'')') 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, QNTIME.                                                     
+                                                                        
+!     ======================                                            
+      SUBROUTINE QNTIME(OPT) 
+!     ======================                                            
+                                                                        
+!---  QNTIME: start/halt/continue the timelog.                          
+!---  Called by user and by QPTIME.                                     
+!---  Input variable: 'Start'    initialise and start the timelog.      
+!---                  'Hold'     stop logging.                          
+!---                  'Cont'     continue logging.                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) OPT 
+      CHARACTER*1   OPT1 
+                                                                        
+                                                                        
+      LOGICAL LTIME 
+      REAL T_START,T_END,T_SPENT 
+      COMMON/QCTIME/T_START(10),T_END(10),T_SPENT(10),N_CALLS(10),      &
+     &E_CALLS(10),LTIME                                                 
+      COMMON/QCFCNT/IFCNT(-1:1,5) 
+                                                                        
+                                                                        
+      CALL QTRACE('QNTIME ',0) 
+                                                                        
+      IF(LENOCC_LHA(OPT).LT.1) GOTO 500 
+      OPT1 = OPT(1:1) 
+      CALL CLTOU_LHA(OPT1) 
+                                                                        
+      IF(OPT1.EQ.'S') THEN 
+                                                                        
+        DO I = 1,10 
+          T_SPENT(I) = 0. 
+          E_CALLS(I) = 0. 
+          N_CALLS(I) = 0 
+        ENDDO 
+        LTIME = .TRUE. 
+                                                                        
+        N_CALLS(1) = N_CALLS(1)+1 
+        CALL TIMEX_LHA(T_START(1)) 
+                                                                        
+      ELSEIF(OPT1.EQ.'H') THEN 
+                                                                        
+        LTIME = .FALSE. 
+        CALL TIMEX_LHA(T_END(1)) 
+        T_SPENT(1) = T_SPENT(1)+T_END(1)-T_START(1) 
+        T_START(1) = T_END(1) 
+                                                                        
+      ELSEIF(OPT1.EQ.'C') THEN 
+                                                                        
+        IF(.NOT.LTIME) THEN 
+          LTIME = .TRUE. 
+          N_CALLS(1) = N_CALLS(1)+1 
+          CALL TIMEX_LHA(T_START(1)) 
+        ENDIF 
+                                                                        
+      ELSE 
+                                                                        
+        GOTO 500 
+                                                                        
+      ENDIF 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r QNTIME ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input OPT :'',A    )') OPT 
+      WRITE(6,'(/'' Option should be S, H or C         '')') 
+                                                                        
+      CALL QTRACE('QNTIME ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, QPTIME.                                                     
+                                                                        
+!     ======================                                            
+      SUBROUTINE QPTIME(LUN) 
+!     ======================                                            
+                                                                        
+!---  QPTIME: start/print the timelog.                                  
+!---  Called by QPRINT.                                                 
+!---  Input variable: LUN logical unit number                           
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL LTIME 
+      REAL T_START,T_END,T_SPENT 
+      COMMON/QCTIME/T_START(10),T_END(10),T_SPENT(10),N_CALLS(10),      &
+     &E_CALLS(10),LTIME                                                 
+      COMMON/QCFCNT/IFCNT(-1:1,5) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      REAL                                                              &
+     &WGTFF1,WGTFG1,                                                    &
+     &WGTGF1,WGTGG1,                                                    &
+     &WGTPP2,WGTPM2,WGTNS2,                                             &
+     &WGTFF2,WGTFG2,                                                    &
+     &WGTGF2,WGTGG2,                                                    &
+     &WGTC2Q,WGTC2G,YNTC2Q,                                             &
+     &WGTCLQ,WGTCLG,WGTC3Q                                              
+                                                                        
+      COMMON/QCWEIT/                                                    &
+     &WGTFF1(MXX*(MXX+1)/2)    ,WGTFG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF1(MXX*(MXX+1)/2)    ,WGTGG1(MXX*(MXX+1)/2,3:5),              &
+     &WGTPP2(MXX*(MXX+1)/2,3:5),WGTPM2(MXX*(MXX+1)/2,3:5),              &
+     &WGTNS2(MXX*(MXX+1)/2,3:5),                                        &
+     &WGTFF2(MXX*(MXX+1)/2,3:5),WGTFG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTGF2(MXX*(MXX+1)/2,3:5),WGTGG2(MXX*(MXX+1)/2,3:5),              &
+     &WGTC2Q(MXX*(MXX+1)/2)    ,WGTC2G(MXX*(MXX+1)/2,3:5),              &
+     &WGTCLQ(MXX*(MXX+1)/2)    ,WGTCLG(MXX*(MXX+1)/2,3:5),              &
+     &WGTC3Q(MXX*(MXX+1)/2)    ,YNTC2Q(MXX)                             
+                                                                        
+      COMMON/QCWADR/ IWADR(MXX,MXX) 
+                                                                        
+                                                                        
+      CALL QNTIME('H') 
+                                                                        
+      N_TOT      = N_CALLS(3)+N_CALLS(4)+N_CALLS(5) 
+      E_TOT      = E_CALLS(3)+E_CALLS(4)+E_CALLS(5) 
+      T_TOT      = T_SPENT(3)+T_SPENT(4)+T_SPENT(5) 
+      T_REST     = T_SPENT(1)-T_TOT-T_SPENT(2)-T_SPENT(6) 
+      DUMMY      = 1. 
+      F_FAST     = 0. 
+      DO J = 1,5 
+        F_FAST   = F_FAST+IFCNT(1,J) 
+      ENDDO 
+      WRITE(LUN,                                                        &
+     &  '(//'' -------------------------------------------------'')')   
+      WRITE(LUN,                                                        &
+     &  '(  '' Routine     # calls   # evols   CPU sec  CPU/evol'')')   
+      WRITE(LUN,                                                        &
+     &  '(  '' -------------------------------------------------'')')   
+      WRITE(LUN,                                                        &
+     & '('' EVOLNM   '',I10,2F10.1,F10.2)') N_CALLS(3),                 &
+     &      E_CALLS(3),T_SPENT(3),T_SPENT(3)/MAX(E_CALLS(3),DUMMY)      
+      WRITE(LUN,                                                        &
+     & '('' EVOLNP   '',I10,2F10.1,F10.2)') N_CALLS(4),                 &
+     &      E_CALLS(4),T_SPENT(4),T_SPENT(4)/MAX(E_CALLS(4),DUMMY)      
+      WRITE(LUN,                                                        &
+     & '('' EVOLSG   '',I10,2F10.1,F10.2)') N_CALLS(5),                 &
+     &      E_CALLS(5),T_SPENT(5),T_SPENT(5)/MAX(E_CALLS(5),DUMMY)      
+      WRITE(LUN,                                                        &
+     &  '(  '' -------------------------------------------------'')')   
+      WRITE(LUN,                                                        &
+     & '('' AP total '',I10,2F10.1,F10.2)') N_TOT,                      &
+     &      E_TOT,T_TOT,T_TOT/MAX(E_TOT,DUMMY)                          
+      WRITE(LUN,'('' '')') 
+      WRITE(LUN,                                                        &
+     & '('' STFAST   '',I10,   2F10.1)') N_CALLS(6),F_FAST,T_SPENT(6)   
+      WRITE(LUN,                                                        &
+     & '('' QNFILW   '',I10,10X,F10.1)') N_CALLS(2),T_SPENT(2)          
+      WRITE(LUN,                                                        &
+     & '('' Other    '',10X,10X,F10.1)') T_REST                         
+      WRITE(LUN,                                                        &
+     &  '(  '' -------------------------------------------------'')')   
+      WRITE(LUN,                                                        &
+     & '('' Total    '',10X,10X,F10.1)') T_SPENT(1)                     
+      WRITE(LUN,                                                        &
+     &  '(  '' -------------------------------------------------'')')   
+                                                                        
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNSTAT.                                                     
+                                                                        
+!     ======================                                            
+      SUBROUTINE QNSTAT(LUN) 
+!     ======================                                            
+                                                                        
+!---  QNSTAT: print number of structure function calculations.          
+!---  Called by user.                                                   
+!---  Input parameter: LUN to be opened by user unless LUN = 6.         
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL LTIME 
+      REAL T_START,T_END,T_SPENT 
+      COMMON/QCTIME/T_START(10),T_END(10),T_SPENT(10),N_CALLS(10),      &
+     &E_CALLS(10),LTIME                                                 
+      COMMON/QCFCNT/IFCNT(-1:1,5) 
+                                                                        
+                                                                        
+      DIMENSION ITOT(5) 
+                                                                        
+       DO J = 1,5 
+        ITOT(J) = 0 
+        DO I = -1,1 
+          ITOT(J) = ITOT(J)+IFCNT(I,J) 
+        ENDDO 
+      ENDDO 
+                                                                        
+      WRITE(LUN,'(//'' ------------------------------'',                &
+     &   ''--------------------------------------------'')')            
+      WRITE(LUN,'(  '' Structure function calls '',                     &
+     &   ''           F2       FL      xF3'',                           &
+     &                ''      F2h      FLh'')')                         
+      WRITE(LUN,'(  '' ------------------------------'',                &
+     &   ''--------------------------------------------'')')            
+      WRITE(LUN,                                                        &
+     & '('' Slow calculation             '',5I9)') (IFCNT( 0,J),J=1,5)  
+      WRITE(LUN,                                                        &
+     & '('' Fast calculation             '',5I9)') (IFCNT( 1,J),J=1,5)  
+      WRITE(LUN,                                                        &
+     & '('' Outside grid or cuts         '',5I9)') (IFCNT(-1,J),J=1,5)  
+      WRITE(LUN,'(  '' ------------------------------'',                &
+     &   ''--------------------------------------------'')')            
+      WRITE(LUN,                                                        &
+     & '('' Total                        '',5I9)') (   ITOT(J),J=1,5)   
+      WRITE(LUN,'(  '' ------------------------------'',                &
+     &   ''--------------------------------------------'')')            
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNIVAL.                                                     
+                                                                        
+!     ================================                                  
+      SUBROUTINE QNIVAL(OPT,FLAG,IVAL) 
+!     ================================                                  
+                                                                        
+!---  QNIVAL: set/get integer variable.                                 
+!---  Called by user or internally by s/r QNISET and QNIGET.            
+!---  Input parameters: 'OPT'   = 'Set' or 'Get'.                       
+!---                    'FLAG'  = variable name to set or get.          
+!---                    'IVAL' (integer) input or output variable.      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) OPT 
+      CHARACTER*1   OPT1 
+      CHARACTER*(*) FLAG 
+      CHARACTER*5   FLAG5 
+                                                                        
+                                                                        
+      COMMON/QCCONS/                                                    &
+     &PI,PROTON,EUTRON,UCLEON,UDSCBT(6),AAM2H,BBM2H,AAM2L,BBM2L,        &
+     &AAAR2,BBBR2,FL_FAC,CBMSTF(4:7),CHARGE(4:7),                       &
+     &C1S3,C2S3,C4S3,C5S3,C8S3,C11S3,C14S3,C16S3,C20S3,C22S3,C28S3,     &
+     &C38S3,C40S3,C44S3,C52S3,C136S3,C11S6,C2S9,C4S9,C10S9,C14S9,C16S9, &
+     &C40S9,C44S9,C62S9,C112S9,C182S9,C11S12,C35S18,C61S12,C215S1,      &
+     &C29S12,CPI2S3,CPIA,CPIB,CPIC,CPID,CPIE,CPIF,CCA,CCF,CTF,CATF,CFTF 
+                                                                        
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      IF(LENOCC_LHA(OPT).LT.1)  THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+      IF(LENOCC_LHA(FLAG).LT.5) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+      OPT1   = OPT(1:1) 
+      FLAG5  = FLAG(1:5) 
+      CALL CLTOU_LHA(OPT1) 
+      CALL CLTOU_LHA(FLAG5) 
+                                                                        
+!     ----------------------                                            
+                           !                                            
+      IF(OPT1.EQ.'S') THEN 
+!     ----------------------                                            
+                                                                        
+        IF    (FLAG5.EQ.'ORDER') THEN 
+          IF(IVAL.LE.0.OR.IVAL.GE.3) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+          IORD   = IVAL 
+!--       Invalidate all evolutions                                     
+          CALL QNFALS(LEVDONE,MXX*10) 
+          LALFOK = .FALSE. 
+        ELSE 
+          IERR = 2 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!     --------------------------                                        
+                               !                                        
+      ELSEIF(OPT1.EQ.'G') THEN 
+!     --------------------------                                        
+                                                                        
+        IF    (FLAG5.EQ.'ORDER') THEN 
+          IVAL = IORD 
+        ELSE 
+          IERR = 2 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!     ------                                                            
+           !                                                            
+      ELSE 
+!     ------                                                            
+                                                                        
+        IERR = 1 
+        GOTO 500 
+                                                                        
+!     -------                                                           
+            !                                                           
+      ENDIF 
+!     -------                                                           
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r QNIVAL ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input OPT : '',A    )') OPT 
+      WRITE(6,'( ''       VAR : '',A    )') FLAG 
+      WRITE(6,'( ''       VAL : '',I10  )') IVAL 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' OPT should be either SET or GET '')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' Variable VAR not found'')') 
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' IVAL out of allowed range'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('QNIVAL ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, QNISET.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE QNISET(FLAG,IVAL) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) FLAG 
+                                                                        
+      CALL QTRACE('QNISET ',0) 
+                                                                        
+      CALL QNIVAL('SET',FLAG,IVAL) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNIGET.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE QNIGET(FLAG,IVAL) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) FLAG 
+                                                                        
+      CALL QTRACE('QNIGET ',0) 
+                                                                        
+      CALL QNIVAL('GET',FLAG,IVAL) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNRVAL.                                                     
+                                                                        
+!     ===============================                                   
+      SUBROUTINE QNRVAL(OPT,FLAG,VAL) 
+!     ===============================                                   
+                                                                        
+!---  QNRVAL: set/get floating point variable.                          
+!---  Called by user or internally by s/r QNRSET and QNRGET.            
+!---  Input parameters: 'OPT'   = 'Set' or 'Get'.                       
+!---                    'FLAG'  = variable name to set or get.          
+!---                    'VAL' (real or d.p.) input or output variable.  
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) OPT 
+      CHARACTER*1   OPT1 
+      CHARACTER*(*) FLAG 
+      CHARACTER*5   FLAG5 
+                                                                        
+                                                                        
+      COMMON/QCCONS/                                                    &
+     &PI,PROTON,EUTRON,UCLEON,UDSCBT(6),AAM2H,BBM2H,AAM2L,BBM2L,        &
+     &AAAR2,BBBR2,FL_FAC,CBMSTF(4:7),CHARGE(4:7),                       &
+     &C1S3,C2S3,C4S3,C5S3,C8S3,C11S3,C14S3,C16S3,C20S3,C22S3,C28S3,     &
+     &C38S3,C40S3,C44S3,C52S3,C136S3,C11S6,C2S9,C4S9,C10S9,C14S9,C16S9, &
+     &C40S9,C44S9,C62S9,C112S9,C182S9,C11S12,C35S18,C61S12,C215S1,      &
+     &C29S12,CPI2S3,CPIA,CPIB,CPIC,CPID,CPIE,CPIF,CCA,CCF,CTF,CATF,CFTF 
+                                                                        
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      IF(LENOCC_LHA(OPT).LT.1)  THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+      IF(LENOCC_LHA(FLAG).LT.5) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+      OPT1   = OPT(1:1) 
+      FLAG5  = FLAG(1:5) 
+      CALL CLTOU_LHA(OPT1) 
+      CALL CLTOU_LHA(FLAG5) 
+                                                                        
+!     ----------------------                                            
+                           !                                            
+      IF(OPT1.EQ.'S') THEN 
+!     ----------------------                                            
+                                                                        
+        IF    (FLAG5.EQ.'AAM2H'.OR.FLAG5.EQ.'AATQ2') THEN 
+          IF(VAL.LE.0.) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+          AAM2H  = VAL 
+          DO I = 1,30 
+            LFFCAL(4,I) = .FALSE. 
+            LFFCAL(5,I) = .FALSE. 
+            LFFCAL(6,I) = .FALSE. 
+            LFFCAL(7,I) = .FALSE. 
+          ENDDO 
+        ELSEIF(FLAG5.EQ.'BBM2H'.OR.FLAG5.EQ.'PLUSB') THEN 
+          BBM2H  = VAL 
+          DO I = 1,30 
+            LFFCAL(4,I) = .FALSE. 
+            LFFCAL(5,I) = .FALSE. 
+            LFFCAL(6,I) = .FALSE. 
+            LFFCAL(7,I) = .FALSE. 
+          ENDDO 
+        ELSEIF(FLAG5.EQ.'AAM2L') THEN 
+          IF(VAL.LE.0.) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+          AAM2L  = VAL 
+          DO I = 1,30 
+            LFFCAL(1,I) = .FALSE. 
+            LFFCAL(2,I) = .FALSE. 
+            LFFCAL(3,I) = .FALSE. 
+          ENDDO 
+        ELSEIF(FLAG5.EQ.'BBM2L') THEN 
+          BBM2L  = VAL 
+          DO I = 1,30 
+            LFFCAL(1,I) = .FALSE. 
+            LFFCAL(2,I) = .FALSE. 
+            LFFCAL(3,I) = .FALSE. 
+          ENDDO 
+        ELSEIF(FLAG5.EQ.'AAAR2') THEN 
+          AAAR2  = VAL 
+!--       Invalidate all evolutions                                     
+          CALL QNFALS(LEVDONE,MXX*10) 
+          LALFOK = .FALSE. 
+          DO I = 1,30 
+            DO J = 1,7 
+              LFFCAL(J,I)  = .FALSE. 
+            ENDDO 
+          ENDDO 
+        ELSEIF(FLAG5.EQ.'BBBR2') THEN 
+          BBBR2  = VAL 
+!--       Invalidate all evolutions                                     
+          CALL QNFALS(LEVDONE,MXX*10) 
+          LALFOK = .FALSE. 
+          DO I = 1,30 
+            DO J = 1,7 
+              LFFCAL(J,I)  = .FALSE. 
+            ENDDO 
+          ENDDO 
+        ELSEIF(FLAG5.EQ.'FLFAC') THEN 
+          FL_FAC = VAL 
+          DO I = 1,30 
+            LFFCAL(2,I)  = .FALSE. 
+          ENDDO 
+        ELSEIF(FLAG5.EQ.'SCAX0') THEN 
+          IF(VAL.LE.0.) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+          SCAX0     = VAL 
+        ELSEIF(FLAG5.EQ.'SCAQ0') THEN 
+          IF(VAL.LE.0.) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+          SCAQ0     = VAL 
+        ELSE 
+          IF(VAL.LE.0.) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+!--       Invalidate all evolutions                                     
+          CALL QNFALS(LEVDONE,MXX*10) 
+                             !force alpha_s to be recalculated          
+          LALFOK = .FALSE. 
+          IF    (FLAG5.EQ.'UMASS') THEN 
+            UDSCBT(1) = VAL 
+          ELSEIF(FLAG5.EQ.'DMASS') THEN 
+            UDSCBT(2) = VAL 
+          ELSEIF(FLAG5.EQ.'SMASS') THEN 
+            UDSCBT(3) = VAL 
+          ELSEIF(FLAG5.EQ.'CMASS') THEN 
+            UDSCBT(4) = VAL 
+            CBMSTF(4) = VAL 
+            CBMSTF(5) = VAL 
+                              !invalidate F2C weight tables             
+            LWFCOK = .FALSE. 
+                              !invalidate FLC weight tables             
+            LWLCOK = .FALSE. 
+          ELSEIF(FLAG5.EQ.'MCSTF') THEN 
+            CBMSTF(4) = VAL 
+            CBMSTF(5) = VAL 
+            LWFCOK = .FALSE. 
+            LWLCOK = .FALSE. 
+          ELSEIF(FLAG5.EQ.'MCALF') THEN 
+            UDSCBT(4) = VAL 
+          ELSEIF(FLAG5.EQ.'BMASS') THEN 
+            UDSCBT(5) = VAL 
+            CBMSTF(6) = VAL 
+            CBMSTF(7) = VAL 
+                              !invalidate F2B weight tables             
+            LWFBOK = .FALSE. 
+                              !invalidate FLB weight tables             
+            LWLBOK = .FALSE. 
+          ELSEIF(FLAG5.EQ.'MBSTF') THEN 
+            CBMSTF(6) = VAL 
+            CBMSTF(7) = VAL 
+            LWFBOK = .FALSE. 
+            LWLBOK = .FALSE. 
+          ELSEIF(FLAG5.EQ.'MBALF') THEN 
+            UDSCBT(5) = VAL 
+          ELSEIF(FLAG5.EQ.'MTALF') THEN 
+            UDSCBT(6) = VAL 
+          ELSEIF(FLAG5.EQ.'TMASS') THEN 
+            UDSCBT(6) = VAL 
+          ELSEIF(FLAG5.EQ.'ALFAS') THEN 
+            ALPHA0    = VAL 
+          ELSEIF(FLAG5.EQ.'ALFQ0') THEN 
+            Q0ALFA    = VAL 
+          ELSE 
+            IERR = 2 
+            GOTO 500 
+          ENDIF 
+        ENDIF 
+                                                                        
+!     --------------------------                                        
+                               !                                        
+      ELSEIF(OPT1.EQ.'G') THEN 
+!     --------------------------                                        
+                                                                        
+        IF    (FLAG5.EQ.'SCAX0') THEN 
+          VAL = SCAX0 
+        ELSEIF(FLAG5.EQ.'SCAQ0') THEN 
+          VAL = SCAQ0 
+        ELSEIF(FLAG5.EQ.'AAM2H'.OR.FLAG5.EQ.'AATQ2') THEN 
+          VAL = AAM2H 
+        ELSEIF(FLAG5.EQ.'BBM2H'.OR.FLAG5.EQ.'PLUSB') THEN 
+          VAL = BBM2H 
+        ELSEIF(FLAG5.EQ.'AAM2L') THEN 
+          VAL = AAM2L 
+        ELSEIF(FLAG5.EQ.'BBM2L') THEN 
+          VAL = BBM2L 
+        ELSEIF(FLAG5.EQ.'AAAR2') THEN 
+          VAL = AAAR2 
+        ELSEIF(FLAG5.EQ.'BBBR2') THEN 
+          VAL = BBBR2 
+        ELSEIF(FLAG5.EQ.'FLFAC') THEN 
+          VAL = FL_FAC 
+        ELSEIF(FLAG5.EQ.'UMASS') THEN 
+          VAL = UDSCBT(1) 
+        ELSEIF(FLAG5.EQ.'DMASS') THEN 
+          VAL = UDSCBT(2) 
+        ELSEIF(FLAG5.EQ.'SMASS') THEN 
+          VAL = UDSCBT(3) 
+        ELSEIF(FLAG5.EQ.'CMASS') THEN 
+          VAL = UDSCBT(4) 
+        ELSEIF(FLAG5.EQ.'BMASS') THEN 
+          VAL = UDSCBT(5) 
+        ELSEIF(FLAG5.EQ.'TMASS') THEN 
+          VAL = UDSCBT(6) 
+        ELSEIF(FLAG5.EQ.'MCSTF') THEN 
+          VAL = CBMSTF(4) 
+        ELSEIF(FLAG5.EQ.'MBSTF') THEN 
+          VAL = CBMSTF(6) 
+        ELSEIF(FLAG5.EQ.'MCALF') THEN 
+          VAL = UDSCBT(4) 
+        ELSEIF(FLAG5.EQ.'MBALF') THEN 
+          VAL = UDSCBT(5) 
+        ELSEIF(FLAG5.EQ.'MTALF') THEN 
+          VAL = UDSCBT(6) 
+        ELSEIF(FLAG5.EQ.'ALFAS') THEN 
+          VAL = ALPHA0 
+        ELSEIF(FLAG5.EQ.'ALFQ0') THEN 
+          VAL = Q0ALFA 
+        ELSEIF(FLAG5.EQ.'TCHRM') THEN 
+          VAL = THRS34 
+        ELSEIF(FLAG5.EQ.'TBOTT') THEN 
+          VAL = THRS45 
+        ELSEIF(FLAG5.EQ.'XMINC') THEN 
+          VAL = XMICUT 
+        ELSEIF(FLAG5.EQ.'QMINC') THEN 
+          VAL = QMICUT 
+        ELSEIF(FLAG5.EQ.'QMAXC') THEN 
+          VAL = QMACUT 
+        ELSEIF(FLAG5.EQ.'ROOTS') THEN 
+          IF(RS2CUT.GE.0.) THEN 
+            VAL = SQRT(RS2CUT) 
+          ELSE 
+            VAL = RS2CUT 
+          ENDIF 
+        ELSEIF(FLAG5.EQ.'QMINA') THEN 
+          VAL = QMINAS 
+        ELSE 
+          IERR = 2 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!     ------                                                            
+           !                                                            
+      ELSE 
+!     ------                                                            
+                                                                        
+        IERR = 1 
+        GOTO 500 
+                                                                        
+!     -------                                                           
+            !                                                           
+      ENDIF 
+!     -------                                                           
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r QNRVAL ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input OPT : '',A    )') OPT 
+      WRITE(6,'( ''       VAR : '',A    )') FLAG 
+      WRITE(6,'( ''       VAL : '',E12.5)') RVAL 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' OPT should be either SET or GET '')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' Variable VAR not found'')') 
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' VAL should be .gt. 0  '')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('QNRVAL ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, QNRSET.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE QNRSET(FLAG,RVAL) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) FLAG 
+                                                                        
+      CALL QTRACE('QNRSET ',0) 
+                                                                        
+      CALL QNRVAL('SET',FLAG,RVAL) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNRGET.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE QNRGET(FLAG,RVAL) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) FLAG 
+                                                                        
+      CALL QTRACE('QNRGET ',0) 
+                                                                        
+      CALL QNRVAL('GET',FLAG,RVAL) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNLVAL.                                                     
+                                                                        
+!     ================================                                  
+      SUBROUTINE QNLVAL(OPT,FLAG,LVAL) 
+!     ================================                                  
+                                                                        
+!---  QNLVAL: set/get logical variable.                                 
+!---  Called by user or internally by s/r QNLSET and QNLGET.            
+!---  Input parameters: 'OPT'   = 'Set' or 'Get'.                       
+!---                    'FLAG'  = variable name to set or get.          
+!---                    'VAL' (logical) input or output variable.       
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) OPT 
+      CHARACTER*1   OPT1 
+      CHARACTER*(*) FLAG 
+      CHARACTER*5   FLAG5 
+      LOGICAL       LVAL 
+                                                                        
+                                                                        
+      COMMON/QCCONS/                                                    &
+     &PI,PROTON,EUTRON,UCLEON,UDSCBT(6),AAM2H,BBM2H,AAM2L,BBM2L,        &
+     &AAAR2,BBBR2,FL_FAC,CBMSTF(4:7),CHARGE(4:7),                       &
+     &C1S3,C2S3,C4S3,C5S3,C8S3,C11S3,C14S3,C16S3,C20S3,C22S3,C28S3,     &
+     &C38S3,C40S3,C44S3,C52S3,C136S3,C11S6,C2S9,C4S9,C10S9,C14S9,C16S9, &
+     &C40S9,C44S9,C62S9,C112S9,C182S9,C11S12,C35S18,C61S12,C215S1,      &
+     &C29S12,CPI2S3,CPIA,CPIB,CPIC,CPID,CPIE,CPIF,CCA,CCF,CTF,CATF,CFTF 
+                                                                        
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+                                                                        
+      IF(LENOCC_LHA(OPT).LT.1)  THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+      IF(LENOCC_LHA(FLAG).LT.5) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+      OPT1   = OPT(1:1) 
+      FLAG5  = FLAG(1:5) 
+      CALL CLTOU_LHA(OPT1) 
+      CALL CLTOU_LHA(FLAG5) 
+                                                                        
+!     ----------------------                                            
+                           !                                            
+      IF(OPT1.EQ.'S') THEN 
+!     ----------------------                                            
+                                                                        
+        IF    (FLAG5.EQ.'W1ANA' ) THEN 
+          LW1ANA = LVAL 
+          IF(LW1ANA) LW1NUM = .FALSE. 
+        ELSEIF(FLAG5.EQ.'W1NUM' ) THEN 
+          LW1NUM = LVAL 
+          IF(LW1NUM) LW1ANA = .FALSE. 
+        ELSEIF(FLAG5.EQ.'W2NUM' ) THEN 
+          LW2NUM = LVAL 
+        ELSEIF(FLAG5.EQ.'W2STF' ) THEN 
+          LW2STF = LVAL 
+        ELSEIF(FLAG5.EQ.'WTF2C' ) THEN 
+          LWF2C  = LVAL 
+        ELSEIF(FLAG5.EQ.'WTFLC' ) THEN 
+          LWFLC  = LVAL 
+        ELSEIF(FLAG5.EQ.'WTF2B' ) THEN 
+          LWF2B  = LVAL 
+        ELSEIF(FLAG5.EQ.'WTFLB' ) THEN 
+          LWFLB  = LVAL 
+        ELSEIF(FLAG5.EQ.'BMARK' ) THEN 
+          LBMARK = LVAL 
+          LALFOK = .FALSE. 
+        ELSEIF(FLAG5.EQ.'LIMCK' ) THEN 
+          LIMCK  = LVAL 
+        ELSEIF(FLAG5.EQ.'CLOWQ' ) THEN 
+          LCLOWQ = LVAL 
+        ELSEIF(FLAG5.EQ.'ASOLD' ) THEN 
+          LASOLD = LVAL 
+          LALFOK = .FALSE. 
+        ELSE 
+          IERR = 2 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!     --------------------------                                        
+                               !                                        
+      ELSEIF(OPT1.EQ.'G') THEN 
+!     --------------------------                                        
+                                                                        
+        IF    (FLAG5.EQ.'W1ANA' ) THEN 
+          LVAL = LW1ANA 
+        ELSEIF(FLAG5.EQ.'W1NUM' ) THEN 
+          LVAL = LW1NUM 
+        ELSEIF(FLAG5.EQ.'W2NUM' ) THEN 
+          LVAL = LW2NUM 
+        ELSEIF(FLAG5.EQ.'W2STF' ) THEN 
+          LVAL = LW2STF 
+        ELSEIF(FLAG5.EQ.'WTF2C' ) THEN 
+          LVAL = LWF2C 
+        ELSEIF(FLAG5.EQ.'WTFLC' ) THEN 
+          LVAL = LWFLC 
+        ELSEIF(FLAG5.EQ.'WTF2B' ) THEN 
+          LVAL = LWF2B 
+        ELSEIF(FLAG5.EQ.'WTFLB' ) THEN 
+          LVAL = LWFLB 
+        ELSEIF(FLAG5.EQ.'BMARK' ) THEN 
+          LVAL = LBMARK 
+        ELSEIF(FLAG5.EQ.'LIMCK' ) THEN 
+          LVAL = LIMCK 
+        ELSEIF(FLAG5.EQ.'CLOWQ' ) THEN 
+          LVAL = LCLOWQ 
+        ELSEIF(FLAG5.EQ.'ASOLD' ) THEN 
+          LVAL = LASOLD 
+        ELSE 
+          IERR = 2 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!     ------                                                            
+           !                                                            
+      ELSE 
+!     ------                                                            
+                                                                        
+        IERR = 1 
+        GOTO 500 
+                                                                        
+!     -------                                                           
+            !                                                           
+      ENDIF 
+!     -------                                                           
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r QNLVAL ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input OPT : '',A    )') OPT 
+      WRITE(6,'( ''       VAR : '',A    )') FLAG 
+      WRITE(6,'( ''       VAL : '',L2   )') LVAL 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' OPT should be either SET or GET '')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' Variable VAR not found'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('QNLVAL ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, QNLSET.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE QNLSET(FLAG,LVAL) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) FLAG 
+      LOGICAL       LVAL 
+                                                                        
+      CALL QTRACE('QNLSET ',0) 
+                                                                        
+      CALL QNLVAL('SET',FLAG,LVAL) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, QNLGET.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE QNLGET(FLAG,LVAL) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      CHARACTER*(*) FLAG 
+      LOGICAL       LVAL 
+                                                                        
+      CALL QTRACE('QNLGET ',0) 
+                                                                        
+      CALL QNLVAL('GET',FLAG,LVAL) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, GRMXMQ.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE GRMXMQ(NXMA,NQMA) 
+!     ============================                                      
+                                                                        
+!---  GRMXMQ: return max allowed number of x, Q2 gridpoints.            
+!---  Called by user.                                                   
+!---  MXX and MQ2 are set by parameter statement in common QCNXQM.      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      CALL QTRACE('GRMXMQ ',0) 
+                                                                        
+      NXMA = MXX-1 
+      NQMA = MQ2-1 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, GRGIVE.                                                     
+                                                                        
+!     ========================================                          
+      SUBROUTINE GRGIVE(NX,XMI,XMA,NQ,QMI,QMA) 
+!     ========================================                          
+                                                                        
+!---  GRGIVE: return current grid definition.                           
+!---  Called by user.                                                   
+!---  Output variables: NX  (integer) number of x gridpoints.           
+!---                    XMI (real or d.p.) lowest x value.              
+!---                    XMA (real or d.p.) highest x value = 1.         
+!---                    NQ  (integer) number of Q2 gridpoints.          
+!---                    QMI (real or d.p.) lowest Q2 value.             
+!---                    QMA (real or d.p.) highest Q2 value.            
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      CALL QTRACE('GRGIVE ',0) 
+                                                                        
+      NX  = NXX 
+      XMI = XXTAB(1) 
+      XMA = XXTAB(NXX+1) 
+      NQ  = NQ2 
+      QMI = Q2TAB(1) 
+      QMA = Q2TAB(NQ2) 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, GRXNUL.                                                     
+                                                                        
+!     =================                                                 
+      SUBROUTINE GRXNUL 
+!     =================                                                 
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      CALL QTRACE('GRXNUL ',0) 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LWT1OK = .FALSE. 
+      LWT2OK = .FALSE. 
+      LWTFOK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+!---  Set grid to zero                                                  
+      CALL QNVNUL(XXTAB,MXX) 
+      CALL QNVNUL(XHTAB,MXX) 
+      CALL QNINUL(IHTAB,MXX) 
+      NXX    = 0 
+      NGRVER = 0 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, GRXINP.                                                     
+                                                                        
+!     ============================                                      
+      SUBROUTINE GRXINP(XARRAY,NX) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      DIMENSION XARRAY(*) 
+                                                                        
+      DATA EPSI /1.E-6/ 
+                                                                        
+      CALL QTRACE('GRXINP ',0) 
+                                                                        
+      IF(NX.LE.0) THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF((NX+NXX).GT.MXX-1) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LWT1OK = .FALSE. 
+      LWT2OK = .FALSE. 
+      LWTFOK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+!---  if this number changes, QCDNUM knows that the grid has changed    
+      NGRVER = NGRVER + 1 
+                                                                        
+      IF(NXX.EQ.0) THEN 
+        DO 10 IX = 1,NX 
+          X = XARRAY(IX) 
+          IF(X.LE.0..OR.X.GT.1.) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+          NXX    = NXX+1 
+          XXTAB(IX) = X 
+   10   CONTINUE 
+        IF(XXTAB(NXX).EQ.1.) THEN 
+          NXX = NXX-1 
+        ELSE 
+          XXTAB(NXX+1) = 1. 
+        ENDIF 
+        RETURN 
+      ENDIF 
+                                                                        
+      IF(XXTAB(NXX).EQ.1.) THEN 
+        NXX = NXX-1 
+      ELSE 
+        XXTAB(NXX+1) = 1. 
+      ENDIF 
+                                                                        
+      NXP = NXX+1 
+                                                                        
+      DO 100 IX = 1,NX 
+                                                                        
+        X = XARRAY(IX) 
+                                                                        
+        IF(X.LE.0..OR.X.GT.1.) THEN 
+          IERR = 3 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!mb     IF(X.LT.XXTAB(1)-EPSI) THEN                                     
+        IF(X/XXTAB(1).LT.1.-EPSI) THEN 
+                                                                        
+          DO 20 JX = NXP,1,-1 
+            XXTAB(JX+1) = XXTAB(JX) 
+   20     CONTINUE 
+          NXP    = NXP+1 
+          XXTAB(1)  = X 
+                                                                        
+!mb     ELSEIF(X.GT.XXTAB(NXP)+EPSI) THEN                               
+        ELSEIF(X/XXTAB(NXP).GT.1.+EPSI) THEN 
+                                                                        
+          NXP    = NXP+1 
+          XXTAB(NXP) = X 
+                                                                        
+        ELSE 
+                                                                        
+          DO 30 I = 1,NXP 
+!mb         IF(XXTAB(I).LE.X+EPSI) IX0 = I                              
+            IF(XXTAB(I)/X.LE.1.+EPSI) IX0 = I 
+   30     CONTINUE 
+                                                                        
+!mb       IF(ABS(XXTAB(IX0)-X).LE.EPSI) THEN                            
+          IF(ABS(XXTAB(IX0)/X-1.).LE.EPSI) THEN 
+            XXTAB(IX0) = X 
+          ELSE 
+            DO 40 JX = NXP,IX0+1,-1 
+              XXTAB(JX+1) = XXTAB(JX) 
+   40       CONTINUE 
+            NXP = NXP+1 
+            XXTAB(IX0+1) = X 
+          ENDIF 
+                                                                        
+        ENDIF 
+                                                                        
+  100 END DO 
+                                                                        
+      IF(XXTAB(NXP).EQ.1.) THEN 
+        NXX = NXP-1 
+      ELSE 
+        NXX = NXP 
+        XXTAB(NXX+1) = 1. 
+      ENDIF 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+!---  Update heavy quark xgrid                                          
+      CALL GXHDEF 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r GRXINP ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input X  :'',E12.5)') X 
+      WRITE(6,'( ''       NX :'',I5   )') NX 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' NX must be .ge. 1'')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' Maximum number of gridpoints exceeded '')') 
+        WRITE(6,'(/'' # existing x  gridpoints ='',I5/                  &
+     &             '' # points to be added     ='',I5/                  &
+     &             '' maximum # points allowed ='',I5)')                &
+     &                NXX, NX, MXX-1                                    
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' Value of X outside allowed range (0,1]'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('GRXINP ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, GRXDEF.                                                     
+                                                                        
+!     ==========================                                        
+      SUBROUTINE GRXDEF(NX,XMIN) 
+!     ==========================                                        
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      CALL QTRACE('GRXDEF ',0) 
+                                                                        
+      IF(NX.LE.0) THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF(NX.GT.MXX-1) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF(XMIN.LE.0.OR.XMIN.GE.1.) THEN 
+        IERR = 3 
+        GOTO 500 
+      ENDIF 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LWT1OK = .FALSE. 
+      LWT2OK = .FALSE. 
+      LWTFOK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+!---  if this number changes, QCDNUM knows that the grid has changed    
+      NGRVER = NGRVER + 1 
+                                                                        
+      XMAX = 1. 
+      YMIN = SYFROMX(XMIN) 
+      YMAX = SYFROMX(XMAX) 
+      BW   = (YMAX-YMIN)/NX 
+      DO I = 1,NX 
+        YI = YMIN+(I-1)*BW 
+        XXTAB(I) = SXFROMY(YI) 
+      ENDDO 
+      XXTAB(1)    = XMIN 
+      XXTAB(NX+1) = 1. 
+      NXX         = NX 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+!---  Update heavy quark xgrid                                          
+      CALL GXHDEF 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r GRXDEF ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input NX    :'',I5   )') NX 
+      WRITE(6,'( ''       Xmin  :'',E12.5)') XMIN 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' NX must be .ge. 1'')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' NX > max number of gridpoints'',                  &
+     &             '' allowed:'',I5)') MXX-1                            
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' Xmin outside allowed range (0,1]'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('GRXDEF ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, GRXLIM.                                                     
+                                                                        
+!     ==========================                                        
+      SUBROUTINE GRXLIM(NX,XMIN) 
+!     ==========================                                        
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      DATA EPSI / 1.E-6 / 
+                                                                        
+      CALL QTRACE('GRXLIM ',0) 
+                                                                        
+      IF(NX.LE.0) THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF(NX.GT.MXX-1) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LWT1OK = .FALSE. 
+      LWT2OK = .FALSE. 
+      LWTFOK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+      IF(XMIN.LE.0.OR.XMIN.GE.1.) THEN 
+        IERR = 3 
+        GOTO 500 
+      ENDIF 
+                                                                        
+!---  if this number changes, QCDNUM knows that the grid has changed    
+      NGRVER = NGRVER + 1 
+                                                                        
+      IF(NXX.EQ.0) THEN 
+        XXTAB(1) = 1. 
+      ELSEIF(XXTAB(NXX).EQ.1.) THEN 
+        NXX = NXX-1 
+      ELSE 
+        XXTAB(NXX+1) = 1. 
+      ENDIF 
+                                                                        
+      NXP = NXX+1 
+                                                                        
+!mb   IF(XMIN.LT.XXTAB(1)-EPSI) THEN                                    
+      IF(XMIN/XXTAB(1).LT.1.-EPSI) THEN 
+        DO 20 IX = NXP,1,-1 
+          XXTAB(IX+1) = XXTAB(IX) 
+   20   CONTINUE 
+        NXP   = NXP+1 
+        XXTAB(1) = XMIN 
+      ENDIF 
+                                                                        
+      IF(NX.GT.NXP-1) THEN 
+   30   CONTINUE 
+        GAPMAX = 0. 
+        DO 35 IX = 1,NXP-1 
+          GAP = SYFROMX(XXTAB(IX+1))-SYFROMX(XXTAB(IX)) 
+          IF(GAP.GT.GAPMAX) THEN 
+            GAPMAX = GAP 
+            IX0    = IX 
+          ENDIF 
+   35   CONTINUE 
+        DO 40 IX = NXP,IX0+1,-1 
+          XXTAB(IX+1) = XXTAB(IX) 
+   40   CONTINUE 
+        NXP = NXP+1 
+        XXTAB(IX0+1) = 0.5*(XXTAB(IX0)+XXTAB(IX0+2)) 
+        IF(NXP-1.LT.NX) GOTO 30 
+                                                                        
+      ELSEIF(NX.LT.NXP-1) THEN 
+   50   CONTINUE 
+        GAPMIN = 999999. 
+        DO 55 IX = 2,NXP-1 
+          GAP = SYFROMX(XXTAB(IX+1))-SYFROMX(XXTAB(IX-1)) 
+          IF(GAP.LE.GAPMIN) THEN 
+            GAPMIN = GAP 
+            IX0    = IX 
+          ENDIF 
+   55   CONTINUE 
+        DO 60 IX = IX0,NXP-1 
+          XXTAB(IX) = XXTAB(IX+1) 
+   60   CONTINUE 
+        XXTAB(NXP) = 0. 
+        NXP = NXP-1 
+        IF(NXP-1.GT.NX) GOTO 50 
+      ENDIF 
+                                                                        
+      IF(XXTAB(NXP).EQ.1.) THEN 
+        NXX = NXP-1 
+      ELSE 
+        NXX = NXP 
+        XXTAB(NXX+1) = 1. 
+      ENDIF 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+!---  Update heavy quark xgrid                                          
+      CALL GXHDEF 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r GRXLIM ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input NX    :'',I5   )') NX 
+      WRITE(6,'( ''       Xmin  :'',E12.5)') XMIN 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' NX must be .ge. 1'')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' NX > max number of gridpoints'',                  &
+     &             '' allowed:'',I5)') MXX-1                            
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' Xmin outside allowed range (0,1]'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('GRXLIM ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, GXHDEF.                                                     
+                                                                        
+!     =================                                                 
+      SUBROUTINE GXHDEF 
+!     =================                                                 
+                                                                        
+!--   Create a purely logarithmic grid in x (XHTAB) for use             
+!--   in the heavy quark structure function calculations.               
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      IF(NXX.EQ.0.OR.NXX.GE.MXX)           RETURN 
+      IF(XXTAB(1).LE.0..OR.XXTAB(1).GE.1.) RETURN 
+                                                                        
+      XL1 = LOG(XXTAB(1)) 
+      XL2 = 0. 
+      BW  = (XL2-XL1)/NXX 
+                                                                        
+      DO IX = 1,NXX 
+        XL = XL1 + (IX-1)*BW 
+        XHTAB(IX) = EXP(XL) 
+        IHTAB(IX) = ABS(IXFROMX(XHTAB(IX))) 
+      ENDDO 
+      XHTAB(NXX+1) = 1. 
+      IHTAB(NXX+1) = NXX+1 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+                                                                        
+!DECK  ID>, SYFROMX.                                                    
+                                                                        
+!     ====================================                              
+      DOUBLE PRECISION FUNCTION SYFROMX(X) 
+!     ====================================                              
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      IF(X.LE.SCAX0) THEN 
+        SYFROMX = LOG(X) 
+      ELSE 
+        SYFROMX = LOG(SCAX0) + (X-SCAX0)/SCAX0 
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, SXFROMY.                                                    
+                                                                        
+!     ====================================                              
+      DOUBLE PRECISION FUNCTION SXFROMY(Y) 
+!     ====================================                              
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      IF(Y.LE.LOG(SCAX0)) THEN 
+        SXFROMY = EXP(Y) 
+      ELSE 
+        SXFROMY = (Y-LOG(SCAX0)+1.) * SCAX0 
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, GRXOUT.                                                     
+                                                                        
+!     =========================                                         
+      SUBROUTINE GRXOUT(XARRAY) 
+!     =========================                                         
+                                                                        
+!---  Copy XXTAB to XARRAY which should have been dimensioned           
+!---  to at least NXX+1 by the user.                                    
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      DIMENSION XARRAY(*) 
+                                                                        
+      CALL QTRACE('GRXOUT ',0) 
+                                                                        
+      DO 10 IX = 1,NXX+1 
+        XARRAY(IX) = XXTAB(IX) 
+   10 END DO 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, LOGXGR.                                                     
+                                                                        
+!     ===============================                                   
+      LOGICAL FUNCTION LOGXGR(IDUMMY) 
+!     ===============================                                   
+                                                                        
+!---  Figure out if xgrid is purely logarithmic                         
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+      REAL    RAT1,RAT 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      LOGXGR = .FALSE. 
+                                                                        
+      IF(NXX.LE.0) RETURN 
+                                                                        
+      RAT1   = XXTAB(2)/XXTAB(1) 
+      LOGXGR = .TRUE. 
+      DO IX = 1,NXX 
+        RAT = XXTAB(IX+1)/XXTAB(IX) 
+        IF(RAT.NE.RAT1) LOGXGR = .FALSE. 
+      ENDDO 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, GRQNUL.                                                     
+                                                                        
+!     =================                                                 
+      SUBROUTINE GRQNUL 
+!     =================                                                 
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      CALL QTRACE('GRQNUL ',0) 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LALFOK = .FALSE. 
+      LDQ2OK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+!---  Set grid to zero                                                  
+      CALL QNVNUL(Q2TAB,MQ2) 
+      NQ2    = 0 
+      NGRVER = 0 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, GRQINP.                                                     
+!                                                                       
+!     ============================                                      
+      SUBROUTINE GRQINP(QARRAY,NQ) 
+!     ============================                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      DIMENSION QARRAY(*) 
+                                                                        
+      DATA EPSI /1.E-6/ 
+                                                                        
+      CALL QTRACE('GRQINP ',0) 
+                                                                        
+      IF(NQ.LE.0) THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF((NQ+NQ2).GT.MQ2-1) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LALFOK = .FALSE. 
+      LDQ2OK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+!---  if this number changes, QCDNUM knows that the grid has changed    
+      NGRVER = NGRVER + 1 
+                                                                        
+      IF(NQ2.EQ.0) THEN 
+        DO 10 IQ = 1,NQ 
+          Q = QARRAY(IQ) 
+          IF(Q.LE.0.) THEN 
+            IERR = 3 
+            GOTO 500 
+          ENDIF 
+          NQ2    = NQ2+1 
+          Q2TAB(IQ) = Q 
+   10   CONTINUE 
+        RETURN 
+      ENDIF 
+                                                                        
+      DO 100 IQ = 1,NQ 
+                                                                        
+        Q = QARRAY(IQ) 
+                                                                        
+        IF(Q.LE.0.) THEN 
+          IERR = 3 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!mb     IF(Q.LT.Q2TAB(1)-EPSI) THEN                                     
+        IF(Q/Q2TAB(1).LT.1.-EPSI) THEN 
+                                                                        
+          DO 20 JQ = NQ2,1,-1 
+            Q2TAB(JQ+1) = Q2TAB(JQ) 
+   20     CONTINUE 
+          NQ2    = NQ2+1 
+          Q2TAB(1)  = Q 
+                                                                        
+!mb     ELSEIF(Q.GT.Q2TAB(NQ2)+EPSI) THEN                               
+        ELSEIF(Q/Q2TAB(NQ2).GT.1.+EPSI) THEN 
+                                                                        
+          NQ2    = NQ2+1 
+          Q2TAB(NQ2) = Q 
+                                                                        
+        ELSE 
+                                                                        
+          DO 30 I = 1,NQ2 
+!mb         IF(Q2TAB(I).LE.Q+EPSI) IQ0 = I                              
+            IF(Q2TAB(I)/Q.LE.1.+EPSI) IQ0 = I 
+   30     CONTINUE 
+                                                                        
+!mb       IF(ABS(Q2TAB(IQ0)-Q).LE.EPSI) THEN                            
+          IF(ABS(Q2TAB(IQ0)/Q-1.).LE.EPSI) THEN 
+            Q2TAB(IQ0) = Q 
+          ELSE 
+            DO 40 JQ = NQ2,IQ0+1,-1 
+              Q2TAB(JQ+1) = Q2TAB(JQ) 
+   40       CONTINUE 
+            NQ2 = NQ2+1 
+            Q2TAB(IQ0+1) = Q 
+          ENDIF 
+                                                                        
+        ENDIF 
+                                                                        
+  100 END DO 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r GRQINP ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input Q2 :'',E12.5)') Q 
+      WRITE(6,'( ''       NQ :'',I5   )') NQ 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' NQ must be .ge. 1'')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' Maximum number of gridpoints exceeded '')') 
+        WRITE(6,'(/'' # existing Q2 gridpoints ='',I5/                  &
+     &             '' # points to be added     ='',I5/                  &
+     &             '' maximum # points allowed ='',I5)')                &
+     &                NQ2, NQ, MQ2-1                                    
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' Value of Q2 outside allowed range > 0'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('GRQINP ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, GRQDEF.                                                     
+                                                                        
+!     ===============================                                   
+      SUBROUTINE GRQDEF(NQ,QMIN,QMAX) 
+!     ===============================                                   
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      CALL QTRACE('GRQDEF ',0) 
+                                                                        
+      IF(NQ.LE.1) THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF(NQ.GT.MQ2-1) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF(QMIN.LE.0.OR.QMAX.LE.0.OR.QMIN.GE.QMAX) THEN 
+        IERR = 3 
+        GOTO 500 
+      ENDIF 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LALFOK = .FALSE. 
+      LDQ2OK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+!---  if this number changes, QCDNUM knows that the grid has changed    
+      NGRVER = NGRVER + 1 
+                                                                        
+      YMIN = SYFROMQ(QMIN) 
+      YMAX = SYFROMQ(QMAX) 
+      BW   = (YMAX-YMIN)/(NQ-1) 
+      DO I = 1,NQ 
+        YI = YMIN+(I-1)*BW 
+        Q2TAB(I) = SQFROMY(YI) 
+      ENDDO 
+      Q2TAB(1)  = QMIN 
+      Q2TAB(NQ) = QMAX 
+      NQ2       = NQ 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r GRQDEF ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input NQ    :'',I5   )') NQ 
+      WRITE(6,'( ''       Q2min :'',E12.5)') QMIN 
+      WRITE(6,'( ''       Q2max :'',E12.5)') QMAX 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' NQ must be .ge. 2'')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' NQ > max number of gridpoints'',                  &
+     &             '' allowed:'',I5)') MQ2-1                            
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' Qmin and/or Qmax .le. 0 or Qmin .ge. Qmax'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('GRQDEF ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, GRQLIM.                                                     
+                                                                        
+!     ===============================                                   
+      SUBROUTINE GRQLIM(NQ,QMIN,QMAX) 
+!     ===============================                                   
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+      LOGICAL                                                           &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL,LASOLD                                                     
+                                                                        
+      COMMON/QCFLAG/                                                    &
+     &IORD,IOLAST,                                                      &
+     &LDOUBL,LBMARK,LWF2C,LWF2B,LWFLC,LWFLB,                            &
+     &LW1ANA,LW1NUM,LW2NUM,LW2STF,LIMCK,LPLUS,                          &
+     &LALFOK,LDQ2OK,LWT1OK,LWT2OK,                                      &
+     &LWTFOK,LWFCOK,LWLCOK,LWFBOK,LWLBOK,LMARK,LCLOWQ,                  &
+     &LFFCAL(7,30),LASOLD                                               
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      COMMON/QCPASS/                                                    &
+     &ALPHA0, Q0ALFA, ASLAST, QALAST,                                   &
+     &ALFASQ(MQ2), ALFAPQ(MQ2), ALFA2Q(MQ2),                            &
+     &DELUP(MQ2), DELDN(MQ2), PDFQCD(MXX,MQ2,0:10),                     &
+     &FNSQCD(MXX,MQ2),DNSQCD(MXX,MQ2),                                  &
+     &FSIQCD(MXX,MQ2),DSIQCD(MXX,MQ2),                                  &
+     &FGLQCD(MXX,MQ2),DGGQCD(MXX,MQ2),                                  &
+     &FSTORE(MXX,MQ2,31:30+NDFMAX),IDFAST(7,30),NDFAST,                 &
+     &MARKFF(MXX,MQ2),MARKFH(MXX,MQ2),MARKQQ(MQ2),                      &
+     &ISTFID(31:30+NDFMAX),IPDFID(31:30+NDFMAX),IEALFA(MQ2),            &
+     &IQL_LAST(10),IQ0_LAST(10),IQH_LAST(10)                            
+                                                                        
+      LOGICAL LEVDONE,LE_DONE 
+      COMMON/QCLEVL/                                                    &
+     &LEVDONE(MXX,10),LE_DONE(MXX)                                      
+                                                                        
+                                                                        
+      DATA EPSI /1.E-6/ 
+                                                                        
+      CALL QTRACE('GRQLIM ',0) 
+                                                                        
+      IF(NQ.LE.0) THEN 
+        IERR = 1 
+        GOTO 500 
+      ENDIF 
+                                                                        
+      IF(NQ.GT.MQ2-1) THEN 
+        IERR = 2 
+        GOTO 500 
+      ENDIF 
+                                                                        
+!---  Invalidate weight tables (validated by call to QNFILW)            
+      LALFOK = .FALSE. 
+      LDQ2OK = .FALSE. 
+      LWFCOK = .FALSE. 
+      LWLCOK = .FALSE. 
+      LWFBOK = .FALSE. 
+      LWLBOK = .FALSE. 
+      LMARK  = .FALSE. 
+!--   Invalidate all evolutions                                         
+      CALL QNFALS(LEVDONE,MXX*10) 
+                                                                        
+!---  if this number changes, QCDNUM knows that the grid has changed    
+      NGRVER = NGRVER + 1 
+                                                                        
+      IF(NQ2.EQ.0) THEN 
+                                                                        
+        IF(QMIN.LE.0..OR.QMAX.LE.0..OR.QMIN.GE.QMAX) THEN 
+          IERR = 3 
+          GOTO 500 
+        ENDIF 
+                                                                        
+        CALL GRQDEF(NQ,QMI,QMA) 
+                                                                        
+      ELSE 
+                                                                        
+        IF(QMIN.LE.0..OR.QMAX.LE.0..OR.QMIN.GE.QMAX) THEN 
+          IERR = 3 
+          GOTO 500 
+        ENDIF 
+                                                                        
+!mb     IF(QMIN.LT.Q2TAB(1)-EPSI) THEN                                  
+        IF(QMIN/Q2TAB(1).LT.1.-EPSI) THEN 
+          DO 20 IQ = NQ2,1,-1 
+            Q2TAB(IQ+1) = Q2TAB(IQ) 
+   20     CONTINUE 
+          NQ2      = NQ2+1 
+          Q2TAB(1) = QMIN 
+        ENDIF 
+!mb     IF(QMAX.GT.Q2TAB(NQ2)+EPSI) THEN                                
+        IF(QMAX/Q2TAB(NQ2).GT.1.+EPSI) THEN 
+          NQ2        = NQ2+1 
+          Q2TAB(NQ2) = QMAX 
+        ENDIF 
+                                                                        
+        IF(NQ.GT.NQ2) THEN 
+   30     CONTINUE 
+          GAPMAX = 0. 
+          DO 35 IQ = 1,NQ2-1 
+            GAP = SYFROMQ(Q2TAB(IQ+1))-SYFROMQ(Q2TAB(IQ)) 
+            IF(GAP.GT.GAPMAX) THEN 
+              GAPMAX = GAP 
+              IQ0    = IQ 
+            ENDIF 
+   35     CONTINUE 
+          DO 40 IQ = NQ2,IQ0+1,-1 
+            Q2TAB(IQ+1) = Q2TAB(IQ) 
+   40     CONTINUE 
+          NQ2 = NQ2+1 
+          Q2TAB(IQ0+1) = SQRT(Q2TAB(IQ0)*Q2TAB(IQ0+2)) 
+          IF(NQ2.LT.NQ) GOTO 30 
+                                                                        
+        ELSEIF(NQ.LT.NQ2) THEN 
+   50     CONTINUE 
+          GAPMIN = 999999. 
+          DO 55 IQ = 2,NQ2-1 
+            GAP = SYFROMQ(Q2TAB(IQ+1))-SYFROMQ(Q2TAB(IQ-1)) 
+            IF(GAP.LE.GAPMIN) THEN 
+              GAPMIN = GAP 
+              IQ0    = IQ 
+            ENDIF 
+   55     CONTINUE 
+          DO 60 IQ = IQ0,NQ2-1 
+            Q2TAB(IQ) = Q2TAB(IQ+1) 
+   60     CONTINUE 
+          Q2TAB(NQ2) = 0. 
+          NQ2 = NQ2-1 
+          IF(NQ2.GT.NQ) GOTO 50 
+        ENDIF 
+                                                                        
+      ENDIF 
+                                                                        
+!---  Update IFAILC                                                     
+      CALL GRSETC 
+                                                                        
+!---  Update NFMAP                                                      
+      CALL QNSETT 
+                                                                        
+      RETURN 
+                                                                        
+  500 CONTINUE 
+                                                                        
+      WRITE(6,'(/'' ------------------------------------'')') 
+      WRITE(6,'( '' QCDNUM error in s/r GRQLIM ---> STOP'')') 
+      WRITE(6,'( '' ------------------------------------'')') 
+      WRITE(6,'( '' Input NQ    :'',I5   )') NQ 
+      WRITE(6,'( ''       Q2min :'',E12.5)') QMIN 
+      WRITE(6,'( ''       Q2max :'',E12.5)') QMAX 
+      IF(IERR.EQ.1) THEN 
+        WRITE(6,'(/'' NQ must be .ge. 1'')') 
+      ELSEIF(IERR.EQ.2) THEN 
+        WRITE(6,'(/'' NQ > max number of gridpoints'',                  &
+     &             '' allowed:'',I5)') MQ2-1                            
+      ELSEIF(IERR.EQ.3) THEN 
+        WRITE(6,'(/'' Qmin and/or Qmax .le. 0 or Qmin .ge. Qmax'')') 
+      ENDIF 
+                                                                        
+      CALL QTRACE('GRQLIM ',1) 
+                                                                        
+      STOP 
+                                                                        
+      END                                           
+                                                                        
+!DECK  ID>, SYFROMQ.                                                    
+                                                                        
+!     ====================================                              
+      DOUBLE PRECISION FUNCTION SYFROMQ(Q) 
+!     ====================================                              
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      IF(Q.LE.SCAQ0) THEN 
+        SYFROMQ = LOG(Q) 
+      ELSE 
+        SYFROMQ = LOG(SCAQ0) + (Q-SCAQ0)/SCAQ0 
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, SQFROMY.                                                    
+                                                                        
+!     ====================================                              
+      DOUBLE PRECISION FUNCTION SQFROMY(Y) 
+!     ====================================                              
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      IF(Y.LE.LOG(SCAQ0)) THEN 
+        SQFROMY = EXP(Y) 
+      ELSE 
+        SQFROMY = (Y-LOG(SCAQ0)+1.) * SCAQ0 
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+                                                                        
+!DECK  ID>, GRQOUT.                                                     
+                                                                        
+!     =========================                                         
+      SUBROUTINE GRQOUT(QARRAY) 
+!     =========================                                         
+                                                                        
+!---  Copy Q2TAB to QARRAY which should have been dimensioned           
+!---  to at least NQ2 by the user.                                      
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      DIMENSION QARRAY(*) 
+                                                                        
+      CALL QTRACE('GRQOUT ',0) 
+                                                                        
+      DO 10 IQ = 1,NQ2 
+        QARRAY(IQ) = Q2TAB(IQ) 
+   10 END DO 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!DECK  ID>, IXFROMX.                                                    
+                                                                        
+!     ===========================                                       
+      INTEGER FUNCTION IXFROMX(X) 
+!     ===========================                                       
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+!---  Returns gridindex IX given a value for X.                         
+!---  If X is outside the current gridboundary then IXFROMX = 0.        
+!---  If X corresponds to gridindex IX  then IXFROMX = IX.              
+!---  If X lies above IX and below IX+1 then IXFROMX = -IX.             
+                                                                        
+!---  NB: X and XXTAB are different only if |X-XXTAB| < epsi.           
+!---  NB: If since the previous call the grid did not change            
+!---      (i.e. NGRVER is the same) and if X did not change, then       
+!---      IXFROMX just returns the result of the previous call.         
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      SAVE XLAST,IXLAST,NGLAST 
+                                                                        
+      DATA XLAST  / 0. / 
+      DATA IXLAST / 0 / 
+      DATA NGLAST / 0 / 
+      DATA EPSI   /1.E-6/ 
+                                                                        
+!     CALL QTRACE('IXFROMX',0)                                          
+                                                                        
+      IF(X.EQ.XLAST.AND.NGRVER.EQ.NGLAST) THEN 
+        IXFROMX = IXLAST 
+        RETURN 
+      ENDIF 
+                                                                        
+      IX      = 0 
+      IXLAST  = 0 
+      NGLAST  = NGRVER 
+      XLAST   = X 
+      IXFROMX = 0 
+                                                                        
+      IF(X.GT.1..OR.NXX.LE.0)   RETURN 
+      IF(X/XXTAB(1).LT.1.-EPSI) RETURN 
+                                                                        
+      DO 10 I = 1,NXX 
+!mb     IF(XXTAB(I).LE.X+EPSI) IX = I                                   
+        IF(XXTAB(I)/X.LE.1.+EPSI) IX = I 
+   10 END DO 
+                                                                        
+!mb   IF(ABS(XXTAB(IX)-X).LE.EPSI) THEN                                 
+      IF(ABS(XXTAB(IX)/X-1.).LE.EPSI) THEN 
+        IXFROMX = IX 
+        IXLAST  = IX 
+      ELSE 
+        IXFROMX = -IX 
+        IXLAST  = -IX 
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!------------------------------------------------                       
+                                                                        
+!-      REAL XR,X1,X2,XLAST                                             
+!-                                                                      
+!-+SEQ,QCNXQM.                                                          
+!-+SEQ,QCGRID.                                                          
+!-                                                                      
+!-      SAVE XLAST,IXLAST,NGLAST                                        
+!-                                                                      
+!-      DATA XLAST  / 0. /                                              
+!-      DATA IXLAST / 0 /                                               
+!-      DATA NGLAST / 0 /                                               
+!-                                                                      
+!-*     CALL QTRACE('IXFROMX',0)                                        
+!-                                                                      
+!-      XR = X                                                          
+!-      IF(XR.EQ.XLAST.AND.NGRVER.EQ.NGLAST) THEN                       
+!-        IXFROMX = IXLAST                                              
+!-        RETURN                                                        
+!-      ENDIF                                                           
+!-                                                                      
+!-      IX      = 0                                                     
+!-      IXLAST  = 0                                                     
+!-      NGLAST  = NGRVER                                                
+!-      XLAST   = X                                                     
+!-      IXFROMX = 0                                                     
+!-                                                                      
+!-      IF(XR.GT.1..OR.NXX.LE.0)   RETURN                               
+!-      X1 = XXTAB(1)                                                   
+!-      IF(XR.LT.X1)               RETURN                               
+!-                                                                      
+!-      DO IX = 1,NXX                                                   
+!-        X2 = XXTAB(IX+1)                                              
+!-        IF(X1.LE.XR.AND.XR.LT.X2) THEN                                
+!-          IXFROMX = -IX                                               
+!-          IF(X1.EQ.XR) IXFROMX = IX                                   
+!-          IXLAST = IX                                                 
+!-          RETURN                                                      
+!-        ENDIF                                                         
+!-        X1 = X2                                                       
+!-      ENDDO                                                           
+!-                                                                      
+!-      RETURN                                                          
+!-      END                                                             
+                                                                        
+!DECK  ID>, IHFROMH.                                                    
+                                                                        
+!     ===========================                                       
+      INTEGER FUNCTION IHFROMH(X) 
+!     ===========================                                       
+                                                                        
+      IMPLICIT DOUBLE PRECISION (A-H,O-Z) 
+                                                                        
+!---  Returns gridindex IX of heavy quark grid given a value for X.     
+!---  If X is outside the current gridboundary then IHFROMH = 0.        
+!---  If X corresponds to gridindex IX  then IHFROMH = IX.              
+!---  If X lies above IX and below IX+1 then IHFROMH = -IX.             
+                                                                        
+!---  NB: X and XHTAB are different only if |X-XHTAB| < epsi.           
+!---  NB: If since the previous call the grid did not change            
+!---      (i.e. NGRVER is the same) and if X did not change, then       
+!---      IHFROMH just returns the result of the previous call.         
+                                                                        
+#ifndef HERA                                                                        
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 120 )
+#else
+      PARAMETER ( MXX = 410 ) 
+      PARAMETER ( MQ2 = 205 )
+#endif       
+                                                                        
+!--   Do not set the following parameter to zero!                       
+      PARAMETER ( NDFMAX = 20) 
+                                                                        
+                                                                        
+      COMMON/QCGRID/                                                    &
+     &SCAX0,SCAQ0,XMICUT,QMICUT,QMACUT,RS2CUT,QMINAS,                   &
+     &XXTAB(MXX),Q2TAB(MQ2),XHTAB(MXX),THRS34,THRS45,                   &
+     &NXX,NQ2,NGRVER,IHTAB(MXX),NFMAP(MQ2),IQF2C(MQ2),                  &
+     &IQF2B(MQ2),IQFLC(MQ2),IQFLB(MQ2),IFAILC(MXX,MQ2)                  
+                                                                        
+                                                                        
+      SAVE XLAST,IXLAST,NGLAST 
+                                                                        
+      DATA XLAST  / 0. / 
+      DATA IXLAST / 0 / 
+      DATA NGLAST / 0 / 
+      DATA EPSI   /1.E-6/ 
+                                                                        
+!     CALL QTRACE('IHFROMH',0)                                          
+                                                                        
+      IF(X.EQ.XLAST.AND.NGRVER.EQ.NGLAST) THEN 
+        IHFROMH = IXLAST 
+        RETURN 
+      ENDIF 
+                                                                        
+      IX      = 0 
+      IXLAST  = 0 
+      NGLAST  = NGRVER 
+      XLAST   = X 
+      IHFROMH = 0 
+                                                                        
+      IF(X.GT.1..OR.NXX.LE.0)   RETURN 
+      IF(X/XHTAB(1).LT.1.-EPSI) RETURN 
+                                                                        
+      DO 10 I = 1,NXX 
+!mb     IF(XHTAB(I).LE.X+EPSI) IX = I                                   
+        IF(XHTAB(I)/X.LE.1.+EPSI) IX = I 
+   10 END DO 
+                                                                        
+!mb   IF(ABS(XHTAB(IX)-X).LE.EPSI) THEN                                 
+      IF(ABS(XHTAB(IX)/X-1.).LE.EPSI) THEN 
+        IHFROMH = IX 
+        IXLAST  = IX 
+      ELSE 
+        IHFROMH = -IX 
+        IXLAST  = -IX 
+      ENDIF 
+                                                                        
+      RETURN 
+      END                                           
+                                                                        
+!------------------------------------------------                       
+                                                                        
+!-      REAL XR,X1,X2,XLAST                                             
+!-                                                                      
+!-+SEQ,QCNXQM.                                                          
+!-+SEQ,QCGRID.                                                          
+!-                                                                      
+!-      SAVE XLAST,IXLAST,NGLAST                                        
+!-                                                                      
+!-      DATA XLAST  / 0. /                                              
+!-      DATA IXLAST / 0 /                                               
+!-      DATA NGLAST / 0 /                                               
+!-                                                                      
+!-*     CALL QTRACE('IXFROMX',0)            &nbs