A Personal History of the NAG Fortran compiler
The year was 1988. The revision of the Fortran standard had fallen into turmoil.
The committee which was revising the language standard for ISO, X3J3 (the U.S. Fortran committee, which has since changed its name to J3), was split roughly into three warring factions:
- The progressives: those who wanted to very greatly modernise the language (mostly users).
- The traditionalists: those who wanted to freeze the language, or perhaps just adopt extremely minor extensions (mostly vendors).
- The moderates: those who wanted to modernise the language, but not by as much as the first group (some users, some vendors).
After the end of the public consultation period in 1987, these three groups could not agree on how to proceed. The traditionalists were saying that the proposed new language could not be implemented. Each moderate was saying that the proposed language was too complicated, and besides was missing his favourite feature (a different one for each person). The progressives were saying that the others just wanted to ruin the new language by taking away the good bits. (Note: In reality it was a good deal more complicated than this, but this is a reasonable simplification which gives some idea of the problem at the time.)
The issue came to a head in the middle of 1988, at the meeting in Paris of the ISO working group on Fortran (this committee rejoices in the name of ISO/IEC JTC1/SC22/WG5). This working group has the responsibility for revising the Fortran standard, though then as now the technical work was essentially delegated to the American committee. Due to the impasse on the American committee, WG5 decided that it was its responsbility to decide what should be in the new language, and therefore discussed the competing proposals.
In response to the traditionalists' claim that the language was so complex and unwieldy that it could never be implemented, at this meeting Julian Tilbury of Salford Software and myself presented a front-end for Fortran 8x (the working name for the language revision) suitable for building software tools or indeed a compiler. It was significant that this demonstration (which analysed the complete, supposedly non-implementable, language) had taken only 3 months to write from scratch. (The demonstration did not quite go without a hitch, because the keyboard was French but the software treated it as English. So when typing in examples I had to close my eyes - or stare fixedly at the screen - and type where I remembered the keys ought to be instead of looking at the keyboard.)
In the event, WG5 decided on a relatively progressive modernisation of the language which would address the concerns expressed by the international community, and specified what new features the language should contain. In more hope than expectation that the work could be quickly done WG5 suggested that the new language be called Fortran 88, and this then became Fortran 90 after the work took longer than hoped.
NAG has built its reputation on a number of fine products, but by far the most important in terms of customers was its numerical library in Fortran. It was clear to NAG that Fortran continued to offer the best facilities for writing numerical software, and that NAG had an interest in Fortran maintaining its market share. It was also believed that Fortran would simply wither away if it were not quickly modernised, which is why NAG supported the efforts of the standards committees by attending these meetings (and also in helping to produce the demonstration in Paris '88).
NAG needed to have early access to Fortran 90 compilers, so that it could develop its products ready for when the compilers became widely available. Furthermore, having made extensive successful use of Fortran (66, then 77) software tools in the development and quality assurance of its Fortran (66/77) library, it wanted also to have access to Fortran 90 software tools. It was also thought that NAG producing a compiler would act as a spur to the other compiler vendors, and also ensure that even if a native vendor compiler was not available for some particular machine, we would have our own that we could use.
It was in the late spring of 1990, in conversation with one of the directors of NAG about the future of Fortran, that it was suggested that I might be able to write a compiler for the new language. I replied that naturally I thought I could do such a thing, having had a long-standing interest in programming language design and implementation, and indeed had designed a language of my own and written a compiler for it while I was at college (a much smaller language than Fortran 90, though!).
Perhaps I should not have been surprised at the turn of events ... first my manager asked me how long I thought it would take me to write a compiler (I answered "definitely more than a year; say about fifteen months?"). The next thing I knew was that had become my assigned task and I had a deadline set at fifteen months! Needless to say, during that development period I worked harder and longer than ever before on a single product.
The first decisions to be taken were the target machine or language, and the implementation language. I decided both to write the compiler in C, and to produce C (as a portable assembler). Some of the reasons being
- I was sufficiently familiar with C to be able to write highly portable code.
- C compilers were widely available (if less so than now).
- It would allow the compiler to be very quickly ported to new systems.
- I could use the C compiler optimiser, reducing the amount of optimisation that the Fortran compiler needed to do itself.
Most of the Fortran 90 features were familiar to me, as I had encountered similar features in other programming languages. One problem was simply the number of features and their interactions. It is possible to put on an extra burst of energy to reach the top of a hill that is within sight, but maintaining that level of output when climbing a mountain is not so easy. One gets to the top of one peak, only to be greeted with the sight of additional vistas opening before you.
The largest feature that I was relatively unfamiliar with was the array syntax and the whole array operations. Since for the first release in particular, correctness was a much more important goal than performance, I took a very simple approach to handling array expressions. Since I was unsure exactly how to evaluate a whole array expression at once, but knew how to evaluate any single array operation, every array expression was broken down into single operations producing a temporary array result. This approach was very successful in guaranteeing the right answer, but unfortunately also quite successful in not providing good performance. (This is why, in release 2.0 a couple of years later, the array expression handling was completely rewritten.)
Another major problem was that of testing the compiler. For the subset that was in Fortran 77 there were existing test suites we could (and did) use. For numerical accuracy we had our own tests and library. But for all the new features there was, of course, virtually no code in existence - just a few examples in the standard itself and in books such as Mike Metcalf and John Reid's "Fortran 90 Explained" (we found this book so clear in its explanations of the new language that we decided to use it as the compiler manual).
I wrote many individual feature test programs myself during development, but this was not sufficient to ensure that features would work when used together. We knew that Brian Smith and others were writing a test suite, so in exchange for use of the prototype compiler to test their test programs, we got bug reports back when the compiler went wrong. This proved to be invaluable, and doubtless without this it would have taken many months longer to bring the compiler to a releasable quality.
By the spring of 1991 I found that I needed a break from doing the compiler all day, so in the evenings I decided to build a car (a Caterham Super Seven). It seems that cars must be simpler than compilers though, as I finished the (high performance) car first!
And so, after many trials and tribulations, the compiler was finally released (as the world's first Fortran 90 compiler) in September 1991, at virtually the same time that the standard saw publication.
For all my hard work in producing the compiler I was rewarded with the tasks not only of supporting and maintaining it, but to extend and enhance it to encompass new language standards (HPF, then Fortran 95 and now Fortran 2003), user requests for extensions (many, mostly historical "dusty-deck" style language), greater performance, and even more facilities for detecting errors in programs both at compile time and execution time. As I write, the current release of the compiler already includes a substantial number of Fortran 2003 features, and work is underway on further improvements.
Malcolm Cohen, Tokyo, October 2004.