      SUBROUTINE TERMDF(RET)                                            
C                                                                       
C     THIS ROUTINE EMPTIES BUFFER IF ANY PARTIAL BLOCKS ARE LEFT.       
C     WRITES END OF FILE LABELS.                                        
C                                                                       
C     PARAMETERS ARE AS FOLLOWS:                                        
C     RET = RETURN FLAG, VALUES ARE:                                    
C            0 - NO ERRORS                                              
C                                                                       
      INCLUDE 'SY:DDFCOM.FTN'                                              
      LOGICAL*1 CEOF,PAD
      DATA CEOF/28/
      DATA PAD/94/
      RET=0                                                             
      CALL STRMOV(CEOF,BB(NCHB-1),1)
      N=NCHB
C
C     CALCULATE NO OF PAD CHARACTERS REQUIRED TO FILL OUT A MULTIPLE OF
C     6 BIT AND 8 BIT CHARACTERS AND 2 CHARACTER WORDS.
C
      NX=NCHB-1
      NZ=NX/6
      NZ2=NZ*6
      NZ3=NX-NZ2
      NZ4=6-NZ3
      IF(NZ4.EQ.6) GO TO 79
      DO 78 I=1,NZ4
      CALL STRMOV(PAD,BB(NCHB),1)
      NCHB=NCHB+1
   78 CONTINUE
   79 CONTINUE
      IF(N.LE.NFIRST)N=0                                                
      CALL WRITE8(BB,NCHB-1,1)
      NCHB=NFIRST                                                       
      CALL CHGFIL
      RETURN                                                            
      END                                                               
