Well I searched for some time but couldn't get what I really need. So in Python it is as simple as it could be: random.random() gives different values every time you run the code, no need to type anything else. Thus,
for i in len(range(x)):
x(i) = random.random()
would give me a different random array x
every time I run my code.
I want to do the same thing in my Fortran 95 code but looks too complicated to me and so far I couldn't figure it out. So I find that rand()
generates the same sequence every time and even if I provide some seed (rand(213)
for example), though the sequence is different now, it is not different every time I run the code and I must change the seed (213
in this example) to change it. On the other hand, I find that the function random_number()
is beyond my understanding when used together with random_seed()
. Without it, it generates the same sequence of numbers again and again:
DO i = 1, n
call random_number(x(i))
ENDDO
On the other hand, the arguments size
, put
and get
are not understandable to me from this link. Can somebody explain these arguments and how to use them so that the random array would be initialized to different values every time I run the program?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire