      Subroutine Pauli (ddinv,nch)
c *** see RH Landau, Program lpott, 1981
c     calculates modification of pi n denominator function from Pauli
c     author..a.w.thomas
      Implicit  Real*8   (a-h,o-z)
      Common /enpaul/ pf,ak,akd,cskkd,xi,e,xon
      Common /enint/ aa,bb,lPauli
      Common /deint/ ans
      Common /enqav/ xip
      Complex*16 ddinv,ci,ans
c     Complex cmplx
      logical lin,lxip,ldiff,lPauli,l1,l2
c
      data lin/.false./
      data eps1,eps2,eps1h,eps5,ci/0.1,0.01,0.05,0.00001,(0.0,1.0)/
      If (lin) GoTo 10
      lin = .true.
      ampi = 137.3/197.33
      amn = 938.91/197.33
      ampisq = ampi**2
c     card gone
      pi = 3.14159265
 10   Continue
c
c     calculate xip parameter...and carry out tests..
c     all momenta ,energies etc. in fm**-1
      xip = ak**2+akd**2+2.0*ak*akd*cskkd
      xip = xi*Sqrt(xip)/2.0
      lxip = .true.
      If (xip.lt.eps2) lxip = .false.
      diff = pf-xip
      ldiff = .true.
      If (abs(diff).lt.eps1) ldiff = .false.
      If (ldiff) GoTo 20
      GoTo 150
c
c     here we are gauranteed  reasonable size for diff...
 20   Continue
      If (diff.lt.0.0) GoTo 110
c
c     now there 2 corrn. integrals..
c      i.e. pf.gt.xip,and pf-xip gt eps2  (c.f. equ.(2) p10)
      lPauli = .false.
      aa = 0.0
      bb = diff
c         first check unlikely coincidence giving trouble..
      If (e.lt.0.0) GoTo 30
      If (abs(diff-xon).gt.eps5) GoTo 30
      print 230, diff,xon
      STOP
 30   Continue
      Call intgl (nch)
      ddinv = ans
c
c      now for second integral
      If (lxip) GoTo 40
      GoTo 60
c
c      here 2nd interval is gt =01.
 40   Continue
      aa = diff
      bb = pf+xip
      lPauli = .true.
c
c     unlikely coincidence&
      If (e.lt.0.0) GoTo 50
      If (abs(bb-xon).gt.eps5) GoTo 50
      print 240, bb,xon
      STOP
 50   Continue
      Call intgl (nch)
      GoTo 100
c
c       here xip is lt =01
 60   Continue
      If (e.lt.0.0) GoTo 90
      aa = diff
      bb = pf+xip
      l1 = xon.gt.aa
      l2 = xon.lt.bb
      If (abs(xon-bb).gt.eps5) GoTo 70
      print 250, xon,bb
      STOP
 70   Continue
      If (l1.and.l2) GoTo 80
      GoTo 90
c
c     here we have xon in interval of size lt =01---use appendix 1.
 80   Continue
      wpf = Sqrt(ampisq+pf**2)
      amu = wpf*amn/(amn+wpf)
      rans = amu*g(pf,nch)**2*pf/2.0
      ans = rans*log((xon-aa)/(bb-xon))
      ans = ans-ci*(rans*pi)
      GoTo 100
c
c     here the interval is lt =01 , but no singulariyt(appendix 1)
 90   Continue
      pfsq = pf**2
      wpf = Sqrt(ampisq+pfsq)
      epf = wpf-ampi+pfsq/(2.0*amn)
      rans = xip*pfsq*g(pf,nch)**2
      rans = rans/(e-epf)
      xzero=0.d0
      ans = cmplx(rans,xzero)
c
c       now put the 2 integrals together..
 100  Continue
      ddinv = ddinv+ans
      Return
c
c     this is the entry to part of Program dealing with xip.gt.pf..
 110  Continue
c     there is now only one integral(see equ. 4)
      aa = -diff
      bb = pf+xip
      If (pf.gt.eps2) GoTo 120
      print 260, pf
      STOP
 120  Continue
      If (e.lt.0.0) GoTo 140
      If (abs(xon-aa).gt.eps5) GoTo 130
      print 270, xon,aa
      STOP
 130  If (abs(xon-bb).gt.eps5) GoTo 140
      print 280, xon,bb
      STOP
c
 140  Continue
c     now there are no end pt. problems..
      lPauli = .true.
      Call intgl (nch)
      ddinv = ans
      Return
c
 150  Continue
c
c     come here onlt If /pf-xip/ lt .1
c      thus,if xip is small ,so ispf,and whole Pauli corrn is small..
      If (lxip) GoTo 160
c   ***                                                        *******
      ddinv = (0.0,0.0)
c   ***                                                        *******
      Return
 160  Continue
c     here neither xip nor pf is ridiculusly small..
      If (diff.gt.0.0) GoTo 170
      GoTo 200
c   ***                                                        *******
c     here pf gt xip. use equ. 2--once again neglect small interval..
c   ***                                                        *******
 170  Continue
      aa = diff
      bb = diff+2.0*xip
      lPauli = .true.
      If (e.lt.0.0) GoTo 180
      l1 = abs(xon-aa).lt.eps5
      l2 = abs(xon-bb).lt.eps5
      If (l1.or.l2) GoTo 190
 180  Continue
c
c     here there are no end pt problems
      Call intgl (nch)
      ddinv = ans
      Return
 190  print 290, xon,aa,bb
      STOP
c
 200  Continue
c     here xip.gt.pf..(equ. 4 )
      aa = -diff
      bb = -diff+2.0*pf
      lPauli = .true.
      If (e.lt.0.0) GoTo 210
      l1 = abs(xon-aa).lt.eps5
      l2 = abs(xon-bb).lt.eps5
      If (l1.or.l2) GoTo 220
 210  Continue
      Call intgl (nch)
      ddinv = ans
      Return
c
 220  print 300, xon,aa,bb
      STOP
c
 230  format (30h possible error in Pauli (15) ,2f20.8)
 240  format (18h Pauli error (35) ,2f20.8)
 250  format (19h Pauli error (105) ,2f20.8)
 260  format (17h Pauli error 305 ,f20.8)
 270  format (11h Pauli 315 ,2f20.8)
 280  format (11h Pauli 325 ,2f20.8)
 290  format (7h 560 = ,3f20.8)
 300  format (7h 660 = ,3f20.8)
      End
