Column-major storage of a Fortran array

A Fortran program declares the array integer :: a(2, 3), which has 2 rows and 3 columns, with subscripts starting at 1. Fortran stores a multidimensional array in column-major order: the elements of the first column come first, then the second column, so the first subscript varies fastest. Languages such as C store the same shape row by row, so the last subscript varies fastest. Counting the first stored element as position 1, fill in the memory position of each element under both layouts, as whole numbers.

ElementFortran column-major positionRow-by-row position
a(1,1)
a(2,1)
a(1,2)
a(2,2)
a(1,3)
a(2,3)

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Fortran and Other Imperative Languages Questions: