public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/114146] New: REPEATABLE argument of RANDOM_INIT and repeated execution of the program
@ 2024-02-28  9:23 wxcvbn789456123-nw6wda at yahoo dot com
  2024-02-28 16:05 ` [Bug fortran/114146] " kargl at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: wxcvbn789456123-nw6wda at yahoo dot com @ 2024-02-28  9:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

* [Bug fortran/114146] REPEATABLE argument of RANDOM_INIT and repeated execution of the program
  2024-02-28  9:23 [Bug fortran/114146] New: REPEATABLE argument of RANDOM_INIT and repeated execution of the program wxcvbn789456123-nw6wda at yahoo dot com
@ 2024-02-28 16:05 ` kargl at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: kargl at gcc dot gnu.org @ 2024-02-28 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5
   Last reconfirmed|                            |2024-02-28
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Severity|normal                      |minor
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
gfortran's implementation matches the wording of the Fortran 2023 standard.

   Case (i):  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.

Looks like someone needs to update the gfortran manual.

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

end of thread, other threads:[~2024-02-28 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28  9:23 [Bug fortran/114146] New: REPEATABLE argument of RANDOM_INIT and repeated execution of the program wxcvbn789456123-nw6wda at yahoo dot com
2024-02-28 16:05 ` [Bug fortran/114146] " kargl at gcc dot gnu.org

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