This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: possible problem with handling IMPLICIT statement


Steve Kargl wrote:
On Wed, Aug 19, 2009 at 10:20:38PM -0700, Steve Kargl wrote:
On Wed, Aug 19, 2009 at 11:20:30PM -0500, Krishna Myneni wrote:
I'm compiling a standard numerical algorithm, written in Fortran 77, and notice an unexpected severe loss of accuracy. The apparent cause appears to be that the gfortran compiler is ignoring the IMPLICIT statement in the subroutine.

There are several real literal constants in toms680.f that
are single precision.  These values are not magically promoted
to double precision by the use of implict double precision.
Try adding -Wall -Wextra to your compiler command.  Does this
report anything?


REMOVE:kargl[14] gfc4x -c -fdump-tree-original -fdefault-real-8 680.f REMOVE:kargl[15] mv 680.f.003t.original dbl REMOVE:kargl[16] gfc4x -c -fdump-tree-original 680.f REMOVE:kargl[17] mv 680.f.003t.original sngl REMOVE:kargl[18] diff -u sngl dbl > zxc

The contents of zxc are


--- sngl 2009-08-19 22:27:53.000000000 -0700 +++ dbl 2009-08-19 22:27:37.000000000 -0700 @@ -39,8 +39,8 @@ *flag = 0; xabs = ABS_EXPR <*xi>; yabs = ABS_EXPR <*yi>; - x = xabs / 6.30000019073486328125e+0; - y = yabs / 4.400000095367431640625e+0; + x = xabs / 6.29999999999999982236431605997495353221893310547e+0; + y = yabs / 4.40000000000000035527136788005009293556213378906e+0; ...

O.k. I didn't realize that the Fortran type-casting rules were different from C, and assumed that the constants would be promoted to double precision automatically. After manually changing the source to toms680.f to explicitly make all of the literal constants be double precision, the problem appears to have been solved, and the -fdefault-real-8 switch is no longer necessary. Thanks.


--
Krishna



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]