Fortran library question / long double usage / kinds.h
François-Xavier Coudert
fxcoudert@gmail.com
Sun Aug 28 14:27: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.
> 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.
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!
> 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.
> 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.
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.
FX
More information about the Fortran
mailing list