最近写了一个只取5实部的傅里叶变换,现在想对结果做个逆变换,不知逆变换程序写得对不对,望各位帮助修改,多谢!
[Fortran] 纯文本查看 复制代码 ! 傅里叶变换
PROGRAM FOURIER
IMPLICIT NONE
REAL(8)::DT,t,FCT,df,pi,w
CHARACTER::U
INTEGER::I,j
REAL(8),DIMENSION(10001)::CT
OPEN(12,FILE='VACFHI.txt')
OPEN(13,FILE='testFT.txt')
dt=1.2 ! fs
df=1.d-4 ! 1 fs^-1 = 33000 cm^-1
pi=4.d0*atan(1.d0)
DO i=1,10001
READ(12,*)U,CT(I)
ENDDO
DO j=1,12500
FCT=0
w=2.d0*pi*dble(j)*df
DO i=0,10000
t=dble(i)*DT
FCT=FCT+2.d0*(CT(I+1)*dCOS(w*t)*DT)
ENDDO
WRITE(13,*)w/pi/2.d0*3.3d4,FCT
ENDDO
CLOSE(12)
CLOSE(13)
END
!傅里叶逆变换
program inverse FT
implicit none
integer,parameter::N=12500
real(8),dimension(N)::FT,u
integer::i,j
real(8)::t,dw,CT,w
open(11,file='testFT.txt')
open(12,file='inverseFT.txt')
do i=1,N
read(11,*)u(i),FT(i)
enddo
do i=1,12500
CT=0
t=i
dw=3.3
do j= 1,N
w=3.3*j
CT=CT+2.d0*(FT(j)*cos(w*t)*dw)
enddo
write(12,*)t,CT
enddo
close(11)
close(12)
end |