      SUBROUTINE GETLDR(RTYPE)                                          
C                                                                       
C          THIS SUBROUTINE UNPACKS THE LEADER PORTION OF THE RECORD.    
C        RTYPE IS USED TO DETERMINE WHETHER THE LEADER BEING UNPACKED   
C        IS FOR THE DDF OR THE DF.                                      
C                                                                       
      INCLUDE 'SY:BCOM.FTN'                              
      INCLUDE 'SY:FLGCM.FTN'                                               
      INCLUDE 'SY:LDCOM.FTN'                                               
C                                                                       
      LOGICAL*1 LTMP(2),NZERO,LBLANK                                    
      EQUIVALENCE (ITMP,LTMP(1))                                        
      DATA NZERO/"60/                                                   
      DATA LBLANK/"40/                                                  
      DATA IBLNK/' '/                                                   
      DATA IZERO/'00'/                                                  
      DATA DF/'DF'/                                                     
      DATA DDF/'DDF'/                                                   
C          GET NEXT CHARACTER                                           
C                                                                       
      IF(DEBUG) PRINT 198                                               
  198 FORMAT(' GETLDR')                                                 
  199 FORMAT(' NBLK = ',I5)                                             
       ITMP = NXTCHR(IDUM)                                 
      IF(DEBUG) PRINT 199,NBLK                                          
      IF(DEBUG) PRINT 200, ITMP  ,RTYPE                                  JULY 5
      IF(RTYPE.EQ.DDF) ITMP=NXTCHR(IDUM)                                
  200 FORMAT(' ITMP = ',I3,' RTYPE = ',A4)                              JULY 5
   30 IF (NBLK .EQ. 1)  GO TO 110                                       
C                                                                       
C         TEST FOR SPAN                                                 
C                                                                       
      IF (ITMP .GE. 48 .AND. ITMP .LE. 51)  GO TO 50                    JULY 5
C                                                                       
C         ITMP IS NOT SPAN, CHECK FOR PADDING                           JULY 5
C                                                                       
      IF (ITMP .EQ. 94)  GO TO 40                                       
C
C      -28        JUST MEANS EF                                         JULY 5
C
      IF(IEOF) SPAN=-28                                                 
      IF (IEOF)  RETURN                                                 
C                                                                       
C         ITMP NOT GOOD                                                 
C                                                                       
      PRINT 9000                                                        
      STOP 'ABORT'                                                      
C                                                                       
   40 ITMP = NXTCHR(IDUM)                                               
      IF (ITMP .NE. 94)  GO TO 30                                       
      GO TO 40                                                          
C                                                                       
   50 SPAN = ITMP - 48                                                  JULY 5
C                                                                       
C          GET RECORD COUNT                                             
C                                                                       
      ITMPX=0                                                           
      DO 105  I = 1, 4                                                  
         ITMPX = 10 * ITMPX + (NXTCHR(IDUM)- NZERO)                     
  105 CONTINUE                                                          
      IF(DEBUG) PRINT 201,ITMPX                                         
  201 FORMAT(' IRCT = ',I5)                                              
      IF (SPAN .LE. 2)  IRCH = 0                                        
      IRCT = ITMPX                                                      
      IBEG = 1                                                          
      GO TO 120                                                         
  110 NBLK = 0                                                          
      IBEG = 2                                                          
      IF(RTYPE.EQ.DF) GO TO 120                                         
      LCSC(1) = LTMP(1)                                                 
      GO TO 135                                                         
  120 IF(RTYPE.EQ.DDF) GO TO 130                                        
C                                                                       
C          DF - SKIP CHARACTERS 0 - 6 OF LEADER                         
C                                                                       
      DO 125  I = IBEG, 7                                               
      ITMPB = NXTCHR(IDUM)                                              
  125 CONTINUE                                                          
      GO TO 150                                                         
C                                                                       
C          DDF - GET AND CHECK SUBSYTEM AND CHARACTER SET CONTROLS      
C                                                                       
  130 LCSC(1)=NXTCHR(IDUM)                                              
      IF(DEBUG) PRINT 202, LCSC(1)                                      
  202 FORMAT(' LCSC(1) = ',A1)                                          
  135 IF(LCSC(1) .NE. LBLANK) FAIL=.TRUE.                               
      LCSC(2)=NXTCHR(IDUM)                                              
      IF(ICSC.NE.IBLANK) FAIL=.TRUE.                                    
      IF(DEBUG) PRINT 9001,LCSC                                         
9001  FORMAT(' LCSC = ',2O3)                                            
C                                                                       
C          SKIP CHARACTERS 3 - 4 OF LEADER                              
C                                                                       
      DO 140  I = 3,4                                                   
         LTMP(1) = NXTCHR(IDUM)                                         
  140 CONTINUE                                                          
C                                                                       
C          GET FIELD CONTROL COUNT (FOR NOW, FAIL IF NOT 00)             
C          BLANKS ARE ACCEPTED AS ZEROS ALTHOUGH THIS IS NOT STANDARD
C                                                                       
      LTMP(1)=NXTCHR(IDUM)                                              
      LTMP(2)=NXTCHR(IDUM)
      IF(LTMP(1).EQ.LBLANK.AND.LTMP(2).EQ.LBLANK) PRINT 9003
9003  FORMAT(' FCC WAS   WILL BE SET TO 00')
      IF(LTMP(1).EQ.LBLANK) LTMP(1)=NZERO                               
       IF(LTMP(2).EQ.LBLANK) LTMP(2)=NZERO
      IFCC=ITMP                                                         
      IF(DEBUG) PRINT 9002,LTMP                                         
9002  FORMAT(' LTMP = ',2O3)                                            
      IF(IFCC.NE.IZERO) FAIL=.TRUE.                                     
C                                                                       
C          GET BASE ADDRESS OF DATA                                     
C                                                                       
  150 ITMPX = 0                                                         
      DO 160  I = 7, 11                                                 
      ITMPX=10 * ITMPX + (NXTCHR(IDUM) - NZERO)                         
  160 CONTINUE                                                          
      IBAS=ITMPX                                                        
      IF(DEBUG) PRINT 203,IBAS                                          
  203 FORMAT(' IBAS = ',I5)                                             
C                                                                       
C          SKIP CHARACTERS 12 - 14                                      
C                                                                       
      DO 180 I = 12, 14                                                 
         ITMPB = NXTCHR(IDUM)                                           
  180 CONTINUE                                                          
C                                                                       
C          DECODE ENTRY MAP                                             
C                                                                       
      LLOF = NXTCHR(IDUM)-NZERO                                         
      LSCP = NXTCHR(IDUM)-NZERO                                         
      LTAG = NXTCHR(IDUM)-NZERO                                         
      ITEMPB=NXTCHR(IDUM)                                               
      IF(DEBUG) PRINT 204 , LLOF,LSCP,LTAG                              
  204 FORMAT(' LLOF = ',I5,'LSCP = ',I5,'LTAP = ',I5)                   
C                                                                       
C          END OF LEADER UNPACK                                         
C                                                                       
      RETURN                                                            
C                                                                       
C          FORMATS                                                      
C                                                                       
 9000 FORMAT (1X,'CHARACTER ERROR IN GETLDR, WILL ABORT')               
C                                                                       
      END                                                               
