I in programing in FOTRAN 90

  • Thread starter jonephy
  • Start date
In summary, the program solves a triiagonal system with five equations. The author is in the early stages of learning FOTRAN, and has written a program to do so. However, he is having errors with it. For example, he is not correctly solving the equation A(i,j) = A(i,j-f(i,k)*A(j,k)), where f is the function. He is also having problems with loops and variables.
  • #1
jonephy
6
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
  • #2
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.
 
  • #3
ooooooh no ... the same errors !?
 
  • #4
please repost source, use code tags
 
  • #5
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

  • fff.zip
    425 bytes · Views: 284
  • #6
o.k., so, you did not implement what I suggested...no wonder you are getting the same errors!
 
  • #7
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
 
  • #9
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
 

1. What is FORTRAN 90?

FORTRAN 90 is a high-level programming language used for scientific and engineering applications. It is an updated version of the original FORTRAN language, with improved features such as dynamic memory allocation, modules, and free-form source code formatting.

2. How is FORTRAN 90 different from other programming languages?

FORTRAN 90 is specifically designed for scientific and engineering applications, making it easier to write and run complex mathematical calculations. It also has built-in functions for handling arrays and matrices, which are commonly used in scientific computing.

3. What are the advantages of using FORTRAN 90?

FORTRAN 90 is highly efficient and optimized for numerical calculations. It also has a large library of standard mathematical and scientific functions, making it easier to perform complex calculations. Additionally, it has a simple syntax and is easy to learn.

4. How do I write a program in FORTRAN 90?

To write a program in FORTRAN 90, you will need a text editor and a compiler. First, you will write your program using the FORTRAN 90 syntax and save it with a .f90 extension. Then, you will use a compiler to convert your code into a machine-readable format. Once compiled, you can run your program and see the results.

5. Can FORTRAN 90 be used for modern programming?

Yes, FORTRAN 90 is still widely used in scientific and engineering fields for its efficient and reliable performance. It has also been updated over the years with new features, making it suitable for modern programming. However, it may not be the best choice for developing software outside of the scientific and engineering realm.

Similar threads

  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
4
Views
602
  • Programming and Computer Science
Replies
5
Views
811
  • Programming and Computer Science
Replies
6
Views
8K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
2
Views
982
  • Programming and Computer Science
Replies
1
Views
939
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
25
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
Back
Top