Skip to content

BUG: odrpack: fix invalid stride checks in d_lpkbls.f #7367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2017
Merged

Conversation

pv
Copy link
Member

@pv pv commented May 2, 2017

Here's a fix for a bug that's been in scipy.odr since forever.

The conversion of the statement

    IF(INCX.EQ.INCY) IF(INCX-1) 5,20,60

to more modern Fortran 77 alternative was done incorrectly in d_lpkbls.f
in commit f17818d. The correct meaning is

    IF (INCX.EQ.INCY) THEN
        IF (INCX.lt.1) GOTO 5
        IF (INCX.eq.1) GOTO 20
        GOTO 60
    END IF

The conversions in the commit for the other .f files look ok.

The actual diff you want to look at is between the original file and this one, which you can summon via
git diff -M 3f92506daca715d1 -- Lib/sandbox/odr/odrpack/d_lpkbls.f scipy/odr/odrpack/d_lpkbls.f

diff --git a/Lib/sandbox/odr/odrpack/d_lpkbls.f b/scipy/odr/odrpack/d_lpkbls.f
similarity index 99%
rename from Lib/sandbox/odr/odrpack/d_lpkbls.f
rename to scipy/odr/odrpack/d_lpkbls.f
index ca2e31e..61b11e7 100644
--- a/Lib/sandbox/odr/odrpack/d_lpkbls.f
+++ b/scipy/odr/odrpack/d_lpkbls.f
@@ -136,7 +136,11 @@ C***FIRST EXECUTABLE STATEMENT  DAXPY
 
 
       IF(N.LE.0.OR.DA.EQ.0.D0) RETURN
-      IF(INCX.EQ.INCY) IF(INCX-1) 5,20,60
+      IF (INCX.EQ.INCY) THEN
+         IF (INCX.lt.1) GOTO 5
+         IF (INCX.eq.1) GOTO 20
+         GOTO 60
+      END IF
     5 CONTINUE
 
 C        CODE FOR NONEQUAL OR NONPOSITIVE INCREMENTS.
@@ -481,7 +485,11 @@ C***FIRST EXECUTABLE STATEMENT  DCOPY
 
 
       IF(N.LE.0)RETURN
-      IF(INCX.EQ.INCY) IF(INCX-1) 5,20,60
+      IF (INCX.EQ.INCY) THEN
+         IF (INCX.lt.1) GOTO 5
+         IF (INCX.eq.1) GOTO 20
+         GOTO 60
+      END IF
     5 CONTINUE
 
 C        CODE FOR UNEQUAL OR NONPOSITIVE INCREMENTS.
@@ -585,7 +593,11 @@ C***FIRST EXECUTABLE STATEMENT  DDOT
 
       DDOT = 0.D0
       IF(N.LE.0)RETURN
-      IF(INCX.EQ.INCY) IF(INCX-1) 5,20,60
+      IF (INCX.EQ.INCY) THEN
+         IF (INCX.lt.1) GOTO 5
+         IF (INCX.eq.1) GOTO 20
+         GOTO 60
+      END IF
     5 CONTINUE
 
 C         CODE FOR UNEQUAL OR NONPOSITIVE INCREMENTS.
@@ -1766,7 +1778,11 @@ C***FIRST EXECUTABLE STATEMENT  DSWAP
 
 
       IF(N.LE.0)RETURN
-      IF(INCX.EQ.INCY) IF(INCX-1) 5,20,60
+      IF (INCX.EQ.INCY) THEN
+         IF (INCX.lt.1) GOTO 5
+         IF (INCX.eq.1) GOTO 20
+         GOTO 60
+      END IF
     5 CONTINUE
 
 C       CODE FOR UNEQUAL OR NONPOSITIVE INCREMENTS.

The conversion of the statement

    IF(INCX.EQ.INCY) IF(INCX-1) 5,20,60

to more modern Fortran 77 alternative was done incorrectly in d_lpkbls.f
in commit f17818d. The correct meaning is

    IF (INCX.EQ.INCY) THEN
        IF (INCX.lt.1) GOTO 5
        IF (INCX.eq.1) GOTO 20
        GOTO 60
    END IF

The conversions in the commit for the other .f files look ok.
@pv pv added defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.odr labels May 2, 2017
@ev-br
Copy link
Member

ev-br commented May 7, 2017

Wow. Magic. Thanks Pauli!

@ev-br ev-br merged commit 58c3964 into scipy:master May 7, 2017
@ev-br ev-br added this to the 1.0 milestone May 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.odr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants