diff --git a/include/common.h b/include/common.h index efda051b..7dc96e57 100644 --- a/include/common.h +++ b/include/common.h @@ -15,7 +15,7 @@ #ifndef __COMMON__ #define __COMMON__ -#define _VERSION_ "v3.2.2" +#define _VERSION_ "v3.2.3" /* @cond INCLUDE_WITH_DOXYGEN */ @@ -100,6 +100,16 @@ extern "C" { /* general CLASS macros */ +//This macro receives additional 'do {' and '} while(0)' to safeguard +//in single-line if else clauses without '{' and '}' +//Also, careful: Since sprintf(NULL,0,x) returns the size of characters +//that are inside of the string x, then the buffer needs to be +//actually one character longer to hold also the null character '\0' +#define class_sprintf(string, format...) do { \ + int _buffer_size_sprintf = snprintf(NULL, 0, format); \ + snprintf(string, _buffer_size_sprintf+1, format); \ +} while (0) + #define class_build_error_string(dest,tmpl,...) { \ ErrorMsg FMsg; \ class_protect_sprintf(FMsg,tmpl,__VA_ARGS__); \ @@ -188,8 +198,8 @@ extern "C" { } /* macro for re-allocating memory, returning error if it failed */ -#define class_realloc(pointer, newname, size, error_message_output) { \ - pointer=(__typeof__(pointer))realloc(newname,size); \ +#define class_realloc(pointer, size, error_message_output) { \ + pointer=(__typeof__(pointer))realloc(pointer,size); \ if (pointer == NULL) { \ int size_int; \ size_int = size; \ @@ -335,6 +345,17 @@ extern "C" { #define class_print_species(name,type) \ printf("-> %-30s Omega = %-15g , omega = %-15g\n",name,pba->Omega0_##type,pba->Omega0_##type*pba->h*pba->h); +//Generic evolver prototype +#define EVOLVER_PROTOTYPE \ + int (*)(double, double *, double *, void *, ErrorMsg), \ + double, double, double *, int *, \ + int, void *, double, double, \ + int (*)(double, void *, double *, ErrorMsg), \ + double, double *, int, \ + int (*)(double, double *, double *, int, void *, ErrorMsg), \ + int (*)(double, double *, double *, void *, ErrorMsg), \ + ErrorMsg + /* Forward-Declare the structs of CLASS */ struct background; struct thermodynamics; diff --git a/include/parallel.h b/include/parallel.h index da18ee78..28fabf90 100644 --- a/include/parallel.h +++ b/include/parallel.h @@ -215,8 +215,8 @@ class TaskSystem { const unsigned int count_; std::vector threads_; - std::vector queues_; std::atomic index_; + std::vector queues_; }; } diff --git a/source/background.c b/source/background.c index 22246e23..65ea692b 100644 --- a/source/background.c +++ b/source/background.c @@ -1442,9 +1442,8 @@ int background_ncdm_init( pba->error_message), pba->error_message, pba->error_message); - pba->q_ncdm[k]=realloc(pba->q_ncdm[k],pba->q_size_ncdm[k]*sizeof(double)); - pba->w_ncdm[k]=realloc(pba->w_ncdm[k],pba->q_size_ncdm[k]*sizeof(double)); - + class_realloc(pba->q_ncdm[k],pba->q_size_ncdm[k]*sizeof(double), pba->error_message); + class_realloc(pba->w_ncdm[k],pba->q_size_ncdm[k]*sizeof(double), pba->error_message); if (pba->background_verbose > 0) { printf("ncdm species i=%d sampled with %d points for purpose of perturbation integration\n", @@ -1470,8 +1469,8 @@ int background_ncdm_init( pba->error_message, pba->error_message); - pba->q_ncdm_bg[k]=realloc(pba->q_ncdm_bg[k],pba->q_size_ncdm_bg[k]*sizeof(double)); - pba->w_ncdm_bg[k]=realloc(pba->w_ncdm_bg[k],pba->q_size_ncdm_bg[k]*sizeof(double)); + class_realloc(pba->q_ncdm_bg[k],pba->q_size_ncdm_bg[k]*sizeof(double), pba->error_message); + class_realloc(pba->w_ncdm_bg[k],pba->q_size_ncdm_bg[k]*sizeof(double), pba->error_message); /** - in verbose mode, inform user of number of sampled momenta for background quantities */ @@ -1886,9 +1885,9 @@ int background_solve( double conformal_distance; /* evolvers */ - extern int evolver_rk(); - extern int evolver_ndf15(); - int (*generic_evolver)() = evolver_ndf15; + extern int evolver_rk(EVOLVER_PROTOTYPE); + extern int evolver_ndf15(EVOLVER_PROTOTYPE); + int (*generic_evolver)(EVOLVER_PROTOTYPE) = evolver_ndf15; /* initial and final loga values */ double loga_ini, loga_final; @@ -2440,9 +2439,9 @@ int background_output_titles( class_store_columntitle(titles,"(.)rho_idm",pba->has_idm); if (pba->has_ncdm == _TRUE_) { for (n=0; nN_ncdm; n++) { - sprintf(tmp,"(.)rho_ncdm[%d]",n); + class_sprintf(tmp,"(.)rho_ncdm[%d]",n); class_store_columntitle(titles,tmp,_TRUE_); - sprintf(tmp,"(.)p_ncdm[%d]",n); + class_sprintf(tmp,"(.)p_ncdm[%d]",n); class_store_columntitle(titles,tmp,_TRUE_); } } diff --git a/source/distortions.c b/source/distortions.c index 507629d6..b198217e 100644 --- a/source/distortions.c +++ b/source/distortions.c @@ -161,8 +161,8 @@ int distortions_constants(struct precision * ppr, pow(pba->Omega0_b*pow(pba->h,2.)/0.02225,-2./5.)* pow(pba->T_cmb/2.726,1./5.); - sprintf(psd->sd_PCA_file_generator,"%s/%s",ppr->sd_external_path,"generate_PCA_files.py"); - sprintf(psd->sd_detector_list_file,"%s/%s",ppr->sd_external_path,"detectors_list.dat"); + class_sprintf(psd->sd_PCA_file_generator,"%s/%s",ppr->sd_external_path,"generate_PCA_files.py"); + class_sprintf(psd->sd_detector_list_file,"%s/%s",ppr->sd_external_path,"detectors_list.dat"); return _SUCCESS_; } @@ -223,12 +223,12 @@ int distortions_set_detector(struct precision * ppr, else { /* Generate a custom name for this custom detector, so we can check if it has already been defined */ if (psd->has_detector_file == _TRUE_) { - sprintf(psd->sd_detector_name, + class_sprintf(psd->sd_detector_name, "Custom__%.80s__Detector", psd->sd_detector_file_name); } else { - sprintf(psd->sd_detector_name, + class_sprintf(psd->sd_detector_name, "Custom__%7.2e_%7.2e_%7.2e_%i_%7.2e__Detector", psd->sd_detector_nu_min,psd->sd_detector_nu_max,psd->sd_detector_nu_delta,psd->sd_detector_bin_number,psd->sd_detector_delta_Ic); } @@ -282,7 +282,7 @@ int distortions_set_detector(struct precision * ppr, psd->error_message, "Detector property type disagrees between stored detector '%s' and input -> Userdefined (input) vs Noisefile (stored)", detector_name); - sprintf(psd->sd_detector_file_name, "%s", detector_noise_file_name); + class_sprintf(psd->sd_detector_file_name, "%s", detector_noise_file_name); psd->has_detector_file = has_detector_noise_file; } else { @@ -304,7 +304,7 @@ int distortions_set_detector(struct precision * ppr, psd->error_message, "Delta frequency (sd_detector_nu_delta) disagrees between stored detector '%s' and input -> %.10e (input) vs %.10e (stored)", detector_name,psd->sd_detector_nu_delta,nu_delta); - class_test(fabs(psd->sd_detector_bin_number-N_bins)>ppr->tol_sd_detector, + class_test(abs(psd->sd_detector_bin_number-N_bins)>ppr->tol_sd_detector, psd->error_message, "Number of bins (sd_detector_bin_number) disagrees between stored detector '%s' and input -> %i (input) vs %i (stored)", detector_name,psd->sd_detector_bin_number,N_bins); @@ -391,7 +391,7 @@ int distortions_generate_detector(struct precision * ppr, } if (psd->has_detector_file == _TRUE_) { - sprintf(temporary_string,"python %s %s %s %s %.10e %.10e %i %i %.10e %.10e %.10e", + class_sprintf(temporary_string,"python %s %s %s %s %.10e %.10e %i %i %.10e %.10e %.10e", psd->sd_PCA_file_generator, psd->sd_detector_name, ppr->sd_external_path, @@ -406,7 +406,7 @@ int distortions_generate_detector(struct precision * ppr, } else { - sprintf(temporary_string,"python %s %s %.10e %.10e %.10e %i %.10e %.10e %i %.10e %i %.10e %.10e %.10e", + class_sprintf(temporary_string,"python %s %s %.10e %.10e %.10e %i %.10e %.10e %i %.10e %i %.10e %.10e %.10e", psd->sd_PCA_file_generator, psd->sd_detector_name, psd->sd_detector_nu_min, @@ -452,7 +452,7 @@ int distortions_read_detector_noisefile(struct precision * ppr, int numcols; /** Open file */ - sprintf(psd->sd_detector_noise_file,"%s/%s",ppr->sd_external_path,psd->sd_detector_file_name); + class_sprintf(psd->sd_detector_noise_file,"%s/%s",ppr->sd_external_path,psd->sd_detector_file_name); class_open(infile, psd->sd_detector_noise_file, "r", psd->error_message); /** Read header */ @@ -1418,7 +1418,7 @@ int distortions_read_br_data(struct precision * ppr, int headlines = 0; /** Open file */ - sprintf(br_file,"%s/%s_branching_ratios.dat", ppr->sd_external_path, psd->sd_detector_name); + class_sprintf(br_file,"%s/%s_branching_ratios.dat", ppr->sd_external_path, psd->sd_detector_name); class_open(infile, br_file, "r", psd->error_message); /** Read header */ @@ -1651,7 +1651,7 @@ int distortions_read_sd_data(struct precision * ppr, int index_x,index_k; /** Open file */ - sprintf(sd_file,"%s/%s_distortions_shapes.dat",ppr->sd_external_path, psd->sd_detector_name); + class_sprintf(sd_file,"%s/%s_distortions_shapes.dat",ppr->sd_external_path, psd->sd_detector_name); class_open(infile, sd_file, "r", psd->error_message); /** Read header */ @@ -1931,16 +1931,16 @@ int distortions_output_sd_titles(struct distortions * psd, class_store_columntitle(titles,"SD_tot",_TRUE_); for (index_type=0;index_typetype_size;++index_type){ if (index_type==psd->index_type_g) { - sprintf(temp_title,"SD[g]"); + class_sprintf(temp_title,"SD[g]"); } if (index_type==psd->index_type_y) { - sprintf(temp_title,"SD[y]"); + class_sprintf(temp_title,"SD[y]"); } if (index_type==psd->index_type_mu) { - sprintf(temp_title,"SD[mu]"); + class_sprintf(temp_title,"SD[mu]"); } if (index_type>=psd->index_type_PCA) { - sprintf(temp_title,"SD[e_%i]",(index_type-psd->index_type_PCA)); + class_sprintf(temp_title,"SD[e_%i]",(index_type-psd->index_type_PCA)); } class_store_columntitle(titles,temp_title,_TRUE_); } diff --git a/source/input.c b/source/input.c index d4ca6fe2..fcdcb52d 100644 --- a/source/input.c +++ b/source/input.c @@ -277,7 +277,7 @@ int input_set_root(char* input_file, /* No file has been found yet */ found_filenum = _FALSE_; for (iextens = 0; iextens < n_extensions; ++iextens){ - sprintf(tmp_file,"%s%02d_%s", outfname, filenum, output_extensions[iextens]); + class_sprintf(tmp_file,"%s%02d_%s", outfname, filenum, output_extensions[iextens]); if (file_exists(tmp_file) == _TRUE_){ /* Found a file, the outer loop is forced to keep searching */ found_filenum = _TRUE_; @@ -295,8 +295,8 @@ int input_set_root(char* input_file, pfc->filename, errmsg), errmsg,errmsg); - sprintf(fc_root.name[0],"root"); - sprintf(fc_root.value[0],"%s%02d_",outfname,filenum); + class_sprintf(fc_root.name[0],"root"); + class_sprintf(fc_root.value[0],"%s%02d_",outfname,filenum); fc_root.read[0] = _FALSE_; class_call(parser_cat(pfc, &fc_root, @@ -314,7 +314,7 @@ int input_set_root(char* input_file, } /* If root was found, set the index in the fc_input struct */ else{ - sprintf(pfc->value[index_root_in_fc_input],"%s%02d_",outfname,filenum); + class_sprintf(pfc->value[index_root_in_fc_input],"%s%02d_",outfname,filenum); (*ppfc_input) = pfc; } } @@ -328,8 +328,8 @@ int input_set_root(char* input_file, pfc->filename, errmsg), errmsg,errmsg); - sprintf(fc_root.name[0],"root"); - sprintf(fc_root.value[0],"%s_",outfname); + class_sprintf(fc_root.name[0],"root"); + class_sprintf(fc_root.value[0],"%s_",outfname); fc_root.read[0] = _FALSE_; class_call(parser_cat(pfc, &fc_root, @@ -347,7 +347,7 @@ int input_set_root(char* input_file, } /* If root was found, set the index in the fc_input struct */ else{ - sprintf(pfc->value[index_root_in_fc_input],"%s_",outfname); + class_sprintf(pfc->value[index_root_in_fc_input],"%s_",outfname); (*ppfc_input) = pfc; } } @@ -658,7 +658,7 @@ int input_shooting(struct file_content * pfc, /* Store xzero */ // This needs to be done with enough accuracy. A standard double has a relative // precision of around 1e-16, so 1e-20 should be good enough for the shooting - sprintf(fzw.fc.value[fzw.unknown_parameters_index[0]],"%.20e",xzero); + class_sprintf(fzw.fc.value[fzw.unknown_parameters_index[0]],"%.20e",xzero); if (input_verbose > 0) { fprintf(stdout," -> found '%s = %s'\n", fzw.fc.name[fzw.unknown_parameters_index[0]], @@ -705,7 +705,7 @@ int input_shooting(struct file_content * pfc, // This needs to be done with enough accuracy. A standard double has a relative // precision of around 1e-16, so 1e-20 should be good enough for the shooting for (counter = 0; counter < unknown_parameters_size; counter++){ - sprintf(fzw.fc.value[fzw.unknown_parameters_index[counter]], + class_sprintf(fzw.fc.value[fzw.unknown_parameters_index[counter]], "%.20e",x_inout[counter]); if (input_verbose > 0) { fprintf(stdout," -> found '%s = %s'\n", @@ -838,7 +838,7 @@ int input_shooting(struct file_content * pfc, A_s = (fzw.target_value[0]/sigma8_or_S8) *(fzw.target_value[0]/sigma8_or_S8) * A_s; //(truesigma/sigma_for_guess)^2 *A_s_for_guess /* Store the derived value with high enough accuracy */ - sprintf(fzw.fc.value[pfc->size],"%.20e",A_s); + class_sprintf(fzw.fc.value[pfc->size],"%.20e",A_s); if (input_verbose > 0) { fprintf(stdout," -> found '%s = %s'\n", fzw.fc.name[pfc->size], @@ -1345,7 +1345,7 @@ int input_try_unknown_parameters(double * unknown_parameter, // This needs to be done with enough accuracy. A standard double has a relative // precision of around 1e-16, so 1e-20 should be good enough for the shooting for (i=0; i < unknown_parameters_size; i++) { - sprintf(pfzw->fc.value[pfzw->unknown_parameters_index[i]],"%.20e",unknown_parameter[i]); + class_sprintf(pfzw->fc.value[pfzw->unknown_parameters_index[i]],"%.20e",unknown_parameter[i]); } class_call(input_read_precisions(&(pfzw->fc),&pr,&ba,&th,&pt,&tr,&pm,&hr,&fo,&le,&sd,&op, @@ -3001,7 +3001,7 @@ int input_read_parameters_species(struct file_content * pfc, if (ppt->perturbations_verbose > 0) { printf("WARNING: only %i entries of alpha_idm_dr were provided for %i moments, filling up the rest with the last entry provided\n", entries_read, ppr->l_max_idr-1); } - class_realloc(ppt->alpha_idm_dr,ppt->alpha_idm_dr,(ppr->l_max_idr-1)*sizeof(double),errmsg); + class_realloc(ppt->alpha_idm_dr,(ppr->l_max_idr-1)*sizeof(double),errmsg); for (n=entries_read; n<(ppr->l_max_idr-1); n++) ppt->alpha_idm_dr[n] = ppt->alpha_idm_dr[entries_read-1]; } } @@ -3044,7 +3044,7 @@ int input_read_parameters_species(struct file_content * pfc, if (ppt->perturbations_verbose > 0) { printf("WARNING: only %i entries of beta_idr were provided for %i moments, filling up the rest with the last entry provided\n", entries_read, ppr->l_max_idr-1); } - class_realloc(ppt->beta_idr,ppt->beta_idr,(ppr->l_max_idr-1)*sizeof(double),errmsg); + class_realloc(ppt->beta_idr,(ppr->l_max_idr-1)*sizeof(double),errmsg); for (n=entries_read; n<(ppr->l_max_idr-1); n++) ppt->beta_idr[n] = ppt->beta_idr[entries_read-1]; } @@ -3133,7 +3133,7 @@ int input_read_parameters_species(struct file_content * pfc, /** 7.3) Final consistency checks for dark matter species */ - class_test(abs(f_cdm + f_idm - 1.) > 1e-10, + class_test(fabs(f_cdm + f_idm - 1.) > 1e-10, errmsg, "The dark matter species do not add up to the expected value"); @@ -3146,7 +3146,7 @@ int input_read_parameters_species(struct file_content * pfc, class_test((f_idm > 0.) && (pba->Omega0_cdm == 0.), errmsg, "If you want a fraction of interacting, to be consistent, you should not set the fraction of CDM to zero"); - class_test(abs(f_cdm + f_idm - 1.) > ppr->tol_fraction_accuracy, + class_test(fabs(f_cdm + f_idm - 1.) > ppr->tol_fraction_accuracy, errmsg, "The dark matter species do not add up to the expected value"); if ( f_idm > 0. ) @@ -4814,7 +4814,7 @@ int input_read_parameters_spectra(struct file_content * pfc, errmsg, errmsg); /* Complete set of parameters */ - if ((flag1 == _TRUE_)) { + if (flag1 == _TRUE_) { if ((strstr(string1,"analytic") != NULL)){ ptr->has_nz_analytic = _TRUE_; } @@ -4829,7 +4829,7 @@ int input_read_parameters_spectra(struct file_content * pfc, errmsg, errmsg); /* Complete set of parameters */ - if ((flag1 == _TRUE_)) { + if (flag1 == _TRUE_) { if ((strstr(string1,"analytic") != NULL)){ ptr->has_nz_evo_analytic = _TRUE_; } @@ -5535,7 +5535,7 @@ int input_write_info(struct file_content * pfc, /* Finally, since all variables are read, we can also print the parameters.ini and unused_parameters files */ if (flag1 == _TRUE_) { - sprintf(param_output_name,"%s%s",pop->root,"parameters.ini"); + class_sprintf(param_output_name,"%s%s",pop->root,"parameters.ini"); class_open(param_output,param_output_name,"w",errmsg); fprintf(param_output,"# List of input/precision parameters actually read\n"); fprintf(param_output,"# (all other parameters set to default values)\n"); @@ -5544,7 +5544,7 @@ int input_write_info(struct file_content * pfc, fprintf(param_output,"# This file can be used as the input file of another run\n"); fprintf(param_output,"#\n"); - sprintf(param_unused_name,"%s%s",pop->root,"unused_parameters"); + class_sprintf(param_unused_name,"%s%s",pop->root,"unused_parameters"); class_open(param_unused,param_unused_name,"w",errmsg); fprintf(param_unused,"# List of input/precision parameters passed\n"); fprintf(param_unused,"# but not used (just for info)\n"); @@ -5890,13 +5890,13 @@ int input_default_params(struct background *pba, /** 5) Injection efficiency */ pin->f_eff_type = f_eff_on_the_spot; pin->f_eff = 1.; - sprintf(pin->f_eff_file,"external/heating/example_f_eff_file.dat"); + class_sprintf(pin->f_eff_file,"external/heating/example_f_eff_file.dat"); /** 6) Deposition function */ pin->chi_type = chi_CK; /** 6.1) External file */ - sprintf(pin->chi_z_file,"external/heating/example_chiz_file.dat"); - sprintf(pin->chi_x_file,"external/heating/example_chix_file.dat"); + class_sprintf(pin->chi_z_file,"external/heating/example_chiz_file.dat"); + class_sprintf(pin->chi_x_file,"external/heating/example_chix_file.dat"); /** * Default to input_read_parameters_nonlinear @@ -6076,7 +6076,7 @@ int input_default_params(struct background *pba, /** 1.a.3) Detector name */ psd->has_user_defined_name = _FALSE_; psd->has_user_defined_detector = _FALSE_; - sprintf(psd->sd_detector_name,"PIXIE"); + class_sprintf(psd->sd_detector_name,"PIXIE"); /** 1.3.a.1) Detector nu min */ psd->sd_detector_nu_min = 30.; /** 1.3.a.2) Detector nu max */ @@ -6114,7 +6114,7 @@ int input_default_params(struct background *pba, /** 1) Output for external files */ /** 1.a) File name */ - sprintf(pop->root,"output/"); + class_sprintf(pop->root,"output/"); /** 1.b) Headers */ pop->write_header = _TRUE_; /** 1.c) Format */ diff --git a/source/lensing.c b/source/lensing.c index c87ca9bc..778af1f7 100644 --- a/source/lensing.c +++ b/source/lensing.c @@ -121,16 +121,6 @@ int lensing_init( double * ksip = NULL; /* ksip[index_mu] */ double * ksim = NULL; /* ksim[index_mu] */ - double fac,fac1; - double X_000; - double X_p000; - double X_220; - double X_022; - double X_p022; - double X_121; - double X_132; - double X_242; - int num_mu,index_mu,icount; int l; double ll; @@ -141,9 +131,6 @@ int lensing_init( double * cl_bb = NULL; /* unlensed cl, to be filled to avoid repeated calls to harmonic_cl_at_l */ double * cl_pp; /* potential cl, to be filled to avoid repeated calls to harmonic_cl_at_l */ - double res,resX,lens; - double resp, resm, lensp, lensm; - double * sqrt1; double * sqrt2; double * sqrt3; @@ -1286,14 +1273,13 @@ int lensing_d00( class_setup_parallel(); for (index_mu=0;index_muroot,"cl.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cl.dat"); class_call(output_open_cl_file(phr, pop, @@ -328,7 +328,7 @@ int output_cl( if (ple->has_lensed_cls == _TRUE_) { - sprintf(file_name,"%s%s",pop->root,"cl_lensed.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cl_lensed.dat"); class_call(output_open_cl_file(phr, pop, @@ -347,14 +347,14 @@ int output_cl( if (_scalars_) { - sprintf(file_name,"%s%s",pop->root,"cls.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar mode"); } if (_tensors_) { - sprintf(file_name,"%s%s",pop->root,"clt.dat"); + class_sprintf(file_name,"%s%s",pop->root,"clt.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for tensor mode"); } @@ -389,105 +389,105 @@ int output_cl( if ((ppt->has_ad == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_ad)) { - sprintf(file_name,"%s%s",pop->root,"cls_ad.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_ad.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar adiabatic (AD) mode"); } if ((ppt->has_bi == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_bi)) { - sprintf(file_name,"%s%s",pop->root,"cls_bi.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_bi.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar baryon isocurvature (BI) mode"); } if ((ppt->has_cdi == _TRUE_) && (index_ic1 == ppt->index_ic_cdi) && (index_ic2 == ppt->index_ic_cdi)) { - sprintf(file_name,"%s%s",pop->root,"cls_cdi.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_cdi.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar CDM isocurvature (CDI) mode"); } if ((ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_nid) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s",pop->root,"cls_nid.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_nid.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar neutrino density isocurvature (NID) mode"); } if ((ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_niv) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s",pop->root,"cls_niv.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_niv.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar neutrino velocity isocurvature (NIV) mode"); } if ((ppt->has_ad == _TRUE_) && (ppt->has_bi == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_bi)) { - sprintf(file_name,"%s%s",pop->root,"cls_ad_bi.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_ad_bi.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross ADxBI mode"); } if ((ppt->has_ad == _TRUE_) && (ppt->has_cdi == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_cdi)) { - sprintf(file_name,"%s%s",pop->root,"cls_ad_cdi.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_ad_cdi.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross ADxCDI mode"); } if ((ppt->has_ad == _TRUE_) && (ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s",pop->root,"cls_ad_nid.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_ad_nid.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross ADxNID mode"); } if ((ppt->has_ad == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s",pop->root,"cls_ad_niv.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_ad_niv.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross ADxNIV mode"); } if ((ppt->has_bi == _TRUE_) && (ppt->has_cdi == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_cdi)) { - sprintf(file_name,"%s%s",pop->root,"cls_bi_cdi.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_bi_cdi.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross BIxCDI mode"); } if ((ppt->has_bi == _TRUE_) && (ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s",pop->root,"cls_bi_nid.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_bi_nid.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross BIxNID mode"); } if ((ppt->has_bi == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s",pop->root,"cls_bi_niv.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_bi_niv.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross BIxNIV mode"); } if ((ppt->has_cdi == _TRUE_) && (ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_cdi) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s",pop->root,"cls_cdi_nid.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_cdi_nid.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross CDIxNID mode"); } if ((ppt->has_cdi == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_cdi) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s",pop->root,"cls_cdi_niv.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_cdi_niv.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross CDIxNIV mode"); } if ((ppt->has_nid == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_nid) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s",pop->root,"cls_nid_niv.dat"); + class_sprintf(file_name,"%s%s",pop->root,"cls_nid_niv.dat"); strcpy(first_line,"[l(l+1)/2pi] C_l's for scalar cross NIDxNIV mode"); } @@ -684,15 +684,15 @@ int output_pk( if ((pfo->has_pk_m == _TRUE_) && (index_pk == pfo->index_pk_m)) { if (pk_output == pk_linear) - sprintf(type_suffix,"pk"); + class_sprintf(type_suffix,"pk"); else - sprintf(type_suffix,"pk_nl"); + class_sprintf(type_suffix,"pk_nl"); } if ((pfo->has_pk_cb == _TRUE_) && (index_pk == pfo->index_pk_cb)) { if (pk_output == pk_linear) - sprintf(type_suffix,"pk_cb"); + class_sprintf(type_suffix,"pk_cb"); else - sprintf(type_suffix,"pk_cb_nl"); + class_sprintf(type_suffix,"pk_cb_nl"); } /** - loop over z */ @@ -708,11 +708,11 @@ int output_pk( if (pop->z_pk_num == 1) redshift_suffix[0]='\0'; else - sprintf(redshift_suffix,"z%d_",index_z+1); + class_sprintf(redshift_suffix,"z%d_",index_z+1); /** - second, open only the relevant files and write a header in each of them */ - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,".dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,".dat"); class_call(output_open_pk_file(pba, pfo, @@ -732,77 +732,77 @@ int output_pk( for (index_ic2 = index_ic1; index_ic2 < pfo->ic_size; index_ic2++) { if ((ppt->has_ad == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_ad)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad.dat"); strcpy(first_line,"for adiabatic (AD) mode "); } if ((ppt->has_bi == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_bi)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi.dat"); strcpy(first_line,"for baryon isocurvature (BI) mode "); } if ((ppt->has_cdi == _TRUE_) && (index_ic1 == ppt->index_ic_cdi) && (index_ic2 == ppt->index_ic_cdi)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_cdi.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_cdi.dat"); strcpy(first_line,"for CDM isocurvature (CDI) mode "); } if ((ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_nid) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_nid.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_nid.dat"); strcpy(first_line,"for neutrino density isocurvature (NID) mode "); } if ((ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_niv) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_niv.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_niv.dat"); strcpy(first_line,"for neutrino velocity isocurvature (NIV) mode "); } if ((ppt->has_ad == _TRUE_) && (ppt->has_bi == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_bi)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_bi.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_bi.dat"); strcpy(first_line,"for cross ADxBI mode "); } if ((ppt->has_ad == _TRUE_) && (ppt->has_cdi == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_cdi)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_cdi.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_cdi.dat"); strcpy(first_line,"for cross ADxCDI mode "); } if ((ppt->has_ad == _TRUE_) && (ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_nid.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_nid.dat"); strcpy(first_line,"for scalar cross ADxNID mode "); } if ((ppt->has_ad == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_ad) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_niv.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_ad_niv.dat"); strcpy(first_line,"for cross ADxNIV mode "); } if ((ppt->has_bi == _TRUE_) && (ppt->has_cdi == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_cdi)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi_cdi.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi_cdi.dat"); strcpy(first_line,"for cross BIxCDI mode "); } if ((ppt->has_bi == _TRUE_) && (ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi_nid.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi_nid.dat"); strcpy(first_line,"for cross BIxNID mode "); } if ((ppt->has_bi == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_bi) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi_niv.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_bi_niv.dat"); strcpy(first_line,"for cross BIxNIV mode "); } if ((ppt->has_cdi == _TRUE_) && (ppt->has_nid == _TRUE_) && (index_ic1 == ppt->index_ic_cdi) && (index_ic2 == ppt->index_ic_nid)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_cdi_nid.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_cdi_nid.dat"); strcpy(first_line,"for cross CDIxNID mode "); } if ((ppt->has_cdi == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_cdi) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_cdi_niv.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_cdi_niv.dat"); strcpy(first_line,"for cross CDIxNIV mode "); } if ((ppt->has_nid == _TRUE_) && (ppt->has_niv == _TRUE_) && (index_ic1 == ppt->index_ic_nid) && (index_ic2 == ppt->index_ic_niv)) { - sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_nid_niv.dat"); + class_sprintf(file_name,"%s%s%s%s",pop->root,redshift_suffix,type_suffix,"_nid_niv.dat"); strcpy(first_line,"for cross NIDxNIV mode "); } @@ -962,7 +962,7 @@ int output_tk( if (pop->z_pk_num == 1) redshift_suffix[0]='\0'; else - sprintf(redshift_suffix,"z%d_",index_z+1); + class_sprintf(redshift_suffix,"z%d_",index_z+1); /** - second, open only the relevant files, and write a heading in each of them */ @@ -982,9 +982,9 @@ int output_tk( ppt->error_message, pop->error_message); if ((ppt->has_ad == _TRUE_) && (ppt->ic_size[index_md] == 1) ) - sprintf(file_name,"%s%s%s",pop->root,redshift_suffix,"tk.dat"); + class_sprintf(file_name,"%s%s%s",pop->root,redshift_suffix,"tk.dat"); else - sprintf(file_name,"%s%s%s%s%s",pop->root,redshift_suffix,"tk_",ic_suffix,".dat"); + class_sprintf(file_name,"%s%s%s%s%s",pop->root,redshift_suffix,"tk_",ic_suffix,".dat"); class_open(tkfile, file_name, "w", pop->error_message); @@ -1061,7 +1061,7 @@ int output_background( pba->error_message, pop->error_message); - sprintf(file_name,"%s%s",pop->root,"background.dat"); + class_sprintf(file_name,"%s%s",pop->root,"background.dat"); class_open(backfile,file_name,"w",pop->error_message); if (pop->write_header == _TRUE_) { @@ -1113,7 +1113,7 @@ int output_thermodynamics( pth->error_message, pop->error_message); - sprintf(file_name,"%s%s",pop->root,"thermodynamics.dat"); + class_sprintf(file_name,"%s%s",pop->root,"thermodynamics.dat"); class_open(thermofile,file_name,"w",pop->error_message); if (pop->write_header == _TRUE_) { @@ -1170,7 +1170,7 @@ int output_perturbations( if (ppt->has_scalars == _TRUE_){ index_md = ppt->index_md_scalars; k = ppt->k[index_md][ppt->index_k_output_values[index_md*ppt->k_output_values_num+index_ikout]]; - sprintf(file_name,"%s%s%d%s",pop->root,"perturbations_k",index_ikout,"_s.dat"); + class_sprintf(file_name,"%s%s%d%s",pop->root,"perturbations_k",index_ikout,"_s.dat"); class_open(out, file_name, "w", ppt->error_message); fprintf(out,"#scalar perturbations for mode k = %.*e Mpc^(-1)\n",_OUTPUTPRECISION_,k); output_print_data(out, @@ -1183,7 +1183,7 @@ int output_perturbations( if (ppt->has_vectors == _TRUE_){ index_md = ppt->index_md_vectors; k = ppt->k[index_md][ppt->index_k_output_values[index_md*ppt->k_output_values_num+index_ikout]]; - sprintf(file_name,"%s%s%d%s",pop->root,"perturbations_k",index_ikout,"_v.dat"); + class_sprintf(file_name,"%s%s%d%s",pop->root,"perturbations_k",index_ikout,"_v.dat"); class_open(out, file_name, "w", ppt->error_message); fprintf(out,"#vector perturbations for mode k = %.*e Mpc^(-1)\n",_OUTPUTPRECISION_,k); output_print_data(out, @@ -1196,7 +1196,7 @@ int output_perturbations( if (ppt->has_tensors == _TRUE_){ index_md = ppt->index_md_tensors; k = ppt->k[index_md][ppt->index_k_output_values[index_md*ppt->k_output_values_num+index_ikout]]; - sprintf(file_name,"%s%s%d%s",pop->root,"perturbations_k",index_ikout,"_t.dat"); + class_sprintf(file_name,"%s%s%d%s",pop->root,"perturbations_k",index_ikout,"_t.dat"); class_open(out, file_name, "w", ppt->error_message); fprintf(out,"#tensor perturbations for mode k = %.*e Mpc^(-1)\n",_OUTPUTPRECISION_,k); output_print_data(out, @@ -1224,7 +1224,7 @@ int output_primordial( double * data; int size_data, number_of_titles; - sprintf(file_name,"%s%s",pop->root,"primordial_Pk.dat"); + class_sprintf(file_name,"%s%s",pop->root,"primordial_Pk.dat"); class_call(primordial_output_titles(ppt,ppm,titles), ppm->error_message, @@ -1278,7 +1278,7 @@ int output_heating(struct injection* pin, struct noninjection* pni, struct outpu if (pop->write_exotic_injection == _TRUE_){ /* File name */ - sprintf(file_name_injection,"%s%s",pop->root,"exotic_injection.dat"); + class_sprintf(file_name_injection,"%s%s",pop->root,"exotic_injection.dat"); /* Titles */ class_call(injection_output_titles(pin,titles_injection), @@ -1320,7 +1320,7 @@ int output_heating(struct injection* pin, struct noninjection* pni, struct outpu if (pop->write_noninjection == _TRUE_){ /* File name */ - sprintf(file_name_noninjection,"%s%s",pop->root,"photon_noninjection.dat"); + class_sprintf(file_name_noninjection,"%s%s",pop->root,"photon_noninjection.dat"); /* Titles */ class_call(noninjection_output_titles(pni,titles_noninjection), @@ -1380,7 +1380,7 @@ int output_distortions( if (pop->write_distortions==_TRUE_ && psd->has_distortions == _TRUE_){ /* File name */ - sprintf(file_name_heat,"%s%s",pop->root,"sd_heating.dat"); + class_sprintf(file_name_heat,"%s%s",pop->root,"sd_heating.dat"); /* Titles */ class_call(distortions_output_heat_titles(psd,titles_heat), @@ -1419,7 +1419,7 @@ int output_distortions( fclose(out_heat); /* File name */ - sprintf(file_name_distortion,"%s%s",pop->root,"sd_distortions.dat"); + class_sprintf(file_name_distortion,"%s%s",pop->root,"sd_distortions.dat"); /* Titles */ class_call(distortions_output_sd_titles(psd,titles_distortion), @@ -1602,41 +1602,41 @@ int output_open_cl_file( if (phr->has_dd == _TRUE_){ for (index_d1=0; index_d1d_size; index_d1++){ for (index_d2=index_d1; index_d2<=MIN(index_d1+phr->non_diag,phr->d_size-1); index_d2++){ - sprintf(tmp,"dens[%d]-dens[%d]",index_d1+1,index_d2+1); + class_sprintf(tmp,"dens[%d]-dens[%d]",index_d1+1,index_d2+1); class_fprintf_columntitle(*clfile,tmp,_TRUE_,colnum); } } } if (phr->has_td == _TRUE_){ for (index_d1=0; index_d1d_size; index_d1++){ - sprintf(tmp,"T-dens[%d]",index_d1+1); + class_sprintf(tmp,"T-dens[%d]",index_d1+1); class_fprintf_columntitle(*clfile,tmp,_TRUE_,colnum); } } if (phr->has_pd == _TRUE_){ for (index_d1=0; index_d1d_size; index_d1++){ - sprintf(tmp,"phi-dens[%d]",index_d1+1); + class_sprintf(tmp,"phi-dens[%d]",index_d1+1); class_fprintf_columntitle(*clfile,tmp,_TRUE_,colnum); } } if (phr->has_ll == _TRUE_){ for (index_d1=0; index_d1d_size; index_d1++){ for (index_d2=index_d1; index_d2<=MIN(index_d1+phr->non_diag,phr->d_size-1); index_d2++){ - sprintf(tmp,"lens[%d]-lens[%d]",index_d1+1,index_d2+1); + class_sprintf(tmp,"lens[%d]-lens[%d]",index_d1+1,index_d2+1); class_fprintf_columntitle(*clfile,tmp,_TRUE_,colnum); } } } if (phr->has_tl == _TRUE_){ for (index_d1=0; index_d1d_size; index_d1++){ - sprintf(tmp,"T-lens[%d]",index_d1+1); + class_sprintf(tmp,"T-lens[%d]",index_d1+1); class_fprintf_columntitle(*clfile,tmp,_TRUE_,colnum); } } if (phr->has_dl == _TRUE_){ for (index_d1=0; index_d1d_size; index_d1++){ for (index_d2=MAX(index_d1-phr->non_diag,0); index_d2<=MIN(index_d1+phr->non_diag,phr->d_size-1); index_d2++) { - sprintf(tmp,"dens[%d]-lens[%d]",index_d1+1,index_d2+1); + class_sprintf(tmp,"dens[%d]-lens[%d]",index_d1+1,index_d2+1); class_fprintf_columntitle(*clfile,tmp,_TRUE_,colnum); } } diff --git a/source/perturbations.c b/source/perturbations.c index 0be0b7d4..77edbd9e 100644 --- a/source/perturbations.c +++ b/source/perturbations.c @@ -562,7 +562,7 @@ int perturbations_output_titles( class_store_columntitle(titles,"d_idr",pba->has_idr); if (pba->has_ncdm == _TRUE_) { for (n_ncdm=0; n_ncdm < pba->N_ncdm; n_ncdm++) { - sprintf(tmp,"d_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"d_ncdm[%d]",n_ncdm); class_store_columntitle(titles,tmp,_TRUE_); } } @@ -591,7 +591,7 @@ int perturbations_output_titles( class_store_columntitle(titles,"t_idr",pba->has_idr); if (pba->has_ncdm == _TRUE_) { for (n_ncdm=0; n_ncdm < pba->N_ncdm; n_ncdm++) { - sprintf(tmp,"t_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"t_ncdm[%d]",n_ncdm); class_store_columntitle(titles,tmp,_TRUE_); } } @@ -708,8 +708,6 @@ int perturbations_init( int index_k; /* running index for type of perturbation */ int index_tp; - /* pointer to one struct perturbations_workspace per thread (one if no openmp) */ - struct perturbations_workspace ** pppw; /* background quantities */ double w_fld_ini, w_fld_0,dw_over_da_fld,integral_fld; @@ -2278,7 +2276,6 @@ int perturbations_get_k_list( ppt->k_size[ppt->index_md_scalars] = index_k; class_realloc(ppt->k[ppt->index_md_scalars], - ppt->k[ppt->index_md_scalars], ppt->k_size[ppt->index_md_scalars]*sizeof(double), ppt->error_message); } @@ -2412,7 +2409,6 @@ int perturbations_get_k_list( ppt->k_size[ppt->index_md_vectors] = index_k; class_realloc(ppt->k[ppt->index_md_vectors], - ppt->k[ppt->index_md_vectors], ppt->k_size[ppt->index_md_vectors]*sizeof(double), ppt->error_message); } @@ -2546,7 +2542,6 @@ int perturbations_get_k_list( ppt->k_size[ppt->index_md_tensors] = index_k; class_realloc(ppt->k[ppt->index_md_tensors], - ppt->k[ppt->index_md_tensors], ppt->k_size[ppt->index_md_tensors]*sizeof(double), ppt->error_message); } @@ -3338,13 +3333,13 @@ int perturbations_prepare_k_output(struct background * pba, /* Non-cold dark matter */ if ((pba->has_ncdm == _TRUE_) && ((ppt->has_density_transfers == _TRUE_) || (ppt->has_velocity_transfers == _TRUE_) || (ppt->has_source_delta_m == _TRUE_))) { for (n_ncdm=0; n_ncdm < pba->N_ncdm; n_ncdm++){ - sprintf(tmp,"delta_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"delta_ncdm[%d]",n_ncdm); class_store_columntitle(ppt->scalar_titles,tmp,_TRUE_); - sprintf(tmp,"theta_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"theta_ncdm[%d]",n_ncdm); class_store_columntitle(ppt->scalar_titles,tmp,_TRUE_); - sprintf(tmp,"shear_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"shear_ncdm[%d]",n_ncdm); class_store_columntitle(ppt->scalar_titles,tmp,_TRUE_); - sprintf(tmp,"cs2_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"cs2_ncdm[%d]",n_ncdm); class_store_columntitle(ppt->scalar_titles,tmp,_TRUE_); } } @@ -3386,11 +3381,11 @@ int perturbations_prepare_k_output(struct background * pba, if (ppt->evolve_tensor_ncdm == _TRUE_) { for (n_ncdm=0; n_ncdm < pba->N_ncdm; n_ncdm++){ - sprintf(tmp,"delta_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"delta_ncdm[%d]",n_ncdm); class_store_columntitle(ppt->tensor_titles,tmp,_TRUE_); - sprintf(tmp,"theta_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"theta_ncdm[%d]",n_ncdm); class_store_columntitle(ppt->tensor_titles,tmp,_TRUE_); - sprintf(tmp,"shear_ncdm[%d]",n_ncdm); + class_sprintf(tmp,"shear_ncdm[%d]",n_ncdm); class_store_columntitle(ppt->tensor_titles,tmp,_TRUE_); } } @@ -8202,7 +8197,7 @@ int perturbations_print_variables(double tau, theta_idr = y[ppw->pv->index_pt_theta_idr]; if (ppt->idr_nature == idr_free_streaming){ - if ((ppw->approx[ppw->index_ap_tca_idm_dr] == (int)tca_idm_dr_on)){ + if (ppw->approx[ppw->index_ap_tca_idm_dr] == (int)tca_idm_dr_on){ shear_idr = ppw->tca_shear_idm_dr; } else{ @@ -8410,9 +8405,9 @@ int perturbations_print_variables(double tau, ppt->size_scalar_perturbation_data[ppw->index_ikout] = 0; } else{ - ppt->scalar_perturbations_data[ppw->index_ikout] = - (double*)realloc(ppt->scalar_perturbations_data[ppw->index_ikout], - sizeof(double)*(ppt->size_scalar_perturbation_data[ppw->index_ikout]+ppt->number_of_scalar_titles)); + class_realloc(ppt->scalar_perturbations_data[ppw->index_ikout], + (ppt->size_scalar_perturbation_data[ppw->index_ikout]+ppt->number_of_scalar_titles)*sizeof(double), + ppt->error_message); } storeidx = 0; dataptr = ppt->scalar_perturbations_data[ppw->index_ikout]+ @@ -8776,7 +8771,7 @@ int perturbations_derivs(double tau, photon_scattering_rate += pvecthermo[pth->index_th_dmu_idm_g]; S_idm_g = 4./3. * pvecback[pba->index_bg_rho_g] / pvecback[pba->index_bg_rho_idm]; } - if ((pth->has_idm_dr == _TRUE_)){ + if (pth->has_idm_dr == _TRUE_){ S_idm_dr = 4./3. * pvecback[pba->index_bg_rho_idr]/ pvecback[pba->index_bg_rho_idm]; dmu_idm_dr = pvecthermo[pth->index_th_dmu_idm_dr]; dmu_idr = pth->b_idr/pth->a_idm_dr*pba->Omega0_idr/pba->Omega0_idm*dmu_idm_dr; diff --git a/source/primordial.c b/source/primordial.c index a5a2ec17..4831d17e 100644 --- a/source/primordial.c +++ b/source/primordial.c @@ -3227,7 +3227,7 @@ int primordial_external_spectrum_init( char command_with_arguments[2*_ARGUMENT_LENGTH_MAX_]; FILE *process; int n_data_guess, n_data = 0; - double *k = NULL, *pks = NULL, *pkt = NULL, *tmp = NULL; + double *k = NULL, *pks = NULL, *pkt = NULL; double this_k, this_pks, this_pkt; int status; int index_k; @@ -3242,16 +3242,16 @@ int primordial_external_spectrum_init( /* Prepare the command */ /* If the command is just a "cat", no arguments need to be passed */ if (strncmp("cat ", ppm->command, 4) == 0) { - sprintf(arguments, " "); + class_sprintf(arguments, " "); } /* otherwise pass the list of arguments */ else { - sprintf(arguments, " %g %g %g %g %g %g %g %g %g %g", + class_sprintf(arguments, " %g %g %g %g %g %g %g %g %g %g", ppm->custom1, ppm->custom2, ppm->custom3, ppm->custom4, ppm->custom5, ppm->custom6, ppm->custom7, ppm->custom8, ppm->custom9, ppm->custom10); } /* write the actual command in a string */ - sprintf(command_with_arguments, "%s %s", ppm->command, arguments); + class_sprintf(command_with_arguments, "%s %s", ppm->command, arguments); if (ppm->primordial_verbose > 0) printf(" -> running: %s\n",command_with_arguments); @@ -3273,24 +3273,12 @@ int primordial_external_spectrum_init( /* (it is faster and safer that reallocating every new line) */ if ((n_data+1) > n_data_guess) { n_data_guess *= 2; - tmp = (double *)realloc(k, n_data_guess*sizeof(double)); - class_test(tmp == NULL, - ppm->error_message, - "Error allocating memory to read the external spectrum.\n"); - k = tmp; - tmp = (double *)realloc(pks, n_data_guess*sizeof(double)); - class_test(tmp == NULL, - ppm->error_message, - "Error allocating memory to read the external spectrum.\n"); - pks = tmp; + class_realloc(k, n_data_guess*sizeof(double), ppm->error_message); + class_realloc(pks, n_data_guess*sizeof(double), ppm->error_message); if (ppt->has_tensors == _TRUE_) { - tmp = (double *)realloc(pkt, n_data_guess*sizeof(double)); - class_test(tmp == NULL, - ppm->error_message, - "Error allocating memory to read the external spectrum.\n"); - pkt = tmp; - }; - }; + class_realloc(pkt, n_data_guess*sizeof(double), ppm->error_message); + } + } /* Store */ k [n_data] = this_k; pks[n_data] = this_pks; @@ -3328,24 +3316,19 @@ int primordial_external_spectrum_init( ppm->lnk_size = n_data; /** - Make room */ class_realloc(ppm->lnk, - ppm->lnk, ppm->lnk_size*sizeof(double), ppm->error_message); class_realloc(ppm->lnpk[ppt->index_md_scalars], - ppm->lnpk[ppt->index_md_scalars], ppm->lnk_size*sizeof(double), ppm->error_message); class_realloc(ppm->ddlnpk[ppt->index_md_scalars], - ppm->ddlnpk[ppt->index_md_scalars], ppm->lnk_size*sizeof(double), ppm->error_message); if (ppt->has_tensors == _TRUE_) { class_realloc(ppm->lnpk[ppt->index_md_tensors], - ppm->lnpk[ppt->index_md_tensors], ppm->lnk_size*sizeof(double), ppm->error_message); class_realloc(ppm->ddlnpk[ppt->index_md_tensors], - ppm->ddlnpk[ppt->index_md_tensors], ppm->lnk_size*sizeof(double), ppm->error_message); }; diff --git a/source/thermodynamics.c b/source/thermodynamics.c index c1683f56..b5cda4a5 100644 --- a/source/thermodynamics.c +++ b/source/thermodynamics.c @@ -1553,9 +1553,9 @@ int thermodynamics_solve( struct thermodynamics_parameters_and_workspace tpaw; /* function pointer to ODE evolver and names of possible evolvers. */ - extern int evolver_rk(); - extern int evolver_ndf15(); - int (*generic_evolver)() = evolver_ndf15; + extern int evolver_rk(EVOLVER_PROTOTYPE); + extern int evolver_ndf15(EVOLVER_PROTOTYPE); + int (*generic_evolver)(EVOLVER_PROTOTYPE) = evolver_ndf15; /** - choose evolver */ switch (ppr->thermo_evolver) { @@ -2190,9 +2190,9 @@ int thermodynamics_reionization_evolve_with_tau( struct thermo_workspace * ptw; /* function pointer to ODE evolver and names of possible evolvers */ - extern int evolver_rk(); - extern int evolver_ndf15(); - int (*generic_evolver)() = evolver_ndf15; + extern int evolver_rk(EVOLVER_PROTOTYPE); + extern int evolver_ndf15(EVOLVER_PROTOTYPE); + int (*generic_evolver)(EVOLVER_PROTOTYPE) = evolver_ndf15; /* pointers towards two thermo vector stuctures (see below) */ @@ -4647,7 +4647,7 @@ int thermodynamics_obtain_z_ini( if (pth->thermodynamics_verbose > 3) printf("The decoupling redshift for idm_dr is z_idm_dec = %.5e\n", z_idm_dec); /* we need to be careful if idm is coupled to photons and idr at the same time */ - class_test(z_idm_dec_min != _HUGE_ && abs(pba->T_idr - pba->T_cmb) > 1e-2, + class_test(z_idm_dec_min != _HUGE_ && fabs(pba->T_idr - pba->T_cmb) > 1e-2, pth->error_message, "It seems that at early times idm is thermally coupled to both idr and photons (possibly through baryons).\nPlease set the initial temperatures equal or disable this error."); diff --git a/source/transfer.c b/source/transfer.c index 60d5330c..026b4554 100644 --- a/source/transfer.c +++ b/source/transfer.c @@ -1218,7 +1218,6 @@ int transfer_get_q_list( /* now, readjust array size */ class_realloc(ptr->q, - ptr->q, ptr->q_size*sizeof(double), ptr->error_message); @@ -4658,7 +4657,6 @@ int transfer_get_lmax(int (*get_xmin_generic)(int sgnK, int fevals=0, index_l_mid; int multiplier; int right_boundary_checked = _FALSE_; - int hil=0,hir=0,bini=0; class_call(get_xmin_generic(sgnK, lvec[0], nu, @@ -4692,7 +4690,6 @@ int transfer_get_lmax(int (*get_xmin_generic)(int sgnK, } /* Hunt for left boundary: */ for (multiplier=1; ;multiplier *= 5){ - hil++; class_call(get_xmin_generic(sgnK, lvec[*index_l_left], nu, @@ -4702,7 +4699,6 @@ int transfer_get_lmax(int (*get_xmin_generic)(int sgnK, &fevals), error_message, error_message); - //printf("Hunt left, iter = %d, x_nonzero=%g\n",hil,x_nonzero); if (x_nonzero <= xmax){ //Boundary found break; @@ -4722,8 +4718,6 @@ int transfer_get_lmax(int (*get_xmin_generic)(int sgnK, /* If not found, hunt for right boundary: */ if (right_boundary_checked == _FALSE_){ for (multiplier=1; ;multiplier *= 5){ - hir++; - //printf("right iteration %d,index_l_right:%d\n",hir,*index_l_right); class_call(get_xmin_generic(sgnK, lvec[*index_l_right], nu, @@ -4755,7 +4749,6 @@ int transfer_get_lmax(int (*get_xmin_generic)(int sgnK, // printf("Do binary search in get_lmax. \n"); //printf("Region: [%d, %d]\n",*index_l_left,*index_l_right); while (((*index_l_right) - (*index_l_left)) > 1) { - bini++; index_l_mid= (int)(0.5*((*index_l_right)+(*index_l_left))); //printf("left:%d, mid=%d, right=%d\n",*index_l_left,index_l_mid,*index_l_right); class_call(get_xmin_generic(sgnK, @@ -4773,9 +4766,6 @@ int transfer_get_lmax(int (*get_xmin_generic)(int sgnK, *index_l_right=index_l_mid; } //printf("Done\n"); - /* printf("Hunt left iter=%d, hunt right iter=%d (fevals: %d). For binary search: %d (fevals: %d)\n", - hil,hir,fevalshunt,bini,fevals); - */ return _SUCCESS_; } diff --git a/tools/arrays.c b/tools/arrays.c index 13c82bfb..dca382dc 100644 --- a/tools/arrays.c +++ b/tools/arrays.c @@ -80,7 +80,7 @@ int array_derive_spline( h = x_array[i+1] - x_array[i]; if (h == 0) { - sprintf(errmsg,"%s(L:%d) h=0, stop to avoid division by zero",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) h=0, stop to avoid division by zero",__func__,__LINE__); return _FAILURE_; } @@ -133,7 +133,7 @@ int array_derive_spline_table_line_to_line( h = x_array[i+1] - x_array[i]; if (h == 0) { - sprintf(errmsg,"%s(L:%d) h=0, stop to avoid division by zero",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) h=0, stop to avoid division by zero",__func__,__LINE__); return _FAILURE_; } @@ -165,7 +165,7 @@ int array_derive1_order2_table_line_to_line( double dxp,dxm,dyp,dym; if (n_lines < 2) { - sprintf(errmsg,"%s(L:%d) routine called with n_lines=%d, should be at least 2",__func__,__LINE__,n_lines); + class_sprintf(errmsg,"%s(L:%d) routine called with n_lines=%d, should be at least 2",__func__,__LINE__,n_lines); return _FAILURE_; } @@ -175,7 +175,7 @@ int array_derive1_order2_table_line_to_line( dym = *(array+0*n_columns+index_y) - *(array+1*n_columns+index_y); if ((dxp*dxm*(dxm-dxp)) == 0.) { - sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); return _FAILURE_; } @@ -192,7 +192,7 @@ int array_derive1_order2_table_line_to_line( dym = *(array+(i-1)*n_columns+index_y) - *(array+i*n_columns+index_y); if ((dxp*dxm*(dxm-dxp)) == 0.) { - sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); return _FAILURE_; } @@ -228,7 +228,7 @@ int array_derive2_order2_table_line_to_line( dym = *(array+(i-1)*n_columns+index_y) - *(array+i*n_columns+index_y); if ((dxp*dxm*(dxm-dxp)) == 0.) { - sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); return _FAILURE_; } @@ -297,7 +297,7 @@ int array_derive_two( double dx1,dx2,dy1,dy2,weight1,weight2; if ((index_dydx == index_x) || (index_dydx == index_y)) { - sprintf(errmsg,"%s(L:%d) : Output column %d must differ from input columns %d and %d",__func__,__LINE__,index_dydx,index_x,index_y); + class_sprintf(errmsg,"%s(L:%d) : Output column %d must differ from input columns %d and %d",__func__,__LINE__,index_dydx,index_x,index_y); return _FAILURE_; } @@ -314,7 +314,7 @@ int array_derive_two( weight2 = dx1*dx1; if ((dx1 == 0.) && (dx2 == 0.)) { - sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) stop to avoid division by zero",__func__,__LINE__); return _FAILURE_; } @@ -352,13 +352,13 @@ int array_spline( double dy_last; if (n_lines < 3) { - sprintf(errmsg,"%s(L:%d) n_lines=%d, while routine needs n_lines >= 3",__func__,__LINE__,n_lines); + class_sprintf(errmsg,"%s(L:%d) n_lines=%d, while routine needs n_lines >= 3",__func__,__LINE__,n_lines); return _FAILURE_; } u = (double*)malloc((n_lines-1) * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } @@ -387,7 +387,7 @@ int array_spline( -dy_first); } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -433,7 +433,7 @@ int array_spline( (*(array+(n_lines-1)*n_columns+index_x) - *(array+(n_lines-2)*n_columns+index_x))); } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -472,7 +472,7 @@ int array_spline_table_line_to_line( u = (double*)malloc((n_lines-1) * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } @@ -494,7 +494,7 @@ int array_spline_table_line_to_line( (x[1] - x[0])-dy_first); } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -534,7 +534,7 @@ int array_spline_table_line_to_line( (x[n_lines-1] - x[n_lines-2])); } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -578,19 +578,19 @@ int array_spline_table_lines( un = (double*)malloc(y_size * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } if (p == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); return _FAILURE_; } if (qn == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); return _FAILURE_; } if (un == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); return _FAILURE_; } @@ -625,7 +625,7 @@ int array_spline_table_lines( } } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -683,7 +683,7 @@ int array_spline_table_lines( } } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -739,19 +739,19 @@ int array_logspline_table_lines( qn = (double*)malloc(y_size * sizeof(double)); un = (double*)malloc(y_size * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } if (p == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); return _FAILURE_; } if (qn == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); return _FAILURE_; } if (un == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); return _FAILURE_; } @@ -786,7 +786,7 @@ int array_logspline_table_lines( } } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -844,7 +844,7 @@ int array_logspline_table_lines( } } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -901,19 +901,19 @@ int array_spline_table_columns( qn = (double*)malloc(y_size * sizeof(double)); un = (double*)malloc(y_size * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } if (p == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); return _FAILURE_; } if (qn == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); return _FAILURE_; } if (un == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); return _FAILURE_; } @@ -959,7 +959,7 @@ int array_spline_table_columns( } } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -1016,7 +1016,7 @@ int array_spline_table_columns( } } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -1069,19 +1069,19 @@ int array_spline_table_columns2( qn = (double*)malloc(y_size * sizeof(double)); un = (double*)malloc(y_size * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } if (p == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate p",__func__,__LINE__); return _FAILURE_; } if (qn == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate qn",__func__,__LINE__); return _FAILURE_; } if (un == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate un",__func__,__LINE__); return _FAILURE_; } @@ -1210,7 +1210,7 @@ int array_spline_table_one_column( u = (double*)malloc((x_size-1) * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } @@ -1243,7 +1243,7 @@ int array_spline_table_one_column( } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -1296,7 +1296,7 @@ int array_spline_table_one_column( } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -1345,7 +1345,7 @@ int array_logspline_table_one_column( u = (double*)malloc((x_stop-1) * sizeof(double)); if (u == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__); return _FAILURE_; } @@ -1378,7 +1378,7 @@ int array_logspline_table_one_column( } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -1432,7 +1432,7 @@ int array_logspline_table_one_column( } else { - sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); + class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode); return _FAILURE_; } } @@ -1528,7 +1528,7 @@ int array_integrate_all_trapzd_or_spline( double h; if ((index_start_spline<0) || (index_start_spline>=n_lines)) { - sprintf(errmsg,"%s(L:%d) index_start_spline outside of range",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) index_start_spline outside of range",__func__,__LINE__); return _FAILURE_; } @@ -1576,7 +1576,7 @@ int array_integrate( double sum; if ((index_int_y_dx == index_x) || (index_int_y_dx == index_y)) { - sprintf(errmsg,"%s(L:%d) : Output column %d must differ from input columns %d and %d",__func__,__LINE__,index_int_y_dx,index_x,index_y); + class_sprintf(errmsg,"%s(L:%d) : Output column %d must differ from input columns %d and %d",__func__,__LINE__,index_int_y_dx,index_x,index_y); return _FAILURE_; } @@ -1612,7 +1612,7 @@ int array_integrate_ratio( double sum; if ((index_int_y1_over_y2_dx == index_x) || (index_int_y1_over_y2_dx == index_y1) || (index_int_y1_over_y2_dx == index_y2)) { - sprintf(errmsg,"%s(L:%d) : Output column %d must differ from input columns %d, %d and %d",__func__,__LINE__,index_int_y1_over_y2_dx,index_x,index_y1,index_y2); + class_sprintf(errmsg,"%s(L:%d) : Output column %d must differ from input columns %d, %d and %d",__func__,__LINE__,index_int_y1_over_y2_dx,index_x,index_y1,index_y2); return _FAILURE_; } @@ -1658,12 +1658,12 @@ int array_interpolate( if (*(array+inf*n_columns+index_x) < *(array+sup*n_columns+index_x)){ if (x < *(array+inf*n_columns+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array+inf*n_columns+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array+inf*n_columns+index_x)); return _FAILURE_; } if (x > *(array+sup*n_columns+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array+sup*n_columns+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array+sup*n_columns+index_x)); return _FAILURE_; } @@ -1680,12 +1680,12 @@ int array_interpolate( else { if (x < *(array+sup*n_columns+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array+sup*n_columns+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array+sup*n_columns+index_x)); return _FAILURE_; } if (x > *(array+inf*n_columns+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array+inf*n_columns+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array+inf*n_columns+index_x)); return _FAILURE_; } @@ -1738,12 +1738,12 @@ int array_interpolate_spline_transposed(double * array, if (array[inf*y_size+index_x] < array[sup*y_size+index_x]){ if (x < array[inf*y_size+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array[inf*y_size+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array[inf*y_size+index_x]); return _FAILURE_; } if (x > array[sup*y_size+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array[sup*y_size+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array[sup*y_size+index_x]); return _FAILURE_; } @@ -1760,12 +1760,12 @@ int array_interpolate_spline_transposed(double * array, else { if (x < array[sup*y_size+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array[sup*y_size+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array[sup*y_size+index_x]); return _FAILURE_; } if (x > array[inf*y_size+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array[inf*y_size+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array[inf*y_size+index_x]); return _FAILURE_; } @@ -1817,12 +1817,12 @@ int array_interpolate_spline( if (x_array[inf] < x_array[sup]){ if (x < x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } if (x > x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } @@ -1839,12 +1839,12 @@ int array_interpolate_spline( else { if (x < x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } if (x > x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } @@ -1894,12 +1894,12 @@ int array_search_bisect( if (array[inf] < array[sup]){ if (c < array[inf]) { - sprintf(errmsg,"%s(L:%d) : c=%e < y_min=%e",__func__,__LINE__,c,array[inf]); + class_sprintf(errmsg,"%s(L:%d) : c=%e < y_min=%e",__func__,__LINE__,c,array[inf]); return _FAILURE_; } if (c > array[sup]) { - sprintf(errmsg,"%s(L:%d) : c=%e > y_max=%e",__func__,__LINE__,c,array[sup]); + class_sprintf(errmsg,"%s(L:%d) : c=%e > y_max=%e",__func__,__LINE__,c,array[sup]); return _FAILURE_; } @@ -1916,12 +1916,12 @@ int array_search_bisect( else { if (c < array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,c,array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,c,array[sup]); return _FAILURE_; } if (c > array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,c,array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,c,array[inf]); return _FAILURE_; } @@ -1965,12 +1965,12 @@ int array_interpolate_linear( if (x_array[inf] < x_array[sup]){ if (x < x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } if (x > x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } @@ -1987,12 +1987,12 @@ int array_interpolate_linear( else { if (x < x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } if (x > x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } @@ -2047,12 +2047,12 @@ int array_interpolate_logspline( if (x_array[inf] < x_array[sup]){ if (x < x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } if (x > x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } @@ -2069,12 +2069,12 @@ int array_interpolate_logspline( else { if (x < x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } if (x > x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } @@ -2132,12 +2132,12 @@ int array_interpolate_spline_one_column( if (x_array[inf] < x_array[sup]){ if (x < x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } if (x > x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } @@ -2154,12 +2154,12 @@ int array_interpolate_spline_one_column( else { if (x < x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } if (x > x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } @@ -2232,12 +2232,12 @@ int array_interpolate_extrapolate_spline_one_column( if (x_array[inf] < x_array[sup]){ if (x < x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } if (x > x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } @@ -2254,12 +2254,12 @@ int array_interpolate_extrapolate_spline_one_column( else { if (x < x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } if (x > x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } @@ -2340,12 +2340,12 @@ int array_interpolate_extrapolate_logspline_loglinear_one_column( if (x_array[inf] < x_array[sup]){ if (x < x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } if (x > x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } @@ -2362,12 +2362,12 @@ int array_interpolate_extrapolate_logspline_loglinear_one_column( else { if (x < x_array[sup]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]); return _FAILURE_; } if (x > x_array[inf]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]); return _FAILURE_; } @@ -2420,7 +2420,7 @@ int array_interpolate_growing_closeby( while (x < *(array+inf*n_columns+index_x)) { inf--; if (inf < 0) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, x,array[index_x]); return _FAILURE_; } @@ -2429,7 +2429,7 @@ int array_interpolate_growing_closeby( while (x > *(array+sup*n_columns+index_x)) { sup++; if (sup > (n_lines-1)) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, x,array[(n_lines-1)*n_columns+index_x]); return _FAILURE_; } @@ -2474,7 +2474,7 @@ int array_interpolate_one_growing_closeby( while (x < *(array+inf*n_columns+index_x)) { inf--; if (inf < 0) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, x,array[index_x]); return _FAILURE_; } @@ -2483,7 +2483,7 @@ int array_interpolate_one_growing_closeby( while (x > *(array+sup*n_columns+index_x)) { sup++; if (sup > (n_lines-1)) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, x,array[(n_lines-1)*n_columns+index_x]); return _FAILURE_; } @@ -2521,11 +2521,11 @@ int array_interpolate_spline_growing_closeby( /* if (*last_index < 0) { - sprintf(errmsg,"%s(L:%d) problem with last_index =%d < 0",__func__,__LINE__,*last_index); + class_sprintf(errmsg,"%s(L:%d) problem with last_index =%d < 0",__func__,__LINE__,*last_index); return _FAILURE_; } if (*last_index > (n_lines-1)) { - sprintf(errmsg,"%s(L:%d) problem with last_index =%d > %d",__func__,__LINE__,*last_index,n_lines-1); + class_sprintf(errmsg,"%s(L:%d) problem with last_index =%d > %d",__func__,__LINE__,*last_index,n_lines-1); return _FAILURE_; } */ @@ -2537,7 +2537,7 @@ int array_interpolate_spline_growing_closeby( while (x < x_array[inf]) { inf--; if (inf < 0) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, x,x_array[0]); return _FAILURE_; } @@ -2546,7 +2546,7 @@ int array_interpolate_spline_growing_closeby( while (x > x_array[sup]) { sup++; if (sup > (n_lines-1)) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, x,x_array[n_lines-1]); return _FAILURE_; } @@ -2593,7 +2593,7 @@ int array_interpolate_spline_growing_hunt( if (x >= x_array[*last_index]) { if (x > x_array[n_lines-1]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, x,x_array[n_lines-1]); return _FAILURE_; } @@ -2620,7 +2620,7 @@ int array_interpolate_spline_growing_hunt( } else { if (x < x_array[0]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__, x,x_array[0]); return _FAILURE_; } @@ -2688,7 +2688,7 @@ int array_spline_hunt(double* x_array, inc=1; if (x >= x_array[last_index]) { if (x > x_array[x_size-1]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__, x,x_array[x_size-1]); return _FAILURE_; } @@ -2715,7 +2715,7 @@ int array_spline_hunt(double* x_array, } else { if (x < x_array[0]) { - sprintf(errmsg,"%s(L:%d) : x=%.20e < x_min=%.20e",__func__,__LINE__, + class_sprintf(errmsg,"%s(L:%d) : x=%.20e < x_min=%.20e",__func__,__LINE__, x,x_array[0]); return _FAILURE_; } @@ -2778,12 +2778,12 @@ int array_interpolate_two( if (x < array_x[inf*n_columns_x+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array_x[inf*n_columns_x+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array_x[inf*n_columns_x+index_x]); return _FAILURE_; } if (x > array_x[sup*n_columns_x+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array_x[sup*n_columns_x+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array_x[sup*n_columns_x+index_x]); return _FAILURE_; } @@ -2800,12 +2800,12 @@ int array_interpolate_two( else { if (x < *(array_x+sup*n_columns_x+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array_x+sup*n_columns_x+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array_x+sup*n_columns_x+index_x)); return _FAILURE_; } if (x > *(array_x+inf*n_columns_x+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array_x+inf*n_columns_x+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array_x+inf*n_columns_x+index_x)); return _FAILURE_; } @@ -2853,12 +2853,12 @@ int array_interpolate_two_bis( if (x < array_x[inf*n_columns_x+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array_x[inf*n_columns_x+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array_x[inf*n_columns_x+index_x]); return _FAILURE_; } if (x > array_x[sup*n_columns_x+index_x]) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array_x[sup*n_columns_x+index_x]); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array_x[sup*n_columns_x+index_x]); return _FAILURE_; } @@ -2875,12 +2875,12 @@ int array_interpolate_two_bis( else { if (x < *(array_x+sup*n_columns_x+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array_x+sup*n_columns_x+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array_x+sup*n_columns_x+index_x)); return _FAILURE_; } if (x > *(array_x+inf*n_columns_x+index_x)) { - sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array_x+inf*n_columns_x+index_x)); + class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array_x+inf*n_columns_x+index_x)); return _FAILURE_; } @@ -2991,12 +2991,12 @@ int array_interpolate_equal( double x_step,x_minus,weight; if (x < x_min) { - sprintf(errmsg,"%s(L:%d) : x out of bounds: x=%e,x_min=%e",__func__,__LINE__,x,x_min); + class_sprintf(errmsg,"%s(L:%d) : x out of bounds: x=%e,x_min=%e",__func__,__LINE__,x,x_min); return _FAILURE_; } if (x > x_max) { - sprintf(errmsg,"%s(L:%d) : x out of bounds: x=%e,x_max=%e",__func__,__LINE__,x,x_max); + class_sprintf(errmsg,"%s(L:%d) : x out of bounds: x=%e,x_max=%e",__func__,__LINE__,x,x_max); return _FAILURE_; } @@ -3136,7 +3136,7 @@ int array_smooth_trg(double * array, smooth=(double*)malloc(k_size*sizeof(double)); if (smooth == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate smooth",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate smooth",__func__,__LINE__); return _FAILURE_; } @@ -3266,7 +3266,7 @@ int array_smooth(double * array, smooth=(double*)malloc(n_lines*sizeof(double)); if (smooth == NULL) { - sprintf(errmsg,"%s(L:%d) Cannot allocate smooth",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) Cannot allocate smooth",__func__,__LINE__); return _FAILURE_; } @@ -3489,11 +3489,11 @@ int array_hunt_descending( /* checks */ if (array[i_inf] < array[i_sup]) { - sprintf(errmsg,"%s(L:%d) array is not in descending order (checked only the boundaries)",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) array is not in descending order (checked only the boundaries)",__func__,__LINE__); return _FAILURE_; } if ((value > array[i_inf]) || (value < array[i_sup])) { - sprintf(errmsg,"%s(L:%d) %e is outside the range [%e, %e]",__func__,__LINE__,value,array[size-1],array[0]); + class_sprintf(errmsg,"%s(L:%d) %e is outside the range [%e, %e]",__func__,__LINE__,value,array[size-1],array[0]); return _FAILURE_; } @@ -3542,11 +3542,11 @@ int array_hunt_ascending( /* checks */ if (array[i_inf] > array[i_sup]) { - sprintf(errmsg,"%s(L:%d) array is not in ascending order (checked only the boundaries)",__func__,__LINE__); + class_sprintf(errmsg,"%s(L:%d) array is not in ascending order (checked only the boundaries)",__func__,__LINE__); return _FAILURE_; } if ((value < array[i_inf]) || (value > array[i_sup])) { - sprintf(errmsg,"%s(L:%d) %e is outside the range [%e, %e]",__func__,__LINE__,value,array[0],array[size-1]); + class_sprintf(errmsg,"%s(L:%d) %e is outside the range [%e, %e]",__func__,__LINE__,value,array[0],array[size-1]); return _FAILURE_; } diff --git a/tools/hyperspherical.c b/tools/hyperspherical.c index 25e8fe01..1a679741 100644 --- a/tools/hyperspherical.c +++ b/tools/hyperspherical.c @@ -27,7 +27,7 @@ int hyperspherical_HIS_create(int K, then relative to ppHIS. */ double deltax, beta2, lambda, x, xfwd; - double *sqrtK, *one_over_sqrtK,*PhiL; + double *sqrtK, *one_over_sqrtK; int j, k, l, nx, lmax, l_recurrence_max; beta2 = beta*beta; @@ -881,6 +881,9 @@ int hyperspherical_WKB(int K,int l,double beta,double y, double *Phi){ airy_sign = 1; } } + else{ + return _FAILURE_; + } argu = 3.0*S/(2.0*e); Q = CscK*CscK-alpha2; C = 0.5*sqrt(alpha)/beta; diff --git a/tools/parser.c b/tools/parser.c index 602e2b72..66dabae7 100644 --- a/tools/parser.c +++ b/tools/parser.c @@ -632,15 +632,15 @@ int parser_cat(struct file_content * pfc1, if (pfc1->size == 0) { class_alloc(pfc3->filename,(strlen(pfc2->filename)+1)*sizeof(char),errmsg); - sprintf(pfc3->filename,"%s",pfc2->filename); + class_sprintf(pfc3->filename,"%s",pfc2->filename); } if (pfc2->size == 0) { class_alloc(pfc3->filename,(strlen(pfc1->filename)+1)*sizeof(char),errmsg); - sprintf(pfc3->filename,"%s",pfc1->filename); + class_sprintf(pfc3->filename,"%s",pfc1->filename); } if ((pfc1->size !=0) && (pfc2->size != 0)) { class_alloc(pfc3->filename,(strlen(pfc1->filename)+strlen(pfc2->filename)+5)*sizeof(char),errmsg); - sprintf(pfc3->filename,"%s or %s",pfc1->filename,pfc2->filename); + class_sprintf(pfc3->filename,"%s or %s",pfc1->filename,pfc2->filename); } pfc3->size = pfc1->size + pfc2->size; diff --git a/tools/quadrature.c b/tools/quadrature.c index 053cd040..41921e4a 100644 --- a/tools/quadrature.c +++ b/tools/quadrature.c @@ -304,17 +304,17 @@ int get_qsampling(double *x, } //printf("N_adapt=%d, N_combined=%d at level=%d, Nlag=%d\n",Nadapt,N_comb,level,NLag); if (adapt_converging==_TRUE_){ - sprintf(method_chosen,"Adaptive Gauss-Kronrod Quadrature"); + class_sprintf(method_chosen,"Adaptive Gauss-Kronrod Quadrature"); /* Gather weights and xvalues from tree: */ i = Nadapt-1; get_leaf_x_and_w(root,&i,x,w,_TRUE_); } else if (Laguerre_converging==_TRUE_){ - sprintf(method_chosen,"Gauss-Laguerre Quadrature"); + class_sprintf(method_chosen,"Gauss-Laguerre Quadrature"); /* x and w is already populated in this case. */ } else if (combined_converging == _TRUE_){ - sprintf(method_chosen,"Combined Quadrature"); + class_sprintf(method_chosen,"Combined Quadrature"); for(i=0; i