Fortran is a compiled programming language developed principally for scientific and engineering computation. Its name derives from “Formula Translation,” reflecting its original purpose: expressing mathematical calculations in a notation closer to algebra than to machine instructions. The first widely distributed Fortran compiler was released by IBM in 1957 for the IBM 704. Subsequent revisions transformed the language from an early system for numerical formulas and loops into a language supporting modules, dynamic arrays, object-oriented programming, interoperability with C, and parallel execution.
Fortran has particular importance in computational physics, weather and climate modeling, numerical linear algebra, and large-scale simulation. Its continued use rests on a combination of accumulated scientific software, explicit facilities for multidimensional arrays, and language rules that help compilers optimize numerical operations. Modern Fortran differs substantially from the fixed-column, label-oriented language associated with early scientific computing, although compatibility with older programs remains an important concern.
Origins and early development
Fortran emerged when programming a scientific computer commonly required detailed knowledge of its instruction set and storage organization. Programs written in assembly language could be efficient, but developing and modifying them was labor-intensive. Earlier automatic-programming systems had demonstrated that symbolic expressions could be translated into machine operations; the central challenge was producing code efficient enough to persuade users to accept a higher-level notation.
John Backus proposed the IBM project in 1953 and led the team that developed the original language and its compiler. A preliminary specification appeared in 1954, and the production compiler became available in 1957. The IBM 704 was an important target because it provided hardware floating-point arithmetic and index registers suited to numerical work. Fortran allowed programmers to write arithmetic expressions, indexed variables, loops, conditional transfers, and input/output statements rather than specify each machine instruction separately.
The compiler was as significant as the language. Its designers devoted substantial effort to optimization, including the organization of loops and the use of registers. This addressed a practical objection to automatic programming: computer time was expensive, and users were reluctant to exchange execution speed for easier program construction. The compiler demonstrated that a high-level source program could be translated into efficient machine code, helping establish compilation as a practical foundation for software development.
Early Fortran nevertheless reflected its hardware and production environment. Source programs were commonly entered on punched cards, statement layout had fixed-column significance, and numerical labels identified branch destinations. Control flow included an arithmetic IF, which selected among three labels according to whether an expression was negative, zero, or positive. The DO loop provided a compact notation for repeated calculations, while formatted input and output accommodated the record-oriented equipment used in scientific installations.
FORTRAN II, introduced in 1958, strengthened support for separately compiled subroutines and functions. This made it more practical to organize calculations into reusable components and to assemble programs from independently developed numerical routines. FORTRAN IV, introduced in the early 1960s, further shaped the language that would become standardized.
Adoption extended beyond IBM as other manufacturers supplied implementations for their machines. Although dialect differences complicated portability, the ability to preserve scientific source code across hardware changes became a major advantage. Fortran helped shift the enduring value of a computational method away from a particular machine program and toward an implementation of an algorithm that could be recompiled on successive computer generations.
Standardization and language evolution
Fortran was among the first programming languages to receive a formal national standard. The American Standards Association approved the first standard in 1966; this version is generally called FORTRAN 66. Standardization established a common language across implementations, although vendor extensions and differences in arithmetic and input/output behavior continued to affect portability. The standard defined language requirements rather than a single compiler or runtime system.
FORTRAN 77, standardized in 1978, consolidated the language used in much late-twentieth-century scientific software. Important additions included a character data type and block-structured IF statements. These reduced dependence on character data packed into numeric storage and on branches used to simulate conditional blocks. Nevertheless, the language retained fixed-form source, widespread use of externally defined procedures, and storage-sharing mechanisms such as COMMON.
Fortran 90 represented a much larger redesign. The international standard was published in 1991, despite the version’s “90” designation. It introduced free-form source, modules, array expressions, allocatable arrays, pointers, derived types, explicit procedure interfaces, and additional control constructs. These features enabled programs to express both numerical operations and software organization more directly. The standardized name became “Fortran” rather than the earlier all-capital spelling.
Fortran 95, published in 1997, was a smaller revision that refined Fortran 90 and incorporated features such as pure procedures. Fortran 2003 added a broad set of capabilities, including support for object-oriented programming, standardized interoperability with C, allocatable components, procedure pointers, and stream input/output. Fortran 2008 brought coarrays into the main language standard, added submodules and DO CONCURRENT, and expanded facilities for parallel and modular programming.
Fortran 2018 integrated further parallel features, including teams and collective operations, as well as expanded C interoperability. Fortran 2023 added features including enumeration types, conditional expressions, and further extensions to intrinsic procedures and parallel facilities. The year in a revision’s name does not imply that every compiler immediately implements every feature; language approval, compiler implementation, and widespread deployment are distinct processes.
The standards are developed through international and national committee work, notably ISO/IEC JTC 1/SC 22/WG 5 and the United States committee J3. A persistent design issue is balancing compatibility with improvements in clarity, safety, and expressiveness. Some older features are designated obsolescent or deleted, but implementations often retain them as extensions. Consequently, “Fortran support” can mean support for a particular standard, a legacy dialect, or a mixture selected through compiler options. The distinction matters when evaluating portability: accepting a source file does not by itself establish that the program conforms to a specified revision.
Source structure, types, and execution
A Fortran application typically consists of a main program and supporting program units, including modules, external procedures, and submodules. Modern free-form source permits statements to be laid out without the column restrictions of older code. An exclamation mark introduces a comment outside a character literal, and an ampersand continues a statement. Names are case-insensitive, although character data retain their case. File extensions such as .f and .f90 commonly influence compiler defaults, but extensions are implementation conventions rather than definitions of a program’s language revision.
Fixed-form source, still important for older programs, traditionally reserves columns 1–5 for statement labels and column 6 for continuation, with the statement field occupying columns 7–72. Compiler options often extend these limits. Moving fixed-form code into a free-form file is therefore not merely a change of filename: continuation rules, comment markers, and significant spacing can require conversion.
Fortran is statically typed. Its intrinsic type categories include integer, real, complex, logical, and character; programs can also define derived types. A type’s kind parameter selects among processor-supported representations. Kind values are not portable byte counts: REAL(KIND=8) does not universally specify an eight-byte representation. Facilities such as SELECTED_REAL_KIND express requirements in terms of precision and exponent range, while ISO_FORTRAN_ENV provides named kinds such as REAL64 for supported storage sizes.
The language retains implicit typing for historical compatibility. Under the traditional default, names beginning with I through N imply integer type, while other initial letters imply real type. An IMPLICIT NONE statement disables that default mapping in its scope, making declarations necessary. Later standards provide additional controls over implicit external procedures. Explicit declarations allow compilers to diagnose misspelled names that might otherwise become unintended variables.
Executable constructs include IF, SELECT CASE, counted DO loops, and condition-controlled loops. Assignment uses =, whereas equality testing uses == or the older .EQ. notation. Fortran distinguishes integer and real arithmetic: an expression such as 3/2 performs integer division and yields 1, even if its result is subsequently assigned to a real variable. A real operand, as in 3.0/2.0, changes the operation.
Variables do not generally acquire a defined value merely because storage has been allocated. Explicit initialization, assignment, or input is needed unless a particular rule provides a value. Declaration initialization also has lifetime implications: a local variable initialized in its declaration normally has the SAVE attribute and preserves its value between procedure invocations. This differs from a fresh executable assignment on each call and can affect recursive or concurrent procedures.
Arrays and the expression of numerical operations
Arrays are central to Fortran’s numerical model. An array has an element type, rank, shape, and bounds. Rank is the number of dimensions; shape is the sequence of extents in those dimensions. For example, REAL :: A(3,4) declares a rank-two array with shape [3,4]. The default lower bound is one, but declarations may specify other bounds, such as A(0:99) or FIELD(-2:N+2), which are useful for mathematical indexing and boundary regions in numerical simulations.
Fortran stores array elements in array-element order, commonly called column-major order: the leftmost subscript varies fastest. For a conventional contiguous rank-two array A(I,J), neighboring values of I occupy adjacent element positions. This differs from the usual layout of multidimensional arrays in C. Loop ordering can therefore strongly influence locality in the processor cache, particularly when a computation repeatedly traverses large arrays.
Whole-array assignment and array expressions permit operations without explicit element-by-element loops. If arrays have conforming shapes, C = A + B expresses elementwise addition. Array sections select ranges, strides, or indexed subsets: A(:,J) selects a column, and X(1:N:2) selects every other element in a range. A scalar may participate in an array operation by applying to each element. Shape conformance, rather than identical subscript bounds, is the central requirement for many such operations.
Intrinsic procedures extend this notation. SUM, PRODUCT, MAXVAL, and MINVAL perform reductions; PACK, UNPACK, and RESHAPE reorganize data; and MATMUL and DOT_PRODUCT express common operations from linear algebra. For a matrix product,
the source statement C = MATMUL(A,B) specifies the operation without prescribing a particular loop nest or optimized library implementation. Elementwise multiplication, by contrast, is written A * B and is not matrix multiplication.
Allocatable arrays provide storage whose size is determined during execution. Allocation status and bounds are tracked by the language, and local allocatable objects without persistent lifetime are normally deallocated when their scope ends. Pointers serve a different purpose: they can refer to existing targets and introduce aliasing relationships. The distinction gives allocatables simpler ownership behavior for many numerical data structures.
High-level array notation does not guarantee minimum memory traffic. Expressions and noncontiguous sections may require temporary arrays, while argument association can involve copying data into or out of contiguous storage. The CONTIGUOUS attribute records a useful constraint, but actual performance still depends on access patterns, compiler transformations, and data size. Consequently, concise array expressions and explicit loops coexist in performance-sensitive code.
Procedures, modules, and data abstraction
Fortran organizes executable functionality into subroutines and functions. A subroutine is invoked with CALL, while a function supplies a result within an expression. Procedures may have dummy arguments corresponding to actual arguments at a call site. Attributes such as INTENT(IN), INTENT(OUT), and INTENT(INOUT) describe permitted use of dummy arguments and help document and check interfaces. They do not, by themselves, define a universal machine-level calling convention.
Modules group declarations, procedures, interfaces, and data. A USE statement makes selected module entities accessible, and PUBLIC and PRIVATE control visibility. Module procedures provide explicit interfaces automatically to users of the module. This enables checking of argument types, ranks, optional arguments, and keyword arguments, addressing weaknesses in older programs where callers and external procedures could disagree without a reliable diagnostic.
A small numerical module illustrates these facilities:
module vector_operations
use, intrinsic :: iso_fortran_env, only: real64
implicit none
private
public :: squared_norm
contains
pure function squared_norm(x) result(value)
real(real64), intent(in) :: x(:)
real(real64) :: value
value = sum(x * x)
end function squared_norm
end module vector_operations
The assumed-shape argument x(:) receives its shape through the procedure interface. The PURE attribute restricts side effects, making the procedure usable in contexts where effects on external state must be controlled. It does not imply that the procedure is evaluated at compile time or automatically executed in parallel.
Generic interfaces allow multiple specific procedures to share a public name, with selection based on properties such as argument type, kind, and rank. Operators and assignment can also be extended for derived types. These mechanisms support mathematical abstractions such as vectors, tensors, and physical quantities while retaining compile-time interface resolution for many calls.
Fortran 2003 introduced type extension, polymorphic entities, and type-bound procedures. A derived type can extend another type, and a CLASS declaration can represent an object whose dynamic type is an extension of a declared base type. Deferred bindings and abstract types permit families of implementations behind a common interface. For example, a simulation framework can define an abstract solver and supply several concrete algorithms.
Submodules, introduced in Fortran 2008, separate parts of a module’s interface from procedure implementations. This can reduce recompilation dependencies and improve organization in large projects. Final procedures and allocatable components support more structured resource lifetimes, although pointer-based structures still require attention to association and ownership.
These features coexist with older mechanisms such as COMMON blocks and INCLUDE files. A large scientific code may therefore contain several generations of organization: global storage inherited from FORTRAN 77, modules added during modernization, and newer object-oriented components around selected subsystems.
Numerical semantics and compiler optimization
Fortran’s numerical types and expression rules describe a computation, but they do not make every mathematically equivalent formulation computationally equivalent. Most practical implementations use floating-point arithmetic, in which real numbers are represented with finite precision and limited exponent range. Rounding, overflow, underflow, and cancellation affect results. In particular, floating-point addition is not generally associative:
This matters when a compiler changes an expression’s evaluation strategy or when a parallel reduction combines partial results in a different order.
A kind selected for adequate decimal precision does not guarantee that a numerical algorithm is stable. For example, computing the small difference of two nearly equal large quantities can lose significant digits even when each operand is individually represented accurately. Likewise, the direct expression SUM(X*X) for a squared norm can overflow for large elements although a scaled algorithm could compute a useful norm. Numerical quality depends jointly on representation, algorithm, input conditioning, and implementation.
Fortran provides intrinsic modules for aspects of IEEE floating-point behavior, including inquiry and control facilities for supported rounding modes, exceptional values, and arithmetic flags. These facilities are conditional on processor support and applicable language requirements. A real kind with 64 bits of storage is not, solely by that designation, a complete promise of every IEEE binary64 behavior under every compiler option.
Optimization is strongly influenced by the language’s rules on argument association and aliasing. When one dummy argument is used to define an object, restrictions can prevent another associated argument from being used to access the same storage in conflicting ways. A compiler may exploit these rules when analyzing loops. This is more precise than the common claim that Fortran “has no pointers” or “forbids aliasing”: modern Fortran has pointers, targets, and several other ways to establish storage relationships, each subject to specific restrictions.
Compilers may perform vectorization, loop transformation, inlining, and interprocedural analysis. Array layout and regular loop bounds often make scientific kernels suitable for such transformations. Nevertheless, a compiler cannot generally infer that arbitrary iterations are independent, and an optimization cannot repair a program that violates the language’s argument-association rules.
Optimization settings also affect reproducibility. Options permitting reassociation or relaxed treatment of exceptional values may produce faster code while changing numerical results. Parallel execution introduces further variation through reduction order and decomposition. Bitwise identical output across processors, compiler versions, and process counts is therefore a separate engineering objective, not an automatic consequence of using the same Fortran source. Validation commonly distinguishes exact agreement from agreement within scientifically justified error tolerances.
Parallel programming and accelerators
Fortran supports parallel computing through both language facilities and external programming systems. These approaches address different execution models. A program may use threads in shared memory, separate processes exchanging messages, language-level coarray images, or accelerators attached to a host processor. Large applications often combine more than one model rather than selecting a single mechanism for all computation.
MPI is widely used for distributed-memory computation. Each process operates on its own address space and exchanges data through library calls. In a grid-based simulation, processes may own different spatial regions and exchange boundary values before advancing the numerical solution. Modern MPI Fortran bindings include the mpi_f08 module, which provides stronger interface checking and more expressive types than older include-file bindings.
OpenMP uses directives, runtime routines, and environment controls to describe parallel execution. In Fortran source, directives commonly appear as specially marked comments beginning with !$OMP. A loop can be distributed over threads, with clauses specifying private variables, shared data, and reductions. Correctness depends on managing dependencies: two iterations that update the same array element may require restructuring or synchronization. Later OpenMP versions also support tasking and offloading to devices.
Coarrays became part of the main language in Fortran 2008. A coarray program executes as a set of images, each with its own ordinary variables, while coindexed syntax allows access to objects on other images. For example, X[2] identifies X on image 2 when X is an appropriate coarray. Synchronization constructs establish ordering and data visibility between images. Coarrays are a programming model, not a promise of physically shared memory; implementations can use communication libraries underneath.
Fortran 2018 expanded this model with facilities including teams, events, and collective operations. Teams allow images to be organized into cooperating groups, while collectives express operations involving a group of images. These features can support domain decomposition and hierarchical applications, but their availability and performance depend on the compiler and runtime.
DO CONCURRENT, introduced in Fortran 2008, specifies iterations subject to restrictions intended to permit execution in any order. It does not require a processor to run them simultaneously. It is distinct from an ordinary DO loop and from an explicit OpenMP directive.
For graphics processing units, additional approaches include OpenACC directives and vendor-supported CUDA Fortran. Device data movement, memory placement, and kernel launch overhead can dominate performance, so successful acceleration involves more than translating loop syntax. A numerical kernel may be highly parallel yet remain limited by memory bandwidth or by repeated transfers between host and accelerator storage.
Input, output, and interoperability
Fortran’s input/output system is unusually prominent in the language itself. Statements such as OPEN, READ, WRITE, CLOSE, and INQUIRE operate on connections identified by unit numbers. External files and internal files—character variables used as formatted input or output destinations—share much of the same formatting machinery. This makes conversion between numeric values and text possible without an external formatting library.
Formatted input/output uses edit descriptors to specify field widths, decimal precision, exponent forms, and other details. For example, an F descriptor produces fixed-point output, while E, ES, and related descriptors provide exponential forms. List-directed output, often written with * as the format, leaves many presentation choices to the processor. It is convenient for inspection but does not establish a universal interchange format. A field that is too narrow can produce asterisks instead of the intended number.
File access can be sequential, direct, or stream-based, subject to the relevant form and connection properties. Sequential files are organized into records. Direct access addresses records by number. Stream access treats a file as a sequence of file storage units and is useful for data formats defined outside Fortran’s record model. Error handling uses facilities such as IOSTAT and IOMSG; NEWUNIT allows an OPEN statement to obtain an available unit number.
Unformatted input/output avoids text conversion but is not automatically portable binary interchange. Sequential unformatted files commonly include implementation-specific record markers, and numeric representation, byte order, and storage conventions can differ. Standardized scientific data libraries such as netCDF and HDF5 address broader requirements for portable representation, dimensions, attributes, and structured datasets. They are library ecosystems rather than intrinsic parts of Fortran.
Standardized C interoperability, introduced in Fortran 2003 and expanded subsequently, provides a more controlled boundary with other languages. The intrinsic module ISO_C_BINDING supplies interoperable kinds and facilities such as C_PTR, C_LOC, and C_F_POINTER. The BIND(C) attribute specifies interoperable procedures or derived types when their declarations satisfy the relevant requirements. A VALUE dummy argument can represent a C-style by-value parameter.
Interoperability still requires agreement about array layout, string representation, object lifetime, and procedure signatures. A normal Fortran character variable is not automatically equivalent to a null-terminated C string, and ordinary module procedures do not automatically expose a stable C symbol.
Compiler-specific module files and calling conventions also matter. The language standard does not prescribe a universal application binary interface, so object files and module interfaces from different compilers are not generally interchangeable. Bindings built through C-compatible interfaces are therefore important for connecting Fortran libraries to Python, C++, and other environments.
Compilers, scientific libraries, and continuing use
Fortran implementations span open-source projects, commercial toolchains, and systems associated with particular processor platforms. GNU Fortran, usually invoked as gfortran, is part of the GNU Compiler Collection. Intel supplies the LLVM-based ifx compiler, while NVIDIA’s HPC SDK includes nvfortran. LLVM Flang is another major compiler effort. These implementations differ in standard coverage, diagnostics, optimization, parallel runtimes, and support for particular accelerators.
A compiler normally translates source into object code, after which a linker combines program components and required libraries. Module dependencies impose a compilation order because a source file using a module generally requires its compiled interface to be available. Build systems such as CMake support these dependencies, while the Fortran Package Manager provides a Fortran-focused approach to building and distributing projects. Testing, version control, and reproducible build configuration remain as important as the choice of language.
The numerical library ecosystem is central to Fortran’s influence. BLAS, the Basic Linear Algebra Subprograms, defines standard interfaces for operations on vectors and matrices. Its levels distinguish vector operations, matrix–vector operations, and matrix–matrix operations. Optimized implementations exploit hardware-specific instruction sets, cache behavior, and parallel execution while preserving the expected interface.
LAPACK builds on these operations to solve systems of linear equations, least-squares problems, eigenvalue problems, and singular-value decompositions. Its development followed earlier packages such as LINPACK and EISPACK. These libraries illustrate an important distinction between source language and software reach: a library written in Fortran can be used indirectly by applications whose main code is written in another language. Many scientific computing environments call compiled numerical routines through wrappers rather than reimplement every algorithm.
Fortran remains prominent in computational fluid dynamics, electronic-structure calculations, ocean and atmosphere models, and other simulations involving large multidimensional fields. Examples include major components of the Weather Research and Forecasting model and the Quantum ESPRESSO electronic-structure suite. Such programs often combine decades of scientific development with newer parallelization and software organization. Their longevity reflects both the cost of validating replacement implementations and the scientific knowledge embedded in the code.
This position does not make Fortran a universal choice. Web services, interactive interfaces, and many general-purpose software domains have larger ecosystems in other languages. Mixed-language applications are therefore common: Fortran handles numerical kernels, another language coordinates workflows, and specialized libraries manage storage, visualization, or communication.
Maintenance presents concrete technical challenges. Legacy code may depend on implicit typing, storage association, nonstandard extensions, or assumptions about integer and real sizes. Modernization can involve introducing explicit interfaces, replacing global storage with modules, separating numerical algorithms from input/output, and establishing regression tests. Because a seemingly small change can alter floating-point evaluation or expose an old interface mismatch, preserving scientific behavior requires attention to numerical meaning as well as successful compilation.