Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: FORTRAN porting question Message-ID: <11488@lanl.gov> Date: 4 Apr 89 21:18:21 GMT References: <16715@mimsy.UUCP> Distribution: usa Organization: Los Alamos National Laboratory Lines: 27 From article <16715@mimsy.UUCP>, by chris@mimsy.UUCP (Chris Torek): > In article <11447@lanl.gov> jlg@lanl.gov (Jim Giles) suggests two >>C NOTE: THIS ONE MAY FAIL DUE TO K BEING UNDEFINED AT THIS POINT. >> IF (I.EQ.J) GOTO 1000 >> ... >> K=0 >> 999 K=K+1 >> ... >> 1000 IF (K.LT.77) goto 999 > > (minor bug: should be k .le. 77) [...] Not true. If the condition were set to (K.LE.77) instead of (K.LT.77), the body of the loop would be executed with K==78. That would be one too many times. You are right, however, that the more common desired inter- pretation of the loop would be: C NOTE: THIS ONE MAY FAIL DUE TO K BEING UNDEFINED AT THIS POINT. IF (I.EQ.J) GOTO 1000 ... K=1 999 ... ! BODY OF LOOP K=K+1 1000 IF (K.LE.77) goto 999 The reason for prefering this would be that the value of K after the loop would be 78, just like the DO-loop would have left.