#!/bin/csh if ( ! -e ~/.ezvasp.rc ) then cat - >! ~/.ezvasp.rc <! vaspin.tmp getlines -jaf "\[[Ii][Nn][Cc]" < vaspin.tmp | getlines -jbf "\\[" | grep -v '^[ ]*$' | \ grep -v -i -e subatom -e magatom -e kppra -e kscheme -e dostat -e dogga -e usepot -e 'istart[ ]*=[ ]*2' >! INCAR grep -i subatom vaspin.tmp | sed 's/.*=//g' >! sed.tmp (getlines -jaf "\[[Pp][Oo][Ss]" < vaspin.tmp | getlines -jbf "\\[") | grep -v '^[ ]*$' >! preposcar.tmp cat preposcar.tmp | sed -f sed.tmp >! poscar.tmp cat preposcar.tmp | tail -n +7 | awk '{print $4}' >! atomlabel.tmp1 cat preposcar.tmp | tail -n +7 | awk '{print $4}' | sed -f sed.tmp >! atomlabel.tmp2 paste atomlabel.tmp2 atomlabel.tmp1 | sort -k 1,1 -s | awk '{n=split($0,a); print a[n]}' >! atomlabel.tmp tail -n +3 poscar.tmp | head -3 >! oldcell.tmp set posmode=`head -6 poscar.tmp | tail -n -1` tail -n +7 poscar.tmp | awk '{print $5,$6,$7}' | grep -q '[TF]' if ( $status == 0 ) then set seldyn endif if ($?latvectpatch) then cat oldcell.tmp | fixcell -c >! newcell.tmp cp -f newcell.tmp cell.tmp else cp -f oldcell.tmp newcell.tmp cp -f oldcell.tmp cell.tmp endif tail -n +6 poscar.tmp | head -1 | grep -q -i '^d' if ($status == 0 && $?latvectpatch) then tail -n +7 poscar.tmp | \ awk 'BEGIN {for (i=1; i<=3; i++) {getline < "oldcell.tmp"; a[1,i]=$1; a[2,i]=$2; a[3,i]=$3; }} \ {c[1]=0; c[2]=0; c[3]=0; b[1]=$1; b[2]=$2; b[3]=$3; \ for (i=1; i<=3; i++) { \ for (j=1; j<=3; j++) {c[i]=c[i]+a[i,j]*b[j]} \ } \ print $4,c[1],c[2],c[3],$5,$6,$7}' | sort -k 1,1 -s >! vacpos.tmp set posmode=Cartesian else tail -n +7 poscar.tmp | awk '{print $4,$1,$2,$3,$5,$6,$7}' | sort -k 1,1 -s >! vacpos.tmp endif grep -v Va vacpos.tmp >! pos.tmp #grep -v Vac vacpos.tmp >! pos.tmp awk '{nb_atom[$1]++} END {for (atom in nb_atom) {print atom,nb_atom[atom]}}' pos.tmp | sort -k 1,1 -s >! atom.tmp ( head -2 poscar.tmp ; \ cat cell.tmp ; \ echo `awk '{print $2}' atom.tmp` ; \ if ($?seldyn) echo Selective Dynamics ; \ echo $posmode ; \ awk '{print $2,$3,$4,$5,$6,$7,$1}' pos.tmp \ ) >! POSCAR grep -q -i dostat vaspin.tmp if ($status == 0) then set dostatic endif grep -q -i kppra vaspin.tmp if ($status == 0) then grep -q -i 'kppra *= *updir' vaspin.tmp if ($status == 0) then cp -f ../KPOINTS . else grep -q -i kscheme vaspin.tmp if ($status == 0) then set kscheme=`grep -i kscheme vaspin.tmp | sed 's/^.*=[ ]*//g'` else set kscheme="Gamma" endif ( echo KPOINTS file ; echo 0 ; echo $kscheme ) >! KPOINTS echo $kscheme | grep -q "^[Mm]" if ( $status == 0 ) then ( echo `grep -i kppra vaspin.tmp | sed 's/^.*=//g'` `cat vacpos.tmp | wc -l` | awk '{print $1/$2}' ; cat cell.tmp ) | kmesh -q -e >>! KPOINTS else ( echo `grep -i kppra vaspin.tmp | sed 's/^.*=//g'` `cat vacpos.tmp | wc -l` | awk '{print $1/$2}' ; cat cell.tmp ) | kmesh -q -r >>! KPOINTS endif echo 0 0 0 >>! KPOINTS endif else (getlines -jaf "\[[Kk][Pp][Oo]" < vaspin.tmp | getlines -jbf "\\[") | grep -v '^[ ]*$' >! KPOINTS endif grep -q -i dogga vaspin.tmp if ($status == 0) then set POTPATH="$POTGGA" else set POTPATH="$POTLDA" endif grep -q -i usepot vaspin.tmp if ($status == 0) then echo set POTPATH=\$POT`grep -i usepot vaspin.tmp | tail -n -1 | sed -e 's/ *[^ =]*[ =]//g' -e 's/ *$//g'` > tmpez.sh source tmpez.sh rm -f tmpez.sh endif echo -n >! POTCAR foreach element ( `sed 's/[+-].*$//g' atom.tmp | awk '{print $1}'` ) if ( -e $POTPATH/$element/POTCAR ) then cat $POTPATH/$element/POTCAR >>! POTCAR else zcat $POTPATH/$element/POTCAR.Z >>! POTCAR endif if ( $status == 1 ) then echo Cannot read $POTPATH/$element/POTCAR\* exit 1 endif end awk '{print $1}' pos.tmp | sed 's/^[^-+]*//g' | awk '{print $1+0}' >! moment.tmp grep -q -i '[1-9]' moment.tmp if ( $status == 0 ) then echo "ISPIN= 2" >>! INCAR echo "MAGMOM= " `cat moment.tmp` >>! INCAR endif grep -q -i 'ISTART[ ]*=[ ]*2' vaspin.tmp if ($status == 0) then if ( ( -e OUTCAR || -e CHGCAR ) && -e WAVECAR ) then echo ISTART=1 >>! INCAR if ( -e OUTCAR ) then grep "dimension x,y,z NGX =" OUTCAR | head -n -1 | sed -e 's/ dimension x,y,z //g' -e 's/ NG/\nNG/g' >>! INCAR else getlines -jaf '^ *$' < CHGCAR | head -n 1 | awk '{print "NGX = " $1; print "NGY = " $2; print "NGZ = " $3}' >>! INCAR endif else echo ISTART=0 >>! INCAR endif endif if (! $?debug ) then rm -f sed.tmp cell.tmp oldcell.tmp newcell.tmp pos.tmp vacpos.tmp atom.tmp poscar.tmp moment.tmp cell.log atomlabel.tmp1 atomlabel.tmp2 preposcar.tmp vaspin.tmp >& /dev/null endif if (! $?norun ) then echo | $VASPCMD >&! vasp.out grep -q 'VERY BAD NEWS! internal error in subroutine IBZKPT' vasp.out if ( $status == 0 ) then cp INCAR INCAR.tmp ( grep -v SYMPREC INCAR.tmp ; echo SYMPREC = 1e-7 ) >! INCAR echo | $VASPCMD >&! vasp.out rm -f INCAR.tmp endif if ($?dostatic) then foreach file (INCAR POSCAR OSZICAR OUTCAR CONTCAR KPOINTS vasp.out) cp -f $file ${file}.relax end cp -f CONTCAR POSCAR cat INCAR.relax | \ grep -v -i ismear | \ grep -v -i isigma | \ grep -v -i nsw | \ grep -v -i ibrion | \ grep -v -i isif >! INCAR echo ISMEAR=-5 >>! INCAR echo IBRION=-1 >>! INCAR echo ISIF=2 >>! INCAR echo | $VASPCMD >&! vasp.out endif foreach file (INCAR POSCAR OSZICAR OUTCAR CONTCAR KPOINTS vasp.out DOSCAR) cp -f $file ${file}.static end endif