]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fortran/doc/gfortran/intrinsic-procedures/randomseed.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / randomseed.rst
CommitLineData
c63539ff
ML
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.. index:: RANDOM_SEED, random number generation, seeding, seeding a random number generator
7
8.. _random_seed:
9
10RANDOM_SEED --- Initialize a pseudo-random number sequence
11**********************************************************
12
13.. function:: RANDOM_SEED(SIZE, PUT, GET)
14
15 Restarts or queries the state of the pseudorandom number generator used by
16 ``RANDOM_NUMBER``.
17
18 :param SIZE:
19 (Optional) Shall be a scalar and of type default
20 ``INTEGER``, with ``INTENT(OUT)``. It specifies the minimum size
21 of the arrays used with the :samp:`{PUT}` and :samp:`{GET}` arguments.
22
23 :param PUT:
24 (Optional) Shall be an array of type default
25 ``INTEGER`` and rank one. It is ``INTENT(IN)`` and the size of
26 the array must be larger than or equal to the number returned by the
27 :samp:`{SIZE}` argument.
28
29 :param GET:
30 (Optional) Shall be an array of type default
31 ``INTEGER`` and rank one. It is ``INTENT(OUT)`` and the size
32 of the array must be larger than or equal to the number returned by
33 the :samp:`{SIZE}` argument.
34
35 Standard:
36 Fortran 90 and later
37
38 Class:
39 Subroutine
40
41 Syntax:
42 .. code-block:: fortran
43
44 CALL RANDOM_SEED([SIZE, PUT, GET])
45
46 Example:
47 .. code-block:: fortran
48
49 program test_random_seed
50 implicit none
51 integer, allocatable :: seed(:)
52 integer :: n
53
54 call random_seed(size = n)
55 allocate(seed(n))
56 call random_seed(get=seed)
57 write (*, *) seed
58 end program test_random_seed
59
60 See also:
61 :ref:`RANDOM_NUMBER`,
3ed1b4ce 62 :ref:`RANDOM_INIT`