source: TOOLS/ConsoGENCI/trunk/launch_conso.sh @ 2792

Last change on this file since 2792 was 2783, checked in by labetoulle, 8 years ago
  • Run everything (DB inserts + plots) from single bash script
  • Change exit codes (unsigned in bash, so no negative values...) :
    • 0: everything was ok;
    • 1: nothing done, 'cause nothing to do => ok;
    • >= 2: error.
  • DB access now needs password
  • plot_bilan: added date of production and plotted range to image
  • Cleaning (useless comments, ...)
  • Property svn:executable set to *
File size: 2.7 KB
Line 
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# set -vx
16
17whereami=$( hostname -s )
18
19# .. System dependant steps ..
20# ============================
21
22python_exe="python"
23case ${whereami} in
24  pc-236) 
25    echo "maison"
26    python_exe="/opt/epd7/bin/python"
27    ;;
28  curie*)
29    echo "curie"
30    # ... Initialize module command ...
31    # ---------------------------------
32    if [ -f /etc/bashrc ] ; then
33      . /etc/bashrc
34    fi
35    # ... Load python ...
36    # -------------------
37    # python/2.7.3 is the default, but it comes with matplotlib 1.2,
38    # which is too old (no context manager for PdfPages)
39    module load python/2.7.8
40    ;;
41  *)
42    echo "Unknown host ${whereami}, exit"
43    exit 1
44    ;;
45esac
46
47# Go to root directory
48# ====================
49ROOT_DIR=$( dirname $0 )
50cd ${ROOT_DIR}
51BIN_DIR=${ROOT_DIR}/bin
52
53declare -A proj_center=(["gencimp6"]="tgcc" ["rgzi"]="idris")
54
55for projet in "${!proj_center[@]}"
56do
57  centre=${proj_center[${projet}]}
58
59  echo -e "\n* ${projet}/${centre}"
60  echo -e "================================================="
61
62  # .. Insert cpt data into database ..
63  # ===================================
64  echo -e "1) Insert cpt data into table"
65  echo -e "-------------------------------------------------"
66  ${python_exe} ${BIN_DIR}/insert_conso_tbl.py -v ${projet} ${centre}
67  RC=$?
68  if [ ${RC} -gt 1 ] ; then
69    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
70    echo "!                                    ! "
71    echo "!   ERROR: script ended abnormally   !"
72    echo "!                                    ! "
73    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
74  elif [ ${RC} -ne 0 ] ; then
75    echo -e "\n   => nothing to do for ${projet}/${centre}"
76    continue
77  fi
78
79  echo "test"
80
81  # .. Plot daily consumption ..
82  # ============================
83  echo -e "\n2) Plot daily consumption"
84  echo -e "-------------------------------------------------"
85  ${python_exe} ${BIN_DIR}/plot_bilan.py -vdf ${projet} ${centre}
86done
87
Note: See TracBrowser for help on using the repository browser.