How to Read in Execution Flags in Fortran

  • Fortran
  • Thread starter MRLX69
  • Start date
  • Tags
    Fortran
In summary, the conversation is about the possibility of passing command-line arguments in Fortran, similar to how it is done in C or C++. One person mentions using "getarg" and provides a link to a man page for reference. Another person notes the versatility of Fortran in terms of its capabilities, such as writing an operating system and compilers for various languages.
  • #1
MRLX69
4
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
  • #2
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:
  • #3
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:
  • #4
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
 

1. What is the purpose of execution flags in Fortran?

Execution flags in Fortran are used to control the execution of a program. They allow the programmer to specify certain conditions or options that will affect how the program runs.

2. How do I read in execution flags in Fortran?

To read in execution flags in Fortran, you will need to use the COMMAND_ARGUMENT_COUNT and GET_COMMAND_ARGUMENT functions. These functions allow you to retrieve the command line arguments passed to the program and store them in variables for later use.

3. Can I use multiple execution flags in Fortran?

Yes, you can use multiple execution flags in Fortran. You can pass multiple arguments through the command line and use conditional statements in your program to determine which flags were passed and how to handle them.

4. What are some common execution flags used in Fortran?

Some common execution flags used in Fortran include -o to specify the output file name, -i to specify an input file, -r to specify a restart file, and -n to specify the number of iterations or steps to run.

5. Is there a specific order in which execution flags should be passed to a Fortran program?

No, there is no specific order in which execution flags should be passed to a Fortran program. However, it is important to follow any specific guidelines or requirements set by the program or compiler you are using. It is also important to ensure that the correct number of arguments are passed and that they are correctly assigned to the corresponding variables in your program.

Similar threads

  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
4K
  • Programming and Computer Science
Replies
6
Views
978
Back
Top