Fortran77 parameter during program execution

I am currently doing Fortran77 assignment, so please don't tell me the exact encoding, but please let me know what I want to do:

Using UNIX terminal, I would like to get the passed parameter by doing

./program.exe parameter

      

+3


source to share


2 answers


In standard Fortran77, you can't. End of the story. Access to command line arguments with fortran programs was not standardized until Fortran 2003.



If you are using the GNU fortran compiler, you can reuse iargc()

and getarg(i, arg)

, which return the number of arguments and the value of a specific argument.

+3


source


In FORTRAN77, you can access command line arguments.

Below is the piece of code that I am using:

  CHARACTER ARGV*10
  N=IARGC()
  CALL GETARG(1,ARGV)

      

Just do it. /a.out 1 2 3



ARGV will store the value of the first argument, i.e. 1

To convert this argument to float use

  READ (ARGV,*) RARG

      

RARG converts ARGV to floating point integer.

+2


source







All Articles