Commit 28cd9156 authored by Matthieu Tristram's avatar Matthieu Tristram
Browse files

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

parents 99ad09ea 5eb55990
package CAMEL
use class *
#CLASS optional FastPk access
macro_append cppflags " -DFASTPK "
#compiler options
#default is gcc here are the C++ compiler options
macro cppflags " -O3 -pipe -ansi -fPIC -Wall "
#do we need optimzations here?
#macro_append cppflags "-ffast-math -m64 "
# 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
#macro_append cppflags "-fopenmp "
macro_append cpplinkflags " -fopenmp "
#CAMEL includes
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
include_dirs "/usr/include/cfitsio"
macro_append CAMEL_linkopts " -lcfitsio"
#JLA :requires cblas/lapack
#macro_append cppflags ' -DJLA '
#include_dirs "/usr/include/atlas"
#macro_append CAMEL_linkopts " -L/usr/lib64/atlas -ltatlas -llapack -ljla "
#application test_jla -group=test -s=$(CAMELROOT)/src/camel test/test_jla.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
#PLANCK
#macro_append cppflags " -DCLIK $(CLIKCFLAGS)"
#macro_append cflags " -DCLIK $(CLIKCFLAGS)"
#macro_append CAMEL_linkopts " $(CLIKLIBS) "
#include_dirs "$(CLIKDIR)/include"
#include_dirs "$(CLIKDIR)/src"
#macro_append cppflags " -DCLIK "
#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=$(CAMELROOT)/src/camel test/test_clik.cc
#application dump_lensing -group=test -s=$(CAMELROOT)/src/camel test/test_lensing.cc
# PICO
#macro_append cppflags " -DPICO $(PICOINC) "
#macro_append CAMEL_linkopts " -L$(PICO_CODE) -lpico -lpython2.7 "
# the previous line should be sufficient otherwise try the PICOLIBS
# (set in camel_setup.sh)
#macro_append CAMEL_linkopts " $(PICOLIBS)"
#macro_append cppflags ' -DPICODATA=\"$(PICO_DATA)\" '
#application testPico -group=test -s=$(CAMELROOT)/src/camel/pico/exec testPico.cc
###FROM THERE YOU DONT NEED TO TOUCH
###########################################################################################
#CAMEL LIBRARIES
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
macro camelsrc "*.cc CMB/*.cc BAO/*.cc Lensing/*.cc pico/*.cc JLA/*.cc Class/*.cc Constraints/*.cc Pk/*.cc"
library MinuitFit -no_share -s=$(CAMELROOT)/src/camel $(camelsrc)
library MCMC -no_share -s=$(CAMELROOT)/src/camel/MCMC *.cc
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 " $(CAMELROOT)/$(CMTCONFIG)/MinuitFit.stamp $(CAMELROOT)/$(CMTCONFIG)/MCMC.stamp "
macro application_suffix ""
#groupe exec
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=$(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 "
macro_append Profile_dependencies " MinuitFit "
macro_append ScanParam_dependencies " MinuitFit "
macro_append writeChi2_dependencies " MinuitFit "
macro_append writeSpectra_dependencies " MinuitFit "
macro_append writeSpectraPkependencies " MinuitFit "
macro_append mcmc_dependencies " MinuitFit "
macro_append mcmc_dependencies " MCMC "
macro_append testKlass_dependencies " MinuitFit"
macro_append clik_example_CC_dependencies " MinuitFit "
macro_append test_clik_dependencies " MinuitFit "
macro_append test_lensing_dependencies " MinuitFit "
macro_append testCLHEP_dependencies " CLHEP "
macro_append testBAO_dependencies " MinuitFit "
macro_append testHiLLiPOP_dependencies " MinuitFit "
macro_append test_jla_dependencies " MinuitFit "
......@@ -4,7 +4,7 @@ use class HEAD
#compiler options
#default is gcc here are the C++ compiler options
macro cppflags " -g -pipe -ansi -Woverloaded-virtual -Wpedantic -Wunused -Wmaybe-uninitialized -Wno-deprecated -Wno-div-by-zero "
macro cppflags " -O2 -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
......@@ -31,7 +31,7 @@ macro_append CAMEL_linkopts " -lcfitsio"
#JLA :requires cblas/lapack
#macro_append cppflags ' -DJLA '
#include_dirs "/usr/include/atlas"
#macro_append CAMEL_linkopts " -L/usr/lib64/atlas -lcblas -llapack -ljla "
#macro_append CAMEL_linkopts " -L/usr/lib/atlas-base -lcblas -llapack_atlas -ljla "
#application test_jla -group=test -s=$(CAMELROOT)/src/camel test/test_jla.cc
......
package CAMEL
#THE FOLLWING LINKS TO YOUR CLASS LIBRARY- YOU CAN TEST WHICH ONE IN YOUR
#SHELL WITH THE FOLLWING COMMAND : cmt show uses
# you may put an explicit version instead of * (as v2.4.4 or v2.*...)
use class *
#CLASS optional FastPk access
#macro_append cppflags " -DFASTPK "
#COMPILER - TO EASE PAIN USE THE SAME THAN FOR CLASS/CLIK COMPILATION
# DEFAULT IS gcc SO DO NOT UNCOMMENT IF YOUR ARE HAPPY WITH THIS (EXAMPLE FOR CHANGING TO ICPC)
#macro cpp "icpc"
#COMPILER FLAGS for default=gcc
#C++ flags
macro cppflags " -O2 -pipe -ansi -Woverloaded-virtual -Wpedantic -Wunused -Wmaybe-uninitialized -Wno-deprecated -Wno-div-by-zero -Wno-variadic-macros"
# C flags
macro cflags " -O2 -fopenmp "
#compiler options
#default is gcc here are the C++ compiler options
macro cppflags " -O3 -pipe -ansi -fPIC -Wall "
# or for icpc (if you changed previously the compiler otherwise don't touch)
#macro cppflags " -O2 -ip -ansi_alias -align -Wbrief "
#do we need optimzations here?
#macro_append cppflags "-ffast-math -m64 "
#
# CFITSIO IS REQUIRED.
# include_dirs indicates the path to fitsio.h/ and CAMEL_linkopts teh
# link to the propoer library. In the following we use the one that was
# compiled when building CLIK but it can be also found
# in your /usr area. If the library is shared you may need to update your
# LD_LIBRARY_PATH or uncomment the next line before sourcing camel_setup.sh
#path_append LD_LIBRARY_PATH "$(CLIKDIR)/lib"
# 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
#macro_append cppflags "-fopenmp "
macro_append cpplinkflags " -fopenmp "
include_dirs "$(CLIKDIR)/include"
macro_append CAMEL_linkopts " -L$(CLIKDIR)/lib -lcfitsio"
#CAMEL includes
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
include_dirs "/usr/include/cfitsio"
macro_append CAMEL_linkopts " -lcfitsio"
#JLA :requires cblas/lapack
#macro_append cppflags ' -DJLA '
#include_dirs "/usr/include/atlas"
#macro_append CAMEL_linkopts " -L/usr/lib64/atlas -ltatlas -llapack -ljla "
#application test_jla -group=test -s=$(CAMELROOT)/src/camel test/test_jla.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
# PLANCK CLIK support [optional]
# NB: you always have access to PLanck/Hillipop (high-ell) likelihood since
# it is native in CAMEL.
# CLIKCFLAGS and CLIKLIBS were defined when you ran: camel_setup.sh
#PLANCK
#macro_append cppflags " -DCLIK $(CLIKCFLAGS)"
#macro_append cflags " -DCLIK $(CLIKCFLAGS)"
#macro_append CAMEL_linkopts " $(CLIKLIBS) "
#include_dirs "$(CLIKDIR)/include"
#include_dirs "$(CLIKDIR)/src"
#macro_append cppflags " -DCLIK "
#macro_append cflags " -DCLIK "
#macro_append CAMEL_linkopts "-L$(CLIKDIR)/lib -lclik "
#application dump_clik -group=test -s=../src/camel test/test_clik.cc
#application dump_lensing -group=test -s=../src/camel test/test_lensing.cc
#JLA [optional] :requires cblas/lapack
# in most linux distributions packaged with the atlas library.
# if you installed CLIK you may also look for them in teh MKLROOT you used.
# 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
#path_append LD_LIBRARY_PATH "$(CLIKDIR)/lib"
#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 [optional]
# PICO
#macro_append cppflags " -DPICO $(PICOINC) "
#macro_append CAMEL_linkopts " -L$(PICO_CODE) -lpico -lpython2.7 "
# if the previous link fails try using the PICOLIBS defined in camel_setup.sh
# the previous line should be sufficient otherwise try the PICOLIBS
# (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
#macro_append cppflags " -DPICO "
#include_dirs "/usr/include/python2.7"
#include_dirs "/usr/lib64/python2.7/site-packages/numpy/core/include"
#include_dirs "$(PICO_CODE)/pypico"
#macro_append CAMEL_linkopts " -L$(PICO_CODE)/build/temp.linux-x86_64-2.7 -lpico -L/usr/lib64/python2.7/config -lpython2.7 "
#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
###########################################################################################
###FROM THERE YOU SHOUL NOT NEED TO TOUCH ANYTHING
###########################################################################################
#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"
###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
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
macro camelsrc "*.cc CMB/*.cc BAO/*.cc Lensing/*.cc pico/*.cc JLA/*.cc Class/*.cc Constraints/*.cc Pk/*.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
macro CAMEL_stamps " $(CAMELROOT)/$(CMTCONFIG)/MinuitFit.stamp $(CAMELROOT)/$(CMTCONFIG)/MCMC.stamp "
macro application_suffix ""
#groupe exec: to build run: make exec
application writeChi2 -group=exec -s=../src/camel exec/writeChi2.cc
application writeSpectra -group=exec -s=../src/camel exec/writeSpectra.cc
application Minimize -group=exec -s=../src/camel exec/Minimize.cc
application ScanParam -group=exec -s=../src/camel exec/ScanParam.cc
application mcmc -group=exec -s=../src/camel/MCMC exec/mainMCMC.cc
#groupe exec
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 "
macro_append Profile_dependencies " MinuitFit "
macro_append ScanParam_dependencies " MinuitFit "
macro_append writeChi2_dependencies " MinuitFit "
macro_append writeSpectra_dependencies " MinuitFit "
macro_append mcmc_dependencies " MinuitFit MCMC"
macro_append writeSpectraPkependencies " MinuitFit "
macro_append mcmc_dependencies " MinuitFit "
macro_append mcmc_dependencies " MCMC "
macro_append testKlass_dependencies " MinuitFit"
macro_append clik_example_CC_dependencies " MinuitFit "
macro_append test_clik_dependencies " MinuitFit "
......@@ -128,5 +119,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 "
......@@ -8,5 +8,5 @@ sptpol_window_dir = camel_data/HighEll/sptpol_cosmomc_oct13/data/sptpol/windows_
nbin = 40
nfreq = 1
spt_windows_lmax = 5000 #PICO
#spt_windows_lmax = 5000 #PICO
......@@ -72,7 +72,7 @@ ClassParams::findIndex(const string& name){
index=i; break;
}
}
planck_assert(index>=0,string("key ")+name+ " not found in ClassParams");
if (index<0) throw Message_error(string("key ")+name+ " not found in ClassParams");
return static_cast<size_t>(index);
}
......@@ -744,3 +744,21 @@ ClassEngine::get_Pkvec(const std::vector<double>& knodes, const std::vector<doub
}
#endif
bool
ClassEngine::get_PkNodes(std::vector<double>& knodes,std::vector<double>& pknodes){
knodes.resize(sp.ln_k_size);
pknodes.resize(sp.ln_k_size);
int index_mode=0;
int index_ic1_ic2=0;
int index_eta = sp.ln_tau_size-1;
for (int index_k=0; index_k < sp.ln_k_size; index_k++){
knodes[index_k]=std::exp(sp.ln_k[index_k]);
pknodes[index_k]=std::exp(sp.ln_pk[(index_eta * sp.ln_k_size + index_k) * sp.ic_ic_size[index_mode] + index_ic1_ic2]);
}
return _SUCCESS_;
}
......@@ -153,9 +153,12 @@ public:
double get_H(double z);
double get_DMod(double z);
//PK related stuuff
double get_Pklin(double k, double z);
double get_PkNL(double k, double z);
//vectorized access (if macro defined)
#ifdef FASTPK
//fixed k and z values: output
......@@ -171,6 +174,11 @@ public:
#endif
//nodes used by class to perfrom spline interpolation: at z=0
//automatically resized
bool get_PkNodes(std::vector<double>& knodes,std::vector<double>& Pknodes);
//combile distance
double com_distance(double z);
......
......@@ -232,11 +232,11 @@ int main(int argc,char** argv){
Timer timer;
cout <<"Pk timer test..." << endl;
vector<double> pkvec(kval.size());
for (size_t i=0;i<1000;i++)
for (size_t i=0;i<100;i++)
e->get_Pkvec(kval,z0,pkvec);
cout << "fast=" << timer.partial() <<endl;
for (size_t i=0;i<1000;i++){
for (size_t i=0;i<100;i++){
for (int k =0; k<kval.size() ; k++){
double pk=e->get_Pklin(kval[k], 0);
}
......
#!/bin/env bash
if [ -z "$NCHAINS" ] ; then
NCHAINS=4
fi
if [ -z "$NCORES" ] ; then
NCORES=8
fi
myexec=$CAMELROOT/$CMTCONFIG/mcmc
if [ $# -ne 2 ]; then
echo "usage: parFile mcsetup.txt"
exit
npar=1
if [ $# -lt 1 ]; then
echo "runMCMC.sh parFile"
echo " [Nsamples=500000]"
echo " [Nchain=4]"
echo " [Ncore=8]"
echo " [queue=mc_long]"
echo " [project=P_planck]"
echo ""
exit
fi
parFile=`readlink -f $1`
Nsample=500000
Nchain=4
Ncore=8
queue=mc_long
project=P_planck
while(( $# > "$npar")); do
((npar = npar + 1))
eval riri=\$$npar
vals=(${riri//=/ })
var=${vals[0]}
eval old=\$${vals[0]}
echo ${vals[0]}=${vals[1]} "( old:"$old")"
if [ -z "$old" ]; then
echo "wrong parameter"
exit
fi
eval ${vals[0]}=${vals[1]}
done
if [ -z "$CLIKDIR" ] ; then
echo "miss CLIKDIR"
exit
echo "miss CLIKDIR"
exit
fi
if ! [ -f $myexec ] ; then
echo "missing exec"
exit
echo "missing exec"
exit
fi
localexec=`basename $myexec`
file=$1
mcsetup=$(readlink -e $2)
parFile=$(readlink -e $file)
parbase=$(basename $parFile)
dirout=${parbase%".par"}_"MC"
zeroot=$PWD/$dirout
if ! [ -f $parFile ] ; then
echo "wrong parFile $parFile"
exit
fi
#cat $parFile
dirpar=`dirname $parFile`
parbase=`basename $parFile`
zename=${parbase%".par"}
echo $dirpar
echo $parFile
ndim=`awk '$1=="par"{n++}; END {print n}' $parFile`
if ! [ -f $parFile ] ; then
echo "wrong parFile $parFile"
#MCMC proposal
cov=${parbase%".par"}.cov
if ! [ -f $dirpar/$cov ] ; then
echo "$dirpar/$cov"
echo "no covariance matrix found ndim=$ndim"
exit
fi
echo `readlink -f $cov`
#create output directory
zeroot=$PWD/${zename}_MC
if [ -d "$zeroot" ] ; then
echo "directory $zeroot exists: still want to run? (y/n)"
read answer
if [ $answer != 'y' ] ; then
echo "exiting"
exit 1
fi
echo "directory $zeroot exists: still want to run? (y/N)"
read answer
if [ "$answer" != 'y' ] ; then
exit 1
fi
else
mkdir $zeroot
fi
#
mkdir $zeroot
cd $zeroot
#MCMC mandatory stuff
#read mcsetup
tmp=`mktemp`
grep proposal_cov $mcsetup >> $tmp
source $tmp
#checks on covmat
if [ -z "${proposal_cov}" ] ; then
echo "missing proposal_cov in mc_setup"
exit 1
fi
if [ ! -f ${proposal_cov} ] ; then
echo "covariance matrix $proposal_cov does not exist"
exit 1
fi
#check sizes
nlines=`wc -l ${proposal_cov} | cut -d " " -f 1`
ndim=`awk '$1=="par"{n++}; END {print n}' $parFile`
echo "ndim=$ndim nlines=$nlines"
if [ $ndim -ne $nlines ] ; then
echo "covariance matrix not compatible in size with parFile"
exit 1
fi
#generate parbase
#enleve precision pour MCMC
grep -v precision $dirpar/$parbase > $parbase
#cp $dirpar/$parbase .
cp $dirpar/$cov .
#setup MCMC
cat > mc_setup <<EOF
dim=$ndim
algo=ada
length=$Nsample
proposal_cov=./$cov
ts=10000
t0=2000
scale=0.001
do_move=false
EOF
#cat mc_setup
cat mc_setup >> $parbase
rm -f mc_setup
echo "**************************************"
cat $mcsetup
echo "**************************************"
cat > zerun.sh <<eof
echo "running on : \$(uname -a)"
export PYTHONPATH=${PICO_CODE}
export OMP_NUM_THREADS=$NCORES
export OMP_NUM_THREADS=$Ncore
cd \$TMPDIR
cp $myexec .
#enleve precision pour MCMC
grep -v precision $parFile > $parbase
cat $mcsetup >> $parbase
#each job from the array will have different seeds but is repoductible.