pgf90 false=0 true=-1

Am I going crazy or is this a new standard in pgf90:
logical .true. is converted to integer -1 (negative one) ?!?!!

the output of this code below is T 0 1

 program trueorfalse
  implicit none
  write(*,*) .true., 1+.true., -(.true.)
end program trueorfalse

Interesting story about logicals and integers.

Since logical is a data type, some think

  1. true is 1 and false is zero.
    and others
  2. false is zero, true is everything else.

and Fortran does not specifically describe the conversion
from logical to integer.


Here are the switches PGI has defined.

-Munixlogical
directs the compiler to treat logical values as true if the value is non-zero and false
if the value is zero (UNIX F77 convention). When -Munixlogical is enabled, a logical
value or test that is non-zero is .TRUE., and a value or test that is zero is .FALSE… In
addition, the value of a logical expression is guaranteed to be one (1) when the result
is .TRUE…
-Mnounixlogical
directs the compiler to use the VMS convention for logical values for true and false.
Even values are true and odd values are false.

I think you need to add
-Munixlogical

to your compilation.

Others will tell you that you should use ‘transfer’ to convert from
logical to integer, as in


logical :: a
integer :: i,j
i=99
a=transfer(i,a)
j=transfer(a,j)