(j3.2006) DOUBLE PRECISION and C Interoperability

Bill Long longb
Tue Sep 11 16:37:30 EDT 2012



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).

Cheers,
Bill



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

-- 
Bill Long                                           longb at cray.com
Fortran Technical Support    &                 voice: 651-605-9024
Bioinformatics Software Development            fax:   651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101





More information about the J3 mailing list