Index: vasp.py
===================================================================
--- vasp.py	(revision 9)
+++ vasp.py	(revision 10)
@@ -151,7 +151,7 @@
 class Vasp(Calculator):
     def __init__(self, restart=None, output_template='vasp', track_output=False, write_input = True, 
                  **kwargs):
-        self.bool_write_input = write_input
+        self.write_input = write_input
         self.name = 'Vasp'
         self.float_params = {}
         self.exp_params = {}
@@ -248,7 +248,6 @@
         # Determine the number of atoms of each atomic species
         # sorted after atomic species
         special_setups = []
-        symbols = {}
         if self.input_params['setups']:
             for m in self.input_params['setups']:
                 try : 
@@ -259,21 +258,41 @@
                     continue
             #print 'special_setups' , special_setups
 
+        #symbols = {}
+        #for m,atom in enumerate(atoms):
+        #    symbol = atom.get_symbol()
+        #    if m in special_setups:
+        #        pass
+        #    else:
+        #        if not symbols.has_key(symbol):
+        #            symbols[symbol] = 1
+        #        else:
+        #            symbols[symbol] += 1
+        
+        symbols = []
         for m,atom in enumerate(atoms):
             symbol = atom.get_symbol()
             if m in special_setups:
                 pass
             else:
-                if not symbols.has_key(symbol):
-                    symbols[symbol] = 1
+                ind = 0
+                bfound = False
+                for symbolX, iatom in symbols:
+                    if symbol == symbolX:
+                        bfound = True
+                        break
+                    ind += 1
+                if bfound:
+                    symbolX, iatom  = symbols[ind]
+                    symbols[ind] = symbolX, iatom+1
                 else:
-                    symbols[symbol] += 1
+                    symbols.append((symbol, 1))
         
         # Build the sorting list
         self.sort = []
         self.sort.extend(special_setups)
 
-        for symbol in symbols:
+        for symbol, iatom in symbols:
             for m,atom in enumerate(atoms):
                 if m in special_setups: 
                     pass
@@ -284,66 +303,72 @@
         for n in range(len(self.resort)):
             self.resort[self.sort[n]] = n
         self.atoms_sorted = atoms[self.sort]
-
+        
         # Check if the necessary POTCAR files exists and
         # create a list of their paths.
         self.symbol_count = []
         for m in special_setups:
-            self.symbol_count.append([atomtypes[m],1])
+            for symbol, iatom in symbols:
+                if symbol == m:
+                    self.symbol_count.append([atomtypes[m],1])
+            #self.symbol_count.append([atomtypes[m],1])
         for m in symbols:
-            self.symbol_count.append([m,symbols[m]])
-        #print 'self.symbol_count',self.symbol_count 
+            for symbol, iatom in symbols:
+                if symbol == m:
+                    self.symbol_count.append([m,iatom])
+            #self.symbol_count.append([m,symbols[m]])
         sys.stdout.flush()
-        xc = '/'
-        #print 'p[xc]',p['xc']
-        if p['xc'] == 'PW91':
-            xc = '_gga/'
-        elif p['xc'] == 'PBE':
-            xc = '_pbe/'
-        if 'VASP_PP_PATH' in os.environ:
-            pppaths = os.environ['VASP_PP_PATH'].split(':')
-        else:
-            pppaths = []
-        self.ppp_list = []
-        # Setting the pseudopotentials, first special setups and 
-        # then according to symbols
-        for m in special_setups:
-            name = 'potpaw'+xc.upper() + p['setups'][str(m)] + '/POTCAR'
-            found = False
-            for path in pppaths:
-                filename = join(path, name)
-                #print 'filename', filename
-                if isfile(filename) or islink(filename):
-                    found = True
-                    self.ppp_list.append(filename)
-                    break
-                elif isfile(filename + '.Z') or islink(filename + '.Z'):
-                    found = True
-                    self.ppp_list.append(filename+'.Z')
-                    break
-            if not found:
-                raise RuntimeError('No pseudopotential for %s!' % symbol)    
-        #print 'symbols', symbols 
-        for symbol in symbols:
-            try:
-                name = 'potpaw'+xc.upper()+symbol + p['setups'][symbol]
-            except (TypeError, KeyError):
-                name = 'potpaw' + xc.upper() + symbol
-            name += '/POTCAR'
-            found = False
-            for path in pppaths:
-                filename = join(path, name)
-                #print 'filename', filename
-                if isfile(filename) or islink(filename):
-                    found = True
-                    self.ppp_list.append(filename)
-                    break
-                elif isfile(filename + '.Z') or islink(filename + '.Z'):
-                    found = True
-                    self.ppp_list.append(filename+'.Z')
-                    break
-            if not found:
-                raise RuntimeError('No pseudopotential for %s!' % symbol)
+        if self.write_input:
+            xc = '/'
+            #print 'p[xc]',p['xc']
+            if p['xc'] == 'PW91':
+                xc = '_gga/'
+            elif p['xc'] == 'PBE':
+                xc = '_pbe/'
+            if 'VASP_PP_PATH' in os.environ:
+                pppaths = os.environ['VASP_PP_PATH'].split(':')
+            else:
+                pppaths = []
+            self.ppp_list = []
+            # Setting the pseudopotentials, first special setups and 
+            # then according to symbols
+            for m in special_setups:
+                name = 'potpaw'+xc.upper() + p['setups'][str(m)] + '/POTCAR'
+                found = False
+                for path in pppaths:
+                    filename = join(path, name)
+                    #print 'filename', filename
+                    if isfile(filename) or islink(filename):
+                        found = True
+                        self.ppp_list.append(filename)
+                        break
+                    elif isfile(filename + '.Z') or islink(filename + '.Z'):
+                        found = True
+                        self.ppp_list.append(filename+'.Z')
+                        break
+                if not found:
+                    raise RuntimeError('No pseudopotential for %s!' % symbol)    
+            #print 'symbols', symbols 
+            for symbol in symbols:
+                try:
+                    name = 'potpaw'+xc.upper()+symbol + p['setups'][symbol]
+                except (TypeError, KeyError):
+                    name = 'potpaw' + xc.upper() + symbol
+                name += '/POTCAR'
+                found = False
+                for path in pppaths:
+                    filename = join(path, name)
+                    #print 'filename', filename
+                    if isfile(filename) or islink(filename):
+                        found = True
+                        self.ppp_list.append(filename)
+                        break
+                    elif isfile(filename + '.Z') or islink(filename + '.Z'):
+                        found = True
+                        self.ppp_list.append(filename+'.Z')
+                        break
+                if not found:
+                    raise RuntimeError('No pseudopotential for %s!' % symbol)
         self.converged = None
         self.setups_changed = None
 
@@ -359,7 +384,7 @@
         from ase.io.vasp import write_vasp
         self.initialize(atoms)
         write_vasp('POSCAR', self.atoms_sorted, symbol_count = self.symbol_count)
-        if self.bool_write_input:
+        if self.write_input:
             self.write_incar(atoms)
             self.write_potcar()
             self.write_kpoints()
