Fortran Programming Course - Variables

Опубликовано: 17 Июнь 2026
на канале: Desmus
63
3

In this video we are going to see what are the variables, its basic types and some floating-point precision adjustments.

What is a Variable?
A variable is a representation for a place in memory that has a specific type of data. It is just a name that represents a data type that is stored in the computer’s main memory (RAM).

Data Types
In Fortran there are 5 basic types:
integer
real
complex
character
logical

The difference between data types is the kind of data that can be stored inside the variable and the size of bytes taken in memory.

Explicit Typing vs. Implicit Typing
Explicit typing means that the type of a variable must be specified, while implicit typing means that the type of a variable is not needed, because the compiler would determine the type according with the value assigned.
By default, Fortran is an implicit typing language, so in order to change to a explicit typing mode we need to communicate with the compiler using an instruction to notify that we are going to specify the variables type.
For security and compatibility reasons it is better to specify an implicit typing instruction.
The instruction to do this is: implicit none.
This instruction must be placed always at the top of the program code.

Floating-Point Precision
There is a special case with floating-point values; we can specify the precision of this data type.
There are two types of precision, one is 32 bits length and the other is 64 bits length.
To specify which one we are going to use, we need to add an instruction in order that the compiler knows how we are going to differentiate between both.
The instruction is the following: use, intrinsic :: iso_fortran_env, only: sp= real32, dp= real64, and always must be placed before the implicit none instruction.

Slides Document: https://docs.google.com/presentation/...
Source Code: https://github.com/desmusapplication/...

Social Media
Facebook: https://web.facebook.com/profile.php?...
X: https://x.com/DesmusApp

Music: Pold - Calm (me) Down