Routine to solve the linear equation system Ax = b author: P J Knight, CCFE, Culham Science Centre a(ndim,ndim) : in/out real array : array A ndim : input integer : dimension of a b(ndim) : in/out real array : RHS vector x(ndim) : output real array : solution for Ax = b This routine solves the linear equation Ax = b. It calls (local copies of) the linpack routines sgefa and sgesl. !
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(inout), | dimension(ndim,ndim) | :: | a | ||
integer, | intent(in) | :: | ndim | |||
real(kind=dp), | intent(inout), | dimension(ndim) | :: | b | ||
real(kind=dp), | intent(inout), | dimension(ndim) | :: | x |
subroutine linesolv(a, ndim, b, x)
!! Routine to solve the linear equation system Ax = b
!! author: P J Knight, CCFE, Culham Science Centre
!! a(ndim,ndim) : in/out real array : array A
!! ndim : input integer : dimension of a
!! b(ndim) : in/out real array : RHS vector
!! x(ndim) : output real array : solution for Ax = b
!! This routine solves the linear equation Ax = b.
!! It calls (local copies of) the linpack routines sgefa and sgesl.
!! !
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
! Arguments
integer, intent(in) :: ndim
real(dp), dimension(ndim,ndim), intent(inout) :: a
real(dp), dimension(ndim), intent(inout) :: b, x
! Local variables
integer :: job, ndim1, info
integer, dimension(ndim) :: ipvt
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
job = 0
ndim1 = ndim
call sgefa(a, ndim, ndim1, ipvt, info)
call sgesl(a, ndim, ndim1, ipvt, b, job)
x(:) = b(:)
end subroutine linesolv