Physics Forums

Physics Forums (http://www.physicsforums.com/index.php)
-   Programming & Computer Science (http://www.physicsforums.com/forumdisplay.php?f=165)
-   -   FORTRAN 95: New to fortran, want to learn how to input a function (http://www.physicsforums.com/showthread.php?t=566760)

FuriousJ Jan11-12 01:55 PM

FORTRAN 95: New to fortran, want to learn how to input a function
 
Hey guys, this is my first post here.

So I'm learning FORTRAN, and I'm writing a trapezoidal integration program as a learning exercise. What I want to do is in addition to asking the user to input the range and precision of the calculations they'd like, I'd also like to be able to enter in the function itself.

From what I can gather this is a fairly non-trivial process and I could use some help.

Even just a general mode of attack that can set me on the right path would be helpful.

Thanks in advance.

jtbell Jan11-12 02:33 PM

Re: FORTRAN 95: New to fortran, want to learn how to input a function
 
You need to write some code for parsing arithmetic expressions, or find some code that someone else has written. Try Googling for something like

parsing arithmetic expressions fortran
arithmetic parser fortran

etc.

With an interpreted language like Perl, it's often possible to read an arithmetic expression as a string and simply evaluate it. With compiled languages like Fortran, you generally can't do this.


All times are GMT -5. The time now is 11:36 PM.

Powered by vBulletin Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2014 Physics Forums