      SUBROUTINE GETSET2(NF,G,LEV,NLEV,IBUF,MAXPK,OK) 
C 
C     * JUL 07/03 - A.IRWIN,F.MAJAESS (REVISED FOR F90 AND LINUX PLATFORMS)
C     * MAR 05/02 - F.MAJAESS (REVISE FOR "CHAR" KIND RECORDS)
C     * MAR 30/92 - E.CHAN ( ADD EXTRA BACKSPACE FOR 2-RECORD FORMAT )
C     * JAN 18/80 - J.D.HENDERSON 
C
C     * READS NEXT SET FROM FILE NF INTO ARRAY G. 
C     * IT ASSUMES THAT THE SET ENDS WHEN IT ENCOUNTERS EITHER
C     * AN END OF FILE, A NEW NAME, OR THE FIRST LEVEL IS REPEATED. 
C     * "LABL" AND "CHAR" KIND RECORDS ARE IGNORED. 
C 
C     * IBUF MUST CONTAIN 8 WORDS FOR THE LABEL AND ENOUGH EXTRA WORDS
C     * TO CONTAIN THE PACKED FIELD. 
C     * IBUF(1-8) RETURNS WITH LAST LABEL IN THE SET. 
C     * AN IMMEDIATE E-O-F RETURNS WITH NLEV=0. 
C     * LEV(NLEV) IS SET TO THE LEVEL VALUES FROM IBUF(4).
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      REAL G(1) 
C 
      LOGICAL OK,REC,SPEC 
      INTEGER LEV(1),IBUF(9)
      INTEGER IB(8) 
C-------------------------------------------------------------------
C     * READ NEXT FIELD AND DETERMINE KIND AND SIZE.
C 
      NLEV=0
  140 CALL RECGET(NF,-1,0,0,0,IBUF,MAXPK,OK)
      IF(.NOT.OK) RETURN
      IF(IBUF(1).EQ.NC4TO8("LABL").OR.
     1   IBUF(1).EQ.NC4TO8("CHAR")) GO TO 140
      OK=.TRUE. 
      INITN=IBUF(3) 
      INITL=IBUF(4) 
      KIND=IBUF(1)
      SPEC=(KIND.EQ.NC4TO8("SPEC") .OR. KIND.EQ.NC4TO8("FOUR"))
      NWDS=IBUF(5)*IBUF(6)
      IF(SPEC) NWDS=NWDS*2
C 
C     * READ THE REST OF THE SET. 
C 
  150 NLEV=NLEV+1 
      LEV(NLEV)=IBUF(4) 
      N=(NLEV-1)*NWDS+1 
      CALL RECUP2(G(N),IBUF)
      DO 170 I=1,8
  170 IB(I)=IBUF(I) 
      CALL RECGET(NF,-1,0,0,0,IBUF,MAXPK,REC) 
      IF(.NOT.REC) RETURN 
      IF(IBUF(1).EQ.NC4TO8("LABL").OR.
     1   IBUF(1).EQ.NC4TO8("CHAR")) GO TO 210
      IF(IBUF(3).NE.INITN) GO TO 210
      IF(IBUF(4).EQ.INITL) GO TO 210
      GO TO 150 
C 
C     * BACKSPACE AND RESTORE IBUF BEFORE RETURNING IF NOT AT EOF.
C 
  210 BACKSPACE NF
      BACKSPACE NF
      DO 220 I=1,8
  220 IBUF(I)=IB(I) 
      RETURN
      END 
