hirchert@uxe.cso.uiuc.edu (03/21/89)
In various postings, Steven R Weintraub (steve@oakhill.UUCP) has been addressing issues relating to nested DO loops sharing a common terminal statement, with a GOTO in the outer loop directed at that common terminal statement. He has made several points that I would dispute: 1. He suggests that market pressures force compiler writers to support such programs. This may be true in some market segments, but there are a large number of successful compilers that do not provide the support he suggests. 2. He suggests that the behavior that is assumed when a programmer writes such a jump is always a skipping of the innner loop and a cycling of the outer loop. Vendors whose customers have codes going back to FORTRAN 66 may expect that such a branch is a resumption of the inner loop from code executed as the "extended range" of that inner loop. It may not always be possible to determine whether extended range of the inner loop or cycling of the outer loop is intended, and it may be possible to generate code such that it can handle either case. If one can generate code so it works either way, the result may be a performance penalty for the vast majority of people who don't want to do either of these things. 3. He suggests that X3J3 is unrealistically ignoring the real world in not defining this case. First, let me point out that to the best of my knowledge, no one has asked X3J3 to do so! X3J3 _has_ been asked what the current standard (FORTRAN 77) has to say on the subject, but has not been asked to change that in the Fortran 8x revision. (Grousing in this group does _not_ constitute a request to X3J3.) Second, it would be difficult for X3J3 to achieve a consensus on what should be meant by this case because of the conflict between the extended range interpretation and the cycling interpretation. Third, X3J3 has attempted to deal with what people want to do by providing features that do them unambiguously. The CYCLE statement can be used to cycle loops and, in most cases where the extended range of DO cannot efficiently be incorporated into the ordinary range of the DO, an internal subroutine can be used to encapsulate such an extended range and make it referenceable without exiting the loop. Kurt W. Hirchert hirchert@ncsa.uiuc.edu National Center for Supercomputing Applications
mcdonald@uxe.cso.uiuc.edu (03/21/89)
One final thing on nested DO;s and extended ranges: If what you want is backward compatibility with old code, for purposes of not having to recode, I sympathise strongly. If you want to write NEW code with funny behaviour of nested loops, including jumping out and then back in, may I humbly suggest that in all Fortrans from Fortran 66 on, that it can be done. In fact, it is easy and legal. It just means avoiding posting code in places where certain constructs cause flame attacks. It might also be a bit (a little bit) slower. It is also MUCH more flexible. Code your own loops with logical if statements, arithmetic statements goto's and labeled statements! So there - I actually did it - I recommended that you use goto's. Doug McDonald