How to Read in Execution Flags in Fortran

  • Context: Fortran 
  • Thread starter Thread starter MRLX69
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary

Discussion Overview

The discussion centers on the ability of Fortran programs to read execution flags or command-line arguments directly during execution, similar to how it is done in Java. Participants explore the feasibility and methods for implementing this functionality in Fortran.

Discussion Character

  • Technical explanation, Conceptual clarification, Debate/contested

Main Points Raised

  • One participant, Mike, inquires about the possibility of passing command-line arguments to a Fortran program, expressing a desire to avoid interactive prompts for input.
  • Another participant suggests that Fortran can handle command-line arguments using the `getarg` function, referencing a man page for further information.
  • A later reply acknowledges the suggestion and expresses gratitude for the information provided.
  • Another participant highlights the versatility of Fortran by listing various applications and systems that have been developed using the language, implying that Fortran can accomplish complex tasks.

Areas of Agreement / Disagreement

Participants generally agree that it is possible to pass command-line arguments in Fortran, but the discussion does not resolve the specifics of implementation or the extent of its capabilities.

Contextual Notes

The discussion does not delve into the details of how `getarg` works or any limitations that may exist in its usage within Fortran programs.

Who May Find This Useful

Readers interested in programming in Fortran, particularly those looking to enhance user input methods in their applications, may find this discussion relevant.

MRLX69
Messages
4
Reaction score
0
Hi All,



Just like to know if it's possible for a Fortran program to read in data on execution.

For example, in JAVA, say if I've written a program for matrix factorization, I can type in the command line:
"java mfact q" for QR factorization or "java mfact c" for Cholesky decomposition, where mfact is my compiled JAVA program.

When I run my Fortran program in command line-interface, the best I can do is run the program, then have the program to ask me for a flag, like:

Code:
  PRINT *, 'Please input the type of factorization you require:'
  READ *, factype

So I'd have to run the program, then it asks me what I want to do. But I'd like to supply the argument as I'm executing the program. Is this possible in Fortran?


Thanks

Mike
 
Technology news on Phys.org
It's very easy to pass command-line arguments in C or C++. I believe you can do something similar with getarg. Here's a link to a man page: http://www.oc.nps.edu/~bird/web101/fortran/getarg.html
 
Last edited by a moderator:
Mark44 said:
It's very easy to pass command-line arguments in C or C++. I believe you can do something similar with getarg. Here's a link to a man page: http://www.oc.nps.edu/~bird/web101/fortran/getarg.html

Ah, thanks!

This is what I needed.
 
Last edited by a moderator:
You can do (just about) anything in Fortran that you need to do. Fortran was used to:

1. Write an operating system (Prime mini's had an OS written mainly in Fortran)
2. Write a 80386 DOS extender (DBOS)
3. Write a Fortran compiler
4. Write a LISP compiler (really)
5. Write a terminal emulator
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
8K