This question already has an answer here:
I have a configuration of N
particles and in a loop I want to choose each of them but without repeat
. I have below codes
but I just found out some repeats on it.
do k=1,num
u=mod(16807.d0*u,2147483647.d0)
v=u/2147883648.d0
s=int(dble(num)*v)+1
if (s.gt.num) s=1
end do
I modified your code and I used it in my program. it works but the problem is I did it in a time interval between 0 and t and every time it makes a same number order :D but the good point is without any repeats in each one.
I'm not entirely sure I understand what you mean, and the code is a bit too long for a comment, but do you mean something like the following?