F90-related question

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Dec 9 19:00:00 GMT 2013


On Mon, Dec 09, 2013 at 06:53:15PM +0100, Janus Weil wrote:
> 
>>
>> He probably wants -freal-4-real-8.  -fdefault-real-8 has a few
>> issues.
> 
> can you illuminate us what kind of 'issues' you are talking about?

I don't remember all the details.  Discussions are in the mailing
list archive.

Original patch:
http://gcc.gnu.org/ml/fortran/2011-11/msg00134.html

See this thread for a longer discussion:
http://gcc.gnu.org/ml/fortran/2011-12/msg00133.html

> > Presonally, I would like to deprecate the -fdefault-*
> > options, but I also recognize that these are too entrenched in
> > the users' brain.
> 
> Before deprecating it, maybe a first step would be to enhance the
> documentation to
> a) mention that -freal-4-real-8 might be preferable over -fdefault-real-8 and
> b) explain why.
> 
> Patches welcome ...

I wrote the documentation for -finteger-* and -freal-* (see r183217).
These options already list some of the troublesome situations:

   These options should be used with care and may not be suitable
   for your codes.  Areas of possible concern include calls to
   external procedures, alignment in 'EQUIVALENCE' and/or 'COMMON',
   generic interfaces, BOZ literal constant conversion, and I/O.
   Inspection of the intermediate representation of the translated
   Fortran code, produced by '-fdump-tree-original', is suggested.

I also wrote the original documentation for -fdefault-* (see r97221).
It was later updated in r1428666 by Daniel Kraft.  The same warning
should appear for these options, but I did not include such a 
warning years ago.

If I were inclined to update the documenation, I would add "DO NOT
USE THIS OPTION, because it is likely that it does not do what you
think it does!" as the first sentence.

> > PS:  The real solution is to use no option; rather fix the code
> > to properly declare all entities.
> 
> That is true. However, doing so for legacy code can be quite
> cumbersome. I think the conversion options are definitely useful for
> many people and we should be careful about deprecating any of them
> prematurely.

Sure, I understand why someone may want to use these options.  Afterall,
I am the person that converted the old -r8, -d8, and -i8 into the
-fdefault-* options and made -fdefault-* work (for some definition of
work).  Either tobi or tkoenig then fixed -fdefault-* to work (for some
definition of work) better.  I am also the person that committed the
-freal-* options.

The problem is users tend to use these options without fully understanding
their possible shortcomings.  Here's an example,

% cat foo.f90
x = 1._4 / 3._4  ! Default real kind literal constants.
print *, x
end
% gfc4x -o z -fdefault-real-8 foo.f90 && ./z
  0.33333334326744080     
% gfc4x -o z -freal-4-real-8 foo.f90 && ./z
  0.33333333333333331     

Now, if your 100 KLOC is sensitive to the above conversion,
you may have a problem that is very difficult to trackdown.  

-- 
Steve



More information about the Fortran mailing list