Commit 4926564b authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

deep cleaning of script

parent a8a7c1d9
#!/bin/bash
EXPECTED_ARGS=2
if [ $# -ne $EXPECTED_ARGS ]
then
echo ">>>> Usage: `basename $0` parfile range"
echo "range should be specified as an interval in the form: I-J (as \"1-3\")"
echo "which corresponds to each array-job interval (ie. starting points)"
echo "parfile values are not shuffled (randomly) for job 1"
exit 1
fi
parFile=$1
range=$2
#check environment
if [ -z "${CAMELROOT}" ] ; then
echo "CAMELROOT undefined: did you sourced camel_setup.sh?"
exit
fi
if [ ! -f "$parFile" ] ; then
echo "Missing parfile=$parFile"
exit
fi
##############define the scanned variable###############
# define the variable that is scanned
var="100*theta_s"
# define the variable/values that is scanned
var="log(10^10A_s)"
#values
# 1. define automatically: N points between xmin and xmax
#values : methods 1 specify number of points N and boudaries [xmin,xmax]
N=50
xmin=1.04
xmax=1.0422
#compute automatically the values
xmin=2.9
xmax=3.2
#compute
for ((i=0;i<N;i++)) ; do
val[$i]=$(echo | awk -v xmin=$xmin -v xmax=$xmax -v N=$N -v i=$i 'BEGIN{step=(xmax-xmin)/(N-1)} {printf("%f",xmin+(i)*step)}')
done
#2. or add explcitely the list of values
# method 2. add explcitely the list of values
#var="Alens"
#val=(0.95 1 1.03 1.05 1.07 1.10 1.12 1.15 1.20 1.25 1.30)
#or
#var=tau_reio
#val=(0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25)
echo "About to run a scan on the ---$var--- variable with the following values"
echo ${val[*]}
######################################################
echo "Scannning variable $var"
echo "values=${val[*]}"
#fix number of cores for openMP
NCORE=8
#default QSUB command (if not overriden by user)
if [ -z "${QSUB_CMD}" ] ; then
QSUB_CMD="qsub -P P_$GROUP -pe multicores $NCORE -q mc_long -R y -j y -l sps=1"
fi
echo "QSUB command will be: ${QSUB_CMD} -t $range"
echo "Is this OK? [y/n]"
read answer
if [ $answer != 'y' ] ; then
......@@ -34,21 +64,16 @@ fi
######################################
#escape problematic characters
varesc=$(printf "%q" $var)
cd `dirname $1`
dirpar=$PWD
cd -
parbase=`basename $1`
file=$dirpar/$parbase
varesc=$(printf "%q" "$var")
dirout=${parbase%".par"}_mprof_"$varesc"
file=$(readlink -e $parFile)
parbase=$(basename $file)
dirout=${parbase%".par"}_mprof_"$var"
if [ -d "$dirout" ] ; then
echo "directory $dirout exists: still want to run? (o/n)"
echo "directory $dirout exists: still want to run? (y/n)"
read answer
if [ $answer != 'o' ] ; then
if [ $answer != 'y' ] ; then
echo "exiting"
exit 1
fi
......@@ -56,37 +81,19 @@ fi
mkdir $dirout
if [ -z "${CAMELROOT}" ] ; then
echo "CAMELROOT undefined"
exit
fi
if [ -z "$CLIKDIR" ] ; then
echo "miss CLIKDIR"
exit
fi
if [ ! -f "$file" ] ; then
echo "mssing $file"
exit
fi
CAMELDIR=${GROUP_DIR}/camel
HERE=$PWD
##########LOOP################################
for i in $(seq 0 $((${#val[@]}-1))) ; do
zeval=${val[$i]}
echo $zeval
OUTDIR=$HERE/$dirout/"$varesc"_${zeval}
OUTDIR=$HERE/$dirout/"$var"_${zeval}
mkdir $OUTDIR
cd $OUTDIR
###################################################
########################################################
cat > camelrun_$zeval <<EOBATCH
#!/bin/bash
#$ -N $(basename $(dirname $PWD))_$zeval
#!/bin/env bash
#$ -N ${parbase}_$zeval
#$ -R y
#$ -j y
#$ -o $PWD
......@@ -97,13 +104,13 @@ cd \$TMPDIR
uname -a
echo "NSLOTS=\$NSLOTS"
export OMP_NUM_THREADS=8
export OMP_NUM_THREADS=$NCORE
export PYTHONPATH=${PICO_CODE}
# copies localeS
cp $CAMELROOT/$CMTCONFIG/Minimize .
cp $CAMELROOT/batch/awk/genrand.awk .
cp $CAMELROOT/work/tools/awk/genrand.awk .
#
#input file -> transforme en pico et enleve var
......@@ -138,10 +145,9 @@ cp -f best_fit "$OUTDIR"/best_fit\${SGE_TASK_ID}
cp -f covmat "$OUTDIR"/covmat\${SGE_TASK_ID}
EOBATCH
#####################################################################################################################################
#SP only
qsub -P P_planck_prod -t 1-3 -pe openmpi_8 8 -q pa_long camelrun_$zeval
qsub -P P_planck_prod -t 4-6 -pe multicores 8 -q mc_long camelrun_$zeval
#qsub -P P_planck_prod -t 1-10 -pe multicores 8 -q mc_long camelrun_$zeval
#####################################################################################################################################
###################################################################
#submit an array job for this scanned value
jobsub="${QSUB_CMD} -t \"$range\" camelrun_$zeval"
eval $jobsub
##################################################################
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment