Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6618 Discussions

Calling FFTW3 by Fortran with MPI, types of variables by using iso_c_binding

dyun
Beginner
127 Views

Hi,

I am working on a complicated fortran code, which uses MPI and calls FFTW3 functions directly.

As FFTW3 manual pdf file says, the integer is replaced by integer(c_intptr_t), the complex becomes complex(c_double_complex). What's the difference between integer type and integer(c_intptr_t) type data (also the difference between complex and complex(c_double_complex) )? Whether I can use integer(c_intptr_t) the same as integer, or vice versa? Moreover, can I pass values to each other?

For example,

integer :: a

integer(c_intptr_t) :: b

a=1

b=a

What's the value and type of b now?

0 Kudos
1 Reply
mecej4
Black Belt
127 Views

In general, pointers and integers are different kinds of integers and should not be mixed. The distinctions may be based on storage size (i.e., 4, 8, etc. bytes), signed/unsigned (from the C point of view) and the restrictions on what can be done with/to pointers versus integers. The C_INTPTR_T of Fortran is the same as the intptr_t type of C.

Here is a small test program that you can run in your environment to establish storage sizes.

program tst
use iso_c_binding
integer :: i4
integer(8) :: i8
integer(c_intptr_t) :: ix
!
write(*,*)sizeof(i4),sizeof(i8),sizeof(ix)
end program

 

Reply