optimize memory in diagonalizations

This commit is contained in:
Pierre-Francois Loos 2023-03-13 10:14:26 +01:00
parent a1b4abf10a
commit c797967170
1 changed files with 18 additions and 4 deletions

View File

@ -19,8 +19,15 @@ subroutine diagonalize_general_matrix(N,A,WR,VR)
! Memory allocation
lwork = 4*N
allocate(WI(N),VL(N,N),work(lwork))
allocate(work(1),WI(N),VL(N,N))
lwork = -1
call dgeev('V','V',N,A,N,WR,WI,VL,N,VR,N,work,lwork,info)
lwork = int(work(1))
deallocate(work)
allocate(work(lwork))
call dgeev('V','V',N,A,N,WR,WI,VL,N,VR,N,work,lwork,info)
@ -49,8 +56,15 @@ subroutine diagonalize_matrix(N,A,e)
! Memory allocation
allocate(work(3*N))
lwork = size(work)
allocate(work(1))
lwork = -1
call dsyev('V','U',N,A,N,e,work,lwork,info)
lwork = int(work(1))
deallocate(work)
allocate(work(lwork))
call dsyev('V','U',N,A,N,e,work,lwork,info)