program spectra use kind_defs use FourierTransform implicit none integer, parameter :: N = 32768 real(dbl) :: t(1:N), x(1:N), P(1:N), f, Ttot complex(dbl) :: c(1:N) integer :: i ! Import data: print *, ' Importing data from "Data/simpel_short.dat".' open(50, file='Data/simpel_short.dat', status='old', action='read') do i = 1,N read(50, *) t(i), x(i) enddo close(50) print *, ' Making spectrum of data using the FFT for comparison' print *, ' with the Least Square-method.' ! Make spectrum for comparison of FFT and Least Square: c = fft(x) P = abs(c)*2.0/sqrt(real(N)) Ttot = maxval(t)-minval(t) open(51, file='Spectra.dat', status='replace', action='write') do i = 1,N/2 f = (i-1)*(1e6/Ttot) ! The frequency in microHz write(51, *) f, P(i) enddo close(51) print *, ' Done. Spectrum saved in Spectra.dat.' end program