fortran66のブログ

fortran について書きます。

【メモ帳】Fortran の組み込み乱数アルゴリズム

random_number algorithm

ifort

( (as + c) MOD m ) / m ?

The RANDOM_NUMBER generator uses two separate congruential generators together to produce a period of approximately 10**18,

software.intel.com

For more information on the algorithm, see the following:

  • Communications of the ACM vol 31 num 6 June 1988, titled: Efficient and Portable Combined Random Number Generators by Pierre L'ecuyer.

  • Springer-Verlag New York, N. Y. 2nd ed. 1987, titled: A Guide to Simulation by Bratley, P., Fox, B. L., and Schrage, L. E.v

PDF 直リン

http://webhome.csc.uvic.ca/~wkui/Courses/CSC446/CLCG.pdf

gfortran

xorshiro256**

This generator has a period of 2^{256} - 1, and when using multiple threads up to 2^{128} threads can each generate 2^{128} random numbers before any aliasing occurs.

gcc.gnu.org

PDF 直リン

PIERRE L’ECUYER による批評

”On the Xorshift Random Number Generators” by FRANC¸OIS PANNETON and PIERRE L’ECUYER https://www.iro.umontreal.ca/~lecuyer/myftp/papers/xorshift.pdf

xorshiro256** 末尾の**は改2の意味?

coarray での乱数初期化(MFE §23.6.3)

Fortran2008 の場合、coarray の image 毎に call random_seed() してやっても、すべての image で同じ乱数が生成されてしまっていました。Fortran 2018 では random_init というサブルーチンが導入されて、各イメージが異なる seed を持つことが出来るようになりました。

fortranwiki.org