c    @(#)filter.f	1.2
c
c
c
      subroutine filter(zz,m,n,nord)
c
c --- zz = field to be filtered
c ---  m = no of points along a side of the array
c --- nord = order of the filter
c
c --- this subroutine filters a field of data. it works in combination
c --- with subroutine shpiro. filter picks the column or row of data,
c --- calls shpiro, and then adds a factor to the data (as calculated
c --- by shpiro.
c
      include 'qg_par.inc'
      dimension zz(mn0),g(mx0+10)
      if(m.gt.mx0+10.or.n.gt.mx0+10)stop'filerr'
      mm1=m-1
      iodev=(nord+1)/2 -nord/2
      fac=-1.+2.*float(iodev)
      fac=fac/2.**(2*nord)
      do 100 j=1,n
        irow=(j-1)*m
        do 10 i=1,m
          g(i)=zz(irow+i)
   10   continue
c
        call shpiro(g,m,nord)
c
        do 50 i=1,m
          zz(irow+i)=zz(irow+i)+fac*g(i)
   50   continue
  100 continue
c
      do 200 i=1,m
        do 110 j=1,n
          g(j)=zz((j-1)*m+i)
  110   continue
c
        call shpiro(g,n,nord)
c
        do 150 j=1,n
          irow=(j-1)*m+i
          zz(irow)=zz(irow)+fac*g(j)
  150   continue
  200 continue
      return
      end
