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