- #1
The_shadow
- 19
- 0
Hi guys having a problem with my code, FORTRAN keeps stating:
lambda(k+1)=(newsum/oldsum)
Error: Incomparable ranks 0 at and 1 in assignment. The code is below:
subroutine powerit(a,b,c,E,n)
implicit none
real, intent(in) :: E
real, intent(inout) :: a(:),b(:),c(:)
!real, intent(out) :: x(:)
real,allocatable :: Phi(:),lambda(:),newsum(:),oldsum(:),d(:),x(:)
real :: phi_0,lambda_0
integer k, I, n
I = 100
phi_0 = 1
lambda_0 = 1
phi(1) = phi_0
lambda(1) = lambda_0
oldsum = phi_0
allocate(lambda(I),phi(I))
Do k = 1, I-1
d(k) = lambda(k)*E*Phi(k)
call tridiag(a,b,c,d,n,x)
Phi(k+1)=x(k)
newsum = sum(Phi)
lambda(k+1) = (newsum/oldsum)
print*, k, lambda(k+1), Phi(k+1)
oldsum = newsum
End do
deallocate(lambda)
end subroutine powerit
end module powermethord
Any ideas? Cheers guys!
lambda(k+1)=(newsum/oldsum)
Error: Incomparable ranks 0 at and 1 in assignment. The code is below:
subroutine powerit(a,b,c,E,n)
implicit none
real, intent(in) :: E
real, intent(inout) :: a(:),b(:),c(:)
!real, intent(out) :: x(:)
real,allocatable :: Phi(:),lambda(:),newsum(:),oldsum(:),d(:),x(:)
real :: phi_0,lambda_0
integer k, I, n
I = 100
phi_0 = 1
lambda_0 = 1
phi(1) = phi_0
lambda(1) = lambda_0
oldsum = phi_0
allocate(lambda(I),phi(I))
Do k = 1, I-1
d(k) = lambda(k)*E*Phi(k)
call tridiag(a,b,c,d,n,x)
Phi(k+1)=x(k)
newsum = sum(Phi)
lambda(k+1) = (newsum/oldsum)
print*, k, lambda(k+1), Phi(k+1)
oldsum = newsum
End do
deallocate(lambda)
end subroutine powerit
end module powermethord
Any ideas? Cheers guys!