Fortran Fortran: Execution and Input in one command line

AI Thread Summary
To read numerical data directly from the command line in Fortran, the GETARG intrinsic routine can be utilized. This allows users to pass arguments to a program when executing it, similar to how input files are handled. For more modern applications, the GET_COMMAND_ARGUMENT routine, introduced in the Fortran 2003 standard, is recommended for better compatibility and functionality. This approach enables users to input floating point numbers directly in the command line, facilitating easier data handling for simple programs that perform calculations, such as multiplying two numbers.
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
25
Views
3K
Replies
4
Views
2K
Replies
1
Views
2K
Replies
5
Views
5K
Replies
2
Views
1K
Replies
8
Views
4K
Replies
10
Views
2K
Back
Top