KronLinInv  0.3
Kronecker-product-based linear inversion

◆ symsolvels()

subroutine, private ompi_kronlininv::symsolvels ( real(dp), dimension(:,:), intent(in)  A,
real(dp), dimension(:,:), intent(in)  B,
real(dp), dimension(:,:), intent(out)  sol 
)
private

Solves a linear system AX = B for symmetric A, real numbers

Parameters
[in]Acoefficients matrix (linear operator)
[in]Bmatrix
[out]solsolution to the linear system (matrix)
Date
5/8/2016 - Initial Version

Definition at line 1245 of file ompi_kronlininv.f08.

1245  real(dp),intent(in) :: a(:,:),b(:,:)
1246  real(dp),intent(out) :: sol(:,:)
1247  integer,parameter :: wmax=3000 ! max size allowed for work
1248  integer,allocatable :: ipiv(:)
1249  integer :: n,nrhs,lda,ldb,lwork
1250  character :: uplo
1251  real(dp),allocatable :: work(:),a2(:,:)
1252  integer :: info
1253  ! External procedures defined in LAPACK
1254  external dsysv
1255  uplo = 'L'
1256  n = size(a,1)
1257  nrhs = size(b,2)
1258  allocate(a2(n,n))
1259  a2 = a
1260  lda = size(a,1)
1261  allocate(ipiv(n))
1262  ldb = size(b,1)
1263  ! copy B to sol to avoid it to be overwritten
1264  sol = b
1265  ! apparently work must be allocated for the query to dsysv to work...
1266  allocate(work(1))
1267  lwork = -1
1268  call dsysv(uplo,n,nrhs,a2,lda,ipiv,sol,ldb,work,lwork,info)
1269  lwork = min(wmax,int(work(1)))
1270  !! now lwork is assigned, so actually calculate eigvec/val
1271  deallocate(work)
1272  allocate(work(lwork))
1273  call dsysv(uplo,n,nrhs,a2,lda,ipiv,sol,ldb,work,lwork,info)
1274  if (info/=0) then
1275  write(*,*) "linear system solver failed...'"
1276  print*,'info: ',info
1277  stop
1278  end if
Here is the caller graph for this function: