      subroutine adrde2(iadrc,iadrp,iadrt,nelc,iscas,ispc1
     *,max_p,nt,ist,ispt1,iadr)
c
c----------------------------------------------------------
c    subroutine d'adressage des determinants
c
c    nt,it,ispt : nb de trous, numero des trous, spin des trous
c    np,ip,ispp : idem pour les part
c----------------------------------------------------------
c
      IMPLICIT REAL*8(A-H,O-X,Z),LOGICAL*1 (Y)
      PARAMETER (maxorb=500,maxsym=8,MNEL=5,maxorbcas=16)
      PARAMETER (MAXELCAS=20)
      common /cs/ noac,nelac,numac(maxorbcas),itype(maxorb),is0,ms2
      common/cas_spin/isz0
      common/sym/itsym(2*maxorb),its(maxsym,maxsym),nsym
      common/mxdetc/maxc(-2:2,maxsym,-2:2),
     *maxca(-2:2,maxsym,maxsym,-2:2)
      dimension maxcl(5*maxsym*5)
      equivalence (maxc(-2,1,-2),maxcl(1))
      common/maxdettrou/maxt(2,maxsym,maxsym,0:1)
      common/maxdetpart/maxp(2,maxsym,maxsym,0:1)
      common /orb/ enuc,eref,norb,noca,nocb
     *,iorb(2*maxorb),ninac,nvirt,noca0
      common/sy2/nts(maxsym),ncs(maxsym),nps(maxsym)
     *,norbs(maxsym)
      common /prep/ nca0,ncb0,ic0(maxorbcas),icamun(maxorb+maxorb)
     *,numt(maxorb),nump(maxorb),nv
     *,gener,yoc(maxorb+maxorb),yrefc(maxorbcas),yac(maxorb)
     *,ygmono,ygddci,ygddc2,ygcas,ygtous
      character*4 gener
      common /ctg/icateg(-2:2,maxsym,-2:2,41)
     *,niit(0:2,maxsym,-1:1)
      common /co_max/ maxtt(2,maxsym,0:1),maxpp(0:2,maxsym,0:1)
      yw=.false.
      yw1=.false.
c     call adrt(nt,it,ispt,iadrt)
c     call adrp(np,ip,ispp,iadrp)
c     call adrc(nca,ica,ncb,icb,iadrc)
c     ist=1
c     ispt1=ispt
c     if(nt.eq.1)then
c        ist=itsym(iorb(it(1)))
c     else
c       if(nt.eq.2)then
c          ist=its(itsym(iorb(it(1))),itsym(iorb(it(2))))
c          ispt1=ispt/nt
c       endif
c     endif
      if(yw) then
         write(6,*)'nt,ispt1,iadrt',nt,ispt1,iadrt
         write(6,*)'iadrc,maxc',iadrc,maxc(nelc,iscas,ispc1)
      endif
c       max_p=maxpp(np,isp,jspin)
      if(yw)write(6,*)'max_p',max_p
      if(yw)write(6,*)'nelc,iscas,ispc1',nelc,iscas,ispc1
      iadrcat=iadrc+maxc(nelc,iscas,ispc1)
     **((iadrp-1)+(iadrt-1)*max_p)
      if(yw)write(6,*)'nelc,iscas,ispc1,nt,ist,ispt1'
     *,nelc,iscas,ispc1,nt,ist,ispt1
      iadr=iadrcat+icateg(nelc,iscas,ispc1,niit(nt,ist,ispt1))
      if(yw)write(6,*)'icateg',icateg(nelc,iscas,ispc1,niit
     *(nt,ist,ispt1))
      if(yw)write(6,*)'iadrt,iadrc,iadrp,iadrcat,iadr'
     *,iadrt,iadrc,iadrp,iadrcat,iadr
      return
      end
