home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!think.com!ames!news.dfrf.nasa.gov!altair.dfrf.nasa.gov!maine
- From: maine@altair.dfrf.nasa.gov (Richard Maine)
- Subject: DO loops (was: Obscure fortran question)
- In-Reply-To: "John C. Ruttenberg"'s message of Tue, 22 Dec 1992 22:22:49 GMT
- Message-ID: <MAINE.92Dec22151503@altair.dfrf.nasa.gov>
- Sender: news@news.dfrf.nasa.gov (Usenet news)
- Organization: NASA Dryden, Edwards, Cal.
- References: <tubetf0@sgi.sgi.com>
- Date: Tue, 22 Dec 1992 23:15:08 GMT
- Lines: 37
-
- On Tue, 22 Dec 1992 22:22:49 GMT, "John C. Ruttenberg" <rutt@paradise.mti.sgi.com> said:
-
- John> Suppose the do variable is assigned above the loop and used in the second
- John> expression of a do. Should its value there be:
- John> 1. Its value above the loop, or
- John> 2. The value of the first expression in the do?
- John> ...
- John> Looking at the standard, I was unable to decide what should happen.
-
- Its value above the loop. Section 11.10.3 of ANSI X3.9-1978 says
-
- 11.10.3 Executing a DO statement. The effect of executing a DO statement
- is to perform the following steps in sequence:
- ^^^^^^^^^^^
- (1) The initial parameter m1, the terminal parameter m2, and the
- incrementation parameter m3 are established by evaluating e1,
- e2, and e3...
-
- (2) The DO-variable becomes defined with the value of the initial
- parameter m1.
-
- Since the effect must be as if these steps were performed *in sequence*,
- the value of the DO-variable used in evaluating e1, e2, and e3 is its
- value above the loop. The value of the DO-variable isn't changed until
- step 2.
-
- The same answer applies to f90.
-
- John> The SGI compiler seems to choose option 2.
-
- Then its broken.
-
- --
- --
- Richard Maine
- maine@altair.dfrf.nasa.gov
-
-