Fortran How to run command line scripts from within Fortran 90

  • Thread starter Thread starter AlphaBetaGamma96
  • Start date Start date
  • Tags Tags
    Fortran Line
Click For Summary
A user is developing a program to solve the three-body problem and seeks to automate plotting results in gnuplot directly from the Fortran 90 program. They have created a script but need guidance on how to execute it automatically within the program. A suggested solution involves using the system command, which, while not part of the Fortran 90 standard, is available in many compilers. This command allows the program to invoke a shell to run the script. Additionally, it is important to include a shebang line at the top of the script to specify the desired shell for execution, ensuring proper functionality on UNIX systems.
AlphaBetaGamma96
Messages
3
Reaction score
0
Hey!

I'm currently making a program which is a three body problem. I managed to get working results which I can plot to gnuplot. The question is, how can I write this within the program itself, so it can automatically plot the information to gnuplot if the user wants it to? (I'm being lazy :P)

I know I have to create a script, which I have done, but I don't know the function in Fortran 90 which will allow me to call it and then run it automatically. I believe there is a function along the lines of get_command_argument (I tried this but it isn't a function) or something similar to that.

Thank you for the help!
AlphaBetaGamma96
 
Technology news on Phys.org
When you do this on UNIX be sure to include a shebang as the very first line first column of your script. This makes the script run with /bin/whatevershell rather than /bin/sh. Which is the default whenever no shell is specified. Example:
Code:
#!/bin/bash

runs the bash shell to execute the script
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
11K
  • · Replies 6 ·
Replies
6
Views
16K
  • · Replies 2 ·
Replies
2
Views
8K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 19 ·
Replies
19
Views
6K
  • · Replies 17 ·
Replies
17
Views
4K