character filein*65,fileout*60,sta*8,dum57*57,ans logical exists data in,ifout,ibeg/3*0/ print 100 100 format (' PULLRECT, Plouff, 3-98. Retrieve data in plouff ', 1 'format (80 columns)',/,' from inside or outside a ', 2 'rectangle bounded by geographic coordinates.',/,' See pro', 3 'gram SURROUND for a polygonal boundary.') print 101 101 format (' TYPE the name of the file where the data are stored:') read 565, filein 565 format (a65) inquire (file=filein,exist=exists) if (.not. exists) then print 102 102 format (' That file was not found. Try once more.') print 101 read 565, filein inquire (file=filein,exist=exists) if (.not. exists) then print 103 103 format (' **STOP. Input file again was not found.') stop end if end if print 104 104 format (' Do you want to select data from inside (not outside) ', 1 'a rectangle?') read 501, ans 501 format (a1) if (ans .eq. 'y' .or. ans .eq. 'Y' .or. ans .eq. ' ') go to 10 ifout=1 print 105 105 format (' Therefore, the data you select will be outside the ', 1 'quadrangle.') 10 print 106 106 format (' TYPE the name of the file where the selected ', 1 'data are to be stored?') read 560, fileout 560 format (a60) inquire (file=fileout,exist=exists) if (exists) then print 107 107 format (' That file already exists.',/,' Do you want to STOP ', 1 'to save it?') read 501, ans if (ans .eq. 'y' .or. ans .eq. 'Y' .or. ans .eq. ' ') stop end if print 110 110 format (' Boundaries are expressed in decimal degrees and mi', 1 'nutes. You may type four',/,' edges for the boundary or ', 2 'half the span of a geographic window (<1 degree)',/,' fol', 3 'lowed by its center coordinates.',/,' The window flag is neg', 4 'ative minutes for the half width span.',/,' Questions will ', 5 'be repeated if your response is unacceptable.') 28 print 115 115 format (' TYPE the coordinates of the south boundary or window ', 1 '(deg, min):') read (5,*,err=28) dgs,fms c Protect against unconventional coordinates. Negatives changed. dgs=abs(dgs) if (dgs .gt. 89.99999 .or. abs(fms) .gt. 59.9999) go to 28 if (fms .ge. 0.0) go to 20 c cm, center coordinate, absolute increment cm=-fms 30 print 116 116 format (' TYPE center coordinate latitude (deg, min):') read (5,*,err=30) dgs,fc dgs=abs(dgs) fc=abs(fc) if (dgs .gt. 89.99999 .or. fc .gt. 59.9999) go to 30 fms=fc-cm dgn=dgs fmn=fc+cm 31 print 111 111 format (' TYPE center coordinate longitude (deg, min):') read (5,*,err=31) dge,fc c Longitude entered or read/saved may be negative or positive. dge=abs(dge) fc=abs(fc) if (dge .gt. 179.99999 .or. fc .gt. 59.9999) go to 31 dgw=dge fme=fc-cm fmw=fc+cm go to 21 20 print 112 112 format (' North edge (deg, min):') read (5,*,err=20) dgn,fmn dgn=abs(dgn) fmn=abs(fmn) if (dgn .gt. 89.99999 .or. fmn .gt. 59.9999) go to 20 32 print 113 113 format (' East edge (deg, min):') read (5,*,err=32) dge,fme dge=abs(dge) fme=abs(fme) if (dge .gt. 179.99999 .or. fme .gt. 59.9999) go to 32 33 print 114 114 format (' West edge (deg, min):') read (5,*,err=33) dgw,fmw dgw=abs(dgw) fmw=abs(fmw) if (dgw .gt. 179.9999 .or. fmw .gt. 59.999) go to 33 c Convert to hundredths of a minute 21 ks=6000.0*dgs+100.0*fms+0.001 kn=6000.0*dgn+100.0*fmn+0.001 ke=6000.0*dge+100.0*fme+0.001 kw=6000.0*dgw+100.0*fmw+0.001 open (15,file=filein,form='formatted',status='old',blank='zero') open (7,file=fileout,form='formatted',status='unknown') nout=0 1 read (15,500,end=9,err=77) sta,latd,latm,lond,lonm,dum57 500 format (a8,i3,3i4,a57) if (ibeg .eq. 0) in=in+1 lat=6000*latd+latm lon=6000*iabs(lond)+lonm if (lat .ge. ks .and. lat .le. kn .and. lon .ge. ke .and. lon 1 .le. kw) then c Inside the window. If outside is selected, read next. if (ifout .ne. 0) go to 1 else c Outside the window. If inside is selected, read next. if (ifout .eq. 0) go to 1 end if c Inside or outside selection nout=nout+1 write (7,500) sta,latd,latm,lond,lonm,dum57 go to 1 77 in=in+1 print 777, in,nout 777 format (' **STOP. Bad input format on line',i5,/,i6,' output ', 1 'lines were written before the error was encountered.') stop 9 close (15) close (7) ibeg=ibeg+1 if (ibeg .eq. 1) print 117, in,filein 117 format (i6,' data points are in input file:',/,7x,a65) print 108, nout,fileout 108 format (i5,' points in: ',a60) c Stop if selection of exterior points was selected if (ifout .eq. 1) stop print 109 109 format (' Do you want to extract more data from the same input ', 1 'file?') read 501, ans c Re-open input file if more interior windows wanted if (ans .eq. 'y' .or. ans .eq. 'Y' .or. ans .eq. ' ') go to 10 stop end