Random_seed and random_number anomoly_2023

I have a short simple nvfortran test program that isn’t behaving as expected. Would you please comment? I have attached a copy of the program and its output running with nvfortran and gfortran. Thanks. MMB.
test_random.f90 (456 Bytes)
nvfortran_results (760 Bytes)
gfortran_results (745 Bytes)
I should have said that I am using nvfortran 22.1. Also, the behaviour using gfortran is what I want! MMB


The first time “random_seed” is called without arguments, the initial seed is set by a variable amount based on time unless the environment variable “STATIC_RANDOM_SEED” is set to ‘yes’, in which case a static initial value is used.

Subsequent calls to “random_seed” without arguments resets the seed back to the initial value. The reasoning being that it allows you to replay the random sequence, similar to using the same put value. Note the Fortran standard doesn’t define the behavior of calling random_seed with arguments only stating that it’s processor dependent.

If you’re wanting each array to have a unique set of values, either remove the intermediary calls to random_seed, or use put values


Hi Mat, thanks for the reply. Your last paragraph contained the answer I needed. Hopefully, the 2018 random_init call will be available soon.

Realated question: how would I implement this on a GPU with OpenACC? Malcolm.

Hi Malcom,

how would I implement this on a GPU with OpenACC?

See: Random numbers inside OpenACC loop (nvfortran compiler)

Though let me know if you have additional questions.