!Performs the check A*z =lambda*z
subroutine Gen_Eigen_Files(fname, n, lambda, vec, kod_eigen)
!use work
use dflib


real(8) lambda(n), vec(n,n)

real(8) ay, ly, dif_y, dif_r, dif_max

integer width

CHARACTER(3)   drive
CHARACTER(256) dir
CHARACTER(100) name
CHARACTER(4)   ext

character($maxpath) fname, val_file, vec_file



! File Names:
call splitpathqq(fname, drive, dir, name, ext)

select case(kod_eigen)
case(1)
val_file =trim(name)//'-OMEGA.dat'

case(2)
val_file =trim(name)//'-FRECV.dat'

case default
val_file =trim(name)//'-VAL.dat'

end select

vec_file =trim(name)//'-VEC.dat'

open(3, file =VAL_file, status ='unknown', form ='formatted')
open(4, file =VEC_file, status ='unknown', form ='formatted')

select case(kod_eigen)
case(1)
write(3,'(a)') ' PULSATII'

case(2)
write(3,'(a)') ' FRECVENTE'

case default

write(3,'(a)') ' VALORI PROPRII'
end select

write(4,'(a,\)') ' VECTORI PROPRII'


IVP_GEN: &
DO IVP =1,n
iwi =width(ivp)

write(3, '(1x, I<iwi>, 1pg24.16)') ivp, lambda(ivp)


! Vectors:
write(4, '(/, I8)') ivp

do l =1,n
write(4, '(g24.16)') VEC(l, ivp)
enddo

ENDDO IVP_GEN

end subroutine Gen_Eigen_Files
