- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for all responses. Now, I think all is clear for me and we can close this topic.
Best,
Adam

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page