home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / fortran / 4315 < prev    next >
Encoding:
Text File  |  1992-11-14  |  1.9 KB  |  46 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!destroyer!gatech!hubcap!mjs
  3. From: mjs@hubcap.clemson.edu (M. J. Saltzman)
  4. Subject: History question--fortran arrays
  5. Message-ID: <1992Nov13.205321.5562@hubcap.clemson.edu>
  6. Organization: Clemson University, Clemson SC
  7. Date: Fri, 13 Nov 1992 20:53:21 GMT
  8. Lines: 36
  9.  
  10. On comp.lang.c, another discussion of the relative virtues of Forrtan
  11. vs. C is occurring (relatively civilized so far, compared to the usual
  12. religious wars).  It's not my intention to perpetuate the argument,
  13. but a question came up that might get a more accurate answer here than
  14. the speculation I've seen over there.
  15.  
  16. Does anyone know the historical justification for having Fortran arrays
  17. stored with the fastest-varying index at the left?
  18.  
  19. My guess is that this is a "natural" order with respect to some matrix
  20. operations, and that perhaps it has to do with data locality rather
  21. than instruction counts, or else it was something peculiar to the IBM
  22. 704.  It's certainly different from the "natural" order dictated by
  23. the C/Pascal/etc. philosophy that a multidimensional array is an array
  24. of arrays (with successive indices appended at the right).
  25.  
  26. I found a copy of a page from the original FORTRAN manual which contains
  27. the following:
  28.  
  29. >_Arrangement_of_Arrays_in_Storage_
  30. >
  31. >A 2-dimensioanl array A will, in the object program, be stored
  32. >sequentially in the order A(1,1), A(2,1), ...., A(m,1), A(1,2), ....,
  33. >A(m,2), ...., A(m,n).  Thus it is stored "columnwise", with the first
  34. >of its subscripts varying most rapidly, and the last varying least
  35. >rapidly.  The same is true of 3-dimensional arrays.  1-dimensional
  36. >arrays are of course simply stored sequentially.  All arrays are
  37. >stored backwards in storage; i.e. the above sequence is in the order
  38. >of decreasing absolute location.
  39.  
  40. But the accompanying article (by Backus) doesn't explain further.
  41.  
  42. -- 
  43.         Matthew Saltzman
  44.         Clemson University Math Sciences
  45.         mjs@clemson.edu
  46.