runMCMC.sh 2.36 KB
Newer Older
Plaszczynski Stephane's avatar
Plaszczynski Stephane committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
#!/bin/env bash
NCHAINS=4
MCORE=20

myexec=$CAMELROOT/$CMTCONFIG/mcmc

if [ $# -ne 2 ]; then
echo "usage: parFile NSAMPLES"
exit
fi


if [ -z "$CLIKDIR" ] ; then
echo "miss CLIKDIR"
exit
fi

if ! [ -f $myexec ] ; then
echo "missing exec"
exit
fi
localexec=`basename $myexec`

parFile=$1
NSAMPLES=$2

if ! [ -f $parFile ] ; then
echo "wrong parFile $parFile"
exit
fi
#cat $parFile
cd `dirname $parFile`
dirpar=$PWD
cd -
parbase=`basename $parFile`
zeroot=${parbase%".par"}_MC


if [ -d  "$zeroot" ] ; then
echo "directory $zeroot exists: still want to run? (o/n)"
read answer
if [ $answer != 'o' ] ; then
echo "exiting"
exit 1
fi
fi


ndim=`awk '$1=="par"{n++}; END {print n}' $parFile`

mkdir $zeroot
cd $zeroot

#MCMC stuff :TT
cov=$dirpar/covmat.dat
if ! [ -f $cov ] ; then
echo "$cov"
echo "no covariance matrix found ndim=$ndim"
exit
fi

cat > mc_setup <<EOF
do_mPk=true
class z_pk 0,0.57
derived  H0
derived  sigma8
derived  sigma8(0.57)
derived  rs_drag
derived  Da(0.57)
derived  Dv(0.106)
derived  Dv(0.32)
derived  Dv(0.57)
derived  f(0.57)
derived  H(0.57)
dim=$ndim
algo=ada
length=$NSAMPLES
proposal_cov=$cov
t0=200
ts=10000
scale=0.001
do_move=false
EOF
cat mc_setup

cat > zerun.sh  <<eof
echo "running on : \$(uname -a)"
source /usr/local/intel/icc/bin/iccvars.sh
export CLIKDIR=$CLIKDIR
source \$CLIKDIR/bin/clik_profile.sh
export PYTHONHOME=/usr/local/python/python-2.7
export PYTHONPATH=/afs/in2p3.fr/group/planck/plaszczy/python2.7/site-packages/pypico
source /usr/local/bin/python27_env.sh
export OMP_NUM_THREADS=$MCORE

cd \$TMPDIR
cp $myexec .
#enleve precision pour MCMC
grep -v precision $dirpar/$parbase > $parbase
cat $PWD/mc_setup >>  $parbase
RANDOM=\${SGE_TASK_ID}
echo "seed=\$RANDOM" >>  $parbase

cp $parbase $PWD/camel.par

./$localexec $parbase $PWD/samples\${SGE_TASK_ID}.txt

cp ar_vs_length.txt ar_$PWD/vs_length\${SGE_TASK_ID}.txt
cp scale_vs_length.txt $PWD/scale_vs_length\${SGE_TASK_ID}.txt
cp corr.txt $PWD/corr\${SGE_TASK_ID}.txt

qstat -j \${JOB_ID} -nenv
eof

echo "**************************************"
cat zerun.sh
echo "OK? [o/n]"
read answer
if [ $answer != 'o' ] ; then
echo "exiting"
exit 1
fi

124 125
#qsub -P P_planck_prod -t 1-$NCHAINS -pe openmpi_$MCORE $MCORE -q pa_long -l sps=1 -V -R y -j y -o $PWD -e $PWD -N $zeroot zerun.sh
qsub -P P_planck_prod -t 1-$NCHAINS -pe multicores $MCORE -q mc_longlasting -l sps=1 -V -R y -j y -o $PWD -e $PWD -N $zeroot zerun.sh
Plaszczynski Stephane's avatar
Plaszczynski Stephane committed
126 127 128


cd -