HomeNews and blogs hub

From Punchcards to Particle Accelerators: Modernising Fortran

Bookmark this page Bookmarked

From Punchcards to Particle Accelerators: Modernising Fortran

Becky Arnold

Becky Arnold

SSI fellow

Posted on 8 May 2019

Estimated read time: 4 min
Sections in this article
Share on blog/article:
Twitter LinkedIn

From Punchcards to Particle Accelerators: Modernising Fortran

Posted by s.aragon on 8 May 2019 - 10:26am University of Manchester building Image by Stephen Richards

By Becky Arnold, University of Sheffield.

On the 4th and 5th of April I attended a workshop on modernising Fortran at the University of Manchester. In technological terms, Fortran is kind of a living dinosaur, like a crocodile. The difference is crocodiles have survived basically by having bigger teeth than everything around them. Fortran survived partly due to its inherent strengths, but mostly by evolving and expanding. This workshop focused on how the language has changed over time, and how to bring older Fortran code up to date.

The workshop took place in the University of Manchester’s Sackville street building, which is as beautiful as the picture above illustrates, and twice as labyrinthine. One of my colleagues – and I am not joking – somehow ended up on the roof while trying to find the workshop on Thursday morning. Luckily I was able to find it quite easily as I got the “running around desperately looking for the right room” step out of the way whilst trying to find exam halls when I did my undergrad in Manchester. But I digress.

The workshop took a very holistic approach. Fortran has existed for longer than most of the workshop’s attendees, and has evolved considerably over that time. This evolution has been informed by (and has itself informed) the development of the wider technological landscape. Understanding this context and history is useful for understanding how the language has progressed and why it has done so in the way it has. Fortran originated back when computer programs were still written on punchards. Memory was scarce, processors were slow, which meant the programming language could not have a single spare ounce of fat. As a result one of Fortran’s major features/advantages is that it can do maths very fast, and even by today’s standards that holds true. This is why, despite the language originating over sixty years ago, many modern programming languages contain large amounts of fortran below the bonet, and why code written in this language exists even in futuristic facilities like particle accelerators.    

Some of the workshop focused on stylistic changes, such as changing relational operators such as .LE. (less than or equal to) to their more readable forms like <=. Another suggested change was to alter keywords that were previously capitalised by convention (such as PROGRAM) to lowercase versions which are more readable, and let’s be real, less ugly. Adopting naming conventions such as using CamelCase for subroutine names, lowercase for matrix names etc can also be useful to make code more quickly understandable.

Features of Fortran such a derived types were also outlined. Derived types can be helpful when a code contains common structures, e.g.:

type rectangle

 real :: length, width

end type rectangle

football_pitch = rectangle(90, 120)

On the other hand some of the advice given was to not use some features, such as GOTO statements which can lead to hard to follow “spaghetti code”. The consequences of GOTO statements can quickly get out of hand, as illustrated by xkcd:

xkcd comic

There was far too much content in this workshop for me possibly outline here (407 slides for the 2 day presentation!) but the main thing I took away was that Fortran is old but evolving, and is likely to have a large role in research computing for decades to come.

Share on blog/article:
Twitter LinkedIn