Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29249 Discussions

How to read an equation from a source file????

nkcfjg
Beginner
576 Views
I would like to read an equation of the type : (15**2-D**2)**0.5 with the variable D, with the command READ(7,*)C and it gives me an error message.Do i have to state thatD is a variable???how???Any ideas?It is kind of urgent , because i have to deliver my homework at school...
0 Kudos
2 Replies
Steven_L_Intel1
Employee
576 Views
Just discovered this accidentally posted to the archive board (which was supposed to be read-only, but wasn't.) Adding this reply so that people see it.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
576 Views

Homework, um? If it's a programming homework, this is definitely not a job for a newbie. The problem is that you any formula you want tocalculate must be seen by compiler at compile-time. If you want to enter a formula in run-time, you must parse it yourself, i.e. read the formula as a character string, analyse the string (whether any substring is a variable, operator (+,-,*,bracket) or number), break it into elementary operations and calculate each intermediate result yourself.

You can find the program which does exactly that here:

http://smidgley.customer.netspace.net.au/fortran/

but I somehow doubt that this was really your assignment :smileywink:.

Jugoslav

0 Kudos
Reply