CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

how to generate random number in Fortran ?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 1, 2003, 11:14
Default how to generate random number in Fortran ?
  #1
tang
Guest
 
Posts: n/a
Any one has experience to generate a random number in Fortran? using

random_number(a), ...

What's the details?

Thanks

tang
  Reply With Quote

Old   April 1, 2003, 14:47
Default Re: how to generate random number in Fortran ?
  #2
R. Andom.
Guest
 
Posts: n/a
Check Numerical Recipes in FORTRAN online......
  Reply With Quote

Old   April 2, 2003, 10:48
Default Re: how to generate random number in Fortran ?
  #3
littlelz
Guest
 
Posts: n/a
for fortran 90, use: CALL RANDOM_NUMBER(random), then the variable random can be used!
  Reply With Quote

Old   April 2, 2003, 10:54
Default Re: how to generate random number in Fortran ?
  #4
tang
Guest
 
Posts: n/a
but use

CALL RANDOM_NUMBER

gives a same number at different runs. That is, it is not random if different runs are made.

Using 'seed' may solve the problem? then how?

  Reply With Quote

Old   April 2, 2003, 12:12
Default Re: how to generate random number in Fortran ?
  #5
Vladimir Krejci
Guest
 
Posts: n/a
I am not sure but all random number generators produce the same number if you use the same number for their initialization. If you want to get a number which is more random (for you) initialize the generator with e.g. actual time on your computer.

hope it helps

vladimir
  Reply With Quote

Old   April 2, 2003, 12:23
Default Re: how to generate random number in Fortran ?
  #6
tang
Guest
 
Posts: n/a
But how to set actual time as the seed? What's the command in Fortran?

Thanks

T
  Reply With Quote

Old   April 2, 2003, 18:48
Default Re: how to generate random number in Fortran ?
  #7
Nashat
Guest
 
Posts: n/a
These links might be helpful:

http://rsc.anu.edu.au/~harry/COURSES...TH/node73.html

http://www.fortran.com/fortran/random1.f90

http://www.fortran.com/fortran/random2.f90

http://www.fortran.com/fortran/kiss.f90

http://www.library.cornell.edu/nr/nr_index.cgi

The system random generator is sometimes not as random as you would like it to be. The routines in Numerical Recepies are pretty good.

Regards.
  Reply With Quote

Old   April 2, 2003, 18:58
Default thanks to your all three
  #8
tang
Guest
 
Posts: n/a
Dear Nashat, etc

Thanks a lot

T
  Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison between C/C++ and Fortran? rick Main CFD Forum 45 September 6, 2011 01:52
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 05:03
DecomposePar unequal number of shared faces maka OpenFOAM Pre-Processing 6 August 12, 2010 10:01
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 20:43
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 08:36


All times are GMT -4. The time now is 14:57.