Statistiques
| Révision :

root / examples / Vasp / Parallel / run_Path_SGE_scratch

Historique | Voir | Annoter | Télécharger (6,9 ko)

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

    
11

    
12
echo "============================================================================================="
13
echo "=                                                                                           ="
14
echo "=                        Vasp Parallel with unique machine                                  ="
15
echo "=                                                                                           ="
16
echo "=                           `date`                                          ="
17
echo "=                                                                                           ="
18
echo "============================================================================================="
19
HOMEDIR=$SGE_O_WORKDIR
20
SCRATCHDIR=`echo $HOMEDIR | awk -F "/" '{$2="scratch"; for(j=2;j<=NF;j++) {printf("/%s",$j);} print ""} ' `
21

    
22
echo "SCRATCHDIR=$SCRATCHDIR"
23

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

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

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

    
70
#
71
# Machinefile
72
#
73
HOSTFILE=$TMPDIR/machines
74

    
75

    
76
#################################
77
#
78
#! we create the 00, 01... and 0x directorires
79
# First we get the number of images in the INCAR file:
80
NbIm=`grep -i IMAGES INCAR | awk -F"=" '{n=$2*1+1; print n}' `
81
#
82
#
83
#################################
84
#
85
# We go to the Work Directory
86
cd $HOMEDIR
87

    
88
# A small test to see if everything matches
89
NbImP=` sed 's/,/^M/g' ${Job}.path | grep -i ngeomf | awk -F"=" '{n=$2*1-1; print n}' `
90
if [ $NbImP -ne $NbIm ]; then
91
 echo "WARNING WARNING WARNING WARNING WARNING WARNING"
92
 echo "IMAGES in INCAR and NGeomF in " ${Job}.path
93
 echo "Do Not Match... problems might be expected..."
94
 echo "Check it !!!"
95
 echo "WARNING WARNING WARNING WARNING WARNING WARNING"
96
fi
97

    
98
if [ $NbIm -le 9 ]; then
99
 Pref="0"
100
else
101
 Pref=""
102
fi
103

    
104
cp $HOSTFILE  $HOMEDIR/tmp
105
cp $PE_HOSTFILE $HOMEDIR/local_PE_HOSTFILE
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
#### We create the images directory on all nodes
119
  for n in `seq -w 0 $NbIm`
120
  do
121
    ndir=$Pref$n
122
    ssh $server mkdir -p ${SCRATCHDIR}/${ndir}
123
  done
124

    
125
#### we copy the Vasp executable to all nodes
126
   scp ${RUNNINGMACHINE}:${VASPDIR}/${VASPEXEC} $server:${SCRATCHDIR}/${VASPEXEC}
127

    
128
#### we copy the files to all nodes
129
   for FILE in INCAR KPOINTS POTCAR 
130
   do
131
     scp $RUNNINGMACHINE:$HOMEDIR/$FILE $server:${SCRATCHDIR}/.
132
   done
133

    
134
done
135

    
136
#### We create the directories and copy files on Master
137
for n in `seq -w 0 $NbIm`
138
do
139
  ndir=$Pref$n
140
  mkdir -p ${SCRATCHDIR}/${ndir}
141
  mkdir -p ${HOMEDIR}/${ndir}
142
done
143

    
144
#### we copy the Vasp executable to Scratch
145
cp ${VASPDIR}/${VASPEXEC} ${SCRATCHDIR}/${VASPEXEC}
146

    
147
#### we copy the files to SCRATCHDIR
148
for FILE in INCAR KPOINTS POTCAR
149
do
150
  cp $HOMEDIR/$FILE ${SCRATCHDIR}/.
151
done
152

    
153

    
154
# ###########################
155
#
156
#  We create the 'VaspExe' file that Path will use to run the
157
# actual VASP calculations of E and forces
158
#
159
#############################
160
# we test if we run on one machine (ie only Master or on many)
161
NOther=`wc -l  $HOMEDIR/machines_other | awk '{print $1}'`
162
if [ $NOther -ge 1 ]; then
163
cat << EOF > ./RunVasp
164
#!/bin/bash
165

    
166
#set -x
167
HOMEDIR=$HOMEDIR
168
SCRATCHDIR=$SCRATCHDIR
169
Pref=$Pref
170

    
171
#### We copy files to other machines
172
for server in \`cat \$HOMEDIR/machines_other\`
173
do
174
  for n in \`seq -w 0 $NbIm\`
175
  do
176
    ndir="$Pref\$n"
177
# we copy the POSCAR file
178
    scp \$HOMEDIR/\${ndir}/POSCAR \$server:\${SCRATCHDIR}/\${ndir}/.
179
  done
180
done
181

    
182
#### We copy files on Master
183
for n in \`seq -w 0 $NbIm\`
184
do
185
  ndir="$Pref\$n"
186
# we copy the POSCAR file
187
  cp \$HOMEDIR/\${ndir}/POSCAR \${SCRATCHDIR}/\${ndir}/.
188
done
189

    
190
cd \$SCRATCHDIR
191

    
192
$MPIRUN -v -prefix $MPIDIR -mca pls_rsh_agent "ssh" -mca btl openib,self -np $NSLOTS \${SCRATCHDIR}/${VASPEXEC} > \${SCRATCHDIR}/out
193

    
194
Iter=\`cat \$HOMEDIR/Path.iter\`
195
RUNNEW=run\${Iter}
196

    
197
#### We copy files from other machines
198
for server in \`cat \$HOMEDIR/machines_other\`
199
do
200
  for n in \`seq -w 0 $NbIm\`
201
  do
202
    ndir="$Pref\$n"
203
    for FILE in  OUTCAR POSCAR OSZICAR XDATCAR CONTCAR
204
    do
205
      scp \$server:\${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}
206
      cp \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}  \$HOMEDIR/\$ndir/\${FILE}
207
    done
208
  done
209
done
210

    
211
#### We copy files on Master
212
for n in \`seq -w 0 $NbIm\`
213
do
214
  ndir=$Pref\$n
215
  for FILE in  OUTCAR POSCAR OSZICAR XDATCAR CONTCAR
216
  do
217
   cp \${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}
218
   cp \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}  \$HOMEDIR/\$ndir/\${FILE}
219
  done
220
done
221

    
222
cp \${SCRATCHDIR}/out  \$HOMEDIR/out_\${RUNNEW}
223

    
224
let Iter=Iter+1
225
echo \$Iter > \$HOMEDIR/Path.iter
226

    
227
cd \$HOMEDIR
228
EOF
229
else
230
# We have only one node, so that everything is store on master
231
cat << EOF > ./RunVasp
232
#!/bin/bash
233

    
234
#set -x
235

    
236
HOMEDIR=$HOMEDIR
237
SCRATCHDIR=$SCRATCHDIR
238
Pref=$Pref
239

    
240
cd \$SCRATCHDIR
241
# We copy files from HOMEDIR to SCRATCHDIR
242
for n in \`seq -w 0 $NbIm\`
243
do
244
  ndir=$Pref\$n
245
  cp \$HOMEDIR/\$ndir/POSCAR \${SCRATCHDIR}/\$ndir/POSCAR
246
done
247

    
248
$MPIRUN -v -prefix $MPIDIR -mca pls_rsh_agent "ssh" -mca btl openib,self -np $NSLOTS \${SCRATCHDIR}/${VASPEXEC} > \${SCRATCHDIR}/out
249

    
250
Iter=\`cat \$HOMEDIR/Path.iter\`
251
RUNNEW=run\${Iter}
252

    
253

    
254
for n in \`seq -w 0 $NbIm\`
255
do
256
  ndir=$Pref\$n
257
  for FILE in  OUTCAR POSCAR OSZICAR XDATCAR CONTCAR
258
  do
259
   cp \${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}
260
   cp \${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}
261
  done
262
done
263
cp \${SCRATCHDIR}/out  \$HOMEDIR/out_\${RUNNEW}
264

    
265
let Iter=Iter+1
266
echo \$Iter > \$HOMEDIR/Path.iter
267

    
268
cd \$HOMEDIR
269
EOF
270
fi
271
chmod u+x ./RunVasp
272

    
273
###############################
274
#
275
# We launch PATH
276
#
277
###############################
278
ln -fs ${PathExe} .
279

    
280
./Path.exe ${Job}.path > ${Job}.out 2> ${Job}.err
281
 
282
#### We delete SCRATCHDIR on all machines
283
for server in `cat $HOMEDIR/machines_other`
284
do
285
 ssh $server rm -rf ${SCRATCHDIR}
286
done
287

    
288
rm -rf ${SCRATCHDIR}