read number in if sentences
read number in if sentences
(OP)
Hallo everybody,
I have this file:
parameter=5
Read(1,*)a
If (a==(parameter))
read(1,*)b
write(2,*)b
end if
where parameter it will be used for differents cases but the problem is that seems to be: If (a==(parameter)).It seems that can not read the number that I give two lines before.
Thanks
Albert
I have this file:
parameter=5
Read(1,*)a
If (a==(parameter))
read(1,*)b
write(2,*)b
end if
where parameter it will be used for differents cases but the problem is that seems to be: If (a==(parameter)).It seems that can not read the number that I give two lines before.
Thanks
Albert
RE: read number in if sentences
two equal signs "==" for that purpose.
RE: read number in if sentences
if I put a number is working:
parameter=5
Read(1,*)a
If (a==(5))
read(1,*)b
write(2,*)b
end if
but not if I put:
If (a==(parameter))
RE: read number in if sentences
Also 5 on its own is considered to be an integer, you should use 5.0 for single precision or 5.0D0 for double precision.
RE: read number in if sentences
RE: read number in if sentences
RE: read number in if sentences
It still doesn't work even If I define parameter and a as integer or as real.
RE: read number in if sentences
If (a==(parameter))
it says "user breakpoint called from code 0x7c901230".
RE: read number in if sentences
RE: read number in if sentences
In Fortran, if you don't declare a variable, and it begins with letters a-h, o-z, it is real. Real, real comparisons don't always work.
CODE
integer:: param, a, b
param = 5
read(1,*)a
if (a .eq. param) then
read(1,*)b
write(2,*)b
end if
stop
end
RE: read number in if sentences
RE: read number in if sentences
.EQ. rules ok...
RE: read number in if sentences
RE: read number in if sentences
Also... the above code now works due to the use of the variable PARAM. The symbol used to check for equality is irrelevant.
Dan
dan@dtware.com
RE: read number in if sentences
The sky is falling...
"==" in FORTRAN.
Doomed, I tell ye, doomed.