- #1
cpburris
Gold Member
- 38
- 4
This isn't really a question for which the template is useful..
Can anyone explain to me why the value of the variable 'seed' in location 1 is different from the value in location 2? The only thing happening in between is the defining of the varaible v(1) using the real function. I don't see where in that 'seed' is given a new value. I've tried google searching 'Fortran seed' and such and can't find any answer.
Can anyone explain to me why the value of the variable 'seed' in location 1 is different from the value in location 2? The only thing happening in between is the defining of the varaible v(1) using the real function. I don't see where in that 'seed' is given a new value. I've tried google searching 'Fortran seed' and such and can't find any answer.
Code:
JRDM = 83721563
call baysprep(JRDM)
! -----------------------------------------
subroutine baysprep(first)
integer first,seed
common /tobays/ v(53),oldbays,seed
save /tobays/
seed = abs(first)
if (seed.gt.2147483647) seed = 24287
do i = 1,53
!Location 1
print*,'seed into do loop iteration=',seed
v(1) = congmult(seed)
!Location 2
print*,'seed coming out of do loop iteration=',seed
end do
!
real function congmult(ix)
!
integer a,p,ix,b15,b16,xhi,xalo,leftlo,fhi,k
data a,b15,b16,p/16807,32768,65536,2147483647/
! assigns variables these values
xhi = ix / b16
xalo = a*(ix - xhi*b16)
leftlo = xalo / b16
fhi = xhi*a + leftlo
k = fhi / b15
ix = (((xalo-leftlo*b16) - p) + (fhi-k*b15)*b16) + k
if (ix.lt.0) ix = ix + p
congmult = real(ix)/2.147483647e+09
end
Last edited by a moderator: