Prerequisites

This book teaches Fortran from scratch, but it does not teach programming from scratch. Here is exactly what you need before Chapter 1 — and, just as importantly, what you do not need.

What you need

You have programmed before, in some language. Python, C, C++, Java, MATLAB, R, Julia — any of them. You should be comfortable with the ideas every language shares:

  • Variables and types — that a program stores values, and that 3 (an integer) and 3.0 (a real number) are different kinds of thing.
  • Control flowif/else decisions, and loops that repeat work.
  • Functions — packaging a computation so you can call it with different inputs.
  • Arrays / lists — an ordered collection of values you can index into.

If you can read this Python function and say what it does, you are ready:

def average(xs):
    total = 0.0
    for x in xs:
        total += x
    return total / len(xs)

You are comfortable with a little mathematics. Algebra; what a matrix is; what a derivative and an integral represent. The mathematics never runs ahead of the computation — we introduce each idea (a finite difference, a linear system, machine epsilon) at the moment the code needs it, in Part V and the performance chapters. Appendix D is a self-contained refresher you can lean on.

You can use a command line. You will compile programs by typing a command in a terminal — gfortran myprogram.f90 -o myprogram — and running the result. If you have never done this, that is fine: Chapter 2 and Appendix C walk you through installing the compiler and using the terminal on Linux, macOS, and Windows, step by step. You need only be willing.

What you do NOT need

  • No prior Fortran. Not a line. If you have seen FORTRAN 77 and disliked it, so much the better — you will see how different modern Fortran is.
  • No high-performance computing experience. Cores, threads, processes, and clusters are all explained from the beginning (Part VIII).
  • No knowledge of compilers, linkers, or how a CPU works. We explain what you need, when you need it.
  • No access to a supercomputer. Every example in the book runs on an ordinary laptop. The parallel chapters run on your laptop's own cores, and the MPI examples run as multiple processes on one machine — a real cluster is nice to have but never required.

A quick self-check

You are ready if you can answer these without looking anything up:

  1. What is the difference between the integer 7 and the real number 7.0?
  2. In your favorite language, how would you sum the numbers from 1 to 100 with a loop?
  3. What does it mean to call a function with an argument?
  4. If A is a matrix and x is a vector, roughly what is A times x?

If those feel comfortable, turn the page. If question 2 or 3 gave you pause, spend a week with any introductory programming tutorial in any language first — the specific language does not matter — and then come back. Fortran will be waiting, and it is not nearly as intimidating as its reputation.