Tags: Fortran Course, Fortran Certificate, Fortran Training, fortran course online, fortran coursera, fortran tutorial.
Fortran is an imperative programming language compiled for general purposes that are particularly suitable for numerical computing and scientific computing.
Fortran was first launched in 1954, Fortran is and is still commonly used as the oldest programming language. Scientific fields, in particular, numerical weather prediction, computational fluid dynamics, and computational physics find their applications.
Fortran is quite common in high-performance computing and is used to mark the program bench and rank the fastest supercomputers in the world.
Fortran is a compiled language, or more specifically it is compiled ahead-of-time. In other words, you must perform a special step called the compilation of your written code before you are able to run it on a computer. This is where Fortran differs from interpreted languages such as Python and R which run through an interpreter which executes the instructions directly but at the cost of computing speed.
Fortran is the dominant programming language used in engineering applications. It is therefore important for engineering graduates to be able to read and modify Fortran code. From time to time, so-called experts predict that Fortran will rapidly fade in popularity and soon become extinct. These predictions have always failed. Fortran is the most enduring computer programming language in history. One of the main reasons Fortran has survived and will survive is software inertia.
Over the years, a vast collection of code has been written with Fortran in many scientific and engineering machines, allowing the language to persist.
Some of the reasons you should learn Fortran:
1. Built-in support for arguments in subroutines
2. Rich set of intrinsic functions
3. Built-in support for complex numbers
4. Support for array notation allowing operations on array sections
5. Strong aliasing rules for memory pointers, resulting in more efficient code after compilation
6. Some legacy code are written in Fortran and still in operation.
FORTRAN was designed for scientists, engineers, and programmers. There are a set of rules governing Fortran code and whether a code is valid and can be compiled. Fortran uses a popular code structure term called Syntax- a combination of characters and reserved keywords to create a Fortran program and issue an instruction to the computer.
Below are Basics of Fortran Programming:
This is the structure of the Fortran program and it has a reserved keyword for doing just that. Fortran uses the PROGRAM keyword, followed, optionally, by a name for the program to begin a program and end it with the END PROGRAM keyword.
! Do some stuff, other code, statements, functions
Within the PROGRAM statements, you can define functions, declare variables to be used in these functions, just like in other programming languages.
These are values or data used in your program. A variable can refer to a single value like 1 or point to a larger data structure such as a list. They can also be used to store data like texts, words, decimal and many more.
Each variable usually refers to a type of data. A data type describes what kind of data the variable is expected to hold. It can either numbers which are integers or words which is a string. We could say x=3, this means x is holding an integer type of data, however, we didn't specify what type of data it's holding. Most programming languages require you to specify what type of data a particular variable is expected to hold.
In Fortran, variables are declared as below:
INTEGER :: n = 3
INTEGER :: m = 6
The above code in Fortran means we are creating two INTEGER variables. The keyword INTEGER is used to specify what kind of data we are creating and that's a variable with numbers. There are others like REAL , LOGICAL , etc.
This is the easiest way to see the results of a calculation or print a message on the console and also collects inputs from users to be used in a calculation for instance. This basically provides a way to print a message on the console and a way for users to type in values using the keyboard right from the program.
Read: The READ function tells the FORTRAN program to record the values you enter using the keyboard and store them in variables that you define in your program. We can see a working example :
READ(*,*) a, b, c
In Fortran functions, any inputs needed for the function are placed inside a list within the two round-brackets (parentheses), as in reading (input1, input2, etc…). When the program is running and gets to the READ statement, it will prompt you to enter a variable and press enter.
Write: WRITE function is similar to the READ function. It just prints out the given values to the console screen. For instance:
WRITE(*,*) a, b, c
This would print the values assigned to the variables specified in the code.
Fortran is primarily designed for numerical calculations, and it has many built-in functions for mathematical operations. In Fortran, we use the basic functions: +, -, *, / for addition, subtraction, multiplication, and division.
This is the logic flow of a program. This is for instance where most calculations are being made and decides on the final results. It is a bit like the logical decisions we make in our everyday life. For instance, we could say IF it's raining THEN don't go outside, ELSE there is an umbrella you are free to go to. Below is an example:
LOGICAL :: Raining
LOGICAL :: Umbrella
IF (Raining .AND. Umbrella) THEN
WRITE(*,*) "Its raining and I have an umbrella, I can go out"
WRITE(*,*) "Its raining and I have no umberella, I can't g out"
The IF and THEN statements: These two keywords are used to make logical decisions within a program. The IF [CONDITION(S)…] THEN construct is used to do something based on a condition being met.
The ELSE statement: The ELSE statement is usually optional, although it's useful if you have something you want to do if the condition is false. Most times, the ELSE statement is used here to print an error message if the conditions are not met.
End IF statement: This indicates the end of a decision-making block. You must remember to always end it with the END IF statement.
Most programming languages usually need to be compiled or go through a process before it can be run or executed. Fortran programs need to be compiled to what the computer understands using the gfortran compiler. This compiles Fortran code to what the computer understands. Save your code in a text file with .f90 extension and run it against the compiler to generate the machine code.
You can run the command below in your terminal directory:
gfortran example.f90 -o example
This tells gfortran to take the file example.f90 and generate a program called example for us to run. The -o flag lets us indicate an output name for our generated program. This will generate a file example in your directory which can be run from the command line.
Fortran has many advantages, some of which are:
Fortran - Introduction/Overview
Fortran - Environment Setup
Fortran - Basic Syntax
Fortran - Data Types
Fortran - Variables
Fortran - Constants
Fortran - Operators
Fortran - Decisions
Fortran - Loops
Fortran - Numbers
Fortran - Characters
Fortran - Strings
Fortran - Arrays
Fortran - Dynamic Arrays
Fortran - Derived Data Types
Fortran - Pointers
Fortran - Basic Input Output
Fortran - File Input Output
Fortran - Procedures
Fortran - Modules
Fortran - Intrinsic Functions
Fortran - Numeric Precision
Fortran - Program Libraries
Fortran - Programming Style
Fortran - Debugging Program
Fortran - Video Lectures
Fortran - Exams and Certification
Login & Study At Your Pace
500+ Relevant Tech Courses
300,000+ Enrolled Students
Don't have an account? Create your account to Start Learning!
The Scholarship offer is a discount program to take our Course Programs and Certification valued at $70 USD for a reduced fee of $7 USD. - Offer Closes Soon!!
Copyrights © 2020. SIIT - Scholars International Institute of Technology is a subsidiary of Scholars Global Tech. All Rights Reserved.
Don't have an account? Create your account to Start Learning!