1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-12-23 04:43:38 +01:00
qp_plugins_scemama/fnmf/non_hermit.irp.f

75 lines
1.9 KiB
FortranFixed
Raw Normal View History

2022-03-11 15:49:43 +01:00
subroutine lapack_g_non_sym_real(n, H, LDH, S, LDS, beta, &
n_real, vl, LDVL, vr, LDVR)
implicit none
integer, intent(in) :: n, LDH, LDS, LDVL, LDVR
double precision, intent(in) :: H(LDH,n), S(LDS,n)
double precision, intent(out) :: VL(LDVL,n), VR(LDVR,n), beta(n)
integer, intent(out) :: n_real
integer :: lwork, info, i,j
2022-12-07 10:18:33 +01:00
double precision, allocatable :: work(:), Htmp(:,:), Stmp(:,:)
2022-03-11 15:49:43 +01:00
double precision, allocatable :: alphar(:), alphai(:), vltmp(:,:), vrtmp(:,:)
2022-12-07 10:18:33 +01:00
integer, allocatable :: iorder(:), list_good(:)
2022-03-11 15:49:43 +01:00
lwork = -1
2022-12-07 10:18:33 +01:00
allocate(work(1), alphar(n), alphai(n), vltmp(n,n), vrtmp(n,n), &
Htmp(n,n), Stmp(n,n), list_good(n))
2022-03-11 15:49:43 +01:00
2022-12-07 10:18:33 +01:00
Htmp(1:n,1:n) = H(1:n,1:n)
Stmp(1:n,1:n) = S(1:n,1:n)
call dggev('V', 'V', n, Htmp, size(Htmp,1), Stmp, size(Stmp,1), alphar, alphai, beta, &
2022-03-11 15:49:43 +01:00
vltmp, size(vltmp,1), vrtmp, size(vrtmp,1), work, lwork, info)
lwork = int(work(1))
deallocate(work)
allocate(work(lwork))
2022-12-07 10:18:33 +01:00
call dggev('V', 'V', n, Htmp, size(Htmp,1), Stmp, size(Stmp,1), alphar, alphai, beta, &
2022-03-11 15:49:43 +01:00
vltmp, size(vltmp,1), vrtmp, size(vrtmp,1), work, lwork, info)
deallocate(work)
if (info /= 0) then
stop 'DGGEV Diagonalization failed'
endif
allocate(iorder(n))
n_real = 0
do i=1,n
if (dabs(alphai(i)) < 1.d-10) then
n_real += 1
2022-12-07 10:18:33 +01:00
list_good(n_real) = i
else
2022-03-11 15:49:43 +01:00
alphar(i) = dble(huge(1.0))
endif
enddo
2022-12-07 10:18:33 +01:00
do i=1,n
if (dabs(beta(i)/(alphar(i)+1.d-12)) < 1.d-10) then
beta(i) = 0.d0
else
beta(i) = alphar(i)/beta(i)
endif
enddo
do i=1,n_real
iorder(i) = i
do j=1,n
vrtmp(j,i) = vrtmp(j,list_good(i))
vltmp(j,i) = vltmp(j,list_good(i))
end do
end do
call dsort(beta, iorder, n_real)
2022-03-11 15:49:43 +01:00
do i=1,n_real
do j=1,n
vr(j,i) = vrtmp(j,iorder(i))
vl(j,i) = vltmp(j,iorder(i))
end do
end do
2022-12-07 10:18:33 +01:00
deallocate(vrtmp, vltmp, iorder, Htmp, Stmp)
2022-03-11 15:49:43 +01:00
end