Fortran library question / long double usage / kinds.h
Steve Ellcey
sje@cup.hp.com
Sat Aug 27 11:13:00 GMT 2005
While looking at a Fortran PR I looked at the kinds.h header file
that mk-kinds-h.sh generates for IA64 HP-UX. That header winds
up including:
typedef long double GFC_REAL_10;
typedef complex long double GFC_COMPLEX_10;
#define HAVE_GFC_REAL_10
typedef long double GFC_REAL_16;
typedef complex long double GFC_COMPLEX_16;
#define HAVE_GFC_REAL_16
Which is quite bogus since long double can't be both 10 and 16 bytes
long. In fact on HP-UX, long double is 16 bytes and __float80 is 10
bytes (plus padding). (On IA64 Linux long double is 10 bytes and 16
bytes is not fully supported.)
The problem, as I see it, is that mk-kinds-h.sh assumes that if you have
a 4 byte (kind=4) real type in Fortran it must be the same as the C
float type, likewise an 8 byte real type must be double in C and a 10
and/or 16 byte real is 'long double'. I am trying to figure out the
best way to fix this.
Basically, the whole mapping of Fortran real types to C float types
seems very broken and very fragile. But I haven't been able to come up
with a better way to do it though and was wondering if anyone else had
any ideas. I see that right now we pass the Fortran compiler to the
mk-kinds-h.sh script and use that to see if we support various kinds of
reals, I thought if we passed in the C compiler that might help but C
doesn't seem to offer a good way to find the sizes of float, double, and
long double short of actually running a C program that calls sizeof.
Steve Ellcey
sje@cup.hp.com
More information about the Fortran
mailing list