文章主要讲fortran在gpu端生成随机数。
首先,调用库函数 cublas_device
其次,声明四个变量
type(curandStateXORWOW) :: h
integer(8) :: seed, seq, offset
最后,调用函数
call curand_init(seed, seq, offset, h)
random = curand_uniform(h)
random为(0,1)之间的实数
最最后,编译的时候 需要在在编译指令里添加 -Mcudalib=curand
这样就可以生成随机数了