non-compatible round-off when printing for gfortran
satyaakam goswami
satyaakam@gmail.com
Fri Jul 20 08:50:00 GMT 2007
Hi
There is an incompatibility in round-off when printing between
gfortran (i tried both gcc411 and 412) and other fortran compiler (i
tried g77 from gcc3.2.3 and f77 from SUN forte 7 and 8)
Here is an example, it says better than me.
program test
real myr(10)
integer i
do i=1,10
myr(i)=0.2+0.01*i
enddo
write(*,1) (myr(i),i=1,10)
do i=1,10
myr(i)=0.3+0.01*i
enddo
write(*,1) (myr(i),i=1,10)
1 format (10(f3.1,1x))
end
For gfortran it outputs:
0.2 0.2 0.2 0.2 0.3 0.3 0.3 0.3 0.3 0.3
0.3 0.3 0.3 0.3 0.4 0.4 0.4 0.4 0.4 0.4
but for other compiler i tried (g77 and f77 from forte) it outputs:
0.2 0.2 0.2 0.2 0.2 0.3 0.3 0.3 0.3 0.3
0.3 0.3 0.3 0.3 0.4 0.4 0.4 0.4 0.4 0.4
I understand that correct round-off is "phylosofic issue" here, but
that causes inconvinience for cross-platforming and porting.
I think it would be better to have at list compiler option to allow
user to select round-off way.
Satya on behalf of Konstantin
More information about the Fortran
mailing list