cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c      program pscreen

c     Screens a post file to grid specs - 1 post record per grid
c      cell is output.

      character id*8
      real post(8)
c      real gridpt(200000)
      real gridpt(130000)
      parameter (dval=1.0E38)
      ij(i,j)= i+(j-1)*ncol

      call getfile2(21,' Infile ','in','unformatted','.pos')
      call getfile2(22,' Screened outfile ','out','unformatted',
     &   '.scr')

      print '(/,1x,a)',  
     &      ' Imagine a grid of cells overlying your data...'
      print '(/a$)', ' Give ncol,nrow,xo,dx,yo,dy: '
      read *, ncol,nrow,xo,dx,yo,dy
c      if(ncol*nrow.gt.200000) then
      if(ncol*nrow.gt.130000) then
c       print *,' ncol*row TOO BIG (>200,000)'
       print *,' ncol*row TOO BIG (>130,000)'
       stop
      endif

      do 5 j=1,nrow
      do 5 i=1,ncol
      gridpt(ij(i,j))=dval
  5   continue

      ntot=0
      npts=0

 10   call getpost (21, id, post, *80)
      ntot=ntot+1
      xlon=post(1)
      xlat=post(2)
      i=nint((xlon-xo)/dx) + 1
      j=nint((xlat-yo)/dy) + 1
      if(gridpt(ij(i,j)).ge.dval) then
        call putpost (22, id, post)
        gridpt(ij(i,j))=post(3)
        npts=npts+1
      endif
      go to 10

 80   print *, ' '
      print *, '     npts in =', ntot
      print *, '     npts out=', npts

      close(21)
      call closeblp (22)

      stop ' '
      end
