-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch_sakam
More file actions
executable file
·92 lines (76 loc) · 3.04 KB
/
launch_sakam
File metadata and controls
executable file
·92 lines (76 loc) · 3.04 KB
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
#!/bin/bash
set -e # Exit on error
#--- It avoids that numpy takes more than one core ------------
export OPENBLAS_NUM_THREADS=1
export MKL_NUM_THREADS=1
#------------------------------------------------
#-------------- Global variables -----------------------------------------
GLOBALS=$1
if [ ! -f $GLOBALS ]
then
echo "Input file does not exists!"
echo "You must provide a valid global variables file"
exit
fi
#----- Read models list into bash array
IFS=',' read -r -a MODELS <<< $(grep -m 1 models $GLOBALS | awk '{print $3}' | tr -d '[]"')
IFS=',' read -r -a AGES <<< $(grep -m 1 ages $GLOBALS | awk '{print $3}' | tr -d '[]"')
TNP="$(grep -m 1 size $GLOBALS | awk '{print $3}')"
PATH_BSE="$(grep -m 1 dir_base $GLOBALS | awk '{print $3}' | tr -d '"')"
PATH_SKM="$(grep -m 1 dir_sakam $GLOBALS | awk '{print $3}' | tr -d '"')"
STATICS=$PATH_SKM"/statics.py"
NAME_PKL="$(grep -m 1 -wr '\bname_globals\b' $GLOBALS | awk '{print $3}' | tr -d '"')"
#------------------------------------------------------------------
#================ Loop over models ============================================
for model in "${MODELS[@]}"
do
#--------- Local variables -------
PATH_MDL=$PATH_BSE$model
mkdir -p $PATH_MDL
#--------------------------------
#================ Loop over ages ============================================
for age in "${AGES[@]}"
do
echo "Running with $model model at $age Myr ..."
#--------- Local variables -------
PATH_AGE=$PATH_MDL"/"$age
mkdir -p $PATH_AGE
#--------------------------------
PKL=$PATH_AGE"/"$NAME_PKL
GLBLS=$PATH_AGE"/globals.py"
LOG_OUT=${PATH_AGE}"/log_out"
LOG_ERR=${PATH_AGE}"/log_error"
#--------------------------------
#----- Create global variables file -------
sed -e "s|XXX|$model|g" -e "s|YYY|$age|g" $GLOBALS > $GLBLS
#---------------------------------------------------
#------ Launch global variables file ------
python -u $GLBLS
python -u $STATICS $PKL
#-----------------------------------------
#------- Pre processing -----------------------
echo "Preprocessing catalogue ..."
python -u $PATH_SKM/preprocess.py $PKL >> $LOG_OUT 2>> $LOG_ERR
#----------------------------------------------
#----- Split catalogue -------------------------------------
echo "Splitting catalogue ..."
python -u $PATH_SKM/split.py $PKL >> $LOG_OUT 2>> $LOG_ERR
#-----------------------------------------------------------
#=========== Loop over parts ======================
for PRC in $(eval echo "{1..$TNP}")
do
echo "Launching part $PRC of $TNP"
sed s/XXX/$PRC/g $PATH_SKM/fit.py > $PATH_AGE/tmp.py
python -u $PATH_AGE/tmp.py $PKL >> $LOG_OUT 2>> $LOG_ERR &
sleep 10
rm $PATH_AGE/tmp.py
done
#==================================================
echo "Waiting for $model-$age Myr processes to finish ..."
wait
#--------- Unify outputs ------------------------------
python -u $PATH_SKM/unify.py $PKL >> $LOG_OUT 2>> $LOG_ERR
#------------------------------------------------------
done
done
#==============================================================================