forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Random function

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Fri Dec 17, 2004 10:11 am    Post subject: Random function Reply with quote

Hello,

Could anybody show me an example of the use of the random function and the modification of the seed at each call of the subroutine (random_seed for example). I can't manage to have random values when I start my program.

Thank you for your answer

TL
Back to top
Anonymous
Guest





PostPosted: Sat Dec 18, 2004 8:44 am    Post subject: Random function Reply with quote

I think you should be able to generate a non repeatable sequence of pseudo-random numbers by calling
Code:
SYSTEM_CLOCK
to set the seed. Perhaps something like this:
[pre]INTEGER :: Seed
REAL :: X

CALL SYSTEM_CLOCK(COUNT = Seed)
CALL RANDOM_SEED(PUT = Seed)
CALL RANDOM_NUMBER(HARVEST = X)

WRITE (UNIT=*,FMT="(A,I10)") "Seed = ", Seed
WRITE (UNIT=*,FMT="(A,F12.10)") "X = ", X[/pre]
I hope this helps.

- Miguel.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group