      function BABBCD(IOCCA1, IOCCB1, IOCCA2, IOCCB2, NMOS)
      implicit double precision (A-H,O-Z)
      include 'SIZES'
      include 'MOP6FILE'
      dimension IOCCA1(NMOS), IOCCB1(NMOS), IOCCA2(NMOS), IOCCB2(NMOS)
***********************************************************************
*
* BABBCD EVALUATES THE C.I. MATRIX ELEMENT FOR TWO MICROSTATES DIFFERING
*       BY TWO BETA MOS. ONE MICROSTATE HAS BETA ELECTRONS IN
*       M.O.S PSI(I) AND PSI(J) FOR WHICH THE OTHER MICROSTATE HAS
*       ELECTRONS IN PSI(K) AND PSI(L)
*
***********************************************************************
      common /XYIJKL/ XY(NMECI,NMECI,NMECI,NMECI)
      IJ=0
      do 10 I=1,NMOS
   10 if (IOCCB1(I) .LT. IOCCB2(I)) go to 20
   20 do 30 J=I+1,NMOS
         if (IOCCB1(J) .LT. IOCCB2(J)) go to 40
   30 IJ=IJ+IOCCA2(J)+IOCCB2(J)
   40 IJ=IJ+IOCCA2(J)
      do 50 K=1,NMOS
   50 if (IOCCB1(K) .GT. IOCCB2(K)) go to 60
   60 do 70 L=K+1,NMOS
         if (IOCCB1(L) .GT. IOCCB2(L)) go to 80
   70 IJ=IJ+IOCCA1(L)+IOCCB1(L)
   80 IJ=IJ+IOCCA1(L)
      if ((IJ/2)*2.EQ.IJ) then
         ONE=1.D0
      else
         ONE=-1.D0
      end if
      BABBCD=(XY(I,K,J,L)-XY(I,L,J,K))*ONE
      return
      end
