Fortran
| Company type | Programming language |
|---|---|
| Industry | Software, scientific computing |
| Founded | 1956 |
| Founder | IBM |
Area served | Worldwide |
Key people | John Backus, Richard Goldberg, Sheldon F. Best, Harlan Herrick, Peter Sheridan, Roy Nutt, Robert Nelson, Irving Ziller, Harold Stern, Lois Haibt, David Sayre |
| Products | Fortran programming language and compilers |
| Owner | IBM (original creator) |
| Parent | IBM (original development) |
Fortran (; previously known as FORTRAN) is a third-generation, compiled, imperative language designed primarily for numerical computation and scientific calculations.
Created by IBM, the initial reference guide was published in 1956, with the first dependable compilers emerging two years afterward. Fortran is widely applied in scientific and engineering domains, including numerical weather prediction, finite element analysis, computational fluid dynamics, plasma physics, geophysics, computational physics, crystallography, and computational chemistry. It continues to be a staple in high-performance computing environments and serves as a benchmark for the world’s fastest supercomputers.
Over time, Fortran has undergone numerous revisions and dialect expansions. The American National Standards Institute (ANSI) established the first official standard in 1966 to address compiler inconsistencies. Subsequent editions introduced significant enhancements: character data types (Fortran 77), structured programming, arrays, modularity, and generic programming capabilities (Fortran 90), parallel processing support (Fortran 95), object-oriented programming constructs (Fortran 2003), and concurrent programming features (Fortran 2008).
As of April 2024, Fortran remains among the top ten programming languages on the TIOBE index, underscoring its sustained importance in scientific research and high-performance computing sectors.
Naming
The initial FORTRAN manual defined the acronym as a Formula Translating System, presenting the name in small caps. Other interpretations include Formula Translator or Formula Translation. Due to early IBM hardware lacking support for lowercase letters, all FORTRAN versions up to FORTRAN 77 were rendered entirely in uppercase characters. FORTRAN 77 marked the last edition restricted to uppercase-only character sets. Beginning with Fortran 90, official international standards have adopted the capitalized form "Fortran."
Origins
In late 1953, John Backus proposed to IBM an alternative to programming in assembly language for the IBM 704 mainframe.[1] Backus headed a development team that included Richard Goldberg, Sheldon F. Best, Harlan Herrick, Peter Sheridan, Roy Nutt, Robert Nelson, Irving Ziller, Harold Stern, Lois Haibt, and David Sayre. Their design aimed to simplify entering mathematical formulas into computers, drawing inspiration from the earlier Laning and Zierler system of 1952.[2]
By November 1954, a draft specification titled The IBM Mathematical Formula Translating System was finalized. The first official FORTRAN manual was published in October 1956,[3] followed by the delivery of the initial compiler in April 1957. Fortran produced efficient machine code that was acceptable even to programmers accustomed to assembly language.[4]
In a 1979 interview, Backus explained that his motivation was convenience: frustrated by programming on the IBM 701, he sought a more user-friendly approach.
FORTRAN rapidly gained traction among scientists requiring intensive numerical computation, which encouraged ongoing improvements in compiler speed and efficiency. The addition of complex number support made it particularly valuable for technical disciplines such as electrical engineering.[5]
By 1960, FORTRAN versions were available for IBM models including the 709, 650, 1620, and 7090. Its widespread adoption led to over forty different compilers being developed by various manufacturers by 1963.
On the IBM 1401, FORTRAN featured a novel 63-phase compiler that operated completely within its limited core memory of 8000 six-bit characters. It executed from tape or card decks without requiring extra storage devices and converted programs into executable form using overlays.[6] This methodology was detailed in sources like Anatomy of a Compiler and IBM technical manuals.[7][8] The resulting executable incorporated interpreted elements such as floating-point calculations and input/output functions—anticipating similar techniques like UCSD Pascal's P-code by roughly twenty years. An interpreted simplified version called GOTRAN allowed "load and go" functionality on early IBM 1620 machines.[9] Contemporary Fortran implementations are fully compiled to maximize performance.
The evolution of Fortran closely paralleled advancements in early compiler technologies, contributing significantly to progress in compiler theory and design focused on producing optimized code for high-level languages.
FORTRAN
The first FORTRAN version for the IBM 704 supported 32 different statement types, including:
- Assignment statements
- The three-way arithmetic statement, which directed program flow depending on whether an expression was negative, zero, or positive
- Exception handling commands (, , ) and controls for sense switches and indicator lights (, , )
- Various forms of statements, such as computed and assigned variants
- loop constructs
- Formatted input/output operations: , , , , and
- Unformatted I/O commands for tape and drum read/write
- File management instructions: , ,
- Program flow controls: , , and
- The statement, which provided hints to the compiler for optimization purposes
The only comparison tool available was the arithmetic statement, which tested differences but carried a risk of overflow; subsequent versions introduced logical operations to overcome this limitation.
An optional statement allowed programmers to specify branch probabilities for the arithmetic and estimate the iteration count for loops. The earliest FORTRAN compiler utilized these weights to perform a compile-time Monte Carlo simulation aimed at optimizing memory layout of basic blocks—an innovative optimization approach detailed in Backus et al.'s work, The FORTRAN Automatic Coding System.
Initially, the compiler detected errors by halting execution and producing error codes that programmers had to look up manually. Later, error-handling routines developed by NASA were incorporated, enabling the system to identify specific code lines causing errors and thereby improving debugging efficiency.
Fixed layout and punched cards
Prior to disk storage and text editors, programs were input using 80-column punched card decks created with an keypunch machine, with each card representing one line of code. The deck was then fed into a card reader for compilation. Since punched cards lacked lowercase letters and many special characters, IBM 026 keypunch machines printed repurposed characters specifically for FORTRAN use.
Corresponding to this input format, Fortran source code employed a fixed-column layout where the first 72 columns were read as twelve 36-bit words.
A "C" placed in column 1 signified a comment line that the compiler ignored. Otherwise, columns were allocated as follows:
- Columns 1–5: label field used for DO loops, GO TO statements, IF conditions, or FORMAT labels; any leading zeros were disregarded.
- Column 6: continuation indicator; any character other than blank or zero denoted that the current line continued from the previous one.
- Columns 7–72: statement field containing executable code.
- Columns 73–80: not interpreted by IBM 704 card readers.
Columns 73–80 frequently contained sequence numbers or annotations to facilitate reordering cards if they became misplaced—this was especially common in stable production environments. An IBM 519 machine could duplicate decks while adding sequence numbers automatically. Early FORTRAN compilers imposed stricter constraints due to hardware limitations. Keypunch devices could be configured to tab directly to column 7 and stop input after column 72. Later compiler versions relaxed these fixed-format rules, with Fortran 90 eliminating them entirely.
Within the statement field, spaces were disregarded except inside text literals, allowing flexible formatting or clearer variable names (for instance, equated ). For example, <syntaxhighlight lang="fortran" inline>101010DO101I=1,101</syntaxhighlight> was equivalent to <syntaxhighlight lang="fortranfixed" inline>10101 DO 101 I = 1, 101</syntaxhighlight>. Note that subtle distinctions between commas and periods affected how statements were interpreted.
Hollerith strings, initially permitted only in FORMAT and DATA statements, used a character count followed by an 'H' prefix (e.g., ) to retain spaces within strings; however, incorrect counts often resulted in errors.
Evolution
| Year | Common Name | Official Standard |
|---|---|---|
| 1957 | FORTRAN | — |
| 1958 | FORTRAN II | — |
| 1958 | FORTRAN III | — |
| 1961 | FORTRAN IV | — |
| 1966 | FORTRAN 66 | ANSI X3.9-1966 |
| 1978 | FORTRAN 77 | ANSI X3.9-1978 |
| 1991 | Fortran 90 | ANSI X3.198-1992 ISO/IEC 1539:1991 |
| 1997 | Fortran 95 | ISO/IEC 1539-1:1997 |
| 2004 | Fortran 2003 | ISO/IEC 1539-1:2004 |
| 2010 | Fortran 2008 | ISO/IEC 1539-1:2010 |
| 2018 | Fortran 2018 | ISO/IEC 1539-1:2018 |
| 2023 | Fortran 2023 | ISO/IEC 1539-1:2023 |
FORTRAN II
Introduced by IBM in 1958, FORTRAN II expanded programming capabilities by incorporating procedural programming features, allowing programmers to write subroutines and functions that return values through parameters passed by reference. The COMMON statement was added to facilitate sharing global variables among subroutines. Six new statements were introduced:
- , , and
- and
Later revisions also brought in the data types and .
Due to hardware constraints related to call stack management, early FORTRAN compilers did not support recursion. Although recursion was not officially part of the FORTRAN 77 standard, many compiler implementations provided it as an option; notably, Burroughs mainframes enabled recursion by default. The RECURSIVE keyword made recursion a standardized feature starting with Fortran 90.
Example of a Basic FORTRAN II Program
The following sample program computes the area of a triangle using Heron's formula. It reads three integer side lengths (A, B, C) from an input tape reel, verifies whether these values can constitute a valid triangle, and then outputs the calculated area formatted with two decimal places. Variables beginning with letters I through N are integers; all others are treated as floating-point numbers. Variable identifiers are restricted to six characters.
<syntaxhighlight lang="fortranfixed"> C AREA OF A TRIANGLE USING STANDARD SQUARE ROOT FUNCTION C INPUT - TAPE READER UNIT 5, INTEGER DATA INPUT C OUTPUT - LINE PRINTER UNIT 6, REAL NUMBER OUTPUT C ERROR IN INPUT RESULTS IN ERROR CODE 1 IN JOB CONTROL LISTING
READ INPUT TAPE 5,501,IA,IB,IC 501 FORMAT (3I5)
C IA, IB, AND IC MUST BE POSITIVE NONZERO VALUES C VERIFY THAT THE SUM OF ANY TWO SIDES EXCEEDS THE THIRD SIDE
IF (IA) 777,777,701 701 IF (IB) 777,777,702 702 IF (IC) 777,777,703 703 IF (IA+IB-IC) 777,777,704 704 IF (IA+IC-IB) 777,777,705 705 IF (IB+IC-IA) 777,777,799 777 STOP 1
C COMPUTE AREA USING HERON'S FORMULA 799 S = FLOATF(IA + IB + IC) / 2.0
AREA = SQRTF(S * (S - FLOATF(IA)) * (S - FLOATF(IB)) *
+ (S - FLOATF(IC)))
WRITE OUTPUT TAPE 6,601,IA,IB,IC,AREA
601 FORMAT (4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2,
+ 13H SQUARE UNITS)
STOP
END
</syntaxhighlight>
FORTRAN III
Developed by IBM in the same year as FORTRAN II (1958), FORTRAN III introduced support for inline assembly language code and Boolean expressions; however, it was never commercially distributed. Similar to its predecessors on the IBM 704 platform, FORTRAN III contained machine-specific features that hindered portability between different hardware systems. Comparable portability challenges were common among early FORTRAN versions produced by other manufacturers.
FORTRAN IV
IBM initiated the development of FORTRAN IV in 1961 to meet user requirements. This iteration removed platform-specific elements present in FORTRAN II and introduced enhancements including the data type, support for logical expressions, and a logical IF construct as an alternative to the arithmetic IF. It also incorporated explicit type declarations along with an statement to override default typing rules.
Initially launched in 1962 for the IBM 7030 Stretch, FORTRAN IV was later ported to the IBM 7090, IBM 7094, and, by 1966, to the IBM 1401. By 1965, it sought alignment with standards under development by the American Standards Association's X3.4.3 FORTRAN Working Group.
Between 1966 and 1968, IBM released several FORTRAN IV compilers for the IBM System/360, each distinguished by letters denoting minimum memory requirements:
- 1966: FORTRAN IV F for DOS/360 (64K bytes)
- 1966: FORTRAN IV G for OS/360 (128K bytes)
- 1968: FORTRAN IV H for OS/360 (256K bytes)
Digital Equipment Corporation supported DECSYSTEM-10 Fortran IV (F40) on the PDP-10 from 1967 through 1975. Additionally, compilers were available for the UNIVAC 1100 series and Control Data Corporation's CDC 6000 series and CDC 7000 series machines.
By this era, FORTRAN IV had become a prominent instructional tool; implementations such as University of Waterloo's WATFOR and WATFIV notably streamlined compilation processes.
In most FORTRAN IV environments—excluding CDC systems—only one statement per line was permitted; CDC systems allowed multiple statements separated by a character. The punched card format adhered to a four-field layout as standard.
Importantly, IBM "G" and UNIVAC compilers enabled inline comments distinguished by special delimiters—UNIVAC used a "master space" V character, while IBM utilized hexadecimal FF—although comments were disallowed within continuation cards.
FORTRAN 66
A significant development in FORTRAN’s evolution was the establishment of an American Standards Association committee (now known as the American National Standards Institute or ANSI), sponsored by the Business Equipment Manufacturers Association (BEMA), tasked with creating an American Standard Fortran. The standards ratified in March 1966 defined two languages: FORTRAN based on FORTRAN IV and Basic FORTRAN derived from FORTRAN II but stripped of machine-dependent features. This official standard X3.9-1966 became widely recognized as FORTRAN 66, marking the first industry-wide standardized version of FORTRAN.
Key features of FORTRAN 66 included:
- Support for main program units, , , and
- Data types such as , , , , and
- Statements including , , , , and
- The statement for initializing variables
- Built-in intrinsic functions alongside
- Assignment operations and control flow constructs encompassing various forms of IF and logical/arithmetic expressions
- Looping via
- Sequential input/output statements: , , , , and
- Statements
- Procedure invocation using , return via , and program control through and
- Use of Hollerith constants within data and format statements
- Identifiers restricted to six characters maximum
- Comment lines introduced by an
Adapting programs like Heron's example from Fortran II to compile under FORTRAN 66 requires updates such as substituting machine-specific versions of / with portable equivalents and removing redundant type conversions. Replacing arithmetic IF statements with logical IFs can also enhance code clarity.
<syntaxhighlight lang="fortranfixed"> C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION C INPUT - TAPE READER UNIT 5, INTEGER INPUT C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING
READ (5, 501) IA, IB, IC 501 FORMAT (3I5)
C C IA, IB, AND IC MAY NOT BE NEGATIVE OR ZERO C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE C MUST BE GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO
IF (IA .GT. 0 .AND. IB .GT. 0 .AND. IC .GT. 0) GOTO 10
WRITE (6, 602)
602 FORMAT (42H IA, IB, AND IC MUST BE GREATER THAN ZERO.)
STOP 1
10 CONTINUE
C
IF (IA+IB-IC .GT. 0
+ .AND. IA+IC-IB .GT. 0
+ .AND. IB+IC-IA .GT. 0) GOTO 20
WRITE (6, 603)
603 FORMAT (50H SUM OF TWO SIDES MUST BE GREATER THAN THIRD SIDE.)
STOP 1
20 CONTINUE
C C USING HERON'S FORMULA WE CALCULATE THE C AREA OF THE TRIANGLE
S = (IA + IB + IC) / 2.0
AREA = SQRT ( S * (S - IA) * (S - IB) * (S - IC))
WRITE (6, 601) IA, IB, IC, AREA
601 FORMAT (4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2,
+ 13H SQUARE UNITS)
STOP
END
</syntaxhighlight>
FORTRAN 77
Building upon the FORTRAN 66 specification, compiler developers introduced various extensions that prompted the ANSI committee X3J3, under CBEMA sponsorship, to update the standard in 1969. This effort culminated in the approval of FORTRAN 77 (X3.9-1978) in April 1978, which incorporated significant enhancements to overcome the shortcomings of FORTRAN 66:
- Introduction of block and end-block constructs with optional else and else if clauses to support structured programming paradigms
- Advanced DO loops capable of handling parameterized expressions, negative step values, and zero iteration counts
- Expanded input/output capabilities including new read, write, and print statements
- Support for direct-access file input/output operations
- Addition of the CHARACTER data type, replacing Hollerith strings and broadening character manipulation functionality
- PARAMETER statement for defining symbolic constants
- SAVE statement to maintain local variable values between procedure calls
- Generic intrinsic functions allowing multiple data types as arguments (e.g., abs accepting integer or real)
- Lexical string comparison intrinsics (such as compare, index, verify) following ASCII collating sequence, mandated by the U.S. Department of Defense
- Arrays extended to support up to seven dimensions along with generalized subscript expressions
Certain features from earlier standards were eliminated or modified due to incompatibility with existing programs, as ANSI had not yet adopted a formal deprecation policy. Notable removals included:
- Hollerith constants and data declarations (e.g., <syntaxhighlight lang="fortran" inline>GREET = 12HHELLO THERE!</syntaxhighlight>)
- Use of H edit descriptors within FORMAT statements for reading operations
- Accessing array elements beyond declared bounds (overindexing)
- Control flow transfers that jump into or out of DO loop bodies ("Extended Range")
A Fortran 77 adaptation of the Heron program runs seamlessly without changes from its Fortran 66 version but updates I/O operations by employing list-directed input/output and substitutes Hollerith format descriptors with quoted strings. It also replaces unstructured jumps with structured block constructs.
<syntaxhighlight lang="fortranfixed">
PROGRAM HERON
C COMPUTES THE AREA OF A TRIANGLE USING THE STANDARD SQUARE ROOT FUNCTION C INPUT - FROM DEFAULT STANDARD INPUT UNIT, INTEGER VALUES EXPECTED C OUTPUT - TO DEFAULT STANDARD OUTPUT UNIT, REAL NUMBER OUTPUT C INPUT ERRORS DISPLAY ERROR MESSAGE AND TERMINATE WITH CODE 1 IN JOB CONTROL LISTING
READ (*, *) IA, IB, IC
C C IA, IB, AND IC MUST BE POSITIVE NON-ZERO VALUES C ADDITIONALLY, THE SUM OF ANY TWO SIDES MUST EXCEED THE THIRD SIDE; THIS IS VERIFIED BELOW
IF (IA .LE. 0 .OR. IB .LE. 0 .OR. IC .LE. 0) THEN
WRITE (*, *) 'IA, IB, and IC must be greater than zero.'
STOP 1
END IF
C
IF (IA+IB-IC .LE. 0
+ .OR. IA+IC-IB .LE. 0
+ .OR. IB+IC-IA .LE. 0) THEN
WRITE (*, *) 'Sum of two sides must be greater than third side.'
STOP 1
END IF
C C CALCULATE THE TRIANGLE AREA USING HERON'S FORMULA
S = (IA + IB + IC) / 2.0
AREA = SQRT ( S * (S - IA) * (S - IB) * (S - IC))
WRITE (*, 601) IA, IB, IC, AREA
601 FORMAT ('A= ', I5, ' B= ', I5, ' C= ', I5, ' AREA= ', F10.2,
+ ' square units')
STOP
END</syntaxhighlight>
Transition to ANSI Standard Fortran
Efforts to create a successor standard to FORTRAN 77 encountered numerous delays as technological advancements in computing outpaced standardization processes. Despite this lag, FORTRAN 77 remained the predominant "Standard FORTRAN" language for close to fifteen years.
One important practical enhancement was MIL-STD-1753 (1978), established by the U.S. Department of Defense to formalize features commonly supported by FORTRAN 77 compilers but absent from the ANSI standard at that time. These additions were subsequently integrated into Fortran 90:
- INCLUDE and ENTRY statements
- ASSIGN statement
- Alternate RETURN mechanisms
- Bitwise manipulation intrinsic functions derived from Industrial Real-Time Fortran
The IEEE 1003.9 POSIX Standard (1991) facilitated FORTRAN 77 programs in invoking POSIX system calls by defining over one hundred standardized calls related to process management, signal handling, file and device control, procedure pointers, and stream input/output operations in a platform-independent manner.
Fortran 90
Serving as the much-anticipated update to FORTRAN 77, Fortran 90 (originally named Fortran 8X) was standardized under ISO/IEC 1539:1991 and later adopted as an ANSI standard in 1992. This version formally transitioned the language's name from FORTRAN to Fortran and incorporated significant advancements aligned with contemporary programming methodologies:
- Introduction of free-form source code input, removing the previous fixed-column limitations
- Support for lowercase keywords and identifiers extended to 31 characters, compared to the prior limit of six
- Addition of inline commenting capabilities
- Enhanced array handling enabling operations on entire or partial arrays, facilitating complex engineering calculations:
- Array assignments and expressions such as <syntaxhighlight lang="fortran" inline>X(1:N)=R(1:N)*COS(A(1:N))</syntaxhighlight>
- Conditional array assignments
- Array-valued constants, expressions, user-defined functions, and constructors
- Introduction of procedures
- Modules designed to encapsulate related procedures and data with controlled visibility
- Improved argument passing featuring compile-time interface validation
- Customizable interfaces supporting generic procedures
- Operator overloading capabilities
- Derived (structured) data types with more expressive declaration syntax
- Dynamic memory management through , , and
- Pointer facilities including , pointer assignment, and for managing dynamic data structures
- Structured looping constructs such as , , and
- Multi-branch selection using constructs
- Portable control over numerical precision
- A broad range of new and enhanced intrinsic functions
These enhancements established Fortran 90 as a flexible language well-suited for scientific and engineering tasks within modern computing contexts.
Obsolescence and deletions
Fortran 90 maintained full backward compatibility by retaining all features from earlier standards; any program compliant with FORTRAN 77 remained valid under Fortran 90. Nevertheless, a limited set of features were designated as "obsolescent," signaling their anticipated removal in subsequent revisions. These elements can be substituted with newer Fortran constructs, with some preserved temporarily to support legacy code migration but many eliminated in the Fortran 95 update.
| Feature marked obsolescent | Present status |
|---|---|
| Arithmetic IF statement | Obsolescent since F90; removed in F2018 |
| DO loop parameters or control variables that are non-integer | Obsolescent since F90; removed in F95 |
| Shared DO-loop termination or termination using statements other than END DO or CONTINUE | Obsolescent since F90; removed in F2018 |
| Branching to END IF from outside its block | Obsolescent since F90; removed in F95 |
| PAUSE statement | Obsolescent since F90; removed in F95 |
| ASSIGN statement and assigned GO TO statement | Obsolescent since F90; removed in F95 |
| Assigned statement numbers and FORMAT specifiers | Obsolescent since F90; removed in F95 |
| H edit descriptor | Obsolescent since F90; removed in F95 |
| Vertical format control | Removed in F2003 |
| Alternate return mechanism | Obsolescent since F90 |
| Computed GO TO statement | Obsolescent since F90 |
| Statement functions | Obsolescent since F90 |
| DATA statements within executable code sections | Obsolescent since F90 |
| Assumed length character functions | Obsolescent since F90 |
| Fixed form source code style | Obsolescent since F90 |
| CHARACTER* style declarations for CHARACTER type | Obsolescent since F90 |
| ENTRY statements | Obsolescent since F2008 |
| Label-based DO statements | Obsolescent since F2018 |
| COMMON and EQUIVALENCE statements along with BLOCK DATA units | Obsolescent since F2018 |
| Specific intrinsic function names | Obsolescent since F2018 |
| FORALL construct and statement | Obsolescent since F2018 |
Example: "Hello, World!"
<syntaxhighlight lang="fortran"> program helloworld
print *, "Hello, World!"
end program helloworld </syntaxhighlight>
Fortran 95
Fortran 95 (ISO/IEC 1539-1:1997) represented a modest update that resolved lingering issues from Fortran 90 and incorporated enhancements derived from the High Performance Fortran standard:
- Introduction of and nested structures to facilitate improved vectorization
- Support for user-defined and procedures
- Ability to assign default initial values to components of derived types, including pointers
- Broadened initialization expressions applicable to data objects
- Capability to initialize pointers with
- Automatic release of arrays once they go out of scope
The set of intrinsic functions was expanded, such as by adding a parameter to .
Several outdated features were eliminated:
- statements utilizing non-integer index variables
- Branching to from outside its defining block
- , , assigned , and assigned format specifiers
- Hollerith () edit descriptor
Important technical reports supplemented the standard, notably those enhancing allocatable arrays (Allocatable TR) which permitted their use within derived type components, as procedure arguments, and as function return types—thereby improving memory management and optimization compared to pointers. Another report introduced support for IEEE floating-point arithmetic and exception handling (IEEE TR).
Conditional compilation and variable-length strings
Alongside the compulsory "Base language" (ISO/IEC 1539-1:1997), Fortran 95 offered two optional modules:
- Variable-length character strings (ISO/IEC 1539-2:2000)
- Conditional compilation (ISO/IEC 1539-3:1998)
These components collectively form the multipart International Standard (ISO/IEC 1539).
While these optional modules cater to particular needs of users and implementers, they are not mandatory for all compilers claiming conformance. When implemented, adherence to the corresponding standard part is required.
Modern Fortran
The standards developed in the twenty-first century, especially those incorporating object-oriented programming capabilities and Coarray Fortran, define what is widely referred to as 'Modern Fortran.' This designation is increasingly prevalent within industry publications.
Fortran 2003
Fortran 2003 (ISO/IEC 1539-1:2004) brought substantial advancements, including:
- Enhancements to derived types such as parameterized types, refined accessibility controls, improved constructors, and finalizers
- Comprehensive object-oriented programming features: type extension, inheritance mechanisms, polymorphism, dynamic memory allocation, and type-bound procedures enabling abstract data types
- Improved data management: allocatable components within derived types, deferred parameters for types, introduction of the attribute, explicit typing for arrays during allocation, pointer enhancements, expanded initialization capabilities, and upgraded intrinsic functions
- Advances in input/output operations: asynchronous transfers, stream access modes, user-defined transfer procedures for derived types, control over rounding during format conversions, named constants for preconnected units, introduction of the statement, standardized keywords across I/O routines, and facilities for error message retrieval
- Addition of procedure pointers functionality
- Compliance with IEEE 754-2008 floating-point arithmetic standards including exception handling
- Enhanced interoperability with the C language
- Internationalization support featuring ISO 10646 four-byte character encoding and options for decimal or comma separators in numeric input/output
- Better integration with operating systems through access to command-line arguments, environment variables, and processor-generated error messages
A notable technical report supplement was ISO TR-19767: Enhanced module facilities in Fortran, which introduced sub-modules. These allow modular separation between interface declarations and implementation details—similar in concept to Modula-2 modules or Ada’s private child units—facilitating large-scale library development while protecting proprietary code interfaces and minimizing recompilation dependencies.
Fortran 2008
Ratified in September 2010 as ISO/IEC 1539-1:2010, Fortran 2008 represents a modest revision that refined and rectified aspects of Fortran 2003 while adding several new capabilities such as:
- Introduction of sub-modules to improve module organization, superseding ISO/IEC TR 19767:2005
- Implementation of Coarray Fortran to support parallel processing
- The DO CONCURRENT loop construct enabling independent iteration execution
- The CONTIGUOUS attribute to define memory layout explicitly
- The BLOCK construct facilitating scoped declaration blocks
- Recursive allocatable components providing an alternative to recursive pointers
The Final Draft International Standard (FDIS) is identified as N1830.
Additionally, ISO Technical Specification (TS) 29113, titled Further Interoperability of Fortran with C, submitted in May 2012, enhances the language’s compatibility with C by enabling array descriptor access and supporting more flexible argument typing.
Fortran 2018
Published on November 28, 2018, Fortran 2018—initially designated Fortran 2015—constitutes a major update that consolidates two earlier Technical Specifications:
- ISO/IEC TS 29113:2012 on extended interoperability with C
- ISO/IEC TS 18508:2015 introducing additional parallel programming features
Notable improvements include compliance with the ISO/IEC/IEEE 60559:2011 floating-point standard, support for hexadecimal input/output operations, enhancements to IMPLICIT NONE semantics, along with various other refinements.
The revision also eliminated outdated constructs such as the arithmetic IF statement, non-block DO loops, COMMON and EQUIVALENCE declarations, BLOCK DATA units, labelled DO loops, certain intrinsic function names, and the FORALL statement and construct—thereby streamlining the language for contemporary business applications.
Fortran 2023
The latest iteration, Fortran 2023 (ISO/IEC 1539-1:2023), released in November 2023 and accessible via ISO, constitutes a minor update to the Fortran 2018 standard. It primarily addresses corrections and omissions while introducing incremental features like support for enumerated types.
Language features
An extensive summary of Fortran 95’s language characteristics is available in a dedicated article. Subsequent editions, collectively termed 'Modern Fortran,' expand upon this base and are comprehensively documented.
Science and engineering
Although once described as "old-fashioned" in a 1968 publication, Fortran continues to serve as a cornerstone in scientific and engineering computation, with a vast array of software actively utilized today. Authorities such as Jay Pasachoff (1984) highlighted its critical importance in physics and astronomy education, while Cecil E. Leith (1993) referred to it as the "mother tongue of scientific computing," emphasizing its persistent prominence in the marketplace.
Fortran remains a preferred language for high-performance supercomputing applications across diverse domains including astronomy, climate simulation, computational chemistry, economics, fluid mechanics, physics modeling, data analytics, hydrology, numerical linear algebra (supported by libraries like LAPACK, IMSL, and NAG), optimization problems, satellite system modeling, structural engineering design, and meteorological forecasting. Numerous floating-point benchmark suites employed for processor evaluation—such as SPEC CFP2006 and CFP2017—are implemented in Fortran. Its mathematical algorithms are extensively documented in authoritative texts like Numerical Recipes.
In modern computational science workflows, extensive libraries such as METIS (for graph partitioning), PETSc and Trilinos (for linear algebra), along with deal.II or FEniCS (supporting mesh generation and finite element methods) are frequently utilized. Since the early 2000s, many auxiliary libraries have been developed using C or C++, while high-level languages including Wolfram Language, MATLAB, Python, and R have gained traction for specialized scientific tasks. To facilitate seamless integration with these environments, Fortran 2003 introduced foreign function interfaces compatible with C; this interoperability was further enhanced by incorporating ISO/IEC Technical Specification 29113 into the Fortran 2018 standard.
Portability
In the early stages, achieving portability was a major obstacle due to the absence of unified standards—IBM’s own reference manual lacked consistency, and vendors often differentiated their offerings through incompatible features. Although the 1966 standard established syntax and semantic rules, many suppliers continued to introduce extensions that were not compatible with one another. Experienced programmers understood that these extensions led to expensive portability complications and employed tools such as The PFORT Verifier to handle them. It was only after the 1977 standard, when the National Bureau of Standards (now NIST) released FIPS PUB 69, that processors used by the U.S. Government were mandated to detect these extensions. As a result, most compilers eventually incorporated options to identify such nonstandard additions.
Aside from incompatible extensions, numerical portability required attention to arithmetic behavior. The PORT library developed by Fox and colleagues addressed this within the framework of the 1966 standard, influencing features later integrated into the 1990 standard via intrinsic inquiry functions. The widespread adoption of the IEEE 754 specification for binary floating-point arithmetic has largely resolved these numerical portability concerns.
Accessing details about the computing environment—including command-line arguments, environment variables, and error messages—remained difficult until solutions appeared in the 2003 standard. Additionally, extensive engineering and scientific libraries predominantly written in C introduced portability obstacles; these were alleviated by adding C interoperability in the same 2003 update.
Currently, it is possible to develop fully portable Fortran applications without dependence on a preprocessor.
Obsolete variants
Prior to the Fortran 66 standard, individual compilers supported distinct Fortran dialects, some deviating significantly from mainstream versions.
The initial Fortran compiler emphasized execution efficiency, which made compiler creation complex and typically relegated to hardware manufacturers aiming to enhance their sales. This environment fostered a market for fast compilers with robust diagnostic capabilities designed for programmers, particularly students. Notable examples include Watfor, Watfiv, PUFFT, alongside smaller tools like FORGO, Wits Fortran, and Kingston Fortran 2.
Fortran 5, introduced by Data General during the 1970s and 1980s for its Nova, Eclipse, and MV series computers, featured an optimizing compiler well-tailored for minicomputers and bore close resemblance to FORTRAN 66.
FORTRAN V was released by Control Data Corporation in 1968 targeting the CDC 6600 series and was based on FORTRAN IV. Univac also offered a FORTRAN V compiler for its 1100 series machines; Athena FORTRAN derived from this implementation.
Vendor-specific variants produced by manufacturers of high-performance scientific computers such as Burroughs, CDC, Cray, Honeywell, IBM, Texas Instruments, and UNIVAC incorporated extensions exploiting hardware capabilities like instruction caches, CPU pipelines, and vector processing arrays. IBM’s H Extended IUP compiler optimized machine instructions to simultaneously utilize multiple arithmetic units. The CFD compiler was designed for NASA Ames Research Center’s ILLIAC IV supercomputer. IBM Research developed VECTRAN, an extended FORTRAN dialect tailored for vector and matrix computations.
Object-Oriented Fortran introduced features for grouping objects and supporting parallel execution; it ran on platforms including Solaris, IRIX, NeXTSTEP, iPSC, and nCUBE but is no longer maintained.
Most hardware-specific extensions have either disappeared or been absorbed into official standards; prominent exceptions include OpenMP, an extension supporting shared memory parallelism across platforms, and Coarray Fortran designed for parallel programming models.
FOR TRANSIT was a simplified IBM 704 FORTRAN subset implemented on the IBM 650 through a translator developed at Carnegie in the late 1950s. Due to hardware constraints, it imposed limitations but maintained compatibility with IBM 704 FORTRAN source code.
Permitted statements encompassed arithmetic assignments, various GO TO forms, IF conditions, DO loops, PAUSE/STOP commands, CONTINUE and END statements, READ/PUNCH operations, DIMENSION declarations, and EQUIVALENCE statements. Programs could contain up to ten subroutines.
FOR TRANSIT source code was restricted to columns 7–56 on punched cards. The translation process involved three stages: converting source code to IT language; compiling IT language into SOAP assembly language; then generating object code executed with punched cards used for input/output.
Two versions existed for IBM 650 machines equipped with 2000-word memory drums: FOR TRANSIT I (S) and FOR TRANSIT II (designed for machines featuring indexing registers and automatic floating-point decimal arithmetic). The manual also provided wiring diagrams for the IBM 533 card reader/punch control panel.
Fortran-derived languages
Prior to the introduction of FORTRAN 77, numerous preprocessors enhanced the language by enabling structured programming, supporting longer variable identifiers, introducing extra data types, allowing conditional compilation, and providing macro capabilities. Among the widely used preprocessors were EFL, FLECS, iftran, MORTRAN, SFtran, S-Fortran, Ratfor, and Ratfiv. For instance, EFL, Ratfor, and Ratfiv created C-like syntaxes that translated into standard FORTRAN 66 code. The PFORT preprocessor played a significant role in promoting code portability. Although the language itself evolved over time, preprocessors continue to be utilized for tasks such as conditional compilation and macro substitution.
During the 1960s, the University of Waterloo developed WATFOR based on FORTRAN IV, which gained broad acceptance in academic settings. WATFOR simplified the batch processing workflow by executing programs immediately if they were free of syntax errors, enabling students to concentrate on programming logic without dealing with job control or system intricacies. Despite its advantages, WATFOR had restricted input/output device access and was eventually replaced by WATFIV and subsequent iterations.
LRLTRAN originated at Lawrence Radiation Laboratory as an extension of Fortran that incorporated vector operations and dynamic memory management features suited for systems programming. This preprocessor was distributed alongside the Livermore Time Sharing System (LTSS).
The Fortran 95 Standard optionally includes a Part 3 specification called "CoCo," which introduces conditional compilation functionality. Additionally, many Fortran compilers incorporate portions of the C preprocessor to achieve similar effects.
SIMSCRIPT is a Fortran-based preprocessor specifically designed for modeling and simulating extensive discrete event systems.
The F programming language represents a simplified subset of Fortran 95 that removes obsolete and redundant features such as the EQUIVALENCE statement while maintaining array processing capabilities inherited from Fortran 90. It is aimed primarily at educational purposes and scientific computation with a compiled and structured design. Similarly, Essential Lahey Fortran 90 (ELF90) provided a comparable subset.
Lahey and Fujitsu jointly developed a version of Fortran compatible with the Microsoft .NET Framework. Silverfrost FTN95 also offers support for generating .NET-compatible code.
Code examples
The example below illustrates dynamic memory allocation alongside array operations introduced in Fortran 90. It notably avoids explicit loops or conditional branching by applying mathematical functions directly to arrays. This program calculates averages from user-input data.
<syntaxhighlight lang="fortran"> program average
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
if (number_of_points > 0) average_points = sum(points) / number_of_points 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.)
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)
end program average </syntaxhighlight>
Humor
At the FORTRAN standards committee session that officially designated "FORTRAN 77," a tongue-in-cheek proposal entitled "Letter O Considered Harmful" was circulated among attendees. This mock suggestion advocated for removing the letter "O" from variable identifiers—and even from the entire character set—to prevent confusion with the digit zero. The exaggerated rationale humorously claimed this would encourage structured programming by disallowing the use of the statement along with problematic statements. Although such a change could render some programs invalid, those were largely regarded as non-compliant anyway.
In discussions about DO loop iteration counts in Fortran 77, Loren Meissner wittily proposed setting the minimum number of loop executions to two, arguing that performing fewer than two iterations would defeat the fundamental purpose of looping.
When deciding on syntax for assumed-length arrays, a debate emerged over whether to use an asterisk ("*") or a colon (":") as the delimiter. Walt Brainerd humorously dubbed his commentary "Astronomy vs. Gastroenterology," reflecting the contrasting preferences.
In FORTRAN, variables beginning with letters I through N are implicitly typed as integers; all others default to real numbers unless explicitly declared otherwise. This led to the quip: "In FORTRAN, GOD is REAL (unless declared INTEGER)."
See also
Further reading
- Language standards
- Commonly referred to as FORTRAN 66.
- Also identified as ISO 1539–1980, informally called FORTRAN 77.
- Known informally as Fortran 90.
- Informally Fortran 95; Part 1 officially ratified by ANSI.
- Commonly called Fortran 2003.
- Often referred to as Fortran 2008.
- Related standards
- Additional references
- Books
- Arjen, Markus (2012), Modern Fortran in Practice, Cambridge University Press.
- Curcic, Milan, Modern Fortran: building efficient parallel applications, Manning Publications Company.
- Other volumes cover structured programming techniques, migration strategies, and scientific computing applications.
- Articles
- Allen, F.E. (September 1981), A History of Language Processor Technology in IBM
This carefully selected collection highlights essential standards, reference works, and authoritative literature valuable for enterprises utilizing Fortran in scientific research, engineering projects, and legacy system upgrades.
External links
- ISO/IEC JTC1/SC22/WG5—the official Fortran standards committee
- Fortran Standards Documents—documentation from GFortran
- fortran-lang.org (established 2020)
- History of FORTRAN and Fortran II—Computer History Museum
- Valmer Norrod et al.: A self-study course in FORTRAN programming—Volume I—textbook, Computer Science Corporation, El Segundo, California (April 1970)
- Valmer Norrod, Sheldon Blecher, and Martha Horton: A self-study course in FORTRAN programming—Volume II—workbook, NASA CR-1478 (April 1970)
- An introduction to the Fortran programming language, Reinhold Bader and Nisarg Patel, Leibniz Supercomputing Centre
- A coarray tutorial
- Victor Eijkhout: Introduction to Scientific Programming in C++17/Fortran2008, The Art of HPC, volume 3 (PDF)
- Articles with short description
- Fortran
- Fortran programming language family
- American inventions
- Array programming languages
- Computer standards
- Numerical programming languages
- Object-oriented programming languages
- Procedural programming languages
- High-level programming languages
- IBM software
- Programming languages created in 1957
- Programming languages with an ISO standard
- Statically typed programming languages
- Unix programming tools
- 1957 software
- Pages with reference errors