Fortran 90 - gfortran error - help

In summary, the conversation is about a fortran 90 program that uses the trapezium method to find the definite integral of a function. The program is producing an error, which is caused by a mistake in the code where the parentheses were missing. The user has asked for help and has since corrected the mistake.
  • #1
Bussell93
9
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
  • #2
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.)
 
  • #3
this made me feel very stupid! sometimes the answer is right in front of your face. Thanks a lot! Will do for next time.
 

1. What does the error "gfortran: error: Fortran 90 is required for this feature" mean?

This error means that the code is using a feature that is only supported in Fortran 90 or above, and the compiler being used (gfortran) does not support older versions of Fortran.

2. How can I fix the gfortran error in Fortran 90?

To fix this error, you will need to update your code to use Fortran 90 syntax and features, or use a different compiler that supports older versions of Fortran.

3. Can I still use Fortran 77 with gfortran?

No, gfortran does not support Fortran 77. It only supports Fortran 90 and newer versions.

4. What are the main differences between Fortran 77 and Fortran 90?

Fortran 90 introduced many new features and improvements such as free-form source code, dynamic memory allocation, and modules. It also has improved support for structured programming and array operations.

5. Is it worth upgrading to Fortran 90 from Fortran 77?

It depends on your specific needs and the complexity of your code. If your code requires the new features and improvements in Fortran 90, then it would be worth upgrading. However, if your code is simple and works well in Fortran 77, there may not be a need to upgrade.

Similar threads

  • Programming and Computer Science
Replies
4
Views
619
  • Programming and Computer Science
Replies
15
Views
210
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
12
Views
964
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
Back
Top