Fortran is really that hard

Alexander Patashinski, a Landau student and awardee, now professor at the Department of Physics at Northwestern University, where I spent my post-doc time, once remarked almost resignedly during a discussion: "You start with English and you end up with Fortran". Although at that time the language Fortran itself was not necessarily meant but the enormously increased importance of the computer in theoretical physics, it is still significant that the name Fortran was synonymous with this development.

Tony Hoare, professor at Oxford, inventor of the Quick-Sort algorithm and Turing Prize winner provoked at a conference in 1982 with the statement: "I don’t know what the language of the year 2000 will look like, but I know it will be called Fortran."What he meant was not, as critics assumed, that Fortran" will be "the" programming language in 2000, but rather that Fortran will still exist in 2000, as Fortran is constantly adapting interesting features and properties of other new languages, a process that continues to this day, and I venture to say that it will continue in the future.

Piet Hut, professor of astrophysics at the Institute for Advanced Study in Princeton, gets right to the point when he writes on one of his blogs:

"Physicists have a traditional aversion to learning any other language than Fortran, with which they grow up, no matter how useful the other languages ​​may be. But without ever parting from their beloved Fortran, it was Fortran that changed out from under them, incorporating many of the features that the other languages ​​had pioneered. So, when asked how future physicists will program, a good answer is: we have not the foggiest idea, but whatever it is, it will still be called Fortran."

There is actually no better way of summarizing the current state of affairs, because Fortran lives on the one hand from the aversion of physicists / chemists / etc. To learn new languages, where Fortran has grown so fond of your heart and mostly does what you want, and on the other hand from Fortran's ability to adapt and renew, so that Fortran of today is actually a completely different language than Fortran, the as Formula Translator was created in the mid-1950s, but has retained its strengths over time. In short, when you speak Fortran, you speak a living language.

But now a little bit about the history of Fortran. Fortran was created at IBM between 1954 and 1957 and has thus practically participated in the entire hardware development from the mainframe to PC and vector computers to today's parallel systems during its almost 60 years of existence. Not to forget - from very personal experience - 8-bit computer under CP / M, where the Fortran compiler was contributed by a small, rather unknown software company called Microsoft at the end of the 1970s. (Unfortunately the author fears that the last 8 "floppy with the compiler was lost during one of the relocations.)

According to its inventor John Backus (actually he was the head of a small development group), a major reason for the development of Fortran at IBM was the fact that he did not enjoy programming, especially since programs for the mainframe type IBM 704 were written in assembler code at the time and the number of instructions was relatively large. The first compiler appeared in 1957 and quickly convinced its skeptics, as it reduced the number of instructions by a factor of 20 on the one hand and was able to keep up the speed of the generated code with handwritten assembler routines on the other.

In order to take the wind out of the sails of the speed critics, the first Fortran compiler was designed as an optimizing compiler, a fact that characterizes Fortran compilers to this day and has thus contributed significantly to the widespread acceptance and survival of the Fortran language. The first edition of Fortran, Fortran I, contained 32 instructions, 14 of which included input and output on magnetic tapes, paper and punched cards, but also instructions for controlling switches and lights on the operator console. This means that the number of instructions (implicit data types, IF, DO loops, GOTO, labels, fields) for translating the formulas into a computer program was not very large, which meant that such programs were somewhat confusing for today's programmers work, to put it politely, since structuring via subroutines and functions was only possible in the next edition of Fortran II in 1958. This represented a big step forward in terms of maintainability and expandability of Fortran programs. Fortran II also introduced an additional instruction called COMMON for the transfer of data between the individual program parts via parameter lists (references) and return values, with which data can be elegantly stored in Could summarize blocks that were used in the various subroutines. In addition, a COMMON block could be given a name, which made it possible to structure the data easily (I do not want to go into similarities to C structures here). However, this very Fortran-typical instruction in particular represented an intrinsic source of error, since in principle only the start address of a COMMON block was transferred and therefore with an unskillful change in a subroutine (e.g. unused elements in a block could be reused, because storage space was scarce in times without virtual storage management) difficult-to-find runtime errors or - even worse - incorrect results were the result. So it was advisable to stick to a few simple rules when using COMMON blocks, such as: B. not to mix different data types in one block. A simple remedy was only created 30 years later with the introduction of modules in the Fortran 90 standard. However, the COMMON blocks were an inevitable thing to do if you wanted to use OVERLAY techniques, a technique to make a large application such as B. to accommodate the solution of the Schrödinger equation in solids in the scarce main memory (e.g. a maximum of 200,000 octal words for users of the CDC Cyber ​​at the TU data center in the early 1980s). The advent of operating systems with virtual memory management around the same time then solved this problem, but sometimes at the expense of execution speed.

Before the introduction of the first open standard for high-level programming languages, ANSI Fortran 66, two important data types, DOUBLE PRECISION (usually 64-bit floating point number) and COMPLEX, were added to the language, which play an important role in numerical solutions of scientific problems because, to come back to my subject, the fifth place after the decimal point in a number with five places in front of the decimal point is significant. The ANSI Fortran 66 standard is based on the IBM Fortran IV published in 1962 (Fortran III remained unpublished), which essentially removed all machine-dependent features from Fortran II and also allowed Boolean data types and comparisons. Fortran 66 also represented an additional innovation when standardization was transferred from a private company IBM to a not-for-profit standardization organization, ANSI, where companies and organizations in working groups can contribute to the standard or agree on a standard.

After several companies began to expand the standard in a proprietary manner relatively quickly after the appearance of Fortran 66, ANSI decided in 1969 to expand the 66 standard, which ultimately led to the Fortran 77 standard, which was finally adopted in 1978. Fortran 77 heralded the end of the GOTO jump instructions, which often extended over large areas, by introducing block IF and END IF and IF THEN ELSE branches, which significantly increased the readability of Fortran programs. The handling of non-numeric data has also been simplified with the new data type CHARACTER. The PARAMETER instruction also brought a relief that should not be underestimated. For example, by changing a variable of the PARAMETER type, it was possible to adapt field sizes at all points in the program, and thus virtually "dynamic" memory management was possible at compilation time; correct dynamic memory management was only possible with Fortran 90. In the mid-1970s, there was a rapid development in programming techniques and hardware, with the result that the determination of a successor to the Fortran 77 standard was repeatedly delayed because the proposals were in some cases already out of date when they were submitted. In essence, the Fortran 77 standard lasted for almost 15 years, with most of the available compilers adding a few instructions to the ANSI standard (e.g. DO WHILE or END DO) as defined by MIL-STD-1753 of the US Department of Defense in 1978 were. The long-delayed Fortran 90 standard was accepted as the ISO in 1991 and as the ANSI standard in 1992. Fortran 90 was a big step and introduced a lot of innovations. I would like to briefly list the most important ones here:

  • Free format for Fortran programs (columns 1-6 and 72-80 are no longer significant)
  • Operations with entire fields or field areas and no longer only with individual elements
  • Use of modules with access rights to individual areas
  • Improved parameter transfer
  • Derived and abstract data types
  • Dynamic memory allocation
  • SELECT CASE to avoid lengthy IF THEN ELSE constructions
  • and much more

Although Fortran 90/95 is still the de facto standard today, development has continued and continues. Fortran 95 is a further development of the Fortran 90 standard, which, in addition to eliminating open questions of the 90 standard, mainly took over constructs to support programming on parallel computers from HPF (High Performance Fortran).

The next standard in 2003 was another big step forward when object-oriented programming was supported with Fortran for the first time, which enables the use of object-oriented paradigms such as inheritance or polymorphism. This standard is already largely supported by the currently available compilers. How much the innovations of this standard are already being implemented in existing programs would certainly be worth a closer examination. However, I dare to doubt that existing large packages, which have been developed over the years and have essentially reached Fortran 90/95, will quickly be expanded to include object-oriented options. However, Fortran 2003 or the 2008 standard accepted in 2010 would be an attractive alternative to C ++, as the existing fast numerical libraries should provide a runtime advantage.

This leads to other reasons for Fortran's survival for nearly 60 years: the compilers and existing program libraries. As mentioned above, even the first Fortran compiler was a well-optimizing compiler and this tradition continued. In principle, the strength of the Fortran compiler has always been the good coordination of the optimization possibilities of the compiler with the possibilities of the hardware used, which means that hardware manufacturers also had or have a team for compiler development or work closely with an external compiler manufacturer. That is why IBM always had its own compiler, which was and is perfectly matched to the respective architecture, be it 390 mainframe or power architecture of the workstations or parallel computers. The same was true for DEC, whose Fortran was almost something of a gold standard for both the VAX computers and the Alpha RISC processors. It was also indicative of the importance of good compilers for hardware manufacturers that Intel took over the DEC Fortran Compiler Team after the merger of DEC with COMPAQ (later HP) and thus created the basis for the de facto standard for x86 CPUs, the Intel Fortran Compiler who is able to exhaust the possibilities of Intel CPUs, which unfortunately was only true to a limited extent for AMD's x86 CPUs in the past. In the latest versions of the Intel Fortran compiler, however, this shortcoming should be eliminated. This is also shown by a runtime comparison of 16 Fortran programs with typical numerical tasks that were compiled with the x86 compilers available today (see www.polyhedron.com/compare.html). A big plus point of the Intel compiler is its relatively low price for universities and non-commercial users. A third major manufacturer, SUN, is still making its SUN Studio Fortran Compiler available free of charge after the takeover by Oracle. The compilers of the GNU Compiler Suite g77 and gfortran, which are based on the GNU gcc compiler backend and partially support the 2003 and 2008 standard with gfortran, are also free of charge. A very nice overview of all available compilers is e.g. This can be found, for example, at www.fortranplus.co.uk/fortran_info.html.

Good libraries for mathematical functions or operations, such as B. algebraic matrix operations or efficient fast Fourier transformations. Such are z. B. made available by IBM in the ESSL library or by Intel in the MKL library optimized for the CPU architecture. With ACML (http://developer.amd.com/cpu/Libraries/acml/pages/default.aspx), AMD also offers a highly optimized numerical library for downloading for a number of Fortran compilers. A wealth of high quality alternative numerical libraries such as LAPACK or SCALAPACK can be found on Netlib (www.netlib.org), the latter being integrated in ESSL and MKL but also in ACML.

All these possibilities with regard to compilers and efficient libraries together with the properties of the Fortran standard that are particularly suitable for solving numerical problems have created an environment that makes Fortran the language of choice for solving scientific problems today and in the foreseeable future. Of course, one should also not forget the large amount of publicly available high-quality Fortran code that has accumulated over the last 60 years, and the fact that numerical codes in particular cannot be easily ported to other languages, which usually leads to large Parts have to be rewritten, which in the case of a notorious unavailability of free programmers in scientific environments encounters natural resistance, apart of course from the aversion of scientists to learn a new language that they consider unnecessary, as already mentioned at the beginning.

For this article, in addition to the quotations cited, use was made of relevant Wikipedia articles and references cited therein as well as of posts on comp.lang.fortran.