
  PROGRAM Main
   implicit none

   INTERFACE
    SUBROUTINE PrintMat(A)
    REAL, DIMENSION(:,:) :: A
    END SUBROUTINE
   END INTERFACE

   real, target, dimension( 3, 3 ) :: A      ! Matrix
   real, dimension(:,:), pointer :: B        ! Pointer to matrix
   integer :: i, j

   DO i = 1, SIZE(A(:, 1))
      DO j = 1, SIZE(A(1, :))
         A(i,j) = i + j              ! Initialize
      END DO
   END DO

   CALL PrintMat(A)                  ! Show initial matrix

   B => A

   B(1,1) = 1234		     ! Make change

   CALL PrintMat(A)                  ! Show changed matrix

  end program

! ====================================

  SUBROUTINE PrintMat(A)
   IMPLICIT NONE
   REAL, DIMENSION(:,:) :: A
   integer :: i, j

   DO i = 1, SIZE(A(:, 1))
      WRITE (6, '("[")', ADVANCE="NO")
      DO j = 1, SIZE(A(1, :))
         WRITE (6, '(2X F6.1)', ADVANCE="NO")   A(i,j)
      END DO
      WRITE (6, '("]")', ADVANCE="NO")
      print *
   END DO
   print *
  END SUBROUTINE

