Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Real*4 and C_FLOAT

Kusiek__Adam
Beginner
113 Views

Hi,

I am working on integration of C program with Fortran subroutines - using C/Fortran interoperability (ISO_C_BINDING). When I pass single precision array from C to Fortran subroutine can I be ALWAYS sure that C_FLOAT is the same as REAL*4. So in other words inside Fortran procedure I want to use values of passed array (via pointer) and do not want to copy elements from C_FLOAT array to REAL*4 array (then conversion is - as I assume - automatic between these two) ? 

Best, 

Adam 

 

0 Kudos
3 Replies
IanH
Black Belt
113 Views

No.

  • REAL*4 isn't standard Fortran - it is an extension.
  • The C standard does not require a float be four bytes.
  • You could potentially have different forms of floating point representation with the same byte count.
TimP
Black Belt
113 Views

Although "real*4" and C_FLOAT are physically the same on Intel platforms, in some contexts where both are visible to the compiler, the equivalence may not be recognized.  Companion compilers may not be implemented with equality among C_FLOAT, selected_real_kind(6), and REAL32, even on a platform where all refer to the same floating point format.

Kusiek__Adam
Beginner
113 Views

Thank you for all responses. Now, I think all is clear for me and we can close this topic. 

Best, 

Adam  

 

Reply