Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
ccl_error.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CCL_BOUNDS_CHECK_INTERP
 
#define CCL_ERROR_MEMORY   1025
 
#define CCL_ERROR_LINSPACE   1026
 
#define CCL_ERROR_INCONSISTENT   1027
 
#define CCL_ERROR_SPLINE   1028
 
#define CCL_ERROR_SPLINE_EV   1029
 
#define CCL_ERROR_INTEG   1030
 
#define CCL_ERROR_ROOT   1031
 
#define CCL_ERROR_CLASS   1032
 
#define CCL_ERROR_COMPUTECHI   1033
 
#define CCL_ERROR_MF   1034
 
#define CCL_ERROR_HMF_INTERP   1035
 
#define CCL_ERROR_PARAMETERS   1036
 
#define CCL_ERROR_NU_INT   1037
 
#define CCL_ERROR_EMULATOR_BOUND   1038
 
#define CCL_ERROR_NU_SOLVE   1039
 
#define CCL_ERROR_NOT_IMPLEMENTED   1040
 
#define CCL_ERROR_MNU_UNPHYSICAL   1041
 
#define CCL_ERROR_ANGPOW   1042
 
#define CCL_ERROR_MISSING_CONFIG_FILE   1043
 
#define CCL_ERROR_HALOCONC   1044
 
#define CCL_ERROR_HALOWIN   1045
 
#define CCL_ERROR_HMF_DV   1046
 
#define CCL_ERROR_CONC_DV   1047
 
#define CCL_ERROR_ONE_HALO_INT   1048
 
#define CCL_ERROR_TWO_HALO_INT   1049
 
#define CCL_ERROR_FILE_WRITE   1050
 
#define CCL_ERROR_FILE_READ   1051
 
#define CCL_ERROR_LOGSPACE   1052
 
#define CCL_ERROR_LINLOGSPACE   1053
 
#define CCL_ERROR_CONFIG_FILE   1054
 

Enumerations

enum  CCLErrorPolicy { CCL_ERROR_POLICY_EXIT = 0, CCL_ERROR_POLICY_CONTINUE = 1 }
 
enum  CCLDebugModePolicy { CCL_DEBUG_MODE_OFF = 0, CCL_DEBUG_MODE_ON = 1, CCL_DEBUG_MODE_WARNING = 2 }
 

Functions

void ccl_raise_exception (int err, const char *msg,...)
 
void ccl_raise_warning (int err, const char *msg,...)
 
void ccl_raise_gsl_warning (int gslstatus, const char *msg,...)
 
void ccl_set_error_policy (CCLErrorPolicy error_policy)
 
void ccl_set_debug_policy (CCLDebugModePolicy debug_policy)
 
void ccl_check_status (ccl_cosmology *cosmo, int *status)
 
void ccl_check_status_nocosmo (int *status)
 

Macro Definition Documentation

#define CCL_BOUNDS_CHECK_INTERP

Definition at line 8 of file ccl_error.h.

#define CCL_ERROR_ANGPOW   1042

Definition at line 27 of file ccl_error.h.

#define CCL_ERROR_CONC_DV   1047

Definition at line 32 of file ccl_error.h.

Referenced by ccl_halo_concentration().

#define CCL_ERROR_CONFIG_FILE   1054

Definition at line 39 of file ccl_error.h.

#define CCL_ERROR_EMULATOR_BOUND   1038

Definition at line 23 of file ccl_error.h.

Referenced by ccl_nonlin_matter_power(), and ccl_pkemu().

#define CCL_ERROR_FILE_READ   1051

Definition at line 36 of file ccl_error.h.

Referenced by ccl_parameters_read_yaml().

#define CCL_ERROR_FILE_WRITE   1050

Definition at line 35 of file ccl_error.h.

Referenced by ccl_parameters_write_yaml().

#define CCL_ERROR_HALOCONC   1044

Definition at line 29 of file ccl_error.h.

Referenced by ccl_halo_concentration().

#define CCL_ERROR_HALOWIN   1045

Definition at line 30 of file ccl_error.h.

Referenced by window_function().

#define CCL_ERROR_HMF_DV   1046

Definition at line 31 of file ccl_error.h.

Referenced by ccl_halo_b1(), and massfunc_f().

#define CCL_ERROR_HMF_INTERP   1035

Definition at line 20 of file ccl_error.h.

Referenced by ccl_check_status(), ccl_check_status_nocosmo(), and massfunc_f().

#define CCL_ERROR_LINLOGSPACE   1053

Definition at line 38 of file ccl_error.h.

Referenced by ccl_linlog_spacing().

#define CCL_ERROR_LOGSPACE   1052

Definition at line 37 of file ccl_error.h.

Referenced by ccl_log_spacing().

#define CCL_ERROR_MF   1034

Definition at line 19 of file ccl_error.h.

Referenced by ccl_halo_b1(), and massfunc_f().

#define CCL_ERROR_MISSING_CONFIG_FILE   1043
#define CCL_ERROR_MNU_UNPHYSICAL   1041

Definition at line 26 of file ccl_error.h.

Referenced by ccl_check_status_nocosmo(), ccl_nu_masses(), and ccl_parameters_create().

#define CCL_ERROR_NU_INT   1037
#define CCL_ERROR_NU_SOLVE   1039

Definition at line 24 of file ccl_error.h.

Referenced by ccl_check_status(), and ccl_check_status_nocosmo().

#define CCL_ERROR_ONE_HALO_INT   1048

Definition at line 33 of file ccl_error.h.

Referenced by one_halo_integral().

#define CCL_ERROR_PARAMETERS   1036

Definition at line 21 of file ccl_error.h.

Referenced by ccl_omega_x(), and ccl_sinn().

#define CCL_ERROR_ROOT   1031

Definition at line 16 of file ccl_error.h.

Referenced by ccl_cosmology_compute_distances().

#define CCL_ERROR_SPLINE_EV   1029
#define CCL_ERROR_TWO_HALO_INT   1049

Definition at line 34 of file ccl_error.h.

Referenced by two_halo_integral().

Enumeration Type Documentation

Enumerator
CCL_DEBUG_MODE_OFF 
CCL_DEBUG_MODE_ON 
CCL_DEBUG_MODE_WARNING 

Definition at line 46 of file ccl_error.h.

Enumerator
CCL_ERROR_POLICY_EXIT 
CCL_ERROR_POLICY_CONTINUE 

Definition at line 41 of file ccl_error.h.

Function Documentation

void ccl_check_status ( ccl_cosmology cosmo,
int *  status 
)

Check the error status Given a status, check if any errors have occurred, based on the CCL_ERRORs defined so far.

Returns
void

Definition at line 88 of file ccl_error.c.

References CCL_ERROR_COMPUTECHI, CCL_ERROR_HMF_INTERP, CCL_ERROR_LINSPACE, CCL_ERROR_NU_INT, CCL_ERROR_NU_SOLVE, CCL_ERROR_SPLINE, ccl_raise_exception(), and ccl_cosmology::status_message.

Referenced by ccl_angular_cl_native(), ccl_angular_cls(), ccl_cl_tracer(), ccl_comoving_angular_distance(), ccl_comoving_radial_distance(), ccl_correlation(), ccl_correlation_3d(), ccl_cosmology_compute_power(), ccl_distance_modulus(), ccl_dlninvsig_dlogm(), ccl_growth_factor(), ccl_growth_factor_unnorm(), ccl_growth_rate(), ccl_h_over_h0(), ccl_halo_bias(), ccl_omega_x(), ccl_scale_factor_of_chi(), ccl_sigmaM(), h_over_h0(), and massfunc_f().

89 {
90 
91  switch (*status) {
92  case 0: // all good, nothing to do
93  return;
94  case CCL_ERROR_LINSPACE: // spacing allocation error, always terminate
95  ccl_raise_exception(*status, cosmo->status_message);
96  case CCL_ERROR_SPLINE: // spline allocation error, always terminate
97  ccl_raise_exception(*status, cosmo->status_message);
98  case CCL_ERROR_COMPUTECHI: // compute_chi error //RH
99  ccl_raise_exception(*status, cosmo->status_message);
100  case CCL_ERROR_HMF_INTERP: // terminate if hmf definition not supported
101  ccl_raise_exception(*status, cosmo->status_message);
102  case CCL_ERROR_NU_INT: // error in getting the neutrino integral spline: exit. No status_message in cosmo because can't pass cosmology to the function.
103  ccl_raise_exception(*status, "Error, in ccl_neutrinos.c. ccl_calculate_nu_phasespace_spline(): Error in setting neutrino phasespace spline.");
104  case CCL_ERROR_NU_SOLVE: // error in converting Omeganuh2-> Mnu: exit. No status_message in cosmo because can't pass cosmology to the function.
105  ccl_raise_exception(*status, "Error, in ccl_neutrinos.c. Omeganuh2_to_Mnu(): Root finding did not converge.");
106  // TODO: Implement softer error handling, e.g. for integral convergence here
107  default:
108  ccl_raise_exception(*status, cosmo->status_message);
109  }
110 }
void ccl_raise_exception(int err, const char *msg,...)
Definition: ccl_error.c:35
#define CCL_ERROR_NU_SOLVE
Definition: ccl_error.h:24
#define CCL_ERROR_HMF_INTERP
Definition: ccl_error.h:20
#define CCL_ERROR_NU_INT
Definition: ccl_error.h:22
#define CCL_ERROR_SPLINE
Definition: ccl_error.h:13
#define CCL_ERROR_LINSPACE
Definition: ccl_error.h:11
#define CCL_ERROR_COMPUTECHI
Definition: ccl_error.h:18
char status_message[500]
Definition: ccl_core.h:136
void ccl_check_status_nocosmo ( int *  status)

Check the error status - no cosmology Given a status, check if any errors have occurred, based on the CCL_ERRORs defined so far.

Returns
void

Definition at line 116 of file ccl_error.c.

References CCL_ERROR_COMPUTECHI, CCL_ERROR_HMF_INTERP, CCL_ERROR_LINSPACE, CCL_ERROR_MNU_UNPHYSICAL, CCL_ERROR_NOT_IMPLEMENTED, CCL_ERROR_NU_INT, CCL_ERROR_NU_SOLVE, CCL_ERROR_SPLINE, and ccl_raise_exception().

Referenced by ccl_nu_masses(), ccl_parameters_create(), ccl_parameters_fill_initial(), and nu_phasespace_intg().

117 {
118  switch (*status) {
119  case 0: // Nothing to do
120  return;
121  case CCL_ERROR_LINSPACE:
122  // Spacing allocation error, always terminate
123  ccl_raise_exception(*status, "CCL_ERROR_LINSPACE: Spacing allocation error.");
124  case CCL_ERROR_SPLINE:
125  // Spline allocation error, always terminate
126  ccl_raise_exception(*status, "CCL_ERROR_SPLINE: Spline allocation error.");
128  // Compute_chi error
129  ccl_raise_exception(*status,
130  "CCL_ERROR_COMPUTECHI: Comoving distance chi computation failed.");
132  // Terminate if hmf definition not supported
133  ccl_raise_exception(*status,
134  "CCL_ERROR_HMF_INTERP: Halo mass function definition not supported.");
135  case CCL_ERROR_NU_INT:
136  // Error in getting the neutrino integral spline: exit. No status_message
137  // in cosmo because can't pass cosmology to the function.
138  ccl_raise_exception(*status,
139  "CCL_ERROR_NU_INT: Error getting the neutrino phase-space integral spline.");
140  case CCL_ERROR_NU_SOLVE:
141  // Error in converting Omeganuh2-> Mnu: exit. No status_message in cosmo
142  // because can't pass cosmology to the function.
143  ccl_raise_exception(*status,
144  "CCL_ERROR_NU_SOLVE: Error converting Omeganuh2 -> Mnu.");
146  // Error in the sum of mnu or Omeganu passed for the hierarchy requested.
147  ccl_raise_exception(*status,
148  "CCL_ERROR_MNU_UNPHYSICAL: Sum of neutrinos masses for this Omeganu value is incompatible with the requested mass hierarchy.");
150  ccl_raise_exception(*status,
151  "CCL_ERROR_NOT_IMPLEMENTED: the type of m_nu specified is not supported.");
152  default:
153  ccl_raise_exception(*status,
154  "Unrecognized error code (see gsl_errno.h for error codes 1-32).");
155  }
156 }
void ccl_raise_exception(int err, const char *msg,...)
Definition: ccl_error.c:35
#define CCL_ERROR_NOT_IMPLEMENTED
Definition: ccl_error.h:25
#define CCL_ERROR_NU_SOLVE
Definition: ccl_error.h:24
#define CCL_ERROR_HMF_INTERP
Definition: ccl_error.h:20
#define CCL_ERROR_NU_INT
Definition: ccl_error.h:22
#define CCL_ERROR_SPLINE
Definition: ccl_error.h:13
#define CCL_ERROR_LINSPACE
Definition: ccl_error.h:11
#define CCL_ERROR_MNU_UNPHYSICAL
Definition: ccl_error.h:26
#define CCL_ERROR_COMPUTECHI
Definition: ccl_error.h:18
void ccl_raise_exception ( int  err,
const char *  msg,
  ... 
)

Raise an exception Given a status, give an error message.

Returns
void

Definition at line 35 of file ccl_error.c.

References _ccl_debug_mode_policy, _ccl_error_policy, CCL_DEBUG_MODE_ON, and CCL_ERROR_POLICY_EXIT.

Referenced by calculate_nu_phasespace_spline(), ccl_check_status(), ccl_check_status_nocosmo(), ccl_cosmology_read_config(), ccl_dNdz_tomog(), ccl_halo_concentration(), ccl_norm_integrand(), ccl_parameters_read_yaml(), ccl_pkemu(), and window_function().

36 {
37  char message[256];
38 
39  va_list va;
40  va_start(va, msg);
41  vsnprintf(message, 250, msg, va);
42  va_end(va);
43 
44  // Print error message and exit if fatal errors are enabled
45  if ((_ccl_error_policy == CCL_ERROR_POLICY_EXIT) && (err)) {
46  fprintf(stderr, "ERROR %d: %s\n", err, message);
47  exit(1);
48  }
49  // Print error message and exit if debug output is enabled
50  else if ((_ccl_debug_mode_policy == CCL_DEBUG_MODE_ON) && (err)){
51  fprintf(stderr, "ERROR %d: %s\n", err, message);
52  }
53 }
static CCLErrorPolicy _ccl_error_policy
Definition: ccl_error.c:12
static CCLDebugModePolicy _ccl_debug_mode_policy
Definition: ccl_error.c:20
void ccl_raise_gsl_warning ( int  gslstatus,
const char *  msg,
  ... 
)

Raise a warning based on a GSL error message Given a GSL status, give a warning message.

Returns
void

Definition at line 75 of file ccl_error.c.

References ccl_raise_warning().

Referenced by a_of_chi(), calculate_nu_phasespace_spline(), ccl_angular_cl_native(), ccl_comoving_angular_distance(), ccl_comoving_radial_distance(), ccl_cosmology_compute_growth(), ccl_cosmology_compute_sigma(), ccl_dlninvsig_dlogm(), ccl_dNdz_tomog(), ccl_growth_factor(), ccl_growth_rate(), ccl_h_over_h0(), ccl_linear_matter_power(), ccl_nonlin_matter_power(), ccl_norm_integrand(), ccl_power_extrapol_highk(), ccl_power_extrapol_lowk(), ccl_scale_factor_of_chi(), ccl_sigmaM(), ccl_sigmaR(), ccl_sigmaV(), ccl_spline_eval(), ccl_tracer_corr_bessel(), clt_init_nz(), compute_chi(), growth_factor_and_growth_rate(), massfunc_f(), nu_phasespace_intg(), one_halo_integral(), two_halo_integral(), window_lensing(), and window_magnification().

76 {
77  char message[256];
78 
79  va_list va;
80  va_start(va, msg);
81  vsnprintf(message, 250, msg, va);
82  va_end(va);
83 
84  ccl_raise_warning(gslstatus, "%s GSL error: %s", message, gsl_strerror(gslstatus));
85  return;
86 }
void ccl_raise_warning(int err, const char *msg,...)
Definition: ccl_error.c:56
void ccl_raise_warning ( int  err,
const char *  msg,
  ... 
)

Raise a warning Given a status, give a warning message.

Returns
void

Definition at line 56 of file ccl_error.c.

References _ccl_debug_mode_policy, CCL_DEBUG_MODE_ON, and CCL_DEBUG_MODE_WARNING.

Referenced by ccl_linear_spacing(), ccl_linlog_spacing(), ccl_log_spacing(), ccl_nonlin_matter_power(), and ccl_raise_gsl_warning().

57 {
58  char message[256];
59 
60  va_list va;
61  va_start(va, msg);
62  vsnprintf(message, 250, msg, va);
63  va_end(va);
64 
65  // For now just print warning to stderr if debug is enabled.
66  // TODO: Implement some kind of error stack that can be passed on to, e.g.,
67  // the python binding.
70  fprintf(stderr, "WARNING: %s\n", message);
71  }
72 }
static CCLDebugModePolicy _ccl_debug_mode_policy
Definition: ccl_error.c:20
void ccl_set_debug_policy ( CCLDebugModePolicy  debug_policy)

Set the error policy debug_policy the debug mode policy

Returns
void

Definition at line 29 of file ccl_error.c.

References _ccl_debug_mode_policy.

Referenced by compare_cls(), compare_corr(), and Cosmo_Param::init().

30 {
31  _ccl_debug_mode_policy = debug_policy;
32 }
static CCLDebugModePolicy _ccl_debug_mode_policy
Definition: ccl_error.c:20
void ccl_set_error_policy ( CCLErrorPolicy  error_policy)

Set the error policy error_policy the error policy

Returns
void

Definition at line 23 of file ccl_error.c.

References _ccl_error_policy.

Referenced by Cosmo_Param::init().

24 {
25  _ccl_error_policy = error_policy;
26 }
static CCLErrorPolicy _ccl_error_policy
Definition: ccl_error.c:12