* Bug 98253 - Conflicting random_seed/random_init results
@ 2020-12-12 16:27 Damian Rouson
0 siblings, 0 replies; only message in thread
From: Damian Rouson @ 2020-12-12 16:27 UTC (permalink / raw)
To: gfortran; +Cc: Brad Richardson
16.9.155 Case (i) in the Fortran 2018 standard states
CALL RANDOM_INIT (REPEATABLE=true, IMAGE_DISTINCT=true) is equivalent to
invoking RANDOM_SEED with a processor-dependent value for PUT that is
different on every invoking image. In each execution of the program with
the same execution environment, if the invoking image index value in the
initial team is the same, the value for PUT shall be the same.
but the two programs below give different results.
% cat random_init.f90
implicit none
integer i
real r
call random_init(repeatable=.true., image_distinct=.true.)
do i=1,5
call random_number(r)
print *,r
end do
end
% cat random_seed.f90
implicit none
integer i, n
real r
call random_seed(size=n)
call random_seed(put=[(i,i=1,n)])
do i=1,5
call random_number(r)
print *,r
end do
end
% /usr/local/Cellar/gnu/11.0.0/bin/gfortran random_init.f90
% ./a.out
0.731217086
0.652637541
0.381399393
0.817764997
0.394176722
% /usr/local/Cellar/gnu/11.0.0/bin/gfortran random_seed.f90
% ./a.out
0.471070886
0.117344737
0.357547939
0.318134785
0.696753800
% /usr/local/Cellar/gnu/11.0.0/bin/gfortran --version
GNU Fortran (GCC) 11.0.0 20200804 (experimental)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-12 16:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-12 16:27 Bug 98253 - Conflicting random_seed/random_init results Damian Rouson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).