Commit 0bf3502d authored by Goran Jelic-Cizmek's avatar Goran Jelic-Cizmek
Browse files

Made the code compatible with C++

Mostly modified some explicit casting, and it all works.
parent cf38b387
......@@ -361,7 +361,7 @@ int coffe_background_init(
z_array[i] = z;
w_array[i] = coffe_dark_energy_eos(z, par);
}
coffe_init_spline(&ipar.w, z_array, w_array, bins + 1, 1);
coffe_init_spline(&ipar.w, z_array, w_array, bins + 1, COFFE_INTERP_LINEAR);
free(w_array);
double *wint_array = (double *)coffe_malloc(sizeof(double)*(bins + 1));
......@@ -377,7 +377,7 @@ int coffe_background_init(
)
);
}
coffe_init_spline(&ipar.wint, z_array, wint_array, bins + 1, 1);
coffe_init_spline(&ipar.wint, z_array, wint_array, bins + 1, COFFE_INTERP_LINEAR);
free(wint_array);
double *xint_array = (double *)coffe_malloc(sizeof(double)*(bins + 1));
......@@ -404,7 +404,7 @@ int coffe_background_init(
/(1 - (ipar.Omega0_cdm + ipar.Omega0_baryon));
}
}
coffe_init_spline(&ipar.xint, z_array, xint_array, bins + 1, 1);
coffe_init_spline(&ipar.xint, z_array, xint_array, bins + 1, COFFE_INTERP_LINEAR);
free(xint_array);
free(z_array);
......
......@@ -1319,42 +1319,42 @@ int coffe_free_class_struct(
{
#ifdef HAVE_CLASS
if (input->file_content){
parser_free(input->file_content);
parser_free((struct file_content *)input->file_content);
free(input->file_content);
}
if (input->background){
background_free(input->background);
background_free((struct background *)input->background);
free(input->background);
}
if (input->thermodynamics){
thermodynamics_free(input->thermodynamics);
thermodynamics_free((struct thermo *)input->thermodynamics);
free(input->thermodynamics);
}
if (input->perturb){
perturb_free(input->perturb);
perturb_free((struct perturbs *)input->perturb);
free(input->perturb);
}
if (input->primordial){
primordial_free(input->primordial);
primordial_free((struct primordial *)input->primordial);
free(input->primordial);
}
if (input->nonlinear){
nonlinear_free(input->nonlinear);
nonlinear_free((struct nonlinear *)input->nonlinear);
free(input->nonlinear);
}
if (input->transfer){
transfer_free(input->transfer);
transfer_free((struct transfers *)input->transfer);
free(input->transfer);
}
if (input->spectra){
spectra_free(input->spectra);
spectra_free((struct spectra *)input->spectra);
free(input->spectra);
}
#endif
......
......@@ -443,7 +443,7 @@ typedef struct coffe_parameters_t
int covariance_integration_bins;
int covariance_interpolation_method;
enum coffe_interp2d_type covariance_interpolation_method;
int covariance_window;
......
......@@ -309,7 +309,7 @@ static int covariance_integrate_fftlog(
const size_t npixels_max,
const double k_min_norm,
const double k_max_norm,
const int interpolation_method,
const enum coffe_interp2d_type interpolation_method,
double *result
)
{
......@@ -572,7 +572,7 @@ int coffe_covariance_init(
k,
temp_spectrum_pk,
k_size,
5
par->interp_method
);
coffe_init_spline(
......@@ -580,7 +580,7 @@ int coffe_covariance_init(
k,
temp_spectrum_pk2,
k_size,
5
par->interp_method
);
/* memory cleanup */
......
......@@ -777,7 +777,7 @@ int coffe_integrals_init(
pk_at_z2d,
z_size,
output_real_len,
2
par->covariance_interpolation_method
);
/* we didn't free it above, so we do it here */
......@@ -923,7 +923,7 @@ int coffe_integrals_init(
result2d,
nbins + 1,
nbins + 1,
2
par->covariance_interpolation_method
);
free(chi_array);
......@@ -1089,7 +1089,7 @@ int coffe_integrals_init(
pk_at_z2d,
z_size,
output_real_len,
2
par->covariance_interpolation_method
);
/* we didn't free it above, so we do it here */
......@@ -1253,7 +1253,7 @@ int coffe_integrals_init(
pk_at_z2d,
z_size,
output_real_len,
2
par->covariance_interpolation_method
);
/* we didn't free it above, so we do it here */
......@@ -1418,7 +1418,7 @@ int coffe_integrals_init(
pk_at_z2d,
z_size,
output_real_len,
2
par->covariance_interpolation_method
);
/* we didn't free it above, so we do it here */
......
......@@ -937,7 +937,11 @@ int coffe_parser_init(
}
/* the interpolation method for GSL */
parse_int(conf, "interpolation", &par->interp_method, COFFE_FALSE);
{
int temp;
parse_int(conf, "interpolation", &temp, COFFE_FALSE);
par->interp_method = (enum coffe_interp1d_type)temp;
}
/* the cosine of the angle for the full sky correlation function */
if (par->output_type == CORRFUNC){
......@@ -1021,7 +1025,11 @@ int coffe_parser_init(
print_error_verbose(PROG_VALUE_ERROR, "covariance_integration_bins");
exit(EXIT_FAILURE);
}
parse_int(conf, "covariance_interpolation_method", &par->covariance_interpolation_method, COFFE_TRUE);
{
int temp;
parse_int(conf, "covariance_interpolation_method", &temp, COFFE_TRUE);
par->covariance_interpolation_method = (enum coffe_interp2d_type)temp;
}
if (
par->covariance_interpolation_method != 1 &&
par->covariance_interpolation_method != 2
......@@ -1346,7 +1354,11 @@ int coffe_parser_init(
parse_int(conf, "have_class", &par->have_class, COFFE_TRUE);
if (par->have_class){
parse_int(conf, "pk_type", &par->pk_type, COFFE_TRUE);
{
int temp;
parse_int(conf, "pk_type", &temp, COFFE_TRUE);
par->pk_type = (enum coffe_pk_type)temp;
}
parse_double(conf, "h", &par->h, COFFE_TRUE);
parse_double(conf, "sigma8", &par->sigma8, COFFE_TRUE);
parse_double(conf, "n_s", &par->n_s, COFFE_TRUE);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment