character filein*65,fileout*65,ans*1 data n,n9,last/3*0/,xmin,ymin/2*9999999./,xmax,ymax/2*-9999999./ logical exists print 100 100 format (' Plouff, 9-97, CUTOLN. Program to reduce the length ', 1 'of an OLN file to be',/,' plotted by deleting points that ', 2 'are less than 0.01 inch from the last',/,' point. The ', 3 'method depends on the scale to be plotted and previewing the', 4 /,' file for the minimum latitude.') 1 print 101 101 format (' TYPE the name of the OLN file (<66 characters):') read 565, filein 565 format (a65) inquire (file=filein,exist=exists) if (.not. exists) then print 102 102 format ('The file was not found. Do you want to try again?') read 501, ans 501 format (a1) if (ans .eq. 'y' .or. ans .eq. 'Y' .or. ans .eq. ' ') go to 1 stop end if 2 print 103 103 format ('TYPE the reciprocal of the map scale (integer) (zero ', 1 'to stop):') read (5,*,err=2) iscale if (iscale .eq. 0) stop print 104 104 format ('An output file name for the trimmed data should in', 1 'clude an indication of the',/,' scale for which it is ', 2 'intended (e.g., without last 3 digits.') 3 print 105 105 format (' TYPE the name of the output OLN file (<66 charac', 1 'ters):') read 565, fileout inquire (file=fileout,exist=exists) if (exists) then print 106 106 format ('Pick another name. That file already exists') go to 3 end if open (7,file=filein,form='formatted',status='old') open (9,file=fileout,form='formatted',status='new') c Displacements are related to the nominal 1.85 km/minute for latitudes 4 read (7,*,end=5) xd,xm,yd,ym n=n+1 if (abs(xd) .gt. 998.0) then n9=n9+1 else x=abs(xd)+abs(xm/60.0) if (xd .lt. 0.0) x=-x y=abs(yd)+abs(ym/60.0) if (yd .lt. 0.0) y=-y if (x .lt. xmin) xmin=x if (y .lt. ymin) ymin=y if (x .gt. xmax) xmax=x if (y .gt. ymax) ymax=y end if go to 4 5 print 107, n,n9,ymin,ymax,xmin,xmax 107 format ('The input file has',i8,' points with',i5,' 99-delimi', 1 'ters.',/,' Latitudes range from',f9.3,' to',f9.3,' degrees.', 2 /,'Longitudes range from',f9.3,' to',f9.3,' degrees.') faclat=1.85 faclon=1.86*cos(ymin/57.29578) rewind 7 c Minimum acceptable change of 0.01 inch expressed in degrees conv=0.01*float(iscale)*0.3048/(12.0*60000.0) dx=conv/faclon dy=conv/faclat dxy2=dx*dx+dy*dy flag=-alog10(dy) c Establish output figures to right of decimal and then precision c for larger scales. flag=1 for scales smaller than 4,545,454. iflag=flag if (iflag .lt. 1) iflag=1 if (iflag .gt. 6) iflag=6 nmin=iflag-1 ndeg=nmin+2 if (iflag .eq. 1) nmin=1 print 109, faclon,dy,dx,ndeg,nmin 109 format ('Conversion factors are 1.85 and',f5.2,' km/minute ', 1 'for latitude and longitude.',/,' 0.01 inch is',f8.5,' and', 2 f8.5,' degree at your scale. The output file will',/, 3 ' have',i2,' digits to the right of the decimal point for de', 4 'grees and',/,i3,' digits for minutes.') n=0 n9=0 npt=-1 c Flag NPT. -1 before first line of file or after last 999-delimiter c was written. 0 after first point of new segment. 1 after a second c or later point accepted since last delimiter. 6 read (7,*,end=97) xd,xm,yd,ym if (abs(xd) .gt. 998.0) then c A 999-delimiter if (npt) 6,8,7 7 call iwrite (n,n9,iflag,xdf,xmf,ydf,ymf,iscale) call iwrite (n,n9,9,xdf,xmf,ydf,ymf,iscale) last=9 8 npt=-1 else c Not a 999-delimiter if (npt .gt. -1) go to 9 c First point after a delimiter of first point of all npt=0 go to 10 c One or more accepted points of a segment have been passed 9 x=abs(xd)+abs(xm/60.0) if (xd .lt. 0.0) x=-x y=abs(yd)+abs(ym/60.0) if (yd .lt. 0.0) y=-y ds2=abs(yf-y)**2+abs(xf-x)**2 c Skip this point if too close to last if (ds2 .lt. dxy2) go to 6 call iwrite (n,n9,iflag,xdf,xmf,ydf,ymf,iscale) last=1 npt=1 c Save coordinates of first or later good point c Don't write until another good point or a delimiter is encountered. 10 xf=x yf=y xdf=xd ydf=yd xmf=xm ymf=ym end if go to 6 c After last line read 97 if (npt .lt. 1 .and. last .eq. 9) go to 99 if (npt .lt. 1 .and. last .eq. 1) go to 98 call iwrite (n,n9,iflag,xdf,xmf,ydf,ymf,iscale) 98 call iwrite (n,n9,9,xdf,xmf,ydf,ymf,iscale) 99 print 199, n,n9 199 format ('The output file has',i8,' points and',i5, 1 ' de-limited segments.') close (7) close (9) stop end subroutine iwrite (n,n9,iflag,xd,xm,yd,ym,iscale) if (iflag .eq. 9) then n9=n9+1 write (9,909) 909 format (' -999.0 0.0 -999.0 0.0') return end if n=n+1 if (n .eq. 1) then write (9,900) xd,xm,yd,ym,iscale 900 format (f11.5,3f10.5,' SCALE=',i10) c Could print warning for exceeding single precision degrees at c large scales. Therefore, minutes must be non-zero. return end if go to (1,2,3,4,5,6) iflag c Minutes have better accuracy than needed 1 write (9,901) xd,xm,yd,ym 901 format (f7.2,f5.1,f6.2,f5.1) return c Degrees and minutes have same accuracy 2 write (9,902) xd,xm,yd,ym 902 format (f8.3,f5.1,f7.3,f5.1) return 3 write (9,903) xd,xm,yd,ym 903 format (f9.4,f6.2,f8.4,f6.2) return c Reaches point where single precision is exceeded if zero minutes 4 write (9,904) xd,xm,yd,ym 904 format (f10.5,f7.3,f9.5,f7.3) return 5 write (9,905) xd,xm,yd,ym 905 format (f11.6,f8.4,f10.6,f8.4) return 6 write (9,906) xd,xm,yd,ym 906 format (f12.7,f9.5,f11.7,f9.5) return end