      SUBROUTINE ENGOUT(ENG)
C
C READ 60 MINOR FRAMES OF ENGINEERING DATA.  EACH MINOR FRAME CONTAINS 60
C ENGINEERING WORDS REPRESENTING COMMUTATOR POSITIONS 100 THROUGH 159.
C THE 60 COMMUTATOR POSITIONS ARE MAPPED TO 223 DECK WORDS.  COMMUTATOR 
C WORDS 116, 120, 125, 130, 146, 150 AND 156 ARE MAPPED TO SPECIFIC DECK
C WORDS ACCORDING TO ENGINEERING MINOR FRAME COUNT.  ONCE ENGINEERING WORDS
C ARE MAPPED TO CORRESPONDING DECK WORDS, THE DECOMMUTATION MAP PROVIDES
C IDENTIFICATION OF A PARTICULAR ENGINEERING WORD.
C
C ORIGINAL SOURCE WRITTEN BY SANDY KRAMER, CODE 692, 06/09/94
C ENHANCED TO MAP ENGINEERING DATA - SBK  05/13/96
C
      CHARACTER DATAID*4
      LOGICAL*1 ENG(3600),COM(60),EDAT(224,60),EVAL(0:720)/721*0/
      INTEGER*2 DATATYPE(2),WORD32(2)
      INTEGER*4 COM116(60),COM120(60),COM125(60),COM130(60),
     &          COM146(60),COM150(60),COM155(60)
C
      INTEGER*2 TABLE(223)/ 100,101,102,103,104,105,106,107,108,109,110,
     &  111,112,113,114,115,300,301,302,303,304,305,306,307,308,309,310,
     &  311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,
     &  327,328,329,117,118,119,500,501,502,503,504,505,506,507,508,509,
     &  510,511,512,513,514,121,122,123,124,200,201,202,203,204,205,206,
     &  207,208,209,126,127,128,129,400,401,402,403,404,405,406,407,408,
     &  409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,
     &  425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,
     &  441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,
     &  457,458,459,131,132,133,134,135,136,137,138,139,140,141,142,143,
     &  144,145,330,331,332,333,334,335,336,337,338,339,340,341,342,343,
     &  344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,
     &  147,148,149,600,601,602,603,604,605,606,607,608,609,610,611,612,
     &  613,614,151,152,153,154,210,211,212,213,214,215,216,217,218,219,
     &  156,157,158,159/
C
      REAL*4 HDR(32)
C
      EQUIVALENCE (SUMOUT,       HDR(1)), (HDR(1),       DATAID),
     &            (HDR(12),      TIMEPD), (HDR(17), DATATYPE(1)), 
     &            (HDR(32),    WORD32(1)                       )
C
      DATA COM116
     &      /300,301,302,303,304,305,306,307,308,309,
     &       310,311,312,313,314,315,316,317,318,319,
     &       320,321,322,323,324,325,326,327,328,329,
     &       300,301,302,303,304,305,306,307,308,309,
     &       310,311,312,313,314,315,316,317,318,319,
     &       320,321,322,323,324,325,326,327,328,329/
C
      DATA COM120
     &      /500,501,502,503,504,505,506,507,508,509,
     &       510,511,512,513,514,500,501,502,503,504,
     &       505,506,507,508,509,510,511,512,513,514,
     &       500,501,502,503,504,505,506,507,508,509,
     &       510,511,512,513,514,500,501,502,503,504,
     &       505,506,507,508,509,510,511,512,513,514/
C
      DATA COM125
     &      /200,201,202,203,204,205,206,207,208,209,
     &       200,201,202,203,204,205,206,207,208,209,
     &       200,201,202,203,204,205,206,207,208,209,
     &       200,201,202,203,204,205,206,207,208,209,
     &       200,201,202,203,204,205,206,207,208,209,
     &       200,201,202,203,204,205,206,207,208,209/
C
      DATA COM130
     &      /400,401,402,403,404,405,406,407,408,409,
     &       410,411,412,413,414,415,416,417,418,419,
     &       420,421,422,423,424,425,426,427,428,429,
     &       430,431,432,433,434,435,436,437,438,439,
     &       440,441,442,443,444,445,446,447,448,449,
     &       450,451,452,453,454,455,456,457,458,459/
C
      DATA COM146
     &      /330,331,332,333,334,335,336,337,338,339,
     &       340,341,342,343,344,345,346,347,348,349,
     &       350,351,352,353,354,355,356,357,358,359,
     &       330,331,332,333,334,335,336,337,338,339,
     &       340,341,342,343,344,345,346,347,348,349,
     &       350,351,352,353,354,355,356,357,358,359/
C
      DATA COM150
     &      /600,601,602,603,604,605,606,607,608,609,
     &       610,611,612,613,614,600,601,602,603,604,
     &       605,606,607,608,609,610,611,612,613,614,
     &       600,601,602,603,604,605,606,607,608,609,
     &       610,611,612,613,614,600,601,602,603,604,
     &       605,606,607,608,609,610,611,612,613,614/
C
      DATA COM155
     &      /210,211,212,213,214,215,216,217,218,219,
     &       210,211,212,213,214,215,216,217,218,219,
     &       210,211,212,213,214,215,216,217,218,219,
     &       210,211,212,213,214,215,216,217,218,219,
     &       210,211,212,213,214,215,216,217,218,219,
     &       210,211,212,213,214,215,216,217,218,219/
C
      DATA ICNT/0/
C
      INCLUDE 'UNPACK.INC'
C
      ICNT = ICNT + 1
      RECWRITE = RECWRITE + 1
      DATAID = 'ENG '
      TIMEPD = 0.0
      DATATYPE(1) = 7
      WORD32(1) = RECWRITE
      WORD32(2) = 3416
C
C     IF ( ICNT.EQ.1 ) 
C    & OPEN(87,FILE='ENG.DAT',STATUS='NEW',FORM='UNFORMATTED',
C    &      RECORDTYPE='VARIABLE',RECL=8191)
C
      DO J = 1,60
C
C EXTRACT 8-BIT ENGINEERING DATA.  FIRST EIGHT WORDS CORRESPOND TO MEASUREMENT
C NUMBERS E-160 THROUGH E-167.  E-160 THROUGH E-163 CONTAIN THE HEX FRAME
C SYNCHRONIZATION CODE 03915ED3.
C
       DO I = 1,60
C
        K = (J-1)*480 + (I-1)*8
        CALL MOVBIT(ENG, K, 8, COM(I), 0)
        L = I + 99  ! commuter number
        IF ( L.EQ.116 ) L = COM116(J)
        IF ( L.EQ.120 ) L = COM120(J)
        IF ( L.EQ.125 ) L = COM125(J)
        IF ( L.EQ.130 ) L = COM130(J)
        IF ( L.EQ.146 ) L = COM146(J)
        IF ( L.EQ.150 ) L = COM150(J)
        IF ( L.EQ.155 ) L = COM155(J)
C
        DO IMAP = 1,223
         INDEX = TABLE(IMAP)  ! get deck number
         IF ( L.EQ.INDEX ) THEN
          EVAL(MAP(IMAP)) = COM(I)  ! save measurement
          EDAT(IMAP,J) = COM(I)  ! save measurements from each MF
         END IF
        END DO
C
       END DO
C
C       if ( eval(160).eq.'03'x .and.
C     &      eval(161).eq.'91'x .and.
C     &      eval(162).eq.'5e'x .and.
C     &      eval(163).eq.'d3'x )
C     &  WRITE(87) (MAP(I),I=1,223),(EVAL(MAP(I)),I=1,223)
C
      END DO
C
C output 14016 byte record (3504 words)
C
      WRITE(66) HDR, MAP, EDAT 
C
      RETURN
      END
