root / examples / Vasp / Parallel / run_Path_SGE_scratch
Historique | Voir | Annoter | Télécharger (6,9 ko)
| 1 | 1 | pfleura2 | #!/bin/bash |
|---|---|---|---|
| 2 | 1 | pfleura2 | #$ -S /bin/bash |
| 3 | 1 | pfleura2 | #$ -N Vasp_PU3 |
| 4 | 1 | pfleura2 | #$ -cwd |
| 5 | 1 | pfleura2 | #$ -V |
| 6 | 1 | pfleura2 | #$ -o Vasp_para.batch-log |
| 7 | 1 | pfleura2 | #$ -j y |
| 8 | 1 | pfleura2 | #$ -q r410lin24ibcourt |
| 9 | 1 | pfleura2 | #$ -pe mpi32 32 |
| 10 | 1 | pfleura2 | |
| 11 | 1 | pfleura2 | |
| 12 | 1 | pfleura2 | echo "=============================================================================================" |
| 13 | 1 | pfleura2 | echo "= =" |
| 14 | 1 | pfleura2 | echo "= Vasp Parallel with unique machine =" |
| 15 | 1 | pfleura2 | echo "= =" |
| 16 | 1 | pfleura2 | echo "= `date` =" |
| 17 | 1 | pfleura2 | echo "= =" |
| 18 | 1 | pfleura2 | echo "=============================================================================================" |
| 19 | 1 | pfleura2 | HOMEDIR=$SGE_O_WORKDIR |
| 20 | 1 | pfleura2 | SCRATCHDIR=`echo $HOMEDIR | awk -F "/" '{$2="scratch"; for(j=2;j<=NF;j++) {printf("/%s",$j);} print ""} ' `
|
| 21 | 1 | pfleura2 | |
| 22 | 1 | pfleura2 | echo "SCRATCHDIR=$SCRATCHDIR" |
| 23 | 1 | pfleura2 | |
| 24 | 1 | pfleura2 | #Iter is the index for storing files as POSCAR_runXX |
| 25 | 1 | pfleura2 | Iter=1 |
| 26 | 1 | pfleura2 | echo $Iter > Path.iter |
| 27 | 1 | pfleura2 | |
| 28 | 1 | pfleura2 | ###################################### |
| 29 | 1 | pfleura2 | # |
| 30 | 1 | pfleura2 | # you might have to change the following variables |
| 31 | 1 | pfleura2 | # |
| 32 | 1 | pfleura2 | ###################################### |
| 33 | 1 | pfleura2 | # |
| 34 | 1 | pfleura2 | # Name of the Path Input file |
| 35 | 1 | pfleura2 | # |
| 36 | 1 | pfleura2 | Job=Test_Vasp_Para |
| 37 | 1 | pfleura2 | # |
| 38 | 1 | pfleura2 | # |
| 39 | 1 | pfleura2 | # Where is Path.exe ?? |
| 40 | 1 | pfleura2 | # |
| 41 | 12 | pfleura2 | PathExe=~/Programs/optnpath/src/Path.exe |
| 42 | 1 | pfleura2 | # |
| 43 | 1 | pfleura2 | # Where is VASP ? |
| 44 | 1 | pfleura2 | # |
| 45 | 1 | pfleura2 | export VASPDIR=~/Programs/VASP |
| 46 | 1 | pfleura2 | export VASPEXEC=VASP4635_R410_STD |
| 47 | 1 | pfleura2 | # |
| 48 | 1 | pfleura2 | # Whre is mpirun ? |
| 49 | 1 | pfleura2 | # |
| 50 | 1 | pfleura2 | export MPIDIR=/softs/openmpi-1.4.1-intel/ |
| 51 | 1 | pfleura2 | export MPIRUN=$MPIDIR/bin/mpirun |
| 52 | 1 | pfleura2 | # |
| 53 | 1 | pfleura2 | # |
| 54 | 1 | pfleura2 | # Machine where the files are |
| 55 | 1 | pfleura2 | # |
| 56 | 1 | pfleura2 | RUNNINGMACHINE=r410comp1-pub |
| 57 | 1 | pfleura2 | |
| 58 | 1 | pfleura2 | # Some libraries... |
| 59 | 1 | pfleura2 | # |
| 60 | 1 | pfleura2 | #For intel 11.1.069 |
| 61 | 1 | pfleura2 | source /softs/intel/v11.1.069/bin/intel64/ifortvars_intel64.sh |
| 62 | 1 | pfleura2 | export LD_LIBRARY_PATH=/softs/fftw/2.1.5/ps-gb/lib:$LD_LIBRARY_PATH:/usr/lib |
| 63 | 1 | pfleura2 | 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 | 1 | pfleura2 | export LANG=C |
| 65 | 1 | pfleura2 | # |
| 66 | 1 | pfleura2 | #Usually nothing has to be changed after this line |
| 67 | 1 | pfleura2 | # |
| 68 | 1 | pfleura2 | ################################################# |
| 69 | 1 | pfleura2 | |
| 70 | 1 | pfleura2 | # |
| 71 | 1 | pfleura2 | # Machinefile |
| 72 | 1 | pfleura2 | # |
| 73 | 1 | pfleura2 | HOSTFILE=$TMPDIR/machines |
| 74 | 1 | pfleura2 | |
| 75 | 1 | pfleura2 | |
| 76 | 1 | pfleura2 | ################################# |
| 77 | 1 | pfleura2 | # |
| 78 | 1 | pfleura2 | #! we create the 00, 01... and 0x directorires |
| 79 | 1 | pfleura2 | # First we get the number of images in the INCAR file: |
| 80 | 1 | pfleura2 | NbIm=`grep -i IMAGES INCAR | awk -F"=" '{n=$2*1+1; print n}' `
|
| 81 | 1 | pfleura2 | # |
| 82 | 1 | pfleura2 | # |
| 83 | 1 | pfleura2 | ################################# |
| 84 | 1 | pfleura2 | # |
| 85 | 1 | pfleura2 | # We go to the Work Directory |
| 86 | 1 | pfleura2 | cd $HOMEDIR |
| 87 | 1 | pfleura2 | |
| 88 | 1 | pfleura2 | # A small test to see if everything matches |
| 89 | 1 | pfleura2 | NbImP=` sed 's/,/^M/g' ${Job}.path | grep -i ngeomf | awk -F"=" '{n=$2*1-1; print n}' `
|
| 90 | 1 | pfleura2 | if [ $NbImP -ne $NbIm ]; then |
| 91 | 1 | pfleura2 | echo "WARNING WARNING WARNING WARNING WARNING WARNING" |
| 92 | 1 | pfleura2 | echo "IMAGES in INCAR and NGeomF in " ${Job}.path
|
| 93 | 1 | pfleura2 | echo "Do Not Match... problems might be expected..." |
| 94 | 1 | pfleura2 | echo "Check it !!!" |
| 95 | 1 | pfleura2 | echo "WARNING WARNING WARNING WARNING WARNING WARNING" |
| 96 | 1 | pfleura2 | fi |
| 97 | 1 | pfleura2 | |
| 98 | 1 | pfleura2 | if [ $NbIm -le 9 ]; then |
| 99 | 1 | pfleura2 | Pref="0" |
| 100 | 1 | pfleura2 | else |
| 101 | 1 | pfleura2 | Pref="" |
| 102 | 1 | pfleura2 | fi |
| 103 | 1 | pfleura2 | |
| 104 | 1 | pfleura2 | cp $HOSTFILE $HOMEDIR/tmp |
| 105 | 1 | pfleura2 | cp $PE_HOSTFILE $HOMEDIR/local_PE_HOSTFILE |
| 106 | 1 | pfleura2 | Master="`head -1 $HOSTFILE`" |
| 107 | 1 | pfleura2 | echo $Master > $HOMEDIR/Master |
| 108 | 1 | pfleura2 | |
| 109 | 1 | pfleura2 | FUniq=`which uniq` |
| 110 | 1 | pfleura2 | Uniq=${FUniq:-"sort -u"}
|
| 111 | 1 | pfleura2 | $Uniq $HOSTFILE > $HOMEDIR/machines_unique |
| 112 | 1 | pfleura2 | grep -v $Master $HOMEDIR/machines_unique > $HOMEDIR/machines_other |
| 113 | 1 | pfleura2 | |
| 114 | 1 | pfleura2 | |
| 115 | 1 | pfleura2 | #### We create the directories and copy files to other machines |
| 116 | 1 | pfleura2 | for server in `cat $HOMEDIR/machines_other` |
| 117 | 1 | pfleura2 | do |
| 118 | 1 | pfleura2 | #### We create the images directory on all nodes |
| 119 | 1 | pfleura2 | for n in `seq -w 0 $NbIm` |
| 120 | 1 | pfleura2 | do |
| 121 | 1 | pfleura2 | ndir=$Pref$n |
| 122 | 1 | pfleura2 | ssh $server mkdir -p ${SCRATCHDIR}/${ndir}
|
| 123 | 1 | pfleura2 | done |
| 124 | 1 | pfleura2 | |
| 125 | 1 | pfleura2 | #### we copy the Vasp executable to all nodes |
| 126 | 1 | pfleura2 | scp ${RUNNINGMACHINE}:${VASPDIR}/${VASPEXEC} $server:${SCRATCHDIR}/${VASPEXEC}
|
| 127 | 1 | pfleura2 | |
| 128 | 1 | pfleura2 | #### we copy the files to all nodes |
| 129 | 1 | pfleura2 | for FILE in INCAR KPOINTS POTCAR |
| 130 | 1 | pfleura2 | do |
| 131 | 1 | pfleura2 | scp $RUNNINGMACHINE:$HOMEDIR/$FILE $server:${SCRATCHDIR}/.
|
| 132 | 1 | pfleura2 | done |
| 133 | 1 | pfleura2 | |
| 134 | 1 | pfleura2 | done |
| 135 | 1 | pfleura2 | |
| 136 | 1 | pfleura2 | #### We create the directories and copy files on Master |
| 137 | 1 | pfleura2 | for n in `seq -w 0 $NbIm` |
| 138 | 1 | pfleura2 | do |
| 139 | 1 | pfleura2 | ndir=$Pref$n |
| 140 | 1 | pfleura2 | mkdir -p ${SCRATCHDIR}/${ndir}
|
| 141 | 1 | pfleura2 | mkdir -p ${HOMEDIR}/${ndir}
|
| 142 | 1 | pfleura2 | done |
| 143 | 1 | pfleura2 | |
| 144 | 1 | pfleura2 | #### we copy the Vasp executable to Scratch |
| 145 | 1 | pfleura2 | cp ${VASPDIR}/${VASPEXEC} ${SCRATCHDIR}/${VASPEXEC}
|
| 146 | 1 | pfleura2 | |
| 147 | 1 | pfleura2 | #### we copy the files to SCRATCHDIR |
| 148 | 1 | pfleura2 | for FILE in INCAR KPOINTS POTCAR |
| 149 | 1 | pfleura2 | do |
| 150 | 1 | pfleura2 | cp $HOMEDIR/$FILE ${SCRATCHDIR}/.
|
| 151 | 1 | pfleura2 | done |
| 152 | 1 | pfleura2 | |
| 153 | 1 | pfleura2 | |
| 154 | 1 | pfleura2 | # ########################### |
| 155 | 1 | pfleura2 | # |
| 156 | 1 | pfleura2 | # We create the 'VaspExe' file that Path will use to run the |
| 157 | 1 | pfleura2 | # actual VASP calculations of E and forces |
| 158 | 1 | pfleura2 | # |
| 159 | 1 | pfleura2 | ############################# |
| 160 | 1 | pfleura2 | # we test if we run on one machine (ie only Master or on many) |
| 161 | 1 | pfleura2 | NOther=`wc -l $HOMEDIR/machines_other | awk '{print $1}'`
|
| 162 | 1 | pfleura2 | if [ $NOther -ge 1 ]; then |
| 163 | 1 | pfleura2 | cat << EOF > ./RunVasp |
| 164 | 1 | pfleura2 | #!/bin/bash |
| 165 | 1 | pfleura2 | |
| 166 | 1 | pfleura2 | #set -x |
| 167 | 1 | pfleura2 | HOMEDIR=$HOMEDIR |
| 168 | 1 | pfleura2 | SCRATCHDIR=$SCRATCHDIR |
| 169 | 1 | pfleura2 | Pref=$Pref |
| 170 | 1 | pfleura2 | |
| 171 | 1 | pfleura2 | #### We copy files to other machines |
| 172 | 1 | pfleura2 | for server in \`cat \$HOMEDIR/machines_other\` |
| 173 | 1 | pfleura2 | do |
| 174 | 1 | pfleura2 | for n in \`seq -w 0 $NbIm\` |
| 175 | 1 | pfleura2 | do |
| 176 | 1 | pfleura2 | ndir="$Pref\$n" |
| 177 | 1 | pfleura2 | # we copy the POSCAR file |
| 178 | 1 | pfleura2 | scp \$HOMEDIR/\${ndir}/POSCAR \$server:\${SCRATCHDIR}/\${ndir}/.
|
| 179 | 1 | pfleura2 | done |
| 180 | 1 | pfleura2 | done |
| 181 | 1 | pfleura2 | |
| 182 | 1 | pfleura2 | #### We copy files on Master |
| 183 | 1 | pfleura2 | for n in \`seq -w 0 $NbIm\` |
| 184 | 1 | pfleura2 | do |
| 185 | 1 | pfleura2 | ndir="$Pref\$n" |
| 186 | 1 | pfleura2 | # we copy the POSCAR file |
| 187 | 1 | pfleura2 | cp \$HOMEDIR/\${ndir}/POSCAR \${SCRATCHDIR}/\${ndir}/.
|
| 188 | 1 | pfleura2 | done |
| 189 | 1 | pfleura2 | |
| 190 | 1 | pfleura2 | cd \$SCRATCHDIR |
| 191 | 1 | pfleura2 | |
| 192 | 1 | pfleura2 | $MPIRUN -v -prefix $MPIDIR -mca pls_rsh_agent "ssh" -mca btl openib,self -np $NSLOTS \${SCRATCHDIR}/${VASPEXEC} > \${SCRATCHDIR}/out
|
| 193 | 1 | pfleura2 | |
| 194 | 1 | pfleura2 | Iter=\`cat \$HOMEDIR/Path.iter\` |
| 195 | 1 | pfleura2 | RUNNEW=run\${Iter}
|
| 196 | 1 | pfleura2 | |
| 197 | 1 | pfleura2 | #### We copy files from other machines |
| 198 | 1 | pfleura2 | for server in \`cat \$HOMEDIR/machines_other\` |
| 199 | 1 | pfleura2 | do |
| 200 | 1 | pfleura2 | for n in \`seq -w 0 $NbIm\` |
| 201 | 1 | pfleura2 | do |
| 202 | 1 | pfleura2 | ndir="$Pref\$n" |
| 203 | 1 | pfleura2 | for FILE in OUTCAR POSCAR OSZICAR XDATCAR CONTCAR |
| 204 | 1 | pfleura2 | do |
| 205 | 1 | pfleura2 | scp \$server:\${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}
|
| 206 | 1 | pfleura2 | cp \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW} \$HOMEDIR/\$ndir/\${FILE}
|
| 207 | 1 | pfleura2 | done |
| 208 | 1 | pfleura2 | done |
| 209 | 1 | pfleura2 | done |
| 210 | 1 | pfleura2 | |
| 211 | 1 | pfleura2 | #### We copy files on Master |
| 212 | 1 | pfleura2 | for n in \`seq -w 0 $NbIm\` |
| 213 | 1 | pfleura2 | do |
| 214 | 1 | pfleura2 | ndir=$Pref\$n |
| 215 | 1 | pfleura2 | for FILE in OUTCAR POSCAR OSZICAR XDATCAR CONTCAR |
| 216 | 1 | pfleura2 | do |
| 217 | 1 | pfleura2 | cp \${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}
|
| 218 | 1 | pfleura2 | cp \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW} \$HOMEDIR/\$ndir/\${FILE}
|
| 219 | 1 | pfleura2 | done |
| 220 | 1 | pfleura2 | done |
| 221 | 1 | pfleura2 | |
| 222 | 1 | pfleura2 | cp \${SCRATCHDIR}/out \$HOMEDIR/out_\${RUNNEW}
|
| 223 | 1 | pfleura2 | |
| 224 | 1 | pfleura2 | let Iter=Iter+1 |
| 225 | 1 | pfleura2 | echo \$Iter > \$HOMEDIR/Path.iter |
| 226 | 1 | pfleura2 | |
| 227 | 1 | pfleura2 | cd \$HOMEDIR |
| 228 | 1 | pfleura2 | EOF |
| 229 | 1 | pfleura2 | else |
| 230 | 1 | pfleura2 | # We have only one node, so that everything is store on master |
| 231 | 1 | pfleura2 | cat << EOF > ./RunVasp |
| 232 | 1 | pfleura2 | #!/bin/bash |
| 233 | 1 | pfleura2 | |
| 234 | 1 | pfleura2 | #set -x |
| 235 | 1 | pfleura2 | |
| 236 | 1 | pfleura2 | HOMEDIR=$HOMEDIR |
| 237 | 1 | pfleura2 | SCRATCHDIR=$SCRATCHDIR |
| 238 | 1 | pfleura2 | Pref=$Pref |
| 239 | 1 | pfleura2 | |
| 240 | 1 | pfleura2 | cd \$SCRATCHDIR |
| 241 | 1 | pfleura2 | # We copy files from HOMEDIR to SCRATCHDIR |
| 242 | 1 | pfleura2 | for n in \`seq -w 0 $NbIm\` |
| 243 | 1 | pfleura2 | do |
| 244 | 1 | pfleura2 | ndir=$Pref\$n |
| 245 | 1 | pfleura2 | cp \$HOMEDIR/\$ndir/POSCAR \${SCRATCHDIR}/\$ndir/POSCAR
|
| 246 | 1 | pfleura2 | done |
| 247 | 1 | pfleura2 | |
| 248 | 1 | pfleura2 | $MPIRUN -v -prefix $MPIDIR -mca pls_rsh_agent "ssh" -mca btl openib,self -np $NSLOTS \${SCRATCHDIR}/${VASPEXEC} > \${SCRATCHDIR}/out
|
| 249 | 1 | pfleura2 | |
| 250 | 1 | pfleura2 | Iter=\`cat \$HOMEDIR/Path.iter\` |
| 251 | 1 | pfleura2 | RUNNEW=run\${Iter}
|
| 252 | 1 | pfleura2 | |
| 253 | 1 | pfleura2 | |
| 254 | 1 | pfleura2 | for n in \`seq -w 0 $NbIm\` |
| 255 | 1 | pfleura2 | do |
| 256 | 1 | pfleura2 | ndir=$Pref\$n |
| 257 | 1 | pfleura2 | for FILE in OUTCAR POSCAR OSZICAR XDATCAR CONTCAR |
| 258 | 1 | pfleura2 | do |
| 259 | 1 | pfleura2 | cp \${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}_\${RUNNEW}
|
| 260 | 1 | pfleura2 | cp \${SCRATCHDIR}/\$ndir/\$FILE \$HOMEDIR/\$ndir/\${FILE}
|
| 261 | 1 | pfleura2 | done |
| 262 | 1 | pfleura2 | done |
| 263 | 1 | pfleura2 | cp \${SCRATCHDIR}/out \$HOMEDIR/out_\${RUNNEW}
|
| 264 | 1 | pfleura2 | |
| 265 | 1 | pfleura2 | let Iter=Iter+1 |
| 266 | 1 | pfleura2 | echo \$Iter > \$HOMEDIR/Path.iter |
| 267 | 1 | pfleura2 | |
| 268 | 1 | pfleura2 | cd \$HOMEDIR |
| 269 | 1 | pfleura2 | EOF |
| 270 | 1 | pfleura2 | fi |
| 271 | 1 | pfleura2 | chmod u+x ./RunVasp |
| 272 | 1 | pfleura2 | |
| 273 | 1 | pfleura2 | ############################### |
| 274 | 1 | pfleura2 | # |
| 275 | 1 | pfleura2 | # We launch PATH |
| 276 | 1 | pfleura2 | # |
| 277 | 1 | pfleura2 | ############################### |
| 278 | 1 | pfleura2 | ln -fs ${PathExe} .
|
| 279 | 1 | pfleura2 | |
| 280 | 1 | pfleura2 | ./Path.exe ${Job}.path > ${Job}.out 2> ${Job}.err
|
| 281 | 1 | pfleura2 | |
| 282 | 1 | pfleura2 | #### We delete SCRATCHDIR on all machines |
| 283 | 1 | pfleura2 | for server in `cat $HOMEDIR/machines_other` |
| 284 | 1 | pfleura2 | do |
| 285 | 1 | pfleura2 | ssh $server rm -rf ${SCRATCHDIR}
|
| 286 | 1 | pfleura2 | done |
| 287 | 1 | pfleura2 | |
| 288 | 12 | pfleura2 | rm -rf ${SCRATCHDIR} |