Statistiques
| Révision :

root / examples / Vasp / Serial / run_Path_SGE_scratch

Historique | Voir | Annoter | Télécharger (5,48 ko)

1
#!/bin/bash
2
#$ -S /bin/bash
3
#$ -N Vasp_S_U1
4
#$ -cwd 
5
#$ -V
6
#$ -o Vasp_para.batch-log
7
#$ -j y
8
#$ -q dl165adf
9
#$ -pe mpi8 8
10

    
11

    
12
echo "============================================================================================="
13
echo "=                                                                                           ="
14
echo "=                        Path with Serial Vasp  with unique machine                         ="
15
echo "=                                                                                           ="
16
echo "=                           `date`                                          ="
17
echo "=                                                                                           ="
18
echo "============================================================================================="
19

    
20
HOMEDIR=$SGE_O_WORKDIR
21
SCRATCHDIR=`echo $HOMEDIR | awk -F "/" '{$2="scratch"; for(j=2;j<=NF;j++) {printf("/%s",$j);} print ""} ' `
22

    
23
#Iter is the index for storing files as POSCAR_runXX
24
Iter=1
25
echo $Iter > Path.iter
26

    
27

    
28

    
29
######################################
30
#
31
# you might have to change the following variables
32
#
33
######################################
34
#
35
# Name of the Path Input file
36
#
37
Job=Test_Vasp_Serial
38
#
39
#
40
# Where is Path.exe ??
41
#
42
PathExe=~/Programs/optnpath/src/Path.exe
43
#
44
# Where is VASP ?
45
#
46
export VASPDIR=~/Programs/VASP
47
export VASPEXEC=VASP4635_R410_STD
48
#
49
# Whre is mpirun ?
50
#
51
export MPIDIR=/softs/openmpi-1.4.1-intel/
52
export MPIRUN=$MPIDIR/bin/mpirun
53
#
54
#
55
# Machine where the files are
56
#
57
RUNNINGMACHINE=r410comp1-pub
58

    
59
# Some libraries... 
60
#
61
#For intel 11.1.069
62
source /softs/intel/v11.1.069/bin/intel64/ifortvars_intel64.sh
63
export LD_LIBRARY_PATH=/softs/fftw/2.1.5/ps-gb/lib:$LD_LIBRARY_PATH:/usr/lib
64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/softs/intel/v11.1.069/mkl/lib/em64t/:$MPIDIR/lib/:/softs/intel/v11.1.069/lib/intel64
65
export LANG=C
66
#
67
#Usually nothing has to be changed after this line
68
#
69
#################################################
70

    
71
#
72
# Machinefile
73
#
74
HOSTFILE=$TMPDIR/machines
75
cp $HOSTFILE $HOMEDIR/local_machines
76

    
77

    
78
#################################
79
#
80
# We go to the Work Directory
81
cd $HOMEDIR
82

    
83

    
84
#################################
85
#
86
#
87
# We check that the INCAR file is not a NEB
88
#
89
NbIm=`grep -i IMAGES INCAR  `
90
if [ "$NbIm" != "" ]; then
91
  mv INCAR INCAR.ori
92
  grep -v IMAGES INCAR.ori > INCAR
93

    
94
 echo "WARNING WARNING WARNING WARNING WARNING WARNING"
95
 echo "IMAGES was in INCAR "
96
 echo "I copied INCAR to INCAR.ori and deleted this line"
97
 echo "Check it !!!"
98
 echo "WARNING WARNING WARNING WARNING WARNING WARNING"
99
fi
100

    
101
##############################
102
#
103
# As we work in the scratchdir
104
#
105
# We will create directories there
106
Master="`head -1 $HOSTFILE`"
107
echo $Master > $HOMEDIR/Master
108

    
109
FUniq=`which uniq`
110
Uniq=${FUniq:-"sort -u"}
111
$Uniq $HOSTFILE > $HOMEDIR/machines_unique
112
grep -v $Master $HOMEDIR/machines_unique > $HOMEDIR/machines_other
113

    
114

    
115
#### We create the directories and copy files to other machines
116
for server in `cat $HOMEDIR/machines_other`
117
do
118
  ssh $server mkdir -p ${SCRATCHDIR}
119
#### we copy the Vasp executable to all nodes
120
  scp ${RUNNINGMACHINE}:${VASPDIR}/${VASPEXEC} $server:${SCRATCHDIR}/${VASPEXEC}
121

    
122
#### we copy the files to all nodes
123
  for FILE in INCAR KPOINTS POTCAR 
124
  do
125
    scp $RUNNINGMACHINE:$HOMEDIR/$FILE $server:${SCRATCHDIR}/.
126
  done
127
done
128

    
129
#### We create the directories and copy files on Master
130
mkdir -p ${SCRATCHDIR}
131

    
132
#### we copy the Vasp executable to Scratch
133
cp ${VASPDIR}/${VASPEXEC} ${SCRATCHDIR}/${VASPEXEC}
134

    
135
#### we copy the files to SCRATCHDIR
136
for FILE in INCAR KPOINTS POTCAR
137
do
138
  cp $HOMEDIR/$FILE ${SCRATCHDIR}/.
139
done
140

    
141

    
142
#############################
143
#
144
#  We create the 'VaspExe' file that Path will use to run the
145
# actual VASP calculations of E and forces
146
#
147
#############################
148
NOther=`wc -l  $HOMEDIR/machines_other | awk '{print $1}'`
149
if [ $NOther -ge 1 ]; then
150
cat << EOF > ./RunVasp
151
#!/bin/bash
152

    
153
#set -x
154
HOMEDIR=$HOMEDIR
155
SCRATCHDIR=$SCRATCHDIR
156

    
157

    
158
Iter=\`cat \$HOMEDIR/Path.iter\`
159
RUNNEW=run\${Iter}
160

    
161
#### We copy the POSCAR file to other machines
162
for server in \`cat \$HOMEDIR/machines_other\`
163
do
164
  scp \$HOMEDIR/POSCAR \$server:\${SCRATCHDIR}/.
165
done
166

    
167
#### We copy files on Master
168
cp \$HOMEDIR/POSCAR \${SCRATCHDIR}/.
169

    
170

    
171
cd \$SCRATCHDIR
172

    
173
$MPIRUN -v -prefix $MPIDIR  -mca btl openib,self -np $NSLOTS \${SCRATCHDIR}/${VASPEXEC} > \${HOMEDIR}/out_\${RUNNEW}
174

    
175
for FILE in  OUTCAR POSCAR OSZICAR XDATCAR CONTCAR
176
do
177
 cp \${SCRATCHDIR}/\$FILE \$HOMEDIR/\${FILE}_\${RUNNEW}
178
 cp \$HOMEDIR/\${FILE}_\${RUNNEW}  \$HOMEDIR/\${FILE}
179
done
180

    
181
cp \${SCRATCHDIR}/out  \$HOMEDIR/out_\${RUNNEW}
182

    
183
let Iter=Iter+1
184
echo \$Iter > \$HOMEDIR/Path.iter
185

    
186
cd \$HOMEDIR
187

    
188
EOF
189
else
190
cat << EOF > ./RunVasp
191
#!/bin/bash
192

    
193
#set -x
194
HOMEDIR=$HOMEDIR
195
SCRATCHDIR=$SCRATCHDIR
196

    
197
Iter=\`cat \$HOMEDIR/Path.iter\`
198
RUNNEW=run\${Iter}
199

    
200
#### We copy the POSCAR file
201
cp \$HOMEDIR/POSCAR \${SCRATCHDIR}/.
202

    
203
cd \$SCRATCHDIR
204

    
205
$MPIRUN -v -prefix $MPIDIR  -mca btl openib,self -np $NSLOTS \${SCRATCHDIR}/${VASPEXEC} > \${HOMEDIR}/out_\${RUNNEW}
206

    
207

    
208
for FILE in  OUTCAR POSCAR OSZICAR XDATCAR CONTCAR
209
do
210
 cp \${SCRATCHDIR}/\$FILE \$HOMEDIR/\${FILE}_\${RUNNEW}
211
 cp \$HOMEDIR/\${FILE}_\${RUNNEW}  \$HOMEDIR/\${FILE}
212
done
213

    
214
cp \${SCRATCHDIR}/out  \$HOMEDIR/out_\${RUNNEW}
215

    
216
let Iter=Iter+1
217
echo \$Iter > \$HOMEDIR/Path.iter
218

    
219
cd \$HOMEDIR
220

    
221
EOF
222
fi
223

    
224
chmod u+x ./RunVasp
225

    
226
###############################
227
#
228
# We launch PATH
229
#
230
###############################
231
ln -fs ${PathExe} .
232

    
233
./Path.exe ${Job}.path > ${Job}.out 2> ${Job}.err
234
 
235
#######################""
236
#
237
# We delete the SCRATCHDIRs
238
for server in \`cat \$HOMEDIR/machines_other\`
239
do
240
  ssh $server rm -rf $SCRATCHDIR
241
done
242

    
243
rm -rf $SCRATCHDIR