1 | #!/bin/bash |
---|
2 | # |
---|
3 | # ==================================================================== # |
---|
4 | # Author: Sonia Labetoulle # |
---|
5 | # Contact: sonia.labetoulle _at_ ipsl.jussieu.fr # |
---|
6 | # Created: March 21 2016 # |
---|
7 | # History: # |
---|
8 | # Modification: # |
---|
9 | # ==================================================================== # |
---|
10 | # Launch everything needed to track the consumption # |
---|
11 | # for GENCI projects. # |
---|
12 | # To be executed by a cron # |
---|
13 | # ====================================================================== |
---|
14 | |
---|
15 | date |
---|
16 | whereami=$( hostname -s ) |
---|
17 | |
---|
18 | # set -vx |
---|
19 | |
---|
20 | # .. System dependant steps .. |
---|
21 | # ============================ |
---|
22 | |
---|
23 | python_exe="python" |
---|
24 | case ${whereami} in |
---|
25 | pc-236) |
---|
26 | echo "maison" |
---|
27 | python_exe="/opt/epd7/bin/python" |
---|
28 | ;; |
---|
29 | curie*) |
---|
30 | echo "curie" |
---|
31 | # ... Initialize module command ... |
---|
32 | # --------------------------------- |
---|
33 | if [ -f /etc/bashrc ] ; then |
---|
34 | . /etc/bashrc |
---|
35 | fi |
---|
36 | # ... Load python ... |
---|
37 | # ------------------- |
---|
38 | #Â python/2.7.3 is the default, but it comes with matplotlib 1.2, |
---|
39 | # which is too old (no context manager for PdfPages) |
---|
40 | module load python/2.7.8 |
---|
41 | ;; |
---|
42 | *) |
---|
43 | echo "Unknown host ${whereami}, exit" |
---|
44 | exit 1 |
---|
45 | ;; |
---|
46 | esac |
---|
47 | |
---|
48 | # Go to root directory |
---|
49 | # ==================== |
---|
50 | ROOT_DIR=$( dirname $0 ) |
---|
51 | cd ${ROOT_DIR} |
---|
52 | BIN_DIR=${ROOT_DIR}/bin |
---|
53 | |
---|
54 | declare -A proj_center=(["gencmip6"]="tgcc" ["rgzi"]="idris") |
---|
55 | |
---|
56 | for projet in "${!proj_center[@]}" |
---|
57 | do |
---|
58 | centre=${proj_center[${projet}]} |
---|
59 | |
---|
60 | echo -e "\n* ${projet}/${centre}" |
---|
61 | echo -e "=================================================" |
---|
62 | |
---|
63 | # .. Insert cpt data into database .. |
---|
64 | # =================================== |
---|
65 | echo -e "1) Insert cpt data into table" |
---|
66 | echo -e "-------------------------------------------------" |
---|
67 | ${python_exe} ${BIN_DIR}/insert_conso_tbl.py -v ${projet} ${centre} |
---|
68 | RC=$? |
---|
69 | if [ ${RC} -gt 1 ] ; then |
---|
70 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
---|
71 | echo "! ! " |
---|
72 | echo "! ERROR: script ended abnormally !" |
---|
73 | echo "! ! " |
---|
74 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
---|
75 | elif [ ${RC} -ne 0 ] ; then |
---|
76 | echo -e "\n => nothing to do for ${projet}/${centre}" |
---|
77 | continue |
---|
78 | fi |
---|
79 | |
---|
80 | echo "test" |
---|
81 | |
---|
82 | # .. Plot daily consumption .. |
---|
83 | # ============================ |
---|
84 | echo -e "\n2) Plot daily consumption" |
---|
85 | echo -e "-------------------------------------------------" |
---|
86 | ${python_exe} ${BIN_DIR}/plot_bilan.py -vdf ${projet} ${centre} |
---|
87 | done |
---|
88 | |
---|