Paul,
I have succeeded in constructing a short reproducer for the false integer overflow bug that I reported recently ( http://forums.silverfrost.com/viewtopic.php?p=33464 ). The new reproducer is straight Fortran 77, with less than 100 lines. To see the bug, please compile with /check, link and run. The program aborts with integer overflow on line 71.
Thanks.
program main
implicit none
integer lrw, neq
real y(2), rwork(50)
EXTERNAL fsub
!
lrw = 50
neq = 2
y(1) = 2.0
y(2) = 0.0
call dvode (fsub, neq, y, rwork, lrw)
stop
!
end !program main
subroutine dvode(func, neq, y, rwork, lrw)
implicit none
integer neq, lrw, i, lf0
real y(neq), rwork(lrw)
integer n, lewt, lyh
EXTERNAL func
n = neq
lyh = 21
lewt = lyh + 13*n
lf0 = lyh + n
call func (y, rwork(lf0))
do i = 1,n
rwork(lyh+i-1) = y(i)
end do
do i = 1, n
rwork(i+lewt-1) = 1.0e6
rwork(lf0+i-1) = 3.0e-6*rwork(lf0+i-1)
end do
call dvstep (y, rwork(lyh), n, func) ! section of 1-D work array passed for 2-D array in callee
return
end !subroutine dvode
subroutine dvstep(y, yh, ldyh, func)
implicit none
integer ldyh
real y(2), yh(ldyh,2)
integer i
EXTERNAL func
do i = 1, ldyh
yh(i,1) = yh(i,1) + yh(i,2)
end do
call dvnlsd (y, yh, ldyh, func)
return
end !subroutine dvstep
!
!the subroutine arg func is not used in this bug reproducer, but needs to be present
!to preserve the overflow bug
!
subroutine dvnlsd(y, yh, ldyh, func)
! implicit none ==>> activating this line makes bug disappear
integer ldyh
real y(ldyh), yh(ldyh,*) !replacing '*' by 2 makes bug disappear
EXTERNAL func
call dcopy (2, yh(1, 1), y) ! Integer overflow here with /check
stop 'Normal completion'
end !subroutine dvnlsd
subroutine dcopy(n, dx, dy)
implicit none
integer n, i
real dx(n), dy(n)
do i = 1, n
dy(i) = dx(i)
end do
return
end !subroutine dcopy
subroutine fsub(y, ydot)
implicit none
real y(2), ydot(2)
ydot(1) = y(2)
ydot(2) = 3.0*(1.0 - y(1)*y(1))*y(2) - y(1)
return
end !subroutine fsub