https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114146

            Bug ID: 114146
           Summary: REPEATABLE argument of RANDOM_INIT and repeated
                    execution of the program
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wxcvbn789456123-nw6wda at yahoo dot com
  Target Milestone: ---

Reading the documentation for the random_init subroutine at this address:

https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gfortran/RANDOM_005fINIT.html

This documentation states the following when this subroutine is called with an
argument REPEATABLE set to .TRUE. :

"If it [REPEATABLE] is .true., the seed is set to a processor-dependent value
that is the same each time 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."

(The same text appears in version 11.4.0 of the documentation).

However, in the example below, repeated executions of the program "a.exe"
generate the same sequence of random numbers.

bash 1 : uname -smo
CYGWIN_NT-10.0-19045 x86_64 Cygwin
bash 2 : gfortran --version | head -2
GNU Fortran (GCC) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
bash 3 : cat a.f90

PROGRAM random_init_test
   REAL :: x(2)
   CALL random_init(REPEATABLE=.TRUE., IMAGE_DISTINCT=.TRUE.)
   CALL random_number(x)
   PRINT *, x
END PROGRAM random_init_test

bash 4 : gfortran a.f90 -o a.exe
bash 5 : ./a.exe
  0.825262189      0.191325366
bash 6 : ./a.exe
  0.825262189      0.191325366
bash 7 : sleep 10
bash 8 : ./a.exe
  0.825262189      0.191325366
  • [Bug fortran/114146] ... wxcvbn789456123-nw6wda at yahoo dot com via Gcc-bugs

Reply via email to