Resurrection script

From Wiki
Jump to navigation Jump to search

Setting up the calculation

In order to use them properly, put the three script into your ~/bin/ folder in MareNostrum.


Script 1: resurrection

#!/bin/bash
# Rodrigo García-Muelas
# 28/03/2013
# 
# Input:
# $1 Name of work
# $2 Suffix (number id)
# $3 Queue
# $4 Number of processors
# $5 Number of hours of runtime
# $6 Extra number of minuts of runtime
#
# Motivation: I create a directory for the next step.
# Then, I create the new run.sh, which shall call this script
# And send
# run.sh has an internal time control

i=$(($2+1)) 

mkdir ../$i
cp ./INCAR ../$i/INCAR
cp ./KPOINTS ../$i/KPOINTS
cp ./CONTCAR ../$i/POSCAR
cp ./POTCAR ../$i/POTCAR
mv ./WAVECAR ../$i/WAVECAR
mv ./CHGCAR ../$i/CHGCAR
rm ./CHG

cd ../$i/
rungen_resurrection $1 $i $3 $4 $5 $6 # generate run.sh
bsub < run.sh                         # submit run.sh
exit

Script 2: rungen_resurrection

#!/bin/bash
# Rodrigo García-Muelas
# 28/03/2013
# 
# Input:
# $1 Name of work
# $2 Suffix (number id)
# $3 Queue
# $4 Number of processors
# $5 Runtime hours
# $6 Runtime minutes (add)
#
# Motivation: I create a directory for the next step.
# Then, I create the new run.sh, which shall call this script

case $3 in
 16a)  queue=class_a  ; mar=1 ; procqueue=16 ; maxhours=47 ;;
 16b)  queue=class_b  ; mar=1 ; procqueue=16 ; maxhours=22 ;; # maybe they give priority to shorter works 
 16c)  queue=class_c  ; mar=1 ; procqueue=16 ; maxhours=22 ;; # idem
 *)    echo "Error in queue name!!! " ; exit ;;
esac

# Comprobate if the number of processors is correct 
let AAA=`expr $4 % $procqueue` ; if [ 0 != $AAA ] ; then exit 1 ; fi # number of processars right?

# Generating the run.sh file 
cat >run.sh<<!
#!/bin/bash
#BSUB -J $1$2
#BSUB -q $queue 
#BSUB -n $4 
#BSUB -W $5:59
#BSUB -o o_$1$2.%J
#BSUB -e e_$1$2.%J
#BSUB -u rgarcia@iciq.es
#BSUB -R"span[ptile=16]"

### Load environment variables ###########
module load VASP/5.3.3

### Run job ##############################
resurrection_timecontrol $5 $6 r_$1$2 &
mpirun vasp.complex ; touch stopflag ; resurrection $1 $2 $3 $4 $5 $6 ; echo the dynamics has been resurrected >> r_$1$2 ; exit

!

Script 3: resurrection_timecontrol

#!/bin/bash
#
# Rodrigo García-Muelas
# Improved on May 17th, 2013
#
# INPUT
#
# $1 number of hours   +
# $2 number of minutes
#    (before generating file STOPCAR)
# $3 name of file
# 
# INTERNAL
#
# timeini : The calculus starts
# timeend : The calculus ends
# timenow : Current time 


timeini=`date +'%s'` 
timenow=$timeini
timeend=$(($timeini+3600*$1+60*$2))

echo resurrection flags are timeini $timeini timeend $timeend >> $3

# If VASP finishes before timeend, kill this process

while [ $timenow -lt $timeend ] ;  do 
sleep 60s
if [ -e stopflag ] ; then rm stopflag ; echo resurrection: VASP finished normally at $timenow >> $3 ; exit ; fi
timenow=`date +'%s'` 
done

# If timeend is reached, write STOPCAR 

echo resurrection: writing STOPCAR at $timenow >> $3 
cat >STOPCAR<<!
 LSTOP = .TRUE.

!

exit