作业帮 > 综合 > 作业

一段fortran程序,用于生成随机数,哪里出问题了

来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/07/13 11:10:07
一段fortran程序,用于生成随机数,哪里出问题了
real*8 function random()
implicit double precision(a-h,o-z)
common/random_s/x
x=dmod(x*1953125d0,8388593d0)
random=(x+0.1d0)/8388593d0
return
end
block data
real*8 x
common/random_s/x
data x/235621d0/
end block data
另外,问题是The type of the function reference does not match the type of the function definition.
有人说是形参和实参类型不一致,求问该怎么改动
我在调用的时候语句是a=random()
请问哪里出现什么问题了吗?
该怎么解决?
一段fortran程序,用于生成随机数,哪里出问题了
你给出的 random 没有任何虚参,不存在类型不一致的情况.
1.随机数,Fortran 有内置的函数random_number可以实现.
2.如果你要找出你的问题,建议你给出完整代码.
再问: 完整代码很长,不便复制,问题就是那句The type of the function reference does not match the type of the function definition. 还有,这段子函数程序本身没有什么问题吗? 内置的暂且不要。如果需要的话我自行改动,大神还是帮我看看这段子函数。
再答: 这子程序没有语法问题。但能否实现随机数,我觉得够呛。为什么内置的不要呢?? The type of the function reference does not match the type of the function definition. 意思确实是实参和虚参类型不一致,但不是发生在你给出的子程序上。 你给出的子程序,根本没有虚参啊。 最后,我强烈建议你放弃使用 common 和 data 语句。