      SUBROUTINE RBLABL
      IMPLICIT NONE
*
* RBLABL - Read Binary label record into common block
*
* Local Variables...
*    BINREC - Binary record read from input file
*    IOS    - Input/Output status
*
      INCLUDE 'misc.inc'
      INCLUDE 'labl.inc'

      CHARACTER BINREC*500
      INTEGER   IOS

      CALL RBREAD (BINREC)

      IF (BINREC(1:1) .EQ. '1') THEN
         RECKEY = BINREC(1:20)
         RECORD = BINREC(21:)
      ELSE
         RECKEY = ' '
         RECORD = BINREC
      ENDIF

      IF (RECORD(1:6) .NE. 'UARS 1') THEN
         PRINT *,'* Not a UARS label record'
         STOP

      ELSE
         LEVEL = RECORD(106:108)
         IF (LEVEL .EQ. '3AT' .OR. LEVEL .EQ. '3TP') THEN

            READ (UNIT=RECORD,FMT=1000,ERR=900,IOSTAT=IOS)
     +         SATEID,RECTYP,INSTID,SPECIE,FVERNO,PRECNO,NCONTS,NPRECS,
     +         CREATE,FSTYEA,FSTDAY,FSTMIL,LSTYEA,LSTDAY,LSTMIL,
     +         LEVEL,UARSDN,NPEREC,BASEIN,BINLEN,
     +         CCBVER,FCYCNO,VFFLAG,TOTENT,NUMENT
 1000       FORMAT (A4,A2,A12,A12,A4,A8,I4,I8,A23,A3,A3,A8,A3,A3,A8,
     +              A3,A4,A4,A4,I5,A9,A5,A1,I4,I4)

         ELSE

            READ (UNIT=RECORD,FMT=2000,ERR=900,IOSTAT=IOS)
     +         SATEID,RECTYP,INSTID,SPECIE,FVERNO,PRECNO,NCONTS,NPRECS,
     +         CREATE,FSTYEA,FSTDAY,FSTMIL,LSTYEA,LSTDAY,LSTMIL,
     +         LEVEL,UARSDN,NPEREC,BASEIN,BINLEN,MINLAT,MAXLAT,
     +         CCBVER,FCYCNO,VFFLAG,TOTENT,NUMENT
 2000       FORMAT (A4,A2,A12,A12,A4,A8,I4,I8,A23,A3,A3,A8,A3,A3,A8,
     +              A3,A4,A4,A4,I5,A3,A3,A9,A5,A1,I4,I4)

         ENDIF

         IF (TOTENT .NE. 0 .OR. NUMENT .NE. 0) THEN
            PRINT *,'* Warning - the value for the number of'
            PRINT *,'* time/version entries in the label record is'
            PRINT *,'* non-zero. As these entries are only used for'
            PRINT *,'* virtual files created via RAC data transfer,'
            PRINT *,'* they have not been implemented in this code.'
         ENDIF

      ENDIF

      RETURN
*
* Errors...
*
  900 CONTINUE
      PRINT *,'* RBLABL: Read error parsing binary record'
      PRINT *,'          IOSTAT = ',IOS

      END
