Fortran (originally derived from Formula Translation)
Created by IBM in the 1950s, it was the first high-level programming language and remains a powerhouse in the scientific community today.
Fortran was developed by John Backus at IBM in 1957. Before Fortran, programmers had to write in assembly or machine code, which was incredibly tedious. Fortran changed the world by allowing humans to write code that looked more like mathematical equations.
Fortran I/II/IV: The early years that established the language.
Fortran 77: The most "classic" version. It introduced character strings and logical IF statements. Much legacy code still exists in this format.
Fortran 90/95: A massive leap forward. It introduced array programming, modules, and free-form source code (getting rid of the strict column-based formatting).
Modern Fortran (2003, 2008, 2018, 2023): Added Object-Oriented Programming (OOP) features, Coarrays (for parallel computing), and better interoperability with the C language.
You might wonder why scientists don't just use Python or C++. Fortran has specific "superpowers":
Execution Speed: Fortran is compiled and highly optimized for numerical data. In many heavy-duty math simulations, it is still faster than almost anything else.
Array Handling: It treats arrays as "first-class citizens." You can perform operations on entire matrices with very simple syntax.
Legacy Libraries: Decades of highly optimized math libraries (like BLAS and LAPACK) are written in Fortran. Most modern languages actually "wrap" these Fortran libraries under the hood.
Parallelism: With features like Coarrays, Fortran is designed to run across thousands of CPU cores in supercomputers.
Modern Fortran is much cleaner than the old "punch card" style of the 70s. Here is what a basic calculation looks like:
program circle_area
implicit none
real :: radius, area
real, parameter :: PI = 3.14159265
print *, "Enter the radius:"
read *, radius
area = PI * radius**2
print *, "The area is:", area
end program circle_area
program multiply_inputs
implicit none
! Variable declarations
real :: num1, num2, result
integer, parameter :: file_unit = 10
logical :: file_exists
! 1. Accept two numeric inputs from the user
print *, "Enter the first number:"
read *, num1
print *, "Enter the second number:"
read *, num2
! 2. Store and multiply the values
result = num1 * num2
! 3. Output to the display screen (Standard Output)
print *, "------------------------------------"
print *, "Calculation Result (Screen):"
print *, num1, " x ", num2, " = ", result
print *, "------------------------------------"
! 4. Output to a file (to be sent to a printer)
! In modern systems, we write to a .txt or .out file
! which can then be sent to a physical printer.
open(unit=file_unit, file='print_job.txt', status='replace')
write(file_unit, *) "FORTRAN PRINT REPORT"
write(file_unit, *) "Input A: ", num1
write(file_unit, *) "Input B: ", num2
write(file_unit, *) "Result: ", result
close(file_unit)
print *, "A copy has been saved to 'print_job.txt' for printing."
end program multiply_inputs