Fortran: Execution and Input in one command line

  • Context: Fortran 
  • Thread starter Thread starter Aerandir90
  • Start date Start date
  • Tags Tags
    Fortran Input Line
Click For Summary
SUMMARY

In Fortran, the GETARG intrinsic routine allows users to read command line arguments, including numerical data, directly during execution. For optimal results, the GET_COMMAND_ARGUMENT routine, introduced in the Fortran 2003 standard, is recommended for new code. This method enables users to pass floating point numbers as command line arguments, enhancing the flexibility of input handling in Fortran programs. The discussion emphasizes the transition from older methods to more modern practices in Fortran programming.

PREREQUISITES
  • Familiarity with Fortran programming language
  • Understanding of command line execution
  • Knowledge of Fortran 2003 standards
  • Basic concepts of intrinsic routines in Fortran
NEXT STEPS
  • Research the GET_COMMAND_ARGUMENT routine in Fortran 2003
  • Explore command line argument handling in Fortran
  • Learn about intrinsic routines in Fortran
  • Examine examples of numerical input handling in Fortran programs
USEFUL FOR

New Fortran programmers, software developers working with numerical computations, and anyone interested in enhancing command line input capabilities in Fortran applications.

Aerandir90
Messages
1
Reaction score
0
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!
 
Technology news on Phys.org
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.
 

Similar threads

  • · Replies 25 ·
Replies
25
Views
4K
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 8 ·
Replies
8
Views
4K