INTEGER SEED, NUMBER, GUESS PRINT *, 'ENTER A RANDOM NUMBER SEED' READ *, SEED CALL SRAND(SEED) NUMBER = INT( RAND(0) * 100 + 1 ) PRINT *, 'GUESS A NUMBER BETWEEN 1 AND 100' 10 READ *, GUESS IF (GUESS.LT.NUMBER) THEN PRINT *, 'TOO LOW' ELSE IF (GUESS.GT.NUMBER) THEN...
INTEGER SEED, NUMBER, GUESS PRINT *, 'ENTER A RANDOM NUMBER SEED' READ *, SEED CALL SRAND(SEED) NUMBER = INT( RAND(0) * 100 + 1 ) PRINT *, 'GUESS A NUMBER BETWEEN 1 AND 100' 10 READ *, GUESS IF (GUESS.LT.NUMBER) THEN PRINT *, 'TOO LOW' ELSE IF (GUESS.GT.NUMBER) THEN...
示例:舍入,求介于 –1 和 +1 之间的 100,000 个随机数之和: demo% cat t4.f parameter ( n = 100000 ) double precision d_lcrans, lb / -1.0 /, s, ub / +1.0 /, v(n) s = d_lcrans ( v, n, lb, ub ) ! Get n random nos. between -1 and +1 s = 0.0 do i = 1, n...
The range includes 0.0 and excludes 1.0. The algorithm is a multiplicative, congruential type, general random number generator. The initial value ofishould be a large odd integer. Each call toRANgets the next random number in the sequence. ...
! | "Minimal" random numberof Park and Miller with | ! | Bays-Durham shuffle and added. Returns a uniform | ! | random deviate between 0.0 and 1.0 (exclusive of the end points). | ! | Call with idum a negative integer to initialize; thereafter do | ...
rand()不大好用,用这个:0-1之间类似于 program test implicit none real :: x call random_seed()! 系统根据日期和时间随机地提供种子"call random_number(x)print *,x end program 另外,在一个程序中, "call random_seed () 这一句是不能重复的,只能用一次。所以它不能放到循环里面去...
Blank Control BN and BZ 注 w - 宽度, m - 最小宽度 , d - 小数位数 , e - 指数位数 program format implicit none real :: array(10) character(len=6) :: text = 'String' print '(A3)', text ! 只能打印‘Str’ print '(A6)', text ! 可以打印‘String’ call random_number(array)...
program multidimred use cudafor real(8), managed :: a(5,5,5,5,5) real(8), managed :: b(5,5,5,5) real(8) :: c call random_number(a) do idim = 1, 5 b = sum(a, dim=idim) c = max(maxval(b), c) end do print *,"Max along any dimension",c end program Array ...
1). One module may reference another. Sign in to download full-size image Figure 1. A module that defines a type suitable for interval arithmetic, the operation to perform addition between two scalar objects of that type, and the assignment of a real object to an object of type interval....
REAL(KIND = kind_number) :: real_var 1. 根据传统惯例,在任意指定计算机上的较短版本的REAL数据类型被看作是单精度的,较长版本的REAL数据类型被看作是双精度的。在大部分计算机上,单精度实数用4字节(32位)来存储,双精度实数用8字节(64位)来存储。而在一些64位处理器上,用8字节(64位)来存储单精度数,...