CLASS MANUAL
output.c File Reference
#include "output.h"
+ Include dependency graph for output.c:

Functions

int output_init (struct background *pba, struct thermodynamics *pth, struct perturbations *ppt, struct primordial *ppm, struct transfer *ptr, struct harmonic *phr, struct fourier *pfo, struct lensing *ple, struct distortions *psd, struct output *pop)
 
int output_cl (struct background *pba, struct perturbations *ppt, struct harmonic *phr, struct lensing *ple, struct output *pop)
 
int output_pk (struct background *pba, struct perturbations *ppt, struct fourier *pfo, struct output *pop, enum pk_outputs pk_output)
 
int output_tk (struct background *pba, struct perturbations *ppt, struct output *pop)
 
int output_heating (struct injection *pin, struct noninjection *pni, struct output *pop)
 
int output_distortions (struct distortions *psd, struct output *pop)
 
int output_print_data (FILE *out, char titles[_MAXTITLESTRINGLENGTH_], double *dataptr, int size_dataptr)
 
int output_open_cl_file (struct harmonic *phr, struct output *pop, FILE **clfile, FileName filename, char *first_line, int lmax)
 
int output_one_line_of_cl (struct background *pba, struct harmonic *phr, struct output *pop, FILE *clfile, double l, double *cl, int ct_size)
 
int output_open_pk_file (struct background *pba, struct fourier *pfo, struct output *pop, FILE **pkfile, FileName filename, char *first_line, double z)
 
int output_one_line_of_pk (FILE *pkfile, double one_k, double one_pk)
 

Detailed Description

Documented output module

Julien Lesgourgues, 26.08.2010

This module writes the output in files.

The following functions can be called from other modules or from the main:

  1. output_init() (must be called after harmonic_init())
  2. output_total_cl_at_l() (can be called even before output_init())

No memory needs to be deallocated after that, hence there is no output_free() routine like in other modules.

Function Documentation

◆ output_init()

int output_init ( struct background pba,
struct thermodynamics pth,
struct perturbations ppt,
struct primordial ppm,
struct transfer ptr,
struct harmonic phr,
struct fourier pfo,
struct lensing ple,
struct distortions psd,
struct output pop 
)

This routine writes the output in files.

Parameters
pbaInput: pointer to background structure (needed for calling harmonic_pk_at_z())
pthInput: pointer to thermodynamics structure
pptInput: pointer perturbation structure
ppmInput: pointer to primordial structure
ptrInput: pointer to transfer structure
phrInput: pointer to harmonic structure
pfoInput: pointer to fourier structure
pleInput: pointer to lensing structure
psdInput: pointer to distortions structure
popInput: pointer to output structure

Summary:

  • check that we really want to output at least one file
  • deal with all anisotropy power spectra $ C_l$'s
  • deal with all Fourier matter power spectra P(k)'s
  • deal with density and matter power spectra
  • deal with background quantities
  • deal with thermodynamics quantities
  • deal with perturbation quantities
  • deal with primordial spectra
  • deal with heating
  • deal with spectral distortions

◆ output_cl()

int output_cl ( struct background pba,
struct perturbations ppt,
struct harmonic phr,
struct lensing ple,
struct output pop 
)

This routines writes the output in files for anisotropy power spectra $ C_l$'s.

Parameters
pbaInput: pointer to background structure (needed for $ T_{cmb}$)
pptInput: pointer perturbation structure
phrInput: pointer to harmonic structure
pleInput: pointer to lensing structure
popInput: pointer to output structure

Summary:

  • define local variables
  • first, allocate all arrays of files and $ C_l$'s
  • second, open only the relevant files, and write a heading in each of them
  • third, perform loop over l. For each multipole, get all $ C_l$'s by calling harmonic_cl_at_l() and distribute the results to relevant files
  • finally, close files and free arrays of files and $ C_l$'s

◆ output_pk()

int output_pk ( struct background pba,
struct perturbations ppt,
struct fourier pfo,
struct output pop,
enum pk_outputs  pk_output 
)

This routines writes the output in files for Fourier matter power spectra P(k)'s (linear or non-linear)

Parameters
pbaInput: pointer to background structure (needed for calling harmonic_pk_at_z())
pptInput: pointer perturbation structure
pfoInput: pointer to fourier structure
popInput: pointer to output structure
pk_outputInput: pk_linear or pk_nonlinear

Summary:

  • define local variables
  • preliminary: check whether we need to output the decomposition into contributions from each initial condition
  • allocate arrays to store the P(k)
  • allocate pointer to output files
  • loop over pk type (_cb, _m)
  • loop over z
  • first, check that requested redshift z_pk is consistent
  • second, open only the relevant files and write a header in each of them
  • third, compute P(k) for each k
  • fourth, write in files
  • fifth, close files

◆ output_tk()

int output_tk ( struct background pba,
struct perturbations ppt,
struct output pop 
)

This routines writes the output in files for matter transfer functions $ T_i(k)$'s.

Parameters
pbaInput: pointer to background structure (needed for calling harmonic_pk_at_z())
pptInput: pointer perturbation structure
popInput: pointer to output structure

Summary:

  • define local variables
  • first, check that requested redshift z_pk is consistent
  • second, open only the relevant files, and write a heading in each of them
  • free memory and close files

◆ output_heating()

int output_heating ( struct injection *  pin,
struct noninjection *  pni,
struct output pop 
)

Local variables

◆ output_distortions()

int output_distortions ( struct distortions psd,
struct output pop 
)

Local variables

◆ output_print_data()

int output_print_data ( FILE *  out,
char  titles[_MAXTITLESTRINGLENGTH_],
double *  dataptr,
int  size_dataptr 
)

Summary

  • First we print the titles
  • Then we print the data

◆ output_open_cl_file()

int output_open_cl_file ( struct harmonic phr,
struct output pop,
FILE **  clfile,
FileName  filename,
char *  first_line,
int  lmax 
)

This routine opens one file where some $ C_l$'s will be written, and writes a heading with some general information concerning its content.

Parameters
phrInput: pointer to harmonic structure
popInput: pointer to output structure
clfileOutput: returned pointer to file pointer
filenameInput: name of the file
first_lineInput: text describing the content (mode, initial condition..)
lmaxInput: last multipole in the file (the first one is assumed to be 2)
Returns
the error status

Summary

  • First we deal with the entries that are dependent of format type
  • Next deal with entries that are independent of format type

◆ output_one_line_of_cl()

int output_one_line_of_cl ( struct background pba,
struct harmonic phr,
struct output pop,
FILE *  clfile,
double  l,
double *  cl,
int  ct_size 
)

This routine write one line with l and all $ C_l$'s for all types (TT, TE...)

Parameters
pbaInput: pointer to background structure (needed for $ T_{cmb}$)
phrInput: pointer to harmonic structure
popInput: pointer to output structure
clfileInput: file pointer
lInput: multipole
clInput: $ C_l$'s for all types
ct_sizeInput: number of types
Returns
the error status

◆ output_open_pk_file()

int output_open_pk_file ( struct background pba,
struct fourier pfo,
struct output pop,
FILE **  pkfile,
FileName  filename,
char *  first_line,
double  z 
)

This routine opens one file where some P(k)'s will be written, and writes a heading with some general information concerning its content.

Parameters
pbaInput: pointer to background structure (needed for h)
pfoInput: pointer to fourier structure
popInput: pointer to output structure
pkfileOutput: returned pointer to file pointer
filenameInput: name of the file
first_lineInput: text describing the content (initial conditions, ...)
zInput: redshift of the output
Returns
the error status

◆ output_one_line_of_pk()

int output_one_line_of_pk ( FILE *  pkfile,
double  one_k,
double  one_pk 
)

This routine writes one line with k and P(k)

Parameters
pkfileInput: file pointer
one_kInput: wavenumber
one_pkInput: matter power spectrum
Returns
the error status