-
Notifications
You must be signed in to change notification settings - Fork 1
/
CheckFinishAll
executable file
·120 lines (109 loc) · 3.5 KB
/
CheckFinishAll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
print_usage() {
echo "HI, $USER!"
echo ""
echo "THIS SCRIPT IS TO CHECK CONVERGENCY OF A VASP CALCULATIONS."
echo
printf "Usage: $(basename "$0") [-h][-b][-o] <file-path>"
echo
echo " -h: help option"
echo " -b : For cheking convergency of bandgap calculation using METAGGA=mbj"
echo " -o : For cheking convergency of optimization calculation (Default: Single point non-bandgap calculation)"
echo " e.g. CheckFinishAll -b 'S5/N03.7/conf*'"
echo
exit
}
if [[ $# -eq 0 ]] ;then print_usage; fi
file=$1
while getopts ":b:o:h" options ; do
case $options in
b) file=${OPTARG}
check="bandgap" ;;
o) file=${OPTARG}
check='optimization' ;;
h) print_usage;;
\?) printExit E "Invalid option: -$OPTARG." ;;
esac
done
CheckFinishOptimization(){
printf "++ Optimization Convergency check\n\n"
a=()
for j in $file;do
if [ -s "$j/OUTCAR" ] ; then
if [ $( grep -L 'reached required accuracy' $j/OUTCAR) ] ; then
printf "\e[38;5;213m-- Warning:\e[0m $j didn't finish.\n"
a+=" $j"
fi
else
printf "\e[38;5;1m** Error:\e[0m $j doesn't have OUTCAR or Empty.\n"
a+=" $j"
fi
done
echo " "
echo "All files that didn't converge: "
echo ${a[@]}
echo " "
}
CheckFinishSinglePoint(){
printf "++ Singlepoint Convergency check\n\n"
for j in $file;do
if [ -s "$j/OUTCAR" ] ; then
totalsteps=$(grep E0 $j/OSZICAR | tail -n 1 | awk '{print $1}')
if [[ $totalsteps -gt 1 ]]; then
printf "\e[38;5;213m** Warning:\e[0m $j not a single point calculation. Multiple steps found in OSZICAR.\n"
else
nelmoutcar=$(awk '/NELM/ {print $3}' $j/OUTCAR | cut -d ';' -f1)
nelmoszicar=$(tail -n 2 $j/OSZICAR | head -n 1 | awk '{print $2}')
nelmdiff=$(bc<<<"$nelmoutcar-$nelmoszicar")
if [[ $nelmdiff -ne 0 ]];then
if [ $( grep -L 'Total CPU time used' $j/OUTCAR) ] ; then
printf "\e[38;5;213m-- Warning:\e[0m $j didn't finish.\n"
fi
else
printf "\e[38;5;213m-- Warning:\e[0m $j didn't finish properly. All the NELM step is consumed.\n"
fi
fi
else
printf "\e[38;5;1m** Error:\e[0m $j doesn't have OUTCAR or Empty.\n"
fi
done
}
CheckFinishBandgap(){
printf "++ Bandgap Convergency check\n\n"
for j in $file;do
#echo $j
if [ -s "$j/OUTCAR" ] ; then
if grep -q "METAGGA = MBJ" $j/OUTCAR; then
nelmoutcar=$(awk '/NELM/ {print $3}' $j/OUTCAR | cut -d ';' -f1)
#nelmoszicar=$(tail -n 2 $j/OSZICAR | head -n 1 | awk '{print $2}')
nelmoszicar=$(grep 'Iteration' $j/OUTCAR | tail -n 1 | awk '{print $4}' | cut -d ')' -f1)
nelmdiff=$(bc<<<"$nelmoutcar-$nelmoszicar")
if [[ $nelmdiff -ne 0 ]];then
if [ $( grep -L 'Total CPU time used' $j/OUTCAR) ] ; then
printf "\e[38;5;213m-- Warning:\e[0m $j didn't finish.\n"
fi
else
printf "\e[38;5;213m-- Warning:\e[0m $j didn't finish properly. All the NELM step is consumed.\n"
fi
else
printf "\e[38;5;91m++ Warning:\e[0m MBJ metagga is not used in $j.\n"
i=$(awk '/ISIF/ {print $3}' $j/OUTCAR)
if [[ $i -ne 0 ]]; then
printf "\e[38;5;91m++ Warning:\e[0m ISIF in $j/OUTCAR = $i (not 0).\n"
fi
fi
else
printf "\e[38;5;1m** Error:\e[0m $j doesn't have OUTCAR or Empty.\n"
fi
done
}
echo
echo "File supplied = $file"
echo
if [[ "$check" == 'bandgap' ]]; then
CheckFinishBandgap
elif [[ "$check" == 'optimization' ]]; then
CheckFinishOptimization
else
CheckFinishSinglePoint
fi