program bkdrivery

! sample driver program for Baxter and King (1999) symmetric representation of band pass filter.

implicit none

integer, parameter:: rk = selected_real_kind(15,307), ik = selected_int_kind(9)

integer(ik):: n, dn, up, k, t
real(rk), allocatable:: y(:), ybp(:)
character(20):: datafile

external:: bkfilter

dn = 32
up = 6
k = 12

datafile = 'GDPbus.txt'

open(unit = 30, file = datafile, status = 'old', action = 'read')

read(30,*) n

allocate(y(n), ybp(n))

do t = 1, n
    read(30,*) y(t)
end do

close(30)

y = dlog(y)

call bkfilter(n, y, up, dn, k, ybp)

do t = 1, n

write(*, '(1x, 2F12.4)') y(t), ybp(t)

end do 

deallocate(y, ybp)

end program bkdrivery
