I want to run m*n matrix to do QR decomposition in fortran
PROGRAM SUBDEM
INTEGER key, n, m, loopA
REAL resq
REAL A(3,2)
REAL B(3)
REAL X(2)
key = 0
n = 2
m = 3
resq = 0
CALL QR(m, n, A, B, X, resq)
END
The QR routine is:
subroutine QR(m, n, a, b, x, resq)
implicit double precision (a-h, o-z)
dimension a(m,n),b(m),x(n)
double precision sum, dot
resq=-2.0
if (m .lt. n) then
return
endif
resq=-1.0
! Loop ending on 1800 rotates a into upper triangular form.
do 1800 j=1, n
! Find constants for rotation and diagonal entry.
sq=0.0
do 1100 i=j, m
sq=a(i,j)**2 + sq
1100 continue
if (sq .eq. 0.0) then
return
endif
qv1=-sign(sqrt(sq), a(j,j))
u1=a(j,j) - qv1
a(j,j)=qv1
j1=j + 1
! Rotate remaining columns of sub-matrix.
do 1400 jj=j1, n
dot=u1*a(j,jj)
do 1200 i=j1, m
dot=a(i,jj)*a(i,j) + dot
1200 continue
const=dot/abs(qv1*u1)
do 1300 i=j1, m
a(i,jj)=a(i,jj) - const*a(i,j)
1300 continue
a(j,jj)=a(j,jj) - const*u1
1400 continue
! Rotate b vector.
dot=u1*b(j)
do 1600 i=j1, m
dot=b(i)*a(i,j) + dot
1600 continue
const=dot/abs(qv1*u1)
b(j)=b(j) - const*u1
do 1700 i=j1, m
b(i)=b(i) - const*a(i,j)
1700 continue
1800 continue
! Solve triangular system by back-substitution.
do 2200 ii=1, n
i=n-ii+1
sum=b(i)
do 2100 j=i+1, n
sum=sum - a(i,j)*x(j)
2100 continue
if (a(i,i).eq. 0.0) then
return
endif
x(i)=sum/a(i,i)
2200 continue
! Find residual in overdetermined case.
resq=0.0
do 2300 i=n+1, m
resq=b(i)**2 + resq
2300 continue
return
end subroutine
However I am getting:
Error 1 error #6633: The type of the actual argument differs from the
type of the dummy argument. [A] Error 2 error #6633: The type of
the actual argument differs from the type of the dummy argument.
[B] Error 3 error #6633: The type of the actual argument differs
from the type of the dummy argument. [X] Error 4 error #6633: The
type of the actual argument differs from the type of the dummy
argument. [RESQ]
What Am I doing wrong?