subroutine linear_solver(A, b, x, n, info) c------------------------------------------------- c c Driver to solve the linear system: c A * x = b c using the LAPACK routine DGESV c (A being a general matrix) c c UBC, Sep 2 2000 c c------------------------------------------------- implicit none character*13 cdnm parameter ( cdnm = 'linear_solver' ) logical ltrace parameter ( ltrace = .false. ) integer n real*8 A(n,n), AT(n,n) real*8 b(n), x(n) integer nrhs c------------------------------------------------ c Leading order of the vectors. (???) c------------------------------------------------ integer lda, ldb c------------------------------------------------ integer ipiv(n) integer info c------------------------------------------------ integer i, j c================================================ c================================================ if ( ltrace ) then write(0,*) cdnm,': A=',A write(0,*) cdnm,': b=',b write(0,*) cdnm,': n=',n endif if ( n .le. 0 ) then write(0,*) cdnm,': Dimension of the system 0 !!' return endif nrhs = 1 lda = n ldb = n do i =1 , n do j = 1, n AT(j,i) = A(i,j) enddo enddo call dgesv(n, nrhs, AT, lda, ipiv, b, ldb, info) do i = 1 , n x(i) = b(i) enddo if ( ltrace ) then if ( info .eq. 0 ) write(0,*) cdnm,': System solved '// & 'successfully.' write(0,*) cdnm,': x=',x write(0,*) cdnm,': ipiv=',ipiv endif if ( info .lt. 0 ) then write(0,*) '#######################################' write(0,*) cdnm,': Cant solve the linear system !!!' write(0,*) cdnm,': info =',info write(0,*) cdnm,': Check the ',info,'-th argument to DGESV' write(0,*) '#######################################' endif if ( info .gt. 0 ) then write(0,*) '#######################################' write(0,*) cdnm,': Cant solve the linear system !!!' write(0,*) cdnm,': info =',info write(0,*) cdnm,': U(',info,',',info,')=0 !!!' write(0,*) '#######################################' endif return end