      subroutine xc_partial(nfunctional,xcnrg,xcpota,xcpotb,dnstya,
     &                      dnstyb,dnstyt,gradxa,gradya,gradza,gradxb,
     &                      gradyb,gradzb,gradxt,gradyt,gradzt,dbdgama,
     &                      dbdgamb,dbdgamc)

c  this subroutine written by alain st-amant of the
c  department of chemistry, university of ottawa, ottawa, canada.
c  all rights reserved.  this is part of the DeFT project.

      implicit real*8(a-h,o-z)

      data small,expcut/1.0d-15,80.0d0/

      data zero,one,two,three,four,five,six,seven,dnine,eleven/
     &    0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,6.0d0,7.0d0,9.0d0,11.0d0/

      data third,threequarters,fourthirds,fivethirds/
     &    0.33333333333333d0,0.75d0,1.3333333333333d0,1.6666666666667d0/

      data pi,dnom,zetadnom,pialpha/
     &    3.1415926535898d0,5.1297633d0,0.519842099d0,1.636963801d0/

      data fperdew,cp1,cp2,cp3,cp4/
     &    0.11d0,0.023266d0,7.389d-06,8.723d0,0.472d0/

      data tenthousand,thirtythousand,cpa,cpb,cpc,cpd/
     &    10000.0d0,30000.0d0,0.001667d0,0.002568d0,1.745d0,0.004235d0/

      gmoda=sqrt(gradxa*gradxa+gradya*gradya+gradza*gradza)
      gmodb=sqrt(gradxb*gradxb+gradyb*gradyb+gradzb*gradzb)
      gmodt=sqrt(gradxt*gradxt+gradyt*gradyt+gradzt*gradzt)

      bvalue=zero
      dbdrhoa=zero
      dbdrhob=zero
      dbdgama=zero
      dbdgamb=zero
      dbdgamc=zero

      if(dnstyt.lt.small) goto 1001

      call becke_partial(dnstya,dnstyb,gmoda,gmodb,bvalue,
     &                   dbdrhoa,dbdrhob,dbdgama,dbdgamb)

      if(gmodt.lt.small) goto 1001

      call perdew_partial(dnstya,dnstyb,dnstyt,gmodt,bvalue,
     &                    dbdrhoa,dbdrhob,dbdgama,dbdgamb,dbdgamc)

 1001 continue

      xcnrg=xcnrg+bvalue

      xcpota=xcpota+dbdrhoa
      xcpotb=xcpotb+dbdrhob

      return
      end
