Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/ccl_fftlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void fht(int npk, int N,
double dim, double mu, double q, double kcrc,
int noring, double complex* u, int *status)
{
fftw_plan forward_plan, reverse_plan;
fftw_plan forward_plan = NULL, reverse_plan = NULL;
double L = log(k[N-1]/k[0]) * N/(N-1.);
double complex* ulocal = NULL;
if(u == NULL) {
Expand All @@ -225,8 +225,8 @@ static void fht(int npk, int N,
}
}

fftw_complex* a_tmp;
fftw_complex* b_tmp;
fftw_complex* a_tmp = NULL;
fftw_complex* b_tmp = NULL;
if(*status == 0) {
a_tmp = fftw_alloc_complex(N);
if(a_tmp==NULL)
Expand Down Expand Up @@ -336,18 +336,16 @@ static void fht(int npk, int N,
} //end omp parallel
}

if(*status == 0) {
fftw_destroy_plan(forward_plan);
fftw_destroy_plan(reverse_plan);
}
if(forward_plan != NULL) fftw_destroy_plan(forward_plan);
if(reverse_plan != NULL) fftw_destroy_plan(reverse_plan);

free(ulocal);
//TODO: free this up
fftw_free(a_tmp);
fftw_free(b_tmp);
}

/* Compute the discrete Hankel transform of the function a(r)
/* Compute the discrete Hankel transform of the function a(r)
* weighted by a power law and the nth derivative of the
* (spherical) bessel function. Explicitly, this function computes
* \tilde{a}(k)= \int \frac{dr}{(xk)^plaw} a(r) (J/j)^(n)_\mu(xk)
Expand All @@ -369,11 +367,11 @@ static void general_fht(int npk, int N,
kcrc = mu+1.0;
mu = mu+0.5*spherical_bessel;

fftw_plan forward_plan, reverse_plan;
fftw_plan forward_plan = NULL, reverse_plan = NULL;
double L = log(k[N-1]/k[0]) * N/(N-1.);
double complex* ulocal = NULL;
if(u == NULL) {

kcrc = goodkr_new_deriv(N, mu, q, L, spherical_bessel, bessel_deriv,plaw, kcrc);

ulocal = malloc (sizeof(complex double)*N);
Expand All @@ -386,8 +384,8 @@ static void general_fht(int npk, int N,
}
}

fftw_complex* a_tmp;
fftw_complex* b_tmp;
fftw_complex* a_tmp = NULL;
fftw_complex* b_tmp = NULL;
if(*status == 0) {
a_tmp = fftw_alloc_complex(N);
if(a_tmp==NULL)
Expand Down Expand Up @@ -500,10 +498,8 @@ static void general_fht(int npk, int N,
} //end omp parallel
}

if(*status == 0) {
fftw_destroy_plan(forward_plan);
fftw_destroy_plan(reverse_plan);
}
if(forward_plan != NULL) fftw_destroy_plan(forward_plan);
if(reverse_plan != NULL) fftw_destroy_plan(reverse_plan);

free(ulocal);
//TODO: free this up
Expand Down
8 changes: 5 additions & 3 deletions src/ccl_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ static ccl_f2d_t *ccl_compute_linpower_analytic(ccl_cosmology* cosmo, void* par,
y2d[j] += log_sigma8;
}

// Free the first spline unconditionally; re-allocate with normalisation only on success.
// Without this, ccl_sigma8 failure above would leak the first psp_out.
ccl_f2d_t_free(psp_out);
psp_out = NULL;

if(*status==0) {
// Free the previous P(k,a) spline, and allocate a new one to store the
// properly-normalized P(k,a)
ccl_f2d_t_free(psp_out);
psp_out = ccl_f2d_t_new(na,z,nk,x,y2d,NULL,NULL,0,
1,2,ccl_f2d_cclgrowth,1,0,2,
ccl_f2d_3,status);
Expand Down
Loading