I am new in using LAPACK subroutines. I need to use sgeqp3.f and sorgqr.f.
Before putting them in the fluid dynamics code I use, I made a trial, but I wasn't successful. Could you please help me in finding the mistake I am making? I think I didn't defined well some arguments like WORK and JPVT. How should I define them? The program runs with no mistakes but the TAU is never updated.
Down here there is the trial code
Thank you.
Chiara
- Code: Select all
program main
integer m,n,LWORK,INFO
integer,allocatable,dimension (:) :: JPVT
real xb,yb
real, allocatable, dimension (:) :: xbi,ybi,WORK,TAU
real,allocatable,dimension (:,:) :: a
m=8
n=5
xb=2.
yb=2.
allocate(xbi(m))
xbi(1)=1.
xbi(2)=2.
xbi(3)=3.
xbi(4)=1.
xbi(5)=3.
xbi(6)=1.
xbi(7)=2.
xbi(8)=3.
allocate(ybi(m))
ybi(1)=2.
ybi(2)=2.
ybi(3)=2.
ybi(4)=1.
ybi(5)=1.
ybi(6)=0.
ybi(7)=0.
ybi(8)=0.
allocate(a(m,n))
do i=1,m
a(i,1)=xbi(i)-xb
a(i,2)=ybi(i)-yb
a(i,3)=(xbi(i)-xb)*(ybi(i)-yb)
a(i,4)=0.5*(xbi(i)-xb)*(xbi(i)-xb)
a(i,5)=0-5*(ybi(i)-yb)*(ybi(i)-yb)
end do
LWORK=-1
allocate(WORK(1))
allocate(TAU(n))
allocate(JPVT(n))
JPVT=0
TAU=0.
call SGEQP3(m,n,a,m,JPVT,TAU,WORK,LWORK,INFO)
! LWORK=WORK(1)
! deallocate(WORK)
! allocate(WORK(LWORK))
! WORK=0
write(*,*)JPVT(1:n)
call SORGQR(m,n,n,a,m,TAU,WORK,LWORK,INFO)
do i=1,m
write(*,*)a(i,1:n)
end do
write(*,*)'WORK=',WORK(1)
write(*,*)'INFO=',INFO
write(*,*)
do i=1,n
write(*,*)TAU(i)
end do
end program

