Fortran: Execution and Input in one command line

  • Fortran
  • Thread starter Aerandir90
  • Start date
  • #1
Hello all,

I wanted to know if there was a way to read in numerical data on the same command line on which you execute a file.

I know you can do that for i/o files like:
test.exe < file1.in > file2.out

But I wanted to know if there's some similar notation that can be used for floating point numbers.

Supposing I have this simple program that reads in 2 numbers and outputs their product.
I want to be able to do something similar to the above example in the command line:

test.exe < 3.2 87.3

Hope what I'm asking is clear enough..
I'm very new to Fortran so I'm not too sure about stuff like this
Thanks!
 

Answers and Replies

  • #2
33,936
5,584
You can do this using the GETARG intrinsic routine. Here's a link to a page that describes how to use this function - http://gcc.gnu.org/onlinedocs/gfortran/GETARG.html.

The page above also recommends that new code be written using the newer GET_COMMAND_ARGUMENT routine that is defined by the Fortran 2003 standard.
 

Related Threads on Fortran: Execution and Input in one command line

Replies
6
Views
14K
Replies
3
Views
2K
Replies
3
Views
1K
  • Last Post
Replies
4
Views
4K
  • Last Post
Replies
7
Views
5K
Replies
5
Views
1K
  • Last Post
Replies
1
Views
3K
Top