program fixfiles c c 3/29/94: c Read shuttle orbit data files in /d/foster/jwise/shuttle, and c rewrite new files eliminating lines that begin with "1". Also c eliminate header lines that begin with ' J', except the first c occurrence of such a line. Original files are saved in the dir c /d/foster/jwise/shuttle/orig, then the new files can be moved c to $file:r (removing the .new, thus their names become same as c the originals), and written to the mss /FOSTER/shuttle using the c script msput c in /d/foster/jwise/shuttle. The new mss files may c then be read by ~/tracsat. c (original files obtained from John Wise and Brian Sullivan, see c ~/jwise, /d/foster/jwise, etc) c parameter(nfiles=14) character*16 flnm(nfiles) character*24 dir character*132 rec character*1 char1 data dir/'/d/foster/jwise/shuttle/'/ data flnm / + 'pc10a.dat ','pc10b.dat ','pc11a.dat ', + 'pc11b.dat ','pc11e.dat ','pc11f.dat ', + 'pc11g.dat ','pc12a.dat ','pc12b.dat ', + 'pc13.dat ','pc16.dat ','pc42a.dat ', + 'pc42b.dat ','pc44a.dat '/ data lurd/21/, luwr/22/ c do 100 i=1,nfiles len = lenstr(flnm(i)) open(lurd,file=dir//flnm(i)(1:len),err=900) open(luwr,file=dir//flnm(i)(1:len)//'.new',err=900) ij = 0 irec = 0 do ii=1,1000000 read(lurd,"(a)",end=901) char1 irec = irec+1 if (char1.ne.'1') then backspace(lurd) read(lurd,"(a)",end=901) rec if (rec(2:2).ne.'J') then write(luwr,"(a)") rec(1:lenstr(rec)) elseif (ij.eq.0) then ij = 1 write(luwr,"(a)") rec(1:lenstr(rec)) endif else write(6,"('Found ''1'' on file ',a,' at rec ',i5)") + flnm(i)(1:len),irec endif enddo 901 continue write(6,"(' ')") write(6,"('EOF on file ',a,' (irec=',i5,')')") flnm(i)(1:len), + irec close(lurd) close(luwr) goto 100 900 continue write(6,"('Error opening file ',a,' -- skipping this file')") + flnm(i)(1:len) 100 continue stop end c function lenstr(str) character*(*) str c c Return index to last non-blank char in str c length = len(str) do i=length,1,-1 if (str(i:i).ne.' ') then lenstr = i return endif enddo lenstr = 0 return end