
!------------------------------------------------------------------------------
!
!  Program name:
!
!    reshape_constructor
!
!  Purpose:
!
!    This program demonstrates the use of the array constructor and 
!    the intrinsic function RESHAPE to generate the same array 
!    as the one created by matrix.f90.
!
!------------------------------------------------------------------------------

PROGRAM reshape_constructor

  IMPLICIT NONE
  INTEGER, PARAMETER :: n = 9
  INTEGER, DIMENSION (n,n) :: ia
  INTEGER :: i, j

  ! Assign matrix ia with array constructor:
  WRITE(*,'(//"Assign with Array Constructor:"/)')

  ia = RESHAPE( (/ (((i + j*10), j=1,n), i=1,n) /), SHAPE = (/ n,n /) )

  ! Write out whole array, rowwise:
  WRITE(*,'(9i5)') (ia(i, :), i = 1, n)

END PROGRAM reshape_constructor
