I've been trying to make a pretty basic LCG pseudorandom number generator in Fortran 77 to print out 1000 random numbers to a file, but for whatever reason the output is just 1000 0s. The entire code is pretty short so I've combed it over multiple times and tried changing some things around but I can't for the life of me figure out what is wrong. I have a hunch that it could be a scope issue (if such a concept is even useful in Fortran), but that is really unfounded.
PROGRAM RANDOM
COMMON ISEED, RANDOMNUMBER
ISEED = 123
OPEN (UNIT=1,FILE='rand.in',STATUS='UNKNOWN')
J=1
7 CALL RANDU(ISEED)
J=J+1
WRITE(1,*) RANDOMNUMBER
IF(J<1000)GOTO 7
STOP
END
SUBROUTINE RANDU(ISEED)
PARAMETER (IMAX = 2147483647, IMAXINV = 1./IMAX)
ISEED = ISEED * 65539
IF(ISEED<0) ISEED = ISEED + IMAX + 1
RANDOMNUMBER = ISEED * IMAXINV
RETURN
END
Does anyone have any ideas here? I'm fresh out.
Aucun commentaire:
Enregistrer un commentaire