Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran: Execution and Input in one command line

  1. Jul 21, 2011 #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!
     
  2. jcsd
  3. Jul 21, 2011 #2

    Mark44

    Staff: Mentor

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook