Skip to content

Instantly share code, notes, and snippets.

@appleparan
Created October 3, 2016 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appleparan/be9eb47be87f5440c8008118492b4f10 to your computer and use it in GitHub Desktop.
Save appleparan/be9eb47be87f5440c8008118492b4f10 to your computer and use it in GitHub Desktop.
program FFTWFAIL_IFORT
use ISO_C_BINDING
implicit None
include 'fftw3.f03'
integer, parameter :: nxp = 128, nyp = 128, nzp = 128
real(kind=4), dimension(:,:,:), allocatable, target :: test
integer :: i, j, k
complex(C_DOUBLE_COMPLEX), pointer :: ffttest_c(:, :, :)
real(C_DOUBLE), pointer :: ffttest(:, :, :)
type(C_PTR) :: p_ffttest_c, p_ffttest
integer :: seed
integer(8) :: plan_c2r_ffttest
real :: rand1, rand2
p_ffttest_c = fftw_alloc_complex(int((nxp/2+1)*nyp*nzp, C_SIZE_T))
p_ffttest = fftw_alloc_real(int(nxp*nyp*nzp, C_SIZE_T))
call c_f_pointer(p_ffttest_c, ffttest_c, [nxp/2+1, nyp, nzp])
call c_f_pointer(p_ffttest, ffttest, [nxp, nyp, nzp])
call system_clock(seed)
call srand(seed)
do i = 1, nxp
do j = 1, nyp
do k = 1, nzp
call random_number(rand1)
call random_number(rand2)
ffttest_c(i, j, k) = cmplx(rand1, rand2)
end do
end do
end do
call dfftw_plan_dft_c2r_3d(plan_c2r_ffttest, nzp, nyp, nxp, ffttest_c, ffttest, FFTW_ESTIMATE)
call dfftw_execute_dft_c2r(plan_c2r_ffttest, ffttest_c, ffttest)
call dfftw_destroy_plan(plan_c2r_ffttest)
deallocate(ffttest_c)
deallocate(ffttest)
print *, "fftw alloc success"
allocate(test(nxp, nyp, nzp))
deallocate(test)
print *, "alloc success"
end program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment