Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!mit-eddie!ll-xn!ames!ptsfa!ihnp4!homxb!genesis!hotlg!anumb!eao From: eao@anumb.UUCP (e.a.olson) Newsgroups: comp.lang.fortran,comp.lang.pascal Subject: Re: Array storage order Message-ID: <105@anumb.UUCP> Date: Mon, 29-Jun-87 19:56:33 EDT Article-I.D.: anumb.105 Posted: Mon Jun 29 19:56:33 1987 Date-Received: Wed, 1-Jul-87 04:43:40 EDT References: <1215@batcomputer.tn.cornell.edu> Organization: AT&T Bell Labs, Andover MA Lines: 23 Xref: mnetor comp.lang.fortran:134 comp.lang.pascal:176 > We're trying to arrange for a C subroutine library to be callable from > Fortran and Pascal and also transportable between machines. > > One of the questions that has come up is with respect to the storage > order of 2-dimensional arrays. In C, array element [1][2] is stored > in memory immediately after element [1][1]. I believe this is locked > into the language - pointer arithmetic and all that. On the Fortran > compilers I can get to, (2,1), not (1,2), immediately follows (1,1). > The pascal I haven't investigated yet. > > Question: is this array storage order mandated by the Fortran-77 standard? > How about the Pascal standard? If so, then I'll document the arrays as being > "backwards" in these languages. If not, I'll keep two code versions. > Obviously, two manual versions would be less hassle. > > Help appreciated. > > garry wiegand (garry@oak.cadif.cornell.edu - ARPA) > (garry@crnlthry - BITNET) The order is mandated by the standard. In fortran, arrays are stored in row-major order. In 'C' and Pascal arrays are stored in column-major order.