RANDOM_WRITE: FORTRAN90 version This program makes a file of random integers for input to the DIEHARD tests. Select a sequence from this list: 1. A multiply-with-carry (MWC) generator x(n) = a * x(n-1) + carry mod 2^32 2. A MWC generator on pairs of 16 bits 3. The "Mother of all random number generators" 4. The KISS generator 5. The simple but very good generator COMBO 6. The lagged Fibonacci-MWC combination ULTRA 7. A combination MWC/subtract-with-borrow (SWB) generator, period ~ 10^364 8. An extended congruential generator 9. The Super-Duper generator 10. A subtract-with-borrow generator 11. Any specified congruential generator 12. The 31-bit generator ran2 from Numerical Recipes 13. Any specified shift-register generator, 31 or 32 bits 14. The system generator in Sun Fortran f77 15. Any lagged-Fibonacci generator, x(n) = x(n-r) op x(n-s) 16. An inverse congruential generator RANDOM_WRITE: Enter your choice, 1 to 16: MAKE_1616: This program creates the binary file 1616.32, containing 11+ megabytes of integers made by concatenating two 16-bit multiply-with-carry generators. The two generators have the form x(n)=a*x(n-1)+carry mod 2^16 and y(n)=b*y(n-1)+carry mod 2^16, with suggested choices for multipliers A and B. The carry C works as follows: If a and x are 16-bit and C at most 14 bits, then forming a*x+c produces an at-most 31-bit result. That result mod 2^16 (the rightmost 16 bits) is the new x and the topmost 16 bits the new carry c. The sequence of resulting x's has period the order of 2^16 in the group of residues relatively prime to m=a*2^16-1, which will be a*2^15-1 for the multipliers suggested here. You will be prompted to choose a and b and two seeds. Output is a 32-bit integer, the pair x,y side by side. This multiply-with-carry generator is best done in assembler, where it takes about 200 nanoseconds with a Pentium 120. A Fortran version takes about 300 ns. It seems to pass all tests and is highly recommended for speed and simplicity. The essence of a version in C requires only two statements: x = a * ( x & 65535 ) + ( x >> 16 ); y = b * ( y & 65535 ) + ( y >> 16 ); if x and y are 32-bit integers with carry in the top and output in the bottom half. The 32-bit integer returned is (x<<16)+(y&65525) Select multipliers a and b, a /= b, from this list: ----------------------------------------------------------- 18000 18030 18273 18513 18879 19074 19098 19164 19215 19584 19599 19950 20088 20508 20544 20664 20814 20970 21153 21243 21423 21723 21954 22125 22188 22293 22860 22938 22965 22974 23109 23124 23163 23208 23508 23520 23553 23658 23865 24114 24219 24660 24699 24864 24948 25023 25308 25443 26004 26088 26154 26550 26679 26838 27183 27258 27753 27795 27810 27834 27960 28320 28380 28689 28710 28794 28854 28959 28980 29013 29379 29889 30135 30345 30459 30714 30903 30963 31059 31083 ----------------------------------------------------------- Enter a and b: (my favorites are 18000 and 30903) Enter two (<=31 bit) seed integers, not zero Computation is beginning. Please be patient! MAKE_1616: The data has been written to "1616.32". 2,867,200 32-bit random integers (11,468,800 bytes) have been written to the file. They are the concatenated output of two 16-bit multiply-with-carry generators. The period is 597273182964842496. (the last 4 digits may be lost to roundoff). The correct last 4 digits are 2497 RANDOM_WRITE: Normal end of execution.