# Re: random numbers in fortran

*From*: "Michael Metcalf" <michaelmetcalf@xxxxxxxxxxxxxx>*Date*: Mon, 27 Nov 2006 20:25:22 GMT

"lane straatman" <grumpy196884@xxxxxxxxxxx> wrote in message

news:1164653494.820050.94760@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Since I want to simulate shuffling a deck of cards, I guess I'll ask

for 52 pseudorandoms at a pop, multiply by 52 and take the floor. I

believe this gives random ints between zero and fifty-one.

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

Regards,

Mike Metcalf

.

**Follow-Ups**:**Re: random numbers in fortran***From:*Jan Vorbrüggen

**References**:**random numbers in fortran***From:*lane straatman

**Re: random numbers in fortran***From:*Thomas Koenig

- Prev by Date:
**Re: random numbers in fortran** - Next by Date:
**Re: Fortran WRITE changes ctime** - Previous by thread:
**Re: random numbers in fortran** - Next by thread:
**Re: random numbers in fortran** - Index(es):