program mapasciitoascii c convert an ascii map file to an ascii map file but delete any c longitudes outside the goes-17 projection range: c namely, anything 90 degrees of longitude from the center longitude of 137W implicit none c integer numvals, numpts, maxnumpts real xlatmin,xlatmax,xlonmin,xlonmax integer ia, i, iunit, ounit character*256 fname,fname2 character fullpath*256 integer, parameter :: maxpts = 59617 real xlatmap(maxpts),xlonmap(maxpts) real, parameter :: g17lon = -137. real right, left, negleft, posright, a, b logical iuse left = g17lon - 90. + 360. right = g17lon + 90. negleft = -180. posright = 180. maxnumpts = 0 call getarg(1,fname) i = index(fname,'.ascii') if (i.lt.0) then print *,'ERROR: looking for a filename that ends in .ascii' call exit(1) endif fname2 = fname(1:i)//"g17" iunit = 11 ounit = 12 open (unit=ounit,file=fname2,form='formatted', & status='unknown',err=35) open (unit=iunit,file=fname,form='formatted', & status='old',err=33) 10 continue read(iunit,*,end=1000) numvals,xlatmin,xlatmax, & xlonmax,xlonmin,xlatmap(1),xlonmap(1) numpts=numvals/2 maxnumpts = max(numpts,maxnumpts) if (numpts.gt.maxpts) then print '("numvals = ",i8," numpts > maxpts ",2(i8,1x))' $ ,numvals,numpts,maxpts endif read(iunit,'(8F9.3)')(xlatmap(i),xlonmap(i),i=2,numpts) iuse = .false. if (xlonmin.gt.xlonmax) then a = xlonmin b = xlonmax xlonmax = a xlonmin = b endif if (xlonmin.lt.0.) then if (xlonmin.ge.negleft .and. xlonmax.le.right) then iuse = .true. endif else if (xlonmin.ge.left .and. xlonmax.le.posright) then iuse = .true. endif endif if (iuse) then write(ounit,'(i4,14x,6F9.3)') $ numvals,xlatmin,xlatmax,xlonmin,xlonmax $ ,xlatmap(1),xlonmap(1) write(ounit,'(8F9.3)')(xlatmap(i),xlonmap(i),i=2,numpts) endif goto 10 1000 continue close (iunit) print *,'maxnumvals = ',2*maxnumpts print *,'maxnumpts = ',maxnumpts close (ounit) c stop c 33 continue write(*,*)'Could not open ',trim(fname),' for reading.' call exit(1) 35 continue write(*,*)'Could not open file ',trim(fname2),' for writing.' call exit(1) c end