program matinv_lu
!http://www.rcs.arch.t.u-tokyo.ac.jp/kusuhara/tips/linux/fortran.html
  implicit none
  integer, parameter :: N = 2, PI = acos(-1.0d0)
  integer :: i, j, ij, ji
  integer, parameter :: ijmax=50, jimax=50
  real(8) :: D(1:N,1:N), workD(1:N,1:N)
  real(8) :: B(1:N,1:N)
  real(8) :: A(1:N,1:N)  
!  real(8) :: E(1:N,1:N)
!  complex(8) :: Ei(1:N)
  real(8) :: U0, Ujh, Uj, Lamda, z, dz, f, p, l, k, M, beta, dl, dlamda, wimax, wimax2, LamdaMax, LMax, zmax, x, xmax
!----------------------------------------------------------------
  integer, parameter :: LDA = N, LDA3 = LDA*4, LWORK_for_eigen = N*4, LDVL=N, LDVR=N
      integer :: LWORK
      real(8) ::Wr(1:LDA), Wi(1:LDA), WORK_for_eigen(1:LWORK_for_eigen)!WORK_for_eigen(1:LDA3), Sigma(1:LDA), Sigma1, Sigma2, psi(1:N)!(1:LDA)!, C(1:LDA,1:N)
      complex(8) :: VL(1:LDVL,1:N), VR(1:LDVR,1:N)!, VR_wimax(1:LDVR,1:N),e!, Wr(1:LDA), Wi(1:LDA)
!----------------------------------------------------------------
  integer              :: IPIV(1:N), INFO
  real(8)              :: LWORK0
  real(8), allocatable :: WORK(:)

  A(1,1)=3.0d0
  A(1,2)=2.0d0
!  A(1,3)=2.0d0
  A(2,1)=-2.0d0
  A(2,2)=3.0d0
!  A(2,3)=-1.0d0
!  A(3,1)=0.0d0
!  A(3,2)=0.0d0
!  A(3,3)=3.0d0

      call DGEEV('N','V', N, A, LDA, Wr, Wi, VL, LDVL, VR, LDVR, WORK_for_eigen, LWORK_for_eigen, INFO)
      write(6,*) info
      write(6,100) Wr, Wi
      write(6,100) real(VR), aimag(VR)

100   format(2(1x,E12.5))
!gfortran eigenvector_lapack_for_check.f90 -llapack -lblas -fbounds-check
end program matinv_lu
