#!/bin/bash
#
################################################################################
#
# Bash script for plotting file "RMSDVEFF.OUT" using gnuplot.
# Useful for checking convergence of a calculation.
# The label "r" refers to the currently running calculation.
#
# @Pasquale Pavone  (2010, October, 8)
#_______________________________________________________________________________

RUNDIR=$EXCITINGRUNDIR

CURRENT=$PWD

pointsize=0.9

if [ -f 'gnu-input' ]; then
    rm gnu-input
fi

if [ -e '../workdir' ]; then
    echo 
    read -p 'Enter label [r or 01,02,...] >>>> ' label
    echo
else 
    echo 
    read -p 'Enter label [r or 00,label,...] >>>> ' label
    echo
fi

if [ "$label" == "r" ]; then
    inpf=$RUNDIR/xc-rundir/RMSDVEFF.OUT
else
    inpf=$CURRENT/rundir-$label/RMSDVEFF.OUT
fi

cat>>gnu-input<<***
 set ter pos landscape enhanced color solid lw 2
 set out 'gnu.ps'
 set multiplot   
 set data sty lp
#set xtics 0.02
 set mxtics 0
 set grid 
 set key o r
 set key spacing 1.5 
 set key box
 set nokey
 set log y
#===============================================
 set size    0.86, 0.83
 set origin  0.05, 0.05
 set yr [$1:$2]
 set xr [:]
 set title "$3"  0,-0.8  font "Helvetica,18"
 set xlabel "Iteration"  0.0,0.0 font "Helvetica,18"     
 set ylabel "RMSDVEFF.OUT" 0.0,0.0 font "Helvetica,18"
 set xtics font "Helvetica,16"
 set ytics font "Helvetica,16"
 plot '$inpf' pt 7 ps $pointsize lt 1 lw 2 title ''    
#===============================================
 unset multiplot  
 quit
***
gnuplot < gnu-input
rm gnu-input
#-----------------------------------------------------------------------
#convert gnu.ps -rotate 90 $1-vs.png
#-----------------------------------------------------------------------

