      SUBROUTINE HEADFILL(TFLAG,EDRTIME,SCMODE)
C
C FILL SUMMARY HEADER BLOCK
C
      CHARACTER TFLAG*4,RECTYPE*4,FLTID*4,TIMEFMT*4,TELFMT*4,
     &          DM(0:31)*4
C
      INTEGER*2 EDRTIME(6),TIME(6),CURRYEAR(6),LAUNCH(6),MODCNT(3),
     &          DATATYPE(2),COUNT(2),MAGCOMM(2),STATUS(2)
C
      INTEGER*4 SCMODE
C
      REAL*4 HDR(32)
C
      REAL*8 DD,TD
C
      INCLUDE 'UNPACK.INC'
C
      EQUIVALENCE (SUMOUT(1),HDR(1))
C
      EQUIVALENCE (HDR(1),RECTYPE),        (HDR(2),TELFMT),
     &            (HDR(3),FLTID),          (HDR(4),TIME(1)),
     &            (HDR(7),DD),             (HDR(9),TD),
     &            (HDR(11),TIMEFMT(1:1)),  (HDR(12),TIMEPD),
     &            (HDR(13),MODCNT(1)),     (HDR(15),STATUS(1)),
     &            (HDR(16),MAGCOMM(1)),    (HDR(17),DATATYPE(1)),   
     &            (HDR(32),COUNT(1))
C
      DATA DM/'ENG ','CR-2','CR-3','CR-4','CR-5','CR-6','CR-7','CR-1',
     &        'G10A','****','GS-3','****','GS-7','****','GS-6','GS-4',
     &        '****','GS-2','****','****','****','****','OC-2','OC-1',
     &        'CR5A','GS10','GS-8','****','****','UV5A','****','****'/
C
C DATA TIME
C
      DO I = 1,6
       TIME(I) = EDRTIME(I)
      END DO
C
C TIME TYPE
C
      TIMEFMT = TFLAG
C
      LAUNCH(1) = 77
      LAUNCH(2) = 232
      LAUNCH(3) = 0
      LAUNCH(4) = 0
      LAUNCH(5) = 0
      LAUNCH(6) = 0
      CALL ELPSTIME(LAUNCH,TIME,TD)
C
      CURRYEAR(1) = TIME(1)
      CURRYEAR(2) = 1
      CURRYEAR(3) = 0
      CURRYEAR(4) = 0
      CURRYEAR(5) = 0
      CURRYEAR(6) = 0
      CALL ELPSTIME(CURRYEAR,TIME,DD)
C
C TELEMETRY FORMAT
C
      TELFMT = DM(DATMOD)
C
C S/C ID
C
      IF (SCID.EQ.0) THEN 
       FLTID = 'FLT2'
      ELSE IF (SCID.EQ.1) THEN
       FLTID = 'FLT1'
      ELSE IF (SCID.EQ.2) THEN
       FLTID = 'PTM '
      ELSE IF (SCID.EQ.3) THEN
       FLTID = 'SIM1'
      ELSE IF (SCID.EQ.4) THEN
       FLTID = 'SIM2'
      ELSE
       FLTID = 'UKWN'
      END IF
C
C COUNTERS
C
      MODCNT(1) = MOD216
      MODCNT(2) = MOD60
      MODCNT(3) = LINCNT
C
C ASSIGN FIRST MAG STATUS WORD OF SUB-HEADER BLOCK TO SUMMARY HEADER
C
      STATUS(1) = STAT1(1)
      STATUS(2) = STAT2(1)
C
C MAG COMMAND WORD
C
      MAGCOMM(1) = MCOMM1(1)
      MAGCOMM(2) = MCOMM2(1)
C
C DATA RATE
C
      DATATYPE(2) = SCMODE
C
      RETURN
      END
