Page 1 of 1

problem with subroutine dgetrs in lapack-3.0

PostPosted: Wed Nov 07, 2007 7:15 am
by lonix
The test script is below:
Code: Select all
 integer N, NRHS, LDA, LDB, INFO
    parameter(N=4, NRHS=1, LDA=4, LDB=4)
    double precision A(4,4), B(4,1)
    integer IPIV(4)
    A(1,1) = 1.; A(1,2) = 10.; A(1,3)= 1.;  A(1,4) = 1.
    A(2,1) = 2.; A(2,2) = -1.; A(2,3)= 50.; A(2,4) = -11.
    A(3,1) = 4.; A(3,2) = 8.;  A(3,3)= -7.; A(3,4) = -19.
    A(4,1) = 4.; A(4,2) = 8.;  A(4,3)= -7.; A(4,4) = 23
   
    B(1,1) = 13.; B(2,1) = 40.; B(3,1) = -14.; B(4,1) = 28.
    call dgetrs('N', N, NRHS, A, LDA, IPIV, B, LDB, INFO)
    write(*,*)B
    end

and it compiles well with:
f77 test.f -o test -llapack
and it actually generate the execute file "test", but when I execute this file, there is segment fault. I doubt that whether the algorithm in this subroutine has its own flaw. Anyone can explain this kind of phenomenon? Many thanks.

PostPosted: Wed Nov 07, 2007 8:15 am
by sven
IPIV is an input argument to DGETRS and so needs to be defined before the call to DGETRS. I am sure that you realise that DGETRS is normally preceded by a call to DGETRF, which factorizes A and returns the pivot indices in IPIV.

Best wishes,

Sven Hammarling.

PostPosted: Wed Nov 07, 2007 9:47 am
by lonix
I got it, thanks very much.