      subroutine preadi
      use module
      use moddi
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      print*,'num3',num3(norb+1)
      yw=.false.
!      i=0
!      do icl=1,ncl
!         iacc=0
!         irefus=0
!         do ii=1,nequis(icl)
!            i=i+1
!            do j=1,i-1
!               do k=1,j-1
!                  do l=1,k-1
!                     if(ii==nequis(icl)) then
!                        iacc=iacc+1
!                     else
!                        irefus=irefus+1
!                     endif
!                  enddo
!               enddo
!            enddo
!         enddo   
!         ito=iacc+irefus
!         print'(a,4i4)','icl,iacc,irefus,ito',icl,iacc,irefus,ito
!         print*,':::::::::::::::::::::::::::::'
!      enddo
      itot=0
      iacct=0
      allocate(numa(norb+1))
      numa=0
      do icl=1,ncl
         iacc=0
         do jcl=1,icl
            nj=nequis(jcl)
            do kcl=1,jcl
               nk=nequis(kcl)
               do lcl=1,kcl
                  nl=nequis(lcl)
!                 print*,'preadi,icl',icl,jcl,kcl,lcl
!                 print*,'preadi,nj',nj,nk,nl
                  if(icl==jcl) then
                     if(jcl==kcl) then
                        if(kcl==lcl) then
                           ii=num2(nj)
                           iacc=iacc+ii
                        else
                           ii=num1(nj)*nl
                           iacc=iacc+ii
                        endif
                     else
                        if(kcl==lcl) then
                           ii=num1(nk+1)*(nj-1)
                           iacc=iacc+ii
                        else
                           ii=(nj-1)*nk*nl
                           iacc=iacc+ii
                        endif
                     endif
                  else
                     if(jcl==kcl) then
                        if(kcl==lcl) then
                           ii=num2(nj+1)
                           iacc=iacc+ii
                        else
                           ii=num1(nj+1)*nl
                           iacc=iacc+ii
                        endif
                     else
                        if(kcl==lcl) then
                           ii=num1(nk+1)*nj
                           iacc=iacc+ii
                        else
                           ii=nj*nk*nl
                           iacc=iacc+ii
                        endif
                     endif
                  endif  
!                 print*,'preadi',ii
                  !print'(a,4i4)','classes',icl,jcl,kcl,lcl
                  !print'(a,4i4)','ii,iacc',ii,iacc
                  !print*,':::::::::::::::::::::::::::::'
               enddo
            enddo
         enddo
         ! iacc : nb d'integrales acceptees dans la classe icl
         iacct=iacct+iacc
         numa(iequiloc(icl,nequis(icl))+1)=iacct
!         print*,'icl,iacc',icl,iacc
!         print*,':::::::::::::::::::::::::::::'
      enddo 
      yw=.false.
      if(yw) then
         do k=1,norb
            print*,'num3,numa',k,num3(k+1),numa(k+1)
         enddo
      endif
      return
      end

