Fortran is a computer programming language that is extensively used in numerical, scientific computing. While out with the scientific community, Fortran has declined in popularity over the years, it still has a strong user base with scientific programmers, and is also used in organisations such as weather forecasters, financial trading, and in engineering simulations. Fortran programs can be highly optimised to run on high performance computers, and in general the language is suited to producing code where performance is important.
Fortran is a compiled language, or more specifically it is compiled ahead-of-time. In other words, you must perform a special step called compilation of your written code before you are able to run it on a computer. This is where Fortran differs to interpreted languages such as Python and R which run through an interpreter which executes the instructions directly, but at the cost of compute speed.
Fortran is imperative programming language compiled for general purpose that are particularly suitable for numerical and scientific computing.
History:
One of the oldest programming languages, the FORTRAN was developed by a team of programmers at IBM led by John Backus, and was first published in 1957. The name FORTRAN is an acronym for Formula Translation, because it was designed to allow easy translation of math formulas into code.
The objective during it's design was to create a programming language that would be: simple to learn, suitable for a wide variety of applications, machine independent, and would allow complex mathematical expressions to be stated similarly to regular algebraic notation. While still being almost as efficient in execution as assembly language. Since FORTRAN was so much easier to code, programmers were able to write programs 500% faster than before, while execution efficiency was only reduced by 20%, this allowed them to focus more on the problem solving aspects of a problem, and less on coding.
FORTRAN was so innovative not only because it was the first high-level language, but also because of it's compiler, which is credited as giving rise to the branch of computer science now known as compiler theory. Several years after it's release FORTRAN had developed many different dialects, (due to special tweaking by programmers trying to make it better suit their personal needs) making it very difficult to transfer programs from one machine to another.
Syntax:
Each program contains one main program and may or may not contain other program units. The syntax of the main program is as follows −
program program_name
implicit none
! type declaration statements
! executable statements
end program program_name
Example:
Let’s write a program that adds two numbers and prints the result −
program addNumbers
! This simple program adds two numbers
implicit none
! Type declarations
real :: a, b, result
! Executable statements
a = 12.0
b = 15.0
result = a + b
print *, 'The total is ', result
end program addNumbers
Output:
The total is 27.0000000
Keywords
Keywords are special words, reserved for the language. These reserved words cannot be used as identifiers or names.
The following table, lists the Fortran keywords −
Features:
1. High performance
Fortran has been designed from the ground-up for computationally intensive applications in science and engineering. Mature and battle-tested compilers and libraries allow you to write code that runs close to the metal, fast.
2. Statically and strongly typed
Fortran is statically and strongly typed, which allows the compiler to catch many programming errors early on for you. This also allows the compiler to generate efficient binary code.
3. Easy to learn and use
Fortran is a relatively small language that is surprisingly easy to learn and use. Expressing most mathematical and arithmetic operations over large arrays is as simple as you'd write them as equations on a whiteboard.
4. Versatile
Fortran allows you to write code in a style that best fits your problem: Imperative, procedural, array-oriented, object-oriented, or functional.
5. Natively parallel
Fortran is a natively parallel programming language with intuitive array-like syntax to communicate data between CPUs. You can run almost the same code on a single CPU, on a shared-memory multicore system, or on a distributed-memory HPC or cloud-based system. Coarrays, teams, events, and collective subroutines allow you to express different parallel programming patterns that best fit your problem at hand.
Advantages:
Fortran supports Numerical analysis and scientific computation
Fortran supports the Generic and Structured programming
Fortran supports Array and the Modular programming
High performance
Object-oriented programming
Extremely optimized for the vectorization
Fortran is readable and easy to understand
Very fast in Scientific Computing
Disadvantages:
Fortran has liberal rules and an extensive system of default values: while this reduces programming effort it also makes it harder for the system to detect the programmer's mistakes.
Fortran does not insist on this but, in consequence, if you make a spelling mistake in a variable name the compiler is likely to use two variables when you only intended to use one. Such errors can be serious but are not always easy to detect.
Fortran also lacks various control and data structures which simplify programming languages with a more modern design.
The Tech Platform
Comments