mercredi 30 décembre 2020

Change the range of IRAND() in Fortran 77 [duplicate]

I am trying to create a list of random numbers (integers) in fortran 77 but can't quite make it work.

My problem is a want a list of N random integers, say N = 100. But also, I want the random numbers to only appear in a range between 1 and N.

So if I make:

       do 1001 j=1, N
           ar = IRAND()
           print*, j,ar
 1001 continue

That just gives me a list of integers from 0 through 2147483647.

Is there a way to change the range in IRAND()? or quick fix at least?




Aucun commentaire:

Enregistrer un commentaire