Fortran facts for kids
Paradigm | Multi-paradigm: structured, imperative (procedural, object-oriented), generic, array |
---|---|
Designed by | John Backus |
Developer | John Backus and IBM |
First appeared | 1957 |
Stable release |
Fortran 2023 (ISO/IEC 1539:2023) / November 17, 2023
|
Typing discipline | strong, static, manifest |
Filename extensions | , ,
|
Major implementations | |
Absoft, Cray, GFortran, G95, IBM XL Fortran, Intel, Hitachi, Lahey/Fujitsu, Numerical Algorithms Group, Open Watcom, PathScale, PGI, Silverfrost, Oracle Solaris Studio, others | |
Influenced by | |
Speedcoding | |
Influenced | |
ALGOL 58, BASIC, C, Chapel, CMS-2, DOPE, Fortress, MATLAB, PL/I, PACT I, MUMPS, IDL, Ratfor |
Fortran (pronounced FOR-tran) is a very old and powerful programming language. It was created by IBM in 1957. Fortran is great for solving math problems and doing scientific calculations. This makes it perfect for engineers and scientists.
People use Fortran for many important tasks. These include predicting the weather, designing airplanes, and understanding how liquids flow. It's also used in computational physics and chemistry. Fortran is a top choice for high-performance computing. This means it runs programs on the world's fastest supercomputers.
Over the years, Fortran has changed a lot. New versions have added features like handling text, structured programming, and object-oriented programming. This helps programmers organize their code better. Fortran is still very popular today. It often ranks among the top ten programming languages.
Contents
Understanding the Name Fortran
The name Fortran comes from "Formula Translating System." It means it helps computers understand math formulas. In the past, the name was always written in capital letters, like FORTRAN. This was because early computers could only use uppercase letters.
Since 1990, the official name has been "Fortran," with only the first letter capitalized.
How Fortran Started
In 1953, a scientist named John Backus had an idea. He wanted to make it easier to program computers. At the time, people used assembly language. This was very hard to write. Backus worked with a team at IBM to create Fortran. Their goal was to let people type math equations directly into the computer.
The first Fortran manual came out in 1956. The first Fortran compiler was ready in 1957. A compiler is a special program. It turns the code you write into instructions the computer can understand. Fortran was so good that even assembly language programmers started using it.
John Backus once said he was "lazy." He didn't like writing long programs. So, he created Fortran to make programming easier. This new language quickly became popular. Scientists used it for programs that needed a lot of math. Fortran also had a special feature for complex numbers. This made it great for things like electrical engineering.
By 1960, many computers could use Fortran. Other computer companies also started making Fortran compilers. By 1963, there were over 40 different Fortran compilers!
Early Fortran Versions
Early Fortran programs were often written on punched cards. Each card held one line of code. These cards were then fed into a computer.

The cards had special rules for where you could type. For example, column 1 was for comments. Columns 1 to 5 were for labels. Column 6 was for continuing a line of code. The actual program code went from column 7 to 72. Columns 73 to 80 were ignored. This allowed programmers to add notes or sequence numbers.
In early Fortran, spaces in the code usually didn't matter. So, "AVG OF X" was the same as "AVGOFX." This could sometimes make code hard to read.
FORTRAN II: Adding Subroutines
IBM released FORTRAN II in 1958. This version was a big step forward. It allowed programmers to write subroutines and functions. These are like mini-programs that do specific tasks. They help break down big problems into smaller, easier parts. This made programs more organized.
FORTRAN II also added a way for different parts of a program to share information. This was done using a `COMMON` statement. Later, FORTRAN II also added support for `DOUBLE PRECISION` and `COMPLEX` numbers.
FORTRAN IV: New Features and Standards
IBM started working on FORTRAN IV in 1961. This version removed some features that only worked on specific machines. It also added new, useful features. These included a `LOGICAL` data type for true/false values. It also introduced the `logical IF` statement. This was a better way to make decisions in a program.
FORTRAN IV was released in 1962. It became very popular. By 1965, it was becoming a standard. This meant that different computers could run the same Fortran programs.
FORTRAN 66: The First Official Standard
In 1966, the American Standards Association (now American National Standards Institute or ANSI) created the first official standard for Fortran. This version was called FORTRAN 66. It helped make sure that Fortran programs would work on different computers.
FORTRAN 66 included many important features:
- Main programs, subroutines, and functions.
- Different types of numbers: `INTEGER`, `REAL`, `DOUBLE PRECISION`, `COMPLEX`.
- `LOGICAL` data type for true/false.
- Statements like `COMMON` and `DIMENSION` to organize data.
- `DO` loops for repeating actions.
- `READ` and `WRITE` statements for input and output.
- `IF` statements for making decisions.
FORTRAN 77: Improving Structure and Text Handling
The next big update was FORTRAN 77, approved in 1978. This version brought many improvements. A key addition was the `BLOCK IF` statement. This made it much easier to write structured programs. Structured programs are clearer and easier to understand.
FORTRAN 77 also added a `CHARACTER` data type. This allowed programmers to work with text and words much more easily. Before this, handling text was very difficult in Fortran. Other new features included:
- Better `DO` loops.
- `OPEN`, `CLOSE`, and `INQUIRE` statements for managing files.
- The `IMPLICIT` statement to control how variables are named.
- `PARAMETER` statement for defining constants.
Some older, less useful features were removed in FORTRAN 77. This helped keep the language modern and efficient.
Modern Fortran: From 90 to Today
The Fortran language has continued to grow and improve. Versions from the 1990s onwards are often called 'Modern Fortran'.
Fortran 90: A Big Leap Forward
Fortran 90 was a huge update, released in 1991. It brought many new features that changed how people wrote Fortran code:
- Free-form code: You no longer had to worry about specific columns for your code.
- Longer names: Variable names could be up to 31 characters long, making them more descriptive.
- Array operations: You could now work with entire arrays (lists of numbers) at once. This made math and engineering calculations much simpler.
- Modules: This allowed programmers to group related code and data together.
- Dynamic memory: Programs could ask for memory as needed while running.
- Pointers: These are like special variables that "point" to other data.
- Better loops and decisions: New `DO` loop structures and `SELECT CASE` statements made code clearer.
Fortran 90 was designed to be compatible with older FORTRAN 77 programs. This meant old programs would still work.
"Hello, World!" Example
Here's a simple Fortran 90 program that prints "Hello, World!" to the screen. This is often the first program people learn in a new language.
program helloworld
print *, "Hello, World!"
end program helloworld
Fortran 95: Small Improvements
Fortran 95 (1997) was a smaller update. It fixed some issues from Fortran 90. It also added features to help with parallel computing. This is where a program runs parts of its code at the same time. Some old features that were marked as "obsolescent" in Fortran 90 were removed in Fortran 95.
Fortran 2003: Object-Oriented Features
Fortran 2003 (2004) was another major update. It added support for object-oriented programming (OOP). OOP helps programmers organize code into "objects." These objects can have their own data and actions. This makes it easier to create complex programs.
Other important additions included:
- Better ways to handle different types of data.
- Improved input and output (I/O) features.
- Support for IEEE floating-point arithmetic. This helps ensure math calculations are very accurate.
- Ability to work with the C programming language. This lets Fortran programs use code written in C.
- Better support for different languages and operating systems.
Fortran 2008: Parallel Computing and Sub-modules
Fortran 2008 (2010) was a minor update. It added `Coarray Fortran`. This is a way to write programs that run on many computers at once. It also added `DO CONCURRENT`. This helps run parts of a loop at the same time. Sub-modules were also added to help organize large programs.
Fortran 2018: More Parallelism and C Interoperability
Fortran 2018 (2018) continued to improve the language. It added more features for parallel computing. It also made it even easier for Fortran programs to work with C programs. This is important because many useful libraries are written in C.
Fortran 2023: Latest Version
Fortran 2023 (2023) is the newest version. It mainly fixes small issues and adds a few new features. One new feature is the ability to use enumerated types. These let you define a list of named values.
Fortran in Science and Engineering
Even though Fortran is an old language, it's still very important. Scientists and engineers use it every day. It's the main language for many supercomputer tasks. These include:
- Studying stars and galaxies (astronomy).
- Creating climate models.
- Designing structures (structural engineering).
- Predicting the weather.
Many tests that measure how fast computers are use Fortran programs. This shows how powerful Fortran is for math. While other languages like C++ and Python are also used, Fortran remains a core language for scientific computing.
Making Fortran Programs Work Everywhere
In the early days, Fortran programs sometimes didn't work on different computers. This was because each computer company had its own version of Fortran. Over time, official standards helped fix this. Now, if you write a Fortran program carefully, it can run on almost any computer.
Modern Fortran also makes it easy to use libraries written in other languages, like C. This means Fortran programmers can use a wider range of tools.
Code Example: Calculating Averages
This example shows how Fortran 90 and newer versions can work with arrays. It calculates the average of numbers you type in. Notice how it handles the whole list of numbers at once, without many `DO` loops.
program average
! Read in some numbers and take the average
! As written, if there are no data points, an average of zero is returned
! While this may not be desired behavior, it keeps this example simple
implicit none
real, allocatable :: points(:)
integer :: number_of_points
real :: average_points, positive_average, negative_average
average_points = 0.
positive_average = 0.
negative_average = 0.
write (*,*) "Input number of points to average:"
read (*,*) number_of_points
allocate (points(number_of_points))
write (*,*) "Enter the points to average:"
read (*,*) points
! Take the average by summing points and dividing by number_of_points
if (number_of_points > 0) average_points = sum(points) / number_of_points
! Now form average over positive and negative points only
if (count(points > 0.) > 0) positive_average = sum(points, points > 0.) / count(points > 0.)
if (count(points < 0.) > 0) negative_average = sum(points, points < 0.) / count(points < 0.)
! Print result to terminal stdout unit 6
write (*,'(a,g12.4)') 'Average = ', average_points
write (*,'(a,g12.4)') 'Average of positive points = ', positive_average
write (*,'(a,g12.4)') 'Average of negative points = ', negative_average
deallocate (points) ! free memory
end program average
Fun Facts About Fortran
Programmers sometimes make jokes about their languages. Here are a couple about Fortran:
- In Fortran, variable names starting with I, J, K, L, M, or N are usually integers (whole numbers). Other letters mean they are real numbers (with decimals). This led to the joke: "In FORTRAN, GOD is REAL (unless declared INTEGER)."
- Once, a proposal was made to remove the letter "O" from Fortran. This was a joke to stop people from using the `GO TO` statement, which was seen as messy.
Images for kids
-
FORTRAN code on a punched card, showing the specialized uses of columns 1–5, 6 and 73–80
-
A reproduction of a FORTRAN coding form, printed on paper and intended to be used by programmers to prepare programs for punching onto cards by keypunch operators. Now obsolete.
Error: no page names specified (help).
- f2c
- F2PY
- FORMAC
- List of Fortran compilers
- List of Fortran numerical libraries
- List of programming languages
- Matrix representation
- Spaghetti code