本帖最后由 likm1110 于 2015-3-13 09:14 编辑
[Fortran] 纯文本查看 复制代码 Module ran001
Implicit None
Save
Integer :: n = 9876
End Module ran001
!-------------------------------------------------------------
Subroutine random0(ran)
Use ran001
Implicit None
Real, Intent(out) :: ran
n = Mod(8121 * n + 28411, 134456) ! A number between 0 and 134455
ran = real(n) / 134456. ! Generate a number [0,1.)
End Subroutine random0
!-------------------------------------------------------------
Subroutine seed(iseed)
Use ran001
Implicit None
Integer, Intent(in) :: iseed
n = abs(iseed)
End Subroutine seed
这是一个产生为随机数的程序。我就想问问,在Module里为什么要定义n的初值? |