#!/bin/bash
# Script pour lancer grisli en batch au LSCE
# Works for the 
#PBS -N RUNNAME
# Specify batch queue
#PBS -q QUEUE
#PBS -v BATCH_NUM_PROC_TOT=PROC_NUMBER
#PBS -l nodes=1:ppn=PPN_NUMBER
# Specify execution shell
##PBS -S /bin/bash
# Request that stdin and stdout are merged in the same output file
#PBS -j eo
# Send a mail when the job terminates
#PBS -m e -M christophe.dumas@lsce.ipsl.fr

export MKL_NUM_THREADS=4
export OMP_NUM_THREADS=4
export KMP_STACKSIZE=16000000 #2048000000 # KMP_STACKSIZE remplace OMP_STACKSIZE avec ifort

module load netcdf/4

MODEL="SOURCESREP"
EXEDIR="EXEREP"

rm EXE_NAME
echo "Grisli is being compiled..."
cd $MODEL
make clean && make EXE_NAME

cd $EXEDIR
LID=`date +%y%m%d-%H%M%S`
echo "`date` -- GRISLI EXECUTION BEGINS HERE"
./EXE_NAME >& EXE_NAME.log.$LID

wait
echo "`date` -- GRISLI EXECUTION HAS FINISHED"

