This chapter describes the random number generation subroutines.
The random number generation subroutine generates uniformly
distributed random numbers.
Table 107. List of Random Number Generation Subroutines (Message Passing)
Descriptive Name | Long-Precision Subroutine | Page |
---|---|---|
Uniform Random Number Generator | PDURNG | PDURNG--Uniform Random Number Generator |
This section contains the random number generation subroutine description.
This subroutine generates a global vector x of n uniform pseudo-random numbers in the ranges (0,1) or (-1,1), depending on the iopt argument. The random numbers are generated using the multiplicative congruential method with a user-specified seed, as follows:
where:
If n is 0, no computation is performed, and the initial seed is unchanged.
The global output vector x is distributed across the np
processes, using block-cyclic distribution with a block size nb. (The
processor grid can be one- or two-dimensions. For two dimensions, processes
are selected in row-major order.) The length n of vector x
must be a multiple of (np)(nb).
x, seed | Subroutine |
Long-precision real | PDURNG |
Fortran | CALL PDURNG (seed, n, nb, x, iopt, icontxt) |
C and C++ | pdurng (seed, n, nb, x, iopt, icontxt); |
Scope: global
Specified as: a number of the data type indicated in Table 108. You should specify seed to be an odd, whole number; otherwise, PDURNG sets it to an odd, whole number and continues with the computation. The value of seed must be 1.0 <= seed < 2.048.
Scope: global
Specified as: a fullword integer; n >= 0 and n must be divisible by (nb)(np).
Scope: global
Specified as: a fullword integer; nb > 0.
If iopt = 0, the range is (0,1).
If iopt = 1, the range is (-1,1).
Scope: global
Specified as: a fullword integer; iopt = 0 or 1.
Scope: global
Specified as: the fullword integer that was returned by a prior call to BLACS_GRIDINIT or BLACS_GRIDMAP.
Scope: global
Returned as: a number of the data type indicated in Table 108. It is an odd, whole number, where 1.0 <= seed < 2.048.
If iopt = 0, they are in the range (0,1).
If iopt = 1, they are in the range (-1,1).
Scope: local
Returned as: a one-dimensional array of (at least) length n/np, with a block size of nb, containing numbers of the data type indicated in Table 108.
lsattr -E -H -l sys0
None
This example generates 30 random numbers in global vector x with a block size of 3, using block-cyclic distribution over a 5 × 1 process grid.
ORDER = 'R' NPROW = 5 NPCOL = 1 CALL BLACS_GET(0, 0, ICONTXT) CALL BLACS_GRIDINIT(ICONTXT, ORDER, NPROW, NPCOL) CALL BLACS_GRIDINFO(ICONTXT, NPROW, NPCOL, MYROW, MYCOL) SEED N NB X IOPT ICONTXT | | | | | | CALL PDURNG( SEED , 30 , 3 , X , 0 , ICONTXT) SEED = 31415926535897.0
Note: | icontxt is the output of the BLACS_GRIDINIT call. |
SEED = (a30s0) mod (m) = 6316434292705.0
Global vector x with block size 3:
B,D 0 * * | 0.683821516135299845 | 0 | 0.058874407800946215 | | 0.391855250856924187 | | -------------------- | | 0.755994653022330709 | 1 | 0.557764301423606668 | | 0.001333801764989317 | | -------------------- | | 0.056855932753212101 | 2 | 0.331063036202269956 | | 0.347339794409027292 | | -------------------- | | 0.649429020370863697 | 3 | 0.386144876217390021 | | 0.457224855098420591 | | -------------------- | | 0.892518134165118937 | 4 | 0.074548748224632532 | | 0.912379366805073033 | | -------------------- | | 0.112809499110515077 | 5 | 0.857547605095465570 | | 0.756480901897081282 | | -------------------- | | 0.046993364463578046 | 6 | 0.889457684002341153 | | 0.167775766106718294 | | -------------------- | | 0.504952722600595649 | 7 | 0.999725924546471134 | | 0.696269487398215148 | | -------------------- | | 0.671896598019703362 | 8 | 0.271472156040264423 | | 0.566418406688985243 | | -------------------- | | 0.464684865759100063 | 9 | 0.982442539763031419 | | 0.022440482512937620 | * *
The following is the 5 × 1 process grid:
B,D | 0 |
---|---|
0
5 | P00 |
1
6 | P10 |
2
7 | P20 |
3
8 | P30 |
4
9 | P40 |
Local arrays for x:
p,q | 0 -----|---------------------- | 0.683821516135299845 | 0.058874407800946215 | 0.391855250856924187 0 | 0.112809499110515077 | 0.857547605095465570 | 0.756480901897081282 -----|---------------------- | 0.755994653022330709 | 0.557764301423606668 | 0.001333801764989317 1 | 0.046993364463578046 | 0.889457684002341153 | 0.167775766106718294 -----|---------------------- | 0.056855932753212101 | 0.331063036202269956 | 0.347339794409027292 2 | 0.504952722600595649 | 0.999725924546471134 | 0.696269487398215148 -----|---------------------- | 0.649429020370863697 | 0.386144876217390021 | 0.457224855098420591 3 | 0.671896598019703362 | 0.271472156040264423 | 0.566418406688985243 -----|---------------------- | 0.892518134165118937 | 0.074548748224632532 | 0.912379366805073033 4 | 0.464684865759100063 | 0.982442539763031419 | 0.022440482512937620