FORTRAN 95: New to fortran, want to learn how to input a function

In summary, the speaker is asking for help with writing a program in FORTRAN that involves parsing arithmetic expressions. They are seeking advice on the best approach and resources for completing this task.
  • #1
FuriousJ
5
0
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.
 
Technology news on Phys.org
  • #2
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.
 
Last edited:

1. What is FORTRAN 95?

FORTRAN 95 is a high-level programming language primarily used for scientific and engineering applications. It was first developed in the 1950s and has since gone through several updates, with FORTRAN 95 being the most recent version.

2. How do I input a function in FORTRAN 95?

To input a function in FORTRAN 95, you will need to use the FUNCTION statement, which is followed by the function name, arguments, and the function body. The function body should contain the mathematical operations to be performed and the final result should be returned using the RETURN statement.

3. Can I use variables in my function in FORTRAN 95?

Yes, you can use variables in your function in FORTRAN 95. You can declare variables using the REAL or INTEGER statements and then use them in your function body to perform calculations.

4. How do I compile and run my FORTRAN 95 program?

To compile and run your FORTRAN 95 program, you will need a compiler, which is a software that translates your code into machine-readable instructions. Popular compilers for FORTRAN 95 include GNU Fortran and Intel Fortran. Once you have a compiler installed, you can use it to compile your code and then run the executable file that is generated.

5. Are there any resources available for learning FORTRAN 95?

Yes, there are plenty of resources available for learning FORTRAN 95. You can find online tutorials, books, and even video courses that can help you get started with the language. It is also helpful to join online communities or forums where you can ask questions and get support from experienced FORTRAN programmers.

Similar threads

  • Programming and Computer Science
Replies
3
Views
4K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
13
Views
7K
  • Programming and Computer Science
Replies
5
Views
9K
  • Programming and Computer Science
Replies
2
Views
4K
  • Programming and Computer Science
Replies
2
Views
8K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
3
Views
10K
  • Programming and Computer Science
Replies
4
Views
4K
Back
Top