Fortran 90: giving the variable's value on the execution of a program

In summary, the conversation discusses the possibility of defining a variable with a given value while executing a Fortran 90 program, using the command line arguments. The person asking the question is new to Fortran and is seeking guidance on how to efficiently search for information on this topic. They are then directed to try searching for "fortran 90 command line arguments" which leads them to helpful references.
  • #1
arhangela
2
0
Hello

I wondered if in Fortran 90 I can define a variable whose value will be given only while executing the program, in the same line as the execution command, for example like this:

./exe 100

I know one can use the "read" command, but that way you only enter the variable's value once the program is executed (in a new line)

I tried to Google it but I'm new to Fortran and I'm not sure to know the right terms to look for it efficiently.

Thanks!
 
Technology news on Phys.org
  • #2
arhangela said:
I tried to Google it but I'm new to Fortran and I'm not sure to know the right terms to look for it efficiently.

Try Googling for

fortran 90 command line arguments

The first page has several references that look promising.
 
  • #3
Thanks jtbell! It works now :)
 

1. What is Fortran 90?

Fortran 90 is a high-level programming language commonly used in scientific and engineering applications. It is an extension of the original Fortran language, with added features for structured programming and modular code development.

2. How do I give a variable's value in Fortran 90?

In Fortran 90, variables can be assigned a value using the assignment operator (=). For example, to assign the value 5 to a variable x, you would write x = 5 in your code. This value can also be given during program execution using input statements.

3. Can I change the value of a variable during program execution in Fortran 90?

Yes, variables can be reassigned new values during program execution in Fortran 90. This allows for dynamic and flexible programming, as the value of a variable can be updated based on other calculations or user input.

4. What happens if I do not give a value to a variable in Fortran 90?

If a value is not explicitly given to a variable in Fortran 90, it will be assigned a default value. The default value depends on the data type of the variable. For example, a default value of zero is assigned to an integer variable, while a default value of an empty string is assigned to a character variable.

5. Is there a limit to the number of variables I can use in a Fortran 90 program?

No, there is no limit to the number of variables you can use in a Fortran 90 program. However, it is important to use meaningful and concise variable names to make your code more readable and manageable.

Similar threads

  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
2
Views
786
  • Programming and Computer Science
Replies
4
Views
498
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
10
Views
1K
  • Programming and Computer Science
Replies
22
Views
868
Back
Top