How FORTRAN Stores Two-Dimensional Arrays in Memory

ID: Q27780

4.00 4.01 4.10 5.10 1.00 1.00a | 4.10 5.10 | 1.00 4.00

MS-DOS                         | OS/2      | WINDOWS NT
kbusage

The information in this article applies to:

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 reference words: kbinf 4.00 4.10 5.10 1.00 KBCategory: kbusage KBSubcategory: FORTLngIss
Keywords          : kbFortranPS kbLangFortran 
Version           : 4.00 4.01 4.10 5.10 1.00 1.00a |
Platform          : MS-DOS NT OS/2 WINDOWS

Last Reviewed: May 2, 1998