For the following minimal example, there appears to be a regression in Intel Fortran LLVM 2023.0.0 20221201 and Classic 2021.8.0.20221119 that works in 2022.2.1 Build 20221101. The `random_init()` second call should use a new seed, but does not.
program demo_rand use, intrinsic :: iso_fortran_env, only : stderr=>error_unit implicit none real :: r1, r2 call random_init(.false., .false.) call random_number(r1) call random_init(.false., .false.) call random_number(r2) if (r1==r2) then write(stderr,*) 'random_init fail: ', r1, ' == ', r2 error stop 'these two random number should not match if random_init is working' endif print *, "OK: random_init: ", r1, " /= ", r2 end program
You are correct that the second call to RANDOM_INIT should result in a different sequence. The standard says (emphasis mine), "CALL RANDOM_INIT(REPEATABLE=false, IMAGE_DISTINCT=false) is equivalent to invoking RANDOM_SEED with a processor-dependent value for PUT that is the same on every invoking image. Different values for PUT shall be used for subsequent invocations, and for each execution of the program."
I've reworked your test program to more precisely match what the standard says:
program demo_rand use, intrinsic :: iso_fortran_env, only : stderr=>error_unit implicit none integer :: szize integer, allocatable :: seed1(:),seed2(:) call random_seed(size=szize) allocate (seed1(szize),seed2(szize)) call random_init(.false., .false.) call random_seed (get=seed1) print *, seed1 call random_init(.false., .false.) call random_seed(get=seed2) print *, seed2 if (all(seed1==seed2)) then write(stderr,*) 'random_init fail' error stop 'these two seeds should not match if random_init is working' endif print *, "OK: random_init" end program
In contrast to the first post that report a change in behavior in the last release, do not see any changes in behavior between 2022.1, 2022.2.1 and 2023.0 versions of ifx on Linux (I just tried these three versions as I all have them locally installed).
Here i s a link to the compiler explorer with Steve's slightly modified example in ifx 2022.2.1:
Thanks @hakostra1 you are correct. I was checking between Windows 2022.2.1 that does NOT have this issue and Linux that has long had this issue. I also checked with ifort Version 2021.1 Build 20201112 on Linux and saw the same issue. So yes, it's NOT actually a regression, it's just long broken behavior.