Fortran Library Reference

ran: Generate a Random Number between 0 and 1

Repeated calls to ran generate a sequence of random numbers with a uniform distribution.

r = ran( i )

i

INTEGER*4

Input 

Variable or array element 

r

REAL

Output 

Variable or array element 

See lcrans(3m).

Example: ran:


demo% cat ran1.f 
* ran1.f -- Generate random numbers. 
    INTEGER*4 i, n 
    real r(10) 
    i = 760013 
    do n = 1, 10 
        r(n) = ran ( i ) 
    end do 
    write ( *, "( 5 f11.6 )" ) r 
    end 
demo% f77 -silent ran1.f
demo% a.out 
   0.222058 0.299851 0.390777 0.607055 0.653188 
   0.060174 0.149466 0.444353 0.002982 0.976519 
demo% 

Note the following: