[RFC] Support of IEEE modules, first draft for comments
FX
fxcoudert@gmail.com
Sun Nov 17 14:04:00 GMT 2013
Hi Dominique,
Thanks for the feedback.
> I have applied your patch on x86_64-apple-darwin13 and powerpc-apple-darwin9.
> I have bootstapped both platforms without any problem. The test ieee_1.F90
> succeeds on x86_64-apple-darwin13, but not on powerpc-apple-darwin9
>
> Fatal Error: Can't open module file 'ieee_features.mod' for reading at (1): No such file or directory
Yes, that’s expected: powerpc-darwin is not supported by current FPU-specific code in libgfortran (for example, you can’t use -ffpe-trap on it either).
However, this being an intrinsic module, we can sure improve the error message a bit.
> It seems that ieee_support_rounding(*) is not implemented.
Oops. I forgot about it. Weirder: in my handwritten notes, I have put a checkmark next to it, meaning I thought I had added it)
> It seems also that the changing the rounding mode has no effect on the result
Yes, because you’re using a constant expression :)
It’s a murky area, but there is agreement that such simplifications are allowed under a rule of “mathematical equivalence” in the standards… see for example :
— Fortran interpretation F03/0078 (http://j3-fortran.org/doc/standing/links/016.txt)
— this thread : http://www.rhinocerus.net/forum/lang-fortran/628265-re-reordering-expressions-nan.html
It’s also what other compilers currently do.
It works the way you expect if you use a variable:
use, intrinsic :: ieee_arithmetic
implicit none
integer, parameter :: sp = kind(1.0)
TYPE(IEEE_ROUND_TYPE) ROUND_VALUE
real(kind=sp) :: x
x = -1
call ieee_get_rounding_mode(ROUND_VALUE)
print *, ROUND_VALUE == ieee_nearest, ROUND_VALUE == ieee_to_zero
print *, ROUND_VALUE == ieee_up, ROUND_VALUE == ieee_down
call ieee_set_rounding_mode(ieee_nearest)
call ieee_get_rounding_mode(ROUND_VALUE)
print *, ROUND_VALUE == ieee_nearest
write(unit=*, fmt="(F40.35)") x/3
call ieee_set_rounding_mode(ieee_up)
call ieee_get_rounding_mode(ROUND_VALUE)
print *, ROUND_VALUE == ieee_up
write(unit=*, fmt="(F40.35)") x/3
call ieee_set_rounding_mode(ieee_to_zero)
call ieee_get_rounding_mode(ROUND_VALUE)
print *, ROUND_VALUE == ieee_to_zero
write(unit=*, fmt="(F40.35)") x/3
call ieee_set_rounding_mode(ieee_down)
call ieee_get_rounding_mode(ROUND_VALUE)
print *, ROUND_VALUE == ieee_down
write(unit=*, fmt="(F40.35)") x/3
end
Cheers,
FX
More information about the Fortran
mailing list