      SUBROUTINE FILEV(LEVELS,NLEV,IBUF,NFL)
C 
C     * MAR 05/02 - F.MAJAESS (REVISE FOR "CHAR" KIND RECORDS)
C     * AUG 18/92 - E.CHAN    (REPLACE UNFORMATTED READS WITH FBUFFIN)
C     * MAR 16/92 - E.CHAN    (MODIFY FOR CCRN DATA IN 2-RECORD FORMAT)
C     * MAR 11/88 - F.MAJAESS (RETURN IN IBUF WHAT WAS READ IN THE
C                              FIRST RECORD OF THE MULTILEVELS SET) 
C     * MAR 21/80 - J.D.HENDERSON 
C     * FINDS THE NUMBER OF LEVELS IN A SET ON FILE NFL.
C     * THIS IS DONE BY COUNTING RECORDS UNTIL THE LEVEL
C     *  IN IBUF(4) RETURNS TO ITS INITIAL VALUE. 
C     * "LABL" AND "CHAR" KIND RECORDS ARE IGNORED.
C     * THE LEVELS ARRAY RETURNS WITH THE ACTUAL LEVEL VALUES.
C     * AN EMPTY FILE RETURNS WITH NLEV=0.
C 
C     * NFL POSITIVE USES THE FIRST SET ON THE FILE.
C     * NFL NEGATIVE USES THE NEXT SET ON THE FILE. 
C     * NOTE THAT THE FILE IS REWOUND AFTER READING IN BOTH CASES.
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      INTEGER LEVELS(1),IBUF(8),KBUF(8) 
C---------------------------------------------------------------------
C     * READ THE FIRST LABEL. SKIP "LABL" AND "CHAR" KIND RECORDS. 
C     * RETURN IF EOF.
C 
      NF=ABS(NFL)
      IF(NFL.GT.0) REWIND NF
      NLEV=0
C
  110 CALL FBUFFIN(NF,IBUF,-8,K,LEN)
      IF (K.GE.0) GO TO 210
      IF (IBUF(1).EQ.NC4TO8("LABL").OR.
     +    IBUF(1).EQ.NC4TO8("CHAR")) GO TO 110
      INITL=IBUF(4) 
      DO 115 I=1,8
        KBUF(I)=IBUF(I) 
  115 CONTINUE
C 
C     * READ THE REST OF THE LABELS IN THIS SET.
C 
  150 NLEV=NLEV+1 
      LEVELS(NLEV)=IBUF(4)
C 
      CALL FBUFFIN(NF,IBUF,-8,K,LEN)
      IF (K.GE.0) GO TO 200
      IF((IBUF(1).EQ.NC4TO8("LABL")).OR.(IBUF(1).EQ.NC4TO8("CHAR"))
     +                      .OR.(IBUF(4).EQ.INITL )) GO TO 200 
      GO TO 150 
C 
C     * RETURN IN IBUF WHAT WAS READ IN THE FIRST RECORD OF THE SET.
C 
  200 DO 205 I=1,8
        IBUF(I)=KBUF(I) 
  205 CONTINUE
C 
C     * REWIND BEFORE RETURNING.
C 
  210 REWIND NF 
      RETURN
      END 
