Skip to content

Instantly share code, notes, and snippets.

@kshramt
Created June 25, 2013 10:37
Show Gist options
  • Save kshramt/5857532 to your computer and use it in GitHub Desktop.
Save kshramt/5857532 to your computer and use it in GitHub Desktop.
! mac$ gfortran-mp-4.8 $(pkg-config --cflags --libs fftw3) try_fftw3.F90
! ubuntu$ gfortran $(pkg-config --cflags --libs fftw3) -I/usr/include try_fftw3.F90
! ubuntu$ ifort $(pkg-config --cflags --libs fftw3) try_fftw3.F90
program main
use, intrinsic:: iso_fortran_env, only: INPUT_UNIT, OUTPUT_UNIT, ERROR_UNIT
use, intrinsic:: iso_c_binding
implicit none
type(C_PTR):: plan
! Integer(8):: plan
Real(kind=C_DOUBLE):: in(1:128)
Complex(kind=C_DOUBLE_COMPLEX):: out(1:128/2 + 1)
Integer:: i
include 'fftw3.f03'
in = 0
out = 0
! call fftw_print_plan(fftw_plan_dft_r2c_1d(128_C_INT, in, out, FFTW_ESTIMATE))
in = sin(0.1*[(i, i = 1, 128)])
plan = fftw_plan_dft_r2c_1d(128_C_INT, in, out, FFTW_ESTIMATE)
call fftw_execute_dft_r2c(plan, in, out)
! call fftw_destroy_plan(plan)
! do i = 1, 128
! print*, in(i)
! end do
do i = 1, 128/2 + 1
print*, abs(out(i))
end do
! print*, out
stop
end program main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment