!PROGRAM EXAMPLE
!  USE LA_PRECISION, ONLY: WP => SP
!  USE F77_LAPACK, ONLY: LA_GEQRF
!  IMPLICIT NONE
!  CHARACTER(LEN=*), PARAMETER :: FMT = '(7(1X,F9.3))'
!  INTEGER :: I, INFO, LDA, LWORK, M, N
!  REAL(WP), ALLOCATABLE :: A(:,:), TAU(:), WORK(:)
!  M = 5; N = 6; LDA = M; LWORK = -1
!  ALLOCATE( A(M,N), TAU(MIN(M,N)), WORK(MAX(1,N)) )
!  CALL RANDOM_NUMBER(A)
!  CALL LA_GEQRF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
!  LWORK = INT(WORK(1)); DEALLOCATE( WORK )
!  ALLOCATE( WORK(LWORK) )
!  CALL LA_GEQRF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
!  WRITE(*,*) 'INFO = ', INFO 
!  IF( INFO == 0 )THEN 
!    WRITE(*,*) 'Matrix A on exit:'
!    DO I = 1, M; WRITE (*,FMT) A(I,:); ENDDO
!  ENDIF
!END PROGRAM EXAMPLE
PROGRAM EXAMPLE 
  USE LA_PRECISION, ONLY: WP => SP 
  USE F77_LAPACK, ONLY: LA_GEQRF 
  IMPLICIT NONE 
  CHARACTER(LEN=*), PARAMETER :: FMT = '(7(1X,F9.3))' 
  INTEGER :: I, INFO, LDA, LWORK, M, N 
  REAL(WP), ALLOCATABLE :: A(:,:), TAU(:), WORK(:) 
  M = 5; N = 6; LDA = M; LWORK = -1 
  ALLOCATE( A(M,N), TAU(MIN(M,N)), WORK(MAX(1,N)) ) 
  CALL RANDOM_NUMBER(A) 
  CALL LA_GEQRF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) 
  LWORK = INT(WORK(1)); DEALLOCATE( WORK ) 
  ALLOCATE( WORK(LWORK) ) 
  CALL LA_GEQRF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) 
  WRITE(*,*) 'INFO = ', INFO  
  IF( INFO == 0 )THEN 
    WRITE(*,*) 'Matrix A on exit:' 
    DO I = 1, M; WRITE (*,FMT) A(I,:); ENDDO 
  ENDIF 
END PROGRAM EXAMPLE
