module filter 
    use const
    use var
implicit real*8 (a-h,o-z)
contains


subroutine modified_filter 
    do k=1,k1
	do j=2,j1
	    do i=2,i1
		tmp_u=fltw*(.5*u1(i,j,k)-ulf(i,j,k)+.5*u2(i,j,k))
		u1(i,j,k)=ulf(i,j,k)+rawf*tmp_u
		ulf(i,j,k)=u2(i,j,k)+(rawf-1.)*tmp_u
		tmp_v=fltw*(.5*v1(i,j,k)-vlf(i,j,k)+.5*v2(i,j,k))
		v1(i,j,k)=vlf(i,j,k)+rawf*tmp_v
		vlf(i,j,k)=v2(i,j,k)+(rawf-1.)*tmp_v
		tmp_t=fltw*(.5*t1(i,j,k)-tlf(i,j,k)+.5*t2(i,j,k))
		t1(i,j,k)=tlf(i,j,k)+rawf*tmp_t
		tlf(i,j,k)=t2(i,j,k)+(rawf-1.)*tmp_t
		tmp_s=fltw*(.5*s1(i,j,k)-slf(i,j,k)+.5*s2(i,j,k))
		s1(i,j,k)=slf(i,j,k)+rawf*tmp_s
		slf(i,j,k)=s2(i,j,k)+(rawf-1.)*tmp_s
!yc
                tmp_c=fltw*(.5*c1(i,j,k)-clf(i,j,k)+.5*c2(i,j,k))
                c1(i,j,k)=clf(i,j,k)+rawf*tmp_c
                clf(i,j,k)=c2(i,j,k)+(rawf-1.)*tmp_c
!yc
	    enddo
	enddo
    enddo
end subroutine

end module
