program readsedr c c This routine reblocks binary FTP'd Voyager SEDR files written in c IBM System 370 format to restore the original record structure. c EBCDIC character data residing in the header record is converted c to ASCII format. c c Navigation and pointing vector blocks are separated into individual c records. Null pointing vector blocks are eliminated. c c Conversion of binary data to the VMS representation is performed by c a separate routine to be called after reblocking. c character chdr(45)*4,dsn*50 integer*4 ihdr(45),pvlen logical*1 navrec,fill logical*4 lrec(128),lnav(252),lpv(126) c equivalence ( lpv(101), nextpv ) c include '($iodef)' ! VMS i/o conversion routines c c open spanned binary input file of IBM 370 format data c write(6,*) ' Enter dsn' read(5,'(a)') dsn write(6,*) dsn open(10,file=dsn,form='unformatted',status='old',readonly) c c open VAXG format output file of variable length records c write(6,*) ' Enter dsn' read(5,'(a)') dsn write(6,*) dsn open(11,file=dsn,form='unformatted', & status='new',recordtype='variable',recl=8191) c c read header record and first 83 words of navigation record 1 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), & (lnav(i),i=1,83) 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 output header record w/o integer conversion to VAX 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 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 126 or 252 words (504 or 1008 bytes) c 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 pvlen = 126 c c read spanned navigation and pointing vector records c iword = 84 navrec = .true. fill = .false. 10 continue read(10,end=900) (lrec(i),i=1,128) do i = 1,128 if ( navrec ) then ! load navigation record array if ( iword.le.navlen ) then lnav(iword) = lrec(i) iword = iword + 1 else write(11) (lnav(j),j=1,navlen) navrec = .false. lpv(1) = lrec(i) iword = 2 end if else ! load pointing vector array if ( iword.le.pvlen ) then lpv(iword) = lrec(i) iword = iword + 1 else if ( fill ) then ! skip fill pointing vector fill = .false. else write(11) (lpv(j),j=1,pvlen) end if if ( nextpv.eq.0 ) then ! check for continuation of pointing vector navrec = .true. lnav(1) = lrec(i) else lpv(1) = lrec(i) end if iyear = lrec(i) if ( iyear.eq.0 ) then ! expect null pointing vector block fill = .true. navrec = .false. lpv(1) = lrec(i) end if iword = 2 end if end if end do goto 10 c 900 continue stop 800 format(1x,i4,1x,i3.3,3(1x,i2.2),1x,i3.3,1x,e10.4) end