fix: ensure separate seeds on parallel threads, fixes #411
This commit is contained in:
committed by
Franck HOUSSEN
parent
9fe9d462a6
commit
b29d5630fc
@@ -177,11 +177,11 @@ c %------------------------%
|
||||
c | Local Scalars & Arrays |
|
||||
c %------------------------%
|
||||
c
|
||||
logical first, orth
|
||||
integer idist, iseed(4), iter, msglvl, jj
|
||||
logical first, inits, orth
|
||||
integer idist, iseed(4), iter, msglvl, jj, myid, igen
|
||||
Double precision
|
||||
& rnorm0, buf2(1)
|
||||
save first, iseed, iter, msglvl, orth, rnorm0
|
||||
save first, iseed, inits, iter, msglvl, orth, rnorm0
|
||||
c
|
||||
Double precision
|
||||
& rnorm_buf
|
||||
@@ -206,6 +206,12 @@ c %---------------------%
|
||||
c
|
||||
intrinsic abs, sqrt
|
||||
c
|
||||
c %-----------------%
|
||||
c | Data Statements |
|
||||
c %-----------------%
|
||||
c
|
||||
data inits /.true./
|
||||
c
|
||||
c %-----------------------%
|
||||
c | Executable Statements |
|
||||
c %-----------------------%
|
||||
@@ -216,10 +222,30 @@ c | Initialize the seed of the LAPACK |
|
||||
c | random number generator |
|
||||
c %-----------------------------------%
|
||||
c
|
||||
iseed(1) = 1
|
||||
iseed(2) = 3
|
||||
iseed(3) = 5
|
||||
iseed(4) = 7
|
||||
if (inits) then
|
||||
c
|
||||
c %-----------------------------------%
|
||||
c | Generate a seed on each processor |
|
||||
c | using process id (myid). |
|
||||
c | Note: the seed must be between 1 |
|
||||
c | and 4095. iseed(4) must be odd. |
|
||||
c %-----------------------------------%
|
||||
c
|
||||
call MPI_COMM_RANK(comm, myid, ierr)
|
||||
igen = 1000 + 2*myid + 1
|
||||
if (igen .gt. 4095) then
|
||||
write(0,*) 'Error in p_getv0: seed exceeds 4095!'
|
||||
end if
|
||||
c
|
||||
iseed(1) = igen/1000
|
||||
igen = mod(igen,1000)
|
||||
iseed(2) = igen/100
|
||||
igen = mod(igen,100)
|
||||
iseed(3) = igen/10
|
||||
iseed(4) = mod(igen,10)
|
||||
c
|
||||
inits = .false.
|
||||
end if
|
||||
c
|
||||
if (ido .eq. 0) then
|
||||
c
|
||||
|
||||
+32
-11
@@ -177,11 +177,11 @@ c %------------------------%
|
||||
c | Local Scalars & Arrays |
|
||||
c %------------------------%
|
||||
c
|
||||
logical first, orth
|
||||
integer idist, iseed(4), iter, msglvl, jj
|
||||
logical first, inits, orth
|
||||
integer idist, iseed(4), iter, msglvl, jj, myid, igen
|
||||
Real
|
||||
& rnorm0
|
||||
save first, iseed, iter, msglvl, orth, rnorm0
|
||||
save first, iseed, inits, iter, msglvl, orth, rnorm0
|
||||
c
|
||||
Real
|
||||
& rnorm_buf
|
||||
@@ -206,20 +206,41 @@ c %---------------------%
|
||||
c
|
||||
intrinsic abs, sqrt
|
||||
c
|
||||
c %-----------------%
|
||||
c | Data Statements |
|
||||
c %-----------------%
|
||||
c
|
||||
data inits /.true./
|
||||
c
|
||||
c %-----------------------%
|
||||
c | Executable Statements |
|
||||
c %-----------------------%
|
||||
c
|
||||
c
|
||||
c %-----------------------------------%
|
||||
c | Initialize the seed of the LAPACK |
|
||||
c | random number generator |
|
||||
c %-----------------------------------%
|
||||
if (inits) then
|
||||
c
|
||||
iseed(1) = 1
|
||||
iseed(2) = 3
|
||||
iseed(3) = 5
|
||||
iseed(4) = 7
|
||||
c %-----------------------------------%
|
||||
c | Generate a seed on each processor |
|
||||
c | using process id (myid). |
|
||||
c | Note: the seed must be between 1 |
|
||||
c | and 4095. iseed(4) must be odd. |
|
||||
c %-----------------------------------%
|
||||
c
|
||||
call MPI_COMM_RANK(comm, myid, ierr)
|
||||
igen = 1000 + 2*myid + 1
|
||||
if (igen .gt. 4095) then
|
||||
write(0,*) 'Error in p_getv0: seed exceeds 4095!'
|
||||
end if
|
||||
c
|
||||
iseed(1) = igen/1000
|
||||
igen = mod(igen,1000)
|
||||
iseed(2) = igen/100
|
||||
igen = mod(igen,100)
|
||||
iseed(3) = igen/10
|
||||
iseed(4) = mod(igen,10)
|
||||
c
|
||||
inits = .false.
|
||||
end if
|
||||
c
|
||||
if (ido .eq. 0) then
|
||||
c
|
||||
|
||||
Reference in New Issue
Block a user