      subroutine mulccco(x,y,z,i,aa)
      use module
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      dimension aa(3)
      integer x,y,z,i
      call mulcccod(y,x,z,i,aa(2),aa(1))
      call mulcccod(x,z,y,i,aa(3),aa(2))
      call mulcccod(y,z,x,i,aa(3),aa(1))
      return
      end
 
       subroutine mulceco(x1,z1,i1,aa)
      use module
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      dimension aa(2)
      integer x1,y1,z1,i1
      integer x,y,z,i
!      if(itype(z1)==3) then
!         i=z1
!         z=i1
!         x=x1
!      else
         i=i1
         z=z1
         x=x1
!      endif
      call mulcccod(x,x,z,i,aa(1),aa(2))
      call mulcccod(x,z,x,i,aa(2),aa(1))
!      call mulcccox(z,x,x,i,aa(1)-aa(2))
      return
      end
       subroutine mulcccvd2(x1,y1,z1,a,aa1,aa2)
      use module
      use mod_ena
      use mod_ena2
      use mod_mula
      use mod_itp
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      integer a,x,y,z,b,x1,y1,z1
      integer,allocatable,dimension(:) :: idetc1,idetc2,isgnc
      dimension ntp(0:6),aal(2),isec1(2),isec2(2)
      character(31) elmat(27)
 
 
      if(w)print*,'entree mulcccvd2'
!      deallocate(itp1,itp2)
      x=num_oav(x1)
      y=num_oav(y1)
      z=num_oav(z1)
      jsgn=1
      if(x>y.and.x/=z) jsgn=-1
 
 
      !On va rajouter deux trous i et j et une particule b
      !det1 ij--->[xy....]--->b det2 ij--->[z...]a--->a(b)
      if(w)print*,'mulcccvd on ajoute deux trous et une particule'
     *,x1,y1,z1,a
      n=0
      nntp=0
      do iipair2=idebliscond(a),ifinliscond(a)
         ipair21=liscond(iipair2)
         i=ilpair(1,ipair21)
         do ipair22=1,nlpairp
            j=ilpair(1,ipair22)
            b=ilpair(2,ipair22)
            if ((ilp(j,a)/=0).and.(ilp(i,b)/=0).and.(j<i)) cycle
            ipair1=ipair22
            icc1=ilc1(i)
            if(icc1==0) then
               icc1=ilc1(j)
               ipair1=ilp(i,b)
            endif
            if(icc1==0.or.ipair1==0) cycle
            if(ipc(il(j,b),icc1)==0) cycle
            iimax=max(ipair21,ipair22)
            iimin=min(ipair21,ipair22)
            ii1=iimax*(iimax-1)/2+iimin
            if(ipp(ii1)==0) cycle
            n=n+1
            itp2(n)=abs(ipp(ii1))
            itp1(n)=abs(ipc(il(j,b),icc1))
            if(b>a) then
               ltp1(n)=1
            else if(b<a) then
               ltp1(n)=2
            else
               ltp1(n)=3
            endif
            if(i==j) ltp1(n)=ltp1(n)+3
            nntp(ltp1(n))=nntp(ltp1(n))+1
            if(w)print'(a,20i4)','j,i,a,b',
     *      j,i,a,b,n,ltp1(n),nntp(ltp1(n)),
     *      itp1(n),itp2(n)
         enddo
      enddo
      if(n/=0) then
         call reoitp(n,6,nntp)
         if(w)print'(a,20i3)','ITP',itp1(1:n)
         if(w)print'(a,20i3)','ITP',itp2(1:n)
         !
         elmat(1:6)=(/'i+ j+ -> b+    | i+ j+ -> A+ b+',
     *                'i+ j+ -> b+    | i+ j+ -> b+ A+',
     *                'i+ j+ -> b+    | i+ j+ -> A+=b+',
     *                'i+=j+ -> b+    | i+=j+ -> A+ b+',
     *                'i+=j+ -> b+    | i+=j+ -> b+ A+',
     *                'i+=j+ -> b+    | i+=j+ -> A+=b+'/)
         call mula0(x,y,z,0)
         aa3=aa1
         !
         if(w)print*,'icas1'
         call mula(aa3,'+-+v',elmat,n,6,1,'A-')
         call mula(aa3,'-+-v',elmat,n,6,1,'i-','j-','b-')
         !
         if(w)print*,'icas2'
         call mula(aa3,'+-+v',elmat,n,6,1,'A-','i-')
         call mula(aa3,'-+-v',elmat,n,6,1,'j-','b-')
         !
         if(w)print*,'icas3'
         call mula(aa3,'+-+v',elmat,n,3,1,'A-','j-')
         call mula(aa3,'-+-v',elmat,n,3,1,'i-','b-')
         !
         if(w)print*,'icas4'
         call mula(aa3,'+-+v',elmat,n,6,1,'A-','b-')
         call mula(aa3,'-+-v',elmat,n,6,1,'i-','j-')
         !
         if(w)print*,'icas5'
         call mula(aa3,'+-+v',elmat,n,6,1,'A-','i-','j-')
         call mula(aa3,'-+-v',elmat,n,6,1,'b-')
         !
         if(w)print*,'icas6'
         call mula(aa3,'+-+v',elmat,n,6,1,'A-','i-','b-')
         call mula(aa3,'-+-v',elmat,n,6,1,'j-')
         !
         if(w)print*,'icas7'
         call mula(aa3,'+-+v',elmat,n,3,1,'A-','j-','b-')
         call mula(aa3,'-+-v',elmat,n,3,1,'i-')
         !
         if(w)print*,'icas8'
         call mula(aa3,'+-+v',elmat,n,6,1,'A-','i-','j-','b-')
         call mula(aa3,'-+-v',elmat,n,6,1)
         !
         !==========================
         !
         if(x/=y) then
            aa3=aa1-aa2
            ydir=.false.
            yoci((/x,y,z/))=.true.
            if(x==z)yoci(z)=.false.
            !
            if(w)print*,'icas21'
            call mula(aa3,'+++v',elmat,n,6,jsgn)
            call mula(aa3,'---v',elmat,n,6,jsgn,'A-','i-','j-','b-')
            !
            if(w)print*,'icas22'
            call mula(aa3,'+++v',elmat,n,6,jsgn,'i-')
            call mula(aa3,'---v',elmat,n,6,jsgn,'A-','j-','b-')
            !
            if(w)print*,'icas23'
            call mula(aa3,'+++v',elmat,n,3,jsgn,'j-')
            call mula(aa3,'---v',elmat,n,3,jsgn,'A-','i-','b-')
            !
            if(w)print*,'icas24'
            call mula(aa3,'+++v',elmat,n,6,jsgn,'b-')
            call mula(aa3,'---v',elmat,n,6,jsgn,'A-','i-','j-')
            !
            if(w)print*,'icas25'
            call mula(aa3,'+++v',elmat,n,6,jsgn,'i-','j-')
            call mula(aa3,'---v',elmat,n,6,jsgn,'A-','b-')
            !
            if(w)print*,'icas26'
            call mula(aa3,'+++v',elmat,n,6,jsgn,'i-','b-')
            call mula(aa3,'---v',elmat,n,6,jsgn,'A-','j-')
            !
            if(w)print*,'icas27'
            call mula(aa3,'+++v',elmat,n,3,jsgn,'j-','b-')
            call mula(aa3,'---v',elmat,n,3,jsgn,'A-','i-')
            !
            if(w)print*,'icas28'
            call mula(aa3,'+++v',elmat,n,6,jsgn,'i-','j-','b-')
            call mula(aa3,'---v',elmat,n,6,jsgn,'A-')
            ydir=.true.
            yoci((/x,y,z/))=.false.
            !
            !==========================
            !
            call mula0(x,y,0,z)
            aa3=aa2
            !
            if(w)print*,'icas31'
            call mula(aa3,'+-v-',elmat,n,6,1)
            call mula(aa3,'-+v+',elmat,n,6,1,'A-','i-','j-','b-')
            !
            if(w)print*,'icas32'
            call mula(aa3,'+-v-',elmat,n,6,1,'i-')
            call mula(aa3,'-+v+',elmat,n,6,1,'A-','j-','b-')
            !
            if(w)print*,'icas33'
            call mula(aa3,'+-v-',elmat,n,3,1,'j-')
            call mula(aa3,'-+v+',elmat,n,3,1,'A-','i-','b-')
            !
            if(w)print*,'icas34'
            call mula(aa3,'+-v-',elmat,n,6,1,'b-')
            call mula(aa3,'-+v+',elmat,n,6,1,'A-','i-','j-')
            !
            if(w)print*,'icas35'
            call mula(aa3,'+-v-',elmat,n,6,1,'i-','j-')
            call mula(aa3,'-+v+',elmat,n,6,1,'A-','b-')
            !
            if(w)print*,'icas36'
            call mula(aa3,'+-v-',elmat,n,6,1,'i-','b-')
            call mula(aa3,'-+v+',elmat,n,6,1,'A-','j-')
            !
            if(w)print*,'icas37'
            call mula(aa3,'+-v-',elmat,n,3,1,'j-','b-')
            call mula(aa3,'-+v+',elmat,n,3,1,'A-','i-')
            !
            if(w)print*,'icas38'
            call mula(aa3,'+-v-',elmat,n,6,1,'i-','j-','b-')
            call mula(aa3,'-+v+',elmat,n,6,1,'A-')
            !
         endif
      endif
 
 
 
      !
      !
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      !On va rajouter un trou i et une particule b
      !det1 i--->[xy....]--->b det2 i--->[z...]a--->a(b)
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      if(w)print*,'mulcccvd on ajoute un trou et une particule'
     *,x1,y1,z1,a
      n=0
      nntp=0
      do j=1,nlpair
         i=ilpair(1,j)
         b=ilpair(2,j)
         if (ilc1(a)/=0.and.ilp(i,b)/=0) then
            if(ipc(ilp(i,b),nlco+ilc1(a))==0) cycle
            n=n+1
            if(b<a) then
               ltp1(n)=2
            else if(b>a) then
               ltp1(n)=1
            else
               ltp1(n)=3
            endif
            itp1(n)=il(i,b)
            itp2(n)=abs(ipc(ilp(i,b),nlco+ilc1(a)))
            nntp(ltp1(n))=nntp(ltp1(n))+1
         else
            ipairia=ilp(i,a)
            if(ipairia/=0) then
               ilc1b=ilc1(b)
               if(ilc1b/=0) then
                  if(ipc(ipairia,nlco+ilc1b)==0) cycle
                  n=n+1
                  if(b<a) then
                     ltp1(n)=2
                  else if(b>a) then
                     ltp1(n)=1
                  else
                     ltp1(n)=3
                  endif
                  itp1(n)=il(i,b)
                  itp2(n)=abs(ipc(ipairia,nlco+ilc1b))
                  nntp(ltp1(n))=nntp(ltp1(n))+1
               endif
            endif
         endif
      enddo
      if(n/=0) then
         call reoitp(n,3,nntp)
         if(w)print'(a,20i3)','ITP',itp1(1:n)
         if(w)print'(a,20i3)','ITP',itp2(1:n)
         !
         elmat(1:3)=(/'i+    -> b+    | i+    -> A+ b+',
     *                'i+    -> b+    | i+    -> b+ A+',
     *                'i+    -> b+    | i+    -> b+=A+'/)
         !
         call mula0(x,y,z,0)
         aa3=aa1
         !
         if(w)print*,'icas1'
         call mula(aa3,'+-+v',elmat,n,3,1,'A-')
         call mula(aa3,'-+-v',elmat,n,3,1,'i-','b-')
         !
         if(w)print*,'icas2'
         call mula(aa3,'+-+v',elmat,n,3,1,'A-','i-')
         call mula(aa3,'-+-v',elmat,n,3,1,'b-')
         !
         if(w)print*,'icas3'
         call mula(aa3,'+-+v',elmat,n,3,1,'A-','b-')
         call mula(aa3,'-+-v',elmat,n,3,1,'i-')
         !
         if(w)print*,'icas4'
         call mula(aa3,'+-+v',elmat,n,3,1,'A-','i-','b-')
         call mula(aa3,'-+-v',elmat,n,3,1)
         !
         !============
         !
         if(x/=y) then
            aa3=aa1-aa2
            !
            ydir=.false.
            yoci((/x,y,z/))=.true.
            if(x==z)yoci(z)=.false.
            if(w)print*,'icas5'
            call mula(aa3,'+++v',elmat,n,3,jsgn)
            call mula(aa3,'---v',elmat,n,3,jsgn,'A-','i-','b-')
            !
            if(w)print*,'icas6'
            call mula(aa3,'+++v',elmat,n,3,jsgn,'b-')
            call mula(aa3,'---v',elmat,n,3,jsgn,'A-','i-')
            !
            if(w)print*,'icas7'
            call mula(aa3,'+++v',elmat,n,3,jsgn,'i-')
            call mula(aa3,'---v',elmat,n,3,jsgn,'A-','b-')
            !
            if(w)print*,'icas8'
            call mula(aa3,'+++v',elmat,n,3,jsgn,'i-','b-')
            call mula(aa3,'---v',elmat,n,3,jsgn,'A-')
            ydir=.true.
            yoci((/x,y,z/))=.false.
            !
            !=================
            !
            call mula0(x,y,0,z)
            aa3=aa2
            !w=.true.
            if(w)print*,'icas9'
            call mula(aa3,'+-v-',elmat,n,3,1)
            call mula(aa3,'-+v+',elmat,n,3,1,'A-','i-','b-')
            !w=.false.
            !
            if(w)print*,'icasa'
            call mula(aa3,'+-v-',elmat,n,3,1,'i-')
            call mula(aa3,'-+v+',elmat,n,3,1,'A-','b-')
            !
            if(w)print*,'icasb'
            call mula(aa3,'+-v-',elmat,n,3,1,'b-')
            call mula(aa3,'-+v+',elmat,n,3,1,'A-','i-')
            !
            if(w)print*,'icasc'
            call mula(aa3,'+-v-',elmat,n,3,1,'i-','b-')
            call mula(aa3,'-+v+',elmat,n,3,1,'A-')
            !
         endif
      endif
      return
 
      end
 
 
