How FORTRAN Stores Two-Dimensional Arrays in Memory

ID: Q27780


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0, 1.0a
  • Microsoft Fortran Powerstation 32 for Windows NT, versions 1.0, 4.0


SUMMARY

FORTRAN is different from languages such as C and Pascal in the way that it stores two-dimensional arrays in memory. Although array elements are referenced in row major notation, i.e., (row, column), just as in C or Pascal, FORTRAN stores two-dimensional arrays as one-dimensional column arrays.

For example, in C, a two-dimensional array with three rows and four columns will be stored in memory in the following sequence:

(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4)
However, FORTRAN will store the same array in the following sequence:
(1,1),(2,1),(3,1),(1,2),(2,2),(3,2),(1,3),(2,3),(3,3),(1,4),(2,4),(3,4)

Additional query words: kbinf 4.00 4.10 5.10 1.00

Keywords : kbFortranPS kbLangFortran
Version : :1.0,1.0a,4.0,4.01,4.1,5.1
Platform : MS-DOS NT OS/2 WINDOWS
Issue type :


Last Reviewed: November 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.