<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Seventh Sense &#187; VASP</title>
	<atom:link href="http://sgowtham.net/blog/category/technology/vasp/feed/" rel="self" type="application/rss+xml" />
	<link>http://sgowtham.net/blog</link>
	<description>Rambling about life&#039;s little things, in 7 ≡ 1 (mod 6) fashion</description>
	<lastBuildDate>Tue, 28 Feb 2012 23:25:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
	<title>Seventh Sense</title>
	<url>http://sgowtham.net/images/sg_logo_rss.png</url>
	<link>http://sgowtham.net/blog</link>
	<width>32</width>
	<height>32</height>
	</image>
		<item>
		<title>BASH &#8211; vasp2xyz, A Script To Extract Coordinates From VASP</title>
		<link>http://sgowtham.net/blog/2009/12/22/bash-vasp2xyz-a-script-to-extract-coordinates-from-vasp/</link>
		<comments>http://sgowtham.net/blog/2009/12/22/bash-vasp2xyz-a-script-to-extract-coordinates-from-vasp/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 22:00:54 +0000</pubDate>
		<dc:creator>Gowtham</dc:creator>
				<category><![CDATA[AWK]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[VASP]]></category>

		<guid isPermaLink="false">http://sgowtham.net/blog/?p=2547</guid>
		<description><![CDATA[Users of VASP are often familiar with the struggles/hardships to easily visualize the coordinates from the output file [OUTCAR]. To that effect, I wrote the following script [with help at a crucial stage from Pat Krogel, CEC @ MTU]. It expects OUTCAR &#038; POSCAR from a calculation to be in the same folder and when [...]]]></description>
			<content:encoded><![CDATA[<p>Users of <a href="http://cms.mpi.univie.ac.at/vasp/" target="_blank">VASP</a> are often familiar with the struggles/hardships to <em>easily</em> visualize the coordinates from the output file [<strong>OUTCAR</strong>]. To that effect, I wrote the following script [with help at a crucial stage from Pat Krogel, <a href="http://www.cec.mtu.edu"/ target="_blank">CEC</a> @ MTU]. It expects <strong>OUTCAR</strong> &#038; <strong>POSCAR</strong> from a calculation to be in the same folder and when successfully completed, it results in <strong>OUTPUT_FILENAME.xyz</strong> &#8211; containing frame-by-frame [corresponding to each (optimization) step] XYZ co-ordinates of the system.</p>
<p><br clear="all"></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Script to extract the atomic positions (xyz) from </span>
<span style="color: #666666; font-style: italic;"># POSCAR &amp; OUTCAR files of VASP and write them to a </span>
<span style="color: #666666; font-style: italic;"># file, to be used with Jmol, MolDen and such other</span>
<span style="color: #666666; font-style: italic;"># third party programs</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># First written: Gowtham, Tue, 22 Dec 2009 11:11:12 -0500</span>
<span style="color: #666666; font-style: italic;"># Last modified: Gowtham, Tue, 22 Dec 2009 16:29:36 -0500</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Essential VASP Files</span>
<span style="color: #666666; font-style: italic;"># If missing, quit the program</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">POSCAR</span>=<span style="color: #ff0000;">&quot;POSCAR&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">OUTCAR</span>=<span style="color: #ff0000;">&quot;OUTCAR&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$POSCAR</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$OUTCAR</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  <span style="color: #007800;">$POSCAR</span> &amp; <span style="color: #007800;">$OUTCAR</span> found&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  ERROR : POSCAR &amp;/or OUTCAR missing&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Output Filename </span>
<span style="color: #666666; font-style: italic;"># If missing, quit the program</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">OUTPUT</span>=<span style="color: #007800;">$1</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  ERROR : OUTPUT_FILENAME Missing&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  Usage : vasp2xyz.sh OUTPUT_FILENAME&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Delete scratch files</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> Final.tmp.<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$OUTPUT</span>.xyz
&nbsp;
<span style="color: #666666; font-style: italic;"># Atoms related information</span>
<span style="color: #666666; font-style: italic;"># Extracted from POSCAR &amp; OUTCAR</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Total number of atom types</span>
<span style="color: #666666; font-style: italic;"># Pat Krogel: Tue, 22 Dec 2009 13:13:48 -050</span>
<span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-a</span> <span style="color: #007800;">ATOM_TYPE</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">'6 p'</span> <span style="color: #007800;">$POSCAR</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ATOM_TYPE_TOTAL</span>=<span style="color: #800000;">${#ATOM_TYPE[@]}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Total number of atoms</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ATOMS_TOTAL</span>=<span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #660033;">-lt</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ATOM_TYPE_TOTAL</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">iATOM_TYPE</span>=<span style="color: #800000;">${ATOM_TYPE[$i]}</span>
  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ATOMS_TOTAL</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$ATOMS_TOTAL</span> + <span style="color: #007800;">$iATOM_TYPE</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">i</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$i</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Atom labels</span>
<span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-a</span> <span style="color: #007800;">ATOM_LABEL</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;POTCAR:&quot;</span> <span style="color: #007800;">$OUTCAR</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> -<span style="color: #007800;">$ATOM_TYPE_TOTAL</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/_.*//g'</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ATOM_LABEL_TOTAL</span>=<span style="color: #800000;">${#ATOM_LABEL[@]}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Print2Screen</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ATOM_TYPE_TOTAL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ATOM_LABEL_TOTAL</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  ERROR : Atom Type Total (<span style="color: #007800;">$ATOM_TYPE_TOTAL</span>) does NOT&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;          match Atom Label Count (<span style="color: #007800;">$ATOM_LABEL_COUNT</span>)&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  Please make sure OUTCAR &amp; POSCAR are from the same&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  system and calculation&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> 
  <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  Number of Atom Types   :&quot;</span> <span style="color: #007800;">$ATOM_TYPE_TOTAL</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  Atom Type              :&quot;</span> <span style="color: #800000;">${ATOM_LABEL[@]}</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  Atom Type Count        :&quot;</span> <span style="color: #800000;">${ATOM_TYPE[@]}</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  Total Number of Atoms  :&quot;</span> <span style="color: #007800;">$ATOMS_TOTAL</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># ATOM_LABEL_2 is an array of atom labels</span>
  <span style="color: #666666; font-style: italic;"># with each atom label appearing an appropriate</span>
  <span style="color: #666666; font-style: italic;"># number of times, to a total of $ATOMS_TOTAL</span>
  <span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-a</span> ATOM_LABEL_2
  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">REPEAT</span>=<span style="color: #000000;">0</span>
  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">j</span>=<span style="color: #000000;">0</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$j</span>&quot;</span> <span style="color: #660033;">-lt</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ATOM_TYPE_TOTAL</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; 
  <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">k</span>=<span style="color: #000000;">1</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$k</span>&quot;</span> <span style="color: #660033;">-le</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${ATOM_TYPE[$j]}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; 
    <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">REPEAT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$REPEAT</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
      <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">k</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$k</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
      ATOM_LABEL_2<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$REPEAT</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #800000;">${ATOM_LABEL[$j]}</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">j</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$j</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #666666; font-style: italic;"># echo ${ATOM_LABEL_2[@]}</span>
<span style="color: #666666; font-style: italic;"># echo ${#ATOM_LABEL_2[@]}</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Record the line numbers where coordinates are written</span>
  <span style="color: #666666; font-style: italic;"># in OUTCAR. Actual coordinates begin 2 lines below</span>
  <span style="color: #666666; font-style: italic;"># the recorded numbers</span>
  <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;POSITION&quot;</span> <span style="color: #007800;">$OUTCAR</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/:/ /g'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/POSITION.*//g'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> LINE_NUMBERS.tmp
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">FRAME_NUMBER</span>=<span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> START
  <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">START_HERE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$START</span> + <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">END_HERE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$START_HERE</span> + <span style="color: #007800;">$ATOMS_TOTAL</span> - <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ATOMS_TOTAL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$OUTPUT</span>.xyz
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;# Frame Number: <span style="color: #007800;">$FRAME_NUMBER</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$OUTPUT</span>.xyz
    <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$START_HERE</span>,<span style="color: #007800;">$END_HERE</span> p&quot;</span> <span style="color: #007800;">$OUTCAR</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{printf &quot;%12.8f %12.8f %12.8f\n&quot;, $1, $2, $3}'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> Final.tmp.<span style="color: #007800;">$FRAME_NUMBER</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">l</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> X Y Z
    <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${ATOM_LABEL_2[$l]}</span> <span style="color: #007800;">$X</span> <span style="color: #007800;">$Y</span> <span style="color: #007800;">$Z</span> <span style="color: #000000; font-weight: bold;">&gt;</span> Final.tmp.<span style="color: #007800;">$FRAME_NUMBER</span>.<span style="color: #007800;">$l</span>
      <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ printf &quot;%-3s %12.8f %12.8f %12.8f\n&quot;, $1, $2, $3, $4 }'</span> Final.tmp.<span style="color: #007800;">$FRAME_NUMBER</span>.<span style="color: #007800;">$l</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$OUTPUT</span>.xyz
      <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">l</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$l</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">done</span><span style="color: #000000; font-weight: bold;">&lt;</span>Final.tmp.<span style="color: #007800;">$FRAME_NUMBER</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">FRAME_NUMBER</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$FRAME_NUMBER</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #000000; font-weight: bold;">done</span><span style="color: #000000; font-weight: bold;">&lt;</span>LINE_NUMBERS.tmp
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">FRAMES_TOTAL</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$FRAME_NUMBER</span> - <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  Total Number of Frames :&quot;</span> <span style="color: #007800;">$FRAMES_TOTAL</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Delete scratch files</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> LINE_NUMBERS.tmp 
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> Final.tmp.<span style="color: #000000; font-weight: bold;">*</span></pre></td></tr></table></div>

<p><br clear="all"></p>
<h3 class="blog">Test Case</h3>
<p>If POSCAR and OUTCAR aren&#8217;t handily available for testing, one could download the following:</p>
<p align="center"><a href="http://sgowtham.net/blog/files/20091222/POSCAR" target="_blank">POSCAR</a> | <a href="http://sgowtham.net/blog/files/20091222/OUTCAR" target="_blank">OUTCAR</a></p>
<p><br clear="all"><br />
<img class="framed" src="http://sgowtham.net/blog/files/20091222/vasp2xyz_00.png" title="vasp2xyz" alt="vasp2xyz" border="0">
<p class="bpcaption">Running vasp2xyz.sh</p>
<p><br clear="all"><br />
<img class="framed" src="http://sgowtham.net/blog/files/20091222/vasp2xyz_01.png" title="vasp2xyz" alt="vasp2xyz" border="0">
<p class="bpcaption">Resulting xyz file</p>
<p><br clear="all"><br />
<img class="framed" src="http://sgowtham.net/blog/files/20091222/ONCH.png" title="vasp2xyz" alt="vasp2xyz" border="0">
<p class="bpcaption">xyz file visualized with Jmol</p>
<p><br clear="all"><br />
If you have suggestions to make this better/efficient, please do post them as comments.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsgowtham.net%2Fblog%2F2009%2F12%2F22%2Fbash-vasp2xyz-a-script-to-extract-coordinates-from-vasp%2F&amp;title=BASH%20%26%238211%3B%20vasp2xyz%2C%20A%20Script%20To%20Extract%20Coordinates%20From%20VASP" id="wpa2a_2"><img src="http://sgowtham.net/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sgowtham.net/blog/2009/12/22/bash-vasp2xyz-a-script-to-extract-coordinates-from-vasp/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>SIESTA, SMEAGOL, VASP &#8230; BlueGene/L</title>
		<link>http://sgowtham.net/blog/2007/05/11/siesta-smeagol-vasp-bluegenel/</link>
		<comments>http://sgowtham.net/blog/2007/05/11/siesta-smeagol-vasp-bluegenel/#comments</comments>
		<pubDate>Fri, 11 May 2007 16:15:47 +0000</pubDate>
		<dc:creator>Gowtham</dc:creator>
				<category><![CDATA[BlueGene]]></category>
		<category><![CDATA[SIESTA]]></category>
		<category><![CDATA[SMEAGOL]]></category>
		<category><![CDATA[VASP]]></category>

		<guid isPermaLink="false">http://sgowtham.net/blog/2007/05/11/siesta-smeagol-vasp-bluegenel/</guid>
		<description><![CDATA[Well, some of you have been regular readers (and commentors) for my ramblings in this part of the e-world and such of those have known that I have been in Europe &#8211; J&#252;lich, Germany &#8211; to be precise. However, while chatting with few of my friends, I noticed an incoherent idea as to why yours-truly [...]]]></description>
			<content:encoded><![CDATA[<p>Well, some of you have been regular readers (and commentors) for my ramblings in this part of the e-world and such of those have known that I have been in Europe &#8211; J&uuml;lich, Germany &#8211; to be precise. However, while chatting with few of my friends, I noticed an incoherent idea as to why yours-truly is in Germany any way&#8230; Some thought I was here on a pleasure trip/vacation, some others thought I had too much money and free time to burn, some more thought I was here for a photographic expedition, while only few have known the real reason&#8230;</p>
<p>We (as in our <a href="http://www.phy.mtu.edu/pandey/" target="_blank">research group</a> at Michigan Tech) have had a trial account on <a href="http://jumpdoc.fz-juelich.de/" target="_blank">JUMP</a> and <a href="http://www.fz-juelich.de/zam/ibm-bgl/" target="_blank">JUBL</a> in <a href="http://www.fz-juelich.de/nic/" target="_blank">Jon von Neumann Institute of Computing</a>, J&uuml;lich. But not having enough success, at least until recently, to get <a href="http://sgowtham.net/blog/2007/04/15/mpi-smeagol-work/" target="_blank">SIESTA/SMEAGOL compiled/running</a> on our own <a href="http://rama.phy.mtu.edu/" target="_blank">beowulf linux cluster</a> prevented me from pursuing similar attempts on JUMP/JUBL. Also, my inability to understand, let alone solve, the error messages spit out during many a futile attempts (on JUMP) didn&#8217;t really help much and neither did the 6 hour time difference between Houghton and J&uuml;lich.</p>
<p>Work week at the NIC/CBB got off to a most unlikely of starts, but a very pleasant one indeed &#8211; <em>Champagne Party</em>!! I don&#8217;t recall any meeting, let alone the first thing on a Monday morning, to begin with sipping Champagne. This party was in celebration of CBSB 07 success but like every such meeting, it also did a detailed post-mortem of the workshop itself &#8211; what went right, what went wrong, what was done better compared to previous edition, what could be done better in subsequent editions, possible locations for CBSB 08 &#8230; and so on.  </p>
<p>Much of my <a href="http://sgowtham.net/schedule/week.php?cal=ResSchool&#038;getdate=20070513" target="_blank">working time</a> at NIC/CBB was spent in making many parts of the source code <a href="http://www-128.ibm.com/developerworks/library/pa-nldec04-xlcompilers/" target="_blank">XL Compilers</a> compliant and fortunately enough, SMEAGOL compiled and test runs successfully finished on JUBL around 4:58pm Friday! Otherwise, weekend ahead would have been really loooong and so would have been the return journey.  A successful compilation/execution of SMEAGOL implicitly implies the same about SIESTA and as an added bonus, one other group that successfully compiled and tested VASP on JUBL sent us the <em>Makefile</em> (and are willing to help us more, if need be) <img src='http://sgowtham.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><br clear="all"><br />
<img class="framed" src="http://sgowtham.net/blog/files/20070511/JUMP_TestJob_0.png" title="SIESTA, SMEAGOL, VASP ... BlueGene/L" alt="SIESTA, SMEAGOL, VASP ... BlueGene/L" border="0"></p>
<p class="bpcaption">Our test calculation running on JUMP</p>
<p><br clear="all"><br />
<img class="framed" src="http://sgowtham.net/blog/files/20070511/JUBL_0.jpg" title="SIESTA, SMEAGOL, VASP ... BlueGene/L" alt="SIESTA, SMEAGOL, VASP ... BlueGene/L" border="0"></p>
<p class="bpcaption">JUBL &#8211; 8 racks of IBM BlueGene/L</p>
<p><br clear="all"><br />
Working and discussing things with Jan as well as almost every member of the NIC/CBB group (discussions weren&#8217;t always about computers and/or sciences) has taught me many things: I think I know a bit more about IBM <a href="http://en.wikipedia.org/wiki/Blue_Gene" target="_blank">BlueGene</a>; understand the term <em>compiler strictness</em> (I had very little or no such understanding when Dr. Roberto Orlando had mentioned it a in <a href="http://sgowtham.net/blog/2006/09/22/paparazzi-ascs-06/" target="_blank">ASCS workshop</a>); understand the compile-time error messages better and know how to fix some of them at least. Probably the most important lesson of all was the following: </p>
<blockquote><p>Hope (that things will somehow work out for good) &#8211; when combined with patience, perseverance and practice &#8211; is a really good thing</p></blockquote>
<p><br clear="all"><br />
PS: If you/your group have an access to BlueGene/L at J&uuml;lich or elsewhere and are trying to get these programs working, do not hesitate to contact for Makefile tips, source code editions, etc. You may just post your question as a comment in the form below and I will respond at my earliest.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsgowtham.net%2Fblog%2F2007%2F05%2F11%2Fsiesta-smeagol-vasp-bluegenel%2F&amp;title=SIESTA%2C%20SMEAGOL%2C%20VASP%20%26%238230%3B%20BlueGene%2FL" id="wpa2a_4"><img src="http://sgowtham.net/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sgowtham.net/blog/2007/05/11/siesta-smeagol-vasp-bluegenel/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>SIESTA &amp; Global Warming</title>
		<link>http://sgowtham.net/blog/2007/01/16/siesta-global-warming/</link>
		<comments>http://sgowtham.net/blog/2007/01/16/siesta-global-warming/#comments</comments>
		<pubDate>Wed, 17 Jan 2007 01:18:39 +0000</pubDate>
		<dc:creator>Gowtham</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[SIESTA]]></category>
		<category><![CDATA[VASP]]></category>

		<guid isPermaLink="false">http://sgowtham.net/blog/2007/01/16/siesta-global-warming/</guid>
		<description><![CDATA[I knew this would catch your attention &#8211; before you come out all the way to Houghton to kill me, give me a fair chance to explain: I will start out with describing the title. SIESTA is not what you generally know it as &#8211; but it&#8217;s an acronym for Spanish Initiative for Electronic Simulations [...]]]></description>
			<content:encoded><![CDATA[<p>I knew this would catch your attention &#8211; before you come out all the way to Houghton to kill me, give me a fair chance to explain: I will start out with describing the title. <em>SIESTA</em> is not what you generally know it as &#8211; but it&#8217;s an acronym for <em>Spanish Initiative for Electronic Simulations  with Thousands of Atoms</em>. But users around the globe have come to the conclusion that when they do use this <a href="http://www.uam.es/departamentos/ciencias/fismateriac/siesta/" target="_blank">SIESTA</a>, they get enough time for a <a href="http://en.wikipedia.org/wiki/Siesta" target="_blank">SIESTA</a>! Now that we are clear about the first part of the title, let me go on to the second part. <em>Global Warming</em> &#8211; no hidden definitions or anything like that here. It is what you know it is &#8211; <a href="http://en.wikipedia.org/wiki/Global_warming" target="_blank">Global Warming</a>.</p>
<p>Now, <em>how are these two related to each other</em>, you ask? Ever since changing majors from pure Physics to Engineering Physics, Santa (yeah, the Santa) has been bringing me a wonderful Christmas gift &#8211; a gift of a unique kind that nerds and geeks would understand and appreciate. Last year, in 2005 December, it was the solution to the bugging problem of <a href="http://sgowtham.net/blog/2005/12/22/good-news-atlast/" target="_blank">VASP compilation</a>. And since then, I have been a <em>good</em> person, tried to stay away from troubles and such blah blah blah&#8230; For the past few months, I have been attempting to compile two programs &#8211; SIESTA being one of them. And this time, for Christmas, Santa (yeah, the same Santa) completely forgot about my gift (solution to the bugging compilation/run time errors associated with SIESTA) &#8211; or so I thought.</p>
<p>Three weeks after Christmas and two weeks into the New Year, all of a sudden Santa stops by to deliver my gift! I finally get some workable solution to the problem &#8211; the one that&#8217;s been bugging me for over two months. And if you have been a regular reader of these entries, you would have read it <a href="http://sgowtham.net/blog/2006/12/23/lost-in-compilation/" target="_blank">here</a>. Santa not only gave me my gift but also explained as to why I was the last person on his list. And therein lies the <em>relation between global warming and SIESTA</em>! According to Santa&#8217;s usual gift-distributing route, he starts from North pole, goes down to South pole via Houghton and returns back to North pole via Denver. But this time around, Houghton did not receive its usual share of snow by Christmas (global warming &#8211; makes sense?) thus forcing Santa to reverse his route. He went to South pole via Denver (they got all the snow in Christmas; global warming again &#8211; makes more sense?) and stopped in Houghton on his way back to North pole&#8230; We have been getting some snow off late and Lake Superior has started to freeze &#8211; at least near the shores&#8230;</p>
<p><img class="framed" src="http://sgowtham.net/blog/files/20070116/dsc_7185.jpg" title="Freezing Superior Shores" alt="Freezing Superior Shores" border="0"></p>
<p class="bpcaption">Freezing Lake Superior Shores near Baraga, MI</p>
<p><img class="framed" src="http://sgowtham.net/blog/files/20070116/dsc_7190.jpg" title="Freezing Superior Shores" alt="Freezing Superior Shores" border="0"></p>
<p class="bpcaption">Freezing Lake Superior Shores near Baraga, MI</p>
<p>Well, Santa did his part and so did /me &#8211; I have spent countably infinite hours and attempts to compile these programs and quite many people (around the globe) have helped in this regard &#8211; some directly and some indirectly. Though the problem still has some unexplicable inconsistency when it comes to running on multiple processors, what helped the most were the ones shown in the picture below &#8211; a lot of them too:</p>
<p><img class="framed" src="http://sgowtham.net/blog/files/20070116/dsc_7207.jpg" title="Coffee, Chai and Beer -- Catalysts in Compilation" alt="Coffee, Chai and Beer -- Catalysts in Compilation" border="0"></p>
<p class="bpcaption">Coffee, Chai and Beer &#8212; Catalysts in Compilation</p>
<p>Well, it is here that my semi-treatise on the relation between SIESTA and Global Warming ends &#8211; if you haven&#8217;t realized that the latter is affecting your lifestyle, aspirations, compilations, and such &#8211; be warned &#8211; you have been living in your own damned sweet little universe. It&#8217;s about time to wake up and do something about it &#8211; so that I get my Christmas gifts on time <img src='http://sgowtham.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsgowtham.net%2Fblog%2F2007%2F01%2F16%2Fsiesta-global-warming%2F&amp;title=SIESTA%20%26amp%3B%20Global%20Warming" id="wpa2a_6"><img src="http://sgowtham.net/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sgowtham.net/blog/2007/01/16/siesta-global-warming/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>VASP, MPICH, Intel Compilers And NPACI Rocks</title>
		<link>http://sgowtham.net/blog/2005/12/22/vasp-mpich-intel-compilers-and-npaci-rocks/</link>
		<comments>http://sgowtham.net/blog/2005/12/22/vasp-mpich-intel-compilers-and-npaci-rocks/#comments</comments>
		<pubDate>Thu, 22 Dec 2005 18:44:41 +0000</pubDate>
		<dc:creator>Gowtham</dc:creator>
				<category><![CDATA[MichiganTech]]></category>
		<category><![CDATA[MPI]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Rocks]]></category>
		<category><![CDATA[VASP]]></category>

		<guid isPermaLink="false">http://sgowtham.net/blog/?p=6</guid>
		<description><![CDATA[Much of the weekend was spent in some relaxation, shoveling snow (I have come to realize that this is a very good exercise &#8211; it can make one sweat even when it’s 10 F outside!) and trying to debug the errors associated with execution of parallel version of VASP 4.6.28. However, same errors persisted and [...]]]></description>
			<content:encoded><![CDATA[<p>Much of the weekend was spent in some relaxation, shoveling snow (I have come to realize that this is a very good exercise &#8211; it can make one sweat even when it’s 10 F outside!) and trying to debug the errors associated with execution of parallel version of VASP 4.6.28. However, same errors persisted and I didn’t go too far ahead with it. </p>
<p>I got in touch with few of Intel’s authorized resellers (one in Bloomington, MN &#8211; who transferred the call to someone else in Boston, MA) to see if I can get a copy of version 8.x of FORTRAN and C compilers. Though the latter person promised to get back to me with some favorable information soon, I got directly in touch with an Intel Support Technician &#8211; hoping that he/she wouldn’t be from a call center in some <em>other</em> country. Fortunately, it was somebody in California and unfortunately, he redirected me back to their re-sellers. Last call, pretty much out of desperation, did what I wanted : I just had to register the non-commercially downloaded products for <em>Premier Support</em> and I would be entitled for previous versions too. If only Intel explicitly mentioned what <em>Premier Support</em> actually is, my worries would have ended a long time ago. By the way, if you are now wondering what the error message was (running on 2 processors), here it is:</p>
<p><br clear="all"></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="vim" style="font-family:monospace;">running <span style="color: #25BB4D;">on</span>    <span style="color: #000000; font-weight:bold;">2</span> nodes
distr<span style="color: #000000;">:</span>  one band <span style="color: #25BB4D;">on</span>    <span style="color: #000000; font-weight:bold;">1</span> nodes,    <span style="color: #000000; font-weight:bold;">2</span> groups
vasp<span style="color: #000000;">.</span>4<span style="color: #000000;">.</span>6<span style="color: #000000;">.</span>28 25Jul05 complex
POSCAR found <span style="color: #000000;">:</span>  <span style="color: #000000; font-weight:bold;">4</span> types and   <span style="color: #000000; font-weight:bold;">18</span> ions
LDA part<span style="color: #000000;">:</span> xc<span style="color: #000000;">-</span>table <span style="color: #804040;">for</span> Ceperly<span style="color: #000000;">-</span>Alder, standard interpolation
found WAVECAR, reading the header
POSCAR, INCAR and KPOINTS ok, starting setup
WARNING<span style="color: #000000;">:</span> <span style="color: #668080;">wrap</span> around errors must be expected
FFT<span style="color: #000000;">:</span> planning <span style="color: #000000;">...</span>           <span style="color: #000000; font-weight:bold;">1</span>
reading WAVECAR
the WAVECAR file was read sucessfully
LAPACK<span style="color: #000000;">:</span> Routine ZPOTRF failed<span style="color: #000000;">!</span>           <span style="color: #000000; font-weight:bold;">8</span>
LAPACK<span style="color: #000000;">:</span> Routine ZPOTRF failed<span style="color: #000000;">!</span>           <span style="color: #000000; font-weight:bold;">8</span></pre></td></tr></table></div>

<p>Having managed to get version 8.x and 7.x of Intel compilers, situation only got worse as the error message remained the same <img alt="(" src="http://sgowtham.net/blog/wp-images/smilies/icon_sad.gif" />  At this point,  I must thank the help offered by VASP Tech Support and <a href="mailto:andriNOSPAM@u.washington.edu">Andri Arnaldsson</a> (from University of Washington) &#8211; they have been pretty quick in their responses, sent their copies of Makefiles along with several tips and tricks. Changing compiler versions, using a previous version of MPICH (1.2.7p1 to be precise), repeating compilation many times with different BLAS, LAPACK libraries … nothing helped. </p>
<p>Taking a break for an hour and watching an episode of South Park seemed to have helped. A modification in the key words used for Google! search and reading some discussion forum lot more carefully, I found that adding three lines at the end of VASP Makefile (what this does is to reduce the level of optimization for <tt>mpi.F</tt>), the error vanished and the calculations started running smoothly. I repeated the same calculation using 2, 4, 6 and 8 processors and noticed a slightly strange behavior &#8211; when the number of processors was 2, 4 or 8, energy optimization is exactly same as in a serial calculation but when the number of processors is 2*N (N=3 in this case), energy optimization route is different &#8211; final result is still exactly the same. Though I have to do more trials (say 3, 5, 7, 9, 10 processors) to completely convince myself, it appears to me that using 2<sup>N</sup> processors does the trick. Like Dave Kraus mentioned once before &#8211; <em>knowing what trick works is certainly important, but knowing why that trick works is even more important</em>.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsgowtham.net%2Fblog%2F2005%2F12%2F22%2Fvasp-mpich-intel-compilers-and-npaci-rocks%2F&amp;title=VASP%2C%20MPICH%2C%20Intel%20Compilers%20And%20NPACI%20Rocks" id="wpa2a_8"><img src="http://sgowtham.net/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sgowtham.net/blog/2005/12/22/vasp-mpich-intel-compilers-and-npaci-rocks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

