What are Implicit Variables in FORTRAN and How Do They Affect Programming?

In summary, the conversation was about a new project given by a professor to calculate the form factor of a cavity for a particle detector. The person was asked to use code from a colleague, written in FORTRAN, but had difficulty deciphering it due to implicit variable declarations. The only information they found was that variables starting with "i" through "n" are integers, but they couldn't find a full list online. They were hoping for guidance on this issue, and the other person explained that untyped variables are implicitly REAL for names starting with "A-H" or "O-Z" and INTEGER for names starting with "I-N", but it can be overridden with the use of the IMPLICIT statement. In the end, the person
  • #1
Poop-Loops
732
1
I got a new project from my professor to calculate the form factor of the cavity for his particle detector thing. He told me to get some code from a colleague, decipher it, and use it for the new cavity.

The code is in FORTRAN. I've had some programming experience, so it's not so bad, but this guy wrote the code for himself, so it's not easy to decipher. The main problem I am having is he is using a lot of implicit variable declarations. The only thing I've been able to find is that if it starts with "i" through "n" it's an integer. But I can't find a list anywhere online.

I was hoping one of you could point me in the right direction.
 
Technology news on Phys.org
  • #2
Untyped variables are implicitly REAL for variables with names starting with characters "A-H" or "O-Z" and INTEGER for variables with names starting with characters "I - N".

This may, of course, be overriden by the use of the IMPLICIT statement.
 
  • #3
That's it? Phew, thought it would be a lot more complicated.

Yeah, I'm getting a lot of "i"this and "i"that without any indication of what is going on. =/

Thanks for your help!
 

1. What are implicit variables in FORTRAN?

Implicit variables in FORTRAN are variables that are defined without explicitly stating their data type. This means that the data type of the variable is assumed based on its first letter. For example, a variable starting with the letter "i" would be assumed to be an integer, while a variable starting with "r" would be assumed to be a real number.

2. How are implicit variables declared in FORTRAN?

In FORTRAN, implicit variables are declared by simply using them in the code. They do not need to be explicitly declared using a data type statement. However, some compilers may require an "implicit none" statement to be included in the code to avoid any potential errors.

3. What are the advantages and disadvantages of using implicit variables in FORTRAN?

The main advantage of using implicit variables in FORTRAN is that it can save time and space in coding, as there is no need to explicitly declare data types. However, it can also lead to errors and confusion if variables are not named carefully, and it may not be compatible with all compilers.

4. Can implicit variables be changed in FORTRAN?

Yes, implicit variables can be changed in FORTRAN by using a "implicit none" statement in the code. This will disable implicit typing and require all variables to be explicitly declared with a data type. Additionally, some compilers may have specific options or flags that allow for implicit typing to be enabled or disabled.

5. Are implicit variables still used in modern versions of FORTRAN?

While implicit variables were commonly used in older versions of FORTRAN, they are not as widely used in modern versions such as FORTRAN 90 and above. These newer versions encourage explicit declaration of variables and have stricter rules for implicit typing. However, some legacy code may still use implicit variables.

Similar threads

  • Programming and Computer Science
Replies
4
Views
613
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
16
Views
3K
  • Programming and Computer Science
Replies
13
Views
1K
  • Programming and Computer Science
Replies
9
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
2
Replies
59
Views
9K
Back
Top