8 November 2023 11:35:10.167 AM random_mpi(): Master process: FORTRAN77 version The number of processors is P = 4 This program shows how a stream of random numbers can be computed "in parallel" in an MPI program. We assume we are using a linear congruential random number generator or "LCRG", which takes an integer input and returns a new integer output: U = ( A * V + B ) mod C We assume that we want the MPI program to produce the same sequence of random values as a sequential program would - but we want each processor to compute one part of that sequence. We do this by computing a new LCRG which can compute every P'th entry of the original one. Our LCRG works with integers, but it is easy to turn each integer into a real number between [0,1]. LCRG parameters: A = 16807 B = 0 C = 2147483647 Let processor 0 generate the entire sequence. K ID Input Output 0 0 12345 1 0 12345 207482415 2 0 207482415 1790989824 3 0 1790989824 2035175616 4 0 2035175616 77048696 5 0 77048696 24794531 6 0 24794531 109854999 1 1 207482415 5 1 207482415 24794531 9 1 24794531 1963079340 13 1 1963079340 573802814 17 1 573802814 728311420 21 1 728311420 1856187544 25 1 1856187544 1997725285 29 1 1997725285 1099641175 33 1 1099641175 2109273007 37 1 2109273007 1982386332 2 2 1790989824 6 2 1790989824 109854999 10 2 109854999 1683198519 14 2 1683198519 1702319868 18 2 1702319868 73248040 22 2 73248040 449112039 26 2 449112039 2009527797 30 2 2009527797 424962143 34 2 424962143 2038867620 38 2 2038867620 1905782366 7 0 109854999 1644515420 8 0 1644515420 1256127050 9 0 1256127050 1963079340 10 0 1963079340 1683198519 11 0 1683198519 715426902 12 0 715426902 419002361 13 0 419002361 573802814 14 0 573802814 1702319868 15 0 1702319868 2112876142 16 0 2112876142 319731802 17 0 319731802 728311420 18 0 728311420 73248040 19 0 73248040 571678549 20 0 571678549 359536365 21 0 359536365 1856187544 22 0 1856187544 449112039 23 0 449112039 1968503915 24 0 1968503915 512233723 25 0 512233723 1997725285 26 0 1997725285 2009527797 27 0 2009527797 658367810 28 0 658367810 1352033326 29 0 1352033326 1099641175 30 0 1099641175 424962143 31 0 424962143 1955611126 32 0 1955611126 718977347 33 0 718977347 2109273007 34 0 2109273007 2038867620 35 0 2038867620 1999017808 36 0 1999017808 110641741 37 0 110641741 1982386332 38 0 1982386332 1905782366 39 0 1905782366 765630357 40 0 765630357 227397275 LCRG parameters for P processors: AN = 984943658 BN = 0 C = 2147483647 Have ALL the processors participate in computing the same random number sequence. K ID Input Output 0 0 12345 4 0 12345 77048696 8 0 77048696 1256127050 12 0 1256127050 419002361 16 0 419002361 319731802 20 0 319731802 359536365 24 0 359536365 512233723 28 0 512233723 1352033326 32 0 1352033326 718977347 36 0 718977347 110641741 40 0 110641741 227397275 3 3 2035175616 7 3 2035175616 1644515420 11 3 1644515420 715426902 15 3 715426902 2112876142 19 3 2112876142 571678549 23 3 571678549 1968503915 27 3 1968503915 658367810 31 3 658367810 1955611126 35 3 1955611126 1999017808 39 3 1999017808 765630357 random_mpi(): Master process: Normal end of execution. 8 November 2023 11:35:10.168 AM