      subroutine get_hdr(iarray,oarray)

C Subroutine unpacks RSC-11-6 header; returns results as a 42 element array

C This subroutine calls subroutine  mvbits,  which may not be available on
C  all systems but which transfers bits from an input variable to an output
C  variable as follows:
C
C               call mvbits(a,i,j,b,k)
C  where
C           a   is a 32-bit input, assumed for convenience to be integer
C           b   is a 32-bit output, also assumed integer
C           i   is the least significant bit in  a  to be copied
C                          (msb is 31, lsb is 0)
C           j   is the number of bits to be moved (i+j <= 32)
C           k   is the least significant bit in  b  to be overwritten
C
C  For positive  a  and initial  b=0  the following are equivalent:
C        call mvbits(a,i,j,b,k)   and   b=(mod(a,2**(i+j))/(2**i))*2**k


C Output array of header values contains
C  NB: Original position is in terms of 16-bit words where bit 01 is MSB and
C      bit 16 is LSB.  Internal position is in terms of 32-bit words where
C      bit 00 is LSB and bit 31 is MSB.
C
C           Index    Original    Internal
C            in      Position    Position          Description
C          oarray   (RSC-11-6)  in iarray
C                   Word  Bits  Word  Bits
C          ------  ---- -----  ---- -----  -----------------------------
C             01    01    01    01    31   Time-tag validity indicator
C             02    01    02    01    30   Record continuity indicator
C             03    01    03    01    29   Copy source error indicator
C             04    01    04    01    28   Sample count validity indicator
C             05    01  05-08   01  24-27  ODA tape type indicator
C             06    01  09-16   01  16-23  Tape Number
C             07    02  01-16   01  00-15  Record number
C             08    03  01-16   02  16-31  Record length
C             09    04  01-08   02  08-15  Spacecraft number
C             10    04  09-16   02  00-07  Source station
C             11    05  01-16   03  16-31  DRA tape number
C             12    06  01-04   03  12-15  Data time tag - hundreds of days
C             13    06  05-08   03  08-11                  tens of days
C             14    06  09-12   03  04-07                  units of days
C             15    06  13-16   03  00-03                  tens of hours
C             16    07  01-04   04  28-31                  units of hours
C             17    07  05-08   04  24-27                  tens of minutes
C             18    07  09-12   04  20-23                  units of minutes
C             19    07  13-16   04  16-19                  tens of seconds
C             20    08  01-04   04  12-15                  units of seconds
C             21    08  05-16   04  00-11                  microseconds (part 1)
C                   09  01-08   05  24-31                               (part 2)
C             22    09  09-11   05  21-23  DRA input selection
C             23    09    12    05    20   DRA 1-pps status
C             24    09    13    05    19   DRA clock sync status
C             25    09    14    05    18   Real-time recording monitor
C             26    09    15    05    17   DRA microsecond time status
C             27    09    16    05    16   DRA time-track sync
C             28    10  12-16   05  00-04  Reduction rate
C             29    11  12-16   06  16-20  Channel sampling rate
C             30    12    01    06    15   Reduction rate source
C             31    12  02-04   06  12-14  Reduction rate decimation ratio
C             32    12    05    06    11   1 pps track selection
C             33    12    06    06    10   Time track selection
C             34    12  07-08   06  08-09  Reduction channel selection
C             35    12  09-16   06  00-07  Input block size register (part 1)
C                   13  01-16   07  16-31                            (part 2)
C             36    23  01-09   12  23-31  Reduction day of year
C             37    23    16    12    16   Reduction seconds of day (part 1)
C                   24  01-16   12  00-15                           (part 2)
C             38    26    09    13    07   Input buffer overflow flag
C             39    26    10    13    06   1 pps out-of-sync flag
C             40    26    11    13    05   Bit slip flag
C             41    26  14-16   13  00-02  Decimation counter value
C             42    27  01-16   14  16-31  Sample count (part 1)
C                   28  01-16   14  00-15               (part 2)


      integer*4     iarray(1264)     ! input data record
      integer*4     oarray(42)       ! unpacked header data

      call mvbits(iarray(1),31,01,oarray(01),0)   ! Word 1
      call mvbits(iarray(1),30,01,oarray(02),0)
      call mvbits(iarray(1),29,01,oarray(03),0)
      call mvbits(iarray(1),28,01,oarray(04),0)
      call mvbits(iarray(1),24,04,oarray(05),0)
      call mvbits(iarray(1),16,08,oarray(06),0)

      call mvbits(iarray(1),00,16,oarray(07),0)   ! Word 2

      call mvbits(iarray(2),16,16,oarray(08),0)   ! Word 3

      call mvbits(iarray(2),08,08,oarray(09),0)   ! Word 4
      call mvbits(iarray(2),00,08,oarray(10),0)

      call mvbits(iarray(3),16,16,oarray(11),0)   ! Word 5

      call mvbits(iarray(3),12,04,oarray(12),0)   ! Word 6
      call mvbits(iarray(3),08,04,oarray(13),0)
      call mvbits(iarray(3),04,04,oarray(14),0)
      call mvbits(iarray(3),00,04,oarray(15),0)

      call mvbits(iarray(4),28,04,oarray(16),0)   ! Word 7
      call mvbits(iarray(4),24,04,oarray(17),0)
      call mvbits(iarray(4),20,04,oarray(18),0)
      call mvbits(iarray(4),16,04,oarray(19),0)

      call mvbits(iarray(4),12,04,oarray(20),0)   ! Word 8
      call mvbits(iarray(4),00,12,oarray(21),8)

      call mvbits(iarray(5),24,08,oarray(21),0)   ! Word 9
      call mvbits(iarray(5),21,03,oarray(22),0)
      call mvbits(iarray(5),20,01,oarray(23),0)
      call mvbits(iarray(5),19,01,oarray(24),0)
      call mvbits(iarray(5),18,01,oarray(25),0)
      call mvbits(iarray(5),17,01,oarray(26),0)
      call mvbits(iarray(5),16,01,oarray(27),0)

      call mvbits(iarray(5),00,05,oarray(28),0)   ! Word 10

      call mvbits(iarray(6),16,05,oarray(29),0)   ! Word 11

      call mvbits(iarray(6),15,01,oarray(30),0)   ! Word 12
      call mvbits(iarray(6),12,03,oarray(31),0)
      call mvbits(iarray(6),11,01,oarray(32),0)
      call mvbits(iarray(6),10,01,oarray(33),0)
      call mvbits(iarray(6),08,02,oarray(34),0)
      call mvbits(iarray(6),00,08,oarray(36),24)

      call mvbits(iarray(7),16,16,oarray(36),8)   ! Word 13
      oarray(35) =  rshift(oarray(35),8)
      oarray(36) =0

      call mvbits(iarray(12),23,09,oarray(36),0)  ! Word 23
      call mvbits(iarray(12),16,01,oarray(37),16)

      call mvbits(iarray(12),00,16,oarray(37),0)  ! Word 24

      call mvbits(iarray(13),07,01,oarray(38),0)  ! Word 26
      call mvbits(iarray(13),06,01,oarray(39),0)
      call mvbits(iarray(13),05,01,oarray(40),0)
      call mvbits(iarray(13),00,03,oarray(41),0)

      oarray(42) = iarray(14)                     ! Words 27-28

      return
      end
