CLASS status check now added
@@ -369,10 +369,19 @@ static void ccl_cosmology_compute_power_class(ccl_cosmology * cosmo, int * statu
//The 2D interpolation routines access the function values y_{k_ia_j} with the following ordering:
//y_ij = y2d[j*N_k + i]
//with i = 0,...,N_k-1 and j = 0,...,N_a-1.
- s = spectra_pk_at_k_and_z(&ba, &pm, &sp,x[i],1./z[j]-1., &psout_l,&ic);
+ s |= spectra_pk_at_k_and_z(&ba, &pm, &sp,x[i],1./z[j]-1., &psout_l,&ic);
y2d_lin[j*nk+i] = log(psout_l);
}
}
+ if(s){
+ free(x);
+ free(z);
+ free(y2d_nl);
+ free(y2d_lin);
+ *status = CCL_ERROR_CLASS;
+ strcpy(cosmo->status_message ,"ccl_power.c: ccl_cosmology_compute_power_class(): Error computing CLASS power spectrum\n");
+ ccl_free_class_structs(cosmo, &ba,&th,&pt,&tr,&pm,&sp,&nl,&le,status);
+ }
for (int i=0; i<nk; i++)
x[i] = log(x[i]);
@@ -398,12 +407,23 @@ static void ccl_cosmology_compute_power_class(ccl_cosmology * cosmo, int * statu
for (int i=0; i<nk; i++){
for (int j = 0; j < na; j++){
- s = spectra_pk_nl_at_k_and_z(&ba, &pm, &sp,exp(x[i]),1./z[j]-1.,&psout_nl);
+ s |= spectra_pk_nl_at_k_and_z(&ba, &pm, &sp,exp(x[i]),1./z[j]-1.,&psout_nl);
y2d_nl[j*nk+i] = log(psout_nl);
}
}
+ if(s){
+ free(x);
+ free(z);
+ free(y2d_nl);
+ free(y2d_lin);
+ *status = CCL_ERROR_CLASS;
+ strcpy(cosmo->status_message ,"ccl_power.c: ccl_cosmology_compute_power_class(): Error computing CLASS power spectrum\n");
+ ccl_free_class_structs(cosmo, &ba,&th,&pt,&tr,&pm,&sp,&nl,&le,status);
+ }
+
gsl_spline2d * log_power_nl = gsl_spline2d_alloc(PNL_SPLINE_TYPE, nk,na);
pwstatus = gsl_spline2d_init(log_power_nl, x, z, y2d_nl,nk,na);
+
if (pwstatus){
free(x);
free(z);
