      SUBROUTINE PCKIND(IVALUE,ISPIN,SYVEC1,SYVEC2,NSMSZ1,NSMSZ2,
     &                  I,J,A,B)
C
C THIS ROUTINE RETURNS I,J,A AND B FOR IVALUE, WHICH IS THE ABSOLUTE
C  OFFSET IN THE SYMMETRY PACKED LIST.  T
C  IF ISPIN IS 1 OR 2, THE LIST STRUCTURE IS ASSUMED TO BE A<B;I<J AND
C  a<b;i,j RESPECTIVELY.  IF ISPIN IS 3, IT IS ASSUMED TO BE A,b;I,j.
C  NDISSZ IS THE SIZE OF THE DISTRIBUTIONS.
C
CEND
C
      IMPLICIT INTEGER (A-Z)
      DIMENSION SYVEC1(NSMSZ1),SYVEC2(NSMSZ2)
      COMMON /INFO/ NOCCO(2),NVRTO(2)
      COMMON /SYMPOP/ IRPDPD(8,22),ISYTYP(2,500),N(18)
      COMMON /SYMINF/ NSTART,NIRREP,IRREPA(255),IRREPB(255),
     &                DIRPRD(8,8)
      ILRG(IX)=INT(0.5D0*(1.D0+DSQRT(8.d0*IX-7)))+1
      NNM1O2(IX)=(IX*(IX-1))/2
      IGETI(LSTELM,NUMA)=1+(LSTELM-1)/NUMA
      IGETA(LSTELM,NUMA)=LSTELM-(IGETI(LSTELM,NUMA)-1)*NUMA
      IF(IVALUE.Eq.0)THEN
       I=0
       J=0
       A=0
       B=0
       RETURN
      ENDIF
      IF(ISPIN.EQ.3)LIST=46
      IF(ISPIN.EQ.2)LIST=45
      IF(ISPIN.EQ.1)LIST=44
C
C DETERMINE THE DPD IRREP FOR IVALUE.
C
      NSIZ=0
      IBOTL=0
      IBOTR=0
      DO 10 IRREP=1,NIRREP
       NSYDIS=IRPDPD(IRREP,ISYTYP(2,LIST))
       NSYDSZ=IRPDPD(IRREP,ISYTYP(1,LIST))
       NSIZ=NSIZ+NSYDIS*NSYDSZ
       IF(IVALUE.LE.NSIZ)GOTO 20
       IBOTR=IBOTR+NSYDIS
       IBOTL=IBOTL+NSYDSZ
10    CONTINUE
20    NOFF=NSIZ-NSYDIS*NSYDSZ
C
C THE DPD IRREP IS KNOWN, SO DETERMINE THE OFFSET WITHIN THIS IRREP.
C
      IOFF=IVALUE-NOFF
      NSYDIS=IRPDPD(IRREP,ISYTYP(2,LIST))
      NSYDSZ=IRPDPD(IRREP,ISYTYP(1,LIST))
C
C DETERMINE OFFSETS IN BOTH ELEMENTS OF THE DPD LIST FOR THIS IRREP.
C
      if(ioff.eq.0)then
        idisp=0
        ielemp=0
       else
      IDISP=IGETI(IOFF,NSYDSZ)
      IELEMP=IGETA(IOFF,NSYDSZ)
      endif
C
C DETERMINE OFFSETS IN UNPACKED LIST.
C
      IELEMU=SYVEC1(IBOTL+IELEMP)
      IDISU=SYVEC2(IBOTR+IDISP)
      IF(ISPIN.EQ.3)THEN
       J=1+(IDISU-1)/NOCCO(1)
       I=IDISU-(J-1)*NOCCO(1)
       B=1+NOCCO(2)+(IELEMU-1)/NVRTO(1)
       IB=B-NOCCO(2)
       A=NOCCO(1)+IELEMU-(IB-1)*NVRTO(1)
      ELSEIF(ISPIN.LT.3)THEN
       I=ILRG(IDISU)
       A=NOCCO(ISPIN)+ILRG(IELEMU)
       J=IDISU-NNM1O2(I-1)
       B=NOCCO(ISPIN)+IELEMU-NNM1O2(ILRG(IELEMU)-1)
      ENDIF
      RETURN
      END
