To: J3 J3/14-184 From: David Muxworthy Subject: UK proposal UK-22 RANDOM_NUMBER intrinsic Date: 2014 June 09 Status: For Consideration Basic Functionality: Independent random number generators Rationale: In N2013, Van Snyder says: "It is processor dependent whether common or independent random number generators are used, and there's no way to detect which is the situation. Therefore taking action using one assumption or the other (e.g., calling or not calling RANDOM_SEED on each image with a hopefully-different value, maybe dependent on the image number) might be the wrong thing to do. It is preferable to provide a named constant in ISO_FORTRAN_ENV to indicate whether the processor uses a common random number generator on all images, or intrinsic procedures so to inquire or specify. References to the intrinsic subroutine that specifies whether common or independent random number generators are used should be image control statements. 13.5p4 should be adjusted so that the segment ordering requirement applies only if a common random number generator is used." We would like to go further and require the processor to provide independent and different sequences. In a program John Reid wrote recently, he felt forced to generate his random numbers on image 1. He saw no other way of staying within the standard and getting random numbers. This is thoroughly unsatisfactory when we are aiming for execution on large numbers of processors. Bill Long commented in an email: "People have long been using MPI to execute in parallel on a large number of processors, and the exact same problem exists in that case. The traditional solution is to use a generator with at least 2 seeds. The value of one seed is the same on all MPI ranks (images), while the second is unique to each rank. For a sufficiently good generator, you don't do too badly." This illustrates that it is not difficult for compilers to provide adequately independent sequences. Our wording is intended to allow such an implementation, or perhaps something better. Syntax: No syntax change. Edits to J3/14-007r1(= N2014): [325:4-8] In 13.5 Standard generic intrinsic procedures, delete paragraph 4: "If RANDOM_SEED is called ... processor dependent." [382:22+] 13.7.136 RANDOM SEED ([SIZE, PUT, GET]) at the end of paragraph 5, add paragraph: "If no invocations of RANDOM_SEED are made, each image shall produce a different sequence of pseudo-random numbers."