Failure of implicit real*8
N.M. Maclaren
nmm1@cam.ac.uk
Sun Feb 20 19:24:00 GMT 2011
On Feb 20 2011, Steve Kargl wrote:
>>
>> >Note of caution when not using -fdefault-real-8: 1.0 is a default-real
>> >variable, thus for, e.g.,
>> > real*8 sqrt
>> > sq2 = sqrt(2.0)
>> >you loose precision, unless you do
>> > sq2 = sqrt(2.0d0)
>>
>> Is it safe for all constants and the problematic intrinsics (like cmplx)?
>> If so, I may mention it a bit more definitely in my course, more as a
>> debugging tool than as something to rely on - i.e. if using this works,
>> look for unmodified constants and intrinsics without kind.
>
>The above is just one problem. Consider the dusty deck
>(ie nonconforming, nonportable) method for manipulating
>the bits of a REAL:
>
> EQUIVALENCE(X,I)
> I = 2139095040
> print *, I, x
> end
Oh, very true (and the snipped points), but my course is modified from
Steve Morgan's and teaches only modern Fortran. I give several dire
warnings about old Fortran features (like COMMON, implicit procedure
declaration and calling LAPACK). The only advice I give about EQUIVALENCE
in any course is "Don't - REALLY don't", and I stress the use of IMPLICIT
NONE (everywhere, but EVERYWHERE) at least half a dozen times.
By far the most common gotchas in clean, modern Fortran are constants
and a few intrinsics. I don't think that I know of another that is of
any consequence.
Regards,
Nick Maclaren.
More information about the Fortran
mailing list