Fortran library question / long double usage / kinds.h

Steve Ellcey sje@cup.hp.com
Tue Aug 30 02:18:00 GMT 2005


> First question: I thought you said (in another mail) that the Fortran
> front-end did not compile on IA64 HP-UX? As I already said, I think
> nobody in the gfortran team has access to a IA64 HP-UX (and certainly,
> I do not, although it would probably help me much in writing the
> large-kinds support patches). If you have knowledge of a way we can
> get access to such a machine (even with restrictions, and for a short
> period of time), that would be very useful.

I don't recall saying this, though there was a time when it was true.
I can certainly build Fortran now and have submitted various patches to
fix other Fortran bugs.

I'll check around, I know someone with IA64 Linux machines that can be
made available, but I am not sure about HP-UX machines.

> The best way is probably to have a list of possible Fortran kinds,
> determine the ones that are available, and to have a list of possible
> C floating-point types, and determine the ones that are available.
> Then, match them by size. I do have a mk-kinds-h.sh script that does
> exactly that, but I thought that I could as well work on another issue
> before submitting it: the library functions (such as the math library
> functions) must be used in accordance to the C types, and the script
> should really provide a way to do this. This is not very difficult,
> but requires fixing a lot a places in the library code, so I'm
> progressing slowly!

Is this something that you think will be done for 4.1?  If not, I have a
quick workaround/hack that I am testing, basically a patch to the
Fortran compiler (gfc_init_kinds) so that only the floating point types
that correspond to float, double, and long double are recognized as
legitimate fortran floating point types.  This means that __float80 and
__fpreg on IA64 HP-UX will have no corresponding Fortran types but I
think that is OK for now.  And it means that the official types (float,
double, long double) will work fine on HP-UX without any library
changes.

Does such a patch sound like something that would be acceptable?

> There is a possibility to find it at compile-time (thanks Paul B. to
> hint me to that):
> 
> int main(void) { int m[sizeof(float) == 4 ? 1 : -1]; return 0; }
> 
> This will only compile if float has size 4.

I don't think this handles all the complications we have on IA64 HP-UX.
Both sizeof(__float80) and sizeof(long double) will both return 16 on
IA64 HP-UX because the memory needed for __float80 is padded out to 16
bytes.  The precision value is different and that is what the Fortran
compiler (gfc_init_kinds) uses to differentiate and to set __float80 to
be real*10 and long double to be real*16.  Unfortunately, I don't see
any way to access this information in a standard way without the Fortran
library accessing the compiler internal information.

Steve Ellcey
sje@cup.hp.com



More information about the Fortran mailing list