For me, the word “Fortran” brings back nostalgic memories of coding sheets, late nights, and really bad coffee. Things have changed a lot in 40 years, and so has Fortran. No longer uppercase only and a fixed layout, modern Fortran code doesn’t look very different from any other modern programming language. The language remains not only relevant, but is still the language of choice for particular niche tasks such as precision mathematical calculations with lots of floating-point data. Parallel programming capabilities have been built in since 2008, and there is a huge body of well-written and debugged Fortran routines out there for reuse.
Simply put, this book by Clerman and Spector is a style guide for writing modern Fortran. It doesn’t aim to teach Fortran programming, but instead introduces the concepts necessary for writing good, easy-to-read code. The authors also alert more experienced programmers to the new functionality and techniques available in modern Fortran.
Chapter 1 is a brief introduction to the layout of the book. Clerman and Spector then deliver several short chapters on coding style. Chapter 2 lays down general principles for writing good code, which continues in chapter 3 with guidelines for formatting and layout. This chapter demonstrates the dramatic improvements in formatting compared to earlier Fortran versions. Chapter 4 discusses conventions for naming variables and procedures, and chapter 5 covers documentation, emphasizing self-documenting code. Chapter 6 discusses how to use modules to better organize code, and chapter 7 covers the initialization and management of data objects and flow control through procedures, particularly the graceful handling of errors. Chapter 8 presents guidelines for using Fortran’s detailed input and output statements. Chapter 9 discusses the organization of source code into modules and highlights recent additions to the language that assist the logical packaging of source code in files.
The last few chapters cover a number of general topics. Chapter 10 looks at general writing techniques, chapter 11 introduces object-oriented Fortran programming, and chapter 12 introduces various techniques for parallel processing using Fortran. Chapter 13 covers floating-point operations and chapter 14 discusses C interoperability. The final chapter provides recommendations for updating older, pre-Fortran 90 programs.
The appendices contain source code listings for programs referenced throughout the book and a summary list of the rules and guidelines that Clerman and Spector recommend for producing well-written Fortran programs. The idea of a separate numbering for these rules/guidelines throughout the book is a good idea, but the layout and integration of that numbering with the separate section numbering makes navigating the book difficult. Large blocks of source code are liberally sprinkled throughout the book to illustrate the coding style points. However, this also tends to make navigating the book a bit difficult. The book has a good table of contents and bibliography, and an adequate index.
Clerman and Spector provide guidelines for writing good, readable Fortran programs. The book will be useful for new programmers looking for guidance in good coding style, as well as for experienced programmers, particularly those maintaining or updating old Fortran code.