F90-related question
Steve Kargl
sgk@troutmask.apl.washington.edu
Tue Dec 10 16:06:00 GMT 2013
On Tue, Dec 10, 2013 at 03:14:48PM +0100, Janus Weil wrote:
> >> > I don't knw the answers your questions,
> >> > but if I had to guess the sentence can probably be removed.
> >>
> >> Well, if you don't know it, then I don't know who should. Apparently
> >> you have committed this sentence in r97221.
> >
> > Hmm, so, I did. It seems that I wrote that sentence
> > 9 years ago. I have no recall as to why/what the
> > sentence was meant to convey :-/
>
> Ok. Note that http://gcc.gnu.org/onlinedocs/gfortran/KIND-Type-Parameters.html
> claims that the default kind for INTEGER and REAL is 4 (apparentyl
> target-independent; if there are exceptions from this, they should be
> documented there). Therefore I propose to remove the sentence "Do
> nothing if this is already the default" (since this is apparently
> never the case), see attached patch.
No, the sentence (or a modified version needs to stay)
for -fdefault-real-8. This option also causes a promotion
of DOUBLE PRECISION if there is another REAL kind type
parameter with 2*sizeof(DOUBLE PRECISION) available.
Consider
real r
double precision d
r = 1 ! 1 is exactly representable in all precisions
d = 1
r = 4 * atan(r)
d = 4 * atan(d)
print *, r, d
end
% gfc45 -o z -fdefault-real-8 foo.f90 && ./z
3.1415926535897931 3.1415926535897931
% gfc46 -o z -fdefault-real-8 foo.f90 && ./z
3.1415926535897931 3.1415926535897932384626433832795028
The difference is that 4.5 did not have REAL(16), but 4.6 does.
The top of the file created by -fdump-tree-original for 4.5 is
MAIN__ ()
{
real(kind=8) d;
real(kind=8) r;
while 4.6 has
MAIN__ ()
{
real(kind=16) d;
real(kind=8) r;
> The patch also
> * replaces the footnote-like markers (1) and (2) by ** and ***,
> respectively (the numbers are confusing and might be mistaken for
> alternative default values, I think),
> * does some linkification and
> * adds references from -fdefault-real-8 to -freal-4-real-8 and from
> -fdefault-integer-8 to -finteger-4-integer-8 (illustrating the
> differences).
This part is ok.
--
Steve
More information about the Fortran
mailing list