You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
do j =1, n
rowj = w(j)
jm1 = j -1
! apply the previous transformations to
! r(i,j), i=1,2,...,j-1, and to w(j).
if (jm1 >=1) thendo i =1, jm1
temp =Cos(i)*r(i, j) +Sin(i)*rowj
rowj =-Sin(i)*r(i, j) +Cos(i)*rowj
r(i, j) = temp
end doend if
As you may notice for j = 1, jm1 = 0, meaning the if loop surrounding the inner do loop is totally superfluous.
As @arjenmarkus kindly explained in his reply at Discourse, this is a "legacy" issue related to Fortran 66 DO semantics. Edit: See Section 7.1.2.8 in the ANSI X 3.9 Fortran 66 standard. The requirement to surround the DO loop with an IF block came from the line:
At time of execution of the DO statement, m1, m2, and m3 must be greater than zero.
The MINPACK source code in the present state remains full of this pattern. Maybe CamFort, plusFORT, or fpt have a tool which could fix this?
It would be a good idea to start a document or wiki- page collecting such legacy "gotchas" if we plan to do more "modernization".
The text was updated successfully, but these errors were encountered:
ivan-pi
changed the title
Superfluous if due to one pass do-loops
Superfluous if blocks due to FORTRAN 66 do statement semantics
Feb 15, 2022
Here's a section of code from
rwupdt
:As you may notice for
j = 1
,jm1 = 0
, meaning the if loop surrounding the inner do loop is totally superfluous.As @arjenmarkus kindly explained in his reply at Discourse, this is a "legacy" issue related to Fortran 66 DO semantics. Edit: See Section 7.1.2.8 in the ANSI X 3.9 Fortran 66 standard. The requirement to surround the DO loop with an IF block came from the line:
The MINPACK source code in the present state remains full of this pattern. Maybe CamFort, plusFORT, or fpt have a tool which could fix this?
It would be a good idea to start a document or wiki- page collecting such legacy "gotchas" if we plan to do more "modernization".
The text was updated successfully, but these errors were encountered: