Skip to main content

2.2) More on Declarations


If you don’t declare what variables types you are using then Fortran will decide for you. It is all based on the first letter of the variable name. If you have a variable, say temp, then it starts with the letter t and so Fortran would assume it is a real number. If you don’t declare, then variables beginning with letters a to h or o to z will be assumed to be real and variables starting with letters i to n will be assumed to be integers.
If we don’t want this to be used then we need to declare the variable types. You can make the variables real in the ex2.f95 code by adding lines real :: tc and real :: tf. Please see the video clip that updates the program in this way.


Using variable declarations in programs.