In this article from one of the co-authors of Modern Fortran Explained, Michael Metcalf examines different versions of Fortran and explores the programming language’s relevance in the twenty-first century.
Never in his wildest dreams could IBM’s John Backus, developing the Fortran programming language back in 1957, have imagined that it would be a world-wide success, and still be going from strength to strength many years later. Given the oft-repeated predictions of its imminent demise, it is a surprise, even to some of its most devoted users, that the language is not only still with us, but is even being further developed for today’s demanding applications.
As computers double in power every few years and have become able to perform huge calculations by the use of duplicated processors running in parallel, and as the problems to be solved have become ever more complex, the question has sometimes arisen as to whether Fortran is still adequate for the task. Early programs contained only a few hundred statements. Today, programs of a million lines or more are commonplace. To manage their complexity, it is essential to have some means to write them reliably and understandably so that they produce correct results and be modified later.
Beginning with Fortran 77, the standardization bodies have responded to the challenge of keeping abreast with these trends. Fortran 90 introduced a new notation that allows arrays of numbers, for instance matrices, to be handled in a natural and clear way, and added many new built-in facilities for manipulating such arrays. For instance, to add together all the numbers in an array, a single command (called sum) is all that is required.
The use of the array-handling facilities makes scientific programming simpler, less error prone and more efficient than ever.
To make programs more reliable, the language has introduced a wealth of features designed to catch programming errors during the early phase of compilation, when they can be quickly and cheaply corrected. These features included new ways of structuring programs and the ability to ensure that the components of a program, the subprograms and modules, ‘fit together’ properly. Other innovations were abstract data types, dynamic memory allocation, and pointers.
Subsequent standards have added yet more important features: interoperability with the C programming language, support for object-oriented programming and for the IEEE Floating-Point Standard, as well as for parallel programming using coarrays,.
The objective of coarrays is to allow the simultaneous processing of arrays on multiple processors. In this model, not only is data distributed over processors, as in an SIMD (Single Instruction Multiple Data) model, but work also is distributed, using the SPMD (Single Program Multiple Data) model, where each processor runs a copy of the program known as an image. The syntax required makes only a small impact upon the appearance of a program. Data distribution is achieved by specifying that any object declared without coarray syntax exists independently in all the images and can be accessed only from within its own image, whereas objects specified with coarray syntax have the additional property that they can be accessed directly from any other image.
In order to better distinguish present language versions from past ones, those versions of Fortran corresponding to any of the three standards so far published this century (the latest as recently as November 2018), are loosely referred to as ‘Modern Fortran’, a term to be found in a number of book titles.
Modern Fortran is still a procedural, imperative, compiled language with a syntax well suited to a direct representation of mathematical formulas, where individual procedures may be compiled separately. But now they may be grouped into modules, allowing the convenient construction of very large programs and procedure libraries. Procedures communicate via global data areas or by argument association. Access to the language’s notable parallel processing feature, coarrays, is obtained through a convenient syntax that allows checks to be made before any runs are made and obviates the need to make explicit use of external libraries.
So we see that Fortran’s particular advantages as a high-end numerical language, especially where arrays are the main form of data object and/or where complex arithmetic is involved, are still to the fore. It is able to attain the highest achievable optimization, mainly because multi-dimensional arrays are ‘natural’ objects and because its pointers are highly constrained.
Thus, there is every sign that Modern Fortran will continue to be used to tackle the major scientific computing problems of the next decades, and will long remain a living tribute to the early pioneers.
For further reading, read the author’s piece in the Journal of Computer Science & Technology.
Michael Metcalf worked for many years at CERN. He is the author or co-author of a range of publications, including Modern Fortran Explained, Fifth Edition, and its forerunners.