Path: utzoo!mnetor!uunet!husc6!cmcl2!beta!unm-la!unmvax!nmtsun!john From: john@nmtsun.nmt.edu (John Shipman) Newsgroups: comp.lang.fortran Subject: Re: Modifying iteration variables in DO loops Message-ID: <1331@nmtsun.nmt.edu> Date: 3 Feb 88 14:05:30 GMT References: <1309@nmtsun.nmt.edu> <4026@aw.sei.cmu.edu> Organization: Zoological Data Processing Lines: 35 Keywords: X3 standard FORTRAN 77 Summary: Oops Apologies for my erroneous earlier posting. I have this problem trying to stay awake while reading X3 standards. So, given that you can't modify the iteration variable, what's the right way to implement a DO loop? The standard seems to imply that you use a hidden counter to control the loop, but your benchmarks won't shine if you have to maintain this counter as well as the visible iteration variable. My guess would be that you dispense with the hidden counter and use the visible iteration variable to control the loop, just making sure that the number of iterations will be as specified in the standard---right? Next question: what if you pass the iteration variable to a subroutine and that subroutine clobbers it? It would be hard for the compiler to know that, especially if the subroutine were linked in later. program main do 83 loop = 1, 2 call trouble ( loop ) 83 continue write ( 6, * ) loop end subroutine trouble ( arg ) arg = arg + 1 return end Does this program conform to the standard? If not, is there any reasonable way for the compiler to catch the violation? -- John Shipman/Zoological Data Processing/Socorro, New Mexico USENET: ihnp4!lanl!unm-la!unmvax!nmtsun!john ``If you can't take it, get stronger.'' --Falline Danforth