program main
    use bremModule
    implicit none

! for the gaussian
!    real*8, parameter :: pi2=4.d0*atan(1.d0)
!    real*8, parameter :: sig=1.d-5
!    real*8, parameter :: const=1.d0/(sig*sqrt(2*pi2))
!    real*8 tempReal

! for the FFT
    real*8, parameter :: nmax=3.14*5, dn=1.0d-3
    integer, parameter :: nLength=nmax/dn
    complex*16 nListIn(-nLength:nLength),nListOut(-nLength:nLength)
    integer j

    OPEN(UNIT=15, FILE='out/in.txt')
    OPEN(UNIT=16, FILE='out/outReal.txt')
    OPEN(UNIT=17, FILE='out/outImag.txt')

    do j=-nLength,nLength
! true delta function (inverse transform)
!       if (dn*j.eq.1.5) then
!          nListIn(j)=(1000.d0,0.0d0)
!       else
!          nListIn(j)=(0.0d0,0.0d0)
!       end if

! narrow gaussian (backward transform)
!      tempReal=const*exp(-(j*dn-1.5d0)**2/(2.d0*sig**2))
!      nListIn(j)=dcmplx(tempReal,0.d0)

! testing the forward transform (constant function)
       nListIn(j)=dcmplx( 1.d0,0.d0 )

    end do

!    nListOut=FFTB(nListIn,nLength)
    nListOut=FFTF(nListIn,nLength)

    do j=-nLength,nLength
       write(15,*) j*dn,real( nListIn(j) )
       write(16,*) j*dn,real( nListOut(j) )
       write(17,*) j*dn,imag( nListOut(j) )
    end do

    close(15)
    close(16)
    close(17)
end
