Commit d343e429 authored by Matthieu Tristram's avatar Matthieu Tristram
Browse files

Merge branch 'master' of https://gitlab.in2p3.fr/cosmotools/CAMEL

parents 9c845981 2eabc76a
......@@ -2,9 +2,13 @@
#cmt stuff
if [ -z "$CMTCLASS" ] ; then
echo "CMTCLASS is undefined"
exit 1
return
else
if [ -z "$CMTPATH" ] ; then
export CMTPATH=${CMTCLASS}
else
export CMTPATH=${CMTPATH}:${CMTCLASS}
fi
fi
if [ ! -f setup.sh ] ; then
......@@ -16,18 +20,18 @@ fi
source ./setup.sh
if [ -z "$CAMELROOT" ] ; then
echo "CAMELROOT undefined ...something went wrong. do you have a requirements file?"
exit 1
return
fi
#creating link
if [ -z "${CAMEL_DATA}" ] ; then
echo "CAMEL_DATA undefined: review your installation (see http://camel.in2p3.fr/wiki/pmwiki.php?n=Main.Install)"
exit 1
return
fi
if [ ! -d "${CAMEL_DATA}" ] ; then
echo "empty CAMEL_DATA directory : please fix (see http://camel.in2p3.fr/wiki/pmwiki.php?n=Main.Install)"
exit 1
return
fi
echo CAMEL_DATA="${CAMEL_DATA}"
......
......@@ -4,7 +4,7 @@ use class HEAD
#compiler options
#default is gcc here are the C++ compiler options
macro cppflags " -O3 -pipe -ansi -Woverloaded-virtual -Wpedantic -Wunused -Wmaybe-uninitialized -Wno-deprecated -Wno-div-by-zero "
macro cppflags " -g -pipe -ansi -Woverloaded-virtual -Wpedantic -Wunused -Wmaybe-uninitialized -Wno-deprecated -Wno-div-by-zero "
# although it may be strange we do not compile CAMEL with OMP because CLASS is not thread safe
# no worries: CLASS is compiled with OMP
......@@ -13,14 +13,14 @@ macro_append cpplinkflags " -fopenmp "
#CAMEL includes
include_dirs " ../src"
include_dirs "../src/camel"
include_dirs "../src/Minuit2-5.28.00/src"
include_dirs "../src/Minuit2-5.28.00/inc"
include_dirs "../src/cxxsupport"
include_dirs "../src/AbsRand"
include_dirs "../src/camel/JLA"
include_dirs "../src/camel/JLA/jla_likelihood_v3/src"
include_dirs " $(CAMELROOT)/src"
include_dirs " $(CAMELROOT)/src/camel"
include_dirs " $(CAMELROOT)/src/Minuit2-5.28.00/src"
include_dirs " $(CAMELROOT)/src/Minuit2-5.28.00/inc"
include_dirs "$(CAMELROOT)/src/cxxsupport"
include_dirs "$(CAMELROOT)/src/AbsRand"
include_dirs "$(CAMELROOT)/src/camel/JLA"
include_dirs "$(CAMELROOT)/src/camel/JLA/jla_likelihood_v3/src"
#cfitsio
......@@ -32,7 +32,7 @@ macro_append CAMEL_linkopts " -lcfitsio"
#macro_append cppflags ' -DJLA '
#include_dirs "/usr/include/atlas"
#macro_append CAMEL_linkopts " -L/usr/lib64/atlas -lcblas -llapack -ljla "
#application test_jla -group=test -s=../src/camel test/test_jla.cc
#application test_jla -group=test -s=$(CAMELROOT)/src/camel test/test_jla.cc
#PLANCK
......@@ -46,8 +46,8 @@ macro_append CAMEL_linkopts " -lcfitsio"
#macro_append cflags " -DCLIK "
#macro_append CAMEL_linkopts "-L$(CLIKDIR)/lib -lclik "
#path_append LD_LIBRARY_PATH "$(CLIKDIR)/lib"
#application dump_clik -group=test -s=../src/camel test/test_clik.cc
#application dump_lensing -group=test -s=../src/camel test/test_lensing.cc
#application dump_clik -group=test -s=$(CAMELROOT)/src/camel test/test_clik.cc
#application dump_lensing -group=test -s=$(CAMELROOT)/src/camel test/test_lensing.cc
# PICO
......@@ -57,44 +57,48 @@ macro_append CAMEL_linkopts " -lcfitsio"
# (set in camel_setup.sh)
#macro_append CAMEL_linkopts " $(PICOLIBS)"
#macro_append cppflags ' -DPICODATA=\"$(PICO_DATA)\" '
#application testPico -group=test -s=../src/camel/pico/exec testPico.cc
#application testPico -group=test -s=$(CAMELROOT)/src/camel/pico/exec testPico.cc
#CLASS optional FastPk access
macro_append cppflags " -DFASTPK "
###FROM THERE YOU DONT NEED TO TOUCH
###########################################################################################
#CAMEL LIBRARIES
library Minuit -no_share ../src/Minuit2-5.28.00/src/*.cxx
library Util -no_share -x=ddl.cc ../src/cxxsupport/*.cc
library AbsRand -no_share ../src/AbsRand/*.cc
library CLHEP -no_share ../src/CLHEP/src/*.cc
library jla -no_share ../src/camel/JLA/jla_likelihood_v3/src/ini.c ../src/camel/JLA/jla_likelihood_v3/src/jla.cc
library Minuit -no_share $(CAMELROOT)/src/Minuit2-5.28.00/src/*.cxx
library Util -no_share -x=ddl.cc $(CAMELROOT)/src/cxxsupport/*.cc
library AbsRand -no_share $(CAMELROOT)/src/AbsRand/*.cc
library CLHEP -no_share $(CAMELROOT)/src/CLHEP/src/*.cc
library jla -no_share $(CAMELROOT)/src/camel/JLA/jla_likelihood_v3/src/ini.c $(CAMELROOT)/src/camel/JLA/jla_likelihood_v3/src/jla.cc
macro camelsrc "*.cc CMB/*.cc BAO/*.cc Lensing/*.cc pico/*.cc JLA/*.cc Class/*.cc Constraints/*.cc"
library MinuitFit -no_share -s=../src/camel $(camelsrc)
library MCMC -no_share -s=../src/camel/MCMC *.cc
library MinuitFit -no_share -s=$(CAMELROOT)/src/camel $(camelsrc)
library MCMC -no_share -s=$(CAMELROOT)/src/camel/MCMC *.cc
macro CAMEL_linkopts "-L$(CAMEL_root)/${CMTCONFIG} -lMinuitFit -lMinuit -lMCMC -lCLHEP -lAbsRand -lUtil "
macro CAMEL_linkopts "-L$(CAMELROOT)/${CMTCONFIG} -lMinuitFit -lMinuit -lMCMC -lCLHEP -lAbsRand -lUtil "
macro_append cppflags ' -DRELPATH=\"$(CAMELROOT)/lik\" '
#CAMEL applications
# pour relinker si changement: toutes les application du package
macro CAMEL_stamps " $(PACKAGE_ROOT)/$(CMTCONFIG)/MinuitFit.stamp $(PACKAGE_ROOT)/$(CMTCONFIG)/MCMC.stamp "
macro CAMEL_stamps " $(CAMELROOT)/$(CMTCONFIG)/MinuitFit.stamp $(CAMELROOT)/$(CMTCONFIG)/MCMC.stamp "
macro application_suffix ""
#groupe exec
application writeChi2 -group=exec -s=../src/camel exec/writeChi2.cc
application writeSpectra -group=exec -s=../src/camel exec/writeSpectra.cc
application writeSpectraPk -group=exec -s=../src/camel exec/writeSpectraPk.cc
application Minimize -group=exec -s=../src/camel exec/Minimize.cc
application Profile -group=exec -s=../src/camel exec/Profile.cc
application ScanParam -group=exec -s=../src/camel exec/ScanParam.cc
application mcmc -group=exec -s=../src/camel/MCMC exec/mainMCMC.cc
application writeChi2 -group=exec -s=$(CAMELROOT)/src/camel exec/writeChi2.cc
application writeSpectra -group=exec -s=$(CAMELROOT)/src/camel exec/writeSpectra.cc
application writeSpectraPk -group=exec -s=$(CAMELROOT)/src/camel exec/writeSpectraPk.cc
application Minimize -group=exec -s=$(CAMELROOT)/src/camel exec/Minimize.cc
application Profile -group=exec -s=$(CAMELROOT)/src/camel exec/Profile.cc
application ScanParam -group=exec -s=$(CAMELROOT)/src/camel exec/ScanParam.cc
application mcmc -group=exec -s=$(CAMELROOT)/src/camel/MCMC exec/mainMCMC.cc
#tests
application testKlass -group=test -s=../src/camel test/testKlass.cc
application testCLHEP -group=test -s=../src/camel/test testCLHEP.cc
application testBAO -group=test -s=../src/camel/test testBAO.cc
application testHiLLiPOP -group=test -s=../src/camel/test testHiLLiPOP.cc
application testKlass -group=test -s=$(CAMELROOT)/src/camel test/testKlass.cc
application testCLHEP -group=test -s=$(CAMELROOT)/src/camel/test testCLHEP.cc
application testBAO -group=test -s=$(CAMELROOT)/src/camel/test testBAO.cc
application testHiLLiPOP -group=test -s=$(CAMELROOT)/src/camel/test testHiLLiPOP.cc
#lIST OF ALL DEPENDENCIES
macro_append Minimize_dependencies " MinuitFit "
......@@ -113,5 +117,4 @@ macro_append testCLHEP_dependencies " CLHEP "
macro_append testBAO_dependencies " MinuitFit "
macro_append testHiLLiPOP_dependencies " MinuitFit "
macro_append test_jla_dependencies " MinuitFit "
macro_append testPico_dependencies " MinuitFit "
......@@ -7,20 +7,20 @@ macro cpp "icpc"
macro cppflags " -O2 -ip -ansi_alias -align -Wbrief -Wdeprecated -Wuninitialized -align -Wbrief -Wunused-function -Wpointer-arith -Wreturn-type"
#CAMEL includes
include_dirs " ../src"
include_dirs "../src/camel"
include_dirs "../src/Minuit2-5.28.00/src"
include_dirs "../src/Minuit2-5.28.00/inc"
include_dirs "../src/cxxsupport"
include_dirs "../src/AbsRand"
include_dirs "../src/camel/JLA"
include_dirs "../src/camel/JLA/jla_likelihood_v3/src"
include_dirs " $(CAMELROOT)/src"
include_dirs "$(CAMELROOT)/src/camel"
include_dirs "$(CAMELROOT)/src/Minuit2-5.28.00/src"
include_dirs "$(CAMELROOT)/src/Minuit2-5.28.00/inc"
include_dirs "$(CAMELROOT)/src/cxxsupport"
include_dirs "$(CAMELROOT)/src/AbsRand"
include_dirs "$(CAMELROOT)/src/camel/JLA"
include_dirs "$(CAMELROOT)/src/camel/JLA/jla_likelihood_v3/src"
#JLA :requires cblas/lapack (use intel versions)
macro_append cppflags " -DJLA "
macro_append CAMEL_linkopts " -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -ljla "
application test_jla -group=test -s=../src/camel test/test_jla.cc
application test_jla -group=test -s=$(CAMELROOT)/src/camel test/test_jla.cc
#cfitsio
#cfitsio: here the CLIK version (below) will be used so no need
......@@ -38,20 +38,20 @@ macro_append CAMEL_linkopts " $(CLIKLIBS) "
macro_append cppflags " -DPICO $(PICOINC) "
macro_append CAMEL_linkopts " $(PICOLIBS)"
macro_append cppflags ' -DPICODATA=\"$(PICO_DATA)\" '
application testPico -group=test -s=../src/camel/pico/exec testPico.cc
application FitClassFromPico -group=exec -s=../src/camel exec/FitClassFromPico.cc
application testPico -group=test -s=$(CAMELROOT)/src/camel/pico/exec testPico.cc
application FitClassFromPico -group=exec -s=$(CAMELROOT)/src/camel exec/FitClassFromPico.cc
#CAMEL LIBRARIES
library Minuit -no_share ../src/Minuit2-5.28.00/src/*.cxx
library Util -no_share -x=ddl.cc ../src/cxxsupport/*.cc
library AbsRand -no_share ../src/AbsRand/*.cc
library CLHEP -no_share ../src/CLHEP/src/*.cc
library jla -no_share ../src/camel/JLA/jla_likelihood_v3/src/ini.c ../src/camel/JLA/jla_likelihood_v3/src/jla.cc
library Minuit -no_share $(CAMELROOT)/src/Minuit2-5.28.00/src/*.cxx
library Util -no_share -x=ddl.cc $(CAMELROOT)/src/cxxsupport/*.cc
library AbsRand -no_share $(CAMELROOT)/src/AbsRand/*.cc
library CLHEP -no_share $(CAMELROOT)/src/CLHEP/src/*.cc
library jla -no_share $(CAMELROOT)/src/camel/JLA/jla_likelihood_v3/src/ini.c $(CAMELROOT)/src/camel/JLA/jla_likelihood_v3/src/jla.cc
macro camelsrc "*.cc CMB/*.cc BAO/*.cc Lensing/*.cc pico/*.cc JLA/*.cc Class/*.cc Constraints/*.cc"
library MinuitFit -no_share -s=../src/camel $(camelsrc)
library MCMC -no_share -s=../src/camel/MCMC *.cc
library MinuitFit -no_share -s=$(CAMELROOT)/src/camel $(camelsrc)
library MCMC -no_share -s=$(CAMELROOT)/src/camel/MCMC *.cc
macro CAMEL_linkopts "-L$(CAMEL_root)/${CMTCONFIG} -lMinuitFit -lMinuit -lMCMC -lCLHEP -lAbsRand -lUtil "
macro_append cppflags ' -DRELPATH=\"$(CAMELROOT)/lik\" '
......@@ -59,26 +59,26 @@ macro_append cppflags ' -DRELPATH=\"$(CAMELROOT)/lik\" '
#CAMEL applications
# pour relinker si changement: toutes les application du package
macro CAMEL_stamps " $(PACKAGE_ROOT)/$(CMTCONFIG)/MinuitFit.stamp $(PACKAGE_ROOT)/$(CMTCONFIG)/MCMC.stamp "
macro CAMEL_stamps " $(CAMELROOT)/$(CMTCONFIG)/MinuitFit.stamp $(CAMELROOT)/$(CMTCONFIG)/MCMC.stamp "
macro application_suffix ""
#groupe exec
application writeChi2 -group=exec -s=../src/camel exec/writeChi2.cc
application writeSpectra -group=exec -s=../src/camel exec/writeSpectra.cc
application writeSpectraPk -group=exec -s=../src/camel exec/writeSpectraPk.cc
application Minimize -group=exec -s=../src/camel exec/Minimize.cc
application Profile -group=exec -s=../src/camel exec/Profile.cc
application ScanParam -group=exec -s=../src/camel exec/ScanParam.cc
application mcmc -group=exec -s=../src/camel/MCMC exec/mainMCMC.cc
application writeChi2 -group=exec -s=$(CAMELROOT)/src/camel exec/writeChi2.cc
application writeSpectra -group=exec -s=$(CAMELROOT)/src/camel exec/writeSpectra.cc
application writeSpectraPk -group=exec -s=$(CAMELROOT)/src/camel exec/writeSpectraPk.cc
application Minimize -group=exec -s=$(CAMELROOT)/src/camel exec/Minimize.cc
application Profile -group=exec -s=$(CAMELROOT)/src/camel exec/Profile.cc
application ScanParam -group=exec -s=$(CAMELROOT)/src/camel exec/ScanParam.cc
application mcmc -group=exec -s=$(CAMELROOT)/src/camel/MCMC exec/mainMCMC.cc
#tests
application testKlass -group=test -s=../src/camel test/testKlass.cc
application testCLHEP -group=test -s=../src/camel/test testCLHEP.cc
application testBAO -group=test -s=../src/camel/test testBAO.cc
application testHiLLiPOP -group=test -s=../src/camel/test testHiLLiPOP.cc
application dump_clik -group=test -s=../src/camel test/test_clik.cc
application dump_lensing -group=test -s=../src/camel test/test_lensing.cc
application testKlass -group=test -s=$(CAMELROOT)/src/camel test/testKlass.cc
application testCLHEP -group=test -s=$(CAMELROOT)/src/camel/test testCLHEP.cc
application testBAO -group=test -s=$(CAMELROOT)/src/camel/test testBAO.cc
application testHiLLiPOP -group=test -s=$(CAMELROOT)/src/camel/test testHiLLiPOP.cc
application dump_clik -group=test -s=$(CAMELROOT)/src/camel test/test_clik.cc
application dump_lensing -group=test -s=$(CAMELROOT)/src/camel test/test_lensing.cc
#lIST OF ALL DEPENDENCIES
macro_append Minimize_dependencies " MinuitFit "
......
MultipolesRange = camel_data/Hillipop/Binning/binning.fits
Beams = camel_data/Hillipop/Data/DX11d_r3_HM/LALmaskSuperExt-ConservativeCO/bell/beam
XSpectra = camel_data/Hillipop/Data/DX11d_r3_HM/LALmaskSuperExt-ConservativeCO/spectra/cross_DX11d_HM_SuperExtCO
XSpectraErrors = camel_data/Hillipop/Data/DX11d_r3_HM/LALmaskSuperExt-ConservativeCO/spectra/cross_DX11d_HM_SuperExtCO
CovMatrix = camel_data/Hillipop/Data/DX11d_r3_HM/LALmaskSuperExt-ConservativeCO/pclcvm/invfll_DX11dr3HM_SG_pack
SZ = camel_data/Hillipop/Foregrounds/ClSZ_poiss_corr_MD2_cppp_bestCl_NILC_extra12_cibps_lmax10000.fits
kSZ = camel_data/Hillipop/Foregrounds/ksz_shaw_bat_PWAS_MD_tau062.fits
CIB = camel_data/Hillipop/Foregrounds/CIB_v3
SZxCIB = camel_data/Hillipop/Foregrounds/SZxCIB
Dust = camel_data/Hillipop/Foregrounds/Dust_LALmaskSuperExt-ConservativeCO_DX11d
TT = 0
EE = 0
BB = 0
TE = 1
ET = 1
map = 6
freq0 = 100
freq1 = 100
freq2 = 143
freq3 = 143
freq4 = 217
freq5 = 217
FileOut =
......@@ -159,9 +159,10 @@ Chi2Factory::gimeChi2(Parser& parser){
allCl->add(acte);
}
cout << "NUMBER OF LIKELIHOODS=" << allCl->nLik() << endl;
cout << "TTmax=" << allCl->getTTmax() << endl;
cout << "NUMBER OF CMB LIKELIHOODS=" << allCl->nLik() << endl;
int lmax=allCl->getTTmax();
cout << "TTmax=" << lmax << endl;
//lensing may affect lmax too
#ifdef CLIK
......@@ -175,18 +176,10 @@ Chi2Factory::gimeChi2(Parser& parser){
if (!fid && lensing->lmax() > lmax) lmax=lensing->lmax();
}
#endif
//overide if you want
if (parser.params.param_present("lmax")){
int Lmax=parser.params.find<int>("lmax");
if (lmax != Lmax)
cout << " WARNING your specified LMAX=" << Lmax <<" differs from the guessed TT range:" << lmax <<" use at you own risks!" << endl;
lmax=Lmax;
}
cout << "#########################################" << endl;
cout << "Engine lmax=" << lmax << endl;
//2. creation ENGINE
......@@ -207,17 +200,24 @@ lmax=Lmax;
//extra class params
ClassParams classparms(parser.classparms);
//CMB
string output="";
if (lmax>0) {
classparms.add("l_max_scalars",lmax);
output+="tCl,pCl,lCl";
output="tCl,pCl,lCl";
}
//if P(k) needed
const bool doPk=parser.params.find<bool>("do_mPk",false);
if (doPk) output+=",mPk";
//if pk asked or no CMB
if (doPk || lmax<2) {
output+=(output.size()==0? "mPk" : ",mPk");
}
cout << ">>> CLASS output will be: " << output << endl;
classparms.add("output",output); //polar +lens+clphi
for (size_t i=0;i<classparms.size();i++)
......@@ -230,7 +230,6 @@ lmax=Lmax;
}
cout << "CLASS \t--> precision =" << pre << endl;
//le calculateur de spectres
//MnUserVariables upar(parser.upar);
e=new MnClassEngine(parser.vars(),
......@@ -244,9 +243,10 @@ lmax=Lmax;
//4. observables:
//rajoute l'engine aux Cl
allCl->setEngine(e);
comb->add(allCl);
if (lmax>=2 ){
allCl->setEngine(e);
comb->add(allCl);
}
//lensing
#ifdef CLIK
......
......@@ -85,8 +85,8 @@ void ClassParams::updateVal(const unsigned& i,const string& newval) {pars[i].sec
//---------------
// Constructors --
//----------------
ClassEngine::ClassEngine(const ClassParams& pars): cl(0),dofree(true),_hasPk(false){
ClassEngine::ClassEngine(const ClassParams& pars): cl(0),dofree(true),pvecback(0){
_lmax=-1; //default
cout << "Running CLASS version " << _VERSION_ << endl;
......@@ -108,13 +108,13 @@ ClassEngine::ClassEngine(const ClassParams& pars): cl(0),dofree(true),_hasPk(fal
istringstream strstrm(pars.value(i));
strstrm >> _lmax;
}
if (pars.key(i)=="output") {
if (pars.value(i).find("mPk") != std::string::npos) _hasPk=true;
}
}
cout << __FILE__ << " : using lmax=" << _lmax <<endl;
assert(_lmax>0);
//store class output
if (pars.key(i)=="output") _output=pars.value(i);
//is nonlinear set
if (pars.key(i)=="non linear") _nonlin=true;
}
//input
if (input_init(&fc,&pr,&ba,&th,&pt,&tr,&pm,&sp,&nl,&le,&op,_errmsg) == _FAILURE_)
throw invalid_argument(_errmsg);
......@@ -134,7 +134,7 @@ ClassEngine::ClassEngine(const ClassParams& pars): cl(0),dofree(true),_hasPk(fal
}
ClassEngine::ClassEngine(const ClassParams& pars,const string & precision_file): cl(0),dofree(true),_hasPk(false){
ClassEngine::ClassEngine(const ClassParams& pars,const string & precision_file): cl(0),dofree(true),pvecback(0){
cout << "Running CLASS version " << _VERSION_ << endl;
......@@ -162,17 +162,12 @@ ClassEngine::ClassEngine(const ClassParams& pars,const string & precision_file):
istringstream strstrm(pars.value(i));
strstrm >> _lmax;
}
if (pars.key(i)=="output") {
if (pars.value(i).find("mPk") != std::string::npos) {
_hasPk=true;
cout << "found Pk: status" << (int)hasPk() << endl;
}
}
}
cout << __FILE__ << " : using lmax=" << _lmax <<endl;
assert(_lmax>0);
//store class output
if (pars.key(i)=="output") _output=pars.value(i);
//is nonlinear set?
if (pars.key(i)=="non linear") _nonlin=true;
}
//concatenate both
if (parser_cat(&fc_input,&fc_precision,&fc,_errmsg) == _FAILURE_) throw invalid_argument(_errmsg);
......@@ -276,11 +271,14 @@ int ClassEngine::class_main(
return _FAILURE_;
}
delete [] pvecback;
if (background_init(ppr,pba) == _FAILURE_) {
printf("\n\nError running background_init \n=>%s\n",pba->error_message);
dofree=false;
return _FAILURE_;
}
pvecback=new double[ba.bg_size];
if (thermodynamics_init(ppr,pba,pth) == _FAILURE_) {
printf("\n\nError in thermodynamics_init \n=>%s\n",pth->error_message);
......@@ -530,62 +528,56 @@ double ClassEngine::get_f(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double f_z=pvecback[ba.index_bg_f];
#ifdef DBUG
cout << "f_of_z= "<< f_z <<endl;
#endif
free (pvecback);
return f_z;
}
double ClassEngine::get_Pk(double k, double z){
double ClassEngine::get_growthD(double z)
{
double tau;
int index;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double D=pvecback[ba.index_bg_D];
return D;
}
double ClassEngine::get_Pklin(double k, double z){
double tau;
int index;
double *pvecback;
double * pk_ic = NULL;
double mypk =0.;
//cout << " debut de getpk "<<endl;
background_tau_of_z(&ba,z,&tau);
//cout << " after bkg "<<tau<< endl;
///pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
// int ret = spectra_pk_at_k_and_z(&ba,&pm,&sp,k,z,&mypk,pk_ic);
int ret=spectra_pk_at_k_and_z(&ba,&pm,&sp,k,z,&mypk,pk_ic);
//cout << " z "<<z<< " k "<< k << " tau "<< tau<<" pk "<< mypk<<" return code " << ret<< endl;
free (pvecback);
return mypk;
}
double ClassEngine::get_PkNL(double k, double z){
double tau;
int index;
double *pvecback;
double mypk;
background_tau_of_z(&ba,z,&tau);
//cout << "pknl after bkg "<<tau<< endl;
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
//cout << "pknl after bkg @tau "<<tau<< " z "<<z<< " k "<< k << endl;
int ret = spectra_pk_nl_at_k_and_z(&ba,&pm,&sp,k,z,&mypk);
free (pvecback);
return mypk;
}
......@@ -594,15 +586,11 @@ double ClassEngine::get_sigma8(double z)
{
double tau;
int index;
double *pvecback;
double sigma8 = -99.;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
//background_at_tau(pba,tau,pba->long_info,pba->inter_normal,&last_index,pvecback);
......@@ -610,7 +598,6 @@ double ClassEngine::get_sigma8(double z)
#ifdef DBUG
cout << "sigma_8= " << sigma8 <<" at "<<z<<" tau "<<tau<<" bah "<<ba.h<< "size " << ba.bg_size << " index "<< index<<endl;
#endif
free (pvecback);
planck_assert( sigma8 != -99. , " sigma8 could not be computed at " +str(z) + " \n 1) check z_pk and z_max_pk parameters for class \n 2) that you have enabled the Pk computation with : do_mPk = true \n ");
return sigma8;
......@@ -620,12 +607,9 @@ double ClassEngine::get_Dv(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
// cout << " dv : tau= "<< tau <<endl;
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
......@@ -644,7 +628,6 @@ double ClassEngine::get_Dv(double z)
#ifdef DBUG
cout << D_v << endl;
#endif
free (pvecback);
return D_v;
}
......@@ -652,13 +635,9 @@ double ClassEngine::get_Fz(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
......@@ -670,7 +649,6 @@ double ClassEngine::get_Fz(double z)
cout << "D_ang= "<< D_ang <<endl;
#endif
double F_z = (1.+z) * D_ang * H_z /(3.e8) ; // is there speed of light somewhere ?
free (pvecback);
return F_z;
}
......@@ -678,35 +656,40 @@ double ClassEngine::get_H(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);