Re: random numbers in fortran



It doesn't, there will certainly be duplicates. Here's a simple-minded way to get what you want:

function scatter(how_many)
integer :: how_many, scatter(how_many), ii, index
real :: numbers(how_many)
call random_number(numbers)
do ii = 1, how_many
index = minloc(numbers, dim=1)
scatter(ii) = index
numbers(index) = 2.0
end do
end function scatter

What this actually does is to sort the random numbers, and use the index sequence that results as the permutation. This is the usual way to do such
things, although your sort algorithm is O(n^2) instead of O(n ld n) - which
for n=52 will hardly matter.

Jan
.