program gpsda implicit real*8 (a-h,o-z) dimension idsv(37) character*40 seqfil,dafile character*3 flag,symbol(5) data symbol /' # ',' + ',' * ',' SV','EOF'/ c............................................................... c . c Program - gpsda Author - B. Remondi Date - 2/2/85 . c . c Function - This program takes as input an NGS-type ASCII . c file of GPS ECF positions and velocities and . c converts it to a somewhat compact direct access . c data file of recl=52 bytes. . c . c The direct access file is built as shown below. One needs . c only to know that all integers used are Int*4 and all . c other variables are real*8. This simplicity was chosen . c for ease of transfer to other computers. . c . c irec=1 . c write(666,rec=irec) jyear,imon,iday,ihr,imin,seci, . c deltat,mjd,fmjd,nepoch . c . c irec=2 . c write(666,rec=irec) numsv,(idsv(k), k=1,12) . c irec=3 . c write(666,rec=irec) (idsv(k), k=13,25) . c irec=4 . c write(666,rec=irec) (idsv(k), k=26,37) . c . c do 1000 kepoch=1,nepoch . c do 1000 knumsv=1,numsv . c . c irec=irec+1 . c write(666,rec=irec) iflag,x,y,z,vx,vy,vz . c . c1000 continue . c . c . c . c . c . c . c............................................................... c c Prompt user for name of ASCII sequential orbit file NGS-type. c write(6,100) 100 format(' Enter name of sequential ASCII ECF orbit file; ', + 'NGS-type.') read(5,200) seqfil 200 format(a40) junit=555 open(junit,file=seqfil,iostat=ios,err=9000,status='old', + access='sequential') write(6,250) seqfil 250 format('NGS-type ASCII sequential file ',a40,' has been opened.') go to 275 9000 continue write(6,9010) seqfil,ios 9010 format(' Problem opening the NGS-type ASCII orbit file ',a40, + ' ios= ',i8) stop ' Inspect the ASCII orbit file before trying again.' 275 continue c c Prompt the user for the name of the output direct access ECF c pos-vel file. c write(6,300) 300 format(' Enter the name of the direct access ECF pos-vel', + ' file to be created.') read(5,200) dafile open(666,file=dafile,iostat=ios,recl=52,err=9100, + access='direct',status='new') write(6,325) dafile 325 format(' The output direct access file ',a40,' has been opened.') go to 350 9100 continue write(6,9110) dafile,ios 9110 Format(' Problem opening the direct access orbit file', + /,a40,' ios= ',i8) stop ' Most likely a name conflict, but check the ios.' 350 continue c c Read record 1 of the ASCII file. Write record 1 of the direct c access file; a 52 byte record. c read(555,400) flag,jyear,imon,iday,ihr,imin,seci,deltat, +mjd,fmjd,nepoch 400 format(a3,1x,i4,4i3,1x,f10.7,1x,f14.7,1x,i5,1x,f15.14,1x,i6) if(flag.ne.symbol(1)) stop ' # flag did not match.' irec=1 write(666,rec=irec) jyear,imon,iday,ihr,imin,seci,deltat, +mjd,fmjd,nepoch c c Read record 2 of the ASCII file. Write records 2, 3, and 4 of c the direct access file; 52 bytes, 52 bytes, and 48 bytes respec- c tively. c read(555,500) flag,numsv,idsv 500 format(a3,i2,1x,37i2) if(flag.ne.symbol(2)) stop ' + flag did not match.' irec=2 write(666,rec=irec) numsv,(idsv(k), k=1,12) irec=3 write(666,rec=irec) (idsv(k), k=13,25) irec=4 write(666,rec=irec) (idsv(k), k=26,37) c c This completes the direct access header information. Next comes c the ECF pos-vel data. The first parameter, iflag, lets the user c know that there is no useful orbit data for that SV at that time. c c Now read and write nepoch sets of orbital data. c do 1000 kepoch=1,nepoch c c The next record, the epoch time record, will not be used. c Nevertheless the flag will be checked. c read(555,1100) flag 1100 format(a3) if(flag.ne.symbol(3)) write(6,1110) kepoch 1110 format(' The * flag did not match at epoch ',i6) c c Now read the pos-vel data for the numsv SVs. c do 2000 knumsv=1,numsv read(555,2100) flag,x,y,z,vx,vy,vz 2100 format(a3,2x,3(1x,f12.5),3(1x,f11.8)) if(flag.ne.symbol(4)) write(6,2110) kepoch,knumsv 2110 format(' The SV flag does not match for (epoch,idsv) ',2i6) c c Sometimes NGS writes zero-position data for the sake of a c uniform orbit file; thus we check for this and set a flag c so that, hereafter, only the flag need be checked. c dist=x*x+y*y+z*z iflag=0 if(dist.lt.1.d0) iflag=1 irec=irec+1 write(666,rec=irec) iflag,x,y,z,vx,vy,vz 2000 continue 1000 continue c c Read the last record of the ASCII file to verify the expected EOF. c read(555,2500) flag 2500 format(a3) if(flag.ne.symbol(5)) stop ' The EOF flag does not match.' stop ' Normal completion.' end