
! -- Programme to solve square linear systems.  Illustrates array features
!    including:
!
!     -- allocatable arrays (heap space);
!     -- stack :
!         -- assumed shape arrays;
!         -- automatic arrays --- local workspace;

PROGRAM linalg

USE main_mod
USE lin_alg

  INTEGER :: size

  REAL, DIMENSION(:,:), ALLOCATABLE :: coeffs
  REAL, DIMENSION(:), ALLOCATABLE   :: rhs, soln
                                                 ! ...allocatable arrays, which
                                                 !    are allocated below...

  size = System_Size()
  
  ALLOCATE(coeffs(size,size))
  ALLOCATE(rhs(size))
  ALLOCATE(soln(size))

  CALL Get_Coeffs(coeffs)
  CALL Get_RHS(rhs)

  CALL Solve_System(coeffs, rhs, soln)
!!  CALL Check_Soln(coeffs, rhs, soln)

END PROGRAM linalg
