      SUBROUTINE FRMLST(NATOM,IREF,IORBIT,IORDGP,TRNMAT,IATLST,IPTR,
     &                  MEMBER,ICOUNT,JCOUNT)
C
C THIS ROUTINE CREATES THE MEMBER AND TRNMAT ARRAYS FOR A PARTICULAR
C  ORBIT, GIVEN THE REFERENCE ATOM AND IPTR ARRAYS. 
C
      IMPLICIT INTEGER (A-H,O-Z)
      DIMENSION IPTR(NATOM,IORDGP),IATLST(NATOM) 
      INTEGER TRNMAT(NATOM),MEMBER(NATOM)
      PARAMETER (LUOUT = 6)
      JIN=0  
      IFIRST=0
      DO 10 I=1,IORDGP
       IATLST(IPTR(IREF,I))=IORBIT
       TRNMAT(IPTR(IREF,I))=I
       IF(IREF.EQ.IPTR(IREF,I))TRNMAT(IPTR(IREF,I))=0
10    CONTINUE
      DO 33 I=1,NATOM
       IF(IATLST(I).EQ.IORBIT)THEN
        JIN=JIN+1
        ICOUNT=ICOUNT+1
        JCOUNT=JCOUNT+1
        IF(JIN.EQ.1)IFIRST=ICOUNT
        MEMBER(ICOUNT)=I
       ENDIF
 33   CONTINUE
C
C MAKE SURE THAT THE FIRST ENTRY FOR THIS ORBIT IN MEMBER IS THE
C  REFERENCE ATOM. IF NOT, SWAP THE ORDERING.
C
      JLOC=CHKINT(MEMBER,NATOM,IREF)
      IF(JLOC.NE.IFIRST)THEN
       WRITE(LUOUT,100)
100    FORMAT(T3,'@FRMLST-I, Member ordering differs from Z-matrix',
     &           ' order.')
       ITEMP=MEMBER(IFIRST)
       MEMBER(IFIRST)=IREF
       MEMBER(JLOC)=ITEMP
      ENDIF
      RETURN
      END
