diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-06-01 17:05:02 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-06-01 17:05:02 +0000 |
commit | ddd3e26e42b8d55989f9964c6ec6ee50b30b1802 (patch) | |
tree | 0bf61ebd5153e8a07d2e13d7f8dc20fc8dfbcfea /gcc/fortran/intrinsic.texi | |
parent | 77b8fb05b3ae9223abb7bac05d8af6892cfa251a (diff) | |
download | gcc-ddd3e26e42b8d55989f9964c6ec6ee50b30b1802.zip gcc-ddd3e26e42b8d55989f9964c6ec6ee50b30b1802.tar.gz gcc-ddd3e26e42b8d55989f9964c6ec6ee50b30b1802.tar.bz2 |
re PR fortran/63570 ([F2018] Implement 13.7.137 RANDOM INIT (REPEATABLE, IMAGE DISTINCT))
2018-06-01 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/63570
* check.c (gfc_check_random_init): New function. Check arguments of
RANDOM_INIT.
* gfortran.h (GFC_ISYM_RANDOM_INIT): New enum token.
* intrinsic.c (add_subroutines): Add RANDOM_INIT to list of
subroutines.
(gfc_check_intrinsic_standard): Introduce Fortran 2018 check.
* intrinsic.h: Add prototypes for gfc_check_random_init and
gfc_resolve_random_init
* intrinsic.texi: Document new intrinsic subprogram.
* iresolve.c (gfc_resolve_random_init): Resolve routine name.
* trans-decl.c: Declare gfor_fndecl_random_init
* trans-intrinsic.c (conv_intrinsic_random_init): New function.
Translate call to RANDOM_INIT.
(gfc_conv_intrinsic_subroutine): Call it.
* trans.h: Declare gfor_fndecl_random_init
2018-06-01 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/63570
* gfortran.dg/random_init_1.f90: New test.
* gfortran.dg/random_init_2.f90: New test.
* gfortran.dg/random_init_3.f90: New test.
* gfortran.dg/random_init_4.f90: New test.
* gfortran.dg/random_init_5.f90: New test.
* gfortran.dg/random_init_6.f90: New test.
2018-06-01 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/63570
* libgfortran/Makefile.am: Add random_init.f90 to build.
* libgfortran/Makefile.in: Regenerated.
* libgfortran/gfortran.map: Expose symbol for _gfortran_random_init.
* libgfortran/intrinsics/random_init.f90: Implementation.
From-SVN: r261075
Diffstat (limited to 'gcc/fortran/intrinsic.texi')
-rw-r--r-- | gcc/fortran/intrinsic.texi | 59 |
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 |