https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98253
Bug ID: 98253
Summary: Conflicting random_seed/random_init results
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: damian at sourceryinstitute dot org
Target Milestone: ---
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)