Compiling | Inputs | Outputs| Customization | History | Comparison | Source files | Accuracy | Add-ons | References


Code for Anisotropies in the Microwave Background by Antony Lewis and Anthony Challinor.

This version August 2018.

Originally based on CMBFAST developed by Uros Seljak and Matias Zaldarriaga, itself based on Boltzmann code written by Edmund Bertschinger, Chung-Pei Ma and Paul Bode. For latest information on this program see

CAMB is also supplied as part of the CosmoMC parameter estimation package. For an extension including perturbed recombination, 21cm, lensing and number count sources see CAMB sources (latest in the devel branch on github).

Compiling and running

To install and compile yourself you will need a Fortran 90 (or higher) compiler - you can get the free gfortran compiler, or the optimized Intel compiler ifort is installed on many academic clusters and also supports integrated development and debugging in Visual Studio under Windows. Alternatively you can use CAMB in the pre-configured CosmoBox virtual machine.

To install yourself from the command line:

The Makefile comes set up for gfortran and ifort compilers. Edit the relevant parts of the Makefile to compile on other systems. If you have Intel's Visual Fortran you can use the projects in the VisualStudio folder, no need to use the Makefile. To run on multi-processor machines add the -openmp (or equivalent) option to the Makefile's FFLAGS parameter to compile a parallelized (OPENMP) version. The code is also available from GitHub.

Martina Schwind has kindly contributed some introductory slides with details of program running and internal structure. For some further technical details about the algorithms, equations and code see the CAMB notes. For a demo of how to use CAMB with the python wrapper see the demo notebook.

Input parameters

The params.ini file specifies the parameters used to run the program. Comments in params.ini should make this fairly self-explanatory, more complicated cases, for example to run with multiple neutrino mass eigenstates and sterile neutrinos at different temperatures see the documentation and examples in the CAMB notes. To produce the matter power spectrum in addition to CMB Cl set get_transfer = T; the do_nonlinear input parameter determines whether this is output as the linear power spectrum or includes non-linear corrections from the Halofit model.

The default params.ini file produces results in μK2 from the given primordial curvature perturbation power (scalar_amp) on 0.05 MPc-1 scales. To get unnormalized dimensionless results set scalar_amp(1)=1 and CMB_outputscale=1. To compute lensed Cls you must set the normalization to some realistic value (the calculation is non-linear, so normalization matters).


Unlensed scalar angular power spectra are output to output_root_scalCls.dat. The columns are
Here all CX are l(l+1)C_l/2pi except for CΦ and CΦT which are CΦ= l4 ClΦ, where ClΦ is the (CMB) lensing potential power spectrum, and CΦT = l3 ClΦT. The lensing terms in square brackets are only produced if do_lensing = T. If CMB_outputscale = 7.4311e12 ([TCMB106]2, the default), the units are μK2. Note that lensing spectra are also multiplied by CMB_outputscale, so you may want to divide this out of the answer to get a sensible dimensionless spectrum or use the lens_potential_output_file file mentioned below. If requested the lensed power spectrum is output to output_root_lensedCls.dat

Tensor angular power spectra are output to output_root_tensCls.dat if requested. The columns are

If scalars and tensors are generated, the total spectrum is in output_root_totCls.dat, in the same format as the tensor output file.

If do_lensing=T and lens_potential_output_file is specified a file is output containing unlensed scalar (+tensor if calculated) spectra along with the lensing potentials in this format:

where as before CX are l(l+1)Cl/2π, and d is the deflection angle, so Cdd=[l(l+1)]2ClΦ/2π, CdT=[l(l+1)]3/2ClΦT/2π, CdE=[l(l+1)]3/2ClΦE/2π. These are the spectra required for simulating lensed skies using

If transfer functions are requested the columns in the output_root_transfer.dat output file are:

1 k/h wavenumber in h Mpc-1
2 Delta_CDM/k2 CDM
3 Delta_b/k2 baryons
4 Delta_g/k2 photons
5 Delta_r/k2 massless neutrinos
6 Delta_nu/k2 massive neutrinos
7 Delta_tot/k2 CDM+baryons+massive neutrinos
8 Delta_nonu/k2 CDM+baryons
9 Delta_totde/k2 CDM+baryons+massive neutrinos+ dark energy(numerator only)
10 Φ The Weyl potential (φ+ψ)/2
11 vel_Newt_cdm/k2 vel_Newt_cdm is -vcdm k/H (Newtonian-gauge CDM velocity vcdm)
12 vel_Newt_b/k2 vel_Newt_b is -vb k/H (Newtonian-gauge baryon velocity vb)
13 vel_baryon_cdm/k2 relative baryon-CDM velocity (vb-vcdm)

where Delta_X is defined as (delta rho_X)/rho_X in the synchronous gauge and evaluated at the requested redshift, given a unit primordial curvature perturbation on superhorizon scales (for adiabatic modes, chi_0=-1). The column numbers correspond to the Transfer_xx integer constants defined in the Transfer module (modules.f90).

output_root_matterpower.dat contains the conventionally normalized matter power spectrum (for baryons+cdm+massive neutrinos), in h/Mpc units.

Compilation options and code modifications

You can edit the Makefile's EQUATIONS, POWERSPECTRUM, RECOMBINATION and REIONIZATION variables , which determine which module is used to implement and model various parts of the calculation. The POWERSPECTRUM.f90 file7 contains a module giving the initial power spectrum, the EQUATIONS.f90 file contains the background evolution equations and sets of gauge-dependent perturbation equations (the alternative equations_ppf.f90 is provided to implement the common w, wa varying dark energy parameterization). RECOMBINATION.f90 gives the background recombination history: recfast by default, but you can also compile to use CosmoRec and HyRec. REIONIZATION is by default a simple relatively fast single-step reionization model (following arXiv:0804.3865). Various other modules can also be changed at compile time if desired. To avoid problems run make clean after changing the Makefile before recompiling. You can also use e.g. make RECOMBINATION=cosmorec to override the default and compile with a different module.

You can produce files in FITS format - to do this you will need to have HEALPIX installed and make some edits to the Makefile - see the Makefile for details. After compiling with make camb_fits, you can then use camb_fits instead of camb - the FITS file produced is given the name specified in params.ini. Note that the FITS file format for polarization changed with HEALPIX 1.2, CAMB uses the new format.

All the equations that need to be modified for simple non-standard models are in the equations.f90 file. It should be possible to produce other files for extended models (see the sample quintessence module). (Note that varying constant - e.g. alpha - models are not quite so simple to plug in; a sample equations_ppf.f90 file provided to implement a varying w dark energy equation of state in the PPF model).

After modifying any of the source code run make clean before running make to recompile (Visual Fortran will re-compile dependent code automatically). Run make all to build a library libcamb.a that you can use when linking to other programs. (You will also need to include the module files using -I/cambfolder).

Some details about what different source code files do are given below, see also the CAMB notes.

A test suite is included, and will run automatically on Travis when committing or making pull requests on the GitHub repository. Python unit tests are in the pycamb/camb_tests directory, and scripts for comparing outputs for a variety of models (as run on Travis) are in the tests directory.

Version history

August 2018
August 2017
January 2017
November 2016
May 2016
November 2015
February 2015
January 2015
April 2014
March 2014
December 2013
November 2013
October 2013
September 2013
July 2013
March 2013
October 2012
January 2012
December 2011
October 2011
July 2011
January 2011

January 2010
Recfast updated to version 1.5 (rising to 2% change at l=2000; added rate fudge to match 0910.4383; use RECFAST_Hswitch = F to recover old result). Added lens_potential_output_file parameter to get sensibly normalized lensing potential ([l(l+1)]2Cl/2π and temperature correlation). Added code parameter do_bispectrum to modules.f90 for parameter tweaks to get accurate transfer functions for fNL calculations.

February 2009
Fixed serious bug in the calculation of lensed non-flat models (introduced in the Feb 2008 version).

November 2008
Fixed proton mass error (and hence incorrect baryon evolution on pressure-damping scales; note CAMB is not as accurate as CAMB sources anyway due to use of adiabatic pressure).

September 2008
Restructured recombination module to allow use of different models. RECFAST default implementation updated to version 1.4.2 (+fixes, tiny change to results). Misc minor changes.

June 2008
Fixed significant bug affecting very closed models (introduced Feb 2008; slightly closed models were fine).

March 2008
(26th March, fixed pivot parameters in sample .ini)
New reionization history model: new input parameter re_delta_redshift (does not change optical depth), and option to set re_ionization_frac=-1 to automatically set the reionization fraction from input YHe assuming Helium is singly reionized at the same time as hydrogen (hence mapping of redshift to optical depth different to before at 10% level; see the notes). Reionization history now specified in (replaceable) module in reionization.f90; default includes tiny effect of He double reionization at z~3.5. Some internal reorganization. Added pivot_scalar and pivot_tensor input parameters for initial power spectrum. output subroutine (equations.f90) re-arranged to separated ISW source terms.

February 2008
Updated RECFAST to version 1.4 (~0.5% effect at high l; new RECFAST_fudge_He,RECFAST_Heswitch parameters, removed Dubrovich modifications). lensed_total_output_file parameter to get lensed scalar plus tensor power spectrum. Calculates CosmoMC's theta parameter for each model (code in modules.f90). Modules routine MatterPowerData_Load to read in matter power (for splining from pre-computed file); MatterPowerData_k function now extrapolates low-k out of range. transfer_interp_matterpower parameter to switch between interpolated regular grid in log k or array at actual computed values (better for later re-interpolation). Added camb.vfproj Intel Visual Fortran project file. Simplifying internal changes from CAMB sources, e.g. use of Ranges module for setting time steps and k sampling values; also now switches to log k source spacing at very high l to speed up calculation where spectra smooth. More diagnostics and options in the test suite.

November 2006
Updated RECFAST to version 1.3 (0.1% effect on Cl). Tweak to get <0.3% error in matter power spectrum around the peak when transfer_high_precision = T.

September 2006
Fixed problem generating combinations of scalars and tensors in camb.f90 (since August version).

August 2006
Speeded calculation of lensed spectra and lensing power spectrum by using Limber approximation on small scales (no loss of accuracy). Fixed missing f_K in source term for non-flat lensing potential. Minor changes to default parameters and compatibility tweaks. Can download test suite for comparing accuracy and code versions.

July 2006
Fixed bug setting default neutrino degeneracy if none specified and initialization of nu_mass_eigenstates for programmatic access. Other minor fixes.

June 2006
Added support for arbitrary neutrino mass splittings. New option to set transfer_k_per_logint=0 to get automatic accurate k-sampling of the matter power spectrum. Fixed Transfer_GetMatterPower at large scales for non-flat models. New setting value massive_nu_approx=3 to use whatever method is good to get fast accurate results. Other internal changes.

March 2006
Fixed bug lensing scalar spectrum when generated at the same time as tensors. New (hard coded) parameter lmin in modules.f90 - set to 1 if you want to generate temperature and lensing potential l=1 (Newtonian Gauge) Cl.

April 2005
Added do_nonlinear option to apply non-linear corrections from HALOFIT (astro-ph/0207664). do_nonlinear = 1 applies just to the matter power spectra, do_nonlinear=2 applies corrections to the lensed CMB power spectra (important for BB). HALOFIT should only be used for standard adiabatic ΛCDM models with power law initial power spectra. New recombination option (1 does RECFAST as before, 2 uses modified version from astro-ph/0501672). New option do_late_rad_trunction to turn off the small scale radiation hierarchies after matter domination (see astro-ph/0503277 and the notes) - saves some time. New output_root option to prefix output file names and generate output_root_params.ini file of input parameters for the run.

November 2004
Default lensing routine (lensing_method=1) changed to use new full-sky correlation function method (astro-ph/0502425) in preference to the harmonic method of astro-ph/0001303 (lensing_method=3; inaccurate at l>1000 at ~1.5% level by l=2000). The lensed result is now significantly faster and more accurate. Also added flat-sky method (lensing_method=2) of astro-ph/9505109 and astro-ph/9803150 as in CMBFAST (accurate to 0.4%). New accurate_BB parameter to get lensed BB accurately (within assumptions of linearity and given k_max, l_max, etc.). Note lensed_output_file no longer contains any tensor contribution. Various changes for better accuracy and compiler compatibility, including same accuracy with massive neutrinos as with massless.

August 2004
Fixed effect of reionization on the lensed Cl (0.5% on small scale TT).

June 2004

Fixed serious problem with tensor mode polarized Cl from reionization (significantly underestimated power). Changed default tensor pivot scale to 0.05 Mpc-1 (same as for scalars). Flat Bessel functions no longer cached to disk (faster to compute than read in many cases; prevents problems in uses with MPI). New accurate_reionization flag for accurate calculation of large scale scalar EE around the first dip (also outputs computed optical depth due to reionization). Option to output vector mode spectra from regular vorticity mode (astro-ph/0403583) or magnetic field (astro-ph/0406096).

December 2003
Fix - 17 Dec: corrected problem with significantly non-flat models (e.g. ΩK=-0.1, H0=40)

Improved accuracy of non-flat calculation, and allowed for very nearly flat models (ΩK ~ 1e-5). Non-flat code should be as accurate as the flat (0.5%) on most scales. Added run-time parameters do_tensor_neutrinos (to include the neutrino evolution in the tensor equations) and cs2_lam (constant sound speed of the dark energy) instead of having to modify the code. Fixed fatal bug in tensor neutrino setup introduced some time this year. Added parameter CMB_outputscale to scale output Cls by a constant (see comments in params.ini for getting microK^2 output).

July 2003

Fixed instability in bessels.f90 which gave problem for very nearly flat closed models with abnormal Helium fractions (and possibly other models). Dark energy equations in equations.f90 changed to use simpler general fluid equations for the perturbations (see astro-ph/0307104). inidriver.F90 now reads in scalar amplitude even if computing tensors only (so combination with the initial ratio sets correct tensor amplitude).

May 2003

Fixed bug in equations.f90 giving errors with non-flat models. Fixed bug in inidriver.F90 setting H0 with use_physical=F. Fixed camb.f90 file in download - missing routines for getting Cl transfer functions.

April 2003

Some major restructuring, including new functions to return the CMB transfer functions (see camb.f90). The tight coupling code has been re-written, adding quadrupole terms and accounting for the time variation of the opacity numerically. The code should be more accurate and faster, especially on small scales. Minor fixes to RECFAST to match version in CMBFAST (0.01% effect on Cls), and bug fix in output routine (0.3%). Includes constant w dark energy and running spectral index parameters by default (rather than with an add-on). New use_physical parameter to allow alternative model specification by Om_b h^2, Om_b h^2 and Om_k. Polarization .fits files now compatible with HEALPIX 1.2.

November 2002

Minor changes for greater compiler compatibility, in particular with Visual Fortran. Makefile includes suggested options for a variety of compilers.

September 2002

Added support for neutrino isocurvature initial conditions, and totally correlated mixed initial conditions (assuming the same power spectrum for each mode) - new initial_vector parameter in params.ini. Partially correlated mixed initial conditions can be computed by combining results from different runs with totally correlated initial conditions.

July 2002

Changes for compatibility with CosmoMC. New option to output matter power spectrum. Changed default pivot point for tensor initial power spectrum to 0.002 MPc-1 (power_tilt.f90), added pivot point and normalization to initial power parameters. Minor enhancements to inifile.f90. Utility routines Re_OpticalDepthAtZ and Transfer_GetMatterPower added to modules.f90.

March 2002

Massive neutrino support improved. Background evolution is much faster, and only ever needs to be computed once for all neutrino masses. Output transfer function files now include columns for the massive neutrino and total perturbations. Sigma_8 is now computed including CDM, baryons and massive neutrinos. Fixed problem computing matter power spectrum in massive neutrino models. New parameter massive_nu_approx to control how the massive neutrinos are evolved - option for new approximate fast scheme that is quite accurate for the CMB. New feedback_level parameter that can be used to get useful information about the model being calculated.
Fixed rare problem computing closed models, and bug in computation of closed transfer functions. The names of the massive neutrino subroutines have been changed because the argument that is passed has changed.

February 2002

Fixed FITS file output to start at l=0 rather than l=2 to be consistent with HEALPIX.

January 2002

The code is now fully internally parallelized and lensing is supported. Can now use about 16 processors with good efficiency - just compile with the OpenMP -mp compiler flag. The lensing power spectrum is computed explicitly and then used to computed the lensed CMB power spectra using the full-sky results of astro-ph/0001303 (many thanks for Gayoung Chon for work on the lensed power spectrum code). To generate the lensed power spectra set do_lensing=T in params.ini and the output will be in the lensed_output_file. The lensing power spectrum l4 Clφφ is also output as the 5th column of the scalar_output_file, followed by the cross-correlation with the temperature l3 ClφT.

October 2001

Fixed bug in RECFAST - corrects C_l errors at 1-2% level. Background evolution is now determined from routines in gauge_inv.f90 (and gauge_sync.f90) - you now only need to edit these files to add additional matter components, use extended theories, etc. RECFAST now consistent with massive neutrinos. Added Makefile for better compilation, and added option to create FITS format power spectrum files. Changed driver.f90 to driver.F90, and new file writefits.f90. Some minor changes to ease use with a wider range of compilers (e.g. NaG F95 for Linux).

May 2001

Fixed the neutrino ratio factor in the normalization of the scalar power spectrum to be consistent with the power spectrum as defined since the January 2001 version. Changes to gauge_inv.f90 and gauge_sync.f90.

April 2001

New example code. These samples show how you can call CAMB from other programs via a subroutine. There are also improved InitialPower modules for parameterizing the initial power spectrum to obtain meaningful tensor/scalar ratios for general models and for parameterizing in terms of slow-roll inflation parameters.

Fixed a floating error arising when both tensor and scalar spectra are generated but with ratio zero.

February 2001

Fixed bug in recfast.f90 introduced in August 2000 update (caused erroneous blip in ionization history).

January 2001

New file power.f90 added to separate out the InitialPower module for easily modifying the initial power spectrum. The InitialPower module now has additional parameters to control the normalization of the output Cls, allowing absolute computations using correctly normalized initial power spectra (set the UseScalTensRatio parameter to false to compute the tensor/scalar ratio correctly from the initial power spectra in general models). The InitialPower module is now commented to fully explain the definition of the power spectra that should be returned by the TensorPower and ScalarPower routines.

The transfer functions are now output in terms of k rather than beta (nu*K) in non-flat models, and the way to compute the matter power spectrum from the transfer functions via d2norm is documented. The variables used to propagate the tensor modes in gauge_inv.f90 have been changed to be equivalent to the metric variables, improving stability when DoTensorNeutrinos=true.

September 2000

Now uses an accurate approximation to propagate massive neutrino perturbations once no longer highly relativistic, speeding up computation by about a factor of two (gauge_inv routine only). All massive neutrino code is now re-organized into a module called MassiveNu in modules.f90. The massive neutrino equations are described in astro-ph/0203507

August 2000

Minor changes to recfast.f90 and modules.f90 to prevent floating point errors on some systems. (Thanks for Louise Griffiths)

July 2000

Fixes inaccurate computation of the tensor quadrupole in flat models, pointed out in astro-ph/0006392 . The only code change is to subroutine TensSourceSumIntJl in cmbmain.f90.

February 2000

Massive neutrinos are now supported. The treatment is essentially the same as CMBFAST. However gauge_inv now includes neutrino anisotropic stress in the tensor computation by default, accounting for massive neutrinos when appropriate. You can revert to the old default by changing the "DoTensorNeutrinos" parameter in gauge_inv.

This version also fixes the tight coupling switch over to give accurate results with gauge_sync. This fixes errors introduced in CMBFAST 3.0/CAMB Nov 99.

November 1999

Adds support for RECFAST recombination and fixes various bugs that were in CMBFAST 2.4.1 but fixed in CMBFAST 3.0. RECFAST is an option via the fifth line in the input file as in CMBFAST. Using it does not slow things down significantly and corrects errors at around the 2% level.

Comparison with CLASS

The CLASS CMB code is written independently of CAMB and CMBFAST and is in pure C (not C++, despite the name). The basic equations and algorithm are substantially the same as CMBFAST in both cases, with CLASS having a C implementation of CAMB's lensed power spectrum method, and CAMB implementing in F90 some of the new very-sub-horizon approximations introduced in CLASS (which make little difference at WMAP precision, but significantly increase speed for small-scales and high accuracy). The codes use different combinations of approximation schemes and sampling for massive neutrinos. For standard models at CAMB's default accuracy settings speeds should be similar depending on compilers used, with CAMB's high_accuracy_default option being similar to CLASS's cl_permille.pre.

Comparison with CMBFAST

This code was originally developed from CMBFAST 2.4.1 to support closed models and gauge invariant variables. After releasing this code CMBFAST 3.2 was released which also supports closed models. These codes were developed independently and so are somewhat different, and both codes have developed independently since then.

The main differences in the non-flat computation lie in how we perform the integral of the source functions with the hyperspherical Bessel functions. We use Kosowsky's WKB approximation or the recursion relation to evaluate the Bessel functions at the starting point of ranges of integration, and then integrate the differential equation. CMBFAST integrates up the differential equation from a pre-calculated starting point. Unlike CMBFAST 3.2 our ranges of integration continue into the Chi > pi/2 region for closed models. We avoid problems with stability of the integration (contamination with the irregular solution) by cutting off the integration when the errors become important (where the values in the dissipative tail are becoming small). This leads to very small errors, and allows for a much simpler scheme than that used in CMBFAST 3.2 where the symmetry of the Bessel functions is used to extend to the Chi> Pi/2 region.

From the user's point of view the main point is that this code is rather faster than CMBFAST in many cases. Assuming same recombination history CAMB agrees with the CMBFAST 4.5 high precision TT calculation to < 1% at low l, and about 0.3% at l>100 in concordance flat models. If CAMB is run with high precision options the agreement is nearly 0.1% at high l. The polarized spectra also agree well except around the first dip in the EE spectrum with reionization (see CAMB's accurate_reionization parameter).

Note that as of March 2008 CAMB's reionization parameterization is slightly different to CMBFAST. CMBFAST 4.5.1 also uses an old version of RECFAST.

CMBFAST 3.2 introduced an include file for adjusting the l-sampling. In CAMB this is done automatically depending on the model, so there is no need to modify the l-sampling by hand.

CMBFAST uses the flat sky and Limber approximation and works from the transfer functions to work out the lensing potential, CAMB uses the full result (agreement is excellent). CAMB uses a full-sky correlation function method rather than the flat sky approx (about max 0.4% effect on EE).

CMBFAST 4 uses a "k-splitting" to allow rapid computation of grids of models to reasonable accuracy. If you need to generate a large number of models and accuracy is not vital using CMBFAST 4 would probably save you some time and effort. CMBFAST 4 also supports some extended models not supported by CAMB, e.g. 5-D models.

CAMB is in Fortran 90 and is more modularized, so using different initial power spectra, modified equations, etc. is often just a case of modifying one or two files and re-compiling.

Note that the conventions for the polarization power spectra output by CAMB agree with those of CMBFAST. This sign convention for the cross-correlation C_l^TE spectrum differs from the definitions in astro-ph/9911481. As from CMBFAST 4.2 the initial power spectrum normalization conventions also agree.

The source files


Main wrapper routines for running CAMB in your programs. Add "use camb" to your programs and call CAMB_GetResults to generate output from a set of model parameters (specified in the CAMBparams type - defined at the top of modules.f90). You can call CAMB_ValidateParams(P) to check that the parameter set is valid, use CAMB_GetAge to compute the age of a model in gigayears, and CAMB_GetCls to retrieve the computed Cls. The results can also be accessed directly using the arrays in the ModelData module (defined in modules.f90).

Sample programs tester.f90 and sigma8.f90 are supplied showing how to use CAMB from your own programs. You can also use CAMB_GetTransfers to access the C_l transfer functions directly without incorporating the initial power spectrum.


The main subroutine that does integrations, etc. Encompasses CMBFAST's cmbflat and cmbopen.


Files containing background and perturbation evolution equations. The perturbations equations used are derived in the covariant approach, fixing to the CDM (zero acceleration) frame, which are essentially equivalent to the synchronous gauge equations.

The file defines a module called "GaugeInterface" which provides the necessary perturbation calculation routines for "cmbmain".

The subroutine dtauda(a) returns dt/da and is used wherever the background evolution is needed. It can be modified for different backgrounds. You may also need to change the GetOmegak routine if you add additional components, and can edit the init_background routine to do additional initialization.

outtransf writes out the matter transfer functions.

The "output" subroutine computes the scalar sources at a given time for a given wavenumber. These are the temperature, E polarization and (if doing lensing) the lensing source. By editing the equation for the lensing source it should be straightforward to compute power spectra for other matter tracers, e.g. for cross-correlation with the CMB. The lensing power spectrum is automatically computed if DoLensing=T.

equations_ppf.f90 is an alternative module that allows evolving dark energy crossing w=-1.


This file defines a module called InitialPower that returns the initial power spectra. Change this file to use your own initial power spectrum, change how the spectra are parameterized, or to change how the Cls are normalized. Comments in the code explain this further.


This file defines a module called Reionization that parameterizes the reionization history and supplies a function Reionization_xe that gives xe as a function of redshift. Optical depth input parameters are mapped into zre (defined as where xe is half its maximum (ex second He reionization)) using a binary search. See the CAMB notes for discussion. This module should be easily modifiable for alternative reionization models.


Implements the NonLinear module, to calculate non linear scalings of the matter power spectrum as a function of redshift. Uses HALOFIT (astro-ph/0207664, code thanks to Robert Smith, with tweaks from arXiv:1208.2701 (thanks Ryuichi Takahashi) - see that paper for discussion of numerical accuracy. This module can be replaced to use a different non-linear fitting method if desired.


Reads in parameters from a file of name/value pairs and calls CAMB. Modify this file to generate grids of models, change the parameterization, etc.


Various modules used by the other parts of the program, Module "ModelParams" contains most of the model parameters. Boolean vars flat, open and closed determine the model type.


Module to calculate spherical and hyper-spherical Bessel functions. Hyper-spherical functions generated by use of either the recursion relation or Kosowsky's WKB approximation. Based on Arthur Kosowsky's "hyperjl.c".


Lensing module for computing the lensed CMB power spectra from the unlensed spectra and a lensing power spectrum. See astro-ph/0502425.


Various subroutines for interpolation, and modified Runge-Kutta dverk for parallelized evolution.


Subroutine WriteFitsCls that uses HEALPIX routines to output power spectrum in FITS format.


RECFAST integrator for Cosmic Recombination of Hydrogen and Helium by Douglas Scott (with minor modifications for CMBFAST and the CAMB). See RECFAST for the original code. This module implements the RECOMBINATION module required by CAMB, and could be replaced by more detailed codes. Sample wrappers are also provided for CosmoRec and HyRec, but the libraries for these must be installed separately.


Implements calculation of simple separable primordial bispectra, specifically the local constant fNL model, and the CMB lensing bispectrum due to the linear temperature and polarization cross-correlation with the lensing potential. Compile with FISHER defined in the makefile to also calculate Fisher elements, including the effects of lensing signal variance (edit Makefile to link to LAPACK if necessary). Note that the primordial bispectra here are unlensed (see arXiv:0905.4732 for a calculation), but the lensed bispectra are calculated non-perturbatively (but approximately) using the lensed small-scale CMB power spectra. Note that calculating primordial bispectra is significantly slower than doing standard power spectrum calculations, however it parallelizes well.


Scalar numerical errors should rarely exceed 0.3% for min(2500, L well into the damping tail) at default accuracy setting, and 0.1% for 500<L<2000 with high_accuracy_default=T. Matter power spectrum errors are usually dominated by interpolation in the acoustic oscillations, with about 0.2% accuracy with high_accuracy_default (but much better rms accuracy). For a detailed study of numerical accuracy as of January 2012 see arXiv:1201.3654. See also comparison with CMBFAST. Accuracy of course assumes the model is correct, and is dependent on RECFAST being the correct ionization history. Lensed C_l TT, TE and EE are accurate at the same level (to within the approximation that the lensing potential is linear, or the accuracy of the HALOFIT non-linear model).

Extreme models (e.g. scale > 4, h>1) may give errors of 5% or more.

Tensor errors around 2% or more on small scales (e.g. due to l-interpolation). Low l accuracy somewhat worse than scalars (typically < 1%). Turn on neutrinos in the input file for accurate results (automatic on high accuracy setting).

Hierarchy truncation errors up to 5% at high l (>1500) in some closed models

You can improve or check accuracy (or increase speed) by changing global accuracy parameters at the bottom of the params.ini input file. Convergence and stability can be checked using the test suite.

Add-ons, extensions, external sites


Some notes and relevant Maple derivations are given here (see also the Appendix of astro-ph/0406096). The CAMB notes outline the equations and approximations used, and relation to standard synchronous-gauge and Newtonian-gauge variables; see also arXiv:1201.3654. There is a BibTex file of references (including CosmoMC).

CMB power spectrum parameter degeneracies in the era of precision cosmology
Cullan Howlett, Antony Lewis, Alex Hall, Anthony Challinor arXiv:1201.3654.

Efficient computation of CMB anisotropies in closed FRW Models
Antony Lewis, Anthony Challinor and Anthony Lasenby astro-ph/9911177 Ap. J. 538:473-476, 2000.

Geometric Algebra and Covariant Methods in Physics and Cosmology, Chapters 6&7
PhD thesis, Antony Lewis 2000. PostScript.

Covariant theory

Cosmic Microwave Background Anisotropies in the CDM model: A Covariant and Gauge-Invariant Approach
Anthony Challinor and Anthony Lasenby, astro-ph/9804301 Ap. J. 513:1 1-22, 1999

Evolution of cosmological dark matter perturbations
Antony Lewis and Anthony Challinor astro-ph/0203507 Phys. Rev. D66, 023531 (2002)

Microwave background anisotropies from gravitational waves: the 1+3 covariant approach
Anthony Challinor, astro-ph/9906474

Microwave background polarization in cosmological models
Anthony Challinor, astro-ph/9911481

CMB anisotropies from primordial inhomogeneous magnetic fields
Antony Lewis, astro-ph/0406096
(The appendix contains general derivations of the multipole equations and Cl as used in CAMB)

Initial conditions

The General Primordial Cosmic Perturbation
Martin Bucher, Kavilan Moodley and Neil Turok, astro-ph/9904231 (These results extended to the non-flat case; see the theory page)

Observable primordial vector modes
Antony Lewis, astro-ph/0403583


Stable clustering, the halo model and nonlinear cosmological power spectra
Smith, R. E. and others, astro-ph/0207664.

Revising the Halofit Model for the Nonlinear Matter Power Spectrum
Ryuichi Takahashi and others, arXiv:1208.2701.


A new calculation of the recombination epoch.
Seager, S., Sasselov, D. & Scott, D., 1999, ApJ, 523, L1, astro-ph/9909275.

How well do we understand cosmological recombination?
Wong, Wan Yan and Moss, Adam and Scott, Douglas, arXiv:0711.1357.

Weak lensing of the CMB

Lensed CMB power spectra from all-sky correlation functions
A. Challinor and A. Lewis. astro-ph/0502425. (For Maple derivations see the theory page.)
Also: Weak Lensing of the CMB, astro-ph/0601594.

Gravitational lensing effect on cosmic microwave background anisotropies: A Power spectrum approach
Uros Seljak. astro-ph/9505109

Gravitational Lensing Effect on Cosmic Microwave Background Polarization
Uros Seljak and Matias Zaldarriaga. astro-ph/9803150

Weak Lensing of the CMB: A Harmonic Approach
Wayne Hu. astro-ph/0001303
See also astro-ph/0301064, astro-ph/0301031


The shape of the CMB lensing bispectrum
Antony Lewis, Anthony Challinor and Duncan Hanson arXiv:1101.2234

Sub-horizon radiation approximations

The Cosmic Linear Anisotropy Solving System (CLASS) II: Approximation schemes
Blas, Diego and Lesgourgues, Julien and Tram, Thomas. arXiv:1104.2933

Massive Neutrinos

CMB power spectrum parameter degeneracies in the era of precision cosmology
Cullan Howlett, Antony Lewis, Alex Hall, Anthony Challinor. arXiv:1201.3654 JCAP 04(2012)027

Evolution of cosmological dark matter perturbations
Antony Lewis and Anthony Challinor astro-ph/0203507 Phys. Rev. D66, 023531 (2002)

Synchronous gauge theory and non-flat models

Complete treatment of CMB anisotropies in a FRW universe
Wayne Hu, Uros Seljak and Matias Zaldarriaga. Phys. Rev. D57:6, 3290-3301, 1998. astro-ph/9709066.

WKB approx to hyperspherical Bessel functions

Efficient Computation of Hyperspherical Bessel Functions
Arthur Kosowsky, astro-ph/9805173

CMBFAST and the line of sight approach

A line of sight integration approach to Cosmic Microwave Background Anisotropies
Uros Seljak and Matias Zaldarriaga, astro-ph/9603033 Ap.J. 469:2 437-444, 1996

Integral solution for the microwave background anisotropies in nonflat universes
Matias Zaldarriaga, Uros Seljak, Edmund Bertschinger. ApJ. 494:491-501, 1998. astro-ph/9704265.

CMBFAST for spatially closed universes
Uros Seljak and Matias Zaldariaga, astro-ph/9911219