Re: PGI wierdness with .EQV.
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Thu, 19 Jun 2008 10:23:34 -0700
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
.
- Follow-Ups:
- Re: PGI wierdness with .EQV.
- From: James Van Buskirk
- Re: PGI wierdness with .EQV.
- References:
- PGI wierdness with .EQV.
- From: Carlie J. Coats
- PGI wierdness with .EQV.
- Prev by Date: Re: Memory Leak Problem
- Next by Date: Re: Pointer arithmetic with C_F_POINTER
- Previous by thread: Re: PGI wierdness with .EQV.
- Next by thread: Re: PGI wierdness with .EQV.
- Index(es):
Relevant Pages
|
|