I'm working on a school project where I have to make a program that takes a random number between 1 and 0 and interprets at as left, right, or no change on a liner plot. I don't understand why the position is constant at 0. Any help? Here it is:
program test
implicit none
integer, dimension(100)::tau
integer, dimension(100)::position=0
real,dimension(100)::x
real::y,a,b
integer::n
a=1/3
b=2/3
do n=1,100
tau(n)=n
call random_number(y)
x(n)=y
end do
position(1)=0
do n=1,100
if (x(n) .le. a) then
position(n)=position(n)+1
else if ((x(n) .gt. a) .and. (x(n) .le. b)) then
position(n)=position(n)-1
else
position(n)=position(n)+0
end if
end do
open(unit=10, file="test.txt")
do n=1,100
write(10,*) tau(n),x(n), position(n)
end do
close(10)
end program test