module filter_mod

contains
  !----------------------------------------------
  ! Hamming window taper
  !----------------------------------------------
  subroutine hammingw(ctmp, nw1, nw2, nw3, nw4)
    complex         :: ctmp(:)
    integer         :: nw1, nw2, nw3, nw4
    integer         :: iw, nt
    real(kind=4)    :: s
    real(kind=4)    :: PI
    parameter(PI=3.14159265359)

    nt=size(ctmp)
    do iw=1, nt/2+1
       if(iw.ge.nw1.and.iw.le.nw2)then
          s=0.54+0.46*cos(PI*(iw-nw1)/(nw2-nw1)-PI)
          ctmp(iw)=ctmp(iw)*s
       else if(iw.ge.nw3.and.iw.le.nw4)then
          s=0.54+0.46*cos(PI*(nw3-iw)/(nw4-nw3))
          ctmp(iw)=ctmp(iw)*s
       else if(iw.gt.nw4.or.iw.lt.nw1)then
          ctmp(iw)=0.0
       end if
    end do
  end subroutine


end module
