Random _number

Subroutine Type:

Random_number is a intrinsic subroutine that was introduced in Fortran 90.

Subroutine Purpose:

This subroutine takes either a single REAL variable or an array of type REAL and loads it with pseudo-random numbers that range in value from zero to one. The probability distribution for the resulting numbers is basically uniform on the range from zero to one. However, note the qualifier "pseudo" before "random". The results of the subroutine are only a close facimile to a sequence of random numbers. If you are in an exotic application requiring a truely random distribution of numbers, you will have to look for other sources of your numbers (not a likely situation in scientific and engineering applications)

Required Arguments:

call random_number ( result )

First take notice that since random_number is a subroutine it needs to be referenced with a call statement. Second, the argument result can either be a REAL scalar variable or array.

Optional Arguments:

There are no optional arguments to this subroutine.

Results:

It is difficult to show results from this subroutine since the values that loads are randomly selected between zero and one. The best thing to do is to actually write a small program that calls this subroutine and prints out the values that it loads into your variables. Before you do this, please keep in mind the way you reference this subroutine. A call must be issued to the subroutine and the array argument can either be by itself or appear after the HARVEST = argument. For instance, both of the below calls will accomplish the same thing.
		call random_number(x)
		call random_number( harvest = x )

For additional information and examples see:

Examples: drvsort.f

Up one level / Home


Written by Jason Wehr : jcw142@psu.edu and Maintained by John Mahaffy : jhm@cac.psu.edu