How to run command line scripts from within Fortran 90

  • Context: Fortran 
  • Thread starter Thread starter AlphaBetaGamma96
  • Start date Start date
  • Tags Tags
    Fortran Line
Click For Summary

Discussion Overview

The discussion revolves around how to execute command line scripts from within a Fortran 90 program, specifically in the context of automating the plotting of results from a three body problem simulation using gnuplot.

Discussion Character

  • Technical explanation, Homework-related

Main Points Raised

  • One participant seeks a method to automatically run a gnuplot script from within their Fortran 90 program, mentioning the need for a function to call the script.
  • Another participant suggests using the SYSTEM function, which is available in many compilers, to invoke a shell for running the script.
  • A third participant notes that while not part of the Fortran 90 standard, many compilers support a system command for this purpose, providing a link to additional resources.
  • One participant advises including a shebang line at the beginning of the script when running on UNIX systems to specify the shell to be used, illustrating with an example of a bash shebang.

Areas of Agreement / Disagreement

Participants provide various suggestions and resources, but there is no consensus on a single method or function, indicating multiple approaches may exist.

Contextual Notes

There is mention of the SYSTEM function not being part of the Fortran 90 standard, which may limit its applicability depending on the compiler used. Additionally, the effectiveness of the shebang line is context-dependent, relying on the operating system.

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
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · 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 17 ·
Replies
17
Views
5K
  • · Replies 19 ·
Replies
19
Views
7K