Fortran random seed initialization
Fortran 2018 specifies a new subroutine random_init()
.
Gfortran 9 and Intel oneAPI support random_init
.
Build systems such as Meson and CMake can detect compiler capabilities. random/ folder full example
Meson standard random_init
detection:
f18random = fc.links('call random_init(.false., .false.); end', name:'F2018 random_init')
CMake standard random_init
detection:
include(CheckSourceCompiles)
check_source_compiles(Fortran "call random_init(.false., .false.); end" f18random)
Older versions of gfortran call random_seed()
gives a unique seed.
Not every compiler vendor gives a unique seed for random_seed() however.