Fortran Array
Fortran Array
implicit none
real, parameter :: PI = 4.0 * atan( 1.0 ) ! The number pi
real, dimension(3,3) :: a, b, c ! Declare size of a, b and c
! real a(3,3), b(3,3), c(3,3) ! Alternative dimension statement
integer i, j ! Counters
character(len=*), parameter :: fmt = "( a, 3(/, 3(1x, f8.3)), / )"
! Format string for output
! Matrix sum
c = a + b
write( *, fmt ) "a+b", ( ( c(i,j), j = 1, 3 ), i = 1, 3 )
! "element-by-element" multiplication
c = a * b
write( *, fmt ) "a*b", ( ( c(i,j), j = 1, 3 ), i = 1, 3 )