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

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!spool.mu.edu!sgiblab!sgigate!sgi!paradise.mti.sgi.com!rutt
  3. From: "John C. Ruttenberg" <rutt@paradise.mti.sgi.com>
  4. Subject: Obscure fortran question
  5. Message-ID: <tubetf0@sgi.sgi.com>
  6. Sender: rutt@paradise.mti.sgi.com
  7. Reply-To: rutt@paradise.mti.sgi.com
  8. Organization: Silicon Graphics, Inc.  Mountain View, CA
  9. Date: Tue, 22 Dec 1992 22:22:49 GMT
  10. Lines: 42
  11.  
  12.  
  13.  
  14. Suppose the do variable is assigned above the loop and used in the second
  15. expression of a do.  Should its value there be:
  16.  
  17.     1. Its value above the loop, or
  18.  
  19.     2. The value of the first expression in the do?
  20.  
  21. This is the same as the question of wheter the control variable and the final
  22. bound are initialized in parallel or serially.  Looking at the standard, I was
  23. unable to decide what should happen.
  24.  
  25. The SGI compiler seems to choose option 2.  Here's a test that demonstrates
  26. this.
  27.  
  28.       count = 0
  29.       i = 10
  30.       do 240 i = 1, identity(i)
  31. 240     count = count + 1
  32.       print *, count, i
  33.       stop
  34.       end
  35.  
  36.       integer function identity(i)
  37.       integer i
  38.  
  39.       identity = i
  40.  
  41.       return
  42.       end
  43.  
  44. This prints:
  45.  
  46.             1           2
  47.  
  48. demonstrating that i had a value of 1 (not 10) at the time of the call to
  49. identify?  Is this right?
  50.  
  51.  
  52.  
  53.  
  54.