This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
non-compatible round-off when printing for gfortran
- From: "satyaakam goswami" <satyaakam at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Date: Fri, 20 Jul 2007 14:20:00 +0530
- Subject: non-compatible round-off when printing for gfortran
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=hCsAT1ajs84ZmNWPEvTtZEYiVSA8Ng/0SD0FzPDTuNaS7iH6NbinlS4m34LMf4zG7oaXkP+9FT542OMeNX5vu28P5NBNgPcRSzcidHmsPI1JyxTki0Sd6XvK9d0y+9zj4HX7gRc5sAmXUAIoAVrxOcS/oszCsPvWMlRadS4FvoQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=RWwo3iLdjkErrNKq4VUwoSrT+nz4IWy2is40FGv1k7G2sMFo71xP34quHvEiD/ic6aIhWlB3t0MThXXMbxDpd4CLvmR+nMIdRLjWfMgBAGR/27topXrnB9zApqEPX1dPVKaSkel/NF+SJfLWHtDE5GC+EaVK45RGfMlF5G3T6Gk=
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