Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
25 Views

Real*4 and C_FLOAT

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
Highlighted
Black Belt
25 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
Highlighted
Black Belt
25 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
Highlighted
Beginner
25 Views

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

Best, 

Adam  

 

0 Kudos