******************************************************************
*
*	TITLE:  UNPACK VOYAGER 322 WORD CR-5 EDR SUBHEADER (PLS DATA)
*
*	FILE NAME:  PLSCR5.FOR
*
*	PURPOSE:  TO UNPACK THE SUBHEADER (PLS DATA) ACCORDING TO THE 
*                  SPECIFIED MOD60 FORMAT
* 
*	HISTORY:
*
*	AUTHOR       	  DATE              CHANGE
*	--------          ----              ------
*	S. B. KRAMER     09/26/92           ORIGINAL CODE
*                                           (MODE CR-5)
*
*	CALLING SEQUENCE:  SUBROUTINE PLSCR5()
*
*	MODULES REFERENCED:
*
*		MOVBIT
*
*	COMMON AREAS:
*
*		SEE UNPACK.INC FOR COMMON AREA DEFINITIONS
*
*	PDL:
*
*		EXTRACT MAG AND PLASMA COMMAND WORDS
*		EXTRACT MAG STATUS WORDS
*		RETURN
*
******************************************************************
      SUBROUTINE PLSCR5()
C
      INTEGER*2 TIME(6)
C
      LOGICAL*4 STATIM
C
      DATA ICALL/0/
C
      INCLUDE 'UNPACK.INC'
C
      IF (DRSDAT.NE.35) RETURN
      ICALL = ICALL + 1
C
C MAG COMMAND WORDS
C
      MCOMM1(1) = 0
      MCOMM2(1) = 0
      CALL MOVBIT(PLS,  8,  8, MCOMM1(1), 0)
      CALL MOVBIT(PLS,  0,  8, MCOMM1(1), 8)
      CALL MOVBIT(PLS, 24,  8, MCOMM2(1), 0)
      CALL MOVBIT(PLS, 16,  8, MCOMM2(1), 8)
C
C PLASMA COMMAND WORDS
C
      PCOMM1(1) = 0
      PCOMM2(1) = 0
      CALL MOVBIT(PLS, 40,  8, PCOMM1(1), 0)
      CALL MOVBIT(PLS, 32,  8, PCOMM1(1), 8)
      CALL MOVBIT(PLS, 56,  8, PCOMM2(1), 0)
      CALL MOVBIT(PLS, 48,  8, PCOMM2(1), 8)
C
C MAG COMMAND WORDS
C
      MCOMM1(2) = 0
      MCOMM2(2) = 0
      CALL MOVBIT(PLS, 72,  8, MCOMM1(2), 0)
      CALL MOVBIT(PLS, 64,  8, MCOMM1(2), 8)
      CALL MOVBIT(PLS, 88,  8, MCOMM2(2), 0)
      CALL MOVBIT(PLS, 80,  8, MCOMM2(2), 8)
C
C PLASMA COMMAND WORDS
C
      PCOMM1(2) = 0
      PCOMM2(2) = 0
      CALL MOVBIT(PLS, 104,  8, PCOMM1(2), 0)
      CALL MOVBIT(PLS,  96,  8, PCOMM1(2), 8)
      CALL MOVBIT(PLS, 120,  8, PCOMM2(2), 0)
      CALL MOVBIT(PLS, 112,  8, PCOMM2(2), 8)
C
C MAG COMMAND WORDS
C
      MCOMM1(3) = 0
      MCOMM2(3) = 0
      CALL MOVBIT(PLS, 136,  8, MCOMM1(3), 0)
      CALL MOVBIT(PLS, 128,  8, MCOMM1(3), 8)
      CALL MOVBIT(PLS, 152,  8, MCOMM2(3), 0)
      CALL MOVBIT(PLS, 144,  8, MCOMM2(3), 8)
C
C PLASMA COMMAND WORDS
C
      PCOMM1(3) = 0
      PCOMM2(3) = 0
      CALL MOVBIT(PLS, 168,  8, PCOMM1(3), 0)
      CALL MOVBIT(PLS, 160,  8, PCOMM1(3), 8)
      CALL MOVBIT(PLS, 184,  8, PCOMM2(3), 0)
      CALL MOVBIT(PLS, 176,  8, PCOMM2(3), 8)
C
C SPARE BITS 192-255 (WORDS 7-8)
C
      CONTINUE
C
C MAG STATUS WORDS FORMAT
C
C BIT  15             0                     15             0
C      |______________|                     |______________|
C      |    STAT1     |                     |    STAT2     |
C      +--------------+                     +--------------+
C
C 15 - FILL                                 FILL
C 14 - FILL                                 FILL
C 13 - FILL                                 FILL
C 12 - FILL                                 FILL
C 11 - OBLFM MODE                           OBLFM FLIGHT CALIBRATION
C 10 - OBLFM RANGE BIT 1 (LSB)              IBLFM FLIGHT CALIBRATION
C  9 - OBLFM RANGE BIT 2                    OBHFM FLIGHT CALIBRATION
C  8 - OBLFM RANGE BIT 3 (MSB)              IBHFM FLIGHT CALIBRATION
C  7 - IBLFM MODE                           IFC POLARITY
C  6 - IBLFM RANGE BIT 1 (LSB)              PROCESSOR SELECTION
C  5 - IBLFM RANGE BIT 2                    IBLFM FLIPPER POSITION
C  4 - IBLFM RANGE BIT 3 (MSB)              IBLFM FLIPPER LOCK STATUS
C  3 - OBHFM MODE                           OBLFM FLIPPER POSITION
C  2 - OBHFM RANGE BIT 1                    OBLFM FLIPPER LOCK STATUS
C  1 - IBHFM MODE                           PRIME LFM STATUS
C  0 - IBHFM RANGE BIT 1                    ELECTRICAL FLIPPER
C
C MAG STATUS WORDS FOR MF-1
C
      STAT1(1) = 0
      STAT2(1) = 0
      CALL MOVBIT(PLS, 264,  8, STAT1(1), 0)
      CALL MOVBIT(PLS, 256,  8, STAT1(1), 8)
      CALL MOVBIT(PLS, 280,  8, STAT2(1), 0)
      CALL MOVBIT(PLS, 272,  8, STAT2(1), 8)
c      write(6,'(1x,2(z4.4))') stat1(1),stat2(1)
C
C MAG STATUS WORDS FOR MF-6
C
      STAT1(2) = 0
      STAT2(2) = 0
      CALL MOVBIT(PLS, 296,  8, STAT1(2), 0)
      CALL MOVBIT(PLS, 288,  8, STAT1(2), 8)
      CALL MOVBIT(PLS, 312,  8, STAT2(2), 0)
      CALL MOVBIT(PLS, 304,  8, STAT2(2), 8)
c      write(6,'(1x,2(z4.4))') stat1(2),stat2(2)
C
C MAG STATUS WORDS FOR MF-11
C
      STAT1(3) = 0
      STAT2(3) = 0
      CALL MOVBIT(PLS, 328,  8, STAT1(3), 0)
      CALL MOVBIT(PLS, 320,  8, STAT1(3), 8)
      CALL MOVBIT(PLS, 344,  8, STAT2(3), 0)
      CALL MOVBIT(PLS, 336,  8, STAT2(3), 8)
c      write(6,'(1x,2(z4.4))') stat1(3),stat2(3)
C
C MAG STATUS WORDS FOR MF-16
C
      STAT1(4) = 0
      STAT2(4) = 0
      CALL MOVBIT(PLS, 360,  8, STAT1(4), 0)
      CALL MOVBIT(PLS, 352,  8, STAT1(4), 8)
      CALL MOVBIT(PLS, 376,  8, STAT2(4), 0)
      CALL MOVBIT(PLS, 368,  8, STAT2(4), 8)
c      write(6,'(1x,2(z4.4))') stat1(4),stat2(4)
C
C MAG STATUS WORDS FOR MF-21
C
      STAT1(5) = 0
      STAT2(5) = 0
      CALL MOVBIT(PLS, 392,  8, STAT1(5), 0)
      CALL MOVBIT(PLS, 384,  8, STAT1(5), 8)
      CALL MOVBIT(PLS, 408,  8, STAT2(5), 0)
      CALL MOVBIT(PLS, 400,  8, STAT2(5), 8)
c      write(6,'(1x,2(z4.4))') stat1(5),stat2(5)
C
C MAG STATUS WORDS FOR MF-26
C
      STAT1(6) = 0
      STAT2(6) = 0
      CALL MOVBIT(PLS, 424,  8, STAT1(6), 0)
      CALL MOVBIT(PLS, 416,  8, STAT1(6), 8)
      CALL MOVBIT(PLS, 440,  8, STAT2(6), 0)
      CALL MOVBIT(PLS, 432,  8, STAT2(6), 8)
c      write(6,'(1x,2(z4.4))') stat1(6),stat2(6)
C
C START SPACECRAFT EVENT TIME IN MILLISECONDS OF DAY (UNSIGNED INTEGER)
C
      CALL MOVBIT(PLS, 472, 8, STATIM,  0)
      CALL MOVBIT(PLS, 464, 8, STATIM,  8)
      CALL MOVBIT(PLS, 456, 8, STATIM, 16)
      CALL MOVBIT(PLS, 448, 8, STATIM, 24)
C
C SPARE BITS 480-511 (WORD 16)
C
      CONTINUE
C
C MAG STATUS WORDS FOR MF-31
C
      STAT1(7) = 0
      STAT2(7) = 0
      CALL MOVBIT(PLS, 520,  8, STAT1(7), 0)
      CALL MOVBIT(PLS, 512,  8, STAT1(7), 8)
      CALL MOVBIT(PLS, 536,  8, STAT2(7), 0)
      CALL MOVBIT(PLS, 528,  8, STAT2(7), 8)
c      write(6,'(1x,2(z4.4))') stat1(7),stat2(7)
C
C MAG STATUS WORDS FOR MF-36
C
      STAT1(8) = 0
      STAT2(8) = 0
      CALL MOVBIT(PLS, 552,  8, STAT1(8), 0)
      CALL MOVBIT(PLS, 544,  8, STAT1(8), 8)
      CALL MOVBIT(PLS, 568,  8, STAT2(8), 0)
      CALL MOVBIT(PLS, 560,  8, STAT2(8), 8)
c      write(6,'(1x,2(z4.4))') stat1(8),stat2(8)
C
C MAG STATUS WORDS FOR MF-41
C
      STAT1(9) = 0
      STAT2(9) = 0
      CALL MOVBIT(PLS, 584,  8, STAT1(9), 0)
      CALL MOVBIT(PLS, 576,  8, STAT1(9), 8)
      CALL MOVBIT(PLS, 600,  8, STAT2(9), 0)
      CALL MOVBIT(PLS, 592,  8, STAT2(9), 8)
c      write(6,'(1x,2(z4.4))') stat1(9),stat2(9)
C
C MAG STATUS WORDS FOR MF-46
C
      STAT1(10) = 0
      STAT2(10) = 0
      CALL MOVBIT(PLS, 616,  8, STAT1(10), 0)
      CALL MOVBIT(PLS, 608,  8, STAT1(10), 8)
      CALL MOVBIT(PLS, 632,  8, STAT2(10), 0)
      CALL MOVBIT(PLS, 624,  8, STAT2(10), 8)
c      write(6,'(1x,2(z4.4))') stat1(10),stat2(10)
C
C MAG STATUS WORDS FOR MF-51
C
      STAT1(11) = 0
      STAT2(11) = 0
      CALL MOVBIT(PLS, 648,  8, STAT1(11), 0)
      CALL MOVBIT(PLS, 640,  8, STAT1(11), 8)
      CALL MOVBIT(PLS, 664,  8, STAT2(11), 0)
      CALL MOVBIT(PLS, 656,  8, STAT2(11), 8)
c      write(6,'(1x,2(z4.4))') stat1(11),stat2(11)
C
C MAG STATUS WORDS FOR MF-56
C
      STAT1(12) = 0
      STAT2(12) = 0
      CALL MOVBIT(PLS, 680,  8, STAT1(12), 0)
      CALL MOVBIT(PLS, 672,  8, STAT1(12), 8)
      CALL MOVBIT(PLS, 696,  8, STAT2(12), 0)
      CALL MOVBIT(PLS, 688,  8, STAT2(12), 8)
c      write(6,'(1x,2(z4.4))') stat1(12),stat2(12)
C
C PLASMA WORDS (1200 WORDS)
C
      DO J = 1,1200
       IOFF = (J-1)*8
       CALL MOVBIT(PLS, 640+IOFF, 8, M(J), 0)
      END DO
C
      IF ( SYS2(25) ) THEN
C
       IF ( ICALL.EQ.1 ) THEN
        OPEN(90,FILE='STATUS.DAT',FORM='FORMATTED',STATUS='NEW',
     &       CARRIAGECONTROL='LIST')
         WRITE(90,'('' REC  M   MILLI-         TIME         MAG  MAG'',
     &              ''  PLS  PLS  MAG  MAG'')')
         WRITE(90,'(''  #   O   SECONDS                     CMD  CMD'',
     &              ''  CMD  CMD  STAT STAT'')')
         WRITE(90,'(''      D   OF DAY  YY DDD HH MM SS MS  #1   #2'',
     &              ''   #1   #2   #1   #2'')')
         WRITE(90,'(''      E'')')
         WRITE(90,*)
        END IF
C
       TIME(1) = YEAR3
       CALL CONHOUR(SCETHR,TIME)
       CALL CONSEC(SCETSC,TIME)
       TIME(6) = SCETML
       DO I=1,12
        ICMD = (I-1)/6 + 1
        WRITE(90,800)  RECNUM,DATMOD,STATIM,TIME,
     &                 MCOMM1(ICMD),MCOMM2(ICMD),PCOMM1(1),PCOMM2(1),
     &                 STAT1(I),STAT2(I)
       END DO
      END IF
C
      RETURN
  800 FORMAT(I5,1X,Z2.2,1X,I8,1X,I2,1X,I3.3,3(1X,I2.2),1X,I3.3,
     &       6(1X,Z4.4))
      END
