      subroutine muloooodx(i,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,corr1,corr2
      character(31) elmat(81)
      !
      if(w)print*,'entree muloooodx i,j,k,l',i,j,k,l
      call caldfc(idist,2,0)
      ysp1=itest(21)==1
      ysp0=itest(21)==0
      !
      !
      !signe
      isgn1=1-2*mod(sum(num_oav((/i,j,k,l/))),2)
      isgn2=isgn1
      ! changt de signe s'il y a un croisement
      !if((j-k)*(l-i)<0) isgn2=-isgn2
      if((i-j)*(k-l)<0) isgn2=-isgn2
 
      if(all(ilc1((/i,j,k,l/))/=0)) then
         ii1=ilc1(k)
         ii2=ilc1(l)
         ii3=ilc1(i)
         ii4=ilc1(j)
!+ J+ -> A+    | k+ I+ -> B+
         elmat(1)='      ->       |       ->      '
         ! Adresse de la partie tp
         if(ii1<ii2) then
            itp1(1)=num1(ii2)+ii1
            elmat(1)(1:5)='K+ L+'
         else if(ii1==ii2) then
            itp1(1)=ii1
            elmat(1)(1:5)='K+=L+'
         else if(ii1>ii2) then
            itp1(1)=num1(ii1)+ii2
            elmat(1)(1:5)='L+ K+'
         endif
         if(ii3<ii4) then
            itp2(1)=num1(ii4)+ii3
            elmat(1)(18:22)='I+ J+'
         else if(ii3==ii4) then
            itp2(1)=ii3
            elmat(1)(18:22)='I+=J+'
         else if(ii3>ii4) then
            itp2(1)=num1(ii3)+ii4
            elmat(1)(18:22)='J+ I+'
         endif
         nntp(1)=1
         ltp1(1)=1
         if(w)print'(a,20i3)','ITP',itp1(1)
         if(w)print'(a,20i3)','ITP',itp2(1)
         !
         if(i/=k.or.l/=j) then
            aa3=aa1
            if(ysp1) aa3=aa3*2
            !
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,1,1,isgn1,'L-','J-')
            if(ysp0.and.(k/=l.or.i/=j))
     *      call mulatp(aa3,elmat,1,1,isgn1,'K-','I-')
            !
            !============
            !
            if(k/=l.and.i/=j) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas2',isgn2
               call mulatp(aa3,elmat,1,1,isgn2)
               if(ysp0)
     *         call mulatp(aa3,elmat,1,1,isgn2,'I-','J-','K-','L-')
            endif
         endif
         !
         !============
         !
         if(j/=k.or.i/=l) then
            if(k/=l.and.i/=j) then
               aa3=aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas3'
               call mulatp(aa3,elmat,1,1,isgn1,'L-','I-')
               if(ysp0.and.(i/=k.or.l/=j))
     *         call mulatp(aa3,elmat,1,1,isgn1,'K-','J-')
               !
            endif
         endif
      endif
      !
      !////////////////////////////////////////////////////
      if(w)print*,'muloooodx on ajoute une part  i,j,k,l',i,j,k,l
      !////////////////////////////////////////////////////
      !
      if(igener<3) return
      if(itest(22)==1.and.iter==1) return
      call caldfc(idist,2,1)
      n=0
      nntp=0
      do iipaird=idebliscond(i),ifinliscond(i)
         ipair2=liscond(iipaird)
         if(ilc1(j)/=0) then
            icc2=ilc1(j)
         else
            cycle
         endif
         a=ilpair(2,ipair2)
         if(ilc1(k)/=0.and.ilp(l,a)/=0) then
            icc1=ilc1(k)
            ipair1=ilp(l,a)
         else if(ilc1(l)/=0.and.ilp(k,a)/=0) then
            icc1=ilc1(l)
            ipair1=ilp(k,a)
         else
            cycle
         endif
         if(ipc(ipair1,icc1)==0) cycle
         if(ipc(ipair2,icc2)==0) cycle
         n=n+1
         itp1(n)=abs(ipc(ipair1,icc1))
         itp2(n)=abs(ipc(ipair2,icc2))
         ltp1(n)=1
         nntp(ltp1(n))=nntp(ltp1(n))+1
         if(w)print'(a,30i3)','i,j,k,l,a',i,j,k,l,a,n,
     *   ltp1(n),nntp(ltp1(n)),
     *   itp1(n),itp2(n)
         !
      enddo
      do iipaird=idebliscond(j),ifinliscond(j)
         ipair2=liscond(iipaird)
         a=ilpair(2,ipair2)
         if(ilc1(i)/=0.and.(ilc1(j)==0.or.ilp(i,a)==0)) then
            icc2=ilc1(i)
         else
            cycle
         endif
         if(ilc1(k)/=0.and.ilp(l,a)/=0) then
            icc1=ilc1(k)
            ipair1=ilp(l,a)
         else if(ilc1(l)/=0.and.ilp(k,a)/=0) then
            icc1=ilc1(l)
            ipair1=ilp(k,a)
         else
            cycle
         endif
         if(ipc(ipair1,icc1)==0) cycle
         if(ipc(ipair2,icc2)==0) cycle
         n=n+1
         itp1(n)=abs(ipc(ipair1,icc1))
         itp2(n)=abs(ipc(ipair2,icc2))
         ltp1(n)=1
         nntp(ltp1(n))=nntp(ltp1(n))+1
         if(w)print'(a,30i3)','I,j,k,l,a',I,j,k,l,a,n,
     *   ltp1(n),nntp(ltp1(n)),
     *   itp1(n),itp2(n)
         !
      enddo
      if(w)print'(a,20i3)','ITP',itp1(1:n)
      if(w)print'(a,20i3)','ITP',itp2(1:n)
      if(w)print*,'nntp',nntp(1:n)
      if(n>0) then
         ltp1(1)=n
         elmat(1)='      -> a+    |       -> a+   '
         if(k<l) then
            elmat(1)(1:5)='K+ L+'
         else if(k==l) then
            elmat(1)(1:5)='K+=L+'
         else if(k>l) then
            elmat(1)(1:5)='L+ K+'
         endif
         if(i<j) then
            elmat(1)(18:22)='I+ J+'
         else if(i==j) then
            elmat(1)(18:22)='I+=J+'
         else if(i>j) then
            elmat(1)(18:22)='J+ I+'
         endif
         !
         if(k/=i.or.l/=j) then
            aa3=aa1
            if(ysp1) aa3=aa3*2
            !
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,n,1,isgn1,'L-','J-')
            if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','I-','a-')
            !
            if((k/=l.or.i/=j).and.(k/=j.or.i/=l)) then
               if(w)print*,'icas2'
               call mulatp(aa3,elmat,n,1,isgn1,'L-','J-','a-')
               if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','I-')
            endif
            !
            !============
            !
            if(k/=l.and.i/=j) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas3',isgn2
               call mulatp(aa3,elmat,n,1,isgn2)
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,isgn2,'K-','I-','L-','J-','a-')
               !
               if(w)print*,'icas4',isgn2
               call mulatp(aa3,elmat,n,1,isgn2,'a-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,isgn2,'K-','I-','L-','J-')
            endif
         endif
         !
         !============
         !
         if(k/=j.or.i/=l) then
            if(k/=l.and.i/=j) then
               aa3=aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas5'
               call mulatp(aa3,elmat,n,1,isgn1,'L-','I-')
               if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','J-','a-')
               !
               if((k/=i.or.l/=j).and.(k/=l.or.i/=j)) then
                  if(w)print*,'icas6'
                  call mulatp(aa3,elmat,n,1,isgn1,'L-','I-','a-')
                  if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','J-')
               endif
               !
            endif
         endif
      endif
      !
      !////////////////////////////////////////////////////
      if(w)print*,'muloooodx on ajoute 2 part  k,l,i,j',k,l,i,j
      !////////////////////////////////////////////////////
      !
      if(igener<4) return
      call caldfc(idist,2,2)
      n=0
      nntp=0
      do iipaird=idebliscond(i),ifinliscond(i)
         ipair2=liscond(iipaird)
         a=ilpair(2,ipair2)
         do jjpaire=idebliscond(j),ifinliscond(j)
            jpair2=liscond(jjpaire)
            b=ilpair(2,jpair2)
            if(ilp(j,a)/=0.and.ilp(i,b)/=0.and.a>b) cycle
            if(ilp(k,a)/=0.and.ilp(l,b)/=0) then
               ipair1=ilp(k,a)
               jpair1=ilp(l,b)
            elseif(ilp(k,b)/=0.and.ilp(l,a)/=0) then
               ipair1=ilp(k,b)
               jpair1=ilp(l,a)
            else
               cycle
            endif
            iimax1=max(ipair1,jpair1)
            iimin1=min(ipair1,jpair1)
            iimax2=max(ipair2,jpair2)
            iimin2=min(ipair2,jpair2)
            ii1=iimax1*(iimax1-1)/2+iimin1
            ii2=iimax2*(iimax2-1)/2+iimin2
            if(ipp(ii1)==0) cycle
            if(ipp(ii2)==0) cycle
            n=n+1
            itp1(n)=abs(ipp(ii1))
            itp2(n)=abs(ipp(ii2))
            if(a==b) then
               ltp1(n)=2
            else
               ltp1(n)=1
            endif
            nntp(ltp1(n))=nntp(ltp1(n))+1
            if(w)print'(a,30i3)','K,l,i,j,a,b',k,l,i,j,a,b,n,
     *      ltp1(n),nntp(ltp1(n)),
     *      itp1(n),itp2(n)
         enddo
      enddo
      if(n>0) then
         call reoitp(n,2,nntp)
         if(w)print'(a,20i3)','ITP',itp1(1:n)
         if(w)print'(a,20i3)','ITP',itp2(1:n)
         !
         elmat(1:2)=(/'      -> a+ b+ |       -> a+ b+',
     *   '      -> a+=b+ |       -> a+=b+'/)
         if(k<l) then
            elmat(1:2)(1:5)='K+ L+'
         else if(k==l) then
            elmat(1:2)(1:5)='K+=L+'
         else if(k>l) then
            elmat(1:2)(1:5)='L+ K+'
         endif
         if(i<j) then
            elmat(1:2)(18:22)='I+ J+'
         else if(i==j) then
            elmat(1:2)(18:22)='I+=J+'
         else if(i>j) then
            elmat(1:2)(18:22)='J+ I+'
         endif
         !
         if(k/=i.or.l/=j) then
            aa3=aa1
            if(ysp1) aa3=aa3*2
            !
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,n,1,isgn1,'L-','J-')
            if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','I-','a-','b-')
            !
            if(w)print*,'icas2'
            call mulatp(aa3,elmat,n,2,isgn1,'L-','J-','b-')
            if(k/=l.or.i/=j) then
               if(ysp0)call mulatp(aa3,elmat,n,2,isgn1,'K-','I-','a-')
            else
               if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','I-','a-')
            endif
            !
            if((k/=l.or.i/=j).and.(k/=j.or.i/=l)) then
               if(w)print*,'icas3'
               call mulatp(aa3,elmat,n,1,isgn1,'L-','J-','a-')
               if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','I-','b-')
               !
               if(w)print*,'icas4'
               call mulatp(aa3,elmat,n,1,isgn1,'L-','J-','a-','b-')
               if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','I-')
            endif
            !
            !============
            !
            if(k/=l.and.i/=j) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               !
               if(w)print*,'icas5',isgn2
               call mulatp(aa3,elmat,n,1,isgn2)
               if(ysp0)call mulatp(aa3,elmat,n,1,isgn2,
     *         'K-','I-','L-','J-','a-','b-')
               !
               if(w)print*,'icas6'
               call mulatp(aa3,elmat,n,2,isgn2,'b-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,2,isgn2,'K-','I-','L-','J-','a-')
               !
               if(w)print*,'icas7'
               call mulatp(aa3,elmat,n,1,isgn2,'a-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,isgn2,'K-','I-','L-','J-','b-')
               !
               if(w)print*,'icas8'
               call mulatp(aa3,elmat,n,1,isgn2,'a-','b-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,isgn2,'K-','I-','L-','J-')
            endif
         endif
         !
         !============
         !
         if(k/=j.or.i/=l) then
            if(k/=l.and.i/=j) then
               aa3=aa2
               if(ysp1) aa3=aa3*2
               !
               if(w)print*,'icas9'
               call mulatp(aa3,elmat,n,1,isgn1,'L-','I-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,isgn1,'K-','J-','a-','b-')
               !
               if(w)print*,'icasa'
               call mulatp(aa3,elmat,n,2,isgn1,'L-','I-','b-')
               if(k/=i.or.l/=j) then
                  if(ysp0)
     *            call mulatp(aa3,elmat,n,2,isgn1,'K-','J-','a-')
               else
                  if(ysp0)call mulatp(aa3,elmat,n,1,1,'K-','J-','a-')
               endif
               !
               if(k/=i.or.l/=j.and.(k/=l.or.i/=j)) then
                  if(w)print*,'icasb',k,l,i,j
                  call mulatp(aa3,elmat,n,1,isgn1,'L-','I-','a-')
                  if(ysp0)
     *            call mulatp(aa3,elmat,n,1,isgn1,'K-','J-','b-')
                  !
                  if(w)print*,'icasc'
                  call mulatp(aa3,elmat,n,1,isgn1,'L-','I-','a-','b-')
                  if(ysp0)call mulatp(aa3,elmat,n,1,isgn1,'K-','J-')
               endif
               !
            endif
         endif
      endif
      !
      return
      end
