      subroutine mulooovdx(a,j,k,l,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
      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
      ! ntp,ntp1,ntp2       : nombre d'adresses T/P
      !  det1 : kl --> a(b)      det2 : j --> (b)
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      !
      ! on n'ajoute aucune particule
      ! conditions : j lie au CAS, [paire (k,a) et l lie au CAS] ou
      ! [paire (l,a) et k lie au CAS]
      !
      ysp1=itest(21)==1
      ysp0=itest(21)==0
      !ysp1=.false.
      !ysp0=.true.
      !///////////////////////////////////////////////////
      if(w)print*,'mulooovdx 0 part',a,j,k,l,aa
      !///////////////////////////////////////////////////
      ! signe
      jsgna=-1+2*mod(num_oav(j)+num_oav(l)+ninac+nocac0-num_oav(k),2)
      jsgnb=-1+2*mod(num_oav(j)+num_oav(l)+ninac+nocbc0-num_oav(k),2)
 
      if(w)print*,'isgn0,isgna,isgnb',isgn0,isgna,isgnb
      if(all((/ilp(k,a),ilp(l,a)/)==0)) return
      if(igener<3) return
      call caldfc(idist,2,1)
      if(ilc1(j).ne.0.and.noac.ne.0) then
         if(ilc1(l).ne.0.and.ilp(k,a).ne.0) then
            ybon=.true.
            jc=ilc1(l)
            jpair=ilp(k,a)
         else if(ilc1(k).ne.0.and.ilp(l,a).ne.0) then
            ybon=.true.
            jc=ilc1(k)
            jpair=ilp(l,a)
         else
            ybon=.false.
         endif
         if(ybon) ybon=ybon.and.ipc(jpair,jc)/=0
         if(w)print*,'ipair',ipair,ybon
         if(ybon) then
            ! Adresse de la partie tp
            if(w)print*,'jpair',jpair,jc,ipc(jpair,jc)
            itp1(1)=abs(ipc(jpair,jc))
            itp2(1)=ilc1(j)
            ltp1(1)=1
            nntp(1)=1
            n=1
            if(w)print'(a,30i3)','a,j,k,l',a,j,k,l,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(k<l) then
               elmat(1)='K+ L+ -> A+    | J+    ->      '
            elseif(k>l) then
               elmat(1)='L+ K+ -> A+    | J+    ->      '
            else
               elmat(1)='L+=K+ -> A+    | J+    ->      '
            endif
            aa3=aa1
            if(ysp1) aa3=aa3*2
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,n,1,jsgna,'J-','L-')
            if(ysp0)call mulatp(aa3,elmat,n,1,jsgnb,'A-','K-')
            !
            !=============
            !
            if(k/=l) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas2'
               if(l>k) 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,'J-','A-','L-','K-')
               !
               !===============
               !
               aa3=aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas2'
               call mulatp(aa3,elmat,n,1,jsgna,'J-','K-')
               if(ysp0)call mulatp(aa3,elmat,n,1,jsgnb,'L-','A-')
               !
            endif
         endif
      endif
 
      !
      !////////////////////////////////////////////////////
      if(w)print*,'mulooovdx on ajoute une particule',a,j,k,l
      !////////////////////////////////////////////////////
      if(igener<4) return
      call caldfc(idist,2,2)
      n=0
      nntp=0
      do iipair1=idebliscond(j),idebliscond(j+1)-1
         ipair1=liscond(iipair1)
         b=ilpair(2,ipair1)
         if(ilp(k,a).ne.0.and.ilp(l,b).ne.0) then
            ipair2=ilp(k,a)
            ipair3=ilp(l,b)
         else if(ilp(k,b).ne.0.and.ilp(l,a).ne.0) then
            ipair2=ilp(k,b)
            ipair3=ilp(l,a)
         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(a,b,ltp1(n))
         if(k>l) then
            ltp1(n)=ltp1(n)+3
         elseif(k==l) then
            ltp1(n)=ltp1(n)+6
         endif
         nntp(ltp1(n))=nntp(ltp1(n))+1
         if(w)print'(a,30i3)','a,j,k,l,b',a,j,k,l,b,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)=(/'K+ L+ -> A+ b+ | J+    -> b+   ',
     *                'K+ L+ -> b+ A+ | J+    -> b+   ',
     *                'K+ L+ -> A+=b+ | J+    -> b+   ',
     *                'L+ K+ -> A+ b+ | J+    -> b+   ',
     *                'L+ K+ -> b+ A+ | J+    -> b+   ',
     *                'L+ K+ -> A+=b+ | J+    -> b+   ',
     *                'K+=L+ -> A+ b+ | J+    -> b+   ',
     *                'K+=L+ -> b+ A+ | J+    -> b+   ',
     *                'K+=L+ -> A+=b+ | J+    -> b+   '/)
         aa3=aa1
         if(ysp1) aa3=aa3*2
         !
         if(w)print*,'icas1'
         call mulatp(aa3,elmat,n,9,-jsgna,'J-','L-')
         if(ysp0)call mulatp(aa3,elmat,n,9,-jsgnb,'A-','K-','b-')
         !
         if(w)print*,'icas2'
         call mulatp(aa3,elmat,n,9,jsgna,'J-','L-','b-')
         if(ysp0)call mulatp(aa3,elmat,n,9,jsgnb,'A-','K-')
         !
         !===============
         !
         if(k/=l) then
            aa3=aa1-aa2
            if(ysp1) aa3=aa3*2
            if(l<k) then
               jsgna1=jsgna
               jsgnb1=jsgnb
            else
               jsgna1=jsgna
               jsgnb1=jsgnb
            endif
            !
            if(w)print*,'icas3'
            call mulatp(aa3,elmat,n,9,-jsgna1)
            if(ysp0)
     *      call mulatp(aa3,elmat,n,9,-jsgnb1,'J-','L-','A-','K-','b-')
            !
            if(w)print*,'icas4'
            call mulatp(aa3,elmat,n,9,jsgna1,'b-')
            if(ysp0)
     *      call mulatp(aa3,elmat,n,9,jsgnb1,'J-','L-','A-','K-')
            !
            !==============
            !
            if(w)print*,'icas5'
            aa3=aa2
            if(ysp1) aa3=aa3*2
            call mulatp(aa3,elmat,n,9,-jsgna,'J-','K-')
            if(ysp0)call mulatp(aa3,elmat,n,9,-jsgnb,'L-','A-','b-')
            !
            if(w)print*,'icas6'
            call mulatp(aa3,elmat,n,9,jsgna,'J-','K-','b-')
            if(ysp0)call mulatp(aa3,elmat,n,9,jsgnb,'L-','A-')
            !
         endif
      endif
 
      return
      end
 
 
 
 
