Fortran 90 - gfortran error - help

Click For Summary
SUMMARY

The forum discussion centers on a Fortran 90 compilation error encountered while implementing the trapezium method for numerical integration using gfortran. The specific error message indicates an "Unclassifiable statement" due to incorrect syntax in the assignment of the variable ITRAP. The correct syntax requires the use of the multiplication operator (*) between terms, specifically changing the line to ITRAP = (z/2)*((G(a) + G(b)) + z*area). This highlights the importance of proper syntax in Fortran programming.

PREREQUISITES
  • Understanding of Fortran 90 programming syntax
  • Familiarity with numerical integration methods, specifically the trapezium rule
  • Experience with gfortran compiler and its error messages
  • Knowledge of variable declaration and arithmetic operations in Fortran
NEXT STEPS
  • Review Fortran 90 syntax rules and common pitfalls
  • Explore numerical integration techniques beyond the trapezium rule
  • Learn how to effectively debug Fortran code using gfortran
  • Investigate best practices for writing clean and maintainable Fortran code
USEFUL FOR

This discussion is beneficial for Fortran developers, students learning numerical methods, and anyone seeking to troubleshoot compilation errors in Fortran 90 programs.

Bussell93
Messages
9
Reaction score
0
Hi, I have written a fortran 90 program that finds the definite integral of a function using the trapezium method.

Everything is fine, other than when I compile my program it produces the following error:

assignment_2_final.f90:127.2:

ITRAP = (z/2)((G(a) + G(b)) + z*area)
1
Error: Unclassifiable statement at (1)

My code looks like this...

PROGRAM assignment_2
IMPLICIT NONE

REAL(kind = 8) :: x, h, Error_F, Error_C, Error_D2, a, b, z, area, ITRAP
INTEGER :: i, N

area = 0.0

...

z = b - a

DO i=1,N-1
area = area + G(a+i*z)
END DO

ITRAP = (z/2)((G(a) + G(b)) + z*area)

WRITE(6,*)
WRITE(6,*)'The definite integral of g(x) using'
WRITE(6,*)'the trapezium rule = ',ITRAP
WRITE(6,*)

The user is asked to enter values for a, b and N.

I have changed the code and still cannot come up with the solution to my error, any help would be greatly appreciated :smile:
 
Technology news on Phys.org
Bussell93 said:
ITRAP = (z/2)((G(a) + G(b)) + z*area)

That should be
Code:
ITRAP = (z/2)*((G(a) + G(b)) + z*area)

(Please use
Code:
 tags when posting code.)
 
this made me feel very stupid! sometimes the answer is right in front of your face. Thanks a lot! Will do for next time.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K