To: J3 J3/14-184r1 From: David Muxworthy & Steve Lionel Subject: UK proposal UK-22 RANDOM_NUMBER intrinsic Date: 2014 June 23 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 provide a mechanism to request that the processor 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. This paper also proposes, as an option, of requiring that each image have its own random number generator. If this is not done, then the programmer doesn't know if adding a call to RANDOM_SEED in each image will reset the sequence for other images. 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): Option 1: [325:5-8] In 13.5 Standard generic intrinsic procedures, replace: "It is processor dependent whether each image uses a separate random number generator, or if some or all images use common random number generators. On images that use a common generator, the interleaving of calls to RANDOM NUMBER in unordered segments is processor dependent." with: "Each image uses a separate random number generator; a call to RANDOM_SEED on one image does not affect the sequence generated by calls to RANDOM_NUMBER on other images." [382:6] 13.7.136 RANDOM_SEED - replace: "If no argument is present, the processor assigns a processor-dependent value to the seed." with: "If no argument is present, the processor assigns a processor-dependent, unpredictable value to the seed different from that assigned by other calls to RANDOM_SEED without arguments in the same program." Option 2: Only the edit to [382:6] is done - it remains permissible for images to share a common generator, and a call to RANDOM_SEED affects all images (as it could today.)