Microsoft KB Archive/27780

= How FORTRAN Stores Two-Dimensional Arrays in Memory =

Article ID: 27780

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.01
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN PowerStation 1.0 Standard Edition
 * Microsoft Fortran PowerStation 1.0a for MS-DOS
 * Microsoft FORTRAN PowerStation 32
 * Microsoft FORTRAN PowerStation 32

-



This article was previously published under Q27780



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: kblangfortran KB27780

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.