program sedrcnvt c c read reblocked Voyager SEDR file and convert numeric values from c IBM System 370 to VMS representation. c c The SEDR file consists of a series of logical records. Each logical c record contains one navigation block and all pointing vector blocks c associated with it. Each pointing vector block consists of 126 bytes. c Navigation blocks associated with the Jupiter, Uranus and Neptune c encounters have lengths of 252 bytes. All other navigation blocks c are 126 bytes in length. c c A navigation block may be followed by one more pointing vector c records. Word 101 of a pointing vector block contains a flag c indicating the occurance of another pointing vector block. A null c value denotes the last pointing vector block of the logical record. c A value of one indicates another pointing vector block follows. The c last pointing vector block of a logical record may be followed by c a zero filled logical block (126 bytes). c c Written by Sandy Kramer, HSTX, code 692, NASA GSFC, 03/15/96 c modified to interface with SEDRBLOCK program, 09/11/96 - SBK c character chdr(45)*4,dsn*50,projid*4,fileid*4,sedrid*8,scid*1 integer*4 inav(252),ipv(126),ihdr(45),navrec,pvrec,iword(126) logical*1 navread logical*4 lpv(126),lnav(252) real*4 rnav(252),rpv(126) real*8 realtime,pvtime,opvtime c equivalence ( projid, chdr(1) ), ( fileid, chdr(2) ), & ( sedrid, chdr(4) ), ( dataid, chdr(14) ), & ( lnav(7), rnav(7) ), ( lnav(1), iword(1) ) c data arad/1.495985e8/ c include '($iodef)' ! VMS i/o conversion routines c write(6,*) ' Enter input dsn' read(5,'(a)') dsn open(10,file=dsn,convert='ibm',form='unformatted',status='old', & recordtype='variable',readonly) write(6,*) ' Enter output nav dsn' read(5,'(a)') dsn open(11,file=dsn,form='unformatted',status='new', & recordtype='variable',recl=8191) write(6,*) ' Enter output pv dsn' read(5,'(a)') dsn open(12,file=dsn,form='formatted',status='new', & recordtype='variable',recl=8191,carriagecontrol='list') c c read header record c read(10,end=900) chdr(1),chdr(2),ihdr(3),chdr(4),chdr(5),ihdr(6), & ihdr(7),chdr(8),chdr(9),ihdr(10),ihdr(11), & (chdr(i),i=12,27),(ihdr(i),i=28,45) c istat = lib$tra_ebc_asc(chdr(1),chdr(1)) ! EBCDIC to ASCII istat = lib$tra_ebc_asc(chdr(2),chdr(2)) ! EBCDIC to ASCII istat = lib$tra_ebc_asc(chdr(4),chdr(4)) ! EBCDIC to ASCII istat = lib$tra_ebc_asc(chdr(5),chdr(5)) ! EBCDIC to ASCII istat = lib$tra_ebc_asc(chdr(8),chdr(8)) ! EBCDIC to ASCII istat = lib$tra_ebc_asc(chdr(9),chdr(9)) ! EBCDIC to ASCII do i = 12,27 istat = lib$tra_ebc_asc(chdr(i),chdr(i)) ! EBCDIC to ASCII end do c c display header record c write(6,*) chdr(1),chdr(2),ihdr(3),chdr(4),chdr(5),ihdr(6), & ihdr(7),chdr(8),chdr(9),ihdr(10),ihdr(11), & (chdr(i),i=12,27),(ihdr(i),i=28,45) ! header rec c c output header record with conversion to ASCII and VMS integer format c write(11) chdr(1),chdr(2),ihdr(3),chdr(4),chdr(5),ihdr(6), & ihdr(7),chdr(8),chdr(9),ihdr(10),ihdr(11), & (chdr(i),i=12,27),(ihdr(i),i=28,45) c c determine navigation record length (504/1008 bytes) from header info. c all pointing vector records are 126 words (504 bytes) in length. c if ( chdr(14).eq.'LAUN' .or. & chdr(14).eq.'CRUI' .or. & chdr(14).eq.'SATU' .or. & chdr(14).eq.'XCRU' ) then navlen = 126 else if ( chdr(14).eq.'JUPI' .or. & chdr(14).eq.'URAN' .or. & chdr(14).eq.'NEPT' ) then navlen = 252 else write(6,*) write(6,*) 'Invalid SEDR type!' write(6,*) stop end if C C WRITE POINTING VECTOR DATA HDR C WRITE(12,'(''$$VGR'')') C WRITE(12,700) PROJID WRITE(12,701) SEDRID IF ( SEDRID(4:4).EQ.'0' ) SCID = 'B' IF ( SEDRID(4:4).EQ.'1' ) SCID = 'A' WRITE(12,702) SCID WRITE(12,703) WRITE(12,704) WRITE(12,705) WRITE(12,706) WRITE(12,707) WRITE(12,'(''*'')') WRITE(12,709) WRITE(12,710) WRITE(12,'(''*'')') WRITE(12,'(''$$EOH'')') 700 FORMAT('PROJECT ID ',A4) 701 FORMAT('FILE ID ',A8,3X,'POINTING VECTOR FILE') 702 FORMAT('SCID ',A1) 703 FORMAT('CREATION ') 704 FORMAT('BEGIN SCE 00-000/00:00:00.000') 705 FORMAT('CUTOFF SCE 00-000/00:00:00.000') 706 FORMAT('OPTION ') 707 FORMAT('INITIAL ') 709 FORMAT('*',T23,'UNIT',T39,'ECL50',T54,'ECL50',T69,'ECL50') 710 FORMAT('*',T6,'SCET (UTC)',T23,'VECTOR',T36,'X-COMPONENT', & T51,'Y-COMPONENT',T66,'Z-COMPONENT') c c Read navigation and pointing vector records. Expect at least c one pointing vector record to follow a navigation record. c iprd = 0 inrd = 0 navrec = 0 pvrec = 0 navread = .true. opvtime = 0.0d0 10 continue c c verify record type before conversion - SBK 09/08/99 c read(10,end=900) (lnav(i),i=1,126) c write(6,*) 'NAV word 101 = ',iword(101),(iword(i),i=1,4) backspace(10) if ( iword(101).eq.0 .or. iword(101).eq.1 ) then ! found PV rec navread = .false. goto 20 end if c read(10,end=900) (inav(i),i=1,6),(rnav(i),i=7,navlen) inrd = inrd + 1 write(6,*) 'Reading nav rec # ',inrd if ( inav(1).eq.0 ) goto 10 ! skip null record c distance = rnav(51)/arad c write(6,800) (inav(i),i=1,6),distance write(11) (inav(i),i=1,6),(rnav(i),i=7,navlen) navrec = navrec + 1 navread = .false. 20 continue if ( navread ) goto 10 c c read and convert pointing vector record c read(10,end=900) (ipv(i),i=1,8),(rpv(i),i=9,100),ipv(101), & (rpv(i),i=102,103),(lpv(i),i=104,126) iprd = iprd + 1 write(6,*) 'Reading pv rec # ',iprd if ( ipv(1).eq.0 ) then ! skip null pointing vector record navread = .true. goto 10 end if c c time regression check - SBK 09/08/99 c pvtime = realtime(ipv) if ( pvtime.le.opvtime ) goto 30 opvtime = pvtime c if ( ipv(1).lt.2000 ) then ipv(1) = ipv(1) - 1900 else ipv(1) = ipv(1) - 2000 end if write(12,801) (ipv(i),i=1,6),(rpv(i),i=12,14) write(12,802) (rpv(i),i=15,17) write(12,803) (rpv(i),i=18,20) pvrec = pvrec + 1 c 30 continue if ( ipv(101).eq.0 ) then navread = .true. ! expect navigation record next goto 20 else if ( ipv(101).eq.1 ) then navread = .false. ! expect another pointing vector record goto 20 end if c 900 continue write(6,*) write(6,*) navrec,' navigation records written' write(6,*) pvrec,' pointing vector records written' write(6,*) stop 800 format(i4,1x,i3.3,3(1x,i2.2),1x,i3.3,1x,e10.4) 801 format(I2,'-',I3.3,'/',2(I2.2,':'),I2.2,'.',I3.3, & 3X,'PITCH',7X,3(E13.7,2X)) 802 format(22X,'YAW ',7X,3(E13.7,2X)) 803 format(22X,'ROLL ',7X,3(E13.7,2X)) end REAL*8 FUNCTION REALTIME(TIME) C C CONVERT INTEGER CALENDAR TIME INTO DECIMAL YEAR REAL TIME. C INTEGER*4 TIME(6) REAL*8 DAYS C DAYS = 365.0D0 IF (MOD(TIME(1),4).EQ.0) DAYS = 366.0D0 REALTIME = DBLE(TIME(1)) + & DBLE(TIME(2)-1)/DAYS + & DBLE(TIME(3))/24.0D0/DAYS + & DBLE(TIME(4))/60.0D0/24.0D0/DAYS + & DBLE(TIME(5))/60.0D0/60.0D0/24.0D0/DAYS + & DBLE(TIME(6))/1000.0D0/60.0D0/60.0D0/24.0D0/DAYS C C ASSUME 2 DIGIT YEAR. ANY YEAR BEFORE VOYAGER LAUNCH (77) IS IN TO NEXT C CENTURY. C IF (TIME(1).LT.77) REALTIME = REALTIME + 100.0D0 C RETURN END