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.
6 .. index:: RANDOM_INIT, random number generation, initialization
10 RANDOM_INIT --- Initialize a pseudo-random number generator
11 ***********************************************************
13 .. function:: RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)
15 Initializes the state of the pseudorandom number generator used by
19 Shall be a scalar with a ``LOGICAL`` type,
20 and it is ``INTENT(IN)``. If it is ``.true.``, the seed is set to
21 a processor-dependent value that is the same each time ``RANDOM_INIT``
22 is called from the same image. The term 'same image' means a single
23 instance of program execution. The sequence of random numbers is different
24 for repeated execution of the program. If it is ``.false.``, the seed
25 is set to a processor-dependent value.
27 :param IMAGE_DISTINCT:
28 Shall be a scalar with a
29 ``LOGICAL`` type, and it is ``INTENT(IN)``. If it is ``.true.``,
30 the seed is set to a processor-dependent value that is distinct from th
31 seed set by a call to ``RANDOM_INIT`` in another image. If it is
32 ``.false.``, the seed is set to a value that does depend which image called
42 .. code-block:: fortran
44 CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)
47 .. code-block:: fortran
49 program test_random_seed
52 call random_init(.true., .true.)
54 call random_init(.true., .true.)
56 ! x and y are the same sequence
57 if (any(x /= y)) call abort
58 end program test_random_seed