C====EXCHANGE POTENTIAL IN HARTREE-FOCK==
C======== EQUATIONS======================
      SUBROUTINE EXCHAN(ALFA,BET,H,R1,
     *R2,R4,R5,R6,R8,ALM3,GAM,NE5,ISIGM,
     *IG,IQ,KK,ISIGM1,ISIGM2)
C==========================================
      REAL*8 ALFA,BET,H,R1(NE5),R2(NE5),P,R8(NE5,*),
     *R4(NE5),R5(NE5),R6(NE5),ALM3(1),GAM(1),GAMA
      INTEGER KK(1),ISIGM1(1),ISIGM2(1),IQ(1)
      NE=NE5-15
      IF(IG.LT.1) RETURN
      DO 3 IW=1,IG
      IA=0
      IF(ISIGM1(IW).EQ.ISIGM) IA=ISIGM2(IW)
      IF(ISIGM2(IW).EQ.ISIGM) IA=ISIGM1(IW)
      IF(IA.EQ. 0 ) GOTO 110
      CALL COLUMN(NE5,R8(1,IA),R5)
      DO 50 JJ=1,NE
      R6(JJ+1)=R5(JJ+2)*R2(JJ+2)
   50 CONTINUE
      CALL POT(ALFA,BET,H,R1,R6,KK(IW),NE5)
      GAMA=2.*GAM(IW)/(R5(2)*DFLOAT(IQ(ISIGM)))
      DO 51 JJ=1,NE
      R4(JJ+1)=R4(JJ+1)+(GAMA*R6(JJ+1)+ALM3(IA)/
     *R5(2)*R1(JJ+2))*R5(JJ+2)
   51 CONTINUE
  110 CONTINUE
    3 CONTINUE
      P=H*H /12.
      DO 305 J=1,NE
      R4(J+1)=P*R1(J+2)*R4(J+1)/(ALFA*R1(J+2)+BET)**2
  305 CONTINUE
      RETURN
      END
