In FORTRAN, we have to define
the number of *ROWS* and the number of *COLUMNS* of
a matrix in that order after the variable name in the declaration
statements.

INTEGER :: DAYS(12,31) REAL :: YSALES(12,2) CHARACTER (LEN=3) :: SEASON(4,3)

**READING AND PRINTING
MATRICES
**

* Arrays are stored by columns.

PROGRAM MATRICES IMPLICIT NONE CHARACTER(LEN=3) :: MONTHS(3,4) READ 33,MONTHS 33 FORMAT (12(' ',A3)) PRINT 33,MONTHS L1: DO I=1,3 L2: DO J=1,4 PRINT 40,I,J,MONTHS(I,J) 40 FORMAT (' ROW ',I1,' COLUMN ',I1,' IS ',A3) END DO L2 END DO L1 STOP END PROGRAM MATRICES/DATA

JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC/ENDRUN

JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC ROW 1 COLUMN 1 IS JAN ROW 1 COLUMN 2 IS APR ROW 1 COLUMN 3 IS JUL ROW 1 COLUMN 4 IS OCT ROW 2 COLUMN 1 IS FEB :

SEE EXAMPLES :

P71.F90 MATRIX
INPUT/OUTPUT

P72.F90 MATRIX
SUMMARY

P73.F90 MATRIX MULTIPLICATION PROGRAM

On to the next lecture

Go back to lecture menu