Fortran
Fortran is a general-purpose, imperative programming language designed primarily for numeric computation and scientific computing, featuring strong support for array operations, mathematical functions, and high-performance execution.[1] Developed by a team led by John Backus at IBM starting in 1954, it was the first high-level programming language, aimed at translating mathematical formulas into efficient machine code to simplify coding for scientists and engineers.[2] The initial version, known as Fortran I, was commercially released in 1957 as the IBM Mathematical Formula Translating System, with its first compiler delivered in April of that year after testing on the IBM 704 computer.[3][2]
The language's development addressed the limitations of early computers, where programming required low-level assembly code; Fortran reduced the effort dramatically, for example, condensing a problem that took about 1,000 assembly instructions into just 47 Fortran statements.[2] Key contributors included a diverse team of experts such as a crystallographer, cryptographer, and programmer Lois Haibt, who emphasized collaborative learning during the three-year project.[2] Fortran I introduced innovations like an optimizing compiler that produced code nearly as fast as hand-assembled programs, setting a precedent for modern compilers.[2] Subsequent versions, such as Fortran II (1958), expanded features like subroutines and input/output capabilities, while the language became a U.S. national standard by the mid-1960s.[2]
Over decades, Fortran has evolved through international standards set by ISO and the IEC, with the latest being Fortran 2023, which enhances parallelism through coarrays, teams, and collective operations for high-performance computing (HPC).[4] It supports multiple paradigms, including procedural, object-oriented, and functional programming, while remaining statically typed for reliability and efficiency.[1] Today, Fortran dominates in fields like weather forecasting, fluid dynamics, nuclear simulations, and supercomputer benchmarks, powering much of the world's scientific software due to its maturity and performance on parallel architectures.[1] Despite competition from newer languages, it continues to be actively developed and used in mission-critical applications, underscoring its enduring impact on computational science.[2][1]
History
Origins
Development of Fortran began in 1954 at IBM, led by John Backus, with the goal of creating a high-level programming language for the IBM 704 computer to automate mathematical computations that had previously required tedious assembly language programming.[2][5] This initiative addressed the pressing need for greater programming productivity in scientific research during the early computer era, where scientists and engineers often relied on professional programmers to translate formulas into machine code, leading to significant delays and errors.[6][2]
The design principles emphasized a language tailored for scientific programming, prioritizing readability—through algebraic notation resembling mathematical expressions—and efficiency in generated code, while abstracting away machine-specific details to make it more accessible than low-level alternatives.[2][5] Backus's team adopted a fixed-form layout based on 72-column punched cards, where specific columns designated continuation lines (column 6), statement labels (columns 1-5), and comments (column 7 with a C), facilitating input on the era's hardware while enforcing structured code organization.[2]
Key innovations in the initial implementation included automatic memory allocation for variables and expression evaluation that handled arithmetic operations without requiring programmers to manage registers manually, marking a significant departure from assembly practices.[2][5] The first compiler was completed in 1957, releasing the initial version known as FORTRAN (short for Formula Translation), which dramatically reduced programming effort—for instance, translating a 1,000-line assembly routine into just 47 lines of Fortran code.[6][2]
Early Development
Following the release of FORTRAN I, IBM introduced FORTRAN II in 1958, which significantly enhanced support for larger programs through features like separate compilation of subroutines, linking of relocatable binary modules, and overlay structures to manage memory efficiently.[7] These additions allowed programmers to modularize code, compile subroutines independently while retaining symbolic information, and combine FORTRAN and assembly components via a binary symbolic subroutine loader, addressing the limitations of monolithic compilation in earlier versions.[7][8]
FORTRAN III, also developed in 1958 and released on a limited basis to approximately 20 installations (primarily IBM sites), extended these capabilities by incorporating support for complex data types and basic input/output operations, including enhanced I/O with alphanumeric handling via a new FORMAT code "A" for mixed symbolic and FORTRAN statements.[7] However, its compiler proved overly complex due to heavy reliance on machine-specific features of the IBM 704, leading to a short lifespan and minimal adoption before development shifted focus.[7][8]
By 1961-1962, FORTRAN IV emerged as a more portable iteration, expanding compatibility across diverse machines and introducing Boolean expressions through the logical IF statement, alongside improved error handling and diagnostics to aid program reliability.[8] This version also added debugging tools, such as better trace facilities, and expanded library functions available on tape (e.g., SQRTF for square roots), facilitating broader use in scientific computing.[7] Key events included rapid adoption by vendors like Univac (for the Solid-State 80) and CDC (for the 1604) starting in 1961, which helped propagate the language beyond IBM systems.[9]
Throughout this period, developers faced challenges in balancing portability with machine-specific optimizations, particularly as hardware transitioned from vacuum tube-based systems like the IBM 704 to transistorized architectures such as the IBM 709, which demanded adjustments for differing word lengths, memory constraints, and I/O mechanisms.[7][8] These evolutions from FORTRAN I's fixed layout laid the groundwork for more robust programming practices.[7]
Standardization
The formal standardization of Fortran commenced in the mid-1960s amid growing concerns over inconsistencies across vendor implementations of FORTRAN IV, which featured varying interpretations of syntax and semantics. The American Standards Association (ASA), predecessor to the American National Standards Institute (ANSI), established the X3J3 committee to address these ambiguities and create a unified specification. This work resulted in the first official standard, FORTRAN 66 (ANSI X3.9-1966), published on March 7, 1966, which defined a core language for enhanced portability by stripping away many machine-dependent vendor extensions while retaining essential elements like program units (main, SUBROUTINE, FUNCTION, BLOCK DATA), data types (INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL), and statements for control flow, arrays, and I/O.[10][11]
FORTRAN 66 marked the first programming language to achieve formal standardization, earning international recognition through adoption by the International Organization for Standardization (ISO) shortly thereafter. By focusing on a minimal, consistent subset derived from FORTRAN IV, the standard promoted interoperability across diverse computing environments, though it drew criticism for its austerity, such as the absence of advanced features like formatted I/O enhancements present in some proprietary dialects. The X3J3 committee's efforts ensured that compilers adhering to this specification could produce portable code, significantly reducing the fragmentation that had plagued earlier Fortran variants.[12][13]
As computational needs evolved, the X3J3 committee initiated revisions in the early 1970s to incorporate structured programming constructs without sacrificing compatibility. This culminated in Fortran 77 (ANSI X3.9-1978), approved in April 1978 and also adopted by ISO, which extended the language with features including the block IF statement for improved control flow, the CHARACTER data type for string handling, parameterized DO loops, and direct-access I/O for efficient file operations. Debates within the committee highlighted tensions between advocates for fuller structured programming paradigms—such as eliminating GOTO statements—and proponents of backward compatibility to support the vast existing codebase, ultimately favoring a conservative approach that made Fortran 77 a superset of FORTRAN 66.[14][15]
Fortran 77 rapidly achieved dominance as the de facto global standard for scientific computing, with widespread implementation in compilers by major vendors and integration into educational curricula and industrial workflows through the 1980s. Its standardization fostered reliability in numerical applications, enabling consistent performance across platforms and solidifying Fortran's role in high-performance computing until subsequent revisions.[16]
Fortran 90 and 95
Fortran 90, formally known as ISO/IEC 1539:1991, represented a major revision of the language, developed by the ANSI X3J3 subcommittee (now INCITS J3) in collaboration with the international ISO/IEC JTC1/SC22/WG5 working group during the 1980s.[17] This effort aimed to modernize Fortran by incorporating structured programming elements, such as modules for data encapsulation and improved array handling, while ensuring full backward compatibility with Fortran 77 to preserve existing codebases in scientific and engineering applications.[18] The standard was published in 1991 after extensive deliberation to balance innovation with reliability, addressing limitations in earlier versions like fixed-form source code and static memory allocation.[19]
Key innovations in Fortran 90 included free-form source code, which allowed statements to span multiple lines without column restrictions, enhancing readability and reducing errors from punched-card era constraints.[20] Modules provided a mechanism for organizing code into reusable units, encapsulating data types, variables, and procedures to promote modularity; for example, a module might define a type and associated operations accessible via USE statements in other programs.[21] Dynamic memory management was introduced through the ALLOCATE and DEALLOCATE statements, enabling runtime allocation of arrays whose sizes were determined during execution, such as ALLOCATE(A(10)) for a one-dimensional array.[22] Recursive procedures were permitted, allowing functions to call themselves, which facilitated more elegant solutions to problems like tree traversals. To streamline the language, several outdated features from Fortran 77 were designated obsolescent, including Hollerith constants for character data and the EQUIVALENCE statement for overlaying storage, signaling their potential removal in future standards.[23]
Fortran 95, defined by ISO/IEC 1539-1:1997, built on Fortran 90 with minor refinements and was published in 1997 as a technical corrigendum and extension, maintaining compatibility while addressing practical needs in high-performance computing.[24] Notable additions included the FORALL construct for concurrent array assignments without dependencies, improving expressiveness for vectorized operations, as in FORALL (I=1:N) A(I) = B(I) + C(I).[24] PURE procedures were introduced to denote functions without side effects, enabling compiler optimizations and safer use in parallel contexts.[25] Conditional compilation via directives in ISO/IEC 1539-3:1997 allowed source code variants for different platforms, such as #ifdef blocks for architecture-specific code.[26] Minor enhancements supported varying-length character strings through adjustable bounds. This revision also deleted obsolescent features from Fortran 90, such as Hollerith constants and EQUIVALENCE, to simplify the language core.[23]
The introduction of these features in Fortran 90 and 95 marked a pivotal shift, revitalizing the language for modern scientific computing by supporting larger, more maintainable codebases and leveraging emerging hardware capabilities like vector processors.[27] This overhaul facilitated Fortran's continued dominance in numerical simulations and research, with widespread adoption in academic and national laboratory environments.[28]
Modern Revisions
The modern revisions of Fortran, beginning with the 2003 standard, have introduced advanced language capabilities to address evolving demands in high-performance computing, object-oriented design, and interoperability with other languages. These updates build on the foundational modernizations of Fortran 90 and 95 by incorporating features for parallelism, safety, and integration with contemporary software ecosystems. Published as ISO/IEC 1539-1:2004, Fortran 2003 marked a significant expansion, adding support for object-oriented programming through classes, inheritance, and polymorphism via type-bound procedures and dynamic dispatch. It also introduced interoperability with C via the ISO_C_BINDING module, enabling seamless calling of C functions and data sharing, which facilitates integration with libraries written in other languages. Additionally, parameterized derived types were added, allowing generic programming by parameterizing type definitions at compile time.[29]
Fortran 2008, formalized in ISO/IEC 1539-1:2010, further enhanced modularity and performance for large-scale applications. A key addition was submodules, which extend modules by providing a hierarchical structure for private implementation details without exposing them to users, improving code organization and encapsulation. Parallel I/O capabilities were introduced through enhancements to the OPEN and INQUIRE statements, supporting collective file operations across multiple processes to optimize data handling in distributed environments. The standard also expanded intrinsic functions for mathematical operations, including complex number support and improved bitwise operations, to better serve numerical computations.[30]
The Fortran 2018 revision, published as ISO/IEC 1539-1:2018, emphasized concurrency and robustness in response to multi-core architectures and high-performance needs. It expanded the DO CONCURRENT construct from Fortran 2008, adding support for reduction clauses and local initialization to enable more efficient loop-level parallelism without data races. Coarray teams were introduced, allowing dynamic creation and management of groups of images for scalable parallel execution, building on the coarray model for partitioned global address space programming. Error handling was improved with the introduction of the STOP statement's error code support and enhanced ALLOCATE failure options, promoting safer program execution.[31]
Fortran 2023, released as ISO/IEC 1539-1:2023, focuses on enhanced expressiveness, safety, and further interoperability to meet modern development practices. It introduces enumerated types (ENUMs) for defining named constants, reducing errors in code that relies on integer flags. A standardized preprocessor with directives for conditional compilation and macro-like expansions was added, improving portability across compilers that previously relied on non-standard tools like cpp. C interoperability was extended with features such as improved pointer handling and value types, streamlining mixed-language projects. These changes prioritize performance optimizations, like longer source lines and automatic reallocation for character variables, while addressing security concerns through obsolescence of vulnerable features.[4]
The evolution of Fortran's standardization process reflects a shift toward greater international collaboration. Originally managed by the U.S.-based INCITS J3 committee (formerly X3J3), development now involves ISO/IEC JTC1/SC22/WG5, which coordinates input from national bodies worldwide to ensure global applicability. This structure has enabled responses to demands from high-performance computing and multi-core systems, with features like coarrays and teams directly addressing scalability in parallel environments.[12][32] As of 2025, work is underway on the next revision, tentatively Fortran 2025, with ongoing meetings and work item lists developed by WG5.[32]
Language Features
Syntax and Layout
Fortran's syntax and layout have evolved significantly since its inception, transitioning from rigid, column-based formatting suited to punched-card input to more flexible structures that accommodate modern text editors and development practices. The language defines two primary source forms: fixed form, which was the sole format in early standards like Fortran 77, and free form, introduced in Fortran 90 to enhance readability and portability.[33][34] These forms govern how source code lines are structured, including positioning of statements, comments, and continuations, while maintaining compatibility across implementations.
In fixed form, source code adheres to a strict 72-column layout derived from 80-column punched cards, where positions 1 through 5 are reserved for optional statement labels (numeric identifiers for branching), position 6 indicates line continuation with any non-blank character (often '0' through '5'), and positions 7 through 72 contain the actual code.[33] Positions 73 through 80, if present, are ignored as optional sequence numbers. Comments in fixed form begin with 'C', 'c', '*', or '!' in column 1, extending to the end of the line, and statements must start in column 7 or later unless labeled.[34] Continuation lines are limited to a maximum of 19 in practice for many compilers, though the standard permits up to 255, and blank characters in column 6 signal the start of a new statement.[33] This format, while obsolescent since Fortran 95, remains supported for legacy code portability.[33]
Free form, the default since Fortran 90, removes column restrictions, allowing code to begin anywhere on a line up to a maximum of 132 characters (extendable by processors).[33][34] Statements can span multiple lines via an ampersand (&) as the last non-blank character before any comment or end-of-line, with an optional leading & on the continuation line for clarity; up to 255 such continuations are allowed.[33] Comments start with '!' anywhere on the line and extend to the end, enabling inline annotations without disrupting layout.[34] Semicolons may separate multiple statements on a single line in free form, though they are optional at the end, and block constructs like programs or subroutines require explicit END statements to terminate.[33]
Fortran keywords and identifiers are case-insensitive throughout both forms, treating variants like "PROGRAM" and "program" as identical, which simplifies code but requires careful naming to avoid unintended matches in mixed-case environments.[33][34] This feature, consistent since the language's early days, applies to all lexical tokens except character literals.[33]
The evolution from fixed to free form reflects Fortran's adaptation to computing advancements, moving away from the punched-card era's constraints—where early programs like those on IBM 704 systems demanded precise columnar alignment—to editor-friendly formats that support indentation for readability without altering semantics.[33] Fixed form has been obsolescent since Fortran 95 but remains supported for backward compatibility in modern standards, allowing mixed use via compiler directives or file extensions (e.g., .f for fixed, .f90 for free).[34]
For example, a simple assignment in fixed form might appear as:
while in free form, it could be indented and annotated:
x = 1.0 ! Initialize variable
x = 1.0 ! Initialize variable
Both execute identically due to case insensitivity and layout flexibility in the latter.[34]
Data Types and Declarations
Fortran supports five intrinsic data types: integer for whole numbers, real for floating-point values, complex for numbers with real and imaginary parts, logical for boolean values, and character for strings.[35] These types can be specified with a kind parameter to control storage size and precision, which is processor-dependent but often follows common conventions such as INTEGER(KIND=4) for 32-bit integers or REAL(KIND=8) for double-precision floating-point with approximately 15 decimal digits of precision.[36] For example, the declaration integer(kind=4) :: i allocates a 32-bit signed integer variable, while real(kind=8) :: x = 3.14159 declares a double-precision real.[35]
Variables in Fortran must be declared explicitly when using the IMPLICIT NONE statement, which disables the default implicit typing rules (where variables starting with I-N are integers and others reals) and is recommended for all modern code to enhance type safety and prevent errors.[37] Declarations follow the syntax type-specifier :: variable-list, such as integer :: count, index or character(len=20) :: name.[38] Constants are defined using the PARAMETER attribute, ensuring their values cannot be modified at runtime; for instance, real, parameter :: pi = 3.1415926535 creates an unchangeable double-precision constant.[39]
Introduced in Fortran 90, derived types allow users to create composite data structures by combining intrinsic or other derived types as components, enabling encapsulation similar to records or structs in other languages.[40] A derived type is declared using the TYPE construct, such as:
type :: point
real :: x, y
end type point
type :: point
real :: x, y
end type point
This defines a type with two real components, which can then be instantiated as type(point) :: origin and accessed via origin%x = 0.0.[40] Components support initialization, either at declaration (e.g., real :: z = 0.0 within the type) or via structure constructors like type(point)(1.0, 2.0).[40]
For dynamic memory management, Fortran provides the allocatable and pointer attributes, both introduced in Fortran 90 to support flexible storage allocation without fixed sizes at compile time.[41] The allocatable attribute applies to variables or components, allowing runtime allocation via the ALLOCATE statement; for example, real, allocatable :: array(:) declares a one-dimensional allocatable array, which can be sized with allocate(array(100)).[41] Allocatable entities are automatically deallocated when out of scope, promoting safer memory handling compared to static arrays.[42]
The pointer attribute designates variables that reference (or "point to") other data objects, useful for linked structures or aliasing; declaration uses type, pointer :: var, and association occurs via => in statements like allocate(target); var => target.[43] Pointers must target entities with the TARGET attribute if needed, and they support dynamic polymorphism but require explicit nullification to avoid dangling references.[43]
Fortran 2003 extended derived types with object-oriented features, including type-bound procedures that bind specific subroutines or functions directly to a type, facilitating encapsulation and polymorphism.[44] These are declared after the CONTAINS statement within a type definition, such as:
type :: vector
real :: components(3)
contains
procedure :: norm => vector_norm
end type vector
type :: vector
real :: components(3)
contains
procedure :: norm => vector_norm
end type vector
This allows invoking the bound procedure as vec%norm(), where vector_norm is an external subroutine, integrating behavior with data in an OOP manner without global procedure calls.[44] Type-bound procedures support generics and finalizers for cleanup, enhancing modularity in complex simulations.[44]
Control Structures
Fortran's control structures have evolved significantly since the language's inception, transitioning from unstructured branching mechanisms to modern, structured constructs that promote readability and maintainability. The original Fortran (1957) featured the arithmetic IF statement, which conditionally transferred control to one of three labels based on whether an arithmetic expression evaluated to negative, zero, or positive, reflecting the era's reliance on unconditional GOTO statements for flow control.[45] This approach, while efficient for early compilers, led to "spaghetti code" issues, prompting later revisions to introduce more disciplined alternatives.[45]
The Fortran 77 standard marked a pivotal shift toward structured programming by introducing the block IF construct, which allowed multi-line conditional blocks with ELSE and ELSE IF clauses, replacing much of the need for arithmetic IF (now deprecated but still supported for legacy code).[46] The block IF syntax is:
IF (logical-expression) THEN
block
[ELSE IF (logical-expression) THEN
block
]...
[ELSE
block
]
END IF
IF (logical-expression) THEN
block
[ELSE IF (logical-expression) THEN
block
]...
[ELSE
block
]
END IF
This enables chains of ELSE IF for handling multiple conditions, evaluating the logical expression (using relational operators like ==, /=, <, >, <=, >=) sequentially until a true branch is found or the ELSE executes.[47]
Looping constructs began with the indexed DO loop in early Fortran, specifying fixed iteration bounds and an optional step, as in DO i = 1, 10 or DO i = 1, 10, 2 for even increments.[45] Fortran 77 formalized this as a block construct (END DO), preventing unstructured entry or exit except via transfers like GOTO (discouraged). The DO WHILE loop, added in Fortran 90, supports condition-based iteration without a predefined counter: DO WHILE (logical-expression) ... END DO, repeating until the expression is false.[20] Fortran 2008 introduced DO CONCURRENT for expressing independent iterations amenable to parallel execution, though its core sequential semantics align with traditional loops; parallel aspects are detailed elsewhere.
The SELECT CASE construct, introduced in Fortran 90, provides efficient multi-way branching on a scalar expression, akin to a switch statement, avoiding lengthy IF-ELSE IF chains for discrete values.[20] Its syntax is:
SELECT CASE (expression)
CASE (case-value-list)
block
[CASE DEFAULT
block
]
END SELECT
SELECT CASE (expression)
CASE (case-value-list)
block
[CASE DEFAULT
block
]
END SELECT
Case values can be constants, ranges (e.g., 1:5), or defaults, with the first matching case executing; the expression must be integer, logical, character, or compatible.[48]
For finer loop control, Fortran 90 added EXIT and CYCLE statements, applicable to any enclosing DO construct (including named ones for nesting). EXIT terminates the loop immediately, transferring control to the statement after END DO, as in IF (condition) [EXIT](/page/Exit) to break early.[20] CYCLE skips the remaining statements in the current iteration, advancing to the next, useful for filtering, e.g., IF (i > 5) [CYCLE](/page/Cycle) to ignore later values.[20] These enhancements, building on Fortran 77's foundations, ensure robust, structured flow control across revisions.[47]
Procedures and Modules
In Fortran, procedures provide a mechanism for modularizing code through subroutines and functions. Subroutines are invoked using the CALL statement and perform actions without returning a value directly, while functions are invoked within expressions or assignments and return a computed value via the RESULT clause or the function name.[49] This distinction allows subroutines to handle side effects like input/output or state modifications, whereas functions emphasize pure computations.[17]
Dummy arguments in procedures specify the interface for actual arguments passed from the caller. By default, Fortran passes arguments by reference, meaning the procedure receives a pointer to the actual argument's storage, allowing modifications to propagate back to the caller.[50] The INTENT attribute, introduced in Fortran 90, clarifies the usage intent of dummy arguments to aid optimization and error detection: INTENT(IN) indicates input-only arguments that cannot be modified; INTENT(OUT) specifies output arguments whose initial values are undefined and must be defined before use; INTENT(INOUT) allows both input and output, with the argument modifiable and its initial value preserved.[50] For example, in a subroutine printing a matrix:
fortran
subroutine print_matrix(n, m, A)
[integer](/page/Integer), intent(in) :: n, m
real, intent(in) :: A(n, m)
! Printing logic here
end subroutine print_matrix
subroutine print_matrix(n, m, A)
[integer](/page/Integer), intent(in) :: n, m
real, intent(in) :: A(n, m)
! Printing logic here
end subroutine print_matrix
Here, n and m are inputs, and A is read-only. Fortran 2003 introduced the VALUE attribute for scalar dummy arguments in procedures with explicit interfaces and the BIND(C) attribute, enabling pass-by-value semantics where a local copy is made, isolating changes from the caller—primarily for C interoperability.[29]
Modules, added in Fortran 90, encapsulate data and procedures to promote reusability and namespace management. A module declares entities with PUBLIC or PRIVATE access specifiers: PUBLIC entities are accessible outside the module, while PRIVATE ones are hidden, enforcing encapsulation.[51] The CONTAINS statement within a module defines internal procedures, and the USE statement imports module entities into a program unit, optionally with ONLY to limit imports. For instance:
fortran
module math_utils
implicit none
private
public :: vector_norm
contains
function vector_norm(n, vec) result(norm)
integer, intent(in) :: n
real, intent(in) :: vec(n)
real :: norm
norm = sqrt(sum(vec**2))
end function vector_norm
end module math_utils
module math_utils
implicit none
private
public :: vector_norm
contains
function vector_norm(n, vec) result(norm)
integer, intent(in) :: n
real, intent(in) :: vec(n)
real :: norm
norm = sqrt(sum(vec**2))
end function vector_norm
end module math_utils
This module exports only vector_norm, keeping internal details private. USE math_utils; then invokes vector_norm(5, v) in the main program.[49]
Recursion became supported in Fortran 90 via the RECURSIVE prefix on SUBROUTINE or FUNCTION statements, allowing a procedure to invoke itself directly or indirectly, with local variables allocated on the stack per call.[52] Prior standards prohibited recursion to simplify storage management. Procedure interfaces, also from Fortran 90, enable overloading through generic INTERFACE blocks, where a single name resolves to specific procedures based on argument types, ranks, or kinds—distinguishing calls without ambiguity. For example, a generic norm could overload for scalars, vectors, and matrices via an INTERFACE norm with multiple specific bindings.[53]
Fortran 2008 extended modules with submodules, which nest under a parent module or another submodule to organize implementations separately from interfaces. A submodule provides definitions for procedures declared in its ancestor, accessing ancestor's entities via host association without USE, and supports descendant submodules for hierarchical structures. This facilitates large-scale projects by reducing recompilation dependencies and isolating implementation details, as SAVE is implicit for entities. For example, a parent module declares a procedure interface, while a submodule supplies its body, enhancing modularity without exposing internals.[54]
Arrays and Parallelism
Fortran arrays have evolved significantly since the language's inception, transitioning from static, fixed-size declarations in early standards like Fortran 77 to dynamic allocatable arrays introduced in Fortran 90, which allow runtime dimensioning via the ALLOCATABLE attribute. This progression culminated in advanced parallel features in later revisions, such as assumed-rank arrays in Fortran 2018, enabling flexible handling of arrays of varying ranks without explicit rank specification. These developments reflect Fortran's adaptation to scientific computing needs, emphasizing efficiency in memory usage and parallelism for high-performance applications.[55]
Arrays in Fortran are declared using a type specifier followed by dimensions in parentheses, as in REAL :: A(10) for a one-dimensional array of ten real numbers, with indices starting at 1 by default and support for custom lower bounds like REAL :: B(-5:5). Whole-array operations permit concise element-wise computations without loops, such as A = B + C or assignment of constants like A = 0.0, leveraging the language's array-centric design for vectorizable code. Array slicing further enhances manipulation, allowing sections like A(1:5) for the first five elements, A(1:10:2) for every other element, or multidimensional slices like Matrix(:, 1) for an entire column, all without data copying in many cases.[56]
Intrinsic functions underpin efficient array processing and automatic vectorization by compilers. The SUM function reduces an array to its scalar sum or along a dimension, as in total = SUM(A), promoting rank reduction for multidimensional arrays. Similarly, MATMUL handles matrix multiplication for compatible rank-1 or rank-2 arrays, treating vectors appropriately as rows or columns and supporting logical operations with .AND., which compilers optimize for SIMD instructions.[57]
Parallelism at the array level began with the FORALL construct in Fortran 90, a non-iterative generalization of masked array assignments that specifies independent element operations executable in any order, facilitating compiler-directed parallelism without explicit threading. This was introduced alongside the DO CONCURRENT construct in Fortran 2008, which structures loops for potential concurrent iteration execution across threads or devices, assuming no inter-iteration dependencies to enable safe parallelization, as in DO CONCURRENT (i=1:100) A(i) = B(i) + C(i).[58][59]
Fortran 2008 introduced coarrays for distributed-memory parallelism in a single-program multiple-data (SPMD) model, where arrays are declared with a codimension section like REAL :: X(100)[*] to replicate across images (processing units). Remote data access uses square-bracket notation, such as X = Y[2] to copy from image 2, with each image maintaining private memory copies. Synchronization ensures consistency via constructs like SYNC ALL for global barriers or SYNC IMAGES(img) for specific images, supporting scalable parallel algorithms with minimal code changes.[60]
Applications
Scientific Computing
Fortran has been foundational in numerical weather prediction since its inception, enabling the implementation of complex mathematical models for atmospheric simulations. Developed in the mid-1950s to address the computational demands of scientific calculations, Fortran facilitated the first successful numerical forecasts by handling iterative solutions to partial differential equations that describe weather dynamics. Today, major operational models, such as those used by the National Oceanic and Atmospheric Administration (NOAA), continue to rely on Fortran for core numerical routines due to its proven reliability in processing vast meteorological datasets.[2][61]
In quantum chemistry, Fortran powers key software packages like Gaussian, which performs high-accuracy ab initio computations to predict molecular geometries, energies, and spectra. These tools leverage Fortran's robust support for intricate algorithms involving electron correlations and basis set expansions, essential for advancing chemical research. Similarly, early adoption in physics at Los Alamos National Laboratory involved Fortran-based codes for simulating nuclear processes and particle transport, where the language's efficiency supported critical national security applications during the Cold War era. A 2023 Los Alamos report highlights that many such legacy physics codes remain in active use, underscoring Fortran's enduring role in high-stakes simulations.[62][63]
Fortran's integration with libraries like BLAS (Basic Linear Algebra Subprograms) and LAPACK (Linear Algebra Package) enhances its utility in scientific computing by providing optimized Fortran routines for vector and matrix operations, which are ubiquitous in data analysis and modeling. These libraries enable efficient solving of linear systems and eigenvalue problems, forming the backbone of algorithms in fields ranging from physics to biology. In biological simulations, for example, Fortran programs such as BIOTURB model bioturbation effects on sediment distributions, while others simulate protein dynamics and genetic evolution, demonstrating the language's versatility in handling stochastic processes and large-scale biomolecular data.[64][65][66]
A primary advantage of Fortran in scientific contexts is its precise control over numerical representations, supporting data types from single to quadruple precision to mitigate errors in extended computations involving floating-point operations. Complementing this, Fortran's native I/O facilities excel at managing large datasets through unformatted binary transfers, which minimize overhead and support direct access for terabyte-scale simulation outputs. As of 2025, Fortran dominates open-source scientific software ecosystems, with its popularity surging in numerical and data-intensive applications and ongoing adoption in peer-reviewed research tools.[67][68][69][70]
Engineering and Simulation
Fortran has been instrumental in engineering simulations since the mid-20th century, particularly in finite element analysis (FEA) for structural integrity and computational fluid dynamics (CFD) for aerodynamic and hydrodynamic modeling. Its robust numerical capabilities enable engineers to solve complex partial differential equations that govern physical phenomena in materials under stress or fluids in motion. Key software packages developed in Fortran exemplify this role; for instance, NASTRAN, originally created by NASA in the late 1960s, remains a cornerstone for multidisciplinary structural analysis, performing static, dynamic, and thermal simulations on aerospace components.[71] In CFD, Fortran-based solvers like NASA's FUN3D and CFL3D facilitate high-fidelity simulations of viscous flows around aircraft and vehicles, leveraging the language's efficiency in handling large-scale matrix operations.[72]
Fortran's built-in support for complex data types is particularly valuable in electrical engineering simulations, where it models impedance and phasor representations in circuit analysis and electromagnetic field computations. For example, complex numbers allow direct manipulation of AC signals without decomposing into real and imaginary components manually, streamlining simulations of power systems and antennas. Additionally, Fortran's double precision arithmetic, which provides up to 15-16 decimal digits of accuracy, is essential for maintaining precision in iterative solvers common to engineering models, reducing rounding errors in stress-strain calculations or turbulence modeling.[73][74]
In industry applications, Fortran powers critical simulations in aerospace, where NASA continues to rely on legacy Fortran codes for mission-critical analyses like orbital mechanics and re-entry dynamics. In the automotive sector, tools such as PAM-CRASH utilize Fortran for explicit finite element crash simulations, predicting vehicle deformation and occupant safety during high-speed impacts. These examples highlight Fortran's enduring impact on design validation, enabling virtual prototyping that minimizes physical testing costs.
The evolution of Fortran in engineering traces back to the 1960s, when it supported batch-processed simulations on mainframes for early FEA and CFD prototypes, often integrated with nascent numerical control systems. By the 1970s and 1980s, advancements in Fortran standards allowed seamless incorporation into computer-aided design (CAD) environments, facilitating interactive modeling of complex geometries. As of 2025, Fortran persists in engineering through legacy systems wrapped in modern interfaces, such as Python or C++ bindings, ensuring compatibility with contemporary workflows while preserving validated simulation accuracy.[2][75]
Fortran has maintained a prominent role in high-performance computing (HPC), particularly on supercomputers listed in the TOP500 rankings, where it powers many scientific simulations due to its optimized handling of numerical computations and array operations. For instance, the Frontier supercomputer at Oak Ridge National Laboratory, ranked second on the TOP500 list as of June 2025 with a performance of 1.353 exaFLOPS, extensively utilizes Fortran-based codes for applications such as climate modeling through the Energy Exascale Earth System Model (E3SM). In E3SM, Fortran components enable high-resolution simulations of atmospheric and oceanic processes, achieving record performance metrics like 1.26 simulated years per day on Frontier's cloud-resolving configurations. This dominance stems from Fortran's legacy in legacy codes and its efficiency in vectorized operations, making it a staple for workloads that constitute a significant portion of supercomputer runtime in fields like earth system modeling.[76]
Fortran integrates seamlessly with parallel processing frameworks essential for distributed and shared-memory computing in HPC environments. The Message Passing Interface (MPI) and OpenMP are widely adopted for Fortran applications, enabling scalable distributed-memory parallelism across clusters and node-level thread-based acceleration, respectively; hybrid MPI-OpenMP approaches have demonstrated performance gains in exascale prototypes by combining inter-node communication with intra-node vectorization. As a native alternative, Fortran's coarray feature, introduced in the 2008 standard, supports partitioned global address space programming without external libraries, offering simpler syntax for parallel data sharing in multi-node setups. These integrations allow Fortran codes to exploit the heterogeneous architectures of modern supercomputers effectively.
Compilers such as those from HPE Cray and Intel provide advanced optimizations tailored for HPC, particularly in automatic vectorization, which enhances performance on vector processors and SIMD units by transforming scalar loops into vector instructions. For example, Cray's vectorization options, including the -O vector n flag, can yield significant speedups in array-heavy computations with minimal code changes, while Intel's Fortran compiler uses directives like !DIR$ IVDEP to guide aggressive vectorization, achieving up to several-fold improvements in benchmarks on multi-core systems. Studies comparing these compilers on HPC mini-applications have shown Cray and Intel achieving high vectorization rates, often exceeding 80% efficiency on relevant workloads.
In recent exascale developments, Fortran continues to adapt for systems like Aurora at Argonne National Laboratory, which entered production in early 2025 using Intel Xeon Max and Data Center GPU Max processors and is ranked third on the TOP500 list as of November 2025 with 1.012 exaFLOPS; preparation efforts emphasize Fortran compatibility via OpenMP offloading for GPU acceleration. Tools like Caffeine extend Fortran's parallelism to exascale GPUs, enabling legacy codes to run efficiently on heterogeneous nodes without full rewrites. However, challenges persist in migrating serial or CPU-centric Fortran codes to heterogeneous GPU systems, including performance portability across architectures and the need for directives-based offloading, which can introduce overheads and require substantial refactoring to maintain scalability at exascale.[77]
Implementations and Portability
The development of Fortran compilers began with the pioneering efforts at IBM, where the first Fortran compiler was released in 1957 for the IBM 704 computer, marking the advent of the first high-level programming language with an optimizing compiler.[2] This initial implementation, led by John Backus, translated mathematical formulas into efficient machine code, significantly advancing scientific computing.[78] Subsequent IBM compilers, such as Fortran II in 1958, introduced features like subroutines and function subprograms, evolving the language while maintaining backward compatibility.[79]
Among contemporary Fortran compilers, gfortran, the GNU Fortran frontend integrated into the GNU Compiler Collection (GCC), stands as a free, open-source option supporting Fortran standards up to 2018 and beyond, with the latest GCC 15.2 release in August 2025 providing robust optimizations for general-purpose use.[80] The Intel Fortran Compiler, now primarily the LLVM-based ifx in the oneAPI 2025 release, is optimized for x86 architectures and Intel hardware, offering advanced performance tuning for Intel processors while discontinuing the legacy ifort edition.[81] For high-performance computing (HPC), the HPE Cray Compiling Environment (CCE) Fortran compiler targets supercomputing systems, supporting most features of the Fortran 2023 standard except for the .NIL. constant and leveraging Clang/LLVM backends for vector processors and accelerators.[82] Additionally, Flang, an open-source LLVM-based Fortran compiler initiated around 2018, has matured by 2025 into a production-ready tool, renamed from flang-new and integrated into the LLVM ecosystem for modular, extensible compilation.[83][84] LFortran, another open-source LLVM-based Fortran compiler, is a modern, interactive tool currently in alpha quality (stable release 0.58.0 as of December 2025), supporting interactive development and under active maintenance.[85]
Supporting these compilers are essential development tools, including debuggers like GNU Debugger (GDB), which integrates seamlessly with gfortran for breakpoint setting and variable inspection on Unix-like systems.[86] For HPC environments, specialized debuggers such as TotalView and Arm DDT provide multi-process debugging capabilities for parallel Fortran applications.[87] Profilers, including Intel VTune Profiler bundled with oneAPI, enable performance analysis by identifying bottlenecks in memory access and computation loops.[88] Integrated development environments (IDEs) like Photran, an Eclipse-based plugin, offer syntax highlighting, refactoring, and build integration specifically for Fortran, supporting cross-platform workflows.[89]
Modern Fortran compilers in 2025 incorporate advanced performance features such as automatic parallelization and vectorization to exploit multicore processors and SIMD instructions without manual intervention. For instance, Intel ifx enables auto-vectorization at optimization level -O2 and higher, transforming scalar loops into vectorized code for improved throughput on AVX-512 enabled hardware.[90] Similarly, gfortran supports loop parallelization via the -ftree-parallelize-loops flag, distributing iterations across threads, while HPE Cray CCE applies directive-based auto-parallelization for DO CONCURRENT constructs in HPC workloads. These features, refined through iterative releases, allow compilers to achieve near-peak performance on diverse architectures by analyzing data dependencies and loop structures.[91]
Fortran compilers exhibit broad cross-platform availability, running on operating systems from Windows and Linux to macOS, and scaling to supercomputers via distributions like GCC and LLVM. gfortran, for example, compiles natively across these platforms through GCC binaries, ensuring portability for scientific applications. Intel oneAPI tools extend to Windows and Linux, while Flang's LLVM foundation facilitates builds on embedded systems to large clusters.[92][93] HPE Cray environments, though HPC-centric, support x86 and Arm architectures for deployment on diverse supercomputing infrastructures.[94]
Standards Compliance
Fortran standards compliance has evolved significantly since the language's inception, ensuring portability across implementations. In the 1960s, early Fortran implementations were often loose and vendor-specific, with dialects proliferating due to minimal standardization; the first ANSI standard, Fortran 66, was published in 1966 to address this but permitted extensions that hindered full interoperability.[16] By the 1970s and 1980s, the Fortran 77 standard (ANSI X3.9-1978) introduced stricter conformance requirements, though adoption was gradual as compilers updated slowly, leading to a more reliable but still varied ecosystem.[16] The 1990s marked a pivotal shift with Fortran 90 (ISO/IEC 1539:1991), which mandated compilers to diagnose non-standard syntax and errors, enforcing rigorous testing and reducing dialectal deviations for enhanced portability.[16]
Validation of standard conformance relies on test suites designed to verify compiler adherence to ISO/IEC specifications. Historically, the National Institute of Standards and Technology (NIST) developed comprehensive test programs in the 1970s, such as the NBS FORTRAN Test Programs, to check compliance with Fortran 66 and early revisions by exercising language forms and interpretations.[95] These suites, written in standard Fortran, remain influential for legacy validation, though modern efforts have shifted toward community-driven and vendor-specific tools; for instance, the J3 Fortran committee has proposed a thorough testsuite covering positive and negative cases for all standard features and constraints since 2019, aiding ongoing verification.[96] Frameworks like the Berkeley Lab Fortran Compiler Test Suite further support testing by providing a modular set of cases to evaluate compiler behavior against current standards.[97]
Compliance levels vary between full implementation and subsets, allowing developers to target core features for broader portability. For example, the Fortran 2008 standard (ISO/IEC 1539-1:2010) defines a baseline "core" subset excluding advanced parallel features like coarrays, which some compilers, such as early Cray implementations, supported partially for high-performance computing while deferring full adoption.[98] Major compilers report feature-by-feature support rather than binary full/partial status; IBM XL Fortran, starting with version 14.1, achieved progressive compliance with Fortran 2008 elements like submodules and polymorphic entities, reaching near-full coverage by later releases.[99] This tiered approach ensures essential syntax and semantics are portable, with subsets like the Fortran 2008 core enabling compatibility across diverse hardware without requiring every optional extension.
Vendor-specific extensions often contrast with standard purity, introducing flags that enhance performance or compatibility but risk portability. For instance, the GNU Fortran compiler's -fdefault-real-8 option defaults real literals to double precision (kind 8), a non-standard behavior mimicking older dialects for legacy code, while standard-compliant modes enforce single precision unless specified.[100] Similarly, DEC compatibility modes in gfortran enable nonstandard features like abbreviated keywords to emulate historical compilers, but these must be disabled for ISO conformance to avoid vendor lock-in.[100] IBM compilers include extensions for vector programming and shared extensions with other vendors, which are flagged during compilation to distinguish them from pure standard features, promoting awareness of potential interoperability issues.[101]
As of 2025, Fortran 2018 (ISO/IEC 1539-1:2018) enjoys near-universal support among major compilers, facilitating widespread portability for modern applications. The Intel Fortran Compiler (ifx) in its 2025 release fully implements all Fortran 2018 features, including enhanced IEEE arithmetic and assume directives.[81] GNU Fortran (gfortran) provides comprehensive Fortran 2018 coverage, with parallel features via OpenCoarrays integration, while LLVM Flang achieves full syntactic and semantic support under active development.[102] NVIDIA HPC SDK and NAG compilers also offer significant Fortran 2018 compliance, including atomic operations and teams.[102] For the emerging Fortran 2023 standard (ISO/IEC 1539-1:2023), support remains partial; Intel ifx includes select features like updated SYSTEM_CLOCK semantics and BOZ literal handling in array constructors, HPE Cray supports most elements except the .NIL. constant, and Flang implements a subset such as extended IEEE functions but lacks coarrays and enumerations.[81][103][104] This progressive adoption underscores ongoing efforts to balance innovation with backward compatibility.
Interoperability
Fortran's interoperability features enable seamless integration with other programming languages, particularly C, allowing Fortran code to be called from or to call C routines in mixed-language environments. Prior to the Fortran 2003 standard, interoperability relied on compiler-specific conventions and manual adjustments, such as explicit pointer manipulations and name mangling to align Fortran's calling mechanisms with C's, which often led to portability issues across implementations.[105][106] The introduction of standardized mechanisms in Fortran 2003 marked a significant evolution, providing portable bindings that eliminated much of the vendor-specific code required in the 1990s.[29]
The core of Fortran's C interoperability is the ISO C Binding, introduced in Fortran 2003 via the intrinsic module iso_c_binding. This module defines named constants for C-compatible kind parameters (e.g., C_INT for C's int type, C_FLOAT for float), derived types like C_PTR for opaque C pointers and C_FUNPTR for function pointers, and procedures such as C_LOC to obtain the address of a Fortran object and C_F_POINTER to associate a C pointer with a Fortran pointer.[107][29] The BIND(C) attribute is applied to procedures, derived types, and global variables to declare them interoperable with C, ensuring they adhere to C's naming and linkage rules without Fortran's default name decoration. For procedures, BIND(C) requires an explicit interface and supports the VALUE attribute for scalar arguments to pass them by value, aligning with C's convention, while arrays and other arguments default to pass-by-reference.[108][109] Derived types marked BIND(C) must consist of interoperable components, excluding pointers or allocatables, to map directly to C structs.[29]
Key differences in calling conventions necessitate adjustments for reliable interoperability. Fortran passes arguments by reference using descriptors or addresses, whereas C passes scalars by value and arrays as pointers to their first element. To reconcile this, Fortran developers use the VALUE attribute in BIND(C) procedures for by-value passing of simple scalars, preventing unintended modifications in C code.[110][111] Additionally, Fortran arrays are column-major and 1-based, contrasting C's row-major, 0-based indexing; interoperability mappings reverse dimensions and adjust indices accordingly, often requiring explicit transpositions in mixed code. The iso_fortran_env module complements this by providing environment constants like ATOMIC_INT_KIND, aiding in type matching across languages, though it is not exclusively for C binding.[112][108]
Practical use cases abound in scientific computing, where Fortran's numerical strengths are leveraged alongside other languages. For instance, the F2PY tool, part of NumPy, generates Python extension modules from Fortran source, enabling Python scripts to call Fortran subroutines for performance-critical tasks like matrix operations while handling I/O and orchestration in Python.[113] F2PY supports Fortran 77 through modern features, including iso_c_binding interfaces, and automatically manages array passing and COMMON blocks as Python variables. Similarly, calling Fortran from C++ uses extern "C" wrappers around BIND(C) procedures, allowing C++ classes to invoke Fortran kernels for simulations, as seen in high-performance libraries where Fortran handles compute-intensive loops.[114][115]
Recent advancements, aligned with the Fortran 2023 standard, enhance interoperability in accelerator environments through improved support for directive-based GPU offloading via OpenACC. OpenACC directives, such as !$acc kernels or !$acc [parallel](/page/The_Parallel), allow Fortran code to offload computations to GPUs portably across vendors, with compilers like NVIDIA's NVFORTRAN providing seamless integration with C/C++ host code.[116] These extensions build on Fortran 2003 bindings by enabling mixed-language GPU workflows, where C++ manages data transfer and Fortran performs parallel kernels, improving scalability in heterogeneous systems without altering core interoperability mechanisms.[117]
Variants and Extensions
Obsolete Variants
Before the establishment of the Fortran 66 standard, numerous vendor-specific extensions and dialects proliferated, leading to significant incompatibilities across systems. These obsolete variants often introduced proprietary features to optimize for particular hardware or user needs, but their lack of adherence to a common specification rendered them non-portable. As standardization efforts gained traction through the American National Standards Institute (ANSI), these dialects were gradually supplanted, with most fading by the late 1970s or early 1980s.[118]
One prominent example is WATFOR, developed in 1965 by undergraduate students at the University of Waterloo for the IBM 7040 computer. Designed as a student-oriented Fortran IV compiler, it emphasized rapid compilation—achieving compile times under 0.5 seconds for typical programs—through an in-core, load-and-go approach that sacrificed some optimization for speed and simplicity. This made it ideal for educational environments where frequent recompilation was common, but it omitted advanced features like complex arithmetic and certain I/O capabilities found in full Fortran IV. WATFOR was succeeded by WATFIV in 1967, which incorporated additional extensions such as enhanced debugging and structured programming elements presented at SHARE conferences, further tailoring it for academic use. However, as standardized Fortran compilers became widely available, WATFOR and WATFIV were phased out by the 1980s, though they influenced early computing education by democratizing access to high-level programming.[119][120]
Data General's Fortran 5, introduced in the early 1970s, represented another discontinued dialect optimized for their minicomputer line, including the Nova, Eclipse, and later MV systems. Marketed until the early 1980s, it extended Fortran IV with vendor-specific enhancements like improved real-time support and business-oriented features, but included quirks such as non-standard integer division semantics and limited precision handling that deviated from emerging standards. For instance, its I/O routines supported proprietary disk formats incompatible with other systems, and math functions like logarithmic operations sometimes used machine-specific approximations no longer supported in modern compilers. This lack of portability doomed it as users migrated to ANSI-compliant versions, though it played a role in early minicomputer-based scientific applications.[121][122]
Basic Fortran emerged as a minimal subset in the late 1960s and 1970s, targeted at resource-constrained microcomputers and small systems like the Intel 8080. It stripped down core Fortran features to essentials—such as basic arithmetic, loops, and simple I/O—excluding complex data types, subroutines, and advanced control structures to fit within limited memory (often under 64 KB). This made it suitable for early embedded and educational programming on devices like the Altair 8800, but its incomplete implementation led to issues like unsupported floating-point operations and non-standard array handling. By the 1980s, as full Fortran subsets aligned with standards like Fortran 77 became feasible on microcomputers, Basic Fortran was rendered obsolete, leaving a legacy in pioneering numerical computing on personal-scale hardware.[123][124]
Vendor extensions, such as those in CDC's Fortran implementations (e.g., FTN for the 6000 series), further exemplified pre-standard diversity. These often added hardware-tuned features like optimized vector arithmetic or graphical output primitives for plotters, but quirks including unique statement numbering and recovery mechanisms caused portability nightmares. The dominance of ANSI standards ultimately marginalized these variants by the 1980s, as their non-standard I/O (e.g., direct tape control) and math libraries (e.g., extended precision functions) were deprecated in favor of uniform compliance. Despite their obsolescence, these dialects shaped early Fortran adoption in education and industry, fostering innovation before portability became paramount.[125][126]
Derived Languages
Several languages and extensions have been derived from Fortran's syntax and semantics to address its limitations in structured programming, array handling, or high-performance computing, often serving specialized domains such as scientific numerics or education.[127][128][129]
Ratfor, developed by Brian Kernighan in 1975, is a structured programming preprocessor for Fortran 66 that introduces C-like control structures, including multi-statement *if*-then-else blocks, *while* and for loops, repeat-until constructs, and break statements, while translating the code into equivalent Fortran statements to leverage existing compilers.[127] This allowed programmers to write more readable, modular code without the goto-heavy style typical of early Fortran, though it remained tied to Fortran's underlying model for efficiency in numerical tasks.[127]
The F language, introduced in 1996 by Michael Metcalf and John Reid in their book, is a strict subset of Fortran 95 designed for array-oriented programming and teaching modern computational concepts, omitting legacy features like computed gotos and equivalence statements to promote safer, more regular code while retaining Fortran's powerful array operations and modules.[130] F programs compile directly with any Fortran 95-compliant compiler, emphasizing simplicity for numerical algorithms without sacrificing performance.[130]
Fortress, initiated by Sun Microsystems in 2001 with funding from the DARPA High Productivity Computing Systems program, aimed to modernize Fortran for parallel high-performance computing by incorporating mathematical notation, implicit parallelism, and traits for reusable components, positioning itself as a successor language with syntax closer to pseudocode.[129] Despite prototypes demonstrating multicore efficiency, the project was discontinued in 2012 following Oracle's acquisition of Sun, marking it as a failed effort to replace Fortran in large-scale scientific applications.[131]
MATLAB originated in the late 1970s as an interactive matrix laboratory built directly in Fortran by Cleve Moler, leveraging libraries like LINPACK and EISPACK for numerical computations, which provided the foundation for its array-centric syntax and domain-specific focus on linear algebra and simulation.[132] Although MATLAB evolved into an independent language with its own interpreter by the 1980s, its core numeric model retains Fortran's influence in handling multidimensional arrays and vectorized operations.[132]
Fortran's array model has indirectly shaped modern tools like NumPy in Python, which adopts Fortran's column-major (Fortran-order) memory layout for compatibility and efficiency in numerical array manipulations, enabling seamless integration with Fortran-based libraries such as BLAS.[133] Similarly, Julia, developed since 2009, draws on Fortran's emphasis on high-performance array processing to achieve comparable speeds in scientific computing, while adding dynamic typing and multiple dispatch for broader applicability.[134]
As of 2025, derived Fortran languages remain niche, with legacy extensions like Ratfor and F seeing limited use in educational or historical contexts, while broader influences persist in domain-specific tools rather than active, standalone languages.
Code Examples
Basic Program Structure
A Fortran program is structured as a main program unit that begins with a PROGRAM statement, followed by the executable statements forming the main block, and terminates with an END or END PROGRAM statement.[135] This design allows execution to commence directly at the first executable statement after any specification statements, without requiring an explicit entry point function such as main() in languages like C.[136] The PROGRAM statement optionally names the unit for identification and debugging purposes, while the ending statement ensures proper termination and return to the operating system.[137]
In historical Fortran 77, programs adhered to a fixed-form source layout, where statements occupied specific columns (typically 7 through 72), and comments began with a C or * in column 1. A simple "Hello, World!" example in this style demonstrates the core structure:
PROGRAM HELLO
PRINT *, 'Hello, World!'
END
PROGRAM HELLO
PRINT *, 'Hello, World!'
END
Here, the PROGRAM statement initiates the unit, the PRINT statement performs output to standard output using list-directed formatting, and END concludes the program.[137] This fixed-form approach enforced rigid formatting to facilitate punched-card input during the era's hardware constraints.[135]
Modern Fortran, starting from the Fortran 90 standard, introduced free-form source layout, allowing more flexible indentation and line continuation without column restrictions, along with enhancements like explicit typing via IMPLICIT NONE. An equivalent "Hello, World!" program uses the WRITE statement for output and follows this contemporary structure:
program hello
implicit none
write(*, *) 'Hello, World!'
end program hello
program hello
implicit none
write(*, *) 'Hello, World!'
end program hello
The program keyword (lowercase optional but conventional) starts the unit, implicit none prevents implicit variable declarations to promote safer coding, the write statement directs output similarly to PRINT but with explicit unit and format arguments, and end program hello explicitly names the ending for clarity.[138] This evolution prioritizes readability and portability across compilers while preserving the fundamental program unit model.[136]
Numerical Computation Example
A representative numerical computation in Fortran involves approximating the value of π using the Leibniz infinite series, where π/4 = ∑_{k=1}^∞ [(-1)^{k+1} / (2k - 1)]. This series summation demonstrates Fortran's strengths in handling iterative floating-point arithmetic and array operations efficiently. The following Fortran 95+ code snippet computes an approximation by allocating a real array to store the series terms, summing them via the intrinsic SUM function, and scaling the result by 4.
fortran
PROGRAM ComputePi
IMPLICIT NONE
INTEGER :: i, n
REAL, ALLOCATABLE :: terms(:)
REAL :: pi_approx
n = 1000000 ! Number of terms for summation
ALLOCATE(terms(n))
DO i = 1, n
terms(i) = (-1)**(i + 1) / (2 * i - 1)
END DO
pi_approx = 4.0 * SUM(terms)
PRINT *, 'Approximation of pi:', pi_approx
DEALLOCATE(terms)
END PROGRAM ComputePi
PROGRAM ComputePi
IMPLICIT NONE
INTEGER :: i, n
REAL, ALLOCATABLE :: terms(:)
REAL :: pi_approx
n = 1000000 ! Number of terms for summation
ALLOCATE(terms(n))
DO i = 1, n
terms(i) = (-1)**(i + 1) / (2 * i - 1)
END DO
pi_approx = 4.0 * SUM(terms)
PRINT *, 'Approximation of pi:', pi_approx
DEALLOCATE(terms)
END PROGRAM ComputePi
In this example, variables are declared explicitly with IMPLICIT NONE to enforce type safety: i and n as integers for loop control and array size, and terms as a allocatable real array for storing the alternating fractional terms. The DO loop iterates over the indices, computing each term using the exponentiation operator (**) and basic arithmetic, which leverages Fortran's optimized handling of floating-point operations. The SUM intrinsic then aggregates the array elements in a vectorized manner, often benefiting from compiler optimizations like those in gfortran or Intel Fortran, which can achieve near-peak performance on modern CPUs for such workloads. Finally, the result is output via a simple PRINT statement, and memory is explicitly deallocated to prevent leaks in larger programs.
Fortran excels in this context due to its design for high-performance numerical tasks, where tight loops and array intrinsics enable efficient execution on hardware accelerators, contrasting with interpreted scripting languages like Python that require additional libraries (e.g., NumPy) and often incur overhead in pure loop-based computations. For instance, benchmarks show Fortran codes for series summations running 10-100 times faster than equivalent unoptimized Python scripts on multicore systems, underscoring its role in scientific simulations.[139]
Cultural Aspects
Humor and Anecdotes
Fortran has elicited a wealth of humor in programming circles, often centered on its rigid syntax and legacy features. A classic one-liner declares, "GOD is REAL (unless declared INTEGER)," playing on the language's explicit variable typing requirements.[140] Similarly, programmers jest that "Fortran: what 2 computers do before interface," riffing on the language's early emphasis on mathematical expressions over modern interoperability concepts.[140]
Early development anecdotes highlight the intense, improvisational nature of Fortran's creation under John Backus at IBM. Backus assembled a small team of recent graduates and mathematicians, many lacking formal programming experience, leading to late-night brainstorming sessions that transformed mathematical notation into executable code by 1957.[141]
Punched card mishaps added to the era's folklore, as Fortran programs were typically submitted as physical decks that could scatter if dropped. Programmers recall witnessing students lose hours resorting hundreds of cards after an accidental spill, a disaster exacerbated by the lack of numbering on many decks.[142] Such incidents fueled self-deprecating tales of Fortran's unforgiving input methods, contrasting sharply with its computational prowess.
Fortran's cultural footprint includes nods in popular media and astronomy. In the 2016 film Hidden Figures, NASA mathematician Dorothy Vaughan self-teaches Fortran and instructs her team on it to transition from human computation to electronic programming for space missions.[143] The language even earned a celestial tribute: asteroid (9548) Fortran, discovered in 1985 by the Spacewatch program at Kitt Peak National Observatory, orbits the main asteroid belt as a nod to its foundational role in scientific computing.[144] As of 2025, Fortran continues to influence high-performance computing culture through discussions of its enduring relevance in scientific software.[1]
Further reading
This section provides a curated list of recommended books on Fortran, drawn from suggestions in scientific computing communities and developer forums. The selection includes resources for learning the language, comprehensive references, and texts covering both classic and modern standards up to Fortran 2023.
-
Modern Fortran Explained: Incorporating Fortran 2023 by Michael Metcalf, John Reid, and Malcolm Cohen
A definitive reference that elucidates the full Fortran language, including the latest standards up to 2023. It is particularly valuable for documentation and advanced users, featuring updates on modern elements such as enhanced parallelism.
-
Modern Fortran: Building Efficient Parallel Applications by Milan Curcic
A practical guide emphasizing modern Fortran for high-performance computing, including parallelism. Suitable for beginners and experienced users in scientific applications.
-
Fortran 95/2003 for Scientists and Engineers by Stephen J. Chapman
A textbook focused on scientific and engineering applications, covering fundamentals with examples. Widely used for learning and as a reference in technical fields.
-
Introduction to Programming with Fortran by Ian Chivers and Jane Sleightholme
An introductory text progressing from basics to advanced topics, aligned with modern standards. Recommended for self-study and novices.
-
Guide to Fortran 2008 Programming by Walter S. Brainerd
A clear guide on Fortran 2008 features, ideal for beginners adopting modern practices and as a syntax reference.
-
Fortran 90 Handbook: Complete ANSI/ISO Reference by Jeanne C. Adams et al.
An exhaustive reference for Fortran 90 standards, foundational for understanding core language features and documentation.
-
Modern Fortran in Practice by Arjen Markus
A book on practical techniques for real-world problems in science and engineering, suitable for intermediate users.
-
Structured FORTRAN 77 for Engineers and Scientists by D. M. Etter
A classic text on structured programming, adopted in engineering education for foundational concepts.
-
Schaum's Outline of Programming with Fortran 77 by William E. Mayo and Martin Cwiakala
A problem-oriented resource with solved examples, useful for practice and quick reference.
-
A First Course in Scientific Computing: Symbolic, Graphic, and Numeric Modeling Using Maple, Java, Mathematica, and Fortran90 by Rubin H. Landau
An interdisciplinary introduction integrating Fortran 90 with computational science tools, common in academic curricula.