]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/srand.rst
sphinx: copy files from texi2rst-generated repository
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / srand.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. _srand:
7
8 SRAND --- Reinitialize the random number generator
9 **************************************************
10
11 .. index:: SRAND, random number generation, seeding, seeding a random number generator
12
13 .. function:: SRAND(SEED)
14
15 ``SRAND`` reinitializes the pseudo-random number generator
16 called by ``RAND`` and ``IRAND``. The new seed used by the
17 generator is specified by the required argument :samp:`{SEED}`.
18
19 :param SEED:
20 Shall be a scalar ``INTEGER(kind=4)``.
21
22 :return:
23 Does not return anything.
24
25 Standard:
26 GNU extension
27
28 Class:
29 Subroutine
30
31 Syntax:
32 .. code-block:: fortran
33
34 CALL SRAND(SEED)
35
36 Example:
37 See ``RAND`` and ``IRAND`` for examples.
38
39 Notes:
40 The Fortran standard specifies the intrinsic subroutines
41 ``RANDOM_SEED`` to initialize the pseudo-random number
42 generator and ``RANDOM_NUMBER`` to generate pseudo-random numbers.
43 These subroutines should be used in new codes.
44
45 Please note that in GNU Fortran, these two sets of intrinsics (``RAND``,
46 ``IRAND`` and ``SRAND`` on the one hand, ``RANDOM_NUMBER`` and
47 ``RANDOM_SEED`` on the other hand) access two independent
48 pseudo-random number generators.
49
50 See also:
51 :ref:`RAND`,
52 :ref:`RANDOM_SEED`,
53 :ref:`RANDOM_NUMBER`