aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/intrinsic.texi
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/intrinsic.texi')
-rw-r--r--gcc/fortran/intrinsic.texi59
1 files changed, 57 insertions, 2 deletions
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index adea02a..ca006c9 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -262,6 +262,7 @@ Some basic guidelines for editing this document:
* @code{RADIX}: RADIX, Base of a data model
* @code{RAN}: RAN, Real pseudo-random number
* @code{RAND}: RAND, Real pseudo-random number
+* @code{RANDOM_INIT}: RANDOM_INIT, Initialize pseudo-random number generator
* @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
* @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
* @code{RANGE}: RANGE, Decimal exponent range
@@ -11598,6 +11599,60 @@ end program test_rand
@end table
+@node RANDOM_INIT
+@section @code{RANDOM_INIT} --- Initialize a pseudo-random number generator
+@fnindex RANDOM_INIT
+@cindex random number generation, initialization
+
+@table @asis
+@item @emph{Description}:
+Initializes the state of the pseudorandom number generator used by
+@code{RANDOM_NUMBER}.
+
+@item @emph{Standard}:
+Fortran 2018
+
+@item @emph{Class}:
+Subroutine
+
+@item @emph{Syntax}:
+@code{CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .20 .75
+@item @var{REPEATABLE} @tab Shall be a scalar with a @code{LOGICAL} type,
+and it is @code{INTENT(IN)}. If it is @code{.true.}, the seed is set to
+a processor-dependent value that is the same each time @code{RANDOM_INIT}
+is called from the same image. The term ``same image'' means a single
+instance of program execution. The sequence of random numbers is different
+for repeated execution of the program. If it is @code{.false.}, the seed
+is set to a processor-dependent value.
+@item @var{IMAGE_DISTINCT} @tab Shall be a scalar with a
+@code{LOGICAL} type, and it is @code{INTENT(IN)}. If it is @code{.true.},
+the seed is set to a processor-dependent value that is distinct from th
+seed set by a call to @code{RANDOM_INIT} in another image. If it is
+@code{.false.}, the seed is set value that does depend which image called
+@code{RANDOM_INIT}.
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+program test_random_seed
+ implicit none
+ real x(3), y(3)
+ call random_init(.true., .true.)
+ call random_number(x)
+ call random_init(.true., .true.)
+ call random_number(y)
+ ! x and y are the same sequence
+ if (any(x /= y)) call abort
+end program test_random_seed
+@end smallexample
+
+@item @emph{See also}:
+@ref{RANDOM_NUMBER}, @ref{RANDOM_SEED}
+@end table
+
@node RANDOM_NUMBER
@section @code{RANDOM_NUMBER} --- Pseudo-random number
@@ -11643,7 +11698,7 @@ end program
@end smallexample
@item @emph{See also}:
-@ref{RANDOM_SEED}
+@ref{RANDOM_SEED}, @ref{RANDOM_INIT}
@end table
@@ -11713,7 +11768,7 @@ end program test_random_seed
@end smallexample
@item @emph{See also}:
-@ref{RANDOM_NUMBER}
+@ref{RANDOM_NUMBER}, @ref{RANDOM_INIT}
@end table