-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathout2in.sh
executable file
·125 lines (90 loc) · 3.63 KB
/
out2in.sh
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
121
#!/bin/bash
#01/07/2015
#Sebastian ECHEVERRI RESTREPO
#sebastianecheverri@ at gmail.com
#############################################################################
#Reads an output file .out from abinit and generates .in files to be read by v_sim
#inputs
# .out file
#outputs
# series of .in files
# this files are numbered starting from file00000.in
#notes
#the generated files only contain the necessary information for visualization,
# they are not enough for running a simulation with abinit
#############################################################################
#############################################################################
#File to read
OutFileName=$1
######
#This part reads the initial configuration (the atom positions will be the
# same as in the input file used for the simulation
#Reading acell, rprim, ntypat, znucl.
#v_sim asks for chkprim so it is also written
grep acell $OutFileName | head -1 > file00000.in
grep -A2 rprim $OutFileName | head -3 >> file00000.in
echo 'chkprim 0' >> file00000.in
grep -m2 ntypat $OutFileName | tail -1 >> file00000.in
grep znucl $OutFileName | head -1 >> file00000.in
#Reading natom. in the .out file, typat might take more than one line. The
# maximum number of values per line is 20. So, the number of atoms is
# used to see how many lines need to be read
grep -m3 natom $OutFileName | tail -1 >> file00000.in
natom=`grep -m3 natom $OutFileName | tail -1 | awk '{print $2}'`
natom_1=`awk -v natom=$natom 'BEGIN{print natom-1}'`
if [ $natom -le 20 ]
then
grep -m3 typat $OutFileName | tail -1 >> file00000.in
elif [ $natom -le 40 ]
then
grep -m3 -A1 typat $OutFileName | tail -2 >> file00000.in
elif [ $natom -le 60 ]
then
grep -m3 -A2 typat $OutFileName | tail -3 >> file00000.in
fi
grep -m1 -A $natom_1 xred $OutFileName >> file00000.in
######
#for the rest of the configurations
#reading the number of files that will be generated
nfiles=`grep '(xred)' $OutFileName | wc | awk '{print $1}'`
#checking if the box dimensions are changed. If they are not changed,
# the initial values are used
optcell=`grep optcell $OutFileName | head -1 | awk '{print $2}'`
for i in $(seq -f "%05g" 1 $nfiles)
#for i in `seq 1 $nfiles`;
do
#if the cell dimensions do not change,the initial values are used
# for acell and rprim
#if the cell dimensions change,the values of acell is different for
# for each file. Note that angdeg is used instead of rprim
if [ ! -z "$optcell" ]; then
grep -m$i -A1 '(acell)' $OutFileName | tail -1 | awk '{print "acell", $0}' > file$i.in
grep -m$i -A1 "degrees]" $OutFileName | tail -1 | awk '{print "angdeg", $0}' >> file$i.in
else
grep acell $OutFileName | head -1 > file$i.in
grep -A2 rprim $OutFileName | head -3 >> file$i.in
fi
#v_sim asks for chkprim so it is also written
echo 'chkprim 0' >> file$i.in
#reading ntypat, znucl
grep -m2 ntypat $OutFileName | tail -1 >> file$i.in
grep znucl $OutFileName | head -1 >> file$i.in
#Reading natom. in the .out file, typat might take more than one line. The
# maximum number of values per line is 20. So, the number of atoms is
# used to see how many lines need to be read
grep -m3 natom $OutFileName | tail -1 >> file$i.in
if [ $natom -le 20 ]
then
grep -m3 typat $OutFileName | tail -1 >> file$i.in
elif [ $natom -le 40 ]
then
grep -m3 -A1 typat $OutFileName | tail -2 >> file$i.in
elif [ $natom -le 60 ]
then
grep -m3 -A2 typat $OutFileName | tail -3 >> file$i.in
fi
#reading the coordinates xred
echo 'xred ' >> file$i.in
grep -m$i -A $natom '(xred)' $OutFileName | tail -$natom >> file$i.in
echo "Generating file" $i
done