(j3.2006) DOUBLE PRECISION and C Interoperability

Van Snyder Van.Snyder
Tue Sep 11 18:56:19 EDT 2012


On Tue, 2012-09-11 at 15:37 -0500, Bill Long wrote:
> 
> On 9/11/12 3:27 PM, Van Snyder wrote:
> > On Thu, 2012-09-06 at 11:58 +0900, Malcolm Cohen wrote:
> >> On 09/05/12 18:41, Robert Corbett wrote:
> >>> If a C companion processor imposes stricter requirements
> >>> on alignment for objects of type double than a Fortran
> >>> processor can guarantee for objects of type
> >>> DOUBLE PRECISION, can C double and Fortran DOUBLE PRECSION
> >>
> >> or Fortran REAL with the -double option.
> >>
> >>> be considered interoperable types?
> >>
> >> I don't think so, at least not entirely.
> >
> > This seems to suggest that C_DOUBLE and KIND(0.0d0) aren't necessarily
> > the same -- depending upon which companion processor the Fortran
> > processor is instructed to work with.
> >
> 
> The Fortran vendor gets to choose what C processors are valid 
> companions. Typically this is the C compiler from the same vendor. 
> Maybe (likely) that's the only one.
> 
> By default  C_DOUBLE would normally be the same value as KIND(0.0d0). 
> However, if the Fortran code was compiled with switches that promoted 
> "single" to 64-bits reals  and "double" to 128-bit reals then the 
> relationship would fail.   Or course, the use of such switches is 
> strongly discouraged.  Similarly, the use of "d0" is also obsolete.
> 
> You have a more reliable chance of C_DOUBLE being the same as 
> SELECTED_REAL_KIND(12).

Does this guarantee the same rules for alignment that the C processor
requires?  If C_DOUBLE is not equal KIND(0.0d0) there is a chance the
Fortran processor could enforce the companion processor's alignment
rules.  Of course, where the alignment rules are the same, there's no
problem for C_DOUBLE to be equal to KIND(0.0d0).

> 
> Cheers,
> Bill
> 
> 
> 
> >
> > _______________________________________________
> > J3 mailing list
> > J3 at mailman.j3-fortran.org
> > http://mailman.j3-fortran.org/mailman/listinfo/j3
> >
> 





More information about the J3 mailing list