#!/bin/bash
#
# Cron to keep track of core usage for GENCMIP6 project.
# To be executed every hour
# ======================================================================

# Initialize module command
# =========================
if [ -f /etc/bashrc ] ; then
  . /etc/bashrc
fi
# Load python
# ===========
# python/2.7.3 is the default, but it comes with matplotlib 1.2, 
# which is too old (no context manager for PdfPages)
module load python/2.7.8

# Go to root directory
# ====================
cd /ccc/cont003/home/dsm/p86ipsl/ConsoGENCMIP6/

# Main script to get data
# =======================
script="run_pen_v2"
printf "${script}\n"
echo "--------------------"
bin/${script}.sh
rc=$?
if [ ${rc} -ne 0 ] ; then
  echo "${script} terminated abnormally"
  exit
else
  echo "${script} OK"
fi

# Plot running and pending jobs
# =============================
# -d : copy plot on dods
script="plot_jobs"
printf "\n${script}\n"
echo "--------------------"
bin/${script}.py -d
rc=$?
if [ ${rc} -ne 0 ] ; then
  echo "${script} terminated abnormally"
else
  echo "${script} OK"
fi

printf "\nEnd of script OK\n"
