From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8E2C8388C03A; Sat, 12 Dec 2020 18:20:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E2C8388C03A From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/98253] Conflicting random_seed/random_init results Date: Sat, 12 Dec 2020 18:20:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Dec 2020 18:20:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98253 --- Comment #3 from kargl at gcc dot gnu.org --- Third thought. Here are the programs you meant to write (without error checking such as how_to_use_random_init must be run before how_to_seed_with_random_seed_like_random_init). program how_to_use_random_init implicit none integer fd, i, n integer, allocatable :: seeds(:) real r call random_init(repeatable=3D.true., image_distinct=3D.true.) call random_seed(size=3Dn) allocate(seeds(n)) call random_seed(get=3Dseeds) open(newunit=3Dfd,file=3D'seed.cache',access=3D'stream',status=3D'replac= e') write(fd) seeds close(fd) do i=3D1,5 call random_number(r) print *,r=20 end do end program how_to_use_random_init program how_to_seed_with_random_seed_like_random_init implicit none integer fd, i, n integer, allocatable :: seeds(:) real r call random_seed(size=3Dn) allocate(seeds(n)) open(newunit=3Dfd,file=3D'seed.cache',access=3D'stream',status=3D'old') read(fd) seeds close(fd) call random_seed(put=3Dseeds) do i=3D1,5 call random_number(r) print *,r=20 end do end program how_to_seed_with_random_seed_like_random_init=