Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Real*4 and C_FLOAT

Kusiek__Adam
Beginner
472 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
Honored Contributor II
472 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.
0 Kudos
TimP
Honored Contributor III
472 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.

0 Kudos
Kusiek__Adam
Beginner
472 Views

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

Best, 

Adam  

 

0 Kudos
Reply