subroutine filt_da(f_c,dfdx_c,dfdy_c)
! kills the oddball components in f, and calculates in plane derivatives
use types,only:rprec
use param,only:lh,nx,ny,nz
use fft
implicit none
integer::jz
! only need complex treatment
complex(kind=rprec),dimension(lh,ny,nz)::f_c,dfdx_c,dfdy_c
real(kind=rprec)::const, ignore_me
! loop through horizontal slices
const=1._rprec/(nx*ny)
do jz=1,nz
   f_c(:,:,jz)=const*f_c(:,:,jz)   !normalize
   call rfftwnd_f77_one_real_to_complex(forw,f_c(:,:,jz),ignore_me)
! what exactly is the filter doing here? in other words, why is routine
! called filt_da? not filtering anything
! kill the oddballs
   f_c(lh,:,jz)=0._rprec
   f_c(:,ny/2+1,jz)=0._rprec
! in-plane derivatives
   dfdy_c(:,:,jz)=eye*ky(:,:)*f_c(:,:,jz)
   dfdx_c(:,:,jz)=eye*kx(:,:)*f_c(:,:,jz)
! the oddballs for derivatives should already be dead, since they are for f
! inverse transform 
   call rfftwnd_f77_one_complex_to_real(back,f_c(:,:,jz),ignore_me)
   call rfftwnd_f77_one_complex_to_real(back,dfdx_c(:,:,jz),ignore_me)
   call rfftwnd_f77_one_complex_to_real(back,dfdy_c(:,:,jz),ignore_me)
end do
end subroutine filt_da
