IRAND(3f)

DESCRIPTION
IRAND(FLAG) returns a pseudo-random number from a uniform distribution between 0 and a system-dependent limit (which is in most cases 2147483647). If FLAG is 0, the next number in the current sequence is returned; if FLAG is 1, the generator is restarted by CALL SRAND(0); if FLAG has any other value, it is used as a new seed with SRAND.

This intrinsic routine is provided for backwards compatibility with GNU Fortran 77. It implements a simple modulo generator as provided by g77. For new code, one should consider the use of RANDOM_NUMBER as it implements a superior algorithm.

STANDARD
GNU extension

CLASS
Function

SYNTAX
RESULT = IRAND(I)

ARGUMENTS

I Shall be a scalar INTEGER of kind 4.

RETURN VALUE
The return value is of INTEGER(kind=4) type.

EXAMPLE
          program test_irand
            integer,parameter :: seed = 86456

            call srand(seed)
            print *, irand(), irand(), irand(), irand()
            print *, irand(seed), irand(), irand(), irand()
          end program test_irand

AUTHOR

This information was taken from the GFortran documentation (https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gfortran/) and converted to a manpage by AstroFloyd (http://astrofloyd.org).