      subroutine caliz(nat,ial)
      use module
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! matrice iz, pour l'adressage Handy
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
      logical yw,yw1
      yw=.false.
      yw1=.false.
      if(yw1) then
              print*,'caliz,nat,ial',nat,ial
      endif
      DO L=1,nat
         IFIN=MIN0(ial-1,L)
         DO K=1,IFIN
            IZZ=0
            DO M=nat-L+1,nat-K
               if(yw)write(6,*)'izz',izz
               if(yw)print*,'C',M,ial-K,C(M,ial-K),M-1,ial-K-1,
     *         C(M-1,ial-K-1)
               IZZ=IZZ+C(M,ial-K)-C(M-1,ial-K-1)
            enddo
            if(yw)write(6,*)'izz',izz
            iz(K,L,ial)=IZZ
            if(yw)print*,'k,l,iz',k,l,iz(k,l,ial)
         enddo
         if(yw1)print*,'l,iz(K,L,ial)',l,iz(1:ifin,l,ial)
         if(yw)print*,'ial,l',ial,l
         iz(ial,L,ial)=L-ial
         if(yw1)print*,'L,iz(ial,L,ial)',l,iz(ial,l,ial)
         if(yw)print*,'ial,l,iz',ial,l,iz(ial,l,ial)
      enddo
      return
      end
       subroutine rang2(ial,idet1,irang)
      use module
      integer idet1(ial)
      logical yw
      yw=.false.
      if(yw)write(6,*)'entree dans rang2'
      if(yw)write(6,*)'ial,idet1',ial,(idet1(k),k=1,ial)
      irang=1
      DO I=1,ial
         ID=idet1(I)
         if(yw)write(6,*)'I,ID',I,ID
         irang=irang+iz(I,ID,ial)
         if(yw)write(6,*)'i,id,iz(i,id,ial)',i,id,iz(i,id,ial)
         if(yw)write(6,*)'irang,ial',irang,ial
      enddo
      if(yw)print*,'irang sortie rang2',irang
      return
      end
