      subroutine adrps(np,ip,iadrp)
c
c----------------------------------------------------------
c    subroutine d'adressage des determinants des particules
c    (gener='MR..')
c
c    np,ip : nb de particules, numero des particules
c----------------------------------------------------------
c
      IMPLICIT REAL*8(A-H,O-X,Z),LOGICAL*1 (Y)
      PARAMETER (maxorbcas=16,maxsym=8)
      include 'maxorb.prm'
      common/sy2/nts(maxsym),ncs(maxsym),nps(maxsym)
     *,norbs(maxsym)
      common/sym/itsym(2*maxorb),its(maxsym,maxsym),nsym
      common/sy3/itorbi(maxorb),isbrot(maxorb),itorbc(maxorb)
     *,itorbs(maxorb)
      common /orb/ enuc,eref,norb,noca,nocb
     *,iorb(2*maxorb),ninac,nvirt,noca0
      common /prep2s/ icatts(maxsym,maxsym),icatps(maxsym,maxsym)
      common /prep2/ icatt(2,maxsym,maxsym,-1:1),
     *icatp(2,maxsym,maxsym,-1:1)
     *,itorb(maxorb*2),icatc(maxsym,maxsym,0:maxorbcas,0:maxorbcas)
      dimension idet1(2)
      dimension ip(2)
      yw=.false.
      if(np.eq.0) then
         iadrp=1
      else if(np.eq.1) then
         iadrp=itorb(iorb(ip(1)))
      else
         jp1=iorb(ip(1))
         jp2=iorb(ip(2))
         if(jp1.eq.jp2) then
            iadrp=itorbc(jp1)
         else
            ip1=min(jp1,jp2)
            ip2=max(jp1,jp2)
            if(yw)print*,'dans adrps ip',ip1,ip2
            is1=itsym(ip1)
            is2=itsym(ip2)
            if(is1.eq.is2) then
               idet1(1)=itorb(ip1)
               idet1(2)=itorb(ip2)
               if(yw)print*,'dans adrps idet1',idet1
               call rang2s(nps(is1),2,idet1,iadrp)
               iadrp=iadrp+icatps(is1,is1)
            else
               jp1=itorb(ip1)
               jp2=itorb(ip2)
               iadrp=jp1+(jp2-1)*nps(is1)
     *         +icatps(is1,is2)
               if(yw)write(75,*)'jp1,jp2,is1,is2,nps(is1),icatps',
     *         jp1,jp2,is1,is2,nps(is1),icatps(is1,is2),'$'
               if(yw)call scril
 
            endif
         endif
      endif
      return
      end
 
