Logicals and .EQ.
Brooks Moses
bmoses@stanford.edu
Fri Jul 8 05:40:00 GMT 2005
Craig Powers wrote:
> In attempting to build code that currently lives mainly in IFC and
> occasionally in CVF, I encountered an error on using .EQ. to compare LOGICAL
> values (as in, IF (<logical variable> == .FALSE.)). Although this is fixed
> easily enough to .EQV. instead, I was wondering if it might not be a good
> idea to allow the .EQ. operation as well. I have no idea what the standard
> requires; a glance through an online Compaq Fortran reference manual did not
> enlighten.
A glance through the Fortran-95 draft specification finds that it is
distinctly an extension; section 7.1.2 (among others) indicates that the
arguments of .EQ. cannot be logicals. Thus, this should definitely be
diagnosed as a syntax error if -std=f95 is used.
Though it's much more difficult to prove a negative, it doesn't appear
to me that it would be nonconforming for a compiler to allow this as an
extension. I'm not particularly sure what the merits of it are, though;
I would think that the minor short-term benefits of having such
sloppiness allowed would be outweighed by the long-term inconvenience of
begin surprised by all of these when one tried to port the code to
another compiler.
- Brooks
More information about the Fortran
mailing list