if statements with eqv/and
MILAD FATENEJAD
mfatenejad@students.wisc.edu
Sun Feb 11 17:40:00 GMT 2007
Hello:
I had a question about if statements involving .eqv. and .and.. I noticed that the following code does not run as I would expect...
program test
implicit none
logical :: boolean = .false.
integer :: num = 3
integer :: int = 2
if(boolean .eqv. .TRUE. .AND. num == 2 ) then
print *, "Hello World"
end if
end program test
If I run this program it prints "Hello World", however, if I change "boolean .eqv. .TRUE." to "int == 2" doesn't print anything.
I would like it to interpret the if as:
if( (boolean .eqn. .true.) .and. (num == 2) )
I know I can use parentheses to force the correct behavior in the .eqv. example...but I would like to know if this is a problem with gfortran or if it is correct behavior...what is the standards compliant approach? Furthermore, why does it work with int == 2 and not with .eqv.?
I ask because I am trying to port a large scientific application I didn't write to gfortran. I wanted to make sure this wasn't a problem in gfortran before I recommended changes.
Thank You
Milad Fatenejad
More information about the Fortran
mailing list