Can we create pure functions in Fortran which generate random numbers?

前端 未结 2 995
我在风中等你
我在风中等你 2020-12-22 01:13

My goal is to write a pure function using random numbers which can be used in a DO CONCURRENT structure. The compiler does not seem to permit this.

mwe.f95:8         


        
2条回答
  •  庸人自扰
    2020-12-22 01:20

    You'll need pure random number generator. It is quite possible to make, say, for Linear Congruential Generator, where seed (being 64bit unsigned integer) is the same as state and is the same as return value. In that case state/seed is kept externally outside the sampling routine, passed explicitly and on getting it back from RNG is stored

提交回复
热议问题