home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / fortran / 4840 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.8 KB  |  50 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!think.com!ames!news.dfrf.nasa.gov!altair.dfrf.nasa.gov!maine
  3. From: maine@altair.dfrf.nasa.gov (Richard Maine)
  4. Subject: DO loops (was: Obscure fortran question)
  5. In-Reply-To: "John C. Ruttenberg"'s message of Tue, 22 Dec 1992 22:22:49 GMT
  6. Message-ID: <MAINE.92Dec22151503@altair.dfrf.nasa.gov>
  7. Sender: news@news.dfrf.nasa.gov (Usenet news)
  8. Organization: NASA Dryden, Edwards, Cal.
  9. References: <tubetf0@sgi.sgi.com>
  10. Date: Tue, 22 Dec 1992 23:15:08 GMT
  11. Lines: 37
  12.  
  13. On Tue, 22 Dec 1992 22:22:49 GMT, "John C. Ruttenberg" <rutt@paradise.mti.sgi.com> said:
  14.  
  15. John> Suppose the do variable is assigned above the loop and used in the second
  16. John> expression of a do.  Should its value there be:
  17. John>     1. Its value above the loop, or
  18. John>     2. The value of the first expression in the do?
  19. John> ...
  20. John> Looking at the standard, I was unable to decide what should happen.
  21.  
  22. Its value above the loop.  Section 11.10.3 of ANSI X3.9-1978 says
  23.  
  24.     11.10.3 Executing a DO statement.  The effect of executing a DO statement
  25.     is to perform the following steps in sequence:
  26.                                     ^^^^^^^^^^^
  27.       (1) The initial parameter m1, the terminal parameter m2, and the
  28.           incrementation parameter m3 are established by evaluating e1,
  29.           e2, and e3...
  30.  
  31.       (2) The DO-variable becomes defined with the value of the initial
  32.           parameter m1.
  33.  
  34. Since the effect must be as if these steps were performed *in sequence*,
  35. the value of the DO-variable used in evaluating e1, e2, and e3 is its
  36. value above the loop.  The value of the DO-variable isn't changed until
  37. step 2.
  38.  
  39. The same answer applies to f90.
  40.  
  41. John> The SGI compiler seems to choose option 2.
  42.  
  43. Then its broken.
  44.  
  45. --
  46. --
  47. Richard Maine
  48. maine@altair.dfrf.nasa.gov
  49.  
  50.