[BUG FIX] Make sure iseed is always initialized to values allowed by

lapack ?larnv.

This means killing inits variable:
  - Using MPI, inits (shared variable) may be set to false by one proc,
    and prevent other procs to initialize seeds (as inits is shared by
    use of the save fortran keyword).
  - Not using MPI, inits only prevents from re-initializing seeds which
    have already been initialized.

This commit is not-op. From a functional point of view, we are doing
the same thing. From an implementation point of view, we make sure
iseed is always (for all MPI procs) initialized to values allowed
by lapack (if not, lapack crashes).

This problem doesn't occur with sequential code. Changes have been
done in both sequential and MPI code to keep things symmetric.
This commit is contained in:
Franck HOUSSEN
2022-08-14 23:06:47 +02:00
parent f36eb6c75d
commit ce2e69a849
9 changed files with 75 additions and 148 deletions
+1
View File
@@ -27,6 +27,7 @@ arpack-ng - 3.9.0
* arpackmm: restart bug fix.
* pyarpack: fix compilation warning, test on macos and latest boost-python (1.79).
* arpackSolver: fix error messages.
* [BUG FIX] Make sure iseed is always initialized to values allowed by lapack ?larnv.
[ Haoyang Liu ]
* CMake: minimum required version changed to 3.0
+19 -29
View File
@@ -176,13 +176,13 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj, myid, igen
Real
& rnorm0
Complex
& cnorm, cnorm2
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
Complex
& cnorm_buf, buf2(1)
@@ -203,12 +203,6 @@ c
& ccdotc
external ccdotc, pscnorm2, slapy2
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -219,30 +213,26 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
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 %-----------------------------------%
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.
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
if (ido .eq. 0) then
c
+6 -15
View File
@@ -177,11 +177,11 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj
Double precision
& rnorm0, buf2(1)
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
Double precision
& rnorm_buf
@@ -206,12 +206,6 @@ c %---------------------%
c
intrinsic abs, sqrt
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -222,13 +216,10 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
if (inits) then
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
inits = .false.
end if
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
c
if (ido .eq. 0) then
c
+6 -15
View File
@@ -177,11 +177,11 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj
Real
& rnorm0
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
Real
& rnorm_buf
@@ -206,12 +206,6 @@ c %---------------------%
c
intrinsic abs, sqrt
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -222,13 +216,10 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
if (inits) then
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
inits = .false.
end if
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
c
if (ido .eq. 0) then
c
+19 -29
View File
@@ -176,13 +176,13 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj, myid, igen
Double precision
& rnorm0
Complex*16
& cnorm, cnorm2
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
Complex*16
& cnorm_buf, buf2(1)
@@ -203,12 +203,6 @@ c
& zzdotc
external zzdotc , pdznorm2 , dlapy2
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -219,30 +213,26 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
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 %-----------------------------------%
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.
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
if (ido .eq. 0) then
c
+6 -15
View File
@@ -156,13 +156,13 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj
Real
& rnorm0
Complex
& cnorm
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
c %----------------------%
c | External Subroutines |
@@ -180,12 +180,6 @@ c
& ccdotc
external ccdotc, scnrm2, slapy2
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -196,13 +190,10 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
if (inits) then
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
inits = .false.
end if
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
c
if (ido .eq. 0) then
c
+6 -15
View File
@@ -157,11 +157,11 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj
Double precision
& rnorm0
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
c %----------------------%
c | External Subroutines |
@@ -183,12 +183,6 @@ c %---------------------%
c
intrinsic abs, sqrt
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -199,13 +193,10 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
if (inits) then
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
inits = .false.
end if
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
c
if (ido .eq. 0) then
c
+6 -15
View File
@@ -157,11 +157,11 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj
Real
& rnorm0
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
c %----------------------%
c | External Subroutines |
@@ -183,12 +183,6 @@ c %---------------------%
c
intrinsic abs, sqrt
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -199,13 +193,10 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
if (inits) then
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
inits = .false.
end if
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
c
if (ido .eq. 0) then
c
+6 -15
View File
@@ -156,13 +156,13 @@ c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
logical first, inits, orth
logical first, orth
integer idist, iseed(4), iter, msglvl, jj
Double precision
& rnorm0
Complex*16
& cnorm
save first, iseed, inits, iter, msglvl, orth, rnorm0
save first, iseed, iter, msglvl, orth, rnorm0
c
c %----------------------%
c | External Subroutines |
@@ -180,12 +180,6 @@ c
& zzdotc
external zzdotc, dznrm2, dlapy2
c
c %-----------------%
c | Data Statements |
c %-----------------%
c
data inits /.true./
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
@@ -196,13 +190,10 @@ c | Initialize the seed of the LAPACK |
c | random number generator |
c %-----------------------------------%
c
if (inits) then
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
inits = .false.
end if
iseed(1) = 1
iseed(2) = 3
iseed(3) = 5
iseed(4) = 7
c
if (ido .eq. 0) then
c