Fortran compilers

CAMB internally uses modern (object-oriented) Fortran 2008 for most numerical calculations, and needs a recent fortran compiler to build the numerical library. The recommended compilers are

  • gfortran version 6.3 or higher

  • Intel Fortran (ifort), version 18.0.1 or higher (some things may work with version 14+)

The gfortran compiler is part of the standard “gcc” compiler package, and may be pre-installed on recent unix systems. Check the version using “gfortran –version”.

If you do not have a suitable Fortran compiler, you can get one as follows:


Download the binary installation


Download gfortran as part of MinGW-w64 (select x86_64 option in the installation program) or get latest from niXman on GitHub (e.g. x86_64-13.2.0-release-win32-seh-msvcrt-rt_v11-rev1)


To install from the standard repository use:

  • “sudo apt-get update; sudo apt-get install gfortran”

Alternatively you can compile and run in a container or virtual machine: e.g., see CosmoBox. For example, to run a configured shell in docker where you can install and run camb from the command line (after changing to the camb directory):

docker run -v /local/git/path/CAMB:/camb -i -t cmbant/cosmobox

Updating and modified Fortran code

In the main CAMB source root directory, to re-build the Fortran binary including any pulled or local changes use:

python make

This will also work on Windows as long as you have MinGW-w64 installed under Program Files as described above.

Note that you will need to close all python instances using camb before you can re-load with an updated library. This includes in Jupyter notebooks; just re-start the kernel or use:

import IPython

If you want to automamatically rebuild the library from Jupyter you can do something like this:

import subprocess
import sys
import os
src_dir = '/path/to/git/CAMB'
    subprocess.check_output(r'python "%s" make'%os.path.join(src_dir, ''),
    import camb
    print('Using CAMB %s installed at %s'%(camb.__version__,

except subprocess.CalledProcessError as E: