! -*- Fortran -*-
! Time-stamp: <struct.inc  Fri Jul 11 18:04:53 MET DST 1997>
!+
! NAME:
!     STRUCT.INC
! OUTPUTS:
!     CHARACTER seq*1           ! A: parameter structure GEN
!                               ! B: raw data structures NDM, HDM1, HDM2
! COMMON BLOCKS:
!     COMMON      /ALL/       GEN
!     COMMON      /ALL0/      NDM
!     COMMON      /ALL1/      HDM1
!     COMMON      /ALL2/      HDM2
! PROCEDURE:
!     Structure GEN is updated by:
!     CLR_GEN     clears all entries
!     FILL_GEN    fills STRUCTURE with data from 1 dim. parameter tape
!     FILL_GEN_FAKE fills STRUCTURE with data from Sorted Data tape
!     FILL_NDM    only GEN.I2A_B and GEN.AzShift entries
!     FILL_HDM1   only GEN.AzShift entry
!     FILL_HDM2   only GEN.AzShift entry
!
!     STRUCTURE NDM is updated by:
!     FILL_NDM
!
!     STRUCTURE HDM1 is updated by:
!     FILL_HDM1
!
!     STRUCTURE HDM2 is updated by:
!     FILL_HDM2
! COMMENTS:
!     The data for each spectrum is contained in two separate records:
!     a parameter record and a raw data record. The parameter record
!     contains orbit/attitude information and all hydrodynamic
!     quantities and is read using the Fortran structure GEN. The raw
!     data record contains the raw count rate data and is read using the
!     Fortran structures NDM, HDM1 or HDM2, depending on the data mode
!     and format. 
!     The unnecessary character byte 'seq' in each DM structure throws
!     off any 2,4,8-byte boundary aligning. An alignment compiler option
!     will have to be used with some compilers: /NOALIGN, /ALIGN=NONE,
!     /ALIGN=PACKED, /ALIGN=(RECORDS=PACKED,COMMONS=PACKED)
! MODIFICATION HISTORY:
!     Feb/Mar 1992, Rainer Schwenn (MPAe)/Paul Hick (UCSD)
!     Nov 96, Jul 97, Kevin Ivory (MPAe) formatting, comments & DEC options
!-
!DEC$ OPTIONS /NOALIGN /WARN=NOALIGN
      STRUCTURE /GEN_STRUCT/
        CHARACTER mSec*8        ! Time of day (1,...,86400000 ms)
        CHARACTER seq*1         ! Sequence character 'A'

        BYTE      Year          ! Year-1900 (74,...,85 a)
        INTEGER*2 Doy           ! Day of year (1,...,366 d)

        BYTE      Helios        ! S/C ID (1,2)
        BYTE      Mode          ! 0=NDM,1=HDM;10=NDM,11=HDM; >1: no raw data
        INTEGER*2 BitRate       ! Bitrate (bps: 2^(3,...,12))
        BYTE      Format        ! Format (1,2,3,5)
        BYTE      DisMod        ! Distribution mode (0,...,7)
        BYTE      Shift         ! Alternating shift: 0=no shift; 1=shift
        BYTE      AzShift       ! Perihelion shift:  0=no shift; 1=shift
        BYTE      I1A_3         ! 1=I1A on; 2=I3 on; 0=both off
        BYTE      I2A_B         ! 1=I2A on; 2=I2B on

        REAL*4    SpinRate      ! Average spin rate (1/s)
        REAL*4    Pitch         ! Pitch angle (deg)
        REAL*4    Aspect        ! Solar aspect angle (deg)

        REAL*4    HelLngAsc     ! Heliographic longitude (from ascending node)
        REAL*4    HelDisSun     ! Heliocentric distance  (0.29,...,1.0 AU)
        REAL*4    HelVrad       ! Radial velocity Helios (AU/day)
        REAL*4    HelVnorm      ! Normal velocity Helios (AU/day)
        REAL*4    HelCarLng     ! Carrington longitude Helios (deg)
        REAL*4    HelCarLat     ! Heliographic latitude (deg)
        INTEGER*2 HelCarRot     ! Carrington rotation number Helios

        REAL*4    EarDisSun     ! Heliocentric distance of Earth (AU)
        REAL*4    EarCarLng     ! Carrington longitude Earth (deg)
        REAL*4    EarCarLat     ! Heliographic latitude Earth (deg)
        INTEGER*2 EarCarRot     ! Carrington rotation number Earth

        REAL*4    HSEangle      ! Helios-Sun-Earth angle (deg)

        REAL*4    Vp_I1A        ! Proton velocity (km/s)
        REAL*4    Tp_I1A        ! Proton temperature (K)
        REAL*4    Np_I1A        ! Proton density (cm^-3)
        REAL*4    AZp_I1A       ! Azimuthal flow angle (deg)
        REAL*4    ELp_I1A       ! Elevational flow angle (deg)

        REAL*4    Valpha        ! Helium velocity (km/s)
        REAL*4    Talpha        ! Helium temperature (K)
        REAL*4    Nalpha        ! Helium density (cm^-3)

        REAL*4    ZeroRate_I1A  ! Average zero count rate

        REAL*4    Vp_I1B        ! Proton velocity (km/s)
        REAL*4    Tp_I1B        ! Proton temperature (K)
        REAL*4    Np_I1B        ! Proton density (cm^-3)

        REAL*4    ZeroRate_I1B  ! Zero count rate average
        REAL*4    ZeroVar_I1B   ! Zero count rate variation

        REAL*4    Bx            ! Magnetic field x (0.01 nT)
        REAL*4    By            ! Magnetic field y (0.01 nT)
        REAL*4    Bz            ! Magnetic field z (0.01 nT)

        REAL*4    BxSig         ! Magnetic field sigma x (0.01 nT)
        REAL*4    BySig         ! Magnetic field sigma y (0.01 nT)
        REAL*4    BzSig         ! Magnetic field sigma z (0.01 nT)

        REAL*4    I1Aint(5)     ! Raw data finger print /  from 1 dim.  \
        REAL*4    I1B(5)        ! Raw data finger print \ parameter tape/
      END STRUCTURE             ! 198 bytes

      STRUCTURE /NDM_STRUCT/    ! Used when GEN.Mode = 0
        CHARACTER mSec*8        ! Time of day (1,...,86400000 ms)
        CHARACTER seq*1         ! Sequence character 'B'
        INTEGER*4 Init(8)       ! Initial data quality words
        INTEGER*4 Qw(5)         ! Instrument quality words
        BYTE      MaxEl         ! Elevation index of max (1,...,8)
        BYTE      MaxAz         ! Azimuth index of max (1,...,16)
        BYTE      MaxEn         ! Energy index of max (1,...,32)
        BYTE      Mass          ! Mass channel index (instrument I3)
        REAL*4    I1B(32)       ! Complete integrated I1b data
        REAL*4    I1Aint(32)    ! (Az & El)-integrated I1a/I3 data
        INTEGER*4 I2AB(8,16)    ! Electron data (instrument I2 a or b)
        REAL*4    I1A_3(5,5,9)  ! Proton+alpha data (instruments I1a/I3)
! (el,az,en) -> (maxel-2:maxel+2,maxaz-2:maxaz+2,maxen-2:maxen+6)
      END STRUCTURE             ! 1733 bytes

      STRUCTURE /HDM1_STRUCT/   ! Used when GEN.Mode=1, GEN.Format=1,5
        CHARACTER mSec*8        ! Time of day (1,...,86400000 ms), EDF 1
        CHARACTER seq*1         ! Sequence character 'B'
        INTEGER*4 mSecE(2:4)    ! Times of EDF 2,3,4
        INTEGER*4 Init(8,4)     ! Initial data quality words
        INTEGER*4 Qw(5,4)       ! Instrument quality words
        BYTE      MaxEl(4)      ! Elevation index of max (1,...,8)
        BYTE      MaxAz(4)      ! Azimuth index of max (1,...,16)
        BYTE      MaxEn(4)      ! Energy index of max (1,...,32)
        BYTE      Mass(4)       ! Mass channel index (instrument I3)
        REAL*4    I1B(32)       ! Complete integrated I1b data
        REAL*4    I1Aint(32)    ! (Az & El)-integrated I1a/I3 data
        INTEGER*4 I2AB(8,32)    ! Electron data (instrument I2 a and b)
        REAL*4    I1A_3(7,7,32) ! Proton+alpha data (instrument I1a/I3)
                                ! (el,az,en) -> (2:7,5:11,1:32)
      END STRUCTURE             ! 7797 bytes

      STRUCTURE /HDM2_STRUCT/   ! Used when GEN.Mode=1, GEN.Format=2,3
        CHARACTER mSec*8        ! Time of day (1,...,86400000 ms), EDF 1
        CHARACTER seq*1         ! Sequence character 'B'
        INTEGER*4 mSecE(2:4)    ! Times of EDF 2,3,4
        INTEGER*4 Init(8,4)     ! Initial data quality words
        INTEGER*4 Qw(5,4)       ! Instrument quality words
        BYTE      MaxEl(4)      ! Elevation index of max (1,...,8)
        BYTE      MaxAz(4)      ! Azimuth index of max (1,...,16)
        BYTE      MaxEn(4)      ! Energy index of max (1,...,32)
        BYTE      Mass(4)       ! Mass channel index (instrument I3)
        REAL*4    I1B(32)       ! Complete integrated I1b data
        REAL*4    I1Aint(32)    ! (Az & El)-integrated I1a/I3 data
        INTEGER*4 I2AB(8,32)    ! Electron data (instrument I2 a and b)
        REAL*4    I1A_3(6,7,32) ! Proton+alpha data (instrument I1a/I3)
                                ! (el,az,en) -> (2:6,5:11,1:32)
      END STRUCTURE             ! 6901 bytes

      RECORD /GEN_STRUCT/     GEN
      RECORD /NDM_STRUCT/     NDM
      RECORD /HDM1_STRUCT/    HDM1
      RECORD /HDM2_STRUCT/    HDM2

      COMMON      /ALL/       GEN
      COMMON      /ALL0/      NDM
      COMMON      /ALL1/      HDM1
      COMMON      /ALL2/      HDM2
!DEC$ END OPTIONS