Problem with fpm when I want to use FFTW


I have an issue using the FFTW library with FPM.

So, I installed for Windows (FFTW Installation on Windows)

I have this code

module FFTW3
  use, intrinsic :: iso_c_binding
  include 'fftw-3.3.5-dll64/fftw3.f03'
end module FFTW3

program test

  use FFTW3 
  implicit none
  integer plan
  integer , parameter :: N=4
  complex, dimension(N) :: in_fft, out_fft
  integer i

  write(*,*) 'In FFT:'

  in_fft = [(2,5),(5,6),(5,8),(1,3)]

  do i = 1,N,1
    print*, '    in(',i,') = ',in_fft(i)

  call dfftw_plan_dft_1d ( plan, N, in_fft, out_fft, FFTW_FORWARD, FFTW_ESTIMATE )

  call dfftw_execute ( plan )

  write(*,*) 'Out FFT:'
  do i = 1,N,1
    print*, '    out(',i,') = ',out_fft(i)

  call dfftw_destroy_plan ( plan )
end program test
├── app
│   └── main.f90
├── fpm.toml
├── src
│   └── FFTW3.f90 
│   └──  fftw-3.3.5-dll64

I get this error when I compile

f951.exe: Error: Unexpected end of file in '.\.\src\fftw-3.3.5-dll64\fftw3.f'

   22 |   call dfftw_plan_dft_1d ( plan, N, in_fft, out_fft, FFTW_FORWARD, FFTW_ESTIMATE )
      |                                                                                  1
Error: Procedure 'dfftw_plan_dft_1d' called with an implicit interface at (1) [-Werror=implicit-interface]
compilation terminated due to -fmax-errors=1.
<ERROR> Compilation failed for object " src_fftw-3.3.5-dll64_fftw3.f.o "
<ERROR> Compilation failed for object " app_main.f90.o "
<ERROR> stopping due to failed compilation

However, when I don’t use fpm but gfortran (gfortran -o test_fftw.exe test.f90 -LC:\fftw-3.3.4-dll64 -lfftw3) it works.

(I haven’t added anything to fpm.toml; I’m not sure if I need to add the FFTW dependency.)

Welcome to Discourse @Jules_M!

Because your library is using legacy Fortran, please ensure that implicit typing rules are enabled in fpm.toml:

implicit-typing = true
implicit-external = true
source-form = "default"