How Do I Resolve Syntax Errors in My Fortran 90 Tridiagonal System Solver?

  • Context: Fortran 
  • Thread starter Thread starter jonephy
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around resolving syntax errors in a Fortran 90 program designed to solve a tridiagonal system of equations. Participants provide feedback on the code and suggest modifications to address the errors encountered by the original poster.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • The original poster shares their Fortran code and the specific syntax errors they are encountering.
  • One participant suggests modifying the declaration of arrays to use the correct syntax for Fortran 90.
  • The original poster reports that they are still encountering the same errors after attempting the suggested changes.
  • Another participant emphasizes the importance of double-checking the implementation of suggestions and points out issues with the structure of the loops in the code.
  • There are indications of confusion regarding the implementation of changes, as the original poster claims to have followed the advice but still faces issues.

Areas of Agreement / Disagreement

Participants express differing views on the original poster's adherence to the suggested changes, with some believing that the original poster did not implement the advice correctly, while the original poster insists they did. The discussion remains unresolved regarding the specific cause of the errors.

Contextual Notes

There are mentions of missing "end do" statements and issues with loop variables, indicating potential structural problems in the code that have not been fully addressed.

Who May Find This Useful

Individuals learning Fortran 90, particularly those working on numerical methods and programming for solving systems of equations.

jonephy
Messages
6
Reaction score
0
Hi
I have written a program in FOTRAN for solving special system called Tridiagonal system
has 5 equation
I'm in the learning stage of FOTRAN 90
and this my program::
Please help me

program triiagonal
implicit none
real, dimension A(5,5),B(5,5),f(5),X(5)
integer::n,i,j,m,k,l,s1,s2
print*,"input the number of element(n)"
read*,n
do i=1,n
do j=1,n+1
print*,"input the matrix a(i,j)"
read*,A(i,j)
end do
end do
m=n*(n-1)/2
do i=2,n
do k=1,n-1
if(A(i,j)/=0)then
do j=1,n+1
A(i,j)=A(i,j)-f(i,k)*A(j,k)
end do
else
do l=i-1,i-1
do j=1,n+1
b(i,j)=a(i,j)
a(i,j)=a(i+1,j)
a(i+1,j)=b(i,j)
end do
end do
end if
do i=n,1,-1
do j=i+1,n
s2=s2+A(i,j)*(j)
end do
s1=a(i,n+1)
x(i)=(s1-s2)/a(i.i)
end program triiagonal


this my error::
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(3): error FOR3852: syntax error detected between DIMENSION and A
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(10): error FOR3701: symbol A is not a variable
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(18): error FOR3712: symbol A is not an array
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(24): error FOR3712: symbol A is not an array
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(25): error FOR3712: symbol A is not an array
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(29): error FOR3541: duplicated DO index variable - I
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(34): error FOR3251: symbol I is not a derived type detected between % and I
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(36): error FOR3597: missing 3 END DO statements
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(36): error FOR2290: implicit type for X
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(36): error FOR2290: implicit type for F
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(36): error FOR2290: implicit type for B
C:\Documents and Settings\eXtreme\Desktop\New Folder\ffff\fff.f90(36): error FOR2290: implicit type for A

Your help would be appreciated.
Thanks
 
Technology news on Phys.org
Replace this:
Code:
real, dimension A(5,5),B(5,5),f(5),X(5)
with this:
Code:
real, dimension(5,5) :: A,B
real, dimension(5) :: f,X
and try again.
 
ooooooh no ... the same errors !?
 
please repost source, use code tags
 
Code:
program  tridiagonal	
implicit none 
real, dimension  A(5,5),B(5,5),f(5),X(5)
integer::n,i,j,m,k,l,s1,s2
print*,"input the number of element(n)"
read*,n
do i=1,n
 do j=1,n+1
  print*,"input the matrix a(i,j)"
  read*,A(i,j) 
 end do
end do
  m=n*(n-1)/2
do i=2,n
 do k=1,n-1
 if(A(i,j)/=0)then
 do j=1,n+1
 A(i,j)=A(i,j)-f(i,k)*A(j,k)
 end do
 else
do l=i-1,i-1
 do j=1,n+1
 b(i,j)=a(i,j)
 a(i,j)=a(i+1,j)
 a(i+1,j)=b(i,j)
 end do								  
end do
end if 
do i=n,1,-1
do j=i+1,n
  s2=s2+A(i,j)*(j)
 end do
 s1=a(i,n+1)
 x(i)=(s1-s2)/a(i.i)

end program  tridiagonal
my program in attachment ...
 

Attachments

o.k., so, you did not implement what I suggested...no wonder you are getting the same errors!
 
No No ... This my ... i implemented what you suggested :)
But i am getting the same errors ,,,,,,, so i post the program before Modifying >>
^_^
Please help me ,,,
Bye
 
Then what does your code look like now?
 
jonephy:

please try to be more careful and let it be you who does the double checking of things...we are here to guide you, not to do the work for you.

please double check what you are doing and make sure you implemented the changes I suggested earlier.

also, you have a mess with your do-loops and the loop variables...step back and double check all that; there are also a couple of "end do" missing.
 
  • #10
Thanks all
Ok, i will be more careful
and i will trying to fix all problems in my program
>>>>
Good Bye
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K