      subroutine mulcccod(x1,y1,z1,i,aaa1,aaa2)
      use module
      use mod_ena
      use mod_mula
      use mod_itp
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      integer i,x1,y1,z1,i1,x,y,z,a,b,b1,aa,bb
      integer,allocatable,dimension(:) :: idetc1,idetc2,isgnc
      character(31) elmat(27)
      !
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      ! 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 : [xy...](kl) --> (b)      det2 : [z...](kl) --> a(b)
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      !
      x=num_oav(x1)
      y=num_oav(y1)
      i1=num_oav(i)
      z=num_oav(z1)
      !symetrie de spin
      aa1=aaa1
      aa2=aaa2
      ysp1=itest(21)==1
      ysp0=itest(21)==0
      if(ysp1) then
         aa1=aa1*2
         aa2=aa2*2
      endif
      ! Signe
      jsgn=1-mod(ninac+num_oav(i),2)*2
      jsgn2=jsgn
      if(x<y.and.x/=z) jsgn2=-jsgn
      !
 
      if(w)print*,'mulcccod 0',x1,y1,z1,i
      call caldfc(idist,1,0)
      call caldfc(idist2,0,0)
      if(ilc1(i).ne.0) then
!         if(iter>=iterh)print*,'subr mulcccod classhab(1,0)'
         if (iter>=iterh.and..not.ycalmat3) call classhab(1,0)
!         print*,'cccod hab',hab
!         print'(2i5,l2)',iter,iterh,ycalmat3
!         if (iter>=iterh.and..not.ycalmat3)stop'cccod'
         itp1(1)=ilc1(i)
         itp2(1)=1
         ltp1(1)=1
         nntp(1)=1
         n=1
         if(w)print'(a,20i4)','i',i,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)
         !
         elmat(1)='I+    ->       |       ->      '
         !
         aa3=aa1
         call mula0(x,y,z,0)
         !
         if(w)print*,'icas1'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,1,jsgn,'I-')
         call mula(aa3,'-+-o',elmat,n,1,jsgn)
         !
         !==================
         !
         if(x/=y) then
            aa3=aa1-aa2
            ydir=.false.
            yoci((/x,y,z/))=.true.
            if(x==z)yoci(z)=.false.
            if(w)print*,'icas3'
            if(ysp0)call mula(aa3,'+++o',elmat,n,1,jsgn2)
            call mula(aa3,'---o',elmat,n,1,jsgn2,'I-')
            ydir=.true.
            yoci((/x,y,z/))=.false.
            !
            !========================
            !
            call mula0(x,y,0,z)
            aa3=aa2
            if(w)print*,'icas5'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,1,jsgn)
            call mula(aa3,'-+o+',elmat,n,1,jsgn,'I-')
            !
         endif
      endif
 
      hab=0
 
      if(itest(22)==1.and.iter==1) return
 
      !On va rajouter une particule a
      !det1 i--->[xy....]--->a det2 [z...]--->a
      !a et b doivent etre liees au CAS
      !///////////////////////////////////////////////////
      if(w)print*,'mulcccod on ajoute une particule',x1,y1,z1,i
      !///////////////////////////////////////////////////
      n=0
      nntp=0
      call caldfc(idist,1,1)
      call caldfc(idist2,0,1)
      do b1=1,nlcv
         b=ilc(nlco+b1)
         if(il(i,b)==0) cycle
         n=n+1
         itp1(n)=il(i,b)
         itp2(n)=ilc1(b)
         ltp1(n)=1
         nntp(ltp1(n))=nntp(ltp1(n))+1
         if(w)print'(a,20i4)','b,i',b,i,n,
     *   ltp1(n),nntp(ltp1(n)),
     *   itp1(n),itp2(n)
      enddo
      if(n/=0) then
         call reoitp(n,1,nntp)
         if(w)print'(a,20i3)','ITP',itp1(1:n)
         if(w)print'(a,20i3)','ITP',itp2(1:n)
         !
         !
         !
         elmat(1)='I+    -> b+    |       -> b+   '
         !
         aa3=aa1
         call mula0(x,y,z,0)
         !
         if(w)print*,'icas1'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,1,jsgn,'I-')
         call mula(aa3,'-+-o',elmat,n,1,jsgn,'b-')
         !
         if(w)print*,'icas2'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,1,jsgn,'I-','b-')
         call mula(aa3,'-+-o',elmat,n,1,jsgn)
         !
         !==================
         !
         if(x/=y) then
            aa3=aa1-aa2
            ydir=.false.
            yoci((/x,y,z/))=.true.
            if(x==z)yoci(z)=.false.
            if(w)print*,'icas3'
            if(ysp0)call mula(aa3,'+++o',elmat,n,1,jsgn2)
            call mula(aa3,'---o',elmat,n,1,jsgn2,'I-','b-')
            !
            if(w)print*,'icas4'
            if(ysp0)call mula(aa3,'+++o',elmat,n,1,jsgn2,'b-')
            call mula(aa3,'---o',elmat,n,1,jsgn2,'I-')
            ydir=.true.
            yoci((/x,y,z/))=.false.
            !
            !========================
            !
            aa3=aa2
            call mula0(x,y,0,z)
            if(w)print*,'icas5'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,1,jsgn)
            call mula(aa3,'-+o+',elmat,n,1,jsgn,'I-','b-')
            !
            if(w)print*,'icas6'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,1,jsgn,'b-')
            call mula(aa3,'-+o+',elmat,n,1,jsgn,'I-')
            !
         endif
      endif
 
      !On va rajouter un trou j
      !det1 ij--->[xy....] det2 j--->[z...]
      if(igener<2) return
      !//////////////////////////////////////////////
      if(w)print*,'mulcccod on ajoute un trou',x1,y1,z1,i
      !//////////////////////////////////////////////
      ii=ilc1(i)
      if (ii.ne.0) then
         n=0
         nntp=0
         call caldfc(idist,2,0)
         call caldfc(idist2,1,0)
         do jj=1,nlco
            j=ilc(jj)
!            if (j<i) then
            n=n+1
            itp2(n)=jj
            if (ii>jj) then
               itp1(n)=num1(ii)+jj
               ltp1(n)=1
            else if (ii<jj) then
               itp1(n)=num1(jj)+ii
               ltp1(n)=2
            else
               itp1(n)=ii
               ltp1(n)=3
            endif
            nntp(ltp1(n))=nntp(ltp1(n))+1
            if(w)print'(a,20i4)','b,i,j',b,i,j,n,
     *      ltp1(n),nntp(ltp1(n)),
     *      itp1(n),itp2(n)
!            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)=(/'j+ I+ ->       | j+    ->      ',
     *      'I+ j+ ->       | j+    ->      ',
     *      'I+=j+ ->       | j+    ->      '/)
            !
            aa3=aa1
            call mula0(x,y,z,0)
            !
            if(w)print*,'icas1'
            if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-')
            call mula(aa3,'-+-o',elmat,n,3,jsgn,'j-')
            !
            if(w)print*,'icas2'
            if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-','j-')
            call mula(aa3,'-+-o',elmat,n,3,jsgn)
            !
            !================
            !
            if(x/=y) then
               ydir=.false.
               yoci((/x,y,z/))=.true.
               if(x==z)yoci(z)=.false.
               aa3=aa1-aa2
               if(w)print*,'icas3'
               if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2)
               call mula(aa3,'---o',elmat,n,3,jsgn2,'I-','j-')
               !
               if(w)print*,'icas4'
               if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'j-')
               call mula(aa3,'---o',elmat,n,3,jsgn2,'I-')
               ydir=.true.
               yoci((/x,y,z/))=.false.
               !
               !================
               !
               call mula0(x,y,0,z)
               aa3=aa2
               !
               if(w)print*,'icas5'
               if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn)
               call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-','j-')
               !
               if(w)print*,'icas6'
               if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'j-')
               call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-')
               !
            endif
         endif
      endif
 
      !On va rajouter deux particules a et b
      !det1 i---->[xy....]--->ab det2 [z...]--->ab
      !i doit etre lie au CAS
      !i doit etre lie a a
 
      if(igener<3) return
      !/////////////////////////////////////////////////////
      if(w)print*,'mulcccod on ajoute deux particules',x1,y1,z1,i
      !/////////////////////////////////////////////////////
      n=0
      nntp=0
      call caldfc(idist,1,2)
      call caldfc(idist2,0,2)
      do aa=1,nlcv
         do bb=1,aa
            a=ilc(nlco+aa)
            b=ilc(nlco+bb)
            if (ilp(i,a)/=0) then
               if(ipc(ilp(i,a),nlco+ilc1(b))==0) cycle
               n=n+1
               itp1(n)=abs(ipc(ilp(i,a),nlco+ilc1(b)))
               if(a==b) then
                  itp2(n)=bb
                  ltp1(n)=2
               else
                  itp2(n)=num1(aa)+bb
                  ltp1(n)=1
               endif
               nntp(ltp1(n))=nntp(ltp1(n))+1
               if(w)print'(a,20i4)','a,b,i',a,b,i,n,
     *         ltp1(n),nntp(ltp1(n)),
     *         itp1(n),itp2(n)
            elseif(ilp(i,b)/=0) then
               if(ipc(ilp(i,b),nlco+ilc1(a))==0) cycle
               n=n+1
               itp1(n)=abs(ipc(ilp(i,b),nlco+ilc1(a)))
               if(a==b) then
                  itp2(n)=bb
                  ltp1(n)=2
               else
                  itp2(n)=num1(aa)+bb
                  ltp1(n)=1
               endif
               nntp(ltp1(n))=nntp(ltp1(n))+1
               if(w)print'(a,20i4)','a,b,i',a,b,i,n,
     *         ltp1(n),nntp(ltp1(n)),
     *         itp1(n),itp2(n)
            endif
         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)=(/'I+    -> a+ b+ |       -> a+ b+',
     *   'I+    -> a+=b+ |       -> a+=b+'/)
         !
         call mula0(x,y,z,0)
         aa3=aa1
         !
         if(w)print*,'icas1'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,1,jsgn,'I-')
         call mula(aa3,'-+-o',elmat,n,1,jsgn,'a-','b-')
         !
         if(w)print*,'icas2'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,2,jsgn,'I-','b-')
         call mula(aa3,'-+-o',elmat,n,2,jsgn,'a-')
         !
!         if(x/=y) then
         if(w)print*,'icas3'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,1,jsgn,'I-','a-')
         call mula(aa3,'-+-o',elmat,n,1,jsgn,'b-')
!         endif
         !
         if(w)print*,'icas4'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,1,jsgn,'I-','a-','b-')
         call mula(aa3,'-+-o',elmat,n,1,jsgn)
         !
         !============
         !
         if(x/=y) then
            aa3=aa1-aa2
            ydir=.false.
            yoci((/x,y,z/))=.true.
            if(x==z)yoci(z)=.false.
            !
            if(w)print*,'icas5'
            if(ysp0)call mula(aa3,'+++o',elmat,n,1,jsgn2)
            call mula(aa3,'---o',elmat,n,1,jsgn2,'I-','a-','b-')
            !
            if(w)print*,'icas6'
            if(ysp0)call mula(aa3,'+++o',elmat,n,2,jsgn2,'a-')
            call mula(aa3,'---o',elmat,n,2,jsgn2,'I-','b-')
            !
            if(w)print*,'icas7'
            if(ysp0)call mula(aa3,'+++o',elmat,n,1,jsgn2,'b-')
            call mula(aa3,'---o',elmat,n,1,jsgn2,'I-','a-')
            !
            if(w)print*,'icas8'
            if(ysp0)call mula(aa3,'+++o',elmat,n,1,jsgn2,'a-','b-')
            call mula(aa3,'---o',elmat,n,1,jsgn2,'I-')
            ydir=.true.
            yoci((/x,y,z/))=.false.
            !
            !============
            !
            call mula0(x,y,0,z)
            aa3=aa2
            !
            if(w)print*,'icas9'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,1,jsgn)
            call mula(aa3,'-+o+',elmat,n,1,jsgn,'I-','a-','b-')
            !
            if(w)print*,'icasa'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,2,jsgn,'a-')
            call mula(aa3,'-+o+',elmat,n,2,jsgn,'I-','b-')
            !
            if(w)print*,'icasb'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,1,jsgn,'b-')
            call mula(aa3,'-+o+',elmat,n,1,jsgn,'I-','a-')
            !
            if(w)print*,'icasc'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,1,jsgn,'a-','b-')
            call mula(aa3,'-+o+',elmat,n,1,jsgn,'I-')
            !
         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*,'mulcccod on ajoute un trou et une particule',x,y,z,i
      !////////////////////////////////////////////////////////////
 
      n=0
      nntp=0
      call caldfc(idist,2,1)
      call caldfc(idist2,1,1)
      do ipair=1,nlpair
         j=ilpair(1,ipair)
         a=ilpair(2,ipair)
         if (ilc1(i)/=0.and.ilp(j,a)/=0) then
            if(ipc(il(j,a),ilc1(i))==0) cycle
            n=n+1
            if(j<i) then
               ltp1(n)=1
            else if(j>i) then
               ltp1(n)=2
            else
               ltp1(n)=3
            endif
            itp1(n)=abs(ipc(il(j,a),ilc1(i)))
            itp2(n)=il(j,a)
            nntp(ltp1(n))=nntp(ltp1(n))+1
            if(w)print'(a,20i4)','a,j,i',a,j,i,n,
     *      ltp1(n),nntp(ltp1(n)),
     *      itp1(n),itp2(n)
         else
            ipairia=ilp(i,a)
            if(ipairia/=0) then
               ilc1b=ilc1(j)
               if(ilc1b/=0) then
                  if(ipc(ipairia,ilc1b)==0) cycle
                  n=n+1
                  if(j<i) then
                     ltp1(n)=1
                  else if(j>i) then
                     ltp1(n)=2
                  else
                     ltp1(n)=3
                  endif
                  itp2(n)=il(j,a)
                  itp1(n)=abs(ipc(ipairia,ilc1b))
                  nntp(ltp1(n))=nntp(ltp1(n))+1
                  if(w)print'(a,20i4)','a,j,i',a,j,i,n,
     *            ltp1(n),nntp(ltp1(n)),
     *            itp1(n),itp2(n)
               endif
            endif
         endif
      enddo
      if(n>0) then
         call reoitp(n,3,nntp)
         if(w)print'(a,80i3)','ITP',itp1(1:n)
         if(w)print'(a,80i3)','ITP',itp2(1:n)
         elmat(1:3)=(/'j+ I+ -> a+    | j+    -> a+   ',
     *   'I+ j+ -> a+    | j+    -> a+   ',
     *   'j+=I+ -> a+    | j+    -> a+   '/)
         call mula0(x,y,z,0)
         aa3=aa1
         !
         if(w)print*,'icas1'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-')
         call mula(aa3,'-+-o',elmat,n,3,jsgn,'j-','a-')
         !
         if(w)print*,'icas3'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-','a-')
         call mula(aa3,'-+-o',elmat,n,3,jsgn,'j-')
         !
         if(w)print*,'icas5'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,2,jsgn,'I-','j-')
         call mula(aa3,'-+-o',elmat,n,2,jsgn,'a-')
         !
         if(w)print*,'icas7'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,2,jsgn,'I-','a-','j-')
         call mula(aa3,'-+-o',elmat,n,2,jsgn)
         !
         !===============
         !
         if(x/=y) then
            ydir=.false.
            yoci((/x,y,z/))=.true.
            if(x==z)yoci(z)=.false.
            aa3=aa1-aa2
            !
            if(w)print*,'icas21'
            if(ysp0)call mula(aa3,'+++o',elmat,n,2,jsgn2)
            call mula(aa3,'---o',elmat,n,2,jsgn2,'I-','j-','a-')
            !
            if(w)print*,'icas23'
            if(ysp0)call mula(aa3,'+++o',elmat,n,2,jsgn2,'a-')
            call mula(aa3,'---o',elmat,n,2,jsgn2,'I-','j-')
            !
            if(w)print*,'icas25'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'j-')
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-','a-')
            !
            if(w)print*,'icas27'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'a-','j-')
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-')
            ydir=.true.
            yoci((/x,y,z/))=.false.
            !
            !===============
            !
            aa3=aa2
            call mula0(x,y,0,z)
            !
            if(w)print*,'icas31'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,2,jsgn)
            call mula(aa3,'-+o+',elmat,n,2,jsgn,'I-','j-','a-')
            !
            if(w)print*,'icas33'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,2,jsgn,'a-')
            call mula(aa3,'-+o+',elmat,n,2,jsgn,'I-','j-')
            !
            if(w)print*,'icas35'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'j-')
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-','a-')
            !
            if(w)print*,'icas37'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'a-','j-')
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-')
            !
         endif
      endif
 
      !On va rajouter deux particules a et b et un trou j
      !det1 ij--->[xy....]--->ab det2 j--->[z...]--->ab
      if(igener<4) return
      !/////////////////////////////////////////////////////////////////
      if(w)print*,'mulcccod on ajoute un trou et deux particules',
     *x1,y1,z1,i
      !/////////////////////////////////////////////////////////////////
      !
      n=0
      nntp=0
      call caldfc(idist,2,2)
      call caldfc(idist2,1,2)
      do aa=1,nlcv
         a=ilc(aa+nlco)
         jpair=ilp(i,a)
         do ipair=1,nlpairp
            j=ilpair(1,ipair)
            b=ilpair(2,ipair)
            if ((ilp(j,a)/=0).and.(ilc1(b)/=0).and.(a<b)) cycle
            ipair11=ilp(i,a)
            ipair12=ipair
            if(ipair11==0.or.ipair12==0) then
               ipair11=ilp(i,b)
               ipair12=ilp(j,a)
               if(ipair11==0.or.ipair12==0) cycle
            endif
            if(ipc(ipair,nlco+aa)==0) cycle
            iimax=max(ipair11,ipair12)
            iimin=min(ipair11,ipair12)
            ii1=iimax*(iimax-1)/2+iimin
            if(ipp(ii1)==0) cycle
            n=n+1
            itp1(n)=abs(ipp(ii1))
            itp2(n)=abs(ipc(ipair,nlco+aa))
            if(j<i) then
               ltp1(n)=1
            else if(j>i) then
               ltp1(n)=2
            else
               ltp1(n)=3
            endif
            if(a==b) ltp1(n)=ltp1(n)+3
            nntp(ltp1(n))=nntp(ltp1(n))+1
            if(w)print'(a,10i4)','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,80i3)','ITP',itp1(1:n)
         if(w)print'(a,80i3)','ITP',itp2(1:n)
         elmat(1:6)=(/'j+ I+ -> a+ b+ | j+    -> a+ b+',
     *   'I+ j+ -> a+ b+ | j+    -> a+ b+',
     *   'j+=I+ -> a+ b+ | j+    -> a+ b+',
     *   'j+ I+ -> a+=b+ | j+    -> a+=b+',
     *   'I+ j+ -> a+=b+ | j+    -> a+=b+',
     *   'j+=I+ -> a+=b+ | j+    -> a+=b+'/)
         call mula0(x,y,z,0)
         aa3=aa1
         !
         if(w)print*,'icas1'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-')
         call mula(aa3,'-+-o',elmat,n,3,jsgn,'j-','a-','b-')
         !
         if(w)print*,'icas2'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,6,jsgn,'I-','b-')
         call mula(aa3,'-+-o',elmat,n,6,jsgn,'j-','a-')
         !
         if(w)print*,'icas3'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-','a-')
         call mula(aa3,'-+-o',elmat,n,3,jsgn,'j-','b-')
         !
         if(w)print*,'icas4'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-','a-','b-')
         call mula(aa3,'-+-o',elmat,n,3,jsgn,'j-')
         !
         if(w)print*,'icas5'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-','j-')
         call mula(aa3,'-+-o',elmat,n,3,jsgn,'b-','a-')
         !
         if(w)print*,'icas6'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,6,jsgn,'I-','b-','j-')
         call mula(aa3,'-+-o',elmat,n,6,jsgn,'a-')
         !
         if(w)print*,'icas7'
         if(ysp0)call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-','a-','j-')
         call mula(aa3,'-+-o',elmat,n,3,jsgn,'b-')
         !
         if(w)print*,'icas8'
         call mula(aa3,'+-+o',elmat,n,3,jsgn,'I-','b-','j-','a-')
         if(ysp0)call mula(aa3,'-+-o',elmat,n,3,jsgn)
         !
         !===============
         !
         if(x/=y) then
            ydir=.false.
            yoci((/x,y,z/))=.true.
            if(x==z)yoci(z)=.false.
            aa3=aa1-aa2
            !
            if(w)print*,'icas21'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2)
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-','j-','a-','b-')
            !
            if(w)print*,'icas22'
            if(ysp0)call mula(aa3,'+++o',elmat,n,6,jsgn2,'b-')
            call mula(aa3,'---o',elmat,n,6,jsgn2,'I-','j-','a-')
            !
            if(w)print*,'icas23'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'a-')
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-','j-','b-')
            !
            if(w)print*,'icas24'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'a-','b-')
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-','j-')
            !
            if(w)print*,'icas25'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'j-')
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-','b-','a-')
            !
            if(w)print*,'icas26'
            if(ysp0)call mula(aa3,'+++o',elmat,n,6,jsgn2,'b-','j-')
            call mula(aa3,'---o',elmat,n,6,jsgn2,'I-','a-')
            !
            if(w)print*,'icas27'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'a-','j-')
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-','b-')
            !
            if(w)print*,'icas28'
            if(ysp0)call mula(aa3,'+++o',elmat,n,3,jsgn2,'b-','j-','a-')
            call mula(aa3,'---o',elmat,n,3,jsgn2,'I-')
            ydir=.true.
            yoci((/x,y,z/))=.false.
            !
            !===============
            !
            call mula0(x,y,0,z)
            aa3=aa2
            !
            if(w)print*,'icas31'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn)
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-','j-','a-','b-')
            !
            if(w)print*,'icas32'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,6,jsgn,'b-')
            call mula(aa3,'-+o+',elmat,n,6,jsgn,'I-','j-','a-')
            !
            if(w)print*,'icas33'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'a-')
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-','j-','b-')
            !
            if(w)print*,'icas34'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'a-','b-')
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-','j-')
            !
            if(w)print*,'icas35'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'j-')
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-','b-','a-')
            !
            if(w)print*,'icas36'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,6,jsgn,'b-','j-')
            call mula(aa3,'-+o+',elmat,n,6,jsgn,'I-','a-')
            !
            if(w)print*,'icas37'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'a-','j-')
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-','b-')
            !
            if(w)print*,'icas38'
            if(ysp0)call mula(aa3,'+-o-',elmat,n,3,jsgn,'b-','j-','a-')
            call mula(aa3,'-+o+',elmat,n,3,jsgn,'I-')
            !
         endif
      endif
      return
      end
