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.
 

FAQ: Fortran 90 - gfortran error - help

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.

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.

Can I still use Fortran 77 with gfortran?

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

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.

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

Replies
5
Views
1K
Replies
3
Views
1K
Replies
25
Views
2K
Replies
4
Views
2K
Replies
2
Views
2K
Replies
17
Views
5K
Replies
4
Views
2K
Replies
12
Views
1K
Replies
8
Views
1K
Back
Top