Skip to content

Commit

Permalink
removed extra file dealocation call
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Mesinger committed Jul 12, 2017
1 parent 119e6e0 commit 42e7566
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions Programs/find_HII_bubbles.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int main(int argc, char ** argv){
int x,y,z, N_min_cell, LAST_FILTER_STEP, num_th, arg_offset, i,j,k;
unsigned long long ct, ion_ct, sample_ct;
float f_coll_crit, pixel_volume, density_over_mean, erfc_num, erfc_denom, erfc_denom_cell, res_xH, Splined_Fcoll;
float *xH=NULL, *xH_m=NULL, TVIR_MIN, MFP, xHI_from_xrays, std_xrays, *z_re=NULL, *Gamma12=NULL, *mfp=NULL;
float *xH=NULL, TVIR_MIN, MFP, xHI_from_xrays, std_xrays, *z_re=NULL, *Gamma12=NULL, *mfp=NULL;
fftwf_complex *M_coll_unfiltered=NULL, *M_coll_filtered=NULL, *deltax_unfiltered=NULL, *deltax_filtered=NULL, *xe_unfiltered=NULL, *xe_filtered=NULL;
fftwf_complex *N_rec_unfiltered=NULL, *N_rec_filtered=NULL;
fftwf_plan plan;
Expand Down Expand Up @@ -197,7 +197,7 @@ Check that your inclusion (or not) of [<previous redshift>] is consistent with t
cell_length_factor = 1;
}
init_ps();
init_MHR();
if (INHOMO_RECO) { init_MHR();}
init_21cmMC_arrays();


Expand Down Expand Up @@ -251,12 +251,12 @@ Check that your inclusion (or not) of [<previous redshift>] is consistent with t

// allocate memory for the neutral fraction box
xH = (float *) fftwf_malloc(sizeof(float)*HII_TOT_NUM_PIXELS);
xH_m = (float *) fftwf_malloc(sizeof(float)*HII_TOT_NUM_PIXELS);
if (!xH || !xH_m){
// xH_m = (float *) fftwf_malloc(sizeof(float)*HII_TOT_NUM_PIXELS);
if (!xH){
strcpy(error_message, "find_HII_bubbles.c: Error allocating memory for xH box\nAborting...\n");
goto CLEANUP;
}
for (ct=0; ct<HII_TOT_NUM_PIXELS; ct++){ xH[ct] = xH_m[ct] = 1; }
for (ct=0; ct<HII_TOT_NUM_PIXELS; ct++){ xH[ct] = 1; }


// compute the mean collpased fraction at this redshift
Expand All @@ -281,7 +281,7 @@ Check that your inclusion (or not) of [<previous redshift>] is consistent with t
if (!(F = fopen(filename, "rb"))){
fprintf(stderr, "find_HII_bubbles: Unable to open x_e file at %s\nAborting...\n", filename);
fprintf(LOG, "find_HII_bubbles: Unable to open x_e file at %s\nAborting...\n", filename);
fclose(LOG); fftwf_free(xH); fftwf_free(xH_m); fftwf_cleanup_threads();
fclose(LOG); fftwf_free(xH); fftwf_cleanup_threads();
free_ps(); destroy_21cmMC_arrays(); return -1;
}
for (ct=0; ct<HII_TOT_NUM_PIXELS; ct++){
Expand Down Expand Up @@ -328,7 +328,7 @@ Check that your inclusion (or not) of [<previous redshift>] is consistent with t
fprintf(stderr, "find_HII_bubbles.c: Write error occured while writting xH box.\n");
fprintf(LOG, "find_HII_bubbles.c: Write error occured while writting xH box.\n");
}
free_ps(); fclose(F); fclose(LOG); fftwf_free(xH); fftwf_free(xH_m); fftwf_cleanup_threads();
free_ps(); fclose(F); fclose(LOG); fftwf_free(xH); fftwf_cleanup_threads();
destroy_21cmMC_arrays(); return (int) (global_xH * 100);
}

Expand Down Expand Up @@ -520,7 +520,6 @@ Check that your inclusion (or not) of [<previous redshift>] is consistent with t
fprintf(stderr, error_message);
fprintf(LOG, error_message);
fftwf_free(xH);
fftwf_free(xH_m);
fftwf_free(z_re);
fftwf_free(Gamma12);
fclose(LOG);
Expand All @@ -529,9 +528,8 @@ Check that your inclusion (or not) of [<previous redshift>] is consistent with t
fftwf_free(M_coll_unfiltered);
fftwf_free(M_coll_filtered);
fftwf_cleanup_threads();
if (F){ fclose(F);}
free_ps();
free_MHR();
if (INHOMO_RECO) { free_MHR();}
fftwf_free(xe_filtered);
fftwf_free(xe_unfiltered);
fftwf_free(N_rec_unfiltered);
Expand Down Expand Up @@ -936,25 +934,21 @@ Check that your inclusion (or not) of [<previous redshift>] is consistent with t
}


fprintf(stderr, error_message);
fprintf(LOG, error_message);
fftwf_free(xH);
fftwf_free(xH_m);
fftwf_free(z_re);
fftwf_free(Gamma12);
fclose(LOG);
fftwf_free(deltax_unfiltered);
fftwf_free(deltax_filtered);
fftwf_free(M_coll_unfiltered);
fftwf_free(M_coll_filtered);
fftwf_cleanup_threads();
if (F){ fclose(F);}
free_ps();
free_MHR();
fftwf_free(xe_filtered);
fftwf_free(xe_unfiltered);
if (INHOMO_RECO) { free_MHR();}
fftwf_free(N_rec_unfiltered);
fftwf_free(N_rec_filtered);
fftwf_free(z_re);
fftwf_free(Gamma12);
fftwf_free(xe_filtered);
fftwf_free(xe_unfiltered);
destroy_21cmMC_arrays();

return 0;
Expand Down

0 comments on commit 42e7566

Please sign in to comment.