Problem with fortran code :( - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Problem with fortran code :(

Hi guys I've been stuck on this for the best part of a day now. I'm new to programming (3 days so far) and just can' seem to get this to work!!! My code is below:

Module powermethord
use tri
implicit none

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 :: x(:),d(:)
real :: phi_0,lambda_0, lambda, newsum, oldsum, phi
integer :: k, I, j
integer, intent(in) :: n

j = 10
lambda_0 = 1
phi_0 = 1
phi = phi_0
lambda = lambda_0
oldsum = phi_0
Do k = 1, j-1
print*, d
call tridiag(a,b,c,d,n,x)
d(k) = lambda*(E*x(i))
newsum = sum(x)
lambda = (newsum/oldsum)
print*, k, lambda, x(i)
oldsum = newsum
End do
end subroutine powerit
end module powermethord

the sub routine tridiag is given by:

Module tri
implicit none

subroutine tridiag(a,b,c,d,n,x)
implicit none

integer, intent(in) :: n
real, intent(in) :: a(:),b(:),c(:),d(:)
real, intent(out) :: x(:)
real :: bp(n),dp(n)
real :: dx
integer j,l

bp(1) = b(1)
dp(1) = d(1)
firstpass: do j = 2,n
dx = a(j)/bp(j-1)
bp(j) = b(j) - dx*c(j-1)
dp(j) = d(j) - dx*dp(j-1)
end do firstpass
x(n) = dp(n)/bp(n)
backsub:do j = l-1, 1, -1
x(j) = (dp(j) - c(j)*x(j+1))/bp(j)
print*, j,x(j)
end do backsub
!print*, i,x(i)
end subroutine tridiag
end module tri

any ideas what's going wrong?! Thanks guys!!!
Sign In or Register to comment.