How to debug Fortran 90 compile error "There is no specific subroutine for the generic 'foo' at (1)"?

Jakub Narębski picture Jakub Narębski · Nov 8, 2011 · Viewed 8.2k times · Source

I am trying to write Fortran 2003 bindings to CUFFT library using iso_c_bindings module, but I have problems with cufftPlanMany subroutine (similar to sfftw_plan_many_dft in FFTW library).

The bindings itself look like this:


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! cufftResult cufftPlanMany(cufftHandle *plan, int rank, int *n,
!                           int *inembed, int istride, int idist,
!                           int *onembed, int ostride, int odist,
!                           cufftType type, int batch)
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

interface cufftPlanMany
subroutine cufftPlanMany(plan, rank, n, &
                         inembed, istride, idist, &
                         onembed, ostride, odist, &
                         type, batch) &
& bind(C,name='cufftPlanMany')
use iso_c_binding
integer(c_int):: plan
integer(c_int),value:: rank, type, batch
integer(c_int):: n(*)
integer(c_int),value:: istride, idist, ostride, odist
integer(c_int):: inembed(*), onembed(*)
end subroutine cufftPlanMany
end interface cufftPlanMany

The calling part looks like this:


  integer(c_int):: plan
  integer(c_int):: batch
  integer(c_size_t):: size

! ...

    call cufftPlanMany(plan, 1, size,&
                       0, 1, size,&
                       0, 1, size,&
                       CUFFT_C2C, batch)

Unfortunately trying to compile this results in

Error: There is no specific subroutine for the generic 'cufftplanmany' at (1)

compilation error. Trying to use variables in place of constants didn't help either. Could you help with debugging this?

The compiler used is gfortran: GNU Fortran (Gentoo 4.4.5 p1.2, pie-0.4.5) 4.4.5

Answer

Vladimir F picture Vladimir F · Nov 8, 2011

You have a generic (named) interface.

The error message normally means that some of your arguments are wrong.

In general, when you know which specific procedure of the generic interface you want to call, try to call it directly, not through the generic name. You will get another error message that will tell you, which argument is wrong. For that, you need to have the generic name and the specific name distinct.


Your specific case:

Why do you declare n, inembed, onembed as arrays, when they should be int*, eg. just passed as integer from Fortran? Also, you should not interchange int and size_t. size_t is commonly 64-bit and int 32-bit but they are simply not the same in general and should be distinguished.