Solving Error "REAL Expression in DO Loop"

Click For Summary
SUMMARY

The discussion centers on resolving the "REAL expression in DO loop" error encountered while using the g95 Fortran 95 compiler. The error indicates that the compiler requires the use of the -freal-loops flag to enable floating-point variables in DO loops. This adjustment allows the use of REAL types as loop parameters, which is not permitted by default in Fortran 95. Implementing this flag during compilation effectively resolves the issue.

PREREQUISITES
  • Understanding of Fortran 95 programming language
  • Familiarity with g95 compiler usage
  • Knowledge of DO loop structures in Fortran
  • Basic command line operations for compiling code
NEXT STEPS
  • Research the g95 compiler documentation for additional flags and options
  • Learn about floating-point arithmetic in Fortran 95
  • Explore best practices for using DO loops with different data types
  • Investigate other Fortran compilers and their handling of REAL expressions in loops
USEFUL FOR

This discussion is beneficial for Fortran developers, particularly those using the g95 compiler, and anyone troubleshooting floating-point issues in loop constructs.

jcang
Messages
2
Reaction score
0
freal Loops?

Hi everybody..

I have a question.
Recently, I'm using g95 to run my Fortran 95 program.
But it occur an error, which is:

REAL expression in DO loop at <1> - to enable REAL loop parameters use -freal-loops

What is freal loop exactly?
and How to solve this problem?

Any help is appreciated.
Thanks.
 
Technology news on Phys.org


Do loops normally use integers. To allow "reals" (floating point) to be used in loops, you need to add a command line parameter when invoking the compiler.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 66 ·
3
Replies
66
Views
6K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K