Re: PGI wierdness with .EQV.



Carlie J. Coats <carlie@xxxxxxxxxxxxxxx> wrote:

that the program below does not behave correctly when compiled with
PGI F90 (of which I don't have a copy). Either replacing the
IF-clause by the logically equivalent "IF ( LVAR ) THEN" or using
an alternate compiler (g95, ifort, sunf95) causes the program to behave
as expected.
....
IF ( .TRUE. .EQV. LVAR ) THEN

Well, stylistically, I far prefer the simpler "IF (LVAR)", but that
aside...

1. As Glen and James note, if your LVAR is not a properly defined
logical variable, then all bets are off; that would be a program bug,
not a compiler one, even if the program happened to work with many other
compilers. That's the kind of thing that happens with nonstandard code.

In particular, if the value comes from C, then as James mentioned, you
should use an integer, not a logical Fortran variable to correspond to
most C usage. Much as James might prefer otherwise, any different usage
is nonstandard, nonportable, and yes, can well cause obscure symptoms.
Fortran is not C; logical and integer are diferent types and do not have
any standardized bit-level correpondence. Any use of TRANSFER or other
bit-level twiddling to get logical values is nonportable and *WILL*
cause problems (as James has nicely proven). Making a Fortran logical
variable argument-associate with a C integer also constitutes such
bit-level twidling.

If you happen to have a both a C99 (I think it is new to C99, but I'm
not 100% sure of that) compiler with the _Bool type and an F2003
compiler that supports that C compiler as a companion processor, then
you can use a Fortran logical to interoperate with a C _Bool. I'm
guessing that the odds of that being what you are doing are negligable.
If that's not what you are doing, then use a Fortran integer and convert
it to logical as desired using normal Fortran such as

logical_var = integer_var==0
(/=0, whichever the C-ish rule is; I always get it confused).

2. Or if that's not it and the lvar variable is indeed properly defined
as a Fortran logical, then maybe you just found yet another PGI bug. I
don't recall that one, but I sure do recall quite a few other PGI bugs
on trivial things.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: PGI Preprocessor problems
    ... >> I have a project developed using the INTEL ifc compiler. ... >> test the code on a platform where I have to use the PGI FORTRAN ... >> code is using preprocessor directives. ...
    (comp.lang.fortran)
  • Re: Running Windows Programs from Fortran
    ... I use the Compaq Visual Fortran ver.6.6 on a 32 machine and/or PGI ... end program xsystem ... Maybe it is present in PGI, too -- I don't use that compiler. ...
    (comp.lang.fortran)
  • Re: A question on Newtons Method
    ... >> I can't believe you'd advise a noob to use a compiler which is still ... > production codes and codes from textbooks. ... > The Fortran standard generally does not specify the required behavior ... >> another important class of hassle which most numerical programmers ...
    (sci.math.num-analysis)
  • Fortran Resources (June)
    ... and the standard for the Fortran language and its derivatives. ... WHERE CAN I OBTAIN A FORTRAN 95 COMPILER? ... Absoft Fortran compilers, debuggers, and development tools for Windows, ... are available for Linux systems. ...
    (comp.lang.fortran)
  • Fortran Resources (July 2004)
    ... and the standard for the Fortran language and its derivatives. ... WHERE CAN I OBTAIN A FORTRAN 95 COMPILER? ... Absoft Fortran compilers, debuggers, and development tools for Windows, ... are available for Linux systems. ...
    (comp.lang.fortran)