public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/98253] New: Conflicting random_seed/random_init results
@ 2020-12-12 16:24 damian at sourceryinstitute dot org
  2020-12-12 17:33 ` [Bug fortran/98253] " kargl at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: damian at sourceryinstitute dot org @ 2020-12-12 16:24 UTC (permalink / raw)
  To: gcc-bugs

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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-12-13  0:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-12 16:24 [Bug fortran/98253] New: Conflicting random_seed/random_init results damian at sourceryinstitute dot org
2020-12-12 17:33 ` [Bug fortran/98253] " kargl at gcc dot gnu.org
2020-12-12 17:47 ` kargl at gcc dot gnu.org
2020-12-12 18:20 ` kargl at gcc dot gnu.org
2020-12-12 18:53 ` dominiq at lps dot ens.fr
2020-12-12 21:20 ` damian at sourceryinstitute dot org
2020-12-12 21:31 ` kargl at gcc dot gnu.org
2020-12-12 22:54 ` damian at sourceryinstitute dot org
2020-12-12 23:55 ` damian at sourceryinstitute dot org
2020-12-13  0:20 ` sgk at troutmask dot apl.washington.edu

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).