
C     PROGRAM PIOPLASM:reads Pioneer 10/11 plasma experiment hi-res summary
C                     dataset in VAX BINARY format and writes some parameters 
C                     within desired time interval in ASCII format.
C
C     Version: 6/29/95, J. F. Cooper / Hughes STX Corp.
C
C     INPUT FILE NAME: TEMPSM.DAT (copied from PnnV23SUM.DAT)- VAX BINARY format
C
C     DEFINE VARIABLE TYPES, DIMENSIONS, COMMON BLOCK, AND EQUIVALENCE
C
         IMPLICIT REAL*4 (A-H,O-W)
         REAL*4 JYDD,NBREC,NSWREC,NHR,NSEC
         CHARACTER*50 OUTFIL
         DIMENSION REC1(27)  ! Summary data
C         DIMENSION REC1(30)  ! Hourly data
         CHARACTER*4 ISCID
C         COMMON /CREC1/  ! Hourly average common block
C     *   ISCID, JYDD, NSEC, RAD, HLONG, HLAT, NBREC, NSWREC, 
C     *   BNON1, BMAG, BAZM, BPOL, BNON2, RBMAG, RBAZM, RBPOL,
C     *   TEM, DEN, VEL, AZM, POL, RTEM, RDEN, RVEL,
C     *   RAZM, RPOL, FLUX, PRES, PCONV, ERG
         COMMON /CREC1/   ! Summary data common block
     *   ISCID, JYDD, NSEC, RAD, HLONG, HLAT, CHISQ, BADREC,
     *   BSCA, BMAG, BAZM, BPOL, DAVGBM, DBMAG, DBAZM, DBPOL,
     *   TEM, DEN, VEL, AZM, POL, DTEM, DDEN, DVEL, DAZM, DPOL,DPROC
C
C     *      ISCID,JYDD,NSEC,RAD,HLONG,HLAT,CHISQ,BADREC,BSCA,BMAG,BAZM,   
C     *      BPOL,DAVGBM,DBMAG,DBAZM,DBPOL,TEM,DEN,VEL,AZM,POL,DTEM,DDEN,   
C     *      DVEL,DAZM,DPOL,DPROC 
         EQUIVALENCE (REC1(1),ISCID)
	 DATA IU/6/,AU/1.497E8/
C
C     OPEN THE INPUT FILE
C
         OPEN(UNIT=10,FILE='TEMPSM.DAT',
     *      STATUS='OLD',READONLY,FORM='UNFORMATTED')
C     OPEN THE OUTPUT FILE
         WRITE(6,*) ' Enter OUTPUT FILENAME (P10PLASM_YYYY.ASC)'
         READ(5,10) OUTFIL
10       FORMAT(A50)
         OPEN(UNIT=20,FILE=OUTFIL,RECL=218,STATUS='NEW')
C
C..   READ IN DESIRED START, STOP DATES AS YYDDD.
C
         WRITE(6,*) ' Enter start & stop dates (yyddd): '
	 READ(5,*) ISTART,ISTOP
C	  WRITE(IU,1003)
C     WRITE OUTPUT HEADER RECORD
         WRITE(20,15) 
15       FORMAT(' SCID   YYDDD    NSEC        RAD HLONG  HLAT    ',
     *      'CHISQ BADREC   BSCA   BMAG   BAZM   BPOL  DAVGBM   ',
     *      'DBMAG   DBAZM   DBPOL       TEM       DEN    VEL    ',
     *      'AZM   POL      DTEM      DDEN      DVEL      DAZM      ',
     *      'DPOL   DPROC')
C
C     READ DATA RECORDS FROM FT10F001. TEST FOR DESIRED INTERVAL.
C
20	 READ(10,END=100) REC1
C         WRITE(6,*) ISCID,JYDD,NSEC
	 IF(JYDD.LT.ISTART) GOTO 20
	 IF(JYDD.GT.ISTOP)  GOTO 100
C
C.....RECORD IS IN DESIRED INTERVAL. WRITE OUTPUT AND READ NEXT RECORD.
C
	 R=RAD/AU
         NHR= NSEC/3600.0  ! Summary data
C
C	 WRITE(IU,1004) ISCID,JYDD,NHR,VEL,DEN,TEM,AZM,POL
         WRITE(20,1005)
     *      ISCID,JYDD,NSEC,RAD,HLONG,HLAT,CHISQ,BADREC,BSCA,BMAG,BAZM,   
     *      BPOL,DAVGBM,DBMAG,DBAZM,DBPOL,TEM,DEN,VEL,AZM,POL,DTEM,DDEN,   
     *      DVEL,DAZM,DPOL,DPROC 
1005     FORMAT(1X,A4,1X,F7.1,1X,F7.1,1X,E10.4,1X,F5.1,1X,F5.1,1X,
     *      F8.2,1X,F6.2,1X,F6.1,1X,F6.1,1X,F6.1,1X,F6.1,1X,F7.2,1X,
     *      F7.2,1X,F7.2,1X,F7.2,1X,E9.3,1X,E9.3,1X,F6.1,1X,F6.1,1X,
     *      F5.1,1X, E9.3,1X,E9.3,1X,E9.3,1X,E9.3,1X,E9.3,1X,F7.1)
         GOTO 20
C
C.....END OF LISTING
C
100      WRITE(6,*) ' END OF INPUT FILE'
300      STOP
C
C     OUTPUT FORMAT STATEMENTS
C
1003  FORMAT(' ISCID  YYDDD  HR    VEL    DEN      TEMP   AZM   POL'//)
1004  FORMAT(2X,A4,1X,F6.0,1X,F3.0,1X,F8.1,1X,F8.3,1X,F9.0,1X,2F7.2)
C
      END			
