Javatpoint Logo
Javatpoint Logo

What is FORTRAN?

What is FORTRAN

Fortran, formerly written in all caps (FORTRAN), which stands for Formula Translation, was one of the first programming languages that were designed for numeric computation and scientific computing. It is still in use; however, it is the oldest programming language. In 1954, John Backus and the IBM team began work on Fortran's development. On October 15, 1956, the reference manual was made available to the public, and the first compiler followed in 1957.

Fortran is an imperative programming language that uses are widespread in science, particularly in the domains of computational physics, computational fluid dynamics, as well as numerical weather prediction. It is frequently used to mark the program bench and rank the world's fastest supercomputers, as it is quite common in high-performance computing.

It is a compiled language, or more especially, one that is precompiled. In other words, before you can execute your written source code on a computer system, you must go through a unique process known as compilation. In this respect, Fortran is different from interpreted languages like Python and R, which are run through an interpreter and directly carry out the instructions at the expense of processing speed.

Fortran has a number of qualities that make it appropriate for scientists, including:

  • It contains a rich set of intrinsic functions.
  • It provides support for array notation, which allows operations on array sections.
  • It has strong aliasing rules for memory pointers, which helps to make more efficient code after compilation.
  • It has built-in support for complex numbers and arguments in subroutines.

In modern times, Fortran is still widely used to run floating-point benchmark testing on new computer processors, despite competition from languages like C and C++. It has survived with time due to a sizable body of code that has been created in numerous scientific and engineering equipment as well.

Through the years, Fortran has developed. Prior to supporting object-oriented features such as type extension and inheritance, polymorphism, and dynamic type allocation, it was a strictly procedural programming language.

Why Learn Fortran?

The most popular programming language for engineering applications is Fortran, which makes it necessary to learn it. Therefore, it is crucial that engineering graduates have the skills necessary to understand and modify source code written in Fortran. With time, it is occasionally predicted by so-called experts that the use of Fortran will experience a rapid decline and eventually disappear.

These forecasts have consistently been wrong. The longest-lasting computer programming language in history is Fortran. Software inertia is one of the primary reasons Fortran has endured and will survive. Through the years, due to a sizable body of code that has been created in numerous scientific and engineering machines, Fortran has survived.

Fortran Basics

The primary creation of Fortran is for scientists, engineers, and programmers. There are a set of rules that help to govern its code and verify whether a code is valid or can be considered legitimate and compilable. Fortran creates programs and sends commands to the computer with the help of using a popular term for code structure called syntax, which combines characters and reserved words.

Basics of Fortran Programming are given below:

1. Program Structure

Fortran programs follow a structure, and this language contains a reserved keyword for accomplishing just that. It uses the PROGRAM keyword, which is then optionally followed by the name of the program to start it and end it with the END PROGRAM keyword.

Example

Just like in other programming languages, you can declare variables and define functions to be utilized in these functions within PROGRAM statements.

2. Variables Definition

These are the data or values that are used in your program.

One single value, like 1, or printing to a larger data structure, like a list, can be referenced by a variable. They can also be used to hold information such as text, words, numeric, as well as many other types of data. Typically, each variable denotes a specific sort of data. A data type represents what type of data is to be held by the variable. Either it can be numbers that are integers or words, which is a string. For case, x=5 where x is a variable, and it stored the value 5, and it indicates that x is holding data of the integer type; however, we didn't define what kind of data x is storing. The majority of programming languages demand that you need to specify the kind of data that a certain variable is expected to hold.

In Fortran programming language, variables are declared as shown below:

We are creating two INTEGER variables with the Fortran code above. These variables contain some value. To indicate the data we are creating is a variable with numbers, the keyword INTEGER is used. There are some others, including REAL, LOGICAL, etc.

3. Read and Write Message

This allows you to quickly gather user input for things like calculations and also to view a calculation's findings or print a message on the console. This essentially gives users a method to type data directly into the application with the help of using the keyboard and a way to print messages on the console.

Read: The FORTRAN software is instructed to record the values you type on the keyboard and store them in variables you specify in your program by using the READ function. You can see a good illustration below:

In Fortran functions, any inputs required by a Fortran function are located inside a pair of round brackets (parentheses), as in reading (input1, input2, etc.). You will get a prompt to input a variable and press enter while the program is running when it reaches the READ statement.

Write: The WRITE function is much like to the READ function. It merely displays the supplied values on the terminal screen. For example:

The values you assign to the specified variables will be printed out by this code.

4. Mathematical operations

In order to perform mathematical operations, Fortran has several built-in functions and is primarily intended for use in numerical calculations. The addition, subtraction, multiplication, and division operations in Fortran are performed using the +, -, *, and / fundamental functions.

5. Decision Making

This is how a program's logic works. For example, the majority of calculations are conducted here, which also determines the outcome. It is bit similar to the logical decisions we make in daily life in certain ways. For case, we can decide "If it's raining, don't go outside; ELSE we use umbrella to go outside freely. Here's an illustration logically:

Components of Decision Making:

  • The IF and THEN statements. Two keywords, IF and THEN, are used to make logical decisions within a program. When a condition is satisfied, action is taken using the IF [CONDITION(S)...] THEN construct.
  • The ELSE statement. The ELSE sentence is commonly not required; hence, it is optional; but it can be helpful in the condition where you have something you want to do if the condition is false or not satisfied. If the conditions are not met, the ELSE statement is typically used to output an error message.
  • End IF statement. This is a statement that represents the completion of the decision-making block. Always remember to add an END IF statement in order to end the decision-making statements.

6. Compilation

Before being run or executed, the majority of programming languages often require to be compiled or go through a process. The gfortran compiler is used to compile Fortran programs into a format that the computer can understand. By doing this, Fortran code gets converted into a form that can be easily understandable by a computer system. You need to save your file with .f90 extension and then run it through the compiler to create machine code. In your terminal directory, you can run the command below:

This instructs gfortran to create the myfile program for us to run after taking the file myfile.f90. In other words, gfortran compiles the file named myfile.f90. Also, we can specify an output name for our created program using the -o flag. This will create a command-line executable file myfile in your directory.

Where is Fortran Used?

In high-performance computer domains that demand computational science, Fortran is still widely used in this. There are various examples of Fortran programs such as OFF fluid dynamics code, NEMO (Nucleus for European Modelling of the Ocean), and Goddard Institute for Space Studies models.

Because it is simple to translate mathematical formulas into code by using this language, its performance is quickly and well understood by the climate modelling community; therefore, Fortran continues to be used in a wide range of climate modelling applications.

In April 2021, Fortran was listed as the 20th most popular language in the world, which was measured by the TIOBE Index, which gauges the popularity of hundreds of programming languages. Fortran's continuous use in high-performance computing sectors suggests it is here to stay; however, the popularity of alternative programming languages has been increasing over the twenty-first century.

The History of Fortran

Fortran was created by IBM in the 1950s. With the first compiler for the language being released in 1957, the name of Fortran programming language comes from a contraction of Formula Translation, highlighting its intended usage in mathematical calculations.

Fortran II, the language's second generation, was released a year later. There were just 32 statements in this iteration, which makes it a compact but powerful language. In the ensuing decade, Fortran III and Fortran IV were released.

Due to the lack of a language standard in these early years, there are a lot of variants and different compilers have been arisen. The American Standards Association issued its first language standard in 1966 to resolve the issue. Fortran 66 is the name given to this version as it started to gain popularity.

Although the software industry welcomed uniformity, new variations continued to emerge. New versions of the language, such as Fortran 77, would be added as the American Standards Association continued to update it.

In order to enhance writing inline comments and structured programming, later versions added ideas such as the block IF and END IF statements. Many of these creative features can be found in current programming languages, such as C++, Java, Python, etc.

Over the past 40 years, a number of widely used languages have not only adopted some of Fortran's features but have also greatly influenced from it. Fortran had a significant impact on both C and BASIC. Possibly, C is conceivably the most widely used language in the world and BASIC is one of the most well-known programming languages of the 1980s.

According to some experts, Fortran's development is comparable to the development of compiler technology as new compiler approaches are developed to run Fortran programs more effectively.

Below is a table that contains a brief history description of Fortran:

Year Fortran Version
1954 FORTRAN
1958 FORTRAN II
1958 FORTRAN III (It was never released to public)
1961 FORTRAN IV
1972 FORTRAN 66
1980 FORTRAN 77
1991 Fortran 90
1997 Fortran 95
2004 Fortran 2003, which was published as ISO/IEC
September 2010. Fortran 2008, which was published as ISO/IEC
2018 Fortran 2018, it is still in development, which is formally known as Fortran 2015

Advantages of Fortran

There are numerous advantages of Fortran; some are as follows:

  • Fortran is quite powerful in the scientific community. This domain contains a robust ecosystem of tools.
  • The world's fastest native code is written in Fortran. Scientific computing is perfect because of this.
  • Fortran is a great tool for modelling supercomputers as it is highly optimized for vectorization.
  • As compared to C++, Modern Fortran is incredibly easy to read as well as understand.
  • Furthermore, you will not find the terrible syntax of the off-side rule in Fortran like the python language does.

Should I use "Fortran" or "FORTRAN" in my writing?

According to the Microsoft Manual of Style advises, writing "FORTRAN," it should not be written in all capital letters and not be spelt out as "Formula Translation." You should use FORTRAN in your writing if you are discussing FORTRAN versions prior to Fortran 90. However, capitalize only the first letter if you are writing about more modern versions of Fortran or writing about Fortran in general.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA