Coronavirus (Covid-19): Latest updates and information
Skip to main content Skip to navigation

Fortran for Researchers

Slides

Part 1 - Fortran Basics

Part 2 - Arrays

Part 3 - Last Essentials

Part 4 - Other Parts of Fortran This briefly covers almost all the rest of Fortran you might want to use. We don't talk through this, but we do demonstrate it all in the Model codes linked below.

Example Code

All of the example code from the slides, and suggestions and model solutions for programs from Hello World up to almost useful codes are available on Github here.

Other Useful Links and Material

Books Etc

Some "cheatsheet" summaries of the fiddlier parts of Fortran are here along with a description of "Old" (pre 90) Fortran, which you might still come across "in the wild".

Our recommended book for Fortran is Introduction to programming with Fortran : with coverage of Fortran 90, 95, 2003, 2008 and 77 by Ian D. Chivers, Jane Sleightholme. You can find the Springer e-Book in the library (ISBN 9783319177014).

This is a really nice "self-study" guide to Fortran 95 (reproduced w. thanks to Dr Padman)

Online Resources

Doctor Fortran - Steve Lionel worked on Intel's Fortran compiler team for years, and knows Fortran as well as anybody possibly can. He has a series of blog posts, and pops up on Stack Overflow, Intel's developer zone and elsewhere.

Learn X in Y minutes is a handy site for just the syntax and ideas of a new language. Written like a program listing, these go through the basics. They can be a bit intense in a language you've never seen before though.

Rosetta Code is an attempt to compile lots of people's approaches in lots of languages. BEWARE though - nobody reviews these for style. They mostly work as expected, but can suffer from being too clever by half, especially in Fortran, in which you also have to watch out for FORTRAN77 and what are now "bad habits" engrained by it.

The Computer Language Benchmark game has some good examples of how the Fortran you would write as your first solution can actually be almost optimally performant already. In particular, the Fortran examples tend to be much simpler than the hand-optimised C, while getting 90% or more of the performance in the numerical problems. The String problems do not suit Fortran and for some reason the Binary Trees problem also works poorly (possibly the recursion is troublesome?).

Videos

We have some videos on a few of the fiddlier bits of Fortran:

Creating a module, step by step

The Application Binary Interface. Can compilers talk to each other? What about languages? How?

What interfaces are and why they're used

Reading the Fortran Standard document - what does x = func1() * func2() do?