  FUNCTION pivot_row( A )
    real, dimension(:, :) :: A
    real, dimension( : ),  pointer :: pivot_row

    integer, dimension ( 2 ) :: location
    real, dimension(:), ALLOCATABLE, TARGET :: R


    location = MAXLOC( A )      !! Find row + column index of MAX elem.

    print *, " "
    print *, "Pivot element at: ", location

    ALLOCATE( R(SIZE(A(1, :)  ) ) )
    R = A( location(1), : )

    pivot_row => R

  END FUNCTION


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

  PROGRAM Main

    INTERFACE
      FUNCTION  pivot_row( A )
	real, dimension(:, :), target  :: A
	real, dimension( : ),  pointer :: pivot_row
      END FUNCTION
    END INTERFACE

    real, dimension(3, 3) :: A
    integer i, m, n
    real, dimension(:), pointer :: p		! 1 pointer, points to an array

    n = size ( A(1, :) )
    m = n*n

    A = reshape( (/ (i, i=1, m) /) , (/ n, n /) )

    print *, " "
    print *, "Array A:"
    DO i = 1, n, 1
      print *, A(i, :)
    END DO

    p => pivot_row(A)


    print *, " "
    print *, "Pivot row P:"
    print *, p

    p(1) = 100.0

    print *, " "
    print *, "Array A after changing p(1) = 100:"
    DO i = 1, n, 1
      print *, A(i, :)
    END DO

  END PROGRAM

