* This is a simple fortran program to access arrays either * moving along the column or along the row. PROGRAM SIMPLELOOP INTEGER*1 MAT(10000,10000) INTEGER MODE PRINT *, 'In column-major storage, a multidimensional array in ' PRINT *, 'linear memory is accessed such that columns are stored ' PRINT *, 'one after the other.' PRINT *, 'It is the approach used by FORTRAN. The array' PRINT *, ' 1 2 3' PRINT *, ' 4 5 6' PRINT *, 'stored with column-major order would look like:' PRINT *, ' 1 4 2 5 3 6' PRINT *, 'The memory offset could then be computed as:' PRINT *, 'offset = row + column*NUMROWS' PRINT *,'' PRINT *, 'Move along the column = 1, Move along the row = 2:' READ *, MODE IF (MODE.EQ.1) THEN DO 209, J=1,10000 DO 201, I=1,10000 MAT(I,J) = 37 201 CONTINUE 209 CONTINUE PRINT *, 'DONE' END IF IF (MODE.EQ.2) THEN DO 409, I=1,10000 DO 401, J=1,10000 MAT(I,J) = 37 401 CONTINUE 409 CONTINUE PRINT *, 'DONE' END IF END