4

I am currently doing a Fortran77 assignment, so please don't tell me the exact coding, but please give me a hint of what I want to do:

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

./program.exe parameter
1
  • Please don't use the tag homework it is obsolete. Commented Feb 1, 2013 at 17:57

2 Answers 2

6

In standard Fortran77 you can't. End of story. Accessing command line arguments with fortran programs wasn't standardized until Fortran 2003.

If you're using the GNU fortran compiler, you can use the iargc() and getarg(i, arg) functions, which return the number of arguments and the value of a specific argument, resepectively.

Sign up to request clarification or add additional context in comments.

Comments

6

It is possible to access command line arguments in FORTRAN77.

Given below is the code fragment I use :

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

Just do ./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 will convert ARGV into a floating-point integer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.