CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C
C  NAME : READUMP_PEM_L3TP_DATA.F
C
C  USAGE : THIS PROGRAM READS UARS LEVEL 3TP PEM FILES DISTRIBUTED 
C          FROM THE GSFC DAAC.  TO RUN THIS PROGRAM, TYPE IN THE PROGRAM 
C          NAME. THE PROGRAM WILL PROMPT YOU FOR THE METADATA FILE NAME
C          (*MERA EXTENSION).
C          EXAMPLE: READUMP_PEM_L3TP_DATA 
C                   PLEASE ENTER MATA DATA FILE NAME BELLOW :
C                   PEM_L3TP_SHEPS_ELEC_ED_D0211.V0003_C01_META 
C
C  DESCRIPTION : THIS PROGRAM FIRST OPENS THE METADATA FILE (*.*META) 
C                TO GET THE DATA FILE NAME (*.*PROD), AND ITS PHYSICAL 
C                RECORD SIZE.  THE DATA FILE IS THEN OPENED, AND ITS
C                CONTENTS ARE READ AND DUMPED TO THE SCREEN.
C
C  AUTHOR : KE - JUN SUN   HUGHES_STX
C
C  DATE : FEBRUARY 2, 1994
C
C  LIMITATIONS : THIS PROGRAM AND THE DATA IT READS ARE DESIGNED FOR 
C              MACHINES RUNNING A UNIX OPERATING SYSTEM, AND HAVING  
C              32-BIT ARCHITECTURE. IEEE FLOATING POINT AND/OR INTEGER  
C              VALUES WILL NOT TRANSLATE CORRECTLY ON OTHER MACHINES!
C
C  NOTES : SINCE THIS PROGRAM USES THE METADATA FILE (*.*META) TO GET 
C          THE DATA FILE NAME (*.*PROD) AND RECORD SIZE, BOTH THE DATA 
C          FILE AND ITS CORRESPONDING METADATA FILE MUST BE IN THE SAME 
C          DIRECTORY.
C          NAGWare (nag_decs and nag_pfort) AND ftnchek WERE USED
C          ON THIS PROGRAM TO ENHANCE NETWORK PORTABILITY.
C
C  ALGORITHM INFORMATION : NO CALCULATION IS PERFORMED IN THIS PROGRAM.
C
C  VERSION : 0
C
C  TO COMPILE THIS PROGAM :
C         f77 -o READUMP_PEM_L3TP_DATA READUMP_PEM_L3TP_DATA.F
C       or for SUN machines
C         f77 -DSUNF -o READUMP_PEM_L3TP_DATA READUMP_PEM_L3TP_DATA.F
C     EXECUTABLE CODE WILL BE NAMED READUMP_PEM_L3TP_DATA
C
C
C  MODIFICATION : MAY 12, 1994 BY SANDEE@PEMRAC.SPACE.SWRI.EDU
C                                (SANDEE JEFFERS)
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC


C     .. Local Scalars ..
      CHARACTER HDR*28,DATAFN*170,METAFN*170,LINE*255,NREC*8
      INTEGER I,IOSTT,IREC,IROW,K,NUMBPR,RECSIZ,RLEN,DTYPE,ROW,COL
      INTEGER PHYREC, NUMREC
      INTEGER NALPHA ,ZERO
      REAL LATA,LONA,LATB,LONB
C     ..
C     .. Local Arrays ..
      CHARACTER BUFFER(148)
      INTEGER INT5(5),UDTFA(2),UDTFB(2) 
      REAL FLOAT4(4),DATA(2816),STDV(2816),ELEPRT(88)
      REAL EPSTDV(88),EFITPR(6,6),PFITPR(6,4)
      INTEGER EIFIT(6),PIFIT(4)
      REAL ALLTLN(3),ALPAR(20)      
C     ..

      DO 666 I = 1,170
       DATAFN(I:I) = ' '
 666  CONTINUE

C
C     ** REMOVE THE C-COMMENT BELOW IF USING PROGRAM OUT OF SCRIPT
C     PRINT *,' PLEASE ENTER META DATA FILE NAME BELOW: '
      READ (5,FMT='(A)') METAFN

      OPEN (UNIT=20,FILE=METAFN,STATUS='OLD',ERR=991)

C   SKIP 9 LINES IN META FILE

      DO 111 IROW = 1,9
          READ (20,FMT=50) LINE
  111 CONTINUE

C   GET FILE NAME FROM 10TH LINE TO DECIDE DTYPE

      READ (20,FMT=50) LINE
      DO 112 I = 1,70
          DATAFN(I:I) = LINE(14+I:14+I)
  112 CONTINUE

      IF (DATAFN(11:19) .EQ. 'MEPS_ELEC') THEN
        DTYPE = 1
      ELSE IF (DATAFN(11:19) .EQ. 'MEPS_PROT') THEN
        DTYPE = 4 
      ELSE IF (DATAFN(11:19) .EQ. 'HEPS_ELEC') THEN
        DTYPE = 2
      ELSE
        DTYPE = 3
      END IF

C   SKIP ONE LINE

      READ (20,FMT=50) LINE

C   GET RECORD SIZE

      READ (20,FMT=50) LINE
   50 FORMAT (A80)

      READ (LINE(17:21),FMT=113) RECSIZ
  113 FORMAT (I)

C   GET DATA FILE NAME FROM META DATA FILE

      I = 1
      DO 777 WHILE (METAFN(I:I).NE.' ')
       I = I + 1
 777  CONTINUE
      I = I - 4
      DO 888 K = 1,I
        DATAFN(K:K) = METAFN(K:K)
 888  CONTINUE
      DATAFN(I:I+4) = 'PROD'

C   CLOSE META FILE

      CLOSE (20)

C----------------------------------------------------------
C  NOTE: SGI AND HP READ 4 BYTE WORDS, SUN READS 1 BYTE.
C        ADDED BY JAMES JOHNSON 09/27/94.                  
C----------------------------------------------------------
#ifndef SUNF
      RLEN=RECSIZ/4
#endif
#ifdef SUNF
      RLEN=RECSIZ
#endif

      OPEN (UNIT=10,FILE=DATAFN,STATUS='OLD',ERR=992,FORM='UNFORMATTED',
     +     ACCESS='DIRECT',RECL=RLEN)

      PRINT *,'********************************************'
      PRINT *,' READING   ',DATAFN
      PRINT *,'********************************************'
      READ (10,REC=1,IOSTAT=IOSTT,ERR=993) (BUFFER(K),K=1,148)
      WRITE (6,FMT=*) '   DESCRIPTOR RECORD'
      WRITE (6,FMT=*) '-------------------------------'
      WRITE (6,FMT=*) ' SFDU T(Z) AND L(Z) '
      WRITE (6,FMT=*) '-------------------------------'
      WRITE (6,FMT=*) ' CONTROL ID : ', (BUFFER(K),K=1,4)
      WRITE (6,FMT=*) ' VERSION ID : ',BUFFER(5)
      WRITE (6,FMT=*) ' CLASS ID   : ',BUFFER(6)
      WRITE (6,FMT=*) ' DATA DESCRIPTIVE RECORD ID : ',
     +  (BUFFER(K),K=9,12)
      WRITE (6,FMT=*) ' LENGTH : ', (BUFFER(K),K=13,20)
      WRITE (6,FMT=*) '-------------------------------'
      WRITE (6,FMT=*) ' SFDU T(I) AND L(I) '
      WRITE (6,FMT=*) '-------------------------------'
      WRITE (6,FMT=*) ' CONTROL ID : ', (BUFFER(K),K=21,24)
      WRITE (6,FMT=*) ' VERSION ID : ',BUFFER(25)
      WRITE (6,FMT=*) ' CLASS ID   : ',BUFFER(26)
      WRITE (6,FMT=*) ' DATA DESCRIPTIVE RECORD ID : ',
     +  (BUFFER(K),K=29,32)
      WRITE (6,FMT=*) ' LENGTH : ', (BUFFER(K),K=33,40)
      READ (10,REC=2,IOSTAT=IOSTT,ERR=994) (BUFFER(K),K=1,148)
      WRITE (6,FMT=*) '-------------------------------'
      WRITE (6,FMT=*) '   LABEL RECORD'
      WRITE (6,FMT=*) '-------------------------------'
      WRITE (6,FMT=*) ' SATELLITE ID : ', (BUFFER(K),K=1,4)
      WRITE (6,FMT=*) ' RECORD TYPE  : ', (BUFFER(K),K=5,6)
      WRITE (6,FMT=*) ' INSTRUMENT ID : ', (BUFFER(K),K=7,18)
      WRITE (6,FMT=*) ' DATA SUBTYPE OR SPECIES : ', (BUFFER(K),K=19,30)
      WRITE (6,FMT=*) ' FORMAT VERSION NUMBER : ', (BUFFER(K),K=31,34)
      WRITE (6,FMT=*) ' PHYSICAL RECORD COUNT : ', (BUFFER(K),K=35,42)
      WRITE (6,FMT=*) ' NUMBER OF CONTINUATION RECORD FOR FILE LABEL : '
     +  , (BUFFER(K),K=43,46)
      DO 123 I = 1,8
        NREC(I:I) = BUFFER(I+46)
 123  CONTINUE
      READ(NREC(1:8),FMT=321)NUMREC
 321  FORMAT(I8)
      WRITE (6,FMT=*) ' NUMBER OF PHYSICAL RECORD IN FILE : ',NUMREC
      WRITE (6,FMT=*) ' FILE CREATION TIME : ', (BUFFER(K),K=55,77)
      WRITE (6,FMT=*) ' YEAR FOR 1ST DATA RECORD       : ',
     +  (BUFFER(K),K=78,80)
      WRITE (6,FMT=*) ' DAY OF YEAR OF 1ST DATA RECORD : ',
     +  (BUFFER(K),K=81,83)
      WRITE (6,FMT=*) ' MS OF DAY FOR 1ST DATA RECORD  : ',
     +  (BUFFER(K),K=84,91)
      WRITE (6,FMT=*) ' YEAR FOR LAST DATA RECORD       : ',
     +  (BUFFER(K),K=92,94)
      WRITE (6,FMT=*) ' DAY OF YEAR OF LAST DATA RECORD : ',
     +  (BUFFER(K),K=95,97)
      WRITE (6,FMT=*) ' MS OF DAY FOR LAST DATA RECORD : ',
     +  (BUFFER(K),K=98,105)
      WRITE (6,FMT=*) ' DATA LEVEL : ', (BUFFER(K),K=106,108)
      WRITE (6,FMT=*) ' UARS DAY NUMBER : ', (BUFFER(K),K=109,112)
      WRITE (6,FMT=*) ' NUMBER OF DATA POINTS PER RECORD : ',
     +  (BUFFER(K),K=113,116)
      WRITE (6,FMT=*) ' RECORD LENGTH IN BYTES : ',
     +  (BUFFER(K),K=121,125)
      WRITE (6,FMT=*) ' CCB VERSION NUMBER : ', (BUFFER(K),K=126,134)
      WRITE (6,FMT=*) ' FILE CYCLE NUMBER : ', (BUFFER(K),K=135,139)
      WRITE (6,FMT=*) ' VITUAL FILE FLAG : ',BUFFER(140)
      WRITE (6,FMT=*) ' TOTAL NUMBER OF TIME/VERSION ENTRIES IN FILE : '
     +  , (BUFFER(K),K=141,144)
      WRITE (6,FMT=*) ' NUMBER OF TIME/VERSION ENTRIES IN RECORD : ',
     +  (BUFFER(K),K=145,148)

      IREC = 2

      DO 445  PHYREC = 1, (NUMREC - 1)

      WRITE (6,FMT=*) '---------------------------------------------'
      WRITE (6,FMT=*) ' RECORD ',IREC,'   DATA RECORD'
      WRITE (6,FMT=*) '---------------------------------------------'
  
      IF ((DTYPE .EQ. 1) .OR. (DTYPE .EQ. 4)) THEN
C----------------------------------------------------------
C  NOTE: SGI AND HP USE ERR OPTION, SUN USES END INSTEAD
C        ADDED BY JAMES JOHNSON 09/27/94.                  
C----------------------------------------------------------
#ifdef SUNF
       READ (10,REC=IREC+1,IOSTAT=IOSTT,END=900) HDR,INT5,FLOAT4,NUMBPR,
     +  UDTFA,LATA,LONA,UDTFB,LATB,LONB,DATA,STDV 
#endif
#ifndef SUNF
       READ (10,REC=IREC+1,IOSTAT=IOSTT,ERR=900) HDR,INT5,FLOAT4,NUMBPR,
     +  UDTFA,LATA,LONA,UDTFB,LATB,LONB,DATA,STDV 
#endif

       WRITE (6,FMT=*) ' SATELLITE ID  : ',HDR(1:4)
       WRITE (6,FMT=*) ' RECOORD TYPE  : ',HDR(5:6)
       WRITE (6,FMT=*) ' INSTRUMENT ID : ',HDR(7:18)
       WRITE (6,FMT=*) ' PHYSICAL RECORD COUNT : ',HDR(19:26)
       WRITE (6,FMT=*) ' MAX. NUMB. OF WORDS IN RECORD : ',INT5(1)
       WRITE (6,FMT=222) INT5(4),INT5(5)
       WRITE (6,FMT=*) ' LATITUDE : ',FLOAT4(1),' (DEGREES)'
       WRITE (6,FMT=*) ' LONGITUDE: ',FLOAT4(2),' (DEGREES)'
       WRITE (6,FMT=*) ' NUMB. OF 32-BIT PARAMETER WORDS : ',NUMBPR
       WRITE (6,FMT=223) UDTFA(1),UDTFA(2) 
  223  FORMAT ('  1/3 TIME IN UDTF FORMAT: ',I10,I10,
     +       ' (YEAR DAY, MILLISECONDS)')
       WRITE (6,FMT=*) ' 1/3 LATITUDE : ',LATA,' (DEGREES)'
       WRITE (6,FMT=*) ' 1/3 LONGITUDE: ',LONA,' (DEGREES)'
        WRITE (6,FMT=224) UDTFB(1),UDTFB(2) 
  224  FORMAT ('  2/3 TIME IN UDTF FORMAT: ',I10,I10,
     +       ' (YEAR DAY, MILLISECONDS)')
       WRITE (6,FMT=*) ' 2/3 LATITUDE : ',LATB,' (DEGREES)'
       WRITE (6,FMT=*) ' 2/3 LONGITUDE: ',LONB,' (DEGREES)'
       WRITE (6,FMT=*) 
     +       '----------------------------------------------'
       IF (DTYPE .EQ. 1) THEN
        WRITE (6,FMT=*) '                  MEPS ELECTRON'
       ELSE
        WRITE (6,FMT=*) '                  MEPS PROTON'
       END IF
       WRITE (6,FMT=*) 
     +       '                  Data (erg/cm^3/s) Stdv (erg/cm^3/s)'
       WRITE (6,FMT=*)
     +       '----------------------------------------------'

        DO 250 ROW=0,31
          DO 251 COL=0,87
          I = ROW+32*COL+1 
          IF ((DATA(I).GT. (-3.402823*10.0**38.0)) .AND.
     +        (DATA(I).LT. (3.402823*10.0**38.0))) THEN 
           IF  (DATA(I).NE. 0.0) THEN  
              WRITE(6,255)ROW,COL,DATA(I),STDV(I)
 255          FORMAT('  (',I2,','I2,') ',E,'    ',E)
           END IF 
          ELSE
              WRITE (6,FMT=555)ROW,COL 
 555          FORMAT ('  (',I2,','I2,')     ***  FILL VALUE  ***')
          END IF

 251    CONTINUE
 250   CONTINUE 

      ELSE IF (DTYPE .EQ. 2) THEN
       IF (IREC .EQ. 2) THEN
C----------------------------------------------------------
C  NOTE: SGI AND HP USE ERR OPTION, SUN USES END INSTEAD
C        ADDED BY JAMES JOHNSON 09/27/94.                 
C----------------------------------------------------------
#ifdef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,END=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ALLTLN,NALPHA,ALPAR
#endif
#ifndef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,ERR=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ALLTLN,NALPHA,ALPAR
#endif

        WRITE (6,FMT=*) ' SATELLITE ID  : ',HDR(1:4)
        WRITE (6,FMT=*) ' RECOORD TYPE  : ',HDR(5:6)
        WRITE (6,FMT=*) ' INSTRUMENT ID : ',HDR(7:18)
        WRITE (6,FMT=*) ' PHYSICAL RECORD COUNT : ',HDR(19:26)
        WRITE (6,FMT=*) ' MAX. NUMB. OF WORDS IN RECORD : ',INT5(1)
        WRITE (6,FMT=222) INT5(4),INT5(5)
        WRITE (6,FMT=*) ' LATITUDE : ',FLOAT4(1),' (DEGREES)'
        WRITE (6,FMT=*) ' LONGITUDE: ',FLOAT4(2),' (DEGREES)'
        WRITE (6,FMT=*) ' NUMB. OF 32-BIT PARAMETER WORDS : ',NUMBPR
        WRITE (6,FMT=*) ' DEPOSIT ALTITUDE :',ALLTLN(1),' KM'
        WRITE (6,FMT=*) ' DIPOLE LATITUDE  :',ALLTLN(2),' DEGREES'
        WRITE (6,FMT=*) ' DIPOLE LONGITUDE :',ALLTLN(3),' DEGREES'
        WRITE (6,FMT=*) ' NUMBER OF ALPHAS USED :',NALPHA
        DO 230 I = 1,NALPHA
         WRITE (6,FMT=*)I-1,') ALPHA PARAMETER USED :',ALPAR(I)
 230    CONTINUE
       ELSE
C----------------------------------------------------------
C  NOTE: SGI AND HP USE ERR OPTION, SUN USES END INSTEAD
C        ADDED BY JAMES JOHNSON 09/27/94.                  
C----------------------------------------------------------
#ifdef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,END=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ELEPRT,EPSTDV,EFITPR,EIFIT 
#endif
#ifndef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,ERR=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ELEPRT,EPSTDV,EFITPR,EIFIT 
#endif

        WRITE (6,FMT=*) ' SATELLITE ID  : ',HDR(1:4)
        WRITE (6,FMT=*) ' RECOORD TYPE  : ',HDR(5:6)
        WRITE (6,FMT=*) ' INSTRUMENT ID : ',HDR(7:18)
        WRITE (6,FMT=*) ' PHYSICAL RECORD COUNT : ',HDR(19:26)
        WRITE (6,FMT=*) ' MAX. NUMB. OF WORDS IN RECORD : ',INT5(1)
        WRITE (6,FMT=222) INT5(4),INT5(5)
C  222  FORMAT ('  RECORD TIME IN UDTF FORMAT: ',I10,I10,
C     +       ' (YEAR DAY, MILLISECONDS)')

        WRITE (6,FMT=*) ' LATITUDE : ',FLOAT4(1),' (DEGREES)'
        WRITE (6,FMT=*) ' LONGITUDE: ',FLOAT4(2),' (DEGREES)'
        WRITE (6,FMT=*) ' NUMB. OF 32-BIT PARAMETER WORDS : ',NUMBPR
 
       WRITE (6,FMT=*)
     +       '----------------------------------------------'
       WRITE (6,FMT=*)
     +       '         HEPS ELECTRON'
       WRITE (6,FMT=*)
     +       '         Data (erg/cm^3/s) Stdv (erg/cm^3/s)'
       WRITE (6,FMT=*)
     +       '----------------------------------------------'
        ZERO = 0
        DO 231 I = 1,88
          IF ((ELEPRT(I).GT. (-3.402823*10.0**38.0)) .AND.
     +        (ELEPRT(I).LT. (3.402823*10.0**38.0))) THEN
           IF ((ELEPRT(I).NE. 0.0).OR.(EPSTDV(I).NE.0.0)) THEN
              WRITE(6,256)I-1,ELEPRT(I),EPSTDV(I)
C 256          FORMAT('  (',I2,') ',E,'    ',E)
              ZERO = ZERO + 1
           END IF
          ELSE
              WRITE (6,FMT=556)I-1
C 556          FORMAT ('  (',I2,')     ***  FILL VALUE  ***')
          END IF
 231    CONTINUE
        IF (ZERO .EQ. 0) THEN
         WRITE(6,FMT=*)'    *** ALL VALUES = 0 ***'
        END IF
       WRITE (6,FMT=*)
     +       '----------------------------------------------'
      WRITE (6,FMT=*)
     +       '         Parameters '
        WRITE (6,FMT=*)
     +       '----------------------------------------------'

        DO 232 I = 1,6
          WRITE(6,400) I-1,EFITPR(1,I)
 400      FORMAT(' J1 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,401)I-1, EFITPR(2,I)
 401      FORMAT(' J2 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,402)I-1, EFITPR(3,I)
 402      FORMAT(' G1 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,403)I-1, EFITPR(4,I)
 403      FORMAT(' G2 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,404)I-1, EFITPR(5,I)
 404      FORMAT(' SIGMA FIT PARAMETERS  ',I2,')',E)
          WRITE(6,405)I-1, EFITPR(6,I)
 405      FORMAT(' CHI**2 FIT PARAMETERS ',I2,')',E)
 232    CONTINUE

        DO 238 I = 1,6
          WRITE(6,FMT=*)'I TYPE FIT PARAMETERS ',I-1,')', EIFIT(I)
 238    CONTINUE
       ENDIF 
 
      ELSE IF (DTYPE .EQ. 3) THEN
       IF (IREC .EQ. 2) THEN
C----------------------------------------------------------
C  NOTE: SGI AND HP USE ERR OPTION, SUN USES END INSTEAD
C        ADDED BY JAMES JOHNSON 09/27/94.                  
C----------------------------------------------------------
#ifdef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,END=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ALLTLN
#endif
#ifndef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,ERR=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ALLTLN
#endif

        WRITE (6,FMT=*) ' SATELLITE ID  : ',HDR(1:4)
        WRITE (6,FMT=*) ' RECOORD TYPE  : ',HDR(5:6)
        WRITE (6,FMT=*) ' INSTRUMENT ID : ',HDR(7:18)
        WRITE (6,FMT=*) ' PHYSICAL RECORD COUNT : ',HDR(19:26)
        WRITE (6,FMT=*) ' MAX. NUMB. OF WORDS IN RECORD : ',INT5(1)
        WRITE (6,FMT=222) INT5(4),INT5(5)
        WRITE (6,FMT=*) ' LATITUDE : ',FLOAT4(1),' (DEGREES)'
        WRITE (6,FMT=*) ' LONGITUDE: ',FLOAT4(2),' (DEGREES)'
        WRITE (6,FMT=*) ' NUMB. OF 32-BIT PARAMETER WORDS : ',NUMBPR
        WRITE (6,FMT=*) ' DEPOSIT ALTITUDE :',ALLTLN(1),' KM'
        WRITE (6,FMT=*) ' DIPOLE LATITUDE  :',ALLTLN(2),' DEGREES'
        WRITE (6,FMT=*) ' DIPOLE LONGITUDE :',ALLTLN(3),' DEGREES'
        WRITE (6,FMT=*) ' NUMBER OF ALPHAS USED :',NALPHA
       ELSE
C----------------------------------------------------------
C  NOTE: SGI AND HP USE ERR OPTION, SUN USES END INSTEAD
C        ADDED BY JAMES JOHNSON 09/27/94.               
C----------------------------------------------------------
#ifdef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,END=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ELEPRT,EPSTDV,PFITPR,PIFIT 
#endif
#ifndef SUNF
        READ (10,REC=IREC+1,IOSTAT=IOSTT,ERR=900) HDR,INT5,FLOAT4,
     +  NUMBPR,ELEPRT,EPSTDV,PFITPR,PIFIT 
#endif

        WRITE (6,FMT=*) ' SATELLITE ID  : ',HDR(1:4)
        WRITE (6,FMT=*) ' RECOORD TYPE  : ',HDR(5:6)
        WRITE (6,FMT=*) ' INSTRUMENT ID : ',HDR(7:18)
        WRITE (6,FMT=*) ' PHYSICAL RECORD COUNT : ',HDR(19:26)
        WRITE (6,FMT=*) ' MAX. NUMB. OF WORDS IN RECORD : ',INT5(1)
        WRITE (6,FMT=222) INT5(4),INT5(5)
 222    FORMAT ('  RECORD TIME IN UDTF FORMAT: ',I10,I10,
     +       ' (YEAR DAY, MILLISECONDS)')

        WRITE (6,FMT=*) ' LATITUDE : ',FLOAT4(1),' (DEGREES)'
        WRITE (6,FMT=*) ' LONGITUDE: ',FLOAT4(2),' (DEGREES)'
        WRITE (6,FMT=*) ' NUMB. OF 32-BIT PARAMETER WORDS : ',NUMBPR
 
       WRITE (6,FMT=*)
     +       '----------------------------------------------'
       WRITE (6,FMT=*)
     +       '         HEPS PROTON'
       WRITE (6,FMT=*)
     +       '         Data (erg/cm^3/s) Stdv (erg/cm^3/s)'
       WRITE (6,FMT=*)
     +       '----------------------------------------------'
        ZERO = 0
        DO 631 I = 1,88
          IF ((ELEPRT(I).GT. (-3.402823*10.0**38.0)) .AND.
     +        (ELEPRT(I).LT. (3.402823*10.0**38.0))) THEN
           IF ((ELEPRT(I).NE. 0.0).OR.(EPSTDV(I).NE.0.0)) THEN
              WRITE(6,256)I-1,ELEPRT(I),EPSTDV(I)
 256          FORMAT('  (',I2,') ',E,'    ',E)
              ZERO = ZERO + 1
           END IF
          ELSE
              WRITE (6,FMT=556)I-1
 556          FORMAT ('  (',I2,')     ***  FILL VALUE  ***')
          END IF
 631    CONTINUE
        IF (ZERO .EQ. 0) THEN
         WRITE(6,FMT=*)'    *** ALL VALUES = 0 ***'
        END IF
       WRITE (6,FMT=*)
     +       '----------------------------------------------'
      WRITE (6,FMT=*)
     +       '         Parameters '
        WRITE (6,FMT=*)
     +       '----------------------------------------------'

        DO 532 I = 1,4
          WRITE(6,500) I-1,PFITPR(1,I)
 500      FORMAT(' J1 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,501)I-1, PFITPR(2,I)
 501      FORMAT(' J2 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,502)I-1, PFITPR(3,I)
 502      FORMAT(' G1 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,503)I-1, PFITPR(4,I)
 503      FORMAT(' G2 FIT PARAMETERS     ',I2,')',E)
          WRITE(6,504)I-1, PFITPR(5,I)
 504      FORMAT(' SIGMA FIT PARAMETERS  ',I2,')',E)
          WRITE(6,505)I-1, PFITPR(6,I)
 505      FORMAT(' CHI**2 FIT PARAMETERS ',I2,')',E)
 532    CONTINUE
        DO 538 I = 1,4
          WRITE(6,FMT=*)'I TYPE FIT PARAMETERS ',I-1,')', PIFIT(I)
 538    CONTINUE
       END IF 
      END IF

      IREC = IREC + 1

  445 CONTINUE

  900 WRITE (6,FMT=*) ' END OF DATA'
      GO TO 999
  991 WRITE (6,FMT=*) ' CAN NOT OPEN META DATA FILE. '
      GO TO 999
  992 WRITE (6,FMT=*) ' CAN NOT OPEN DATA PRODUCT FILE. '
      GO TO 999
  993 WRITE (6,FMT=*) ' ERROR IN READING 1ST RECORD. ERROR CODE : ',
     +  IOSTT
      GO TO 999
  994 WRITE (6,FMT=*) ' ERROR IN READING 2ND RECORD. ERROR CODE : ',
     +  IOSTT
      GO TO 999

  999 CLOSE (10)
      CONTINUE
      STOP
      END
