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: single to double conversion


On Tue, 26 Sep 2006, Craig Powers wrote:

> promotion from integer to floating point may occur later than a naive
> user would expect.

I believe if promotion from integer to real occured so late in a simple
calculation that it created a mathematically incorrect result, that should
be regarded as a bug in gfortran.  It's quite possible that the developers
disagree with me on this, but I'm just speaking as a chemist who is trying
to get some work done in Fortran.  I've used g77 for years and not had a
problem of this sort.  I haven't encountered a problem like that in
gfortran either, so I hope nothing has changed.

> This is not something that a fortran processor is required to catch, nor
> is it something that is easy to catch, aside from the simplified example
> you present here where both are in the same file.  In the most general
> case, main and ran_u are in different files and are compiled separately
> -- in which case, when compiling main, gfortran would have to know where
> to find ran_u in order to check the interface with the call.

Tobias mentions that ifort may catch this sort of error when using the
-gen-interfaces option.  It would be good if gfortran had the same
capability.

> The response you'll get from at least one prominent expert on
> comp.lang.fortran to problems of this sort is, use modules, which will
> handle all of the interface generation and checking automagically.

That's a good point.  This particular piece of code was legacy Fortran 77,
rather simple, and not containing modules.  It worked fine with g77, and
then we ran into the real*4 -> real*8  lack of promotion compiler issue
with gfortran.  Modules were never really considered, as it worked okay in
g77.

Thanks,

Brian


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