      subroutine mulvvvodx(a,b,d,i,aa1,aa2)
      use module
      use mod_ena
      use mod_mula
      use mod_mulatp
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      integer a,b,d
      character(31) elmat(9)
      !
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      ! Preparation des listes d'adresses du CAS et des TP
      !
      ! i,j,k,l,aa = indices et valeur de l'integrale
      ! itp1,itp2,itp3,itp4 : adresses de la partie T/P
      !  det1 : kl --> a(b)      det2 : j --> (b)
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      !
      ysp1=itest(21)==1
      ysp0=itest(21)==0
      !ysp1=.false.
      !ysp0=.true.
      !//////////////////////////////////////////////////
      if(w)print*,'mulvvvodx 0 trou',a,b,d,i
      !//////////////////////////////////////////////////
      ! signe
      jsgna=1-2*mod(ninac-num_oav(i)+nocac0,2) !saut alpha de k en a
      jsgnb=1-2*mod(ninac-num_oav(i)+nocbc0,2) !saut beta de k en a
      !
      if(igener<3) return
      call caldfc(idist,1,2)
      n=0
      if(ilc1(d)/=0) then
         if(ilc1(a)/=0.and.ilp(i,b)/=0) then
            n=1
            itp1(1)=abs(ipc(ilp(i,b),ilc1(a)+nlco))
            itp2(1)=ilc1(d)
         elseif(ilc1(b)/=0.and.ilp(i,a)/=0) then
            n=1
            itp1(1)=abs(ipc(ilp(i,a),ilc1(b)+nlco))
            itp2(1)=ilc1(d)
         endif
         if(itp1(1)==0) n=n-1
         if(n>0) then
            ltp1(1)=1
            nntp(1)=1
            n=1
            if(w)print'(a,30i3)','A,b,i,d',a,b,i,d,n,
     *      ltp1(n),nntp(ltp1(n)),
     *      itp1(n),itp2(n)
            if(w)print'(a,20i3)','ITP',itp1(1:n)
            if(w)print'(a,20i3)','ITP',itp2(1:n)
            !
            if(a<b) then
               elmat(1)='I+    -> A+ B+ |       -> D+   '
            elseif(a>b) then
               elmat(1)='I+    -> B+ A+ |       -> D+   '
            else
               elmat(1)='I+    -> A+=B+ |       -> D+   '
            endif
            aa3=aa1
            if(ysp1) aa3=aa3*2
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,n,1,jsgnb,'I-','B-')
            if(ysp0)call mulatp(aa3,elmat,n,1,jsgna,'A-','D-')
            !
            !=============
            !
            if(a/=b) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas2'
               if(a<b) then
                  jsgna1=jsgna
                  jsgnb1=jsgnb
               else
                  jsgna1=-jsgna
                  jsgnb1=-jsgnb
               endif
               call mulatp(aa3,elmat,n,1,jsgna1)
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,jsgnb1,'I-','A-','B-','D-')
               !
               !===============
               !
               aa3=aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas2'
               call mulatp(aa3,elmat,n,1,jsgna,'B-','D-')
               if(ysp0)call mulatp(aa3,elmat,n,1,jsgnb,'I-','A-')
               !
            endif
         endif
      endif
      !
      ! on ajoute un trou
      !
      !//////////////////////////////////////////////////
      if(w)print*,'mulvvvodx on ajoute un trou',a,b,d,i
      !//////////////////////////////////////////////////
      !  det1 : kl --> ab      det2 : j --> b
      ! conditions paire (j,b)
      ! [paires (k,a),(l,b)] ou [paires (k,b),(l,a)]
      !
      if(igener<4) return
      call caldfc(idist,2,2)
      n=0
      nntp=0
      do iipair1=idebliscond(d),idebliscond(d+1)-1
         ipair1=liscond(iipair1)
         j=ilpair(1,ipair1)
         if(ilp(j,a).ne.0.and.ilp(i,b).ne.0) then
            ipair2=ilp(j,a)
            ipair3=ilp(i,b)
         else if(ilp(i,a).ne.0.and.ilp(j,b).ne.0) then
            ipair2=ilp(i,a)
            ipair3=ilp(j,b)
         else
            cycle
         endif
         iimax1=max(ipair2,ipair3)
         iimin1=min(ipair3,ipair2)
         ii1=iimax1*(iimax1-1)/2+iimin1
         if(ipp(ii1)==0) cycle
         n=n+1
         itp1(n)=abs(ipp(ii1))
         itp2(n)=ipair1
         call muladd_o_o(j,i,ltp1(n))
         if(a>b) then
            ltp1(n)=ltp1(n)+3
         elseif(a==b) then
            ltp1(n)=ltp1(n)+6
         endif
         nntp(ltp1(n))=nntp(ltp1(n))+1
         if(w)print'(a,30i3)','A,b,i,j,d',a,b,i,j,d,n,
     *   ltp1(n),nntp(ltp1(n)),
     *   itp1(n),itp2(n)
      enddo
      if(n>0) then
         call reoitp(n,9,nntp)
         if(w)print'(a,20i3)','ITP',itp1(1:n)
         if(w)print'(a,20i3)','ITP',itp2(1:n)
         !
         elmat(1:9)=(/'j+ I+ -> A+ B+ | j+    -> D+   ',
     *                'I+ j+ -> A+ B+ | j+    -> D+   ',
     *                'j+=I+ -> A+ B+ | j+    -> D+   ',
     *                'j+ I+ -> B+ A+ | j+    -> D+   ',
     *                'I+ j+ -> B+ A+ | j+    -> D+   ',
     *                'j+=I+ -> B+ A+ | j+    -> D+   ',
     *                'j+ I+ -> A+=B+ | j+    -> D+   ',
     *                'I+ j+ -> A+=B+ | j+    -> D+   ',
     *                'j+=I+ -> A+=B+ | j+    -> D+   '/)
         aa3=aa1
         if(ysp1) aa3=aa3*2
         !
         if(w)print*,'icas1'
         call mulatp(aa3,elmat,n,9,jsgnb,'I-','B-')
         if(ysp0)call mulatp(aa3,elmat,n,9,jsgna,'A-','D-','j-')
         !
         if(w)print*,'icas2'
         call mulatp(aa3,elmat,n,9,-jsgnb,'I-','B-','j-')
         if(ysp0)call mulatp(aa3,elmat,n,9,-jsgna,'A-','D-')
         !
         !===============
         !
         if(a/=b) then
            aa3=aa1-aa2
            if(ysp1) aa3=aa3*2
            !
            if(w)print*,'icas3'
            call mulatp(aa3,elmat,n,9,-jsgna)
            if(ysp0)
     *      call mulatp(aa3,elmat,n,9,-jsgnb,'D-','B-','A-','I-','j-')
            !
            if(w)print*,'icas4'
            call mulatp(aa3,elmat,n,9,jsgna,'j-')
            if(ysp0)call mulatp(aa3,elmat,n,9,jsgnb,'D-','B-','A-','I-')
            !
            !==============
            !
            if(w)print*,'icas5'
            aa3=aa2
            if(ysp1) aa3=aa3*2
            call mulatp(aa3,elmat,n,9,-jsgna,'B-','D-')
            if(ysp0)call mulatp(aa3,elmat,n,9,-jsgnb,'I-','A-','j-')
            !
            if(w)print*,'icas6'
            call mulatp(aa3,elmat,n,9,jsgna,'B-','D-','j-')
            if(ysp0)call mulatp(aa3,elmat,n,9,jsgnb,'I-','A-')
            !
         endif
      endif
      return
      end
 
 
 
 
 
